           token-set (set tokens)
           filtered-tokens (remove-first-of-each token-set current-tokens)]
 
-      (assoc-mem! key filtered-tokens)
+      (set! content (assoc! content key filtered-tokens))
       (s/intersection token-set (set current-tokens))))
 
   (add-accum-reduced! [memory node join-bindings accum-result fact-bindings]

          updated-bindings (assoc (get content key {})
                             fact-bindings
                             accum-result)]
      (assoc-mem! key updated-bindings)))
  
  (add-insertions! [memory node token facts]
    (let [key [:production-memory (:id node) token]
          current-facts (get content key [])]
      (assoc-mem! key (concat current-facts facts))))

  (remove-insertions! [memory node tokens]


          filtered-facts (remove-first-of-each element-set current-facts)]

      ;; Update the memory with the changed facts.
      (set! content (assoc! content key filtered-facts))

      ;; return the removed elements.
      (s/intersection element-set (set current-facts))))
