Index: extensions/dbg_interactive/dbg_interactive.c
===================================================================
--- extensions/dbg_interactive/dbg_interactive.c	(revision 625)
+++ extensions/dbg_interactive/dbg_interactive.c	(revision 639)
@@ -67,6 +67,8 @@
 	
 end:	
-	/* Upon exit, issue the order of terminating to fD */
-	CHECK_FCT_DO(fd_event_send(fd_g_config->cnf_main_ev, FDEV_TERMINATE, 0, NULL), );
+	/* Upon exit, issue the order of terminating to fD, if the interpreter was started without a file */
+	if (!arg) {
+		CHECK_FCT_DO(fd_event_send(fd_g_config->cnf_main_ev, FDEV_TERMINATE, 0, NULL), );
+	}
 
 	return NULL;
Index: extensions/dbg_interactive/dispatch.i
===================================================================
--- extensions/dbg_interactive/dispatch.i	(revision 638)
+++ extensions/dbg_interactive/dispatch.i	(revision 639)
@@ -40,15 +40,15 @@
 
 %{
-/* store the python callback function here */
-static PyObject * py_dispatch_cb = NULL;
-static int        py_dispatch_cb_n = 0;
 /* call it (will be called from a different thread than the interpreter, when message arrives) */
-static int call_the_python_dispatch_callback(struct msg **msg, struct avp *avp, struct session *session, enum disp_action *action) {
+static int call_the_python_dispatch_callback(struct msg **msg, struct avp *avp, struct session *session, void * pycb, enum disp_action *action) {
 	PyObject *PyMsg, *PyAvp, *PySess;
-	PyObject *result = NULL;
+	PyObject *cb, *result = NULL;
 	int ret = 0;
 	
-	if (!py_dispatch_cb)
+	if (!pycb) {
+		fd_log_debug("Internal error: missing the callback!\n");
 		return ENOTSUP;
+	}
+	cb = pycb;
 	
 	SWIG_PYTHON_THREAD_BEGIN_BLOCK;
@@ -59,5 +59,5 @@
 	
 	/* Call the function */
-	result = PyEval_CallFunction(py_dispatch_cb, "(OOO)", PyMsg, PyAvp, PySess);
+	result = PyEval_CallFunction(cb, "(OOO)", PyMsg, PyAvp, PySess);
 	
 	/* The result is supposedly composed of: [ ret, *msg, *action ] */
@@ -108,13 +108,8 @@
 		struct disp_hdl * hdl = NULL;
 		int ret;
-		if (py_dispatch_cb && (py_dispatch_cb != PyCb)) {
-			DI_ERROR(EINVAL, PyExc_SyntaxError, "Only one dispatch callback is supported at the moment in this extension\n.");
-			return NULL;
-		}
-		py_dispatch_cb = PyCb;
-		py_dispatch_cb_n += 1;
-		Py_XINCREF(py_dispatch_cb);
 		
-		ret = fd_disp_register ( call_the_python_dispatch_callback, how, when, &hdl );
+		Py_XINCREF(PyCb);
+		
+		ret = fd_disp_register ( call_the_python_dispatch_callback, how, when, PyCb, &hdl );
 		if (ret != 0) {
 			DI_ERROR(ret, NULL, NULL);
@@ -125,13 +120,10 @@
 	~disp_hdl() {
 		struct disp_hdl * hdl = self;
-		int ret = fd_disp_unregister(&hdl);
+		PyObject * cb = NULL;
+		int ret = fd_disp_unregister(&hdl, (void *)&cb);
 		if (ret != 0) {
 			DI_ERROR(ret, NULL, NULL);
 		}
-		/* Now free the callback */
-		Py_XDECREF(py_dispatch_cb);
-		py_dispatch_cb_n -= 1;
-		if (!py_dispatch_cb_n)
-			py_dispatch_cb = NULL;
+		Py_XDECREF(cb);
 		return;
 	}
Index: extensions/dbg_interactive/sessions.i
===================================================================
--- extensions/dbg_interactive/sessions.i	(revision 638)
+++ extensions/dbg_interactive/sessions.i	(revision 639)
@@ -39,15 +39,15 @@
 
 %{
-/* store the python callback function here */
-static PyObject * py_cleanup_cb = NULL;
 /* 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, char * sid) {
+static void call_the_python_cleanup_callback(session_state * state, char * sid, void * cb) {
 	PyObject *result;
-	if (!py_cleanup_cb)
+	if (!cb) {
+		fd_log_debug("Internal error: missing callback object!\n");
 		return;
+	}
 	
 	/* Call the function */
 	SWIG_PYTHON_THREAD_BEGIN_BLOCK;
-	result = PyEval_CallFunction(py_cleanup_cb, "(Os)", state, sid);
+	result = PyEval_CallFunction((PyObject *)cb, "(Os)", state, sid);
 	Py_XDECREF(result);
 	SWIG_PYTHON_THREAD_END_BLOCK;
@@ -64,12 +64,8 @@
 		struct session_handler * hdl = NULL;
 		int ret;
-		if (py_cleanup_cb) {
-			DI_ERROR(EINVAL, PyExc_SyntaxError, "Only one session handler at a time is supported at the moment in this extension\n.");
-			return NULL;
-		}
-		py_cleanup_cb = PyCb;
-		Py_XINCREF(py_cleanup_cb);
 		
-		ret = fd_sess_handler_create_internal ( &hdl, call_the_python_cleanup_callback );
+		Py_XINCREF(PyCb);
+		
+		ret = fd_sess_handler_create_internal ( &hdl, call_the_python_cleanup_callback, PyCb );
 		if (ret != 0) {
 			DI_ERROR(ret, NULL, NULL);
@@ -80,11 +76,12 @@
 	~session_handler() {
 		struct session_handler * hdl = self;
-		int ret = fd_sess_handler_destroy(&hdl);
+		PyObject * cb = NULL;
+		
+		int ret = fd_sess_handler_destroy(&hdl, (void *)&cb);
 		if (ret != 0) {
 			DI_ERROR(ret, NULL, NULL);
 		}
 		/* Now free the callback */
-		Py_XDECREF(py_cleanup_cb);
-		py_cleanup_cb = NULL;
+		Py_XDECREF(cb);
 		return;
 	}
