Weird behaviour with pathNames ending with /

Fixed removal of last /