Index: /source/ariba/overlay/BaseOverlay.cpp
===================================================================
--- /source/ariba/overlay/BaseOverlay.cpp	(revision 5789)
+++ /source/ariba/overlay/BaseOverlay.cpp	(revision 5803)
@@ -118,11 +118,10 @@
 		// get descriptor of first hop
 		rld = getDescriptor(rlid);
-		if (rld!=NULL) {
-			// is first hop a relay path use local relay
-			if ( rld->relay ) relayNode = rld->localRelay;
-
-			// no-> a proper relay node has been found
-			else relayNode = rld->remoteNode;
-		}
+
+		// is first hop a relay path use local relay
+		if ( rld->relay ) relayNode = rld->localRelay;
+
+		// no-> a proper relay node has been found
+		else relayNode = rld->remoteNode;
 	}
 
@@ -148,9 +147,6 @@
 		    lp->service == OverlayInterface::OVERLAY_SERVICE_ID &&
 		    lp->relay == false &&
-		    lp->up) {
-
-//			std::cout << "using relay node: " << lp->remoteNode.toString() << std::endl;
+		    lp->up)
 			return lp;
-		}
 
 	return NULL;
@@ -1156,5 +1152,5 @@
 			// delegate data message
 			listener->onMessage( overlayMsg,
-				overlayMsg->getSourceNode(), ld==NULL ? LinkID::UNSPECIFIED : ld->overlayId );
+				overlayMsg->getSourceNode(), ld->overlayId );
 
 			ret = true;
@@ -1395,16 +1391,4 @@
 			RelayMessage* relayMsg = overlayMsg->decapsulate<RelayMessage>();
 
-			// mark incoming link as relay
-			if (ld!=NULL) ld->markAsRelay();
-
-			// am I the destination of this message? yes->
-			if (relayMsg->getDestNode() == nodeId ) {
-				// deliver relay message locally!
-				logging_debug("Relay message reached destination. Handling the message.");
-				handleMessage( relayMsg, relayMsg->getDestLink(), LinkID::UNSPECIFIED, remoteNode );
-				ret = true;
-				break;
-			}
-
 			// is relay message informative?
 			switch (relayMsg->getType()) {
@@ -1416,8 +1400,21 @@
 							<< " destination " << relayMsg->getDestNode() );
 
+					// mark incoming link as relay
+					if (ld!=NULL) ld->markAsRelay();
+
+					// am I the destination of this message? yes->
+					if (relayMsg->getDestNode() == nodeId ) {
+						// deliver relay message locally!
+						logging_debug("Relay message reached destination. Handling the message.");
+						handleMessage( relayMsg, relayMsg->getDestLink(), LinkID::UNSPECIFIED, remoteNode );
+						ret = true;
+						break;
+					}
+
 					// create route message
 					OverlayMsg _overMsg( *overlayMsg );
-					relayMsg->setType( RelayMessage::typeRoute );
-					_overMsg.encapsulate( relayMsg );
+					RelayMessage _relayMsg( *relayMsg );
+					_relayMsg.setType( RelayMessage::typeRoute );
+					_overMsg.encapsulate( &_relayMsg );
 
 					// forward message
@@ -1439,9 +1436,22 @@
 							<< " destination " << relayMsg->getDestNode() );
 
