change paths to alleviate write problems, change order to (hopefully?) prevent setup race condition, use chdir to solve windows path space issue