Fix stack overflow

Fixes #33