fixed pending connections and added comments