Improved handling of internal errors.