Adding defensive code for one more place where cleanedPath length could cause a problem with string manipulation in appendPath(..).