Fixed a possible problem in toRelativeName