diff --git a/cmake_targets/autotests/v2/actions/3276.txt b/cmake_targets/autotests/v2/actions/3276.txt
new file mode 100644
index 0000000000000000000000000000000000000000..1976ceb3f3571ff1cfb69eee5ffa3eb62d6bb80c
--- /dev/null
+++ b/cmake_targets/autotests/v2/actions/3276.txt
@@ -0,0 +1,13 @@
+When running lsusb, if you have:
+
+    Bus 001 Device 002: ID 12d1:14fe Huawei Technologies Co., Ltd. Modem (Mass Storage Mode)
+
+You need to run:
+
+    usb_modeswitch -v 12d1 -p 14fe -M '55534243123456780000000000000011062000000100000000000000000000'
+
+After what, running lsusb should give:
+
+    Bus 001 Device 004: ID 12d1:1506 Huawei Technologies Co., Ltd. Modem/Networkcard
+
+Values of 'Bus' and 'Device' may differ of course.
diff --git a/cmake_targets/autotests/v2/actions/bandrich.txt b/cmake_targets/autotests/v2/actions/bandrich.txt
index 8533750c5b1e2633ce8b0d41e7c22257ae596218..faa294465b8b3339b7ac67a6655c73a8543607f0 100644
--- a/cmake_targets/autotests/v2/actions/bandrich.txt
+++ b/cmake_targets/autotests/v2/actions/bandrich.txt
@@ -13,6 +13,16 @@ containing lines:
     SUBSYSTEM=="tty", ENV{ID_VENDOR_ID}=="1a8d", ENV{ID_MODEL_ID}=="100d", ENV{ID_SERIAL_SHORT}=="357473040068155", ENV{ID_USB_INTERFACE_NUM}=="00", SYMLINK+="bandrich.data", MODE="0666"
     SUBSYSTEM=="tty", ENV{ID_VENDOR_ID}=="1a8d", ENV{ID_MODEL_ID}=="100d", ENV{ID_SERIAL_SHORT}=="357473040068155", ENV{ID_USB_INTERFACE_NUM}=="02", SYMLINK+="bandrich.control", MODE="0666"
 
+To avoid NetworkManager to play with the bandrich, add also the line:
+
+    ENV{ID_VENDOR_ID}=="1a8d", ENV{ID_MM_DEVICE_IGNORE}="1"
+
+Maybe also add; , ENV{ID_MM_DEVICE_IGNORE}="1"
+to the two other lines.
+
+Then run: udevadm control --reload-rules
+And:      service network-manager restart
+
 Change vendor_id/model_id/serial/interface num to match yours.
 Use lsusb -v to find values.
 
diff --git a/common/utils/T/tracer/enb.c b/common/utils/T/tracer/enb.c
index 80093eb8486da51d5d1e9bddd628f090fa76beb0..f607743d1592f1473ad172ad9684a7ba17730104 100644
--- a/common/utils/T/tracer/enb.c
+++ b/common/utils/T/tracer/enb.c
@@ -31,7 +31,10 @@ void reset_ue_ids(void)
   int i;
   printf("resetting known UEs\n");
   for (i = 0; i < 65536; i++) ue_id[i] = -1;
-  next_ue_id = 0;
+  ue_id[65535] = 0;
+  ue_id[65534] = 1;     /* HACK: to be removed */
+  ue_id[2]     = 2;     /* this supposes RA RNTI = 2, very openair specific */
+  next_ue_id = 3;
 }
 
 int ue_id_from_rnti(void *_priv, int rnti)
@@ -94,6 +97,7 @@ typedef struct {
   enb_gui *e;
   int ue;                /* what UE is displayed in the UE specific views */
   void *database;
+  int nb_rb;
 } enb_data;
 
 void is_on_changed(void *_d)
@@ -121,27 +125,6 @@ connection_dies:
   if (pthread_mutex_unlock(&d->lock)) abort();
 }
 
