Add a typed memory allocator. Misc minor changes too.