diff --git a/MPSoC/src/request_manager.c b/MPSoC/src/request_manager.c
index 013a0ebb48d9fd5f9142c53b57c04b2f7109ff25..4a5ce3e04aa8e613482d11ab024233df05548fe3 100755
--- a/MPSoC/src/request_manager.c
+++ b/MPSoC/src/request_manager.c
@@ -76,20 +76,20 @@ void executeSendSyncTransaction(request *req) {
      if(sync_write(req->syncChannel->mwmr_fifo, &(req->params), req->nbOfParams*sizeof(req->params))!=req->nbOfParams*sizeof(req->params))continue;
      break;
      }*/
-  selectedReq->syncChannel->ok=1;
+  selectedReq->syncChannel->ok_send=1;
   if(req->nbOfParams==0){
      debugMsg("no params");
      if(sync_write(req->syncChannel->mwmr_fifo, &(req->params), 4)!=4){ debugMsg("****syncchannel write echec");//req->executable==0;
-       selectedReq->syncChannel->ok=0;selectedReq->syncChannel->ok2=1;
+       selectedReq->syncChannel->ok_send=0;selectedReq->syncChannel->ok_receive=1;
      }else{ debugMsg("****syncchannel write success");//req->executable==1;
-       selectedReq->syncChannel->ok=0;selectedReq->syncChannel->ok2=1;
+       selectedReq->syncChannel->ok_send=0;selectedReq->syncChannel->ok_receive=1;
 }
   }
      else{
        if(sync_write(req->syncChannel->mwmr_fifo, &(req->params), req->nbOfParams*sizeof(req->params))!=req->nbOfParams*sizeof(req->params)){ debugMsg("****syncchannel write echec");//req->executable==0;
-selectedReq->syncChannel->ok=0;selectedReq->syncChannel->ok2=1;
+selectedReq->syncChannel->ok_send=0;selectedReq->syncChannel->ok_receive=1;
        }else{debugMsg("****syncchannel write success");//req->executable==1;
-	 selectedReq->syncChannel->ok=0;selectedReq->syncChannel->ok2=1;
+	 selectedReq->syncChannel->ok_send=0;selectedReq->syncChannel->ok_receive=1;
 }
      }
   