-void usage(void)
-{
-  printf(
-"options:\n"
-"    -d <database file>        this option is mandatory\n"
-"    -on <GROUP or ID>         turn log ON for given GROUP or ID\n"
-"    -off <GROUP or ID>        turn log OFF for given GROUP or ID\n"
-"    -ON                       turn all logs ON\n"
-"    -OFF                      turn all logs OFF\n"
-"                              note: you may pass several -on/-off/-ON/-OFF,\n"
-"                                    they will be processed in order\n"
-"                                    by default, all is off\n"
-"    -ip <host>                connect to given IP address (default %s)\n"
-"    -p <port>                 connect to given port (default %d)\n"
-"    -debug-gui                activate GUI debug logs\n",
-  DEFAULT_REMOTE_IP,
-  DEFAULT_REMOTE_PORT
-  );
-  exit(1);
-}
-
 static void *gui_thread(void *_g)
 {
   gui *g = _g;
@@ -248,13 +231,15 @@ static void click(void *private, gui *g,
   enb_data *ed = private;
   enb_gui *e = ed->e;
   int ue = ed->ue;
+  int do_reset = 0;
 
   if (button != 1) return;
   if (w == e->prev_ue_button) { ue--; if (ue < 0) ue = 0; }
   if (w == e->next_ue_button) ue++;
-  if (w == e->current_ue_button) reset_ue_ids();
+  if (w == e->current_ue_button) do_reset = 1;
 
   if (pthread_mutex_lock(&ed->lock)) abort();
+  if (do_reset) reset_ue_ids();
   if (ue != ed->ue) {
     set_current_ue(g, ed, ue);
     ed->ue = ue;
@@ -314,14 +299,14 @@ static void enb_main_gui(enb_gui *e, gui *g, event_handler *h, void *database,
 
   input_signal_plot = new_xy_plot(g, 256, 55, "input signal", 20);
   widget_add_child(g, line, input_signal_plot, -1);
-  xy_plot_set_range(g, input_signal_plot, 0, 7680*10, 20, 70);
+  xy_plot_set_range(g, input_signal_plot, 0, 7680*10 * ed->nb_rb/25, 20, 70);
   input_signal_log = new_framelog(h, database,
       "ENB_PHY_INPUT_SIGNAL", "subframe", "rxdata");
   /* a skip value of 10 means to process 1 frame over 10, that is
    * more or less 10 frames per second
    */
   framelog_set_skip(input_signal_log, 10);
-  input_signal_view = new_view_xy(7680*10, 10,
+  input_signal_view = new_view_xy(7680*10 * ed->nb_rb/25, 10,
       g, input_signal_plot, new_color(g, "#0c0c72"), XY_LOOP_MODE);
   logger_add_view(input_signal_log, input_signal_view);
 
@@ -639,7 +624,7 @@ static void enb_main_gui(enb_gui *e, gui *g, event_handler *h, void *database,
   container_set_child_growable(g, top_container, text, 1);
   e->legacy = new_view_textlist(10000, 10, g, text);
 
-  set_current_ue(g, ed, 0);
+  set_current_ue(g, ed, ed->ue);
   register_notifier(g, "click", e->current_ue_button, click, ed);
   register_notifier(g, "click", e->prev_ue_button, click, ed);
   register_notifier(g, "click", e->next_ue_button, click, ed);
@@ -661,6 +646,28 @@ void view_add_log(view *v, char *log, event_handler *h, void *database,
   on_off(database, log, is_on, 1);
 }
 
+void usage(void)
+{
+  printf(
+"options:\n"
+"    -d   <database file>      this option is mandatory\n"
+"    -rb  <RBs>                setup for this number of RBs (default 25)\n"
+"    -on  <GROUP or ID>        turn log ON for given GROUP or ID\n"
+"    -off <GROUP or ID>        turn log OFF for given GROUP or ID\n"
+"    -ON                       turn all logs ON\n"
+"    -OFF                      turn all logs OFF\n"
+"                              note: you may pass several -on/-off/-ON/-OFF,\n"
+"                                    they will be processed in order\n"
+"                                    by default, all is off\n"
+"    -ip <host>                connect to given IP address (default %s)\n"
+"    -p  <port>                connect to given port (default %d)\n"
+"    -debug-gui                activate GUI debug logs\n",
+  DEFAULT_REMOTE_IP,
+  DEFAULT_REMOTE_PORT
+  );
+  exit(1);
+}
+
 int main(int n, char **v)
 {
   extern int volatile gui_logd;
@@ -681,6 +688,8 @@ int main(int n, char **v)
 
   reset_ue_ids();
 
+  enb_data.nb_rb = 25;
+
   /* write on a socket fails if the other end is closed and we get SIGPIPE */
   if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) abort();
 
@@ -691,6 +700,8 @@ int main(int n, char **v)
     if (!strcmp(v[i], "-h") || !strcmp(v[i], "--help")) usage();
     if (!strcmp(v[i], "-d"))
       { if (i > n-2) usage(); database_filename = v[++i]; continue; }
+    if (!strcmp(v[i], "-rb"))
+      { if (i > n-2) usage(); enb_data.nb_rb = atoi(v[++i]); continue; }
     if (!strcmp(v[i], "-ip")) { if (i > n-2) usage(); ip = v[++i]; continue; }
     if (!strcmp(v[i], "-p"))
       { if (i > n-2) usage(); port = atoi(v[++i]); continue; }
@@ -706,6 +717,11 @@ int main(int n, char **v)
     usage();
   }
 
+  switch (enb_data.nb_rb) {
+  case 25: case 50: case 100: break;
+  default: printf("ERROR, bad value for -rb (%d)\n", enb_data.nb_rb); exit(1);
+  }
+
   if (database_filename == NULL) {
     printf("ERROR: provide a database file (-d)\n");
     exit(1);
@@ -724,7 +740,7 @@ int main(int n, char **v)
   g = gui_init();
   new_thread(gui_thread, g);
 
-  enb_data.ue = 0;
+  enb_data.ue = 3;
   enb_data.e = &eg;
   enb_data.database = database;
 
diff --git a/openair1/PHY/INIT/lte_init.c b/openair1/PHY/INIT/lte_init.c
index f32d4231e86d3a9384cea7807dec6c4818acba47..a170838dad3559a19763773bd2f5dd3c315453b7 100644
--- a/openair1/PHY/INIT/lte_init.c
+++ b/openair1/PHY/INIT/lte_init.c
@@ -1868,6 +1868,8 @@ int phy_init_lte_eNB(PHY_VARS_eNB *eNB,
 
   generate_ul_ref_sigs_rx();
   
+  init_ulsch_power_LUT();
+
   // SRS
   for (UE_id=0; UE_id<NUMBER_OF_UE_MAX; UE_id++) {
     srs_vars[UE_id].srs = (int32_t*)malloc16_clear(2*fp->ofdm_symbol_size*sizeof(int32_t));
diff --git a/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c b/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c
index 65423aa9b6600b8b68f7f5c40db5b18a9a930e38..17748af0b9e4428ab998160346fd3eb510cf9b43 100644
--- a/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c
+++ b/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c
@@ -267,33 +267,28 @@ int32_t temp_in_ifft_0[2048*2] __attribute__((aligned(32)));
 #endif
       }
 
-
-
-      
       // Convert to time domain for visualization
+      memset(temp_in_ifft_0,0,frame_parms->ofdm_symbol_size*sizeof(int32_t));
       for(i=0; i<Msc_RS; i++)
         ((int32_t*)temp_in_ifft_0)[i] = ul_ch_estimates[aa][symbol_offset+i];
+
       switch(frame_parms->N_RB_DL) {
       case 6:
-	
 	idft128((int16_t*) temp_in_ifft_0,
 	       (int16_t*) ul_ch_estimates_time[aa],
 	       1);
 	break;
       case 25:
-	
 	idft512((int16_t*) temp_in_ifft_0,
 	       (int16_t*) ul_ch_estimates_time[aa],
 	       1);
 	break;
       case 50:
-	
 	idft1024((int16_t*) temp_in_ifft_0,
 	       (int16_t*) ul_ch_estimates_time[aa],
 	       1);
 	break;
       case 100:
-	
 	idft2048((int16_t*) temp_in_ifft_0,
 	       (int16_t*) ul_ch_estimates_time[aa],
 	       1);
diff --git a/openair1/PHY/LTE_TRANSPORT/dci.c b/openair1/PHY/LTE_TRANSPORT/dci.c
index b06f69181f32041b891986d72806eccae69bc457..3a42a4c5eaa038eef619f2dd78a92b88756df9d3 100755
--- a/openair1/PHY/LTE_TRANSPORT/dci.c
+++ b/openair1/PHY/LTE_TRANSPORT/dci.c
@@ -2257,11 +2257,18 @@ uint8_t generate_dci_top(uint8_t num_pdcch_symbols,
   y[0] = &yseq0[0];
   y[1] = &yseq1[0];
 
+#if 0
   // reset all bits to <NIL>, here we set <NIL> elements as 2
   // memset(e, 2, DCI_BITS_MAX);
   // here we interpret NIL as a random QPSK sequence. That makes power estimation easier.
   for (i=0; i<DCI_BITS_MAX; i++)
     e[i]=taus()&1;
+#endif
+
+  /* clear all bits, the above code may generate too much false detections
+   * (not sure about this, to be checked somehow)
+   */
+  memset(e, 0, DCI_BITS_MAX);
 
   e_ptr = e;
 
diff --git a/openair1/PHY/LTE_TRANSPORT/dci_tools.c b/openair1/PHY/LTE_TRANSPORT/dci_tools.c
index a4dce4d1ccf6fd8072bea6aaa5196fb00b9e37a8..8a3047b5b2dac3aedd81088398610565f88865c2 100644
--- a/openair1/PHY/LTE_TRANSPORT/dci_tools.c
+++ b/openair1/PHY/LTE_TRANSPORT/dci_tools.c
@@ -6394,12 +6394,11 @@ uint8_t ul_subframe2pdcch_alloc_subframe(LTE_DL_FRAME_PARMS *frame_parms,uint8_t
     return(9);
   else
     return((n+6)%10);
-
 }
 
 uint32_t pdcch_alloc2ul_frame(LTE_DL_FRAME_PARMS *frame_parms,uint32_t frame, uint8_t n)
 {
-  uint32_t ul_frame = 255;
+  uint32_t ul_frame;
 
   if ((frame_parms->frame_type == TDD) &&
       (frame_parms->tdd_config == 1) &&
@@ -6417,8 +6416,7 @@ uint32_t pdcch_alloc2ul_frame(LTE_DL_FRAME_PARMS *frame_parms,uint32_t frame, ui
     ul_frame = (frame+(n>=6 ? 1 : 0));
 
   LOG_D(PHY, "frame %d subframe %d: PUSCH frame = %d\n", frame, n, ul_frame);
-  return ul_frame;
-
+  return ul_frame % 1024;
 }
 
 int32_t pmi_convert_rank1_from_rank2(uint16_t pmi_alloc, int tpmi, int nb_rb)
diff --git a/openair1/PHY/LTE_TRANSPORT/phich.c b/openair1/PHY/LTE_TRANSPORT/phich.c
index 897034c072edac083e54eb47b3bbfbf3195e2ce4..0f6270956c174ab846be74653634e7887d5266aa 100644
--- a/openair1/PHY/LTE_TRANSPORT/phich.c
+++ b/openair1/PHY/LTE_TRANSPORT/phich.c
@@ -151,18 +151,19 @@ unsigned char subframe2_ul_harq(LTE_DL_FRAME_PARMS *frame_parms,unsigned char su
   return(0);
 }
 
-uint8_t phich_frame2_pusch_frame(LTE_DL_FRAME_PARMS *frame_parms,frame_t frame,uint8_t subframe)
+int phich_frame2_pusch_frame(LTE_DL_FRAME_PARMS *frame_parms, int frame, int subframe)
 {
-  uint8_t pusch_frame = 255;
+  int pusch_frame;
+
   if (frame_parms->frame_type == FDD) {
-    pusch_frame = ((subframe<4) ? (frame - 1) : frame);
+    pusch_frame = subframe<4 ? frame + 1024 - 1 : frame;
   } else {
     // Note this is not true, but it doesn't matter, the frame number is irrelevant for TDD!
     pusch_frame = (frame);
   }
 
   LOG_D(PHY, "frame %d subframe %d: PUSCH frame = %d\n", frame, subframe, pusch_frame);
-  return pusch_frame;
+  return pusch_frame % 1024;
 }
 
 uint8_t phich_subframe2_pusch_subframe(LTE_DL_FRAME_PARMS *frame_parms,uint8_t subframe)
diff --git a/openair1/PHY/LTE_TRANSPORT/proto.h b/openair1/PHY/LTE_TRANSPORT/proto.h
index d09e8dc3927e27c145a06c5ef65fe573cacff587..3ee8df87e3296bbb2c2331e77032264a6cc5cf55 100644
--- a/openair1/PHY/LTE_TRANSPORT/proto.h
+++ b/openair1/PHY/LTE_TRANSPORT/proto.h
@@ -1950,7 +1950,7 @@ uint8_t phich_subframe2_pusch_subframe(LTE_DL_FRAME_PARMS *frame_parms,uint8_t s
     @param subframe Subframe of received/transmitted PHICH
     @returns frame of PUSCH transmission
 */
-uint8_t phich_frame2_pusch_frame(LTE_DL_FRAME_PARMS *frame_parms,frame_t frame,uint8_t subframe);
+int phich_frame2_pusch_frame(LTE_DL_FRAME_PARMS *frame_parms, int frame, int subframe);
 
 void print_CQI(void *o,UCI_format_t uci_format,uint8_t eNB_id,int N_RB_DL);
 
@@ -2109,6 +2109,8 @@ int32_t rx_pucch_emul(PHY_VARS_eNB *phy_vars_eNB,
                       uint8_t *payload);
 
 
+void init_ulsch_power_LUT(void);
+
 /*!
   \brief Check for PRACH TXop in subframe
   @param frame_parms Pointer to LTE_DL_FRAME_PARMS
diff --git a/openair1/PHY/LTE_TRANSPORT/pucch.c b/openair1/PHY/LTE_TRANSPORT/pucch.c
index ce39ef0e87ce6b8df33a8086dcdf79f418bcef90..ad9ed2c95d8089f261513ce4767000ddc6c6f91a 100644
--- a/openair1/PHY/LTE_TRANSPORT/pucch.c
+++ b/openair1/PHY/LTE_TRANSPORT/pucch.c
@@ -2420,7 +2420,7 @@ uint32_t rx_pucch(PHY_VARS_eNB *eNB,
       if (fmt==pucch_format1b)
         *(1+payload) = (stat_im<0) ? 1 : 2;
     } else { // insufficient energy on PUCCH so NAK
-      LOG_D(PHY,"PUCCH 1a/b: subframe %d : sigma2_dB %d, stat_max %d, pucch1_thres %d\n",subframe,sigma2_dB,dB_fixed(stat_max),pucch1_thres);
+      LOG_I(PHY,"PUCCH 1a/b: subframe %d : sigma2_dB %d, stat_max %d, pucch1_thres %d\n",subframe,sigma2_dB,dB_fixed(stat_max),pucch1_thres);
       *payload = 4;  // DTX
       ((int16_t*)&eNB->pucch1ab_stats[UE_id][(subframe<<10) + (eNB->pucch1ab_stats_cnt[UE_id][subframe])])[0] = (int16_t)(stat_re);
       ((int16_t*)&eNB->pucch1ab_stats[UE_id][(subframe<<10) + (eNB->pucch1ab_stats_cnt[UE_id][subframe])])[1] = (int16_t)(stat_im);
diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c b/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c
index 0a7d7b1a21f76ce8d3ad8622edb1ec2c68fe93f9..8e97a9af2eed59ea7931f2288b412af1c49df11a 100644
--- a/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c
+++ b/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c
@@ -1102,7 +1102,15 @@ void ulsch_channel_level(int32_t **drs_ch_estimates_ext,
 #endif
 }
 
+int ulsch_power_LUT[750];
 
+void init_ulsch_power_LUT() {
+  
+  int i;
+
+  for (i=0;i<750;i++) ulsch_power_LUT[i] = (int)ceil((pow(2.0,(double)i/100) - 1.0));
+
+}
 
 void rx_ulsch(PHY_VARS_eNB *eNB,
 	      eNB_rxtx_proc_t *proc,
@@ -1164,16 +1172,28 @@ void rx_ulsch(PHY_VARS_eNB *eNB,
                               l/(frame_parms->symbols_per_tti/2));
   }
 
+  int correction_factor = 1;
+  int deltaMCS=1; 
+  int MPR_times_100Ks;
+
+  if (deltaMCS==1) {
+    // Note we're using TBS instead of sumKr, since didn't run segmentation yet!
+
+    MPR_times_100Ks = 500*ulsch[UE_id]->harq_processes[harq_pid]->TBS/(ulsch[UE_id]->harq_processes[harq_pid]->nb_rb*12*4*ulsch[UE_id]->harq_processes[harq_pid]->Nsymb_pusch);
+
+    AssertFatal(MPR_times_100Ks < 750 && MPR_times_100Ks >= 0,"Impossible value for MPR_times_100Ks %d (TBS %d,Nre %d)\n",
+		MPR_times_100Ks,ulsch[UE_id]->harq_processes[harq_pid]->TBS,
+		(ulsch[UE_id]->harq_processes[harq_pid]->nb_rb*12*4*ulsch[UE_id]->harq_processes[harq_pid]->Nsymb_pusch));
+
+    if (MPR_times_100Ks > 0) correction_factor = ulsch_power_LUT[MPR_times_100Ks];
+			       
+  }
   for (i=0; i<frame_parms->nb_antennas_rx; i++) {
     
     pusch_vars->ulsch_power[i] = signal_energy_nodc(pusch_vars->drs_ch_estimates[i],
-						    ulsch[UE_id]->harq_processes[harq_pid]->nb_rb*12);
-    
-#ifdef LOCALIZATION
-    pusch_vars->subcarrier_power = (int32_t *)malloc(ulsch[UE_id]->harq_processes[harq_pid]->nb_rb*12*sizeof(int32_t));
-    pusch_vars->active_subcarrier = subcarrier_energy(pusch_vars->drs_ch_estimates[i],
-						      ulsch[UE_id]->harq_processes[harq_pid]->nb_rb*12, pusch_vars->subcarrier_power, rx_power_correction);
-#endif
+						    ulsch[UE_id]->harq_processes[harq_pid]->nb_rb*12)/correction_factor;
+    /*    printf("%4.4d.%d power harq_pid %d rb %2.2d TBS %2.2d (MPR_times_Ks %d correction %d)  power %d dBtimes10\n", proc->frame_rx, proc->subframe_rx, harq_pid, ulsch[UE_id]->harq_processes[harq_pid]->nb_rb, ulsch[UE_id]->harq_processes[harq_pid]->TBS,MPR_times_100Ks,correction_factor,dB_fixed_times10(pusch_vars->ulsch_power[i])); 
+     */
   }
 
 
diff --git a/openair1/PHY/MODULATION/ofdm_mod.c b/openair1/PHY/MODULATION/ofdm_mod.c
index 4328145c8adf69d2794b1b5a3197444bef18d8ea..369a63355c93d97aaaf102d84fed10cad526c752 100644
--- a/openair1/PHY/MODULATION/ofdm_mod.c
+++ b/openair1/PHY/MODULATION/ofdm_mod.c
@@ -33,47 +33,29 @@ This section deals with basic functions for OFDM Modulation.
 #include "UTIL/LOG/log.h"
 #include "UTIL/LOG/vcd_signal_dumper.h"
 
-//static short temp2[2048*4] __attribute__((aligned(16)));
-
 //#define DEBUG_OFDM_MOD
 
 
 void normal_prefix_mod(int32_t *txdataF,int32_t *txdata,uint8_t nsymb,LTE_DL_FRAME_PARMS *frame_parms)
 {
 
-  uint8_t i;
-  int short_offset=0;
-
-  if ((2*nsymb) < frame_parms->symbols_per_tti)
-    short_offset = 1;
-
-  //  printf("nsymb %d\n",nsymb);
-  for (i=0; i<((short_offset)+2*nsymb/frame_parms->symbols_per_tti); i++) {
-
-#ifdef DEBUG_OFDM_MOD
-    printf("slot i %d (txdata offset %d, txoutput %p)\n",i,(i*(frame_parms->samples_per_tti>>1)),
-           txdata+(i*(frame_parms->samples_per_tti>>1)));
-#endif
-
-    PHY_ofdm_mod(txdataF+(i*frame_parms->ofdm_symbol_size*frame_parms->symbols_per_tti>>1),        // input
-                 txdata+(i*frame_parms->samples_per_tti>>1),         // output
-                 frame_parms->ofdm_symbol_size,                
-                 1,                 // number of symbols
-                 frame_parms->nb_prefix_samples0,               // number of prefix samples
-                 CYCLIC_PREFIX);
-#ifdef DEBUG_OFDM_MOD
-    printf("slot i %d (txdata offset %d)\n",i,OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES0+(i*frame_parms->samples_per_tti>>1));
-#endif
-
-    PHY_ofdm_mod(txdataF+frame_parms->ofdm_symbol_size+(i*frame_parms->ofdm_symbol_size*(frame_parms->symbols_per_tti>>1)),        // input
-                 txdata+OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES0+(i*(frame_parms->samples_per_tti>>1)),         // output
-                 frame_parms->ofdm_symbol_size,                
-                 (short_offset==1) ? 1 :(frame_parms->symbols_per_tti>>1)-1,//6,                 // number of symbols
-                 frame_parms->nb_prefix_samples,               // number of prefix samples
-                 CYCLIC_PREFIX);
 
+  
+  PHY_ofdm_mod(txdataF,        // input
+	       txdata,         // output
+	       frame_parms->ofdm_symbol_size,                
+	       1,                 // number of symbols
+	       frame_parms->nb_prefix_samples0,               // number of prefix samples
+	       CYCLIC_PREFIX);
+  PHY_ofdm_mod(txdataF+frame_parms->ofdm_symbol_size,        // input
+	       txdata+OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES0,         // output
+	       frame_parms->ofdm_symbol_size,                
+	       nsymb-1,
+	       frame_parms->nb_prefix_samples,               // number of prefix samples
+	       CYCLIC_PREFIX);
+  
 
-  }
+  
 }
 
 void PHY_ofdm_mod(int *input,                       /// pointer to complex input
@@ -85,7 +67,7 @@ void PHY_ofdm_mod(int *input,                       /// pointer to complex input
                  )
 {
 
-  static short temp[2048*4] __attribute__((aligned(32)));
+  short temp[2048*4] __attribute__((aligned(32)));
   unsigned short i,j;
   short k;
 
@@ -165,9 +147,10 @@ void PHY_ofdm_mod(int *input,                       /// pointer to complex input
       if (fftsize==128) 
 #endif
       {
-        for (j=0; j<fftsize ; j++) {
+        /*for (j=0; j<fftsize ; j++) {
           output_ptr[j] = temp_ptr[j];
-        }
+        }*/
+        memcpy((void*)output_ptr,(void*)temp_ptr,fftsize<<2);
       }
 
       j=fftsize;
diff --git a/openair1/PHY/TOOLS/time_meas.c b/openair1/PHY/TOOLS/time_meas.c
index 19e9d64d1f024ce3609670771909ec4c04558061..31a613d03297700b9beaeb662a91b487cae50afe 100644
--- a/openair1/PHY/TOOLS/time_meas.c
+++ b/openair1/PHY/TOOLS/time_meas.c
@@ -83,9 +83,8 @@ void print_meas(time_stats_t *ts, const char* name, time_stats_t * total_exec_ti
       //printf("%20s: total: %10.3f ms, average: %10.3f us (%10d trials)\n", name, ts->diff/cpu_freq_GHz/1000000.0, ts->diff/ts->trials/cpu_freq_GHz/1000.0, ts->trials);
 
       if ((total_exec_time == NULL) || (sf_exec_time== NULL)) {
-        fprintf(stderr, "%25s:  %15.3f ms ;  %15.3f us; %15d;\n",
+        fprintf(stderr, "%25s:  %15.3f us; %15d;\n",
                 name,
-                (ts->diff/cpu_freq_GHz/1000000.0),
                 (ts->diff/ts->trials/cpu_freq_GHz/1000.0),
                 ts->trials);
       } else {
diff --git a/openair1/PHY/defs.h b/openair1/PHY/defs.h
index 2cf7dc3f3491e987c28936baf4b3b759382adeb3..3d55b25a74f5e541f3bf3e46640d90c59a7a00cf 100644
--- a/openair1/PHY/defs.h
+++ b/openair1/PHY/defs.h
@@ -331,6 +331,8 @@ typedef struct RU_proc_t_s {
   int instance_cnt_asynch_rxtx;
   /// \internal This variable is protected by \ref mutex_fep
   int instance_cnt_fep;
+  /// \internal This variable is protected by \ref mutex_fep
+  int instance_cnt_feptx;
   /// pthread structure for RU FH processing thread
   pthread_t pthread_FH;
   /// pthread structure for RU prach processing thread
@@ -341,8 +343,10 @@ typedef struct RU_proc_t_s {
 #endif
   /// pthread struct for RU synch thread
   pthread_t pthread_synch;
-  /// pthread struct for RU RX FEP thread
+  /// pthread struct for RU RX FEP worker thread
   pthread_t pthread_fep;
+  /// pthread struct for RU RX FEPTX worker thread
+  pthread_t pthread_feptx;
   /// pthread structure for asychronous RX/TX processing thread
   pthread_t pthread_asynch_rxtx;
   /// flag to indicate first RX acquisition
@@ -361,8 +365,10 @@ typedef struct RU_proc_t_s {
   pthread_attr_t attr_synch;
   /// pthread attributes for asynchronous RX thread
   pthread_attr_t attr_asynch_rxtx;
-  /// pthread attributes for parallel fep thread
+  /// pthread attributes for worker fep thread
   pthread_attr_t attr_fep;
+  /// pthread attributes for worker feptx thread
+  pthread_attr_t attr_feptx;
   /// scheduling parameters for RU FH thread
   struct sched_param sched_param_FH;
   /// scheduling parameters for RU prach thread
@@ -389,6 +395,8 @@ typedef struct RU_proc_t_s {
   pthread_cond_t cond_asynch_rxtx;
   /// condition varaible for RU RX FEP thread
   pthread_cond_t cond_fep;
+  /// condition varaible for RU RX FEPTX thread
+  pthread_cond_t cond_feptx;
   /// condition variable for eNB signal
   pthread_cond_t cond_eNBs;
   /// mutex for RU FH
@@ -405,8 +413,10 @@ typedef struct RU_proc_t_s {
   pthread_mutex_t mutex_eNBs;
   /// mutex for asynch RX/TX thread
   pthread_mutex_t mutex_asynch_rxtx;
-  /// mutex for fep RX
+  /// mutex for fep RX worker thread
   pthread_mutex_t mutex_fep;
+  /// mutex for fep TX worker thread
+  pthread_mutex_t mutex_feptx;
   /// symbol mask for IF4p5 reception per subframe
   uint32_t symbol_mask[10];
   /// number of slave threads
@@ -741,6 +751,8 @@ typedef struct RU_t_s{
   void (*eNB_top)(struct PHY_VARS_eNB_s *eNB, int frame_rx, int subframe_rx, char *string);
   /// Timing statistics
   time_stats_t ofdm_demod_stats;
+  /// Timing statistics (TX)
+  time_stats_t ofdm_mod_stats;
   /// RX and TX buffers for precoder output
   RU_COMMON            common;
   /// beamforming weight vectors per eNB
@@ -756,6 +768,8 @@ typedef struct RU_t_s{
   openair0_timestamp   ts_offset;
   /// process scheduling variables
   RU_proc_t            proc;
+  /// stats thread pthread descriptor
+  pthread_t            ru_stats_thread;
 } RU_t;
 
 
diff --git a/openair1/SCHED/fapi_l1.c b/openair1/SCHED/fapi_l1.c
index a5b0179c7d75c31b02e940ed87631dd6c961c2dd..11cd85d57d35af1c3614c37dfdb44cccc1be70e1 100644
--- a/openair1/SCHED/fapi_l1.c
+++ b/openair1/SCHED/fapi_l1.c
@@ -587,7 +587,7 @@ void schedule_response(Sched_Rsp_t *Sched_INFO)
   ul_frame    = pdcch_alloc2ul_frame(fp,frame,subframe);
 
   AssertFatal(proc->subframe_tx == subframe, "Current subframe %d != NFAPI subframe %d\n",proc->subframe_tx,subframe);
-  AssertFatal(proc->subframe_tx == subframe, "Current frame %d != NFAPI frame %d\n",proc->frame_tx,frame);
+  AssertFatal(proc->frame_tx == frame, "Current frame %d != NFAPI frame %d\n",proc->frame_tx,frame);
 
   uint8_t number_dl_pdu             = DL_req->dl_config_request_body.number_pdu;
   uint8_t number_hi_dci0_pdu        = HI_DCI0_req->hi_dci0_request_body.number_of_dci+HI_DCI0_req->hi_dci0_request_body.number_of_hi;
diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c
index a701ca8590c42bab1af234fd999c04e8bef8d769..8e5358da34fee29ede1624f16ba7ac98cf5538b1 100644
--- a/openair1/SCHED/phy_procedures_lte_eNb.c
+++ b/openair1/SCHED/phy_procedures_lte_eNb.c
@@ -900,7 +900,7 @@ void uci_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc)
 		frame,subframe,
 		pucch_b0b1[0][0],metric[0]);
 
-	  
+      uci->stat = metric[0]; 	  
 	  fill_uci_harq_indication(eNB,uci,frame,subframe,pucch_b0b1[0],0,0xffff);
 
 	}
@@ -971,6 +971,7 @@ void uci_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc)
 	    else if (pucch_b0b1[1][0] != 1 && pucch_b0b1[1][1] != 1) { // 0 ACKs, or at least one DL assignment missed
 	      harq_ack[0] = 0;
 	    }
+        uci->stat = metric[0];
 	    fill_uci_harq_indication(eNB,uci,frame,subframe,harq_ack,2,0xffff); // special_bundling mode
 	  } 
 	  else if ((uci->tdd_bundling == 0) && (uci->num_pucch_resources==2)){ // multiplexing + no SR, implement Table 10.1.3-5 (Rel14) for multiplexing with M=2
@@ -1012,6 +1013,7 @@ void uci_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc)
 		}
 	      }
 	    }
+        uci->stat = max(metric[0],metric[1]);
 	    fill_uci_harq_indication(eNB,uci,frame,subframe,harq_ack,1,tdd_multiplexing_mask); // multiplexing mode
 	  } //else if ((uci->tdd_bundling == 0) && (res==2))
 	  else if ((uci->tdd_bundling == 0) && (uci->num_pucch_resources==3)){ // multiplexing + no SR, implement Table 10.1.3-6 (Rel14) for multiplexing with M=3
@@ -1092,8 +1094,9 @@ void uci_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc)
 		  tdd_multiplexing_mask = 0x4;
 		}
 	      }
+            uci->stat = max_metric;
+            fill_uci_harq_indication(eNB,uci,frame,subframe,harq_ack,1,tdd_multiplexing_mask); // multiplexing mode
 	    }
-	    fill_uci_harq_indication(eNB,uci,frame,subframe,harq_ack,1,tdd_multiplexing_mask); // multiplexing mode
 	  } //else if ((uci->tdd_bundling == 0) && (res==3)) 
 	  else if ((uci->tdd_bundling == 0) && (uci->num_pucch_resources==4)){ // multiplexing + no SR, implement Table 10.1.3-7 (Rel14) for multiplexing with M=4
 	    if (pucch_b0b1[0][0] == 4 ||
@@ -1229,11 +1232,13 @@ void uci_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc)
 		}
 	      }
 	    }
+        uci->stat = max_metric;
 	    fill_uci_harq_indication(eNB,uci,frame,subframe,harq_ack,1,tdd_multiplexing_mask); // multiplexing mode
 	  } // else if ((uci->tdd_bundling == 0) && (res==4))
 	  else { // bundling
 	    harq_ack[0] = pucch_b0b1[0][0];
 	    harq_ack[1] = pucch_b0b1[0][1];
+        uci->stat = metric[0];
 	    fill_uci_harq_indication(eNB,uci,frame,subframe,harq_ack,0,0xffff); // special_bundling mode
 	  }
 	  
@@ -1389,10 +1394,12 @@ void pusch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc)
               ulsch->Mlimit,
               ulsch_harq->o_ACK[0],
               ulsch_harq->o_ACK[1]);
-
-        /*if (dB_fixed_times10(eNB->pusch_vars[i]->ulsch_power[0]) > 300) {
-          dump_ulsch(eNB,frame,subframe,i); exit(-1);
-          } */
+        if (ulsch_harq->round >= 3)  {
+           ulsch_harq->status  = SCH_IDLE;
+           ulsch_harq->handled = 0;
+           ulsch->harq_mask   &= ~(1 << harq_pid);
+           ulsch_harq->round   = 0;
+        } 
 #if defined(MESSAGE_CHART_GENERATOR_PHY)
         MSC_LOG_RX_DISCARDED_MESSAGE(
                                      MSC_PHY_ENB,MSC_PHY_UE,
@@ -1763,6 +1770,7 @@ void fill_uci_harq_indication(PHY_VARS_eNB *eNB,
   // estimate UL_CQI for MAC (from antenna port 0 only)
   int SNRtimes10 = dB_fixed_times10(uci->stat) - 200;//(10*eNB->measurements.n0_power_dB[0]);
 
+  if (SNRtimes10 < -100) LOG_I(PHY,"uci->stat %d \n",uci->stat);
 
   if      (SNRtimes10 < -640) pdu->ul_cqi_information.ul_cqi=0;
   else if (SNRtimes10 >  635) pdu->ul_cqi_information.ul_cqi=255;
diff --git a/openair1/SCHED/ru_procedures.c b/openair1/SCHED/ru_procedures.c
index dd33d1a185b14ae3f6886cbbd5df09294998661f..7e0ca4e76a156c8c3ce1f13644125788de6b1143 100644
--- a/openair1/SCHED/ru_procedures.c
+++ b/openair1/SCHED/ru_procedures.c
@@ -54,10 +54,162 @@
 
 #include <time.h>
 
+#include "targets/RT/USER/rt_wrapper.h"
+
 // RU OFDM Modulator, used in IF4p5 RRU, RCC/RAU with IF5, eNodeB
 
 extern openair0_config_t openair0_cfg[MAX_CARDS];
 
+extern int oai_exit;
+
+
+void feptx0(RU_t *ru,int slot) {
+
+  LTE_DL_FRAME_PARMS *fp = &ru->frame_parms;
+  //int dummy_tx_b[7680*2] __attribute__((aligned(32)));
+
+  unsigned int aa,slot_offset;
+  int i,j, tx_offset;
+  int slot_sizeF = (fp->ofdm_symbol_size)*
+                   ((fp->Ncp==1) ? 6 : 7);
+  int len,len2;
+  int16_t *txdata;
+  int subframe = ru->proc.subframe_tx;
+
+  slot_offset = subframe*fp->samples_per_tti + (slot*(fp->samples_per_tti>>1));
+
+  //    LOG_D(HW,"Frame %d: Generating slot %d\n",frame,next_slot);
+
+  for (aa=0; aa<ru->nb_tx; aa++) {
+    if (fp->Ncp == EXTENDED) PHY_ofdm_mod(&ru->common.txdataF_BF[aa][slot*slot_sizeF],
+					                      (int*)&ru->common.txdata[aa][slot_offset],
+					                      fp->ofdm_symbol_size,
+					                      6,
+					                      fp->nb_prefix_samples,
+					                      CYCLIC_PREFIX);
+    else                     normal_prefix_mod(&ru->common.txdataF_BF[aa][slot*slot_sizeF],
+					                           (int*)&ru->common.txdata[aa][slot_offset],
+					                           7,
+					                           fp);
+    
+   /* 
+    len = fp->samples_per_tti>>1;
+
+    
+    if ((slot_offset+len)>(LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*fp->samples_per_tti)) {
+      tx_offset = (int)slot_offset;
+      txdata = (int16_t*)&ru->common.txdata[aa][tx_offset];
+      len2 = -tx_offset+LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*fp->samples_per_tti;
+      for (i=0; i<(len2<<1); i++) {
+	txdata[i] = ((int16_t*)dummy_tx_b)[i];
+      }
+      txdata = (int16_t*)&ru->common.txdata[aa][0];
+      for (j=0; i<(len<<1); i++,j++) {
+	txdata[j++] = ((int16_t*)dummy_tx_b)[i];
+      }
+    }
+    else {
+      tx_offset = (int)slot_offset;
+      txdata = (int16_t*)&ru->common.txdata[aa][tx_offset];
+      memcpy((void*)txdata,(void*)dummy_tx_b,len<<2);   
+    }
+*/
+    // TDD: turn on tx switch N_TA_offset before by setting buffer in these samples to 0    
+    if ((slot == 0) &&
+        (fp->frame_type == TDD) && 
+        ((fp->tdd_config==0) ||
+         (fp->tdd_config==1) ||
+         (fp->tdd_config==2) ||
+         (fp->tdd_config==6)) &&  
+        ((subframe==0) || (subframe==5))) {
+      for (i=0; i<ru->N_TA_offset; i++) {
+	tx_offset = (int)slot_offset+i-ru->N_TA_offset/2;
+	if (tx_offset<0)
+	  tx_offset += LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*fp->samples_per_tti;
+	
+	if (tx_offset>=(LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*fp->samples_per_tti))
+	  tx_offset -= LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*fp->samples_per_tti;
+	
+	ru->common.txdata[aa][tx_offset] = 0x00000000;
+      }
+    }
+  }
+}
+
+static void *feptx_thread(void *param) {
+
+  RU_t *ru = (RU_t *)param;
+  RU_proc_t *proc  = &ru->proc;
+
+  thread_top_init("feptx_thread",0,870000,1000000,1000000);
+
+  while (!oai_exit) {
+
+    if (wait_on_condition(&proc->mutex_feptx,&proc->cond_feptx,&proc->instance_cnt_feptx,"feptx thread")<0) break;  
+    feptx0(ru,1);
+    if (release_thread(&proc->mutex_feptx,&proc->instance_cnt_feptx,"feptx thread")<0) break;
+
+    if (pthread_cond_signal(&proc->cond_feptx) != 0) {
+      printf("[eNB] ERROR pthread_cond_signal for feptx thread exit\n");
+      exit_fun( "ERROR pthread_cond_signal" );
+      return NULL;
+    }
+  }
+
+
+
+  return(NULL);
+}
+
+void feptx_ofdm_2thread(RU_t *ru) {
+
+  LTE_DL_FRAME_PARMS *fp=&ru->frame_parms;
+  RU_proc_t *proc = &ru->proc;
+  struct timespec wait;
+  int subframe = ru->proc.subframe_tx;
+
+  wait.tv_sec=0;
+  wait.tv_nsec=5000000L;
+
+  start_meas(&ru->ofdm_mod_stats);
+
+  if (subframe_select(fp,subframe) == SF_UL) return;
+
+  if (subframe_select(fp,subframe)==SF_DL) {
+    // If this is not an S-subframe
+    if (pthread_mutex_timedlock(&proc->mutex_feptx,&wait) != 0) {
+      printf("[RU] ERROR pthread_mutex_lock for feptx thread (IC %d)\n", proc->instance_cnt_feptx);
+      exit_fun( "error locking mutex_feptx" );
+      return;
+    }
+    
+    if (proc->instance_cnt_feptx==0) {
+      printf("[RU] FEPtx thread busy\n");
+      exit_fun("FEPtx thread busy");
+      pthread_mutex_unlock( &proc->mutex_feptx );
+      return;
+    }
+    
+    ++proc->instance_cnt_feptx;
+    
+    
+    if (pthread_cond_signal(&proc->cond_feptx) != 0) {
+      printf("[RU] ERROR pthread_cond_signal for feptx thread\n");
+      exit_fun( "ERROR pthread_cond_signal" );
+      return;
+    }
+    
+    pthread_mutex_unlock( &proc->mutex_feptx );
+  }
+
+  // call first slot in this thread
+  feptx0(ru,0);
+  wait_on_busy_condition(&proc->mutex_feptx,&proc->cond_feptx,&proc->instance_cnt_feptx,"feptx thread");  
+
+  stop_meas(&ru->ofdm_mod_stats);
+
+}
+
 void feptx_ofdm(RU_t *ru) {
      
   LTE_DL_FRAME_PARMS *fp=&ru->frame_parms;
@@ -83,6 +235,8 @@ void feptx_ofdm(RU_t *ru) {
       ((subframe_select(fp,subframe)==SF_S))) {
     //    LOG_D(HW,"Frame %d: Generating slot %d\n",frame,next_slot);
 
+    start_meas(&ru->ofdm_mod_stats);
+
     for (aa=0; aa<ru->nb_tx; aa++) {
       if (fp->Ncp == EXTENDED) {
         PHY_ofdm_mod(&ru->common.txdataF_BF[aa][0],
@@ -167,11 +321,12 @@ void feptx_ofdm(RU_t *ru) {
        }
      }
       */
-     if ((((fp->tdd_config==0) ||
-	   (fp->tdd_config==1) ||
-	   (fp->tdd_config==2) ||
-	   (fp->tdd_config==6)) && 
-	   (subframe==0)) || (subframe==5)) {
+     if ((fp->frame_type == TDD) && 
+         ((fp->tdd_config==0) ||
+	      (fp->tdd_config==1) ||
+	      (fp->tdd_config==2) ||
+	      (fp->tdd_config==6)) && 
+	     ((subframe==0) || (subframe==5))) {
        // turn on tx switch N_TA_offset before
        //LOG_D(HW,"subframe %d, time to switch to tx (N_TA_offset %d, slot_offset %d) \n",subframe,ru->N_TA_offset,slot_offset);
        for (i=0; i<ru->N_TA_offset; i++) {
@@ -185,6 +340,7 @@ void feptx_ofdm(RU_t *ru) {
          ru->common.txdata[aa][tx_offset] = 0x00000000;
        }
      }
+     stop_meas(&ru->ofdm_mod_stats);
      LOG_D(PHY,"feptx_ofdm (TXPATH): frame %d, subframe %d: txp (time %p) %d dB, txp (freq) %d dB\n",
 	   ru->proc.frame_tx,subframe,txdata,dB_fixed(signal_energy((int32_t*)txdata,fp->samples_per_tti)),
 	   dB_fixed(signal_energy_nodc(ru->common.txdataF_BF[aa],2*slot_sizeF)));
@@ -234,11 +390,6 @@ void feptx_prec(RU_t *ru) {
   }
 }
 
-typedef struct {
-  RU_t *ru;
-  int slot;
-} fep_task;
-
 void fep0(RU_t *ru,int slot) {
 
   RU_proc_t *proc       = &ru->proc;
@@ -259,12 +410,13 @@ void fep0(RU_t *ru,int slot) {
 
 
 
-extern int oai_exit;
-
 static void *fep_thread(void *param) {
 
   RU_t *ru = (RU_t *)param;
   RU_proc_t *proc  = &ru->proc;
+
+  thread_top_init("fep_thread",0,870000,1000000,1000000);
+
   while (!oai_exit) {
 
     if (wait_on_condition(&proc->mutex_fep,&proc->cond_fep,&proc->instance_cnt_fep,"fep thread")<0) break;  
@@ -283,6 +435,20 @@ static void *fep_thread(void *param) {
   return(NULL);
 }
 
+void init_feptx_thread(RU_t *ru,pthread_attr_t *attr_feptx) {
+
+  RU_proc_t *proc = &ru->proc;
+
+  proc->instance_cnt_feptx         = -1;
+    
+  pthread_mutex_init( &proc->mutex_feptx, NULL);
+  pthread_cond_init( &proc->cond_feptx, NULL);
+
+  pthread_create(&proc->pthread_feptx, attr_feptx, feptx_thread, (void*)ru);
+
+
+}
+
 void init_fep_thread(RU_t *ru,pthread_attr_t *attr_fep) {
 
   RU_proc_t *proc = &ru->proc;
diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c
index d625508f6c978ba8c3e4838484b2f37863d9b32d..5b74cdc4aec5180ce4473dfa60209222b53f2226 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler.c
@@ -476,10 +476,12 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frameP, sub_frame
     CC_id        = UE_PCCID(module_idP, i);
 
     if ((frameP==0)&&(subframeP==0)) {
-      LOG_D(MAC,"UE  rnti %x : %s, PHR %d dB CQI %d\n", rnti,
+      LOG_I(MAC,"UE  rnti %x : %s, PHR %d dB DL CQI %d PUSCH SNR %d PUCCH SNR %d\n", rnti,
             UE_list->UE_sched_ctrl[i].ul_out_of_sync==0 ? "in synch" : "out of sync",
             UE_list->UE_template[CC_id][i].phr_info,
-            UE_list->UE_sched_ctrl[i].dl_cqi[CC_id]);
+            UE_list->UE_sched_ctrl[i].dl_cqi[CC_id],
+	    (UE_list->UE_sched_ctrl[i].pusch_snr[CC_id]-128)/2,
+	    (UE_list->UE_sched_ctrl[i].pucch1_snr[CC_id]-128)/2);
     }
 
     RC.eNB[module_idP][CC_id]->pusch_stats_bsr[i][(frameP*10)+subframeP]=-63;
diff --git a/openair2/LAYER2/MAC/eNB_scheduler_RA.c b/openair2/LAYER2/MAC/eNB_scheduler_RA.c
index c2700ed10665db40532bee8f8a4a5635b4b8a207..eb26e55d59c167851308bb03a6a8a21fa6745eb9 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_RA.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_RA.c
@@ -388,7 +388,7 @@ void generate_Msg2(module_id_t module_idP,int CC_idP,frame_t frameP,sub_frame_t
     {
 
       if ((RA_template->Msg2_frame == frameP) && (RA_template->Msg2_subframe == subframeP)) {
-	LOG_I(MAC,"[eNB %d] CC_id %d Frame %d, subframeP %d: Generating RAR DCI, RA_active %d format 1A (%d,%d))\n",
+	LOG_D(MAC,"[eNB %d] CC_id %d Frame %d, subframeP %d: Generating RAR DCI, RA_active %d format 1A (%d,%d))\n",
 	      module_idP, CC_idP, frameP, subframeP,
 	      RA_template->RA_active,
 	      
@@ -860,7 +860,7 @@ void generate_Msg4(module_id_t module_idP,int CC_idP,frame_t frameP,sub_frame_t
 			     1,                           // ndi
 			     0,                           // rv
 			     0);                          // vrb_flag
-    LOG_I(MAC,"Frame %d, subframe %d: Msg4 DCI pdu_num %d (rnti %x,rnti_type %d,harq_pid %d, resource_block_coding (%p) %d\n",
+    LOG_D(MAC,"Frame %d, subframe %d: Msg4 DCI pdu_num %d (rnti %x,rnti_type %d,harq_pid %d, resource_block_coding (%p) %d\n",
 		  frameP,
 	      subframeP,
           dl_req->number_pdu,
@@ -947,7 +947,7 @@ void generate_Msg4(module_id_t module_idP,int CC_idP,frame_t frameP,sub_frame_t
 				  (cc->p_eNB==1 ) ? 1 : 2,     // transmission mode
 				  1,                           // num_bf_prb_per_subband
 				  1);                          // num_bf_vector
-      LOG_I(MAC,"Filled DLSCH config, pdu number %d, non-dci pdu_index %d\n",dl_req->number_pdu,eNB->pdu_index[CC_idP]);
+      LOG_D(MAC,"Filled DLSCH config, pdu number %d, non-dci pdu_index %d\n",dl_req->number_pdu,eNB->pdu_index[CC_idP]);
 
 	  // DL request
 	  eNB->TX_req[CC_idP].sfn_sf = fill_nfapi_tx_req(&eNB->TX_req[CC_idP].tx_request_body,
@@ -1082,7 +1082,7 @@ void check_Msg4_retransmission(module_id_t module_idP,int CC_idP,frame_t frameP,
 	    dl_req->number_dci++;
 	    dl_req->number_pdu++;
 	    
-	    LOG_I(MAC,"msg4 retransmission for rnti %x (round %d) fsf %d/%d\n", RA_template->rnti, round, frameP, subframeP);
+	    LOG_D(MAC,"msg4 retransmission for rnti %x (round %d) fsf %d/%d\n", RA_template->rnti, round, frameP, subframeP);
 	    	  // DLSCH Config
 	    fill_nfapi_dlsch_config(eNB,
 				    dl_req,
@@ -1164,7 +1164,7 @@ void schedule_RA(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP)
 
       if (RA_template->RA_active == TRUE) {
 
-        LOG_I(MAC,"[eNB %d][RAPROC] Frame %d, Subframe %d : CC_id %d RA %d is active (generate RAR %d, generate_Msg4 %d, wait_ack_Msg4 %d, rnti %x)\n",
+        LOG_D(MAC,"[eNB %d][RAPROC] Frame %d, Subframe %d : CC_id %d RA %d is active (generate RAR %d, generate_Msg4 %d, wait_ack_Msg4 %d, rnti %x)\n",
               module_idP,frameP,subframeP,CC_id,i,RA_template->generate_rar,RA_template->generate_Msg4,RA_template->wait_ack_Msg4, RA_template->rnti);
 
         if      (RA_template->generate_rar == 1)  generate_Msg2(module_idP,CC_id,frameP,subframeP,RA_template);
diff --git a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c
index c38adca4fba3916177d66e7a4b97b8e1c9410991..80c35adbcec04d06e805c2a56f9f569b5677a0c2 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c
@@ -1181,8 +1181,9 @@ schedule_ue_spec(
           // this is the normalized RX power
 	  eNB_UE_stats =  &UE_list->eNB_UE_stats[CC_id][UE_id];
 
+          /* TODO: fix how we deal with power, unit is not dBm, it's special from nfapi */
 	  normalized_rx_power = ue_sched_ctl->pucch1_snr[CC_id];
-	  target_rx_power = 20;
+	  target_rx_power = 208;
 	    
           // this assumes accumulated tpc
 	  // make sure that we are only sending a tpc update once a frame, otherwise the control loop will freak out
@@ -1195,10 +1196,10 @@ schedule_ue_spec(
 	      UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_frame=frameP;
 	      UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_subframe=subframeP;
 	      
-	      if (normalized_rx_power>(target_rx_power+1)) {
+	      if (normalized_rx_power>(target_rx_power+4)) {
 		tpc = 0; //-1
 		tpc_accumulated--;
-	      } else if (normalized_rx_power<(target_rx_power-1)) {
+	      } else if (normalized_rx_power<(target_rx_power-4)) {
 		tpc = 2; //+1
 		tpc_accumulated++;
 	      } else {
diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c
index db368cde2eebe1e95ce932b35bdb20188536ea6c..3097a0c094ccd680136fc35a2d2b464ed045b4b2 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c
@@ -3606,8 +3606,11 @@ void SR_indication(module_id_t mod_idP, int cc_idP, frame_t frameP, sub_frame_t
 
     UE_sched_ctrl *sched_ctl = &UE_list->UE_sched_ctrl[UE_id];
 
+#if 0
+    /* for the moment don't use ul_cqi from SR, value is too different from harq */
     sched_ctl->pucch1_snr[cc_idP]        = ul_cqi;
     sched_ctl->pucch1_cqi_update[cc_idP] = 1;
+#endif
 
     UE_list->UE_template[cc_idP][UE_id].ul_SR = 1;
     UE_list->UE_template[cc_idP][UE_id].ul_active = TRUE;
diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c
index af86640a2410390ae2388479fe2d8a02331c27b9..ee5ae3b5849328cf7ae4a5f57cc37e39cab5d6cd 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c
@@ -64,25 +64,25 @@
 uint8_t rb_table[34] = {1,2,3,4,5,6,8,9,10,12,15,16,18,20,24,25,27,30,32,36,40,45,48,50,54,60,64,72,75,80,81,90,96,100};
 
 void rx_sdu(const module_id_t enb_mod_idP,
-	    const int         CC_idP,
-	    const frame_t     frameP,
-	    const sub_frame_t subframeP,
-	    const rnti_t      rntiP,
-	    uint8_t          *sduP,
-	    const uint16_t    sdu_lenP,
-	    const uint16_t    timing_advance,
-	    const uint8_t     ul_cqi) {
-
-
+            const int         CC_idP,
+            const frame_t     frameP,
+            const sub_frame_t subframeP,
+            const rnti_t      rntiP,
+            uint8_t          *sduP,
+            const uint16_t    sdu_lenP,
+            const uint16_t    timing_advance,
+            const uint8_t     ul_cqi)
+{
+  int current_rnti = rntiP;
   unsigned char  rx_ces[MAX_NUM_CE],num_ce,num_sdu,i,*payload_ptr;
   unsigned char  rx_lcids[NB_RB_MAX];
   unsigned short rx_lengths[NB_RB_MAX];
-  int    UE_id = find_UE_id(enb_mod_idP,rntiP);
+  int    UE_id = find_UE_id(enb_mod_idP, current_rnti);
   int RA_id;
   int ii,j;
   eNB_MAC_INST *eNB = RC.mac[enb_mod_idP];
   int    harq_pid = subframe2harqpid(&eNB->common_channels[CC_idP],frameP,subframeP);
-  
+
   UE_list_t *UE_list= &eNB->UE_list;
   int crnti_rx=0;
   int old_buffer_info;
@@ -98,20 +98,18 @@ void rx_sdu(const module_id_t enb_mod_idP,
 
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RX_SDU,1);
   if (opt_enabled == 1) {
-    trace_pdu(0, sduP,sdu_lenP, 0, 3, rntiP, frameP, subframeP, 0,0);
+    trace_pdu(0, sduP,sdu_lenP, 0, 3, current_rnti, frameP, subframeP, 0,0);
     LOG_D(OPT,"[eNB %d][ULSCH] Frame %d  rnti %x  with size %d\n",
-    		  enb_mod_idP, frameP, rntiP, sdu_lenP);
+                      enb_mod_idP, frameP, current_rnti, sdu_lenP);
   }
-  
 
   if (UE_id!=-1) {
-
     LOG_D(MAC,"[eNB %d][PUSCH %d] CC_id %d Received ULSCH sdu round %d from PHY (rnti %x, UE_id %d) ul_cqi %d\n",enb_mod_idP,harq_pid,CC_idP, UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid],
-	  rntiP,UE_id,ul_cqi);
+          current_rnti, UE_id,ul_cqi);
 
     AssertFatal(UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid] < 8,
-		"round >= 8\n");
-    if (sduP!=NULL) { 
+                "round >= 8\n");
+    if (sduP!=NULL) {
        UE_list->UE_sched_ctrl[UE_id].ul_inactivity_timer   = 0;
        UE_list->UE_sched_ctrl[UE_id].ul_failure_timer      = 0;
        UE_list->UE_sched_ctrl[UE_id].ul_scheduled         &= (~(1<<harq_pid));
@@ -129,13 +127,13 @@ void rx_sdu(const module_id_t enb_mod_idP,
     }
     else { // we've got an error
       LOG_D(MAC,"[eNB %d][PUSCH %d] CC_id %d ULSCH in error in round %d, ul_cqi %d\n",enb_mod_idP,harq_pid,CC_idP,
-	        UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid],ul_cqi);
+                UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid],ul_cqi);
 
       //      AssertFatal(1==0,"ulsch in error\n");
       if (UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid] == 3) {
-	     UE_list->UE_sched_ctrl[UE_id].ul_scheduled       &= (~(1<<harq_pid));
-	     UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid]=0;
-	     if (UE_list->UE_sched_ctrl[UE_id].ul_consecutive_errors++ == 10)
+             UE_list->UE_sched_ctrl[UE_id].ul_scheduled       &= (~(1<<harq_pid));
+             UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid]=0;
+             if (UE_list->UE_sched_ctrl[UE_id].ul_consecutive_errors++ == 10)
             UE_list->UE_sched_ctrl[UE_id].ul_failure_timer = 1;
       }
       else UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid]++;
@@ -143,23 +141,23 @@ void rx_sdu(const module_id_t enb_mod_idP,
 
     }
   }
-  else if ((RA_id = find_RA_id(enb_mod_idP,CC_idP,rntiP))!=-1) { // Check if this is an RA process for the rnti
+  else if ((RA_id = find_RA_id(enb_mod_idP,CC_idP,current_rnti))!=-1) { // Check if this is an RA process for the rnti
     AssertFatal(eNB->common_channels[CC_idP].radioResourceConfigCommon->rach_ConfigCommon.maxHARQ_Msg3Tx>1,
-		"maxHARQ %d should be greater than 1\n",
-		(int)eNB->common_channels[CC_idP].radioResourceConfigCommon->rach_ConfigCommon.maxHARQ_Msg3Tx);
+                "maxHARQ %d should be greater than 1\n",
+                (int)eNB->common_channels[CC_idP].radioResourceConfigCommon->rach_ConfigCommon.maxHARQ_Msg3Tx);
 
     LOG_D(MAC,"[eNB %d][PUSCH %d] CC_id %d Received ULSCH sdu round %d from PHY (rnti %x, RA_id %d) ul_cqi %d\n",enb_mod_idP,harq_pid,CC_idP,
      RA_template[RA_id].msg3_round,
-     rntiP,RA_id,ul_cqi);
+     current_rnti,RA_id,ul_cqi);
 
-    first_rb                   = RA_template->msg3_first_rb; 
+    first_rb                   = RA_template->msg3_first_rb;
 
     if (sduP==NULL) { // we've got an error on Msg3
       LOG_D(MAC,"[eNB %d] CC_id %d, RA %d ULSCH in error in round %d/%d\n",enb_mod_idP,CC_idP,RA_id,
-	    RA_template[RA_id].msg3_round,
-	    (int)eNB->common_channels[CC_idP].radioResourceConfigCommon->rach_ConfigCommon.maxHARQ_Msg3Tx);
-      if (RA_template[RA_id].msg3_round == eNB->common_channels[CC_idP].radioResourceConfigCommon->rach_ConfigCommon.maxHARQ_Msg3Tx-1) { 
-	cancel_ra_proc(enb_mod_idP,CC_idP,frameP,rntiP);
+            RA_template[RA_id].msg3_round,
+            (int)eNB->common_channels[CC_idP].radioResourceConfigCommon->rach_ConfigCommon.maxHARQ_Msg3Tx);
+      if (RA_template[RA_id].msg3_round == eNB->common_channels[CC_idP].radioResourceConfigCommon->rach_ConfigCommon.maxHARQ_Msg3Tx-1) {
+        cancel_ra_proc(enb_mod_idP,CC_idP,frameP,current_rnti);
       }
 
       else {
@@ -174,15 +172,14 @@ void rx_sdu(const module_id_t enb_mod_idP,
     }
   }
   else  {
-    LOG_W(MAC,"Cannot find UE or RA corresponding to ULSCH rnti %x, dropping it\n",
-          rntiP);
+    LOG_W(MAC,"Cannot find UE or RA corresponding to ULSCH rnti %x, dropping it\n", current_rnti);
     return;
   }
   payload_ptr = parse_ulsch_header(sduP,&num_ce,&num_sdu,rx_ces,rx_lcids,rx_lengths,sdu_lenP);
 
-  T(T_ENB_MAC_UE_UL_PDU, T_INT(enb_mod_idP), T_INT(CC_idP), T_INT(rntiP), T_INT(frameP), T_INT(subframeP),
+  T(T_ENB_MAC_UE_UL_PDU, T_INT(enb_mod_idP), T_INT(CC_idP), T_INT(current_rnti), T_INT(frameP), T_INT(subframeP),
     T_INT(harq_pid), T_INT(sdu_lenP), T_INT(num_ce), T_INT(num_sdu));
-  T(T_ENB_MAC_UE_UL_PDU_WITH_DATA, T_INT(enb_mod_idP), T_INT(CC_idP), T_INT(rntiP), T_INT(frameP), T_INT(subframeP),
+  T(T_ENB_MAC_UE_UL_PDU_WITH_DATA, T_INT(enb_mod_idP), T_INT(CC_idP), T_INT(current_rnti), T_INT(frameP), T_INT(subframeP),
     T_INT(harq_pid), T_INT(sdu_lenP), T_INT(num_ce), T_INT(num_sdu), T_BUFFER(sduP, sdu_lenP));
 
   eNB->eNB_stats[CC_idP].ulsch_bytes_rx=sdu_lenP;
@@ -194,9 +191,9 @@ void rx_sdu(const module_id_t enb_mod_idP,
   // control element
   for (i=0; i<num_ce; i++) {
 
-    T(T_ENB_MAC_UE_UL_CE, T_INT(enb_mod_idP), T_INT(CC_idP), T_INT(rntiP), T_INT(frameP), T_INT(subframeP),
+    T(T_ENB_MAC_UE_UL_CE, T_INT(enb_mod_idP), T_INT(CC_idP), T_INT(current_rnti), T_INT(frameP), T_INT(subframeP),
       T_INT(rx_ces[i]));
-    
+
     switch (rx_ces[i]) { // implement and process BSR + CRNTI +
     case POWER_HEADROOM:
       if (UE_id != -1) {
@@ -204,33 +201,43 @@ void rx_sdu(const module_id_t enb_mod_idP,
         LOG_D(MAC, "[eNB %d] CC_id %d MAC CE_LCID %d : Received PHR PH = %d (db)\n",
               enb_mod_idP, CC_idP, rx_ces[i], UE_list->UE_template[CC_idP][UE_id].phr_info);
         UE_list->UE_template[CC_idP][UE_id].phr_info_configured=1;
-	UE_list->UE_sched_ctrl[UE_id].phr_received = 1;
+        UE_list->UE_sched_ctrl[UE_id].phr_received = 1;
       }
       payload_ptr+=sizeof(POWER_HEADROOM_CMD);
       break;
 
-    case CRNTI:
-      UE_id = find_UE_id(enb_mod_idP,(((uint16_t)payload_ptr[0])<<8) + payload_ptr[1]);
+    case CRNTI: {
+      int old_rnti = (((uint16_t)payload_ptr[0])<<8) + payload_ptr[1];
+      int old_UE_id = find_UE_id(enb_mod_idP, old_rnti);
       LOG_D(MAC, "[eNB %d] Frame %d, Subframe %d CC_id %d MAC CE_LCID %d (ce %d/%d): CRNTI %x (UE_id %d) in Msg3\n",
-	    frameP,subframeP,enb_mod_idP, CC_idP, rx_ces[i], i,num_ce,(((uint16_t)payload_ptr[0])<<8) + payload_ptr[1],UE_id);
-      if (UE_id!=-1) {
-	UE_list->UE_sched_ctrl[UE_id].ul_inactivity_timer=0;
-	UE_list->UE_sched_ctrl[UE_id].ul_failure_timer=0;
-	if (UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync > 0) {
-	  UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync=0;
-	  mac_eNB_rrc_ul_in_sync(enb_mod_idP,CC_idP,frameP,subframeP,(((uint16_t)payload_ptr[0])<<8) + payload_ptr[1]);
-	}
-printf("TODO: deal with CRNTI\n");
-abort();
+            enb_mod_idP, frameP, subframeP, CC_idP, rx_ces[i], i, num_ce, old_rnti, old_UE_id);
+      if (old_UE_id != -1) {
+        /* TODO: if the UE did random access (followed by a MAC uplink with
+         * CRNTI) because none of its scheduling request was granted, then
+         * according to 36.321 5.4.4 the UE's MAC will notify RRC to release
+         * PUCCH/SRS. According to 36.331 5.3.13 the UE will then apply
+         * default configuration for CQI reporting and scheduling requests,
+         * which basically means that the CQI requests won't work anymore and
+         * that the UE won't do any scheduling request anymore as long as the
+         * eNB doesn't reconfigure the UE.
+         * We have to take care of this. As the code is, nothing is done and
+         * the UE state in the eNB is wrong.
+         */
+        UE_id = old_UE_id;
+        UE_list->UE_sched_ctrl[UE_id].ul_inactivity_timer = 0;
+        UE_list->UE_sched_ctrl[UE_id].ul_failure_timer    = 0;
+        if (UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync > 0) {
+          UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync = 0;
+          mac_eNB_rrc_ul_in_sync(enb_mod_idP, CC_idP, frameP, subframeP, old_rnti);
+        }
+        /* receiving CRNTI means that the current rnti has to go away */
+        cancel_ra_proc(enb_mod_idP,CC_idP,frameP,current_rnti);
+        current_rnti = old_rnti;
       }
       crnti_rx=1;
       payload_ptr+=2;
-      /*
-      if (msg3_flagP != NULL) {
-	*msg3_flagP = 0;
-	}*/
-
       break;
+    }
 
     case TRUNCATED_BSR:
     case SHORT_BSR: {
@@ -238,31 +245,31 @@ abort();
       lcgid = (payload_ptr[0] >> 6);
 
       LOG_D(MAC, "[eNB %d] CC_id %d MAC CE_LCID %d : Received short BSR LCGID = %u bsr = %d\n",
-	    enb_mod_idP, CC_idP, rx_ces[i], lcgid, payload_ptr[0] & 0x3f);
+            enb_mod_idP, CC_idP, rx_ces[i], lcgid, payload_ptr[0] & 0x3f);
 
       if (crnti_rx==1)
-	LOG_D(MAC, "[eNB %d] CC_id %d MAC CE_LCID %d : Received short BSR LCGID = %u bsr = %d\n",
-	      enb_mod_idP, CC_idP, rx_ces[i], lcgid, payload_ptr[0] & 0x3f);
+        LOG_D(MAC, "[eNB %d] CC_id %d MAC CE_LCID %d : Received short BSR LCGID = %u bsr = %d\n",
+              enb_mod_idP, CC_idP, rx_ces[i], lcgid, payload_ptr[0] & 0x3f);
       if (UE_id  != -1) {
 
         UE_list->UE_template[CC_idP][UE_id].bsr_info[lcgid] = (payload_ptr[0] & 0x3f);
 
-	// update buffer info
-	
-	UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[lcgid]=BSR_TABLE[UE_list->UE_template[CC_idP][UE_id].bsr_info[lcgid]];
+        // update buffer info
+
+        UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[lcgid]=BSR_TABLE[UE_list->UE_template[CC_idP][UE_id].bsr_info[lcgid]];
 
-	UE_list->UE_template[CC_idP][UE_id].ul_total_buffer= UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[lcgid];
+        UE_list->UE_template[CC_idP][UE_id].ul_total_buffer= UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[lcgid];
 
-	RC.eNB[enb_mod_idP][CC_idP]->pusch_stats_bsr[UE_id][(frameP*10)+subframeP] = (payload_ptr[0] & 0x3f);
-	if (UE_id == UE_list->head)
-	  VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_BSR,RC.eNB[enb_mod_idP][CC_idP]->pusch_stats_bsr[UE_id][(frameP*10)+subframeP]);	
+        RC.eNB[enb_mod_idP][CC_idP]->pusch_stats_bsr[UE_id][(frameP*10)+subframeP] = (payload_ptr[0] & 0x3f);
+        if (UE_id == UE_list->head)
+          VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_BSR,RC.eNB[enb_mod_idP][CC_idP]->pusch_stats_bsr[UE_id][(frameP*10)+subframeP]);
         if (UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[lcgid] == 0 ) {
           UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[lcgid]=frameP;
         }
-	if (mac_eNB_get_rrc_status(enb_mod_idP,UE_RNTI(enb_mod_idP,UE_id)) < RRC_CONNECTED)
-	  LOG_D(MAC, "[eNB %d] CC_id %d MAC CE_LCID %d : ul_total_buffer = %d (lcg increment %d)\n",
-		enb_mod_idP, CC_idP, rx_ces[i], UE_list->UE_template[CC_idP][UE_id].ul_total_buffer,
-		UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[lcgid]);	
+        if (mac_eNB_get_rrc_status(enb_mod_idP,UE_RNTI(enb_mod_idP,UE_id)) < RRC_CONNECTED)
+          LOG_D(MAC, "[eNB %d] CC_id %d MAC CE_LCID %d : ul_total_buffer = %d (lcg increment %d)\n",
+                enb_mod_idP, CC_idP, rx_ces[i], UE_list->UE_template[CC_idP][UE_id].ul_total_buffer,
+                UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[lcgid]);
       }
       else {
 
@@ -280,39 +287,39 @@ abort();
           ((payload_ptr[1] & 0x0F) << 2) | ((payload_ptr[2] & 0xC0) >> 6);
         UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID3] = (payload_ptr[2] & 0x3F);
 
-	// update buffer info
-	old_buffer_info = UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID0];
-	UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID0]=BSR_TABLE[UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID0]];
-
-	UE_list->UE_template[CC_idP][UE_id].ul_total_buffer+= UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID0];
-	if (UE_list->UE_template[CC_idP][UE_id].ul_total_buffer >= old_buffer_info)
-	  UE_list->UE_template[CC_idP][UE_id].ul_total_buffer -= old_buffer_info;
-	else
-	  UE_list->UE_template[CC_idP][UE_id].ul_total_buffer = 0;
-
-	old_buffer_info = UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID1];
-	UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID1]=BSR_TABLE[UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID1]];
-	UE_list->UE_template[CC_idP][UE_id].ul_total_buffer+= UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID1];
-	if (UE_list->UE_template[CC_idP][UE_id].ul_total_buffer >= old_buffer_info)
-	  UE_list->UE_template[CC_idP][UE_id].ul_total_buffer -= old_buffer_info;
-	else
-	  UE_list->UE_template[CC_idP][UE_id].ul_total_buffer = 0;
-
-	old_buffer_info = UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID2];
-	UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID2]=BSR_TABLE[UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID2]];
-	UE_list->UE_template[CC_idP][UE_id].ul_total_buffer+= UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID2];
-	if (UE_list->UE_template[CC_idP][UE_id].ul_total_buffer >= old_buffer_info)
-	  UE_list->UE_template[CC_idP][UE_id].ul_total_buffer -= old_buffer_info;
-	else
-	  UE_list->UE_template[CC_idP][UE_id].ul_total_buffer = 0;
-
-	old_buffer_info = UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID3];
-	UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID3]=BSR_TABLE[UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID3]];
-	UE_list->UE_template[CC_idP][UE_id].ul_total_buffer+= UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID3];
-	if (UE_list->UE_template[CC_idP][UE_id].ul_total_buffer >= old_buffer_info)
-	  UE_list->UE_template[CC_idP][UE_id].ul_total_buffer -= old_buffer_info;
-	else
-	  UE_list->UE_template[CC_idP][UE_id].ul_total_buffer = 0;
+        // update buffer info
+        old_buffer_info = UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID0];
+        UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID0]=BSR_TABLE[UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID0]];
+
+        UE_list->UE_template[CC_idP][UE_id].ul_total_buffer+= UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID0];
+        if (UE_list->UE_template[CC_idP][UE_id].ul_total_buffer >= old_buffer_info)
+          UE_list->UE_template[CC_idP][UE_id].ul_total_buffer -= old_buffer_info;
+        else
+          UE_list->UE_template[CC_idP][UE_id].ul_total_buffer = 0;
+
+        old_buffer_info = UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID1];
+        UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID1]=BSR_TABLE[UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID1]];
+        UE_list->UE_template[CC_idP][UE_id].ul_total_buffer+= UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID1];
+        if (UE_list->UE_template[CC_idP][UE_id].ul_total_buffer >= old_buffer_info)
+          UE_list->UE_template[CC_idP][UE_id].ul_total_buffer -= old_buffer_info;
+        else
+          UE_list->UE_template[CC_idP][UE_id].ul_total_buffer = 0;
+
+        old_buffer_info = UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID2];
+        UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID2]=BSR_TABLE[UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID2]];
+        UE_list->UE_template[CC_idP][UE_id].ul_total_buffer+= UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID2];
+        if (UE_list->UE_template[CC_idP][UE_id].ul_total_buffer >= old_buffer_info)
+          UE_list->UE_template[CC_idP][UE_id].ul_total_buffer -= old_buffer_info;
+        else
+          UE_list->UE_template[CC_idP][UE_id].ul_total_buffer = 0;
+
+        old_buffer_info = UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID3];
+        UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID3]=BSR_TABLE[UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID3]];
+        UE_list->UE_template[CC_idP][UE_id].ul_total_buffer+= UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID3];
+        if (UE_list->UE_template[CC_idP][UE_id].ul_total_buffer >= old_buffer_info)
+          UE_list->UE_template[CC_idP][UE_id].ul_total_buffer -= old_buffer_info;
+        else
+          UE_list->UE_template[CC_idP][UE_id].ul_total_buffer = 0;
 
         LOG_D(MAC, "[eNB %d] CC_id %d MAC CE_LCID %d: Received long BSR LCGID0 = %u LCGID1 = "
               "%u LCGID2 = %u LCGID3 = %u\n",
@@ -370,9 +377,9 @@ abort();
   for (i=0; i<num_sdu; i++) {
     LOG_D(MAC,"SDU Number %d MAC Subheader SDU_LCID %d, length %d\n",i,rx_lcids[i],rx_lengths[i]);
 
-    T(T_ENB_MAC_UE_UL_SDU, T_INT(enb_mod_idP), T_INT(CC_idP), T_INT(rntiP), T_INT(frameP), T_INT(subframeP),
+    T(T_ENB_MAC_UE_UL_SDU, T_INT(enb_mod_idP), T_INT(CC_idP), T_INT(current_rnti), T_INT(frameP), T_INT(subframeP),
       T_INT(rx_lcids[i]), T_INT(rx_lengths[i]));
-    T(T_ENB_MAC_UE_UL_SDU_WITH_DATA, T_INT(enb_mod_idP), T_INT(CC_idP), T_INT(rntiP), T_INT(frameP), T_INT(subframeP),
+    T(T_ENB_MAC_UE_UL_SDU_WITH_DATA, T_INT(enb_mod_idP), T_INT(CC_idP), T_INT(current_rnti), T_INT(frameP), T_INT(subframeP),
       T_INT(rx_lcids[i]), T_INT(rx_lengths[i]), T_BUFFER(payload_ptr, rx_lengths[i]));
 
     switch (rx_lcids[i]) {
@@ -384,18 +391,18 @@ abort();
       }
       LOG_D(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d, Received CCCH:  %x.%x.%x.%x.%x.%x, Terminating RA procedure for UE rnti %x\n",
             enb_mod_idP,CC_idP,frameP,
-            payload_ptr[0],payload_ptr[1],payload_ptr[2],payload_ptr[3],payload_ptr[4], payload_ptr[5], rntiP);
+            payload_ptr[0],payload_ptr[1],payload_ptr[2],payload_ptr[3],payload_ptr[4], payload_ptr[5], current_rnti);
       VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_TERMINATE_RA_PROC,1);
       VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_TERMINATE_RA_PROC,0);
       for (ii=0; ii<NB_RA_PROC_MAX; ii++) {
-	RA_TEMPLATE *RA_template = &eNB->common_channels[CC_idP].RA_template[ii];
+        RA_TEMPLATE *RA_template = &eNB->common_channels[CC_idP].RA_template[ii];
 
         LOG_D(MAC,"[eNB %d][RAPROC] CC_id %d Checking proc %d : rnti (%x, %x), active %d\n",
               enb_mod_idP, CC_idP, ii,
-              RA_template->rnti, rntiP,
+              RA_template->rnti, current_rnti,
               RA_template->RA_active);
 
-        if ((RA_template->rnti==rntiP) &&
+        if ((RA_template->rnti==current_rnti) &&
             (RA_template->RA_active==TRUE)) {
 
           //payload_ptr = parse_ulsch_header(msg3,&num_ce,&num_sdu,rx_ces,rx_lcids,rx_lengths,msg3_len);
@@ -411,53 +418,53 @@ abort();
                       #endif
                       )) == -1 ) {
               AssertFatal(1==0,"[MAC][eNB] Max user count reached\n");
-	      // kill RA procedure
+              // kill RA procedure
             } else
               LOG_D(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d Added user with rnti %x => UE %d\n",
                     enb_mod_idP,CC_idP,frameP,RA_template->rnti,UE_id);
           } else {
             LOG_D(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d CCCH: Received Msg3 from already registered UE %d: length %d, offset %ld\n",
                   enb_mod_idP,CC_idP,frameP,UE_id,rx_lengths[i],payload_ptr-sduP);
-	    // kill RA procedure
+            // kill RA procedure
           }
 
-	  mac_rrc_data_ind(
-			   enb_mod_idP,
-			   CC_idP,
-			   frameP,subframeP,
-			   rntiP,
-			   CCCH,
-			   (uint8_t*)payload_ptr,
-			   rx_lengths[i],
-			   ENB_FLAG_YES,
-			   enb_mod_idP,
+          mac_rrc_data_ind(
+                           enb_mod_idP,
+                           CC_idP,
+                           frameP,subframeP,
+                           current_rnti,
+                           CCCH,
+                           (uint8_t*)payload_ptr,
+                           rx_lengths[i],
+                           ENB_FLAG_YES,
+                           enb_mod_idP,
                            0
                            );
-	  
-	  
+
+
           if (num_ce >0) {  // handle msg3 which is not RRCConnectionRequest
             //  process_ra_message(msg3,num_ce,rx_lcids,rx_ces);
           }
 
-	  // prepare transmission of Msg4
+          // prepare transmission of Msg4
           RA_template->generate_Msg4 = 1;
           RA_template->wait_ack_Msg4 = 0;
 
 
 
-	  // Program Msg4 PDCCH+DLSCH/MPDCCH transmission 4 subframes from now, // Check if this is ok for BL/CE, or if the rule is different
-	  RA_template->Msg4_frame    = frameP + ((subframeP>5) ? 1 : 0);
-	  RA_template->Msg4_subframe = (subframeP+4)%10;
-	  
+          // Program Msg4 PDCCH+DLSCH/MPDCCH transmission 4 subframes from now, // Check if this is ok for BL/CE, or if the rule is different
+          RA_template->Msg4_frame    = frameP + ((subframeP>5) ? 1 : 0);
+          RA_template->Msg4_subframe = (subframeP+4)%10;
+
         } // if process is active
       } // loop on RA processes
