Index: extensions/_sample/sample.c
===================================================================
--- extensions/_sample/sample.c	(revision 974)
+++ extensions/_sample/sample.c	(revision 1088)
@@ -85,5 +85,4 @@
 		CHECK_FCT( fd_dict_new ( fd_g_config->cnf_dict, DICT_RULE, &rule_data, example_avp_avp, NULL ));
 		
-		fd_dict_dump_object(example_avp_avp);
 	}
 	TRACE_DEBUG(INFO, "'Example-AVP' created without error");
Index: extensions/app_diameap/diameap_server.c
===================================================================
--- extensions/app_diameap/diameap_server.c	(revision 1027)
+++ extensions/app_diameap/diameap_server.c	(revision 1088)
@@ -85,9 +85,7 @@
 
 
-void diameap_cli_sess_cleanup(void * arg, char * sid, void * opaque)
-{
-
-	struct diameap_sess_data_sm * diameap_sess_data =
-			(struct diameap_sess_data_sm *) arg;
+void diameap_cli_sess_cleanup(struct sess_state * diameap_sess_data, os0_t sid, void * opaque)
+{
+
 	CHECK_PARAMS_DO( diameap_sess_data, return );
 
@@ -141,5 +139,5 @@
 static int diameap_initialize_diameap_sm(
 		struct diameap_state_machine * diameap_sm,
-		struct diameap_sess_data_sm * diameap_sess_data)
+		struct sess_state * diameap_sess_data)
 {
 	TRACE_ENTRY("%p %p", diameap_sm, diameap_sess_data);
@@ -1017,5 +1015,5 @@
 
 static int diameap_sess_data_new(
-		struct diameap_sess_data_sm *diameap_sess_data,
+		struct sess_state *diameap_sess_data,
 		struct diameap_state_machine *diameap_sm)
 {
@@ -3064,5 +3062,5 @@
 	TRACE_ENTRY("%p %p %p %p", rmsg, ravp, sess, action);
 
-	struct diameap_sess_data_sm * diameap_sess_data = NULL;
+	struct sess_state * diameap_sess_data = NULL;
 	struct diameap_state_machine * diameap_sm = NULL;
 	struct diameap_eap_interface eap_i;
@@ -3258,7 +3256,7 @@
 			TRACE_DEBUG(FULL+1,"%sStoring DiamEAP session data.",DIAMEAP_EXTENSION)
 			;
-			CHECK_MALLOC(diameap_sess_data = malloc(sizeof(struct diameap_sess_data_sm)))
-			;
-			memset(diameap_sess_data, 0, sizeof(struct diameap_sess_data_sm));
+			CHECK_MALLOC(diameap_sess_data = malloc(sizeof(struct sess_state)))
+			;
+			memset(diameap_sess_data, 0, sizeof(struct sess_state));
 			diameap_sess_data_new(diameap_sess_data, diameap_sm);
 
@@ -3389,5 +3387,5 @@
 
 	/*create handler for sessions */
-	CHECK_FCT(fd_sess_handler_create(&diameap_server_reg, diameap_cli_sess_cleanup, NULL));
+	CHECK_FCT(fd_sess_handler_create(&diameap_server_reg, diameap_cli_sess_cleanup, NULL, NULL));
 
 	/* Register the callback */
Index: extensions/app_diameap/diameap_server.h
===================================================================
--- extensions/app_diameap/diameap_server.h	(revision 441)
+++ extensions/app_diameap/diameap_server.h	(revision 1088)
@@ -40,7 +40,7 @@
 #define DIAMEAP_SERVER_H_
 
-
+ 
 /* session data structure to store */
-struct diameap_sess_data_sm
+struct sess_state
 {
 	int invalid_eappackets; /* Number of invalid EAP Packet received*/
Index: extensions/app_radgw/rgwx_acct.c
===================================================================
--- extensions/app_radgw/rgwx_acct.c	(revision 1027)
+++ extensions/app_radgw/rgwx_acct.c	(revision 1088)
@@ -160,4 +160,9 @@
 };
 
+static DECLARE_FD_DUMP_PROTOTYPE(acct_conf_session_state_dump, struct sess_state * st)
+{
+	return fd_dump_extend( FD_DUMP_STD_PARAMS, "[rgwx sess_state](@%p): aai:%x str:%d TC:%u", st, st->auth_appl, st->send_str, st->term_cause);
+}
+
 /* Initialize the plugin */
 static int acct_conf_parse(char * conffile, struct rgwp_config ** state)
@@ -172,5 +177,5 @@
 	memset(new, 0, sizeof(struct rgwp_config));
 	
-	CHECK_FCT( fd_sess_handler_create( &new->sess_hdl, free, NULL ) );
+	CHECK_FCT( fd_sess_handler_create( &new->sess_hdl, (void *)free, acct_conf_session_state_dump, NULL ) );
 	new->confstr = conffile;
 	
Index: extensions/app_radgw/rgwx_auth.c
===================================================================
--- extensions/app_radgw/rgwx_auth.c	(revision 1027)
+++ extensions/app_radgw/rgwx_auth.c	(revision 1088)
@@ -125,4 +125,9 @@
 };
 
+struct sess_state {
+	char req_auth[16];
+};
+
+
 /* Initialize the plugin */
 static int auth_conf_parse(char * confstr, struct rgwp_config ** state)
@@ -137,5 +142,5 @@
 	memset(new, 0, sizeof(struct rgwp_config));
 	
-	CHECK_FCT( fd_sess_handler_create( &new->sess_hdl, free, NULL ) );
+	CHECK_FCT( fd_sess_handler_create( &new->sess_hdl, (void *)free, NULL, NULL ) );
 	new->confstr = confstr;
 	
@@ -1057,9 +1062,9 @@
 	/* Store the request identifier in the session (if provided) */
 	{
-		unsigned char * req_auth;
-		CHECK_MALLOC(req_auth = malloc(16));
-		memcpy(req_auth, &rad_req->hdr->authenticator[0], 16);
+		struct sess_state  *st;
+		CHECK_MALLOC(st = malloc(sizeof(struct sess_state)));
+		memcpy(st->req_auth, &rad_req->hdr->authenticator[0], 16);
 		
-		CHECK_FCT( fd_sess_state_store( cs->sess_hdl, sess, &req_auth ) );
+		CHECK_FCT( fd_sess_state_store( cs->sess_hdl, sess, &st ) );
 	}
 	
@@ -1077,5 +1082,5 @@
 	int no_str = 0; /* indicate if an STR is required for this server */
 	uint8_t	tuntag = 0;
-	unsigned char * req_auth = NULL;
+	struct sess_state  *st;
 	int error_cause = 0;
 	struct session * sess;
@@ -1089,5 +1094,5 @@
 	CHECK_FCT( fd_msg_sess_get(fd_g_config->cnf_dict, *diam_ans, &sess, NULL) );
 	if (sess) {
-		CHECK_FCT( fd_sess_state_retrieve( cs->sess_hdl, sess, &req_auth ) );
+		CHECK_FCT( fd_sess_state_retrieve( cs->sess_hdl, sess, &st ) );
 		CHECK_FCT( fd_sess_getsid(sess, &sid, &sidlen) );
 	} /* else ? */
@@ -1759,5 +1764,5 @@
 											
 											/* We need the request authenticator */
-											CHECK_PARAMS(req_auth);
+											CHECK_PARAMS(st);
 
 											/* Retrieve the shared secret */
@@ -1778,5 +1783,5 @@
 											addr[0] = secret;
 											len[0] = secret_len;
-											addr[1] = req_auth;
+											addr[1] = st->req_auth;
 											len[1] = 16;
 											addr[2] = &buf[1];
@@ -1853,5 +1858,5 @@
 
 						/* We need the request authenticator */
-						CHECK_PARAMS(req_auth);
+						CHECK_PARAMS(st);
 
 						/* Retrieve the shared secret */
@@ -1866,5 +1871,5 @@
 						send_len = ahdr->avp_value->os.len - recv_len;
 						
-						if ( ! radius_msg_add_mppe_keys(*rad_fw, req_auth, secret, secret_len, 
+						if ( ! radius_msg_add_mppe_keys(*rad_fw, st->req_auth, secret, secret_len, 
 								ahdr->avp_value->os.data + recv_len, send_len,
 								ahdr->avp_value->os.data, recv_len) ) {
@@ -1925,5 +1930,5 @@
 	
 	CHECK_FCT( fd_msg_free( aoh ) );
-	free(req_auth);
+	free(st);
 	
 	if (error_cause) {
Index: extensions/app_radgw/rgwx_echodrop.c
===================================================================
--- extensions/app_radgw/rgwx_echodrop.c	(revision 996)
+++ extensions/app_radgw/rgwx_echodrop.c	(revision 1088)
@@ -38,18 +38,29 @@
 #include "rgwx_echodrop.h"
 
+struct sess_state {
+	struct fd_list sentinel;
+};
+
 /* If a session is destroyed, empty the list of ed_saved_attribute */
-static void state_delete(void * arg, char * sid, void * opaque) {
-	struct fd_list * list = (struct fd_list *)arg;
-	
-	CHECK_PARAMS_DO( list, return );
-	
-	while (!FD_IS_LIST_EMPTY(list)) {
-		struct ed_saved_attribute * esa = (struct ed_saved_attribute *)(list->next);
+static void state_delete(struct sess_state * arg, os0_t sid, void * opaque) {
+	while (!FD_IS_LIST_EMPTY(&arg->sentinel)) {
+		struct ed_saved_attribute * esa = (struct ed_saved_attribute *)(arg->sentinel.next);
 		fd_list_unlink(&esa->chain);
 		free(esa);
 	}
-	free(list);
-}
-
+	free(arg);
+}
+
+static DECLARE_FD_DUMP_PROTOTYPE(ed_session_state_dump, struct sess_state * st)
+{
+	struct fd_list * li;
+	CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "[rgwx sess_state](@%p):\n", st), return NULL);	
+	for (li = st->sentinel.next; li != &st->sentinel; li = li->next) {
+		struct ed_saved_attribute * esa = (struct ed_saved_attribute *)(li);
+		CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "[rgwx sess_state {esa}] t:%2hhx l:%2hhx d:", esa->attr.type, esa->attr.length), return NULL);
+		CHECK_MALLOC_DO( fd_dump_extend_hexdump(FD_DUMP_STD_PARAMS, (&esa->attr.length) + 1, esa->attr.length - 2, 0,0), return NULL);
+		CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\n"), return NULL);
+	}
+}
 
 /* Initialize the plugin and parse the configuration. */
@@ -69,5 +80,5 @@
 	
 	/* Create the session handler */
-	CHECK_FCT( fd_sess_handler_create( &new->sess_hdl, state_delete, NULL ) );
+	CHECK_FCT( fd_sess_handler_create( &new->sess_hdl, state_delete, ed_session_state_dump, NULL ) );
 	
 	/* Parse the configuration file */
@@ -217,4 +228,5 @@
 	if (!FD_IS_LIST_EMPTY(&echo_list)) {
 		struct session * sess;
+		struct sess_state * st;
 		
 		CHECK_FCT( fd_msg_sess_get(fd_g_config->cnf_dict, *diam_fw, &sess, NULL) );
@@ -229,10 +241,10 @@
 		
 		/* Move the values in a dynamically allocated list */
-		CHECK_MALLOC( li = malloc(sizeof(struct fd_list)) );
-		fd_list_init(li, NULL);
-		fd_list_move_end(li, &echo_list);
+		CHECK_MALLOC( st = malloc(sizeof(struct sess_state)) );
+		fd_list_init(&st->sentinel, NULL);
+		fd_list_move_end(&st->sentinel, &echo_list);
 		
 		/* Save the list in the session */
-		CHECK_FCT( fd_sess_state_store( cs->sess_hdl, sess, &li ) );
+		CHECK_FCT( fd_sess_state_store( cs->sess_hdl, sess, &st ) );
 	}
 	
@@ -243,6 +255,6 @@
 static int ed_diam_ans( struct rgwp_config * cs, struct msg ** diam_ans, struct radius_msg ** rad_fw, struct rgw_client * cli )
 {
-	struct fd_list * list = NULL;
 	struct session * sess;
+	struct sess_state * st;
 	
 	TRACE_ENTRY("%p %p %p %p", cs, diam_ans, rad_fw, cli);
@@ -258,6 +270,6 @@
 	
 	/* Now try and retrieve any data from the session */
-	CHECK_FCT( fd_sess_state_retrieve( cs->sess_hdl, sess, &list ) );
-	if (list == NULL) {
+	CHECK_FCT( fd_sess_state_retrieve( cs->sess_hdl, sess, &st ) );
+	if (st == NULL) {
 		/* No attribute saved in the session, just return */
 		return 0;
@@ -268,6 +280,6 @@
 	CHECK_PARAMS( rad_fw && *rad_fw);
 	
-	while (! FD_IS_LIST_EMPTY(list) ) {
-		struct ed_saved_attribute * esa = (struct ed_saved_attribute *)(list->next);
+	while (! FD_IS_LIST_EMPTY(&st->sentinel) ) {
+		struct ed_saved_attribute * esa = (struct ed_saved_attribute *)(st->sentinel.next);
 		
 		fd_list_unlink(&esa->chain);
@@ -280,5 +292,5 @@
 		free(esa);
 	}
-	free(list);
+	free(st);
 
 	return 0;
Index: extensions/app_radgw/rgwx_sip.c
===================================================================
--- extensions/app_radgw/rgwx_sip.c	(revision 1027)
+++ extensions/app_radgw/rgwx_sip.c	(revision 1088)
@@ -134,5 +134,4 @@
 		
 	} dict; /* cache of the dictionary objects we use */
-	struct session_handler * sess_hdl; /* We store RADIUS request authenticator information in the session */
 	char * confstr;
 	//Chained list of nonce
@@ -258,5 +257,4 @@
 	memset(new, 0, sizeof(struct rgwp_config));
 	
-	CHECK_FCT( fd_sess_handler_create( &new->sess_hdl, free, NULL ) );
 	new->confstr = conffile;
 	
@@ -312,6 +310,4 @@
 	CHECK_PARAMS_DO( state, return );
 	
-	CHECK_FCT_DO( fd_sess_handler_destroy( &state->sess_hdl, NULL ),  );
-	
 	nonce_deletelistnonce(state);
 	CHECK_POSIX_DO(pthread_mutex_destroy(&state->nonce_mutex), /*continue*/);
@@ -320,5 +316,4 @@
 	return;
 }
-
 
 /* Handle an incoming RADIUS request */
@@ -717,13 +712,4 @@
 	//fd_msg_dump_walk(1,*diam_fw);
 	
-	/* Store the request identifier in the session */
-	{
-		unsigned char * req_sip;
-		CHECK_MALLOC(req_sip = malloc(16));
-		memcpy(req_sip, &rad_req->hdr->authenticator[0], 16);
-		
-		CHECK_FCT( fd_sess_state_store( cs->sess_hdl, sess, &req_sip ) );
-	}
-	
 	
 	return 0;
@@ -857,7 +843,4 @@
 	}
 	
-	CHECK_FCT( fd_sess_state_retrieve( cs->sess_hdl, sess, &req_sip ) );
-	free(req_sip);
-	
 	return 0;
 }
Index: extensions/app_sip/app_sip.c
===================================================================
--- extensions/app_sip/app_sip.c	(revision 1027)
+++ extensions/app_sip/app_sip.c	(revision 1088)
@@ -50,5 +50,4 @@
 
 struct disp_hdl * app_sip_default_hdl=NULL;
-struct session_handler * ds_sess_hdl;
 
 //configuration stucture
@@ -213,6 +212,4 @@
 		return EINVAL;
 	
-	CHECK_FCT(fd_sess_handler_create(&ds_sess_hdl, free, NULL));
-	
 	//Creation of thread for Registration Termination	
 	if(pthread_create(&rtr_thread, NULL,rtr_socket, NULL))
@@ -238,5 +235,4 @@
 	
 	(void) fd_disp_unregister(&app_sip_MAR_hdl, NULL);
-	CHECK_FCT_DO( fd_sess_handler_destroy(&ds_sess_hdl, NULL),return);
 	
 	
Index: extensions/app_sip/app_sip.h
===================================================================
--- extensions/app_sip/app_sip.h	(revision 1034)
+++ extensions/app_sip/app_sip.h	(revision 1088)
@@ -212,9 +212,4 @@
 #define CODE_SIP_USER_DATA_TYPE	388
 #define CODE_SIP_AOR	122
-
-struct ds_nonce
-{
-	char *nonce;
-};
 
 //Storage for some useful AVPs
Index: extensions/app_sip/multimediaauth.c
===================================================================
--- extensions/app_sip/multimediaauth.c	(revision 639)
+++ extensions/app_sip/multimediaauth.c	(revision 1088)
@@ -36,4 +36,9 @@
 #include "app_sip.h"
 
+struct sess_state
+{
+	char *nonce;
+};
+
 
 int app_sip_MAR_cb( struct msg ** msg, struct avp * paramavp, struct session * sess, void * opaque, enum disp_action * act)
@@ -56,5 +61,5 @@
 	
 	//The nonce we will store and retrieve in session
-	struct ds_nonce *storednonce=NULL;
+	struct sess_state *storednonce=NULL;
 	
 	
@@ -362,6 +367,6 @@
 									
 									//We store the nonce (storednonce structure) inside the session
-									storednonce=malloc(sizeof(struct ds_nonce));
-									memset(storednonce,0,sizeof(struct ds_nonce));
+									storednonce=malloc(sizeof(struct sess_state));
+									memset(storednonce,0,sizeof(struct sess_state));
 									CHECK_MALLOC(storednonce->nonce=malloc(NONCE_SIZE*2+1));
 									memcpy(storednonce->nonce,(char *)nonce,NONCE_SIZE*2+1);
Index: extensions/dbg_interactive/dictionary.i
===================================================================
--- extensions/dbg_interactive/dictionary.i	(revision 979)
+++ extensions/dbg_interactive/dictionary.i	(revision 1088)
@@ -60,5 +60,8 @@
 	}
 	void dump() {
-		fd_dict_dump($self);
+		char * buf = NULL;
+		size_t len;
+		printf("%s", fd_dict_dump(&buf, &len, NULL, $self));
+		free(buf);
 	}
 	PyObject * vendors_list() {
@@ -128,5 +131,8 @@
 %extend dict_object {
 	void dump() {
-		fd_dict_dump_object($self);
+		char * buf = NULL;
+		size_t len;
+		printf("%s", fd_dict_dump_object(&buf, &len, NULL, $self));
+		free(buf);
 	}
 	enum dict_object_type gettype() {
Index: extensions/dbg_interactive/endpoints.i
===================================================================
--- extensions/dbg_interactive/endpoints.i	(revision 978)
+++ extensions/dbg_interactive/endpoints.i	(revision 1088)
@@ -126,5 +126,8 @@
 	
 	void dump() {
-		fd_ep_dump_one( "", $self );
+		char * buf = NULL;
+		size_t len;
+		printf("%s", fd_ep_dump_one(&buf, &len, NULL, $self));
+		free(buf);
 	}
 }
Index: extensions/dbg_interactive/messages.i
===================================================================
--- extensions/dbg_interactive/messages.i	(revision 1078)
+++ extensions/dbg_interactive/messages.i	(revision 1088)
@@ -291,8 +291,8 @@
 	/* Dump */
 	void dump (int tree = 1) {
-		if (tree)
-			fd_msg_dump_walk(0, $self);
-		else
-			fd_msg_dump_one(0, $self);
+		char * buf = NULL;
+		size_t len;
+		printf("%s", fd_msg_dump_treeview(&buf, &len, NULL, $self, NULL, 0, tree));
+		free(buf);
 	}
 	
@@ -570,8 +570,8 @@
 	/* Dump */
 	void dump (int tree = 1) {
-		if (tree)
-			fd_msg_dump_walk(0, $self);
-		else
-			fd_msg_dump_one(0, $self);
+		char * buf = NULL;
+		size_t len;
+		printf("%s", fd_msg_dump_treeview(&buf, &len, NULL, $self, NULL, 0, tree));
+		free(buf);
 	}
 	
Index: extensions/dbg_interactive/sessions.i
===================================================================
--- extensions/dbg_interactive/sessions.i	(revision 1013)
+++ extensions/dbg_interactive/sessions.i	(revision 1088)
@@ -39,6 +39,10 @@
 
 %{
+struct sess_state {
+	PyObject * pystate;
+};
+
 /* call it (might be called from a different thread than the interpreter, when session times out) */
-static void call_the_python_cleanup_callback(session_state * state, os0_t sid, void * cb) {
+static void call_the_python_cleanup_callback(struct sess_state * state, os0_t sid, void * cb) {
 	PyObject *result;
 	if (!cb) {
@@ -67,5 +71,5 @@
 		Py_XINCREF(PyCb);
 		
-		ret = fd_sess_handler_create_internal ( &hdl, call_the_python_cleanup_callback, PyCb );
+		ret = fd_sess_handler_create ( &hdl, call_the_python_cleanup_callback, NULL, PyCb );
 		if (ret != 0) {
 			DI_ERROR(ret, NULL, NULL);
@@ -87,5 +91,8 @@
 	}
 	void dump() {
-		fd_sess_dump_hdl(0, $self);
+		char * buf = NULL;
+		size_t len;
+		printf("%s", fd_sess_dump_hdl(&buf, &len, NULL, $self));
+		free(buf);
 	}
 }
@@ -166,11 +173,16 @@
 	}
 	void dump() {
-		fd_sess_dump(0, $self);
+		char * buf = NULL;
+		size_t len = 0;
+		printf("%s", fd_sess_dump(&buf, &len, NULL, $self, 1) );
+		free(buf);
 	}
 	void store(struct session_handler * handler, PyObject * DISOWN) {
 		int ret;
-		void * store = DISOWN;
+		struct sess_state * st = NULL;
+		st = malloc(sizeof(struct sess_state));
+		st->pystate = DISOWN;
 		Py_XINCREF(DISOWN);
-		ret = fd_sess_state_store_internal(handler, $self, (void *) &store);
+		ret = fd_sess_state_store(handler, $self, (void *) &st);
 		if (ret != 0) {
 			DI_ERROR(ret, NULL, NULL);
@@ -180,14 +192,17 @@
 	PyObject * retrieve(struct session_handler * handler) {
 		int ret;
+		struct sess_state * st = NULL;
 		PyObject * state = NULL;
-		ret = fd_sess_state_retrieve_internal(handler, $self, (void *) &state);
-		if (ret != 0) {
-			DI_ERROR(ret, NULL, NULL);
-			return NULL;
-		}
-		if (state == NULL) {
+		ret = fd_sess_state_retrieve_internal(handler, $self, (void *) &st);
+		if (ret != 0) {
+			DI_ERROR(ret, NULL, NULL);
+			return NULL;
+		}
+		if (st == NULL) {
 			Py_INCREF(Py_None);
 			return Py_None;
 		}
+		state = st->pystate;
+		free(st);
 		return state;
 	}
Index: extensions/dbg_monitor/dbg_monitor.c
===================================================================
--- extensions/dbg_monitor/dbg_monitor.c	(revision 1083)
+++ extensions/dbg_monitor/dbg_monitor.c	(revision 1088)
@@ -78,4 +78,6 @@
 	int i = 0;
 	fd_log_threadname("Monitor thread");
+	char * buf = NULL;
+	size_t len;
 	
 	/* Loop */
@@ -111,5 +113,5 @@
 			struct peer_hdr * p = (struct peer_hdr *)li->o;
 			
-			fd_peer_dump(p, NONE);
+			TRACE_DEBUG(INFO, "%s", fd_peer_dump(&buf, &len, NULL, p, 1));
 			
 			CHECK_FCT_DO( fd_stat_getstats(STAT_P_PSM, p, &current_count, &limit_count, &highest_count, &total_count, &total, &blocking, &last), );
@@ -123,8 +125,11 @@
 		CHECK_FCT_DO( pthread_rwlock_unlock(&fd_g_peers_rw), /* continue */ );
 		
-		CHECK_FCT_DO(fd_event_send(fd_g_config->cnf_main_ev, FDEV_DUMP_SERV, 0, NULL), /* continue */);
+		TRACE_DEBUG(INFO, "[dbg_monitor] Dumping servers information");
+		TRACE_DEBUG(INFO, "%s", fd_servers_dump(&buf, &len, NULL));
+		
 		sleep(1);
 	}
 	
+	free(buf);
 	return NULL;
 }
@@ -133,8 +138,13 @@
 static void got_sig()
 {
-	fd_log_debug("[dbg_monitor] Dumping extra information");
-	CHECK_FCT_DO(fd_event_send(fd_g_config->cnf_main_ev, FDEV_DUMP_DICT, 0, NULL), /* continue */);
-	CHECK_FCT_DO(fd_event_send(fd_g_config->cnf_main_ev, FDEV_DUMP_CONFIG, 0, NULL), /* continue */);
-	CHECK_FCT_DO(fd_event_send(fd_g_config->cnf_main_ev, FDEV_DUMP_EXT, 0, NULL), /* continue */);
+	char * buf = NULL;
+	size_t len;
+	TRACE_DEBUG(INFO, "[dbg_monitor] Dumping config information");
+	TRACE_DEBUG(INFO, "%s", fd_conf_dump(&buf, &len, NULL));
+	TRACE_DEBUG(INFO, "[dbg_monitor] Dumping extensions information");
+	TRACE_DEBUG(INFO, "%s", fd_ext_dump(&buf, &len, NULL));
+	TRACE_DEBUG(INFO, "[dbg_monitor] Dumping dictionary information");
+	TRACE_DEBUG(INFO, "%s", fd_dict_dump(&buf, &len, NULL, fd_g_config->cnf_dict));
+	free(buf);
 }
 
Index: extensions/dict_legacy_xml/dict_lxml_xml.c
===================================================================
--- extensions/dict_legacy_xml/dict_lxml_xml.c	(revision 974)
+++ extensions/dict_legacy_xml/dict_lxml_xml.c	(revision 1088)
@@ -1809,7 +1809,4 @@
 	
 	TRACE_DEBUG(FULL, "Conversion from '%s' to freeDiameter internal format complete.", xmlfilename);
-	if (TRACE_BOOL(ANNOYING)) {
-		fd_dict_dump(fd_g_config->cnf_dict);
-	}
 	
 	/* Done */
Index: extensions/test_app/ta_cli.c
===================================================================
--- extensions/test_app/ta_cli.c	(revision 930)
+++ extensions/test_app/ta_cli.c	(revision 1088)
@@ -46,5 +46,5 @@
 static struct session_handler * ta_cli_reg = NULL;
 
-struct ta_mess_info {
+struct sess_state {
 	int32_t		randval;	/* a random value to store in Test-AVP */
 	struct timespec ts;		/* Time of sending the message */
@@ -54,5 +54,5 @@
 static void ta_cb_ans(void * data, struct msg ** msg)
 {
-	struct ta_mess_info * mi = NULL;
+	struct sess_state * mi = NULL;
 	struct timespec ts;
 	struct session * sess;
@@ -177,5 +177,5 @@
 	struct avp * avp;
 	union avp_value val;
-	struct ta_mess_info * mi = NULL, *svg;
+	struct sess_state * mi = NULL, *svg;
 	struct session *sess = NULL;
 	
@@ -191,5 +191,5 @@
 	
 	/* Create the random value to store with the session */
-	mi = malloc(sizeof(struct ta_mess_info));
+	mi = malloc(sizeof(struct sess_state));
 	if (mi == NULL) {
 		fd_log_debug("malloc failed: %s", strerror(errno));
@@ -265,5 +265,5 @@
 int ta_cli_init(void)
 {
-	CHECK_FCT( fd_sess_handler_create(&ta_cli_reg, free, NULL) );
+	CHECK_FCT( fd_sess_handler_create(&ta_cli_reg, (void *)free, NULL, NULL) );
 	
 	CHECK_FCT( fd_event_trig_regcb(ta_conf->signal, "test_app.cli", ta_cli_test_message ) );
Index: extensions/test_sip/test_sip.c
===================================================================
--- extensions/test_sip/test_sip.c	(revision 972)
+++ extensions/test_sip/test_sip.c	(revision 1088)
@@ -54,5 +54,4 @@
 
 struct disp_hdl * test_sip_default_hdl=NULL;
-struct session_handler * ts_sess_hdl;
 
 //configuration stucture
@@ -214,5 +213,4 @@
 	*/
 	
-	CHECK_FCT(fd_sess_handler_create(&ts_sess_hdl, free, NULL));
 	//CHECK_FCT( fd_event_trig_regcb(30, "test_sip", (void *)test_sipSL_LIR_cb ) );
 	CHECK_FCT( fd_event_trig_regcb(30, "test_sip", (void *)test_sip_SAR_cb ) );
Index: freeDiameterd/main.c
===================================================================
--- freeDiameterd/main.c	(revision 1081)
+++ freeDiameterd/main.c	(revision 1088)
@@ -210,5 +210,5 @@
 				
 			case 'd':	/* Increase verbosity of debug messages.  */
-				fd_g_debug_lvl++;
+				fd_g_debug_lvl--;
 				break;
 				
@@ -236,5 +236,5 @@
 				
 			case 'q':	/* Decrease verbosity then remove debug messages.  */
-				fd_g_debug_lvl--;
+				fd_g_debug_lvl++;
 				break;
 
Index: include/freeDiameter/libfdcore.h
===================================================================
--- include/freeDiameter/libfdcore.h	(revision 1085)
+++ include/freeDiameter/libfdcore.h	(revision 1088)
@@ -803,4 +803,5 @@
 int fd_event_trig_regcb(int trigger_val, const char * module, void (*cb)(void));
 
+#ifndef SWIG
 DECLARE_FD_DUMP_PROTOTYPE(fd_event_trig_dump);
 
@@ -808,7 +809,8 @@
 DECLARE_FD_DUMP_PROTOTYPE(fd_conf_dump);
 DECLARE_FD_DUMP_PROTOTYPE(fd_ext_dump);
+DECLARE_FD_DUMP_PROTOTYPE(fd_servers_dump);
+#endif /* SWIG */
 DECLARE_FD_DUMP_PROTOTYPE(fd_peer_dump_list, int details);
 DECLARE_FD_DUMP_PROTOTYPE(fd_peer_dump, struct peer_hdr * p, int details);
-DECLARE_FD_DUMP_PROTOTYPE(fd_servers_dump);
 
 /*============================================================*/
Index: include/freeDiameter/libfdproto.h
===================================================================
--- include/freeDiameter/libfdproto.h	(revision 1087)
+++ include/freeDiameter/libfdproto.h	(revision 1088)
@@ -222,6 +222,7 @@
 
 
-/* Helper function for the *dump functions that add into a buffer */
+/* Helper functions for the *dump functions that add into a buffer */
 char * fd_dump_extend(char ** buf, size_t *len, size_t *offset, const char * format, ... ) _ATTRIBUTE_PRINTFLIKE_(4,5);
+char * fd_dump_extend_hexdump(char ** buf, size_t *len, size_t *offset, uint8_t *data, size_t datalen, size_t trunc, size_t wrap );
 
 /* All dump functions follow the same prototype:
@@ -1817,7 +1818,7 @@
 
 /* The state information that a module associate with a session -- each module defines its own data format */
-typedef void session_state;
-
-typedef DECLARE_FD_DUMP_PROTOTYPE(session_state_dump, session_state * st);
+struct sess_state; /* declare this in your own extension */
+
+typedef DECLARE_FD_DUMP_PROTOTYPE((*session_state_dump), struct sess_state * st);
 
 /* The following function must be called to activate the session expiry mechanism */
@@ -1843,8 +1844,5 @@
  *  ENOMEM	: Not enough memory to complete the operation
  */
-int fd_sess_handler_create_internal ( struct session_handler ** handler, void (*cleanup)(session_state * state, os0_t sid, void * opaque), session_state_dump dumper, void * opaque );
-/* Macro to avoid casting everywhere */
-#define fd_sess_handler_create( _handler, _cleanup, _dumper, _opaque ) \
-	fd_sess_handler_create_internal( (_handler), (void (*)(session_state *, os0_t, void *))(_cleanup), _dumper, (void *)(_opaque) )
+int fd_sess_handler_create ( struct session_handler ** handler, void (*cleanup)(struct sess_state * state, os0_t sid, void * opaque), session_state_dump dumper, void * opaque );
 
 	
@@ -2018,7 +2016,5 @@
  *  ENOMEM	: Not enough memory to complete the operation
  */
-int fd_sess_state_store_internal ( struct session_handler * handler, struct session * session, session_state ** state );
-#define fd_sess_state_store( _handler, _session, _state ) \
-	fd_sess_state_store_internal( (_handler), (_session), (void *)(_state) )
+int fd_sess_state_store ( struct session_handler * handler, struct session * session, struct sess_state ** state );
 
 /*
@@ -2040,7 +2036,5 @@
  *  EINVAL 	: A parameter is invalid.
  */
-int fd_sess_state_retrieve_internal ( struct session_handler * handler, struct session * session, session_state ** state ); 
-#define fd_sess_state_retrieve( _handler, _session, _state ) \
-	fd_sess_state_retrieve_internal( (_handler), (_session), (void *)(_state) )
+int fd_sess_state_retrieve ( struct session_handler * handler, struct session * session, struct sess_state ** state ); 
 
 
Index: libfdproto/fdproto-internal.h
===================================================================
--- libfdproto/fdproto-internal.h	(revision 1085)
+++ libfdproto/fdproto-internal.h	(revision 1088)
@@ -48,7 +48,4 @@
 void fd_sess_fini(void);
 
-/* Where debug messages are sent */
-extern FILE * fd_g_debug_fstr;
-
 /* Iterator on the rules of a parent object */
 int fd_dict_iterate_rules ( struct dict_object *parent, void * data, int (*cb)(void *, struct dict_rule_data *) );
Index: libfdproto/init.c
===================================================================
--- libfdproto/init.c	(revision 974)
+++ libfdproto/init.c	(revision 1088)
@@ -58,7 +58,4 @@
 	}
 	
-	/* Set the debug stream */
-	fd_g_debug_fstr = stdout;
-	
 	/* Initialize the modules that need it */
 	fd_msg_eteid_init();
Index: libfdproto/log.c
===================================================================
--- libfdproto/log.c	(revision 1085)
+++ libfdproto/log.c	(revision 1088)
@@ -38,9 +38,7 @@
 #include <stdarg.h>
 
-FILE * fd_g_debug_fstr;
-
 pthread_mutex_t fd_log_lock = PTHREAD_MUTEX_INITIALIZER;
 pthread_key_t	fd_log_thname;
-int fd_g_debug_lvl = INFO;
+int fd_g_debug_lvl = FD_LOG_NOTICE;
 
 static void fd_internal_logger( int, const char *, va_list );
@@ -88,14 +86,14 @@
 
 
-static void fd_internal_logger( int loglevel, const char *format, va_list ap )
+static void fd_internal_logger( int printlevel, const char *format, va_list ap )
 {
     char buf[25];
-    FILE *fstr = fd_g_debug_fstr ?: stdout;
-    int local_use_color = 0;
-
-    /* logging has been decided by macros outside already */
+
+    /* Do we need to trace this ? */
+    if (printlevel < fd_g_debug_lvl)
+    	return;
 
     /* add timestamp */
-    fprintf(fstr, "%s  ", fd_log_time(NULL, buf, sizeof(buf)));
+    printf("%s  ", fd_log_time(NULL, buf, sizeof(buf)));
     
     /* Use colors on stdout ? */
@@ -107,20 +105,18 @@
     }
     
-    /* now, this time log, do we use colors? */
-    if ((fstr == stdout) && (use_colors == 1))
-	    local_use_color = 1;
+    switch(printlevel) {
+	    case FD_LOG_ANNOYING:  printf("%s	A   ", (use_colors == 1) ? "\e[0;37m" : ""); break;
+	    case FD_LOG_DEBUG:     printf("%s DBG   ", (use_colors == 1) ? "\e[0;37m" : ""); break;
+	    case FD_LOG_NOTICE:    printf("%sNOTI   ", (use_colors == 1) ? "\e[1;37m" : ""); break;
+	    case FD_LOG_ERROR:     printf("%sERROR  ", (use_colors == 1) ? "\e[0;31m" : ""); break;
+	    case FD_LOG_FATAL:     printf("%sFATAL! ", (use_colors == 1) ? "\e[0;31m" : ""); break;
+	    default:               printf("%s ???   ", (use_colors == 1) ? "\e[0;31m" : "");
+    }
+    vprintf(format, ap);
+    if (use_colors == 1)
+	     printf("\e[00m");
+    printf("\n");
     
-    switch(loglevel) {
-	    case FD_LOG_DEBUG:  fprintf(fstr, "%s DBG   ", local_use_color ? "\e[0;37m" : ""); break;
-	    case FD_LOG_NOTICE: fprintf(fstr, "%sNOTI   ", local_use_color ? "\e[1;37m" : ""); break;
-	    case FD_LOG_ERROR:  fprintf(fstr, "%sERROR  ", local_use_color ? "\e[0;31m" : ""); break;
-	    default:            fprintf(fstr, "%s ???   ", local_use_color ? "\e[0;31m" : "");
-    }
-    vfprintf(fstr, format, ap);
-    if (local_use_color)
-	     fprintf(fstr, "\e[00m");
-    fprintf(fstr, "\n");
-    
-    fflush(fstr);
+    fflush(stdout);
 }
 
@@ -212,4 +208,16 @@
 
 
+static size_t sys_mempagesz = 0;
+
+static size_t get_mempagesz(void) {
+	if (!sys_mempagesz) {
+		sys_mempagesz = sysconf(_SC_PAGESIZE); /* We alloc buffer by memory pages for efficiency */
+		if (sys_mempagesz <= 0)
+			sys_mempagesz = 1024; /* default size if above call failed */
+	}
+	return sys_mempagesz;
+}
+
+
 /* Helper function for fd_*_dump. Prints the format string from 'offset' into '*buf', extends if needed. The location of buf can be updated by this function. */
 char * fd_dump_extend(char ** buf, size_t *len, size_t *offset, const char * format, ... )
@@ -218,11 +226,5 @@
 	int to_write;
 	size_t o = 0;
-	static size_t mempagesz = 0;
-	
-	if (!mempagesz) {
-		mempagesz = sysconf(_SC_PAGESIZE); /* We alloc buffer by memory pages for efficiency */
-		if (mempagesz <= 0)
-			mempagesz = 1024; /* default size if above call failed */
-	}
+	size_t mempagesz = get_mempagesz();
 	
 	/* we do not TRACE_ENTRY this one on purpose */
@@ -258,2 +260,60 @@
 	return *buf;
 }
+
+char * fd_dump_extend_hexdump(char ** buf, size_t *len, size_t *offset, uint8_t *data, size_t datalen, size_t trunc, size_t wrap )
+{
+	int truncated = 0;
+	size_t towrite = 0;
+	size_t o = 0;
+	int i;
+	char * p;
+	size_t mempagesz = get_mempagesz();
+#define TRUNK_MARK "[...]"
+
+	CHECK_PARAMS_DO(buf && len && data, return NULL);
+	
+	if (trunc && (datalen > trunc)) {
+		datalen = trunc;
+		truncated = 1;
+	}
+	
+	towrite = datalen * 2;
+	
+	if (wrap)
+		towrite += datalen / wrap; /* add 1 '\n' every wrap byte */
+	
+	if (truncated)
+		towrite += CONSTSTRLEN(TRUNK_MARK);
+	
+	
+	if (offset)
+		o = *offset;
+	
+	if (*buf == NULL) {
+		/* Directly allocate the size we need */
+		*len = (((towrite + o) / mempagesz) + 1 ) * mempagesz;
+		CHECK_MALLOC_DO(*buf = malloc(*len), return NULL);
+	} else if ((towrite + o) >= *len) {
+		/* There is no room in the buffer, we extend and redo */
+		size_t new_len = (((towrite + o) / mempagesz) + 1) * mempagesz;
+		CHECK_MALLOC_DO(*buf = realloc(*buf, new_len), return NULL);
+		*len = new_len;
+	}
+	
+	p = *buf + o;
+	for (i = 0; i < datalen; i++) {
+		sprintf(p, "%2hhX", data[i]);
+		p+=2;
+		if ((wrap) && ((i+1) % wrap == 0)) {
+			*p++='\n'; *p ='\0'; /* we want to ensure the buffer is always 0-terminated */
+		}
+	}
+	
+	if (truncated)
+		memcpy(p, TRUNK_MARK, CONSTSTRLEN(TRUNK_MARK));
+		
+	if (offset)
+		*offset += towrite;
+	
+	return *buf;
+}
Index: libfdproto/sessions.c
===================================================================
--- libfdproto/sessions.c	(revision 1085)
+++ libfdproto/sessions.c	(revision 1088)
@@ -69,6 +69,6 @@
 	int		  eyec;	/* An eye catcher also used to ensure the object is valid, must be SH_EYEC */
 	int		  id;	/* A unique integer to identify this handler */
-	void 		(*cleanup)(session_state *, os0_t, void *); /* The cleanup function to be called for cleaning a state */
-	session_state_dump *state_dump; /* dumper function */
+	void 		(*cleanup)(struct sess_state *, os0_t, void *); /* The cleanup function to be called for cleaning a state */
+	session_state_dump state_dump; /* dumper function */
 	void             *opaque; /* a value that is passed as is to the cleanup callback */
 };
@@ -81,5 +81,5 @@
 struct state {
 	int			 eyec;	/* Must be SD_EYEC */
-	session_state		*state;	/* The state registered by the application, never NULL (or the whole object is deleted) */
+	struct sess_state	*state;	/* The state registered by the application, never NULL (or the whole object is deleted) */
 	struct fd_list		 chain;	/* Chaining in the list of session's states ordered by hdl->id */
 	union {
@@ -274,5 +274,5 @@
 
 /* Create a new handler */
-int fd_sess_handler_create_internal ( struct session_handler ** handler, void (*cleanup)(session_state *, os0_t, void *), session_state_dump dumper, void * opaque )
+int fd_sess_handler_create ( struct session_handler ** handler, void (*cleanup)(struct sess_state *, os0_t, void *), session_state_dump dumper, void * opaque )
 {
 	struct session_handler *new;
@@ -720,5 +720,5 @@
 
 /* Save a state information with a session */
-int fd_sess_state_store_internal ( struct session_handler * handler, struct session * session, session_state ** state )
+int fd_sess_state_store ( struct session_handler * handler, struct session * session, struct sess_state ** state )
 {
 	struct state *new;
@@ -773,5 +773,5 @@
 
 /* Get the data back */
-int fd_sess_state_retrieve_internal ( struct session_handler * handler, struct session * session, session_state ** state )
+int fd_sess_state_retrieve ( struct session_handler * handler, struct session * session, struct sess_state ** state )
 {
 	struct fd_list * li;
Index: tests/testcnx.c
===================================================================
--- tests/testcnx.c	(revision 974)
+++ tests/testcnx.c	(revision 1088)
@@ -715,5 +715,5 @@
 		/* For debug: dump the object */
 		fd_log_debug("Dumping CER");
-		fd_msg_dump_walk(0, cer);
+		fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, cer, fd_g_config->cnf_dict, 0, 1));
 		#endif
 		
Index: tests/testdict.c
===================================================================
--- tests/testdict.c	(revision 788)
+++ tests/testdict.c	(revision 1088)
@@ -192,5 +192,5 @@
 		CHECK(1, obj ? 1 : 0 );
 #if 1
-		fd_dict_dump_object(obj);
+		fd_log_debug("%s", fd_dict_dump_object(FD_DUMP_TEST_PARAMS, obj));
 #endif
 		CHECK( 0, fd_dict_delete(obj) );
Index: tests/testdisp.c
===================================================================
--- tests/testdisp.c	(revision 1018)
+++ tests/testdisp.c	(revision 1088)
@@ -699,5 +699,5 @@
 		
 		#if 0
-		fd_conf_dump();
+		fd_log_debug("%s", fd_conf_dump(FD_DUMP_TEST_PARAMS));
 		#endif
 	}
Index: tests/testfifo.c
===================================================================
--- tests/testfifo.c	(revision 1071)
+++ tests/testfifo.c	(revision 1088)
@@ -559,6 +559,4 @@
 		CHECK( 14, iter );
 		
-		/* fd_fifo_dump(0, "test", queue, NULL); */
-		
 		for (; i < td.nbr; i++) {
 			CHECK( 0, fd_fifo_tryget(queue, &item) );
Index: tests/testmesg.c
===================================================================
--- tests/testmesg.c	(revision 1047)
+++ tests/testmesg.c	(revision 1088)
@@ -61,6 +61,6 @@
 		#if 0
 		/* For debug: dump the object */
-		fd_log_debug("Dumping Accounting-Request empty message");
-		fd_msg_dump_walk( 0, acr );
+		fd_log_debug("Dumping Accounting-Request empty message:");
+		fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, acr, fd_g_config->cnf_dict, 0, 1));
 		#endif
 	}
@@ -79,7 +79,7 @@
 		/* For debug: dump the object */
 		fd_log_debug("Dumping Proxy-Info AVP");
-		fd_msg_dump_walk(0, pi);
+		fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, pi, fd_g_config->cnf_dict, 0, 1));
 		fd_log_debug("Dumping dictionary model");
-		fd_dict_dump_object(pi_model);
+		fd_log_debug("%s", fd_dict_dump_object(FD_DUMP_TEST_PARAMS, pi_model));
 		#endif
 		
@@ -107,5 +107,5 @@
 		/* For debug: dump the object */
 		fd_log_debug("Dumping Accounting-Request with Proxy-Info AVP at the end");
-		fd_msg_dump_walk(0, acr);
+		fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, acr, fd_g_config->cnf_dict, 0, 1));
 		#endif
 	}
@@ -306,10 +306,10 @@
 						*/
 			#if 0
-			fd_dict_dump_object ( gavp );
+			fd_log_debug("%s", fd_dict_dump_object(FD_DUMP_TEST_PARAMS, gavp));
 			#endif
 		}
 		#if 0
 		{
-			fd_dict_dump_object ( vendor );
+			fd_log_debug("%s", fd_dict_dump_object(FD_DUMP_TEST_PARAMS, vendor));
 		}
 		#endif
@@ -365,5 +365,5 @@
 			#if 0
 			fd_log_debug("AVP no vendor, value 3.1415:");
-			fd_msg_dump_one(0, avpi);
+			fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, avpi, fd_g_config->cnf_dict, 0, 0));
 			#endif
 			CHECK( 0, fd_msg_avp_hdr ( avpi, &avpdata ) );
