Fix bug in flag parsing