Changed how working directory is handled.

Needs more work.