some refactoring, adding an in-memory store