@@ -382,5 +382,5 @@
 			#if 0
 			fd_log_debug("AVP vendor, value 0x123456789abcdeL:");
-			fd_msg_dump_one(0, avpi);
+			fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, avpi, fd_g_config->cnf_dict, 0, 0));
 			#endif
 			CHECK( 0, fd_msg_avp_hdr ( avpi, &avpdata ) );
@@ -408,5 +408,5 @@
 				#if 0
 				fd_log_debug("AVP enum i32, value 2 (from const):");
-				fd_msg_dump_one(0, avpi);
+				fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, avpi, fd_g_config->cnf_dict, 0, 0));
 				#endif
 			}
@@ -429,5 +429,5 @@
 				#if 0
 				fd_log_debug("AVP enum i32, value -5 (from const):");
-				fd_msg_dump_one(0, avpi);
+				fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, avpi, fd_g_config->cnf_dict, 0, 0));
 				#endif
 				/* Check the size is correct ( 12 for header + 4 for value ) */
@@ -444,5 +444,5 @@
 			#if 0
 			fd_log_debug("AVP vendor enum i32, value -10 (not const):");
-			fd_msg_dump_one(0, avpi);
+			fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, avpi, fd_g_config->cnf_dict, 0, 0));
 			#endif
 			
@@ -459,5 +459,5 @@
 				#if 0
 				fd_log_debug("AVP octet string, 'This\\0 is a b...'");
