Restructure to accept gitpath. Ensure that subprocesses are cleaned up.