improve error handling and reporting.