-      
+
       break ;
 
     case DCCH :
     case DCCH1 :
       //      if(eNB_mac_inst[module_idP][CC_idP].Dcch_lchan[UE_id].Active==1){
-      
+
 
 #if defined(ENABLE_MAC_PAYLOAD_DEBUG)
       LOG_T(MAC,"offset: %d\n",(unsigned char)((unsigned char*)payload_ptr-sduP));
@@ -468,35 +475,35 @@ abort();
 #endif
 
       if (UE_id != -1) {
-	// adjust buffer occupancy of the correponding logical channel group
-	if (UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] >= rx_lengths[i])
-	  UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] -= rx_lengths[i];
-	else
-	  UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] = 0;
+        // adjust buffer occupancy of the correponding logical channel group
+        if (UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] >= rx_lengths[i])
+          UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] -= rx_lengths[i];
+        else
+          UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] = 0;
 
           LOG_D(MAC,"[eNB %d] CC_id %d Frame %d : ULSCH -> UL-DCCH, received %d bytes form UE %d on LCID %d \n",
                 enb_mod_idP,CC_idP,frameP, rx_lengths[i], UE_id, rx_lcids[i]);
 
           mac_rlc_data_ind(
-			   enb_mod_idP,
-			   rntiP,
-			   enb_mod_idP,
-			   frameP,
-			   ENB_FLAG_YES,
-			   MBMS_FLAG_NO,
-			   rx_lcids[i],
-			   (char *)payload_ptr,
-			   rx_lengths[i],
-			   1,
-			   NULL);//(unsigned int*)crc_status);
+                           enb_mod_idP,
+                           current_rnti,
+                           enb_mod_idP,
+                           frameP,
+                           ENB_FLAG_YES,
+                           MBMS_FLAG_NO,
+                           rx_lcids[i],
+                           (char *)payload_ptr,
+                           rx_lengths[i],
+                           1,
+                           NULL);//(unsigned int*)crc_status);
           UE_list->eNB_UE_stats[CC_idP][UE_id].num_pdu_rx[rx_lcids[i]]+=1;
           UE_list->eNB_UE_stats[CC_idP][UE_id].num_bytes_rx[rx_lcids[i]]+=rx_lengths[i];
 
 
       } /* UE_id != -1 */
 