@@ -136,7 +136,7 @@ void executeReceiveSyncTransaction(request *req) {
   debugInt("syncchannel burst \n", req->nbOfParams*sizeof(req->params));
   debugInt("syncchannel params \n", req->params[0]);
   debugInt("syncchannel paramsize \n", sizeof(req->params));
-  /* while(1){
+  /* while(){
   if(req->nbOfParams==0){ 
     debugMsg("pas de params");
     if(sync_read(selectedReq->syncChannel->mwmr_fifo, &(selectedReq->params), 4 )!=4) continue
@@ -148,22 +148,24 @@ void executeReceiveSyncTransaction(request *req) {
   break;
   }*/
   //DG 11.05.
- selectedReq->syncChannel->ok=1;
+  // int ko=1;
+  //while(ko){
+ selectedReq->syncChannel->ok_send=1;
  if(req->nbOfParams==0){ 
     debugMsg("pas de params");
     if(sync_read(selectedReq->syncChannel->mwmr_fifo, &(selectedReq->params), 4 )!=4){ debugMsg("****syncchannel read echec");//req->executable==0;
-      selectedReq->syncChannel->ok=1;selectedReq->syncChannel->ok2=0;
+      selectedReq->syncChannel->ok_send=1;selectedReq->syncChannel->ok_receive=0;
     } else { debugMsg("****syncchannel read success");//req->executable==1;
-      selectedReq->syncChannel->ok=1;selectedReq->syncChannel->ok2=0;
+      selectedReq->syncChannel->ok_send=1;selectedReq->syncChannel->ok_receive=0;//ko=0;
 }}
  else{
    if(sync_read(selectedReq->syncChannel->mwmr_fifo, &(selectedReq->params),  selectedReq->nbOfParams*sizeof(selectedReq->params))!= selectedReq->nbOfParams*sizeof(selectedReq->params)){debugMsg("****syncchannel read echec");//req->executable==0;
-     selectedReq->syncChannel->ok=1;selectedReq->syncChannel->ok2=0;
+     selectedReq->syncChannel->ok_send=1;selectedReq->syncChannel->ok_receive=0;
 }else{ 
      debugMsg("****syncchannel read success");//req->executable==1;
-     selectedReq->syncChannel->ok=1;selectedReq->syncChannel->ok2=0;
+     selectedReq->syncChannel->ok_send=1;selectedReq->syncChannel->ok_receive=0;//ko=0;
 }}
-
+ // }
   debugMsg("after syncchannel read");
   debugInt("req->params \n", req->params);
   traceSynchroRequest(selectedReq, req);
@@ -328,24 +330,32 @@ int executable(setOfRequests *list, int nb) {
     req->executable = 0;
     if (req->delayElapsed) {
       if (req->type == SEND_SYNC_REQUEST) {
-	//DG 8.2. ici le probleme! wait queue empty pour B0 :(
+
 	debugMsg("Send sync");
-	debugInt("req->syncChannel->inWaitQueue ",req->syncChannel->inWaitQueue);
-	debugInt("req->syncChannel address", &(req->syncChannel));
+	debugInt("req->syncChannel->inWaitQueue ",req->syncChannel->inWaitQueue);	debugInt("req->syncChannel->outWaitQueue ",req->syncChannel->outWaitQueue);
+	debugInt("req->syncChannel address ", &(req->syncChannel->mwmr_fifo));
+debug2Msg("req->syncChannel outname ", (req->syncChannel->outname));
+debug2Msg("req->syncChannel inname ", (req->syncChannel->inname));
+	debugInt("req->syncChannel ok ", (req->syncChannel->ok_send));
 
-	//if ((req->syncChannel->inWaitQueue != NULL)&&(req->syncChannel->ok==1)) {// DG 8.2. non c'est correct: il faut un rendez-vous synchrone entre inqueue et outqueue
+	//if ((req->syncChannel->inWaitQueue != NULL)&&(req->syncChannel->ok_send==1)) {// DG 8.2. non c'est correct: il faut un rendez-vous synchrone entre inqueue et outqueue
         //if (req->syncChannel->outWaitQueue != NULL) {//DG 8.2.??
-	if ((req->syncChannel->inWaitQueue != NULL)){
-	  debugMsg("Send sync executable");
-	  debugInt("ok=",req->syncChannel->ok);
-	  //req->syncChannel->ok==0;
-	  req->syncChannel->ok2==0;
+	//if ((req->syncChannel->inWaitQueue != NULL)){
+	if ((req->syncChannel->inWaitQueue != NULL)&&req->syncChannel->ok_send==1){//DG 1.6.
+	  debug2Msg(list->owner,"Send sync executable");
+	  debugInt("ok_send=",req->syncChannel->ok_send);
+	  req->syncChannel->ok_send=0;
+	  req->syncChannel->ok_receive=1;
 	  req->executable = 1;
+	  req->syncChannel->outWaitQueue = addToRequestQueue(req->syncChannel->outWaitQueue, req);	//DG 01.06. inWaitQueue for corresponding receive even if no made pending
 	  cpt ++;
 	  }  else {
-
-	  debugMsg("Send sync not executable"); 
-	  debugInt("not exe ok=",req->syncChannel->ok);
+	  // req->syncChannel->ok_receive=1; //DG 1.6.??
+	  debug2Msg(list->owner,"Send sync not executable"); 
+	  //req->syncChannel->ok_send=1;
+	  req->syncChannel->ok_receive=1;
+	  debugInt("ok_send=",req->syncChannel->ok_send);
+	  debugInt("ok_receive=",req->syncChannel->ok_receive);
 	  }
 	  ////index ++;
       }
@@ -353,21 +363,29 @@ int executable(setOfRequests *list, int nb) {
       if (req->type == RECEIVE_SYNC_REQUEST) {
 	debugMsg("receive sync");
 	debugInt("req->syncChannel->outWaitQueue ",req->syncChannel->outWaitQueue);
-        debugInt("req->syncChannel address", &(req->syncChannel));
+	debugInt("req->syncChannel->inWaitQueue ",req->syncChannel->inWaitQueue);
+        debugInt("req->syncChannel address", &(req->syncChannel->mwmr_fifo));
+debug2Msg("req->syncChannel outname ", (req->syncChannel->outname));
+debug2Msg("req->syncChannel inname ", (req->syncChannel->inname));
+	debugInt("req->syncChannel ok_receive ", (req->syncChannel->ok_send));
 	//if ((req->syncChannel->outWaitQueue != NULL)&&(req->syncChannel->inWaitQueue != NULL)) {
-	//	if ((req->syncChannel->outWaitQueue != NULL)&&(req->syncChannel->ok==1)) {// DG 8.2. non c'est correct: il faut un rendez-vous synchrone entre inqueue et outqueue
+	//	if ((req->syncChannel->outWaitQueue != NULL)&&(req->syncChannel->ok_send==1)) {// DG 8.2. non c'est correct: il faut un rendez-vous synchrone entre inqueue et outqueue
         //if (req->syncChannel->inWaitQueue != NULL) {//DG 8.2.??
-	//if ((req->syncChannel->ok2==1)&&(req->syncChannel->inWaitQueue != NULL)) {
-	//if (req->syncChannel->ok2==1){
-	if ((req->syncChannel->outWaitQueue != NULL)&&req->syncChannel->ok2==1){
+	//if ((req->syncChannel->ok_receive==1)&&(req->syncChannel->inWaitQueue != NULL)) {
+	//if (req->syncChannel->ok_receive==1){
+	//if ((req->syncChannel->outWaitQueue != NULL)&&req->syncChannel->ok_receive==1){
+	if ((req->syncChannel->outWaitQueue != NULL)&&req->syncChannel->ok_receive==1){//DG 1.6.
 	  req->executable = 1;
-	  debugMsg("Receive sync executable");
-	  //req->syncChannel->ok2==0;
-	  req->syncChannel->ok=0;
+	  // req->syncChannel->inWaitQueue = addToRequestQueue(req->syncChannel->inWaitQueue, req);//DG 1.6.
+	  debug2Msg(list->owner,"Receive sync executable");
+	  req->syncChannel->ok_receive=0;
+	  req->syncChannel->ok_send=1;
 	  cpt ++;
 	}
  else {
-   debugMsg("Receive sync not executable");
+   debug2Msg(list->owner,"Receive sync not executable");  
+   //req->syncChannel->ok_receive=1;
+   req->syncChannel->ok_send=1;
 	  }
 	//index ++;
       }
@@ -442,16 +460,21 @@ void private__makeRequestPending(setOfRequests *list) {
   while(req != NULL) {
     if ((req->delayElapsed) && (!(req->alreadyPending))) {
       if (req->type == SEND_SYNC_REQUEST) {
-	debug2Msg(list->owner,"Adding pending sync request in outWaitqueue");
-	req->syncChannel->outWaitQueue = addToRequestQueue(req->syncChannel->outWaitQueue, req);
-
+	debug2Msg(list->owner,"Adding pending send sync request in outWaitqueue");
+	//debug2Msg(list->owner,"Adding pending send sync request in inWaitqueue");
+req->syncChannel->outWaitQueue = addToRequestQueue(req->syncChannel->outWaitQueue, req);
+//req->syncChannel->inWaitQueue = addToRequestQueue(req->syncChannel->inWaitQueue, req);	//DG 01.06. inWaitQueue
 	req->alreadyPending = 1;
       }
 
       if (req->type ==  RECEIVE_SYNC_REQUEST) {
-	debugMsg("Adding pending request in inWaitqueue");
+	debug2Msg(list->owner,"Adding pending receive sync request in inWaitqueue");	
+	
+	//debug2Msg(list->owner,"Adding pending receive sync request in outWaitqueue");
 	req->alreadyPending = 1;
 	req->syncChannel->inWaitQueue = addToRequestQueue(req->syncChannel->inWaitQueue, req);
+	//req->syncChannel->outWaitQueue = addToRequestQueue(req->syncChannel->outWaitQueue, req);
+	//DG 01.06. outWaitQueue
       }
 
       if (req->type == SEND_ASYNC_REQUEST) {
@@ -536,7 +559,7 @@ request *private__executeRequests0(setOfRequests *list, int nb) {
   // Compute which requests can be executed
  
   howMany = executable(list, nb);
- 
+  debug2Msg(list->owner, " counting executable requests");
   debugInt("Counting requests=", howMany);
  
   if (howMany == 0) {
@@ -587,6 +610,7 @@ request *private__executeRequests(setOfRequests *list) {
   // Is a request already selected?
 
   if (list->selectedRequest != NULL) {
+
     return list->selectedRequest;
   }
 
diff --git a/MPSoC/src/syncchannel.c b/MPSoC/src/syncchannel.c
index d98d28c54a3f198986bdfaf3aa9712907153e2ae..abc70b0ad0b7355e071aacd1b3708ad1cba75c84 100755
--- a/MPSoC/src/syncchannel.c
+++ b/MPSoC/src/syncchannel.c
@@ -16,17 +16,20 @@ void mwmr_sync_flush(struct mwmr_s *fifo){
 
 int sync_read( struct mwmr_s *fifo, void *_ptr, int lensw ){  
   int i;
-  debugInt("debug fifo read\n",fifo);
-  debugInt("debug ptr \n",_ptr);
-  debugInt("debug  lensw \n", lensw);
-  debugInt("debug  fifo status address \n", &(fifo->status));
-  debugInt("debug  fifo status \n", (fifo->status));
-  debugInt("debug  fifo lock address\n", &(fifo->status->lock));
-  debugInt("debug  fifo rptr address\n", &(fifo->status->rptr));
-  debugInt("debug  fifo wptr address\n", &(fifo->status->rptr));
-  debugInt("debug  fifo lock \n", fifo->status->lock);
-  i=mwmr_try_read(fifo,_ptr,lensw); 
+  debugInt("read debug fifo read\n",fifo);
+  debugInt("read debug ptr \n",_ptr);
+  debugInt("read debug  lensw \n", lensw);
+  debugInt("read debug  fifo status address \n", &(fifo->status));
+  debugInt("read debug  fifo status \n", (fifo->status));
+  debugInt("read debug  fifo lock address\n", &(fifo->status->lock));
+  debugInt("read debug  fifo rptr address\n", &(fifo->status->rptr));
+  debugInt("read debug  fifo wptr address\n", &(fifo->status->rptr));
+  debugInt("read debug  fifo lock \n", fifo->status->lock);
+  i=mwmr_try_read(fifo,_ptr,lensw);
+  debugInt("debug i \n", i);
+  //mwmr_read(fifo,_ptr,lensw);
   return i;
+  //return lensw;
 }
 
 int sync_write( struct mwmr_s *fifo, void *_ptr, int lensw ){
@@ -41,8 +44,10 @@ int sync_write( struct mwmr_s *fifo, void *_ptr, int lensw ){
   debugInt("debug  fifo wptr address\n", &(fifo->status->rptr));
   debugInt("debug  fifo lock \n", fifo->status->lock);
   i=mwmr_try_write(fifo,_ptr,lensw);
-  //mwmr_write(fifo,_ptr,1);
+  //mwmr_write(fifo,_ptr,lensw);
+  debugInt("debug i \n", i);
   return i;
+  //return lensw;
 }
 
 syncchannel *getNewSyncchannel(char *outname, char *inname, struct mwmr_s *fifo) {
diff --git a/MPSoC/src/syncchannel.h b/MPSoC/src/syncchannel.h
index f4e713918e1f869cdd7c3905c946d3367dfc9474..a0ed86e5e693a47c8e12ccadc517472026fd4624 100755
--- a/MPSoC/src/syncchannel.h
+++ b/MPSoC/src/syncchannel.h
@@ -13,8 +13,8 @@ struct syncchannel {
   struct request* outWaitQueue; 
   bool isBroadcast;
   struct mwmr_s *mwmr_fifo;
-  int ok; 
-  int ok2;
+  int ok_send; 
+  int ok_receive;
 };
 
 typedef struct syncchannel syncchannel;
diff --git a/src/ddtranslatorSoclib/toSoclib/TasksAndMainGenerator.java b/src/ddtranslatorSoclib/toSoclib/TasksAndMainGenerator.java
index 7abb9e906cf08fb1b65352a0f52fd67488c66ba3..30508dc31f55f26b0393db8bb424f2eada544909 100755
--- a/src/ddtranslatorSoclib/toSoclib/TasksAndMainGenerator.java
+++ b/src/ddtranslatorSoclib/toSoclib/TasksAndMainGenerator.java
@@ -190,7 +190,7 @@ public class TasksAndMainGenerator {
     	mainFile.appendToBeforeMainCode("/* Main mutex */" + CR);
 
     	mainFile.appendToHCode("extern pthread_mutex_t __mainMutex;" + CR + CR);
-    	//  mainFile.appendToBeforeMainCode("pthread_mutex_t __mainMutex;" + CR + CR);
+    	
     	mainFile.appendToBeforeMainCode("pthread_barrier_t barrier ;" + CR );
     	mainFile.appendToBeforeMainCode("pthread_attr_t *attr_t;" + CR );
     	mainFile.appendToBeforeMainCode("pthread_mutex_t __mainMutex;" + CR2 );
@@ -199,12 +199,11 @@ public class TasksAndMainGenerator {
 
     	//for(AvatarRelation ar: avspec.getRelations()) {
     	for (AvatarRAM ram : TopCellGenerator.avatardd.getAllRAM()) { 
-    		//for(AvatarChannel ar: avspec.getChannels()) {
-    		//for(AvatarChannel channel: ram.getChannels()){ 
-		    for(AvatarRelation ar: avspec.getRelations()) {//DG 15.05.2017
-
-			for(int i=0; i<ar.nbOfSignals() ; i++) {//DG 15.05.2017
+    		
+	    for(AvatarRelation ar: avspec.getRelations()) {
 
+       		for(int i=0; i<ar.nbOfSignals() ; i++) {
+		   
     			mainFile.appendToBeforeMainCode("#define CHANNEL"+d+" __attribute__((section(\"section_channel"+d+"\")))" + CR ); 	
     			mainFile.appendToBeforeMainCode("#define LOCK"+d+" __attribute__((section(\"section_lock"+d+"\")))" + CR );//one lock per channel
     			d++;		      			
@@ -232,32 +231,23 @@ public class TasksAndMainGenerator {
         for(AvatarRelation ar: avspec.getRelations()) {
 	    
 	if (!ar.isAsynchronous()) {
-	    //ar.setId(j); 
-	    // ar.setId(i);//DG 15.05.2017 
-	    //j++;
-	    //i++; 		    
+k= ar.nbOfSignals()-1;     
+	   		    
 	    for(i=0; i<ar.nbOfSignals() ; i++) {
-ar.setId(i);//DG 15.05.2017 
-//i++; 
+		ar.setId(i);
 
-            ar.setId(i);//DG 15.05.2017 
+		mainFile.appendToHCode("extern syncchannel __" + getChannelName(ar, i) + ";" + CR);
 
-			mainFile.appendToHCode("extern syncchannel __" + getChannelName(ar, i) + ";" + CR);
+		mainFile.appendToBeforeMainCode("syncchannel __" +getChannelName(ar, i) + ";" + CR);
 
-			mainFile.appendToBeforeMainCode("syncchannel __" +getChannelName(ar, i) + ";" + CR);
-
-	mainFile.appendToMainCode(getChannelName(ar, i) + "_status.rptr = 0;" + CR);		
-	mainFile.appendToMainCode(getChannelName(ar, i) + "_status.wptr = 0;" + CR);
-	mainFile.appendToMainCode(getChannelName(ar, i) + "_status.usage = 0;" + CR);
-	mainFile.appendToMainCode(getChannelName(ar, i) + "_status.lock = 0;" + CR2);
+		mainFile.appendToMainCode(getChannelName(ar, i) + "_status.rptr = 0;" + CR);		
+		mainFile.appendToMainCode(getChannelName(ar, i) + "_status.wptr = 0;" + CR);
+		mainFile.appendToMainCode(getChannelName(ar, i) + "_status.usage = 0;" + CR);
+		mainFile.appendToMainCode(getChannelName(ar, i) + "_status.lock = 0;" + CR2);
 	
-	//mainFile.appendToMainCode(getChannelName(ar, i) + ".width = 4;" + CR);
-
 
-	//DG 27.03.
-	AvatarSignal sig = ar.getSignal1(0);
+	AvatarSignal sig = ar.getSignal1(i);
         int nbParams= sig.getNbParams();	
-	//DG 9.5.
 	
 	if (nbParams>0)
 	    mainFile.appendToMainCode(getChannelName(ar, i) + ".width = "+ (nbParams*4)+";" + CR);
@@ -272,14 +262,13 @@ ar.setId(i);//DG 15.05.2017
 	mainFile.appendToMainCode("__" + getChannelName(ar, i) + ".inname =\"" + ar.getInSignal(i).getName() + "\";" + CR);
 	mainFile.appendToMainCode("__" +getChannelName(ar, i) + ".outname =\"" + ar.getOutSignal(i).getName() + "\";" + CR);		
 	mainFile.appendToMainCode("__" + getChannelName(ar, i) + ".mwmr_fifo = &" + getChannelName(ar, i) + ";" + CR);
-
-	//DG 18.05 ToDo: attention il y a des canaux dans un sens et dans un autre; il faut adapter les initialisations de ok et ok 2 en fonction!!!
-	//	AvatarSignal sig;
-	if(sig.isOut()){//DG 19.05. sig est deja declare (sig1 du block :-)
-	    mainFile.appendToMainCode("__" + getChannelName(ar, i) + ".ok = 1;" + CR);	mainFile.appendToMainCode("__" + getChannelName(ar, i) + ".ok2 = 0;" + CR);
+	
+if(sig.isIn()){//DG 19.05. sig est deja declare (sig1 du block :-)
+	    mainFile.appendToMainCode("__" + getChannelName(ar, i) + ".ok_send = 0;" + CR);	mainFile.appendToMainCode("__" + getChannelName(ar, i) + ".ok_receive = 1;" + CR);
 	    }
-	    else{   
-	    	    mainFile.appendToMainCode("__" + getChannelName(ar, i) + ".ok = 0;" + CR);	mainFile.appendToMainCode("__" + getChannelName(ar, i) + ".ok2 = 1;" + CR);
+
+	if(sig.isOut()){
+	    mainFile.appendToMainCode("__" + getChannelName(ar, i) + ".ok_send = 1;" + CR);	mainFile.appendToMainCode("__" + getChannelName(ar, i) + ".ok_receive = 0;" + CR);
 	    }
 
 	/* init because mutekh initializer does not work for this */		
@@ -289,14 +278,7 @@ ar.setId(i);//DG 15.05.2017
 			mainFile.appendToMainCode(getChannelName(ar, i)+".status->rptr=0;" + CR);
 			mainFile.appendToMainCode(getChannelName(ar, i)+".status->usage=0;" + CR);
 			mainFile.appendToMainCode(getChannelName(ar, i) + ".status->wptr =0;" + CR);
-				     
-			/*	mainFile.appendToBeforeMainCode("uint32_t const "+ getChannelName(ar, i)+"_lock LOCK"+ar.getId()+";" + CR); 
-	mainFile.appendToBeforeMainCode("struct mwmr_status_s "+ getChannelName(ar, i) +"_status CHANNEL"+ar.getId()+";" + CR); 		
-	       
-	mainFile.appendToBeforeMainCode("uint8_t "+getChannelName(ar, i) +"_data[32] CHANNEL"+ar.getId()+";" + CR);
-		
-	mainFile.appendToBeforeMainCode("struct mwmr_s "+getChannelName(ar, i) +" CHANNEL"+ar.getId()+";" + CR2);*/
-
+				     		
 		mainFile.appendToBeforeMainCode("uint32_t const "+ getChannelName(ar, i)+"_lock LOCK"+k+";" + CR); 
 	mainFile.appendToBeforeMainCode("struct mwmr_status_s "+ getChannelName(ar, i) +"_status CHANNEL"+k+";" + CR); 		
 	       
@@ -304,7 +286,7 @@ ar.setId(i);//DG 15.05.2017
 		
 	mainFile.appendToBeforeMainCode("struct mwmr_s "+getChannelName(ar, i) +" CHANNEL"+k+";" + CR2);
 				
-	k++;	    
+	k--;//DG 24.05.	    
 	    }
 	}
 	}
@@ -319,6 +301,7 @@ ar.setId(i);//DG 15.05.2017
             int j=0;
 	    for(AvatarRelation ar: avspec.getRelations()) {
 		//ar.setId(j); j++;//DG
+   //DG 24.05.2017 pas reinitialiser k car 0 to n syncchannels n+1 to m asyncchannels
 		if (ar.isAsynchronous()) {
 		    for(int i=0; i<ar.nbOfSignals() ; i++) {
 
@@ -339,8 +322,8 @@ ar.setId(i);//DG 15.05.2017
 			if (nbParams>0)
 			    mainFile.appendToMainCode(getChannelName(ar, i) + ".width = "+ (nbParams*4)+";" + CR);
 			else mainFile.appendToMainCode(getChannelName(ar, i) + ".width = "+ 4 +";" + CR);
-	//	mainFile.appendToMainCode(getChannelName(ar, i) + ".depth = "+ ar.getSizeOfFIFO()+"1;" + CR);
-	mainFile.appendToMainCode(getChannelName(ar, i) + ".depth = "+ ar.getSizeOfFIFO()+";" + CR);//DG 27.03.
+
+			mainFile.appendToMainCode(getChannelName(ar, i) + ".depth = "+ ar.getSizeOfFIFO()+";" + CR);//DG 27.03.
 			mainFile.appendToMainCode(getChannelName(ar, i) + ".gdepth = "+getChannelName(ar, i)+".depth;" + CR); 
 			mainFile.appendToMainCode(getChannelName(ar, i) + ".buffer = "+getChannelName(ar, i)+"_data;" + CR);
 			mainFile.appendToMainCode(getChannelName(ar, i) + ".status = &"+getChannelName(ar, i)+"_status;" + CR);
@@ -363,22 +346,15 @@ ar.setId(i);//DG 15.05.2017
 	mainFile.appendToMainCode(getChannelName(ar, i)+".status->rptr=0;" + CR);
 	mainFile.appendToMainCode(getChannelName(ar, i)+".status->usage=0;" + CR);
 	mainFile.appendToMainCode(getChannelName(ar, i)+".status->wptr=0;" + CR);
-	    
-	    
-	//int seg_no=0;
-	/*      mainFile.appendToBeforeMainCode("uint32_t const "+ getChannelName(ar, i)+"_lock LOCK"+ar.getId()+";" + CR); 
-	mainFile.appendToBeforeMainCode("struct mwmr_status_s "+ getChannelName(ar, i) +"_status CHANNEL"+ar.getId()+";" + CR); 		
-	       
-	mainFile.appendToBeforeMainCode("uint8_t "+getChannelName(ar, i) +"_data[32] CHANNEL"+ar.getId()+";" + CR);
-		
-	mainFile.appendToBeforeMainCode("struct mwmr_s "+getChannelName(ar, i) +" CHANNEL"+ar.getId()+";" + CR2);*/		
-		   mainFile.appendToBeforeMainCode("uint32_t const "+ getChannelName(ar, i)+"_lock LOCK"+k+";" + CR); 
+	    	    
+	
+	mainFile.appendToBeforeMainCode("uint32_t const "+ getChannelName(ar, i)+"_lock LOCK"+k+";" + CR); 
 	mainFile.appendToBeforeMainCode("struct mwmr_status_s "+ getChannelName(ar, i) +"_status CHANNEL"+k+";" + CR); 		
 	       
 	mainFile.appendToBeforeMainCode("uint8_t "+getChannelName(ar, i) +"_data[32] CHANNEL"+k+";" + CR);
 		
 	mainFile.appendToBeforeMainCode("struct mwmr_s "+getChannelName(ar, i) +" CHANNEL"+k+";" + CR2);
-		k++;		    
+	k--;	    
 		    }
 		}
 	    }
@@ -611,12 +587,10 @@ ar.setId(i);//DG 15.05.2017
             ret2+= CR + "struct mwmr_s *" + getChannelName(ar, as);
 	    //}
         }
-
-
         return ret2;
     }
 
-  
+
     public static String[] enleveDoublons(String[] table) {
 
         String[] copy = new String[table.length];
@@ -730,7 +704,6 @@ ar.setId(i);//DG 15.05.2017
         String tmp;
         // Making other states
 
-
         for(AvatarStateMachineElement asme: asm.getListOfElements()) {
             if (asme instanceof AvatarState) {
                 s += "case STATE__" + asme.getName() + ": " + CR;
@@ -751,7 +724,6 @@ ar.setId(i);//DG 15.05.2017
         }
 
         s += "}" + CR;
-
         s += "}" + CR;
 
         s+= "//printf(\"Exiting = %s\\n\", __myname);" + CR;
@@ -764,7 +736,6 @@ ar.setId(i);//DG 15.05.2017
     public String makeBehaviourFromElement(AvatarBlock _block, AvatarStateMachineElement _asme, boolean firstCall) {
      //   AvatarStateMachineElement asme0;
 
-
         if (_asme == null) {
             return "";
         }
@@ -910,8 +881,7 @@ ar.setId(i);//DG 15.05.2017
         if (_asme instanceof AvatarActionOnSignal) {
             AvatarActionOnSignal aaos = (AvatarActionOnSignal)_asme;
             ret += makeSignalAction(aaos, 0, false, "", "");
-           // AvatarSignal as = aaos.getSignal();
-           // AvatarRelation ar = avspec.getAvatarRelationWithSignal(as);
+           ;
             ret += executeOneRequest("__req0");
             ret += traceRequest();
         }
@@ -975,7 +945,7 @@ ar.setId(i);//DG 15.05.2017
 		    ret += "__params" + _index + "[" + i + "] = &" +  _aaos.getValue(i) + ";" + CR;
                 }
                 if (ar.isAsynchronous()) {
-		    //DG 3.12. inserted debug messages
+		  
 		    ret += "debug2Msg(__myname, \"-> (=====)before MakeNewRequest\");" + CR;
 		    ret+="debugInt(\"channel address\", &__req"+_index+");" + CR;
 		    ret += "makeNewRequest(&__req" + _index + ", " + _aaos.getID() + ", SEND_ASYNC_REQUEST, " + delay + ", " + _aaos.getNbOfValues() + ", __params" + _index + ");" + CR;
@@ -1023,12 +993,10 @@ ar.setId(i);//DG 15.05.2017
 	return ret;
     }
 
-
     private String makeImmediateAction(AvatarTransition _at, int _index) {
         String ret = "";
         if (_at.isGuarded()) {
-           String g = modifyGuard(_at.getGuard().toString());
-	   
+           String g = modifyGuard(_at.getGuard().toString());	   
             ret += "if (" + g + ") {" + CR;
         }
 
@@ -1101,12 +1069,7 @@ ar.setId(i);//DG 15.05.2017
 		int i;
 		
 	  if(ar.nbOfSignals()!=0){
-	      for(i=0; i<ar.nbOfSignals() ; i++) {		  		
-	
-		  //	  if(((ar.block1.getName()==taskFile.getName())||(ar.block2.getName()==taskFile.getName()))&&(ar.isAsynchronous())){ //DG 2.5.
-
-		  //DG 5.7.2016 is it correct to declare one channels array per couple f communicationg tasks? Attention doubly named channels!
-
+	      for(i=0; i<ar.nbOfSignals() ; i++) {		  				
 		  if(((ar.block1.getName()==taskFile.getName())||(ar.block2.getName()==taskFile.getName()))){ 
 		      channelString+="channels_array_"+  taskFile.getName() +"["+j+"]=&"+getChannelName(ar, i)+";" + CR;
 		      cptchannels_array ++;
@@ -1116,7 +1079,7 @@ ar.setId(i);//DG 15.05.2017
 }	  
 	    }
 	    //skip this line if there are no channels associated
-	 	  //DG 5.7.2016 is it correct to declare one channels array per couple f communicationg tasks? Attention doubly named channels!
+	 	 
 	        if(!(cptchannels_array==0)){
 		mainFile.appendToMainCode("struct mwmr_s *channels_array_"+  taskFile.getName() +"["+cptchannels_array+"];"+CR);
 	        mainFile.appendToMainCode(channelString+CR);
@@ -1129,12 +1092,10 @@ ar.setId(i);//DG 15.05.2017
 	    mainFile.appendToMainCode("ptr =malloc(sizeof(pthread_t));" + CR);		   
 	    mainFile.appendToMainCode("thread__"+taskFile.getName() + "= (pthread_t)ptr;" + CR); 
 	    mainFile.appendToMainCode("attr_t = malloc(sizeof(pthread_attr_t));" + CR);
-	    //mainFile.appendToMainCode("attr_t->cpucount = "+ taskFile.getCPUId()  +";  " +CR);
+	    
 	    mainFile.appendToMainCode("pthread_attr_affinity(attr_t, "+ taskFile.getCPUId()  +");  " +CR);
 	    mainFile.appendToMainCode(CR + CR + mainDebugMsg("Starting tasks"));
-	    //if(cptchannels_array==0){
-	    //	mainFile.appendToMainCode("pthread_create(&thread__" +taskFile.getName()+", NULL, mainFunc__" + taskFile.getName()+", NULL);" + CR2);
-	    // }else{	    
+	   
 	    mainFile.appendToMainCode("pthread_create(&thread__" +taskFile.getName()+", attr_t, mainFunc__" + taskFile.getName() +", (void *)channels_array_"+taskFile.getName()+");" + CR2);
 	    //}		    
 	}