I can already Tell this is going to be a pain

Completely untested start to port

* https://github.com/google/liquidfun/commit/4a2a1bab27fc32cd58e54210325c1a335f7665f9#diff-3c9bd41ca86aedb27cf1e2a383b5556fL1110
* https://github.com/google/liquidfun/commit/1efbf14674fc82c69524e62ce0ce6c41dab4f3b9#diff-3c9bd41ca86aedb27cf1e2a383b5556fL67