diff --git a/.gitignore b/.gitignore
index 1525a6ecc1d335a1aa6d7c53c7d1ffb691544c8f..7fe1d65caaba9365f636aa817de17497b3886575 100644
--- a/.gitignore
+++ b/.gitignore
@@ -98,6 +98,8 @@ sflphone-gtk/pixmaps/Makefile
 /sflphone-gtk/src/sflphone-gtk
 /sflphone-gtk/autom4te*
 /sflphone-gtk/sflphone.desktop
+/sflphone-gtk/confdefs.h
+/sflphone-gtk/conftest.dir
 
 # Ignore sub-modules stuff
 ## libiax2
diff --git a/configure.ac b/configure.ac
index 988fc35e537e21c1680ba68c5e02b282227e57d0..8d6672d4885d5a9215cbe41f7fec2cafd4a2808d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -270,14 +270,14 @@ AC_ARG_WITH([iax2],
 
 LIBIAX2=
 AS_IF([test "x$with_iax2" != xno],
-  [AC_CHECK_LIB([iax2], [iax_init],
+    [AC_CHECK_HEADER([iax2/iax.h], , AC_MSG_FAILURE([Unable to find the libiax2 headers. You may need to install sflphone-iax2-dev package. You may use --without-iax2 to compile without iax2 protocol support.]))]
+    [AC_CHECK_LIB([iax2], [iax_init],
     [],
     [AC_MSG_FAILURE(
-       [libiax2 link test failed. You need the sflphone-iax2 package.  You may use --without-iax2 to compile without iax2 protocol support.])]
+       [libiax2 link test failed. You may use --without-iax2 to compile without iax2 protocol support.])]
        )
-   ]
-  [AC_CHECK_HEADER([iax2/iax.h], , AC_MSG_FAILURE([Unable to find the libiax2 headers. You may need to install sflphone-iax2-dev package. You may use --without-iax2 to compile without iax2 protocol support.]))]
-   )
+    ]
+)
     
 AC_DEFINE([HAVE_IAX], test "x$with_iax2" = "xyes", [Define if you have libiax2])
 AM_CONDITIONAL(USE_IAX, test "x$with_iax2" = "xyes" )
diff --git a/libs/dbus-c++/src/eventloop.cpp b/libs/dbus-c++/src/eventloop.cpp
index 1d4aa2a19c44409eeb7b7d3161f3195633521c8d..a9b875701c31119a87c323c5c2b5aabfe878e6e1 100644
--- a/libs/dbus-c++/src/eventloop.cpp
+++ b/libs/dbus-c++/src/eventloop.cpp
@@ -150,7 +150,8 @@ void DefaultMainLoop::dispatch()
 	}
 	_mutex_w.unlock();
 
-	int wait_min = 10000;
+	// int wait_min = 10000;
+        int wait_min = 500;
 
 	DefaultTimeouts::iterator ti;
 
diff --git a/libs/libiax2/iax2-config.in b/libs/libiax2/iax2-config.in
index 360b79f6d7b96c8b485d6a07e13d8e04b962bd4d..295e69a97b706bb34ce8a97b870708222643fc55 100644
--- a/libs/libiax2/iax2-config.in
+++ b/libs/libiax2/iax2-config.in
@@ -1,11 +1,11 @@
 #!/bin/sh
-iax_libs="-L/usr/lib -liax2"
-iax_cflags=""
-
 prefix=@prefix@
 exec_prefix=@exec_prefix@
 exec_prefix_set=no
 
+iax_libs="-L$prefix -liax2"
+iax_cflags=""
+
 usage="\
 Usage: iax2-config [--prefix[=DIR]] [--exec-prefix[=DIR]] [--version] [--libs] [--cflags]"
 
diff --git a/sflphone-gtk/pixmaps/Makefile.am b/sflphone-gtk/pixmaps/Makefile.am
index 9a2a423f663b9d0f42807b366af692eceb72089b..ad647489534e07fd5adbab90ac802d96b0d8b52e 100644
--- a/sflphone-gtk/pixmaps/Makefile.am
+++ b/sflphone-gtk/pixmaps/Makefile.am
@@ -2,6 +2,6 @@ icondir   = $(datadir)/pixmaps
 
 icon_DATA = sflphone.png
 
-buttons_DATA = accept.svg current.svg transfert.svg hang_up.svg hold.svg unhold.svg refuse.svg call.svg ring.svg dial.svg mic.svg mic_25.svg mic_50.svg mic_75.svg speaker.svg speaker_25.svg speaker_50.svg speaker_75.svg fail.svg incoming.svg outgoing.svg missed.svg mailbox.svg busy.svg icon_accept.svg icon_hold.svg icon_unhold.svg icon_hangup.svg icon_call.svg icon_dialpad.svg icon_volume.svg icon_dialpad_off.svg icon_volume_off.svg history.svg history2.svg sflphone.png stock_person.svg icon_rec.svg rec_call.svg addressbook.svg contact_default.svg face-monkey.svg users.svg home.svg
+buttons_DATA = accept.svg current.svg transfert.svg hang_up.svg hold.svg unhold.svg refuse.svg call.svg ring.svg dial.svg mic.svg mic_25.svg mic_50.svg mic_75.svg speaker.svg speaker_25.svg speaker_50.svg speaker_75.svg fail.svg incoming.svg outgoing.svg missed.svg mailbox.svg busy.svg icon_accept.svg icon_hold.svg icon_unhold.svg icon_hangup.svg icon_call.svg icon_dialpad.svg icon_volume.svg icon_dialpad_off.svg icon_volume_off.svg history.svg history2.svg sflphone.png stock_person.svg icon_rec.svg rec_call.svg addressbook.svg contact_default.svg face-monkey.svg users.svg home.svg wait-on.gif wait-off.gif
 buttonsdir   = $(datadir)/sflphone
 EXTRA_DIST   = $(buttons_DATA) $(icon_DATA)
diff --git a/sflphone-gtk/pixmaps/wait-off.gif b/sflphone-gtk/pixmaps/wait-off.gif
new file mode 100644
index 0000000000000000000000000000000000000000..14d50e9fac6d8611ff87922a7af51a9065e5d710
Binary files /dev/null and b/sflphone-gtk/pixmaps/wait-off.gif differ
diff --git a/sflphone-gtk/pixmaps/wait-on.gif b/sflphone-gtk/pixmaps/wait-on.gif
new file mode 100644
index 0000000000000000000000000000000000000000..1c72ebb554be018511ae972c3f2361dff02dce02
Binary files /dev/null and b/sflphone-gtk/pixmaps/wait-on.gif differ
diff --git a/sflphone-gtk/src/actions.c b/sflphone-gtk/src/actions.c
index 0e6d68437b9d2b73bab76555f4e7e6082adfe215..f3275f017b2b899ed41b7730c57296f4f258cfbe 100644
--- a/sflphone-gtk/src/actions.c
+++ b/sflphone-gtk/src/actions.c
@@ -233,7 +233,7 @@ gboolean sflphone_init()
         current_calls = calltab_init();
         history = calltab_init();
         contacts = calltab_init();
-        if(SHOW_SEARCHBAR)  histfilter = create_filter(GTK_TREE_MODEL(history->store));
+        //if(SHOW_SEARCHBAR)  histfilter = create_filter(GTK_TREE_MODEL(history->store));
         init();
         account_list_init ();
         codec_list_init();
@@ -368,6 +368,12 @@ sflphone_off_hold ()
                 break;
         }
     }
+  
+    if(dbus_get_is_recording(selectedCall))
+        g_print("Currently recording! \n");
+    else
+        g_print("Not recording currently \n");
+    
 }
 
 
@@ -524,23 +530,18 @@ process_dialing(call_t * c, guint keyval, gchar * key)
 sflphone_new_call()
 {
 
+    call_t *c;
+    gchar *from, *to;
+
     sflphone_on_hold();
 
     // Play a tone when creating a new call
     if( call_list_get_size(current_calls) == 0 )
         dbus_start_tone( TRUE , ( voice_mails > 0 )? TONE_WITH_MESSAGE : TONE_WITHOUT_MESSAGE) ;
 
-    call_t * c = g_new0 (call_t, 1);
-    c->state = CALL_STATE_DIALING;
-    c->from = g_strconcat("\"\" <>", NULL);
-
-    c->callID = g_new0(gchar, 30);
-    g_sprintf(c->callID, "%d", rand());
-
-    c->to = g_strdup("");
-
-    c->_start = 0;
-    c->_stop = 0;
+    to = g_strdup("");
+    from = g_strconcat("\"\" <>", NULL);
+    create_new_call (to, from, CALL_STATE_DIALING, "", &c);
 
     call_list_add(current_calls,c);
     update_call_tree_add(current_calls,c);
@@ -681,6 +682,9 @@ sflphone_place_call ( call_t * c )
 
     if(c->state == CALL_STATE_DIALING && strcmp(c->to, "") != 0)
     {
+    
+        //format_phone_number (&c->to); 
+        
         if( account_list_get_size() == 0 )
         {
             notify_no_accounts();
@@ -743,6 +747,7 @@ sflphone_place_call ( call_t * c )
         }
         // Update history
         c->history_state = OUTGOING;
+        g_print ("add in history\n");
         call_list_add(history, c);
     }
 }
