         }
     }
     
-    internal func assignID(for term: Term) throws -> TermID {
-        if let i = id(for: term) {
-//            print("term already has ID: \(i) <-> \(term)")
-            return i
-        }
-        
-//        print("assigning ID for \(term)")
-        let insert: Insert
-        switch term.type {
-        case .iri:
-            insert = termsTable.insert(termTypeColumn <- TermType.iri.rawValue, termValueColumn <- term.value)
-        case .blank:
-            insert = termsTable.insert(termTypeColumn <- TermType.blank.rawValue, termValueColumn <- term.value)
-        case .language(let lang):
-            insert = termsTable.insert(
-                termTypeColumn <- TermType.literal.rawValue,
-                termValueColumn <- term.value,
-                termDatatypeColumn <- id(for: Term(iri: Namespace.rdf.langString)),
-                termLangColumn <- lang)
-        case .datatype(let dt):
-            insert = try termsTable.insert(
-                termTypeColumn <- TermType.literal.rawValue,
-                termValueColumn <- term.value,
-                termDatatypeColumn <- assignID(for: Term(iri: dt.value)))
-        }
-//        print("INSERT: \(insert)")
-        try db.run(insert)
-        guard let i = id(for: term) else {
-            throw SQLiteQuadStoreError.idAssignmentError
-        }
-        return i
-    }
-    
-    internal func id(for term: Term) -> TermID? {
-        if let i = t2icache[term] {
-            return i
-        }
-        
-        var query = termsTable.select(idColumn).filter(termValueColumn == term.value)
-        switch term.type {
-        case .blank:
-            query = query.filter(termTypeColumn == TermType.blank.rawValue)
-        case .iri:
-            query = query.filter(termTypeColumn == TermType.iri.rawValue)
-        case .language(let lang):
-            query = query.filter(termTypeColumn == TermType.literal.rawValue).filter(termLangColumn == lang)
-        case .datatype(let dt):
-            guard let dtid = id(for: Term(iri: dt.value)) else {
-                return nil
-            }
-            query = query.filter(termTypeColumn == TermType.literal.rawValue).filter(termDatatypeColumn == dtid)
-        }
-        
-        do {
-            guard let row = try db.pluck(query) else {
-//                print("============")
-//                print("Failed to find row for term: \(term)")
-//                print("\(query)")
-//                print("------------")
-                return nil
-            }
-            let i = row[idColumn]
-            t2icache[term] = i
-            return i
-        } catch {}
-        return nil
-    }
+//    internal func assignID(for term: Term) throws -> TermID {
+//        if let i = id(for: term) {
+////            print("term already has ID: \(i) <-> \(term)")
+//            return i
+//        }
+//
+////        print("assigning ID for \(term)")
+//        let insert: Insert
+//        switch term.type {
+//        case .iri:
+//            insert = termsTable.insert(termTypeColumn <- TermType.iri.rawValue, termValueColumn <- term.value)
+//        case .blank:
+//            insert = termsTable.insert(termTypeColumn <- TermType.blank.rawValue, termValueColumn <- term.value)
+//        case .language(let lang):
+//            insert = termsTable.insert(
+//                termTypeColumn <- TermType.literal.rawValue,
+//                termValueColumn <- term.value,
+//                termDatatypeColumn <- id(for: Term(iri: Namespace.rdf.langString)),
+//                termLangColumn <- lang)
+//        case .datatype(let dt):
+//            insert = try termsTable.insert(
+//                termTypeColumn <- TermType.literal.rawValue,
+//                termValueColumn <- term.value,
+//                termDatatypeColumn <- assignID(for: Term(iri: dt.value)))
+//        }
+////        print("INSERT: \(insert)")
+//        try db.run(insert)
+//        guard let i = id(for: term) else {
+//            throw SQLiteQuadStoreError.idAssignmentError
+//        }
+//        return i
+//    }
+    
+//    internal func id(for term: Term) -> TermID? {
+//        if let i = t2icache[term] {
+//            return i
+//        }
+//
+//        var query = termsTable.select(idColumn).filter(termValueColumn == term.value)
+//        switch term.type {
+//        case .blank:
+//            query = query.filter(termTypeColumn == TermType.blank.rawValue)
+//        case .iri:
+//            query = query.filter(termTypeColumn == TermType.iri.rawValue)
+//        case .language(let lang):
+//            query = query.filter(termTypeColumn == TermType.literal.rawValue).filter(termLangColumn == lang)
+//        case .datatype(let dt):
+//            guard let dtid = id(for: Term(iri: dt.value)) else {
+//                return nil
+//            }
+//            query = query.filter(termTypeColumn == TermType.literal.rawValue).filter(termDatatypeColumn == dtid)
+//        }
+//
+//        do {
+//            guard let row = try db.pluck(query) else {
+////                print("============")
+////                print("Failed to find row for term: \(term)")
+////                print("\(query)")
+////                print("------------")
+//                return nil
+//            }
+//            let i = row[idColumn]
+//            t2icache[term] = i
+//            return i
+//        } catch {}
+//        return nil
+//    }
 
     internal func term(from row: Row, typeColumn: SQLite.Expression<Int64>, valueColumn: SQLite.Expression<String>, languageColumn: SQLite.Expression<String?>, datatypeColumn: SQLite.Expression<Int64?>) -> Term? {
         guard let type = TermType(rawValue: row[typeColumn]) else {

        }
    }
    
    internal func term(for id: TermID) -> Term? {
        if let t = i2tcache[id] {
            return t
        }
        
        let query = termsTable.select(termsTable[*]).filter(idColumn == id)
        do {
            guard let row = try db.pluck(query) else {
                return nil
            }
            guard let t = term(from: row, typeColumn: termTypeColumn, valueColumn: termValueColumn, languageColumn: termLangColumn, datatypeColumn: termDatatypeColumn) else {
                return nil
            }
            i2tcache[id] = t
            return t
        } catch {}
        return nil
    }
    
    public func makeIterator() -> AnyIterator<Quad> {
        let query = quadsTable.select(quadsTable[*])

        i2tcache = LRUCache(capacity: 1024)
        t2icache = LRUCache(capacity: 1024)
        if initialize {
            next = (iri: 0, blank: 0, datatype: 0, language: 0)
            try initializeTables()
        } else {
            next = try SQLiteQuadStore.loadMaxIDs(from: db)
        }
    }
    
