Refined and fixed logging.