fixed a lot of flag stuff