diff --git a/daemon/configure.ac b/daemon/configure.ac
index 13891c95daf495c9c45e84ebb115d338217df5de..befc460958dea8cc86d26b291a4ba05f9881415e 100644
--- a/daemon/configure.ac
+++ b/daemon/configure.ac
@@ -180,16 +180,7 @@ DBUS_CPP_REQUIRED_VERSION=0.6.0-pre1
 PKG_CHECK_MODULES(DBUSCPP, dbus-c++-1,,
 	AC_MSG_ERROR([You need the DBus-c++ libraries (version $DBUS_CPP_REQUIRED_VERSION or better)]))
 
-AC_ARG_WITH(debug,
-		AS_HELP_STRING(
-				[--with-debug],
-				[Set to enable debugging information @<:@default=no@:>@]
-				),
-			[CXXFLAGS="-g -O0"],
-			[CXXFLAGS="-O2"]
-			)
-
-CXXFLAGS="${CXXFLAGS} -Wno-return-type -Wall -Wextra -Wnon-virtual-dtor"
+CXXFLAGS="${CXXFLAGS} -g -Wno-return-type -Wall -Wextra -Wnon-virtual-dtor"
 
 AC_CHECK_LIB([expat], XML_ParserCreate_MM,
 		[AC_CHECK_HEADERS(expat.h, have_expat=true, have_expat=false)],
diff --git a/daemon/src/audio/pulseaudio/audiostream.cpp b/daemon/src/audio/pulseaudio/audiostream.cpp
index cf3b72a9b59b33159f59bb1ac645a244d8b1a393..b36b849bd3efabd5172e85e4915069cb7d9156fc 100644
--- a/daemon/src/audio/pulseaudio/audiostream.cpp
+++ b/daemon/src/audio/pulseaudio/audiostream.cpp
@@ -93,7 +93,7 @@ AudioStream::~AudioStream()
 }
 
 void
