KaiGai Kohei, reviewed by Dimitri Fontaine and me.
This is still a bit of a hack, but it's better than the old way, for sure. KaiGai Kohei, with one change by me to make it compile