Refactors flags