Better error handling and reporting