diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c
index 95af038ab0265ec9dd6832de6deb6950aacbffa0..01102636fceae9700de483520fe24d821bfd1490 100644
--- a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c
+++ b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c
@@ -44,6 +44,7 @@
 #include "PHY/CODING/extern.h"
 #include "PHY/CODING/lte_interleaver_inline.h"
 #include "PHY/LTE_TRANSPORT/defs.h"
+#include "PHY/LTE_TRANSPORT/proto.h"
 #include "defs.h"
 #include "UTIL/LOG/vcd_signal_dumper.h"
 
@@ -91,11 +92,11 @@ void free_eNB_dlsch(LTE_eNB_DLSCH_t *dlsch)
 #endif
 
         for (r=0; r<MAX_NUM_DLSCH_SEGMENTS; r++) {
-
+	  
 #ifdef DEBUG_DLSCH_FREE
           msg("Freeing dlsch process %d c[%d] (%p)\n",i,r,dlsch->harq_processes[i]->c[r]);
 #endif
-
+	  
           if (dlsch->harq_processes[i]->c[r]) {
             free16(dlsch->harq_processes[i]->c[r],((r==0)?8:0) + 3+768);
             dlsch->harq_processes[i]->c[r] = NULL;
@@ -104,17 +105,17 @@ void free_eNB_dlsch(LTE_eNB_DLSCH_t *dlsch)
             free16(dlsch->harq_processes[i]->d[r],(96+12+3+(3*6144)));
             dlsch->harq_processes[i]->d[r] = NULL;
           }
-        }
-
-        free16(dlsch->harq_processes[i],sizeof(LTE_DL_eNB_HARQ_t));
-        dlsch->harq_processes[i] = NULL;
+        
+	}
+	free16(dlsch->harq_processes[i],sizeof(LTE_DL_eNB_HARQ_t));
+	dlsch->harq_processes[i] = NULL;
       }
     }
-
+    
     free16(dlsch,sizeof(LTE_eNB_DLSCH_t));
     dlsch = NULL;
-  }
-
+    }
+  
 }
 
 LTE_eNB_DLSCH_t *new_eNB_dlsch(unsigned char Kmimo,unsigned char Mdlharq,uint32_t Nsoft,unsigned char N_RB_DL, uint8_t abstraction_flag)
@@ -204,28 +205,28 @@ LTE_eNB_DLSCH_t *new_eNB_dlsch(unsigned char Kmimo,unsigned char Mdlharq,uint32_
       for (i=0; i<Mdlharq; i++) {
         dlsch->harq_processes[i]->round=0;
 
-        if (abstraction_flag==0) {
-          for (j=0; j<96; j++)
-            for (r=0; r<MAX_NUM_DLSCH_SEGMENTS/bw_scaling; r++) {
-        //      printf("dlsch->harq_processes[%d]->d[%d] %p\n",i,r,dlsch->harq_processes[i]->d[r]);
-              dlsch->harq_processes[i]->d[r][j] = LTE_NULL;
-            }
-        }
+	for (j=0; j<96; j++)
+	  for (r=0; r<MAX_NUM_DLSCH_SEGMENTS/bw_scaling; r++) {
+	    //      printf("dlsch->harq_processes[%d]->d[%d] %p\n",i,r,dlsch->harq_processes[i]->d[r]);
+	    if (dlsch->harq_processes[i]->d[r])
+	      dlsch->harq_processes[i]->d[r][j] = LTE_NULL;
+	  }
+        
       }
 
       return(dlsch);
     }
   }
 
-  LOG_D(PHY, "new_eNB_dlsch exit flag %d, size of  %ld\n",
-        exit_flag, sizeof(LTE_eNB_DLSCH_t));
+  LOG_D(PHY,"new_eNB_dlsch exit flag %d, size of  %ld\n",
+	exit_flag, sizeof(LTE_eNB_DLSCH_t));
   free_eNB_dlsch(dlsch);
   return(NULL);
 
 
 }
 
