I would much prefer if messages like this were conditionally encoded as v2 or v3 based on the passed-in features, instead of doing the loop splitting and merging nonsense. (Look at how the encode_classic() pattern we've started to build up.)