- 
-      // } 
+
+      // }
       break;
 
       // all the DRBS
@@ -511,67 +518,67 @@ abort();
       LOG_T(MAC,"\n");
 #endif
       if (rx_lcids[i]  < NB_RB_MAX ) {
-	LOG_D(MAC,"[eNB %d] CC_id %d Frame %d : ULSCH -> UL-DTCH, received %d bytes from UE %d for lcid %d\n",
-	      enb_mod_idP,CC_idP,frameP, rx_lengths[i], UE_id, rx_lcids[i]);
-	
-	if (UE_id != -1) {
-	  // adjust buffer occupancy of the correponding logical channel group
-	  LOG_D(MAC,"[eNB %d] CC_id %d Frame %d : ULSCH -> UL-DTCH, received %d bytes from UE %d for lcid %d, removing from LCGID %ld, %d\n",
-		enb_mod_idP,CC_idP,frameP, rx_lengths[i], UE_id,rx_lcids[i],
-		UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]],
-		UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]]);
-	  
-	  if (UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] >= rx_lengths[i])
-	    UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] -= rx_lengths[i];
-	  else
-	    UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] = 0;
-	  if ((rx_lengths[i] <SCH_PAYLOAD_SIZE_MAX) &&  (rx_lengths[i] > 0) ) {   // MAX SIZE OF transport block
-	    mac_rlc_data_ind(
-			     enb_mod_idP,
-			     rntiP,
-			     enb_mod_idP,
-			     frameP,
-			     ENB_FLAG_YES,
-			     MBMS_FLAG_NO,
-			     rx_lcids[i],
-			     (char *)payload_ptr,
-			     rx_lengths[i],
-			     1,
-			     NULL);//(unsigned int*)crc_status);
-	    
-	    UE_list->eNB_UE_stats[CC_idP][UE_id].num_pdu_rx[rx_lcids[i]]+=1;
-	    UE_list->eNB_UE_stats[CC_idP][UE_id].num_bytes_rx[rx_lcids[i]]+=rx_lengths[i];
-	  }
-	  else { /* rx_length[i] */
-	    UE_list->eNB_UE_stats[CC_idP][UE_id].num_errors_rx+=1;
-	    LOG_E(MAC,"[eNB %d] CC_id %d Frame %d : Max size of transport block reached LCID %d from UE %d ",
-		  enb_mod_idP, CC_idP, frameP, rx_lcids[i], UE_id);
-	  }
-	}    
-	else {/*(UE_id != -1*/ 
-	  LOG_E(MAC,"[eNB %d] CC_id %d Frame %d : received unsupported or unknown LCID %d from UE %d ",
-		enb_mod_idP, CC_idP, frameP, rx_lcids[i], UE_id);
-	}
+        LOG_D(MAC,"[eNB %d] CC_id %d Frame %d : ULSCH -> UL-DTCH, received %d bytes from UE %d for lcid %d\n",
+              enb_mod_idP,CC_idP,frameP, rx_lengths[i], UE_id, rx_lcids[i]);
+
+        if (UE_id != -1) {
+          // adjust buffer occupancy of the correponding logical channel group
+          LOG_D(MAC,"[eNB %d] CC_id %d Frame %d : ULSCH -> UL-DTCH, received %d bytes from UE %d for lcid %d, removing from LCGID %ld, %d\n",
+                enb_mod_idP,CC_idP,frameP, rx_lengths[i], UE_id,rx_lcids[i],
+                UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]],
+                UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]]);
+
+          if (UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] >= rx_lengths[i])
+            UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] -= rx_lengths[i];
+          else
+            UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] = 0;
+          if ((rx_lengths[i] <SCH_PAYLOAD_SIZE_MAX) &&  (rx_lengths[i] > 0) ) {   // MAX SIZE OF transport block
+            mac_rlc_data_ind(
+                             enb_mod_idP,
+                             current_rnti,
+                             enb_mod_idP,
+                             frameP,
+                             ENB_FLAG_YES,
+                             MBMS_FLAG_NO,
+                             rx_lcids[i],
+                             (char *)payload_ptr,
+                             rx_lengths[i],
+                             1,
+                             NULL);//(unsigned int*)crc_status);
+
+            UE_list->eNB_UE_stats[CC_idP][UE_id].num_pdu_rx[rx_lcids[i]]+=1;
+            UE_list->eNB_UE_stats[CC_idP][UE_id].num_bytes_rx[rx_lcids[i]]+=rx_lengths[i];
+          }
+          else { /* rx_length[i] */
+            UE_list->eNB_UE_stats[CC_idP][UE_id].num_errors_rx+=1;
+            LOG_E(MAC,"[eNB %d] CC_id %d Frame %d : Max size of transport block reached LCID %d from UE %d ",
+                  enb_mod_idP, CC_idP, frameP, rx_lcids[i], UE_id);
+          }
+        }
+        else {/*(UE_id != -1*/
+          LOG_E(MAC,"[eNB %d] CC_id %d Frame %d : received unsupported or unknown LCID %d from UE %d ",
+                enb_mod_idP, CC_idP, frameP, rx_lcids[i], UE_id);
+        }
       }
 
       break;
     }
