Fix NullReferenceException in case of duplicate anchor.