Moved the reset of the current working directory to after where I actually need it set, oops!