Improved handling of errors.