memory functions moved to library