Properly parse arguments and flags