refactoring. Moving memory store.
fix bug