-AudioStream::stream_state_callback (pa_stream* s, void* user_data)
+AudioStream::stream_state_callback (pa_stream* s, void* user_data UNUSED)
 {
     char str[PA_SAMPLE_SPEC_SNPRINT_MAX];
 
diff --git a/daemon/src/audio/sound/audiofile.cpp b/daemon/src/audio/sound/audiofile.cpp
index 619be1aec84eb72b970e75c0adb3ae5eba77aaab..c744aca12eb7e06cbce7c5f2a1a0a8115ebc3920 100644
--- a/daemon/src/audio/sound/audiofile.cpp
+++ b/daemon/src/audio/sound/audiofile.cpp
@@ -172,18 +172,10 @@ WaveFile::WaveFile (const std::string& fileName, unsigned int audioSamplingRate)
     fileStream.read ( (char*) &blockal, 2);
 
     // Determine the data type
-    SOUND_FORMAT dataType;
     SINT16 dt;
     fileStream.read ( (char*) &dt, 2);
-	if (dt == 8)
-		dataType = 1; // SINT8;
-	else if (dt == 16)
-		dataType = 2; // SINT16;
-	else if (dt == 32)
-		dataType = 3; // SINT32;
-	else {
+	if (dt != 8 && dt != 16 && dt != 32)
 		throw AudioFileException("File's bits per sample with is not supported");
-	}
 
     // Find the "data" chunk
     char data[4] = { 0, 0, 0, 0 };
diff --git a/daemon/src/dbus/callmanager.h b/daemon/src/dbus/callmanager.h
index 08ee61622f9d258595e62780c5dc7487a47f6399..4706decd8ec0192a27de6d7836215d660aa99b26 100644
--- a/daemon/src/dbus/callmanager.h
+++ b/daemon/src/dbus/callmanager.h
@@ -42,6 +42,11 @@
 #pragma GCC diagnostic warning "-Wignored-qualifiers"
 #pragma GCC diagnostic warning "-Wunused-parameter"
 
+#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 6
+/* This warning option only exists for gcc 4.6.0 and greater. */
+#pragma GCC diagnostic warning "-Wunused-but-set-variable"
+#endif
+
 #include <dbus-c++/dbus.h>
 #include <stdexcept>
 
diff --git a/daemon/src/dbus/configurationmanager.h b/daemon/src/dbus/configurationmanager.h
index 08fd6da1a660b90770e6fde1aa461b168bcd6972..0bb9536fe2d9518d634e4e90b3b29cb23b801fbc 100644
--- a/daemon/src/dbus/configurationmanager.h
+++ b/daemon/src/dbus/configurationmanager.h
@@ -44,6 +44,10 @@
 #pragma GCC diagnostic warning "-Wignored-qualifiers"
 #pragma GCC diagnostic warning "-Wunused-parameter"
 
+#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 6
+#pragma GCC diagnostic warning "-Wunused-but-set-variable"
+#endif
+
 #include <dbus-c++/dbus.h>
 
 class ConfigurationManager
diff --git a/daemon/src/dbus/dbusmanager.h b/daemon/src/dbus/dbusmanager.h
index 2e3ee3911f5b93a09a133c11dffa7a9eb9c0e1bb..a6bc51b8d66548c9f3a1eec71a3c6a926c7ab075 100644
--- a/daemon/src/dbus/dbusmanager.h
+++ b/daemon/src/dbus/dbusmanager.h
@@ -34,6 +34,8 @@
 #pragma GCC diagnostic ignored "-Wignored-qualifiers"
 #pragma GCC diagnostic ignored "-Wunused-parameter"
 #include <dbus-c++/dbus.h>
+#pragma GCC diagnostic warning "-Wignored-qualifiers"
+#pragma GCC diagnostic warning "-Wunused-parameter"
 class ConfigurationManager;
 class CallManager;
 class NetworkManager;
diff --git a/daemon/src/dbus/instance.h b/daemon/src/dbus/instance.h
index a31bff37c173a4eac922709b0e6b387e3722376f..0258d7fdcd8f16be390979a524f83350bbe0a57c 100644
--- a/daemon/src/dbus/instance.h
+++ b/daemon/src/dbus/instance.h
@@ -40,6 +40,10 @@
 #include "instance-glue.h"
 #pragma GCC diagnostic warning "-Wignored-qualifiers"
 #pragma GCC diagnostic warning "-Wunused-parameter"
+#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 6
+#pragma GCC diagnostic warning "-Wunused-but-set-variable"
+#endif
+
 #include <dbus-c++/dbus.h>
 
 
diff --git a/daemon/src/managerimpl.cpp b/daemon/src/managerimpl.cpp
index 9b1f1a1ac5af722a217bd6bf68dc7eec30d228d6..d7965974c9433bd77e2de9299b681a2b728a398e 100644
--- a/daemon/src/managerimpl.cpp
+++ b/daemon/src/managerimpl.cpp
@@ -1101,9 +1101,6 @@ void ManagerImpl::detachParticipant (const std::string& call_id,
         	return;
         }
 
-        // TODO: add conference_id as a second parameter
-        ConferenceMap::iterator iter = _conferencemap.find(call->getConfId());
-
         Conference *conf = getConferenceFromCallID(call_id);
         if (conf == NULL) {
             _error ("Manager: Error: Call is not conferencing, cannot detach");
diff --git a/daemon/src/sip/sdp.cpp b/daemon/src/sip/sdp.cpp
index 70030a01b845d665ffe785b9f1030bdb77c3e71f..a39800e9ef211db80adc131bbe5fb032e204e7a2 100644
--- a/daemon/src/sip/sdp.cpp
+++ b/daemon/src/sip/sdp.cpp
@@ -337,9 +337,6 @@ int Sdp::createLocalSession (const CodecOrder &selectedCodecs)
 int Sdp::createOffer (const CodecOrder &selectedCodecs)
 {
     pj_status_t status;
-    pjmedia_sdp_neg_state state;
-
-    _info ("SDP: Create initial offer");
 
     // Build the SDP session descriptor
     status = createLocalSession (selectedCodecs);
@@ -355,8 +352,6 @@ int Sdp::createOffer (const CodecOrder &selectedCodecs)
         return status;
     }
 
-    state = pjmedia_sdp_neg_get_state (negotiator_);
-
     PJ_ASSERT_RETURN (status == PJ_SUCCESS, 1);
 
     return PJ_SUCCESS;
diff --git a/gnome/src/actions.c b/gnome/src/actions.c
index cc608e476f7e8a471c505b9af4f9e0e0892c3f51..30828fbcdf61fe44632fc5c36ea9ddceb64f1ae3 100644
--- a/gnome/src/actions.c
+++ b/gnome/src/actions.c
@@ -384,10 +384,6 @@ sflphone_hang_up()
                 selectedCall->_state = CALL_STATE_DIALING;
                 time (&selectedCall->_time_stop);
 
-                //if ( (im_window_get_nb_tabs() > 1) && selectedCall->_im_widget &&
-                //        ! (IM_WIDGET (selectedCall->_im_widget)->containText))
-                //    im_window_remove_tab (selectedCall->_im_widget);
-                //else
                 im_widget_update_state (IM_WIDGET (selectedCall->_im_widget), FALSE);
 
                 break;
@@ -436,7 +432,8 @@ sflphone_pick_up()
 
             // if instant messaging window is visible, create new tab (deleted automatically if not used)
             if (im_window_is_visible())
-                im_widget_display ( (IMWidget **) (&selectedCall->_im_widget), NULL, selectedCall->_callID, NULL);
+                if (!selectedCall->_im_widget)
+                    selectedCall->_im_widget = im_widget_display(selectedCall->_callID);
 
             break;
         case CALL_STATE_INCOMING:
@@ -444,9 +441,9 @@ sflphone_pick_up()
             calltree_update_call (history, selectedCall, NULL);
 
             // if instant messaging window is visible, create new tab (deleted automatically if not used)
-            if (selectedCall->_im_widget && im_window_is_visible()) {
-                im_widget_display ( (IMWidget **) (&selectedCall->_im_widget), NULL, selectedCall->_callID, NULL);
-            }
+            if (im_window_is_visible())
+                if (!selectedCall->_im_widget)
+                    selectedCall->_im_widget = im_widget_display(selectedCall->_callID);
 
             dbus_accept (selectedCall);
             break;
@@ -896,9 +893,7 @@ sflphone_detach_participant (const gchar* callID)
         g_free (selectedCall->_confID);
         selectedCall->_confID = NULL;
     }
-    // Instant messaging widget should have been deactivated during the conference
-    if (selectedCall->_im_widget)
-        im_widget_update_state (IM_WIDGET (selectedCall->_im_widget), TRUE);
+    im_widget_update_state (IM_WIDGET (selectedCall->_im_widget), TRUE);
     calltree_remove_call (current_calls, selectedCall, NULL);
     calltree_add_call (current_calls, selectedCall, NULL);
     dbus_detach_participant (selectedCall->_callID);
diff --git a/gnome/src/dbus/dbus.c b/gnome/src/dbus/dbus.c
index 2e3546b0e55a767a3c2d8b4c7bbf78849efb7951..5139b4ef42a466a75d5da8e621904d9f35a74f3a 100644
--- a/gnome/src/dbus/dbus.c
+++ b/gnome/src/dbus/dbus.c
@@ -122,17 +122,15 @@ voice_mail_cb (DBusGProxy *proxy UNUSED, const gchar* accountID, const guint nb,
 static void
 incoming_message_cb (DBusGProxy *proxy UNUSED, const gchar* callID UNUSED, const gchar *from, const gchar* msg, void * foo  UNUSED)
 {
-    DEBUG ("DBUS: Message \"%s\" from %s!", msg, from);
-
     // do not display message if instant messaging is disabled
     if (eel_gconf_key_exists (INSTANT_MESSAGING_ENABLED) && !eel_gconf_get_integer (INSTANT_MESSAGING_ENABLED))
         return;
 
-    IMWidget **widget;
+    GtkWidget **widget;
     gchar *id;
     callable_obj_t *call = calllist_get_call (current_calls, callID);
     if (call) {
-        widget = (IMWidget **) &call->_im_widget;
+        widget = &call->_im_widget;
         id = call->_callID;
     } else {
         conference_obj_t *conf = conferencelist_get (current_calls, callID);
@@ -140,12 +138,14 @@ incoming_message_cb (DBusGProxy *proxy UNUSED, const gchar* callID UNUSED, const
             ERROR ("Message received, but no recipient found");
             return;
         }
-        widget = (IMWidget **) &conf->_im_widget;
+        widget = &conf->_im_widget;
         id = conf->_confID;
     }
 
-    if (im_widget_display (widget, msg, id, from))
-        im_widget_add_message (*widget, from, msg, 0);
+    if (!*widget)
+        *widget = im_widget_display(id);
+
+    im_widget_add_message (IM_WIDGET(*widget), from, msg, 0);
 }
 
 static void
@@ -211,7 +211,7 @@ static void toggle_im(conference_obj_t *conf, gboolean activate)
 {
     for (GSList *part = conf->participant_list; part; part = g_slist_next (part)) {
         callable_obj_t *call = calllist_get_call (current_calls, part->data);
-        if (call && call->_im_widget)
+        if (call)
             im_widget_update_state (IM_WIDGET (call->_im_widget), activate);
     }
 }
@@ -282,9 +282,7 @@ conference_created_cb (DBusGProxy *proxy UNUSED, const gchar* confID, void * foo
         // set when this call have been added to the conference
         time(&call->_time_added);
 
-        // if a text widget is already created, disable it, use conference widget instead
-        if (call->_im_widget)
-            im_widget_update_state (IM_WIDGET (call->_im_widget), FALSE);
+        im_widget_update_state (IM_WIDGET (call->_im_widget), FALSE);
 
         // if one of these participant is currently recording, the whole conference will be recorded
         if(call->_state == CALL_STATE_RECORD)
@@ -312,9 +310,7 @@ conference_removed_cb (DBusGProxy *proxy UNUSED, const gchar* confID, void * foo
     conference_obj_t * c = conferencelist_get (current_calls, confID);
     calltree_remove_conference (current_calls, c, NULL);
 
-    // deactivate instant messaging window for this conference
-    if (c->_im_widget)
-        im_widget_update_state (IM_WIDGET (c->_im_widget), FALSE);
+    im_widget_update_state (IM_WIDGET (c->_im_widget), FALSE);
 
     // remove all participant for this conference
     for (GSList *p = c->participant_list; p; p = conference_next_participant (p)) {
@@ -324,9 +320,7 @@ conference_removed_cb (DBusGProxy *proxy UNUSED, const gchar* confID, void * foo
             g_free (call->_confID);
             call->_confID = NULL;
 
-            // if an instant messaging was previously disabled, enabled it
-            if (call->_im_widget)
-                im_widget_update_state (IM_WIDGET (call->_im_widget), TRUE);
+            im_widget_update_state(IM_WIDGET (call->_im_widget), TRUE);
         }
     }
 
diff --git a/gnome/src/imwindow.c b/gnome/src/imwindow.c
index 8d5c07f2ebb5818fceddfece851b056ef5d7d4ad..301ae698ed96310993acfbc0870982c1c292f88f 100644
--- a/gnome/src/imwindow.c
+++ b/gnome/src/imwindow.c
@@ -83,15 +83,11 @@ on_delete (GtkWidget * widget UNUSED, gpointer data UNUSED)
 static void
 on_switch_page (GtkNotebook *notebook, GtkNotebookPage *page UNUSED, guint page_num, gpointer userdata UNUSED)
 {
-    guint index = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook));
-
     GtkWidget *tab = gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), page_num);
 
     // show the current widget
     gtk_widget_grab_focus (tab);
     gtk_widget_show_now (tab);
-
-    DEBUG ("InstantMessaging: switch to %i -  current = %i\n", page_num, index);
 }
 
 static void