-				fd_msg_dump_one(0, avpi);
+				fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, avpi, fd_g_config->cnf_dict, 0, 0));
 				#endif
 				CHECK( 0, fd_msg_avp_hdr ( avpi, &avpdata ) );
@@ -488,5 +488,5 @@
 				#if 0
 				fd_log_debug("AVP Enumuerated OctetString (from const):");
-				fd_msg_dump_one(0, avpi);
+				fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, avpi, fd_g_config->cnf_dict, 0, 0));
 				#endif
 				/* Check the size is correct ( 12 for header + 5 for value ) */
@@ -513,5 +513,5 @@
 				#if 0
 				fd_log_debug("AVP Enumuerated OctetString (from const):");
-				fd_msg_dump_one(0, avpi);
+				fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, avpi, fd_g_config->cnf_dict, 0, 0));
 				#endif
 				/* Check the size is correct ( 12 for header + 3 for value ) */
@@ -535,5 +535,5 @@
 				#if 0
 				fd_log_debug("AVP octet string, '1234678'");
-				fd_msg_dump_one(0, avpch);
+				fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, avpch, fd_g_config->cnf_dict, 0, 0));
 				#endif
 				CHECK( 0, fd_msg_update_length ( avpch ) );
@@ -548,5 +548,5 @@
 				#if 0
 				fd_log_debug("AVP octet string, '12346789'");
