Added cleanup of log when saving to the log.