-  
+
     payload_ptr+=rx_lengths[i];
   }
 
   // Program ACK for PHICH
-  LOG_D(MAC,"Programming PHICH ACK for rnti %x harq_pid %d (first_rb %d)\n",rntiP,harq_pid,first_rb);
+  LOG_D(MAC,"Programming PHICH ACK for rnti %x harq_pid %d (first_rb %d)\n",current_rnti,harq_pid,first_rb);
   nfapi_hi_dci0_request_body_t   *hi_dci0_req = &eNB->HI_DCI0_req[CC_idP].hi_dci0_request_body;
-  nfapi_hi_dci0_request_pdu_t    *hi_dci0_pdu = &hi_dci0_req->hi_dci0_pdu_list[hi_dci0_req->number_of_dci+hi_dci0_req->number_of_hi]; 	
+  nfapi_hi_dci0_request_pdu_t    *hi_dci0_pdu = &hi_dci0_req->hi_dci0_pdu_list[hi_dci0_req->number_of_dci+hi_dci0_req->number_of_hi];
   memset((void*)hi_dci0_pdu,0,sizeof(nfapi_hi_dci0_request_pdu_t));
-  hi_dci0_pdu->pdu_type                                               = NFAPI_HI_DCI0_HI_PDU_TYPE; 
+  hi_dci0_pdu->pdu_type                                               = NFAPI_HI_DCI0_HI_PDU_TYPE;
   hi_dci0_pdu->pdu_size                                               = 2+sizeof(nfapi_hi_dci0_hi_pdu);