+					// mark incoming link as relay
+					if (ld!=NULL) ld->markAsRelay();
+
+					// am I the destination of this message? yes->
+					if (relayMsg->getDestNode() == nodeId ) {
+						// deliver relay message locally!
+						logging_debug("Relay message reached destination. Handling the message.");
+						handleMessage( relayMsg, relayMsg->getDestLink(), LinkID::UNSPECIFIED, remoteNode );
+						ret = true;
+						break;
+					}
+
 					// am I the relay for this message? yes->
 					if (relayMsg->getRelayNode() == nodeId ) {
 						logging_debug("I'm the relay for this message. Sending to destination.");
 						OverlayMsg _overMsg( *overlayMsg );
-						_overMsg.encapsulate(relayMsg);
+						RelayMessage _relayMsg( *relayMsg );
+						_overMsg.encapsulate(&_relayMsg);
 
 						/// this must be handled by using relay link!
@@ -1607,5 +1617,5 @@
 
 			// missed more than four keep-alive messages (10 sec)? -> drop link
-			if (ld->keepAliveMissed > 8) {
+			if (ld->keepAliveMissed > 4) {
 				logging_info( "Link connection request is stale, closing: " << ld );
 				oldlinks.push_back( ld );
Index: /source/ariba/overlay/messages/RelayMessage.h
===================================================================
--- /source/ariba/overlay/messages/RelayMessage.h	(revision 5789)
+++ /source/ariba/overlay/messages/RelayMessage.h	(revision 5803)
@@ -37,10 +37,5 @@
 	/// contructs a unspecified relay message
 	RelayMessage() :
-		type(typeInvalid), relayNode(NodeID::UNSPECIFIED), destNode(NodeID::UNSPECIFIED), destLink(LinkID::UNSPECIFIED) {
-	}
-
-	RelayMessage( const RelayMessage& rhs ) :
-		type(rhs.type), relayNode(rhs.relayNode), destNode(rhs.destNode), destLink(rhs.destLink) {
-
+		type(typeInvalid), relayNode(NodeID::UNSPECIFIED), destNode(NodeID::UNSPECIFIED) {
 	}
 
Index: /source/ariba/overlay/modules/chord/Chord.cpp
===================================================================
--- /source/ariba/overlay/modules/chord/Chord.cpp	(revision 5789)
+++ /source/ariba/overlay/modules/chord/Chord.cpp	(revision 5803)
@@ -58,6 +58,4 @@
 	// create routing table
 	this->table = new chord_routing_table(_nodeid, 2);
-
-	// init counters
 	orphan_removal_counter = 0;
 	discovery_count = 0;
@@ -92,6 +90,5 @@
 
 	// establish link via base overlay
-	return baseoverlay.establishLink(endp, node, OverlayInterface::OVERLAY_SERVICE_ID,
-			remoteRelay );
+	return baseoverlay.establishLink(endp, node, OverlayInterface::OVERLAY_SERVICE_ID, remoteRelay );
 }
 
@@ -100,12 +97,4 @@
 	if (link.isUnspecified()) return 0;
 	return baseoverlay.sendMessage(msg, link);
-}
-
-const LinkID& Chord::get_next_hop( const NodeID& id ) const {
-	BOOST_FOREACH( const back_route& br, back_routes )
-		if (br.id==id) return br.link;
-	const route_item* item = table->get_next_hop(id);
-	if (item==NULL) return LinkID::UNSPECIFIED;
-	return item->info;
 }
 
@@ -123,6 +112,6 @@
 
 	// get next hop
-	LinkID next_link = get_next_hop(destination);
-	if (!next_link.isUnspecified()) send(&cmsg, next_link);
+	const route_item* item = table->get_next_hop(destination);
+	if (item!=NULL && !item->info.isUnspecified()) send(&cmsg, item->info);
 }
 
@@ -190,8 +179,8 @@
 void Chord::routeMessage(const NodeID& destnode, Message* msg) {
 	// get next hop
-	LinkID next_link = get_next_hop(destnode);
+	const route_item* item = table->get_next_hop(destnode);
 
 	// message for this node? yes-> delegate to base overlay
-	if (destnode == nodeid)
+	if (item->id == nodeid || destnode == nodeid)
 		baseoverlay.incomingRouteMessage( msg, LinkID::UNSPECIFIED, nodeid );
 
@@ -199,5 +188,5 @@
 		ChordMessage cmsg(ChordMessage::route, nodeid, destnode);
 		cmsg.encapsulate(msg);
-		send(&cmsg, next_link);
+		send(&cmsg, item->info);
 	}
 }
@@ -214,5 +203,13 @@
 /// @see OverlayInterface.h
 const LinkID& Chord::getNextLinkId( const NodeID& id ) const {
-	return get_next_hop(id);
+	// get next hop
+	const route_item* item = table->get_next_hop(id);
+
+	// returns a unspecified id when this is itself
+	if (item == NULL || item->id == nodeid)
+		return LinkID::UNSPECIFIED;
+
+	/// return routing info
+	return item->info;
 }
 
@@ -223,6 +220,6 @@
 		// all nodes that I know, fingers, succ/pred
 		for (size_t i = 0; i < table->size(); i++){
-			if (/*(*table)[i]->ref_count != 0
-					&&*/ !(*table)[i]->info.isUnspecified())
+			if ((*table)[i]->ref_count != 0
+					&& !(*table)[i]->info.isUnspecified())
 				nodelist.push_back((*table)[i]->id);
 		}
