Fixes multiple bugs in flag command