Split to library. Reimplemented sample strategy in new state.