Added better temp folder detection (using $TMP and '.' as fallbacks for $TEMP).