     }
 
     private func setHistorySites(var historySites: [Site]) {
+        // Sites are invalidated and we have a new data set, so do a replace.
+        if (sitesInvalidated) {
+            sites = []
+        }
+
         // We requery every time we do a deletion. If the query contains a top site that's
         // bubbled up that wasn't there previously (e.g., a page just finished loading
         // in the background), it will change the index of any following site currently

        sites += suggestedSites as [Site]
    }

    subscript(index: Int) -> Site? {
        if count() == 0 {
            return nil

        // invalidate the cache and requery. This allows us to always show results right away if they are cached but
        // also load in the up-to-date results asynchronously if needed
        reloadTopSitesWithLimit(frecencyLimit) >>> {
            self.profile.history.updateTopSitesCacheIfInvalidated() >>== { dirty in
                if dirty {
                    self.dataSource.invalidateSites()
                    self.reloadTopSitesWithLimit(frecencyLimit)
                }
            }
        }
    }
