Improve error reporting, minor cleanup.

Adds to #3.