   ([k] (alloc-id k 1 nil))
   ([k size] (alloc-id k size nil))
   ([k size action-fn]
-     (let [bits  (get allocator-bits k)
-           limit (get allocator-limits k)]
+     (let [bits  (get allocator-bits k)]
        (when-not bits
          (throw (Exception. (str "Unable to get allocator bits for keyword " k))))
-       (when-not limit
-         (throw (Exception. (str "Unable to get allocator limit for keyword " k))))
        (dosync
-        (let [id (find-gap @bits size 0 0 limit)]
+        (let [id (find-gap @bits size)]
           (alter bits fill-gaps id size true)
           (when action-fn (execute-action-fn #(action-fn id) "alloc-id"))
           id)))))

  ([k id] (free-id k id 1 nil))
  ([k id size] (free-id k id size nil))
  ([k id size action-fn]
     (let [bits (get allocator-bits k)
           limit (get allocator-limits k)]
       (dosync
        (alter bits fill-gaps id size false)
        (when action-fn (execute-action-fn action-fn "free-id"))))))

      bs)))

(defn- find-gap
  "Returns index of the first gap in vector bs with specified size where gap is
  defined as a falsey value.

  example:
  (find-gap [true false true false false false true] 3) ;=> 3"
  ([bs size] (find-gap bs size 0 0))
  ([bs size idx gap-found]
     (let [limit (count bs)]
       (when (> idx limit)
         (throw (Exception. (str "No more ids! Unable to allocate a sequence of ids of length: " size))))
       (if (= gap-found size)
         (- idx gap-found)
         (let [gap-found (if (not (get bs idx)) (inc gap-found) 0)]
           (find-gap bs size (inc idx) gap-found))))))

(def action-fn-executor* (agent nil))