-  hi_dci0_pdu->hi_pdu.hi_pdu_rel8.resource_block_start                = first_rb; 
+  hi_dci0_pdu->hi_pdu.hi_pdu_rel8.resource_block_start                = first_rb;
   hi_dci0_pdu->hi_pdu.hi_pdu_rel8.cyclic_shift_2_for_drms             = 0;
   hi_dci0_pdu->hi_pdu.hi_pdu_rel8.hi_value                            = 1;
   hi_dci0_req->number_of_hi++;
-																	
+
   /* NN--> FK: we could either check the payload, or use a phy helper to detect a false msg3 */
   if ((num_sdu == 0) && (num_ce==0)) {
     if (UE_id != -1)
@@ -595,10 +602,8 @@ abort();
   stop_meas(&eNB->rx_ulsch_sdu);
 }
 
-
 uint32_t bytes_to_bsr_index(int32_t nbytes)
 {
-
   uint32_t i=0;
 
   if (nbytes<0) {
@@ -615,13 +620,11 @@ uint32_t bytes_to_bsr_index(int32_t nbytes)
 
 void add_ue_ulsch_info(module_id_t module_idP, int CC_id, int UE_id, sub_frame_t subframeP, UE_ULSCH_STATUS status)
 {
-
   eNB_ulsch_info[module_idP][CC_id][UE_id].rnti             = UE_RNTI(module_idP,UE_id);
   eNB_ulsch_info[module_idP][CC_id][UE_id].subframe         = subframeP;
   eNB_ulsch_info[module_idP][CC_id][UE_id].status           = status;
 
   eNB_ulsch_info[module_idP][CC_id][UE_id].serving_num++;
-
 }
 
 unsigned char *parse_ulsch_header(unsigned char *mac_header,
@@ -632,7 +635,6 @@ unsigned char *parse_ulsch_header(unsigned char *mac_header,
                                   unsigned short *rx_lengths,
                                   unsigned short tb_length)
 {
-
   unsigned char not_done=1,num_ces=0,num_sdus=0,lcid,num_sdu_cnt;
   unsigned char *mac_header_ptr = mac_header;
   unsigned short length, ce_len=0;
@@ -721,14 +723,10 @@ void set_msg3_subframe(module_id_t Mod_id,
 }
 
 
-void schedule_ulsch(module_id_t module_idP, 
-		    frame_t frameP,
-		    sub_frame_t subframeP) { 
-
-
-
-
-
+void schedule_ulsch(module_id_t module_idP,
+                    frame_t frameP,
+                    sub_frame_t subframeP)
+{
   uint16_t first_rb[MAX_NUM_CCs],i;
   int CC_id;
   eNB_MAC_INST *eNB=RC.mac[module_idP];
@@ -736,7 +734,6 @@ void schedule_ulsch(module_id_t module_idP,
 
   start_meas(&eNB->schedule_ulsch);
 
-
   int sched_subframe = (subframeP+4)%10;
 
   cc = &eNB->common_channels[0];
@@ -747,13 +744,13 @@ void schedule_ulsch(module_id_t module_idP,
     switch (subframeP) {
     case 0:
       if ((tdd_sfa == 0)||
-	  (tdd_sfa == 3)||
-	  (tdd_sfa == 6)) sched_subframe = 4;
+          (tdd_sfa == 3)||
+          (tdd_sfa == 6)) sched_subframe = 4;
       else return;
       break;
     case 1:
       if ((tdd_sfa==0)||
-	  (tdd_sfa==1)) sched_subframe = 7;
+          (tdd_sfa==1)) sched_subframe = 7;
       else if (tdd_sfa==6) sched_subframe = 8;
       break;
     default:
@@ -812,7 +809,7 @@ void schedule_ulsch(module_id_t module_idP,
     // Msg3 is using 1 PRB so we need to increase first_rb accordingly
     // not sure about the break (can there be more than 1 active RA procedure?)
 
-    
+
     for (i=0; i<NB_RA_PROC_MAX; i++) {
       if ((cc->RA_template[i].RA_active == TRUE) &&
           (cc->RA_template[i].generate_rar == 0) &&
@@ -820,7 +817,7 @@ void schedule_ulsch(module_id_t module_idP,
           (cc->RA_template[i].wait_ack_Msg4 == 0) &&
           (cc->RA_template[i].Msg3_subframe == sched_subframe)) {
         first_rb[CC_id]++;
-	//    cc->RA_template[i].Msg3_subframe = -1;
+        //    cc->RA_template[i].Msg3_subframe = -1;
         break;
       }
     }
@@ -829,24 +826,20 @@ void schedule_ulsch(module_id_t module_idP,
   schedule_ulsch_rnti(module_idP, frameP, subframeP, sched_subframe,first_rb);
 
   stop_meas(&eNB->schedule_ulsch);
-
 }
 
-
-
 void schedule_ulsch_rnti(module_id_t   module_idP,
                          frame_t       frameP,
                          sub_frame_t   subframeP,
                          unsigned char sched_subframeP,
                          uint16_t     *first_rb)
 {
-
   int               UE_id;
   uint8_t           aggregation    = 2;
   rnti_t            rnti           = -1;
   uint8_t           round          = 0;
   uint8_t           harq_pid       = 0;
-  uint8_t           status         = 0; 
+  uint8_t           status         = 0;
   uint8_t           rb_table_index = -1;
   uint32_t          cqi_req,cshift,ndi,tpc;
   int32_t           normalized_rx_power;
@@ -872,11 +865,9 @@ void schedule_ulsch_rnti(module_id_t   module_idP,
 
   nfapi_ul_config_request_pdu_t  *ul_config_pdu;
 
-
-
   nfapi_ul_config_request_body_t *ul_req_tmp       = &eNB->UL_req_tmp[CC_id][sched_subframeP].ul_config_request_body;
 
-  ul_config_pdu                                    = &ul_req_tmp->ul_config_pdu_list[0]; 
+  ul_config_pdu                                    = &ul_req_tmp->ul_config_pdu_list[0];
 
 
   LOG_D(MAC,"entering ulsch preprocesor\n");
@@ -889,14 +880,13 @@ void schedule_ulsch_rnti(module_id_t   module_idP,
 
   eNB->HI_DCI0_req[CC_id].sfn_sf = (frameP<<4)+subframeP;
 
-
   // loop over all active UEs
   for (UE_id=UE_list->head_ul; UE_id>=0; UE_id=UE_list->next_ul[UE_id]) {
 
     // don't schedule if Msg4 is not received yet
     if (UE_list->UE_template[UE_PCCID(module_idP,UE_id)][UE_id].configured==FALSE) {
-      LOG_D(MAC,"[eNB %d] frame %d subfarme %d, UE %d: not configured, skipping UE scheduling \n", 
-	    module_idP,frameP,subframeP,UE_id);
+      LOG_D(MAC,"[eNB %d] frame %d subfarme %d, UE %d: not configured, skipping UE scheduling \n",
+            module_idP,frameP,subframeP,UE_id);
       continue;
     }
 
@@ -909,11 +899,11 @@ void schedule_ulsch_rnti(module_id_t   module_idP,
 
     drop_ue = 0;
     /* let's drop the UE if get_eNB_UE_stats returns NULL when calling it with any of the UE's active UL CCs */
-    /* TODO: refine? 
+    /* TODO: refine?
 
     for (n=0; n<UE_list->numactiveULCCs[UE_id]; n++) {
       CC_id = UE_list->ordered_ULCCids[n][UE_id];
-      
+
       if (mac_xface->get_eNB_UE_stats(module_idP,CC_id,rnti) == NULL) {
         LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d: no PHY context\n", module_idP,frameP,subframeP,UE_id,rnti,CC_id);
         drop_ue = 1;
@@ -949,25 +939,23 @@ abort();
       N_RB_UL      = to_prb(cc[CC_id].ul_Bandwidth);
 
       /*
-      aggregation=get_aggregation(get_bw_index(module_idP,CC_id), 
-				  eNB_UE_stats->dl_cqi,
-				  format0);
+      aggregation=get_aggregation(get_bw_index(module_idP,CC_id),
+                                  eNB_UE_stats->dl_cqi,
+                                  format0);
       */
 
       if (CCE_allocation_infeasible(module_idP,CC_id,1,subframeP,aggregation,rnti)) {
         LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d: not enough nCCE\n", module_idP,frameP,subframeP,UE_id,rnti,CC_id);
         continue; // break;
-      } 
+      }
 
       /* be sure that there are some free RBs */
       if (first_rb[CC_id] >= N_RB_UL-1) {
-	LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d: dropping, not enough RBs\n",
-	      module_idP,frameP,subframeP,UE_id,rnti,CC_id);
+        LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d: dropping, not enough RBs\n",
+              module_idP,frameP,subframeP,UE_id,rnti,CC_id);
         continue;
       }
 
-
-
       //      if (eNB_UE_stats->mode == PUSCH) { // ue has a ulsch channel
 
       UE_template   = &UE_list->UE_template[CC_id][UE_id];
@@ -975,261 +963,255 @@ abort();
       harq_pid      = subframe2harqpid(&cc[CC_id],sched_frame,sched_subframeP);
       round         = UE_sched_ctrl->round_UL[CC_id][harq_pid];
       AssertFatal(round<8,"round %d > 7 for UE %d/%x\n",round,UE_id,rnti);
-      LOG_D(MAC,"[eNB %d] frame %d subframe %d,Checking PUSCH %d for UE %d/%x CC %d : aggregation level %d, N_RB_UL %d\n", 
-	    module_idP,frameP,subframeP,harq_pid,UE_id,rnti,CC_id, aggregation,N_RB_UL);
+      LOG_D(MAC,"[eNB %d] frame %d subframe %d,Checking PUSCH %d for UE %d/%x CC %d : aggregation level %d, N_RB_UL %d\n",
+            module_idP,frameP,subframeP,harq_pid,UE_id,rnti,CC_id, aggregation,N_RB_UL);
 
       RC.eNB[module_idP][CC_id]->pusch_stats_BO[UE_id][(frameP*10)+subframeP] = UE_template->ul_total_buffer;
-      VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_BO,RC.eNB[module_idP][CC_id]->pusch_stats_BO[UE_id][(frameP*10)+subframeP]);	
+      VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_BO,RC.eNB[module_idP][CC_id]->pusch_stats_BO[UE_id][(frameP*10)+subframeP]);
       if (UE_is_to_be_scheduled(module_idP,CC_id,UE_id) > 0 || round > 0)// || ((frameP%10)==0))
-	// if there is information on bsr of DCCH, DTCH or if there is UL_SR, or if there is a packet to retransmit, or we want to schedule a periodic feedback every 10 frames
+        // if there is information on bsr of DCCH, DTCH or if there is UL_SR, or if there is a packet to retransmit, or we want to schedule a periodic feedback every 10 frames
         {
-	  LOG_D(MAC,"[eNB %d][PUSCH %d] Frame %d subframe %d Scheduling UE %d/%x in round %d(SR %d,UL_inactivity timer %d,UL_failure timer %d,cqi_req_timer %d)\n",
-		module_idP,harq_pid,frameP,subframeP,UE_id,rnti,round,UE_template->ul_SR,
-		UE_sched_ctrl->ul_inactivity_timer,
+          LOG_D(MAC,"[eNB %d][PUSCH %d] Frame %d subframe %d Scheduling UE %d/%x in round %d(SR %d,UL_inactivity timer %d,UL_failure timer %d,cqi_req_timer %d)\n",
+                module_idP,harq_pid,frameP,subframeP,UE_id,rnti,round,UE_template->ul_SR,
+                UE_sched_ctrl->ul_inactivity_timer,
 
-		UE_sched_ctrl->ul_failure_timer,
+                UE_sched_ctrl->ul_failure_timer,
 
-		UE_sched_ctrl->cqi_req_timer);
+                UE_sched_ctrl->cqi_req_timer);
           // reset the scheduling request
           UE_template->ul_SR = 0;
           status = mac_eNB_get_rrc_status(module_idP,rnti);
-	  if (status < RRC_CONNECTED)
-	    cqi_req = 0;
-	  else if (UE_sched_ctrl->cqi_req_timer>30) {
-	    cqi_req = 1;
-	    UE_sched_ctrl->cqi_req_timer=0;
-	  }
-	  else
-	    cqi_req = 0;
-	  
+          if (status < RRC_CONNECTED)
+            cqi_req = 0;
+          else if (UE_sched_ctrl->cqi_req_timer>30) {
+            cqi_req = 1;
+            UE_sched_ctrl->cqi_req_timer=0;
+          }
+          else
+            cqi_req = 0;
 
           //power control
           //compute the expected ULSCH RX power (for the stats)
-	  
+
           // this is the normalized RX power and this should be constant (regardless of mcs
           normalized_rx_power = UE_sched_ctrl->pusch_snr[CC_id];
-          target_rx_power = 200;
-	  
+          target_rx_power = 178;
+
           // this assumes accumulated tpc
-	  // make sure that we are only sending a tpc update once a frame, otherwise the control loop will freak out
-	  int32_t framex10psubframe = UE_template->pusch_tpc_tx_frame*10+UE_template->pusch_tpc_tx_subframe;
+          // make sure that we are only sending a tpc update once a frame, otherwise the control loop will freak out
+          int32_t framex10psubframe = UE_template->pusch_tpc_tx_frame*10+UE_template->pusch_tpc_tx_subframe;
           if (((framex10psubframe+10)<=(frameP*10+subframeP)) || //normal case
-	      ((framex10psubframe>(frameP*10+subframeP)) && (((10240-framex10psubframe+frameP*10+subframeP)>=10)))) //frame wrap-around
-	    {
-	      UE_template->pusch_tpc_tx_frame=frameP;
-	      UE_template->pusch_tpc_tx_subframe=subframeP;
-	      if (normalized_rx_power>(target_rx_power+1)) {
-		tpc = 0; //-1
-		tpc_accumulated--;
-	      } else if (normalized_rx_power<(target_rx_power-1)) {
-		tpc = 2; //+1
-		tpc_accumulated++;
-	      } else {
-		tpc = 1; //0
-	      }
-	    } else {
+              ((framex10psubframe>(frameP*10+subframeP)) && (((10240-framex10psubframe+frameP*10+subframeP)>=10)))) //frame wrap-around
+            {
+              UE_template->pusch_tpc_tx_frame=frameP;
+              UE_template->pusch_tpc_tx_subframe=subframeP;
+              if (normalized_rx_power>(target_rx_power+4)) {
+                tpc = 0; //-1
+                tpc_accumulated--;
+              } else if (normalized_rx_power<(target_rx_power-4)) {
+                tpc = 2; //+1
+                tpc_accumulated++;
+              } else {
+                tpc = 1; //0
+              }
+            } else {
             tpc = 1; //0
           }
-	  //tpc = 1;
-	  if (tpc!=1) {
-	    LOG_D(MAC,"[eNB %d] ULSCH scheduler: frame %d, subframe %d, harq_pid %d, tpc %d, accumulated %d, normalized/target rx power %d/%d\n",
-		  module_idP,frameP,subframeP,harq_pid,tpc,
-		  tpc_accumulated,normalized_rx_power,target_rx_power);
-	  }
-	  
+          //tpc = 1;
+          if (tpc!=1) {
+            LOG_D(MAC,"[eNB %d] ULSCH scheduler: frame %d, subframe %d, harq_pid %d, tpc %d, accumulated %d, normalized/target rx power %d/%d\n",
+                  module_idP,frameP,subframeP,harq_pid,tpc,
+                  tpc_accumulated,normalized_rx_power,target_rx_power);
+          }
+
           // new transmission
           if (round==0) {
-	    
+
             ndi = 1-UE_template->oldNDI_UL[harq_pid];
             UE_template->oldNDI_UL[harq_pid]=ndi;
-	    UE_list->eNB_UE_stats[CC_id][UE_id].normalized_rx_power=normalized_rx_power;
-	    UE_list->eNB_UE_stats[CC_id][UE_id].target_rx_power=target_rx_power;
-	    UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs1=UE_template->pre_assigned_mcs_ul;
+            UE_list->eNB_UE_stats[CC_id][UE_id].normalized_rx_power=normalized_rx_power;
+            UE_list->eNB_UE_stats[CC_id][UE_id].target_rx_power=target_rx_power;
+            UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs1=UE_template->pre_assigned_mcs_ul;
             UE_template->mcs_UL[harq_pid] = UE_template->pre_assigned_mcs_ul;//cmin (UE_template->pre_assigned_mcs_ul, openair_daq_vars.target_ue_ul_mcs); // adjust, based on user-defined MCS
             if (UE_template->pre_allocated_rb_table_index_ul >=0) {
               rb_table_index=UE_template->pre_allocated_rb_table_index_ul;
             } else {
-	      UE_template->mcs_UL[harq_pid]=10;//cmin (10, openair_daq_vars.target_ue_ul_mcs);
+              UE_template->mcs_UL[harq_pid]=10;//cmin (10, openair_daq_vars.target_ue_ul_mcs);
               rb_table_index=5; // for PHR
-	    }
-	    
+            }
+
             UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs2=UE_template->mcs_UL[harq_pid];
-	    //            buffer_occupancy = UE_template->ul_total_buffer;
+            //            buffer_occupancy = UE_template->ul_total_buffer;
+
 
-	    
             while (((rb_table[rb_table_index]>(N_RB_UL-1-first_rb[CC_id])) ||
-		    (rb_table[rb_table_index]>45)) &&
+                    (rb_table[rb_table_index]>45)) &&
                    (rb_table_index>0)) {
               rb_table_index--;
             }
-	    
+
             UE_template->TBS_UL[harq_pid] = get_TBS_UL(UE_template->mcs_UL[harq_pid],rb_table[rb_table_index]);
-	    UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used_rx+=rb_table[rb_table_index];
-	    UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_TBS=UE_template->TBS_UL[harq_pid];
-	    //            buffer_occupancy -= TBS;
-            	    
+            UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used_rx+=rb_table[rb_table_index];
+            UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_TBS=UE_template->TBS_UL[harq_pid];
+            //            buffer_occupancy -= TBS;
+
             T(T_ENB_MAC_UE_UL_SCHEDULE, T_INT(module_idP), T_INT(CC_id), T_INT(rnti), T_INT(frameP),
               T_INT(subframeP), T_INT(harq_pid), T_INT(UE_template->mcs_UL[harq_pid]), T_INT(first_rb[CC_id]), T_INT(rb_table[rb_table_index]),
               T_INT(UE_template->TBS_UL[harq_pid]), T_INT(ndi));
-	    
-	    if (mac_eNB_get_rrc_status(module_idP,rnti) < RRC_CONNECTED)
-	      LOG_D(MAC,"[eNB %d][PUSCH %d/%x] CC_id %d Frame %d subframeP %d Scheduled UE %d (mcs %d, first rb %d, nb_rb %d, rb_table_index %d, TBS %d, harq_pid %d)\n",
-		    module_idP,harq_pid,rnti,CC_id,frameP,subframeP,UE_id,UE_template->mcs_UL[harq_pid],
-		    first_rb[CC_id],rb_table[rb_table_index],
-		    rb_table_index,UE_template->TBS_UL[harq_pid],harq_pid);
-	    
-	    // bad indices : 20 (40 PRB), 21 (45 PRB), 22 (48 PRB)
+
+            if (mac_eNB_get_rrc_status(module_idP,rnti) < RRC_CONNECTED)
+              LOG_D(MAC,"[eNB %d][PUSCH %d/%x] CC_id %d Frame %d subframeP %d Scheduled UE %d (mcs %d, first rb %d, nb_rb %d, rb_table_index %d, TBS %d, harq_pid %d)\n",
+                    module_idP,harq_pid,rnti,CC_id,frameP,subframeP,UE_id,UE_template->mcs_UL[harq_pid],
+                    first_rb[CC_id],rb_table[rb_table_index],
+                    rb_table_index,UE_template->TBS_UL[harq_pid],harq_pid);
+
+            // bad indices : 20 (40 PRB), 21 (45 PRB), 22 (48 PRB)
             //store for possible retransmission
             UE_template->nb_rb_ul[harq_pid]    = rb_table[rb_table_index];
             UE_template->first_rb_ul[harq_pid] = first_rb[CC_id];
-	    
-	    UE_sched_ctrl->ul_scheduled |= (1<<harq_pid);
-	    if (UE_id == UE_list->head)
-	      VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_SCHEDULED,UE_sched_ctrl->ul_scheduled);
-	    
-	    // adjust total UL buffer status by TBS, wait for UL sdus to do final update
-	    LOG_D(MAC,"[eNB %d] CC_id %d UE %d/%x : adjusting ul_total_buffer, old %d, TBS %d\n", module_idP,CC_id,UE_id,rnti,UE_template->ul_total_buffer,UE_template->TBS_UL[harq_pid]);
-	    if (UE_template->ul_total_buffer > UE_template->TBS_UL[harq_pid])
-	      UE_template->ul_total_buffer -= UE_template->TBS_UL[harq_pid];
-	    else
-	      UE_template->ul_total_buffer = 0;
-	    LOG_D(MAC,"ul_total_buffer, new %d\n", UE_template->ul_total_buffer);
-	    // Cyclic shift for DM RS
-	    cshift = 0;// values from 0 to 7 can be used for mapping the cyclic shift (36.211 , Table 5.5.2.1.1-1)
-	    // save it for a potential retransmission
-            UE_template->cshift[harq_pid] = cshift;	    
-
-	    hi_dci0_pdu                                                         = &hi_dci0_req->hi_dci0_pdu_list[eNB->HI_DCI0_req[CC_id].hi_dci0_request_body.number_of_dci+eNB->HI_DCI0_req[CC_id].hi_dci0_request_body.number_of_hi]; 	
-	    memset((void*)hi_dci0_pdu,0,sizeof(nfapi_hi_dci0_request_pdu_t));
-	    hi_dci0_pdu->pdu_type                                               = NFAPI_HI_DCI0_DCI_PDU_TYPE; 
-	    hi_dci0_pdu->pdu_size                                               = 2+sizeof(nfapi_hi_dci0_dci_pdu);
-	    hi_dci0_pdu->dci_pdu.dci_pdu_rel8.dci_format                        = NFAPI_UL_DCI_FORMAT_0;
-	    hi_dci0_pdu->dci_pdu.dci_pdu_rel8.aggregation_level                 = aggregation;
-	    hi_dci0_pdu->dci_pdu.dci_pdu_rel8.rnti                              = rnti;
-	    hi_dci0_pdu->dci_pdu.dci_pdu_rel8.transmission_power                = 6000;
-	    hi_dci0_pdu->dci_pdu.dci_pdu_rel8.resource_block_start              = first_rb[CC_id];
-	    hi_dci0_pdu->dci_pdu.dci_pdu_rel8.number_of_resource_block          = rb_table[rb_table_index];
-	    hi_dci0_pdu->dci_pdu.dci_pdu_rel8.mcs_1                             = UE_template->mcs_UL[harq_pid];
-	    hi_dci0_pdu->dci_pdu.dci_pdu_rel8.cyclic_shift_2_for_drms           = cshift;
-	    hi_dci0_pdu->dci_pdu.dci_pdu_rel8.frequency_hopping_enabled_flag    = 0;
-	    hi_dci0_pdu->dci_pdu.dci_pdu_rel8.new_data_indication_1             = ndi;
-	    hi_dci0_pdu->dci_pdu.dci_pdu_rel8.tpc                               = tpc;
-	    hi_dci0_pdu->dci_pdu.dci_pdu_rel8.cqi_csi_request                   = cqi_req;
-	    hi_dci0_pdu->dci_pdu.dci_pdu_rel8.dl_assignment_index               = UE_template->DAI_ul[sched_subframeP];
-
-	    
-	    eNB->HI_DCI0_req[CC_id].hi_dci0_request_body.number_of_dci++;
-	    
-	    LOG_D(MAC,"[PUSCH %d] Frame %d, Subframe %d: Adding UL CONFIG.Request for UE %d/%x, ulsch_frame %d, ulsch_subframe %d\n",
-		  harq_pid,frameP,subframeP,UE_id,rnti,sched_frame,sched_subframeP);
-	    
-	    // Add UL_config PDUs
-	    fill_nfapi_ulsch_config_request_rel8(&ul_req_tmp->ul_config_pdu_list[ul_req_tmp->number_of_pdus],
-						 cqi_req,
-						 cc,
-						 UE_template->physicalConfigDedicated,
-						 get_tmode(module_idP,CC_id,UE_id),
-						 eNB->ul_handle,
-						 rnti,
-						 first_rb[CC_id], // resource_block_start
-						 rb_table[rb_table_index], // number_of_resource_blocks
-						 UE_template->mcs_UL[harq_pid],
-						 cshift, // cyclic_shift_2_for_drms
-						 0, // frequency_hopping_enabled_flag
-						 0, // frequency_hopping_bits
-						 ndi, // new_data_indication
-						 0, // redundancy_version
-						 harq_pid, // harq_process_number
-						 0, // ul_tx_mode
-						 0, // current_tx_nb
-						 0, // n_srs
-						 get_TBS_UL(UE_template->mcs_UL[harq_pid],
-							    rb_table[rb_table_index])
-						 );
+
+            UE_sched_ctrl->ul_scheduled |= (1<<harq_pid);
+            if (UE_id == UE_list->head)
+              VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_SCHEDULED,UE_sched_ctrl->ul_scheduled);
+
+            // adjust total UL buffer status by TBS, wait for UL sdus to do final update
+            LOG_D(MAC,"[eNB %d] CC_id %d UE %d/%x : adjusting ul_total_buffer, old %d, TBS %d\n", module_idP,CC_id,UE_id,rnti,UE_template->ul_total_buffer,UE_template->TBS_UL[harq_pid]);
+            if (UE_template->ul_total_buffer > UE_template->TBS_UL[harq_pid])
+              UE_template->ul_total_buffer -= UE_template->TBS_UL[harq_pid];
+            else
+              UE_template->ul_total_buffer = 0;
+            LOG_D(MAC,"ul_total_buffer, new %d\n", UE_template->ul_total_buffer);
+            // Cyclic shift for DM RS
+            cshift = 0;// values from 0 to 7 can be used for mapping the cyclic shift (36.211 , Table 5.5.2.1.1-1)
+            // save it for a potential retransmission
+            UE_template->cshift[harq_pid] = cshift;
+
+            hi_dci0_pdu                                                         = &hi_dci0_req->hi_dci0_pdu_list[eNB->HI_DCI0_req[CC_id].hi_dci0_request_body.number_of_dci+eNB->HI_DCI0_req[CC_id].hi_dci0_request_body.number_of_hi];
+            memset((void*)hi_dci0_pdu,0,sizeof(nfapi_hi_dci0_request_pdu_t));
+            hi_dci0_pdu->pdu_type                                               = NFAPI_HI_DCI0_DCI_PDU_TYPE;
+            hi_dci0_pdu->pdu_size                                               = 2+sizeof(nfapi_hi_dci0_dci_pdu);
+            hi_dci0_pdu->dci_pdu.dci_pdu_rel8.dci_format                        = NFAPI_UL_DCI_FORMAT_0;
+            hi_dci0_pdu->dci_pdu.dci_pdu_rel8.aggregation_level                 = aggregation;
+            hi_dci0_pdu->dci_pdu.dci_pdu_rel8.rnti                              = rnti;
+            hi_dci0_pdu->dci_pdu.dci_pdu_rel8.transmission_power                = 6000;
+            hi_dci0_pdu->dci_pdu.dci_pdu_rel8.resource_block_start              = first_rb[CC_id];
+            hi_dci0_pdu->dci_pdu.dci_pdu_rel8.number_of_resource_block          = rb_table[rb_table_index];
+            hi_dci0_pdu->dci_pdu.dci_pdu_rel8.mcs_1                             = UE_template->mcs_UL[harq_pid];
+            hi_dci0_pdu->dci_pdu.dci_pdu_rel8.cyclic_shift_2_for_drms           = cshift;
+            hi_dci0_pdu->dci_pdu.dci_pdu_rel8.frequency_hopping_enabled_flag    = 0;
+            hi_dci0_pdu->dci_pdu.dci_pdu_rel8.new_data_indication_1             = ndi;
+            hi_dci0_pdu->dci_pdu.dci_pdu_rel8.tpc                               = tpc;
+            hi_dci0_pdu->dci_pdu.dci_pdu_rel8.cqi_csi_request                   = cqi_req;
+            hi_dci0_pdu->dci_pdu.dci_pdu_rel8.dl_assignment_index               = UE_template->DAI_ul[sched_subframeP];
+
+            eNB->HI_DCI0_req[CC_id].hi_dci0_request_body.number_of_dci++;
+
+            LOG_D(MAC,"[PUSCH %d] Frame %d, Subframe %d: Adding UL CONFIG.Request for UE %d/%x, ulsch_frame %d, ulsch_subframe %d\n",
+                  harq_pid,frameP,subframeP,UE_id,rnti,sched_frame,sched_subframeP);
+
+            // Add UL_config PDUs
+            fill_nfapi_ulsch_config_request_rel8(&ul_req_tmp->ul_config_pdu_list[ul_req_tmp->number_of_pdus],
+                                                 cqi_req,
+                                                 cc,
+                                                 UE_template->physicalConfigDedicated,
+                                                 get_tmode(module_idP,CC_id,UE_id),
+                                                 eNB->ul_handle,
+                                                 rnti,
+                                                 first_rb[CC_id], // resource_block_start
+                                                 rb_table[rb_table_index], // number_of_resource_blocks
+                                                 UE_template->mcs_UL[harq_pid],
+                                                 cshift, // cyclic_shift_2_for_drms
+                                                 0, // frequency_hopping_enabled_flag
+                                                 0, // frequency_hopping_bits
+                                                 ndi, // new_data_indication
+                                                 0, // redundancy_version
+                                                 harq_pid, // harq_process_number
+                                                 0, // ul_tx_mode
+                                                 0, // current_tx_nb
+                                                 0, // n_srs
+                                                 get_TBS_UL(UE_template->mcs_UL[harq_pid],
+                                                            rb_table[rb_table_index])
+                                                 );
 #ifdef Rel14
-	    if (UE_template->rach_resource_type>0) { // This is a BL/CE UE allocation
-	      fill_nfapi_ulsch_config_request_emtc(&ul_req_tmp->ul_config_pdu_list[ul_req_tmp->number_of_pdus],
-						   UE_template->rach_resource_type>2 ? 2 : 1,
-						   1, //total_number_of_repetitions
-						   1, //repetition_number
-						   (frameP*10)+subframeP);
-	    }
+            if (UE_template->rach_resource_type>0) { // This is a BL/CE UE allocation
+              fill_nfapi_ulsch_config_request_emtc(&ul_req_tmp->ul_config_pdu_list[ul_req_tmp->number_of_pdus],
+                                                   UE_template->rach_resource_type>2 ? 2 : 1,
+                                                   1, //total_number_of_repetitions
+                                                   1, //repetition_number
+                                                   (frameP*10)+subframeP);
+            }
 #endif
-	    ul_req_tmp->number_of_pdus++;
-	    eNB->ul_handle++;
-	    
-	    
-	  	
-	    add_ue_ulsch_info(module_idP,
-			      CC_id,
-			      UE_id,
-			      subframeP,
-			      S_UL_SCHEDULED);
-	    
-	    LOG_D(MAC,"[eNB %d] CC_id %d Frame %d, subframeP %d: Generated ULSCH DCI for next UE_id %d, format 0\n", module_idP,CC_id,frameP,subframeP,UE_id);
+            ul_req_tmp->number_of_pdus++;
+            eNB->ul_handle++;
+
+            add_ue_ulsch_info(module_idP,
+                              CC_id,
+                              UE_id,
+                              subframeP,
+                              S_UL_SCHEDULED);
 
+            LOG_D(MAC,"[eNB %d] CC_id %d Frame %d, subframeP %d: Generated ULSCH DCI for next UE_id %d, format 0\n", module_idP,CC_id,frameP,subframeP,UE_id);
 
             // increment first rb for next UE allocation
             first_rb[CC_id]+=rb_table[rb_table_index];
-	    
-	  }
-	  else { // round > 0 => retransmission
+          }
+          else { // round > 0 => retransmission
             T(T_ENB_MAC_UE_UL_SCHEDULE_RETRANSMISSION, T_INT(module_idP), T_INT(CC_id), T_INT(rnti), T_INT(frameP),
               T_INT(subframeP), T_INT(harq_pid), T_INT(UE_template->mcs_UL[harq_pid]), T_INT(first_rb[CC_id]), T_INT(rb_table[rb_table_index]),
               T_INT(round));
 
-	    // fill in NAK information
-	    
-	    hi_dci0_pdu                                                         = &hi_dci0_req->hi_dci0_pdu_list[hi_dci0_req->number_of_dci+hi_dci0_req->number_of_hi]; 	
-	    memset((void*)hi_dci0_pdu,0,sizeof(nfapi_hi_dci0_request_pdu_t));
-	    hi_dci0_pdu->pdu_type                                               = NFAPI_HI_DCI0_HI_PDU_TYPE; 
-	    hi_dci0_pdu->pdu_size                                               = 2+sizeof(nfapi_hi_dci0_hi_pdu);
-	    hi_dci0_pdu->hi_pdu.hi_pdu_rel8.resource_block_start                = UE_template->first_rb_ul[harq_pid];
-	    hi_dci0_pdu->hi_pdu.hi_pdu_rel8.cyclic_shift_2_for_drms             = UE_template->cshift[harq_pid];
-	    hi_dci0_pdu->hi_pdu.hi_pdu_rel8.hi_value                            = 0;
-	    hi_dci0_req->number_of_hi++;
+            // fill in NAK information
+
+            hi_dci0_pdu                                                         = &hi_dci0_req->hi_dci0_pdu_list[hi_dci0_req->number_of_dci+hi_dci0_req->number_of_hi];
+            memset((void*)hi_dci0_pdu,0,sizeof(nfapi_hi_dci0_request_pdu_t));
+            hi_dci0_pdu->pdu_type                                               = NFAPI_HI_DCI0_HI_PDU_TYPE;
+            hi_dci0_pdu->pdu_size                                               = 2+sizeof(nfapi_hi_dci0_hi_pdu);
+            hi_dci0_pdu->hi_pdu.hi_pdu_rel8.resource_block_start                = UE_template->first_rb_ul[harq_pid];
+            hi_dci0_pdu->hi_pdu.hi_pdu_rel8.cyclic_shift_2_for_drms             = UE_template->cshift[harq_pid];
+            hi_dci0_pdu->hi_pdu.hi_pdu_rel8.hi_value                            = 0;
+            hi_dci0_req->number_of_hi++;
             LOG_D(MAC,"[eNB %d][PUSCH %d/%x] CC_id %d Frame %d subframeP %d Scheduled (PHICH) UE %d (mcs %d, first rb %d, nb_rb %d, TBS %d, round %d)\n",
                   module_idP,harq_pid,rnti,CC_id,frameP,subframeP,UE_id,UE_template->mcs_UL[harq_pid],
                   UE_template->first_rb_ul[harq_pid], UE_template->nb_rb_ul[harq_pid],
                   UE_template->TBS_UL[harq_pid],round);
-	    // Add UL_config PDUs
-	    LOG_D(MAC,"[PUSCH %d] Frame %d, Subframe %d: Adding UL CONFIG.Request for UE %d/%x, ulsch_frame %d, ulsch_subframe %d\n",
-		  harq_pid,frameP,subframeP,UE_id,rnti,sched_frame,sched_subframeP);
-	    fill_nfapi_ulsch_config_request_rel8(&ul_req_tmp->ul_config_pdu_list[ul_req_tmp->number_of_pdus],
-						 cqi_req,
-						 cc,
-						 UE_template->physicalConfigDedicated,
-						 get_tmode(module_idP,CC_id,UE_id),
-						 eNB->ul_handle,
-						 rnti,
-						 UE_template->first_rb_ul[harq_pid], // resource_block_start
-						 UE_template->nb_rb_ul[harq_pid], // number_of_resource_blocks
-						 UE_template->mcs_UL[harq_pid],
-						 cshift, // cyclic_shift_2_for_drms
-						 0, // frequency_hopping_enabled_flag
-						 0, // frequency_hopping_bits
-						 UE_template->oldNDI_UL[harq_pid], // new_data_indication
-						 rvidx_tab[round&3], // redundancy_version
-						 harq_pid, // harq_process_number
-						 0, // ul_tx_mode
-						 0, // current_tx_nb
-						 0, // n_srs
-						 UE_template->TBS_UL[harq_pid]
-						 );
+            // Add UL_config PDUs
+            LOG_D(MAC,"[PUSCH %d] Frame %d, Subframe %d: Adding UL CONFIG.Request for UE %d/%x, ulsch_frame %d, ulsch_subframe %d\n",
+                  harq_pid,frameP,subframeP,UE_id,rnti,sched_frame,sched_subframeP);
+            fill_nfapi_ulsch_config_request_rel8(&ul_req_tmp->ul_config_pdu_list[ul_req_tmp->number_of_pdus],
+                                                 cqi_req,
+                                                 cc,
+                                                 UE_template->physicalConfigDedicated,
+                                                 get_tmode(module_idP,CC_id,UE_id),
+                                                 eNB->ul_handle,
+                                                 rnti,
+                                                 UE_template->first_rb_ul[harq_pid], // resource_block_start
+                                                 UE_template->nb_rb_ul[harq_pid], // number_of_resource_blocks
+                                                 UE_template->mcs_UL[harq_pid],
+                                                 cshift, // cyclic_shift_2_for_drms
+                                                 0, // frequency_hopping_enabled_flag
+                                                 0, // frequency_hopping_bits
+                                                 UE_template->oldNDI_UL[harq_pid], // new_data_indication
+                                                 rvidx_tab[round&3], // redundancy_version
+                                                 harq_pid, // harq_process_number
+                                                 0, // ul_tx_mode
+                                                 0, // current_tx_nb
+                                                 0, // n_srs
+                                                 UE_template->TBS_UL[harq_pid]
+                                                 );
 #ifdef Rel14
-	    if (UE_template->rach_resource_type>0) { // This is a BL/CE UE allocation
-	      fill_nfapi_ulsch_config_request_emtc(&ul_req_tmp->ul_config_pdu_list[ul_req_tmp->number_of_pdus],
-						   UE_template->rach_resource_type>2 ? 2 : 1,
-						   1, //total_number_of_repetitions
-						   1, //repetition_number
-						   (frameP*10)+subframeP);
-	    }
+            if (UE_template->rach_resource_type>0) { // This is a BL/CE UE allocation
+              fill_nfapi_ulsch_config_request_emtc(&ul_req_tmp->ul_config_pdu_list[ul_req_tmp->number_of_pdus],
+                                                   UE_template->rach_resource_type>2 ? 2 : 1,
+                                                   1, //total_number_of_repetitions
+                                                   1, //repetition_number
+                                                   (frameP*10)+subframeP);
+            }
 #endif
-	      ul_req_tmp->number_of_pdus++;
-	      eNB->ul_handle++;
+              ul_req_tmp->number_of_pdus++;
+              eNB->ul_handle++;
 
-	  }/* 
-	  else if (round > 0) { //we schedule a retransmission
+          }/*
+          else if (round > 0) { //we schedule a retransmission
 
             ndi = UE_template->oldNDI_UL[harq_pid];
 
@@ -1243,23 +1225,22 @@ abort();
             LOG_I(MAC,"[eNB %d][PUSCH %d/%x] CC_id %d Frame %d subframeP %d Scheduled UE retransmission (mcs %d, first rb %d, nb_rb %d, harq_pid %d, round %d)\n",
                   module_idP,UE_id,rnti,CC_id,frameP,subframeP,mcs,
                   first_rb[CC_id],UE_template->nb_rb_ul[harq_pid],
-		  harq_pid, round);
+                  harq_pid, round);
 
             rballoc = mac_xface->computeRIV(frame_parms->N_RB_UL,
                                             first_rb[CC_id],
                                             UE_template->nb_rb_ul[harq_pid]);
             first_rb[CC_id]+=UE_template->nb_rb_ul[harq_pid];  // increment for next UE allocation
-         
-	    UE_list->eNB_UE_stats[CC_id][UE_id].num_retransmission_rx+=1;
-	    UE_list->eNB_UE_stats[CC_id][UE_id].rbs_used_retx_rx=UE_template->nb_rb_ul[harq_pid];
-	    UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used_rx+=UE_template->nb_rb_ul[harq_pid];
-	    UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs1=mcs;
-	    UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs2=mcs;
-	  }
-	   */
-	  
+
+            UE_list->eNB_UE_stats[CC_id][UE_id].num_retransmission_rx+=1;
+            UE_list->eNB_UE_stats[CC_id][UE_id].rbs_used_retx_rx=UE_template->nb_rb_ul[harq_pid];
+            UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used_rx+=UE_template->nb_rb_ul[harq_pid];
+            UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs1=mcs;
+            UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs2=mcs;
+          }
+           */
+
         } // UE_is_to_be_scheduled
     } // loop over UE_id
   } // loop of CC_id
 }
-
diff --git a/openair2/PHY_INTERFACE/IF_Module.c b/openair2/PHY_INTERFACE/IF_Module.c
index 0fa5453fe3ff56753b8802a4103b927a1e1d8fe5..b1014e8bde4305bbda989435bd456e0bec63daeb 100644
--- a/openair2/PHY_INTERFACE/IF_Module.c
+++ b/openair2/PHY_INTERFACE/IF_Module.c
@@ -366,6 +366,14 @@ static void dump_dl(Sched_Rsp_t *d)
   A("XXXX up          tpc_bitmap           %d\n", q->tpc_bitmap);
   A("XXXX up          transmission_power   %d\n", q->transmission_power);
           }
