Changed Memory class for more abstraction, more details and elegance to Main