Minor modifications to error handling.