replace last usages of memory pointer in the main class