@@ -141,6 +137,7 @@ im_window_init()
 
     // Restore position according to the configuration stored in gconf
     gtk_window_move (GTK_WINDOW (im_window), position_x, position_y);
+    gtk_widget_set_visible(im_window, FALSE);
 }
 
 gboolean
@@ -155,28 +152,15 @@ im_window_is_active ()
 gboolean
 im_window_is_visible ()
 {
-    return gtk_widget_get_visible (GTK_WIDGET(im_window_get()));
-}
-
-
-void
-im_window_show ()
-{
-    gtk_window_present (im_window_get ());
+    return gtk_widget_get_visible(GTK_WIDGET(im_window_get()));
 }
 
 void
 im_window_add (GtkWidget *widget)
 {
     if (im_window_get()) {
-        /* Add the new tab to the notebook */
         im_window_add_tab (widget);
-
-        /* Show it all */
         gtk_widget_show_all (GTK_WIDGET(im_window_get()));
-    } 
-    else {
-        ERROR ("InstantMessaging: Error: Could not create the main instant messaging window");
     }
 }
 
@@ -199,6 +183,14 @@ close_tab_cb (GtkButton *button UNUSED, gpointer userdata)
     // gtk_widget_destroy (im_window);
 }
 
+static void
+im_window_hide_show_tabs ()
+{
+    /* If only one tab is open, do not display the tab, only the content */
+    gtk_notebook_set_show_tabs(GTK_NOTEBOOK (im_notebook),
+        gtk_notebook_get_n_pages (GTK_NOTEBOOK (im_notebook)) != 1);
+}
+
 void
 im_window_add_tab (GtkWidget *widget)
 {
@@ -247,17 +239,6 @@ im_window_add_tab (GtkWidget *widget)
     im_window_hide_show_tabs ();
 }
 
