         assert(false, "Invalid bookmark data.")
         return nodeFactory(row)
     }
+}
+
+public class SQLiteBookmarks: BookmarksModelFactory {
+    let db: BrowserDB
+    let favicons: FaviconsTable<Favicon>
+
+    private static let defaultFolderTitle = NSLocalizedString("Untitled", tableName: "Storage", comment: "The default name for bookmark folders without titles.")
+    private static let defaultItemTitle = NSLocalizedString("Untitled", tableName: "Storage", comment: "The default name for bookmark nodes without titles.")
+
+    public init(db: BrowserDB) {
+        self.db = db
+        self.favicons = FaviconsTable<Favicon>()
+    }
 
     private func getChildrenWhere(whereClause: String, args: Args, includeIcon: Bool) -> Cursor<BookmarkNode> {
         var err: NSError? = nil
         return db.withReadableConnection(&err) { (conn, err) -> Cursor<BookmarkNode> in
             let inner = "SELECT id, type, guid, url, title, faviconID FROM \(TableBookmarks) WHERE \(whereClause)"
 
+            let sql: String
             if includeIcon {
-                let sql =
+                sql =
                 "SELECT bookmarks.id AS id, bookmarks.type AS type, guid, bookmarks.url AS url, title, " +
                 "favicons.url AS iconURL, favicons.date AS iconDate, favicons.type AS iconType " +
                 "FROM (\(inner)) AS bookmarks " +
                 "LEFT OUTER JOIN favicons ON bookmarks.faviconID = favicons.id"
-                return conn.executeQuery(sql, factory: SQLiteBookmarks.factory, withArgs: args)
             } else {
-                return conn.executeQuery(inner, factory: SQLiteBookmarks.factory, withArgs: args)
-            }
+                sql = inner
+            }
+
+            return conn.executeQuery(sql, factory: LocalBookmarkNodeFactory.factory, withArgs: args)
         }
     }
 

        return BookmarkNode(guid: guid, title: title)
    }

    private class func factory(row: SDRow) -> BookmarkNode {
        if let typeCode = row["type"] as? Int, type = BookmarkNodeType(rawValue: typeCode) {
            switch type {
            case .Bookmark:

        "FROM (\(inner)) AS bookmarks " +
        "LEFT OUTER JOIN favicons ON bookmarks.faviconID = favicons.id"
        let args: Args = [url.absoluteString]
        return db.runQuery(sql, args: args, factory: LocalBookmarkNodeFactory.itemFactory)
    }
}

