diff --git a/src/audio/audiortp.cpp b/src/audio/audiortp.cpp
index 5c43810e56db0742905eedb6926df8289f893fa9..286829d7c748640ab5c4b4601a729611deb4c164 100644
--- a/src/audio/audiortp.cpp
+++ b/src/audio/audiortp.cpp
@@ -198,8 +198,8 @@ AudioRtpRTX::sendSessionFromMic (unsigned char* data_to_send, int16* data_from_m
 	int k; 
 	int compSize; 
 	
-	if (Manager::instance().getCall(_ca->getId())->isOnMute() or
-				!Manager::instance().isCurrentId(_ca->getId())) {
+	if (Manager::instance().getCall(_ca->getId())->isOnMute()/* or
+				!Manager::instance().isCurrentId(_ca->getId())*/) {
 		// Mute :send 0's over the network.
 		Manager::instance().getAudioDriver()->micRingBuffer().Get(data_from_mic, 
 			RTP_FRAMES2SEND*2*sizeof(int16));
diff --git a/src/call.cpp b/src/call.cpp
index a0e56d779a59e735442d665c934db0278bab9623..e1d54d543ed1391e7bc264ed9eb3f026ac0437d1 100644
--- a/src/call.cpp
+++ b/src/call.cpp
@@ -218,9 +218,9 @@ Call::isIncomingType (void)
 }
 
 int 
-Call::outgoingCall  (short id, const string& to)
+Call::outgoingCall(const string& to)
 {
-	return _voIPLink->outgoingInvite(id, to);
+	return _voIPLink->outgoingInvite(_id, to);
 }
 
 int 
diff --git a/src/call.h b/src/call.h
index 77bd26e1d183b9e7c633a2a64977774b299d7957..de2f0e7791316332d1aa3c6ffaf3b8418c46ee1a 100644
--- a/src/call.h
+++ b/src/call.h
@@ -96,7 +96,7 @@ public:
 	bool isOutgoingType (void);
 	bool isIncomingType (void);
 	
-	int outgoingCall  	(short id, const std::string& to);
+	int outgoingCall  	(const std::string& to);
 	int hangup  		(void);
 	int cancel  		(void);
 	int answer  		(void);
diff --git a/src/gui/server/guiserver.cpp b/src/gui/server/guiserver.cpp
index 2597c44e261a96a4cf891fad7f497351c47d1030..29c697960091a92ca71c200e9737c24befea675d 100644
--- a/src/gui/server/guiserver.cpp
+++ b/src/gui/server/guiserver.cpp
@@ -44,6 +44,8 @@ TCPSessionIO::run() {
 GUIServer::GUIServer()
 {
   _factory.registerAll();
+  _sessionIO = 0;
+  _shouldQuit = false;
 }
 
 // destructor
@@ -73,7 +75,7 @@ GUIServer::exec() {
     Request *request;
     
     while (std::cin.good()) {
-    
+      
       // waiting for a new connection
       std::cout << "waiting for a new connection..." << std::endl;
 
@@ -84,7 +86,8 @@ GUIServer::exec() {
       // wait for the first message
       std::cout << "accepting connection..." << std::endl;
 
-      while(_sessionIO->good()) {
+      _shouldQuit = false;
+      while(_sessionIO->good() && !_shouldQuit) {
         if ( _requests.pop(request, 1000)) {
           output = request->execute(*this);
           handleExecutedRequest(request, output);
@@ -103,15 +106,17 @@ void
 GUIServer::pushRequestMessage(const std::string &request)
 {
   Request *tempRequest = _factory.create(request);
-  std::cout << "pushRequestMessage" << std::endl;
   _requests.push(tempRequest);
 }
 
 void 
 GUIServer::pushResponseMessage(const ResponseMessage &response) 
 {
-  std::cout << "pushResponseMessage" << std::endl;
-  _sessionIO->push(response.toString());
+  if (_sessionIO) {
+    _sessionIO->push(response.toString());
+  } else {
+    std::cerr << "PushResponseMessage: " << response.toString() << std::endl;
+  }
 
   // remove the request from the list 
   if (response.isFinal()) {
@@ -140,7 +145,9 @@ GUIServer::handleExecutedRequest(Request * const request, const ResponseMessage&
       delete request;
     }
   }
-  _sessionIO->push(response.toString());
+  if (_sessionIO) {
+    _sessionIO->push(response.toString());
+  }
 }
 
 /** 
@@ -207,7 +214,11 @@ GUIServer::peerAnsweredCall (short id)
   CallMap::iterator iter = _callMap.find(id);
   if ( iter != _callMap.end() ) {
     pushResponseMessage(ResponseMessage("200", iter->second.sequenceId(), "OK"));
-  } 
+  } else {
+    std::ostringstream responseMessage;
+    responseMessage << "Peer Answered Call: " << id;
+    pushResponseMessage(ResponseMessage("500", "seq0", responseMessage.str()));
+  }
 }
 
 int  
@@ -283,12 +294,14 @@ GUIServer::setup (void)
 int  
 GUIServer::selectedCall (void) 
 {
+  std::cout << "should not be here" << std::endl;
   return 0;
 }
 
 bool  
 GUIServer::isCurrentId (short) 
 {
+  std::cout << "should not be here" << std::endl;
   return false;
 }
 
diff --git a/src/gui/server/guiserver.h b/src/gui/server/guiserver.h
index 81930c83f96f72700b4b91da847578ad710dca20..ef59d6e072fcbbf103c19a840bfd925a1dde752d 100644
--- a/src/gui/server/guiserver.h
+++ b/src/gui/server/guiserver.h
@@ -90,6 +90,7 @@ public:
 
   int outgoingCall (const std::string& to) {return GuiFramework::outgoingCall(to);}
   void hangup(const std::string& callId);
+  void quit() {_shouldQuit=true;}
     
 private:
   TCPSessionIO* _sessionIO;
@@ -108,6 +109,7 @@ private:
 
   RequestFactory _factory;
   ost::Mutex _mutex;
+  bool _shouldQuit;
 };
 
 #endif // __GUI_SERVER_H__
diff --git a/src/gui/server/request.cpp b/src/gui/server/request.cpp
index 91ccf32b21dd4cd17b51f7714f1475b8b29686dc..60bf8850df653ed86d4679c99744ed19263d63e4 100644
--- a/src/gui/server/request.cpp
+++ b/src/gui/server/request.cpp
@@ -28,12 +28,42 @@ RequestCall::execute(GUIServer& gui)
   if (serverCallId) {
     SubCall scIndex(_sequenceId,_callId);
     gui.insertSubCall(serverCallId, scIndex);
-    return message("150", "Trying...");
+    return message("150", "Trying");
   } else {
     return message("500","Server Error");
   }
 }
 
+ResponseMessage
+RequestAnswer::execute(GUIServer& gui)
+{
+  return message("200","TODO");
+}
+
+ResponseMessage
+RequestRefuse::execute(GUIServer& gui)
+{
+  return message("200","TODO");
+}
+
+ResponseMessage
+RequestHold::execute(GUIServer& gui)
+{
+  return message("200","TODO");
+}
+
+ResponseMessage
+RequestUnhold::execute(GUIServer& gui)
+{
+  return message("200","TODO");
+}
+
+ResponseMessage
+RequestTransfer::execute(GUIServer& gui)
+{
+  return message("200","TODO");
+}
+
 ResponseMessage
 RequestHangup::execute(GUIServer& gui)
 {
@@ -45,3 +75,23 @@ RequestHangup::execute(GUIServer& gui)
   }
 }
 
+
+ResponseMessage
+RequestMute::execute(GUIServer& gui)
+{
+  return message("200","TODO");
+}
+
+ResponseMessage
+RequestUnmute::execute(GUIServer& gui)
+{
+  return message("200","TODO");
+}
+
+ResponseMessage
+RequestQuit::execute(GUIServer& gui)
+{
+  gui.quit();
+  return message("200", "Quitting");
+}
+
diff --git a/src/gui/server/request.h b/src/gui/server/request.h
index c07a65cbdf01905e626d245e86fe556cde503b7c..ee9a8e0233b402797367b247213195d3d6618f7e 100644
--- a/src/gui/server/request.h
+++ b/src/gui/server/request.h
@@ -105,7 +105,7 @@ public:
     }
   }
   virtual ~RequestGlobalCall() {}
-  virtual ResponseMessage execute(GUIServer& gui) { return message("200","OK"); }
+  virtual ResponseMessage execute(GUIServer& gui) = 0;
 
 protected:
   std::string _callId;
@@ -114,22 +114,27 @@ protected:
 class RequestAnswer : public RequestGlobalCall {
 public:
   RequestAnswer(const std::string &sequenceId, const TokenList& argList) : RequestGlobalCall(sequenceId,argList) {}
+  ResponseMessage execute(GUIServer& gui);
 };
 class RequestRefuse : public RequestGlobalCall {
 public:
   RequestRefuse(const std::string &sequenceId, const TokenList& argList) : RequestGlobalCall(sequenceId,argList) {}
+  ResponseMessage execute(GUIServer& gui);
 };
 class RequestHold : public RequestGlobalCall {
 public:
   RequestHold(const std::string &sequenceId, const TokenList& argList) : RequestGlobalCall(sequenceId,argList) {}
+  ResponseMessage execute(GUIServer& gui);
 };
 class RequestUnhold : public RequestGlobalCall {
 public:
   RequestUnhold(const std::string &sequenceId, const TokenList& argList) : RequestGlobalCall(sequenceId,argList) {}
+  ResponseMessage execute(GUIServer& gui);
 };
 class RequestTransfer : public RequestGlobalCall {
 public:
   RequestTransfer(const std::string &sequenceId, const TokenList& argList) : RequestGlobalCall(sequenceId,argList) {}
+  ResponseMessage execute(GUIServer& gui);
 };
 class RequestHangup : public RequestGlobalCall {
 public:
@@ -142,23 +147,25 @@ class RequestGlobal : public Request
 public:
   RequestGlobal(const std::string &sequenceId, const TokenList& argList) : Request(sequenceId,argList) {}
   virtual ~RequestGlobal() {}
-  virtual ResponseMessage execute(GUIServer& gui) { return message("200","OK"); }
+  virtual ResponseMessage execute(GUIServer& gui) = 0;
 };
 
 class RequestMute : public RequestGlobal {
 public:
   RequestMute(const std::string &sequenceId, const TokenList& argList) : RequestGlobal(sequenceId,argList) {}
+  ResponseMessage execute(GUIServer& gui);
 };
 class RequestUnmute : public RequestGlobal {
 public:
   RequestUnmute(const std::string &sequenceId, const TokenList& argList) : RequestGlobal(sequenceId,argList) {}
+  ResponseMessage execute(GUIServer& gui);
 };
 class RequestQuit : public RequestGlobal {
 public:
   RequestQuit(const std::string &sequenceId, const TokenList& argList) : RequestGlobal(sequenceId,argList) {}
+  ResponseMessage execute(GUIServer& gui);
 };
 
-
 class RequestSyntaxError : public Request 
 {
 public:
diff --git a/src/managerimpl.cpp b/src/managerimpl.cpp
index 7181325ba4c644064dad2e4dedc14caa20ebe07c..e022bfcb32256d965250216990018c35955b856e 100644
--- a/src/managerimpl.cpp
+++ b/src/managerimpl.cpp
@@ -280,12 +280,13 @@ ManagerImpl::getVoIPLinkVector (void)
 	return &_voIPLinkVector;
 }
 
-void
+Call *
 ManagerImpl::pushBackNewCall (short id, enum CallType type)
 {
 	Call* call = new Call(id, type, _voIPLinkVector.at(DFT_VOIP_LINK));
 	// Set the wanted voip-link (first of the list)
 	_callVector.push_back(call);
+  return call;
 }
 
 void
@@ -312,16 +313,16 @@ ManagerImpl::outgoingCall (const string& to)
 	Call* call;
 	
 	id = generateNewCallId();
-	pushBackNewCall(id, Outgoing);
-	
+	call = pushBackNewCall(id, Outgoing);
 	_debug("Outgoing Call with identifiant %d\n", id);
-	call = getCall(id);
-	if (call == NULL)
-		return 0;
+	
+	//call = getCall(id);
+	//if (call == NULL)
+	//	return 0;
 	
 	call->setStatus(string(TRYING_STATUS));
 	call->setState(Progressing);
-	if (call->outgoingCall(id, to) == 0) {
+	if (call->outgoingCall(to) == 0) {
 		return id;
 	} else {
 		return 0;
@@ -568,9 +569,9 @@ ManagerImpl::peerAnsweredCall (short id)
 	call->setStatus(string(CONNECTED_STATUS));
 
 	call->setState(Answered);
-	if (isCurrentId(id)) {
+	//if (isCurrentId(id)) {
 		_gui->peerAnsweredCall(id);
-	}
+	//}
 }
 
 int 
diff --git a/src/managerimpl.h b/src/managerimpl.h
index 2368f90c6f0bf2191e1dcff87e55fe64ca09ebf5..134afce56be157b66426c7b6966177dc142658de 100644
--- a/src/managerimpl.h
+++ b/src/managerimpl.h
@@ -132,7 +132,7 @@ public:
 	/*
 	 * Add a new call at the end of the CallVector with identifiant 'id'
 	 */
-	void pushBackNewCall (short id, enum CallType type);
+	Call* pushBackNewCall (short id, enum CallType type);
 	
 	/*
 	 * Erase the Call(id) from the CallVector
diff --git a/src/sipcall.cpp b/src/sipcall.cpp
index a22ab74721ec62e68f2b6e29afc9f229c96fe832..3d16b798f5ba64ba02d90dc5bae3ced070f0a48d 100644
--- a/src/sipcall.cpp
+++ b/src/sipcall.cpp
@@ -36,7 +36,11 @@ using namespace std;
 
 SipCall::SipCall (short id, CodecDescriptorVector* cdv) 
 {
-	_id = id;	// Same id of Call object
+	_id = id;	  // Same id of Call object
+	_cid = 0; // call id, from the sipvoiplink
+	_did = 0; // dialog id
+	_tid = 0; // transaction id
+
 	alloc();
 	_cdv = cdv;
 	_audiocodec = NULL;
diff --git a/src/sipvoiplink.cpp b/src/sipvoiplink.cpp
index 36b99d67d622c9d28a493c534614460fb9b9c63b..65ac7d62db1f5da0f31a427f967d6a0e2224c418 100644
--- a/src/sipvoiplink.cpp
+++ b/src/sipvoiplink.cpp
@@ -51,7 +51,6 @@ SipVoIPLink::SipVoIPLink (short id)
 {
   setId(id);
   _localPort = 0;
-  _cid = 0;
   _reg_id = -1;
   _nMsgVoicemail = 0;
   _evThread = new EventThread(this);
@@ -356,10 +355,11 @@ SipVoIPLink::cancel (short id)
 {
   int i = 0;
   if (!Manager::instance().getbCongestion()) {
-    _debug("Cancel call [id = %d, cid = %d]\n", id, getCid());
+    SipCall *call = getSipCall(id);
+    _debug("Cancel call [id = %d, cid = %d]\n", id, call->getCid());
     // Release SIP stack.
     eXosip_lock();
-    i = eXosip_call_terminate (getCid(), -1);
+    i = eXosip_call_terminate (call->getCid(), -1);
     eXosip_unlock();
   }
   deleteSipCall(id);
@@ -614,37 +614,41 @@ SipVoIPLink::getEvent (void)
   case EXOSIP_CALL_ANSWERED: 
     id = findCallId(event);
     if (id == 0) {
-      id = findCallIdWhenRinging();
+      id = findCallIdInitial(event);
+    }
+    SipCall *call = getSipCall(id);
+    if ( call ) {
+      _debug("Call is answered [id = %d, cid = %d, did = %d], localport=%d\n", 
+	   id, event->cid, event->did,call->getLocalAudioPort());
     }
-    _debug("Call is answered [id = %d, cid = %d, did = %d], localport=%d\n", 
-	   id, event->cid, event->did,getSipCall(id)->getLocalAudioPort());
  
     // Answer
-    if (id > 0 and !Manager::instance().getCall(id)->isOnHold()
-	and !Manager::instance().getCall(id)->isOffHold()) {
-      getSipCall(id)->setStandBy(false);
-      if (getSipCall(id)->answeredCall(event) != -1) {
-	getSipCall(id)->answeredCall_without_hold(event);
-	Manager::instance().peerAnsweredCall(id);
-
-	// Outgoing call is answered, start the sound channel.
-	if (_audiortp.createNewSession (getSipCall(id)) < 0) {
-	  _debug("FATAL: Unable to start sound (%s:%d)\n", 
-		 __FILE__, __LINE__);
-	  exit(1);
-	}
+    if (id > 0 && !Manager::instance().getCall(id)->isOnHold()
+               && !Manager::instance().getCall(id)->isOffHold()) {
+      call->setStandBy(false);
+      if (call->answeredCall(event) != -1) {
+        call->answeredCall_without_hold(event);
+        Manager::instance().peerAnsweredCall(id);
+
+        // Outgoing call is answered, start the sound channel.
+        if (_audiortp.createNewSession (call) < 0) {
+          _debug("FATAL: Unable to start sound (%s:%d)\n", 
+          __FILE__, __LINE__);
+          exit(1);
+        }
       }
     } else {
       // Answer to on/off hold to send ACK
       if (id > 0) {
-	getSipCall(id)->answeredCall(event);
-	_debug("-----------------------\n");
+        call->answeredCall(event);
+        _debug("-----------------------\n");
       }
     }
     break;
 			
   case EXOSIP_CALL_RINGING: //peer call is ringing
-    id = findCallIdWhenRinging();
+    id = findCallId(event);
+    //id = findCallIdWhenRinging();
 			
     _debug("Call is ringing [id = %d, cid = %d, did = %d]\n", 
 	   id, event->cid, event->did);
@@ -712,7 +716,8 @@ SipVoIPLink::getEvent (void)
     case ADDR_INCOMPLETE:
     case BUSY_HERE:
       // Display error on the screen phone
-      Manager::instance().displayError(event->response->reason_phrase);
+      //Manager::instance().displayError(event->response->reason_phrase);
+      Manager::instance().displayErrorText(id, event->response->reason_phrase);
       Manager::instance().congestion(true);
       break;
     case REQ_TERMINATED:
@@ -879,8 +884,9 @@ SipVoIPLink::newOutgoingCall (short callid)
 {
   _sipcallVector.push_back(new SipCall(callid, 
 					Manager::instance().getCodecDescVector()));
-  if (getSipCall(callid) != NULL) {
-    getSipCall(callid)->setStandBy(true);
+  SipCall *call = getSipCall(callid);
+  if ( call != NULL) {
+    call->setStandBy(true);
   }
 }
 
@@ -1200,6 +1206,10 @@ int
 SipVoIPLink::startCall (short id, const string& from, const string& to, 
 			const string& subject,  const string& route) 
 {
+  SipCall *call = getSipCall(id);
+  if ( call == NULL) {
+    return -1; // error, we can't find the sipcall
+  }
   osip_message_t *invite;
   int i;
 
@@ -1228,11 +1238,7 @@ SipVoIPLink::startCall (short id, const string& from, const string& to,
   }
 	
   // Set local audio port for sipcall(id)
-  if (getSipCall(id) != NULL) {
-    getSipCall(id)->setLocalAudioPort(_localPort);
-  } else {
-    return -1;
-  }
+  call->setLocalAudioPort(_localPort);
 	
   bzero (port, 64);
   snprintf (port, 63, "%d", getLocalPort());
@@ -1242,7 +1248,7 @@ SipVoIPLink::startCall (short id, const string& from, const string& to,
                                         (char*)route.data(),
                                         (char*)subject.data());
   if (i != 0) {
-    return -1;
+    return -1; // error when building the invite
   }
   	
 
@@ -1296,37 +1302,62 @@ SipVoIPLink::startCall (short id, const string& from, const string& to,
   
   eXosip_lock();
 	
-  i = eXosip_call_send_initial_invite (invite);
+  // this is the cid (call id from exosip)
+  int cid = eXosip_call_send_initial_invite (invite);
+
+  // Keep the cid in case of cancelling
+  call->setCid(cid);
 
-  if (i <= 0) {
+  if (cid <= 0) {
     eXosip_unlock();
     return -1;
   } else {
-    eXosip_call_set_reference (i, NULL);
+    eXosip_call_set_reference (cid, NULL);
   }
 
   eXosip_unlock();
 
-  // Keep the cid in case of cancelling
-  setCid(i);
-  
-  return i;	
+  return cid; // this is the Cid
 }
 
 short
 SipVoIPLink::findCallId (eXosip_event_t *e)
 {
-  unsigned int k;
-	
-  for (k = 0; k < _sipcallVector.size(); k++) {
-    if (_sipcallVector.at(k)->getCid() == e->cid and
-	_sipcallVector.at(k)->getDid()	== e->did) {
-      return _sipcallVector.at(k)->getId();
+  for (unsigned int k = 0; k < _sipcallVector.size(); k++) {
+    SipCall *call = _sipcallVector.at(k);
+    if (call->getCid() == e->cid &&
+        call->getDid() == e->did) {
+      return call->getId();
     }
   }
   return 0;
 }
 
+/**
+ * This function is used when findCallId failed (return 0)
+ * ie: the dialog id change
+ *     can be use when anwsering a new call or 
+ *         when cancelling a call
+ */
+short
+SipVoIPLink::findCallIdInitial (eXosip_event_t *e)
+{
+  for (unsigned int k = 0; k < _sipcallVector.size(); k++) {
+    SipCall *call = _sipcallVector.at(k);
+    // the dialog id is not set when you do a new call
+    // so you can't check it when you want to retreive it
+    // for the first call anwser
+    if (call->getCid() == e->cid) {
+      return call->getId();
+    }
+  }
+  return 0;
+}
+/**
+ * YM: (2005-09-21) This function is really really bad..
+ * Should be removed !
+ * Don't ask the GUI which call it use...
+ */
 short
 SipVoIPLink::findCallIdWhenRinging (void)
 {
diff --git a/src/sipvoiplink.h b/src/sipvoiplink.h
index 6b2d5dfb29c1501619529cf410c0899677bc5428..f8f76ec2f09c80b44c6bd9e628da94314afe4092 100644
--- a/src/sipvoiplink.h
+++ b/src/sipvoiplink.h
@@ -114,11 +114,7 @@ public:
 	 */
 	AudioCodec* getAudioCodec(short callid);
 
-	// Use to Cancel
-	inline void setCid (int cid) { _cid = cid; }
-	inline int getCid (void) { return _cid; }
-
-	// Handle voice-message
+// Handle voice-message
 	inline void setMsgVoicemail (int nMsg) { _nMsgVoicemail = nMsg; }
 	inline int getMsgVoicemail (void) { return _nMsgVoicemail; }
 	
@@ -180,6 +176,7 @@ private:
 	 * Return the id of the found call
 	 */
 	short findCallId (eXosip_event_t *e);
+  short findCallIdInitial (eXosip_event_t *e);
 	short findCallIdWhenRinging (void);
 
 	/*
@@ -209,7 +206,6 @@ private:
 	std::vector< SipCall * > _sipcallVector;
 	AudioRtp 		_audiortp;
 	int 			_localPort;
-	int 			_cid;
 	int 			_reg_id;
 	int 			_nMsgVoicemail;
 };