Limit the number of recursive calls

Closes #3