-				fd_msg_dump_one(0, avpch);
+				fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, avpch, fd_g_config->cnf_dict, 0, 0));
 				#endif
 			  }
@@ -580,5 +580,5 @@
 			CHECK( 0, fd_msg_update_length ( msg ) );
 			#if 0
-			fd_msg_dump_walk(0, msg);
+			fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, msg, fd_g_config->cnf_dict, 0, 1));
 			#endif
 			CHECK( 344, msgdata->msg_length );
@@ -660,5 +660,5 @@
 			CHECK( 0, fd_msg_parse_buffer( &buf_cpy, 344, &msg) );
 			#if 0
-			fd_msg_dump_walk(0, msg);
+			fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, msg, fd_g_config->cnf_dict, 0, 1));
 			#endif
 			
@@ -733,5 +733,5 @@
 				
 				#if 0
-				fd_msg_dump_walk(0, msg);
+				fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, msg, fd_g_config->cnf_dict, 0, 1));
 				#endif
 				
@@ -769,5 +769,5 @@
 				CHECK( 0, fd_msg_bufferize( msg, &buftmp, NULL ) );				
 				
-				fd_msg_dump_walk(0, msg);
+				fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, msg, fd_g_config->cnf_dict, 0, 1));
 				
 				TODO("Check the Failed-AVP is as expected");
