diff --git a/sflphone-common/libs/dbus-c++/src/eventloop.cpp b/sflphone-common/libs/dbus-c++/src/eventloop.cpp
index 30a5d6b8c37fce1e6e80d4aa99faa430a2ecc612..f74cafeaa6385fb66bf45d96f64315c25f3ec0a8 100644
--- a/sflphone-common/libs/dbus-c++/src/eventloop.cpp
+++ b/sflphone-common/libs/dbus-c++/src/eventloop.cpp
@@ -30,7 +30,7 @@
 
 #include <sys/poll.h>
 #include <sys/time.h>
-#include <unistd.h> 
+#include <unistd.h>
 
 #include <dbus/dbus.h>
 
@@ -98,9 +98,9 @@ void DefaultMutex::unlock()
 
 DefaultMainLoop::DefaultMainLoop()
 {
-    if(pipe(_terminateFd) < 0) {
+    if (pipe (_terminateFd) < 0) {
         throw ErrorFailed ("unable to create unamed pipe");
-    }  
+    }
 }
 
 DefaultMainLoop::~DefaultMainLoop()
@@ -133,23 +133,24 @@ DefaultMainLoop::~DefaultMainLoop()
         ti = tmp;
     }
 
-    close(_terminateFd[0]);
-    close(_terminateFd[1]);
-    
+    close (_terminateFd[0]);
+
+    close (_terminateFd[1]);
+
     _mutex_t.unlock();
 }
 
-void DefaultMainLoop::terminate() 
+void DefaultMainLoop::terminate()
 {
-    write(_terminateFd[1], " ", 1);
+    write (_terminateFd[1], " ", 1);
 }
 
 void DefaultMainLoop::dispatch()
