Temp dir now works in every OS variant. code cleanup!