Better handling of internal errors, and client errors.