Refactored flag parsing.