Switch from optparse to argparse wherever possible

Not ready for landing.