PS in making the above-mentioned changes, I noticed (remembered?) that the way tag spaces are returned from environments is weirdly all-or-nothing. If I'm understanding it correctly, all changes to the tag space in an environment are lost when you leave it, unless you execute
return_tagspace, in which case they are all retained (or maybe just those after or before the call? not sure about that).
If anybody is looking at how environments and tags interact (and/or wants to try an idea we've discussed, of automatically wrapping tag-retrieved code in environments), then you should definitely take a closer look at this and maybe consider alternatives.