Refactor memory structure
The expression of memory and memory elements is struggling to be adaptable to changes; changes to memory tend to be very complex and error prone, touching lots of files.
Refactor the memory related classes to improve structure.