Moved mem functions to own file