Better exception handling and error reporting