Remove more use of memory function