memory routines moved to separate file