Enhanced error handling.