Here are the updated patches. I split the changes into two: 0001 fixes the Assert failure and updates the out-of-date comment for generate_orderedappend_paths(), while 0002 addresses the second and third issues I described upthread.
The assertion failure also exists in v18, so I think it would be best to get 0001 pushed and backpatched before the code freeze. I'm not sure whether 0002 should be backpatched. Before that, I'd like to know whether these two patches make sense.
Thanks for the patch.
The fix for the assert failure looks good to me. And, yes, it would be good to backpatch this before the code freeze.