Flags were corrupted when value changed