@@ -860,3 +865,11 @@ sflphone_fill_codec_list()
     }
 }
 
+void format_phone_number (gchar **number) {
+
+    gchar *_number;
+
+    _number = *number;
+
+    //strip_spaces (&_number);
+}
diff --git a/sflphone-gtk/src/calltab.h b/sflphone-gtk/src/calltab.h
index 7d84696df2fa4f4471455b09859b54ccb75d5a79..d3b85ca977f85f159ae9e13dafb44d1a25f09d9b 100644
--- a/sflphone-gtk/src/calltab.h
+++ b/sflphone-gtk/src/calltab.h
@@ -23,7 +23,7 @@
 #include <calllist.h>
 #include <gtk/gtk.h>
 
-GtkTreeModel* histfilter;
+//GtkTreeModel* histfilter;
 
 calltab_t* calltab_init();
 
diff --git a/sflphone-gtk/src/calltree.c b/sflphone-gtk/src/calltree.c
index b9fbdab365ebf7065185f8e2469a834cb0fc19e8..f0f1fdfdeca03d9fb872b338d7771a7d57edfc3a 100644
--- a/sflphone-gtk/src/calltree.c
+++ b/sflphone-gtk/src/calltree.c
@@ -295,80 +295,80 @@ toolbar_update_buttons ()
   gtk_signal_handler_unblock(transfertButton, transfertButtonConnId);
 
   call_t * selectedCall = call_get_selected(active_calltree);
-  if (selectedCall)
-  {
-    switch(selectedCall->state)
-    {
-      case CALL_STATE_INCOMING:
-	gtk_widget_set_sensitive( GTK_WIDGET(pickupButton),     TRUE);
-	gtk_widget_set_sensitive( GTK_WIDGET(hangupButton),	TRUE);
-	g_object_ref(callButton);
-	gtk_container_remove(GTK_CONTAINER(toolbar), GTK_WIDGET(callButton));
-	gtk_toolbar_insert(GTK_TOOLBAR(toolbar), pickupButton, 0);
-	break;
-      case CALL_STATE_HOLD:
-	gtk_widget_set_sensitive( GTK_WIDGET(hangupButton),     TRUE);
-	gtk_widget_set_sensitive( GTK_WIDGET(unholdButton),     TRUE);
-	gtk_widget_set_sensitive( GTK_WIDGET(callButton),       TRUE);
-	g_object_ref(holdButton);
-	gtk_container_remove(GTK_CONTAINER(toolbar), GTK_WIDGET(holdButton));
-	gtk_toolbar_insert(GTK_TOOLBAR(toolbar), unholdButton, 3);
-	break;
-      case CALL_STATE_RINGING:
-	gtk_widget_set_sensitive( GTK_WIDGET(hangupButton),     TRUE);
-	gtk_widget_set_sensitive( GTK_WIDGET(callButton),     TRUE);
-	break;
-      case CALL_STATE_DIALING:
-	if( active_calltree != history )  gtk_widget_set_sensitive( GTK_WIDGET(hangupButton),     TRUE);
-	gtk_widget_set_sensitive( GTK_WIDGET(pickupButton),       TRUE);
-	g_object_ref(callButton);
-	gtk_container_remove(GTK_CONTAINER(toolbar), GTK_WIDGET(callButton));
-	gtk_toolbar_insert(GTK_TOOLBAR(toolbar), pickupButton, 0);
-	break;
-      case CALL_STATE_CURRENT:
-	gtk_widget_set_sensitive( GTK_WIDGET(hangupButton),     TRUE);
-	gtk_widget_set_sensitive( GTK_WIDGET(holdButton),       TRUE);
-	gtk_widget_set_sensitive( GTK_WIDGET(transfertButton),  TRUE);
-	gtk_widget_set_sensitive( GTK_WIDGET(callButton),       TRUE);
-        gtk_widget_set_sensitive( GTK_WIDGET(recButton),        TRUE);
-	break;
-      case CALL_STATE_BUSY:
-      case CALL_STATE_FAILURE:
-	gtk_widget_set_sensitive( GTK_WIDGET(hangupButton),     TRUE);
-	break;
-      case CALL_STATE_TRANSFERT:
-	gtk_signal_handler_block(GTK_OBJECT(transfertButton),transfertButtonConnId);
-	gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(transfertButton), TRUE);
-	gtk_signal_handler_unblock(transfertButton, transfertButtonConnId);
-	gtk_widget_set_sensitive( GTK_WIDGET(callButton),       TRUE);
-	gtk_widget_set_sensitive( GTK_WIDGET(hangupButton),     TRUE);
-	gtk_widget_set_sensitive( GTK_WIDGET(holdButton),       TRUE);
-	gtk_widget_set_sensitive( GTK_WIDGET(transfertButton),  TRUE);
-	break;
-      case CALL_STATE_RECORD:
-	gtk_widget_set_sensitive( GTK_WIDGET(hangupButton),     TRUE);
-	gtk_widget_set_sensitive( GTK_WIDGET(holdButton),       TRUE);
-	gtk_widget_set_sensitive( GTK_WIDGET(transfertButton),  TRUE);
-	gtk_widget_set_sensitive( GTK_WIDGET(callButton),       TRUE);
-        gtk_widget_set_sensitive( GTK_WIDGET(recButton),        TRUE);
-	break;
-      default:
-	g_warning("Toolbar update - Should not happen!");
-	break;
-    }
-  }
-  else
-  {
-    if( account_list_get_size() > 0 )
+    if (selectedCall)
     {
-      gtk_widget_set_sensitive( GTK_WIDGET(callButton), TRUE );
-      gtk_widget_set_sensitive( GTK_WIDGET(mailboxButton), TRUE );
+        switch(selectedCall->state)
+        {
+            case CALL_STATE_INCOMING:
+	            gtk_widget_set_sensitive( GTK_WIDGET(pickupButton),     TRUE);
+	            gtk_widget_set_sensitive( GTK_WIDGET(hangupButton),	TRUE);
+	            g_object_ref(callButton);
+	            gtk_container_remove(GTK_CONTAINER(toolbar), GTK_WIDGET(callButton));
+	            gtk_toolbar_insert(GTK_TOOLBAR(toolbar), pickupButton, 0);
+	        break;
+            case CALL_STATE_HOLD:
+	            gtk_widget_set_sensitive( GTK_WIDGET(hangupButton),     TRUE);
+	            gtk_widget_set_sensitive( GTK_WIDGET(unholdButton),     TRUE);
+	            gtk_widget_set_sensitive( GTK_WIDGET(callButton),       TRUE);
+	            g_object_ref(holdButton);
+	            gtk_container_remove(GTK_CONTAINER(toolbar), GTK_WIDGET(holdButton));
+	            gtk_toolbar_insert(GTK_TOOLBAR(toolbar), unholdButton, 3);
+	        break;
+            case CALL_STATE_RINGING:
+	            gtk_widget_set_sensitive( GTK_WIDGET(hangupButton),     TRUE);
+	            gtk_widget_set_sensitive( GTK_WIDGET(callButton),     TRUE);
+	        break;
+            case CALL_STATE_DIALING:
+	            if( active_calltree == current_calls )  gtk_widget_set_sensitive( GTK_WIDGET(hangupButton),     TRUE);
+	            gtk_widget_set_sensitive( GTK_WIDGET(pickupButton),       TRUE);
+	            g_object_ref(callButton);
+	            gtk_container_remove(GTK_CONTAINER(toolbar), GTK_WIDGET(callButton));
+	            gtk_toolbar_insert(GTK_TOOLBAR(toolbar), pickupButton, 0);
+	        break;
+            case CALL_STATE_CURRENT:
+	            gtk_widget_set_sensitive( GTK_WIDGET(hangupButton),     TRUE);
+	            gtk_widget_set_sensitive( GTK_WIDGET(holdButton),       TRUE);
+	            gtk_widget_set_sensitive( GTK_WIDGET(transfertButton),  TRUE);
+	            gtk_widget_set_sensitive( GTK_WIDGET(callButton),       TRUE);
+                gtk_widget_set_sensitive( GTK_WIDGET(recButton),        TRUE);
+	        break;
+            case CALL_STATE_BUSY:
+            case CALL_STATE_FAILURE:
+	            gtk_widget_set_sensitive( GTK_WIDGET(hangupButton),     TRUE);
+	            break;
+            case CALL_STATE_TRANSFERT:
+	            gtk_signal_handler_block(GTK_OBJECT(transfertButton),transfertButtonConnId);
+            	gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(transfertButton), TRUE);
+	            gtk_signal_handler_unblock(transfertButton, transfertButtonConnId);
+	            gtk_widget_set_sensitive( GTK_WIDGET(callButton),       TRUE);
+	            gtk_widget_set_sensitive( GTK_WIDGET(hangupButton),     TRUE);
+	            gtk_widget_set_sensitive( GTK_WIDGET(holdButton),       TRUE);
+	            gtk_widget_set_sensitive( GTK_WIDGET(transfertButton),  TRUE);
+	            break;
+            case CALL_STATE_RECORD:
+	            gtk_widget_set_sensitive( GTK_WIDGET(hangupButton),     TRUE);
+	            gtk_widget_set_sensitive( GTK_WIDGET(holdButton),       TRUE);
+	            gtk_widget_set_sensitive( GTK_WIDGET(transfertButton),  TRUE);
+	            gtk_widget_set_sensitive( GTK_WIDGET(callButton),       TRUE);
+                gtk_widget_set_sensitive( GTK_WIDGET(recButton),        TRUE);
+	        break;
+            default:
+	            g_warning("Toolbar update - Should not happen!");
+	        break;
+        }
     }
     else
     {
-      gtk_widget_set_sensitive( GTK_WIDGET(callButton), FALSE);
+        if( account_list_get_size() > 0 )
+        {
+            gtk_widget_set_sensitive( GTK_WIDGET(callButton), TRUE );
+            gtk_widget_set_sensitive( GTK_WIDGET(mailboxButton), TRUE );
+        }
+        else
+        {
+            gtk_widget_set_sensitive( GTK_WIDGET(callButton), FALSE);
+        }
     }
