error reporting and bug fixes