Started refactoring memory section
More refactoring of vm