Use exceptions instead of abort

Fixes #230