-  }
 }
 
 
@@ -399,54 +399,58 @@ void  row_activated(GtkTreeView       *tree_view UNUSED,
     GtkTreeViewColumn *column UNUSED,
     void * data UNUSED)
 {
-  g_print("double click action\n");
-  call_t* selectedCall;
-  call_t* new_call;
-  gchar *to, *from, *account_id;
-  selectedCall = call_get_selected( active_calltree );
+    call_t* selectedCall;
+    call_t* new_call;
+    gchar *to, *from, *account_id;
+    
+    g_print("double click action\n");
+  
+    selectedCall = call_get_selected( active_calltree );
 
-  if (selectedCall)
-  {
-    // Get the right event from the right calltree
-    if( active_calltree == current_calls )
+    if (selectedCall)
     {
-      switch(selectedCall->state)
-      {
-	case CALL_STATE_INCOMING:
-	  dbus_accept(selectedCall);
-          stop_notification();
-	  break;
-	case CALL_STATE_HOLD:
-	  dbus_unhold(selectedCall);
-	  break;
-	case CALL_STATE_RINGING:
-	case CALL_STATE_CURRENT:
-	case CALL_STATE_BUSY:
-	case CALL_STATE_FAILURE:
-	  break;
-	case CALL_STATE_DIALING:
-	  sflphone_place_call (selectedCall);
-	  break;
-	default:
-	  g_warning("Row activated - Should not happen!");
-	  break;
-      }
-    }
-    // if history
-    else
-    {
-      to = g_strdup(call_get_number(selectedCall));
-      from = g_strconcat("\"\" <", call_get_number(selectedCall), ">",NULL);
-      account_id = g_strdup (selectedCall->accountID);
-
-      create_new_call (to, from, CALL_STATE_DIALING, account_id, &new_call);
-
-      call_list_add(current_calls, new_call);
-      update_call_tree_add(current_calls, new_call);
-      sflphone_place_call(new_call);
-      display_calltree(current_calls);
+        // Get the right event from the right calltree
+        if( active_calltree == current_calls )
+        {
+            switch(selectedCall->state)
+            {
+                case CALL_STATE_INCOMING:
+	                dbus_accept(selectedCall);
+                    stop_notification();
+	                break;
+	            case CALL_STATE_HOLD:
+	                dbus_unhold(selectedCall);
+	                break;
+	            case CALL_STATE_RINGING:
+	            case CALL_STATE_CURRENT:
+	            case CALL_STATE_BUSY:
+	            case CALL_STATE_FAILURE:
+	                break;
+	            case CALL_STATE_DIALING:
+	                sflphone_place_call (selectedCall);
+	            break;
+	            default:
+	                g_warning("Row activated - Should not happen!");
+	                break;
+            }
+        }
+    
+        // If history or contact: double click action places a new call
+        else
+        {
+            to = g_strdup(call_get_number(selectedCall));
+            from = g_strconcat("\"\" <", call_get_number(selectedCall), ">",NULL);
+            account_id = g_strdup (selectedCall->accountID);
+
+            // Create a new call
+            create_new_call (to, from, CALL_STATE_DIALING, account_id, &new_call);
+
+            call_list_add(current_calls, new_call);
+            update_call_tree_add(current_calls, new_call);
+            sflphone_place_call(new_call);
+            display_calltree(current_calls);
+        }
     }
-  }
 }
 
   GtkWidget *
diff --git a/sflphone-gtk/src/contactlist/eds.c b/sflphone-gtk/src/contactlist/eds.c
index 6071f27e96b2828284c850c8ffd05cabbff94cef..6444a6ca2a6edb15610484d999392e1a2bbdaddf 100644
--- a/sflphone-gtk/src/contactlist/eds.c
+++ b/sflphone-gtk/src/contactlist/eds.c
@@ -31,6 +31,7 @@
 #include "eds.h"
 
 typedef struct _Handler_And_Data {
+    int                 search_id;
     SearchAsyncHandler  handler;
     gpointer            user_data;
     GList              *hits;
@@ -95,6 +96,7 @@ create_query (const char* s)
     GArray *parts = split_query_string (s);
     EBookQuery ***field_queries;
     EBookQuery **q;
+    EBookQuery **phone;
     guint j;
     int i;
 
@@ -110,13 +112,19 @@ create_query (const char* s)
     }
     g_array_free (parts, TRUE);
 
-    query = e_book_query_or (n_search_fields, q, TRUE);
+    phone = g_new0 (EBookQuery *, 3);
+    phone[0] = e_book_query_field_exists (E_CONTACT_PHONE_BUSINESS);
+    phone[1] = e_book_query_field_exists (E_CONTACT_PHONE_HOME);
+    phone[2] = e_book_query_field_exists (E_CONTACT_PHONE_MOBILE);
+
+    query = e_book_query_andv (e_book_query_or (n_search_fields, q, FALSE), e_book_query_or (3, phone, FALSE));
 
     for (i = 0; i < n_search_fields; i++) {
         g_free (field_queries[i]);
     }
     g_free (field_queries);
     g_free (q);
+    g_free (phone);
 
     return query;
 }
@@ -188,30 +196,66 @@ init (void)
         }
     }
 
+    current_search_id = 0;
+
     g_object_unref (source_list);
 }
 
+/**
+ * Final callback after all books have been processed.
+ */
     static void
 view_finish (EBookView *book_view, Handler_And_Data *had)
 {
+    GList *i;
     SearchAsyncHandler had_handler = had->handler;
     GList *had_hits = had->hits;
     gpointer had_user_data = had->user_data;
+    int search_id = had->search_id;
     g_free (had);
 
     g_return_if_fail (book_view != NULL);
     g_object_unref (book_view);
 
-    had_handler (had_hits, had_user_data);
+    if(search_id == current_search_id)
+    {
+      // Reinitialize search id to prevent overflow
+      if(current_search_id > 5000)
+        current_search_id = 0;
+
+      // Call display callback
+      had_handler (had_hits, had_user_data);
+    }
+    else
+    {
+      // Some hits could have been processed but will not be used
+      for (i = had_hits; i != NULL; i = i->next)
+      {
+          Hit *entry;
+          entry = i->data;
+          free_hit(entry);
+      }
+      g_list_free(had_hits);
+    }
 }
 
