Fix infinite loops

Ref #114 and lots of comments in person and over twitter. I *think* this cracks it.