fix bugs dealing with handling of links