 
 
 (defn get-members [{:keys [conn] :as connector}]
-  (map (fn [path]
-         {:path path :val (System/currentTimeMillis)})
-       (car/wcar conn
-            (car/keys (clojure.string/join [(members-path connector) "/*"])))))
-
+  (into #{} (map (fn [path]
+									 {:path path :val (System/currentTimeMillis)})
+                 (car/wcar conn
+									            (car/keys (clojure.string/join [(members-path connector) "/*"]))))))
 
 (defn join 
   ([connector]
     (join connector host-name))
-  ([{:keys [conn conf state-ref] :as connector} node-name]
+  ([{:keys [conn conf member-event-ch state-ref] :as connector} node-name]
     (let [{:keys [heart-beat-freq]} conf
           path (members-path connector node-name)
           val (System/currentTimeMillis)]

  (clojure.string/join ["/" (clojure.string/join "/" (flatten [group-name "locks" path]))]))


(defn close [{:keys [state-ref]}]
  ;delete connection's state
  (dosync (alter state-ref (fn [state] {}))))
                        
(defn create-connection 

                )
     (dosync (alter state-ref 
            (fn [state]
               (assoc state :members (into #{} (conj (:members state) {:path path :val val})))
              )))
     (>!! member-event-ch {:left-members #{} :joined-members #{node-name}})
     )))
     
       
	    
(defn- members-left [members u-members]
  (clojure.set/difference (into #{} (map :path members)) (into #{} (map :path u-members))))

(defn- members-joined [members u-members]
  (clojure.set/difference (into #{} (map :path u-members)) (into #{} (map :path members))))

(defn heart-beat [connector {:keys [members locks empherals] :as state}]
  "Sends out the heart beat and updates all TTL nodes,
   The members are queried and if any difference a fresh list created for the state
   which is returned"
  (send-updates connector (concat members locks empherals))
    ;(prn "calling lef-members " members " " u-members)
    (let [u-members (get-members connector)
          left-members (if (> (count members) 0) (members-left members u-members) #{})
          joined-members (members-joined members u-members)]
        
         ;publish event
        (if (or (> (count left-members) 0) (> (count joined-members) 0))
          (>!! (:member-event-ch connector) {:left-members left-members :joined-members joined-members}))

        (if (not (= members u-members))
		      (merge state {:members u-members})
		           state)))

(defn unregister-event-ch [{:keys [member-event-mult]} ch]
  (untap member-event-mult ch))

(defn register-member-event-ch [{:keys [member-event-mult]}]
  "Returns a channel from which member register events can be read"
  (let [ch (chan (sliding-buffer 10))]
    (tap member-event-mult ch)
    ch))

(defn create-group-connector 
  ([host]
