Migrated you to argparse instead of optparse

Hey, updated your code to use argparse instead of optparse, which according to the documentation is deprecated. Moved some of the __main__ code into a couple of functions just to clean it up a bit.

Thanks!
Scott