Set CWD for jobs

This implements a lot of the code for #18 and #5