Now uses `cwd` argument to set the current working directory for subprocess.