+/**
+ * Callback called after each ebook search completed.
+ * Used to store book search results.
+ */
     static void
 view_contacts_added_cb (EBookView *book_view, GList *contacts, gpointer user_data)
 {
-    
     GdkPixbuf *photo;
 
     Handler_And_Data *had = (Handler_And_Data *) user_data;
+
+    if(had->search_id != current_search_id)
+    {
+      e_book_view_stop (book_view);
+      return;
+    }
+
     if (had->max_results_remaining <= 0) {
         e_book_view_stop (book_view);
         had->book_views_remaining--;
@@ -261,6 +305,10 @@ view_contacts_added_cb (EBookView *book_view, GList *contacts, gpointer user_dat
     }
 }
 
+/**
+ * Callback called after each ebook search completed.
+ * Used to call final callback when all books have been read.
+ */
     static void
 view_completed_cb (EBookView *book_view, EBookViewStatus status, gpointer user_data)
 {
@@ -271,17 +319,30 @@ view_completed_cb (EBookView *book_view, EBookViewStatus status, gpointer user_d
     }
 }
 
+
     void
 search_async (const char         *query,
         int                 max_results,
         SearchAsyncHandler  handler,
         gpointer            user_data)
 {
-    GSList *iter;
+    // Increment search id
+    current_search_id++;
 
-    EBookQuery* book_query = create_query (query);
+    // If query is null
+    if(strlen(query) < 1)
+    {
+      // If data displayed (from previous search), directly call callback
+      handler(NULL, user_data);
 
+      return;
+    }
+
+    GSList *iter;
+    EBookQuery* book_query = create_query (query);
     Handler_And_Data *had = g_new (Handler_And_Data, 1);
+
+    had->search_id = current_search_id;
     had->handler = handler;
     had->user_data = user_data;
     had->hits = NULL;
diff --git a/sflphone-gtk/src/contactlist/eds.h b/sflphone-gtk/src/contactlist/eds.h
index c0e411dc797f7be5edee7a6f0cfd7be84627b49c..64d464e04f70c044111d2ba898e37993a5f5da2f 100644
--- a/sflphone-gtk/src/contactlist/eds.h
+++ b/sflphone-gtk/src/contactlist/eds.h
@@ -35,8 +35,10 @@
 
 G_BEGIN_DECLS
 
+int current_search_id;
+
 /**
- * Reprsent a contact entry 
+ * Reprsent a contact entry
  */
 typedef struct _Hit
 {
@@ -48,7 +50,7 @@ typedef struct _Hit
 } Hit;
 
 /**
- * Free a contact entry 
+ * Free a contact entry
  */
 void free_hit (Hit *h);
 
diff --git a/sflphone-gtk/src/dbus.c b/sflphone-gtk/src/dbus.c
index ab494b5ff716bb329e221cda5cab3215ae8fdb08..c1def3f9b629a24a81ff406b5c286e12585d7dd6 100644
--- a/sflphone-gtk/src/dbus.c
+++ b/sflphone-gtk/src/dbus.c
@@ -1123,7 +1123,7 @@ dbus_set_record(const call_t * c)
 	    }
 }
 
-gboolean
+gboolean*
 dbus_get_is_recording(const call_t * c)
 {
        g_print("calling dbus_get_is_recording on CallManager\n");
@@ -1132,12 +1132,14 @@ dbus_get_is_recording(const call_t * c)
        org_sflphone_SFLphone_CallManager_get_is_recording (
                        callManagerProxy, 
                        c->callID, 
-                       isRecording, 
+                       &isRecording, 
                        &error);
 	    if(error)
 	    {
 		    g_error_free(error);
 	    }
+            //g_print("RECORDING: %i \n",isRecording);
+            return isRecording;
 }
 
 void
diff --git a/sflphone-gtk/src/historyfilter.c b/sflphone-gtk/src/historyfilter.c
deleted file mode 100644
index db1d405246aa83a8dd83ea1d07a243c898763d64..0000000000000000000000000000000000000000
--- a/sflphone-gtk/src/historyfilter.c
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- *  Copyright (C) 2008 Savoir-Faire Linux inc.
- *  Author: Antoine Reversat <antoine.reversat@savoirfairelinux.com>
- *                                                                              
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 3 of the License, or
- *  (at your option) any later version.
- *                                                                                
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *                                                                              
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include <string.h>
-
-#include <historyfilter.h>
-#include <calltree.h>
-
-GtkWidget * filter_entry;
-
-GtkTreeModel*
-create_filter(GtkTreeModel* child)
-{
-	GtkTreeModel* ret = gtk_tree_model_filter_new(child, NULL);
-	gtk_tree_model_filter_set_visible_func(GTK_TREE_MODEL_FILTER(ret), is_visible, NULL, NULL);
-	return GTK_TREE_MODEL(ret);
-} 
-
-gboolean
-is_visible(GtkTreeModel* model, GtkTreeIter* iter, gpointer data UNUSED)
-{
-  if( SHOW_SEARCHBAR )
-  {
-	GValue val;
-
-	gchar* text = NULL;
-	gchar* search = (gchar*)gtk_entry_get_text(GTK_ENTRY(filter_entry));
-    memset (&val, 0, sizeof(val));
-	gtk_tree_model_get_value(GTK_TREE_MODEL(model), iter, 1, &val);
-	if(G_VALUE_HOLDS_STRING(&val)){
-		text = (gchar *)g_value_get_string(&val);
- 	}
-	if(text != NULL && g_ascii_strncasecmp(search, _("Search"), 6) != 0){
-		return g_regex_match_simple(search, text, G_REGEX_CASELESS, 0);
- 	}
-    g_value_unset (&val);
-	return TRUE;
-  }
-  return TRUE;
-} 
-
-void
-filter_entry_changed(GtkEntry* entry UNUSED, gchar* arg1 UNUSED, gpointer data UNUSED)
-{ 
-	gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(historyButton), TRUE);
-	gtk_tree_model_filter_refilter(GTK_TREE_MODEL_FILTER(histfilter));
-}
-
-void
-clear_filter_entry_if_default(GtkWidget* widget UNUSED, gpointer user_data UNUSED)
-{
-	if(g_ascii_strncasecmp(gtk_entry_get_text(GTK_ENTRY(filter_entry)), _("Search"), 6) == 0)
-		gtk_entry_set_text(GTK_ENTRY(filter_entry), "");
-}
-
-GtkWidget*
-create_filter_entry() 
-{
-	GtkWidget* image;
-	GtkWidget* ret = gtk_hbox_new(FALSE, 0);
-      
-	filter_entry = sexy_icon_entry_new();
-	//filter_entry = gtk_entry_new();
-	image = gtk_image_new_from_stock( GTK_STOCK_FIND , GTK_ICON_SIZE_SMALL_TOOLBAR);
-	sexy_icon_entry_set_icon( SEXY_ICON_ENTRY(filter_entry), SEXY_ICON_ENTRY_PRIMARY , GTK_IMAGE(image) ); 
-	sexy_icon_entry_add_clear_button( SEXY_ICON_ENTRY(filter_entry) );
-	gtk_entry_set_text(GTK_ENTRY(filter_entry), _("Search"));	
-	g_signal_connect(GTK_ENTRY(filter_entry), "changed", G_CALLBACK(filter_entry_changed), NULL);
-	g_signal_connect(GTK_ENTRY(filter_entry), "grab-focus", G_CALLBACK(clear_filter_entry_if_default), NULL);
-
-	gtk_box_pack_start(GTK_BOX(ret), filter_entry, TRUE, TRUE, 0);
-	return ret;
-}
diff --git a/sflphone-gtk/src/historyfilter.h b/sflphone-gtk/src/historyfilter.h
deleted file mode 100644
index 72d46b8ce7d640dbd5ae0f1c9b9adb2eb2462b66..0000000000000000000000000000000000000000
--- a/sflphone-gtk/src/historyfilter.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- *  Copyright (C) 2007 Savoir-Faire Linux inc.
- *  Author: Antoine Reversat <antoine.reversat@savoirfairelinux.com>
- *                                                                              
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 3 of the License, or
- *  (at your option) any later version.
- *                                                                                
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *                                                                              
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
- 
-#ifndef __HFILTER_H__
-#define __HFILTER_H__
-
-#include <calllist.h>
-#include <gtk/gtk.h>
-#include <libsexy/sexy-icon-entry.h>
-
-GtkTreeModel* create_filter(GtkTreeModel* child);
-
-gboolean is_visible(GtkTreeModel* model, GtkTreeIter* iter, gpointer data);
-GtkWidget* create_filter_entry();
-#endif
diff --git a/sflphone-gtk/src/mainwindow.c b/sflphone-gtk/src/mainwindow.c
index 5eb09084712bba75755e6280d47930bcf7e927ad..02d274ceeaace8181fd2ab4c1e8918707054f69e 100644
--- a/sflphone-gtk/src/mainwindow.c
+++ b/sflphone-gtk/src/mainwindow.c
@@ -172,7 +172,7 @@ create_main_window ()
   /* dont't show the contact list */
   gtk_widget_hide(contacts->tree);
 
