Thanks @ekuber
The code is far from production-worthy ATM, but I might be able clean it up for minimal cases where the suggestions are good. (That might take me a while to get to though).
I can also open issues for the problems identified in the appendix.