Better error handling.

Fixes #3.