Redmine/6553: Fix implicit looping over multiple lists

Pull request for initial review of the changes to the code. Planning to add more test coverage to the acceptance test before merging.
(petty, padding) A bool is likely smaller than a word.  The two pointers have to be word-aligned.  So the struct shall have padding in it between the bool and the first pointer.  If the bool were last, there would still be padding (so this is not a big deal) but
* padding at the end feels tidier (or, to put it another way, putting all the whole-word-sized fields first makes it easier to see where one could later add a field in existing padding) and
* if anyone adds another field, it'll probably be at the end [0], where there is some hope that it can land in the padding, if the prior fields had their padding at the end.

[0] getting folk to add fields to a struct anywhere but the end is an uphill battle; when there are many developers changing the same code at the same time, they always produce conflicts as a result, because they all added *at the end*, i.e. in the same place ...