-void
-im_window_hide_show_tabs ()
-{
-    /* If only one tab is open, do not display the tab, only the content */
-    if (gtk_notebook_get_n_pages (GTK_NOTEBOOK (im_notebook)) == 1) {
-        gtk_notebook_set_show_tabs (GTK_NOTEBOOK (im_notebook), FALSE);
-    } else
-        gtk_notebook_set_show_tabs (GTK_NOTEBOOK (im_notebook), TRUE);
-
-}
-
 void
 im_window_show_tab (GtkWidget *widget)
 {
diff --git a/gnome/src/imwindow.h b/gnome/src/imwindow.h
index 1a3ab3f1cf801b77a7b70c6e596fca060199e602..0db8c628c4ba13e219465132a8fddacce88718c6 100644
--- a/gnome/src/imwindow.h
+++ b/gnome/src/imwindow.h
@@ -52,8 +52,6 @@ void im_window_add (GtkWidget *widget);
  */
 void im_window_remove_tab (GtkWidget *widget);
 
-void im_window_show ();
-
 /**
  * Return wether the instant messaging window have been created or not
  */
@@ -75,11 +73,6 @@ gint im_window_get_nb_tabs (void);
 */
 void im_window_add_tab (GtkWidget *widget);
 
-/*! @function
-@abstract	Decide whether or not the notebook should display its tab. Display the tabs only if more than one tab is opened.
-*/
-void im_window_hide_show_tabs ();
-
 /*! @function
 @abstract Select the specified tab as current in instant messaging window
 @param The tab to be set as current
diff --git a/gnome/src/uimanager.c b/gnome/src/uimanager.c
index 059203d1c4b5dd71463aeea55ccb33675fb76271..7b4a1b6a93cb1d03e7a564a463c4654f6081fd26 100644
--- a/gnome/src/uimanager.c
+++ b/gnome/src/uimanager.c
@@ -577,14 +577,16 @@ call_im(void* foo UNUSED)
     conference_obj_t *selectedConf = calltab_get_selected_conf(current_calls);
 
     if (calltab_get_selected_type(current_calls) == A_CALL) {
-        if (selectedCall)
-            im_widget_display((IMWidget **) (&selectedCall->_im_widget), NULL, selectedCall->_callID, NULL);
-        else
+        if (selectedCall) {
+            if (!selectedCall->_im_widget)
+                selectedCall->_im_widget = im_widget_display(selectedCall->_callID);
+        } else
             WARN("Sorry. Instant messaging is not allowed outside a call\n");
     } else {
-        if (selectedConf)
-            im_widget_display((IMWidget **) (&selectedConf->_im_widget), NULL, selectedConf->_confID, NULL);
-        else
+        if (selectedConf) {
+            if (!selectedConf->_im_widget)
+                selectedConf->_im_widget = im_widget_display(selectedConf->_confID);
+        } else
             WARN("Sorry. Instant messaging is not allowed outside a call\n");
     }
 }
diff --git a/gnome/src/widget/imwidget.c b/gnome/src/widget/imwidget.c
index c287e5ded6118a6af2309a8b5fe2980947d4d26e..fd1087a5a77618355599ed26071d225d83421119 100644
--- a/gnome/src/widget/imwidget.c
+++ b/gnome/src/widget/imwidget.c
@@ -35,6 +35,7 @@
 #include <JavaScriptCore/JavaScript.h>
 #include <gdk/gdkkeysyms.h>
 #include <gtk/gtk.h>
+#include <assert.h>
 #include "sflphone_const.h"
 
 
@@ -44,84 +45,81 @@ static void
 on_frame_loading_done (GObject *gobject UNUSED, GParamSpec *pspec UNUSED, gpointer user_data)
 {
     IMWidget *im = IM_WIDGET (user_data);
-    callable_obj_t *call;
-    conference_obj_t *conf;
-
-    if (im->first_message && im->first_message_from) {
-        switch (webkit_web_frame_get_load_status (WEBKIT_WEB_FRAME (im->web_frame))) {
-            case WEBKIT_LOAD_PROVISIONAL:
-            case WEBKIT_LOAD_COMMITTED:
-                break;
-            case WEBKIT_LOAD_FINISHED:
-                call = calllist_get_call (current_calls, im->call_id);
-                conf = conferencelist_get (current_calls, im->call_id);
-
-                if (call)
-                    im_widget_add_message (im, im->first_message_from, im->first_message, 0);
-
-                if (conf)
-                    im_widget_add_message (im, im->first_message_from, im->first_message, 0);
-
-                g_free (im->first_message);
-                g_free (im->first_message_from);
-                im->first_message = NULL;
-                im->first_message_from = NULL;
-                DEBUG ("InstantMessaging: JavaScrip loading frame finished");
-                break;
-            case WEBKIT_LOAD_FIRST_VISUALLY_NON_EMPTY_LAYOUT:
-                // case WEBKIT_LOAD_FAILED: // only available in webkit-1.0-2
-                break;
-	    case WEBKIT_LOAD_FAILED:
-		DEBUG("InstantMessaging: Webkit load failed");
-    		break;    
-	    default:
-		ERROR("InstantMessaging: Error: Not a valid case in switch");
-	        break;
-	}
-    }
 
+    if (!im->first_message || !im->first_message_from)
+        return;
+
+    switch (webkit_web_frame_get_load_status (WEBKIT_WEB_FRAME (im->web_frame))) {
+        case WEBKIT_LOAD_FIRST_VISUALLY_NON_EMPTY_LAYOUT:
+        case WEBKIT_LOAD_PROVISIONAL:
+        case WEBKIT_LOAD_COMMITTED:
+            break;
+        case WEBKIT_LOAD_FINISHED:
+            if (calllist_get_call (current_calls, im->call_id))
+                im_widget_add_message (im, im->first_message_from, im->first_message, 0);
+
+            if (conferencelist_get (current_calls, im->call_id))
+                im_widget_add_message (im, im->first_message_from, im->first_message, 0);
+
+            g_free(im->first_message);
+            g_free(im->first_message_from);
+            im->first_message = NULL;
+            im->first_message_from = NULL;
+            break;
+        case WEBKIT_LOAD_FAILED:
+            DEBUG("InstantMessaging: Webkit load failed");
+            break;
+    }
 }
 
-gchar *
+static gchar *
 escape_single_quotes (const gchar *message)
 {
-    gchar **ptr_token;
-    gchar *string = "";
+    gchar **ptr_token = g_strsplit(message, "'", 0);
+    gchar *string = g_strjoinv("\\'", ptr_token);
 
-    DEBUG ("InstantMessaging: message: %s", message);
+    g_strfreev(ptr_token);
+    return string;
+}
 
-    if ( (ptr_token = g_strsplit (message, "'", 0))) {
-        string = g_strjoinv ("\\'", ptr_token);
-    }
+static gchar*
+im_widget_add_message_time ()
+{
+    time_t now;
+    char str[100];
 
-    return string;
+    /* Compute the current time */
+    time (&now);
+    const struct tm* ptr = localtime (&now);
+
+    /* Get the time of the message. Format: HH:MM::SS */
+    strftime(str, sizeof(str), "%R", (const struct tm *) ptr);
+    return g_strdup(str);
 }
 
 void
 im_widget_add_message (IMWidget *im, const gchar *from, const gchar *message, gint level)
 {
-    if (im) {
+    assert(im);
 
-        /* Compute the date the message was sent */
-        gchar *msgtime = im_widget_add_message_time ();
+    /* Compute the date the message was sent */
+    gchar *msgtime = im_widget_add_message_time ();
 
-        /* Check for the message level */
-        gchar *css_class = (level == MESSAGE_LEVEL_ERROR) ? "error" : "";
+    gchar *css_class = (level == MESSAGE_LEVEL_ERROR) ? "error" : "";
 
-        gchar *message_escaped = escape_single_quotes (message);
+    gchar *message_escaped = escape_single_quotes (message);
 
-        /* Prepare and execute the Javascript code */
-        gchar *script = g_strdup_printf ("add_message('%s', '%s', '%s', '%s');", message_escaped, from, css_class, msgtime);
-        webkit_web_view_execute_script (WEBKIT_WEB_VIEW (im->web_view), script);
+    /* Prepare and execute the Javascript code */
+    gchar *script = g_strdup_printf ("add_message('%s', '%s', '%s', '%s');", message_escaped, from, css_class, msgtime);
+    webkit_web_view_execute_script (WEBKIT_WEB_VIEW (im->web_view), script);
 
-        /* Mark it as used */
-        im->containText = TRUE;
+    /* Mark it as used */
+    im->containText = TRUE;
 
-        /* Cleanup */
-        g_free (script);
-        g_free (message_escaped);
-        g_free (msgtime);
-    }
+    /* Cleanup */
+    g_free (script);
+    g_free (message_escaped);
+    g_free (msgtime);
 }
 
 static gboolean
