Fix to correctly handle temp directory.