Fix temp-dir handling