Took another look at this and pushed the v3 version to master with backpatchesto 16 and 17 for the access-after-alloc-failure fixes.
--Daniel Gustafsson