diff --git a/sflphone-common/src/audio/alsa/alsalayer.cpp b/sflphone-common/src/audio/alsa/alsalayer.cpp
index 5719c6aa23d67458a346590185d41bde0e52da02..98f191d50c56388d16976c8f36ab01f04f3d7687 100644
--- a/sflphone-common/src/audio/alsa/alsalayer.cpp
+++ b/sflphone-common/src/audio/alsa/alsalayer.cpp
@@ -861,32 +861,19 @@ void AlsaLayer::audioCallback (void)
     } else {
 
         tone = _manager->getTelephoneTone();
-        file_tone = _manager->getTelephoneFile();
 
         toGet = framesPerBufferAlsa;
         maxBytes = toGet * sizeof (SFLDataFormat);
 
         if (tone != 0) {
 
-            out = (SFLDataFormat*) malloc (maxBytes * sizeof (SFLDataFormat));
+            out = (SFLDataFormat *) malloc (maxBytes);
             tone->getNext (out, toGet, spkrVolume);
             write (out , maxBytes, _PlaybackHandle);
 
             free (out);
             out = 0;
 
-	    /*
-        } else if (file_tone != 0) {
-
-            out = (SFLDataFormat*) malloc (maxBytes * sizeof (SFLDataFormat));
-            file_tone->getNext (out, toGet, spkrVolume);
-            write (out , maxBytes, _PlaybackHandle);
-
-            free (out);
-            out = 0;
-
-        } else {
-	*/
 	} else {
 
 
@@ -947,7 +934,7 @@ void AlsaLayer::audioCallback (void)
 
             } else {
 
-                if ( (tone == 0) && (file_tone == 0)) {
+                if (tone == 0) {
 
                     SFLDataFormat* zeros = (SFLDataFormat*) malloc (framesPerBufferAlsa * sizeof (SFLDataFormat));
 
@@ -975,7 +962,7 @@ void AlsaLayer::audioCallback (void)
 
     if (file_tone != NULL) {
 
-        out = (SFLDataFormat*) malloc (maxBytes * sizeof (SFLDataFormat));
+        out = (SFLDataFormat *) malloc (maxBytes);
 	file_tone->getNext (out, toGet, spkrVolume);
 	write (out, maxBytes, _RingtoneHandle);
 
@@ -984,8 +971,8 @@ void AlsaLayer::audioCallback (void)
 
     } else {
 
-        out = (SFLDataFormat*) malloc ( maxBytes * sizeof (SFLDataFormat));
-	memset(out, 0, maxBytes * sizeof (SFLDataFormat));
+        out = (SFLDataFormat *) malloc ( maxBytes);
+	memset(out, 0, maxBytes);
 	write(out, maxBytes, _RingtoneHandle);
 
 	free(out);
diff --git a/sflphone-common/src/audio/pulseaudio/pulselayer.cpp b/sflphone-common/src/audio/pulseaudio/pulselayer.cpp
index 820538b9922c7312b86374780abf2c892fe9b9b2..e6b3c905be06c4511e750da771b2d903d73c1d4b 100644
--- a/sflphone-common/src/audio/pulseaudio/pulselayer.cpp
+++ b/sflphone-common/src/audio/pulseaudio/pulselayer.cpp
@@ -732,7 +732,6 @@ void PulseLayer::writeToSpeaker (void)
     } else {
 
         AudioLoop* tone = _manager->getTelephoneTone();
-        AudioLoop* file_tone = _manager->getTelephoneFile();
 
         // flush remaining samples in _urgentRingBuffer
         flushUrgent();
@@ -749,22 +748,6 @@ void PulseLayer::writeToSpeaker (void)
                 pa_xfree (out);
 
             }
-	    //}
-
-        // else if (file_tone != 0) {
-
-	  /*
-            if (playback->getStreamState() == PA_STREAM_READY) {
-
-                out = (SFLDataFormat*) pa_xmalloc (writeableSize);
-                int copied = file_tone->getNext (out, writeableSize / sizeof (SFLDataFormat), 100);
-
-                pa_stream_write (playback->pulseStream(), out, copied * sizeof (SFLDataFormat), NULL, 0, PA_SEEK_RELATIVE);
-
-                pa_xfree (out);
-
-            }
-	  */
 
         } else {
 
@@ -831,7 +814,7 @@ void PulseLayer::writeToSpeaker (void)
 
             } else {
 
-                if ( (tone == 0) && (file_tone == 0)) {
+                if (tone == 0) {
 
                     SFLDataFormat* zeros = (SFLDataFormat*) pa_xmalloc (writeableSize);
 
@@ -916,27 +899,29 @@ void PulseLayer::ringtoneToSpeaker(void)
 
   int writableSize = pa_stream_writable_size(ringtone->pulseStream());
 
-  // _debug("writable size: %d", writableSize);
+  _debug("writable size: %d", writableSize);
 
   if (file_tone) {
 
     if(ringtone->getStreamState() == PA_STREAM_READY) {
       
-      out = (SFLDataFormat*)pa_xmalloc(writableSize);
+      out = (SFLDataFormat *)pa_xmalloc(writableSize);
       int copied = file_tone->getNext(out, writableSize/sizeof(SFLDataFormat), 100);
       pa_stream_write(ringtone->pulseStream(), out, copied*sizeof(SFLDataFormat), NULL, 0, PA_SEEK_RELATIVE);
 
       pa_xfree(out);
-
     }
   }
   else {
 
-    out = (SFLDataFormat*)pa_xmalloc(writableSize);
-    memset(out, 0, writableSize);
-    pa_stream_write(ringtone->pulseStream(), out, writableSize, NULL, 0, PA_SEEK_RELATIVE);
+    if(ringtone->getStreamState() == PA_STREAM_READY) {
+
+      out = (SFLDataFormat*)pa_xmalloc(writableSize);
+      memset(out, 0, writableSize);
+      pa_stream_write(ringtone->pulseStream(), out, writableSize, NULL, 0, PA_SEEK_RELATIVE);
     
-    pa_xfree(out);
+      pa_xfree(out);
+    }
   }
     
 
diff --git a/sflphone-common/src/sip/sipvoiplink.cpp b/sflphone-common/src/sip/sipvoiplink.cpp
index 3a3df884beff8615dbf7dfc1f25dc24048138d23..a5642a3b2281936a58b970abe8eb06240dda9171 100644
--- a/sflphone-common/src/sip/sipvoiplink.cpp
+++ b/sflphone-common/src/sip/sipvoiplink.cpp
@@ -269,6 +269,7 @@ SIPVoIPLink::~SIPVoIPLink()
     _debug("UserAgent: SIPVoIPLink destructor called");
 
     terminate();
+
 }
 
 SIPVoIPLink* SIPVoIPLink::instance (const AccountID& id)
@@ -333,7 +334,6 @@ SIPVoIPLink::terminate()
 
     initDone (false);
 
-    _debug("Terminating");
 }
 
 void
@@ -1248,6 +1248,8 @@ SIPVoIPLink::refuse (const CallID& id)
 
     call->getInvSession()->mod_data[getModId() ] = NULL;
 
+    removeCall(id);
+
     terminateOneCall (id);
 
     _debug("UserAgent: Refuse call completed");