performance fix + flag deletion fix