Changed implementation of memory from inheritance to encapsulation