Add memory allocator for context threading tables, cleanup code generation