-  gtk_tree_view_set_model(GTK_TREE_VIEW(history->view), GTK_TREE_MODEL(histfilter));
+  //gtk_tree_view_set_model(GTK_TREE_VIEW(history->view), GTK_TREE_MODEL(histfilter));
   // Configuration wizard
   if (account_list_get_size() == 0)
   {
diff --git a/sflphone-gtk/src/menus.c b/sflphone-gtk/src/menus.c
index 2030f12ccef32560ea4b0d72b016d80b6eeca1fa..6a0a17ea7ed6685e93f951995c705dc5e2b8dc08 100644
--- a/sflphone-gtk/src/menus.c
+++ b/sflphone-gtk/src/menus.c
@@ -324,7 +324,7 @@ create_call_menu()
       NULL);
   gtk_widget_show (menu_items);
 
-  image = gtk_tool_button_new_from_stock (GTK_STOCK_MEDIA_RECORD);
+  image = gtk_image_new_from_stock (GTK_STOCK_MEDIA_RECORD, GTK_ICON_SIZE_MENU);
   recordMenu = gtk_image_menu_item_new_with_mnemonic(_("_Record"));
   gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM ( recordMenu ), image );
   gtk_menu_shell_append (GTK_MENU_SHELL (menu), recordMenu);
@@ -650,7 +650,7 @@ create_view_menu()
   gtk_widget_show (volumeMenu);
 
   image = gtk_image_new_from_stock( GTK_STOCK_FIND , GTK_ICON_SIZE_MENU );
