Refactored logging.