     return (count, mapping)
 }
 
-/**
- Parse the supplied RDF files and load the resulting RDF triples into the database's
- QuadStore in the supplied named graph (or into a graph named with the corresponding
- filename, if no graph name is given).
- 
- - parameter files: Filenames of Turtle or N-Triples files to parse.
- - parameter startTime: The timestamp to use as the database transaction version number.
- - parameter graph: The graph into which parsed triples should be load.
- */
+/// Parse the supplied RDF files and load the resulting RDF triples into the database's
+/// QuadStore in the supplied named graph (or into a graph named with the corresponding
+/// filename, if no graph name is given).
+///
+/// - parameter files: Filenames of Turtle or N-Triples files to parse.
+/// - parameter startTime: The timestamp to use as the database transaction version number.
+/// - parameter graph: The graph into which parsed triples should be load.
+func parse<Q: MutableQuadStoreProtocol>(into store: Q, files: [String], version: Version, graph defaultGraphTerm: Term? = nil) throws -> Int {
+    var count = 0
+    for filename in files {
+        #if os (OSX)
+        guard let path = NSURL(fileURLWithPath: filename).absoluteString else { throw DatabaseError.DataError("Not a valid graph path: \(filename)") }
+        #else
+        let path = NSURL(fileURLWithPath: filename).absoluteString
+        #endif
+        let graph   = defaultGraphTerm ?? Term(value: path, type: .iri)
+        
+        let parser = RDFParserCombined()
+        var quads = [Quad]()
+        print("Parsing RDF...")
+        count = try parser.parse(file: filename, base: graph.value) { (s, p, o) in
+            let q = Quad(subject: s, predicate: p, object: o, graph: graph)
+            quads.append(q)
+        }
+        
+        print("Loading RDF...")
+        try store.load(version: version, quads: quads)
+    }
+    return count
+}
+
 func parse<D : PageDatabase>(_ database: D, files: [String], startTime: UInt64, graph defaultGraphTerm: Term? = nil) throws -> Int {
     var count   = 0
     let version = Version(startTime)
-    try database.update(version: version) { (m) in
-        do {
-            for filename in files {
-                #if os (OSX)
-                guard let path = NSURL(fileURLWithPath: filename).absoluteString else { throw DatabaseError.DataError("Not a valid graph path: \(filename)") }
-                #else
-                let path = NSURL(fileURLWithPath: filename).absoluteString
-                #endif
-                let graph   = defaultGraphTerm ?? Term(value: path, type: .iri)
-                
-                let parser = RDFParserCombined()
-                var quads = [Quad]()
-                print("Parsing RDF...")
-                count = try parser.parse(file: filename, base: graph.value) { (s, p, o) in
-                    let q = Quad(subject: s, predicate: p, object: o, graph: graph)
-                    quads.append(q)
-                }
-                
-                print("Loading RDF...")
-                let store = try MediatedPageQuadStore.create(mediator: m)
-                try store.load(quads: quads)
-            }
-        } catch let e {
-            warn("*** Failed during load of RDF (\(count) triples handled); \(e)")
-            throw DatabaseUpdateError.rollback
-        }
-    }
+    let store = try PageQuadStore(database: database)
+    count += try parse(into: store, files: files, version: version, graph: defaultGraphTerm)
     return count
 }
 

        warn("query time: \(elapsed)s")
    }
    return count
}

private func printResult<R, T>(_ results: QueryResult<R, T>) -> Int {

    print("\(s) \(p) \(o) .")
}

/// Print all the quads present in the database's QuadStore. If an index name is supplied,
/// use it to print quads in its native order.
///
/// - parameter index: The name of an index to use to sort the resulting output.
func serialize<D : PageDatabase>(_ database: D, index: String? = nil) throws -> Int {
    var count = 0
    database.read { (m) in
