Further cleanup and corrections to emscripten call wrappers
o Correct allocation and indexing of heap buffers of various types