Added argparse and removed some redundant code.