Standardize error-handling

Fixes #98.