refactor memory storage and core data storage