Refactoring option parsing

This will make it easier to implement proper subcommand
handling without breaking backwards compat
More cleanup/refactoring
more refactoring