Implemented error reporting and code fixes