Massive refactoring of memory storage