Remove recursion

Small fix to allow more complex scenarios.
Merge pull request #31 from nortikin/master

sync
Merge pull request #51 from ly29/master

Bug fix thanks, it is essential