As tags have \label's, and we just copy the tag's text into existing TeX code, there might be duplicates happening. One way to patch this is to replace \label temporarily by something that prefixes each label with a default stacks- (can be changed or toggled by the user).