Handle infinities explicitly

Fixes #20