-  searchbarMenu = gtk_image_menu_item_new_with_mnemonic (_("_Search history"));
+  searchbarMenu = gtk_image_menu_item_new_with_mnemonic (_("_Search contact"));
   gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM ( searchbarMenu ), image );
   gtk_menu_shell_append (GTK_MENU_SHELL (menu), searchbarMenu);
   g_signal_connect(G_OBJECT (searchbarMenu), "activate",
@@ -812,7 +812,7 @@ show_popup_menu (GtkWidget *my_widget, GdkEventButton *event)
    if(record)
   {
     menu_items = gtk_image_menu_item_new_with_mnemonic(_("_Record"));
-    image = gtk_tool_button_new_from_stock (GTK_STOCK_MEDIA_RECORD);
+    image = gtk_image_new_from_stock (GTK_STOCK_MEDIA_RECORD, GTK_ICON_SIZE_MENU);
     gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_items), image);
     gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
     g_signal_connect (G_OBJECT (menu_items), "activate",
diff --git a/sflphone-gtk/src/searchfilter.c b/sflphone-gtk/src/searchfilter.c
index 8cc99aba8bb27ced019d15fc4030cb07da94540c..92988c519a8ee1a1aea8bc1909ad5e8b91b1c2ec 100644
--- a/sflphone-gtk/src/searchfilter.c
+++ b/sflphone-gtk/src/searchfilter.c
@@ -31,7 +31,7 @@ static void handler_async_search (GList *hits, gpointer user_data UNUSED);
 GtkTreeModel* create_filter (GtkTreeModel* child) {
 
     GtkTreeModel* ret;
-    
+
     ret = gtk_tree_model_filter_new(child, NULL);
     gtk_tree_model_filter_set_visible_func(GTK_TREE_MODEL_FILTER(ret), is_visible, NULL, NULL);
     return GTK_TREE_MODEL(ret);
@@ -76,7 +76,7 @@ static void handler_async_search (GList *hits, gpointer user_data) {
 
     // Retrieve the address book parameters
     addressbook_config = (AddressBook_Config*) user_data;
-        
+
     // reset previous results
     reset_call_tree(contacts);
     call_list_reset(contacts);
@@ -104,23 +104,34 @@ static void handler_async_search (GList *hits, gpointer user_data) {
     }
     g_list_free(hits);
 
+    // Deactivate waiting image
+    deactivateWaitingLayer();
 }
 
-void filter_entry_changed (GtkEntry* entry UNUSED, gchar* arg1 UNUSED, gpointer data UNUSED) {
+void filter_entry_changed (GtkEntry* entry, gchar* arg1 UNUSED, gpointer data UNUSED) {
 
     AddressBook_Config *addressbook_config;
-    
+
     /* Switch to the address book when the focus is on the search bar */
-    if (active_calltree == current_calls)
+    if (active_calltree != contacts)
         display_calltree (contacts);
 
 
     /* We want to search in the contact list */
     if (active_calltree == contacts) {
+        // Activate waiting layer
+        activateWaitingLayer();
+
         // Load the address book parameters
         addressbook_load_parameters (&addressbook_config);
-        // Start the asynchronous search as soon as we have an entry */ 
-        search_async (gtk_entry_get_text (GTK_ENTRY (filter_entry)), addressbook_config->max_results, &handler_async_search, addressbook_config); 
+
+        // Start the asynchronous search as soon as we have an entry */
+        search_async (gtk_entry_get_text (GTK_ENTRY (entry)), addressbook_config->max_results, &handler_async_search, addressbook_config);
+    }
+
+    else if (active_calltree == history) {
+        // Filter the displayed calls
+
     }
 
 }
@@ -138,7 +149,6 @@ GtkWidget* create_filter_entry() {
     GtkWidget* ret = gtk_hbox_new(FALSE, 0);
 
     filter_entry = sexy_icon_entry_new();
-    //filter_entry = gtk_entry_new();
     image = gtk_image_new_from_stock( GTK_STOCK_FIND , GTK_ICON_SIZE_SMALL_TOOLBAR);
     sexy_icon_entry_set_icon( SEXY_ICON_ENTRY(filter_entry), SEXY_ICON_ENTRY_PRIMARY , GTK_IMAGE(image) );
     sexy_icon_entry_add_clear_button( SEXY_ICON_ENTRY(filter_entry) );
@@ -147,6 +157,22 @@ GtkWidget* create_filter_entry() {
     g_signal_connect(GTK_ENTRY(filter_entry), "grab-focus", G_CALLBACK(clear_filter_entry_if_default), NULL);
 
     gtk_box_pack_start(GTK_BOX(ret), filter_entry, TRUE, TRUE, 0);
+
+    // Create waiting icon
+    waitingPixOn = gdk_pixbuf_animation_new_from_file(ICONS_DIR "/wait-on.gif", NULL);
+    waitingPixOff = gdk_pixbuf_new_from_file(ICONS_DIR "/wait-off.gif", NULL);
+    waitingLayer = gtk_image_new_from_pixbuf(waitingPixOff);
+
+    gtk_box_pack_end(GTK_BOX(ret), waitingLayer, TRUE, TRUE, 0);
+
     return ret;
 
 }
+
+void activateWaitingLayer() {
+  gtk_image_set_from_animation(GTK_IMAGE(waitingLayer),waitingPixOn);
+}
+
+void deactivateWaitingLayer() {
+  gtk_image_set_from_pixbuf (GTK_IMAGE(waitingLayer),waitingPixOff);
+}
diff --git a/sflphone-gtk/src/searchfilter.h b/sflphone-gtk/src/searchfilter.h
index 6a85eda4ae7b3b3af7bd6792dce7c0cd0a20d61b..c22109635b98dda14046c583e63585a9ff38c7ad 100644
--- a/sflphone-gtk/src/searchfilter.h
+++ b/sflphone-gtk/src/searchfilter.h
@@ -3,22 +3,22 @@
  *
  *  Author: Antoine Reversat <antoine.reversat@savoirfairelinux.com>
  *  Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>
- *                                                                              
+ *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
  *  the Free Software Foundation; either version 3 of the License, or
  *  (at your option) any later version.
- *                                                                                
+ *
  *  This program is distributed in the hope that it will be useful,
  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  *  GNU General Public License for more details.
- *                                                                              
+ *
  *  You should have received a copy of the GNU General Public License
  *  along with this program; if not, write to the Free Software
  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
- 
+
 #ifndef __SEARCH_FILTER_H__
 #define __SEARCH_FILTER_H__
 
@@ -26,10 +26,20 @@
 #include <gtk/gtk.h>
 #include <libsexy/sexy-icon-entry.h>
 
+GtkWidget *waitingLayer;
+
+GdkPixbufAnimation *waitingPixOn;
+
+GdkPixbuf *waitingPixOff;
+
 GtkTreeModel* create_filter(GtkTreeModel* child);
 
 gboolean is_visible(GtkTreeModel* model, GtkTreeIter* iter, gpointer data);
 
 GtkWidget* create_filter_entry();
 
+void activateWaitingLayer();
+
+void deactivateWaitingLayer();
+
 #endif
diff --git a/src/audio/audiortp.cpp b/src/audio/audiortp.cpp
index 02972a3058afc50dc73fc175fd7aba350e9732f0..e483830cce819875d72de31937997a7c294244a5 100644
--- a/src/audio/audiortp.cpp
+++ b/src/audio/audiortp.cpp
@@ -190,6 +190,9 @@ AudioRtpRTX::initAudioRtpSession (void)
     try {
         if (_ca == 0) { return; }
         _audiocodec = _ca->getLocalSDP()->get_session_media ();
+
+        if (_audiocodec == NULL) { return; }
+
         _codecSampleRate = _audiocodec->getClockRate(); 
 
         ost::InetHostAddress remote_ip(_ca->getLocalSDP()->get_remote_ip().c_str());
diff --git a/src/dbus/instance.cpp b/src/dbus/instance.cpp
index 7011326c1c6339e6448fe6b84ff4ac345f23e2f5..4e880722e75e7dc87a1ef72670befed9447eb082 100644
--- a/src/dbus/instance.cpp
+++ b/src/dbus/instance.cpp
@@ -44,12 +44,12 @@ Instance::Unregister( const int32_t& pid UNUSED)
     count --;
     if(count <= 0)
     {
-        
-        DBusManager::instance().exit();
 
+        
         Manager::instance().terminate();
 
-       
+        DBusManager::instance().exit();
+
     }
 }
 
@@ -58,5 +58,6 @@ Instance::getRegistrationCount( void )
 {
   
   return count;
+
 }
 
diff --git a/src/managerimpl.cpp b/src/managerimpl.cpp
index 45ab60e01b4b4d5895b2278e5bf63541e628bb40..53fe6cf66e476816e55086b1fd31f23fb922e4d4 100644
--- a/src/managerimpl.cpp
+++ b/src/managerimpl.cpp
@@ -447,9 +447,9 @@ ManagerImpl::offHoldCall(const CallID& id)
   
     switchCall(id);
 
-    // codecName = getCurrentCodecName(id);
+    codecName = getCurrentCodecName(id);
     // _debug("ManagerImpl::hangupCall(): broadcast codec name %s \n",codecName.c_str());
-    // if (_dbus) _dbus->getCallManager()->currentSelectedCodec(id,codecName.c_str());
+    if (_dbus) _dbus->getCallManager()->currentSelectedCodec(id,codecName.c_str());
 
     return returnValue;
 }
@@ -741,7 +741,9 @@ ManagerImpl::incomingCall(Call* call, const AccountID& accountId)
     */
   
     /* Broadcast a signal over DBus */
-    _dbus->getCallManager()->incomingCall(accountId, call->getCallId(), from);
+    if (_dbus) _dbus->getCallManager()->incomingCall(accountId, call->getCallId(), from);
+
+    //if (_dbus) _dbus->getCallManager()->callStateChanged(call->getCallId(), "INCOMING");
   
     // Reduce volume of the other pulseaudio-connected audio applications
     if( _audiodriver->getLayerType() == PULSEAUDIO && getConfigInt( PREFERENCES , CONFIG_PA_VOLUME_CTRL ) ) {
@@ -789,7 +791,6 @@ ManagerImpl::peerRingingCall(const CallID& id)
   void
 ManagerImpl::peerHungupCall(const CallID& id)
 {
-    _debug("ManagerImpl::peerHungupCall():this function is called when peer hangup \n");
     PulseLayer *pulselayer;
     AccountID accountid;
     bool returnValue;
@@ -979,15 +980,12 @@ ManagerImpl::ringtone()
     {
         //TODO Comment this because it makes the daemon crashes since the main thread
         //synchronizes the ringtone thread.
-        _debug("RINGING!!! 1\n");
         
         ringchoice = getConfigString(AUDIO, RING_CHOICE);
         //if there is no / inside the path
         if ( ringchoice.find(DIR_SEPARATOR_CH) == std::string::npos ) {
             // check inside global share directory
             ringchoice = std::string(PROGSHAREDIR) + DIR_SEPARATOR_STR + RINGDIR + DIR_SEPARATOR_STR + ringchoice; 
-
-            _debug("RINGING!!! 2\n");
         }
 
         audiolayer = getAudioDriver();
@@ -995,7 +993,6 @@ ManagerImpl::ringtone()
         if (audiolayer == 0)
             return;
 
-        _debug("RINGING!!! 3\n");
 
         samplerate  = audiolayer->getSampleRate();
         codecForTone = _codecDescriptorMap.getFirstCodecAvailable();
@@ -1006,7 +1003,6 @@ ManagerImpl::ringtone()
 
         if (loadFile) {
             
-            _debug("RINGING!!! 5\n");
             _toneMutex.enterMutex(); 
             _audiofile.start();
             _toneMutex.leaveMutex(); 
@@ -1016,18 +1012,15 @@ ManagerImpl::ringtone()
             }
             else{
                 audiolayer->startStream();
-                _debug("RINGING!!! 6\n");
             }
         } else {
             ringback();
-            _debug("RINGING!!! 7\n");
         }
     
     }
     else
     {
         ringback();
-        _debug("RINGING!!! 8\n");
     }
 }
 
@@ -1638,7 +1631,6 @@ ManagerImpl::setRecordingCall(const CallID& id)
   _debug("ManagerImpl::setRecording()! \n");
   AccountID accountid = getAccountFromCall( id );
 
-  // printf("ManagerImpl::CallID: %s", id);
   getAccountLink(accountid)->setRecording(id);
 }
 
@@ -2347,12 +2339,13 @@ ManagerImpl::getNewCallID()
   short
 ManagerImpl::loadAccountMap()
 {
-  _debug("Load account:");
+ 
   short nbAccount = 0;
   TokenList sections = _config.getSections();
   std::string accountType;
   Account* tmpAccount;
 
+
   TokenList::iterator iter = sections.begin();
   while(iter != sections.end()) {
     // Check if it starts with "Account:" (SIP and IAX pour le moment)
@@ -2371,27 +2364,31 @@ ManagerImpl::loadAccountMap()
     else {
       _debug("Unknown %s param in config file (%s)\n", CONFIG_ACCOUNT_TYPE, accountType.c_str());
     }
-
+ 
+    _debug("tmpAccount.getRegistrationState() %i \n ",tmpAccount->getRegistrationState());
     if (tmpAccount != NULL) {
-      _debug(" %s ", iter->c_str());
+    
+      _debug(" %s \n", iter->c_str());
       _accountMap[iter->c_str()] = tmpAccount;
       nbAccount++;
     }
 
     iter++;
   }
-
+  _debug("nbAccount loaded %i \n",nbAccount);
   return nbAccount;
 }
 
   void
 ManagerImpl::unloadAccountMap()
 {
-  _debug("Unloading account map...\n");
+
   AccountMap::iterator iter = _accountMap.begin();
   while ( iter != _accountMap.end() ) {
+
     _debug("-> Deleting account %s\n", iter->first.c_str());
     delete iter->second; iter->second = 0;
+
     iter++;
   }
   _accountMap.clear();
@@ -2465,26 +2462,21 @@ AccountMap ManagerImpl::getSipAccountMap( void )
 
 void ManagerImpl::restartPJSIP (void)
 {
-    //SIPVoIPLink *siplink;
-
-    //unloadAccountMap ();
-
-    /* First unregister all SIP accounts */
-    //this->unregisterCurSIPAccounts();
+    SIPVoIPLink *siplink;
+    siplink = dynamic_cast<SIPVoIPLink*> (getSIPAccountLink ());
+    
+    this->unregisterCurSIPAccounts();
     /* Terminate and initialize the PJSIP library */
-    //siplink = dynamic_cast<SIPVoIPLink*> (getSIPAccountLink ());
-    //if (siplink) 
-    //{
-      //  siplink->terminate ();
-       // _debug ("*************************************************Terminate done\n");
-        //siplink = SIPVoIPLink::instance("");
-        //siplink->init ();
-    //}
-    //_debug("***************************************************Init Done\n");
-    //loadAccountMap();
-    //initRegisterAccounts ();
+    
+    if (siplink) 
+    {
+        siplink->terminate ();
+        siplink = SIPVoIPLink::instance("");
+        siplink->init ();
+    }
+
     /* Then register all enabled SIP accounts */
-    //this->registerCurSIPAccounts(siplink);
+    this->registerCurSIPAccounts(siplink);
 }
 
 VoIPLink* ManagerImpl::getAccountLink(const AccountID& accountID)
@@ -2545,17 +2537,21 @@ void ManagerImpl::unregisterCurSIPAccounts()
 
 void ManagerImpl::registerCurSIPAccounts(VoIPLink *link)
 {
+    
     Account *current;
-  
+
     AccountMap::iterator iter = _accountMap.begin();
+
     while( iter != _accountMap.end() ) {
         current = iter->second;
+        
         if (current) {
             if ( current->isEnabled() && current->getType() == "sip") {
                 //current->setVoIPLink(link);
 	            current->registerVoIPLink();
             }
         }
+        current = NULL;
     iter++;
     }    
 }
diff --git a/src/managerimpl.h b/src/managerimpl.h
index e8267b214a9e2691e58e911cebea219b01b52024..1788d65e65459af23e7257389c9373aff31e6f53 100644
--- a/src/managerimpl.h
+++ b/src/managerimpl.h
@@ -63,9 +63,6 @@ typedef std::map<CallID, Call::CallConfiguration> CallConfigMap;
 /** Define a type for CallID vector (waiting list, incoming not answered) */
 typedef std::set<CallID> CallIDSet;
 
-/** Define a type for recorded audio file names vector */
-typedef std::map<CallID, std::string> RecFileNames; 
-
 /** To send multiple string */
 typedef std::list<std::string> TokenList;
 
@@ -1048,11 +1045,6 @@ class ManagerImpl {
      *		  false otherwise
      */
     bool accountExists(const AccountID& accountID);
-
-    /**
-     * Map the call id to coresponding call
-     */
-    RecFileNames _fileNamesMap;
     
 
 public:
diff --git a/src/plug-in/audiorecorder/audiorecord.cpp b/src/plug-in/audiorecorder/audiorecord.cpp
index aa8e064aa04bdd5358da2db969a417b6f1694448..25703101d97e04e9bae349fd92cb7009cc5181dc 100644
--- a/src/plug-in/audiorecorder/audiorecord.cpp
+++ b/src/plug-in/audiorecorder/audiorecord.cpp
@@ -161,8 +161,8 @@ bool AudioRecord::isOpenFile() {
 
 
 bool AudioRecord::isFileExist() {
+  _debug("AudioRecord::isFileExist(): try to open name : %s \n", fileName_);
   
-  printf("AudioRecord::isFileExist(): try to open name : %s \n", fileName_);
   if(fopen(fileName_,"rb")==0) {
     return true;
   }
@@ -171,7 +171,8 @@ bool AudioRecord::isFileExist() {
 }
 
 bool AudioRecord::isRecording() {
-  _debug("AudioRecording::setRecording() \n");
+  _debug("AudioRecording::isRecording() %i \n", recordingEnabled_);
+  
   
   if(recordingEnabled_)
     return true;
@@ -181,17 +182,17 @@ bool AudioRecord::isRecording() {
 
 
 bool AudioRecord::setRecording() {
-  _debug("AudioRecord::setRecording()\n");
+  _debug("AudioRecord::setRecording() \n");
   
   if (isOpenFile()){
-    _debug("AuioRecord::setRecording()::file already opened\n");
+    _debug("AuioRecord::setRecording()::file already opened \n");
     if(!recordingEnabled_)
       recordingEnabled_ = true;
     else 
       recordingEnabled_ = false;
   }
   else {
-    _debug("AudioRecord::setRecording():Opening the wave file in call during call instantiation\n");
+    _debug("AudioRecord::setRecording():Opening the wave file in call during call instantiation \n");
     openFile();
 
     recordingEnabled_ = true; // once opend file, start recording
diff --git a/src/sdp.cpp b/src/sdp.cpp
index 011875e2ef90491bac7b74e8f51711e5f600a5c7..63a5b69d58da240126aa7ebe7bc8b140e0660fcd 100644
--- a/src/sdp.cpp
+++ b/src/sdp.cpp
@@ -303,14 +303,20 @@ AudioCodec* Sdp::get_session_media( void ){
 
     int nb_media;
     int nb_codec;
+    AudioCodec *codec = NULL;
 
     nb_media = _session_media.size();
-    nb_codec = _session_media[0]->get_media_codec_list().size();
-
-    return _session_media[0]->get_media_codec_list()[0];
+    if (nb_media > 0) {
+        nb_codec = _session_media[0]->get_media_codec_list().size();
+        if (nb_codec > 0) {
+            codec = _session_media[0]->get_media_codec_list()[0];
+        }
+    }
+    return codec;
 }
 
 
+
 void Sdp::toString (void) {
 
     std::ostringstream sdp;
diff --git a/src/sipaccount.cpp b/src/sipaccount.cpp
index 61c8bfd05b2a762891c61ebd8fee8f22fd3f2dda..fc77c0450de4814c82d05b29aea2d5072e82b425 100644
--- a/src/sipaccount.cpp
+++ b/src/sipaccount.cpp
@@ -56,7 +56,7 @@ int SIPAccount::registerVoIPLink()
 
     /* Retrieve the account information */
     /* Stuff needed for SIP registration */
-    setHostname(Manager::instance().getConfigString(_accountID,HOSTNAME));
+    setHostname(Manager::instance().getConfigString(_accountID, HOSTNAME));
     setUsername(Manager::instance().getConfigString(_accountID, USERNAME));
     setPassword(Manager::instance().getConfigString(_accountID, PASSWORD));
 
@@ -69,8 +69,15 @@ int SIPAccount::registerVoIPLink()
 
 int SIPAccount::unregisterVoIPLink()
 {
-  _debug("SIPAccount: unregister account %s\n" , getAccountID().c_str());
-  return _link->sendUnregister( _accountID );
+  _debug("unregister account %s\n" , getAccountID().c_str());
+
+  _regc = NULL;
+
+  if(_link->sendUnregister( _accountID ))
+      return true;
+  else
+      return false;
+  
 }
 
 void SIPAccount::loadConfig() 
diff --git a/src/sipvoiplink.cpp b/src/sipvoiplink.cpp
index d0c6d8edbc3c55e768b7e4fa4d71e3dd7a92aebd..f7bd90921c27f63d7e2fcbe17e588e1d55b5b687 100644
--- a/src/sipvoiplink.cpp
+++ b/src/sipvoiplink.cpp
@@ -49,6 +49,8 @@ int getModId();
  *      */
 bool setCallAudioLocal(SIPCall* call, std::string localIP, bool stun, std::string server);
 
+void handle_incoming_options (pjsip_rx_data *rxdata);
+
 /*
  *  The global pool factory
  */
@@ -101,7 +103,7 @@ void call_on_state_changed( pjsip_inv_session *inv, pjsip_event *e);
 void call_on_media_update( pjsip_inv_session *inv UNUSED, pj_status_t status UNUSED);
 
 /*
- * Called when the invote usage module has created a new dialog and invite
+ * Called when the invite usage module has created a new dialog and invite
  * because of forked outgoing request.
  *
  * @param	inv	A pointer on a pjsip_inv_session structure
@@ -239,7 +241,6 @@ SIPVoIPLink::terminateSIPCall()
         call = dynamic_cast<SIPCall*>(iter->second);
         if (call) {
             // terminate the sip call
-            _debug("SIPVoIPLink::terminateSIPCall()::the call is deleted, should close recording file \n");
             delete call; call = 0;
         }
         iter++;
@@ -250,17 +251,16 @@ SIPVoIPLink::terminateSIPCall()
     void
 SIPVoIPLink::terminateOneCall(const CallID& id)
 {
-    _debug("SIPVoIPLink::terminateOneCall(): function called \n");
 
     SIPCall *call = getSIPCall(id);
     if (call) {
         // terminate the sip call
-        _debug("SIPVoIPLink::terminateOneCall()::the call is deleted, should close recording file \n");
         delete call; call = 0;
     }
 }
 
 void get_remote_sdp_from_offer( pjsip_rx_data *rdata, pjmedia_sdp_session** r_sdp ){
+
     pjmedia_sdp_session *sdp;
     pjsip_msg *msg;
     pjsip_msg_body *body;
@@ -271,9 +271,13 @@ void get_remote_sdp_from_offer( pjsip_rx_data *rdata, pjmedia_sdp_session** r_sd
     body = msg->body;
 
     // Parse the remote request to get the sdp session
-    pjmedia_sdp_parse( rdata->tp_info.pool, (char*)body->data, body->len, &sdp );
+    if (body) {   
+        pjmedia_sdp_parse( rdata->tp_info.pool, (char*)body->data, body->len, &sdp );
+        *r_sdp = sdp;
+    }
 
-    *r_sdp = sdp;
+    else
+        *r_sdp = NULL;
 }
 
     void
@@ -291,7 +295,6 @@ SIPVoIPLink::getEvent()
 
 int SIPVoIPLink::sendRegister( AccountID id )
 {
-
     pj_status_t status;
     int expire_value;
     char contactTmp[256];
@@ -301,6 +304,7 @@ int SIPVoIPLink::sendRegister( AccountID id )
     SIPAccount *account;
     pjsip_regc *regc;
 
+    
     account = dynamic_cast<SIPAccount *> (Manager::instance().getAccount(id));
     hostname = account->getHostname();
     username = account->getUsername();
@@ -312,11 +316,13 @@ int SIPVoIPLink::sendRegister( AccountID id )
     regc = account->getRegistrationInfo();
     /* If the registration already exists, delete it */
     if(regc) {
+        
         status = pjsip_regc_destroy(regc);
         regc = NULL;
         PJ_ASSERT_RETURN( status == PJ_SUCCESS, 1 );
     }
 
+
     account->setRegister(true);
 
     /* Set the expire value of the message from the config file */
@@ -325,6 +331,7 @@ int SIPVoIPLink::sendRegister( AccountID id )
     /* Update the state of the voip link */
     account->setRegistrationState(Trying);
 
+
     if (!validStunServer) {
         account->setRegistrationState(ErrorExistStun);
         account->setRegister(false);
@@ -380,7 +387,7 @@ int SIPVoIPLink::sendRegister( AccountID id )
         return false;
     }
 
-    _debug("Send the registration ######### \n");
+    
     status = pjsip_regc_send(regc, tdata);
     if (status != PJ_SUCCESS) {
         _debug("UserAgent: Unable to send regc request.\n");
@@ -828,7 +835,8 @@ SIPVoIPLink::setRecording(const CallID& id)
 {
     SIPCall* call = getSIPCall(id);
 
-    call->setRecording();
+    if(call)
+        call->setRecording();
 
     // _audiortp->setRecording();
 }
@@ -837,8 +845,11 @@ SIPVoIPLink::setRecording(const CallID& id)
 SIPVoIPLink::isRecording(const CallID& id)
 {
     SIPCall* call = getSIPCall(id);
-
-    return call->isRecording();
+    _debug("call->isRecording() %i \n",call->isRecording());
+    if(call)
+        return call->isRecording();
+    else 
+        return false;
 }
 
 
@@ -846,11 +857,17 @@ SIPVoIPLink::isRecording(const CallID& id)
 SIPVoIPLink::getCurrentCodecName()
 {
 
-    SIPCall *call = getSIPCall(Manager::instance().getCurrentCallId());  
+    SIPCall *call;
+    AudioCodec *ac;
+    std::string name = "";
+    
+    call = getSIPCall(Manager::instance().getCurrentCallId());  
+    ac = call->getLocalSDP()->get_session_media();
 
-    AudioCodec *ac = call->getLocalSDP()->get_session_media();
+    if (ac)
+        name = ac->getCodecName();
 
-    return ac->getCodecName();
+    return name;
 }
 
     bool 
@@ -953,14 +970,17 @@ SIPVoIPLink::SIPStartCall(SIPCall* call, const std::string& subject UNUSED)
     pj_strdup2(_pool, &to, strTo.data());
     pj_strdup2(_pool, &contact, account->getContact().data());
 
-    _debug("%s %s %s\n", from.ptr, contact.ptr, to.ptr);
+    //_debug("%s %s %s\n", from.ptr, contact.ptr, to.ptr);
     // create the dialog (UAC)
     status = pjsip_dlg_create_uac(pjsip_ua_instance(), &from,
             &contact,
             &to,
             NULL,
             &dialog);
-    PJ_ASSERT_RETURN(status == PJ_SUCCESS, false);
+    if (status != PJ_SUCCESS){
+        _debug ("UAC creation failed\n");
+        return false;
+    }
 
     // Create the invite session for this call
     status = pjsip_inv_create_uac(dialog, call->getLocalSDP()->get_local_sdp_session(), 0, &inv);
@@ -1366,7 +1386,7 @@ std::string SIPVoIPLink::getSipTo(const std::string& to_url, std::string hostnam
         _debug("UserAgent: VOIP callbacks initialized\n");
 
         // Add endpoint capabilities (INFO, OPTIONS, etc) for this UA
-        pj_str_t allowed[] = { {(char*)"INFO", 4}, {(char*)"REGISTER", 8} }; //  //{"INVITE", 6}, {"ACK",3}, {"BYE",3}, {"CANCEL",6},  {"OPTIONS", 7}, 
+        pj_str_t allowed[] = { {(char*)"INFO", 4}, {(char*)"REGISTER", 8}, {(char*)"OPTIONS", 7} }; //  //{"INVITE", 6}, {"ACK",3}, {"BYE",3}, {"CANCEL",6} 
         accepted = pj_str((char*)"application/sdp");
 
         // Register supported methods
@@ -1603,15 +1623,12 @@ std::string SIPVoIPLink::getSipTo(const std::string& to_url, std::string hostnam
     /*******************************/
 
     void call_on_state_changed( pjsip_inv_session *inv, pjsip_event *e){
-        _debug("call_on_state_changed!!!!!!!!!\n");
 
         SIPCall *call;
         AccountID accId;
         SIPVoIPLink *link;
         pjsip_rx_data *rdata;
 
-        _debug (" *****************************  NEW CALL STATE %i **************************\n", inv->state);        
-
         /* Retrieve the call information */
         call = reinterpret_cast<SIPCall*> (inv->mod_data[_mod_ua.id]);
         if(!call)
@@ -1679,8 +1696,8 @@ std::string SIPVoIPLink::getSipTo(const std::string& to_url, std::string hostnam
         }
         else {
 
-            // The call is ringing
-            if (inv->state == PJSIP_INV_STATE_EARLY){
+            // The call is ringing - We need to handle this case only on outgoing call
+            if (inv->state == PJSIP_INV_STATE_EARLY && e->body.tsx_state.tsx->role == PJSIP_ROLE_UAC){
                 _debug ("*************************** PJSIP_INV_STATE_EARLY - PEER RINGING ***********************************\n");
                 call->setConnectionState(Call::Ringing);
                 Manager::instance().peerRingingCall(call->getCallId());
@@ -1822,7 +1839,6 @@ void call_on_tsx_changed(pjsip_inv_session *inv, pjsip_transaction *tsx, pjsip_e
     pj_bool_t 
         mod_on_rx_request(pjsip_rx_data *rdata)
         {
-            _debug("mod_on_rx_request!!!!!!!!!\n");
 
             pj_status_t status;
             pj_str_t reason;
@@ -1894,7 +1910,6 @@ void call_on_tsx_changed(pjsip_inv_session *inv, pjsip_transaction *tsx, pjsip_e
                 method_name = "NOTIFY";  	
                 // Retrieve all the message. Should contains only the method name but ...
                 request =  rdata->msg_info.msg->line.req.method.name.ptr;
-                _debug("PRINT REQUEST: %s \n",request);
                 // Check if the message is a notification
                 if( request.find( method_name ) != (size_t)-1 ) {
                     /* Notify the right account */
@@ -1905,6 +1920,12 @@ void call_on_tsx_changed(pjsip_inv_session *inv, pjsip_transaction *tsx, pjsip_e
                 return true;
             }
 
+            // Handle an OPTIONS message
+            if (rdata->msg_info.msg->line.req.method.id == PJSIP_OPTIONS_METHOD) {
+                handle_incoming_options (rdata);
+                return true;
+            }
+
             // Respond statelessly any non-INVITE requests with 500
             if (rdata->msg_info.msg->line.req.method.id != PJSIP_INVITE_METHOD) {
                 if (rdata->msg_info.msg->line.req.method.id != PJSIP_ACK_METHOD) {
@@ -2447,6 +2468,50 @@ void call_on_tsx_changed(pjsip_inv_session *inv, pjsip_transaction *tsx, pjsip_e
 
     }
 
+    void handle_incoming_options (pjsip_rx_data *rdata) {
+        
+        pjsip_tx_data *tdata;
+        pjsip_response_addr res_addr;
+        const pjsip_hdr *cap_hdr;
+        pj_status_t status;
+
+        /* Create basic response. */
+        status = pjsip_endpt_create_response(_endpt, rdata, PJSIP_SC_OK, NULL, &tdata);
+        if (status != PJ_SUCCESS) {
+            return;
+        }
+        
+        /* Add Allow header */
+        cap_hdr = pjsip_endpt_get_capability(_endpt, PJSIP_H_ALLOW, NULL);
+        if (cap_hdr) {
+            pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*)pjsip_hdr_clone(tdata->pool, cap_hdr));
+        }
+
+        /* Add Accept header */
+        cap_hdr = pjsip_endpt_get_capability(_endpt, PJSIP_H_ACCEPT, NULL);
+        if (cap_hdr) {
+            pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*)pjsip_hdr_clone(tdata->pool, cap_hdr));
+        }
+
+        /* Add Supported header */
+        cap_hdr = pjsip_endpt_get_capability(_endpt, PJSIP_H_SUPPORTED, NULL);
+        if (cap_hdr) {
+            pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*)pjsip_hdr_clone(tdata->pool, cap_hdr));
+        }
+
+        /* Add Allow-Events header from the evsub module */
+        cap_hdr = pjsip_evsub_get_allow_events_hdr(NULL);
+        if (cap_hdr) {
+            pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*)pjsip_hdr_clone(tdata->pool, cap_hdr));
+        }
+
+        /* Send response statelessly */
+        pjsip_get_response_addr(tdata->pool, rdata, &res_addr);
+        status = pjsip_endpt_send_response(_endpt, &res_addr, tdata, NULL, NULL);
+        if (status != PJ_SUCCESS)
+            pjsip_tx_data_dec_ref(tdata);
+    }
+
     /*****************************************************************************************************************/