Moved arguement handling into __main__ so that script can be imported into python terminal for testing