Made the addAnchors functionality more flexible.