@@ -783,5 +783,5 @@
 			CHECK( 0, fd_msg_parse_dict( msg, fd_g_config->cnf_dict, NULL ) );
 			#if 0
-			fd_msg_dump_walk(0, msg);
+			fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, msg, fd_g_config->cnf_dict, 0, 1));
 			#endif
 		}
@@ -1336,5 +1336,5 @@
 			/* Okay, now delete the message and parse the buffer, then check we obtain the same values back */
 			#if 0
-			fd_msg_dump_walk(0, msg);
+			fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, msg, fd_g_config->cnf_dict, 0, 1));
 			#endif
 			CHECK( 0, fd_msg_free( msg ) );
@@ -1343,5 +1343,5 @@
 			CHECK( 0, fd_msg_parse_dict( msg, fd_g_config->cnf_dict, NULL ) );
 			#if 0
-			fd_msg_dump_walk(0, msg);
+			fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, msg, fd_g_config->cnf_dict, 0, 1));
 			#endif
 			
Index: tests/testmesg_stress.c
===================================================================
--- tests/testmesg_stress.c	(revision 1076)
+++ tests/testmesg_stress.c	(revision 1088)
@@ -197,13 +197,5 @@
 				< grouped >
 						*/
-			#if 0
-			fd_dict_dump_object ( gavp );
-			#endif
-		}
-		#if 0
-		{
-			fd_dict_dump_object ( vendor );
-		}
-		#endif
+		}
 	}
 	
