Refactor argparsing code and start using argparse2.