Fix crash and cleanup old log.