Lots of Emscripten fixes