Added error logging.