Tail call optimization for search iteration

Fixes #256
Merge branch 'develop' into develop-#85-1