Refactoring to support datomic