added code to removed the anchors from unused references