[Closes #107] Improve error handling and reporting.