Added debug log flushing