Use argparse to parse command line arguments
Split initialization into multiple functions
Use die() in place of error() + sys.exit()