Refactor main script to use argparse instead of optparse, moved into main function