diff --git a/openair2/COMMON/mac_rrc_primitives.h b/openair2/COMMON/mac_rrc_primitives.h
index 3079bebe86773149d2924e3a3b66be5d12f3b5ff..3906bc8ecbe3c4ee9e4b69855a2075dcef06c228 100644
--- a/openair2/COMMON/mac_rrc_primitives.h
+++ b/openair2/COMMON/mac_rrc_primitives.h
@@ -331,8 +331,8 @@ typedef struct{   //RRC_INTERFACE_FUNCTIONS
   char (*openair_rrc_eNB_init)(u8 ); 
   char (*openair_rrc_UE_init)(u8, u8); 
   RRC_status_t (*rrc_rx_tx)(u8,u32,u8,u8); 
-  u8 (*mac_rrc_data_ind)(u8,u32,unsigned short,char *,unsigned short,u8 eNB_flag, u8 eNB_index);
-  u8 (*mac_rrc_data_req)(u8,u32,unsigned short,u8,char *,u8 eNB_flag, u8 eNB_index);
+  u8 (*mac_rrc_data_ind)(u8,u32,u16,u8 *,u16,u8 eNB_flag, u8 eNB_index);
+  u8 (*mac_rrc_data_req)(u8,u32,u16,u8,u8 *,u8 eNB_flag, u8 eNB_index);
   void (*mac_rrc_meas_ind)(u8,MAC_MEAS_REQ_ENTRY*);
   void  (*def_meas_ind)(u8, u8);
   void (*rrc_data_indP)  (module_id_t , rb_id_t , sdu_size_t , char*);
diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c
index d9375209c18d44dce34b486cd09d0125b7fc1885..d24399ca305114d5a7d248414f9eba6763a8526a 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler.c
@@ -265,7 +265,7 @@ void terminate_ra_proc(u8 Mod_id,u32 frame,u16 rnti,unsigned char *msg3, u16 msg
 	}
 
 	if (Is_rrc_registered == 1)
-	  mac_rrc_data_ind(Mod_id,frame,CCCH,(char *)payload_ptr,rx_lengths[0],1,Mod_id,0);
+	  mac_rrc_data_ind(Mod_id,frame,CCCH,(u8 *)payload_ptr,rx_lengths[0],1,Mod_id,0);
 	// add_user.  This is needed to have the rnti for configuring UE (PHY). The UE is removed if RRC
 	// doesn't provide a CCCH SDU
 
@@ -979,7 +979,7 @@ void schedule_SI(unsigned char Mod_id,u32 frame, unsigned char *nprb,unsigned in
   bcch_sdu_length = mac_rrc_data_req(Mod_id,
 				     frame,
 				     BCCH,1,
-				     (char*)&eNB_mac_inst[Mod_id].BCCH_pdu.payload[0],
+				     &eNB_mac_inst[Mod_id].BCCH_pdu.payload[0],
 				     1,
 				     Mod_id,
 				     0); // not used in this case 
@@ -1595,7 +1595,7 @@ void schedule_RA(unsigned char Mod_id,u32 frame, unsigned char subframe,unsigned
 	  rrc_sdu_length = mac_rrc_data_req(Mod_id,
 					    frame,
 					    CCCH,1,
-					    (char*)&eNB_mac_inst[Mod_id].CCCH_pdu.payload[0],
+					    &eNB_mac_inst[Mod_id].CCCH_pdu.payload[0],
 					    1,
 					    Mod_id,
 					    0); // not used in this case 
@@ -3376,7 +3376,7 @@ void schedule_ue_spec(unsigned char Mod_id,
   u16 sdu_length_total=0;
   //  unsigned char loop_count;
   unsigned char DAI;
-  u16 i=0,ii=0,tpmi0=1;
+  u16 i=0;
   u8 dl_pow_off[NUMBER_OF_UE_MAX];
   unsigned char rballoc_sub_UE[NUMBER_OF_UE_MAX][N_RBGS_MAX];
 //   unsigned char rballoc_sub[N_RBGS_MAX];
@@ -4191,7 +4191,9 @@ void eNB_dlsch_ulsch_scheduler(u8 Mod_id,u8 cooperation_flag, u32 frame, u8 subf
   unsigned int nCCE=0;
   int mbsfn_status=0;
   u32 RBalloc=0;
+#ifdef EXMIMO
   int ret;
+#endif
 
   DCI_PDU *DCI_pdu= &eNB_mac_inst[Mod_id].DCI_pdu;
   //  LOG_D(MAC,"[eNB %d] Frame %d, Subframe %d, entering MAC scheduler\n",Mod_id, frame, subframe);
diff --git a/openair2/LAYER2/MAC/ra_procedures.c b/openair2/LAYER2/MAC/ra_procedures.c
index 00d7178bcc4f91c286c354b071a0c7839bbe4505..a78412dc347640e5b963a3b4722409c400e4aa3b 100644
--- a/openair2/LAYER2/MAC/ra_procedures.c
+++ b/openair2/LAYER2/MAC/ra_procedures.c
@@ -240,7 +240,7 @@ PRACH_RESOURCES_t *ue_get_rach(u8 Mod_id,u32 frame, u8 eNB_index,u8 subframe){
 	Size = mac_rrc_data_req(Mod_id,
 				frame,
 				CCCH,1,
-				(char*)&UE_mac_inst[Mod_id].CCCH_pdu.payload[sizeof(SCH_SUBHEADER_SHORT)+1],0,
+				&UE_mac_inst[Mod_id].CCCH_pdu.payload[sizeof(SCH_SUBHEADER_SHORT)+1],0,
 				eNB_index);
 	Size16 = (u16)Size;
 	
diff --git a/openair2/LAYER2/MAC/ue_procedures.c b/openair2/LAYER2/MAC/ue_procedures.c
index 22eb40fa8cee5f2ad67c1a42e995b8a535ceba8a..957a2a51aeaa8046487d9e24c3dcfaf1f41a02cb 100644
--- a/openair2/LAYER2/MAC/ue_procedures.c
+++ b/openair2/LAYER2/MAC/ue_procedures.c
@@ -348,13 +348,13 @@ void ue_send_sdu(u8 Mod_id,u32 frame,u8 *sdu,u16 sdu_len,u8 eNB_index) {
 #if defined(ENABLE_MAC_PAYLOAD_DEBUG)
       int j;
       for (j=0;j<rx_lengths[i];j++)
-        LOG_T(MAC,"%x.",(unsigned char)payload_ptr[j]);
+        LOG_T(MAC,"%x.",(u8)payload_ptr[j]);
       LOG_T(MAC,"\n");
 #endif      
       mac_rrc_data_ind(Mod_id,
 		       frame,
 		       CCCH,
-		       (char *)payload_ptr,rx_lengths[i],0,eNB_index,0);
+		       (u8 *)payload_ptr,rx_lengths[i],0,eNB_index,0);
 
     }
     else if (rx_lcids[i] == DCCH) {
@@ -415,7 +415,7 @@ void ue_decode_si(u8 Mod_id,u32 frame, u8 eNB_index, void *pdu,u16 len) {
   mac_rrc_data_ind(Mod_id,
 		   frame,
 		   BCCH,
-		   (char *)pdu,
+		   (u8 *)pdu,
 		   len,
 		   0,
 		   eNB_index,
diff --git a/openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.c b/openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.c
index 314acf7a8a8893cec4ba5840cb35a007034944b8..6b88c5ac3ce5db4ce3c91dc88ca92565ef038fa1 100644
--- a/openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.c
+++ b/openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.c
@@ -87,7 +87,7 @@
 #include "openair_rrc_L2_interface.h"
  
 /********************************************************************************************************************/
-s8 mac_rrc_data_req(u8 Mod_id, u32 frame, u16 Srb_id, u8 Nb_tb,char *Buffer,u8 eNB_flag,u8 eNB_index, u8 mbsfn_sync_area){
+s8 mac_rrc_data_req(u8 Mod_id, u32 frame, u16 Srb_id, u8 Nb_tb,u8 *Buffer,u8 eNB_flag,u8 eNB_index, u8 mbsfn_sync_area){
 /********************************************************************************************************************/
 #ifdef CELLULAR
   return(rrc_L2_data_req_rx(Mod_id,Srb_id,Nb_tb,Buffer,eNB_index));
@@ -96,7 +96,7 @@ s8 mac_rrc_data_req(u8 Mod_id, u32 frame, u16 Srb_id, u8 Nb_tb,char *Buffer,u8 e
 #endif //CELLULAR
 }   
    
-s8 mac_rrc_data_ind(u8 Mod_id, u32 frame, u16 Srb_id, char *Sdu,u16 Sdu_len,u8 eNB_flag, u8 eNB_index,u8 mbsfn_sync_area){ 
+s8 mac_rrc_data_ind(u8 Mod_id, u32 frame, u16 Srb_id, u8 *Sdu,u16 Sdu_len,u8 eNB_flag, u8 eNB_index,u8 mbsfn_sync_area){
 #ifdef CELLULAR
   return(rrc_L2_mac_data_ind_rx(Mod_id, Srb_id, Sdu, Sdu_len, eNB_index));
 #else 
diff --git a/openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.h b/openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.h
index f51c846cfdc53a496bbd82d154be4c87116d4a72..7019d0fd5a9d30d0cb0be677e42f82048bfa3fd0 100644
--- a/openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.h
+++ b/openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.h
@@ -40,8 +40,8 @@
 
 #include "COMMON/mac_rrc_primitives.h"
 
-s8 mac_rrc_data_req( u8 Mod_id, u32 frame, u16 Srb_id, u8 Nb_tb,char *Buffer,u8 eNB_flag,u8 eNB_index, u8 mbsfn_sync_area);
-s8 mac_rrc_data_ind( u8 Mod_id,  u32 frame, u16 Srb_id, char *Sdu, u16 Sdu_len,u8 eNB_flag, u8 eNB_index,u8 mbsfn_sync_area);
+s8 mac_rrc_data_req( u8 Mod_id, u32 frame, u16 Srb_id, u8 Nb_tb,u8 *Buffer,u8 eNB_flag,u8 eNB_index, u8 mbsfn_sync_area);
+s8 mac_rrc_data_ind( u8 Mod_id,  u32 frame, u16 Srb_id, u8 *Sdu, u16 Sdu_len,u8 eNB_flag, u8 eNB_index,u8 mbsfn_sync_area);
 void mac_lite_sync_ind( u8 Mod_id, u8 status);
 void mac_rrc_meas_ind(u8,MAC_MEAS_REQ_ENTRY*);
 void rlcrrc_data_ind( u8 Mod_id, u32 frame, u8 eNB_flag,unsigned int Rb_id, u32 sdu_size,u8 *Buffer);
diff --git a/openair2/RRC/LITE/L2_interface.c b/openair2/RRC/LITE/L2_interface.c
index 82f27ba59e40c0dce5f43e92f4cbfba3d32003d7..c82e27ecc44dd2a740b6eb8a6eee3485c396066e 100644
--- a/openair2/RRC/LITE/L2_interface.c
+++ b/openair2/RRC/LITE/L2_interface.c
@@ -52,6 +52,10 @@ extern eNB_MAC_INST *eNB_mac_inst;
 extern UE_MAC_INST *UE_mac_inst;
 #endif
 
+#if defined(ENABLE_ITTI)
+# include "intertask_interface.h"
+#endif
+
 //#define RRC_DATA_REQ_DEBUG
 #define DEBUG_RRC
 
@@ -178,23 +182,44 @@ s8 mac_rrc_lite_data_req( u8 Mod_id,
   return(0);
 }
 
-s8 mac_rrc_lite_data_ind(u8 Mod_id, u32 frame, u16 Srb_id, char *Sdu, u16 Sdu_len,u8 eNB_flag,u8 eNB_index,u8 mbsfn_sync_area){
+s8 mac_rrc_lite_data_ind(u8 Mod_id, u32 frame, u16 Srb_id, u8 *Sdu, u16 sdu_size,u8 eNB_flag,u8 eNB_index,u8 mbsfn_sync_area){
 
   SRB_INFO *Srb_info;
+  /*
   int si_window;
+  */
 
   if(eNB_flag == 0){
 
     if(Srb_id == BCCH){
       
       LOG_T(RRC,"[UE %d] Received SDU for BCCH on SRB %d from eNB %d\n",Mod_id,Srb_id,eNB_index);
-      decode_BCCH_DLSCH_Message(Mod_id,frame,eNB_index,Sdu,Sdu_len);
+
+#if defined(ENABLE_ITTI)
+      {
+        MessageDef *message_p;
+        // Uses a new buffer to avoid issue with MAC buffer content that could be changed by MAC (asynchronous message handling).
+        u8 *message_buffer;
+
+        message_buffer = malloc (sdu_size);
+        memcpy (message_buffer, Sdu, sdu_size);
+
+        message_p = itti_alloc_new_message (TASK_MAC, RRC_MAC_BCCH_DATA_IND);
+        RRC_MAC_BCCH_DATA_IND (message_p).frame = frame;
+        RRC_MAC_BCCH_DATA_IND (message_p).sdu_size = sdu_size;
+        RRC_MAC_BCCH_DATA_IND (message_p).sdu_p = message_buffer;
+        RRC_MAC_BCCH_DATA_IND (message_p).enb_index = eNB_index;
+
+        itti_send_msg_to_task (TASK_RRC_UE, Mod_id, message_p);
+      }
+#else
+      decode_BCCH_DLSCH_Message(Mod_id,frame,eNB_index,Sdu,sdu_size);
       /*
       if ((frame %2) == 0) {
 	if (UE_rrc_inst[Mod_id].Info[eNB_index].SIB1Status == 0) {
-	  LOG_D(RRC,"[UE %d] Frame %d : Received SIB1 from eNB %d (%d bytes)\n",Mod_id,frame,eNB_index,Sdu_len);
+	  LOG_D(RRC,"[UE %d] Frame %d : Received SIB1 from eNB %d (%d bytes)\n",Mod_id,frame,eNB_index,sdu_size);
 	  if (UE_rrc_inst[Mod_id].SIB1[eNB_index])
-	    memcpy(UE_rrc_inst[Mod_id].SIB1[eNB_index],&Sdu[0],Sdu_len);
+	    memcpy(UE_rrc_inst[Mod_id].SIB1[eNB_index],&Sdu[0],sdu_size);
 	  else {
 	    LOG_E(RRC,"[FATAL ERROR] SIB1 buffer for eNB %d not allocated, exiting ...\n",eNB_index);
 	    mac_xface->macphy_exit("");
@@ -208,8 +233,8 @@ s8 mac_rrc_lite_data_ind(u8 Mod_id, u32 frame, u16 Srb_id, char *Sdu, u16 Sdu_le
 	if ((UE_rrc_inst[Mod_id].Info[eNB_index].SIB1Status == 1) &&
 	    (UE_rrc_inst[Mod_id].Info[eNB_index].SIStatus == 0)) {
 	  si_window = (frame%UE_rrc_inst[Mod_id].Info[eNB_index].SIperiod)/frame%UE_rrc_inst[Mod_id].Info[eNB_index].SIwindowsize;
-	  LOG_D(RRC,"[UE %d] Frame %d : Received SI (%d bytes), in window %d (SIperiod %d, SIwindowsize %d)\n",Mod_id,frame,Sdu_len,si_window,UE_rrc_inst[Mod_id].Info[eNB_index].SIperiod,UE_rrc_inst[Mod_id].Info[eNB_index].SIwindowsize);
-	  memcpy(UE_rrc_inst[Mod_id].SI[eNB_index],&Sdu[0],Sdu_len);
+	  LOG_D(RRC,"[UE %d] Frame %d : Received SI (%d bytes), in window %d (SIperiod %d, SIwindowsize %d)\n",Mod_id,frame,sdu_size,si_window,UE_rrc_inst[Mod_id].Info[eNB_index].SIperiod,UE_rrc_inst[Mod_id].Info[eNB_index].SIwindowsize);
+	  memcpy(UE_rrc_inst[Mod_id].SI[eNB_index],&Sdu[0],sdu_size);
 	  if (decode_SI(Mod_id,frame,eNB_index,si_window)==0) {
 	    LOG_D(RRC,"[UE %d] Frame %d :Decoded SI successfully\n",Mod_id,frame);
 	    UE_rrc_inst[Mod_id].Info[eNB_index].SIStatus = 1;
@@ -229,17 +254,37 @@ s8 mac_rrc_lite_data_ind(u8 Mod_id, u32 frame, u16 Srb_id, char *Sdu, u16 Sdu_le
 	}
       }
       */
+#endif
     }
 
-
     if((Srb_id & RAB_OFFSET) == CCCH){
-      Srb_info = &UE_rrc_inst[Mod_id].Srb0[eNB_index];
-      
-      if (Sdu_len>0) {
-	LOG_T(RRC,"[UE %d] Received SDU for CCCH on SRB %d from eNB %d\n",Mod_id,Srb_id & RAB_OFFSET,eNB_index);
-	memcpy(Srb_info->Rx_buffer.Payload,Sdu,Sdu_len);
-	Srb_info->Rx_buffer.payload_size = Sdu_len;
-	rrc_ue_decode_ccch(Mod_id,frame,Srb_info,eNB_index);
+      if (sdu_size>0) {
+        LOG_T(RRC,"[UE %d] Received SDU for CCCH on SRB %d from eNB %d\n",Mod_id,Srb_id & RAB_OFFSET,eNB_index);
+
+#if defined(ENABLE_ITTI)
+        {
+          MessageDef *message_p;
+          // Uses a new buffer to avoid issue with MAC buffer content that could be changed by MAC (asynchronous message handling).
+          u8 *message_buffer;
+
+          message_buffer = malloc (sdu_size);
+          memcpy (message_buffer, Sdu, sdu_size);
+
+          message_p = itti_alloc_new_message (TASK_MAC, RRC_MAC_CCCH_DATA_IND);
+          RRC_MAC_CCCH_DATA_IND (message_p).frame = frame;
+          RRC_MAC_CCCH_DATA_IND (message_p).sdu_size = sdu_size;
+          RRC_MAC_CCCH_DATA_IND (message_p).sdu_p = message_buffer;
+          RRC_MAC_CCCH_DATA_IND (message_p).enb_index = eNB_index;
+
+          itti_send_msg_to_task (TASK_RRC_UE, Mod_id, message_p);
+      }
+#else
+        Srb_info = &UE_rrc_inst[Mod_id].Srb0[eNB_index];
+
+        memcpy(Srb_info->Rx_buffer.Payload,Sdu,sdu_size);
+        Srb_info->Rx_buffer.payload_size = sdu_size;
+        rrc_ue_decode_ccch(Mod_id, frame, Srb_info, eNB_index);
+#endif
       }
     }
       
@@ -247,7 +292,28 @@ s8 mac_rrc_lite_data_ind(u8 Mod_id, u32 frame, u16 Srb_id, char *Sdu, u16 Sdu_le
     if ((Srb_id & RAB_OFFSET) == MCCH) {
       LOG_T(RRC,"[UE %d] Frame %d: Received SDU on MBSFN sync area %d for MCCH on SRB %d from eNB %d\n",
 	    Mod_id,frame, mbsfn_sync_area, Srb_id & RAB_OFFSET,eNB_index);
-      decode_MCCH_Message(Mod_id, frame, eNB_index, Sdu, Sdu_len,mbsfn_sync_area);
+
+#if defined(ENABLE_ITTI)
+      {
+        MessageDef *message_p;
+        // Uses a new buffer to avoid issue with MAC buffer content that could be changed by MAC (asynchronous message handling).
+        u8 *message_buffer;
+
+        message_buffer = malloc (sdu_size);
+        memcpy (message_buffer, Sdu, sdu_size);
+
+        message_p = itti_alloc_new_message (TASK_MAC, RRC_MAC_MCCH_DATA_IND);
+        RRC_MAC_MCCH_DATA_IND (message_p).frame = frame;
+        RRC_MAC_MCCH_DATA_IND (message_p).sdu_size = sdu_size;
+        RRC_MAC_MCCH_DATA_IND (message_p).sdu_p = message_buffer;
+        RRC_MAC_MCCH_DATA_IND (message_p).enb_index = eNB_index;
+        RRC_MAC_MCCH_DATA_IND (message_p).mbsfn_sync_area = mbsfn_sync_area;
+
+        itti_send_msg_to_task (TASK_RRC_UE, Mod_id, message_p);
+      }
+#else
+      decode_MCCH_Message(Mod_id, frame, eNB_index, Sdu, sdu_size, mbsfn_sync_area);
+#endif
     }
 #endif // Rel10
 
@@ -269,6 +335,16 @@ s8 mac_rrc_lite_data_ind(u8 Mod_id, u32 frame, u16 Srb_id, char *Sdu, u16 Sdu_le
 //-------------------------------------------------------------------------------------------//
 void mac_lite_sync_ind(u8 Mod_id,u8 Status){
 //-------------------------------------------------------------------------------------------//
+#if defined(ENABLE_ITTI)
+  {
+    MessageDef *message_p;
+
+    message_p = itti_alloc_new_message (TASK_MAC, RRC_MAC_SYNC_IND);
+    RRC_MAC_SYNC_IND(message_p).status = Status;
+
+    itti_send_msg_to_task (TASK_RRC_UE, Mod_id, message_p);
+  }
+#endif
 }
 
 // this function is Not USED anymore
@@ -281,18 +357,52 @@ void rrc_lite_data_ind( u8 Mod_id, u32 frame, u8 eNB_flag,u32 Srb_id, u32 sdu_si
 	(eNB_flag == 1)? "eNB": "UE", 
 	(eNB_flag == 1)? Mod_id : UE_index, 
 	frame, DCCH_index,Srb_id-1,sdu_size);
-  if (eNB_flag ==1)
+
+  if (eNB_flag ==1) {
     rrc_eNB_decode_dcch(Mod_id,frame,DCCH_index,UE_index,Buffer,sdu_size);
-  else
+  }
+  else {
+#if defined(ENABLE_ITTI)
+    {
+      MessageDef *message_p;
+      // Uses a new buffer to avoid issue with PDCP buffer content that could be changed by PDCP (asynchronous message handling).
+      u8 *message_buffer;
+
+      message_buffer = malloc (sdu_size);
+      memcpy (message_buffer, Buffer, sdu_size);
+
+      message_p = itti_alloc_new_message (TASK_PDCP, RRC_DCCH_DATA_IND);
+      RRC_DCCH_DATA_IND (message_p).frame = frame;
+      RRC_DCCH_DATA_IND (message_p).dcch_index = DCCH_index;
+      RRC_DCCH_DATA_IND (message_p).sdu_size = sdu_size;
+      RRC_DCCH_DATA_IND (message_p).sdu_p = message_buffer;
+      RRC_DCCH_DATA_IND (message_p).ue_index = UE_index;
+
+      itti_send_msg_to_task (TASK_RRC_UE, Mod_id - NB_eNB_INST, message_p);
+    }
+#else
     rrc_ue_decode_dcch(Mod_id-NB_eNB_INST,frame,DCCH_index,Buffer,UE_index);
+#endif
+  }
 
 }
 
 void rrc_lite_in_sync_ind(u8 Mod_id, u32 frame, u16 eNB_index) {
+#if defined(ENABLE_ITTI)
+  {
+    MessageDef *message_p;
 
+    message_p = itti_alloc_new_message (TASK_MAC, RRC_MAC_IN_SYNC_IND);
+    RRC_MAC_IN_SYNC_IND (message_p).frame = frame;
+    RRC_MAC_IN_SYNC_IND (message_p).enb_index = eNB_index;
+
+    itti_send_msg_to_task (TASK_RRC_UE, Mod_id, message_p);
+  }
+#else
   UE_rrc_inst[Mod_id].Info[eNB_index].N310_cnt=0;
   if (UE_rrc_inst[Mod_id].Info[eNB_index].T310_active==1)
     UE_rrc_inst[Mod_id].Info[eNB_index].N311_cnt++;
+#endif
 }
 void rrc_lite_out_of_sync_ind(u8  Mod_id, u32 frame, u16 eNB_index){
 
@@ -305,7 +415,19 @@ void rrc_lite_out_of_sync_ind(u8  Mod_id, u32 frame, u16 eNB_index){
 	UE_rrc_inst[Mod_id].Info[eNB_index].N310_cnt,
 	UE_rrc_inst[Mod_id].Info[eNB_index].N311_cnt);
 
+#if defined(ENABLE_ITTI)
+  {
+    MessageDef *message_p;
+
+    message_p = itti_alloc_new_message (TASK_MAC, RRC_MAC_OUT_OF_SYNC_IND);
+    RRC_MAC_OUT_OF_SYNC_IND (message_p).frame = frame;
+    RRC_MAC_OUT_OF_SYNC_IND (message_p).enb_index = eNB_index;
+
+    itti_send_msg_to_task (TASK_RRC_UE, Mod_id, message_p);
+  }
+#else
   UE_rrc_inst[Mod_id].Info[eNB_index].N310_cnt++;
+#endif
 
 }
 
diff --git a/openair2/RRC/LITE/MESSAGES/asn1_msg.c b/openair2/RRC/LITE/MESSAGES/asn1_msg.c
index 80e30c0d3b4c82ee4cea5d879abbd1a6251794dd..a1c6e34bb0bd15b06738f1261252fd2634866b9b 100644
--- a/openair2/RRC/LITE/MESSAGES/asn1_msg.c
+++ b/openair2/RRC/LITE/MESSAGES/asn1_msg.c
@@ -51,6 +51,10 @@
 #include "ReportConfigToAddModList.h"
 #include "MeasIdToAddModList.h"
 
+#if defined(ENABLE_ITTI)
+# include "intertask_interface.h"
+#endif
+
 //#include "PHY/defs.h"
 #ifndef USER_MODE
 #define msg printk
@@ -1627,7 +1631,7 @@ uint8_t do_MBSFNAreaConfig(LTE_DL_FRAME_PARMS *frame_parms,
 }
 #endif
 
-uint8_t do_MeasurementReport(uint8_t *buffer,int measid,int phy_id,int rsrp_s,int rsrq_s,int rsrp_t,int rsrq_t) {
+uint8_t do_MeasurementReport(uint8_t *buffer,int measid,int phy_id,int rsrp_s,int rsrq_s,long rsrp_t,long rsrq_t) {
 
 
   asn_enc_rval_t enc_rval;
@@ -1725,7 +1729,7 @@ uint8_t do_MeasurementReport(uint8_t *buffer,int measid,int phy_id,int rsrp_s,in
   return((enc_rval.encoded+7)/8);
 }
 
-OAI_UECapability_t UECapability;
+static OAI_UECapability_t UECapability; /* TODO declared static to allow returning this has an address should be allocated in a cleaner way. */
 SupportedBandEUTRA_t Bandlist[4];
 BandInfoEUTRA_t BandInfo_meas[4];
 InterFreqBandInfo_t InterFreqBandInfo[4][4];
@@ -1778,7 +1782,7 @@ OAI_UECapability_t *fill_ue_capability() {
   UE_EUTRA_Capability = CALLOC(1,sizeof(*UE_EUTRA_Capability));
   memset(UE_EUTRA_Capability,0,sizeof(*UE_EUTRA_Capability));
 
-  //  UE_EUTRA_Capability->accessStratumRelease = 0;//AccessStratumRelease_rel8;
+  UE_EUTRA_Capability->accessStratumRelease = 0;//AccessStratumRelease_rel8;
   UE_EUTRA_Capability->ue_Category          = 4;
   UE_EUTRA_Capability->pdcp_Parameters.supportedROHC_Profiles.profile0x0001=0;
   UE_EUTRA_Capability->pdcp_Parameters.supportedROHC_Profiles.profile0x0002=0;
@@ -1837,11 +1841,31 @@ OAI_UECapability_t *fill_ue_capability() {
 				   (void*)UE_EUTRA_Capability,
 				   &UECapability.sdu[0],
   				   MAX_UE_CAPABILITY_SIZE);
-  UECapability.sdu_size = (enc_rval.encoded+7)/8;
-  LOG_I(PHY,"[RRC]UE Capability encoded, %d bytes (%d bits)\n",UECapability.sdu_size,enc_rval.encoded+7);
-  for (i=0;i<UECapability.sdu_size;i++)
-    printf("%02x.",UECapability.sdu[i]);
-  printf("\n");
+
+#if defined(ENABLE_ITTI)
+  /* Test code */
+  {
+    MessageDef *message_p;
+
+    message_p = itti_alloc_new_message (TASK_RRC_UE, RRC_UE_EUTRA_CAPABILITY);
+    memcpy (&message_p->msg, UE_EUTRA_Capability, sizeof(RrcUeEutraCapability));
+
+    itti_send_msg_to_task (TASK_RRC_UE, INSTANCE_DEFAULT, message_p);
+  }
+#endif
+
+  UECapability.sdu_size = (enc_rval.encoded + 7) / 8;
+  LOG_I(PHY, "[RRC]UE Capability encoded, %d bytes (%d bits)\n", UECapability.sdu_size, enc_rval.encoded+7);
+  {
+    char *sdu;
+    sdu = malloc (3 * UECapability.sdu_size);
+
+    for (i = 0; i < UECapability.sdu_size; i++)
+      sprintf (&sdu[3 * i], "%02x.", UECapability.sdu[i]);
+
+    LOG_D(PHY, "[RRC]UE Capability encoded, %s\n", sdu);
+  }
+
   return(&UECapability);
 }
 
diff --git a/openair2/RRC/LITE/defs.h b/openair2/RRC/LITE/defs.h
index b908b0a5716a160b53808a79714532ee0591eb55..ff5e62df9c7a7fbdbaf732cc5f81a7cf28c14d9d 100644
--- a/openair2/RRC/LITE/defs.h
+++ b/openair2/RRC/LITE/defs.h
@@ -459,10 +459,15 @@ void rrc_eNB_process_RRCConnectionReconfigurationComplete(u8 Mod_id,u32 frame,u8
    \param UE_index Index of UE transmitting the messages*/
 void rrc_eNB_generate_defaultRRCConnectionReconfiguration(u8 Mod_id, u32 frame, u16 UE_index, u8 *nas_pdu, u32 nas_length);
 
+#if defined(ENABLE_ITTI)
+/**\brief RRC UE task.
+   \param void *args_p Pointer on arguments to start the task. */
+void *rrc_ue_task(void *args_p);
+#endif
 
 //L2_interface.c
 s8 mac_rrc_lite_data_req( u8 Mod_id, u32 frame, unsigned short Srb_id, u8 Nb_tb,char *Buffer,u8 eNB_flag, u8 eNB_index, u8 mbsfn_sync_area);
-s8 mac_rrc_lite_data_ind( u8 Mod_id,  u32 frame, unsigned short Srb_id, char *Sdu, unsigned short Sdu_len,u8 eNB_flag,u8 eNB_index, u8 mbsfn_sync_area);
+s8 mac_rrc_lite_data_ind( u8 Mod_id,  u32 frame, unsigned short Srb_id, u8 *Sdu, unsigned short Sdu_len,u8 eNB_flag,u8 eNB_index, u8 mbsfn_sync_area);
 void mac_sync_ind( u8 Mod_id, u8 status);
 void rrc_lite_data_ind( u8 Mod_id, u32 frame, u8 eNB_flag, u32 Rb_id, u32 sdu_size,u8 *Buffer);
 void rrc_lite_out_of_sync_ind(u8 Mod_id, u32 frame, unsigned short eNB_index);
@@ -470,7 +475,9 @@ void rrc_lite_out_of_sync_ind(u8 Mod_id, u32 frame, unsigned short eNB_index);
 int decode_MCCH_Message(u8 Mod_id, u32 frame, u8 eNB_index, u8 *Sdu, u8 Sdu_len,u8 mbsfn_sync_area);
 void decode_MBSFNAreaConfiguration(u8 Mod_id, u8 eNB_index, u32 frame,u8 mbsfn_sync_area);
 
-int decode_SIB1(u8 Mod_id,u8 CH_index);
+int decode_BCCH_DLSCH_Message(u8 Mod_id,u32 frame,u8 eNB_index,u8 *Sdu,u8 Sdu_len);
+
+  int decode_SIB1(u8 Mod_id,u8 CH_index);
 
 int decode_SI(u8 Mod_id,u32 frame,u8 CH_index,u8 si_window);
 
diff --git a/openair2/RRC/LITE/rrc_common.c b/openair2/RRC/LITE/rrc_common.c
index 6fbcc937a2cbf5959bb3b3c5bb3b1cae058e803b..1e511e99f7dd80f0ed2ec574dd4badf646bc2080 100644
--- a/openair2/RRC/LITE/rrc_common.c
+++ b/openair2/RRC/LITE/rrc_common.c
@@ -1,41 +1,40 @@
 /*******************************************************************************
 
-  Eurecom OpenAirInterface 2
-  Copyright(c) 1999 - 2010 Eurecom
+ Eurecom OpenAirInterface 2
+ Copyright(c) 1999 - 2010 Eurecom
 
-  This program is free software; you can redistribute it and/or modify it
-  under the terms and conditions of the GNU General Public License,
-  version 2, as published by the Free Software Foundation.
+ This program is free software; you can redistribute it and/or modify it
+ under the terms and conditions of the GNU General Public License,
+ version 2, as published by the Free Software Foundation.
 
-  This program is distributed in the hope 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.
+ This program is distributed in the hope 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.,
-  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ 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.,
+ 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
 
-  The full GNU General Public License is included in this distribution in
-  the file called "COPYING".
+ The full GNU General Public License is included in this distribution in
+ the file called "COPYING".
 
-  Contact Information
-  Openair Admin: openair_admin@eurecom.fr
-  Openair Tech : openair_tech@eurecom.fr
-  Forums       : http://forums.eurecom.fsr/openairinterface
-  Address      : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis, France
+ Contact Information
+ Openair Admin: openair_admin@eurecom.fr
+ Openair Tech : openair_tech@eurecom.fr
+ Forums       : http://forums.eurecom.fsr/openairinterface
+ Address      : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis, France
 
-*******************************************************************************/
+ *******************************************************************************/
 
 /*! \file rrc_common.c
-* \brief rrc common procedures for eNB and UE
-* \author Raymond Knopp and Navid Nikaein
-* \date 2011
-* \version 1.0 
-* \company Eurecom
-* \email: raymond.knopp@eurecom.fr and  navid.nikaein@eurecom.fr
-*/ 
-
+ * \brief rrc common procedures for eNB and UE
+ * \author Raymond Knopp and Navid Nikaein
+ * \date 2011
+ * \version 1.0
+ * \company Eurecom
+ * \email: raymond.knopp@eurecom.fr and  navid.nikaein@eurecom.fr
+ */
 
 #include "defs.h"
 #include "extern.h"
@@ -45,37 +44,43 @@
 #include "LAYER2/RLC/rlc.h"
 #include "COMMON/mac_rrc_primitives.h"
 #include "UTIL/LOG/log.h"
+#include "asn1_msg.h"
+
+#if defined(ENABLE_ITTI)
+# include "intertask_interface.h"
+#endif
+
 #define DEBUG_RRC 1
 extern eNB_MAC_INST *eNB_mac_inst;
 extern UE_MAC_INST *UE_mac_inst;
 
 //configure  BCCH & CCCH Logical Channels and associated rrc_buffers, configure associated SRBs
-void openair_rrc_on(u8 Mod_id,u8 eNB_flag){
+void openair_rrc_on(u8 Mod_id, u8 eNB_flag) {
   unsigned short i;
 
-  if( eNB_flag == 1){
-    LOG_I(RRC,"[eNB %d] OPENAIR RRC IN....\n", Mod_id);
-
-    rrc_config_buffer(&eNB_rrc_inst[Mod_id].SI,BCCH,1);
-    eNB_rrc_inst[Mod_id].SI.Active=1;
-    rrc_config_buffer(&eNB_rrc_inst[Mod_id].Srb0,CCCH,1);
-    eNB_rrc_inst[Mod_id].Srb0.Active=1;
- 
-  } else{
-    LOG_I(RRC,"[UE %d] OPENAIR RRC IN....\n", Mod_id);
-    for(i=0;i<NB_eNB_INST;i++){
-      LOG_D(RRC, "[RRC][UE %d] Activating CCCH (eNB %d)\n",Mod_id,i);
+  if (eNB_flag == 1) {
+    LOG_I(RRC, "[eNB %d] OPENAIR RRC IN....\n", Mod_id);
+
+    rrc_config_buffer (&eNB_rrc_inst[Mod_id].SI, BCCH, 1);
+    eNB_rrc_inst[Mod_id].SI.Active = 1;
+    rrc_config_buffer (&eNB_rrc_inst[Mod_id].Srb0, CCCH, 1);
+    eNB_rrc_inst[Mod_id].Srb0.Active = 1;
+
+  }
+  else {
+    LOG_I(RRC, "[UE %d] OPENAIR RRC IN....\n", Mod_id);
+    for (i = 0; i < NB_eNB_INST; i++) {
+      LOG_D(RRC, "[RRC][UE %d] Activating CCCH (eNB %d)\n", Mod_id, i);
       UE_rrc_inst[Mod_id].Srb0[i].Srb_id = CCCH;
-      memcpy(&UE_rrc_inst[Mod_id].Srb0[i].Lchan_desc[0],&CCCH_LCHAN_DESC,LCHAN_DESC_SIZE);
-      memcpy(&UE_rrc_inst[Mod_id].Srb0[i].Lchan_desc[1],&CCCH_LCHAN_DESC,LCHAN_DESC_SIZE);
-      rrc_config_buffer(&UE_rrc_inst[Mod_id].Srb0[i],CCCH,1);
-      UE_rrc_inst[Mod_id].Srb0[i].Active=1;
+      memcpy (&UE_rrc_inst[Mod_id].Srb0[i].Lchan_desc[0], &CCCH_LCHAN_DESC, LCHAN_DESC_SIZE);
+      memcpy (&UE_rrc_inst[Mod_id].Srb0[i].Lchan_desc[1], &CCCH_LCHAN_DESC, LCHAN_DESC_SIZE);
+      rrc_config_buffer (&UE_rrc_inst[Mod_id].Srb0[i], CCCH, 1);
+      UE_rrc_inst[Mod_id].Srb0[i].Active = 1;
     }
   }
 }
 
-int rrc_init_global_param(void){
-
+int rrc_init_global_param(void) {
 
   //#ifdef USER_MODE
   //  Rrc_xface = (RRC_XFACE*)malloc16(sizeof(RRC_XFACE));
@@ -100,70 +105,67 @@ int rrc_init_global_param(void){
 #endif
   //  LOG_D(RRC, "[RRC]INIT_GLOBAL_PARAM: Mac_rlc_xface %p, rrc_rlc_register %p,rlcrrc_data_ind%p\n",Mac_rlc_xface,Mac_rlc_xface->rrc_rlc_register_rrc,rlcrrc_data_ind);
   /*
-  if((Mac_rlc_xface==NULL) || (Mac_rlc_xface->rrc_rlc_register_rrc==NULL) ||
-     (rlcrrc_data_ind==NULL)) {
-    LOG_E(RRC,"Data structured is not initialized \n");
-    return -1;
-  }
-  */
-  rrc_rlc_register_rrc(rlcrrc_data_ind ,NULL); //register with rlc
-
-
-  DCCH_LCHAN_DESC.transport_block_size=4;
-  DCCH_LCHAN_DESC.max_transport_blocks=16;
-  DCCH_LCHAN_DESC.Delay_class=1;
-  DTCH_DL_LCHAN_DESC.transport_block_size=52;
-  DTCH_DL_LCHAN_DESC.max_transport_blocks=20;
-  DTCH_DL_LCHAN_DESC.Delay_class=1;
-  DTCH_UL_LCHAN_DESC.transport_block_size=52;
-  DTCH_UL_LCHAN_DESC.max_transport_blocks=20;
-  DTCH_UL_LCHAN_DESC.Delay_class=1;
-
-  Rlc_info_um.rlc_mode=RLC_UM;
-  Rlc_info_um.rlc.rlc_um_info.timer_reordering=5;
-  Rlc_info_um.rlc.rlc_um_info.sn_field_length=10;
-  Rlc_info_um.rlc.rlc_um_info.is_mXch=0;
+   if((Mac_rlc_xface==NULL) || (Mac_rlc_xface->rrc_rlc_register_rrc==NULL) ||
+   (rlcrrc_data_ind==NULL)) {
+   LOG_E(RRC,"Data structured is not initialized \n");
+   return -1;
+   }
+   */
+  rrc_rlc_register_rrc (rlcrrc_data_ind, NULL); //register with rlc
+
+  DCCH_LCHAN_DESC.transport_block_size = 4;
+  DCCH_LCHAN_DESC.max_transport_blocks = 16;
+  DCCH_LCHAN_DESC.Delay_class = 1;
+  DTCH_DL_LCHAN_DESC.transport_block_size = 52;
+  DTCH_DL_LCHAN_DESC.max_transport_blocks = 20;
+  DTCH_DL_LCHAN_DESC.Delay_class = 1;
+  DTCH_UL_LCHAN_DESC.transport_block_size = 52;
+  DTCH_UL_LCHAN_DESC.max_transport_blocks = 20;
+  DTCH_UL_LCHAN_DESC.Delay_class = 1;
+
+  Rlc_info_um.rlc_mode = RLC_UM;
+  Rlc_info_um.rlc.rlc_um_info.timer_reordering = 5;
+  Rlc_info_um.rlc.rlc_um_info.sn_field_length = 10;
+  Rlc_info_um.rlc.rlc_um_info.is_mXch = 0;
   //Rlc_info_um.rlc.rlc_um_info.sdu_discard_mode=16;
 
-  Rlc_info_am_config.rlc_mode=RLC_AM;
+  Rlc_info_am_config.rlc_mode = RLC_AM;
   Rlc_info_am_config.rlc.rlc_am_info.max_retx_threshold = 50;
-  Rlc_info_am_config.rlc.rlc_am_info.poll_pdu           = 8;
-  Rlc_info_am_config.rlc.rlc_am_info.poll_byte          = 1000;
-  Rlc_info_am_config.rlc.rlc_am_info.t_poll_retransmit  = 15;
-  Rlc_info_am_config.rlc.rlc_am_info.t_reordering       = 50;
-  Rlc_info_am_config.rlc.rlc_am_info.t_status_prohibit  = 10;
+  Rlc_info_am_config.rlc.rlc_am_info.poll_pdu = 8;
+  Rlc_info_am_config.rlc.rlc_am_info.poll_byte = 1000;
+  Rlc_info_am_config.rlc.rlc_am_info.t_poll_retransmit = 15;
+  Rlc_info_am_config.rlc.rlc_am_info.t_reordering = 50;
+  Rlc_info_am_config.rlc.rlc_am_info.t_status_prohibit = 10;
 #ifndef NO_RRM
-  if(L3_xface_init())
-    return(-1);
+  if (L3_xface_init ())
+    return (-1);
 #endif
 
   return 0;
 }
 
-
 #ifndef NO_RRM
 /*------------------------------------------------------------------------------*/
-int L3_xface_init(void){
-/*------------------------------------------------------------------------------*/
+int L3_xface_init(void) {
+  /*------------------------------------------------------------------------------*/
 
   int ret = 0;
 
 #ifdef USER_MODE
 
-  int sock ;
+  int sock;
   LOG_D(RRC, "[L3_XFACE] init de l'interface \n");
 
-  if(open_socket(&S_rrc, RRC_RRM_SOCK_PATH, RRM_RRC_SOCK_PATH,0)==-1)
+  if (open_socket (&S_rrc, RRC_RRM_SOCK_PATH, RRM_RRC_SOCK_PATH, 0) == -1)
     return (-1);
 
-  if (S_rrc.s  == -1)
-    {
-      return (-1);
-    }
+  if (S_rrc.s == -1) {
+    return (-1);
+  }
 
-  socket_setnonblocking(S_rrc.s);
-  msg("Interface Connected... RRM-RRC\n");
-  return 0 ;
+  socket_setnonblocking (S_rrc.s);
+  msg ("Interface Connected... RRM-RRC\n");
+  return 0;
 
 #else
 
@@ -174,7 +176,7 @@ int L3_xface_init(void){
 
     return(-1);
   }
-  else{
+  else {
     msg("[openair][MAC][INIT] Created RRC2RRM fifo %d\n",RRC2RRM_FIFO);
     rtf_reset(RRC2RRM_FIFO);
   }
@@ -186,7 +188,7 @@ int L3_xface_init(void){
 
     return(-1);
   }
-  else{
+  else {
     msg("[openair][MAC][INIT] Created RRC2RRM fifo %d\n",RRM2RRC_FIFO);
     rtf_reset(RRM2RRC_FIFO);
   }
@@ -197,68 +199,67 @@ int L3_xface_init(void){
 }
 #endif
 
-void rrc_config_buffer(SRB_INFO *Srb_info, u8 Lchan_type, u8 Role){
+void rrc_config_buffer(SRB_INFO *Srb_info, u8 Lchan_type, u8 Role) {
 
   Srb_info->Rx_buffer.payload_size = 0;
   Srb_info->Tx_buffer.payload_size = 0;
 }
 
-
 /*------------------------------------------------------------------------------*/
-void openair_rrc_top_init(int eMBMS_active, u8 cba_group_active){
+void openair_rrc_top_init(int eMBMS_active, u8 cba_group_active) {
   /*-----------------------------------------------------------------------------*/
 
   int i;
-  uint8_t size;
   OAI_UECapability_t *UECap;
   //  uint8_t dummy_buffer[100];
 
-  LOG_D(RRC,"[OPENAIR][INIT] Init function start: NB_UE_INST=%d, NB_eNB_INST=%d\n",
-	NB_UE_INST,NB_eNB_INST);
-  
-  if (NB_UE_INST>0){
-    UE_rrc_inst = (UE_RRC_INST*)malloc16(NB_UE_INST*sizeof(UE_RRC_INST));
-    memset(UE_rrc_inst,0,NB_UE_INST*sizeof(UE_RRC_INST));
-    LOG_D(RRC,"ALLOCATE %d Bytes for UE_RRC_INST @ %p\n",(unsigned int)(NB_UE_INST*sizeof(UE_RRC_INST)),UE_rrc_inst);
+  LOG_D(RRC, "[OPENAIR][INIT] Init function start: NB_UE_INST=%d, NB_eNB_INST=%d\n", NB_UE_INST, NB_eNB_INST);
+
+  if (NB_UE_INST > 0) {
+    UE_rrc_inst = (UE_RRC_INST*) malloc16(NB_UE_INST*sizeof(UE_RRC_INST));
+    memset (UE_rrc_inst, 0, NB_UE_INST * sizeof(UE_RRC_INST));
+    LOG_D(RRC, "ALLOCATE %d Bytes for UE_RRC_INST @ %p\n", (unsigned int)(NB_UE_INST*sizeof(UE_RRC_INST)), UE_rrc_inst);
 
     // fill UE capability
-    UECap = fill_ue_capability();
-    for (i=0;i<NB_UE_INST;i++) {
+    UECap = fill_ue_capability ();
+    for (i = 0; i < NB_UE_INST; i++) {
       UE_rrc_inst[i].UECapability = UECap->sdu;
       UE_rrc_inst[i].UECapability_size = UECap->sdu_size;
     }
     /*
-    do_UECapabilityEnquiry(0,
-			   dummy_buffer,
-			   0,
-			   0);*/
+     do_UECapabilityEnquiry(0,
+     dummy_buffer,
+     0,
+     0);*/
 #ifdef Rel10
     LOG_I(RRC,"[UE] eMBMS active state is %d \n", eMBMS_active);
     for (i=0;i<NB_eNB_INST;i++) {
       UE_rrc_inst[i].MBMS_flag = (uint8_t)eMBMS_active;
     }
 #endif 
-  } else
-    UE_rrc_inst=NULL;
-
+  }
+  else
+    UE_rrc_inst = NULL;
 
-  if (NB_eNB_INST>0){
-    eNB_rrc_inst = (eNB_RRC_INST*)malloc16(NB_eNB_INST*sizeof(eNB_RRC_INST));
-    memset(eNB_rrc_inst,0,NB_eNB_INST*sizeof(eNB_RRC_INST));
+  if (NB_eNB_INST > 0) {
+    eNB_rrc_inst = (eNB_RRC_INST*) malloc16(NB_eNB_INST*sizeof(eNB_RRC_INST));
+    memset (eNB_rrc_inst, 0, NB_eNB_INST * sizeof(eNB_RRC_INST));
 #ifdef Rel10
     LOG_I(RRC,"[eNB] eMBMS active state is %d \n", eMBMS_active);
     for (i=0;i<NB_eNB_INST;i++) {
-    eNB_rrc_inst[i].MBMS_flag = (uint8_t)eMBMS_active;
+      eNB_rrc_inst[i].MBMS_flag = (uint8_t)eMBMS_active;
     }
 #endif 
 #ifdef CBA
     for (i=0;i<NB_eNB_INST;i++) {
-      eNB_rrc_inst[i].num_active_cba_groups  = cba_group_active;
+      eNB_rrc_inst[i].num_active_cba_groups = cba_group_active;
     }
 #endif
-    LOG_D(RRC,"ALLOCATE %d Bytes for eNB_RRC_INST @ %p\n",(unsigned int)(NB_eNB_INST*sizeof(eNB_RRC_INST)),eNB_rrc_inst);
-  }else
-    eNB_rrc_inst=NULL;
+    LOG_D(RRC,
+          "ALLOCATE %d Bytes for eNB_RRC_INST @ %p\n", (unsigned int)(NB_eNB_INST*sizeof(eNB_RRC_INST)), eNB_rrc_inst);
+  }
+  else
+    eNB_rrc_inst = NULL;
 #ifndef NO_RRM
 #ifndef USER_MODE
 
@@ -269,99 +270,213 @@ void openair_rrc_top_init(int eMBMS_active, u8 cba_group_active){
   Header_size=sizeof(msg_head_t);
 
 #endif //NO_RRM
-  Data_to_read=0;
+  Data_to_read = 0;
 #endif //USER_MODE
-
 }
 
-void rrc_top_cleanup(void){
+void rrc_top_cleanup(void) {
 
- if (NB_UE_INST>0)
-   free(UE_rrc_inst);
- if (NB_eNB_INST>0)
-   free(eNB_rrc_inst);
+  if (NB_UE_INST > 0)
+    free (UE_rrc_inst);
+  if (NB_eNB_INST > 0)
+    free (eNB_rrc_inst);
 
 }
 
-u16 T300[8] = {100,200,300,400,600,1000,1500,2000};
-u16 T310[8] = {0,50,100,200,500,1000,2000};
-u16 N310[8] = {1,2,3,4,6,8,10,20};
-u16 N311[8] = {1,2,3,4,6,8,10,20};
-
-void rrc_t310_expiration(u32 frame,u8 Mod_id,u8 eNB_index) {
-
-  if (UE_rrc_inst[Mod_id].Info[eNB_index].State!=RRC_CONNECTED) {
-    LOG_D(RRC,"Timer 310 expired, going to RRC_IDLE\n");
-    UE_rrc_inst[Mod_id].Info[eNB_index].State=RRC_IDLE;
-    UE_rrc_inst[Mod_id].Info[eNB_index].UE_index=0xffff;
-    
-    UE_rrc_inst[Mod_id].Srb0[eNB_index].Rx_buffer.payload_size=0;
-    UE_rrc_inst[Mod_id].Srb0[eNB_index].Tx_buffer.payload_size=0;
-    
-    UE_rrc_inst[Mod_id].Srb1[eNB_index].Srb_info.Rx_buffer.payload_size=0;
-    UE_rrc_inst[Mod_id].Srb1[eNB_index].Srb_info.Tx_buffer.payload_size=0;
-    
-    if(UE_rrc_inst[Mod_id].Srb2[eNB_index].Active==1){
-      msg("[RRC Inst %d] eNB_index %d, Remove RB %d\n ",Mod_id,eNB_index,UE_rrc_inst[Mod_id].Srb2[eNB_index].Srb_info.Srb_id);
-      rrc_pdcp_config_req (Mod_id+NB_eNB_INST, frame, 0, ACTION_REMOVE, UE_rrc_inst[Mod_id].Srb2[eNB_index].Srb_info.Srb_id);
-      rrc_rlc_config_req(Mod_id+NB_eNB_INST,frame,0,ACTION_REMOVE,UE_rrc_inst[Mod_id].Srb2[eNB_index].Srb_info.Srb_id,SIGNALLING_RADIO_BEARER,Rlc_info_um);
-      UE_rrc_inst[Mod_id].Srb2[eNB_index].Active=0;
-      UE_rrc_inst[Mod_id].Srb2[eNB_index].Status=IDLE;
-      UE_rrc_inst[Mod_id].Srb2[eNB_index].Next_check_frame=0;
+u16 T300[8] =
+  {100, 200, 300, 400, 600, 1000, 1500, 2000};
+u16 T310[8] =
+  {0, 50, 100, 200, 500, 1000, 2000};
+u16 N310[8] =
+  {1, 2, 3, 4, 6, 8, 10, 20};
+u16 N311[8] =
+  {1, 2, 3, 4, 6, 8, 10, 20};
+
+void rrc_t310_expiration(u32 frame, u8 Mod_id, u8 eNB_index) {
+
+  if (UE_rrc_inst[Mod_id].Info[eNB_index].State != RRC_CONNECTED) {
+    LOG_D(RRC, "Timer 310 expired, going to RRC_IDLE\n");
+    UE_rrc_inst[Mod_id].Info[eNB_index].State = RRC_IDLE;
+    UE_rrc_inst[Mod_id].Info[eNB_index].UE_index = 0xffff;
+
+    UE_rrc_inst[Mod_id].Srb0[eNB_index].Rx_buffer.payload_size = 0;
+    UE_rrc_inst[Mod_id].Srb0[eNB_index].Tx_buffer.payload_size = 0;
+
+    UE_rrc_inst[Mod_id].Srb1[eNB_index].Srb_info.Rx_buffer.payload_size = 0;
+    UE_rrc_inst[Mod_id].Srb1[eNB_index].Srb_info.Tx_buffer.payload_size = 0;
+
+    if (UE_rrc_inst[Mod_id].Srb2[eNB_index].Active == 1) {
+      msg ("[RRC Inst %d] eNB_index %d, Remove RB %d\n ", Mod_id, eNB_index,
+           UE_rrc_inst[Mod_id].Srb2[eNB_index].Srb_info.Srb_id);
+      rrc_pdcp_config_req (Mod_id + NB_eNB_INST, frame, 0, ACTION_REMOVE,
+                           UE_rrc_inst[Mod_id].Srb2[eNB_index].Srb_info.Srb_id);
+      rrc_rlc_config_req (Mod_id + NB_eNB_INST, frame, 0, ACTION_REMOVE,
+                          UE_rrc_inst[Mod_id].Srb2[eNB_index].Srb_info.Srb_id, SIGNALLING_RADIO_BEARER, Rlc_info_um);
+      UE_rrc_inst[Mod_id].Srb2[eNB_index].Active = 0;
+      UE_rrc_inst[Mod_id].Srb2[eNB_index].Status = IDLE;
+      UE_rrc_inst[Mod_id].Srb2[eNB_index].Next_check_frame = 0;
     }
   }
-  else {  // Restablishment procedure
-    LOG_D(RRC,"Timer 310 expired, trying RRCRestablishment ...\n");    
+  else { // Restablishment procedure
+    LOG_D(RRC, "Timer 310 expired, trying RRCRestablishment ...\n");
   }
 }
 
-RRC_status_t rrc_rx_tx(u8 Mod_id,u32 frame, u8 eNB_flag,u8 index){
-      
-  if(eNB_flag == 0) {
+RRC_status_t rrc_rx_tx(u8 Mod_id, u32 frame, u8 eNB_flag, u8 index) {
+
+  if (eNB_flag == 0) {
     // check timers
-    
-    if (UE_rrc_inst[Mod_id].Info[index].T300_active==1) {
+
+    if (UE_rrc_inst[Mod_id].Info[index].T300_active == 1) {
       if ((UE_rrc_inst[Mod_id].Info[index].T300_cnt % 10) == 0)
-	LOG_D(RRC,"[UE %d][RAPROC] Frame %d T300 Count %d ms\n",Mod_id,frame,
-	      UE_rrc_inst[Mod_id].Info[index].T300_cnt);
-      if (UE_rrc_inst[Mod_id].Info[index].T300_cnt == T300[UE_rrc_inst[Mod_id].sib2[index]->ue_TimersAndConstants.t300]) {
-	UE_rrc_inst[Mod_id].Info[index].T300_active = 0;
-	// ALLOW CCCH to be used
-	UE_rrc_inst[Mod_id].Srb0[index].Tx_buffer.payload_size=0;
-	rrc_ue_generate_RRCConnectionRequest(Mod_id,frame,index);
-	return(RRC_ConnSetup_failed);
+        LOG_D(RRC,
+              "[UE %d][RAPROC] Frame %d T300 Count %d ms\n", Mod_id, frame, UE_rrc_inst[Mod_id].Info[index].T300_cnt);
+      if (UE_rrc_inst[Mod_id].Info[index].T300_cnt
+          == T300[UE_rrc_inst[Mod_id].sib2[index]->ue_TimersAndConstants.t300]) {
+        UE_rrc_inst[Mod_id].Info[index].T300_active = 0;
+        // ALLOW CCCH to be used
+        UE_rrc_inst[Mod_id].Srb0[index].Tx_buffer.payload_size = 0;
+        rrc_ue_generate_RRCConnectionRequest (Mod_id, frame, index);
+        return (RRC_ConnSetup_failed);
       }
       UE_rrc_inst[Mod_id].Info[index].T300_cnt++;
     }
     if (UE_rrc_inst[Mod_id].sib2[index]) {
-      if (UE_rrc_inst[Mod_id].Info[index].N310_cnt==N310[UE_rrc_inst[Mod_id].sib2[index]->ue_TimersAndConstants.n310]) {
-	UE_rrc_inst[Mod_id].Info[index].T310_active=1;
+      if (UE_rrc_inst[Mod_id].Info[index].N310_cnt
+          == N310[UE_rrc_inst[Mod_id].sib2[index]->ue_TimersAndConstants.n310]) {
+        UE_rrc_inst[Mod_id].Info[index].T310_active = 1;
       }
     }
     else { // in case we have not received SIB2 yet
-      if (UE_rrc_inst[Mod_id].Info[index].N310_cnt==100) {
-	UE_rrc_inst[Mod_id].Info[index].N310_cnt = 0;
-	return RRC_PHY_RESYNCH;
+      if (UE_rrc_inst[Mod_id].Info[index].N310_cnt == 100) {
+        UE_rrc_inst[Mod_id].Info[index].N310_cnt = 0;
+        return RRC_PHY_RESYNCH;
       }
     }
 
-    if (UE_rrc_inst[Mod_id].Info[index].T310_active==1) {
-      if (UE_rrc_inst[Mod_id].Info[index].N311_cnt ==
-	  N311[UE_rrc_inst[Mod_id].sib2[index]->ue_TimersAndConstants.n311]) {
-	UE_rrc_inst[Mod_id].Info[index].T310_active=0;
-	UE_rrc_inst[Mod_id].Info[index].N311_cnt=0;	
+    if (UE_rrc_inst[Mod_id].Info[index].T310_active == 1) {
+      if (UE_rrc_inst[Mod_id].Info[index].N311_cnt
+          == N311[UE_rrc_inst[Mod_id].sib2[index]->ue_TimersAndConstants.n311]) {
+        UE_rrc_inst[Mod_id].Info[index].T310_active = 0;
+        UE_rrc_inst[Mod_id].Info[index].N311_cnt = 0;
       }
       if ((UE_rrc_inst[Mod_id].Info[index].T310_cnt % 10) == 0)
-	LOG_D(RRC,"[UE %d] Frame %d T310 Count %d ms\n",Mod_id,frame,
-	      UE_rrc_inst[Mod_id].Info[index].T310_cnt);
-      if (UE_rrc_inst[Mod_id].Info[index].T310_cnt == T310[UE_rrc_inst[Mod_id].sib2[index]->ue_TimersAndConstants.t310]) {
-	UE_rrc_inst[Mod_id].Info[index].T310_active = 0;
-	rrc_t310_expiration(frame,Mod_id,index);
-	return(RRC_PHY_RESYNCH);
+        LOG_D(RRC, "[UE %d] Frame %d T310 Count %d ms\n", Mod_id, frame, UE_rrc_inst[Mod_id].Info[index].T310_cnt);
+      if (UE_rrc_inst[Mod_id].Info[index].T310_cnt
+          == T310[UE_rrc_inst[Mod_id].sib2[index]->ue_TimersAndConstants.t310]) {
+        UE_rrc_inst[Mod_id].Info[index].T310_active = 0;
+        rrc_t310_expiration (frame, Mod_id, index);
+        return (RRC_PHY_RESYNCH);
       }
       UE_rrc_inst[Mod_id].Info[index].T310_cnt++;
     }
   }
 
-  return(RRC_OK);
+  return (RRC_OK);
+}
+
+#if defined(ENABLE_ITTI)
+void *rrc_ue_task(void *args_p) {
+  MessageDef *msg_p;
+  char *msg_name;
+  instance_t instance;
+  SRB_INFO *srb_info_p;
+
+  itti_mark_task_ready (TASK_RRC_UE);
+
+  while(1)
+  {
+    // Wait for a message
+    itti_receive_msg (TASK_RRC_UE, &msg_p);
+
+    msg_name = ITTI_MSG_NAME (msg_p);
+    instance = ITTI_MSG_INSTANCE (msg_p);
+
+    switch (msg_p->header.messageId) {
+      case TERMINATE_MESSAGE:
+        itti_exit_task ();
+        break;
+
+      case MESSAGE_TEST:
+        LOG_D(RRC, "Received %s\n", msg_name);
+        break;
+
+      case RRC_MAC_IN_SYNC_IND:
+        LOG_D(RRC, "Received %s: instance %d, frame %d, eNB %d\n", msg_name, instance,
+              RRC_MAC_IN_SYNC_IND (msg_p).frame, RRC_MAC_IN_SYNC_IND (msg_p).enb_index);
+
+        UE_rrc_inst[instance].Info[RRC_MAC_IN_SYNC_IND (msg_p).enb_index].N310_cnt = 0;
+        if (UE_rrc_inst[instance].Info[RRC_MAC_IN_SYNC_IND (msg_p).enb_index].T310_active == 1)
+          UE_rrc_inst[instance].Info[RRC_MAC_IN_SYNC_IND (msg_p).enb_index].N311_cnt++;
+        break;
+
+      case RRC_MAC_OUT_OF_SYNC_IND:
+        LOG_D(RRC, "Received %s: instance %d, frame %d, eNB %d\n", msg_name, instance,
+              RRC_MAC_OUT_OF_SYNC_IND (msg_p).frame, RRC_MAC_OUT_OF_SYNC_IND (msg_p).enb_index);
+
+        UE_rrc_inst[instance].Info[RRC_MAC_OUT_OF_SYNC_IND (msg_p).enb_index].N310_cnt ++;
+        break;
+
+      case RRC_MAC_BCCH_DATA_IND:
+        LOG_D(RRC, "Received %s: instance %d, frame %d, eNB %d\n", msg_name, instance,
+              RRC_MAC_BCCH_DATA_IND (msg_p).frame, RRC_MAC_BCCH_DATA_IND (msg_p).enb_index);
+
+        decode_BCCH_DLSCH_Message (instance, RRC_MAC_BCCH_DATA_IND (msg_p).frame,
+                                   RRC_MAC_BCCH_DATA_IND (msg_p).enb_index, RRC_MAC_BCCH_DATA_IND (msg_p).sdu_p,
+                                   RRC_MAC_BCCH_DATA_IND (msg_p).sdu_size);
+
+        // Message buffer has been processed, free it now.
+        free (RRC_MAC_BCCH_DATA_IND (msg_p).sdu_p);
+        break;
+
+      case RRC_MAC_CCCH_DATA_IND:
+        LOG_D(RRC, "Received %s: instance %d, frame %d, eNB %d\n", msg_name, instance,
+              RRC_MAC_CCCH_DATA_IND (msg_p).frame, RRC_MAC_CCCH_DATA_IND (msg_p).enb_index);
+
+        srb_info_p = &UE_rrc_inst[instance].Srb0[RRC_MAC_CCCH_DATA_IND (msg_p).enb_index];
+
+        memcpy (srb_info_p->Rx_buffer.Payload, RRC_MAC_CCCH_DATA_IND (msg_p).sdu_p,
+                RRC_MAC_CCCH_DATA_IND (msg_p).sdu_size);
+        srb_info_p->Rx_buffer.payload_size = RRC_MAC_CCCH_DATA_IND (msg_p).sdu_size;
+        rrc_ue_decode_ccch (instance, RRC_MAC_CCCH_DATA_IND (msg_p).frame, srb_info_p,
+                            RRC_MAC_CCCH_DATA_IND (msg_p).enb_index);
+
+        // Message buffer has been processed, free it now.
+        free (RRC_MAC_CCCH_DATA_IND (msg_p).sdu_p);
+        break;
+
+#ifdef Rel10
+      case RRC_MAC_MCCH_DATA_IND:
+        LOG_D(RRC, "Received %s: instance %d, frame %d, eNB %d, mbsfn SA %d\n", msg_name, instance,
+              RRC_MAC_MCCH_DATA_IND (msg_p).frame, RRC_MAC_MCCH_DATA_IND (msg_p).eNB_index, RRC_MAC_MCCH_DATA_IND (msg_p).mbsfn_sync_area);
+
+        decode_MCCH_Message (instance, RRC_MAC_MCCH_DATA_IND (msg_p).frame, RRC_MAC_MCCH_DATA_IND (msg_p).eNB_index,
+                             RRC_MAC_MCCH_DATA_IND (msg_p).sdu_p, RRC_MAC_MCCH_DATA_IND (msg_p).sdu_size,
+                             RRC_MAC_MCCH_DATA_IND (msg_p).mbsfn_sync_area);
+
+        // Message buffer has been processed, free it now.
+        free (RRC_MAC_MCCH_DATA_IND (msg_p).sdu_p);
+        break;
+#endif
+
+      case RRC_DCCH_DATA_IND:
+        LOG_D(RRC, "Received %s: instance %d, frame %d, DCCH %d, UE %d\n", msg_name, instance,
+              RRC_DCCH_DATA_IND (msg_p).frame, RRC_DCCH_DATA_IND (msg_p).dcch_index, RRC_DCCH_DATA_IND (msg_p).ue_index);
+
+        rrc_ue_decode_dcch (instance, RRC_DCCH_DATA_IND (msg_p).frame,
+                            RRC_DCCH_DATA_IND (msg_p).dcch_index, RRC_DCCH_DATA_IND (msg_p).sdu_p,
+                            RRC_DCCH_DATA_IND (msg_p).ue_index);
+
+        // Message buffer has been processed, free it now.
+        free (RRC_DCCH_DATA_IND (msg_p).sdu_p);
+        break;
+
+      default:
+        LOG_E(RRC, "Received unexpected message %s\n", msg_name);
+        break;
+    }
+
+    free (msg_p);
+}
 }
+#endif
diff --git a/targets/SIMU/USER/oaisim.c b/targets/SIMU/USER/oaisim.c
index 73cdf67bee66d88ae166e71fd4073e387066c063..286d2a423a36e55a3e77aff988b34257b58630a4 100644
--- a/targets/SIMU/USER/oaisim.c
+++ b/targets/SIMU/USER/oaisim.c
@@ -376,29 +376,13 @@ void *l2l1_task(void *args_p) {
   char fname[64], vname[64];
 
 #if defined(ENABLE_ITTI)
-  MessageDef *message_p;
-  long timer_id;
+    MessageDef *message_p;
 
-  itti_mark_task_ready(TASK_L2L1);
-
-  /* Test code */
-  {
-    message_p = itti_alloc_new_message(TASK_L2L1, MESSAGE_TEST);
-
-    itti_send_msg_to_task(TASK_L2L1, INSTANCE_DEFAULT, message_p);
-
-    /* Request for periodic timer */
-    if (timer_setup(1, 0, TASK_L2L1, INSTANCE_DEFAULT,
-            TIMER_PERIODIC, NULL, &timer_id) < 0)
-    {
-      LOG_E(EMU, "Failed to request new timer with %ds "
-          "of periocidity\n", 1);
-      timer_id = 0;
-    }
-  }
+    itti_mark_task_ready (TASK_L2L1);
 #endif
 
   for (frame = 0; frame < oai_emulation.info.n_frames; frame++) {
+
 #if defined(ENABLE_ITTI)
     // Checks if a message has been sent to L2L1 task
     itti_poll_msg(TASK_L2L1, INSTANCE_ALL, &message_p);
@@ -811,9 +795,6 @@ void *l2l1_task(void *args_p) {
   } //end of frame
 
 #if defined(ENABLE_ITTI)
-  /* Stops test timer */
-  timer_remove(timer_id);
-
   itti_terminate_tasks(TASK_L2L1);
 #endif
 
@@ -1004,7 +985,7 @@ int main(int argc, char **argv) {
   LOG_N(EMU, "\n\n>>>>>>>>>>>>>>>>>>>>>>>>>>> OAIEMU initialization done <<<<<<<<<<<<<<<<<<<<<<<<<<\n\n");
 
 #if defined(ENABLE_ITTI)
-  if (itti_create_task(TASK_L2L1, &l2l1_task, NULL) < 0) {
+  if (itti_create_task(TASK_L2L1, l2l1_task, NULL) < 0) {
     LOG_E(EMU, "Create task failed");
     LOG_D(EMU, "Initializing L2L1 task interface: FAILED\n");
     return -1;
diff --git a/targets/SIMU/USER/oaisim_functions.c b/targets/SIMU/USER/oaisim_functions.c
index 8a8aacce063d1ff2d29caae1994f06459649d34f..cb65a9222455e4040ca2f1ae08ecadd3f6516dbd 100644
--- a/targets/SIMU/USER/oaisim_functions.c
+++ b/targets/SIMU/USER/oaisim_functions.c
@@ -27,6 +27,10 @@
 
 #include "cor_SF_sim.h"
 
+#if defined(ENABLE_ITTI)
+# include "intertask_interface.h"
+#endif
+
 #ifdef SMBV
 extern u8 config_smbv;
 extern char smbv_ip[16];
@@ -110,7 +114,7 @@ void get_simulation_options(int argc, char *argv[]) {
     {NULL, 0, NULL, 0}
   };
 
-  while ((c = getopt_long (argc, argv, "aA:b:B:c:C:D:d:eE:f:FGg:hi:IJ:j:k:L:l:m:M:n:N:oO:p:P:Q:rR:s:S:t:T:u:U:vVx:y:w:W:X:z:Z:", long_options, &option_index)) != -1) {
+  while ((c = getopt_long (argc, argv, "aA:b:B:c:C:D:d:eE:f:FGg:hi:IJ:j:k:L:l:m:M:n:N:oO:p:P:Q:rR:s:S:t:T:u:U:vVw:W:x:X:y:Y:z:Z:", long_options, &option_index)) != -1) {
     switch (c) {
     case 0:
       if (! strcmp(long_options[option_index].name, "pdcp_period")) {
@@ -568,6 +572,15 @@ void init_openair2() {
 #ifdef OPENAIR2
   s32 i;
   s32 UE_id;
+
+#if defined(ENABLE_ITTI)
+  if (itti_create_task(TASK_RRC_UE, rrc_ue_task, NULL) < 0) {
+    LOG_E(EMU, "Create task failed");
+    LOG_D(EMU, "Initializing RRC UE task interface: FAILED\n");
+    exit (-1);;
+  }
+#endif
+
   l2_init (&PHY_vars_eNB_g[0]->lte_frame_parms,oai_emulation.info.eMBMS_active_state, oai_emulation.info.cba_group_active);
   printf ("after L2 init: Nid_cell %d\n", PHY_vars_eNB_g[0]->lte_frame_parms.Nid_cell);
   printf ("after L2 init: frame_type %d,tdd_config %d\n",