Closes PR 14646; fixed according to Robby's suggestion


Vincent, Robby says this diff fixes the bug on renaming that I reported and some playing around suggests that he is correct. But I don't see any test suites in your code and I also don't know how to test this kind of bug. So proceed with caution as you merge.