More refactoring. Extracted some of the event store logic into eventStore.js