Fixes and improvements to the custom memory allocators