Adds the new memory management into the main functions.