diff --git a/src/server/internal-connections.c b/src/server/internal-connections.c
index a7e061390e07d2b5f165b9a44b976f1596030519..c5fe1d8e0f0b9a884f9b59b9b561c57b8ea6e448 100644
--- a/src/server/internal-connections.c
+++ b/src/server/internal-connections.c
@@ -12,6 +12,7 @@
 #include "internal-connections.h"
 #include "lyskomd.h"
 #include "config.h"
+#include "log.h"
 
 INTERNAL  Connection  *all_connections   = NULL;
 
@@ -29,6 +30,8 @@ INTERNAL const Connection EMPTY_CONNECTION =
 		      NULL_CONF_TYPE_i, EMPTY_STRING_i, 0, FALSE, NO_TIME,
 		      0, FALSE});
 
+static int  no_of_allocated_connections = 0;
+
 INTERNAL Connection *
 alloc_connection(void)
 {
@@ -36,6 +39,7 @@ alloc_connection(void)
     
     res = smalloc ( sizeof(Connection) );
     *res = EMPTY_CONNECTION;
+    ++no_of_allocated_connections;
     return res;
 }
 
@@ -78,7 +82,7 @@ new_client(void)
     c->ena_level = 0;
     c->username = EMPTY_STRING;
     c->kill_me = FALSE;
-    
+
     return c;
 }
 
@@ -117,7 +121,29 @@ kill_client(Connection *cp)
 	last_conn = NULL;
 
     cp->magic = CONN_MAGIC_FREE;
+
+    s_clear(&cp->unparsed);
+    s_clear(&cp->what_am_i_doing);
+    s_clear(&cp->username);
+    s_clear(&cp->hostname);
+
+    if ( cp->mux != NULL )
+    {
+	log("kill_client(): client %d has mux != NULL.\n",
+	    cp->session_no);
+    }
+
+    if ( !s_empty(cp->c_string0) || !s_empty(cp->c_string1)
+	|| !s_empty(cp->string0) )
+    {
+	log("kill_client(): unexpected string remains.\n");
+    }
+
+    if ( cp->c_misc_info_p != NULL || cp->c_local_text_no_p != NULL )
+	log("kill_client(): unexpected remaining data.\n");
+
     sfree(cp);
+    --no_of_allocated_connections;
 }
 
 #ifdef DEFENSIVE_CHECKS
@@ -201,3 +227,10 @@ traverse_connections (Session_no session_no)
     else
 	return prev->next->session_no;
 }
+
+void
+dump_allocated_connections(FILE *fp)
+{
+    fprintf(fp, "---" __FILE__ ":\n\tConnections:      %d\n",
+	    no_of_allocated_connections);
+}