Added some error logging.