-void clean_eNb_dlsch(LTE_eNB_DLSCH_t *dlsch, uint8_t abstraction_flag)
+void clean_eNb_dlsch(LTE_eNB_DLSCH_t *dlsch)
 {
 
   unsigned char Mdlharq;
@@ -245,12 +246,11 @@ void clean_eNb_dlsch(LTE_eNB_DLSCH_t *dlsch, uint8_t abstraction_flag)
         dlsch->harq_processes[i]->status = 0;
         dlsch->harq_processes[i]->round  = 0;
 
-        if (abstraction_flag==0) {
-          for (j=0; j<96; j++)
-            for (r=0; r<MAX_NUM_DLSCH_SEGMENTS; r++)
-	      if (dlsch->harq_processes[i]->d[r])
-		dlsch->harq_processes[i]->d[r][j] = LTE_NULL;
-        }
+	for (j=0; j<96; j++)
+	  for (r=0; r<MAX_NUM_DLSCH_SEGMENTS; r++)
+	    if (dlsch->harq_processes[i]->d[r])
+	      dlsch->harq_processes[i]->d[r][j] = LTE_NULL;
+        
       }
     }
   }
diff --git a/openair1/PHY/LTE_TRANSPORT/proto.h b/openair1/PHY/LTE_TRANSPORT/proto.h
index 9afea790b327c6efd15a53949a979f74243c8f7d..15a8f53f54235b7e595d43058687a910e51c314e 100644
--- a/openair1/PHY/LTE_TRANSPORT/proto.h
+++ b/openair1/PHY/LTE_TRANSPORT/proto.h
@@ -54,7 +54,7 @@
 */
 void free_eNB_dlsch(LTE_eNB_DLSCH_t *dlsch);
 
