                (doseq [[other-fields other-index] indexes]
                  (when (-add-facts facts fields other-index (into-array other-fields))
                    (set!! changed? true)))
-               (when changed?
-                 (set! version (+ version 1)))))
+               changed?))
   (tick [this])
   ;; TODO Knowledge.tick using array of flows, needs dirty tracking per flow (requires map from index to flow)
   (tock [this]))
 
 (defn knowledge []
-  (Knowledge. {} 0))
+  (Knowledge. {}))
 
 ;; COMPILER
 


          ;; ensure at least one index per output
          (dotimes [i (alength output-kinds)]
            (.get-or-create-index kn (aget output-kinds i) (aget output-names i) (into-array (filter #(not (nil? %)) (aget output-fields i)))))

          (aset rule-id->flow rule-id
                (Flow. solver output-kinds output-names output-fields)))))

    rule-id->flow))

;; TESTS


    ;; rewrite clauses
    (doseq [[rule-id clauses] @rule-id->clauses]
      (doseq [[_ clause-type clause-id name] clauses
              :when (not (#{"=constant" "=variable" "=function"} name))]
        (let [fields (get @clause-id->fields clause-id)
              var->key (atom {})]
          (doseq [[_ field-type key val] fields]
