Merge runtimes

This is my work in progress on merging the memory management infrastructure in the runtime.

This isn't ready for a merge yet, but people should feel free to review the code and changes.