Another attempt at fixing bug 2. Call replaceInternalLinks() before