-void clean_eNb_dlsch(LTE_eNB_DLSCH_t *dlsch, uint8_t abstraction_flag);
+void clean_eNb_dlsch(LTE_eNB_DLSCH_t *dlsch);
 
 /** \fn new_eNB_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint8_t abstraction_flag)
     \brief This function allocates structures for a particular DLSCH at eNB
@@ -85,7 +85,7 @@ void free_ue_dlsch(LTE_UE_DLSCH_t *dlsch);
 LTE_UE_DLSCH_t *new_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint8_t max_turbo_iterations,uint8_t N_RB_DL, uint8_t abstraction_flag);
 
 
-void clean_eNb_ulsch(LTE_eNB_ULSCH_t *ulsch, uint8_t abstraction_flag);
+void clean_eNb_ulsch(LTE_eNB_ULSCH_t *ulsch);
 
 void free_ue_ulsch(LTE_UE_ULSCH_t *ulsch);
 
diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c
index 25dae3ed63646da5a632e3eed86b6b56f7916284..ca4e8be9339f51088fc9b6a5e73f8107c4a6a382 100644
--- a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c
+++ b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c
@@ -179,7 +179,7 @@ LTE_eNB_ULSCH_t *new_eNB_ulsch(uint8_t Mdlharq,uint8_t max_turbo_iterations,uint
   return(NULL);
 }
 
-void clean_eNb_ulsch(LTE_eNB_ULSCH_t *ulsch, uint8_t abstraction_flag)
+void clean_eNb_ulsch(LTE_eNB_ULSCH_t *ulsch)
 {
 
   unsigned char Mdlharq;
diff --git a/openair1/PHY/impl_defs_top.h b/openair1/PHY/impl_defs_top.h
index e55e28e3be14c4a68fe50900112537ce487a9c9e..4b0edcff29720e0a530a4e9c3eab7c1cd54adc97 100755
--- a/openair1/PHY/impl_defs_top.h
+++ b/openair1/PHY/impl_defs_top.h
@@ -256,7 +256,7 @@
 #define AMP_OVER_2 (AMP>>1)
 
 /// Threshold for PUCCH Format 1 detection
-#define PUCCH1_THRES 10
+#define PUCCH1_THRES 7
 /// Threshold for PUCCH Format 1a/1b detection
 #define PUCCH1a_THRES 4
 
diff --git a/openair1/SCHED/defs.h b/openair1/SCHED/defs.h
index 8692a31f1249a49f390d26a3bd1ba13adf12f0e1..af6acca88002f29def1e24dd2e45db68140ee062 100644
--- a/openair1/SCHED/defs.h
+++ b/openair1/SCHED/defs.h
@@ -405,7 +405,7 @@ void remove_harq_pid_from_freelist(LTE_eNB_DLSCH_t *DLSCH_ptr, int harq_pid);
 
 int8_t find_ue(uint16_t rnti, PHY_VARS_eNB *phy_vars_eNB);
 int32_t add_ue(int16_t rnti, PHY_VARS_eNB *phy_vars_eNB);
-int32_t remove_ue(uint16_t rnti, PHY_VARS_eNB *phy_vars_eNB,uint8_t abstraction_flag);
+int mac_phy_remove_ue(module_id_t Mod_idP,rnti_t rnti);
 
 void process_timing_advance(module_id_t Mod_id,uint8_t CC_id,int16_t timing_advance);
 void process_timing_advance_rar(PHY_VARS_UE *phy_vars_ue,uint16_t timing_advance);
diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c
index a7796a9b6925b68b3710ea2c50c9e7ce633050c6..3552344fb72954f3e381019b8040e435beee668a 100755
--- a/openair1/SCHED/phy_procedures_lte_eNb.c
+++ b/openair1/SCHED/phy_procedures_lte_eNb.c
@@ -198,10 +198,10 @@ int32_t add_ue(int16_t rnti, PHY_VARS_eNB *phy_vars_eNB)
   return(-1);
 }
 
-int32_t remove_ue(uint16_t rnti, PHY_VARS_eNB *phy_vars_eNB, uint8_t abstraction_flag)
-{
+int mac_phy_remove_ue(module_id_t Mod_idP,rnti_t rntiP) {
   uint8_t i;
   int j;
+  PHY_VARS_eNB *phy_vars_eNB = PHY_vars_eNB_g[Mod_idP];
 
   for (i=0; i<NUMBER_OF_UE_MAX; i++) {
     if ((phy_vars_eNB->dlsch_eNB[i]==NULL) || (phy_vars_eNB->ulsch_eNB[i]==NULL)) {
@@ -209,14 +209,14 @@ int32_t remove_ue(uint16_t rnti, PHY_VARS_eNB *phy_vars_eNB, uint8_t abstraction
       LOG_E(PHY,"Can't remove UE, not enough memory allocated\n");
       return(-1);
     } else {
-      if (phy_vars_eNB->eNB_UE_stats[i].crnti==rnti) {
-        MSC_LOG_EVENT(MSC_PHY_ENB, "0 Removed ue %"PRIx16" ", rnti);
+      if (phy_vars_eNB->eNB_UE_stats[i].crnti==rntiP) {
+        MSC_LOG_EVENT(MSC_PHY_ENB, "0 Removed ue %"PRIx16" ", rntiP);
 #ifdef DEBUG_PHY_PROC
 	LOG_I(PHY,"eNB %d removing UE %d with rnti %x\n",phy_vars_eNB->Mod_id,i,rnti);
 #endif
         //msg("[PHY] UE_id %d\n",i);
-        clean_eNb_dlsch(phy_vars_eNB->dlsch_eNB[i][0], abstraction_flag);
-        clean_eNb_ulsch(phy_vars_eNB->ulsch_eNB[i],abstraction_flag);
+        clean_eNb_dlsch(phy_vars_eNB->dlsch_eNB[i][0]);
+        clean_eNb_ulsch(phy_vars_eNB->ulsch_eNB[i]);
         //phy_vars_eNB->eNB_UE_stats[i].crnti = 0;
         memset(&phy_vars_eNB->eNB_UE_stats[i],0,sizeof(LTE_eNB_UE_stats));
         //  mac_exit_wrapper("Removing UE");
@@ -232,7 +232,7 @@ int32_t remove_ue(uint16_t rnti, PHY_VARS_eNB *phy_vars_eNB, uint8_t abstraction
     }
   }
 
-  MSC_LOG_EVENT(MSC_PHY_ENB, "0 Failed remove ue %"PRIx16" (not found)", rnti);
+  MSC_LOG_EVENT(MSC_PHY_ENB, "0 Failed remove ue %"PRIx16" (not found)", rntiP);
   return(-1);
 }
 
@@ -3523,7 +3523,7 @@ void phy_procedures_eNB_RX(const unsigned char sched_subframe,PHY_VARS_eNB *phy_
                                       frame,
                                       phy_vars_eNB->eNB_UE_stats[i].crnti);
 #endif
-            remove_ue(phy_vars_eNB->eNB_UE_stats[i].crnti,phy_vars_eNB,abstraction_flag);
+            mac_phy_remove_ue(phy_vars_eNB->eNB_UE_stats[i].crnti,phy_vars_eNB);
             phy_vars_eNB->ulsch_eNB[(uint32_t)i]->Msg3_active = 0;
             //phy_vars_eNB->ulsch_eNB[i]->harq_processes[harq_pid]->phich_active = 0;
 
@@ -3670,7 +3670,7 @@ void phy_procedures_eNB_RX(const unsigned char sched_subframe,PHY_VARS_eNB *phy_
                                       phy_vars_eNB->CC_id,
                                       frame,
                                       phy_vars_eNB->eNB_UE_stats[i].crnti);
-            remove_ue(phy_vars_eNB->eNB_UE_stats[i].crnti,phy_vars_eNB,abstraction_flag);
+            mac_phy_remove_ue(phy_vars_eNB->eNB_UE_stats[i].crnti,phy_vars_eNB);
             phy_vars_eNB->ulsch_eNB[(uint32_t)i]->Msg3_active = 0;
           }
 
diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c
index d1d08390d7b20b204cf7a1c7da663e01df85bec8..dbc094034b73d9da1c8e05928783bb4fdc08bd49 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler.c
@@ -127,9 +127,9 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag,
 
     // increment this, it is cleared when we receive an sdu
     eNB_mac_inst[module_idP].UE_list.UE_sched_ctrl[i].ul_inactivity_timer++;
-
+    
     if (mac_xface->get_eNB_UE_stats(module_idP, CC_id, rnti)==NULL) {
-      mac_remove_ue(module_idP, i, frameP, subframeP);
+      //      mac_remove_ue(module_idP, i, frameP, subframeP);
     }
     else {
       // check uplink failure
@@ -210,7 +210,7 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag,
 			  0);
 	}
 	else { // ra_pdcch_sent==1
-	  LOG_I(MAC,"UE %d rnti %x: sent PDCCH order for RAPROC waiting (failure timer %d) \n",i,rnti,UE_list->UE_sched_ctrl[i].ul_failure_timer);	    	    
+	  LOG_D(MAC,"UE %d rnti %x: sent PDCCH order for RAPROC waiting (failure timer %d) \n",i,rnti,UE_list->UE_sched_ctrl[i].ul_failure_timer);	    	    
 	  if ((UE_list->UE_sched_ctrl[i].ul_failure_timer % 40) == 0)
 	    UE_list->UE_sched_ctrl[i].ra_pdcch_order_sent=0; // resend every 4 frames	      
 	}
diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c
index e23f007a07a9648230037f5f0cebeabbed70a61f..4ba290bf5958e3db6873a3ab1ba287e959e456c7 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c
@@ -287,44 +287,38 @@ int add_new_ue(module_id_t mod_idP, int cc_idP, rnti_t rntiP,int harq_pidP)
 }
 
 //------------------------------------------------------------------------------
-int mac_remove_ue(module_id_t mod_idP, int ue_idP, int frameP, sub_frame_t subframeP)
+int rrc_mac_remove_ue(module_id_t mod_idP,rnti_t rntiP) 
 //------------------------------------------------------------------------------
 {
 
   int prev,i, ret=-1;
 
-  rnti_t  rnti;
+
   UE_list_t *UE_list = &eNB_mac_inst[mod_idP].UE_list;
-  int pCC_id = UE_PCCID(mod_idP,ue_idP);
+  int UE_id = find_UE_id(mod_idP,rntiP);
+  int pCC_id = UE_PCCID(mod_idP,UE_id);
 
-  rnti = UE_list->UE_template[pCC_id][ue_idP].rnti;
-  LOG_I(MAC,"Removing UE %d from Primary CC_id %d (rnti %x)\n",ue_idP,pCC_id, rnti);
+  LOG_I(MAC,"Removing UE %d from Primary CC_id %d (rnti %x)\n",UE_id,pCC_id, rntiP);
   dump_ue_list(UE_list,0);
 
   // clear all remaining pending transmissions
-  UE_list->UE_template[pCC_id][ue_idP].bsr_info[LCGID0]  = 0;
-  UE_list->UE_template[pCC_id][ue_idP].bsr_info[LCGID1]  = 0;
-  UE_list->UE_template[pCC_id][ue_idP].bsr_info[LCGID2]  = 0;
-  UE_list->UE_template[pCC_id][ue_idP].bsr_info[LCGID3]  = 0;
-
-  UE_list->UE_template[pCC_id][ue_idP].ul_SR             = 0;
-  UE_list->UE_template[pCC_id][ue_idP].rnti              = NOT_A_RNTI;
-  UE_list->UE_template[pCC_id][ue_idP].ul_active         = FALSE;
-  eNB_ulsch_info[mod_idP][pCC_id][ue_idP].rnti                        = NOT_A_RNTI;
-  eNB_ulsch_info[mod_idP][pCC_id][ue_idP].status                      = S_UL_NONE;
-  eNB_dlsch_info[mod_idP][pCC_id][ue_idP].rnti                        = NOT_A_RNTI;
-  eNB_dlsch_info[mod_idP][pCC_id][ue_idP].status                      = S_DL_NONE;
-
-  rrc_eNB_free_UE(
-    mod_idP,
-    rnti,
-    frameP,
-    subframeP);
+  UE_list->UE_template[pCC_id][UE_id].bsr_info[LCGID0]  = 0;
+  UE_list->UE_template[pCC_id][UE_id].bsr_info[LCGID1]  = 0;
+  UE_list->UE_template[pCC_id][UE_id].bsr_info[LCGID2]  = 0;
+  UE_list->UE_template[pCC_id][UE_id].bsr_info[LCGID3]  = 0;
+
+  UE_list->UE_template[pCC_id][UE_id].ul_SR             = 0;
+  UE_list->UE_template[pCC_id][UE_id].rnti              = NOT_A_RNTI;
+  UE_list->UE_template[pCC_id][UE_id].ul_active         = FALSE;
+  eNB_ulsch_info[mod_idP][pCC_id][UE_id].rnti                        = NOT_A_RNTI;
+  eNB_ulsch_info[mod_idP][pCC_id][UE_id].status                      = S_UL_NONE;
+  eNB_dlsch_info[mod_idP][pCC_id][UE_id].rnti                        = NOT_A_RNTI;
+  eNB_dlsch_info[mod_idP][pCC_id][UE_id].status                      = S_DL_NONE;
 
   prev = UE_list->head;
 
   for (i=UE_list->head; i>=0; i=UE_list->next[i]) {
-    if (i == ue_idP) {
+    if (i == UE_id) {
       // link prev to next in Active list
       //if (prev==UE_list->head)
       if (i==UE_list->head) {
@@ -349,7 +343,7 @@ int mac_remove_ue(module_id_t mod_idP, int ue_idP, int frameP, sub_frame_t subfr
   prev = UE_list->head_ul;
 
   for (i=UE_list->head_ul; i>=0; i=UE_list->next_ul[i]) {
-    if (i == ue_idP) {
+    if (i == UE_id) {
       // link prev to next in Active list
       if (prev==UE_list->head_ul) {
         UE_list->head_ul = UE_list->next_ul[i];
@@ -370,7 +364,7 @@ int mac_remove_ue(module_id_t mod_idP, int ue_idP, int frameP, sub_frame_t subfr
     return (0);
   }
 
-  LOG_E(MAC,"error in mac_remove_ue(), could not find previous to %d in UE_list, should never happen, Dumping UE list\n",ue_idP);
+  LOG_E(MAC,"error in mac_remove_ue(), could not find previous to %d in UE_list, should never happen, Dumping UE list\n",UE_id);
   dump_ue_list(UE_list,0);
   mac_xface->macphy_exit("mac_remove_ue: Problem in UE_list");
   return(-1);
diff --git a/openair2/LAYER2/MAC/main.c b/openair2/LAYER2/MAC/main.c
index 32cb3b17384110d771f81495328e06fbe62c2d2f..d5a445744d780ae0aa1e1bf7d7fed4a5a7e53a25 100644
--- a/openair2/LAYER2/MAC/main.c
+++ b/openair2/LAYER2/MAC/main.c
@@ -476,6 +476,7 @@ int l2_init(LTE_DL_FRAME_PARMS *frame_parms,int eMBMS_active, char *uecap_xer,ui
   mac_xface->Msg1_transmitted          = Msg1_tx;
   mac_xface->ra_failed                 = ra_failed;
   mac_xface->ra_succeeded              = ra_succeeded;
+  mac_xface->mac_phy_remove_ue         = mac_phy_remove_ue;
 
   LOG_I(MAC,"[MAIN] init UE MAC functions \n");
   mac_xface->ue_decode_si              = ue_decode_si;
diff --git a/openair2/LAYER2/MAC/proto.h b/openair2/LAYER2/MAC/proto.h
index 632d8c836025abb1fd907d034a2cbca297918b1e..0e1d69d065f63c77f2dcf93d9b34c09cfd17f4ff 100644
--- a/openair2/LAYER2/MAC/proto.h
+++ b/openair2/LAYER2/MAC/proto.h
@@ -499,7 +499,7 @@ uint8_t *parse_ulsch_header(uint8_t *mac_header,
 int l2_init(LTE_DL_FRAME_PARMS *frame_parms,int eMBMS_active, char *uecap_xer, uint8_t cba_group_active, uint8_t HO_active);
 int mac_init(void);
 int add_new_ue(module_id_t Mod_id, int CC_id, rnti_t rnti,int harq_pid);
-int mac_remove_ue(module_id_t Mod_id, int UE_id,int frameP, sub_frame_t subframeP);
+int rrc_mac_remove_ue(module_id_t Mod_id, rnti_t rntiP);
 
 
 int maxround(module_id_t Mod_id,uint16_t rnti,int frame,sub_frame_t subframe,uint8_t ul_flag);
diff --git a/openair2/PHY_INTERFACE/defs.h b/openair2/PHY_INTERFACE/defs.h
index 194b0851186e4cdc484d338158376dd700c8870e..df8cfbdc26a3b81d8032e1e668e5132f0e452eb0 100755
--- a/openair2/PHY_INTERFACE/defs.h
+++ b/openair2/PHY_INTERFACE/defs.h
@@ -134,7 +134,7 @@ typedef struct {
   /// get delta mcs for fast UL AMC
   int16_t (*estimate_ue_tx_power)(uint32_t tbs, uint32_t nb_rb, uint8_t control_only, lte_prefix_type_t ncp, uint8_t use_srs);
 
-
+  int (*mac_phy_remove_ue)(module_id_t Mod_idP,rnti_t rntiP);
   /// UE functions
 
   /// reset the ue phy
diff --git a/openair2/RRC/LITE/L2_interface.c b/openair2/RRC/LITE/L2_interface.c
index 7a4a69e2d21471d63fa2d890fd8c5acd68168dff..8c16eb854245b025130b29d37b9588cbc148d00a 100644
--- a/openair2/RRC/LITE/L2_interface.c
+++ b/openair2/RRC/LITE/L2_interface.c
@@ -716,19 +716,47 @@ mac_eNB_get_rrc_status(
 }
 
 void mac_eNB_rrc_ul_failure(const module_id_t Mod_instP, 
-			    const int CC_id, 
+			    const int CC_idP, 
 			    const frame_t frameP,
 			    const sub_frame_t subframeP,
-			    const rnti_t rnti) {
+			    const rnti_t rntiP) {
 
+  struct rrc_eNB_ue_context_s* ue_context_p = NULL;
+  ue_context_p = rrc_eNB_get_ue_context(
+                   &eNB_rrc_inst[Mod_instP],
+                   rntiP);
+
+  if (ue_context_p != NULL) {
+    LOG_I(RRC,"Frame %d, Subframe %d: UE %x UL failure, activating timer\n",rntiP);
+    ue_context_p->ue_context.ul_failure_timer=1;
+  }
+  else {
+    LOG_E(RRC,"Frame %d, Subframe %d: UE %x unknown \n",rntiP);
+  }
+  
   return;
 }
 
 void mac_eNB_rrc_ul_in_sync(const module_id_t Mod_instP, 
-			    const int CC_id, 
+			    const int CC_idP, 
 			    const frame_t frameP,
 			    const sub_frame_t subframeP,
-			    const rnti_t rnti) {
+			    const rnti_t rntiP) {
+
+  struct rrc_eNB_ue_context_s* ue_context_p = NULL;
+  ue_context_p = rrc_eNB_get_ue_context(
+                   &eNB_rrc_inst[Mod_instP],
+                   rntiP);
+
+
+
+  if (ue_context_p != NULL) {
+    LOG_I(RRC,"Frame %d, Subframe %d: UE %x to UL in synch\n",rntiP);
+    ue_context_p->ue_context.ul_failure_timer=0;
+  }
+  else {
+    LOG_E(RRC,"Frame %d, Subframe %d: UE %x unknown \n",rntiP);
+  }
 
   return;
 }
diff --git a/openair2/RRC/LITE/defs.h b/openair2/RRC/LITE/defs.h
index 78240de082602525457b5e49ca5118dadefbc47f..49dc4d06adda7ae2f82374466636834072882129 100644
--- a/openair2/RRC/LITE/defs.h
+++ b/openair2/RRC/LITE/defs.h
@@ -357,6 +357,7 @@ typedef struct eNB_RRC_UE_s {
   transport_layer_addr_t             enb_gtp_addrs[S1AP_MAX_E_RAB];
   rb_id_t                            enb_gtp_ebi[S1AP_MAX_E_RAB];
 #endif
+  uint32_t                           ul_failure_timer;
 } eNB_RRC_UE_t;
 
 typedef uid_t ue_uid_t;
diff --git a/openair2/RRC/LITE/rrc_common.c b/openair2/RRC/LITE/rrc_common.c
index a27199bdab4a39150e3fffab044821b93f490f80..75a50428f51d6ccc879efea1a3270e639517b946 100644
--- a/openair2/RRC/LITE/rrc_common.c
+++ b/openair2/RRC/LITE/rrc_common.c
@@ -414,9 +414,10 @@ rrc_rx_tx(
   uint8_t        UE_id;
   int32_t        current_timestamp_ms, ref_timestamp_ms;
   struct timeval ts;
+  struct rrc_eNB_ue_context_s*   ue_context_p = NULL;
+
 #ifdef LOCALIZATION
   double                         estimated_distance;
-  struct rrc_eNB_ue_context_s*   ue_context_p = NULL;
   protocol_ctxt_t                ctxt;
 #endif
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_RX_TX,VCD_FUNCTION_IN);
@@ -517,6 +518,20 @@ rrc_rx_tx(
   } else { // eNB
     check_handovers(ctxt_pP);
     // counetr, and get the value and aggregate
+
+    // check for UL failure
+    RB_FOREACH(ue_context_p, rrc_ue_tree_s, &(eNB_rrc_inst[ctxt_pP->module_id].rrc_ue_head)) {
+      if (ue_context_p->ue_context.ul_failure_timer>0) {
+	ue_context_p->ue_context.ul_failure_timer++;
+	if (ue_context_p->ue_context.ul_failure_timer == 1000) {
+	  // remove UE after 1 second after MAC has indicated UL failure
+	  LOG_I(RRC,"Removing UE %x instance\n",ue_context_p->ue_context.rnti);
+	  
+	}
+      }
+
+
+    }
 #ifdef LOCALIZATION
 
     /* for the localization, only primary CC_id might be relevant*/
diff --git a/openair2/RRC/LITE/rrc_eNB.c b/openair2/RRC/LITE/rrc_eNB.c
index befdc32c638be151b1ef61c2c0e4a704db75a815..836217e8d952f2c4584c4823022eecc7ac18d1cd 100644
--- a/openair2/RRC/LITE/rrc_eNB.c
+++ b/openair2/RRC/LITE/rrc_eNB.c
@@ -790,7 +790,6 @@ rrc_eNB_free_mem_UE_context(
 }
 
 //-----------------------------------------------------------------------------
-// called by MAC layer only
 // should be called when UE is lost by eNB
 void
 rrc_eNB_free_UE(
@@ -836,6 +835,7 @@ rrc_eNB_free_UE(
 #endif
     ue_context_p->ue_context.Status = RRC_IDLE;
 
+    rrc_mac_remove_ue(enb_mod_idP,rntiP);
     rrc_rlc_remove_ue(&ctxt);
     pdcp_remove_UE(&ctxt);