Refactor logging.