Fix double-negative bug in flag code