The reference data structures now seem to be working the way I want them. What is missing is the proper ordering of the entries in the structures.
The structures are internally indexed by their GEDCOM ids. These are unique and the binary trees are ordered by these ids to make retrieval quick. However, the IDs are internal numbers needed only by the GEDCOM and are essentially meaningless. The better way to sort and display these is to do it by the order each reference is first encountered in the Everything Report. Then a numbering system based on that order has to be generated. This might be something like S5-3 for the 3rd citation of the 5th source, or N10 for the 10th note.
It took a while to get that working just right, but the numbering of references is now set up the way it should be.