@@ -193,30 +191,9 @@ on_Textview_changed (GtkWidget *widget UNUSED, GdkEventKey *event, gpointer user
     return FALSE;
 }
 
-gchar*
-im_widget_add_message_time ()
-{
-
-    time_t now;
-    unsigned char str[100];
-
-    /* Compute the current time */
-    (void) time (&now);
-    struct tm* ptr;
-    ptr = localtime (&now);
-
-    /* Get the time of the message. Format: HH:MM::SS */
-    strftime ( (char *) str, 100, "%R", (const struct tm *) ptr);
-    gchar *res = g_strdup ( (gchar *) str);
-
-    /* Return the new value */
-    return res;
-}
-
 void
-im_widget_send_message (gchar *id, const gchar *message)
+im_widget_send_message (const gchar *id, const gchar *message)
 {
-
     callable_obj_t *im_widget_call = calllist_get_call (current_calls, id);
     conference_obj_t *im_widget_conf = conferencelist_get (current_calls, id);
 
@@ -228,9 +205,7 @@ im_widget_send_message (gchar *id, const gchar *message)
 
     if (im_widget_conf) {
         dbus_send_text_message (id, message);
-    }
-    /* First check if the call is in CURRENT state, otherwise it could not be sent */
-    else if (im_widget_call) {
+    } else if (im_widget_call) {
         if (im_widget_call->_type == CALL && (im_widget_call->_state == CALL_STATE_CURRENT ||
                                               im_widget_call->_state == CALL_STATE_HOLD ||
                                               im_widget_call->_state == CALL_STATE_RECORD)) {
@@ -290,19 +265,6 @@ im_widget_init (IMWidget *im)
     g_signal_connect (G_OBJECT (im->web_frame), "notify", G_CALLBACK (on_frame_loading_done), im);
 }
 
-GtkWidget *
-im_widget_new()
-{
-    return GTK_WIDGET (g_object_new (IM_WIDGET_TYPE, NULL));
-}
-
-GtkWidget *
-im_widget_new_with_first_message (const gchar *message UNUSED)
-{
-    return GTK_WIDGET (g_object_new (IM_WIDGET_TYPE, NULL));
-}
-
-
 GType
 im_widget_get_type (void)
 {
@@ -332,66 +294,39 @@ im_widget_get_type (void)
     return im_widget_type;
 }
 
-gboolean
-im_widget_display (IMWidget **im, const gchar *message, const gchar *id, const gchar *from)
-{
-
-    /* Work with a copy of the object */
-    // callable_obj_t *tmp = *call;
-
-    /* Use the widget for this specific call, if exists */
-    // if (tmp) {
-    IMWidget *imwidget = *im;// = IM_WIDGET (tmp->_im_widget);
 
-    if (!imwidget) {
-        DEBUG ("creating the im widget for this call\n");
-
-        /* Create the im object, first message must be created asynchronously */
-        if (message)
-            imwidget = IM_WIDGET (im_widget_new ());
-        else
-            imwidget = IM_WIDGET (im_widget_new_with_first_message (message));
-
-        /* Keep a reference on this object in the call struct */
-        // tmp->_im_widget = im;
-        // *call = tmp;
-
-        /* Update the widget with some useful call information: ie the call ID */
-        imwidget->call_id = (gchar *)id;
-
-        /* Create the GtkInfoBar, used to display call information, and status of the IM widget */
-        im_widget_infobar (imwidget);
-
-        /* Add it to the main instant messaging window */
-        im_window_add (GTK_WIDGET (imwidget));
-
-        /* Update the first message to appears at widget creation*/
-        if (message)
-            imwidget->first_message = g_strdup (message);
-
-        if (from)
-            imwidget->first_message_from = g_strdup (from);
-
-        *im = imwidget;
-
-        return FALSE;
-    } else {
-        DEBUG ("im widget exists for this call\n");
-        im_window_show ();
-
-        return TRUE;
+static GtkWidget*
+conf_state_image_widget (conference_state_t state)
+{
+    switch (state) {
+        case CONFERENCE_STATE_ACTIVE_ATACHED:
+        case CONFERENCE_STATE_ACTIVE_DETACHED:
+        case CONFERENCE_STATE_ACTIVE_ATTACHED_RECORD:
+        case CONFERENCE_STATE_ACTIVE_DETACHED_RECORD:
+        case CONFERENCE_STATE_HOLD:
+        case CONFERENCE_STATE_HOLD_RECORD:
+            return gtk_image_new_from_stock(GTK_STOCK_IM, GTK_ICON_SIZE_LARGE_TOOLBAR);
+        default:
+            return gtk_image_new_from_stock(GTK_STOCK_FAIL, GTK_ICON_SIZE_LARGE_TOOLBAR);
     }
+}
 
-    // }
-
-    // return FALSE;
+static GtkWidget*
+call_state_image_widget (call_state_t state)
+{
+    switch (state) {
+        case CALL_STATE_CURRENT:
+        case CALL_STATE_HOLD:
+        case CALL_STATE_RECORD:
+            return gtk_image_new_from_stock(GTK_STOCK_IM, GTK_ICON_SIZE_LARGE_TOOLBAR);
+        default:
+            return gtk_image_new_from_stock(GTK_STOCK_IM, GTK_ICON_SIZE_LARGE_TOOLBAR);
+    }
 }
 
-void
+static void
 im_widget_infobar (IMWidget *im)
 {
-
-    /* Fetch the GTKInfoBar of this very IM Widget */
     GtkWidget *infobar = im->info_bar;
     GtkWidget *content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (infobar));
 
@@ -405,7 +340,7 @@ im_widget_infobar (IMWidget *im)
     if (im_widget_call)
         msg1 = g_strdup_printf ("Calling %s  %s", im_widget_call->_peer_number, im_widget_call->_peer_name);
     else if (im_widget_conf)
-        msg1 = g_strdup_printf ("Conferencing"); // im_widget_conf->_confID);
+        msg1 = g_strdup_printf ("Conferencing");
     else
         msg1 = g_strdup ("");
 
@@ -418,7 +353,6 @@ im_widget_infobar (IMWidget *im)
     if (im_widget_conf)
         im->info_state = conf_state_image_widget (im_widget_conf->_state);
 
-    /* Add a nice icon from our own icon factory */
     GtkWidget *logoUser = gtk_image_new_from_stock (GTK_STOCK_USER, GTK_ICON_SIZE_LARGE_TOOLBAR);
 
     /* Pack it all */
@@ -426,76 +360,33 @@ im_widget_infobar (IMWidget *im)
     gtk_container_add (GTK_CONTAINER (content_area), call_label);
     gtk_container_add (GTK_CONTAINER (content_area), im->info_state);
 
-    /* Message level by default: INFO */
     gtk_info_bar_set_message_type (GTK_INFO_BAR (infobar), GTK_MESSAGE_INFO);
 
-    /* Show the info bar */
     gtk_widget_show (infobar);
 }
 
-GtkWidget*
-call_state_image_widget (call_state_t state)
+GtkWidget *im_widget_display (const gchar *id)
 {
+    IMWidget *imwidget = IM_WIDGET(g_object_new (IM_WIDGET_TYPE, NULL));
+    imwidget->call_id = id;
+    im_widget_infobar (imwidget);
+    im_window_add (GTK_WIDGET (imwidget));
 
-    GtkWidget *image;
-
-    switch (state) {
-        case CALL_STATE_CURRENT:
-        case CALL_STATE_HOLD:
-        case CALL_STATE_RECORD:
-            image = gtk_image_new_from_stock (GTK_STOCK_IM, GTK_ICON_SIZE_LARGE_TOOLBAR);
-            break;
-        default:
-            image = gtk_image_new_from_stock (GTK_STOCK_IM, GTK_ICON_SIZE_LARGE_TOOLBAR);
-            break;
-
-    }
-
-    return image;
+    return GTK_WIDGET(imwidget);
 }
 
-GtkWidget*
-conf_state_image_widget (conference_state_t state)
-{
-
-    GtkWidget *image;
-
-    switch (state) {
-        case CONFERENCE_STATE_ACTIVE_ATACHED:
-        case CONFERENCE_STATE_ACTIVE_DETACHED:
-        case CONFERENCE_STATE_ACTIVE_ATTACHED_RECORD:
-        case CONFERENCE_STATE_ACTIVE_DETACHED_RECORD:
-        case CONFERENCE_STATE_HOLD:
-        case CONFERENCE_STATE_HOLD_RECORD:
-            image = gtk_image_new_from_stock (GTK_STOCK_IM, GTK_ICON_SIZE_LARGE_TOOLBAR);
-            break;
-        default:
-            image = gtk_image_new_from_stock (GTK_STOCK_FAIL, GTK_ICON_SIZE_LARGE_TOOLBAR);
-            break;
-    }
-
-    return image;
-}
 
 void
 im_widget_update_state (IMWidget *im, gboolean active)
 {
-    /* if active = true, it means that we are the call is in current state, so sflphone can send text messages */
-    if (active) {
-        gtk_widget_set_sensitive (im->info_state, TRUE);
-        gtk_info_bar_set_message_type (GTK_INFO_BAR (im->info_bar),
-                                       GTK_MESSAGE_INFO);
-    }
-    /* if active = false, the call is over, we can't send text messages anymore */
-    else {
-        if (im) {
-            gtk_widget_set_sensitive (im->info_state, FALSE);
-            gtk_info_bar_set_message_type (GTK_INFO_BAR (im->info_bar),
-                                           GTK_MESSAGE_WARNING);
-            gtk_widget_set_tooltip_text (im->info_state, "Call has terminated");
-        }
+    if (!im)
+        return;
+    gtk_widget_set_sensitive (im->info_state, active);
+
+    if (active) { /* the call is in current state, so sflphone can send text messages */
+        gtk_info_bar_set_message_type (GTK_INFO_BAR (im->info_bar), GTK_MESSAGE_INFO);
+    } else if (im) { /* the call is over, we can't send text messages anymore */
+        gtk_info_bar_set_message_type (GTK_INFO_BAR (im->info_bar), GTK_MESSAGE_WARNING);
+        gtk_widget_set_tooltip_text (im->info_state, "Call has terminated");
     }
 }
-
-
-
diff --git a/gnome/src/widget/imwidget.h b/gnome/src/widget/imwidget.h
index ea0909f2135701b43e2951cad68821cd836ad722..fd7722927006672df7ba08634f30a9719e7f7588 100644
--- a/gnome/src/widget/imwidget.h
+++ b/gnome/src/widget/imwidget.h
@@ -61,7 +61,7 @@ struct _IMWidget {
     GtkWidget *web_view;
     GtkWidget *info_bar;
     GtkWidget *info_state;
-    gchar *call_id;
+    const gchar *call_id;
     gchar *first_message;           // Message displayed at widget's creation time
     gchar *first_message_from;      // Sender of the first message (usefull in case of a conference)
     WebKitWebFrame *web_frame;      // Our web frame
@@ -77,26 +77,13 @@ struct _IMWidgetClass {
 
 /*! @function
 @abstract	Display the instant messaging interface for this call. If it has not been created yet, create it and attached it to the imWindow.
-@param		A reference on the call attached to the current IM widget
-@param          The first message to be displayed, webkit's frames are loaded asynchronously
+@returns		A reference on the call attached to the current IM widget
 @param 	        The call id to be associated with the IMWidget
-@param          The first message sender, could be different of call id for conferences
-@return         TRUE if window is already created, FALSE elsewhere
  */
-gboolean im_widget_display (IMWidget**, const gchar*, const gchar*, const gchar*);
+GtkWidget *im_widget_display (const gchar*);
 
 GType im_widget_get_type (void) G_GNUC_CONST;
 
-/*! @function
-@abstract       Create a new widget with first_message
-*/
-GtkWidget *im_widget_new ();
-
-/*! @function
-@abstract 	Create a new widget with first_message
-*/
-GtkWidget *im_widget_new_with_first_message (const gchar *message);
-
 
 /*! @function
 @abstract	Add a new message in the webkit view
@@ -107,19 +94,7 @@ GtkWidget *im_widget_new_with_first_message (const gchar *message);
 */
 void im_widget_add_message (IMWidget *im, const gchar *from, const gchar *message, gint level);
 
-void im_widget_send_message (gchar *id, const gchar *message);
-
-gchar* im_widget_add_message_time ();
-
-/*! @function
-@abstract 	Build the GtkInfoBar used to display call information and IM Widget status
-@param		The IM Widget
-*/
-void im_widget_infobar (IMWidget *im);
-
-GtkWidget* call_state_image_widget (call_state_t state);
-
-GtkWidget* conf_state_image_widget (conference_state_t state);
+void im_widget_send_message (const gchar *id, const gchar *message);
 
 void im_widget_update_state (IMWidget *im, gboolean active);