anchor.diff:    (format t "~%;; Syncing local database ~{~A~} from Gatherer..." (last db))
     (loop for i below 18 ;; set this number low for testing; as of Journey into Nyx there are under 400,000 cards in Gatherer
           with m-id = (+ i 1)
  +        with query = (list (cons "multiverseid" (format nil "~D" m-id)))
  +        with str = (drakma:http-request *gatherer-card-url* :parameters query)
  +        with document = (chtml:parse str (cxml-stp:make-builder))
           do (cond ((not m-id) nil)
                    ((not (valid-m-id-p m-id))
                     (format t "~%;; Multiverse ID: ~D does not specify a valid MTG Card. Skipping..." m-id))
                    ((and (card-exists-p m-id :db db)
  -                       (card-matches-p m-id :db db))
  +                       (card-matches-p m-id document :db db))
                     (format t "~%;; Skipping Multiverse ID: ~D" m-id))
                    ((and (card-exists-p m-id :db db)
  -                       (not (card-matches-p m-id :db db)))
  -                  (scrape-gatherer-and-insert-mtg-card-into-db m-id :db db))
  +                       (not (card-matches-p m-id document :db db)))
  +                  (scrape-gatherer-and-insert-mtg-card-into-db m-id document :db db))
                    ((valid-m-id-p m-id)
  -                  (scrape-gatherer-and-insert-mtg-card-into-db m-id :db db))
  +                  (scrape-gatherer-and-insert-mtg-card-into-db m-id document :db db))
                    (t (loop-finish)))
  -           (incf m-id)))
  +           (incf m-id)
  +           (setf query (list (cons "multiverseid" (format nil "~D" m-id)))
  +                 str (drakma:http-request *gatherer-card-url* :parameters query)
  +                 document (chtml:parse str (cxml-stp:make-builder)))))
   
   ;; EOF
  
positive.code:     (return-from parse-card (values name mana-cost color spell-type collectors-num converted-mana-cost card-text flavor-text power toughness set-name rarity artist image))))
  
  (defun download-and-save-card-image (m-id path)
    "Downloads and saves to disk the MTG card image for Multiverse ID *m-id* to Pathname *path*."
    (ensure-directories-exist path)
    (with-open-file (file path
                          :direction :output
  
negative.code:           t
            nil))))
  
  (defun card-matches-p (m-id document &key (db *default-database-connection*))
    "Compares the card DAO in the local database against Gatherer to see if all the fields match."
    (let* ((m-id-str (format nil "~D" m-id))
           (the-card nil))
      (postmodern:with-connection db
        (setf the-card (handler-case (postmodern:get-dao 'rsn-mtg-card (get-card-id-by-multiverse-id m-id)) (error () nil))))
      (multiple-value-bind (name mana-cost color spell-type collectors-num cmc card-text flavor-text power toughness set-name rarity artist image the-set-id)
          (parse-card m-id document)
        (if (and the-card
                 (string-equal (name the-card) name)
                 ;(string-equal (mana-cost the-card) mana-cost)
  