@@ -309,34 +306,16 @@
 	case M::route: {
 		// find next hop
-		LinkID next_link = get_next_hop(m->getDestination());
-
-		// add to back-routes
-		bool found = false;
-		BOOST_FOREACH( back_route br, back_routes) {
-			if (br.id == m->getSource()) {
-				br.link = link;
-				br.lastseen = time(NULL);
-				found = true;
-				break;
-			}
-		}
-		if (!found) {
-			back_route br;
-			br.id = m->getSource();
-			br.link = link;
-			br.lastseen = time(NULL);
-			back_routes.push_back(br);
-		}
+		const route_item* item = table->get_next_hop(m->getDestination());
 
 		// next hop == myself?
 		if (m->getDestination() == nodeid) { // yes-> route to base overlay
 			logging_debug("Send message to baseoverlay");
-			baseoverlay.incomingRouteMessage( m, next_link, remote );
+			baseoverlay.incomingRouteMessage( m, item->info, remote );
 		}
 		// no-> route to next hop
 		else {
-//			logging_debug("Route chord message to "
-//				<< item->id.toString() << " (destination=" << m->getDestination() << ")");
-			send(m, next_link);
+			logging_debug("Route chord message to "
+				<< item->id.toString() << " (destination=" << m->getDestination() << ")");
+			send(m, item->info);
 		}
 		break;
@@ -378,5 +357,4 @@
 					logging_debug("Discovery split: routing discovery message to successor "
 							<< succ_item->id.toString() );
-					cmsg_s.setDestination(succ_item->id);
 					send(&cmsg_s, succ_item->info);
 				}
@@ -392,5 +370,4 @@
 					logging_debug("Discovery split: routing discovery message to predecessor "
 							<< pred_item->id.toString() );
-					cmsg_p.setDestination(pred_item->id);
 					send(&cmsg_p, pred_item->info);
 				}
@@ -399,8 +376,9 @@
 			else {
 				// find next hop
-				LinkID next_link = get_next_hop(m->getDestination());
-			//	logging_debug("routing discovery message to " <<
-			//			linkitem->id.toString() );
-				send(m, next_link);
+				const route_item* item = table->get_next_hop(m->getDestination());
+				if (item == NULL || item->id == nodeid) break;
+				logging_debug("routing discovery message to " <<
+						item->id.toString() );
+				send(m, item->info);
 			}
 			break;
@@ -453,5 +431,5 @@
 void Chord::eventFunction() {
 	stabilize_counter++;
-	if (stabilize_counter < 0 || stabilize_counter >= 2) {
+	if (stabilize_counter < 0 || stabilize_counter == 4) {
 
 		// reset counter
@@ -487,12 +465,4 @@
 		orphan_removal_counter++;
 		if (orphan_removal_counter <0 || orphan_removal_counter >= 4) {
-			back_routes.clear();
-/*			for (vector<back_route>::iterator i = back_routes.begin();
-					i!=back_routes.end(); i++) {
-				back_route& br = *i;
-				if (difftime(br.lastseen,time(NULL))>5) i =
-						back_routes.erase(i)-1;
-			}
-*/
 			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 5789)
+++ /source/ariba/overlay/modules/chord/Chord.h	(revision 5803)
@@ -80,14 +80,4 @@
 	int discovery_count;
 
-	class back_route {
-	public:
-		NodeID id;
-		LinkID link;
-		time_t lastseen;
-	};
-	vector<back_route> back_routes;
-
-	const LinkID& get_next_hop( const NodeID& id ) const;
-
 	// helper: sets up a link using the "base overlay"
 	LinkID setup( const EndpointDescriptor& endp,
Index: /source/ariba/overlay/modules/chord/messages/ChordMessage.h
===================================================================
--- /source/ariba/overlay/modules/chord/messages/ChordMessage.h	(revision 5789)
+++ /source/ariba/overlay/modules/chord/messages/ChordMessage.h	(revision 5803)
@@ -88,14 +88,6 @@
 	}
 
-	void setSource(const NodeID& source ) {
-		this->source = source;
-	}
-
 	const NodeID& getSource() const {
 		return source;
-	}
-
-	void setDestination(const NodeID& destination ) {
-		this->destination = destination;
 	}
 
