Attempt at better error logging.