Turned script into functions. Next step to add argparse "stuff" to script so I can run at command line or call from another script.