Improved error handling and reporting.