Index: tests/testpeers.c
===================================================================
--- tests/testpeers.c	(revision 748)
+++ tests/testpeers.c	(revision 1088)
@@ -57,5 +57,5 @@
 		}
 	}
-	fd_peer_dump_list(0);
+	fd_log_debug("%s", fd_peer_dump_list(FD_DUMP_TEST_PARAMS, 0));
 	/* Check we are able to find again any of these */
 	{
Index: tests/tests.h
===================================================================
--- tests/tests.h	(revision 1078)
+++ tests/tests.h	(revision 1088)
@@ -68,6 +68,7 @@
 /* Define the macro to fail a test with a message */
 #define FAILTEST( message... ){				\
-	TRACE_ERROR(message);				\
-	TRACE_ERROR("FAILED: %s ", __STRIPPED_FILE__);	\
+	LOG_F(message);					\
+	LOG_F("FAILED: %s ", __STRIPPED_FILE__);	\
+	free(tbuf);					\
 	exit(FAIL);					\
 }
@@ -75,22 +76,26 @@
 /* Define the macro to pass a test */
 #define PASSTEST( ){					\
-	TRACE_NOTICE("PASS: %s", __STRIPPED_FILE__);	\
+	LOG_N("PASS: %s", __STRIPPED_FILE__);		\
 	(void)fd_core_shutdown();			\
 	(void)fd_core_wait_shutdown_complete();		\
 	(void)fd_thr_term(&signal_thr);			\
