added trimdir; splitpath, parentdir more robust (handeling trailing pathsep)