Optimization on-the-go.
Optimization is now performed every certain amount of steps.