fix the temp dir cleanup: under certain circumstances it left an empty directory