Hacked to compile with emscripten.