Can probably replace most of this with shell=True