Added flag clearing