+	free(tbuf);					\
 	exit(PASS);					\
 }
 
-static int test_verbo = 0;
 static struct fd_config conf;
 extern struct fd_config * fd_g_config;
 
+/* for dumps */
+static char * tbuf = NULL; size_t tbuflen = 0;
+#define FD_DUMP_TEST_PARAMS &tbuf, &tbuflen, NULL
+
+
 /* Define the standard check routines */
 #define CHECK( _val, _assert ){				\
-	if (test_verbo > 0) {				\
-		TRACE_NOTICE("CHECK( %s == %s )",	\
+	LOG_D("CHECK( %s == %s )",			\
 				#_assert,		\
 				#_val);			\
-	}{						\
+	{						\
 	__typeof__ (_val) __ret = (_assert);		\
 	if (__ret != (_val)) {				\
@@ -143,9 +148,9 @@
 		switch (c) {
 			case 'd':	/* Increase verbosity of debug messages.  */
-				test_verbo++;
+				fd_g_debug_lvl--;
 				break;
 				
 			case 'q':	/* Decrease verbosity.  */
-				test_verbo--;
+				fd_g_debug_lvl++;
 				break;
 			
@@ -178,5 +183,4 @@
 		}
 	}
-	fd_g_debug_lvl = (test_verbo > 0) ? (test_verbo - 1) : 0;
 	if (!no_timeout) {
 		alarm(TEST_TIMEOUT);
Index: tests/testsess.c
===================================================================
--- tests/testsess.c	(revision 888)
+++ tests/testsess.c	(revision 1088)
@@ -43,5 +43,5 @@
 
 #define TEST_EYEC	0x7e57e1ec
-struct mystate {
+struct sess_state {
 	int	eyec;	/* TEST_EYEC */
 	os0_t   sid; 	/* the session with which the data was registered */
@@ -50,5 +50,5 @@
 };
 
-static void mycleanup( struct mystate * data, os0_t sid, void * opaque )
+static void mycleanup( struct sess_state * data, os0_t sid, void * opaque )
 {
 	/* sanity */
@@ -67,10 +67,10 @@
 }
 
-static __inline__ struct mystate * new_state(os0_t sid, int *freed) 
+static __inline__ struct sess_state * new_state(os0_t sid, int *freed) 
 {
-	struct mystate *new;
-	new = malloc(sizeof(struct mystate));
+	struct sess_state *new;
+	new = malloc(sizeof(struct sess_state));
 	CHECK( 1, new ? 1 : 0 );
-	memset(new, 0, sizeof(struct mystate));
+	memset(new, 0, sizeof(struct sess_state));
 	new->eyec = TEST_EYEC;
 	new->sid = os0dup(sid, strlen((char *)sid));
@@ -106,12 +106,12 @@
 	{
 		void * testptr = NULL;
-		CHECK( 0, fd_sess_handler_create ( &hdl1, mycleanup, NULL ) );
-		CHECK( 0, fd_sess_handler_create ( &hdl2, mycleanup, NULL ) );
+		CHECK( 0, fd_sess_handler_create ( &hdl1, mycleanup, NULL, NULL ) );
+		CHECK( 0, fd_sess_handler_create ( &hdl2, mycleanup, NULL, NULL ) );
 		CHECK( 0, fd_sess_handler_destroy( &hdl2, &testptr ) );
 		CHECK( 1, testptr == NULL ? 1 : 0 );
-		CHECK( 0, fd_sess_handler_create ( &hdl2, mycleanup, g_opaque ) );
-		#if 0
-		fd_sess_dump_hdl(0, hdl1);
-		fd_sess_dump_hdl(0, hdl2);
+		CHECK( 0, fd_sess_handler_create ( &hdl2, mycleanup, NULL, g_opaque ) );
+		#if 0
+		fd_log_debug("%s\n", fd_sess_dump_hdl(FD_DUMP_TEST_PARAMS, hdl1));
+		fd_log_debug("%s\n", fd_sess_dump_hdl(FD_DUMP_TEST_PARAMS, hdl2));
 		#endif
 	}
@@ -123,6 +123,6 @@
 		CHECK( 0, fd_sess_new( &sess2, TEST_DIAM_ID, CONSTSTRLEN(TEST_DIAM_ID), NULL, 0 ) );
 		#if 0
-		fd_sess_dump(0, sess1);
-		fd_sess_dump(0, sess2);
+		fd_log_debug("%s\n", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess1, 1));
+		fd_log_debug("%s\n", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess2, 1));
 		#endif
 		
@@ -141,6 +141,6 @@
 		CHECK( 0, fd_sess_new( &sess2, TEST_DIAM_ID, CONSTSTRLEN(TEST_DIAM_ID), TEST_OPT, CONSTSTRLEN(TEST_OPT_IN) - 1 ) );
 		#if 0
-		fd_sess_dump(0, sess1);
-		fd_sess_dump(0, sess2);
+		fd_log_debug("%s\n", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess1, 1));
+		fd_log_debug("%s\n", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess2, 1));
 		#endif
 		
@@ -165,6 +165,6 @@
 		CHECK( 0, fd_sess_new( &sess2, NULL, 0, TEST_SID, CONSTSTRLEN(TEST_SID_IN) - 1 ) );
 		#if 0
-		fd_sess_dump(0, sess1);
-		fd_sess_dump(0, sess2);
+		fd_log_debug("%s\n", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess1, 1));
+		fd_log_debug("%s\n", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess2, 1));
 		#endif
 		CHECK( 0, fd_sess_getsid(sess1, &str1, &str1len) );
@@ -211,5 +211,5 @@
 	/* Test fd_sess_reclaim */
 	{
-		struct mystate *tms;
+		struct sess_state *tms;
 		
 		CHECK( 0, fd_sess_fromsid( TEST_SID, CONSTSTRLEN(TEST_SID_IN), &sess1, &new ) );
@@ -271,5 +271,5 @@
 	/* Test states operations */
 	{
-		struct mystate * ms[6], *tms;
+		struct sess_state * ms[6], *tms;
 		int freed[6];
 		struct timespec timeout;
@@ -295,5 +295,5 @@
 		
 		#if 0
-		fd_sess_dump(0, sess1);
+		fd_log_debug("%s\n", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess1, 1));
 		#endif
 		
@@ -332,7 +332,7 @@
 		
 		#if 0
-		fd_sess_dump(0, sess1);
-		fd_sess_dump(0, sess2);
-		fd_sess_dump(0, sess3);
+		fd_log_debug("%s\n", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess1, 1));
+		fd_log_debug("%s\n", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess2, 1));
+		fd_log_debug("%s\n", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess3, 1));
 		#endif
 		
@@ -357,6 +357,6 @@
 		
 		#if 1
-		fd_sess_dump(0, sess1);
-		fd_sess_dump(0, sess2);
+		fd_log_debug("%s\n", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess1, 1));
+		fd_log_debug("%s\n", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess2, 1));
 		#endif
 		
@@ -373,6 +373,6 @@
 		CHECK( 0, fd_sess_settimeout( sess2, &timeout) );
 		#if 1
-		fd_sess_dump(0, sess1);
-		fd_sess_dump(0, sess2);
+		fd_log_debug("%s\n", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess1, 1));
+		fd_log_debug("%s\n", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess2, 1));
 		#endif
 		timeout.tv_sec = 0;
