                                    local-config
                                    (use-cache-or-update domain domains-info global-config local-config true state))))
               (log-message "Finished updating all domains from remote")
+              (try
+                (log-message "Removing all old versions of domains (CLEANUP")
+                (cleanup-domains domains-info local-config)
+                (catch Throwable t (log-error t "Error when cleaning old versions")))
               (catch Throwable t (log-error t "Error when syncing data") (throw t)))))))))
 
 ;; 1. after *first* load finishes, right the global config with the token within

      (.cleanup local-vs 1))))

(defn cleanup-domains [domains-info local-config]
  (doseq [domain (keys domains-info)]
    (try
      (cleanup-domain domain domains-info local-config)
      (catch Throwable t (log-error t "Error when cleaning old versions of domain: " domain) (throw t)))))

(defn sync-updated
  "Only fetch domains from remote if a newer version is available.

    nil
    (do (if new-data
          (close-domain domain domains-info))
        new-data)))

(defn service-updating? [service-handler download-supervisor]