-{    
+{
     _mutex_w.lock();
 
     int nfd = _watches.size() + 1;
-    
+
     pollfd fds[nfd];
 
     DefaultWatches::iterator wi = _watches.begin();
@@ -165,9 +166,10 @@ void DefaultMainLoop::dispatch()
     }
 
     fds[nfd].fd = _terminateFd[0];
+
     fds[nfd].events = POLLIN;
     fds[nfd].revents = 0;
-        
+
     _mutex_w.unlock();
 
     int wait_min = 10000;
diff --git a/sflphone-common/src/account.cpp b/sflphone-common/src/account.cpp
index 9876b4fd891f51cdf47982c89d0d0403a181cad7..9d283e8fd99739f528eca78a712385e9a893b2e0 100644
--- a/sflphone-common/src/account.cpp
+++ b/sflphone-common/src/account.cpp
@@ -23,10 +23,10 @@
 #include "manager.h"
 
 Account::Account (const AccountID& accountID, std::string type) :
-			_accountID (accountID)
-		 , _link (NULL)
-		 , _enabled (false)
-		 , _type (type)
+        _accountID (accountID)
+        , _link (NULL)
+        , _enabled (false)
+        , _type (type)
 {
     setRegistrationState (Unregistered);
 }
diff --git a/sflphone-common/src/audio/audiortp.cpp b/sflphone-common/src/audio/audiortp.cpp
index 2f0005241bb689bd35cbf1f9ef0a7fcc065ed91c..dbcd950f8f3cf0c7d5ed7a1062c3cdfd5b6a4c07 100644
--- a/sflphone-common/src/audio/audiortp.cpp
+++ b/sflphone-common/src/audio/audiortp.cpp
@@ -25,7 +25,6 @@
 #include <cstdlib>
 #include <ccrtp/rtp.h>
 #include <assert.h>
-#include <string>
 #include <cstring>
 #include <math.h>
 #include <dlfcn.h>
@@ -366,7 +365,7 @@ AudioRtpRTX::processDataEncode()
     if (_audiocodec->getClockRate() != _layerSampleRate) {
 
         int nb_sample_up = nbSample;
-         //_debug("_nbSample audiolayer->getMic(): %i \n", nbSample);
+        //_debug("_nbSample audiolayer->getMic(): %i \n", nbSample);
 
         // Store the length of the mic buffer in samples for recording
         _nSamplesMic = nbSample;
diff --git a/sflphone-common/src/audio/audiostream.cpp b/sflphone-common/src/audio/audiostream.cpp
index fe56b85ed59856f0c1faf1c39c1449bb291984a7..ffdb6e4514aa99d5713b7723af45c8ebc827fa00 100644
--- a/sflphone-common/src/audio/audiostream.cpp
+++ b/sflphone-common/src/audio/audiostream.cpp
@@ -25,13 +25,13 @@ static pa_channel_map channel_map ;
 
 AudioStream::AudioStream (PulseLayerType * driver)
         : _audiostream (NULL),
-         _context (driver->context),
-         _streamType (driver->type), 
-         _streamDescription (driver->description), 
-         _volume(),
-         flag (PA_STREAM_AUTO_TIMING_UPDATE), 
-         sample_spec(),
-         _mainloop(driver->mainloop)
+        _context (driver->context),
+        _streamType (driver->type),
+        _streamDescription (driver->description),
+        _volume(),
+        flag (PA_STREAM_AUTO_TIMING_UPDATE),
+        sample_spec(),
+        _mainloop (driver->mainloop)
 {
     sample_spec.format = PA_SAMPLE_S16LE;
     sample_spec.rate = 44100;
@@ -56,54 +56,58 @@ AudioStream::connectStream()
     return true;
 }
 
-static void success_cb(pa_stream *s, int success, void *userdata) {
+static void success_cb (pa_stream *s, int success, void *userdata)
+{
+
+    assert (s);
 
-    assert(s);
-    
     pa_threaded_mainloop * mainloop = (pa_threaded_mainloop *) userdata;
-             
-    pa_threaded_mainloop_signal(mainloop, 0);
+
+    pa_threaded_mainloop_signal (mainloop, 0);
 }
 
 
 bool
-AudioStream::drainStream(void) {    
+AudioStream::drainStream (void)
+{
     if (_audiostream) {
-        _debug("Draining stream\n");
+        _debug ("Draining stream\n");
         pa_operation * operation;
-        
-        pa_threaded_mainloop_lock(_mainloop);
-        
-        if ((operation = pa_stream_drain(_audiostream, success_cb, _mainloop))) {    
-            while (pa_operation_get_state(operation) != PA_OPERATION_DONE) {
-                if (!_context || pa_context_get_state(_context) != PA_CONTEXT_READY || !_audiostream || pa_stream_get_state(_audiostream) != PA_STREAM_READY) {
-                    _debug("Connection died: %s\n", _context ? pa_strerror(pa_context_errno(_context)) : "NULL");
-                    pa_operation_unref(operation);
+
+        pa_threaded_mainloop_lock (_mainloop);
+
+        if ( (operation = pa_stream_drain (_audiostream, success_cb, _mainloop))) {
+            while (pa_operation_get_state (operation) != PA_OPERATION_DONE) {
+                if (!_context || pa_context_get_state (_context) != PA_CONTEXT_READY || !_audiostream || pa_stream_get_state (_audiostream) != PA_STREAM_READY) {
+                    _debug ("Connection died: %s\n", _context ? pa_strerror (pa_context_errno (_context)) : "NULL");
+                    pa_operation_unref (operation);
                     break;
                 } else {
-                    pa_threaded_mainloop_wait(_mainloop);
+                    pa_threaded_mainloop_wait (_mainloop);
                 }
             }
         }
-        
-        pa_threaded_mainloop_unlock(_mainloop);
+
+        pa_threaded_mainloop_unlock (_mainloop);
     }
 
-	return true;
+    return true;
 }
 
 bool
 AudioStream::disconnectStream (void)
 {
     _debug ("Destroy audio streams\n");
-    
-    pa_threaded_mainloop_lock(_mainloop);
-    if(_audiostream) {
+
+    pa_threaded_mainloop_lock (_mainloop);
+
+    if (_audiostream) {
         pa_stream_disconnect (_audiostream);
         pa_stream_unref (_audiostream);
         _audiostream = NULL;
     }
-    pa_threaded_mainloop_unlock(_mainloop);
+
+    pa_threaded_mainloop_unlock (_mainloop);
 
     return true;
 }
@@ -114,12 +118,12 @@ void
 AudioStream::stream_state_callback (pa_stream* s, void* user_data)
 {
     pa_threaded_mainloop *m;
-    
+
     _debug ("AudioStream::stream_state_callback :: The state of the stream changed\n");
     assert (s);
 
     m = (pa_threaded_mainloop*) user_data;
-    assert(m);
+    assert (m);
 
     switch (pa_stream_get_state (s)) {
 
diff --git a/sflphone-common/src/audio/codecs/g722.cpp b/sflphone-common/src/audio/codecs/g722.cpp
index 9b509cf2477212c22703dba20ef74094b617b283..a95a0a865304dfcd0b72eb46579fe4219a04e118 100644
--- a/sflphone-common/src/audio/codecs/g722.cpp
+++ b/sflphone-common/src/audio/codecs/g722.cpp
@@ -335,13 +335,13 @@ class G722 : public AudioCodec
 
         int g722_encode_release() {
             delete decode_s;
-			return 0;
+            return 0;
         }
 
 
         int g722_decode_release() {
             delete encode_s;
-			return 0;
+            return 0;
         }
 
         int g722_decode (int16_t amp[], const uint8_t g722_data[], int len) {
diff --git a/sflphone-common/src/audio/pulselayer.cpp b/sflphone-common/src/audio/pulselayer.cpp
index d3ff6eb9f4534e535dd9fdcf7fb8a71ee22ec674..c78724a825323ad5ed938ab1449881e4c97720b0 100644
--- a/sflphone-common/src/audio/pulselayer.cpp
+++ b/sflphone-common/src/audio/pulselayer.cpp
@@ -51,31 +51,32 @@ bool
 PulseLayer::closeLayer (void)
 {
     _debug ("PulseLayer::closeLayer :: Destroy pulselayer\n");
-    
-    // Commenting the line below will make the 
-    // PulseLayer to close immediately, not 
-    // waiting for the playback buffer to be 
-    // emptied. It should not hurt. 
+
+    // Commenting the line below will make the
+    // PulseLayer to close immediately, not
+    // waiting for the playback buffer to be
+    // emptied. It should not hurt.
     playback->drainStream();
 
-    if(m) {
-        pa_threaded_mainloop_stop(m);
+    if (m) {
+        pa_threaded_mainloop_stop (m);
     }
-    
+
     playback->disconnectStream();
+
     record->disconnectStream();
-        
-    if(context) {
+
+    if (context) {
         pa_context_disconnect (context);
         pa_context_unref (context);
         context = NULL;
     }
-   
-    if(m) { 
+
+    if (m) {
         pa_threaded_mainloop_free (m);
         m = NULL;
     }
-    
+
     return true;
 }
 
@@ -177,7 +178,7 @@ bool PulseLayer::createStreams (pa_context* c)
     playbackParam->description = PLAYBACK_STREAM_NAME;
     playbackParam->volume = _manager->getSpkrVolume();
     playbackParam->mainloop = m;
-    
+
     playback = new AudioStream (playbackParam);
     playback->connectStream();
     pa_stream_set_write_callback (playback->pulseStream(), audioCallback, this);
@@ -189,7 +190,7 @@ bool PulseLayer::createStreams (pa_context* c)
     recordParam->description = CAPTURE_STREAM_NAME;
     recordParam->volume = _manager->getMicVolume();
     recordParam->mainloop = m;
-    
+
     record = new AudioStream (recordParam);
     record->connectStream();
     pa_stream_set_read_callback (record->pulseStream() , audioCallback, this);
@@ -229,7 +230,7 @@ bool PulseLayer::openDevice (int indexIn UNUSED, int indexOut UNUSED, int sample
 
     _debug ("Connection Done!! \n");
 
-	return true;
+    return true;
 }
 
 void PulseLayer::closeCaptureStream (void)
diff --git a/sflphone-common/src/config/config.cpp b/sflphone-common/src/config/config.cpp
index 4f8c02c8de554f762e1963133d452c67122e1654..6e54c127a7b72bf94cc41704e3d8b681eba31716 100644
--- a/sflphone-common/src/config/config.cpp
+++ b/sflphone-common/src/config/config.cpp
@@ -258,11 +258,11 @@ ConfigTree::saveConfigTree (const std::string& fileName)
     }
 
     file.close();
-    
-    if(chmod(fileName.c_str(), S_IRUSR | S_IWUSR)) {
-        _debug("Failed to set permission on configuration file because: %s\n",strerror(errno));
+
+    if (chmod (fileName.c_str(), S_IRUSR | S_IWUSR)) {
+        _debug ("Failed to set permission on configuration file because: %s\n",strerror (errno));
     }
-    
+
     return true;
 }
 
@@ -274,7 +274,7 @@ int
 ConfigTree::populateFromFile (const std::string& fileName)
 {
     bool out = false;
-    
+
     if (fileName.empty()) {
         return 0;
     }
@@ -339,11 +339,11 @@ ConfigTree::populateFromFile (const std::string& fileName)
     }
 
     file.close();
-    
-    if(chmod(fileName.c_str(), S_IRUSR | S_IWUSR)) {
-        _debug("Failed to set permission on configuration file because: %s\n",strerror(errno));
+
+    if (chmod (fileName.c_str(), S_IRUSR | S_IWUSR)) {
+        _debug ("Failed to set permission on configuration file because: %s\n",strerror (errno));
     }
-    
+
     return 1;
 }
 
diff --git a/sflphone-common/src/config/config.h b/sflphone-common/src/config/config.h
index 0fa75a24acd2e580d1ddb457179f8091507f6d3b..0872889486659d2a7db64634106f36fcb58ce3a0 100644
--- a/sflphone-common/src/config/config.h
+++ b/sflphone-common/src/config/config.h
@@ -155,7 +155,7 @@ class ConfigTree
          * List of sections. Each sections has an ItemList as child
          */
         SectionMap _sections;
-        
+
         friend class ConfigTreeIterator;
 
     public:
diff --git a/sflphone-common/src/history/historyitem.cpp b/sflphone-common/src/history/historyitem.cpp
index fd33f8de345cd36b6154bda152c023ed88b6d7d4..d8d12d7232d90b0f26b8159118e0fa7232a5ff58 100644
--- a/sflphone-common/src/history/historyitem.cpp
+++ b/sflphone-common/src/history/historyitem.cpp
@@ -27,12 +27,12 @@
 #define EMPTY_STRING        "empty"
 
 HistoryItem::HistoryItem (std::string timestamp_start, CallType call_type, std::string timestamp_stop, std::string name, std::string number, std::string account_id)
-        :	_timestamp_start (timestamp_start), 
-			_timestamp_stop (timestamp_stop), 
-			_call_type (call_type), 
-			_name (name), 
-			_number (number), 
-			_account_id (account_id)
+        :	_timestamp_start (timestamp_start),
+        _timestamp_stop (timestamp_stop),
+        _call_type (call_type),
+        _name (name),
+        _number (number),
+        _account_id (account_id)
 {
 }
 
diff --git a/sflphone-common/src/history/historymanager.cpp b/sflphone-common/src/history/historymanager.cpp
index f2fda5c38bfa545eafbbc7791d456ae1f1dcbdd1..ecc07d632884fed39402e54b3b9d938c7994d3c8 100644
--- a/sflphone-common/src/history/historymanager.cpp
+++ b/sflphone-common/src/history/historymanager.cpp
@@ -23,9 +23,9 @@
 #include <cc++/file.h>
 #include <time.h>
 
-HistoryManager::HistoryManager () 
-	:	_history_loaded (false), 
-		_history_path ("")
+HistoryManager::HistoryManager ()
+        :	_history_loaded (false),
+        _history_path ("")
 {
 
 }
diff --git a/sflphone-common/src/main.cpp b/sflphone-common/src/main.cpp
index 2ff273978514238287f68fc5f182bddaab85089d..dd7b3855ac2eea2812acf7d5c1c15847749626f6 100644
--- a/sflphone-common/src/main.cpp
+++ b/sflphone-common/src/main.cpp
@@ -86,29 +86,30 @@ main (int argc, char **argv)
             }
         } else {
             // PID file exists. Check the former process still alive or not. If alive, give user a hint.
-			char *res;
+            char *res;
             res = fgets (cOldPid, 64, fp);
+
             if (res == NULL)	perror ("Error getting string from stream");
-			
-			else
-			{
-				fclose (fp);
-
-				if (kill (atoi (cOldPid), 0) == SUCCESS) {
-					fprintf (stderr, "There is already a sflphoned daemon running in the system. Starting Failed.\n");
-					exit (-1);
-				} else {
-					if ( (fp = fopen (homepid,"w")) == NULL) {
-						fprintf (stderr, "Writing to PID file %s failed. Exited.\n", homepid);
-						exit (-1);
-					} else {
-						fputs (cPid , fp);
-						fclose (fp);
-					}
-
-				}
-			}
-		}
+
+            else {
+                fclose (fp);
+
+                if (kill (atoi (cOldPid), 0) == SUCCESS) {
+                    fprintf (stderr, "There is already a sflphoned daemon running in the system. Starting Failed.\n");
+                    exit (-1);
+                } else {
+                    if ( (fp = fopen (homepid,"w")) == NULL) {
+                        fprintf (stderr, "Writing to PID file %s failed. Exited.\n", homepid);
+                        exit (-1);
+                    } else {
+                        fputs (cPid , fp);
+                        fclose (fp);
+                    }
+
+                }
+            }
+        }
+
         int sessionPort = 0;
 
         if (argc == 2) {
diff --git a/sflphone-common/src/managerimpl.cpp b/sflphone-common/src/managerimpl.cpp
index 654a173d7fc1ec4ab2a4ea203bdbcfc6b287e5c3..0ca48a06ce1fda0cdcffed2c83929781e5c24adf 100644
--- a/sflphone-common/src/managerimpl.cpp
+++ b/sflphone-common/src/managerimpl.cpp
@@ -1620,14 +1620,14 @@ ManagerImpl::getAudioOutputDeviceList (void)
 {
     _debug ("Get audio output device list\n");
     AlsaLayer *layer;
-	std::vector <std::string> devices;
+    std::vector <std::string> devices;
 
     layer = dynamic_cast<AlsaLayer*> (getAudioDriver ());
 
     if (layer)
-		devices = layer -> getSoundCardsInfo (SFL_PCM_PLAYBACK);
+        devices = layer -> getSoundCardsInfo (SFL_PCM_PLAYBACK);
 
-	return devices;
+    return devices;
 }
 
 /**
@@ -1661,14 +1661,14 @@ std::vector<std::string>
 ManagerImpl::getAudioInputDeviceList (void)
 {
     AlsaLayer *audiolayer;
-	std::vector <std::string> devices;
+    std::vector <std::string> devices;
 
     audiolayer = dynamic_cast<AlsaLayer *> (getAudioDriver());
 
     if (audiolayer)
-		devices = audiolayer->getSoundCardsInfo (SFL_PCM_CAPTURE);
+        devices = audiolayer->getSoundCardsInfo (SFL_PCM_CAPTURE);
 
-	return devices;
+    return devices;
 }
 
 /**
@@ -1950,7 +1950,7 @@ void ManagerImpl::setAudioManager (const int32_t& api)
 
     switchAudioManager();
     return;
-    
+
 }
 
 int32_t
@@ -1983,10 +1983,10 @@ ManagerImpl::getAudioDeviceIndex (const std::string name)
 
     alsalayer = dynamic_cast<AlsaLayer *> (getAudioDriver());
 
-    if (alsalayer)   
-		return alsalayer -> soundCardGetIndex (name);
-	else
-		return 0;
+    if (alsalayer)
+        return alsalayer -> soundCardGetIndex (name);
+    else
+        return 0;
 }
 
 std::string
@@ -2205,9 +2205,9 @@ void ManagerImpl::setMicVolume (unsigned short mic_vol)
 
 void ManagerImpl::setSipPort (int port)
 {
-    _debug("Setting to new port %d\n", port);
-    setConfig(PREFERENCES, CONFIG_SIP_PORT, port);
-    
+    _debug ("Setting to new port %d\n", port);
+    setConfig (PREFERENCES, CONFIG_SIP_PORT, port);
+
     this->restartPJSIP ();
 }
 
@@ -2464,12 +2464,13 @@ std::map< std::string, std::string > ManagerImpl::getAccountDetails (const Accou
     a.insert (std::pair<std::string, std::string> (PASSWORD, getConfigString (accountID, PASSWORD)));
     a.insert (std::pair<std::string, std::string> (HOSTNAME, getConfigString (accountID, HOSTNAME)));
     a.insert (std::pair<std::string, std::string> (CONFIG_ACCOUNT_MAILBOX, getConfigString (accountID, CONFIG_ACCOUNT_MAILBOX)));
-    
+
     if (getConfigString (accountID, CONFIG_ACCOUNT_REGISTRATION_EXPIRE).empty()) {
         a.insert (std::pair<std::string, std::string> (CONFIG_ACCOUNT_REGISTRATION_EXPIRE, DFT_EXPIRE_VALUE));
     } else {
         a.insert (std::pair<std::string, std::string> (CONFIG_ACCOUNT_REGISTRATION_EXPIRE, getConfigString (accountID, CONFIG_ACCOUNT_REGISTRATION_EXPIRE)));
     }
+
     return a;
 }
 
@@ -2682,7 +2683,7 @@ ManagerImpl::loadAccountMap()
     short nbAccount = 0;
     TokenList sections = _config.getSections();
     std::string accountType;
-	Account *tmpAccount = 0;
+    Account *tmpAccount = 0;
     std::vector <std::string> account_order;
 
     TokenList::iterator iter = sections.begin();
diff --git a/sflphone-common/src/plug-in/audiorecorder/audiorecord.cpp b/sflphone-common/src/plug-in/audiorecorder/audiorecord.cpp
index 998f91c3b0b4c508180da3133a0b6e7d13ebfe3a..603da3a40c2fe4eccd014cac1bd50c5f50e8d17d 100644
--- a/sflphone-common/src/plug-in/audiorecorder/audiorecord.cpp
+++ b/sflphone-common/src/plug-in/audiorecorder/audiorecord.cpp
@@ -207,8 +207,8 @@ bool AudioRecord::setRecording()
         recordingEnabled_ = true; // once opend file, start recording
     }
 
-	// WARNING: Unused return value
-	return true;
+    // WARNING: Unused return value
+    return true;
 
 }
 
@@ -348,7 +348,7 @@ bool AudioRecord::openExistingRawFile()
         return false;
     }
 
-	return true;
+    return true;
 }
 
 
@@ -391,7 +391,7 @@ bool AudioRecord::openExistingWavFile()
     if (fseek (fp, 4 , SEEK_END) != 0)
         _debug ("AudioRecors::OpenExistingWavFile : 2.Couldn't seek at the en of the file \n");
 
-	return true;
+    return true;
 
 }
 
diff --git a/sflphone-common/src/sdp.cpp b/sflphone-common/src/sdp.cpp
index 64ef13ad7016794e407171685bbbf8d42d1ff3dc..24d4368a100d2f400b560d93d39aed372409fa01 100644
--- a/sflphone-common/src/sdp.cpp
+++ b/sflphone-common/src/sdp.cpp
@@ -35,14 +35,14 @@ static const pj_str_t STR_RTPMAP = { (char*) "rtpmap", 6 };
 
 
 Sdp::Sdp (pj_pool_t *pool)
-		: _local_media_cap()
-		, _session_media (0)
-		, _negociator (NULL)
-		, _ip_addr ("")
-		, _local_offer (NULL)
-		, _negociated_offer (NULL)
-		, _pool (NULL)
-		, _local_extern_audio_port (0)
+        : _local_media_cap()
+        , _session_media (0)
+        , _negociator (NULL)
+        , _ip_addr ("")
+        , _local_offer (NULL)
+        , _negociated_offer (NULL)
+        , _pool (NULL)
+        , _local_extern_audio_port (0)
 {
     _pool = pool;
 }
@@ -211,60 +211,63 @@ int Sdp::receiving_initial_offer (pjmedia_sdp_session* remote)
     return PJ_SUCCESS;
 }
 
-pj_status_t Sdp::check_sdp_answer(pjsip_inv_session *inv, pjsip_rx_data *rdata) 
+pj_status_t Sdp::check_sdp_answer (pjsip_inv_session *inv, pjsip_rx_data *rdata)
 {
     static const pj_str_t str_application = { (char*) "application", 11 };
     static const pj_str_t str_sdp = { (char*) "sdp", 3 };
     pj_status_t status;
     pjsip_msg * message = NULL;
     pjmedia_sdp_session * remote_sdp = NULL;
-    
-    if (pjmedia_sdp_neg_get_state(inv->neg) == PJMEDIA_SDP_NEG_STATE_LOCAL_OFFER) {
-    
+
+    if (pjmedia_sdp_neg_get_state (inv->neg) == PJMEDIA_SDP_NEG_STATE_LOCAL_OFFER) {
+
         message = rdata->msg_info.msg;
-    
-        if(message == NULL) {
-            _debug("No message");
+
+        if (message == NULL) {
+            _debug ("No message");
             return PJMEDIA_SDP_EINSDP;
         }
 
         if (message->body == NULL) {
-            _debug("Empty message body\n");
+            _debug ("Empty message body\n");
             return PJMEDIA_SDP_EINSDP;
         }
 
-        if (pj_stricmp(&message->body->content_type.type, &str_application) || pj_stricmp(&message->body->content_type.subtype, &str_sdp)) {
-            _debug("Incoming Message does not contain SDP\n");
+        if (pj_stricmp (&message->body->content_type.type, &str_application) || pj_stricmp (&message->body->content_type.subtype, &str_sdp)) {
+            _debug ("Incoming Message does not contain SDP\n");
             return PJMEDIA_SDP_EINSDP;
         }
 
         // Parse the SDP body.
-        status = pjmedia_sdp_parse(rdata->tp_info.pool, (char*)message->body->data, message->body->len, &remote_sdp);
+        status = pjmedia_sdp_parse (rdata->tp_info.pool, (char*) message->body->data, message->body->len, &remote_sdp);
+
         if (status == PJ_SUCCESS) {
-            status = pjmedia_sdp_validate(remote_sdp);
+            status = pjmedia_sdp_validate (remote_sdp);
         }
 
         if (status != PJ_SUCCESS) {
-            _debug("SDP cannot be validated\n");
+            _debug ("SDP cannot be validated\n");
             return PJMEDIA_SDP_EINSDP;
         }
-    
+
         // This is an answer
-        _debug("Got SDP answer %s\n", pjsip_rx_data_get_info(rdata));
-        status = pjmedia_sdp_neg_set_remote_answer(inv->pool, inv->neg, remote_sdp);
-        
+        _debug ("Got SDP answer %s\n", pjsip_rx_data_get_info (rdata));
+
+        status = pjmedia_sdp_neg_set_remote_answer (inv->pool, inv->neg, remote_sdp);
+
         if (status != PJ_SUCCESS) {
-            _debug("An error occured while processing remote answer %s\n", pjsip_rx_data_get_info(rdata));
+            _debug ("An error occured while processing remote answer %s\n", pjsip_rx_data_get_info (rdata));
             return PJMEDIA_SDP_EINSDP;
         }
-        
+
         // Prefer our codecs to remote when possible
-        pjmedia_sdp_neg_set_prefer_remote_codec_order(inv->neg, 0);
-        
-        status = pjmedia_sdp_neg_negotiate(inv->pool, inv->neg, 0);
-        _debug("Negotiation returned with status %d PJ_SUCCESS being %d\n", status, PJ_SUCCESS); 
+        pjmedia_sdp_neg_set_prefer_remote_codec_order (inv->neg, 0);
+
+        status = pjmedia_sdp_neg_negotiate (inv->pool, inv->neg, 0);
+
+        _debug ("Negotiation returned with status %d PJ_SUCCESS being %d\n", status, PJ_SUCCESS);
     }
-    
+
     return status;
 }
 
@@ -531,7 +534,7 @@ std::string Sdp::convert_int_to_string (int value)
 void Sdp::set_remote_ip_from_sdp (const pjmedia_sdp_session *r_sdp)
 {
 
-    std::string remote_ip(r_sdp->conn->addr.ptr, r_sdp->conn->addr.slen);
+    std::string remote_ip (r_sdp->conn->addr.ptr, r_sdp->conn->addr.slen);
     _debug ("            Remote IP from fetching SDP: %s\n", remote_ip.c_str());
     this->set_remote_ip (remote_ip);
 }
diff --git a/sflphone-common/src/sipaccount.cpp b/sflphone-common/src/sipaccount.cpp
index 7618e16b331f6bde43ea28f6f57efd225e77a526..ce4bc97075951ce92acb92387e18b60395e232a0 100644
--- a/sflphone-common/src/sipaccount.cpp
+++ b/sflphone-common/src/sipaccount.cpp
@@ -57,22 +57,26 @@ int SIPAccount::registerVoIPLink()
 
     /* Retrieve the account information */
     /* Stuff needed for SIP registration */
+
     if (Manager::instance().getConfigString (_accountID, HOSTNAME).length() >= PJ_MAX_HOSTNAME) {
         return !SUCCESS;
-    } 
-    
+    }
+
     setHostname (Manager::instance().getConfigString (_accountID, HOSTNAME));
+
     setUsername (Manager::instance().getConfigString (_accountID, USERNAME));
     setPassword (Manager::instance().getConfigString (_accountID, PASSWORD));
     _resolveOnce = Manager::instance().getConfigString (_accountID, CONFIG_ACCOUNT_RESOLVE_ONCE) == "1" ? true : false;
+
     if (Manager::instance().getConfigString (_accountID, CONFIG_ACCOUNT_REGISTRATION_EXPIRE).empty()) {
         _registrationExpire = DFT_EXPIRE_VALUE;
     } else {
         _registrationExpire = Manager::instance().getConfigString (_accountID, CONFIG_ACCOUNT_REGISTRATION_EXPIRE);
     }
-    
+
     /* Start registration */
     status = _link->sendRegister (_accountID);
+
     ASSERT (status , SUCCESS);
 
     return SUCCESS;
diff --git a/sflphone-common/src/sipvoiplink.cpp b/sflphone-common/src/sipvoiplink.cpp
index b3e32c2382e9761c42c8889a7bb0b6e498e801bf..1a5fa6f93250a75743cfeb4651d9b5f70062677a 100644
--- a/sflphone-common/src/sipvoiplink.cpp
+++ b/sflphone-common/src/sipvoiplink.cpp
@@ -32,30 +32,29 @@
 
 #define CAN_REINVITE        1
 
-static char * invitationStateMap[] = { 
-(char*) "PJSIP_INV_STATE_NULL", 
-(char*) "PJSIP_INV_STATE_CALLING", 
-(char*) "PJSIP_INV_STATE_INCOMING", 
-(char*) "PJSIP_INV_STATE_EARLY", 
-(char*) "PJSIP_INV_STATE_CONNECTING", 
-(char*) "PJSIP_INV_STATE_CONFIRMED", 
-(char*) "PJSIP_INV_STATE_DISCONNECTED" 
+static char * invitationStateMap[] = {
+    (char*) "PJSIP_INV_STATE_NULL",
+    (char*) "PJSIP_INV_STATE_CALLING",
+    (char*) "PJSIP_INV_STATE_INCOMING",
+    (char*) "PJSIP_INV_STATE_EARLY",
+    (char*) "PJSIP_INV_STATE_CONNECTING",
+    (char*) "PJSIP_INV_STATE_CONFIRMED",
+    (char*) "PJSIP_INV_STATE_DISCONNECTED"
 };
-                                       
+
 static char * transactionStateMap[] = {
-(char*) "PJSIP_TSX_STATE_NULL" ,	
-(char*) "PJSIP_TSX_STATE_CALLING", 	
-(char*) "PJSIP_TSX_STATE_TRYING", 	
-(char*) "PJSIP_TSX_STATE_PROCEEDING", 	
-(char*) "PJSIP_TSX_STATE_COMPLETED", 	
-(char*) "PJSIP_TSX_STATE_CONFIRMED", 	
-(char*) "PJSIP_TSX_STATE_TERMINATED", 	
-(char*) "PJSIP_TSX_STATE_DESTROYED", 	
-(char*) "PJSIP_TSX_STATE_MAX" 
+    (char*) "PJSIP_TSX_STATE_NULL" ,
+    (char*) "PJSIP_TSX_STATE_CALLING",
+    (char*) "PJSIP_TSX_STATE_TRYING",
+    (char*) "PJSIP_TSX_STATE_PROCEEDING",
+    (char*) "PJSIP_TSX_STATE_COMPLETED",
+    (char*) "PJSIP_TSX_STATE_CONFIRMED",
+    (char*) "PJSIP_TSX_STATE_TERMINATED",
+    (char*) "PJSIP_TSX_STATE_DESTROYED",
+    (char*) "PJSIP_TSX_STATE_MAX"
 };
 
-struct result
-{
+struct result {
     pj_status_t             status;
     pjsip_server_addresses  servers;
 };
@@ -172,7 +171,7 @@ void regc_cb (struct pjsip_regc_cbparam *param);
 /*
  * DNS Callback used in workaround for bug #1852
  */
-static void dns_cb(pj_status_t status, void *token, const struct pjsip_server_addresses *addr);
+static void dns_cb (pj_status_t status, void *token, const struct pjsip_server_addresses *addr);
 
 /*
  * Called to handle incoming requests outside dialogs
@@ -251,7 +250,7 @@ bool SIPVoIPLink::init()
         return false;
 
     _regPort = Manager::instance().getSipPort();
-    
+
     /* Instanciate the C++ thread */
     _evThread = new EventThread (this);
 
@@ -364,12 +363,12 @@ int SIPVoIPLink::sendRegister (AccountID id)
 {
     int expire_value;
     char contactTmp[256];
-    
+
     pj_status_t status;
     pj_str_t svr, aor, contact, useragent;
     pjsip_tx_data *tdata;
     pjsip_host_info destination;
-    
+
     std::string tmp, hostname, username, password;
     SIPAccount *account = NULL;
     pjsip_regc *regc;
@@ -377,48 +376,52 @@ int SIPVoIPLink::sendRegister (AccountID id)
     pjsip_hdr hdr_list;
 
     account = dynamic_cast<SIPAccount *> (Manager::instance().getAccount (id));
-    if(account == NULL) {
-        _debug("In sendRegister: account is null");
-        return false; 
+
+    if (account == NULL) {
+        _debug ("In sendRegister: account is null");
+        return false;
     }
-    
-    if(account->isResolveOnce()) {
+
+    if (account->isResolveOnce()) {
+
         struct result result;
         destination.type = PJSIP_TRANSPORT_UNSPECIFIED;
-        destination.flag = pjsip_transport_get_flag_from_type(PJSIP_TRANSPORT_UNSPECIFIED);    
-        destination.addr.host = pj_str(const_cast<char*> ((account->getHostname()).c_str()));
+        destination.flag = pjsip_transport_get_flag_from_type (PJSIP_TRANSPORT_UNSPECIFIED);
+        destination.addr.host = pj_str (const_cast<char*> ( (account->getHostname()).c_str()));
         destination.addr.port = 0;
-        
+
         result.status = 0x12345678;
-        
-        pjsip_endpt_resolve(_endpt, _pool, &destination, &result, &dns_cb);
-        
+
+        pjsip_endpt_resolve (_endpt, _pool, &destination, &result, &dns_cb);
+
         /* The following magic number and construct are inspired from dns_test.c
          * in test-pjsip directory.
          */
+
         while (result.status == 0x12345678) {
             pj_time_val timeout = { 1, 0 };
-            pjsip_endpt_handle_events(_endpt, &timeout);
-            _debug("status : %d\n", result.status);	
+            pjsip_endpt_handle_events (_endpt, &timeout);
+            _debug ("status : %d\n", result.status);
         }
-        
-        if(result.status != PJ_SUCCESS) {
-            _debug("Failed to resolve hostname only once."
-                   " Default resolver will be used on"
-                   " hostname for all requests.\n");
+
+        if (result.status != PJ_SUCCESS) {
+            _debug ("Failed to resolve hostname only once."
+                    " Default resolver will be used on"
+                    " hostname for all requests.\n");
         } else {
-            _debug("%d servers where obtained from name resolution.\n", result.servers.count);
+            _debug ("%d servers where obtained from name resolution.\n", result.servers.count);
             char addr_buf[80];
-            
-            pj_sockaddr_print((pj_sockaddr_t*) &result.servers.entry[0].addr, addr_buf, sizeof(addr_buf), 3);
-            account->setHostname(addr_buf);
+
+            pj_sockaddr_print ( (pj_sockaddr_t*) &result.servers.entry[0].addr, addr_buf, sizeof (addr_buf), 3);
+            account->setHostname (addr_buf);
         }
-    } 
-    
+    }
+
     hostname = account->getHostname();
+
     username = account->getUsername();
-    password = account->getPassword(); 
-    
+    password = account->getPassword();
+
     _mutexSIP.enterMutex();
 
     /* Get the client registration information for this particular account */
@@ -433,9 +436,10 @@ int SIPVoIPLink::sendRegister (AccountID id)
     account->setRegister (true);
 
     /* Set the expire value of the message from the config file */
-    istringstream stream(account->getRegistrationExpire());
+    istringstream stream (account->getRegistrationExpire());
     stream >> expire_value;
-    if(!expire_value) {
+
+    if (!expire_value) {
         expire_value = PJSIP_REGC_EXPIRATION_NOT_SPECIFIED;
     }
 
@@ -1882,7 +1886,7 @@ bool SIPVoIPLink::pjsip_shutdown (void)
     pj_shutdown();
 
     /* Done. */
-	return true;
+    return true;
 }
 
 int getModId()
@@ -1890,13 +1894,15 @@ int getModId()
     return _mod_ua.id;
 }
 
-static void dns_cb(pj_status_t status, void *token, const struct pjsip_server_addresses *addr)
+static void dns_cb (pj_status_t status, void *token, const struct pjsip_server_addresses *addr)
 {
+
     struct result * result = (struct result*) token;
 
     result->status = status;
+
     if (status == PJ_SUCCESS) {
-        pj_memcpy(&result->servers, addr, sizeof(*addr));
+        pj_memcpy (&result->servers, addr, sizeof (*addr));
     }
 }
 
@@ -1961,7 +1967,7 @@ void call_on_state_changed (pjsip_inv_session *inv, pjsip_event *e)
     SIPVoIPLink *link;
     pjsip_rx_data *rdata;
     pj_status_t status;
-    
+
     /* Retrieve the call information */
     call = reinterpret_cast<SIPCall*> (inv->mod_data[_mod_ua.id]);
 
@@ -1971,7 +1977,7 @@ void call_on_state_changed (pjsip_inv_session *inv, pjsip_event *e)
     //Retrieve the body message
     rdata = e->body.tsx_state.src.rdata;
 
-    
+
     /* If this is an outgoing INVITE that was created because of
      * REFER/transfer, send NOTIFY to transferer.
      */
@@ -2032,23 +2038,26 @@ void call_on_state_changed (pjsip_inv_session *inv, pjsip_event *e)
                 }
             }
         }
-        
+
         return;
     }
-    
+
     // 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) {
         call->setConnectionState (Call::Ringing);
         Manager::instance().peerRingingCall (call->getCallId());
-    } 
+    }
+
     // After 2xx is sent/received.
     else if (inv->state == PJSIP_INV_STATE_CONNECTING) {
-        status = call->getLocalSDP()->check_sdp_answer (inv, rdata);    
+        status = call->getLocalSDP()->check_sdp_answer (inv, rdata);
+
         if (status != PJ_SUCCESS) {
-            _debug("Failed to check_incoming_sdp in call_on_state_changed\n");
+            _debug ("Failed to check_incoming_sdp in call_on_state_changed\n");
             return;
         }
     }
+
     // After we sent or received a ACK - The connection is established
     else if (inv->state == PJSIP_INV_STATE_CONFIRMED) {
 
@@ -2062,15 +2071,17 @@ void call_on_state_changed (pjsip_inv_session *inv, pjsip_event *e)
 
         if (link)
             link->SIPCallAnswered (call, rdata);
-    }
-    else if (inv->state == PJSIP_INV_STATE_DISCONNECTED) {
+    } else if (inv->state == PJSIP_INV_STATE_DISCONNECTED) {
         _debug ("Invitation falled in state \"disconnected\".\n");
         _debug ("State: %i, Disconnection cause: %i\n", inv->state, inv->cause);
 
         switch (inv->cause) {
                 /* The call terminates normally - BYE / CANCEL */
+
             case PJSIP_SC_OK:
+
             case PJSIP_SC_DECLINE:
+
             case PJSIP_SC_REQUEST_TERMINATED:
                 accId = Manager::instance().getAccountFromCall (call->getCallId());
                 link = dynamic_cast<SIPVoIPLink *> (Manager::instance().getAccountLink (accId));
@@ -2080,13 +2091,21 @@ void call_on_state_changed (pjsip_inv_session *inv, pjsip_event *e)
                 }
 
                 break;
-             /* The call connection failed */
+
+                /* The call connection failed */
+
             case PJSIP_SC_NOT_FOUND:            /* peer not found */
+
             case PJSIP_SC_REQUEST_TIMEOUT:      /* request timeout */
+
             case PJSIP_SC_NOT_ACCEPTABLE_HERE:  /* no compatible codecs */
+
             case PJSIP_SC_NOT_ACCEPTABLE_ANYWHERE:
+
             case PJSIP_SC_UNSUPPORTED_MEDIA_TYPE:
+
             case PJSIP_SC_UNAUTHORIZED:
+
             case PJSIP_SC_REQUEST_PENDING:
                 accId = Manager::instance().getAccountFromCall (call->getCallId());
                 link = dynamic_cast<SIPVoIPLink *> (Manager::instance().getAccountLink (accId));
@@ -2096,25 +2115,26 @@ void call_on_state_changed (pjsip_inv_session *inv, pjsip_event *e)
                 }
 
                 break;
+
             default:
                 _debug ("sipvoiplink.cpp - line %d : Unhandled call state. This is probably a bug.\n", __LINE__);
                 break;
         }
     }
-  
+
 }
 
 // This callback is called after SDP offer/answer session has completed.
 void call_on_media_update (pjsip_inv_session *inv, pj_status_t status)
 {
     _debug ("call_on_media_update\n");
-    
+
     const pjmedia_sdp_session *local_sdp;
     const pjmedia_sdp_session *remote_sdp;
-    
+
     SIPVoIPLink * link = NULL;
     SIPCall * call;
-    
+
     call = reinterpret_cast<SIPCall *> (inv->mod_data[getModId() ]);
 
     if (!call) {
@@ -2122,39 +2142,41 @@ void call_on_media_update (pjsip_inv_session *inv, pj_status_t status)
         return;
     }
 
-    link = dynamic_cast<SIPVoIPLink *> (Manager::instance().getAccountLink(AccountNULL));
-    if(link == NULL) {
+    link = dynamic_cast<SIPVoIPLink *> (Manager::instance().getAccountLink (AccountNULL));
+
+    if (link == NULL) {
         _debug ("Failed to get sip link\n");
         return;
     }
-    
+
     if (status != PJ_SUCCESS) {
         _debug ("Error while negotiating the offer\n");
-        link->hangup(call->getCallId());
-        Manager::instance().callFailure(call->getCallId());
+        link->hangup (call->getCallId());
+        Manager::instance().callFailure (call->getCallId());
         return;
     }
 
     // Get the new sdp, result of the negotiation
-    pjmedia_sdp_neg_get_active_local  (inv->neg, &local_sdp);
+    pjmedia_sdp_neg_get_active_local (inv->neg, &local_sdp);
+
     pjmedia_sdp_neg_get_active_remote (inv->neg, &remote_sdp);
-        
+
     // Clean the resulting sdp offer to create a new one (in case of a reinvite)
     call->getLocalSDP()->clean_session_media();
-    
+
     // Set the fresh negotiated one, no matter if that was an offer or answer.
-    // The local sdp is updated in case of an answer, even if the remote sdp 
+    // The local sdp is updated in case of an answer, even if the remote sdp
     // is kept internally.
     call->getLocalSDP()->set_negotiated_sdp (local_sdp);
 
-    // Set remote ip / port  
-    call->getLocalSDP()->set_media_transport_info_from_remote_sdp (remote_sdp); 
-        
-    try {    
+    // Set remote ip / port
+    call->getLocalSDP()->set_media_transport_info_from_remote_sdp (remote_sdp);
+
+    try {
         call->setAudioStart (true);
         link->getAudioRtp()->start();
-    } catch(exception& rtpException) {
-        _debug("%s\n", rtpException.what());
+    } catch (exception& rtpException) {
+        _debug ("%s\n", rtpException.what());
     }
 
 }
@@ -2268,7 +2290,7 @@ mod_on_rx_request (pjsip_rx_data *rdata)
     userName = std::string (sip_uri->user.ptr, sip_uri->user.slen);
     server = std::string (sip_uri->host.ptr, sip_uri->host.slen);
 
-    _debug("mod_on_rx_request: %s@%s\n", userName.c_str(), server.c_str());
+    _debug ("mod_on_rx_request: %s@%s\n", userName.c_str(), server.c_str());
 
     // Get the account id of callee from username and server
     account_id = Manager::instance().getAccountIdFromNameAndServer (userName, server);
@@ -2457,7 +2479,7 @@ mod_on_rx_request (pjsip_rx_data *rdata)
 
 pj_bool_t mod_on_rx_response (pjsip_rx_data *rdata UNUSED)
 {
-    _debug("Mod on rx response");
+    _debug ("Mod on rx response");
     return PJ_SUCCESS;
 }
 
@@ -2792,7 +2814,7 @@ void xfer_func_cb (pjsip_evsub *sub, pjsip_event *event)
         if (event->body.rx_msg.rdata->msg_info.msg_buf != NULL) {
             request = event->body.rx_msg.rdata->msg_info.msg_buf;
 
-            if ((int) request.find (noresource) != -1) {
+            if ( (int) request.find (noresource) != -1) {
                 _debug ("UserAgent: NORESOURCE for transfer!\n");
                 link->transferStep2();
                 pjsip_evsub_terminate (sub, PJ_TRUE);
@@ -2801,7 +2823,7 @@ void xfer_func_cb (pjsip_evsub *sub, pjsip_event *event)
                 return;
             }
 
-            if ((int) request.find (ringing) != -1) {
+            if ( (int) request.find (ringing) != -1) {
                 _debug ("UserAgent: transfered call RINGING!\n");
                 link->transferStep2();
                 pjsip_evsub_terminate (sub, PJ_TRUE);