Better detection of script path