           proc-fn (fn []
                     (try
                       (let [^LocalTransferContainer c (take-from-queue in-queue)
-                            new-out (f (.getIn c) (.getOut c))]
-                        (if (not (nil? new-out))
-                          (.setOut c new-out))
-                        (enqueue out-queue c out-counter out-drop-counter))
+                            new-out (if (not (nil? c))
+                                      (f (.getIn c) (.getOut c)))]
+                        (when (not (nil? new-out))
+                          (.setOut c new-out)
+                          (enqueue out-queue c out-counter out-drop-counter)))
                       (catch InterruptedException e
                         (if @running
                           (throw e)))))

                          (try
                            (let [^LocalTransferContainer c (take-from-queue out-queue)]
                              (if (not (nil? c))
                                (out-fn (.getIn c) (.getOut c))
                                (out-fn nil nil)))
                            (catch InterruptedException e
                              (if @running
                                (throw e))))))

  [queue]
  (println "Retrieving data from queue via:")
  (let [expr (condp (fn [^String v ^String s] (.endsWith s v)) queue-setup
               "remove-yield" `(if (not (.isEmpty ~queue))
                                 (.remove ~queue)
                                 (Thread/yield))
               "remove" `(if (not (.isEmpty ~queue))
                           (.remove ~queue))
               `(.take ~queue))]
    (println expr)
    expr))
