Refactoring to handle new memory allocators