Refactoring input/output into datastore module