Another attempt at cwd handling