Index: source/ariba/overlay/BaseOverlay.cpp
===================================================================
--- source/ariba/overlay/BaseOverlay.cpp	(revision 5874)
+++ source/ariba/overlay/BaseOverlay.cpp	(revision 5876)
@@ -211,4 +211,5 @@
 }
 
+/// shows the current link state
 void BaseOverlay::showLinks() {
 	int i=0;
@@ -220,4 +221,19 @@
 	logging_info("----------------------------------------------");
 }
+
+/// compares two arbitrary links to the same node
+int BaseOverlay::compare( const LinkID& lhs, const LinkID& rhs ) {
+	LinkDescriptor* lhsld = getDescriptor(lhs);
+	LinkDescriptor* rhsld = getDescriptor(rhs);
+	if (lhsld==NULL || rhsld==NULL
+		|| !lhsld->up || !rhsld->up
+		|| lhsld->remoteNode != rhsld->remoteNode) return -1;
+
+	if ((lhsld->remoteLink^lhsld->overlayId)<(rhsld->remoteLink^lhsld->overlayId)  )
+		return -1;
+
+	return 1;
+}
+
 
 // internal message delivery ---------------------------------------------------
Index: source/ariba/overlay/BaseOverlay.h
===================================================================
--- source/ariba/overlay/BaseOverlay.h	(revision 5874)
+++ source/ariba/overlay/BaseOverlay.h	(revision 5876)
@@ -434,4 +434,7 @@
 	void showLinks();
 
+	/// compares two arbitrary links to the same node
+	int compare( const LinkID& lhs, const LinkID& rhs );
+
 	// relay route management --------------------------------------------------
 
Index: source/ariba/overlay/modules/chord/Chord.cpp
===================================================================
--- source/ariba/overlay/modules/chord/Chord.cpp	(revision 5874)
+++ source/ariba/overlay/modules/chord/Chord.cpp	(revision 5876)
@@ -232,12 +232,5 @@
 			break;
 		}
-/*
-	// check if we already have a connection, yes-> do not handle duplicate!
-	for (int i=0; i<table->size(); i++)
-		if ((*table)[i]->id == remote && !((*table)[i]->info.isUnspecified()) && (*table)[i]->info != lnk) {
-
-			return;
-		}
-*/
+
 	if (remote==nodeid) {
 		baseoverlay.dropLink(lnk);
@@ -305,7 +298,15 @@
 		);
 
+		// add discovery node id
+		bool found = false;
+		BOOST_FOREACH( NodeID& value, discovery )
+			if (value == m->getSourceNode()) {
+				found = true;
+				break;
+			}
+		if (!found) discovery.push_back(m->getSourceNode());
+
 		// check if source node can be added to routing table and setup link
-		if (m->getSourceNode() != nodeid
-			&& table->is_insertable(m->getSourceNode()))
+		if (m->getSourceNode() != nodeid)
 			setup( dmsg->getEndpoint(), m->getSourceNode() );
 
@@ -317,25 +318,22 @@
 			// closest node? yes-> split to follow successor and predecessor
 			if ( table->is_closest_to(m->getDestinationNode()) ) {
-
-				if (table->get_successor() != NULL) {
+				logging_debug("Discovery split:");
+				if (!table->get_successor()->isUnspecified()) {
 					OverlayMsg omsg(*m);
 					dmsg->setType(Discovery::successor);
 					omsg.encapsulate(dmsg);
-					route_item* succ_item = table->get(*table->get_successor());
-					logging_debug("Discovery split: routing discovery message to successor "
-							<< succ_item->id.toString() );
-					send(&omsg, succ_item->info);
+					logging_debug("* Routing to successor "
+							<< table->get_successor()->toString() );
+					baseoverlay.send( &omsg, *table->get_successor() );
 				}
 
 				// send predecessor message
-				if (table->get_predesessor() != NULL) {
+				if (!table->get_predesessor()->isUnspecified()) {
 					OverlayMsg omsg(*m);
 					dmsg->setType(Discovery::predecessor);
 					omsg.encapsulate(dmsg);
-					route_item* pred_item = table->get(
-							*table->get_predesessor());
-					logging_debug("Discovery split: routing discovery message to predecessor "
-							<< pred_item->id.toString() );
-					send( &omsg, pred_item->info);
+					logging_debug("* Routing to predecessor "
+							<< table->get_predesessor()->toString() );
+					baseoverlay.send( &omsg, *table->get_predesessor() );
 				}
 			}
@@ -365,9 +363,11 @@
 			}
 			if (item == NULL) break;
-			logging_debug("routing discovery message to succ/pred "
+			logging_debug("Routing discovery message to succ/pred "
 				<< item->id.toString() );
 			OverlayMsg omsg(*m);
 			omsg.encapsulate(dmsg);
 			omsg.setDestinationNode(item->id);
+			omsg.setService(OverlayInterface::OVERLAY_SERVICE_ID);
+			omsg.setRelayed(true);
 			baseoverlay.send(&omsg, omsg.getDestinationNode());
 			break;
@@ -407,4 +407,10 @@
 		logging_info("Running stabilization: #links="
 				<< table->size() << " #neighbors=" << numNeighbors );
+
+		// updating neighbors
+		for (int i=0; i<table->size(); i++) {
+			LinkID id = (*table)[i]->info;
+			if (!id.isUnspecified()) discover_neighbors(id);
+		}
 
 		// sending discovery
@@ -417,12 +423,12 @@
 			send_discovery_to(disc2);
 
-		for (int i=0; i<table->size(); i++) {
-			LinkID id = (*table)[i]->info;
-			if (!id.isUnspecified()) discover_neighbors(id);
-		}
 
 		// remove orphan links
 		orphan_removal_counter++;
 		if (orphan_removal_counter <0 || orphan_removal_counter >= 2) {
+			logging_info("Discovered nodes: ");
+			BOOST_FOREACH( NodeID& id, discovery )
+				logging_info("* " << id.toString());
+			discovery.clear();
 			logging_info("Running orphan removal");
 			orphan_removal_counter = 0;
Index: source/ariba/overlay/modules/chord/Chord.h
===================================================================
--- source/ariba/overlay/modules/chord/Chord.h	(revision 5874)
+++ source/ariba/overlay/modules/chord/Chord.h	(revision 5876)
@@ -80,4 +80,5 @@
 	vector<LinkID> bootstrapLinks;
 	vector<NodeID> pending;
+	vector<NodeID> discovery;
 	int discovery_count;
 
Index: source/ariba/utility/transport/tcpip/protlib/address.cpp
===================================================================
--- source/ariba/utility/transport/tcpip/protlib/address.cpp	(revision 5874)
+++ source/ariba/utility/transport/tcpip/protlib/address.cpp	(revision 5876)
@@ -431,6 +431,6 @@
 		// Otherwise they are not equal.
 		if (hostaddress::operator==(ie)) {
-		    if (proto!=app->proto) cout << "protocols not matching" << endl;
-		    if (port !=app->port) cout << "ports not matching" << endl;
+		    //if (proto!=app->proto) cout << "protocols not matching" << endl;
+		    //if (port !=app->port) cout << "ports not matching" << endl;
 
 		    return ((proto==app->proto) && (port==app->port));
