Proper cwd-finding