Return flag count
Add flag resetting