This fixes #8351.  It is now protected so that it if is run again, it doesn't break anything.
Work on bug #8351.  It now corrects any links that are already there.