                                  (+ 1 depth)
                                  max-depth
                                  top-bolt
-                                 truncate?))))))))
+                                 truncate?
+                                 take-n))))))))
 (defn generate2
   "Return all expressions matching spec _spec_ given the model _model_."
   [spec model

        (mapfn #(add-comps % model
                           (rest comp-paths)
                           (rest bolts-at-paths)
                           depth max-depth top-bolt path-from-top)
               (let [path (first comp-paths)
                     bolts-at (first bolts-at-paths)]
                 (flatten
                  (mapfn #(let [bolt (assoc-in bolt path %)]
                            (if (= false (get-in % [:phrasal]))
                              [bolt]
                              (-> (add-bolt-at top-bolt bolt path % model depth max-depth truncate?)
                                  ((fn [with-added-complement]
                                     (if truncate? (truncate with-added-complement [path] model)
                                         with-added-complement))))))
                         bolts-at)))))))))

(defn add-bolt-at [top-bolt bolt path bolt-at model depth max-depth truncate?]
  (lazy-seq
   (mapfn #(do-defaults % model)
          (let [comp-paths (find-comp-paths bolt-at)
                comp-bolts (pmap #(comp-path-to-bolts bolt-at % model (+ 1 depth) max-depth)
                                 comp-paths)]
            (when (not (some empty? comp-bolts))
              (lazy-seq
               (mapfn #(assoc-in bolt path %)

        lexemes-before-phrases
        (lexemes-before-phrases depth max-depth)]
    (if lexemes-before-phrases
      (lazy-seq (concat lexemes bolts-at))
      (lazy-seq (concat bolts-at lexemes)))))

(declare add-bolt-at)

(defn add-comps
  "given a bolt, return the lazy sequence of all bolts derived from this bolt after adding,
   at each supplied path in comp-paths, the bolts for that path."
  [bolt model comp-paths bolts-at-paths depth max-depth & [top-bolt truncate? take-n]]
  (lazy-seq
   (let [top-bolt (or top-bolt bolt)
         truncate? (if (= truncate? false)
