Fixed flags bug