Refactor to eliminate datastore dependency from db.go