Fixed a bug with error logging.