More robust handling of script name/path.