A bit of assorted hacking to make things work with pypy...