             return try quadstore.idquads(matching: pattern)
         default:
             let i = try quadstore.idquads(matching: pattern)
-            var cachedAcceptance = [Quad: Set<String>]()
+            var cachedAcceptance = [[MemoryQuadStore.TermID]: Set<String>]()
             return AnyIterator {
                 repeat {
                     guard let idquad = i.next() else { return nil }

                        return idquad
                    } else {
                        let quad = self.quadstore.quad(from: idquad)
                        if self.accept(quad: quad, languages: self.acceptLanguages, cachedAcceptance: &cachedAcceptance) {
                            return idquad
                        }
                    }

        return siteLanguageQuality[language] ?? 1.0
    }
    
    private func accept<K: Hashable>(quad: Quad, languages: [(String, Double)], cacheKey: K, cachedAcceptance: inout [K: Set<String>]) -> Bool {
        let object = quad.object
        switch object.type {
        case .language(let l):
            if let acceptable = cachedAcceptance[cacheKey] {
                return acceptable.contains(l)
            } else {
