Note that Cardcoins has open sourced this code! https://github.com/CardCoins/additive-rbf-batcher/
It's awesome to see them giving the community such a sophisticated piece of code.