minor fixes to Flag logic