improved detection of TMPDIR