client error handling and logging.
cleanup