Add commandline args, clean up code