refactored memory manager routines