+          if (p->pdu_type == NFAPI_HI_DCI0_HI_PDU_TYPE) {
+            nfapi_hi_dci0_hi_pdu_rel8_t *q = &p->hi_pdu.hi_pdu_rel8;
+  A("XXXX up          rb start    %d\n", q->resource_block_start);
+  A("XXXX up          cs2_drms    %d\n", q->cyclic_shift_2_for_drms);
+  A("XXXX up          ack         %d\n", q->hi_value);
+  A("XXXX up          i_phich     %d\n", q->i_phich);
+  A("XXXX up          power       %d\n", q->transmission_power);
+          }
         }
       }
 
diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210.conf
index 2e7e56589cec2b02c386827fa91b2eca52a71ecb..ff302811e9d7eb89baab3b2648e7d8766f966090 100644
--- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210.conf
+++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210.conf
@@ -50,7 +50,7 @@ eNBs =
       prach_zero_correlation  			      = 1;
       prach_freq_offset       			      = 2;
       pucch_delta_shift       			      = 1;
-      pucch_nRB_CQI           			      = 1;
+      pucch_nRB_CQI           			      = 0;
       pucch_nCS_AN            			      = 0;
       pucch_n1_AN             			      = 32;
       pdsch_referenceSignalPower 			      = -27;
diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.50PRB.nfapi.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.50PRB.nfapi.conf
index 1e2cd126168553bad3d65b67b331a063a90da2d7..c9102b9b08546c383d0324fbb20c1a1d1c571ef0 100644
--- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.50PRB.nfapi.conf
+++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.50PRB.nfapi.conf
@@ -50,7 +50,7 @@ eNBs =
       prach_zero_correlation  			      = 1;
       prach_freq_offset       			      = 2;
       pucch_delta_shift       			      = 1;
