Index: libfdcore/fdcore-internal.h
===================================================================
--- libfdcore/fdcore-internal.h	(revision 1014)
+++ libfdcore/fdcore-internal.h	(revision 1015)
@@ -71,5 +71,5 @@
 #endif /* DPR_TIMEOUT */
 
-/* Delai where the connection is maintained opened to allow exchanging remaining pending answers after DPR/DPA */
+/* Delay where the connection is maintained opened to allow exchanging remaining pending answers after DPR/DPA */
 #ifndef GRACE_TIMEOUT
 #define GRACE_TIMEOUT   1	/* in seconds */
@@ -134,5 +134,5 @@
 	pthread_mutex_t	mtx; /* mutex to protect these lists */
 	pthread_cond_t  cnd; /* cond var used by the thread that handles timeouts */
-	pthread_t       thr; /* the thread that handles timeouts (expirecb called in separate forked threads) */
+	pthread_t       thr; /* the thread that handles timeouts (and calls the anscb) */
 };
 
Index: libfdcore/messages.c
===================================================================
--- libfdcore/messages.c	(revision 1014)
+++ libfdcore/messages.c	(revision 928)
@@ -321,5 +321,5 @@
 	
 	/* Save the callback in the message */
-	CHECK_FCT(  fd_msg_anscb_associate( *pmsg, anscb, data, NULL, NULL /* we should maybe use a safeguard here like 1 hour or so? */ )  );
+	CHECK_FCT(  fd_msg_anscb_associate( *pmsg, anscb, data, NULL /* we should maybe use a safeguard here like 1 hour or so? */ )  );
 	
 	/* Post the message in the outgoing queue */
@@ -330,11 +330,11 @@
 
 /* The variation of the same function with a timeout callback */
-int fd_msg_send_timeout ( struct msg ** pmsg, void (*anscb)(void *, struct msg **), void * data, void (*expirecb)(void *, DiamId_t, size_t, struct msg **), const struct timespec *timeout )
-{
-	TRACE_ENTRY("%p %p %p %p %p", pmsg, anscb, data, expirecb, timeout);
-	CHECK_PARAMS( pmsg && expirecb && timeout );
+int fd_msg_send_timeout ( struct msg ** pmsg, void (*anscb)(void *, struct msg **), void * data, const struct timespec *timeout )
+{
+	TRACE_ENTRY("%p %p %p", pmsg, anscb, data, timeout);
+	CHECK_PARAMS( pmsg && anscb && timeout );
 	
 	/* Save the callback in the message, with the timeout */
-	CHECK_FCT(  fd_msg_anscb_associate( *pmsg, anscb, data, expirecb, timeout )  );
+	CHECK_FCT(  fd_msg_anscb_associate( *pmsg, anscb, data, timeout )  );
 	
 	/* Post the message in the outgoing queue */
Index: libfdcore/p_sr.c
===================================================================
--- libfdcore/p_sr.c	(revision 1014)
+++ libfdcore/p_sr.c	(revision 974)
@@ -85,15 +85,10 @@
 }
 
-struct expire_data {
-	struct msg * request;
-	struct fd_peer * sentto;
-};
-
 /* (detached) thread that calls the anscb on expired messages. 
   We do it in a separate thread to avoid blocking the reception of new messages during this time */
-static void * call_expirecb(void * arg) {
-	struct expire_data * ed = arg;
-	
-	void (*expirecb)(void *, DiamId_t, size_t, struct msg **);
+static void * call_anscb_expire(void * arg) {
+	struct msg * expired_req = arg;
+	
+	void (*anscb)(void *, struct msg **);
 	void * data;
 	
@@ -108,20 +103,18 @@
 	
 	/* Retrieve callback in the message */
-	CHECK_FCT_DO( fd_msg_anscb_get( ed->request, NULL, &expirecb, &data ), return NULL);
-	ASSERT(expirecb);
+	CHECK_FCT_DO( fd_msg_anscb_get( expired_req, &anscb, &data ), return NULL);
+	ASSERT(anscb);
 	
 	/* Clean up this data from the message */
-	CHECK_FCT_DO( fd_msg_anscb_associate( ed->request, NULL, NULL, NULL, NULL ), return NULL);
+	CHECK_FCT_DO( fd_msg_anscb_associate( expired_req, NULL, NULL, NULL ), return NULL);
 
 	/* Call it */
-	(*expirecb)(data, ed->sentto->p_hdr.info.pi_diamid, ed->sentto->p_hdr.info.pi_diamidlen, &ed->request);
+	(*anscb)(data, &expired_req);
 	
 	/* If the callback did not dispose of the message, do it now */
-	if (ed->request) {
-		fd_msg_log(FD_MSG_LOG_DROPPED, ed->request, "Expiration period completed without an answer, and the expiry callback did not dispose of the message.");
-		CHECK_FCT_DO( fd_msg_free(ed->request), /* ignore */ );
-	}
-	
-	free(ed);
+	if (expired_req) {
+		fd_msg_log(FD_MSG_LOG_DROPPED, expired_req, "Expiration period completed without an answer, and the expiry callback did not dispose of the message.");
+		CHECK_FCT_DO( fd_msg_free(expired_req), /* ignore */ );
+	}
 	
 	/* Finish */
@@ -132,6 +125,6 @@
 static void * sr_expiry_th(void * arg) {
 	struct sr_list * srlist = arg;
+	struct msg * expired_req;
 	pthread_attr_t detached;
-	struct expire_data * ed;
 	
 	TRACE_ENTRY("%p", arg);
@@ -184,12 +177,10 @@
 		
 		/* Now, the first request in the list is expired; remove it and call the anscb for it in a new thread */
-		CHECK_MALLOC_DO( ed = malloc(sizeof(struct expire_data)), goto error );
-		ed->sentto = first->chain.head->o;
-		ed->request = first->req;
 		fd_list_unlink(&first->chain);
 		fd_list_unlink(&first->expire);
+		expired_req = first->req;
 		free(first);
 		
-		CHECK_POSIX_DO( pthread_create( &th, &detached, call_expirecb, ed ), goto error );
+		CHECK_POSIX_DO( pthread_create( &th, &detached, call_anscb_expire, expired_req ), goto error );
 
 		/* loop */
Index: libfdcore/routing_dispatch.c
===================================================================
--- libfdcore/routing_dispatch.c	(revision 1014)
+++ libfdcore/routing_dispatch.c	(revision 974)
@@ -467,5 +467,5 @@
 
 		/* Retrieve any registered handler */
-		CHECK_FCT( fd_msg_anscb_get( qry, &anscb, NULL, &data ) );
+		CHECK_FCT( fd_msg_anscb_get( qry, &anscb, &data ) );
 
 		/* If a callback was registered, pass the message to it */
@@ -793,6 +793,4 @@
 	struct rtd_candidate * c;
 	struct msg *msgptr = msg;
-	DiamId_t qry_src = NULL;
-	size_t qry_src_len = 0;
 	
 	/* Read the message header */
@@ -803,4 +801,6 @@
 	if ( ! is_req ) {
 		struct msg * qry;
+		DiamId_t qry_src = NULL;
+		size_t qry_src_len = 0;
 		struct msg_hdr * qry_hdr;
 		struct fd_peer * peer = NULL;
@@ -832,6 +832,4 @@
 	
 	/* From that point, the message is a request */
-	CHECK_FCT( fd_msg_source_get( msgptr, &qry_src, &qry_src_len ) );
-	/* if qry_src != NULL, this message is relayed, otherwise it is locally issued */
 
 	/* Get the routing data out of the message if any (in case of re-transmit) */
