Adds better error logging.