-      pucch_nRB_CQI           			      = 1;
+      pucch_nRB_CQI           			      = 0;
       pucch_nCS_AN            			      = 0;
       pucch_n1_AN             			      = 32;
       pdsch_referenceSignalPower 			      = -27;
diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.conf
index c3c9629bbcdbac60d8cec931806bc1ad76c00d7a..772e13fe6fd0f3e563f0839c146e028cf9c5e748 100644
--- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.conf
+++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.conf
@@ -53,7 +53,7 @@ eNBs =
       prach_zero_correlation  			      = 1;
       prach_freq_offset       			      = 2;
       pucch_delta_shift       			      = 1;
-      pucch_nRB_CQI           			      = 1;
+      pucch_nRB_CQI           			      = 0;
       pucch_nCS_AN            			      = 0;
       pucch_n1_AN             			      = 32;
       pdsch_referenceSignalPower 			      = -27;
diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.lo.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.lo.conf
index e877e4d1ddd969ac8a0a509ae8655a7e0100190c..048f2fcc358fa6de5fc02e48d7223b8b5a202514 100644
--- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.lo.conf
+++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.lo.conf
@@ -53,7 +53,7 @@ eNBs =
       prach_zero_correlation  			      = 1;
       prach_freq_offset       			      = 2;
       pucch_delta_shift       			      = 1;
-      pucch_nRB_CQI           			      = 1;
+      pucch_nRB_CQI           			      = 0;
       pucch_nCS_AN            			      = 0;
       pucch_n1_AN             			      = 32;
       pdsch_referenceSignalPower 			      = -27;
diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c
index 53bf3c7d82f72e15f425e01247bf5a414e22fdd2..3bb282756ffa75198cc82ba509595f2ea9b75e41 100644
--- a/targets/RT/USER/lte-enb.c
+++ b/targets/RT/USER/lte-enb.c
@@ -579,7 +579,6 @@ static void* eNB_thread_prach_br( void* param ) {
 #endif
 
 
-extern void init_fep_thread(PHY_VARS_eNB *, pthread_attr_t *);
 extern void init_td_thread(PHY_VARS_eNB *, pthread_attr_t *);
 extern void init_te_thread(PHY_VARS_eNB *, pthread_attr_t *);
 
diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c
index ad3ea8121c6fe1e78cfc6ac690794ce0fd22fa34..21804817d6601ef6e338bf3911ac80f06e642e87 100644
--- a/targets/RT/USER/lte-ru.c
+++ b/targets/RT/USER/lte-ru.c
@@ -1323,6 +1323,22 @@ int setup_RU_buffers(RU_t *ru) {
   return(0);
 }
 
+static void* ru_stats_thread(void* param) {
+
+  RU_t               *ru      = (RU_t*)param;
+
+  wait_sync("ru_stats_thread");
+
+  while (!oai_exit) {
+     sleep(1);
+     if (opp_enabled == 1) {
+       if (ru->feprx) print_meas(&ru->ofdm_demod_stats,"feprx",NULL,NULL);
+       if (ru->feptx_ofdm) print_meas(&ru->ofdm_mod_stats,"feptx_ofdm",NULL,NULL);
+     }
+  }
+  return(NULL);
+}
+
 static void* ru_thread( void* param ) {
 
   static int ru_thread_status;
@@ -1462,6 +1478,7 @@ static void* ru_thread( void* param ) {
     if ((ru->fh_north_asynch_in == NULL) && (ru->fh_south_out)) ru->fh_south_out(ru);
  
     if (ru->fh_north_out) ru->fh_north_out(ru);
+
   }
   
 
@@ -1563,9 +1580,12 @@ int start_rf(RU_t *ru) {
 }
 
 extern void fep_full(RU_t *ru);
-extern void fep_full_2thread(RU_t *ru);
+extern void ru_fep_full_2thread(RU_t *ru);
 extern void feptx_ofdm(RU_t *ru);
+extern void feptx_ofdm_2thread(RU_t *ru);
 extern void feptx_prec(RU_t *ru);
+extern void init_fep_thread(RU_t *ru,pthread_attr_t *attr);
+extern void init_feptx_thread(RU_t *ru,pthread_attr_t *attr);
 
 void init_RU_proc(RU_t *ru) {
    
@@ -1648,7 +1668,12 @@ void init_RU_proc(RU_t *ru) {
     pthread_setname_np( proc->pthread_FH, name );
     
   }
-  
+
+  if (get_nprocs()>=2) { 
+    if (ru->feprx) init_fep_thread(ru,NULL); 
+    if (ru->feptx_ofdm) init_feptx_thread(ru,NULL);
+  } 
+  if (opp_enabled == 1) pthread_create(&ru->ru_stats_thread,NULL,ru_stats_thread,(void*)ru); 
   
 }
 
@@ -1902,8 +1927,8 @@ void init_RU(char *rf_config_file) {
 	ru->fh_north_out          = fh_if4p5_north_out;       // send_IF4p5 on reception
 	ru->fh_south_out          = tx_rf;                    // send output to RF
 	ru->fh_north_asynch_in    = fh_if4p5_north_asynch_in; // TX packets come asynchronously
-	ru->feprx                 = fep_full;                 // RX DFTs
-	ru->feptx_ofdm            = feptx_ofdm;               // this is fep with idft only (no precoding in RRU)
+	ru->feprx                 = (get_nprocs()<=4) ? fep_full :ru_fep_full_2thread;                 // RX DFTs
+	ru->feptx_ofdm            = (get_nprocs()<=4) ? feptx_ofdm : feptx_ofdm_2thread;               // this is fep with idft only (no precoding in RRU)
 	ru->feptx_prec            = NULL;
 	ru->start_if              = start_if;                 // need to start the if interface for if4p5
 	ru->ifdevice.host_type    = RRU_HOST;
@@ -1920,8 +1945,8 @@ void init_RU(char *rf_config_file) {
       }
       else if (ru->function == eNodeB_3GPP) {  
 	ru->do_prach             = 0;                       // no prach processing in RU            
-	ru->feprx                = fep_full;                // RX DFTs
-	ru->feptx_ofdm           = feptx_ofdm;              // this is fep with idft and precoding
+	ru->feprx                = (get_nprocs()<=2) ? fep_full : ru_fep_full_2thread;                // RX DFTs
+	ru->feptx_ofdm           = (get_nprocs()<=2) ? feptx_ofdm : feptx_ofdm_2thread;              // this is fep with idft and precoding
 	ru->feptx_prec           = feptx_prec;              // this is fep with idft and precoding
 	ru->fh_north_in          = NULL;                    // no incoming fronthaul from north
 	ru->fh_north_out         = NULL;                    // no outgoing fronthaul to north
@@ -1948,9 +1973,9 @@ void init_RU(char *rf_config_file) {
 
     case REMOTE_IF5: // the remote unit is IF5 RRU
       ru->do_prach               = 0;
-      ru->feprx                  = fep_full;                   // this is frequency-shift + DFTs
+      ru->feprx                  = (get_nprocs()<=2) ? fep_full : fep_full;                   // this is frequency-shift + DFTs
       ru->feptx_prec             = feptx_prec;                 // need to do transmit Precoding + IDFTs 
-      ru->feptx_ofdm             = feptx_ofdm;                 // need to do transmit Precoding + IDFTs 
+      ru->feptx_ofdm             = (get_nprocs()<=2) ? feptx_ofdm : feptx_ofdm_2thread;                 // need to do transmit Precoding + IDFTs 
       if (ru->if_timing == synch_to_other) {
 	ru->fh_south_in          = fh_slave_south_in;                  // synchronize to master
 	ru->fh_south_out         = fh_if5_mobipass_south_out;          // use send_IF5 for mobipass