Some changes to error handling.