Added some functionality for error reporting.