I don't know if you were aware of MR !332, which is basically an alternative to this MR. I think I generally prefer your version but there might be some comments on that one that are relevant here too.
I have a bunch of nitpicks that I'm going to comment inline.