Color quads maze

I have a bunch of quads, with a getslice and some random routines I manage to have two different groups, changing randomly. With an input spread I create an animation of the wuads moving from some random positions to some other positions (the two groups).
Now how to deal with the colors? If I have for example 4 quads “transforming” and morphing into 9 quads, how can I retain the color of each one so it doesn t change when a new group is formed?
I am attaching the patch cause I don t find it too easy to explain… (7.2 kB)

A possible solution, not too happy with it: use a S+H to hold the colors as long as the quads don t move. The best thing would be to be able to actually let any wuad retain its color while moving. (7.3 kB)