Add one more layer to the main loop

Since the scipy.optimize.leastsq does not output any information during
the main loop by default, now another layer of main loop is added, where
the leastsq function is called with a trunk of steps in each execution
of the loop.