Distributed Cooperation in Dynamically Changing Groups