Improved error reporting.

fixes #2