Add better error handling and reporting.