Loop implementation factored out into a separate class.
Merge pull request #88 from Dmitry-Me/separateloop

Loop implementation factored out into a separate class.