Replaced getopt with argparse, and optparse fallback