The mechanism for removing duplicated tags in marked up sequences is inefficient. Develop unit tests and refine.