From b42aed9ed95e71284abcad84c81ec2e511606105 Mon Sep 17 00:00:00 2001
From: Raymond Knopp <raymond.knopp@eurecom.fr>
Date: Mon, 17 Apr 2017 10:40:23 -0700
Subject: [PATCH] initial testing version of L1L-L1H split (RRU-RAU)

---
 cmake_targets/CMakeLists.txt                  |    5 +-
 common/utils/itti/intertask_interface.c       |    1 +
 .../CODING/3gpplte_turbo_decoder_sse_8bit.c   |   26 +-
 openair1/PHY/CODING/lte_segmentation.c        |    2 +-
 openair1/PHY/CODING/rate_matching.c           |  247 -
 openair1/PHY/INIT/defs.h                      |   20 +-
 openair1/PHY/INIT/lte_init.c                  |  507 +-
 openair1/PHY/INIT/lte_param_init.c            |    1 -
 openair1/PHY/INIT/lte_parms.c                 |    1 -
 openair1/PHY/LTE_ESTIMATION/defs.h            |   12 +-
 openair1/PHY/LTE_ESTIMATION/lte_adjust_sync.c |   22 +-
 .../lte_dl_bf_channel_estimation.c            |   20 +-
 .../lte_dl_channel_estimation.c               |    6 +-
 .../PHY/LTE_ESTIMATION/lte_eNB_measurements.c |   57 +-
 .../PHY/LTE_ESTIMATION/lte_est_freq_offset.c  |    4 +-
 openair1/PHY/LTE_ESTIMATION/lte_sync_time.c   |   52 +-
 .../PHY/LTE_ESTIMATION/lte_ue_measurements.c  |    4 +-
 .../lte_ul_channel_estimation.c               |  453 +-
 openair1/PHY/LTE_REFSIG/lte_dl_mbsfn.c        |    6 +-
 openair1/PHY/LTE_TRANSPORT/dci.c              |   16 +-
 openair1/PHY/LTE_TRANSPORT/dci_tools.c        |   20 +-
 openair1/PHY/LTE_TRANSPORT/defs.h             |    4 +-
 openair1/PHY/LTE_TRANSPORT/dlsch_coding.c     |   16 +-
 openair1/PHY/LTE_TRANSPORT/dlsch_decoding.c   |   20 +-
 .../PHY/LTE_TRANSPORT/dlsch_demodulation.c    |   40 +-
 .../PHY/LTE_TRANSPORT/dlsch_llr_computation.c |   73 +-
 openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c |   22 +-
 openair1/PHY/LTE_TRANSPORT/if4_tools.c        |  150 +-
 openair1/PHY/LTE_TRANSPORT/if4_tools.h        |   10 +-
 openair1/PHY/LTE_TRANSPORT/if5_tools.c        |  116 +-
 openair1/PHY/LTE_TRANSPORT/if5_tools.h        |    9 +-
 openair1/PHY/LTE_TRANSPORT/initial_sync.c     |    5 +-
 openair1/PHY/LTE_TRANSPORT/lte_mcs.c          |    8 +-
 openair1/PHY/LTE_TRANSPORT/pbch.c             |   48 +-
 openair1/PHY/LTE_TRANSPORT/pcfich.c           |    5 +-
 openair1/PHY/LTE_TRANSPORT/phich.c            |   16 +-
 openair1/PHY/LTE_TRANSPORT/pilots.c           |    2 +-
 openair1/PHY/LTE_TRANSPORT/pilots_mbsfn.c     |    2 +-
 openair1/PHY/LTE_TRANSPORT/pmch.c             |   12 +-
 openair1/PHY/LTE_TRANSPORT/prach.c            |  142 +-
 openair1/PHY/LTE_TRANSPORT/print_stats.c      |   16 +-
 openair1/PHY/LTE_TRANSPORT/proto.h            |   16 +-
 openair1/PHY/LTE_TRANSPORT/pss.c              |    4 +-
 openair1/PHY/LTE_TRANSPORT/pucch.c            |   16 +-
 openair1/PHY/LTE_TRANSPORT/rar_tools.c        |   42 +-
 openair1/PHY/LTE_TRANSPORT/srs_modulation.c   |   16 +-
 .../PHY/LTE_TRANSPORT/ulsch_demodulation.c    |  293 +-
 openair1/PHY/MODULATION/beamforming.c         |    7 +-
 openair1/PHY/MODULATION/defs.h                |    7 +-
 openair1/PHY/MODULATION/ofdm_mod.c            |   16 +-
 openair1/PHY/MODULATION/slot_fep_mbsfn.c      |   14 +-
 openair1/PHY/MODULATION/slot_fep_ul.c         |   19 +-
 openair1/PHY/MODULATION/ul_7_5_kHz.c          |   11 +-
 openair1/PHY/defs.h                           |  580 ++-
 openair1/PHY/extern.h                         |   10 +-
 openair1/PHY/impl_defs_lte.h                  |   59 +-
 openair1/PHY/impl_defs_top.h                  |  180 +-
 openair1/PHY/vars.h                           |   17 +-
 openair1/SCHED/phy_procedures_lte_common.c    |   14 +-
 openair1/SCHED/phy_procedures_lte_eNb.c       |  231 +-
 openair1/SCHED/phy_procedures_lte_ue.c        |   18 +-
 openair1/SCHED/pusch_pc.c                     |   12 +-
 openair1/SCHED/ru_procedures.c                |  188 +-
 .../SIMULATION/ETH_TRANSPORT/emu_transport.c  |   27 +-
 openair1/SIMULATION/TOOLS/random_channel.c    |    2 +-
 openair1/SIMULATION/TOOLS/rangen_double.c     |    2 +-
 openair2/COMMON/mac_rrc_primitives.h          |    1 +
 openair2/COMMON/rrc_messages_types.h          |   14 +-
 openair2/ENB_APP/enb_app.c                    |   59 +-
 openair2/ENB_APP/enb_config.c                 | 4535 +++++++++--------
 openair2/ENB_APP/enb_config.h                 |   31 +-
 openair2/LAYER2/MAC/config.c                  |  851 ++--
 openair2/LAYER2/MAC/defs.h                    |   23 +-
 openair2/LAYER2/MAC/eNB_scheduler.c           |   58 +-
 openair2/LAYER2/MAC/eNB_scheduler_RA.c        |   74 +-
 openair2/LAYER2/MAC/eNB_scheduler_bch.c       |   28 +-
 openair2/LAYER2/MAC/eNB_scheduler_dlsch.c     |   45 +-
 openair2/LAYER2/MAC/eNB_scheduler_mch.c       |  179 +-
 .../LAYER2/MAC/eNB_scheduler_primitives.c     |   34 +-
 openair2/LAYER2/MAC/eNB_scheduler_ulsch.c     |   36 +-
 openair2/LAYER2/MAC/extern.h                  |    5 +-
 openair2/LAYER2/MAC/main.c                    |  428 +-
 openair2/LAYER2/MAC/openair2_proc.c           |    8 +-
 openair2/LAYER2/MAC/pre_processor.c           |   38 +-
 openair2/LAYER2/MAC/proto.h                   |   85 +-
 openair2/LAYER2/MAC/rar_tools.c               |   32 +-
 openair2/LAYER2/MAC/vars.h                    |    1 -
 openair2/LAYER2/Makefile                      |  159 -
 openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c      |   11 +-
 openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm.c        |    6 +-
 openair2/LAYER2/RLC/rlc.c                     |    2 +-
 openair2/LAYER2/layer2_top.c                  |  179 -
 openair2/LAYER2/openair2_proc.c               |    5 +-
 openair2/PHY_INTERFACE/defs.h                 |   12 +
 openair2/RRC/LITE/L2_interface.c              |   57 +-
 openair2/RRC/LITE/MESSAGES/asn1_msg.c         |  304 +-
 openair2/RRC/LITE/MESSAGES/asn1_msg.h         |   39 +-
 openair2/RRC/LITE/defs.h                      |   24 +-
 openair2/RRC/LITE/extern.h                    |   21 +-
 openair2/RRC/LITE/proto.h                     |    1 +
 openair2/RRC/LITE/rrc_UE.c                    |  529 +-
 openair2/RRC/LITE/rrc_common.c                |  148 +-
 openair2/RRC/LITE/rrc_eNB.c                   |  828 ++-
 openair2/RRC/LITE/rrc_eNB_GTPV1U.c            |    6 +-
 openair2/RRC/LITE/rrc_eNB_S1AP.c              |   32 +-
 openair2/RRC/LITE/vars.h                      |   23 -
 openair2/UTIL/MEM/mem_block.c                 |  108 +-
 openair2/UTIL/OCG/OCG.h                       |    6 +-
 openair3/GTPV1-U/gtpv1u_eNB.c                 |   94 +-
 openair3/GTPV1-U/gtpv1u_eNB_task.h            |    5 +-
 targets/ARCH/COMMON/common_lib.c              |   26 +-
 targets/ARCH/COMMON/common_lib.h              |   44 +-
 targets/ARCH/ETHERNET/USERSPACE/LIB/eth_raw.c |   40 +-
 targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c |  226 +-
 .../ETHERNET/USERSPACE/LIB/ethernet_lib.c     |   52 +-
 .../ETHERNET/USERSPACE/LIB/ethernet_lib.h     |   74 +
 targets/ARCH/LMSSDR/USERSPACE/LIB/lms_lib.cpp |    2 +-
 .../CONF/rcc.band7.tm1.if4p5.25PRB.lo.conf    |   31 +-
 .../CONF/rcc.band7.tm1.if4p5.50PRB.lo.conf    |   33 +-
 .../rru.band7.tm1.if4p5.25PRB.oaisim.conf     |  191 +-
 targets/RT/USER/lte-enb.c                     | 1998 +-------
 targets/RT/USER/lte-ru.c                      | 1317 +++--
 targets/RT/USER/lte-softmodem.c               |  457 +-
 targets/RT/USER/lte-ue.c                      |   98 +-
 targets/RT/USER/rt_wrapper.c                  |  110 +-
 targets/RT/USER/rt_wrapper.h                  |    5 +
 targets/SIMU/USER/channel_sim.c               |  265 +-
 targets/SIMU/USER/init_lte.c                  |   91 +-
 targets/SIMU/USER/init_lte.h                  |    2 +-
 targets/SIMU/USER/oaisim.c                    |  347 +-
 targets/SIMU/USER/oaisim.h                    |    8 +-
 targets/SIMU/USER/oaisim_config.c             |    3 +-
 targets/SIMU/USER/oaisim_functions.c          |  580 +--
 targets/SIMU/USER/sinr_sim.c                  |    8 +-
 134 files changed, 8584 insertions(+), 10587 deletions(-)
 delete mode 100644 openair1/PHY/CODING/rate_matching.c
 delete mode 100644 openair2/LAYER2/Makefile
 delete mode 100644 openair2/LAYER2/layer2_top.c

diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt
index bfd86cd183..1e081e6233 100644
--- a/cmake_targets/CMakeLists.txt
+++ b/cmake_targets/CMakeLists.txt
@@ -1012,6 +1012,7 @@ set(SCHED_SRC
   ${OPENAIR1_DIR}/SCHED/phy_procedures_lte_eNb.c
   ${OPENAIR1_DIR}/SCHED/phy_procedures_lte_ue.c
   ${OPENAIR1_DIR}/SCHED/phy_procedures_lte_common.c
+  ${OPENAIR1_DIR}/SCHED/ru_procedures.c
   ${OPENAIR1_DIR}/SCHED/phy_mac_stub.c
   ${OPENAIR1_DIR}/SCHED/pucch_pc.c
   ${OPENAIR1_DIR}/SCHED/pusch_pc.c
@@ -1093,7 +1094,6 @@ set(PHY_SRC
   ${OPENAIR1_DIR}/PHY/CODING/3gpplte_turbo_decoder_sse_16bit.c
   ${OPENAIR1_DIR}/PHY/CODING/3gpplte_turbo_decoder_avx2_16bit.c
   ${OPENAIR1_DIR}/PHY/CODING/lte_rate_matching.c
-  ${OPENAIR1_DIR}/PHY/CODING/rate_matching.c
   ${OPENAIR1_DIR}/PHY/CODING/viterbi.c
   ${OPENAIR1_DIR}/PHY/CODING/viterbi_lte.c
   ${OPENAIR1_DIR}/PHY/INIT/lte_init.c
@@ -1750,6 +1750,7 @@ add_executable(lte-softmodem
   ${OPENAIR_TARGETS}/RT/USER/rt_wrapper.c
   ${OPENAIR_TARGETS}/RT/USER/lte-ue.c
   ${OPENAIR_TARGETS}/RT/USER/lte-enb.c
+  ${OPENAIR_TARGETS}/RT/USER/lte-ru.c
   ${OPENAIR_TARGETS}/RT/USER/lte-softmodem.c
   ${OPENAIR1_DIR}/SIMULATION/TOOLS/taus.c
   ${OPENAIR_TARGETS}/SIMU/USER/init_lte.c
@@ -1873,7 +1874,7 @@ add_executable(oaisim
   ${x2ap_h}
   ${OPENAIR_BIN_DIR}/messages_xml.h
   ${OPENAIR_TARGETS}/RT/USER/lte-ue.c
-  ${OPENAIR_TARGETS}/RT/USER/lte-enb.c
+  ${OPENAIR_TARGETS}/RT/USER/lte-ru.c
   ${OPENAIR_TARGETS}/RT/USER/rt_wrapper.c
   ${OPENAIR_TARGETS}/SIMU/USER/channel_sim.c
   ${OPENAIR_TARGETS}/SIMU/USER/init_lte.c
diff --git a/common/utils/itti/intertask_interface.c b/common/utils/itti/intertask_interface.c
index 28267900af..d70a6386b9 100644
--- a/common/utils/itti/intertask_interface.c
+++ b/common/utils/itti/intertask_interface.c
@@ -206,6 +206,7 @@ void *itti_malloc(task_id_t origin_task_id, task_id_t destination_task_id, ssize
 
 #else
   ptr = malloc (size);
+  if (ptr) memset(ptr,0,size);
 #endif
 
   AssertFatal (ptr != NULL, "Memory allocation of %d bytes failed (%d -> %d)!\n", (int) size, origin_task_id, destination_task_id);
diff --git a/openair1/PHY/CODING/3gpplte_turbo_decoder_sse_8bit.c b/openair1/PHY/CODING/3gpplte_turbo_decoder_sse_8bit.c
index ff7e02a239..b43f477e06 100644
--- a/openair1/PHY/CODING/3gpplte_turbo_decoder_sse_8bit.c
+++ b/openair1/PHY/CODING/3gpplte_turbo_decoder_sse_8bit.c
@@ -55,6 +55,8 @@
 #include "mex.h"
 #endif
 
+#include "common/ran_context.h"
+
 #define SHUFFLE16(a,b,c,d,e,f,g,h) _mm_set_epi8(h==-1?-1:h*2+1, \
             h==-1?-1:h*2, \
             g==-1?-1:g*2+1, \
@@ -122,7 +124,7 @@ void log_map8(llr_t* systematic,
 {
 
 #ifdef DEBUG_LOGMAP
-  msg("log_map, frame_length %d\n",frame_length);
+  printf("log_map, frame_length %d\n",frame_length);
 #endif
 
   if (gamma_stats) start_meas(gamma_stats) ;
@@ -158,7 +160,7 @@ void compute_gamma8(llr_t* m11,llr_t* m10,llr_t* systematic,channel_t* y_parity,
 #endif
 
 #ifdef DEBUG_LOGMAP
-  msg("compute_gamma, %p,%p,%p,%p,framelength %d\n",m11,m10,systematic,y_parity,frame_length);
+  printf("compute_gamma, %p,%p,%p,%p,framelength %d\n",m11,m10,systematic,y_parity,frame_length);
 #endif
 
 #if defined(__x86_64__) || defined(__i386__)
@@ -708,7 +710,7 @@ void compute_ext8(llr_t* alpha,llr_t* beta,llr_t* m_11,llr_t* m_10,llr_t* ext, l
   //
 
 #ifdef DEBUG_LOGMAP
-  msg("compute_ext, %p, %p, %p, %p, %p, %p ,framelength %d\n",alpha,beta,m_11,m_10,ext,systematic,frame_length);
+  printf("compute_ext, %p, %p, %p, %p, %p, %p ,framelength %d\n",alpha,beta,m_11,m_10,ext,systematic,frame_length);
 #endif
 
   alpha_ptr = alpha128;
@@ -843,6 +845,10 @@ void free_td8(void)
   }
 }
 
+
+
+extern RAN_CONTEXT_t RC;
+
 void init_td8()
 {
 
@@ -879,14 +885,14 @@ void init_td8()
       pi2tab8[ind][i] = j;
       //    printf("pi2[%d] = %d\n",i,j);
     }
-
+    
     for (i=0; i<n2; i++) {
       pi = base_interleaver[i];//(unsigned int)threegpplte_interleaver(f1,f2,n);
       pi3 = pi2tab8[ind][pi];
       pi4tab8[ind][pi2tab8[ind][i]] = pi3;
       pi5tab8[ind][pi3] = pi2tab8[ind][i];
       pi6tab8[ind][pi] = pi2tab8[ind][i];
-    }
+      }
 
   }
 }
@@ -958,7 +964,7 @@ unsigned char phy_threegpplte_turbo_decoder8(short *y,
   int offset8_flag=0;
 
   if (crc_type > 3) {
-    msg("Illegal crc length!\n");
+    printf("Illegal crc length!\n");
     return 255;
   }
 
@@ -976,7 +982,7 @@ unsigned char phy_threegpplte_turbo_decoder8(short *y,
   for (iind=0; iind < 188 && f1f2mat[iind].nb_bits != n; iind++);
 
   if ( iind == 188 ) {
-    msg("Illegal frame length!\n");
+    printf("Illegal frame length!\n");
     return 255;
   }
 
@@ -1306,7 +1312,7 @@ unsigned char phy_threegpplte_turbo_decoder8(short *y,
     yp1[i] = *yp;
     yp++;
 #ifdef DEBUG_LOGMAP
-    msg("Term 1 (%d): %d %d\n",i,s[i],yp1[i]);
+    printf("Term 1 (%d): %d %d\n",i,s[i],yp1[i]);
 #endif //DEBUG_LOGMAP
   }
 
@@ -1318,12 +1324,12 @@ unsigned char phy_threegpplte_turbo_decoder8(short *y,
     yp2[i-16] = *yp;
     yp++;
 #ifdef DEBUG_LOGMAP
-    msg("Term 2 (%d): %d %d\n",i-16,s[i],yp2[i-16]);
+    printf("Term 2 (%d): %d %d\n",i-16,s[i],yp2[i-16]);
 #endif //DEBUG_LOGMAP
   }
 
 #ifdef DEBUG_LOGMAP
-  msg("\n");
+  printf("\n");
 #endif //DEBUG_LOGMAP
 
   if (init_stats) stop_meas(init_stats);
diff --git a/openair1/PHY/CODING/lte_segmentation.c b/openair1/PHY/CODING/lte_segmentation.c
index 04056c4c9e..f63d5ddb11 100644
--- a/openair1/PHY/CODING/lte_segmentation.c
+++ b/openair1/PHY/CODING/lte_segmentation.c
@@ -106,7 +106,7 @@ int lte_segmentation(unsigned char *input_buffer,
 #endif
     *Kminus = (*Kplus - 64);
   } else {
-    msg("lte_segmentation.c: Illegal codeword size !!!\n");
+    printf("lte_segmentation.c: Illegal codeword size !!!\n");
     return(-1);
   }
 
diff --git a/openair1/PHY/CODING/rate_matching.c b/openair1/PHY/CODING/rate_matching.c
deleted file mode 100644
index 51ee26ce28..0000000000
--- a/openair1/PHY/CODING/rate_matching.c
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
- * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The OpenAirInterface Software Alliance licenses this file to You under
- * the OAI Public License, Version 1.0  (the "License"); you may not use this file
- * except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.openairinterface.org/?page_id=698
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *-------------------------------------------------------------------------------
- * For more information about the OpenAirInterface (OAI) Software Alliance:
- *      contact@openairinterface.org
- */
-
-#ifdef DEBUG
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <string.h>
-#endif
-
-#include "PHY/defs.h"
-
-//#define DEBUG_PHY 1
-
-unsigned int ps0, ps1, ps2, pb;
-
-//----------------------------------------------
-//
-/*!\brief Tausworthe Uniform Random Generator.  This is based on the hardware implementation described in
-  Lee et al, "A Hardware Gaussian Noise Generator Usign the Box-Muller Method and its Error Analysis," IEEE Trans. on Computers, 2006.
-*/
-//
-
-static inline void pset_taus_seed(unsigned int off)
-{
-
-
-  ps0 = (unsigned int)0x1e23d852 + (off<<4);
-  ps1 = (unsigned int)0x81f38a1c + (off<<4);
-  ps2 = (unsigned int)0xfe1a133e + (off<<4);
-
-}
-
-static inline unsigned int ptaus(void)
-{
-
-  pb = (((ps0 << 13) ^ ps0) >> 19);
-  ps0 = (((ps0 & 0xFFFFFFFE) << 12)^  pb);
-  pb = (((ps1 << 2) ^ ps1) >> 25);
-  ps1 = (((ps1 & 0xFFFFFFF8) << 4)^  pb);
-  pb = (((ps2 << 3) ^ ps2) >> 11);
-  ps2 = (((ps2 & 0xFFFFFFF0) << 17)^  pb);
-  return ps0 ^ ps1 ^ ps2;
-}
-
-
-int rate_matching(unsigned int N_coded,
-                  unsigned int N_input,
-                  unsigned char *inPtr,
-                  unsigned char N_bps,
-                  unsigned int off)
-{
-
-
-  unsigned int i,j,U,Umod,rep_flag=0;
-  unsigned int N_coded2,N_input2,Mod_input2;
-  int N_punctured;
-
-  if ((9*N_coded<(N_input<<2)) || (N_input<(N_coded>>1))) {
-    // check validity of parameters
-    // the first condition represents the case where the rate is greater than 2/3
-    // the second condition represents the case where the rate is less than 1/4
-    msg("[PHY][CODING] Rate matching parameter error (N_coded %d, N_input %d, N_bps %d), exiting\n",N_coded,N_input,N_bps);
-    return(-1);
-  }
-
-  //initialize all bits as transmitted
-  for (i=0; i<N_input; i++)
-    inPtr[i] |= 0x80;
-
-  // No go puncture the bits that should be removed
-  i=0;
-
-  N_coded2 = N_coded/N_bps;
-  pset_taus_seed(off);
-  N_input2 = N_input/N_bps;
-
-  N_punctured = N_input2-N_coded2;
-
-  if (N_punctured < 0) {  // Repeat bits instead of puncturing
-    N_punctured = -N_punctured;
-    rep_flag = 1;
-  }
-
-#ifdef USER_MODE
-#ifdef DEBUG_PHY
-  printf("rate_matching : N_coded %d, N_input %d, N_bps %d\n",N_coded,N_input,N_bps);
-  printf("rate_matching : N_punctured = %d (%d)\n",N_bps*N_punctured,rep_flag);
-  printf("rate_matching : code rate = %f\n",(double)N_input/(double)N_coded/2.0);
-#endif
-#endif
-
-  Mod_input2 = (1<<(1+log2_approx(N_input2)))-1;
-
-  while (i < N_punctured) {
-    // generate N_punctured random positions in the input vector
-    do { // generate a modulo-N_input2 random variable
-      U = ptaus();
-      Umod = U&Mod_input2;
-
-      //      printf("i %d, N_punctured %d U %u Umod %d Iptr[Umod] %x\n",i,N_punctured,U,Umod,inPtr[Umod]);
-      // check if the bit is already punctured/repeated, if so skip it and generate another RV
-      if ((Umod < N_input2) && (((inPtr[Umod]&0x80) == 0)||((inPtr[Umod]&0xc0) == 0xc0)))
-        Umod=N_input2;
-
-    } while (Umod>=N_input2);
-
-    for (j=0; j<N_bps; j++) {          // loop over symbol bits
-      if (rep_flag == 0)
-        inPtr[Umod + (j*N_input2)] &= 0x7f; // clear MSB to indicate bit is punctured
-      else
-        inPtr[Umod + (j*N_input2)] |= 0xc0; // set MSB-1 to indicate bit is repeated
-
-    }
-
-    /*
-    #ifdef USER_MODE
-    #ifdef DEBUG_PHY
-    printf("rate_matching : i= %d, U = %d\n",i,Umod);
-    #endif
-    #endif
-    */
-    i++;
-  }
-
-  return(0);
-}
-
-int rate_matching_lte(unsigned int N_coded,
-                      unsigned int N_input,
-                      unsigned char *inPtr,
-                      unsigned int off)
-{
-
-
-  unsigned int i,U,Umod,rep_flag=0;
-  unsigned int Mod_input;
-  int N_punctured;
-
-  if ((9*N_coded<(N_input<<2)) || (N_input<(N_coded>>1))) {
-    // check validity of parameters
-    // the first condition represents the case where the rate is greater than 2/3
-    // the second condition represents the case where the rate is less than 1/4
-    msg("[PHY][CODING] Rate matching parameter error (N_coded %d, N_input %d), exiting\n",N_coded,N_input);
-    return(-1);
-  }
-
-  //initialize all bits as transmitted
-  for (i=0; i<N_input; i++)
-    inPtr[i] |= 0x80;
-
-  // No go puncture the bits that should be removed
-  i=0;
-
-
-  pset_taus_seed(off);
-
-  N_punctured = N_input-N_coded;
-
-  if (N_punctured < 0) {  // Repeat bits instead of puncturing
-    N_punctured = -N_punctured;
-    rep_flag = 1;
-  }
-
-#ifdef USER_MODE
-#ifdef DEBUG_PHY
-  printf("rate_matching : N_coded %d, N_input %d\n",N_coded,N_input);
-
-  if (rep_flag)
-    printf("rate_matching : N_repeated = %d\n",N_punctured);
-  else
-    printf("rate_matching : N_punctured = %d\n",N_punctured);
-
-  printf("rate_matching : code rate = %f\n",(double)N_input/(double)N_coded/3.0);
-#endif
-#endif
-
-  Mod_input = (1<<(1+log2_approx(N_input)))-1;
-
-  while (i < N_punctured) {
-    // generate N_punctured random positions in the input vector
-    do { // generate a modulo-N_input2 random variable
-      U = ptaus();
-      Umod = U&Mod_input;
-
-      //      printf("i %d, N_punctured %d U %u Umod %d Iptr[Umod] %x\n",i,N_punctured,U,Umod,inPtr[Umod]);
-      // check if the bit is already punctured/repeated, if so skip it and generate another RV
-      if ((Umod < N_input) && (((inPtr[Umod]&0x80) == 0)||((inPtr[Umod]&0xc0) == 0xc0)))
-        Umod=N_input;
-
-    } while (Umod>=N_input);
-
-    if (rep_flag == 0)
-      inPtr[Umod] &= 0x7f; // clear MSB to indicate bit is punctured
-    else
-      inPtr[Umod] |= 0xc0; // set MSB-1 to indicate bit is repeated
-
-
-    /*
-    #ifdef USER_MODE
-    #ifdef DEBUG_PHY
-    printf("rate_matching : i= %d, U = %d\n",i,Umod);
-    #endif
-    #endif
-    */
-    i++;
-  }
-
-  return(0);
-}
-
-
-
-#ifdef MAIN
-void main(int argc,char **argv)
-{
-
-  unsigned char input[1024];
-
-  if (argc == 1) {
-    printf("Provide an input\n");
-    exit(-1);
-  }
-
-  memset(input,0,1024);
-
-  rate_matching(4*157,4*256,input,atoi(argv[1]),0);
-}
-#endif
diff --git a/openair1/PHY/INIT/defs.h b/openair1/PHY/INIT/defs.h
index 27303cb57d..d0a4ce5fb8 100644
--- a/openair1/PHY/INIT/defs.h
+++ b/openair1/PHY/INIT/defs.h
@@ -29,6 +29,7 @@
 //#include "RadioResourceConfigCommonSIB.h"
 #include "RadioResourceConfigDedicated.h"
 #include "TDD-Config.h"
+#include "PHICH-Config.h"
 #include "MBSFN-SubframeConfigList.h"
 #include "MobilityControlInfo.h"
 #ifdef Rel10
@@ -81,17 +82,20 @@ int phy_init_lte_eNB(PHY_VARS_eNB *phy_vars_eNb,
 @param N_RB_DL Number of DL resource blocks
 @param Nid_cell Cell ID
 @param Ncp Normal/Extended Prefix flag
-@param frame_type FDD/TDD framing
 @param p_eNB Number of eNB TX antennas
 @param phich_config Pointer to PHICH_CONFIG_COMMON
  */
-void phy_config_mib(LTE_DL_FRAME_PARMS *lte_frame_parms,
-                    uint8_t                N_RB_DL,
-                    uint8_t                Nid_cell,
-                    uint8_t                Ncp,
-                    uint8_t                frame_type,
-                    uint8_t                p_eNB,
-                    PHICH_CONFIG_COMMON *phich_config);
+void phy_config_mib_eNB(int                    Mod_id,
+			int                    CC_id,
+			int                    eutra_band,
+			int                    N_RB_DL,
+			PHICH_Config_t         *phich_config,
+			int                    Nid_cell,
+			int                    Ncp,
+			int                    p_eNB,
+			uint32_t               dl_CarrierFreq,
+			uint32_t               ul_CarrierFreq);
+
 
 
 /** \brief Configure LTE_DL_FRAME_PARMS with components derived after reception of SIB1.
diff --git a/openair1/PHY/INIT/lte_init.c b/openair1/PHY/INIT/lte_init.c
index f6f8d8f858..6977f5a264 100644
--- a/openair1/PHY/INIT/lte_init.c
+++ b/openair1/PHY/INIT/lte_init.c
@@ -29,7 +29,6 @@
 #include "LAYER2/MAC/extern.h"
 #include "MBSFN-SubframeConfigList.h"
 #include "UTIL/LOG/vcd_signal_dumper.h"
-#define DEBUG_PHY
 #include "assertions.h"
 #include <math.h>
 
@@ -37,23 +36,64 @@ extern uint16_t prach_root_sequence_map0_3[838];
 extern uint16_t prach_root_sequence_map4[138];
 uint8_t dmrs1_tab[8] = {0,2,3,4,6,8,9,10};
 
-// FIXME not used anywhere
-void phy_config_mib(LTE_DL_FRAME_PARMS *fp,
-                    uint8_t N_RB_DL,
-                    uint8_t Nid_cell,
-                    uint8_t Ncp,
-                    uint8_t frame_type,
-                    uint8_t p_eNB,
-                    PHICH_CONFIG_COMMON *phich_config)
-{
-  fp->N_RB_DL                            = N_RB_DL;
+
+int N_RB_DL_array[6] = {6,15,25,50,75,100};
+
+void phy_config_mib_eNB(int                 Mod_id,
+			int                 CC_id,
+			int                 eutra_band,
+			int                 dl_Bandwidth,
+			PHICH_Config_t      *phich_config,
+			int                 Nid_cell,
+			int                 Ncp,
+			int                 p_eNB,
+			uint32_t            dl_CarrierFreq,
+			uint32_t            ul_CarrierFreq) {
+
+  
+  LTE_DL_FRAME_PARMS *fp;
+
+  LOG_I(PHY,"Configuring MIB for instance %d, CCid %d : (band %d,N_RB_DL %d,Nid_cell %d,p %d,DL freq %u)\n",
+	Mod_id, CC_id, eutra_band, N_RB_DL_array[dl_Bandwidth], Nid_cell, p_eNB,dl_CarrierFreq);
+
+  if (RC.eNB == NULL) {
+    RC.eNB = (PHY_VARS_eNB ***)malloc((1+NUMBER_OF_eNB_MAX)*sizeof(PHY_VARS_eNB***));
+    LOG_I(PHY,"RC.eNB = %p\n",RC.eNB);
+    memset(RC.eNB,0,(1+NUMBER_OF_eNB_MAX)*sizeof(PHY_VARS_eNB***));
+  }
+  if (RC.eNB[Mod_id] == NULL) {
+    RC.eNB[Mod_id] = (PHY_VARS_eNB **)malloc((1+MAX_NUM_CCs)*sizeof(PHY_VARS_eNB**));
+    LOG_I(PHY,"RC.eNB[%d] = %p\n",Mod_id,RC.eNB[Mod_id]);
+    memset(RC.eNB[Mod_id],0,(1+MAX_NUM_CCs)*sizeof(PHY_VARS_eNB***));
+  }
+  if (RC.eNB[Mod_id][CC_id] == NULL) {
+    RC.eNB[Mod_id][CC_id] = (PHY_VARS_eNB *)malloc(sizeof(PHY_VARS_eNB));
+    LOG_I(PHY,"RC.eNB[%d][%d] = %p\n",Mod_id,CC_id,RC.eNB[Mod_id][CC_id]);
+    RC.eNB[Mod_id][CC_id]->Mod_id = Mod_id;
+    RC.eNB[Mod_id][CC_id]->CC_id  = CC_id;
+  }
+
+  fp = &RC.eNB[Mod_id][CC_id]->frame_parms;
+
+  fp->N_RB_DL                            = N_RB_DL_array[dl_Bandwidth];
+  fp->N_RB_UL                            = N_RB_DL_array[dl_Bandwidth];
   fp->Nid_cell                           = Nid_cell;
   fp->nushift                            = Nid_cell%6;
+  fp->eutra_band                         = eutra_band;
   fp->Ncp                                = Ncp;
-  fp->frame_type                         = frame_type;
   fp->nb_antenna_ports_eNB               = p_eNB;
-  fp->phich_config_common.phich_resource = phich_config->phich_resource;
-  fp->phich_config_common.phich_duration = phich_config->phich_duration;
+  fp->phich_config_common.phich_resource = phich_config->phich_Resource;
+  fp->phich_config_common.phich_duration = phich_config->phich_Duration;
+  fp->dl_CarrierFreq                     = dl_CarrierFreq;
+  fp->ul_CarrierFreq                     = ul_CarrierFreq;
+  if (dl_CarrierFreq==ul_CarrierFreq)
+    fp->frame_type = TDD;
+  else
+    fp->frame_type = FDD;
+
+  init_frame_parms(fp,1);
+  phy_init_lte_top(fp);
+
 }
 
 void phy_config_sib1_eNB(uint8_t Mod_id,
@@ -63,13 +103,16 @@ void phy_config_sib1_eNB(uint8_t Mod_id,
                          uint16_t SIPeriod)
 {
 
-  LTE_DL_FRAME_PARMS *fp = &PHY_vars_eNB_g[Mod_id][CC_id]->frame_parms;
+  LTE_DL_FRAME_PARMS *fp = &RC.eNB[Mod_id][CC_id]->frame_parms;
 
   if (tdd_Config) {
     fp->tdd_config    = tdd_Config->subframeAssignment;
     fp->tdd_config_S  = tdd_Config->specialSubframePatterns;
+    fp->frame_type    = TDD;
+  }
+  else {
+    fp->frame_type    = FDD;
   }
-
   fp->SIwindowsize  = SIwindowsize;
   fp->SIPeriod      = SIPeriod;
 }
@@ -101,12 +144,13 @@ void phy_config_sib2_eNB(uint8_t Mod_id,
                          struct MBSFN_SubframeConfigList  *mbsfn_SubframeConfigList)
 {
 
-  LTE_DL_FRAME_PARMS *fp = &PHY_vars_eNB_g[Mod_id][CC_id]->frame_parms;
-  //LTE_eNB_UE_stats *eNB_UE_stats      = PHY_vars_eNB_g[Mod_id][CC_id]->eNB_UE_stats;
-  //int32_t rx_total_gain_eNB_dB        = PHY_vars_eNB_g[Mod_id][CC_id]->rx_total_gain_eNB_dB;
+  LTE_DL_FRAME_PARMS *fp = &RC.eNB[Mod_id][CC_id]->frame_parms;
+  //LTE_eNB_UE_stats *eNB_UE_stats      = RC.eNB[Mod_id][CC_id].eNB_UE_stats;
+  //int32_t rx_total_gain_eNB_dB        = RC.eNB[Mod_id][CC_id].rx_total_gain_eNB_dB;
   int i;
 
-  LOG_D(PHY,"[eNB%d] CCid %d: Applying radioResourceConfigCommon\n",Mod_id,CC_id);
+  LOG_I(PHY,"[eNB%d] CCid %d: Applying radioResourceConfigCommon\n",Mod_id,CC_id);
+
 
   fp->prach_config_common.rootSequenceIndex                           =radioResourceConfigCommon->prach_Config.rootSequenceIndex;
   LOG_D(PHY,"prach_config_common.rootSequenceIndex = %d\n",fp->prach_config_common.rootSequenceIndex );
@@ -123,7 +167,7 @@ void phy_config_sib2_eNB(uint8_t Mod_id,
   fp->prach_config_common.prach_ConfigInfo.prach_FreqOffset           =radioResourceConfigCommon->prach_Config.prach_ConfigInfo.prach_FreqOffset;
   LOG_D(PHY,"prach_config_common.prach_ConfigInfo.prach_FreqOffset = %d\n",fp->prach_config_common.prach_ConfigInfo.prach_FreqOffset);
   compute_prach_seq(&fp->prach_config_common,fp->frame_type,
-                    PHY_vars_eNB_g[Mod_id][CC_id]->X_u);
+                    RC.eNB[Mod_id][CC_id]->X_u);
 
   fp->pucch_config_common.deltaPUCCH_Shift = 1+radioResourceConfigCommon->pucch_ConfigCommon.deltaPUCCH_Shift;
   fp->pucch_config_common.nRB_CQI          = radioResourceConfigCommon->pucch_ConfigCommon.nRB_CQI;
@@ -195,7 +239,7 @@ void phy_config_sib2_eNB(uint8_t Mod_id,
 
   // PUCCH
 
-  init_ncs_cell(fp,PHY_vars_eNB_g[Mod_id][CC_id]->ncs_cell);
+  init_ncs_cell(fp,RC.eNB[Mod_id][CC_id]->ncs_cell);
 
   init_ul_hopping(fp);
 
@@ -227,6 +271,8 @@ void phy_config_sib2_eNB(uint8_t Mod_id,
 
   } else
     fp->num_MBSFN_config = 0;
+
+  //
 }
 
 
@@ -373,7 +419,7 @@ void phy_config_sib13_eNB(uint8_t Mod_id,int CC_id,int mbsfn_Area_idx,
                           long mbsfn_AreaId_r9)
 {
 
-  LTE_DL_FRAME_PARMS *fp = &PHY_vars_eNB_g[Mod_id][CC_id]->frame_parms;
+  LTE_DL_FRAME_PARMS *fp = &RC.eNB[Mod_id][CC_id]->frame_parms;
 
 
   LOG_I(PHY,"[eNB%d] Applying MBSFN_Area_id %ld for index %d\n",Mod_id,mbsfn_AreaId_r9,mbsfn_Area_idx);
@@ -383,7 +429,7 @@ void phy_config_sib13_eNB(uint8_t Mod_id,int CC_id,int mbsfn_Area_idx,
     LOG_N(PHY,"Fix me: only called when mbsfn_Area_idx == 0)\n");
   }
 
-  lte_gold_mbsfn(fp,PHY_vars_eNB_g[Mod_id][CC_id]->lte_gold_mbsfn_table,fp->Nid_cell_mbsfn);
+  lte_gold_mbsfn(fp,RC.eNB[Mod_id][CC_id]->lte_gold_mbsfn_table,fp->Nid_cell_mbsfn);
 }
 
 
@@ -649,8 +695,9 @@ void phy_config_dedicated_eNB(uint8_t Mod_id,
                               struct PhysicalConfigDedicated *physicalConfigDedicated)
 {
 
-  PHY_VARS_eNB *eNB = PHY_vars_eNB_g[Mod_id][CC_id];
+  PHY_VARS_eNB *eNB = RC.eNB[Mod_id][CC_id];
   int8_t UE_id = find_ue(rnti,eNB);
+  int i;
 
   if (UE_id == -1) {
     LOG_E( PHY, "[eNB %"PRIu8"] find_ue() returns -1\n", Mod_id);
@@ -684,7 +731,7 @@ void phy_config_dedicated_eNB(uint8_t Mod_id,
 	break;
       case AntennaInfoDedicated__transmissionMode_tm7:
         lte_gold_ue_spec_port5(eNB->lte_gold_uespec_port5_table[0],eNB->frame_parms.Nid_cell,rnti);
-	eNB->do_precoding = 1;
+	for (i=0;i<eNB->num_RU;i++) eNB->RU_list[i]->do_precoding=1;
 	eNB->transmission_mode[UE_id] = 7;
 	break;
       default:
@@ -717,7 +764,7 @@ void phy_config_dedicated_scell_eNB(uint8_t Mod_id,
 {
 
 
-  uint8_t UE_id = find_ue(rnti,PHY_vars_eNB_g[Mod_id][0]);
+  uint8_t UE_id = find_ue(rnti,RC.eNB[Mod_id][0]);
   struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10 = sCellToAddMod_r10->radioResourceConfigDedicatedSCell_r10->physicalConfigDedicatedSCell_r10;
   //struct RadioResourceConfigCommonSCell_r10 *physicalConfigCommonSCell_r10 = sCellToAddMod_r10->radioResourceConfigCommonSCell_r10;
   //PhysCellId_t physCellId_r10 = sCellToAddMod_r10->cellIdentification_r10->physCellId_r10;
@@ -961,8 +1008,8 @@ void  phy_config_cba_rnti (module_id_t Mod_id,int CC_id,eNB_flag_t eNB_flag, uin
   } else {
     //for (i=index; i < NUMBER_OF_UE_MAX; i+=num_active_cba_groups){
     //  LOG_D(PHY,"[eNB %d] configure cba group %d with rnti %x for UE %d, num active cba grp %d\n",Mod_id, i%num_active_cba_groups, cba_rnti, i, num_active_cba_groups);
-    PHY_vars_eNB_g[Mod_id][CC_id]->ulsch[index]->num_active_cba_groups=num_active_cba_groups;
-    PHY_vars_eNB_g[Mod_id][CC_id]->ulsch[index]->cba_rnti[cba_group_id] = cba_rnti;
+    RC.eNB[Mod_id][CC_id]->ulsch[index]->num_active_cba_groups=num_active_cba_groups;
+    RC.eNB[Mod_id][CC_id]->ulsch[index]->cba_rnti[cba_group_id] = cba_rnti;
     //}
   }
 }
@@ -982,13 +1029,11 @@ void phy_init_lte_top(LTE_DL_FRAME_PARMS *frame_parms)
 
   phy_generate_viterbi_tables();
   phy_generate_viterbi_tables_lte();
-
   init_td8();
   init_td16();
 #ifdef __AVX2__
   init_td16avx2();
 #endif
-
   lte_sync_time_init(frame_parms);
 
   generate_ul_ref_sigs();
@@ -1075,7 +1120,7 @@ int phy_init_lte_ue(PHY_VARS_UE *ue,
   int i,j,k;
   int eNB_id;
 
-  printf("Initializing UE vars (abstraction %"PRIu8") for eNB TXant %"PRIu8", UE RXant %"PRIu8"\n",abstraction_flag,fp->nb_antennas_tx,fp->nb_antennas_rx);
+  LOG_D(PHY,"Initializing UE vars (abstraction %"PRIu8") for eNB TXant %"PRIu8", UE RXant %"PRIu8"\n",abstraction_flag,fp->nb_antennas_tx,fp->nb_antennas_rx);
   LOG_D(PHY,"[MSC_NEW][FRAME 00000][PHY_UE][MOD %02u][]\n", ue->Mod_id+NB_eNB_INST);
 
   // many memory allocation sizes are hard coded
@@ -1279,6 +1324,102 @@ int phy_init_lte_ue(PHY_VARS_UE *ue,
   return 0;
 }
 
+
+int phy_init_RU(RU_t *ru) {
+
+  LTE_DL_FRAME_PARMS *fp = &ru->frame_parms;
+  int i,j;
+  int p;
+  int re;
+
+  LOG_I(PHY,"Initializing RU signal buffers (if_south %s)\n",ru_if_types[ru->if_south]);
+
+  if (ru->if_south <= REMOTE_IF5) { // this means REMOTE_IF5 or LOCAL_RF, so allocate memory for time-domain signals 
+    // Time-domain signals
+    ru->common.txdata        = (int32_t**)malloc16(ru->nb_tx*sizeof(int32_t*));
+    ru->common.rxdata        = (int32_t**)malloc16(ru->nb_rx*sizeof(int32_t*) );
+
+
+    for (i=0; i<ru->nb_tx; i++) {
+      // Allocate 10 subframes of I/Q TX signal data (time) if not
+      ru->common.txdata[i]  = (int32_t*)malloc16_clear( fp->samples_per_tti*10*sizeof(int32_t) );
+
+      LOG_I(PHY,"[INIT] common.txdata[%d] = %p (%lu bytes)\n",i,ru->common.txdata[i],
+	     fp->samples_per_tti*10*sizeof(int32_t));
+
+    }
+    for (i=0;i<ru->nb_rx;i++) {
+      ru->common.rxdata[i] = (int32_t*)malloc16_clear( fp->samples_per_tti*10*sizeof(int32_t) );
+    }
+  } // IF5 or local RF
+  else {
+    LOG_I(PHY,"No rxdata/txdata for RU\n");
+    ru->common.txdata        = (int32_t**)NULL;
+    ru->common.rxdata        = (int32_t**)NULL;
+
+  }
+  if (ru->function != NGFI_RRU_IF5) { // we need to do RX/TX RU processing
+    ru->common.rxdata_7_5kHz = (int32_t**)malloc16(ru->nb_rx*sizeof(int32_t*) );
+    for (i=0;i<ru->nb_rx;i++) {
+      ru->common.rxdata_7_5kHz[i] = (int32_t*)malloc16_clear( 2*fp->samples_per_tti*2*sizeof(int32_t) );
+      LOG_I(PHY,"rxdata_7_5kHz[%d] %p for RU %d\n",i,ru->common.rxdata_7_5kHz[i],ru->idx);
+    }
+  
+
+    // allocate IFFT input buffers (TX)
+    ru->common.txdataF_BF = (int32_t **)malloc16(ru->nb_tx*sizeof(int32_t*));
+    LOG_I(PHY,"[INIT] common.txdata_BF= %p (%lu bytes)\n",ru->common.txdataF_BF,
+	  ru->nb_tx*sizeof(int32_t*));
+    for (i=0; i<ru->nb_tx; i++) {
+      ru->common.txdataF_BF[i] = (int32_t*)malloc16_clear(fp->symbols_per_tti*fp->ofdm_symbol_size*sizeof(int32_t) );
+      LOG_I(PHY,"txdataF_BF[%d] %p for RU %d\n",i,ru->common.txdataF_BF[i],ru->idx);
+    }
+    // allocate FFT output buffers (RX)
+    ru->common.rxdataF     = (int32_t**)malloc16(ru->nb_rx*sizeof(int32_t*) );
+    for (i=0; i<ru->nb_rx; i++) {    
+      // allocate 2 subframes of I/Q signal data (frequency)
+      ru->common.rxdataF[i] = (int32_t*)malloc16_clear(sizeof(int32_t)*(2*fp->ofdm_symbol_size*fp->symbols_per_tti) ); 
+      LOG_I(PHY,"rxdataF[%d] %p for RU %d\n",i,ru->common.rxdataF[i],ru->idx);
+    }
+
+    /* number of elements of an array X is computed as sizeof(X) / sizeof(X[0]) */
+    AssertFatal(ru->nb_rx <= sizeof(ru->prach_rxsigF) / sizeof(ru->prach_rxsigF[0]),
+		"nb_antennas_rx too large");
+    ru->prach_rxsigF = (int16_t**)malloc(ru->nb_rx * sizeof(int16_t*));
+    for (i=0; i<ru->nb_rx; i++) {
+      ru->prach_rxsigF[i] = (int16_t*)malloc16_clear( fp->ofdm_symbol_size*12*2*sizeof(int16_t) );
+      LOG_D(PHY,"[INIT] prach_vars->rxsigF[%d] = %p\n",i,ru->prach_rxsigF[i]);
+    }
+
+    for (i=0; i<RC.nb_inst; i++) {
+      for (p=0;p<15;p++) {
+	if (p<ru->eNB_list[i]->frame_parms.nb_antenna_ports_eNB || p==5) {
+	  ru->beam_weights[i][p] = (int32_t **)malloc16_clear(ru->nb_tx*sizeof(int32_t*));
+	  for (j=0; j<ru->nb_tx; j++) {
+	    ru->beam_weights[i][p][j] = (int32_t *)malloc16_clear(fp->ofdm_symbol_size*sizeof(int32_t));
+	    // antenna ports 0-3 are mapped on antennas 0-3
+	    // antenna port 4 is mapped on antenna 0
+	    // antenna ports 5-14 are mapped on all antennas 
+	    if (((i<4) && (i==j)) || ((i==4) && (j==0))) {
+	      for (re=0; re<fp->ofdm_symbol_size; re++) 
+		ru->beam_weights[i][p][j][re] = 0x00007fff; 
+	    }
+	    else if (i>4) {
+	      for (re=0; re<fp->ofdm_symbol_size; re++) 
+		ru->beam_weights[i][p][j][re] = 0x00007fff/ru->nb_tx; 
+	    }  
+	    LOG_D(PHY,"[INIT] lte_common_vars->beam_weights[%d][%d] = %p (%lu bytes)\n",
+		  i,j,ru->beam_weights[i][p][j],
+		  fp->ofdm_symbol_size*sizeof(int32_t)); 
+	  }
+	}
+      }
+    }
+  }
+  ru->common.sync_corr = (uint32_t*)malloc16_clear( LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*sizeof(uint32_t)*fp->samples_per_tti );
+
+}
+  
 int phy_init_lte_eNB(PHY_VARS_eNB *eNB,
                      unsigned char is_secondary_eNB,
                      unsigned char abstraction_flag)
@@ -1291,7 +1432,7 @@ int phy_init_lte_eNB(PHY_VARS_eNB *eNB,
   LTE_eNB_SRS* const srs_vars       = eNB->srs_vars;
   LTE_eNB_PRACH* const prach_vars   = &eNB->prach_vars;
   int i, j, eNB_id, UE_id; 
-  int re;
+
 
   eNB->total_dlsch_bitrate = 0;
   eNB->total_transmitted_bits = 0;
@@ -1303,248 +1444,124 @@ int phy_init_lte_eNB(PHY_VARS_eNB *eNB,
         fp->phich_config_common.phich_duration);
   LOG_D(PHY,"[MSC_NEW][FRAME 00000][PHY_eNB][MOD %02"PRIu8"][]\n", eNB->Mod_id);
 
-  if (eNB->node_function != NGFI_RRU_IF4p5) {
-    lte_gold(fp,eNB->lte_gold_table,fp->Nid_cell);
-    generate_pcfich_reg_mapping(fp);
-    generate_phich_reg_mapping(fp);
+  lte_gold(fp,eNB->lte_gold_table,fp->Nid_cell);
+  generate_pcfich_reg_mapping(fp);
+  generate_phich_reg_mapping(fp);
+  
+  for (UE_id=0; UE_id<NUMBER_OF_UE_MAX; UE_id++) {
+    eNB->first_run_timing_advance[UE_id] =
+      1; ///This flag used to be static. With multiple eNBs this does no longer work, hence we put it in the structure. However it has to be initialized with 1, which is performed here.
     
-    for (UE_id=0; UE_id<NUMBER_OF_UE_MAX; UE_id++) {
-      eNB->first_run_timing_advance[UE_id] =
-	1; ///This flag used to be static. With multiple eNBs this does no longer work, hence we put it in the structure. However it has to be initialized with 1, which is performed here.
-
-      // clear whole structure
-      bzero( &eNB->UE_stats[UE_id], sizeof(LTE_eNB_UE_stats) );
-      
-      eNB->physicalConfigDedicated[UE_id] = NULL;
-    }
+    // clear whole structure
+    bzero( &eNB->UE_stats[UE_id], sizeof(LTE_eNB_UE_stats) );
     
-    eNB->first_run_I0_measurements = 1; ///This flag used to be static. With multiple eNBs this does no longer work, hence we put it in the structure. However it has to be initialized with 1, which is performed here.
+    eNB->physicalConfigDedicated[UE_id] = NULL;
   }
+  
+  eNB->first_run_I0_measurements = 1; ///This flag used to be static. With multiple eNBs this does no longer work, hence we put it in the structure. However it has to be initialized with 1, which is performed here.
+  
 
-  //  for (eNB_id=0; eNB_id<3; eNB_id++) {
-  {
-    eNB_id=0;
-    if (abstraction_flag==0) {
-      
-      // TX vars
-      if (eNB->node_function != NGFI_RCC_IF4p5)
-	common_vars->txdata[eNB_id]  = (int32_t**)malloc16(fp->nb_antennas_tx*sizeof(int32_t*));
-      common_vars->txdataF[eNB_id] = (int32_t **)malloc16(NB_ANTENNA_PORTS_ENB*sizeof(int32_t*));
-      common_vars->txdataF_BF[eNB_id] = (int32_t **)malloc16(fp->nb_antennas_tx*sizeof(int32_t*));
-
-      if (eNB->node_function != NGFI_RRU_IF5) {
-	for (i=0; i<NB_ANTENNA_PORTS_ENB; i++) {
-	  if (i<fp->nb_antenna_ports_eNB || i==5) {
-	    common_vars->txdataF[eNB_id][i] = (int32_t*)malloc16_clear(fp->ofdm_symbol_size*fp->symbols_per_tti*10*sizeof(int32_t) );
-#ifdef DEBUG_PHY
-	    printf("[openair][LTE_PHY][INIT] common_vars->txdataF[%d][%d] = %p (%lu bytes)\n",
-		   eNB_id,i,common_vars->txdataF[eNB_id][i],
-		   fp->ofdm_symbol_size*fp->symbols_per_tti*10*sizeof(int32_t));
-#endif
-	  }
-	}
-      }
-      for (i=0; i<fp->nb_antennas_tx; i++) {
-	common_vars->txdataF_BF[eNB_id][i] = (int32_t*)malloc16_clear(fp->ofdm_symbol_size*sizeof(int32_t) );
-	if (eNB->node_function != NGFI_RCC_IF4p5)
-
-	  // Allocate 10 subframes of I/Q TX signal data (time) if not
-	  common_vars->txdata[eNB_id][i]  = (int32_t*)malloc16_clear( fp->samples_per_tti*10*sizeof(int32_t) );
+  if (abstraction_flag==0) {
+    
+    common_vars->txdataF = (int32_t **)malloc16(NB_ANTENNA_PORTS_ENB*sizeof(int32_t*));
+    common_vars->rxdataF = (int32_t **)malloc16(64*sizeof(int32_t*));
 
-#ifdef DEBUG_PHY
-	printf("[openair][LTE_PHY][INIT] common_vars->txdata[%d][%d] = %p (%lu bytes)\n",eNB_id,i,common_vars->txdata[eNB_id][i],
-	       fp->samples_per_tti*10*sizeof(int32_t));
-#endif
-      }
-      
-      for (i=0; i<NB_ANTENNA_PORTS_ENB; i++) {
-	if (i<fp->nb_antenna_ports_eNB || i==5) {
-	  common_vars->beam_weights[eNB_id][i] = (int32_t **)malloc16_clear(fp->nb_antennas_tx*sizeof(int32_t*));
-	  for (j=0; j<fp->nb_antennas_tx; j++) {
-	    common_vars->beam_weights[eNB_id][i][j] = (int32_t *)malloc16_clear(fp->ofdm_symbol_size*sizeof(int32_t));
-	    // antenna ports 0-3 are mapped on antennas 0-3
-	    // antenna port 4 is mapped on antenna 0
-	    // antenna ports 5-14 are mapped on all antennas 
-	    if (((i<4) && (i==j)) || ((i==4) && (j==0))) {
-	      for (re=0; re<fp->ofdm_symbol_size; re++) 
-		common_vars->beam_weights[eNB_id][i][j][re] = 0x00007fff; 
-	    }
-	    else if (i>4) {
-	      for (re=0; re<fp->ofdm_symbol_size; re++) 
-		common_vars->beam_weights[eNB_id][i][j][re] = 0x00007fff/fp->nb_antennas_tx; 
-	    }  
-#ifdef DEBUG_PHY
-	    msg("[openair][LTE_PHY][INIT] lte_common_vars->beam_weights[%d][%d][%d] = %p (%d bytes)\n",
-		eNB_id,i,j,common_vars->beam_weights[eNB_id][i][j],
-		fp->ofdm_symbol_size*sizeof(int32_t)); 
-#endif
-	  }
-	}
-      }
+    for (i=0; i<NB_ANTENNA_PORTS_ENB; i++) {
+      if (i<fp->nb_antenna_ports_eNB || i==5) {
+	common_vars->txdataF[i] = (int32_t*)malloc16_clear(fp->ofdm_symbol_size*fp->symbols_per_tti*10*sizeof(int32_t) );
 
-      // RX vars
-      if (eNB->node_function != NGFI_RCC_IF4p5) {
-	common_vars->rxdata[eNB_id]        = (int32_t**)malloc16(fp->nb_antennas_rx*sizeof(int32_t*) );
-	common_vars->rxdata_7_5kHz[eNB_id] = (int32_t**)malloc16(fp->nb_antennas_rx*sizeof(int32_t*) );
+	LOG_D(PHY,"[INIT] common_vars->txdataF[%d] = %p (%lu bytes)\n",
+	       i,common_vars->txdataF[i],
+	       fp->ofdm_symbol_size*fp->symbols_per_tti*10*sizeof(int32_t));
       }
-      common_vars->rxdataF[eNB_id]       = (int32_t**)malloc16(fp->nb_antennas_rx*sizeof(int32_t*) );
+    }
+        
 
-      for (i=0; i<fp->nb_antennas_rx; i++) {
-	if (eNB->node_function != NGFI_RCC_IF4p5) {
-	  // allocate 2 subframes of I/Q signal data (time) if not an RCC (no time-domain signals)
-	  common_vars->rxdata[eNB_id][i] = (int32_t*)malloc16_clear( fp->samples_per_tti*10*sizeof(int32_t) );
 
-	  if (eNB->node_function != NGFI_RRU_IF5)
-	    // allocate 2 subframes of I/Q signal data (time, 7.5 kHz offset)
-	    common_vars->rxdata_7_5kHz[eNB_id][i] = (int32_t*)malloc16_clear( 2*fp->samples_per_tti*2*sizeof(int32_t) );
-	}
-	if (eNB->node_function != NGFI_RRU_IF5)
-	  // allocate 2 subframes of I/Q signal data (frequency)
-	  common_vars->rxdataF[eNB_id][i] = (int32_t*)malloc16_clear(sizeof(int32_t)*(2*fp->ofdm_symbol_size*fp->symbols_per_tti) );
-#ifdef DEBUG_PHY
-	printf("[openair][LTE_PHY][INIT] common_vars->rxdata[%d][%d] = %p (%lu bytes)\n",eNB_id,i,common_vars->rxdata[eNB_id][i],fp->samples_per_tti*10*sizeof(int32_t));
-	if (eNB->node_function != NGFI_RRU_IF5)
-	  printf("[openair][LTE_PHY][INIT] common_vars->rxdata_7_5kHz[%d][%d] = %p (%lu bytes)\n",eNB_id,i,common_vars->rxdata_7_5kHz[eNB_id][i],fp->samples_per_tti*2*sizeof(int32_t));
-#endif
-        common_vars->rxdataF[eNB_id][i] = (int32_t*)malloc16_clear(sizeof(int32_t)*(fp->ofdm_symbol_size*fp->symbols_per_tti) );
-      }
-      
-      if ((eNB->node_function != NGFI_RRU_IF4p5)&&(eNB->node_function != NGFI_RRU_IF5)) {
-	// Channel estimates for SRS
-	for (UE_id=0; UE_id<NUMBER_OF_UE_MAX; UE_id++) {
-	  
-	  srs_vars[UE_id].srs_ch_estimates[eNB_id]      = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) );
-	  srs_vars[UE_id].srs_ch_estimates_time[eNB_id] = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) );
-	  
-	  for (i=0; i<fp->nb_antennas_rx; i++) {
-	    srs_vars[UE_id].srs_ch_estimates[eNB_id][i]      = (int32_t*)malloc16_clear( sizeof(int32_t)*fp->ofdm_symbol_size );
-	    srs_vars[UE_id].srs_ch_estimates_time[eNB_id][i] = (int32_t*)malloc16_clear( sizeof(int32_t)*fp->ofdm_symbol_size*2 );
-	  }
-	} //UE_id
+      // Channel estimates for SRS
+      for (UE_id=0; UE_id<NUMBER_OF_UE_MAX; UE_id++) {
 	
-	common_vars->sync_corr[eNB_id] = (uint32_t*)malloc16_clear( LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*sizeof(uint32_t)*fp->samples_per_tti );
-      }
-    } // abstraction_flag = 0
-    else { //UPLINK abstraction = 1
-      eNB->sinr_dB = (double*) malloc16_clear( fp->N_RB_DL*12*sizeof(double) );
-    }
-  } //eNB_id
-  
-  
+	srs_vars[UE_id].srs_ch_estimates      = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) );
+	srs_vars[UE_id].srs_ch_estimates_time = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) );
+	
+	for (i=0; i<fp->nb_antennas_rx; i++) {
+	  srs_vars[UE_id].srs_ch_estimates[i]      = (int32_t*)malloc16_clear( sizeof(int32_t)*fp->ofdm_symbol_size );
+	  srs_vars[UE_id].srs_ch_estimates_time[i] = (int32_t*)malloc16_clear( sizeof(int32_t)*fp->ofdm_symbol_size*2 );
+	}
+      } //UE_id
+  } // abstraction_flag = 0
+  else { //UPLINK abstraction = 1
+    eNB->sinr_dB = (double*) malloc16_clear( fp->N_RB_DL*12*sizeof(double) );
+  }
+
   
   if (abstraction_flag==0) {
-    if ((eNB->node_function != NGFI_RRU_IF4p5)&&(eNB->node_function != NGFI_RRU_IF5)) {
-      generate_ul_ref_sigs_rx();
-      
-      // 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));
-      }
+    generate_ul_ref_sigs_rx();
+    
+    // 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));
     }
   }
   
   
   
-  // ULSCH VARS, skip if NFGI_RRU_IF4
   
-  if ((eNB->node_function!=NGFI_RRU_IF4p5)&&(eNB->node_function != NGFI_RRU_IF5))
-    prach_vars->prachF = (int16_t*)malloc16_clear( 1024*2*sizeof(int16_t) );
   
-  /* number of elements of an array X is computed as sizeof(X) / sizeof(X[0]) */
+  prach_vars->prachF = (int16_t*)malloc16_clear( 1024*2*sizeof(int16_t) );
+  
+  /* number of elements of an array X is computed as sizeof(X) / sizeof(X[0]) 
   AssertFatal(fp->nb_antennas_rx <= sizeof(prach_vars->rxsigF) / sizeof(prach_vars->rxsigF[0]),
               "nb_antennas_rx too large");
   for (i=0; i<fp->nb_antennas_rx; i++) {
     prach_vars->rxsigF[i] = (int16_t*)malloc16_clear( fp->ofdm_symbol_size*12*2*sizeof(int16_t) );
-#ifdef DEBUG_PHY
-    printf("[openair][LTE_PHY][INIT] prach_vars->rxsigF[%d] = %p\n",i,prach_vars->rxsigF[i]);
-#endif
-  }
+    LOG_D(PHY,"[INIT] prach_vars->rxsigF[%d] = %p\n",i,prach_vars->rxsigF[i]);
+    }*/
   
-  if ((eNB->node_function != NGFI_RRU_IF4p5)&&(eNB->node_function != NGFI_RRU_IF5)) {
-    AssertFatal(fp->nb_antennas_rx <= sizeof(prach_vars->prach_ifft) / sizeof(prach_vars->prach_ifft[0]),
-		"nb_antennas_rx too large");
-    for (i=0; i<fp->nb_antennas_rx; i++) {
-      prach_vars->prach_ifft[i] = (int16_t*)malloc16_clear(1024*2*sizeof(int16_t));
-#ifdef DEBUG_PHY
-      printf("[openair][LTE_PHY][INIT] prach_vars->prach_ifft[%d] = %p\n",i,prach_vars->prach_ifft[i]);
-#endif
-    }
 
-    for (UE_id=0; UE_id<NUMBER_OF_UE_MAX; UE_id++) {
-      
-      //FIXME
-      pusch_vars[UE_id] = (LTE_eNB_PUSCH*)malloc16_clear( NUMBER_OF_UE_MAX*sizeof(LTE_eNB_PUSCH) );
-      
-      if (abstraction_flag==0) {
-	for (eNB_id=0; eNB_id<3; eNB_id++) {
-	  
-	  pusch_vars[UE_id]->rxdataF_ext[eNB_id]      = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) );
-	  pusch_vars[UE_id]->rxdataF_ext2[eNB_id]     = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) );
-	  pusch_vars[UE_id]->drs_ch_estimates[eNB_id] = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) );
-	  pusch_vars[UE_id]->drs_ch_estimates_time[eNB_id] = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) );
-	  pusch_vars[UE_id]->rxdataF_comp[eNB_id]     = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) );
-	  pusch_vars[UE_id]->ul_ch_mag[eNB_id]  = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) );
-	  pusch_vars[UE_id]->ul_ch_magb[eNB_id] = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) );
-	  
-	  for (i=0; i<fp->nb_antennas_rx; i++) {
-	    // RK 2 times because of output format of FFT!
-	    // FIXME We should get rid of this
-	    pusch_vars[UE_id]->rxdataF_ext[eNB_id][i]      = (int32_t*)malloc16_clear( 2*sizeof(int32_t)*fp->N_RB_UL*12*fp->symbols_per_tti );
-	    pusch_vars[UE_id]->rxdataF_ext2[eNB_id][i]     = (int32_t*)malloc16_clear( sizeof(int32_t)*fp->N_RB_UL*12*fp->symbols_per_tti );
-	    pusch_vars[UE_id]->drs_ch_estimates[eNB_id][i] = (int32_t*)malloc16_clear( sizeof(int32_t)*fp->N_RB_UL*12*fp->symbols_per_tti );
-	    pusch_vars[UE_id]->drs_ch_estimates_time[eNB_id][i] = (int32_t*)malloc16_clear( 2*2*sizeof(int32_t)*fp->ofdm_symbol_size );
-	    pusch_vars[UE_id]->rxdataF_comp[eNB_id][i]     = (int32_t*)malloc16_clear( sizeof(int32_t)*fp->N_RB_UL*12*fp->symbols_per_tti );
-	    pusch_vars[UE_id]->ul_ch_mag[eNB_id][i]  = (int32_t*)malloc16_clear( fp->symbols_per_tti*sizeof(int32_t)*fp->N_RB_UL*12 );
-	    pusch_vars[UE_id]->ul_ch_magb[eNB_id][i] = (int32_t*)malloc16_clear( fp->symbols_per_tti*sizeof(int32_t)*fp->N_RB_UL*12 );
-	  }
-	} //eNB_id
-	
-	pusch_vars[UE_id]->llr = (int16_t*)malloc16_clear( (8*((3*8*6144)+12))*sizeof(int16_t) );
-      } // abstraction_flag
-    } //UE_id
 
+  
+  for (UE_id=0; UE_id<NUMBER_OF_UE_MAX; UE_id++) {
     
-    if (abstraction_flag==0) {
-      if (is_secondary_eNB) {
-	for (eNB_id=0; eNB_id<3; eNB_id++) {
-	  eNB->dl_precoder_SeNB[eNB_id] = (int **)malloc16(4*sizeof(int*));
-	  
-	  if (eNB->dl_precoder_SeNB[eNB_id]) {
-#ifdef DEBUG_PHY
-	    printf("[openair][SECSYS_PHY][INIT] eNB->dl_precoder_SeNB[%d] allocated at %p\n",eNB_id,
-		eNB->dl_precoder_SeNB[eNB_id]);
-#endif
-	  } else {
-	    printf("[openair][SECSYS_PHY][INIT] eNB->dl_precoder_SeNB[%d] not allocated\n",eNB_id);
-	    return(-1);
-	  }
-	  
-	  for (j=0; j<fp->nb_antennas_tx; j++) {
-	    eNB->dl_precoder_SeNB[eNB_id][j] = (int *)malloc16(2*sizeof(int)*(fp->ofdm_symbol_size)); // repeated format (hence the '2*')
-	    
-	    if (eNB->dl_precoder_SeNB[eNB_id][j]) {
-#ifdef DEBUG_PHY
-	      printf("[openair][LTE_PHY][INIT] eNB->dl_precoder_SeNB[%d][%d] allocated at %p\n",eNB_id,j,
-		  eNB->dl_precoder_SeNB[eNB_id][j]);
-#endif
-	      memset(eNB->dl_precoder_SeNB[eNB_id][j],0,2*sizeof(int)*(fp->ofdm_symbol_size));
-	    } else {
-	      printf("[openair][LTE_PHY][INIT] eNB->dl_precoder_SeNB[%d][%d] not allocated\n",eNB_id,j);
-	      return(-1);
-	    }
-	  } //for(j=...nb_antennas_tx
-	  
-	} //for(eNB_id...
-      }
-    }
+    //FIXME
+    pusch_vars[UE_id] = (LTE_eNB_PUSCH*)malloc16_clear( NUMBER_OF_UE_MAX*sizeof(LTE_eNB_PUSCH) );
     
-    for (UE_id=0; UE_id<NUMBER_OF_UE_MAX; UE_id++)
-      eNB->UE_stats_ptr[UE_id] = &eNB->UE_stats[UE_id];
+    if (abstraction_flag==0) {
+      for (eNB_id=0; eNB_id<3; eNB_id++) {
+	
+	pusch_vars[UE_id]->rxdataF_ext      = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) );
+	pusch_vars[UE_id]->rxdataF_ext2     = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) );
+	pusch_vars[UE_id]->drs_ch_estimates = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) );
+	pusch_vars[UE_id]->drs_ch_estimates_time = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) );
+	pusch_vars[UE_id]->rxdataF_comp     = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) );
+	pusch_vars[UE_id]->ul_ch_mag  = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) );
+	pusch_vars[UE_id]->ul_ch_magb = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) );
+	
+	for (i=0; i<fp->nb_antennas_rx; i++) {
+	  // RK 2 times because of output format of FFT!
+	  // FIXME We should get rid of this
+	  pusch_vars[UE_id]->rxdataF_ext[i]      = (int32_t*)malloc16_clear( 2*sizeof(int32_t)*fp->N_RB_UL*12*fp->symbols_per_tti );
+	  pusch_vars[UE_id]->rxdataF_ext2[i]     = (int32_t*)malloc16_clear( sizeof(int32_t)*fp->N_RB_UL*12*fp->symbols_per_tti );
+	  pusch_vars[UE_id]->drs_ch_estimates[i] = (int32_t*)malloc16_clear( sizeof(int32_t)*fp->N_RB_UL*12*fp->symbols_per_tti );
+	  pusch_vars[UE_id]->drs_ch_estimates_time[i] = (int32_t*)malloc16_clear( 2*2*sizeof(int32_t)*fp->ofdm_symbol_size );
+	  pusch_vars[UE_id]->rxdataF_comp[i]     = (int32_t*)malloc16_clear( sizeof(int32_t)*fp->N_RB_UL*12*fp->symbols_per_tti );
+	  pusch_vars[UE_id]->ul_ch_mag[i]  = (int32_t*)malloc16_clear( fp->symbols_per_tti*sizeof(int32_t)*fp->N_RB_UL*12 );
+	  pusch_vars[UE_id]->ul_ch_magb[i] = (int32_t*)malloc16_clear( fp->symbols_per_tti*sizeof(int32_t)*fp->N_RB_UL*12 );
+	}
+      } //eNB_id
+      
+      pusch_vars[UE_id]->llr = (int16_t*)malloc16_clear( (8*((3*8*6144)+12))*sizeof(int16_t) );
+    } // abstraction_flag
+  } //UE_id
+
     
-    eNB->pdsch_config_dedicated->p_a = dB0; //defaul value until overwritten by RRCConnectionReconfiguration
+  for (UE_id=0; UE_id<NUMBER_OF_UE_MAX; UE_id++)
+    eNB->UE_stats_ptr[UE_id] = &eNB->UE_stats[UE_id];
+  
+  eNB->pdsch_config_dedicated->p_a = dB0; //defaul value until overwritten by RRCConnectionReconfiguration
+  
+  init_prach_tables(839);
 
-    init_prach_tables(839);
-  } // node_function != NGFI_RRU_IF4p5
 
   return (0);
 
diff --git a/openair1/PHY/INIT/lte_param_init.c b/openair1/PHY/INIT/lte_param_init.c
index 4625eba430..006e12b50e 100644
--- a/openair1/PHY/INIT/lte_param_init.c
+++ b/openair1/PHY/INIT/lte_param_init.c
@@ -82,7 +82,6 @@ void lte_param_init(unsigned char N_tx_port_eNB,
   //  frame_parms->Bsrs = 0;
   //  frame_parms->kTC = 0;44
   //  frame_parms->n_RRC = 0;
-  frame_parms->mode1_flag = (transmission_mode == 1 || transmission_mode ==7)? 1 : 0;
 
   init_frame_parms(frame_parms,osf);
 
diff --git a/openair1/PHY/INIT/lte_parms.c b/openair1/PHY/INIT/lte_parms.c
index f0c63df9e6..c0a80f1686 100644
--- a/openair1/PHY/INIT/lte_parms.c
+++ b/openair1/PHY/INIT/lte_parms.c
@@ -204,7 +204,6 @@ void dump_frame_parms(LTE_DL_FRAME_PARMS *frame_parms)
   printf("frame_parms->frame_type=%d\n",frame_parms->frame_type);
   printf("frame_parms->tdd_config=%d\n",frame_parms->tdd_config);
   printf("frame_parms->tdd_config_S=%d\n",frame_parms->tdd_config_S);
-  printf("frame_parms->mode1_flag=%d\n",frame_parms->mode1_flag);
   printf("frame_parms->nb_antenna_ports_eNB=%d\n",frame_parms->nb_antenna_ports_eNB);
   printf("frame_parms->nb_antennas_tx=%d\n",frame_parms->nb_antennas_tx);
   printf("frame_parms->nb_antennas_rx=%d\n",frame_parms->nb_antennas_rx);
diff --git a/openair1/PHY/LTE_ESTIMATION/defs.h b/openair1/PHY/LTE_ESTIMATION/defs.h
index 08615119ef..1d5c1b28fa 100644
--- a/openair1/PHY/LTE_ESTIMATION/defs.h
+++ b/openair1/PHY/LTE_ESTIMATION/defs.h
@@ -219,22 +219,20 @@ void phy_adjust_gain (PHY_VARS_UE *phy_vars_ue,
 
 int lte_ul_channel_estimation(PHY_VARS_eNB *phy_vars_eNB,
 			      eNB_rxtx_proc_t *proc,
-                              module_id_t eNB_id,
                               module_id_t UE_id,
                               uint8_t l,
-                              uint8_t Ns,
-                              uint8_t cooperation_flag);
+                              uint8_t Ns);
+
 
 int16_t lte_ul_freq_offset_estimation(LTE_DL_FRAME_PARMS *frame_parms,
                                       int32_t *ul_ch_estimates,
                                       uint16_t nb_rb);
 
 int lte_srs_channel_estimation(LTE_DL_FRAME_PARMS *frame_parms,
-                               LTE_eNB_COMMON *eNb_common_vars,
-                               LTE_eNB_SRS *eNb_srs_vars,
+                               LTE_eNB_COMMON *eNB_common_vars,
+                               LTE_eNB_SRS *eNB_srs_vars,
                                SOUNDINGRS_UL_CONFIG_DEDICATED *soundingrs_ul_config_dedicated,
-                               unsigned char sub_frame_number,
-                               unsigned char eNb_id);
+                               unsigned char sub_frame_number);
 
 int lte_est_timing_advance(LTE_DL_FRAME_PARMS *frame_parms,
                            LTE_eNB_SRS *lte_eNb_srs,
diff --git a/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync.c b/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync.c
index cefa6fd99f..807c4e3e0a 100644
--- a/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync.c
+++ b/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync.c
@@ -134,23 +134,23 @@ int lte_est_timing_advance(LTE_DL_FRAME_PARMS *frame_parms,
       // do ifft of channel estimate
       switch(frame_parms->N_RB_DL) {
       case 6:
-	dft128((int16_t*) &lte_eNB_srs->srs_ch_estimates[ind][aa][0],
-	       (int16_t*) lte_eNB_srs->srs_ch_estimates_time[ind][aa],
+	dft128((int16_t*) &lte_eNB_srs->srs_ch_estimates[aa][0],
+	       (int16_t*) lte_eNB_srs->srs_ch_estimates_time[aa],
 	       1);
 	break;
       case 25:
-	dft512((int16_t*) &lte_eNB_srs->srs_ch_estimates[ind][aa][0],
-	       (int16_t*) lte_eNB_srs->srs_ch_estimates_time[ind][aa],
+	dft512((int16_t*) &lte_eNB_srs->srs_ch_estimates[aa][0],
+	       (int16_t*) lte_eNB_srs->srs_ch_estimates_time[aa],
 	       1);
 	break;
       case 50:
-	dft1024((int16_t*) &lte_eNB_srs->srs_ch_estimates[ind][aa][0],
-		(int16_t*) lte_eNB_srs->srs_ch_estimates_time[ind][aa],
+	dft1024((int16_t*) &lte_eNB_srs->srs_ch_estimates[aa][0],
+		(int16_t*) lte_eNB_srs->srs_ch_estimates_time[aa],
 		1);
 	break;
       case 100:
-	dft2048((int16_t*) &lte_eNB_srs->srs_ch_estimates[ind][aa][0],
-	       (int16_t*) lte_eNB_srs->srs_ch_estimates_time[ind][aa],
+	dft2048((int16_t*) &lte_eNB_srs->srs_ch_estimates[aa][0],
+	       (int16_t*) lte_eNB_srs->srs_ch_estimates_time[aa],
 	       1);
 	break;
       }
@@ -158,7 +158,7 @@ int lte_est_timing_advance(LTE_DL_FRAME_PARMS *frame_parms,
 #ifdef DEBUG_PHY
       sprintf(fname,"srs_ch_estimates_time_%d%d.m",ind,aa);
       sprintf(vname,"srs_time_%d%d",ind,aa);
-      write_output(fname,vname,lte_eNB_srs->srs_ch_estimates_time[ind][aa],frame_parms->ofdm_symbol_size*2,2,1);
+      write_output(fname,vname,lte_eNB_srs->srs_ch_estimates_time[aa],frame_parms->ofdm_symbol_size*2,2,1);
 #endif
 #endif
     }
@@ -169,8 +169,8 @@ int lte_est_timing_advance(LTE_DL_FRAME_PARMS *frame_parms,
       temp = 0;
 
       for (aa=0; aa<frame_parms->nb_antennas_rx; aa++) {
-        Re = ((int16_t*)lte_eNB_srs->srs_ch_estimates_time[ind][aa])[(i<<1)];
-        Im = ((int16_t*)lte_eNB_srs->srs_ch_estimates_time[ind][aa])[1+(i<<1)];
+        Re = ((int16_t*)lte_eNB_srs->srs_ch_estimates_time[aa])[(i<<1)];
+        Im = ((int16_t*)lte_eNB_srs->srs_ch_estimates_time[aa])[1+(i<<1)];
         temp += (Re*Re/2) + (Im*Im/2);
       }
 
diff --git a/openair1/PHY/LTE_ESTIMATION/lte_dl_bf_channel_estimation.c b/openair1/PHY/LTE_ESTIMATION/lte_dl_bf_channel_estimation.c
index df6a55eaf3..3621425aed 100644
--- a/openair1/PHY/LTE_ESTIMATION/lte_dl_bf_channel_estimation.c
+++ b/openair1/PHY/LTE_ESTIMATION/lte_dl_bf_channel_estimation.c
@@ -200,7 +200,7 @@ int lte_dl_bf_channel_estimation(PHY_VARS_UE *phy_vars_ue,
                                            phy_vars_ue->ch_est_alpha,dl_bf_ch-(frame_parms->ofdm_symbol_size<<1),
                                            1,frame_parms->ofdm_symbol_size);
       } else {
-        msg("lte_dl_bf_channel_estimation: beamforming channel estimation not supported for TM7 Extended CP.\n"); // phy_vars_ue->ch_est_beta should be defined equaling 1/3
+        LOG_E(PHY,"lte_dl_bf_channel_estimation: beamforming channel estimation not supported for TM7 Extended CP.\n"); // phy_vars_ue->ch_est_beta should be defined equaling 1/3
       }
     }
     //estimation and interpolation
@@ -241,11 +241,11 @@ int lte_dl_bf_channel_estimation(PHY_VARS_UE *phy_vars_ue,
                 ch[1] = (short)(((int)pil[0]*rxF[17] + (int)pil[1]*rxF[16])>>15);
                 multadd_real_vector_complex_scalar(fr,ch,dl_bf_ch,16);
               } else {
-                msg("lte_dl_bf_channel_estimation(lte_dl_bf_channel_estimation.c):TM7 beamgforming channel estimation not supported for extented CP\n");
+                LOG_E(PHY,"lte_dl_bf_channel_estimation(lte_dl_bf_channel_estimation.c):TM7 beamgforming channel estimation not supported for extented CP\n");
                 exit(-1);
               }
             } else {
-              msg("lte_dl_bf_channel_estimation(lte_dl_bf_channel_estimation.c): transmission mode not supported.\n");
+              LOG_E(PHY,"lte_dl_bf_channel_estimation(lte_dl_bf_channel_estimation.c): transmission mode not supported.\n");
             }
           }
           nb_rb++;
@@ -395,12 +395,12 @@ int lte_dl_bf_channel_estimation(PHY_VARS_UE *phy_vars_ue,
 
                }  
              } else {
-              msg("lte_dl_bf_channel_estimation(lte_dl_bf_channel_estimation.c):TM7 beamgforming channel estimation not supported for extented CP\n");
-              exit(-1);
+		LOG_E(PHY,"lte_dl_bf_channel_estimation(lte_dl_bf_channel_estimation.c):TM7 beamgforming channel estimation not supported for extented CP\n");
+		exit(-1);
              }
           
            } else {
-            msg("lte_dl_bf_channel_estimation(lte_dl_bf_channel_estimation.c):transmission mode not supported.\n");
+	      LOG_E(PHY,"lte_dl_bf_channel_estimation(lte_dl_bf_channel_estimation.c):transmission mode not supported.\n");
            }
          }       
          nb_rb++;
@@ -644,12 +644,12 @@ int lte_dl_bf_channel_estimation(PHY_VARS_UE *phy_vars_ue,
 
                 }
               } else {
-                msg("lte_dl_bf_channel_estimation(lte_dl_bf_channel_estimation.c):TM7 beamgforming channel estimation not supported for extented CP\n");
+                LOG_E(PHY,"lte_dl_bf_channel_estimation(lte_dl_bf_channel_estimation.c):TM7 beamgforming channel estimation not supported for extented CP\n");
                 exit(-1);
               }
             
             } else {
-              msg("lte_dl_bf_channel_estimation(lte_dl_bf_channel_estimation.c):transmission mode not supported.\n");
+              LOG_E(PHY,"lte_dl_bf_channel_estimation(lte_dl_bf_channel_estimation.c):transmission mode not supported.\n");
             }
           }
           nb_rb++;
@@ -732,10 +732,10 @@ int lte_dl_bf_channel_estimation(PHY_VARS_UE *phy_vars_ue,
             }
 
           } else {
-            msg("lte_dl_bf_channel_estimation:temporal interpolation not supported for TM7 extented CP.\n");
+            LOG_E(PHY,"lte_dl_bf_channel_estimation:temporal interpolation not supported for TM7 extented CP.\n");
           }
         } else {
-          msg("lte_dl_bf_channel_estimation:temporal interpolation not supported for this beamforming mode.\n");
+          LOG_E(PHY,"lte_dl_bf_channel_estimation:temporal interpolation not supported for this beamforming mode.\n");
         } 
       }
     }
diff --git a/openair1/PHY/LTE_ESTIMATION/lte_dl_channel_estimation.c b/openair1/PHY/LTE_ESTIMATION/lte_dl_channel_estimation.c
index b34331eb8d..262443cf43 100644
--- a/openair1/PHY/LTE_ESTIMATION/lte_dl_channel_estimation.c
+++ b/openair1/PHY/LTE_ESTIMATION/lte_dl_channel_estimation.c
@@ -75,7 +75,7 @@ int lte_dl_channel_estimation(PHY_VARS_UE *ue,
   else if ((p==1) && (l>0))
     nu = 0;
   else {
-    msg("lte_dl_channel_estimation: p %d, l %d -> ERROR\n",p,l);
+    LOG_E(PHY,"lte_dl_channel_estimation: p %d, l %d -> ERROR\n",p,l);
     return(-1);
   }
 
@@ -167,7 +167,7 @@ int lte_dl_channel_estimation(PHY_VARS_UE *ue,
     break;
 
   default:
-    msg("lte_dl_channel_estimation: k=%d -> ERROR\n",k);
+    LOG_E(PHY,"lte_dl_channel_estimation: k=%d -> ERROR\n",k);
     return(-1);
     break;
   }
@@ -622,7 +622,7 @@ int lte_dl_channel_estimation(PHY_VARS_UE *ue,
 
       }
     } else {
-      msg("channel estimation not implemented for ue->frame_parms.N_RB_DL = %d\n",ue->frame_parms.N_RB_DL);
+      LOG_E(PHY,"channel estimation not implemented for ue->frame_parms.N_RB_DL = %d\n",ue->frame_parms.N_RB_DL);
     }
 
 
diff --git a/openair1/PHY/LTE_ESTIMATION/lte_eNB_measurements.c b/openair1/PHY/LTE_ESTIMATION/lte_eNB_measurements.c
index a1d315dfed..31136b9eb6 100644
--- a/openair1/PHY/LTE_ESTIMATION/lte_eNB_measurements.c
+++ b/openair1/PHY/LTE_ESTIMATION/lte_eNB_measurements.c
@@ -29,7 +29,7 @@
 #define k1 1024
 #define k2 (1024-k1)
 
-int32_t rx_power_avg_eNB[3][3];
+int32_t rx_power_avg_eNB[3];
 
 
 void lte_eNB_I0_measurements(PHY_VARS_eNB *eNB,
@@ -40,7 +40,7 @@ void lte_eNB_I0_measurements(PHY_VARS_eNB *eNB,
 
   LTE_eNB_COMMON *common_vars = &eNB->common_vars;
   LTE_DL_FRAME_PARMS *frame_parms = &eNB->frame_parms;
-  PHY_MEASUREMENTS_eNB *measurements = &eNB->measurements[eNB_id];
+  PHY_MEASUREMENTS_eNB *measurements = &eNB->measurements;
   uint32_t *rb_mask = eNB->rb_mask_ul;
 
   uint32_t aarx /* ,rx_power_correction */;
@@ -54,23 +54,26 @@ void lte_eNB_I0_measurements(PHY_VARS_eNB *eNB,
 
   measurements->n0_power_tot = 0;
 
-  for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
-    if (clear == 1)
-      measurements->n0_power[aarx]=0;
-
-
-    measurements->n0_power[aarx] = ((k1*signal_energy(&common_vars->rxdata[eNB_id][aarx][(frame_parms->samples_per_tti<<1) -frame_parms->ofdm_symbol_size],
-							  frame_parms->ofdm_symbol_size)) + k2*measurements->n0_power[aarx])>>10;
-    //measurements->n0_power[aarx] = (measurements->n0_power[aarx]) * 12*frame_parms->N_RB_DL)/(frame_parms->ofdm_symbol_size);
-    measurements->n0_power_dB[aarx] = (unsigned short) dB_fixed(measurements->n0_power[aarx]);
-    measurements->n0_power_tot +=  measurements->n0_power[aarx];
-  }
-
-  measurements->n0_power_tot_dB = (unsigned short) dB_fixed(measurements->n0_power_tot);
+  if (common_vars->rxdata!=NULL) {
+    for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
+      if (clear == 1)
+	measurements->n0_power[aarx]=0;
+      
+      
+      measurements->n0_power[aarx] = ((k1*signal_energy(&common_vars->rxdata[aarx][(frame_parms->samples_per_tti<<1) -frame_parms->ofdm_symbol_size],
+							frame_parms->ofdm_symbol_size)) + k2*measurements->n0_power[aarx])>>10;
+      //measurements->n0_power[aarx] = (measurements->n0_power[aarx]) * 12*frame_parms->N_RB_DL)/(frame_parms->ofdm_symbol_size);
+      measurements->n0_power_dB[aarx] = (unsigned short) dB_fixed(measurements->n0_power[aarx]);
+      measurements->n0_power_tot +=  measurements->n0_power[aarx];
+    }
+  
 
-  measurements->n0_power_tot_dBm = measurements->n0_power_tot_dB - eNB->rx_total_gain_dB;
+    measurements->n0_power_tot_dB = (unsigned short) dB_fixed(measurements->n0_power_tot);
+    
+    measurements->n0_power_tot_dBm = measurements->n0_power_tot_dB - eNB->rx_total_gain_dB;
   //      printf("n0_power %d\n",measurements->n0_power_tot_dB);
 
+  }
 
   for (rb=0; rb<frame_parms->N_RB_UL; rb++) {
 
@@ -81,7 +84,7 @@ void lte_eNB_I0_measurements(PHY_VARS_eNB *eNB,
       // select the 7th symbol in an uplink subframe
 	offset = (frame_parms->first_carrier_offset + (rb*12))%frame_parms->ofdm_symbol_size;
 	offset += (7*frame_parms->ofdm_symbol_size);
-	ul_ch  = &common_vars->rxdataF[eNB_id][aarx][offset];
+	ul_ch  = &common_vars->rxdataF[aarx][offset];
 	len = 12;
 	// just do first half of middle PRB for odd number of PRBs
 	if (((frame_parms->N_RB_UL&1) == 1) && 
@@ -117,7 +120,7 @@ void lte_eNB_srs_measurements(PHY_VARS_eNB *eNB,
                               unsigned char init_averaging)
 {
   LTE_DL_FRAME_PARMS *frame_parms = &eNB->frame_parms;
-  PHY_MEASUREMENTS_eNB *measurements = &eNB->measurements[eNB_id];
+  PHY_MEASUREMENTS_eNB *measurements = &eNB->measurements;
   LTE_eNB_SRS *srs_vars = &eNB->srs_vars[UE_id];
 
   int32_t aarx,rx_power_correction;
@@ -128,7 +131,7 @@ void lte_eNB_srs_measurements(PHY_VARS_eNB *eNB,
   //printf("Running eNB_srs_measurements for eNB_id %d\n",eNB_id);
 
   if (init_averaging == 1)
-    rx_power_avg_eNB[eNB_id][UE_id] = 0;
+    rx_power_avg_eNB[UE_id] = 0;
 
   rx_power = 0;
 
@@ -145,9 +148,9 @@ void lte_eNB_srs_measurements(PHY_VARS_eNB *eNB,
 
 
     measurements->rx_spatial_power[UE_id][0][aarx] =
-      ((signal_energy_nodc(&srs_vars->srs_ch_estimates[eNB_id][aarx][frame_parms->first_carrier_offset],
+      ((signal_energy_nodc(&srs_vars->srs_ch_estimates[aarx][frame_parms->first_carrier_offset],
                            (frame_parms->N_RB_DL*6)) +
-        signal_energy_nodc(&srs_vars->srs_ch_estimates[eNB_id][aarx][1],
+        signal_energy_nodc(&srs_vars->srs_ch_estimates[aarx][1],
                            (frame_parms->N_RB_DL*6)))*rx_power_correction) -
       measurements->n0_power[aarx];
 
@@ -169,14 +172,14 @@ void lte_eNB_srs_measurements(PHY_VARS_eNB *eNB,
 
   //    measurements->rx_avg_power_dB[UE_id]/=frame_parms->nb_antennas_rx;
   if (init_averaging == 0)
-    rx_power_avg_eNB[UE_id][eNB_id] = ((k1*rx_power_avg_eNB[UE_id][eNB_id]) + (k2*rx_power))>>10;
+    rx_power_avg_eNB[UE_id] = ((k1*rx_power_avg_eNB[UE_id]) + (k2*rx_power))>>10;
   else
-    rx_power_avg_eNB[UE_id][eNB_id] = rx_power;
+    rx_power_avg_eNB[UE_id] = rx_power;
 
   measurements->wideband_cqi_tot[UE_id] = dB_fixed2(rx_power,2*measurements->n0_power_tot);
   // times 2 since we have noise only in the odd carriers of the srs comb
 
-  measurements->rx_rssi_dBm[UE_id] = (int32_t)dB_fixed(rx_power_avg_eNB[UE_id][eNB_id])-eNB->rx_total_gain_dB;
+  measurements->rx_rssi_dBm[UE_id] = (int32_t)dB_fixed(rx_power_avg_eNB[UE_id])-eNB->rx_total_gain_dB;
 
 
 
@@ -188,9 +191,9 @@ void lte_eNB_srs_measurements(PHY_VARS_eNB *eNB,
 
       //      printf("common_vars->srs_ch_estimates[0] => %x\n",common_vars->srs_ch_estimates[0]);
       if (rb < 12)
-        ul_ch    = &srs_vars->srs_ch_estimates[eNB_id][aarx][frame_parms->first_carrier_offset + (rb*12)];
+        ul_ch    = &srs_vars->srs_ch_estimates[aarx][frame_parms->first_carrier_offset + (rb*12)];
       else if (rb>12)
-        ul_ch    = &srs_vars->srs_ch_estimates[eNB_id][aarx][6 + (rb-13)*12];
+        ul_ch    = &srs_vars->srs_ch_estimates[aarx][6 + (rb-13)*12];
       else {
         measurements->subband_cqi_dB[UE_id][aarx][rb] = 0;
         continue;
@@ -210,7 +213,7 @@ void lte_eNB_srs_measurements(PHY_VARS_eNB *eNB,
           2*measurements->n0_power[aarx]);
       // 2*n0_power since we have noise from the odd carriers in the comb of the srs
 
-      //    msg("subband_cqi[%d][%d][%d] => %d (%d dB)\n",eNB_id,aarx,rb,measurements->subband_cqi[eNB_id][aarx][rb],measurements->subband_cqi_dB[eNB_id][aarx][rb]);
+      //    msg("subband_cqi[%d][%d][%d] => %d (%d dB)\n",eNB_id,aarx,rb,measurements->subband_cqi[aarx][rb],measurements->subband_cqi_dB[aarx][rb]);
     }
 
   }
diff --git a/openair1/PHY/LTE_ESTIMATION/lte_est_freq_offset.c b/openair1/PHY/LTE_ESTIMATION/lte_est_freq_offset.c
index d713cc0163..736a9a412f 100644
--- a/openair1/PHY/LTE_ESTIMATION/lte_est_freq_offset.c
+++ b/openair1/PHY/LTE_ESTIMATION/lte_est_freq_offset.c
@@ -118,7 +118,7 @@ int lte_est_freq_offset(int **dl_ch_estimates,
   ch_offset = (l*(frame_parms->ofdm_symbol_size));
 
   if ((l!=0) && (l!=(4-frame_parms->Ncp))) {
-    msg("lte_est_freq_offset: l (%d) must be 0 or %d\n",l,4-frame_parms->Ncp);
+    LOG_D(PHY,"lte_est_freq_offset: l (%d) must be 0 or %d\n",l,4-frame_parms->Ncp);
     return(-1);
   }
 
@@ -208,7 +208,7 @@ int lte_mbsfn_est_freq_offset(int **dl_ch_estimates,
   ch_offset = (l*(frame_parms->ofdm_symbol_size));
 
   if ((l!=2) && (l!=6) && (l!=10)) {
-    msg("lte_est_freq_offset: l (%d) must be 2 or 6 or 10", l);
+    LOG_D(PHY,"lte_est_freq_offset: l (%d) must be 2 or 6 or 10", l);
     return(-1);
   }
 
diff --git a/openair1/PHY/LTE_ESTIMATION/lte_sync_time.c b/openair1/PHY/LTE_ESTIMATION/lte_sync_time.c
index e6551033f3..95cda0d8d7 100644
--- a/openair1/PHY/LTE_ESTIMATION/lte_sync_time.c
+++ b/openair1/PHY/LTE_ESTIMATION/lte_sync_time.c
@@ -59,31 +59,31 @@ int lte_sync_time_init(LTE_DL_FRAME_PARMS *frame_parms )   // LTE_UE_COMMON *com
 
   if (sync_corr_ue0) {
 #ifdef DEBUG_PHY
-    msg("[openair][LTE_PHY][SYNC] sync_corr_ue allocated at %p\n", sync_corr_ue0);
+    LOG_D(PHY,"[openair][LTE_PHY][SYNC] sync_corr_ue allocated at %p\n", sync_corr_ue0);
 #endif
     //common_vars->sync_corr = sync_corr;
   } else {
-    msg("[openair][LTE_PHY][SYNC] sync_corr_ue0 not allocated\n");
+    LOG_E(PHY,"[openair][LTE_PHY][SYNC] sync_corr_ue0 not allocated\n");
     return(-1);
   }
 
   if (sync_corr_ue1) {
 #ifdef DEBUG_PHY
-    msg("[openair][LTE_PHY][SYNC] sync_corr_ue allocated at %p\n", sync_corr_ue1);
+    LOG_D(PHY,"[openair][LTE_PHY][SYNC] sync_corr_ue allocated at %p\n", sync_corr_ue1);
 #endif
     //common_vars->sync_corr = sync_corr;
   } else {
-    msg("[openair][LTE_PHY][SYNC] sync_corr_ue1 not allocated\n");
+    LOG_E(PHY,"[openair][LTE_PHY][SYNC] sync_corr_ue1 not allocated\n");
     return(-1);
   }
 
   if (sync_corr_ue2) {
 #ifdef DEBUG_PHY
-    msg("[openair][LTE_PHY][SYNC] sync_corr_ue allocated at %p\n", sync_corr_ue2);
+    LOG_D(PHY,"[openair][LTE_PHY][SYNC] sync_corr_ue allocated at %p\n", sync_corr_ue2);
 #endif
     //common_vars->sync_corr = sync_corr;
   } else {
-    msg("[openair][LTE_PHY][SYNC] sync_corr_ue2 not allocated\n");
+    LOG_E(PHY,"[openair][LTE_PHY][SYNC] sync_corr_ue2 not allocated\n");
     return(-1);
   }
 
@@ -94,10 +94,10 @@ int lte_sync_time_init(LTE_DL_FRAME_PARMS *frame_parms )   // LTE_UE_COMMON *com
     //    bzero(primary_synch0_time,(frame_parms->ofdm_symbol_size+frame_parms->nb_prefix_samples)*sizeof(int));
     bzero(primary_synch0_time,(frame_parms->ofdm_symbol_size)*sizeof(int16_t)*2);
 #ifdef DEBUG_PHY
-    msg("[openair][LTE_PHY][SYNC] primary_synch0_time allocated at %p\n", primary_synch0_time);
+    LOG_D(PHY,"[openair][LTE_PHY][SYNC] primary_synch0_time allocated at %p\n", primary_synch0_time);
 #endif
   } else {
-    msg("[openair][LTE_PHY][SYNC] primary_synch0_time not allocated\n");
+    LOG_E(PHY,"[openair][LTE_PHY][SYNC] primary_synch0_time not allocated\n");
     return(-1);
   }
 
@@ -108,10 +108,10 @@ int lte_sync_time_init(LTE_DL_FRAME_PARMS *frame_parms )   // LTE_UE_COMMON *com
     //    bzero(primary_synch1_time,(frame_parms->ofdm_symbol_size+frame_parms->nb_prefix_samples)*sizeof(int));
     bzero(primary_synch1_time,(frame_parms->ofdm_symbol_size)*sizeof(int16_t)*2);
 #ifdef DEBUG_PHY
-    msg("[openair][LTE_PHY][SYNC] primary_synch1_time allocated at %p\n", primary_synch1_time);
+    LOG_D(PHY,"[openair][LTE_PHY][SYNC] primary_synch1_time allocated at %p\n", primary_synch1_time);
 #endif
   } else {
-    msg("[openair][LTE_PHY][SYNC] primary_synch1_time not allocated\n");
+    LOG_E(PHY,"[openair][LTE_PHY][SYNC] primary_synch1_time not allocated\n");
     return(-1);
   }
 
@@ -122,10 +122,10 @@ int lte_sync_time_init(LTE_DL_FRAME_PARMS *frame_parms )   // LTE_UE_COMMON *com
     //    bzero(primary_synch2_time,(frame_parms->ofdm_symbol_size+frame_parms->nb_prefix_samples)*sizeof(int));
     bzero(primary_synch2_time,(frame_parms->ofdm_symbol_size)*sizeof(int16_t)*2);
 #ifdef DEBUG_PHY
-    msg("[openair][LTE_PHY][SYNC] primary_synch2_time allocated at %p\n", primary_synch2_time);
+    LOG_D(PHY,"[openair][LTE_PHY][SYNC] primary_synch2_time allocated at %p\n", primary_synch2_time);
 #endif
   } else {
-    msg("[openair][LTE_PHY][SYNC] primary_synch2_time not allocated\n");
+    LOG_E(PHY,"[openair][LTE_PHY][SYNC] primary_synch2_time not allocated\n");
     return(-1);
   }
 
@@ -292,32 +292,32 @@ void lte_sync_time_free(void)
 
 
   if (sync_corr_ue0) {
-    msg("Freeing sync_corr_ue (%p)...\n",sync_corr_ue0);
+    LOG_D(PHY,"Freeing sync_corr_ue (%p)...\n",sync_corr_ue0);
     free(sync_corr_ue0);
   }
 
   if (sync_corr_ue1) {
-    msg("Freeing sync_corr_ue (%p)...\n",sync_corr_ue1);
+    LOG_D(PHY,"Freeing sync_corr_ue (%p)...\n",sync_corr_ue1);
     free(sync_corr_ue1);
   }
 
   if (sync_corr_ue2) {
-    msg("Freeing sync_corr_ue (%p)...\n",sync_corr_ue2);
+    LOG_D(PHY,"Freeing sync_corr_ue (%p)...\n",sync_corr_ue2);
     free(sync_corr_ue2);
   }
 
   if (primary_synch0_time) {
-    msg("Freeing primary_sync0_time ...\n");
+    LOG_D(PHY,"Freeing primary_sync0_time ...\n");
     free(primary_synch0_time);
   }
 
   if (primary_synch1_time) {
-    msg("Freeing primary_sync1_time ...\n");
+    LOG_D(PHY,"Freeing primary_sync1_time ...\n");
     free(primary_synch1_time);
   }
 
   if (primary_synch2_time) {
-    msg("Freeing primary_sync2_time ...\n");
+    LOG_D(PHY,"Freeing primary_sync2_time ...\n");
     free(primary_synch2_time);
   }
 
@@ -355,19 +355,19 @@ int lte_sync_time(int **rxdata, ///rx data in time domain
   int tmp[3] = {0,0,0};
   int length =   LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*frame_parms->samples_per_tti>>1;
 
-  //msg("[SYNC TIME] Calling sync_time.\n");
+  //LOG_D(PHY,"[SYNC TIME] Calling sync_time.\n");
   if (sync_corr_ue0 == NULL) {
-    msg("[SYNC TIME] sync_corr_ue0 not yet allocated! Exiting.\n");
+    LOG_E(PHY,"[SYNC TIME] sync_corr_ue0 not yet allocated! Exiting.\n");
     return(-1);
   }
 
   if (sync_corr_ue1 == NULL) {
-    msg("[SYNC TIME] sync_corr_ue1 not yet allocated! Exiting.\n");
+    LOG_E(PHY,"[SYNC TIME] sync_corr_ue1 not yet allocated! Exiting.\n");
     return(-1);
   }
 
   if (sync_corr_ue2 == NULL) {
-    msg("[SYNC TIME] sync_corr_ue2 not yet allocated! Exiting.\n");
+    LOG_E(PHY,"[SYNC TIME] sync_corr_ue2 not yet allocated! Exiting.\n");
     return(-1);
   }
 
@@ -383,7 +383,7 @@ int lte_sync_time(int **rxdata, ///rx data in time domain
     // This is necessary since the sync takes a long time and it seems to block all other threads thus screwing up RTAI. If we pause it for a little while during its execution we give RTAI a chance to catch up with its other tasks.
     if ((n%frame_parms->samples_per_tti == 0) && (n>0) && (openair_daq_vars.sync_state==0)) {
 #ifdef DEBUG_PHY
-      msg("[SYNC TIME] pausing for 1000ns, n=%d\n",n);
+      LOG_E(PHY,"[SYNC TIME] pausing for 1000ns, n=%d\n",n);
 #endif
       rt_sleep(nano2count(1000));
     }
@@ -516,7 +516,7 @@ int lte_sync_time_eNB(int32_t **rxdata, ///rx data in time domain
   short *primary_synch_time;
   int eNB_id = frame_parms->Nid_cell%3;
 
-  // msg("[SYNC TIME] Calling sync_time_eNB(%p,%p,%d,%d)\n",rxdata,frame_parms,eNB_id,length);
+  // LOG_E(PHY,"[SYNC TIME] Calling sync_time_eNB(%p,%p,%d,%d)\n",rxdata,frame_parms,eNB_id,length);
   if (sync_corr_eNB == NULL) {
     LOG_E(PHY,"[SYNC TIME] sync_corr_eNB not yet allocated! Exiting.\n");
     return(-1);
@@ -603,11 +603,11 @@ int lte_sync_time_eNB_emul(PHY_VARS_eNB *phy_vars_eNB,
   uint8_t UE_id;
   uint8_t CC_id = phy_vars_eNB->CC_id;
 
-  msg("[PHY] EMUL lte_sync_time_eNB_emul eNB %d, sect_id %d\n",phy_vars_eNB->Mod_id,sect_id);
+  LOG_E(PHY,"[PHY] EMUL lte_sync_time_eNB_emul eNB %d, sect_id %d\n",phy_vars_eNB->Mod_id,sect_id);
   *sync_val = 0;
 
   for (UE_id=0; UE_id<NB_UE_INST; UE_id++) {
-    //msg("[PHY] EMUL : eNB %d checking UE %d (PRACH %d) PL %d dB\n",phy_vars_eNB->Mod_id,UE_id,PHY_vars_UE_g[UE_id]->generate_prach,UE2eNB[UE_id][phy_vars_eNB->Mod_id]->path_loss_dB);
+    //LOG_E(PHY,"[PHY] EMUL : eNB %d checking UE %d (PRACH %d) PL %d dB\n",phy_vars_eNB->Mod_id,UE_id,PHY_vars_UE_g[UE_id]->generate_prach,UE2eNB[UE_id][phy_vars_eNB->Mod_id]->path_loss_dB);
     if ((PHY_vars_UE_g[UE_id][CC_id]->generate_prach == 1) && (phy_vars_eNB->Mod_id == (UE_id % NB_eNB_INST))) {
       *sync_val = 1;
       return(0);
diff --git a/openair1/PHY/LTE_ESTIMATION/lte_ue_measurements.c b/openair1/PHY/LTE_ESTIMATION/lte_ue_measurements.c
index db8fe548a2..09603d96cd 100644
--- a/openair1/PHY/LTE_ESTIMATION/lte_ue_measurements.c
+++ b/openair1/PHY/LTE_ESTIMATION/lte_ue_measurements.c
@@ -571,7 +571,7 @@ void lte_ue_measurements(PHY_VARS_UE *ue,
   ue->measurements.n0_power_avg_dB = dB_fixed( ue->measurements.n0_power_avg);
 
   for (eNB_id = 0; eNB_id < ue->n_connected_eNB; eNB_id++) {
-    if (frame_parms->mode1_flag==0) {
+    if (frame_parms->nb_antenna_ports_eNB!=1) {
       // cqi/pmi information
 
       for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
@@ -758,6 +758,6 @@ void lte_ue_measurements(PHY_VARS_UE *ue,
 void lte_ue_measurements_emul(PHY_VARS_UE *ue,uint8_t subframe,uint8_t eNB_id)
 {
 
-  msg("[PHY] EMUL UE lte_ue_measurements_emul subframe %d, eNB_id %d\n",subframe,eNB_id);
+  LOG_D(PHY,"EMUL UE lte_ue_measurements_emul subframe %d, eNB_id %d\n",subframe,eNB_id);
 }
 
diff --git a/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c b/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c
index 4fef74dd1c..80db570f8c 100644
--- a/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c
+++ b/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c
@@ -23,22 +23,10 @@
 #include "PHY/extern.h"
 #include "PHY/sse_intrin.h"
 //#define DEBUG_CH
+#include "UTIL/LOG/log.h"
 
 #include "T.h"
 
-// For Channel Estimation in Distributed Alamouti Scheme
-//static int16_t temp_out_ifft[2048*4] __attribute__((aligned(16)));
-static int16_t temp_out_fft_0[2048*4] __attribute__((aligned(16)));
-static int16_t temp_out_fft_1[2048*4] __attribute__((aligned(16)));
-static int16_t temp_out_ifft_0[2048*4] __attribute__((aligned(16)));
-static int16_t temp_out_ifft_1[2048*4] __attribute__((aligned(16)));
-
-
-static int32_t temp_in_ifft_0[2048*2] __attribute__((aligned(32)));
-static int32_t temp_in_ifft_1[2048*2] __attribute__((aligned(32)));
-static int32_t temp_in_fft_0[2048*2] __attribute__((aligned(16)));
-static int32_t temp_in_fft_1[2048*2] __attribute__((aligned(16)));
-
 // round(exp(sqrt(-1)*(pi/2)*[0:1:N-1]/N)*pow2(15))
 static int16_t ru_90[2*128] = {32767, 0,32766, 402,32758, 804,32746, 1206,32729, 1608,32706, 2009,32679, 2411,32647, 2811,32610, 3212,32568, 3612,32522, 4011,32470, 4410,32413, 4808,32352, 5205,32286, 5602,32214, 5998,32138, 6393,32058, 6787,31972, 7180,31881, 7571,31786, 7962,31686, 8351,31581, 8740,31471, 9127,31357, 9512,31238, 9896,31114, 10279,30986, 10660,30853, 11039,30715, 11417,30572, 11793,30425, 12167,30274, 12540,30118, 12910,29957, 13279,29792, 13646,29622, 14010,29448, 14373,29269, 14733,29086, 15091,28899, 15447,28707, 15800,28511, 16151,28311, 16500,28106, 16846,27897, 17190,27684, 17531,27467, 17869,27246, 18205,27020, 18538,26791, 18868,26557, 19195,26320, 19520,26078, 19841,25833, 20160,25583, 20475,25330, 20788,25073, 21097,24812, 21403,24548, 21706,24279, 22006,24008, 22302,23732, 22595,23453, 22884,23170, 23170,22884, 23453,22595, 23732,22302, 24008,22006, 24279,21706, 24548,21403, 24812,21097, 25073,20788, 25330,20475, 25583,20160, 25833,19841, 26078,19520, 26320,19195, 26557,18868, 26791,18538, 27020,18205, 27246,17869, 27467,17531, 27684,17190, 27897,16846, 28106,16500, 28311,16151, 28511,15800, 28707,15447, 28899,15091, 29086,14733, 29269,14373, 29448,14010, 29622,13646, 29792,13279, 29957,12910, 30118,12540, 30274,12167, 30425,11793, 30572,11417, 30715,11039, 30853,10660, 30986,10279, 31114,9896, 31238,9512, 31357,9127, 31471,8740, 31581,8351, 31686,7962, 31786,7571, 31881,7180, 31972,6787, 32058,6393, 32138,5998, 32214,5602, 32286,5205, 32352,4808, 32413,4410, 32470,4011, 32522,3612, 32568,3212, 32610,2811, 32647,2411, 32679,2009, 32706,1608, 32729,1206, 32746,804, 32758,402, 32766};
 
@@ -48,20 +36,15 @@ static int16_t ru_90c[2*128] = {32767, 0,32766, -402,32758, -804,32746, -1206,32
 
 int32_t lte_ul_channel_estimation(PHY_VARS_eNB *eNB,
 				  eNB_rxtx_proc_t *proc,
-                                  uint8_t eNB_id,
                                   uint8_t UE_id,
                                   unsigned char l,
-                                  unsigned char Ns,
-                                  uint8_t cooperation_flag)
-{
+                                  unsigned char Ns) {
 
   LTE_DL_FRAME_PARMS *frame_parms = &eNB->frame_parms;
   LTE_eNB_PUSCH *pusch_vars = eNB->pusch_vars[UE_id];
-  int32_t **ul_ch_estimates=pusch_vars->drs_ch_estimates[eNB_id];
-  int32_t **ul_ch_estimates_time=  pusch_vars->drs_ch_estimates_time[eNB_id];
-  int32_t **ul_ch_estimates_0=  pusch_vars->drs_ch_estimates_0[eNB_id];
-  int32_t **ul_ch_estimates_1=  pusch_vars->drs_ch_estimates_1[eNB_id];
-  int32_t **rxdataF_ext=  pusch_vars->rxdataF_ext[eNB_id];
+  int32_t **ul_ch_estimates=pusch_vars->drs_ch_estimates;
+  int32_t **ul_ch_estimates_time=  pusch_vars->drs_ch_estimates_time;
+  int32_t **rxdataF_ext=  pusch_vars->rxdataF_ext;
   int subframe = proc->subframe_rx;
   uint8_t harq_pid = subframe2harq_pid(frame_parms,proc->frame_rx,subframe);
   int16_t delta_phase = 0;
@@ -72,11 +55,8 @@ int32_t lte_ul_channel_estimation(PHY_VARS_eNB *eNB,
   uint16_t aa,Msc_RS,Msc_RS_idx;
   uint16_t * Msc_idx_ptr;
   int k,pilot_pos1 = 3 - frame_parms->Ncp, pilot_pos2 = 10 - 2*frame_parms->Ncp;
-  int16_t alpha, beta;
   int32_t *ul_ch1=NULL, *ul_ch2=NULL;
-  int32_t *ul_ch1_0=NULL,*ul_ch2_0=NULL,*ul_ch1_1=NULL,*ul_ch2_1=NULL;
   int16_t ul_ch_estimates_re,ul_ch_estimates_im;
-  int32_t rx_power_correction;
 
   //uint8_t nb_antennas_rx = frame_parms->nb_antenna_ports_eNB;
   uint8_t nb_antennas_rx = frame_parms->nb_antennas_rx;
@@ -87,7 +67,7 @@ int32_t lte_ul_channel_estimation(PHY_VARS_eNB *eNB,
   uint32_t v=frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.seqhop[Ns+(subframe<<1)];
   int32_t tmp_estimates[N_rb_alloc*12] __attribute__((aligned(16)));
 
-  int symbol_offset,i,j;
+  int symbol_offset,i;
 
   //debug_msg("lte_ul_channel_estimation: cyclic shift %d\n",cyclicShift);
 
@@ -95,11 +75,6 @@ int32_t lte_ul_channel_estimation(PHY_VARS_eNB *eNB,
   int16_t alpha_re[12] = {32767, 28377, 16383,     0,-16384,  -28378,-32768,-28378,-16384,    -1, 16383, 28377};
   int16_t alpha_im[12] = {0,     16383, 28377, 32767, 28377,   16383,     0,-16384,-28378,-32768,-28378,-16384};
 
-  int32_t *in_fft_ptr_0 = (int32_t*)0,*in_fft_ptr_1 = (int32_t*)0,
-           *temp_out_fft_0_ptr = (int32_t*)0,*out_fft_ptr_0 = (int32_t*)0,
-            *temp_out_fft_1_ptr = (int32_t*)0,*out_fft_ptr_1 = (int32_t*)0,
-             *temp_in_ifft_ptr = (int32_t*)0;
-
 #if defined(__x86_64__) || defined(__i386__)
   __m128i *rxdataF128,*ul_ref128,*ul_ch128;
   __m128i mmtmpU0,mmtmpU1,mmtmpU2,mmtmpU3;
@@ -107,6 +82,9 @@ int32_t lte_ul_channel_estimation(PHY_VARS_eNB *eNB,
   int16x8_t *rxdataF128,*ul_ref128,*ul_ch128;
   int32x4_t mmtmp0,mmtmp1,mmtmp_re,mmtmp_im;
 #endif
+
+int32_t temp_in_ifft_0[2048*2] __attribute__((aligned(32)));
+
   Msc_RS = N_rb_alloc*12;
 
   cyclic_shift = (frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift +
@@ -119,7 +97,7 @@ int32_t lte_ul_channel_estimation(PHY_VARS_eNB *eNB,
   if (Msc_idx_ptr)
     Msc_RS_idx = Msc_idx_ptr - dftsizes;
   else {
-    msg("lte_ul_channel_estimation: index for Msc_RS=%d not found\n",Msc_RS);
+    LOG_E(PHY,"lte_ul_channel_estimation: index for Msc_RS=%d not found\n",Msc_RS);
     return(-1);
   }
 
@@ -145,7 +123,6 @@ int32_t lte_ul_channel_estimation(PHY_VARS_eNB *eNB,
 #endif
 #endif
 
-  rx_power_correction = 1;
 
   if (l == (3 - frame_parms->Ncp)) {
 
@@ -290,11 +267,9 @@ int32_t lte_ul_channel_estimation(PHY_VARS_eNB *eNB,
 #endif
       }
 
-      //copy MIMO channel estimates to temporary buffer for EMOS
-      //memcpy(&ul_ch_estimates_0[aa][symbol_offset],&ul_ch_estimates[aa][symbol_offset],frame_parms->ofdm_symbol_size*sizeof(int32_t)*2);
 
-      memset(temp_in_ifft_0,0,frame_parms->ofdm_symbol_size*sizeof(int32_t));
 
+      
       // Convert to time domain for visualization
       for(i=0; i<Msc_RS; i++)
         ((int32_t*)temp_in_ifft_0)[i] = ul_ch_estimates[aa][symbol_offset+i];
@@ -327,7 +302,7 @@ int32_t lte_ul_channel_estimation(PHY_VARS_eNB *eNB,
 
 #if T_TRACER
       if (aa == 0)
-        T(T_ENB_PHY_UL_CHANNEL_ESTIMATE, T_INT(eNB_id), T_INT(UE_id),
+        T(T_ENB_PHY_UL_CHANNEL_ESTIMATE, T_INT(0), T_INT(UE_id),
           T_INT(proc->frame_rx), T_INT(subframe),
           T_INT(0), T_BUFFER(ul_ch_estimates_time[0], 512  * 4));
 #endif
@@ -346,316 +321,106 @@ int32_t lte_ul_channel_estimation(PHY_VARS_eNB *eNB,
 #endif
 
 
-      if(cooperation_flag == 2) {
-        memset(temp_in_ifft_0,0,frame_parms->ofdm_symbol_size*sizeof(int32_t*)*2);
-        memset(temp_in_ifft_1,0,frame_parms->ofdm_symbol_size*sizeof(int32_t*)*2);
-        memset(temp_in_fft_0,0,frame_parms->ofdm_symbol_size*sizeof(int32_t*)*2);
-        memset(temp_in_fft_1,0,frame_parms->ofdm_symbol_size*sizeof(int32_t*)*2);
-
-        temp_in_ifft_ptr = &temp_in_ifft_0[0];
-
-        i = symbol_offset;
-
-        for(j=0; j<(frame_parms->N_RB_UL*12); j++) {
-          temp_in_ifft_ptr[j] = ul_ch_estimates[aa][i];
-          i++;
-        }
-
-        alpha_ind = 0;
-
-        // Compensating for the phase shift introduced at the transmitter
-        for(i=symbol_offset; i<symbol_offset+Msc_RS; i++) {
-          ul_ch_estimates_re = ((int16_t*) ul_ch_estimates[aa])[i<<1];
-          ul_ch_estimates_im = ((int16_t*) ul_ch_estimates[aa])[(i<<1)+1];
-          //    ((int16_t*) ul_ch_estimates[aa])[i<<1] =  (i%2 == 1? 1:-1) * ul_ch_estimates_re;
-          ((int16_t*) ul_ch_estimates[aa])[i<<1] =
-            (int16_t) (((int32_t) (alpha_re[alpha_ind]) * (int32_t) (ul_ch_estimates_re) +
-                        (int32_t) (alpha_im[alpha_ind]) * (int32_t) (ul_ch_estimates_im))>>15);
-
-          //((int16_t*) ul_ch_estimates[aa])[(i<<1)+1] =  (i%2 == 1? 1:-1) * ul_ch_estimates_im;
-          ((int16_t*) ul_ch_estimates[aa])[(i<<1)+1] =
-            (int16_t) (((int32_t) (alpha_re[alpha_ind]) * (int32_t) (ul_ch_estimates_im) -
-                        (int32_t) (alpha_im[alpha_ind]) * (int32_t) (ul_ch_estimates_re))>>15);
-
-          alpha_ind+=10;
-
-          if (alpha_ind>11)
-            alpha_ind-=12;
-        }
-
-        //Extracting Channel Estimates for Distributed Alamouti Receiver Combining
-
-        temp_in_ifft_ptr = &temp_in_ifft_1[0];
-
-        i = symbol_offset;
-
-        for(j=0; j<(frame_parms->N_RB_UL*12); j++) {
-          temp_in_ifft_ptr[j] = ul_ch_estimates[aa][i];
-          i++;
-        }
-
-	switch (frame_parms->N_RB_DL) {
-	case 6:
-	  idft128((int16_t*) &temp_in_ifft_0[0],                          // Performing IFFT on Combined Channel Estimates
-		  temp_out_ifft_0,
-		  1);
-	  idft128((int16_t*) &temp_in_ifft_1[0],                          // Performing IFFT on Combined Channel Estimates
-		  temp_out_ifft_1,
-		  1);
-	  break;
-	case 25:
-	  idft512((int16_t*) &temp_in_ifft_0[0],                          // Performing IFFT on Combined Channel Estimates
-		  temp_out_ifft_0,
-		  1);
-	  idft512((int16_t*) &temp_in_ifft_1[0],                          // Performing IFFT on Combined Channel Estimates
-		  temp_out_ifft_1,
-		  1);
-	  break;
-	case 50:
-	  idft1024((int16_t*) &temp_in_ifft_0[0],                          // Performing IFFT on Combined Channel Estimates
-		  temp_out_ifft_0,
-		  1);
-	  idft1024((int16_t*) &temp_in_ifft_1[0],                          // Performing IFFT on Combined Channel Estimates
-		  temp_out_ifft_1,
-		  1);
-	  break;
-	case 100:
-	  idft2048((int16_t*) &temp_in_ifft_0[0],                          // Performing IFFT on Combined Channel Estimates
-		  temp_out_ifft_0,
-		  1);
-	  idft2048((int16_t*) &temp_in_ifft_1[0],                          // Performing IFFT on Combined Channel Estimates
-		  temp_out_ifft_1,
-		  1);
-	  break;
-	}
-
-        // because the ifft is not power preserving, we should apply the factor sqrt(power_correction) here, but we rather apply power_correction here and nothing after the next fft
-        in_fft_ptr_0 = &temp_in_fft_0[0];
-        in_fft_ptr_1 = &temp_in_fft_1[0];
-
-        for(j=0; j<(frame_parms->ofdm_symbol_size)/12; j++) {
-          if (j>19) {
-            ((int16_t*)in_fft_ptr_0)[-40+(2*j)] = ((int16_t*)temp_out_ifft_0)[-80+(2*j)]*rx_power_correction;
-            ((int16_t*)in_fft_ptr_0)[-40+(2*j)+1] = ((int16_t*)temp_out_ifft_0)[-80+(2*j+1)]*rx_power_correction;
-            ((int16_t*)in_fft_ptr_1)[-40+(2*j)] = ((int16_t*)temp_out_ifft_1)[-80+(2*j)]*rx_power_correction;
-            ((int16_t*)in_fft_ptr_1)[-40+(2*j)+1] = ((int16_t*)temp_out_ifft_1)[-80+(2*j)+1]*rx_power_correction;
-          } else {
-            ((int16_t*)in_fft_ptr_0)[2*(frame_parms->ofdm_symbol_size-20+j)] = ((int16_t*)temp_out_ifft_0)[2*(frame_parms->ofdm_symbol_size-20+j)]*rx_power_correction;
-            ((int16_t*)in_fft_ptr_0)[2*(frame_parms->ofdm_symbol_size-20+j)+1] = ((int16_t*)temp_out_ifft_0)[2*(frame_parms->ofdm_symbol_size-20+j)+1]*rx_power_correction;
-            ((int16_t*)in_fft_ptr_1)[2*(frame_parms->ofdm_symbol_size-20+j)] = ((int16_t*)temp_out_ifft_1)[2*(frame_parms->ofdm_symbol_size-20+j)]*rx_power_correction;
-            ((int16_t*)in_fft_ptr_1)[2*(frame_parms->ofdm_symbol_size-20+j)+1] = ((int16_t*)temp_out_ifft_1)[2*(frame_parms->ofdm_symbol_size-20+j)+1]*rx_power_correction;
-          }
-        }
-
-	switch (frame_parms->N_RB_DL) {
-        case 6:
-	  dft128((int16_t*) &temp_in_fft_0[0],     
-		 // Performing FFT to obtain the Channel Estimates for UE0 to eNB1
-		 temp_out_fft_0,
-		 1);
-	  break;
-        case 25:
-	  dft512((int16_t*) &temp_in_fft_0[0],     
-		 // Performing FFT to obtain the Channel Estimates for UE0 to eNB1
-		 temp_out_fft_0,
-		 1);
-	  break;
-        case 50:
-	  dft1024((int16_t*) &temp_in_fft_0[0],     
-		 // Performing FFT to obtain the Channel Estimates for UE0 to eNB1
-		 temp_out_fft_0,
-		 1);
-	  break;
-        case 100:
-	  dft2048((int16_t*) &temp_in_fft_0[0],     
-		 // Performing FFT to obtain the Channel Estimates for UE0 to eNB1
-		 temp_out_fft_0,
-		 1);
-	  break;
-	}
-
-        out_fft_ptr_0 = &ul_ch_estimates_0[aa][symbol_offset]; // CHANNEL ESTIMATES FOR UE0 TO eNB1
-        temp_out_fft_0_ptr = (int32_t*) temp_out_fft_0;
-
-        i=0;
-
-        for(j=0; j<frame_parms->N_RB_UL*12; j++) {
-          out_fft_ptr_0[i] = temp_out_fft_0_ptr[j];
-          i++;
-        }
-	switch (frame_parms->N_RB_DL) {
-	case 6:
-	  dft128((int16_t*) &temp_in_fft_1[0],                          // Performing FFT to obtain the Channel Estimates for UE1 to eNB1
-		 temp_out_fft_1,
-		 1);
-	  break;
-	case 25:
-	  dft512((int16_t*) &temp_in_fft_1[0],                          // Performing FFT to obtain the Channel Estimates for UE1 to eNB1
-		 temp_out_fft_1,
-		 1);
-	  break;
-	case 50:
-	  dft1024((int16_t*) &temp_in_fft_1[0],                          // Performing FFT to obtain the Channel Estimates for UE1 to eNB1
-		 temp_out_fft_1,
-		 1);
-	  break;
-	case 100:
-	  dft2048((int16_t*) &temp_in_fft_1[0],                          // Performing FFT to obtain the Channel Estimates for UE1 to eNB1
-		 temp_out_fft_1,
-		 1);
-	  break;
-	}
-
-        out_fft_ptr_1 = &ul_ch_estimates_1[aa][symbol_offset];   // CHANNEL ESTIMATES FOR UE1 TO eNB1
-        temp_out_fft_1_ptr = (int32_t*) temp_out_fft_1;
-
-        i=0;
-
-        for(j=0; j<frame_parms->N_RB_UL*12; j++) {
-          out_fft_ptr_1[i] = temp_out_fft_1_ptr[j];
-          i++;
-        }
-
+    
+    
+	if (Ns&1) {//we are in the second slot of the sub-frame, so do the interpolation
+
+	  ul_ch1 = &ul_ch_estimates[aa][frame_parms->N_RB_UL*12*pilot_pos1];
+	  ul_ch2 = &ul_ch_estimates[aa][frame_parms->N_RB_UL*12*pilot_pos2];
+	  
+	  
+	  // Estimation of phase difference between the 2 channel estimates
+	  delta_phase = lte_ul_freq_offset_estimation(frame_parms,
+						      ul_ch_estimates[aa],
+						      N_rb_alloc);
+	  // negative phase index indicates negative Im of ru
+	  //    msg("delta_phase: %d\n",delta_phase);
+	  
 #ifdef DEBUG_CH
-#ifdef USER_MODE
-
-        if((aa == 0)&& (cooperation_flag == 2)) {
-          write_output("test1.m","t1",temp_in_ifft_0,512,1,1);
-          write_output("test2.m","t2",temp_out_ifft_0,512*2,2,1);
-          write_output("test3.m","t3",temp_in_fft_0,512,1,1);
-          write_output("test4.m","t4",temp_out_fft_0,512,1,1);
-          write_output("test5.m","t5",temp_in_fft_1,512,1,1);
-          write_output("test6.m","t6",temp_out_fft_1,512,1,1);
-        }
-
+	  LOG_D(PHY,"lte_ul_channel_estimation: ul_ch1 = %p, ul_ch2 = %p, pilot_pos1=%d, pilot_pos2=%d\n",ul_ch1, ul_ch2, pilot_pos1,pilot_pos2);
 #endif
-#endif
-
-      }//cooperation_flag == 2
-
-      if (Ns&1) {//we are in the second slot of the sub-frame, so do the interpolation
-
-        ul_ch1 = &ul_ch_estimates[aa][frame_parms->N_RB_UL*12*pilot_pos1];
-        ul_ch2 = &ul_ch_estimates[aa][frame_parms->N_RB_UL*12*pilot_pos2];
-
-
-        if(cooperation_flag == 2) { // For Distributed Alamouti
-          ul_ch1_0 = &ul_ch_estimates_0[aa][frame_parms->N_RB_UL*12*pilot_pos1];
-          ul_ch2_0 = &ul_ch_estimates_0[aa][frame_parms->N_RB_UL*12*pilot_pos2];
-
-          ul_ch1_1 = &ul_ch_estimates_1[aa][frame_parms->N_RB_UL*12*pilot_pos1];
-          ul_ch2_1 = &ul_ch_estimates_1[aa][frame_parms->N_RB_UL*12*pilot_pos2];
-        }
-
-        // Estimation of phase difference between the 2 channel estimates
-        delta_phase = lte_ul_freq_offset_estimation(frame_parms,
-                      ul_ch_estimates[aa],
-                      N_rb_alloc);
-        // negative phase index indicates negative Im of ru
-        //    msg("delta_phase: %d\n",delta_phase);
-
+	  
+	  for (k=0; k<frame_parms->symbols_per_tti; k++) {
+	    
+	    // we scale alpha and beta by SCALE (instead of 0x7FFF) to avoid overflows
+	    //	    alpha = (int16_t) (((int32_t) SCALE * (int32_t) (pilot_pos2-k))/(pilot_pos2-pilot_pos1));
+	    //	    beta  = (int16_t) (((int32_t) SCALE * (int32_t) (k-pilot_pos1))/(pilot_pos2-pilot_pos1));
+
+	    
 #ifdef DEBUG_CH
-        msg("lte_ul_channel_estimation: ul_ch1 = %p, ul_ch2 = %p, pilot_pos1=%d, pilot_pos2=%d\n",ul_ch1, ul_ch2, pilot_pos1,pilot_pos2);
-#endif
-
-        for (k=0; k<frame_parms->symbols_per_tti; k++) {
-
-          // we scale alpha and beta by SCALE (instead of 0x7FFF) to avoid overflows
-          alpha = (int16_t) (((int32_t) SCALE * (int32_t) (pilot_pos2-k))/(pilot_pos2-pilot_pos1));
-          beta  = (int16_t) (((int32_t) SCALE * (int32_t) (k-pilot_pos1))/(pilot_pos2-pilot_pos1));
-
-
-#ifdef DEBUG_CH
-          msg("lte_ul_channel_estimation: k=%d, alpha = %d, beta = %d\n",k,alpha,beta);
+	    LOG_D(PHY,"lte_ul_channel_estimation: k=%d, alpha = %d, beta = %d\n",k,alpha,beta);
 #endif
           //symbol_offset_subframe = frame_parms->N_RB_UL*12*k;
-
+	    
           // interpolate between estimates
-          if ((k != pilot_pos1) && (k != pilot_pos2))  {
-            //          multadd_complex_vector_real_scalar((int16_t*) ul_ch1,alpha,(int16_t*) &ul_ch_estimates[aa][frame_parms->N_RB_UL*12*k],1,Msc_RS);
-            //          multadd_complex_vector_real_scalar((int16_t*) ul_ch2,beta ,(int16_t*) &ul_ch_estimates[aa][frame_parms->N_RB_UL*12*k],0,Msc_RS);
-
-            //          multadd_complex_vector_real_scalar((int16_t*) ul_ch1,SCALE,(int16_t*) &ul_ch_estimates[aa][frame_parms->N_RB_UL*12*k],1,Msc_RS);
-            //          multadd_complex_vector_real_scalar((int16_t*) ul_ch2,SCALE,(int16_t*) &ul_ch_estimates[aa][frame_parms->N_RB_UL*12*k],0,Msc_RS);
-            //          msg("phase = %d\n",ru[2*cmax(((delta_phase/7)*(k-3)),0)]);
-
-            // the phase is linearly interpolated
-            current_phase1 = (delta_phase/7)*(k-pilot_pos1);
-            current_phase2 = (delta_phase/7)*(k-pilot_pos2);
-            //          msg("sym: %d, current_phase1: %d, current_phase2: %d\n",k,current_phase1,current_phase2);
-            // set the right quadrant
-            (current_phase1 > 0) ? (ru1 = ru_90) : (ru1 = ru_90c);
-            (current_phase2 > 0) ? (ru2 = ru_90) : (ru2 = ru_90c);
-            // take absolute value and clip
-            current_phase1 = cmin(abs(current_phase1),127);
-            current_phase2 = cmin(abs(current_phase2),127);
-
-            //          msg("sym: %d, current_phase1: %d, ru: %d + j%d, current_phase2: %d, ru: %d + j%d\n",k,current_phase1,ru1[2*current_phase1],ru1[2*current_phase1+1],current_phase2,ru2[2*current_phase2],ru2[2*current_phase2+1]);
-
-            // rotate channel estimates by estimated phase
-            rotate_cpx_vector((int16_t*) ul_ch1,
-                              &ru1[2*current_phase1],
-                              (int16_t*) &ul_ch_estimates[aa][frame_parms->N_RB_UL*12*k],
-                              Msc_RS,
-                              15);
-
-            rotate_cpx_vector((int16_t*) ul_ch2,
-                              &ru2[2*current_phase2],
-                              (int16_t*) &tmp_estimates[0],
-                              Msc_RS,
-                              15);
-
-            // Combine the two rotated estimates
-            multadd_complex_vector_real_scalar((int16_t*) &ul_ch_estimates[aa][frame_parms->N_RB_UL*12*k],SCALE,(int16_t*) &ul_ch_estimates[aa][frame_parms->N_RB_UL*12*k],1,Msc_RS);
-            multadd_complex_vector_real_scalar((int16_t*) &tmp_estimates[0],SCALE,(int16_t*) &ul_ch_estimates[aa][frame_parms->N_RB_UL*12*k],0,Msc_RS);
-
-            /*
-            if ((k<pilot_pos1) || ((k>pilot_pos2))) {
-
+	    if ((k != pilot_pos1) && (k != pilot_pos2))  {
+	      //          multadd_complex_vector_real_scalar((int16_t*) ul_ch1,alpha,(int16_t*) &ul_ch_estimates[aa][frame_parms->N_RB_UL*12*k],1,Msc_RS);
+	      //          multadd_complex_vector_real_scalar((int16_t*) ul_ch2,beta ,(int16_t*) &ul_ch_estimates[aa][frame_parms->N_RB_UL*12*k],0,Msc_RS);
+	      
+	      //          multadd_complex_vector_real_scalar((int16_t*) ul_ch1,SCALE,(int16_t*) &ul_ch_estimates[aa][frame_parms->N_RB_UL*12*k],1,Msc_RS);
+	      //          multadd_complex_vector_real_scalar((int16_t*) ul_ch2,SCALE,(int16_t*) &ul_ch_estimates[aa][frame_parms->N_RB_UL*12*k],0,Msc_RS);
+	      //          msg("phase = %d\n",ru[2*cmax(((delta_phase/7)*(k-3)),0)]);
+	      
+	      // the phase is linearly interpolated
+	      current_phase1 = (delta_phase/7)*(k-pilot_pos1);
+	      current_phase2 = (delta_phase/7)*(k-pilot_pos2);
+	      //          msg("sym: %d, current_phase1: %d, current_phase2: %d\n",k,current_phase1,current_phase2);
+	      // set the right quadrant
+	      (current_phase1 > 0) ? (ru1 = ru_90) : (ru1 = ru_90c);
+	      (current_phase2 > 0) ? (ru2 = ru_90) : (ru2 = ru_90c);
+	      // take absolute value and clip
+	      current_phase1 = cmin(abs(current_phase1),127);
+	      current_phase2 = cmin(abs(current_phase2),127);
+	      
+	      //          msg("sym: %d, current_phase1: %d, ru: %d + j%d, current_phase2: %d, ru: %d + j%d\n",k,current_phase1,ru1[2*current_phase1],ru1[2*current_phase1+1],current_phase2,ru2[2*current_phase2],ru2[2*current_phase2+1]);
+	      
+	      // rotate channel estimates by estimated phase
+	      rotate_cpx_vector((int16_t*) ul_ch1,
+				&ru1[2*current_phase1],
+				(int16_t*) &ul_ch_estimates[aa][frame_parms->N_RB_UL*12*k],
+				Msc_RS,
+				15);
+	      
+	      rotate_cpx_vector((int16_t*) ul_ch2,
+				&ru2[2*current_phase2],
+				(int16_t*) &tmp_estimates[0],
+				Msc_RS,
+				15);
+	      
+	      // Combine the two rotated estimates
+	      multadd_complex_vector_real_scalar((int16_t*) &ul_ch_estimates[aa][frame_parms->N_RB_UL*12*k],SCALE,(int16_t*) &ul_ch_estimates[aa][frame_parms->N_RB_UL*12*k],1,Msc_RS);
+	      multadd_complex_vector_real_scalar((int16_t*) &tmp_estimates[0],SCALE,(int16_t*) &ul_ch_estimates[aa][frame_parms->N_RB_UL*12*k],0,Msc_RS);
+	      
+	      /*
+		if ((k<pilot_pos1) || ((k>pilot_pos2))) {
+		
                 multadd_complex_vector_real_scalar((int16_t*) &ul_ch_estimates[aa][frame_parms->N_RB_UL*12*k],SCALE>>1,(int16_t*) &ul_ch_estimates[aa][frame_parms->N_RB_UL*12*k],1,Msc_RS);
-
+		
                 multadd_complex_vector_real_scalar((int16_t*) &tmp_estimates[0],SCALE>>1,(int16_t*) &ul_ch_estimates[aa][frame_parms->N_RB_UL*12*k],0,Msc_RS);
-
-            } else {
-
+		
+		} else {
+		
                 multadd_complex_vector_real_scalar((int16_t*) &ul_ch_estimates[aa][frame_parms->N_RB_UL*12*k],SCALE>>1,(int16_t*) &ul_ch_estimates[aa][frame_parms->N_RB_UL*12*k],1,Msc_RS);
-
+		
                 multadd_complex_vector_real_scalar((int16_t*) &tmp_estimates[0],SCALE>>1,(int16_t*) &ul_ch_estimates[aa][frame_parms->N_RB_UL*12*k],0,Msc_RS);
-
+		
                 //              multadd_complex_vector_real_scalar((int16_t*) &ul_ch_estimates[aa][frame_parms->N_RB_UL*12*k],alpha,(int16_t*) &ul_ch_estimates[aa][frame_parms->N_RB_UL*12*k],1,Msc_RS);
-
+		
                 //              multadd_complex_vector_real_scalar((int16_t*) &tmp_estimates[0],beta ,(int16_t*) &ul_ch_estimates[aa][frame_parms->N_RB_UL*12*k],0,Msc_RS);
+		
+		}
+	      */
+	      
+	      //      memcpy(&ul_ch_estimates[aa][frame_parms->N_RB_UL*12*k],ul_ch1,Msc_RS*sizeof(int32_t));
+	    }
+	  } //for(k=...
 
-            }
-            */
-
-            //      memcpy(&ul_ch_estimates[aa][frame_parms->N_RB_UL*12*k],ul_ch1,Msc_RS*sizeof(int32_t));
-            if(cooperation_flag == 2) { // For Distributed Alamouti
-              multadd_complex_vector_real_scalar((int16_t*) ul_ch1_0,beta ,(int16_t*) &ul_ch_estimates_0[aa][frame_parms->N_RB_UL*12*k],1,Msc_RS);
-              multadd_complex_vector_real_scalar((int16_t*) ul_ch2_0,alpha,(int16_t*) &ul_ch_estimates_0[aa][frame_parms->N_RB_UL*12*k],0,Msc_RS);
+	  // because of the scaling of alpha and beta we also need to scale the final channel estimate at the pilot positions
+	  
+	  //    multadd_complex_vector_real_scalar((int16_t*) ul_ch1,SCALE,(int16_t*) ul_ch1,1,Msc_RS);
+	  //    multadd_complex_vector_real_scalar((int16_t*) ul_ch2,SCALE,(int16_t*) ul_ch2,1,Msc_RS);
 
-              multadd_complex_vector_real_scalar((int16_t*) ul_ch1_1,beta ,(int16_t*) &ul_ch_estimates_1[aa][frame_parms->N_RB_UL*12*k],1,Msc_RS);
-              multadd_complex_vector_real_scalar((int16_t*) ul_ch2_1,alpha,(int16_t*) &ul_ch_estimates_1[aa][frame_parms->N_RB_UL*12*k],0,Msc_RS);
-            }
-
-          }
-        } //for(k=...
-
-        // because of the scaling of alpha and beta we also need to scale the final channel estimate at the pilot positions
-
-        //    multadd_complex_vector_real_scalar((int16_t*) ul_ch1,SCALE,(int16_t*) ul_ch1,1,Msc_RS);
-        //    multadd_complex_vector_real_scalar((int16_t*) ul_ch2,SCALE,(int16_t*) ul_ch2,1,Msc_RS);
-
-        if(cooperation_flag == 2) { // For Distributed Alamouti
-          multadd_complex_vector_real_scalar((int16_t*) ul_ch1_0,SCALE,(int16_t*) ul_ch1_0,1,Msc_RS);
-          multadd_complex_vector_real_scalar((int16_t*) ul_ch2_0,SCALE,(int16_t*) ul_ch2_0,1,Msc_RS);
-
-          multadd_complex_vector_real_scalar((int16_t*) ul_ch1_1,SCALE,(int16_t*) ul_ch1_1,1,Msc_RS);
-          multadd_complex_vector_real_scalar((int16_t*) ul_ch2_1,SCALE,(int16_t*) ul_ch2_1,1,Msc_RS);
-        }
-
-
-      } //if (Ns&1)
+	} //if (Ns&1)
 
     } //for(aa=...
 
@@ -673,8 +438,8 @@ int32_t lte_srs_channel_estimation(LTE_DL_FRAME_PARMS *frame_parms,
                                    LTE_eNB_COMMON *common_vars,
                                    LTE_eNB_SRS *srs_vars,
                                    SOUNDINGRS_UL_CONFIG_DEDICATED *soundingrs_ul_config_dedicated,
-                                   unsigned char sub_frame_number,
-                                   unsigned char eNB_id)
+                                   unsigned char sub_frame_number)
+
 {
 
   int T_SFC,aa;
@@ -704,24 +469,24 @@ int32_t lte_srs_channel_estimation(LTE_DL_FRAME_PARMS *frame_parms,
     if (generate_srs_rx(frame_parms,
                         soundingrs_ul_config_dedicated,
                         srs_vars->srs)==-1) {
-      msg("lte_srs_channel_estimation: Error in generate_srs_rx\n");
+      LOG_E(PHY,"lte_srs_channel_estimation: Error in generate_srs_rx\n");
       return(-1);
     }
 
     for (aa=0; aa<nb_antennas_rx; aa++) {
 #ifdef DEBUG_SRS
-      msg("SRS channel estimation eNB %d, subframs %d, aarx %d, %p, %p, %p\n",eNB_id,sub_frame_number,aa,
-          &common_vars->rxdataF[eNB_id][aa][2*frame_parms->ofdm_symbol_size*symbol],
+      LOG_E(PHY,"SRS channel estimation, subframs %d, aarx %d, %p, %p, %p\n",sub_frame_number,aa,
+          &common_vars->rxdataF[aa][2*frame_parms->ofdm_symbol_size*symbol],
           srs_vars->srs,
-          srs_vars->srs_ch_estimates[eNB_id][aa]);
+          srs_vars->srs_ch_estimates[aa]);
 #endif
 
       //write_output("eNB_rxF.m","rxF",&common_vars->rxdataF[0][aa][2*frame_parms->ofdm_symbol_size*symbol],2*(frame_parms->ofdm_symbol_size),2,1);
       //write_output("eNB_srs.m","srs_eNB",common_vars->srs,(frame_parms->ofdm_symbol_size),1,1);
 
-      mult_cpx_conj_vector((int16_t*) &common_vars->rxdataF[eNB_id][aa][2*frame_parms->ofdm_symbol_size*symbol],
+      mult_cpx_conj_vector((int16_t*) &common_vars->rxdataF[aa][2*frame_parms->ofdm_symbol_size*symbol],
 			   (int16_t*) srs_vars->srs,
-			   (int16_t*) srs_vars->srs_ch_estimates[eNB_id][aa],
+			   (int16_t*) srs_vars->srs_ch_estimates[aa],
 			   frame_parms->ofdm_symbol_size,
 			   15,
 			   0);
@@ -729,9 +494,9 @@ int32_t lte_srs_channel_estimation(LTE_DL_FRAME_PARMS *frame_parms,
       //msg("SRS channel estimation cmult out\n");
 #ifdef USER_MODE
 #ifdef DEBUG_SRS
-      sprintf(fname,"eNB_id%d_an%d_srs_ch_est.m",eNB_id,aa);
-      sprintf(vname,"eNB%d_%d_srs_ch_est",eNB_id,aa);
-      write_output(fname,vname,srs_vars->srs_ch_estimates[eNB_id][aa],frame_parms->ofdm_symbol_size,1,1);
+      sprintf(fname,"srs_ch_est%d.m",aa);
+      sprintf(vname,"srs_est%d",aa);
+      write_output(fname,vname,srs_vars->srs_ch_estimates[aa],frame_parms->ofdm_symbol_size,1,1);
 #endif
 #endif
     }
diff --git a/openair1/PHY/LTE_REFSIG/lte_dl_mbsfn.c b/openair1/PHY/LTE_REFSIG/lte_dl_mbsfn.c
index cb255d7896..bb0133f7fc 100644
--- a/openair1/PHY/LTE_REFSIG/lte_dl_mbsfn.c
+++ b/openair1/PHY/LTE_REFSIG/lte_dl_mbsfn.c
@@ -64,7 +64,7 @@ int lte_dl_mbsfn(PHY_VARS_eNB *eNB, int32_t *output,
     else if (l==1)
       k = 1+(m<<1);
     else {
-      msg("lte_dl_mbsfn: l %d -> ERROR\n",l);
+      LOG_E(PHY,"lte_dl_mbsfn: l %d -> ERROR\n",l);
       return(-1);
     }
 
@@ -83,9 +83,9 @@ int lte_dl_mbsfn(PHY_VARS_eNB *eNB, int32_t *output,
 
 
 #ifdef DEBUG_DL_MBSFN
-    msg("subframe %d, l %d, m %d, mprime %d, mprime_dword %d, mprime_qpsk_symbol %d\n",
+    LOG_D(PHY,"subframe %d, l %d, m %d, mprime %d, mprime_dword %d, mprime_qpsk_symbol %d\n",
         subframe,l,m,mprime,mprime_dword,mprime_qpsk_symb);
-    msg("index = %d (k %d)(%x)\n",(eNB->lte_gold_mbsfn_table[subframe][l][mprime_dword]>>(2*mprime_qpsk_symb))&3,k,eNB->lte_gold_mbsfn_table[subframe][l][mprime_dword]);
+    LOG_D(PHY,"index = %d (k %d)(%x)\n",(eNB->lte_gold_mbsfn_table[subframe][l][mprime_dword]>>(2*mprime_qpsk_symb))&3,k,eNB->lte_gold_mbsfn_table[subframe][l][mprime_dword]);
 #endif
     mprime++;
 
diff --git a/openair1/PHY/LTE_TRANSPORT/dci.c b/openair1/PHY/LTE_TRANSPORT/dci.c
index 49fe90bf15..a719ae614f 100644
--- a/openair1/PHY/LTE_TRANSPORT/dci.c
+++ b/openair1/PHY/LTE_TRANSPORT/dci.c
@@ -2165,7 +2165,7 @@ uint8_t generate_dci_top(uint8_t num_ue_spec_dci,
 
 
   // Now do modulation
-  if (frame_parms->mode1_flag==1)
+  if (frame_parms->nb_antenna_ports_eNB==1)
     gain_lin_QPSK = (int16_t)((amp*ONE_OVER_SQRT2_Q15)>>15);
   else
     gain_lin_QPSK = amp/2;
@@ -2177,7 +2177,7 @@ uint8_t generate_dci_top(uint8_t num_ue_spec_dci,
 #endif
 
 
-  if (frame_parms->mode1_flag) { //SISO
+  if (frame_parms->nb_antenna_ports_eNB==1) { //SISO
 
 
     for (i=0; i<Msymb2; i++) {
@@ -2396,23 +2396,23 @@ uint8_t generate_dci_top_emul(PHY_VARS_eNB *phy_vars_eNB,
     if (dci_alloc[n_dci].format > 0) { // exclude the uplink dci
 
       if (dci_alloc[n_dci].rnti == SI_RNTI) {
-        dlsch_eNB = PHY_vars_eNB_g[phy_vars_eNB->Mod_id][phy_vars_eNB->CC_id]->dlsch_SI;
+        dlsch_eNB = RC.eNB[phy_vars_eNB->Mod_id][phy_vars_eNB->CC_id]->dlsch_SI;
         eNB_transport_info[phy_vars_eNB->Mod_id][phy_vars_eNB->CC_id].dlsch_type[n_dci_dl] = 0;//SI;
         eNB_transport_info[phy_vars_eNB->Mod_id][phy_vars_eNB->CC_id].harq_pid[n_dci_dl] = 0;
         eNB_transport_info[phy_vars_eNB->Mod_id][phy_vars_eNB->CC_id].tbs[n_dci_dl] = dlsch_eNB->harq_processes[0]->TBS>>3;
         LOG_D(PHY,"[DCI][EMUL]SI tbs is %d and dci index %d harq pid is %d \n",eNB_transport_info[phy_vars_eNB->Mod_id][phy_vars_eNB->CC_id].tbs[n_dci_dl],n_dci_dl,
               eNB_transport_info[phy_vars_eNB->Mod_id][phy_vars_eNB->CC_id].harq_pid[n_dci_dl]);
       } else if (dci_alloc[n_dci_dl].ra_flag == 1) {
-        dlsch_eNB = PHY_vars_eNB_g[phy_vars_eNB->Mod_id][phy_vars_eNB->CC_id]->dlsch_ra;
+        dlsch_eNB = RC.eNB[phy_vars_eNB->Mod_id][phy_vars_eNB->CC_id]->dlsch_ra;
         eNB_transport_info[phy_vars_eNB->Mod_id][phy_vars_eNB->CC_id].dlsch_type[n_dci_dl] = 1;//RA;
         eNB_transport_info[phy_vars_eNB->Mod_id][phy_vars_eNB->CC_id].harq_pid[n_dci_dl] = 0;
         eNB_transport_info[phy_vars_eNB->Mod_id][phy_vars_eNB->CC_id].tbs[n_dci_dl] = dlsch_eNB->harq_processes[0]->TBS>>3;
         LOG_D(PHY,"[DCI][EMUL] RA  tbs is %d and dci index %d harq pid is %d \n",eNB_transport_info[phy_vars_eNB->Mod_id][phy_vars_eNB->CC_id].tbs[n_dci_dl],n_dci_dl,
               eNB_transport_info[phy_vars_eNB->Mod_id][phy_vars_eNB->CC_id].harq_pid[n_dci_dl]);
       } else {
-        ue_id = find_ue(dci_alloc[n_dci_dl].rnti,PHY_vars_eNB_g[phy_vars_eNB->Mod_id][phy_vars_eNB->CC_id]);
+        ue_id = find_ue(dci_alloc[n_dci_dl].rnti,RC.eNB[phy_vars_eNB->Mod_id][phy_vars_eNB->CC_id]);
         DevAssert( ue_id != (uint8_t)-1 );
-        dlsch_eNB = PHY_vars_eNB_g[phy_vars_eNB->Mod_id][phy_vars_eNB->CC_id]->dlsch[ue_id][0];
+        dlsch_eNB = RC.eNB[phy_vars_eNB->Mod_id][phy_vars_eNB->CC_id]->dlsch[ue_id][0];
 
         eNB_transport_info[phy_vars_eNB->Mod_id][phy_vars_eNB->CC_id].dlsch_type[n_dci_dl] = 2;//TB0;
         eNB_transport_info[phy_vars_eNB->Mod_id][phy_vars_eNB->CC_id].harq_pid[n_dci_dl] = dlsch_eNB->current_harq_pid;
@@ -2556,8 +2556,8 @@ uint16_t get_nCCE_mac(uint8_t Mod_id,uint8_t CC_id,int num_pdcch_symbols,int sub
 
   // check for eNB only !
   return(get_nCCE(num_pdcch_symbols,
-		  &PHY_vars_eNB_g[Mod_id][CC_id]->frame_parms,
-		  get_mi(&PHY_vars_eNB_g[Mod_id][CC_id]->frame_parms,subframe))); 
+		  &RC.eNB[Mod_id][CC_id]->frame_parms,
+		  get_mi(&RC.eNB[Mod_id][CC_id]->frame_parms,subframe))); 
 }
 
 
diff --git a/openair1/PHY/LTE_TRANSPORT/dci_tools.c b/openair1/PHY/LTE_TRANSPORT/dci_tools.c
index 72f276408f..beaebbca95 100644
--- a/openair1/PHY/LTE_TRANSPORT/dci_tools.c
+++ b/openair1/PHY/LTE_TRANSPORT/dci_tools.c
@@ -848,10 +848,10 @@ uint8_t get_transmission_mode(module_id_t Mod_id, uint8_t CC_id, rnti_t rnti)
   unsigned char UE_id;
 
   // find the UE_index corresponding to rnti
-  UE_id = find_ue(rnti,PHY_vars_eNB_g[Mod_id][CC_id]);
+  UE_id = find_ue(rnti,RC.eNB[Mod_id][CC_id]);
   DevAssert( UE_id != (unsigned char)-1 );
 
-  return(PHY_vars_eNB_g[Mod_id][CC_id]->transmission_mode[UE_id]);
+  return(RC.eNB[Mod_id][CC_id]->transmission_mode[UE_id]);
 }
 
 int generate_eNB_dlsch_params_from_dci(int frame,
@@ -1084,7 +1084,7 @@ int generate_eNB_dlsch_params_from_dci(int frame,
     dlsch0_harq->Nl          = 1;
     //dlsch0_harq->layer_index = 0;
 
-    dlsch0_harq->mimo_mode   = (frame_parms->mode1_flag == 1) ? SISO : ALAMOUTI;
+    dlsch0_harq->mimo_mode   = (frame_parms->nb_antenna_ports_eNB == 1) ? SISO : ALAMOUTI;
     /*
     if ((rnti!=si_rnti)&&(rnti!=ra_rnti)&&(rnti!=p_rnti)) {  //handle toggling for C-RNTI
     if (dlsch0_harq->first_tx == 1) {
@@ -1235,7 +1235,7 @@ int generate_eNB_dlsch_params_from_dci(int frame,
     dlsch0_harq->Nl          = 1;
     //    dlsch[0]->layer_index = 0;
     if (beamforming_mode == 0)
-      dlsch0_harq->mimo_mode = (frame_parms->mode1_flag == 1) ? SISO : ALAMOUTI;
+      dlsch0_harq->mimo_mode = (frame_parms->nb_antenna_ports_eNB == 1) ? SISO : ALAMOUTI;
     else if (beamforming_mode == 7)
       dlsch0_harq->mimo_mode = TM7;
     else
@@ -2618,7 +2618,7 @@ int generate_eNB_dlsch_params_from_dci(int frame,
     //    printf("Set pmi %x (tpmi %d)\n",dlsch0->pmi_alloc,tpmi);
 
 
-    if (frame_parms->mode1_flag == 1)
+    if (frame_parms->nb_antenna_ports_eNB == 1)
       dlsch0_harq->mimo_mode   = SISO;
 
     //    dlsch0_harq->Ndi         = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->ndi;
@@ -4162,7 +4162,7 @@ int generate_ue_dlsch_params_from_dci(int frame,
     dlsch0_harq->Nl = 1;
     //    dlsch[0]->layer_index = 0;
 
-    dlsch0_harq->mimo_mode = frame_parms->mode1_flag == 1 ?SISO : ALAMOUTI;
+    dlsch0_harq->mimo_mode = frame_parms->nb_antenna_ports_eNB == 1 ?SISO : ALAMOUTI;
     dlsch0_harq->dl_power_off = 1; //no power offset
 
     dlsch[0]->active = 1; // fix no DLSCH decoding for downlink retransmission
@@ -4357,7 +4357,7 @@ int generate_ue_dlsch_params_from_dci(int frame,
 
 
     dlsch0_harq->Nl = 1;
-    dlsch0_harq->mimo_mode = frame_parms->mode1_flag == 1 ?SISO : ALAMOUTI;
+    dlsch0_harq->mimo_mode = frame_parms->nb_antenna_ports_eNB == 1 ?SISO : ALAMOUTI;
     dlsch0_harq->dl_power_off = 1; //no power offset
 
     LOG_D(PHY,"UE (%x/%d): Subframe %d Format1C DCI: harq_status %d, round %d\n",
@@ -4567,7 +4567,7 @@ int generate_ue_dlsch_params_from_dci(int frame,
     dlsch[0]->rnti = rnti;
 
     if (beamforming_mode == 0)
-      dlsch0_harq->mimo_mode   = (frame_parms->mode1_flag == 1) ? SISO : ALAMOUTI;
+      dlsch0_harq->mimo_mode   = (frame_parms->nb_antenna_ports_eNB == 1) ? SISO : ALAMOUTI;
     else if (beamforming_mode == 7)
       dlsch0_harq->mimo_mode   = TM7;
     else
@@ -4896,7 +4896,7 @@ int generate_ue_dlsch_params_from_dci(int frame,
     }
 
 
-    if (frame_parms->mode1_flag == 1)
+    if (frame_parms->nb_antenna_ports_eNB == 1)
       dlsch0_harq->mimo_mode   = SISO;
 
     if (ndi1!=dlsch0_harq->DCINdi) {
@@ -5573,7 +5573,7 @@ int generate_ue_dlsch_params_from_dci(int frame,
     }
 
 
-    if (frame_parms->mode1_flag == 1)
+    if (frame_parms->nb_antenna_ports_eNB == 1)
       dlsch0_harq->mimo_mode   = SISO;
 
 
diff --git a/openair1/PHY/LTE_TRANSPORT/defs.h b/openair1/PHY/LTE_TRANSPORT/defs.h
index 8e17697ff4..f78b4c6701 100644
--- a/openair1/PHY/LTE_TRANSPORT/defs.h
+++ b/openair1/PHY/LTE_TRANSPORT/defs.h
@@ -232,13 +232,13 @@ typedef struct {
 
   // decode phich
   uint8_t decode_phich;
-} LTE_UL_UE_HARQ_t;
+} LTE_UL_UE_HARQ_t; 
 
 typedef struct {
   /// TX buffers for UE-spec transmission (antenna ports 5 or 7..14, prior to precoding)
   int32_t *txdataF[8];
   /// beamforming weights for UE-spec transmission (antenna ports 5 or 7..14), for each codeword, maximum 4 layers?
-  int32_t **ue_spec_bf_weights[4]; 
+  int32_t **ue_spec_bf_weights[MAX_NUM_RU_PER_eNB][4]; 
   /// dl channel estimates (estimated from ul channel estimates)
   int32_t **calib_dl_ch_estimates;
   /// Allocated RNTI (0 means DLSCH_t is not currently used)
diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c
index 8ec2a40d8d..835cf17df8 100644
--- a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c
+++ b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c
@@ -118,6 +118,8 @@ LTE_eNB_DLSCH_t *new_eNB_dlsch(unsigned char Kmimo,unsigned char Mdlharq,uint32_
   unsigned char exit_flag = 0,i,j,r,aa,layer;
   int re;
   unsigned char bw_scaling =1;
+  RU_t *ru;
+  int ru_id;
 
   switch (N_RB_DL) {
   case 6:
@@ -146,22 +148,14 @@ LTE_eNB_DLSCH_t *new_eNB_dlsch(unsigned char Kmimo,unsigned char Mdlharq,uint32_
     dlsch->Mlimit = 4;
     dlsch->Nsoft = Nsoft;
 
-    for (layer=0; layer<4; layer++) {
-      dlsch->ue_spec_bf_weights[layer] = (int32_t**)malloc16(frame_parms->nb_antennas_tx*sizeof(int32_t*));
-  
-       for (aa=0; aa<frame_parms->nb_antennas_tx; aa++) {
-         dlsch->ue_spec_bf_weights[layer][aa] = (int32_t *)malloc16(OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES*sizeof(int32_t));
-         for (re=0;re<OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES; re++) {
-           dlsch->ue_spec_bf_weights[layer][aa][re] = 0x00007fff;
-         }
-       }
-     }
 
+    // NOTE: THIS HAS TO BE REVISED FOR RU, commenting to remove memory leak !!!!!
+    /*
      dlsch->calib_dl_ch_estimates = (int32_t**)malloc16(frame_parms->nb_antennas_tx*sizeof(int32_t*));
      for (aa=0; aa<frame_parms->nb_antennas_tx; aa++) {
        dlsch->calib_dl_ch_estimates[aa] = (int32_t *)malloc16(OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES*sizeof(int32_t));
        
-     }
+       }*/
 
     for (i=0; i<10; i++)
       dlsch->harq_ids[i] = Mdlharq;
diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_decoding.c b/openair1/PHY/LTE_TRANSPORT/dlsch_decoding.c
index 9629502cec..f4569a3c54 100644
--- a/openair1/PHY/LTE_TRANSPORT/dlsch_decoding.c
+++ b/openair1/PHY/LTE_TRANSPORT/dlsch_decoding.c
@@ -861,7 +861,7 @@ uint32_t dlsch_decoding_emul(PHY_VARS_UE *phy_vars_ue,
 
   // may not be necessary for PMCH??
   for (eNB_id2=0; eNB_id2<NB_eNB_INST; eNB_id2++) {
-    if (PHY_vars_eNB_g[eNB_id2][CC_id]->frame_parms.Nid_cell == phy_vars_ue->frame_parms.Nid_cell)
+    if (RC.eNB[eNB_id2][CC_id]->frame_parms.Nid_cell == phy_vars_ue->frame_parms.Nid_cell)
       break;
   }
 
@@ -878,7 +878,7 @@ uint32_t dlsch_decoding_emul(PHY_VARS_UE *phy_vars_ue,
   switch (dlsch_id) {
   case SI_PDSCH: // SI
     dlsch_ue = phy_vars_ue->dlsch_SI[eNB_id];
-    dlsch_eNB = PHY_vars_eNB_g[eNB_id2][CC_id]->dlsch_SI;
+    dlsch_eNB = RC.eNB[eNB_id2][CC_id]->dlsch_SI;
     //    printf("Doing SI: TBS %d\n",dlsch_ue->harq_processes[0]->TBS>>3);
     memcpy(dlsch_ue->harq_processes[0]->b,dlsch_eNB->harq_processes[0]->b,dlsch_ue->harq_processes[0]->TBS>>3);
 #ifdef DEBUG_DLSCH_DECODING
@@ -894,7 +894,7 @@ uint32_t dlsch_decoding_emul(PHY_VARS_UE *phy_vars_ue,
 
   case RA_PDSCH: // RA
     dlsch_ue  = phy_vars_ue->dlsch_ra[eNB_id];
-    dlsch_eNB = PHY_vars_eNB_g[eNB_id2][CC_id]->dlsch_ra;
+    dlsch_eNB = RC.eNB[eNB_id2][CC_id]->dlsch_ra;
     memcpy(dlsch_ue->harq_processes[0]->b,dlsch_eNB->harq_processes[0]->b,dlsch_ue->harq_processes[0]->TBS>>3);
 #ifdef DEBUG_DLSCH_DECODING
     LOG_D(PHY,"RA Decoded\n");
@@ -910,9 +910,9 @@ uint32_t dlsch_decoding_emul(PHY_VARS_UE *phy_vars_ue,
   case PDSCH: // TB0
     dlsch_ue  = phy_vars_ue->dlsch[eNB_id][0];
     harq_pid = dlsch_ue->current_harq_pid;
-    ue_id= (uint32_t)find_ue((int16_t)phy_vars_ue->pdcch_vars[(uint32_t)eNB_id]->crnti,PHY_vars_eNB_g[eNB_id2][CC_id]);
+    ue_id= (uint32_t)find_ue((int16_t)phy_vars_ue->pdcch_vars[(uint32_t)eNB_id]->crnti,RC.eNB[eNB_id2][CC_id]);
     DevAssert( ue_id != (uint32_t)-1 );
-    dlsch_eNB = PHY_vars_eNB_g[eNB_id2][CC_id]->dlsch[ue_id][0];
+    dlsch_eNB = RC.eNB[eNB_id2][CC_id]->dlsch[ue_id][0];
 
 #ifdef DEBUG_DLSCH_DECODING
 
@@ -926,7 +926,7 @@ uint32_t dlsch_decoding_emul(PHY_VARS_UE *phy_vars_ue,
                                 phy_vars_ue->transmission_mode[eNB_id],
                                 dlsch_eNB->harq_processes[harq_pid]->rb_alloc,
                                 dlsch_eNB->harq_processes[harq_pid]->mcs,
-                                PHY_vars_eNB_g[eNB_id][CC_id]->mu_mimo_mode[ue_id].dl_pow_off) == 1) {
+                                RC.eNB[eNB_id][CC_id]->mu_mimo_mode[ue_id].dl_pow_off) == 1) {
       // reset HARQ
       dlsch_ue->harq_processes[harq_pid]->status = SCH_IDLE;
       dlsch_ue->harq_processes[harq_pid]->round  = 0;
@@ -956,9 +956,9 @@ uint32_t dlsch_decoding_emul(PHY_VARS_UE *phy_vars_ue,
   case PDSCH1: { // TB1
     dlsch_ue = phy_vars_ue->dlsch[eNB_id][1];
     harq_pid = dlsch_ue->current_harq_pid;
-    int8_t UE_id = find_ue( phy_vars_ue->pdcch_vars[eNB_id]->crnti, PHY_vars_eNB_g[eNB_id2][CC_id] );
+    int8_t UE_id = find_ue( phy_vars_ue->pdcch_vars[eNB_id]->crnti, RC.eNB[eNB_id2][CC_id] );
     DevAssert( UE_id != -1 );
-    dlsch_eNB = PHY_vars_eNB_g[eNB_id2][CC_id]->dlsch[UE_id][1];
+    dlsch_eNB = RC.eNB[eNB_id2][CC_id]->dlsch[UE_id][1];
     // reset HARQ
     dlsch_ue->harq_processes[harq_pid]->status = SCH_IDLE;
     dlsch_ue->harq_processes[harq_pid]->round  = 0;
@@ -975,7 +975,7 @@ uint32_t dlsch_decoding_emul(PHY_VARS_UE *phy_vars_ue,
   case PMCH: // PMCH
 
     dlsch_ue  = phy_vars_ue->dlsch_MCH[eNB_id];
-    dlsch_eNB = PHY_vars_eNB_g[eNB_id2][CC_id]->dlsch_MCH;
+    dlsch_eNB = RC.eNB[eNB_id2][CC_id]->dlsch_MCH;
 
     LOG_D(PHY,"decoding pmch emul (size is %d, enb %d %d)\n",  dlsch_ue->harq_processes[0]->TBS>>3, eNB_id, eNB_id2);
 #ifdef DEBUG_DLSCH_DECODING
@@ -988,7 +988,7 @@ uint32_t dlsch_decoding_emul(PHY_VARS_UE *phy_vars_ue,
 
     /*
       if (dlsch_abstraction_MIESM(phy_vars_ue->sinr_dB, phy_vars_ue->transmission_mode[eNB_id], dlsch_eNB->rb_alloc,
-        dlsch_eNB->harq_processes[0]->mcs,PHY_vars_eNB_g[eNB_id]->mu_mimo_mode[ue_id].dl_pow_off) == 1) {
+        dlsch_eNB->harq_processes[0]->mcs,RC.eNB[eNB_id]->mu_mimo_mode[ue_id].dl_pow_off) == 1) {
     */
     if (1) {
       // reset HARQ
diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_demodulation.c b/openair1/PHY/LTE_TRANSPORT/dlsch_demodulation.c
index 7d14e8aca7..06261d6a81 100644
--- a/openair1/PHY/LTE_TRANSPORT/dlsch_demodulation.c
+++ b/openair1/PHY/LTE_TRANSPORT/dlsch_demodulation.c
@@ -875,7 +875,7 @@ void dlsch_channel_compensation(int **rxdataF_ext,
 
   if ((symbol_mod == 0) || (symbol_mod == (4-frame_parms->Ncp))) {
 
-    if (frame_parms->mode1_flag==1) // 10 out of 12 so don't reduce size
+    if (frame_parms->nb_antenna_ports_eNB==1) // 10 out of 12 so don't reduce size
       nb_rb=1+(5*nb_rb/6);
     else
       pilots=1;
@@ -1133,7 +1133,7 @@ void dlsch_channel_compensation(int **rxdataF_ext,
   symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol;
 
   if ((symbol_mod == 0) || (symbol_mod == (4-frame_parms->Ncp))) {
-    if (frame_parms->mode1_flag==1) { // 10 out of 12 so don't reduce size
+    if (frame_parms->nb_antenna_ports_eNB==1) { // 10 out of 12 so don't reduce size
       nb_rb=1+(5*nb_rb/6);
     }
     else {
@@ -1736,7 +1736,7 @@ void dlsch_channel_compensation_TM56(int **rxdataF_ext,
   
   symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol;  
   if ((symbol_mod == 0) || (symbol_mod == (4-frame_parms->Ncp))) {
-    if (frame_parms->mode1_flag==1) // 10 out of 12 so don't reduce size
+    if (frame_parms->nb_antenna_ports_eNB==1) // 10 out of 12 so don't reduce size
       { nb_rb=1+(5*nb_rb/6); }
     
     else
@@ -2272,7 +2272,7 @@ void dlsch_channel_compensation_TM3(LTE_DL_FRAME_PARMS *frame_parms,
   symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol;
   
   if ((symbol_mod == 0) || (symbol_mod == (4-frame_parms->Ncp))) {
-    if (frame_parms->mode1_flag==1) // 10 out of 12 so don't reduce size
+    if (frame_parms->nb_antenna_ports_eNB==1) // 10 out of 12 so don't reduce size
       { nb_rb=1+(5*nb_rb/6); }
     
     else
@@ -2783,7 +2783,7 @@ void dlsch_scale_channel(int **dl_ch_estimates_ext,
   symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol;
 
   if ((symbol_mod == 0) || (symbol_mod == (4-frame_parms->Ncp))) {
-    if (frame_parms->mode1_flag==1) // 10 out of 12 so don't reduce size
+    if (frame_parms->nb_antenna_ports_eNB==1) // 10 out of 12 so don't reduce size
       nb_rb=1+(5*nb_rb/6);
     else
       pilots=1;
@@ -2854,7 +2854,7 @@ void dlsch_channel_level(int **dl_ch_estimates_ext,
         avg128D = _mm_add_epi32(avg128D,_mm_madd_epi16(dl_ch128[0],dl_ch128[0]));
         avg128D = _mm_add_epi32(avg128D,_mm_madd_epi16(dl_ch128[1],dl_ch128[1]));
 
-        if (((symbol_mod == 0) || (symbol_mod == (frame_parms->Ncp-1)))&&(frame_parms->mode1_flag==0)) {
+        if (((symbol_mod == 0) || (symbol_mod == (frame_parms->Ncp-1)))&&(frame_parms->nb_antenna_ports_eNB!=1)) {
           dl_ch128+=2;
         } else {
           avg128D = _mm_add_epi32(avg128D,_mm_madd_epi16(dl_ch128[2],dl_ch128[2]));
@@ -2870,9 +2870,9 @@ void dlsch_channel_level(int **dl_ch_estimates_ext,
         */
       }
 
-      if (((symbol_mod == 0) || (symbol_mod == (frame_parms->Ncp-1)))&&(frame_parms->mode1_flag==0))
+      if (((symbol_mod == 0) || (symbol_mod == (frame_parms->Ncp-1)))&&(frame_parms->nb_antenna_ports_eNB!=1))
         nre=8;
-      else if (((symbol_mod == 0) || (symbol_mod == (frame_parms->Ncp-1)))&&(frame_parms->mode1_flag==1))
+      else if (((symbol_mod == 0) || (symbol_mod == (frame_parms->Ncp-1)))&&(frame_parms->nb_antenna_ports_eNB==1))
         nre=10;
       else
         nre=12;
@@ -2913,7 +2913,7 @@ void dlsch_channel_level(int **dl_ch_estimates_ext,
         avg128D = vqaddq_s32(avg128D,vmull_s16(dl_ch128[2],dl_ch128[2]));
         avg128D = vqaddq_s32(avg128D,vmull_s16(dl_ch128[3],dl_ch128[3]));
 
-        if (((symbol_mod == 0) || (symbol_mod == (frame_parms->Ncp-1)))&&(frame_parms->mode1_flag==0)) {
+        if (((symbol_mod == 0) || (symbol_mod == (frame_parms->Ncp-1)))&&(frame_parms->nb_antenna_ports_eNB!=1)) {
           dl_ch128+=4;
         } else {
           avg128D = vqaddq_s32(avg128D,vmull_s16(dl_ch128[4],dl_ch128[4]));
@@ -2930,9 +2930,9 @@ void dlsch_channel_level(int **dl_ch_estimates_ext,
         */
       }
 
-      if (((symbol_mod == 0) || (symbol_mod == (frame_parms->Ncp-1)))&&(frame_parms->mode1_flag==0))
+      if (((symbol_mod == 0) || (symbol_mod == (frame_parms->Ncp-1)))&&(frame_parms->nb_antenna_ports_eNB!=1))
         nre=8;
-      else if (((symbol_mod == 0) || (symbol_mod == (frame_parms->Ncp-1)))&&(frame_parms->mode1_flag==1))
+      else if (((symbol_mod == 0) || (symbol_mod == (frame_parms->Ncp-1)))&&(frame_parms->nb_antenna_ports_eNB==1))
         nre=10;
       else
         nre=12;
@@ -2970,9 +2970,9 @@ void dlsch_channel_level_TM3(int **dl_ch_estimates_ext,
   avg[1] = 0;
   // 5 is always a symbol with no pilots for both normal and extended prefix
 
-  if (((symbol_mod == 0) || (symbol_mod == (frame_parms->Ncp-1)))&&(frame_parms->mode1_flag==0))
+  if (((symbol_mod == 0) || (symbol_mod == (frame_parms->Ncp-1)))&&(frame_parms->nb_antenna_ports_eNB!=1))
     nre=8;
-  else if (((symbol_mod == 0) || (symbol_mod == (frame_parms->Ncp-1)))&&(frame_parms->mode1_flag==1))
+  else if (((symbol_mod == 0) || (symbol_mod == (frame_parms->Ncp-1)))&&(frame_parms->nb_antenna_ports_eNB==1))
     nre=10;
   else
     nre=12;
@@ -2997,7 +2997,7 @@ void dlsch_channel_level_TM3(int **dl_ch_estimates_ext,
       //      mmtmpD1 = _mm_madd_epi16(dl_ch0_128_tmp,dl_ch0_128_tmp);
       avg128D = _mm_add_epi32(avg128D,_mm_madd_epi16(dl_ch0_128_tmp,dl_ch0_128_tmp));
 
-      if (((symbol_mod == 0) || (symbol_mod == (frame_parms->Ncp-1)))&&(frame_parms->mode1_flag==0)) {
+      if (((symbol_mod == 0) || (symbol_mod == (frame_parms->Ncp-1)))&&(frame_parms->nb_antenna_ports_eNB!=1)) {
         dl_ch0_128+=2;
         dl_ch1_128+=2;
       } else {
@@ -3053,9 +3053,9 @@ void dlsch_channel_level_TM56(int **dl_ch_estimates_ext,
   avg[1] = 0;
   // 5 is always a symbol with no pilots for both normal and extended prefix
 
-  if (((symbol_mod == 0) || (symbol_mod == (frame_parms->Ncp-1)))&&(frame_parms->mode1_flag==0))
+  if (((symbol_mod == 0) || (symbol_mod == (frame_parms->Ncp-1)))&&(frame_parms->nb_antenna_ports_eNB!=1))
     nre=8;
-  else if (((symbol_mod == 0) || (symbol_mod == (frame_parms->Ncp-1)))&&(frame_parms->mode1_flag==1))
+  else if (((symbol_mod == 0) || (symbol_mod == (frame_parms->Ncp-1)))&&(frame_parms->nb_antenna_ports_eNB==1))
     nre=10;
   else
     nre=12;
@@ -3080,7 +3080,7 @@ void dlsch_channel_level_TM56(int **dl_ch_estimates_ext,
       //      mmtmpD1 = _mm_madd_epi16(dl_ch0_128_tmp,dl_ch0_128_tmp);
       avg128D = _mm_add_epi32(avg128D,_mm_madd_epi16(dl_ch0_128_tmp,dl_ch0_128_tmp));
 
-      if (((symbol_mod == 0) || (symbol_mod == (frame_parms->Ncp-1)))&&(frame_parms->mode1_flag==0)) {
+      if (((symbol_mod == 0) || (symbol_mod == (frame_parms->Ncp-1)))&&(frame_parms->nb_antenna_ports_eNB!=1)) {
         dl_ch0_128+=2;
         dl_ch1_128+=2;
       } else {
@@ -3144,7 +3144,7 @@ void dlsch_channel_level_TM7(int **dl_bf_ch_estimates_ext,
         avg128D = _mm_add_epi32(avg128D,_mm_madd_epi16(dl_ch128[0],dl_ch128[0]));
         avg128D = _mm_add_epi32(avg128D,_mm_madd_epi16(dl_ch128[1],dl_ch128[1]));
 
-        if (((symbol_mod == 0) || (symbol_mod == (frame_parms->Ncp-1)))&&(frame_parms->mode1_flag==0)) {
+        if (((symbol_mod == 0) || (symbol_mod == (frame_parms->Ncp-1)))&&(frame_parms->nb_antenna_ports_eNB!=1)) {
           dl_ch128+=2;
         } else {
           avg128D = _mm_add_epi32(avg128D,_mm_madd_epi16(dl_ch128[2],dl_ch128[2]));
@@ -4473,7 +4473,7 @@ unsigned short dlsch_extract_rbs_TM7(int **rxdataF,
             rxF_ext+=9-frame_parms->Ncp; 
 
           } else {
-            msg("dlsch_extract_rbs_TM7(dl_demodulation.c):pilot or ue spec pilot detection error\n");
+            LOG_E(PHY,"dlsch_extract_rbs_TM7(dl_demodulation.c):pilot or ue spec pilot detection error\n");
             exit(-1);
           }
 
@@ -4733,7 +4733,7 @@ unsigned short dlsch_extract_rbs_TM7(int **rxdataF,
 	    }
  
           } else {
-            msg("dlsch_extract_rbs_TM7(dl_demodulation.c):pilot or ue spec pilot detection error\n");
+            LOG_E(PHY,"dlsch_extract_rbs_TM7(dl_demodulation.c):pilot or ue spec pilot detection error\n");
             exit(-1);
             
           }
diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_llr_computation.c b/openair1/PHY/LTE_TRANSPORT/dlsch_llr_computation.c
index 8165bc1f23..852ed31e80 100644
--- a/openair1/PHY/LTE_TRANSPORT/dlsch_llr_computation.c
+++ b/openair1/PHY/LTE_TRANSPORT/dlsch_llr_computation.c
@@ -648,13 +648,13 @@ int dlsch_qpsk_llr(LTE_DL_FRAME_PARMS *frame_parms,
   }
 
   if (!llr32) {
-    msg("dlsch_qpsk_llr: llr is null, symbol %d, llr32=%p\n",symbol, llr32);
+    LOG_E(PHY,"dlsch_qpsk_llr: llr is null, symbol %d, llr32=%p\n",symbol, llr32);
     return(-1);
   }
 
 
   if ((symbol_mod==0) || (symbol_mod==(4-frame_parms->Ncp))) {
-    if (frame_parms->mode1_flag==0)
+    if (frame_parms->nb_antenna_ports_eNB!=1)
       len = (nb_rb*8) - (2*pbch_pss_sss_adjust/3);
     else
       len = (nb_rb*10) - (5*pbch_pss_sss_adjust/6);
@@ -736,7 +736,7 @@ void dlsch_16qam_llr(LTE_DL_FRAME_PARMS *frame_parms,
   ch_mag = (int16x8_t*)&dl_ch_mag[0][(symbol*frame_parms->N_RB_DL*12)];
 #endif
   if ((symbol_mod==0) || (symbol_mod==(4-frame_parms->Ncp))) {
-    if (frame_parms->mode1_flag==0)
+    if (frame_parms->nb_antenna_ports_eNB!=1)
       len = (nb_rb*8) - (2*pbch_pss_sss_adjust/3);
     else
       len = (nb_rb*10) - (5*pbch_pss_sss_adjust/6);
@@ -851,7 +851,7 @@ void dlsch_64qam_llr(LTE_DL_FRAME_PARMS *frame_parms,
   ch_magb = (int16x8_t*)&dl_ch_magb[0][(symbol*frame_parms->N_RB_DL*12)];
 #endif
   if ((symbol_mod==0) || (symbol_mod==(4-frame_parms->Ncp))) {
-    if (frame_parms->mode1_flag==0)
+    if (frame_parms->nb_antenna_ports_eNB!=1)
       len = (nb_rb*8) - (2*pbch_pss_sss_adjust/3);
     else
       len = (nb_rb*10) - (5*pbch_pss_sss_adjust/6);
@@ -1015,14 +1015,11 @@ int dlsch_qpsk_qpsk_llr(LTE_DL_FRAME_PARMS *frame_parms,
     llr16 = (int16_t*)(*llr16p);
   }
 
-  if (!llr16) {
-    msg("dlsch_qpsk_qpsk_llr: llr is null, symbol %d\n",symbol);
-    return -1;
-  }
+  AssertFatal(llr16!=NULL,"dlsch_qpsk_qpsk_llr: llr is null, symbol %d\n",symbol);
 
   if ((symbol_mod==0) || (symbol_mod==(4-frame_parms->Ncp))) {
     // if symbol has pilots
-    if (frame_parms->mode1_flag==0)
+    if (frame_parms->nb_antenna_ports_eNB!=1)
       // in 2 antenna ports we have 8 REs per symbol per RB
       len = (nb_rb*8) - (2*pbch_pss_sss_adjust/3);
     else
@@ -1266,14 +1263,12 @@ int dlsch_qpsk_16qam_llr(LTE_DL_FRAME_PARMS *frame_parms,
     llr16 = (int16_t*)(*llr16p);
   }
 
-  if (!llr16) {
-    msg("dlsch_qpsk_qpsk_llr: llr is null, symbol %d\n",symbol);
-    return -1;
-  }
+  AssertFatal(llr16!=NULL,"dlsch_qpsk_qpsk_llr: llr is null, symbol %d\n",symbol);
+
 
   if ((symbol_mod==0) || (symbol_mod==(4-frame_parms->Ncp))) {
     // if symbol has pilots
-    if (frame_parms->mode1_flag==0)
+    if (frame_parms->nb_antenna_ports_eNB!=1)
       // in 2 antenna ports we have 8 REs per symbol per RB
       len = (nb_rb*8) - (2*pbch_pss_sss_adjust/3);
     else
@@ -1550,14 +1545,11 @@ int dlsch_qpsk_64qam_llr(LTE_DL_FRAME_PARMS *frame_parms,
     llr16 = (int16_t*)(*llr16p);
   }
 
-  if (!llr16) {
-    msg("dlsch_qpsk_qam64_llr: llr is null, symbol %d\n",symbol);
-    return -1;
-  }
+  AssertFatal(llr16!=NULL,"dlsch_qpsk_qam64_llr: llr is null, symbol %d\n",symbol);
 
   if ((symbol_mod==0) || (symbol_mod==(4-frame_parms->Ncp))) {
     // if symbol has pilots
-    if (frame_parms->mode1_flag==0)
+    if (frame_parms->nb_antenna_ports_eNB!=1)
       // in 2 antenna ports we have 8 REs per symbol per RB
       len = (nb_rb*8) - (2*pbch_pss_sss_adjust/3);
     else
@@ -2320,14 +2312,11 @@ int dlsch_16qam_qpsk_llr(LTE_DL_FRAME_PARMS *frame_parms,
   }
 
 
-  if (!llr16) {
-    msg("dlsch_16qam_qpsk_llr: llr is null, symbol %d\n",symbol);
-    return(-1);
-  }
+  AssertFatal(llr16!=NULL,"dlsch_16qam_qpsk_llr: llr is null, symbol %d\n",symbol);
 
   if ((symbol_mod==0) || (symbol_mod==(4-frame_parms->Ncp))) {
     // if symbol has pilots
-    if (frame_parms->mode1_flag==0)
+    if (frame_parms->nb_antenna_ports_eNB!=1)
       // in 2 antenna ports we have 8 REs per symbol per RB
       len = (nb_rb*8) - (2*pbch_pss_sss_adjust/3);
     else
@@ -2878,14 +2867,11 @@ int dlsch_16qam_16qam_llr(LTE_DL_FRAME_PARMS *frame_parms,
   }
 
 
-  if (!llr16) {
-    msg("dlsch_16qam_16qam_llr: llr is null, symbol %d\n",symbol);
-    return(-1);
-  }
+  AssertFatal(llr16!=NULL,"dlsch_16qam_16qam_llr: llr is null, symbol %d\n",symbol);
 
   if ((symbol_mod==0) || (symbol_mod==(4-frame_parms->Ncp))) {
     // if symbol has pilots
-    if (frame_parms->mode1_flag==0)
+    if (frame_parms->nb_antenna_ports_eNB!=1)
       // in 2 antenna ports we have 8 REs per symbol per RB
       len = (nb_rb*8) - (2*pbch_pss_sss_adjust/3);
     else
@@ -3514,14 +3500,12 @@ int dlsch_16qam_64qam_llr(LTE_DL_FRAME_PARMS *frame_parms,
   }
 
 
-  if (!llr16) {
-    msg("dlsch_16qam_64qam_llr: llr is null, symbol %d\n",symbol);
-    return(-1);
-  }
+  AssertFatal(llr16!=NULL,"dlsch_16qam_64qam_llr:llr is null, symbol %d\n",symbol);
+
 
   if ((symbol_mod==0) || (symbol_mod==(4-frame_parms->Ncp))) {
     // if symbol has pilots
-    if (frame_parms->mode1_flag==0)
+    if (frame_parms->nb_antenna_ports_eNB!=1)
       // in 2 antenna ports we have 8 REs per symbol per RB
       len = (nb_rb*8) - (2*pbch_pss_sss_adjust/3);
     else
@@ -5079,14 +5063,11 @@ int dlsch_64qam_qpsk_llr(LTE_DL_FRAME_PARMS *frame_parms,
     llr16 = (int16_t*)(*llr16p);
   }
 
-  if (!llr16) {
-    msg("dlsch_64qam_64qam_llr: llr is null, symbol %d\n",symbol);
-    return(-1);
-  }
+  AssertFatal(llr16!=NULL,"dlsch_16qam_64qam_llr:llr is null, symbol %d\n",symbol);
 
   if ((symbol_mod==0) || (symbol_mod==(4-frame_parms->Ncp))) {
     // if symbol has pilots
-    if (frame_parms->mode1_flag==0)
+    if (frame_parms->nb_antenna_ports_eNB!=1)
       // in 2 antenna ports we have 8 REs per symbol per RB
       len = (nb_rb*8) - (2*pbch_pss_sss_adjust/3);
     else
@@ -6625,14 +6606,11 @@ int dlsch_64qam_16qam_llr(LTE_DL_FRAME_PARMS *frame_parms,
     llr16 = (int16_t*)(*llr16p);
   }
 
-  if (!llr16) {
-    msg("dlsch_64qam_16qam_llr: llr is null, symbol %d\n",symbol);
-    return(-1);
-  }
+  AssertFatal(llr16!=NULL,"dlsch_16qam_64qam_llr:llr is null, symbol %d\n",symbol);
 
   if ((symbol_mod==0) || (symbol_mod==(4-frame_parms->Ncp))) {
     // if symbol has pilots
-    if (frame_parms->mode1_flag==0)
+    if (frame_parms->nb_antenna_ports_eNB!=1)
       // in 2 antenna ports we have 8 REs per symbol per RB
       len = (nb_rb*8) - (2*pbch_pss_sss_adjust/3);
     else
@@ -8438,14 +8416,11 @@ int dlsch_64qam_64qam_llr(LTE_DL_FRAME_PARMS *frame_parms,
     llr16 = (int16_t*)(*llr16p);
   }
 
-  if (!llr16) {
-    msg("dlsch_64qam_64qam_llr: llr is null, symbol %d\n",symbol);
-    return(-1);
-  }
+  AssertFatal(llr16!=NULL,"dlsch_16qam_64qam_llr:llr is null, symbol %d\n",symbol);
 
   if ((symbol_mod==0) || (symbol_mod==(4-frame_parms->Ncp))) {
     // if symbol has pilots
-    if (frame_parms->mode1_flag==0)
+    if (frame_parms->nb_antenna_ports_eNB!=1)
       // in 2 antenna ports we have 8 REs per symbol per RB
       len = (nb_rb*8) - (2*pbch_pss_sss_adjust/3);
     else
diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c b/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c
index 1875ada878..d50e3ad285 100644
--- a/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c
+++ b/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c
@@ -87,7 +87,7 @@ uint8_t is_not_UEspecRS(int8_t lprime, uint8_t re, uint8_t nushift, uint8_t Ncp,
       break;
 
     default:
-      msg("is_not_UEspecRS() [dlsch_modulation.c] : ERROR, unknown beamforming_mode %d\n",beamforming_mode);
+      LOG_E(PHY,"is_not_UEspecRS() [dlsch_modulation.c] : ERROR, unknown beamforming_mode %d\n",beamforming_mode);
       return(-1);
   }
 
@@ -593,7 +593,7 @@ int allocate_REs_in_RB(PHY_VARS_eNB* phy_vars_eNB,
   //  int first_layer1;
 
 
-  int use2ndpilots = (frame_parms->mode1_flag==1)?1:0;
+  int use2ndpilots = (frame_parms->nb_antenna_ports_eNB==1)?1:0;
 
   uint32_t tti_offset; //,aa;
   uint8_t re;
@@ -1884,6 +1884,9 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB,
   uint8_t Nl0 = dlsch0_harq->Nl;
   uint8_t Nl1;
 #endif
+  int ru_id;
+  RU_t *ru;
+  int eNB_id;
 
   if (dlsch1) {
     dlsch1_harq = dlsch1->harq_processes[harq_pid];
@@ -1983,9 +1986,16 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB,
           lprime=-1;
       }
 
-      // mapping ue specific beamforming weights from UE specified DLSCH structure to common space
-      for (aa=0;aa<frame_parms->nb_antennas_tx;aa++){
-        memcpy(phy_vars_eNB->common_vars.beam_weights[0][5][aa],dlsch0->ue_spec_bf_weights[0][aa],frame_parms->ofdm_symbol_size*sizeof(int32_t));
+      // mapping ue specific beamforming weights from UE specified DLSCH structure to RU beam weights for the eNB
+      for (ru_id=0;ru_id<RC.nb_RU;ru_id++) {
+	ru = RC.ru[ru_id];
+	for (eNB_id=0;eNB_id<ru->num_eNB;eNB_id++){
+	  if (phy_vars_eNB == ru->eNB_list[eNB_id]) {
+	    for (aa=0;aa<ru->nb_tx;aa++){
+	      memcpy(ru->beam_weights[eNB_id][5][aa],dlsch0->ue_spec_bf_weights[ru_id][0][aa],frame_parms->ofdm_symbol_size*sizeof(int32_t));
+	    }
+	  }
+	}
       }
  
     }
@@ -1996,7 +2006,7 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB,
     nushiftmod3 = frame_parms->nushift%3;
 
     if (pilots>0) {  // compute pilot arrays, could be done statically if performance suffers
-      if (frame_parms->mode1_flag == 1) {
+      if (frame_parms->nb_antenna_ports_eNB == 1) {
 	//	printf("l %d, nushift %d, offset %d\n",l,frame_parms->nushift,offset);
 	for (i=0,i2=0;i<12;i++) {
 	  if ((i!=(frame_parms->nushift+offset)) && (i!=((frame_parms->nushift+6+offset)%12)))
diff --git a/openair1/PHY/LTE_TRANSPORT/if4_tools.c b/openair1/PHY/LTE_TRANSPORT/if4_tools.c
index be1bc6b08e..3c2d950a9e 100755
--- a/openair1/PHY/LTE_TRANSPORT/if4_tools.c
+++ b/openair1/PHY/LTE_TRANSPORT/if4_tools.c
@@ -39,14 +39,16 @@
 #include "targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.h"
 #include "UTIL/LOG/vcd_signal_dumper.h"
 
-void send_IF4p5(PHY_VARS_eNB *eNB, int frame, int subframe, uint16_t packet_type, int k) {
-  LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms;
-  int32_t **txdataF      = (eNB->CC_id==0) ? eNB->common_vars.txdataF[0] : PHY_vars_eNB_g[0][0]->common_vars.txdataF[0];
-  int32_t **rxdataF      = eNB->common_vars.rxdataF[0];
-  int16_t **rxsigF       = eNB->prach_vars.rxsigF;  
-  void *tx_buffer        = eNB->ifbuffer.tx[subframe&1];
-  void *tx_buffer_prach  = eNB->ifbuffer.tx_prach;
-      
+void send_IF4p5(RU_t *ru, int frame, int subframe, uint16_t packet_type, int k) {
+
+  LTE_DL_FRAME_PARMS *fp = &ru->frame_parms;
+  int32_t **txdataF      = ru->common.txdataF_BF;
+  int32_t **rxdataF      = ru->common.rxdataF;
+  int16_t **prach_rxsigF = ru->prach_rxsigF;  
+  void *tx_buffer        = ru->ifbuffer.tx[subframe&1];
+  void *tx_buffer_prach  = ru->ifbuffer.tx_prach;
+
+
   uint16_t symbol_id=0, element_id=0;
   uint16_t db_fulllength, db_halflength; 
   int slotoffsetF=0, blockoffsetF=0; 
@@ -54,18 +56,20 @@ void send_IF4p5(PHY_VARS_eNB *eNB, int frame, int subframe, uint16_t packet_type
   uint16_t *data_block=NULL, *i=NULL;
 
   IF4p5_header_t *packet_header=NULL;
-  eth_state_t *eth = (eth_state_t*) (eNB->ifdevice.priv);
+  eth_state_t *eth = (eth_state_t*) (ru->ifdevice.priv);
   int nsym = fp->symbols_per_tti;
   
-  if (eNB->CC_id==0) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_SEND_IF4, 1 );   
+  if (ru->idx==0) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_SEND_IF4, 1 );   
 
   if (packet_type == IF4p5_PDLFFT) {
+    LOG_I(PHY,"send DL_IF4p5: RU %d frame %d, subframe %d\n",ru->idx,frame,subframe);
+
     if (subframe_select(fp,subframe)==SF_S)
       nsym=fp->dl_symbols_in_S_subframe;
 
     db_fulllength = 12*fp->N_RB_DL;
     db_halflength = (db_fulllength)>>1;
-    slotoffsetF = (subframe)*(fp->ofdm_symbol_size)*((fp->Ncp==1) ? 12 : 14) + 1;
+    slotoffsetF = 0;//(subframe)*(fp->ofdm_symbol_size)*((fp->Ncp==1) ? 12 : 14) + 1;
     blockoffsetF = slotoffsetF + fp->ofdm_symbol_size - db_halflength - 1; 
 
 
@@ -77,27 +81,27 @@ void send_IF4p5(PHY_VARS_eNB *eNB, int frame, int subframe, uint16_t packet_type
       data_block = (uint16_t*)(tx_buffer + sizeof_IF4p5_header_t);
     }    
     gen_IF4p5_dl_header(packet_header, frame, subframe);
-		    
+
+    AssertFatal(txdataF[0]!=NULL,"txdataF_BF[0] is null\n");
     for (symbol_id=0; symbol_id<nsym; symbol_id++) {
-      if (eNB->CC_id==1) LOG_I(PHY,"DL_IF4p5: CC_id %d : frame %d, subframe %d, symbol %d\n",eNB->CC_id,frame,subframe,symbol_id);
       
       for (element_id=0; element_id<db_halflength; element_id++) {
-        i = (uint16_t*) &txdataF[eNB->CC_id][blockoffsetF+element_id];
+        i = (uint16_t*) &txdataF[0][blockoffsetF+element_id];
         data_block[element_id] = ((uint16_t) lin2alaw[*i]) | (lin2alaw[*(i+1)]<<8);
 
-        i = (uint16_t*) &txdataF[eNB->CC_id][slotoffsetF+element_id];
+        i = (uint16_t*) &txdataF[0][slotoffsetF+element_id];
         data_block[element_id+db_halflength] = ((uint16_t) lin2alaw[*i]) | (lin2alaw[*(i+1)]<<8);        
       }
 				 		
       packet_header->frame_status &= ~(0x000f<<26);
       packet_header->frame_status |= (symbol_id&0x000f)<<26; 
 			
-      if ((eNB->ifdevice.trx_write_func(&eNB->ifdevice,
-                                        symbol_id,
-                                        &tx_buffer,
-                                        db_fulllength,
-      			                            1,
-                                        IF4p5_PDLFFT)) < 0) {
+      if ((ru->ifdevice.trx_write_func(&ru->ifdevice,
+				       symbol_id,
+				       &tx_buffer,
+				       db_fulllength,
+				       1,
+				       IF4p5_PDLFFT)) < 0) {
         perror("ETHERNET write for IF4p5_PDLFFT\n");
       }
       
@@ -142,12 +146,12 @@ void send_IF4p5(PHY_VARS_eNB *eNB, int frame, int subframe, uint16_t packet_type
 	packet_header->frame_status &= ~(0x000f<<26);
 	packet_header->frame_status |= (symbol_id&0x000f)<<26; 
 	
-	if ((eNB->ifdevice.trx_write_func(&eNB->ifdevice,
-					  symbol_id,
-					  &tx_buffer,
-					  db_fulllength,
-					  1,
-					  IF4p5_PULFFT)) < 0) {
+	if ((ru->ifdevice.trx_write_func(&ru->ifdevice,
+					 symbol_id,
+					 &tx_buffer,
+					 db_fulllength,
+					 1,
+					 IF4p5_PULFFT)) < 0) {
 	  perror("ETHERNET write for IF4p5_PULFFT\n");
 	}
 	
@@ -156,12 +160,12 @@ void send_IF4p5(PHY_VARS_eNB *eNB, int frame, int subframe, uint16_t packet_type
       }    
     }
     else {
-      if ((eNB->ifdevice.trx_write_func(&eNB->ifdevice,
-					0,
-					&tx_buffer,
-					0,
-					1,
-					IF4p5_PULTICK)) < 0) {
+      if ((ru->ifdevice.trx_write_func(&ru->ifdevice,
+				       0,
+				       &tx_buffer,
+				       0,
+				       1,
+				       IF4p5_PULTICK)) < 0) {
 	perror("ETHERNET write for IF4p5_PULFFT\n");
       }
     }
@@ -181,19 +185,19 @@ void send_IF4p5(PHY_VARS_eNB *eNB, int frame, int subframe, uint16_t packet_type
 
     if (eth->flags == ETH_RAW_IF4p5_MODE) {
       memcpy((int16_t*)(tx_buffer_prach + MAC_HEADER_SIZE_BYTES + sizeof_IF4p5_header_t),
-             (&rxsigF[0][k]), 
+             (&prach_rxsigF[0][k]), 
              PRACH_BLOCK_SIZE_BYTES);
     } else {
       memcpy((int16_t*)(tx_buffer_prach + sizeof_IF4p5_header_t),
-             (&rxsigF[0][k]),
+             (&prach_rxsigF[0][k]),
              PRACH_BLOCK_SIZE_BYTES);
     }
 
-    if ((eNB->ifdevice.trx_write_func(&eNB->ifdevice,
-                                      symbol_id,
-                                      &tx_buffer_prach,
-                                      db_fulllength,
-                                      1,
+    if ((ru->ifdevice.trx_write_func(&ru->ifdevice,
+				     symbol_id,
+				     &tx_buffer_prach,
+				     db_fulllength,
+				     1,
                                       IF4p5_PRACH)) < 0) {
       perror("ETHERNET write for IF4p5_PRACH\n");
     }      
@@ -201,40 +205,41 @@ void send_IF4p5(PHY_VARS_eNB *eNB, int frame, int subframe, uint16_t packet_type
     AssertFatal(1==0, "send_IF4p5 - Unknown packet_type %x", packet_type);     
   }
 
-  if (eNB->CC_id==0) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_SEND_IF4, 0 );  
+  if (ru->idx==0) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_SEND_IF4, 0 );  
   return;  		    
 }
 
 
-void recv_IF4p5(PHY_VARS_eNB *eNB, int *frame, int *subframe, uint16_t *packet_type, uint32_t *symbol_number) {
-  LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms;
-  int32_t **txdataF = eNB->common_vars.txdataF[0];
-  int32_t **rxdataF = eNB->common_vars.rxdataF[0];
-  int16_t **rxsigF = eNB->prach_vars.rxsigF;  
-  void *rx_buffer = eNB->ifbuffer.rx;
+void recv_IF4p5(RU_t *ru, int *frame, int *subframe, uint16_t *packet_type, uint32_t *symbol_number) {
+  LTE_DL_FRAME_PARMS *fp = &ru->frame_parms;
+  int32_t **txdataF      = ru->common.txdataF_BF;
+  int32_t **rxdataF      = ru->common.rxdataF;
+  int16_t **prach_rxsigF = ru->prach_rxsigF;  
+  void *rx_buffer        = ru->ifbuffer.rx;
 
   uint16_t element_id;
   uint16_t db_fulllength, db_halflength; 
   int slotoffsetF=0, blockoffsetF=0; 
-  eth_state_t *eth = (eth_state_t*) (eNB->ifdevice.priv);
+  eth_state_t *eth = (eth_state_t*) (ru->ifdevice.priv);
 
-  if (eNB->CC_id==0) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_RECV_IF4, 1 );   
+  if (ru->idx==0) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_RECV_IF4, 1 );   
   
-  if (eNB->node_function == NGFI_RRU_IF4p5) {
+  if (ru->function == NGFI_RRU_IF4p5) {
     db_fulllength = (12*fp->N_RB_DL); 
-  } else {
+  } else { // This is not an RRU
     db_fulllength = (12*fp->N_RB_UL);     
   }  
   db_halflength = db_fulllength>>1;
 
   IF4p5_header_t *packet_header=NULL;
   uint16_t *data_block=NULL, *i=NULL;
-     
-  if (eNB->ifdevice.trx_read_func(&eNB->ifdevice,
-                                  (int64_t*) packet_type,
-                                  &rx_buffer,
-                                  db_fulllength,
-                                  0) < 0) {
+
+  LOG_I(PHY,"recv IF4p5: RU %d waiting (%d samples)\n",ru->idx,db_fulllength);    
+  if (ru->ifdevice.trx_read_func(&ru->ifdevice,
+				 (int64_t*) packet_type,
+				 &rx_buffer,
+				 db_fulllength,
+				 0) < 0) {
     perror("ETHERNET read");
   }
   
@@ -256,9 +261,9 @@ void recv_IF4p5(PHY_VARS_eNB *eNB, int *frame, int *subframe, uint16_t *packet_t
   if (*packet_type == IF4p5_PDLFFT) {          
     *symbol_number = ((packet_header->frame_status)>>26)&0x000f;         
 
-    LOG_D(PHY,"DL_IF4p5: CC_id %d : frame %d, subframe %d, symbol %d\n",eNB->CC_id,*frame,*subframe,*symbol_number);
+    LOG_I(PHY,"DL_IF4p5: RU %d frame %d, subframe %d, symbol %d\n",ru->idx,*frame,*subframe,*symbol_number);
 
-    slotoffsetF = (*symbol_number)*(fp->ofdm_symbol_size) + (*subframe)*(fp->ofdm_symbol_size)*((fp->Ncp==1) ? 12 : 14) + 1;
+    slotoffsetF = (*symbol_number)*(fp->ofdm_symbol_size);// + (*subframe)*(fp->ofdm_symbol_size)*((fp->Ncp==1) ? 12 : 14) + 1;
     blockoffsetF = slotoffsetF + fp->ofdm_symbol_size - db_halflength - 1; 
         
     for (element_id=0; element_id<db_halflength; element_id++) {
@@ -274,7 +279,7 @@ void recv_IF4p5(PHY_VARS_eNB *eNB, int *frame, int *subframe, uint16_t *packet_t
   } else if (*packet_type == IF4p5_PULFFT) {         
     *symbol_number = ((packet_header->frame_status)>>26)&0x000f;         
 
-    if (eNB->CC_id==0) LOG_D(PHY,"UL_IF4p5: CC_id %d : frame %d, subframe %d, symbol %d\n",eNB->CC_id,*frame,*subframe,*symbol_number);
+    if (ru->idx==0) LOG_D(PHY,"UL_IF4p5: RU %d : frame %d, subframe %d, symbol %d\n",ru->idx,*frame,*subframe,*symbol_number);
 
     slotoffsetF = (*symbol_number)*(fp->ofdm_symbol_size);
     blockoffsetF = slotoffsetF + fp->ofdm_symbol_size - db_halflength; 
@@ -292,18 +297,17 @@ void recv_IF4p5(PHY_VARS_eNB *eNB, int *frame, int *subframe, uint16_t *packet_t
     }
 		
   } else if (*packet_type == IF4p5_PRACH) {  
-     LOG_D(PHY,"PRACH_IF4p5: CC_id %d : frame %d, subframe %d, symbol %d\n",eNB->CC_id,*frame,*subframe);  
-    if (eNB->CC_id==1) LOG_I(PHY,"PRACH_IF4p5: CC_id %d : frame %d, subframe %d, symbol %d\n",eNB->CC_id,*frame,*subframe);
+    LOG_D(PHY,"PRACH_IF4p5: CC_id %d : frame %d, subframe %d\n",ru->idx,*frame,*subframe);  
 
     // FIX: hard coded prach samples length
     db_fulllength = PRACH_HARD_CODED_NUM_SAMPLES;
 
     if (eth->flags == ETH_RAW_IF4p5_MODE) {		
-      memcpy((&rxsigF[0][0]), 
+      memcpy((&prach_rxsigF[0][0]), 
              (int16_t*) (rx_buffer+MAC_HEADER_SIZE_BYTES+sizeof_IF4p5_header_t), 
              PRACH_BLOCK_SIZE_BYTES);
     } else {
-      memcpy((&rxsigF[0][0]),
+      memcpy((&prach_rxsigF[0][0]),
              (int16_t*) (rx_buffer+sizeof_IF4p5_header_t),
              PRACH_BLOCK_SIZE_BYTES);
     }
@@ -313,7 +317,7 @@ void recv_IF4p5(PHY_VARS_eNB *eNB, int *frame, int *subframe, uint16_t *packet_t
     AssertFatal(1==0, "recv_IF4p5 - Unknown packet_type %x", *packet_type);            
   }
 
-  if (eNB->CC_id==0) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_RECV_IF4, 0 );     
+  if (ru->idx==0) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_RECV_IF4, 0 );     
   return;   
 }
 
@@ -358,20 +362,20 @@ void gen_IF4p5_prach_header(IF4p5_header_t *prach_packet, int frame, int subfram
 } 
 
 
-void malloc_IF4p5_buffer(PHY_VARS_eNB *eNB) {
+void malloc_IF4p5_buffer(RU_t *ru) {
   // Keep the size large enough 
-  eth_state_t *eth = (eth_state_t*) (eNB->ifdevice.priv);
+  eth_state_t *eth = (eth_state_t*) (ru->ifdevice.priv);
   int i;
 
   if (eth->flags == ETH_RAW_IF4p5_MODE) {
     for (i=0;i<10;i++)
-      eNB->ifbuffer.tx[i]       = malloc(RAW_IF4p5_PRACH_SIZE_BYTES);
-    eNB->ifbuffer.tx_prach = malloc(RAW_IF4p5_PRACH_SIZE_BYTES);
-    eNB->ifbuffer.rx       = malloc(RAW_IF4p5_PRACH_SIZE_BYTES); 
+      ru->ifbuffer.tx[i]       = malloc(RAW_IF4p5_PRACH_SIZE_BYTES);
+    ru->ifbuffer.tx_prach = malloc(RAW_IF4p5_PRACH_SIZE_BYTES);
+    ru->ifbuffer.rx       = malloc(RAW_IF4p5_PRACH_SIZE_BYTES); 
   } else {
     for (i=0;i<10;i++)
-      eNB->ifbuffer.tx[i]       = malloc(UDP_IF4p5_PRACH_SIZE_BYTES);
-    eNB->ifbuffer.tx_prach = malloc(UDP_IF4p5_PRACH_SIZE_BYTES);
-    eNB->ifbuffer.rx       = malloc(UDP_IF4p5_PRACH_SIZE_BYTES);
+      ru->ifbuffer.tx[i]       = malloc(UDP_IF4p5_PRACH_SIZE_BYTES);
+    ru->ifbuffer.tx_prach = malloc(UDP_IF4p5_PRACH_SIZE_BYTES);
+    ru->ifbuffer.rx       = malloc(UDP_IF4p5_PRACH_SIZE_BYTES);
   }
 }
diff --git a/openair1/PHY/LTE_TRANSPORT/if4_tools.h b/openair1/PHY/LTE_TRANSPORT/if4_tools.h
index e2d4f1f7de..eebbb41557 100644
--- a/openair1/PHY/LTE_TRANSPORT/if4_tools.h
+++ b/openair1/PHY/LTE_TRANSPORT/if4_tools.h
@@ -30,6 +30,8 @@
 * \warning
 */
 
+#ifndef __IF4_TOOLS_H__
+#define __IF4_TOOLS_H__
 #include "PHY/defs.h"
 
 /// Macro for IF4 packet type
@@ -60,8 +62,10 @@ void gen_IF4p5_ul_header(IF4p5_header_t*, uint16_t, int, int);
 
 void gen_IF4p5_prach_header(IF4p5_header_t*, int, int);
 
-void send_IF4p5(PHY_VARS_eNB*, int, int, uint16_t, int);
+void send_IF4p5(RU_t*, int, int, uint16_t, int);
 
-void recv_IF4p5(PHY_VARS_eNB*, int*, int*, uint16_t*, uint32_t*);
+void recv_IF4p5(RU_t*, int*, int*, uint16_t*, uint32_t*);
 
-void malloc_IF4p5_buffer(PHY_VARS_eNB*);
+void malloc_IF4p5_buffer(RU_t*);
+
+#endif
diff --git a/openair1/PHY/LTE_TRANSPORT/if5_tools.c b/openair1/PHY/LTE_TRANSPORT/if5_tools.c
index 5b1c834705..861e8c01b3 100644
--- a/openair1/PHY/LTE_TRANSPORT/if5_tools.c
+++ b/openair1/PHY/LTE_TRANSPORT/if5_tools.c
@@ -42,30 +42,30 @@ int dummy_cnt = 0;
 int subframe_skip_extra = 0;
 int start_flag = 1;
 int offset_cnt = 1;
-void send_IF5(PHY_VARS_eNB *eNB, openair0_timestamp proc_timestamp, int subframe, uint8_t *seqno, uint16_t packet_type) {      
+void send_IF5(RU_t *ru, openair0_timestamp proc_timestamp, int subframe, uint8_t *seqno, uint16_t packet_type) {      
   
-  LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms;
+  LTE_DL_FRAME_PARMS *fp=&ru->frame_parms;
   int32_t *txp[fp->nb_antennas_tx], *rxp[fp->nb_antennas_rx]; 
   int32_t *tx_buffer=NULL;
 
   int8_t dummy_buffer[fp->samples_per_tti*2];
   uint16_t packet_id=0, i=0;
 
-  uint32_t spp_eth  = (uint32_t) eNB->ifdevice.openair0_cfg->samples_per_packet;
-  uint32_t spsf     = (uint32_t) eNB->ifdevice.openair0_cfg->samples_per_frame/10;
+  uint32_t spp_eth  = (uint32_t) ru->ifdevice.openair0_cfg->samples_per_packet;
+  uint32_t spsf     = (uint32_t) ru->ifdevice.openair0_cfg->samples_per_frame/10;
   
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_SEND_IF5, 1 );  
 
   if (packet_type == IF5_RRH_GW_DL) {    
 
     for (i=0; i < fp->nb_antennas_tx; i++)
-      txp[i] = (void*)&eNB->common_vars.txdata[0][i][subframe*fp->samples_per_tti];
+      txp[i] = (void*)&ru->common.txdata[i][subframe*fp->samples_per_tti];
     
     for (packet_id=0; packet_id < spsf / spp_eth; packet_id++) {
 
       VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE_IF, 1 );            
-      eNB->ifdevice.trx_write_func(&eNB->ifdevice,
-                                   (proc_timestamp + packet_id*spp_eth),
+      ru->ifdevice.trx_write_func(&ru->ifdevice,
+				  (proc_timestamp + packet_id*spp_eth),
                                    (void**)txp,
                                    spp_eth,
                                    fp->nb_antennas_tx,
@@ -79,17 +79,17 @@ void send_IF5(PHY_VARS_eNB *eNB, openair0_timestamp proc_timestamp, int subframe
   } else if (packet_type == IF5_RRH_GW_UL) {
         
     for (i=0; i < fp->nb_antennas_rx; i++)
-      rxp[i] = (void*)&eNB->common_vars.rxdata[0][i][subframe*fp->samples_per_tti];
+      rxp[i] = (void*)&ru->common.rxdata[i][subframe*fp->samples_per_tti];
     
     for (packet_id=0; packet_id < spsf / spp_eth; packet_id++) {
 
       VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE_IF, 1 );            
-      eNB->ifdevice.trx_write_func(&eNB->ifdevice,
-                                   (proc_timestamp + packet_id*spp_eth),
-                                   (void**)rxp,
-                                   spp_eth,
-                                   fp->nb_antennas_rx,
-                                   0);
+      ru->ifdevice.trx_write_func(&ru->ifdevice,
+				  (proc_timestamp + packet_id*spp_eth),
+				  (void**)rxp,
+				  spp_eth,
+				  fp->nb_antennas_rx,
+				  0);
       VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE_IF, 0 );            
       for (i=0; i < fp->nb_antennas_rx; i++)
         rxp[i] += spp_eth;
@@ -115,7 +115,7 @@ void send_IF5(PHY_VARS_eNB *eNB, openair0_timestamp proc_timestamp, int subframe
     header->ack = 0;
     header->word0 = 0;  
     
-    txp[0] = (void*)&eNB->common_vars.txdata[0][0][subframe*eNB->frame_parms.samples_per_tti];
+    txp[0] = (void*)&ru->common.txdata[0][subframe*ru->frame_parms.samples_per_tti];
     txp128 = (__m128i *) txp[0];
               
     for (packet_id=0; packet_id<fp->samples_per_tti/db_fulllength; packet_id++) {
@@ -130,7 +130,7 @@ void send_IF5(PHY_VARS_eNB *eNB, openair0_timestamp proc_timestamp, int subframe
       }
       
       // Write the packet to the fronthaul
-      if ((eNB->ifdevice.trx_write_func(&eNB->ifdevice,
+      if ((ru->ifdevice.trx_write_func(&ru->ifdevice,
                                         packet_id,
                                         (void**)&tx_buffer,
                                         db_fulllength,
@@ -174,17 +174,17 @@ void send_IF5(PHY_VARS_eNB *eNB, openair0_timestamp proc_timestamp, int subframe
 }
 
 
-void recv_IF5(PHY_VARS_eNB *eNB, openair0_timestamp *proc_timestamp, int subframe, uint16_t packet_type) {
+void recv_IF5(RU_t *ru, openair0_timestamp *proc_timestamp, int subframe, uint16_t packet_type) {
 
-  LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms;
+  LTE_DL_FRAME_PARMS *fp=&ru->frame_parms;
   int32_t *txp[fp->nb_antennas_tx], *rxp[fp->nb_antennas_rx]; 
 
   uint16_t packet_id=0, i=0;
   int8_t dummy_buffer_rx[fp->samples_per_tti*2];
   uint8_t rxe;
 
-  int32_t spp_eth  = (int32_t) eNB->ifdevice.openair0_cfg->samples_per_packet;
-  int32_t spsf     = (int32_t) eNB->ifdevice.openair0_cfg->samples_per_frame/10;
+  int32_t spp_eth  = (int32_t) ru->ifdevice.openair0_cfg->samples_per_packet;
+  int32_t spsf     = (int32_t) ru->ifdevice.openair0_cfg->samples_per_frame/10;
 
   openair0_timestamp timestamp[spsf / spp_eth];
 
@@ -193,13 +193,13 @@ void recv_IF5(PHY_VARS_eNB *eNB, openair0_timestamp *proc_timestamp, int subfram
   if (packet_type == IF5_RRH_GW_DL) {
         
     for (i=0; i < fp->nb_antennas_tx; i++)
-      txp[i] = (void*)&eNB->common_vars.txdata[0][i][subframe*fp->samples_per_tti];
+      txp[i] = (void*)&ru->common.txdata[i][subframe*fp->samples_per_tti];
     
     for (packet_id=0; packet_id < spsf / spp_eth; packet_id++) {
 
       VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ_IF, 1 );  
-      eNB->ifdevice.trx_read_func(&eNB->ifdevice,
-                                  &timestamp[packet_id],
+      ru->ifdevice.trx_read_func(&ru->ifdevice,
+				 &timestamp[packet_id],
                                   (void**)txp,
                                   spp_eth,
                                   fp->nb_antennas_tx);
@@ -214,15 +214,15 @@ void recv_IF5(PHY_VARS_eNB *eNB, openair0_timestamp *proc_timestamp, int subfram
   } else if (packet_type == IF5_RRH_GW_UL) { 
     
     for (i=0; i < fp->nb_antennas_rx; i++)
-      rxp[i] = (void*)&eNB->common_vars.rxdata[0][i][subframe*fp->samples_per_tti];
+      rxp[i] = (void*)&ru->common.rxdata[i][subframe*fp->samples_per_tti];
     
     for (packet_id=0; packet_id < spsf / spp_eth; packet_id++) {
       VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ_IF, 1 );            
-      eNB->ifdevice.trx_read_func(&eNB->ifdevice,
-                                  &timestamp[packet_id],
-                                  (void**)rxp,
-                                  spp_eth,
-                                  fp->nb_antennas_rx);
+      ru->ifdevice.trx_read_func(&ru->ifdevice,
+				 &timestamp[packet_id],
+				 (void**)rxp,
+				 spp_eth,
+				 fp->nb_antennas_rx);
       VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ_IF, 0 );            
       for (i=0; i < fp->nb_antennas_rx; i++)
         rxp[i] += spp_eth;
@@ -249,60 +249,22 @@ void recv_IF5(PHY_VARS_eNB *eNB, openair0_timestamp *proc_timestamp, int subfram
     IF5_mobipass_header_t *header = (IF5_mobipass_header_t *)((uint8_t *)rx_buffer + MAC_HEADER_SIZE_BYTES);
     data_block_head = (__m128i *)((uint8_t *)rx_buffer + MAC_HEADER_SIZE_BYTES + sizeof_IF5_mobipass_header_t);
  
-    rxp[0] = (void*)&eNB->common_vars.rxdata[0][0][subframe*eNB->frame_parms.samples_per_tti];
+    rxp[0] = (void*)&ru->common.rxdata[subframe*ru->frame_parms.samples_per_tti];
     rxp128 = (__m128i *) (rxp[0]);
  
-    eNB_proc_t *proc = &eNB->proc;
-/*
- //   while(packet_id<fp->samples_per_tti/db_fulllength) {
-      data_block = data_block_head;
-
-      eNB->ifdevice.trx_read_func(&eNB->ifdevice,
-                                       &ts0,
-                                       (void**)&rx_buffer,
-                                       db_fulllength,
-                                        1
-                                        );
-
-      if ((header->seqno == 1)&&(first_packet==1))  { 
-         first_packet = 0;  //ignore the packets before synchnorization
-         packet_id = 0;
-        ts_offset = ntohl(ts0);
-      } 
-      if (first_packet==0) { 
-        packet_cnt++;
-        ts = ntohl(ts0);
-        packet_id = (ts-ts_offset)/db_fulllength;
-        packet_id = packet_id % (fp->samples_per_tti/db_fulllength);
-
-        printf("[IF5_tools]packet_id:%d\n", packet_id);
-        // if (ts_stored == 0) {
-        //   ts_stored = 1;
-        *proc_timestamp = ntohl(ts - (packet_id*db_fulllength));
-        // }
-        rxp[0] = (void*)&eNB->common_vars.rxdata[0][0][(subframe*eNB->frame_parms.samples_per_tti)+packet_id*db_fulllength];
-        rxp128 = (__m128i *) (rxp[0]);
+    RU_proc_t *proc = &ru->proc;
 
-        for (i=0; i<db_fulllength>>2; i+=2) {
-          r0 = _mm_loadu_si128(data_block++);
-          *rxp128++ =_mm_slli_epi16(_mm_srai_epi16(_mm_unpacklo_epi8(r0,r0),8),4);
-          *rxp128++ =_mm_slli_epi16(_mm_srai_epi16(_mm_unpackhi_epi8(r0,r0),8),4);
-        }
-      }
-  //  }//end while
-*/
- 
 
     packet_id=0; 
     while(packet_id<fp->samples_per_tti/db_fulllength) {
       data_block = data_block_head;
 
-      eNB->ifdevice.trx_read_func(&eNB->ifdevice,
-                                       &timestamp_mobipass[packet_id],
-                                       (void**)&rx_buffer,
-                                       db_fulllength,
-                                        1
-                                        );
+      ru->ifdevice.trx_read_func(&ru->ifdevice,
+				 &timestamp_mobipass[packet_id],
+				 (void**)&rx_buffer,
+				 db_fulllength,
+				 1
+				 );
 #ifdef DEBUG_UL_MOBIPASS
       if (((proc->timestamp_tx + lower_offset) > ntohl(timestamp_mobipass[packet_id])) || ((proc->timestamp_tx + upper_offset) < ntohl(timestamp_mobipass[packet_id]))) {
         //ignore the packet
@@ -328,7 +290,7 @@ void recv_IF5(PHY_VARS_eNB *eNB, openair0_timestamp *proc_timestamp, int subfram
         start_flag = 0;
 
         //store rxdata and increase packet_id
-        rxp[0] = (void*)&eNB->common_vars.rxdata[0][0][(subframe*eNB->frame_parms.samples_per_tti)+packet_id*db_fulllength];
+        rxp[0] = (void*)&ru->common.rxdata[0][(subframe*ru->frame_parms.samples_per_tti)+packet_id*db_fulllength];
         rxp128 = (__m128i *) (rxp[0]);
         for (i=0; i<db_fulllength>>2; i+=2) {
           r0 = _mm_loadu_si128(data_block++);
@@ -343,7 +305,7 @@ void recv_IF5(PHY_VARS_eNB *eNB, openair0_timestamp *proc_timestamp, int subfram
       *proc_timestamp = ntohl(timestamp_mobipass[0]); 
 #ifdef DEBUG_UL_MOBIPASS
    LOG_I(PHY,"[Mobipass][Recv_MOBIPASS] timestamp: %llu\n ",  *proc_timestamp);
-if (eNB->CC_id>0) {
+   if (ru->idx>0) {
     rxe = dB_fixed(signal_energy(rxp[0],fp->samples_per_tti)); 
     if (rxe > 0){
       LOG_I(PHY,"[Mobipass] frame:%d, subframe:%d, energy %d\n", (*proc_timestamp/(10*fp->samples_per_tti))&1023,subframe, rxe);
diff --git a/openair1/PHY/LTE_TRANSPORT/if5_tools.h b/openair1/PHY/LTE_TRANSPORT/if5_tools.h
index b6ebe8c841..9cfb8b2339 100644
--- a/openair1/PHY/LTE_TRANSPORT/if5_tools.h
+++ b/openair1/PHY/LTE_TRANSPORT/if5_tools.h
@@ -30,6 +30,9 @@
 * \warning
 */
 
+#ifndef __IF5_TOOLS_H__
+#define __IF5_TOOLS_H__
+
 #include <stdint.h>
 #include "PHY/defs.h"
 
@@ -56,6 +59,8 @@ struct IF5_mobipass_header {
 typedef struct IF5_mobipass_header IF5_mobipass_header_t;
 #define sizeof_IF5_mobipass_header_t 14
 
-void send_IF5(PHY_VARS_eNB*, openair0_timestamp, int, uint8_t*, uint16_t);
+void send_IF5(RU_t *, openair0_timestamp, int, uint8_t*, uint16_t);
+
+void recv_IF5(RU_t *, openair0_timestamp*, int, uint16_t);
 
-void recv_IF5(PHY_VARS_eNB*, openair0_timestamp*, int, uint16_t);
+#endif
diff --git a/openair1/PHY/LTE_TRANSPORT/initial_sync.c b/openair1/PHY/LTE_TRANSPORT/initial_sync.c
index c29562b6cd..2257b74fe8 100644
--- a/openair1/PHY/LTE_TRANSPORT/initial_sync.c
+++ b/openair1/PHY/LTE_TRANSPORT/initial_sync.c
@@ -155,7 +155,6 @@ int pbch_detection(PHY_VARS_UE *ue, runmode_t mode)
     frame_parms->nb_antenna_ports_eNB = pbch_tx_ant;
 
     // set initial transmission mode to 1 or 2 depending on number of detected TX antennas
-    frame_parms->mode1_flag = (pbch_tx_ant==1);
     // openair_daq_vars.dlsch_transmission_mode = (pbch_tx_ant>1) ? 2 : 1;
 
 
@@ -245,9 +244,9 @@ int pbch_detection(PHY_VARS_UE *ue, runmode_t mode)
     ue->proc.proc_rxtx[0].frame_tx = ue->proc.proc_rxtx[0].frame_rx;
     ue->proc.proc_rxtx[1].frame_tx = ue->proc.proc_rxtx[1].frame_rx;
 #ifdef DEBUG_INITIAL_SYNCH
-    LOG_I(PHY,"[UE%d] Initial sync: pbch decoded sucessfully mode1_flag %d, tx_ant %d, frame %d, N_RB_DL %d, phich_duration %d, phich_resource %s!\n",
+    LOG_I(PHY,"[UE%d] Initial sync: pbch decoded sucessfully p %d, tx_ant %d, frame %d, N_RB_DL %d, phich_duration %d, phich_resource %s!\n",
           ue->Mod_id,
-          frame_parms->mode1_flag,
+          frame_parms->nb_antenna_ports_eNB,
           pbch_tx_ant,
           ue->proc.proc_rxtx[0].frame_rx,
           frame_parms->N_RB_DL,
diff --git a/openair1/PHY/LTE_TRANSPORT/lte_mcs.c b/openair1/PHY/LTE_TRANSPORT/lte_mcs.c
index 0abc1511ea..8f8bc80b1e 100644
--- a/openair1/PHY/LTE_TRANSPORT/lte_mcs.c
+++ b/openair1/PHY/LTE_TRANSPORT/lte_mcs.c
@@ -298,7 +298,7 @@ int adjust_G(LTE_DL_FRAME_PARMS *frame_parms,uint32_t *rb_alloc,uint8_t mod_orde
   //    printf("re_pbch_sss %d\n",re_pbch_sss);
   if (subframe==0) {  //PBCH+SSS+PSS
     if (frame_parms->frame_type == TDD) { // TDD
-      if (frame_parms->mode1_flag==0)
+      if (frame_parms->nb_antenna_ports_eNB!=1)
         //2ant so PBCH 3+2/3 symbols, SSS 1 symbol * REs => (14/3)*re_pbch_sss for normal CP,
         // 2+4/3 symbols, SSS 1 symbol => (13/3)*re_pbch_sss for ext. CP
         return((-frame_parms->Ncp+14)*re_pbch_sss * mod_order/3);
@@ -307,7 +307,7 @@ int adjust_G(LTE_DL_FRAME_PARMS *frame_parms,uint32_t *rb_alloc,uint8_t mod_orde
         // 2+10/6 symbols, SSS 1 symbol => (28/6)*re_pbch_sss for ext. CP
         return((-frame_parms->Ncp+29)*re_pbch_sss * mod_order/6);
     } else { // FDD
-      if (frame_parms->mode1_flag==0)
+      if (frame_parms->nb_antenna_ports_eNB!=1)
         //2ant so PBCH 3+2/3 symbols, PSS+SSS 2 symbols * REs => (17/3)*re_pbch_sss for normal CP,
         // 2+4/3 symbols, PSS+SSS 2 symbols => (16/3)*re_pbch_sss for ext. CP
         return((-frame_parms->Ncp+17)*re_pbch_sss * mod_order/3);
@@ -337,7 +337,7 @@ int get_G(LTE_DL_FRAME_PARMS *frame_parms,uint16_t nb_rb,uint32_t *rb_alloc,uint
       // PDDDPDD PDDDPDD - 13 PDSCH symbols, 10 full, 3 w/ pilots = 10*12 + 3*8
       // PCDDPDD PDDDPDD - 12 PDSCH symbols, 9 full, 3 w/ pilots = 9*12 + 3*8
       // PCCDPDD PDDDPDD - 11 PDSCH symbols, 8 full, 3 w/pilots = 8*12 + 3*8
-      if (beamforming_mode==0 && frame_parms->mode1_flag==0) 
+      if (beamforming_mode==0 && frame_parms->nb_antenna_ports_eNB!=1) 
         return((((int)nb_rb * mod_order * ((11-num_pdcch_symbols)*12 + 3*8)) - G_adj)*Nl);
       else if(beamforming_mode==7)
         return(((int)nb_rb * mod_order * ((7-num_pdcch_symbols)*12 + 3*10 + 4*9)) - G_adj);
@@ -347,7 +347,7 @@ int get_G(LTE_DL_FRAME_PARMS *frame_parms,uint16_t nb_rb,uint32_t *rb_alloc,uint
       // PDDPDD PDDPDD - 11 PDSCH symbols, 8 full, 3 w/ pilots = 8*12 + 3*8
       // PCDPDD PDDPDD - 10 PDSCH symbols, 7 full, 3 w/ pilots = 7*12 + 3*8
       // PCCPDD PDDPDD - 9 PDSCH symbols, 6 full, 3 w/pilots = 6*12 + 3*8
-      if (frame_parms->mode1_flag==0)
+      if (frame_parms->nb_antenna_ports_eNB!=1)
         return((((int)nb_rb * mod_order * ((9-num_pdcch_symbols)*12 + 3*8)) - G_adj)*Nl);
       else if(beamforming_mode==7)
         return(((int)nb_rb * mod_order * ((5-num_pdcch_symbols)*12 + 3*8 + 4*9)) - G_adj);
diff --git a/openair1/PHY/LTE_TRANSPORT/pbch.c b/openair1/PHY/LTE_TRANSPORT/pbch.c
index e28e179b07..988580476c 100644
--- a/openair1/PHY/LTE_TRANSPORT/pbch.c
+++ b/openair1/PHY/LTE_TRANSPORT/pbch.c
@@ -63,7 +63,7 @@ int allocate_pbch_REs_in_RB(LTE_DL_FRAME_PARMS *frame_parms,
                             uint32_t *re_allocated)
 {
 
-  MIMO_mode_t mimo_mode   = (frame_parms->mode1_flag==1)?SISO:ALAMOUTI;
+  MIMO_mode_t mimo_mode   = (frame_parms->nb_antenna_ports_eNB==1)?SISO:ALAMOUTI;
 
 
   uint32_t tti_offset;
@@ -213,11 +213,11 @@ int generate_pbch(LTE_eNB_PBCH *eNB_pbch,
 #ifdef DEBUG_PBCH
 
     for (i=0; i<(PBCH_A>>3); i++)
-      msg("[PBCH] pbch_data[%d] = %x\n",i,pbch_a[i]);
+      LOG_D(PHY,"[PBCH] pbch_data[%d] = %x\n",i,pbch_a[i]);
 
 #endif
 
-    if (frame_parms->mode1_flag == 1)
+    if (frame_parms->nb_antenna_ports_eNB == 1)
       amask = 0x0000;
     else {
       switch (frame_parms->nb_antenna_ports_eNB) {
@@ -240,7 +240,7 @@ int generate_pbch(LTE_eNB_PBCH *eNB_pbch,
 #ifdef DEBUG_PBCH_ENCODING
 
     for (i=0; i<16+PBCH_A; i++)
-      msg("%d : (%d,%d,%d)\n",i,*(eNB_pbch->pbch_d+96+(3*i)),*(eNB_pbch->pbch_d+97+(3*i)),*(eNB_pbch->pbch_d+98+(3*i)));
+      LOG_D(PHY,"%d : (%d,%d,%d)\n",i,*(eNB_pbch->pbch_d+96+(3*i)),*(eNB_pbch->pbch_d+97+(3*i)),*(eNB_pbch->pbch_d+98+(3*i)));
 
 #endif //DEBUG_PBCH_ENCODING
 
@@ -271,19 +271,19 @@ int generate_pbch(LTE_eNB_PBCH *eNB_pbch,
       #endif //DEBUG_PBCH
     */
 #ifdef DEBUG_PBCH_ENCODING
-    msg("Doing PBCH interleaving for %d coded bits, e %p\n",pbch_D,eNB_pbch->pbch_e);
+    LOG_D(PHY,"Doing PBCH interleaving for %d coded bits, e %p\n",pbch_D,eNB_pbch->pbch_e);
 #endif
     RCC = sub_block_interleaving_cc(pbch_D,eNB_pbch->pbch_d+96,eNB_pbch->pbch_w);
 
     lte_rate_matching_cc(RCC,pbch_E,eNB_pbch->pbch_w,eNB_pbch->pbch_e);
 
 #ifdef DEBUG_PBCH_ENCODING
-    msg("PBCH_e:\n");
+    LOG_D(PHY,"PBCH_e:\n");
 
     for (i=0; i<pbch_E; i++)
-      msg("%d %d\n",i,*(eNB_pbch->pbch_e+i));
+      LOG_D(PHY,"%d %d\n",i,*(eNB_pbch->pbch_e+i));
 
-    msg("\n");
+    LOG_D(PHY,"\n");
 #endif
 
 
@@ -351,7 +351,7 @@ int generate_pbch(LTE_eNB_PBCH *eNB_pbch,
     }
 
 #ifdef DEBUG_PBCH
-    msg("[PBCH] l=%d, pilots=%d\n",l,pilots);
+    LOG_D(PHY,"[PBCH] l=%d, pilots=%d\n",l,pilots);
 #endif
 
 
@@ -361,7 +361,7 @@ int generate_pbch(LTE_eNB_PBCH *eNB_pbch,
     for (rb=0; rb<6; rb++) {
 
 #ifdef DEBUG_PBCH
-      msg("RB %d, jj %d, re_offset %d, symbol_offset %d, pilots %d, nushift %d\n",rb,jj,re_offset, symbol_offset, pilots,frame_parms->nushift);
+      LOG_D(PHY,"RB %d, jj %d, re_offset %d, symbol_offset %d, pilots %d, nushift %d\n",rb,jj,re_offset, symbol_offset, pilots,frame_parms->nushift);
 #endif
       allocate_pbch_REs_in_RB(frame_parms,
                               txdataF,
@@ -395,7 +395,7 @@ int generate_pbch(LTE_eNB_PBCH *eNB_pbch,
     printf("%d=>(%d,%d)",i,((short*)&txdataF[0][frame_parms->ofdm_symbol_size*(nsymb>>1)+i])[0],
            ((short*)&txdataF[0][frame_parms->ofdm_symbol_size*(nsymb>>1)+i])[1]);
 
-    if (frame_parms->mode1_flag==0) {
+    if (frame_parms->nb_antenna_ports_eNB!=1) {
       printf("(%d,%d)\n",((short*)&txdataF[1][frame_parms->ofdm_symbol_size*(nsymb>>1)+i])[0],
              ((short*)&txdataF[1][frame_parms->ofdm_symbol_size*(nsymb>>1)+i])[1]);
     } else {
@@ -889,7 +889,7 @@ uint16_t rx_pbch(LTE_UE_COMMON *lte_ue_common_vars,
   pbch_E  = (frame_parms->Ncp==0) ? 1920 : 1728; //RE/RB * #RB * bits/RB (QPSK)
   pbch_e_rx = &lte_ue_pbch_vars->llr[frame_mod4*(pbch_E>>2)];
 #ifdef DEBUG_PBCH
-  msg("[PBCH] starting symbol loop (Ncp %d, frame_mod4 %d,mimo_mode %d\n",frame_parms->Ncp,frame_mod4,mimo_mode);
+  LOG_D(PHY,"[PBCH] starting symbol loop (Ncp %d, frame_mod4 %d,mimo_mode %d\n",frame_parms->Ncp,frame_mod4,mimo_mode);
 #endif
 
   // clear LLR buffer
@@ -898,7 +898,7 @@ uint16_t rx_pbch(LTE_UE_COMMON *lte_ue_common_vars,
   for (symbol=(nsymb>>1); symbol<(nsymb>>1)+4; symbol++) {
 
 #ifdef DEBUG_PBCH
-    msg("[PBCH] starting extract\n");
+    LOG_D(PHY,"[PBCH] starting extract\n");
 #endif
     pbch_extract(lte_ue_common_vars->common_vars_rx_data_per_thread[0].rxdataF,
                  lte_ue_common_vars->common_vars_rx_data_per_thread[0].dl_ch_estimates[eNB_id],
@@ -908,8 +908,8 @@ uint16_t rx_pbch(LTE_UE_COMMON *lte_ue_common_vars,
                  high_speed_flag,
                  frame_parms);
 #ifdef DEBUG_PBCH
-    msg("[PHY] PBCH Symbol %d\n",symbol);
-    msg("[PHY] PBCH starting channel_level\n");
+    LOG_D(PHY,"[PHY] PBCH Symbol %d\n",symbol);
+    LOG_D(PHY,"[PHY] PBCH starting channel_level\n");
 #endif
 
     max_h = pbch_channel_level(lte_ue_pbch_vars->dl_ch_estimates_ext,
@@ -918,7 +918,7 @@ uint16_t rx_pbch(LTE_UE_COMMON *lte_ue_common_vars,
     log2_maxh = 3+(log2_approx(max_h)/2);
 
 #ifdef DEBUG_PBCH
-    msg("[PHY] PBCH log2_maxh = %d (%d)\n",log2_maxh,max_h);
+    LOG_D(PHY,"[PHY] PBCH log2_maxh = %d (%d)\n",log2_maxh,max_h);
 #endif
 
     pbch_channel_compensation(lte_ue_pbch_vars->rxdataF_ext,
@@ -936,10 +936,10 @@ uint16_t rx_pbch(LTE_UE_COMMON *lte_ue_common_vars,
 
     if (mimo_mode == ALAMOUTI) {
       pbch_alamouti(frame_parms,lte_ue_pbch_vars->rxdataF_comp,symbol);
-      //  msg("[PBCH][RX] Alamouti receiver not yet implemented!\n");
+      //  LOG_D(PHY,"[PBCH][RX] Alamouti receiver not yet implemented!\n");
       //  return(-1);
     } else if (mimo_mode != SISO) {
-      msg("[PBCH][RX] Unsupported MIMO mode\n");
+      LOG_D(PHY,"[PBCH][RX] Unsupported MIMO mode\n");
       return(-1);
     }
 
@@ -966,7 +966,7 @@ uint16_t rx_pbch(LTE_UE_COMMON *lte_ue_common_vars,
 
   //un-scrambling
 #ifdef DEBUG_PBCH
-  msg("[PBCH] doing unscrambling\n");
+  LOG_D(PHY,"[PBCH] doing unscrambling\n");
 #endif
 
 
@@ -979,7 +979,7 @@ uint16_t rx_pbch(LTE_UE_COMMON *lte_ue_common_vars,
 
   //un-rate matching
 #ifdef DEBUG_PBCH
-  msg("[PBCH] doing un-rate-matching\n");
+  LOG_D(PHY,"[PBCH] doing un-rate-matching\n");
 #endif
 
 
@@ -1008,12 +1008,12 @@ uint16_t rx_pbch(LTE_UE_COMMON *lte_ue_common_vars,
 #ifdef DEBUG_PBCH
 
   for (i=0; i<(PBCH_A>>3); i++)
-    msg("[PBCH] pbch_a[%d] = %x\n",i,decoded_output[i]);
+    LOG_D(PHY,"[PBCH] pbch_a[%d] = %x\n",i,decoded_output[i]);
 
 #endif //DEBUG_PBCH
 
 #ifdef DEBUG_PBCH
-  msg("PBCH CRC %x : %x\n",
+  LOG_D(PHY,"PBCH CRC %x : %x\n",
       crc16(pbch_a,PBCH_A),
       ((uint16_t)pbch_a[PBCH_A>>3]<<8)+pbch_a[(PBCH_A>>3)+1]);
 #endif
@@ -1065,8 +1065,8 @@ uint16_t rx_pbch_emul(PHY_VARS_UE *phy_vars_ue,
 
   if (pbch_phase == (frame_rx % 4)) {
     if (uniformrandom() >= bler) {
-      memcpy(phy_vars_ue->pbch_vars[eNB_id]->decoded_output,PHY_vars_eNB_g[eNB_id][CC_id]->pbch_pdu,PBCH_PDU_SIZE);
-      return(PHY_vars_eNB_g[eNB_id][CC_id]->frame_parms.nb_antenna_ports_eNB);
+      memcpy(phy_vars_ue->pbch_vars[eNB_id]->decoded_output,RC.eNB[eNB_id][CC_id]->pbch_pdu,PBCH_PDU_SIZE);
+      return(RC.eNB[eNB_id][CC_id]->frame_parms.nb_antenna_ports_eNB);
     } else
       return(-1);
   } else
diff --git a/openair1/PHY/LTE_TRANSPORT/pcfich.c b/openair1/PHY/LTE_TRANSPORT/pcfich.c
index 3b141372f0..ab9b55975d 100644
--- a/openair1/PHY/LTE_TRANSPORT/pcfich.c
+++ b/openair1/PHY/LTE_TRANSPORT/pcfich.c
@@ -156,12 +156,12 @@ void generate_pcfich(uint8_t num_pdcch_symbols,
     pcfich_scrambling(frame_parms,subframe,pcfich_b[num_pdcch_symbols-1],pcfich_bt);
 
   // modulation
-  if (frame_parms->mode1_flag==1)
+  if (frame_parms->nb_antenna_ports_eNB==1)
     gain_lin_QPSK = (int16_t)((amp*ONE_OVER_SQRT2_Q15)>>15);
   else
     gain_lin_QPSK = amp/2;
 
-  if (frame_parms->mode1_flag) { // SISO
+  if (frame_parms->nb_antenna_ports_eNB==1) { // SISO
 
     for (i=0; i<16; i++) {
       ((int16_t*)(&(pcfich_d[0][i])))[0]   = ((pcfich_bt[2*i] == 1) ? -gain_lin_QPSK : gain_lin_QPSK);
@@ -243,7 +243,6 @@ uint8_t rx_pcfich(LTE_DL_FRAME_PARMS *frame_parms,
   for (pcfich_quad=0; pcfich_quad<4; pcfich_quad++) {
     reg_offset = (pcfich_reg[pcfich_quad]*4);
 
-    //    if (frame_parms->mode1_flag==1) {  // SISO
     for (i=0; i<4; i++) {
 
       pcfich_d_ptr[0] = ((int16_t*)&rxdataF_comp[0][reg_offset+i])[0]; // RE component
diff --git a/openair1/PHY/LTE_TRANSPORT/phich.c b/openair1/PHY/LTE_TRANSPORT/phich.c
index b46c416706..1df5401c86 100644
--- a/openair1/PHY/LTE_TRANSPORT/phich.c
+++ b/openair1/PHY/LTE_TRANSPORT/phich.c
@@ -429,7 +429,7 @@ void generate_phich(LTE_DL_FRAME_PARMS *frame_parms,
 
   memset(d,0,24*sizeof(int16_t));
 
-  if (frame_parms->mode1_flag==1)
+  if (frame_parms->nb_antenna_ports_eNB==1)
     gain_lin_QPSK = (int16_t)(((int32_t)amp*ONE_OVER_SQRT2_Q15)>>15);
   else
     gain_lin_QPSK = amp/2;
@@ -562,7 +562,7 @@ void generate_phich(LTE_DL_FRAME_PARMS *frame_parms,
 #endif
 
     // modulation here
-    if (frame_parms->mode1_flag == 0) {
+    if (frame_parms->nb_antenna_ports_eNB != 1) {
       // do Alamouti precoding here
 
       // Symbol 0
@@ -691,7 +691,7 @@ void generate_phich(LTE_DL_FRAME_PARMS *frame_parms,
         }
       }
 
-    } // mode1_flag
+    } // nb_antenna_ports_eNB
 
     else {
       // Symbol 0
@@ -774,7 +774,7 @@ void generate_phich(LTE_DL_FRAME_PARMS *frame_parms,
       for (i=0;i<512;i++)
       printf("re %d (%d): %d,%d\n",i,subframe_offset+i,((int16_t*)&y[0][subframe_offset+i])[0],((int16_t*)&y[0][subframe_offset+i])[1]);
       */
-    } // mode1_flag
+    } // nb_antenna_ports_eNB
   } else { // extended prefix
 
     // 6 output symbols
@@ -851,7 +851,7 @@ void generate_phich(LTE_DL_FRAME_PARMS *frame_parms,
 
 
 
-    if (frame_parms->mode1_flag == 0) {
+    if (frame_parms->nb_antenna_ports_eNB != 1) {
       // do Alamouti precoding here
       // Symbol 0
       re_offset = frame_parms->first_carrier_offset + (frame_parms->phich_reg[ngroup_PHICH][0]*6);
@@ -1053,7 +1053,7 @@ void generate_phich(LTE_DL_FRAME_PARMS *frame_parms,
         y0[j+1] += y0_16[m++];
       }
 
-    } // mode1_flag
+    } // nb_antenna_ports_eNB
   } // normal/extended prefix
 }
 
@@ -1399,7 +1399,7 @@ void rx_phich(PHY_VARS_UE *ue,
             subframe,
             HI16,
             nseq_PHICH,
-            ngroup_PHICH,ulsch->harq_processes[harq_pid]->round+1,
+            ngroup_PHICH,
             ulsch->Mlimit);
       //#endif
 
@@ -1489,7 +1489,7 @@ void generate_phich_top(PHY_VARS_eNB *eNB,
 
   LTE_DL_FRAME_PARMS *frame_parms=&eNB->frame_parms;
   LTE_eNB_ULSCH_t **ulsch = eNB->ulsch;
-  int32_t **txdataF = eNB->common_vars.txdataF[sect_id];
+  int32_t **txdataF = eNB->common_vars.txdataF;
   uint8_t harq_pid;
   uint8_t Ngroup_PHICH,ngroup_PHICH,nseq_PHICH;
   uint8_t NSF_PHICH = 4;
diff --git a/openair1/PHY/LTE_TRANSPORT/pilots.c b/openair1/PHY/LTE_TRANSPORT/pilots.c
index a4d0fae259..03fd292886 100644
--- a/openair1/PHY/LTE_TRANSPORT/pilots.c
+++ b/openair1/PHY/LTE_TRANSPORT/pilots.c
@@ -140,7 +140,7 @@ int generate_pilots_slot(PHY_VARS_eNB *eNB,
   uint8_t second_pilot;
 
   if (slot<0 || slot>= 20) {
-    msg("generate_pilots_slot: slot not in range (%d)\n",slot);
+    LOG_E(PHY,"generate_pilots_slot: slot not in range (%d)\n",slot);
     return(-1);
   }
 
diff --git a/openair1/PHY/LTE_TRANSPORT/pilots_mbsfn.c b/openair1/PHY/LTE_TRANSPORT/pilots_mbsfn.c
index 0393a77f0c..45bd163cf2 100644
--- a/openair1/PHY/LTE_TRANSPORT/pilots_mbsfn.c
+++ b/openair1/PHY/LTE_TRANSPORT/pilots_mbsfn.c
@@ -46,7 +46,7 @@ int generate_mbsfn_pilot(PHY_VARS_eNB *eNB,
 
 
   if (subframe<0 || subframe>= 10) {
-    msg("generate_mbsfn_pilots_subframe: subframe not in range (%d)\n",subframe);
+    LOG_E(PHY,"generate_mbsfn_pilots_subframe: subframe not in range (%d)\n",subframe);
     return(-1);
   }
 
diff --git a/openair1/PHY/LTE_TRANSPORT/pmch.c b/openair1/PHY/LTE_TRANSPORT/pmch.c
index 3bd3275883..033948ebf9 100644
--- a/openair1/PHY/LTE_TRANSPORT/pmch.c
+++ b/openair1/PHY/LTE_TRANSPORT/pmch.c
@@ -81,10 +81,11 @@ void dump_mch(PHY_VARS_UE *ue,uint8_t eNB_id,uint16_t coded_bits_per_codeword,in
                &ue->common_vars.rxdata[0][subframe*ue->frame_parms.samples_per_tti],
                ue->frame_parms.samples_per_tti,1,1);
 
+  /*
   if (PHY_vars_eNB_g)
     write_output("txsig_mch.m","txs_mch",
                  &PHY_vars_eNB_g[0][0]->common_vars.txdata[0][0][subframe*ue->frame_parms.samples_per_tti],
-                 ue->frame_parms.samples_per_tti,1,1);
+                 ue->frame_parms.samples_per_tti,1,1);*/
 }
 
 int is_pmch_subframe(uint32_t frame, int subframe, LTE_DL_FRAME_PARMS *frame_parms)
@@ -308,7 +309,7 @@ void generate_mch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,uint8_t *a)
               2,proc->frame_tx,subframe,0);
 
     generate_mbsfn_pilot(eNB,proc,
-                         eNB->common_vars.txdataF[0],
+                         eNB->common_vars.txdataF,
                          AMP);
 
 
@@ -327,7 +328,7 @@ void generate_mch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,uint8_t *a)
     dlsch_scrambling(&eNB->frame_parms,1,eNB->dlsch_MCH,G,0,subframe<<1);
 
 
-    mch_modulation(eNB->common_vars.txdataF[0],
+    mch_modulation(eNB->common_vars.txdataF,
                    AMP,
                    subframe,
                    &eNB->frame_parms,
@@ -661,10 +662,7 @@ int mch_qpsk_llr(LTE_DL_FRAME_PARMS *frame_parms,
     llr32 = (uint32_t*)(*llr32p);
   }
 
-  if (!llr32) {
-    msg("dlsch_qpsk_llr: llr is null, symbol %d, llr32=%p\n",symbol, llr32);
-    return(-1);
-  }
+  AssertFatal(llr32!=NULL,"dlsch_qpsk_llr: llr is null, symbol %d, llr32=%p\n",symbol, llr32);
 
 
   if ((symbol==2) || (symbol==6) || (symbol==10)) {
diff --git a/openair1/PHY/LTE_TRANSPORT/prach.c b/openair1/PHY/LTE_TRANSPORT/prach.c
index 1555162cb4..3c343eaf4e 100644
--- a/openair1/PHY/LTE_TRANSPORT/prach.c
+++ b/openair1/PHY/LTE_TRANSPORT/prach.c
@@ -1089,6 +1089,7 @@ int32_t generate_prach( PHY_VARS_UE *ue, uint8_t eNB_id, uint8_t subframe, uint1
 //__m128i mmtmpX0,mmtmpX1,mmtmpX2,mmtmpX3;
 
 void rx_prach(PHY_VARS_eNB *eNB,
+	      RU_t *ru,
 	      uint16_t *preamble_energy_list, 
 	      uint16_t *preamble_delay_list, 
 	      uint16_t Nf, 
@@ -1096,16 +1097,41 @@ void rx_prach(PHY_VARS_eNB *eNB,
 {
 
   int i;
-  lte_frame_type_t frame_type = eNB->frame_parms.frame_type;
-  int subframe                = eNB->proc.subframe_prach;
-  uint16_t rootSequenceIndex  = eNB->frame_parms.prach_config_common.rootSequenceIndex;
-  uint8_t prach_ConfigIndex   = eNB->frame_parms.prach_config_common.prach_ConfigInfo.prach_ConfigIndex;
-  uint8_t Ncs_config          = eNB->frame_parms.prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig;
-  uint8_t restricted_set      = eNB->frame_parms.prach_config_common.prach_ConfigInfo.highSpeedFlag;
-  int16_t *prachF             = eNB->prach_vars.prachF;
-  int16_t **rxsigF            = eNB->prach_vars.rxsigF;
-  int16_t **prach_ifft        = eNB->prach_vars.prach_ifft;
-  int16_t *prach[eNB->frame_parms.nb_antennas_rx];
+
+  LTE_DL_FRAME_PARMS *fp;
+  lte_frame_type_t   frame_type;
+  uint16_t           rootSequenceIndex;  
+  uint8_t            prach_ConfigIndex;   
+  uint8_t            Ncs_config;          
+  uint8_t            restricted_set;      
+
+  int                subframe;
+  int16_t            *prachF=NULL;
+  int16_t            **rxsigF=NULL;
+  int16_t            **prach_ifft=NULL;
+
+  if (ru) fp = &ru->frame_parms;
+  else if (eNB) fp = &eNB->frame_parms;
+  else AssertFatal(1==0,"rx_prach called without valid RU or eNB descriptor\n");
+  
+  frame_type          = fp->frame_type;
+  rootSequenceIndex   = fp->prach_config_common.rootSequenceIndex;
+  prach_ConfigIndex   = fp->prach_config_common.prach_ConfigInfo.prach_ConfigIndex;
+  Ncs_config          = fp->prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig;
+  restricted_set      = fp->prach_config_common.prach_ConfigInfo.highSpeedFlag;
+  int16_t *prach[fp->nb_antennas_rx];
+
+  if (eNB) {
+    subframe          = eNB->proc.subframe_prach;
+    prachF            = eNB->prach_vars.prachF;
+    rxsigF            = eNB->prach_vars.rxsigF;
+    prach_ifft        = eNB->prach_vars.prach_ifft;
+  }
+  else {
+    subframe          = ru->proc.subframe_prach;
+    rxsigF            = ru->prach_rxsigF;
+  }
+
   int16_t *prach2;
   uint8_t n_ra_prb;
   uint8_t preamble_index;
@@ -1133,10 +1159,12 @@ void rx_prach(PHY_VARS_eNB *eNB,
   int fft_size,log2_ifft_size;
   uint8_t nb_ant_rx = 1; //eNB->frame_parms.nb_antennas_rx;
 
+#ifdef PRACH_DEBUG
   int en;
+#endif
 
   for (aa=0; aa<nb_ant_rx; aa++) {
-    prach[aa] = (int16_t*)&eNB->common_vars.rxdata[0][aa][subframe*eNB->frame_parms.samples_per_tti-eNB->N_TA_offset];
+    if (ru) prach[aa] = (int16_t*)&ru->common.rxdata[aa][subframe*fp->samples_per_tti-ru->N_TA_offset];
   }
 
   // First compute physical root sequence
@@ -1158,9 +1186,9 @@ void rx_prach(PHY_VARS_eNB *eNB,
     NCS = NCS_restricted[Ncs_config];
   }
 
-  start_meas(&eNB->rx_prach);
+  if (eNB) start_meas(&eNB->rx_prach);
 
-  n_ra_prb = get_prach_prb_offset(&(eNB->frame_parms),tdd_mapindex,Nf);
+  n_ra_prb = get_prach_prb_offset(fp,tdd_mapindex,Nf);
   prach_root_sequence_map = (prach_fmt < 4) ? prach_root_sequence_map0_3 : prach_root_sequence_map4;
 
   // PDP is oversampled, e.g. 1024 sample instead of 839
@@ -1194,7 +1222,7 @@ void rx_prach(PHY_VARS_eNB *eNB,
   }
 
   // Adjust CP length based on UL bandwidth
-  switch (eNB->frame_parms.N_RB_UL) {
+  switch (fp->N_RB_UL) {
   case 6:
     Ncp>>=4;
     break;
@@ -1216,21 +1244,20 @@ void rx_prach(PHY_VARS_eNB *eNB,
     break;
 
   case 100:
-    if (eNB->frame_parms.threequarter_fs == 1)
+    if (fp->threequarter_fs == 1)
       Ncp=(Ncp*3)>>2;
     break;
   }
 
 
-  if ((eNB->node_function == eNodeB_3GPP) ||
-      (eNB->node_function == eNodeB_3GPP_BBU) ||
-      (eNB->node_function == NGFI_RRU_IF4p5)) { // compute the DFTs of the PRACH temporal resources
+  if (((eNB!=NULL) && (ru!=NULL) && (ru->function != NGFI_RRU_IF4p5))||
+      ((eNB==NULL) && (ru!=NULL) && (ru->function == NGFI_RRU_IF4p5))) { // compute the DFTs of the PRACH temporal resources
     // Do forward transform
     for (aa=0; aa<nb_ant_rx; aa++) {
       prach2 = prach[aa] + (Ncp<<1);
   
       // do DFT
-      switch (eNB->frame_parms.N_RB_UL) {
+      switch (fp->N_RB_UL) {
       case 6:
 	if (prach_fmt == 4) {
 	  dft256(prach2,rxsigF[aa],1);
@@ -1296,7 +1323,7 @@ void rx_prach(PHY_VARS_eNB *eNB,
 	break;
 	
       case 100:
-	if (eNB->frame_parms.threequarter_fs==0) {
+	if (fp->threequarter_fs==0) {
 	  if (prach_fmt == 4) {
 	    dft4096(prach2,rxsigF[aa],1);
 	  } else {
@@ -1321,47 +1348,32 @@ void rx_prach(PHY_VARS_eNB *eNB,
     }
   }
 
-  if (eNB->node_function == NGFI_RRU_IF4p5) {
-    k = (12*n_ra_prb) - 6*eNB->frame_parms.N_RB_UL;
+  if ((eNB==NULL) && (ru!=NULL) && ru->function == NGFI_RRU_IF4p5) {
+    k = (12*n_ra_prb) - 6*fp->N_RB_UL;
     
     if (k<0) {
-      k+=(eNB->frame_parms.ofdm_symbol_size);
+      k+=(fp->ofdm_symbol_size);
     }
 
     k*=12;
     k+=13; 
     k*=2;
     
-    /// **** send_IF4 of rxsigF to RCC **** ///    
-    send_IF4p5(eNB, eNB->proc.frame_prach, eNB->proc.subframe_prach, IF4p5_PRACH, k);
+    /// **** send_IF4 of rxsigF to RAU **** ///    
+    send_IF4p5(ru, ru->proc.frame_prach, ru->proc.subframe_prach, IF4p5_PRACH, k);
 
 #if 0
-    /* TODO: resolv this conflict (there should be no printf anyway, so no big deal) */
-<<<<<<< HEAD
-    /*
     en = dB_fixed(signal_energy(&rxsigF[0][k],840));
-    printf("Sending PRACH, k %d,n_ra_prb %d, N_RB_UL %d,  en %d\n",k,n_ra_prb,eNB->frame_parms.N_RB_UL,en);
-    if (en>60) {
+    if (en>60)
       printf("PRACH: Frame %d, Subframe %d => %d dB\n",eNB->proc.frame_rx,eNB->proc.subframe_rx,en);
-      write_output("prach_rx0.m","prach_rx0",(int16_t*)&rxsigF[0][k],839,1,1);
-      exit(-1);
-    }
-    */
-
-=======
-        en = dB_fixed(signal_energy(&rxsigF[0][k],840));
-        if (en>60)
-          printf("PRACH: Frame %d, Subframe %d => %d dB\n",eNB->proc.frame_rx,eNB->proc.subframe_rx,en);
->>>>>>> origin/fix-if4p5
 #endif
 
     return;
-  } else if (eNB->node_function == NGFI_RCC_IF4p5) {
-    k = (12*n_ra_prb) - 6*eNB->frame_parms.N_RB_UL;
+  } else if (eNB!=NULL) {
+    k = (12*n_ra_prb) - 6*fp->N_RB_UL;
+    
+    if (k<0) k+=fp->ofdm_symbol_size;
     
-    if (k<0) {
-      k+=(eNB->frame_parms.ofdm_symbol_size);
-    }
 
     k*=12;
     k+=13; 
@@ -1373,30 +1385,16 @@ void rx_prach(PHY_VARS_eNB *eNB,
             839*2*sizeof(int16_t));
 
 #if 0
-    /* TODO: resolv this conflict (there should be no printf anyway, so no big deal) */
-<<<<<<< HEAD
-    /*
-    en = dB_fixed(signal_energy(&rxsigF[0][k],840));
-    printf("Receiving PRACH, k %d,n_ra_prb %d, N_RB_UL %d,  en %d\n",k,n_ra_prb,eNB->frame_parms.N_RB_UL,en);
-    if (en>60) {
-      printf("PRACH: Frame %d, Subframe %d => %d dB\n",eNB->proc.frame_rx,eNB->proc.subframe_rx,en);
-      write_output("prach_rx0.m","prach_rx0",(int16_t*)&rxsigF[0][k],839,1,1);
-      exit(-1);
-    }
-    */
-=======
     en = dB_fixed(signal_energy(&rxsigF[0][k],840));
         /*if (en>60)
     printf("PRACH: Frame %d, Subframe %d => %d dB\n",eNB->proc.frame_rx,eNB->proc.subframe_rx,en);*/
-
->>>>>>> origin/fix-if4p5
 #endif
 
   }
   
-  // in case of RCC and prach received rx_thread wakes up prach
+  // in case of RAU and prach received rx_thread wakes up prach
 
-  // here onwards is for eNodeB_3GPP or NGFI_RCC_IF4p5
+  // here onwards is for eNodeB_3GPP or NGFI_RAU_IF4p5
 
   preamble_offset_old = 99;
 
@@ -1496,25 +1494,20 @@ void rx_prach(PHY_VARS_eNB *eNB,
 
 
       
-      k = (12*n_ra_prb) - 6*eNB->frame_parms.N_RB_UL;
+      k = (12*n_ra_prb) - 6*fp->N_RB_UL;
       
       if (k<0)
-	k+=(eNB->frame_parms.ofdm_symbol_size);
+	k+=fp->ofdm_symbol_size;
       
       k*=12;
       k+=13; // phi + K/2
-      //      k+=(12*eNB->frame_parms.first_carrier_offset);
-      //      if (k>(12*eNB->frame_parms.ofdm_symbol_size))
-      //  k-=(12*eNB->frame_parms.ofdm_symbol_size);
-      
-      // printf("First prach carrier : k %d\n",k);
       k*=2;
       
 
       
       memset( prachF, 0, sizeof(int16_t)*2*1024 );
 #ifdef PRACH_DEBUG
-      write_output("prach_rx0.m","prach_rx0",prach[0],6144+792,1,1);
+      if (prach[0]!= NULL) write_output("prach_rx0.m","prach_rx0",prach[0],6144+792,1,1);
 #endif
       // write_output("prach_rx1.m","prach_rx1",prach[1],6144+792,1,1);
       //       write_output("prach_rxF0.m","prach_rxF0",rxsigF[0],24576,1,1);
@@ -1544,7 +1537,7 @@ void rx_prach(PHY_VARS_eNB *eNB,
 	    */
 	  k+=2;
 	  
-	  if (k==(12*2*eNB->frame_parms.ofdm_symbol_size))
+	  if (k==(12*2*fp->ofdm_symbol_size))
 	    k=0;
 	}
 	
@@ -1565,10 +1558,9 @@ void rx_prach(PHY_VARS_eNB *eNB,
 #ifdef PRACH_DEBUG
 
       if (en>40) {
-	k = (12*n_ra_prb) - 6*eNB->frame_parms.N_RB_UL;
+	k = (12*n_ra_prb) - 6*fp->N_RB_UL;
 	
-	if (k<0)
-	  k+=(eNB->frame_parms.ofdm_symbol_size);
+	if (k<0) k+=fp->ofdm_symbol_size;
 	
 	k*=12;
 	k+=13;
@@ -1608,7 +1600,7 @@ void rx_prach(PHY_VARS_eNB *eNB,
 
   }// preamble_index
   
-  stop_meas(&eNB->rx_prach);
+  if (eNB) stop_meas(&eNB->rx_prach);
   
 }
 
@@ -1801,7 +1793,7 @@ void compute_prach_seq(PRACH_CONFIG_COMMON *prach_config_common,
     for (k=0; k<N_ZC; k++) {
       // 420 is the multiplicative inverse of 2 (required since ru is exp[j 2\pi n])
       X_u[i][k] = ((uint32_t*)ru)[(((k*(1+(inv_u*k)))%N_ZC)*420)%N_ZC];
-      //        printf("X_u[%d][%d] (%d)(%d)(%d) : %d,%d\n",i,k,u*inv_u*k*(1+(inv_u*k)),u*inv_u*k*(1+(inv_u*k))/2,(u*inv_u*k*(1+(inv_u*k))/2)%N_ZC,((int16_t*)&X_u[i][k])[0],((int16_t*)&X_u[i][k])[1]);
+      //printf("X_u[%d][%d] (%d)(%d)(%d) : %d,%d\n",i,k,u*inv_u*k*(1+(inv_u*k)),u*inv_u*k*(1+(inv_u*k))/2,(u*inv_u*k*(1+(inv_u*k))/2)%N_ZC,((int16_t*)&X_u[i][k])[0],((int16_t*)&X_u[i][k])[1]);
     }
   }
 
diff --git a/openair1/PHY/LTE_TRANSPORT/print_stats.c b/openair1/PHY/LTE_TRANSPORT/print_stats.c
index c8d4292e8d..913288e096 100644
--- a/openair1/PHY/LTE_TRANSPORT/print_stats.c
+++ b/openair1/PHY/LTE_TRANSPORT/print_stats.c
@@ -472,7 +472,7 @@ int dump_ue_stats(PHY_VARS_UE *ue, UE_rxtx_proc_t *proc,char* buffer, int length
 #endif
 
  
-      len += sprintf(&buffer[len], "[UE PROC] Transmission Mode %d (mode1_flag %d)\n",ue->transmission_mode[eNB],ue->frame_parms.mode1_flag);
+      len += sprintf(&buffer[len], "[UE PROC] Transmission Mode %d \n",ue->transmission_mode[eNB]);
       len += sprintf(&buffer[len], "[UE PROC] PBCH err conseq %d, PBCH error total %d, PBCH FER %d\n",
                      ue->pbch_vars[eNB]->pdu_errors_conseq,
                      ue->pbch_vars[eNB]->pdu_errors,
@@ -577,9 +577,9 @@ int dump_eNB_stats(PHY_VARS_eNB *eNB, char* buffer, int length)
                    eNB_id,number_of_cards_l,
                    proc->frame_tx,
                    eNB->rx_total_gain_dB,
-                   eNB->measurements[eNB_id].n0_power_tot_dBm,
-                   eNB->measurements[eNB_id].n0_power_dB[0],
-                   eNB->measurements[eNB_id].n0_power_dB[1]);
+                   eNB->measurements.n0_power_tot_dBm,
+                   eNB->measurements.n0_power_dB[0],
+                   eNB->measurements.n0_power_dB[1]);
 
     len += sprintf(&buffer[len],"PRB I0 (%X.%X.%X.%X): ",
 		   eNB->rb_mask_ul[0],
@@ -587,7 +587,7 @@ int dump_eNB_stats(PHY_VARS_eNB *eNB, char* buffer, int length)
 
     for (i=0; i<eNB->frame_parms.N_RB_UL; i++) {
       len += sprintf(&buffer[len],"%4d ",
-                     eNB->measurements[eNB_id].n0_subband_power_tot_dBm[i]);
+                     eNB->measurements.n0_subband_power_tot_dBm[i]);
       if ((i>0) && ((i%25) == 0)) 
 	len += sprintf(&buffer[len],"\n");
     }
@@ -631,7 +631,7 @@ int dump_eNB_stats(PHY_VARS_eNB *eNB, char* buffer, int length)
 		       eNB->frame_parms.ul_power_control_config_common.p0_NominalPUCCH,
 		       dB_fixed(eNB->UE_stats[UE_id].Po_PUCCH1_below/eNB->frame_parms.N_RB_UL)-eNB->rx_total_gain_dB,
 		       dB_fixed(eNB->UE_stats[UE_id].Po_PUCCH1_above/eNB->frame_parms.N_RB_UL)-eNB->rx_total_gain_dB,
-		       PUCCH1_THRES+eNB->measurements[0].n0_power_tot_dBm-dB_fixed(eNB->frame_parms.N_RB_UL));
+		       PUCCH1_THRES+eNB->measurements.n0_power_tot_dBm-dB_fixed(eNB->frame_parms.N_RB_UL));
 	
 	len+= sprintf(&buffer[len],"DL mcs %d, UL mcs %d, UL rb %d, delta_TF %d, ",
 		      eNB->dlsch[(uint8_t)UE_id][0]->harq_processes[0]->mcs,
@@ -640,8 +640,8 @@ int dump_eNB_stats(PHY_VARS_eNB *eNB, char* buffer, int length)
 		      eNB->ulsch[(uint8_t)UE_id]->harq_processes[0]->delta_TF);
 	
 	len += sprintf(&buffer[len],"Wideband CQI: (%d,%d) dB\n",
-		       eNB->measurements[eNB_id].wideband_cqi_dB[UE_id][0],
-		       eNB->measurements[eNB_id].wideband_cqi_dB[UE_id][1]);
+		       eNB->measurements.wideband_cqi_dB[UE_id][0],
+		       eNB->measurements.wideband_cqi_dB[UE_id][1]);
 	
 	/*	len += sprintf(&buffer[len],"[eNB PROC] Subband CQI:    ");
 	
diff --git a/openair1/PHY/LTE_TRANSPORT/proto.h b/openair1/PHY/LTE_TRANSPORT/proto.h
index 52c258762b..93c328c998 100644
--- a/openair1/PHY/LTE_TRANSPORT/proto.h
+++ b/openair1/PHY/LTE_TRANSPORT/proto.h
@@ -1640,16 +1640,13 @@ void generate_RIV_tables(void);
 */
 int initial_sync(PHY_VARS_UE *phy_vars_ue, runmode_t mode);
 
-void rx_ulsch(PHY_VARS_eNB *phy_vars_eNB,
+void rx_ulsch(PHY_VARS_eNB *eNB,
               eNB_rxtx_proc_t *proc,
-	      uint8_t eNB_id,  // this is the effective sector id
-              uint8_t UE_id,
-              LTE_eNB_ULSCH_t **ulsch,
-              uint8_t cooperation_flag);
+              uint8_t UE_id);
 
-void rx_ulsch_emul(PHY_VARS_eNB *phy_vars_eNB,
+
+void rx_ulsch_emul(PHY_VARS_eNB *eNB,
 		   eNB_rxtx_proc_t *proc,
-                   uint8_t sect_id,
                    uint8_t UE_index);
 
 /*!
@@ -1909,7 +1906,8 @@ int32_t generate_prach(PHY_VARS_UE *phy_vars_ue,uint8_t eNB_id,uint8_t subframe,
 
 /*!
   \brief Process PRACH waveform
-  @param phy_vars_eNB Pointer to eNB top-level descriptor
+  @param phy_vars_eNB Pointer to eNB top-level descriptor. If NULL, then this is an RRU
+  @param ru Pointer to RU top-level descriptor. If NULL, then this is an eNB and we make use of the RU_list
   @param preamble_energy_list List of energies for each candidate preamble
   @param preamble_delay_list List of delays for each candidate preamble
   @param Nf System frame number
@@ -1917,7 +1915,7 @@ int32_t generate_prach(PHY_VARS_UE *phy_vars_ue,uint8_t eNB_id,uint8_t subframe,
   @returns 0 on success
 
 */
-void rx_prach(PHY_VARS_eNB *phy_vars_eNB,uint16_t *preamble_energy_list, uint16_t *preamble_delay_list, uint16_t Nf, uint8_t tdd_mapindex);
+void rx_prach(PHY_VARS_eNB *phy_vars_eNB,RU_t *ru,uint16_t *preamble_energy_list, uint16_t *preamble_delay_list, uint16_t Nf, uint8_t tdd_mapindex);
 
 /*!
   \brief Helper for MAC, returns number of available PRACH in TDD for a particular configuration index
diff --git a/openair1/PHY/LTE_TRANSPORT/pss.c b/openair1/PHY/LTE_TRANSPORT/pss.c
index 44c7bffd9a..e6674d6cc7 100644
--- a/openair1/PHY/LTE_TRANSPORT/pss.c
+++ b/openair1/PHY/LTE_TRANSPORT/pss.c
@@ -68,7 +68,7 @@ int generate_pss(int32_t **txdataF,
     break;
 
   default:
-    msg("[PSS] eNb_id has to be 0,1,2\n");
+    LOG_E(PHY,"[PSS] eNb_id has to be 0,1,2\n");
     return(-1);
   }
 
@@ -108,7 +108,7 @@ int generate_pss(int32_t **txdataF,
 int generate_pss_emul(PHY_VARS_eNB *phy_vars_eNb,uint8_t sect_id)
 {
 
-  msg("[PHY] EMUL eNB generate_pss_emul eNB %d, sect_id %d\n",phy_vars_eNb->Mod_id,sect_id);
+  LOG_D(PHY,"EMUL eNB generate_pss_emul eNB %d, sect_id %d\n",phy_vars_eNb->Mod_id,sect_id);
   eNB_transport_info[phy_vars_eNb->Mod_id][phy_vars_eNb->CC_id].cntl.pss=sect_id;
   return(0);
 }
diff --git a/openair1/PHY/LTE_TRANSPORT/pucch.c b/openair1/PHY/LTE_TRANSPORT/pucch.c
index db671f048c..edb7a8b405 100644
--- a/openair1/PHY/LTE_TRANSPORT/pucch.c
+++ b/openair1/PHY/LTE_TRANSPORT/pucch.c
@@ -39,7 +39,7 @@
 #include "T.h"
 
 //uint8_t ncs_cell[20][7];
-//#define DEBUG_PUCCH_TX
+//#define DEBUG_PUCCH_TXS
 //#define DEBUG_PUCCH_RX
 
 int16_t cfo_pucch_np[24*7] = {20787,-25330,27244,-18205,31356,-9512,32767,0,31356,9511,27244,18204,20787,25329,
@@ -664,14 +664,14 @@ uint32_t rx_pucch(PHY_VARS_eNB *eNB,
 
 
   static int first_call=1;
-  LTE_eNB_COMMON *common_vars                = &eNB->common_vars;
+  LTE_eNB_COMMON *common_vars                        = &eNB->common_vars;
   LTE_DL_FRAME_PARMS *frame_parms                    = &eNB->frame_parms;
   //  PUCCH_CONFIG_DEDICATED *pucch_config_dedicated = &eNB->pucch_config_dedicated[UE_id];
-  int8_t sigma2_dB                                   = eNB->measurements[0].n0_subband_power_tot_dB[0]-10;
-  uint32_t *Po_PUCCH                                  = &(eNB->UE_stats[UE_id].Po_PUCCH);
+  int8_t sigma2_dB                                   = eNB->measurements.n0_subband_power_tot_dB[0]-10;
+  uint32_t *Po_PUCCH                                 = &(eNB->UE_stats[UE_id].Po_PUCCH);
   int32_t *Po_PUCCH_dBm                              = &(eNB->UE_stats[UE_id].Po_PUCCH_dBm);
-  uint32_t *Po_PUCCH1_below                           = &(eNB->UE_stats[UE_id].Po_PUCCH1_below);
-  uint32_t *Po_PUCCH1_above                           = &(eNB->UE_stats[UE_id].Po_PUCCH1_above);
+  uint32_t *Po_PUCCH1_below                          = &(eNB->UE_stats[UE_id].Po_PUCCH1_below);
+  uint32_t *Po_PUCCH1_above                          = &(eNB->UE_stats[UE_id].Po_PUCCH1_above);
   int32_t *Po_PUCCH_update                           = &(eNB->UE_stats[UE_id].Po_PUCCH_update);
   uint32_t u,v,n,aa;
   uint32_t z[12*14];
@@ -918,7 +918,7 @@ uint32_t rx_pucch(PHY_VARS_eNB *eNB,
         re_offset -= (frame_parms->ofdm_symbol_size);
 
       symbol_offset = (unsigned int)frame_parms->ofdm_symbol_size*l;
-      rxptr = (int16_t *)&common_vars->rxdataF[0][aa][symbol_offset];
+      rxptr = (int16_t *)&common_vars->rxdataF[aa][symbol_offset];
 
       for (i=0; i<12; i++,j+=2,re_offset++) {
         rxcomp[aa][j]   = (int16_t)((rxptr[re_offset<<1]*(int32_t)zptr[j])>>15)   - ((rxptr[1+(re_offset<<1)]*(int32_t)zptr[1+j])>>15);
@@ -1007,7 +1007,7 @@ uint32_t rx_pucch(PHY_VARS_eNB *eNB,
 #endif
 
 #ifdef DEBUG_PUCCH_RX
-    LOG_I(PHY,"[eNB] PUCCH fmt1:  stat_max : %d, sigma2_dB %d (%d, %d), phase_max : %d\n",dB_fixed(stat_max),sigma2_dB,eNB->measurements[0].n0_subband_power_tot_dBm[6],pucch1_thres,phase_max);
+    LOG_I(PHY,"[eNB] PUCCH fmt1:  stat_max : %d, sigma2_dB %d (%d, %d), phase_max : %d\n",dB_fixed(stat_max),sigma2_dB,eNB->measurements.n0_subband_power_tot_dBm[6],pucch1_thres,phase_max);
 #endif
 
     eNB->pucch1_stats[UE_id][(subframe<<10)+eNB->pucch1_stats_cnt[UE_id][subframe]] = stat_max;
diff --git a/openair1/PHY/LTE_TRANSPORT/rar_tools.c b/openair1/PHY/LTE_TRANSPORT/rar_tools.c
index 60fa52df16..656185544e 100644
--- a/openair1/PHY/LTE_TRANSPORT/rar_tools.c
+++ b/openair1/PHY/LTE_TRANSPORT/rar_tools.c
@@ -152,15 +152,15 @@ int generate_eNB_ulsch_params_from_rar(unsigned char *rar_pdu,
   }
 
 #ifdef DEBUG_RAR
-  msg("ulsch ra (eNB): harq_pid %d\n",harq_pid);
-  msg("ulsch ra (eNB): NBRB     %d\n",ulsch->harq_processes[harq_pid]->nb_rb);
-  msg("ulsch ra (eNB): rballoc  %x\n",ulsch->harq_processes[harq_pid]->first_rb);
-  msg("ulsch ra (eNB): harq_pid %d\n",harq_pid);
-  msg("ulsch ra (eNB): round    %d\n",ulsch->harq_processes[harq_pid]->round);
-  msg("ulsch ra (eNB): TBS      %d\n",ulsch->harq_processes[harq_pid]->TBS);
-  msg("ulsch ra (eNB): mcs      %d\n",ulsch->harq_processes[harq_pid]->mcs);
-  msg("ulsch ra (eNB): Or1      %d\n",ulsch->harq_processes[harq_pid]->Or1);
-  msg("ulsch ra (eNB): ORI      %d\n",ulsch->harq_processes[harq_pid]->O_RI);
+  LOG_D(PHY,"ulsch ra (eNB): harq_pid %d\n",harq_pid);
+  LOG_D(PHY,"ulsch ra (eNB): NBRB     %d\n",ulsch->harq_processes[harq_pid]->nb_rb);
+  LOG_D(PHY,"ulsch ra (eNB): rballoc  %x\n",ulsch->harq_processes[harq_pid]->first_rb);
+  LOG_D(PHY,"ulsch ra (eNB): harq_pid %d\n",harq_pid);
+  LOG_D(PHY,"ulsch ra (eNB): round    %d\n",ulsch->harq_processes[harq_pid]->round);
+  LOG_D(PHY,"ulsch ra (eNB): TBS      %d\n",ulsch->harq_processes[harq_pid]->TBS);
+  LOG_D(PHY,"ulsch ra (eNB): mcs      %d\n",ulsch->harq_processes[harq_pid]->mcs);
+  LOG_D(PHY,"ulsch ra (eNB): Or1      %d\n",ulsch->harq_processes[harq_pid]->Or1);
+  LOG_D(PHY,"ulsch ra (eNB): ORI      %d\n",ulsch->harq_processes[harq_pid]->O_RI);
 #endif
   return(0);
 }
@@ -231,7 +231,7 @@ int generate_ue_ulsch_params_from_rar(PHY_VARS_UE *ue,
   cqireq=rar[3]&1;
 
   if (rballoc>RIV_max) {
-    msg("rar_tools.c: ERROR: rb_alloc (%x) > RIV_max\n",rballoc);
+    LOG_D(PHY,"rar_tools.c: ERROR: rb_alloc (%x) > RIV_max\n",rballoc);
     return(-1);
   }
 
@@ -244,7 +244,7 @@ int generate_ue_ulsch_params_from_rar(PHY_VARS_UE *ue,
   ulsch->power_offset = ue_power_offsets[ulsch->harq_processes[harq_pid]->nb_rb];
 
   if (ulsch->harq_processes[harq_pid]->nb_rb > 4) {
-    msg("rar_tools.c: unlikely rb count for RAR grant : nb_rb > 3\n");
+    LOG_D(PHY,"rar_tools.c: unlikely rb count for RAR grant : nb_rb > 3\n");
     return(-1);
   }
 
@@ -308,16 +308,16 @@ int generate_ue_ulsch_params_from_rar(PHY_VARS_UE *ue,
 
 
   //#ifdef DEBUG_RAR
-  msg("ulsch ra (UE): harq_pid %d\n",harq_pid);
-  msg("ulsch ra (UE): NBRB     %d\n",ulsch->harq_processes[harq_pid]->nb_rb);
-  msg("ulsch ra (UE): first_rb %x\n",ulsch->harq_processes[harq_pid]->first_rb);
-  msg("ulsch ra (UE): nb_rb    %d\n",ulsch->harq_processes[harq_pid]->nb_rb);
-  msg("ulsch ra (UE): round    %d\n",ulsch->harq_processes[harq_pid]->round);
-  msg("ulsch ra (UE): TBS      %d\n",ulsch->harq_processes[harq_pid]->TBS);
-  msg("ulsch ra (UE): mcs      %d\n",ulsch->harq_processes[harq_pid]->mcs);
-  msg("ulsch ra (UE): TPC      %d\n",ulsch->harq_processes[harq_pid]->TPC);
-  msg("ulsch ra (UE): O        %d\n",ulsch->O);
-  msg("ulsch ra (UE): ORI      %d\n",ulsch->O_RI);
+  LOG_D(PHY,"ulsch ra (UE): harq_pid %d\n",harq_pid);
+  LOG_D(PHY,"ulsch ra (UE): NBRB     %d\n",ulsch->harq_processes[harq_pid]->nb_rb);
+  LOG_D(PHY,"ulsch ra (UE): first_rb %x\n",ulsch->harq_processes[harq_pid]->first_rb);
+  LOG_D(PHY,"ulsch ra (UE): nb_rb    %d\n",ulsch->harq_processes[harq_pid]->nb_rb);
+  LOG_D(PHY,"ulsch ra (UE): round    %d\n",ulsch->harq_processes[harq_pid]->round);
+  LOG_D(PHY,"ulsch ra (UE): TBS      %d\n",ulsch->harq_processes[harq_pid]->TBS);
+  LOG_D(PHY,"ulsch ra (UE): mcs      %d\n",ulsch->harq_processes[harq_pid]->mcs);
+  LOG_D(PHY,"ulsch ra (UE): TPC      %d\n",ulsch->harq_processes[harq_pid]->TPC);
+  LOG_D(PHY,"ulsch ra (UE): O        %d\n",ulsch->O);
+  LOG_D(PHY,"ulsch ra (UE): ORI      %d\n",ulsch->O_RI);
 
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX_ULSCH_RAR,VCD_FUNCTION_OUT);
 
diff --git a/openair1/PHY/LTE_TRANSPORT/srs_modulation.c b/openair1/PHY/LTE_TRANSPORT/srs_modulation.c
index 7e29d998a1..947a68bf7c 100644
--- a/openair1/PHY/LTE_TRANSPORT/srs_modulation.c
+++ b/openair1/PHY/LTE_TRANSPORT/srs_modulation.c
@@ -178,7 +178,7 @@ int32_t generate_srs_tx(PHY_VARS_UE *ue,
   }
 
   if (k0<0) {
-    msg("generate_srs: invalid parameter set msrs0=%d, msrsb=%d, Nb=%d => nb=%d, k0=%d\n",msrs0,msrsb,Nb,nb,k0);
+    LOG_E(PHY,"generate_srs: invalid parameter set msrs0=%d, msrsb=%d, Nb=%d => nb=%d, k0=%d\n",msrs0,msrsb,Nb,nb,k0);
     return(-1);
   }
 
@@ -188,7 +188,7 @@ int32_t generate_srs_tx(PHY_VARS_UE *ue,
   if (Msc_idx_ptr)
     Msc_RS_idx = Msc_idx_ptr - dftsizes;
   else {
-    msg("generate_srs: index for Msc_RS=%d not found\n",Msc_RS);
+    LOG_E(PHY,"generate_srs: index for Msc_RS=%d not found\n",Msc_RS);
     return(-1);
   }
 
@@ -199,14 +199,14 @@ int32_t generate_srs_tx(PHY_VARS_UE *ue,
   else if (Msc_RS==144)
     Msc_RS_idx = 9;
   else {
-    msg("generate_srs: index for Msc_RS=%d not implemented\n",Msc_RS);
+    LOG_E(PHY,"generate_srs: index for Msc_RS=%d not implemented\n",Msc_RS);
     return(-1);
   }
 
 #endif
 
 #ifdef DEBUG_SRS
-  msg("generate_srs_tx: Msc_RS = %d, Msc_RS_idx = %d\n",Msc_RS, Msc_RS_idx);
+  LOG_E(PHY,"generate_srs_tx: Msc_RS = %d, Msc_RS_idx = %d\n",Msc_RS, Msc_RS_idx);
 #endif
 
     carrier_pos = (frame_parms->first_carrier_offset + k0);
@@ -285,7 +285,7 @@ int generate_srs_rx(LTE_DL_FRAME_PARMS *frame_parms,
   }
 
   if (k0<0) {
-    msg("Invalid parameter set msrs0=%d, msrsb=%d, Nb=%d => nb=%d, k0=%d\n",msrs0,msrsb,Nb,nb,k0);
+    LOG_E(PHY,"Invalid parameter set msrs0=%d, msrsb=%d, Nb=%d => nb=%d, k0=%d\n",msrs0,msrsb,Nb,nb,k0);
     return(-1);
   }
 
@@ -295,7 +295,7 @@ int generate_srs_rx(LTE_DL_FRAME_PARMS *frame_parms,
   if (Msc_idx_ptr)
     Msc_RS_idx = Msc_idx_ptr - dftsizes;
   else {
-    msg("generate_srs: index for Msc_RS=%d not found\n",Msc_RS);
+    LOG_E(PHY,"generate_srs: index for Msc_RS=%d not found\n",Msc_RS);
     return(-1);
   }
 
@@ -306,14 +306,14 @@ int generate_srs_rx(LTE_DL_FRAME_PARMS *frame_parms,
   else if (Msc_RS==144)
     Msc_RS_idx = 9;
   else {
-    msg("generate_srs: index for Msc_RS=%d not implemented\n",Msc_RS);
+    LOG_E(PHY,"generate_srs: index for Msc_RS=%d not implemented\n",Msc_RS);
     return(-1);
   }
 
 #endif
 
 #ifdef DEBUG_SRS
-  msg("generate_srs_rx: Msc_RS = %d, Msc_RS_idx = %d, k0=%d\n",Msc_RS, Msc_RS_idx,k0);
+  LOG_E(PHY,"generate_srs_rx: Msc_RS = %d, Msc_RS_idx = %d, k0=%d\n",Msc_RS, Msc_RS_idx,k0);
 #endif
 
   carrier_pos = (frame_parms->first_carrier_offset + k0) % frame_parms->ofdm_symbol_size;
diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c b/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c
index 28d7cbbd01..425bd38391 100644
--- a/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c
+++ b/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c
@@ -1572,11 +1572,10 @@ int32_t avgU_0[2],avgU_1[2]; // For the Distributed Alamouti Scheme
 
 void rx_ulsch(PHY_VARS_eNB *eNB,
 	      eNB_rxtx_proc_t *proc,
-              uint8_t eNB_id,  // this is the effective sector id
-              uint8_t UE_id,
-              LTE_eNB_ULSCH_t **ulsch,
-              uint8_t cooperation_flag)
-{
+              uint8_t UE_id) {
+
+
+  LTE_eNB_ULSCH_t **ulsch = eNB->ulsch;
 
   // flagMag = 0;
   LTE_eNB_COMMON *common_vars = &eNB->common_vars;
@@ -1588,25 +1587,19 @@ void rx_ulsch(PHY_VARS_eNB *eNB,
   uint8_t log2_maxh=0,aarx;
 
 
-  int32_t avgs_0,avgs_1;
-  uint32_t log2_maxh_0=0,log2_maxh_1=0;
-
 
   //  uint8_t harq_pid = ( ulsch->RRCConnRequest_flag== 0) ? subframe2harq_pid_tdd(frame_parms->tdd_config,subframe) : 0;
   uint8_t harq_pid;
   uint8_t Qm;
-  uint16_t rx_power_correction;
   int16_t *llrp;
   int subframe = proc->subframe_rx;
 
   harq_pid = subframe2harq_pid(frame_parms,proc->frame_rx,subframe);
   Qm = get_Qm_ul(ulsch[UE_id]->harq_processes[harq_pid]->mcs);
 #ifdef DEBUG_ULSCH
-  printf("rx_ulsch: eNB_id %d, harq_pid %d, nb_rb %d first_rb %d, cooperation %d\n",eNB_id,harq_pid,ulsch[UE_id]->harq_processes[harq_pid]->nb_rb,ulsch[UE_id]->harq_processes[harq_pid]->first_rb,
-      cooperation_flag);
-#endif //DEBUG_ULSCH
+  printf("rx_ulsch: harq_pid %d, nb_rb %d first_rb %d\n",harq_pid,ulsch[UE_id]->harq_processes[harq_pid]->nb_rb,ulsch[UE_id]->harq_processes[harq_pid]->first_rb);
 
-  rx_power_correction = 1;
+#endif //DEBUG_ULSCH
 
   if (ulsch[UE_id]->harq_processes[harq_pid]->nb_rb == 0) {
     LOG_E(PHY,"PUSCH (%d/%x) nb_rb=0!\n", harq_pid,ulsch[UE_id]->rnti);
@@ -1619,115 +1612,62 @@ void rx_ulsch(PHY_VARS_eNB *eNB,
     printf("rx_ulsch : symbol %d (first_rb %d,nb_rb %d), rxdataF %p, rxdataF_ext %p\n",l,
         ulsch[UE_id]->harq_processes[harq_pid]->first_rb,
         ulsch[UE_id]->harq_processes[harq_pid]->nb_rb,
-        common_vars->rxdataF[eNB_id],
-        pusch_vars->rxdataF_ext[eNB_id]);
+        common_vars->rxdataF,
+        pusch_vars->rxdataF_ext);
 #endif //DEBUG_ULSCH
 
-    ulsch_extract_rbs_single(common_vars->rxdataF[eNB_id],
-                             pusch_vars->rxdataF_ext[eNB_id],
+    ulsch_extract_rbs_single(common_vars->rxdataF,
+                             pusch_vars->rxdataF_ext,
                              ulsch[UE_id]->harq_processes[harq_pid]->first_rb,
                              ulsch[UE_id]->harq_processes[harq_pid]->nb_rb,
                              l%(frame_parms->symbols_per_tti/2),
                              l/(frame_parms->symbols_per_tti/2),
                              frame_parms);
-
+    
     lte_ul_channel_estimation(eNB,proc,
-                              eNB_id,
                               UE_id,
                               l%(frame_parms->symbols_per_tti/2),
-                              l/(frame_parms->symbols_per_tti/2),
-                              cooperation_flag);
+                              l/(frame_parms->symbols_per_tti/2));
   }
 
-  if(cooperation_flag == 2) {
-    for (i=0; i<frame_parms->nb_antennas_rx; i++) {
-      pusch_vars->ulsch_power_0[i] = signal_energy(pusch_vars->drs_ch_estimates_0[eNB_id][i],
-                                         ulsch[UE_id]->harq_processes[harq_pid]->nb_rb*12)*rx_power_correction;
-      pusch_vars->ulsch_power_1[i] = signal_energy(pusch_vars->drs_ch_estimates_1[eNB_id][i],
-                                         ulsch[UE_id]->harq_processes[harq_pid]->nb_rb*12)*rx_power_correction;
-    }
-  } else {
-    for (i=0; i<frame_parms->nb_antennas_rx; i++) {
-      /*
-      pusch_vars->ulsch_power[i] = signal_energy_nodc(pusch_vars->drs_ch_estimates[eNB_id][i],
-                                       ulsch[UE_id]->harq_processes[harq_pid]->nb_rb*12)*rx_power_correction;
-
-      */
-      
-      pusch_vars->ulsch_power[i] = signal_energy_nodc(pusch_vars->drs_ch_estimates[eNB_id][i],
-							  ulsch[UE_id]->harq_processes[harq_pid]->nb_rb*12);
-      
+  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[eNB_id][i],
-                                          ulsch[UE_id]->harq_processes[harq_pid]->nb_rb*12, pusch_vars->subcarrier_power, rx_power_correction);
+    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
-    }
   }
 
+
   //write_output("rxdataF_ext.m","rxF_ext",pusch_vars->rxdataF_ext[eNB_id][0],300*(frame_parms->symbols_per_tti-ulsch[UE_id]->srs_active),1,1);
   //write_output("ulsch_chest.m","drs_est",pusch_vars->drs_ch_estimates[eNB_id][0],300*(frame_parms->symbols_per_tti-ulsch[UE_id]->srs_active),1,1);
 
 
-  if(cooperation_flag == 2) {
-    ulsch_channel_level(pusch_vars->drs_ch_estimates_0[eNB_id],
-                        frame_parms,
-                        avgU_0,
-                        ulsch[UE_id]->harq_processes[harq_pid]->nb_rb);
-
-    //  printf("[ULSCH] avg_0[0] %d\n",avgU_0[0]);
-
-
-    avgs_0 = 0;
-
-    for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++)
-      avgs_0 = cmax(avgs_0,avgU_0[(aarx<<1)]);
-
-    log2_maxh_0 = (log2_approx(avgs_0)/2)+ log2_approx(frame_parms->nb_antennas_rx-1)+3;
-#ifdef DEBUG_ULSCH
-    printf("[ULSCH] log2_maxh_0 = %d (%d,%d)\n",log2_maxh_0,avgU_0[0],avgs_0);
-#endif
-
-    ulsch_channel_level(pusch_vars->drs_ch_estimates_1[eNB_id],
-                        frame_parms,
-                        avgU_1,
-                        ulsch[UE_id]->harq_processes[harq_pid]->nb_rb);
-
-    //  printf("[ULSCH] avg_1[0] %d\n",avgU_1[0]);
-
-
-    avgs_1 = 0;
-
-    for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++)
-      avgs_1 = cmax(avgs_1,avgU_1[(aarx<<1)]);
-
-    log2_maxh_1 = (log2_approx(avgs_1)/2) + log2_approx(frame_parms->nb_antennas_rx-1)+3;
+  ulsch_channel_level(pusch_vars->drs_ch_estimates,
+		      frame_parms,
+		      avgU,
+		      ulsch[UE_id]->harq_processes[harq_pid]->nb_rb);
+  
+  //  printf("[ULSCH] avg[0] %d\n",avgU[0]);
+  
+  
+  avgs = 0;
+  
+  for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++)
+    avgs = cmax(avgs,avgU[(aarx<<1)]);
+  
+  //      log2_maxh = 4+(log2_approx(avgs)/2);
+  
+  log2_maxh = (log2_approx(avgs)/2)+ log2_approx(frame_parms->nb_antennas_rx-1)+4;
+  
 #ifdef DEBUG_ULSCH
-    printf("[ULSCH] log2_maxh_1 = %d (%d,%d)\n",log2_maxh_1,avgU_1[0],avgs_1);
+  printf("[ULSCH] log2_maxh = %d (%d,%d)\n",log2_maxh,avgU[0],avgs);
 #endif
-    log2_maxh = max(log2_maxh_0,log2_maxh_1);
-  } else {
-    ulsch_channel_level(pusch_vars->drs_ch_estimates[eNB_id],
-                        frame_parms,
-                        avgU,
-                        ulsch[UE_id]->harq_processes[harq_pid]->nb_rb);
-
-    //  printf("[ULSCH] avg[0] %d\n",avgU[0]);
-
-
-    avgs = 0;
-
-    for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++)
-      avgs = cmax(avgs,avgU[(aarx<<1)]);
-
-    //      log2_maxh = 4+(log2_approx(avgs)/2);
 
-    log2_maxh = (log2_approx(avgs)/2)+ log2_approx(frame_parms->nb_antennas_rx-1)+4;
-
-#ifdef DEBUG_ULSCH
-    printf("[ULSCH] log2_maxh = %d (%d,%d)\n",log2_maxh,avgU[0],avgs);
-#endif
-  }
 
   for (l=0; l<frame_parms->symbols_per_tti-ulsch[UE_id]->harq_processes[harq_pid]->srs_active; l++) {
 
@@ -1736,86 +1676,44 @@ void rx_ulsch(PHY_VARS_eNB *eNB,
       l++;
     }
 
-    if(cooperation_flag == 2) {
-
-      ulsch_channel_compensation_alamouti(
-        pusch_vars->rxdataF_ext[eNB_id],
-        pusch_vars->drs_ch_estimates_0[eNB_id],
-        pusch_vars->drs_ch_estimates_1[eNB_id],
-        pusch_vars->ul_ch_mag_0[eNB_id],
-        pusch_vars->ul_ch_magb_0[eNB_id],
-        pusch_vars->ul_ch_mag_1[eNB_id],
-        pusch_vars->ul_ch_magb_1[eNB_id],
-        pusch_vars->rxdataF_comp_0[eNB_id],
-        pusch_vars->rxdataF_comp_1[eNB_id],
-        frame_parms,
-        l,
-        Qm,
-        ulsch[UE_id]->harq_processes[harq_pid]->nb_rb,
-        log2_maxh);
-
-      ulsch_alamouti(frame_parms,
-                     pusch_vars->rxdataF_comp[eNB_id],
-                     pusch_vars->rxdataF_comp_0[eNB_id],
-                     pusch_vars->rxdataF_comp_1[eNB_id],
-                     pusch_vars->ul_ch_mag[eNB_id],
-                     pusch_vars->ul_ch_magb[eNB_id],
-                     pusch_vars->ul_ch_mag_0[eNB_id],
-                     pusch_vars->ul_ch_magb_0[eNB_id],
-                     pusch_vars->ul_ch_mag_1[eNB_id],
-                     pusch_vars->ul_ch_magb_1[eNB_id],
-                     l,
-                     ulsch[UE_id]->harq_processes[harq_pid]->nb_rb);
-    } else {
-      ulsch_channel_compensation(
-        pusch_vars->rxdataF_ext[eNB_id],
-        pusch_vars->drs_ch_estimates[eNB_id],
-        pusch_vars->ul_ch_mag[eNB_id],
-        pusch_vars->ul_ch_magb[eNB_id],
-        pusch_vars->rxdataF_comp[eNB_id],
-        frame_parms,
-        l,
-        Qm,
-        ulsch[UE_id]->harq_processes[harq_pid]->nb_rb,
-        log2_maxh); // log2_maxh+I0_shift
+    ulsch_channel_compensation(
+			       pusch_vars->rxdataF_ext,
+			       pusch_vars->drs_ch_estimates,
+			       pusch_vars->ul_ch_mag,
+			       pusch_vars->ul_ch_magb,
+			       pusch_vars->rxdataF_comp,
+			       frame_parms,
+			       l,
+			       Qm,
+			       ulsch[UE_id]->harq_processes[harq_pid]->nb_rb,
+			       log2_maxh); // log2_maxh+I0_shift
 
-    }
-
-
-    //eren
-    /* if(flagMag == 0){
-    //writing for the first time
-    write_output(namepointer_log2,"xxx",log2_maxh,1,1,12);
-
-    write_output(namepointer_chMag,"xxx",pusch_vars->ul_ch_mag[eNB_id][0],300,1,11);
-
-    //namepointer_chMag = NULL;
-    flagMag=1;
-    }*/
+  }
 
-    if (frame_parms->nb_antennas_rx > 1)
-      ulsch_detection_mrc(frame_parms,
-                          pusch_vars->rxdataF_comp[eNB_id],
-                          pusch_vars->ul_ch_mag[eNB_id],
-                          pusch_vars->ul_ch_magb[eNB_id],
-                          l,
-                          ulsch[UE_id]->harq_processes[harq_pid]->nb_rb);
 
+  if (frame_parms->nb_antennas_rx > 1)
+    ulsch_detection_mrc(frame_parms,
+			pusch_vars->rxdataF_comp,
+			pusch_vars->ul_ch_mag,
+			pusch_vars->ul_ch_magb,
+			l,
+			ulsch[UE_id]->harq_processes[harq_pid]->nb_rb);
+  
 #ifndef OFDMA_ULSCH
-
-    if ((eNB->measurements->n0_power_dB[0]+3)<pusch_vars->ulsch_power[0]) {
-
-      freq_equalization(frame_parms,
-                        pusch_vars->rxdataF_comp[eNB_id],
-                        pusch_vars->ul_ch_mag[eNB_id],
-                        pusch_vars->ul_ch_magb[eNB_id],
-                        l,
-                        ulsch[UE_id]->harq_processes[harq_pid]->nb_rb*12,
-                        Qm);
-    }
+  
+  if ((eNB->measurements.n0_power_dB[0]+3)<pusch_vars->ulsch_power[0]) {
+    
+    freq_equalization(frame_parms,
+		      pusch_vars->rxdataF_comp,
+		      pusch_vars->ul_ch_mag,
+		      pusch_vars->ul_ch_magb,
+		      l,
+		      ulsch[UE_id]->harq_processes[harq_pid]->nb_rb*12,
+		      Qm);
+  }
 
 #endif
-  }
+  
 
 #ifndef OFDMA_ULSCH
 
@@ -1823,7 +1721,7 @@ void rx_ulsch(PHY_VARS_eNB *eNB,
   // Inverse-Transform equalized outputs
   //  printf("Doing IDFTs\n");
   lte_idft(frame_parms,
-           (uint32_t*)pusch_vars->rxdataF_comp[eNB_id][0],
+           (uint32_t*)pusch_vars->rxdataF_comp[0],
            ulsch[UE_id]->harq_processes[harq_pid]->nb_rb*12);
   //  printf("Done\n");
   //#endif //DEBUG_ULSCH
@@ -1834,10 +1732,10 @@ void rx_ulsch(PHY_VARS_eNB *eNB,
 
   llrp = (int16_t*)&pusch_vars->llr[0];
 
-  T(T_ENB_PHY_PUSCH_IQ, T_INT(eNB_id), T_INT(UE_id), T_INT(proc->frame_rx),
+  T(T_ENB_PHY_PUSCH_IQ, T_INT(0), T_INT(UE_id), T_INT(proc->frame_rx),
     T_INT(subframe), T_INT(ulsch[UE_id]->harq_processes[harq_pid]->nb_rb),
     T_INT(frame_parms->N_RB_UL), T_INT(frame_parms->symbols_per_tti),
-    T_BUFFER(pusch_vars->rxdataF_comp[eNB_id][0],
+    T_BUFFER(pusch_vars->rxdataF_comp[0],
              2 * /* ulsch[UE_id]->harq_processes[harq_pid]->nb_rb */ frame_parms->N_RB_UL *12*frame_parms->symbols_per_tti*2));
 
   for (l=0; l<frame_parms->symbols_per_tti-ulsch[UE_id]->harq_processes[harq_pid]->srs_active; l++) {
@@ -1850,7 +1748,7 @@ void rx_ulsch(PHY_VARS_eNB *eNB,
     switch (Qm) {
     case 2 :
       ulsch_qpsk_llr(frame_parms,
-                     pusch_vars->rxdataF_comp[eNB_id],
+                     pusch_vars->rxdataF_comp,
                      pusch_vars->llr,
                      l,
                      ulsch[UE_id]->harq_processes[harq_pid]->nb_rb,
@@ -1859,19 +1757,19 @@ void rx_ulsch(PHY_VARS_eNB *eNB,
 
     case 4 :
       ulsch_16qam_llr(frame_parms,
-                      pusch_vars->rxdataF_comp[eNB_id],
+                      pusch_vars->rxdataF_comp,
                       pusch_vars->llr,
-                      pusch_vars->ul_ch_mag[eNB_id],
+                      pusch_vars->ul_ch_mag,
                       l,ulsch[UE_id]->harq_processes[harq_pid]->nb_rb,
                       &llrp);
       break;
 
     case 6 :
       ulsch_64qam_llr(frame_parms,
-                      pusch_vars->rxdataF_comp[eNB_id],
+                      pusch_vars->rxdataF_comp,
                       pusch_vars->llr,
-                      pusch_vars->ul_ch_mag[eNB_id],
-                      pusch_vars->ul_ch_magb[eNB_id],
+                      pusch_vars->ul_ch_mag,
+                      pusch_vars->ul_ch_magb,
                       l,ulsch[UE_id]->harq_processes[harq_pid]->nb_rb,
                       &llrp);
       break;
@@ -1888,10 +1786,9 @@ void rx_ulsch(PHY_VARS_eNB *eNB,
 
 void rx_ulsch_emul(PHY_VARS_eNB *eNB,
 		   eNB_rxtx_proc_t *proc,
-                   uint8_t sect_id,
                    uint8_t UE_index)
 {
-  printf("[PHY] EMUL eNB %d rx_ulsch_emul : subframe %d, sect_id %d, UE_index %d\n",eNB->Mod_id,proc->subframe_rx,sect_id,UE_index);
+  printf("[PHY] EMUL eNB %d rx_ulsch_emul : subframe %d, UE_index %d\n",eNB->Mod_id,proc->subframe_rx,UE_index);
   eNB->pusch_vars[UE_index]->ulsch_power[0] = 31622; //=45dB;
   eNB->pusch_vars[UE_index]->ulsch_power[1] = 31622; //=45dB;
 
@@ -1913,39 +1810,41 @@ void rx_ulsch_emul(PHY_VARS_eNB *eNB,
   //#ifndef OAI_EMU
   write_output("/tmp/ulsch_d.m","ulsch_dseq",&eNB->ulsch[UE_id]->harq_processes[harq_pid]->d[0][96],
                eNB->ulsch[UE_id]->harq_processes[harq_pid]->Kplus*3,1,0);
-  write_output("/tmp/rxsig0.m","rxs0", &eNB->common_vars.rxdata[0][0][0],eNB->frame_parms.samples_per_tti*10,1,1);
+  write_output("/tmp/rxsig0.m","rxs0", &eNB->common_vars.rxdata[0][0],eNB->frame_parms.samples_per_tti*10,1,1);
 
+  
   if (eNB->frame_parms.nb_antennas_rx>1)
-    write_output("/tmp/rxsig1.m","rxs1", &eNB->common_vars.rxdata[0][1][0],eNB->frame_parms.samples_per_tti*10,1,1);
+    write_output("/tmp/rxsig1.m","rxs1", &eNB->common_vars.rxdata[1][0],eNB->frame_parms.samples_per_tti*10,1,1);
+  
 
-  write_output("/tmp/rxsigF0.m","rxsF0", &eNB->common_vars.rxdataF[0][0][0],eNB->frame_parms.ofdm_symbol_size*nsymb,1,1);
+  write_output("/tmp/rxsigF0.m","rxsF0", &eNB->common_vars.rxdataF[0][0],eNB->frame_parms.ofdm_symbol_size*nsymb,1,1);
 
   if (eNB->frame_parms.nb_antennas_rx>1)
-    write_output("/tmp/rxsigF1.m","rxsF1", &eNB->common_vars.rxdataF[0][1][0],eNB->frame_parms.ofdm_symbol_size*nsymb,1,1);
+    write_output("/tmp/rxsigF1.m","rxsF1", &eNB->common_vars.rxdataF[1][0],eNB->frame_parms.ofdm_symbol_size*nsymb,1,1);
 
-  write_output("/tmp/rxsigF0_ext.m","rxsF0_ext", &eNB->pusch_vars[UE_id]->rxdataF_ext[0][0][0],eNB->frame_parms.N_RB_UL*12*nsymb,1,1);
+  write_output("/tmp/rxsigF0_ext.m","rxsF0_ext", &eNB->pusch_vars[UE_id]->rxdataF_ext[0][0],eNB->frame_parms.N_RB_UL*12*nsymb,1,1);
 
   if (eNB->frame_parms.nb_antennas_rx>1)
-    write_output("/tmp/rxsigF1_ext.m","rxsF1_ext", &eNB->pusch_vars[UE_id]->rxdataF_ext[1][0][0],eNB->frame_parms.N_RB_UL*12*nsymb,1,1);
+    write_output("/tmp/rxsigF1_ext.m","rxsF1_ext", &eNB->pusch_vars[UE_id]->rxdataF_ext[0][0],eNB->frame_parms.N_RB_UL*12*nsymb,1,1);
 
 
-  write_output("/tmp/srs_est0.m","srsest0",eNB->srs_vars[UE_id].srs_ch_estimates[0][0],eNB->frame_parms.ofdm_symbol_size,1,1);
+  write_output("/tmp/srs_est0.m","srsest0",eNB->srs_vars[UE_id].srs_ch_estimates[0],eNB->frame_parms.ofdm_symbol_size,1,1);
 
   if (eNB->frame_parms.nb_antennas_rx>1)
-    write_output("/tmp/srs_est1.m","srsest1",eNB->srs_vars[UE_id].srs_ch_estimates[0][1],eNB->frame_parms.ofdm_symbol_size,1,1);
+    write_output("/tmp/srs_est1.m","srsest1",eNB->srs_vars[UE_id].srs_ch_estimates[1],eNB->frame_parms.ofdm_symbol_size,1,1);
 
-  write_output("/tmp/drs_est0.m","drsest0",eNB->pusch_vars[UE_id]->drs_ch_estimates[0][0],eNB->frame_parms.N_RB_UL*12*nsymb,1,1);
+  write_output("/tmp/drs_est0.m","drsest0",eNB->pusch_vars[UE_id]->drs_ch_estimates[0],eNB->frame_parms.N_RB_UL*12*nsymb,1,1);
 
   if (eNB->frame_parms.nb_antennas_rx>1)
-    write_output("/tmp/drs_est1.m","drsest1",eNB->pusch_vars[UE_id]->drs_ch_estimates[0][1],eNB->frame_parms.N_RB_UL*12*nsymb,1,1);
+    write_output("/tmp/drs_est1.m","drsest1",eNB->pusch_vars[UE_id]->drs_ch_estimates[1],eNB->frame_parms.N_RB_UL*12*nsymb,1,1);
 
-  write_output("/tmp/ulsch_rxF_comp0.m","ulsch0_rxF_comp0",&eNB->pusch_vars[UE_id]->rxdataF_comp[0][0][0],eNB->frame_parms.N_RB_UL*12*nsymb,1,1);
+  write_output("/tmp/ulsch_rxF_comp0.m","ulsch0_rxF_comp0",&eNB->pusch_vars[UE_id]->rxdataF_comp[0][0],eNB->frame_parms.N_RB_UL*12*nsymb,1,1);
   //  write_output("ulsch_rxF_comp1.m","ulsch0_rxF_comp1",&eNB->pusch_vars[UE_id]->rxdataF_comp[0][1][0],eNB->frame_parms.N_RB_UL*12*nsymb,1,1);
   write_output("/tmp/ulsch_rxF_llr.m","ulsch_llr",eNB->pusch_vars[UE_id]->llr,
                eNB->ulsch[UE_id]->harq_processes[harq_pid]->nb_rb*12*get_Qm_ul(eNB->ulsch[UE_id]->harq_processes[harq_pid]->mcs)
                *eNB->ulsch[UE_id]->harq_processes[harq_pid]->Nsymb_pusch,1,0);
-  write_output("/tmp/ulsch_ch_mag.m","ulsch_ch_mag",&eNB->pusch_vars[UE_id]->ul_ch_mag[0][0][0],eNB->frame_parms.N_RB_UL*12*nsymb,1,1);
-  //  write_output("ulsch_ch_mag1.m","ulsch_ch_mag1",&eNB->pusch_vars[UE_id]->ul_ch_mag[0][1][0],eNB->frame_parms.N_RB_UL*12*nsymb,1,1);
+  write_output("/tmp/ulsch_ch_mag.m","ulsch_ch_mag",&eNB->pusch_vars[UE_id]->ul_ch_mag[0][0],eNB->frame_parms.N_RB_UL*12*nsymb,1,1);
+  //  write_output("ulsch_ch_mag1.m","ulsch_ch_mag1",&eNB->pusch_vars[UE_id]->ul_ch_mag[1][0],eNB->frame_parms.N_RB_UL*12*nsymb,1,1);
   //#endif
 }
 
diff --git a/openair1/PHY/MODULATION/beamforming.c b/openair1/PHY/MODULATION/beamforming.c
index 88ac12b0a7..92b84707ac 100644
--- a/openair1/PHY/MODULATION/beamforming.c
+++ b/openair1/PHY/MODULATION/beamforming.c
@@ -65,7 +65,12 @@ int beam_precoding(int32_t **txdataF,
 
   for (p=0; p<NB_ANTENNA_PORTS_ENB; p++) {
     if (p<frame_parms->nb_antenna_ports_eNB || p==5) {
-      multadd_cpx_vector((int16_t*)&txdataF[p][slot_offset_F+symbol*frame_parms->ofdm_symbol_size],(int16_t*)beam_weights[p][aa], (int16_t*)txdataF_BF[aa], 0, frame_parms->ofdm_symbol_size, 15);
+      multadd_cpx_vector((int16_t*)&txdataF[p][slot_offset_F+symbol*frame_parms->ofdm_symbol_size],
+			 (int16_t*)beam_weights[p][aa], 
+			 (int16_t*)&txdataF_BF[aa][symbol*frame_parms->ofdm_symbol_size], 
+			 0, 
+			 frame_parms->ofdm_symbol_size, 
+			 15);
       //mult_cpx_conj_vector((int16_t*)beam_weights[p][aa], (int16_t*)&txdataF[p][slot_offset_F+symbol*frame_parms->ofdm_symbol_size], (int16_t*)txdataF_BF[aa], frame_parms->ofdm_symbol_size, 15, 1);
 
       // if check version
diff --git a/openair1/PHY/MODULATION/defs.h b/openair1/PHY/MODULATION/defs.h
index da599114a9..1ed81e7993 100644
--- a/openair1/PHY/MODULATION/defs.h
+++ b/openair1/PHY/MODULATION/defs.h
@@ -72,19 +72,18 @@ int slot_fep_mbsfn(PHY_VARS_UE *phy_vars_ue,
                    int no_prefix);
 
 int slot_fep_ul(LTE_DL_FRAME_PARMS *frame_parms,
-                LTE_eNB_COMMON *eNb_common_vars,
+                RU_COMMON *common,
                 unsigned char l,
                 unsigned char Ns,
-                unsigned char eNb_id,
                 int no_prefix);
 
 void normal_prefix_mod(int32_t *txdataF,int32_t *txdata,uint8_t nsymb,LTE_DL_FRAME_PARMS *frame_parms);
 
 void do_OFDM_mod(int32_t **txdataF, int32_t **txdata, uint32_t frame,uint16_t next_slot, LTE_DL_FRAME_PARMS *frame_parms);
 
-void do_OFDM_mod_symbol(LTE_eNB_COMMON *eNB_common_vars, int eNB_id, uint16_t next_slot, LTE_DL_FRAME_PARMS *frame_parms,int do_precoding);
+void do_OFDM_mod_symbol(LTE_eNB_COMMON *eNB_common_vars, RU_COMMON *common, uint16_t next_slot, LTE_DL_FRAME_PARMS *frame_parms,int do_precoding);
 
-void remove_7_5_kHz(PHY_VARS_eNB *phy_vars_eNB,uint8_t subframe);
+void remove_7_5_kHz(RU_t *ru,uint8_t subframe);
 
 void apply_7_5_kHz(PHY_VARS_UE *phy_vars_ue,int32_t*txdata,uint8_t subframe);
 
diff --git a/openair1/PHY/MODULATION/ofdm_mod.c b/openair1/PHY/MODULATION/ofdm_mod.c
index f6f0c1f618..4328145c8a 100644
--- a/openair1/PHY/MODULATION/ofdm_mod.c
+++ b/openair1/PHY/MODULATION/ofdm_mod.c
@@ -282,14 +282,15 @@ void do_OFDM_mod(int32_t **txdataF, int32_t **txdata, uint32_t frame,uint16_t ne
 
 }
 
+/*
 // OFDM modulation for each symbol
-void do_OFDM_mod_symbol(LTE_eNB_COMMON *eNB_common_vars, int eNB_id, uint16_t next_slot, LTE_DL_FRAME_PARMS *frame_parms,int do_precoding)
+void do_OFDM_mod_symbol(LTE_eNB_COMMON *eNB_common_vars, RU_COMMON *common, uint16_t next_slot, LTE_DL_FRAME_PARMS *frame_parms,int do_precoding)
 {
 
   int aa, l, slot_offset, slot_offsetF;
-  int32_t **txdataF    = eNB_common_vars->txdataF[eNB_id];
-  int32_t **txdataF_BF = eNB_common_vars->txdataF_BF[eNB_id];
-  int32_t **txdata     = eNB_common_vars->txdata[eNB_id];
+  int32_t **txdataF    = eNB_common_vars->txdataF;
+  int32_t **txdataF_BF = common->txdataF_BF;
+  int32_t **txdata     = common->txdata;
 
   slot_offset  = (next_slot)*(frame_parms->samples_per_tti>>1);
   slot_offsetF = (next_slot)*(frame_parms->ofdm_symbol_size)*((frame_parms->Ncp==EXTENDED) ? 6 : 7);
@@ -300,7 +301,7 @@ void do_OFDM_mod_symbol(LTE_eNB_COMMON *eNB_common_vars, int eNB_id, uint16_t ne
 
       //printf("do_OFDM_mod_l, slot=%d, l=%d, NUMBER_OF_OFDM_CARRIERS=%d,OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES=%d\n",next_slot, l,NUMBER_OF_OFDM_CARRIERS,OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES);
       VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_BEAM_PRECODING,1);
-      if (do_precoding==1) beam_precoding(txdataF,txdataF_BF,frame_parms,eNB_common_vars->beam_weights[eNB_id],next_slot,l,aa);
+      if (do_precoding==1) beam_precoding(txdataF,txdataF_BF,frame_parms,eNB_common_vars->beam_weights,next_slot,l,aa);
       VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_BEAM_PRECODING,0);
 
       //PMCH case not implemented... 
@@ -329,11 +330,12 @@ void do_OFDM_mod_symbol(LTE_eNB_COMMON *eNB_common_vars, int eNB_id, uint16_t ne
                        frame_parms->nb_prefix_samples,     // number of prefix samples
                        CYCLIC_PREFIX);
 
-          /* printf("txdata[%d][%d]=%d\n",aa,slot_offset+OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES0+(l-1)*OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES,txdata[aa][slot_offset+OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES0+(l-1)*OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES]);
- * */
+          //printf("txdata[%d][%d]=%d\n",aa,slot_offset+OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES0+(l-1)*OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES,txdata[aa][slot_offset+OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES0+(l-1)*OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES]);
+ 
         }
       }
     }
   }
 
 }
+*/
diff --git a/openair1/PHY/MODULATION/slot_fep_mbsfn.c b/openair1/PHY/MODULATION/slot_fep_mbsfn.c
index bead242dd8..471d311182 100644
--- a/openair1/PHY/MODULATION/slot_fep_mbsfn.c
+++ b/openair1/PHY/MODULATION/slot_fep_mbsfn.c
@@ -87,24 +87,24 @@ int slot_fep_mbsfn(PHY_VARS_UE *ue,
 
 
   if (l<0 || l>=12) {
-    msg("slot_fep_mbsfn: l must be between 0 and 11\n");
+    LOG_E(PHY,"slot_fep_mbsfn: l must be between 0 and 11\n");
     return(-1);
   }
 
   if (((subframe == 0) || (subframe == 5) ||    // SFn 0,4,5,9;
        (subframe == 4) || (subframe == 9))
       && (frame_type==FDD) )    {   //check for valid MBSFN subframe
-    msg("slot_fep_mbsfn: Subframe must be 1,2,3,6,7,8 for FDD, Got %d \n",subframe);
+    LOG_E(PHY,"slot_fep_mbsfn: Subframe must be 1,2,3,6,7,8 for FDD, Got %d \n",subframe);
     return(-1);
   } else if (((subframe == 0) || (subframe == 1) || (subframe==2) ||  // SFn 0,4,5,9;
               (subframe == 5) || (subframe == 6))
              && (frame_type==TDD) )   {   //check for valid MBSFN subframe
-    msg("slot_fep_mbsfn: Subframe must be 3,4,7,8,9 for TDD, Got %d \n",subframe);
+    LOG_E(PHY,"slot_fep_mbsfn: Subframe must be 3,4,7,8,9 for TDD, Got %d \n",subframe);
     return(-1);
   }
 
 #ifdef DEBUG_FEP
-  msg("slot_fep_mbsfn: subframe %d, symbol %d, nb_prefix_samples %d, nb_prefix_samples0 %d, subframe_offset %d, sample_offset %d\n", subframe, l, nb_prefix_samples,nb_prefix_samples0,subframe_offset,
+  LOG_D(PHY,"slot_fep_mbsfn: subframe %d, symbol %d, nb_prefix_samples %d, nb_prefix_samples0 %d, subframe_offset %d, sample_offset %d\n", subframe, l, nb_prefix_samples,nb_prefix_samples0,subframe_offset,
       sample_offset);
 #endif
 
@@ -147,7 +147,7 @@ int slot_fep_mbsfn(PHY_VARS_UE *ue,
     for (aa=0; aa<frame_parms->nb_antennas_tx; aa++) {
       if (ue->perfect_ce == 0) {
 #ifdef DEBUG_FEP
-        msg("Channel estimation eNB %d, aatx %d, subframe %d, symbol %d\n",eNB_id,aa,subframe,l);
+        LOG_D(PHY,"Channel estimation eNB %d, aatx %d, subframe %d, symbol %d\n",eNB_id,aa,subframe,l);
 #endif
 
         lte_dl_mbsfn_channel_estimation(ue,
@@ -177,7 +177,7 @@ int slot_fep_mbsfn(PHY_VARS_UE *ue,
         // do frequency offset estimation here!
         // use channel estimates from current symbol (=ch_t) and last symbol (ch_{t-1})
 #ifdef DEBUG_FEP
-        msg("Frequency offset estimation\n");
+        LOG_D(PHY,"Frequency offset estimation\n");
 #endif
         // if ((l == 0) || (l==(4-frame_parms->Ncp)))
         /*    if ((l==2)||(l==6)||(l==10))
@@ -190,7 +190,7 @@ int slot_fep_mbsfn(PHY_VARS_UE *ue,
   }
 
 #ifdef DEBUG_FEP
-  msg("slot_fep_mbsfn: done\n");
+  LOG_D(PHY,"slot_fep_mbsfn: done\n");
 #endif
   return(0);
 }
diff --git a/openair1/PHY/MODULATION/slot_fep_ul.c b/openair1/PHY/MODULATION/slot_fep_ul.c
index e05f5361de..e3da81788e 100644
--- a/openair1/PHY/MODULATION/slot_fep_ul.c
+++ b/openair1/PHY/MODULATION/slot_fep_ul.c
@@ -25,10 +25,9 @@
 //#define DEBUG_FEP
 
 int slot_fep_ul(LTE_DL_FRAME_PARMS *frame_parms,
-                LTE_eNB_COMMON *eNB_common_vars,
+                RU_COMMON *common,
                 unsigned char l,
                 unsigned char Ns,
-                unsigned char eNB_id,
                 int no_prefix)
 {
 #ifdef DEBUG_FEP
@@ -103,8 +102,8 @@ int slot_fep_ul(LTE_DL_FRAME_PARMS *frame_parms,
     rx_offset = slot_offset +nb_prefix_samples0;
     if (l==0) {
 
-      dft( (int16_t *)&eNB_common_vars->rxdata_7_5kHz[eNB_id][aa][rx_offset],
-           (int16_t *)&eNB_common_vars->rxdataF[eNB_id][aa][frame_parms->ofdm_symbol_size*symbol],
+      dft( (int16_t *)&common->rxdata_7_5kHz[aa][rx_offset],
+           (int16_t *)&common->rxdataF[aa][frame_parms->ofdm_symbol_size*symbol],
            1
          );
     } else {
@@ -113,8 +112,8 @@ int slot_fep_ul(LTE_DL_FRAME_PARMS *frame_parms,
       /* should never happen for eNB
       if(rx_offset > (frame_length_samples - frame_parms->ofdm_symbol_size))
       {
-        memcpy((void *)&eNB_common_vars->rxdata_7_5kHz[eNB_id][aa][frame_length_samples],
-               (void *)&eNB_common_vars->rxdata_7_5kHz[eNB_id][aa][0],
+        memcpy((void *)&eNB_common_vars->rxdata_7_5kHz[aa][frame_length_samples],
+               (void *)&eNB_common_vars->rxdata_7_5kHz[aa][0],
                frame_parms->ofdm_symbol_size*sizeof(int));
       }
       */
@@ -122,16 +121,16 @@ int slot_fep_ul(LTE_DL_FRAME_PARMS *frame_parms,
       // check for 256-bit alignment of input buffer and do DFT directly, else do via intermediate buffer
       if( (rx_offset & 15) != 0){
         memcpy((void *)&tmp_dft_in,
-	       (void *)&eNB_common_vars->rxdata_7_5kHz[eNB_id][aa][(rx_offset % frame_length_samples)],
+	       (void *)&common->rxdata_7_5kHz[aa][(rx_offset % frame_length_samples)],
 	       frame_parms->ofdm_symbol_size*sizeof(int));
         dft( (short *) tmp_dft_in,
-             (short*)  &eNB_common_vars->rxdataF[eNB_id][aa][frame_parms->ofdm_symbol_size*symbol],
+             (short*)  &common->rxdataF[aa][frame_parms->ofdm_symbol_size*symbol],
              1
            );
       }
       else{
-      dft( (short *)&eNB_common_vars->rxdata_7_5kHz[eNB_id][aa][rx_offset],
-           (short*)&eNB_common_vars->rxdataF[eNB_id][aa][frame_parms->ofdm_symbol_size*symbol],
+      dft( (short *)&common->rxdata_7_5kHz[aa][rx_offset],
+           (short*)&common->rxdataF[aa][frame_parms->ofdm_symbol_size*symbol],
            1
          );
       }
diff --git a/openair1/PHY/MODULATION/ul_7_5_kHz.c b/openair1/PHY/MODULATION/ul_7_5_kHz.c
index 21a3dc7c43..bcb18eb366 100644
--- a/openair1/PHY/MODULATION/ul_7_5_kHz.c
+++ b/openair1/PHY/MODULATION/ul_7_5_kHz.c
@@ -23,7 +23,6 @@
 #include "PHY/extern.h"
 #include "extern.h"
 #include "kHz_7_5.h"
-#include "prach625Hz.h"
 #ifdef USER_MODE
 #include <math.h>
 #else
@@ -140,12 +139,12 @@ void apply_7_5_kHz(PHY_VARS_UE *ue,int32_t*txdata,uint8_t slot)
 }
 
 
-void remove_7_5_kHz(PHY_VARS_eNB *eNB,uint8_t slot)
+void remove_7_5_kHz(RU_t *ru,uint8_t slot)
 {
 
 
-  int32_t **rxdata=eNB->common_vars.rxdata[0];
-  int32_t **rxdata_7_5kHz=eNB->common_vars.rxdata_7_5kHz[0];
+  int32_t **rxdata=ru->common.rxdata;
+  int32_t **rxdata_7_5kHz=ru->common.rxdata_7_5kHz;
   uint16_t len;
   uint32_t *kHz7_5ptr;
 #if defined(__x86_64__) || defined(__i386__)
@@ -159,7 +158,7 @@ void remove_7_5_kHz(PHY_VARS_eNB *eNB,uint8_t slot)
   uint32_t slot_offset,slot_offset2;
   uint8_t aa;
   uint32_t i;
-  LTE_DL_FRAME_PARMS *frame_parms=&eNB->frame_parms;
+  LTE_DL_FRAME_PARMS *frame_parms=&ru->frame_parms;
 
   switch (frame_parms->N_RB_UL) {
 
@@ -193,7 +192,7 @@ void remove_7_5_kHz(PHY_VARS_eNB *eNB,uint8_t slot)
   }
 
 
-  slot_offset = (uint32_t)slot * frame_parms->samples_per_tti/2-eNB->N_TA_offset;
+  slot_offset = (uint32_t)slot * frame_parms->samples_per_tti/2-ru->N_TA_offset;
   slot_offset2 = (uint32_t)(slot&1) * frame_parms->samples_per_tti/2;
 
   len = frame_parms->samples_per_tti/2;
diff --git a/openair1/PHY/defs.h b/openair1/PHY/defs.h
index 90d12f3dc1..0842050c1d 100644
--- a/openair1/PHY/defs.h
+++ b/openair1/PHY/defs.h
@@ -32,29 +32,34 @@
 #ifndef __PHY_DEFS__H__
 #define __PHY_DEFS__H__
 
+#define _GNU_SOURCE
+#include <sched.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <linux/sched.h>
+#include <signal.h>
+#include <execinfo.h>
+#include <getopt.h>
+#include <sys/sysinfo.h>
+
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <malloc.h>
 #include <string.h>
 #include <math.h>
 #include "common_lib.h"
+#include "msc.h"
 
 //#include <complex.h>
 #include "assertions.h"
 #ifdef MEX
 # define msg mexPrintf
-#else
-# ifdef OPENAIR2
-#   if ENABLE_RAL
-#     include "collection/hashtable/hashtable.h"
-#     include "COMMON/ral_messages_types.h"
-#     include "UTIL/queue.h"
-#   endif
-#   include "log.h"
-#   define msg(aRGS...) LOG_D(PHY, ##aRGS)
-# else
-#   define msg printf
-# endif
 #endif
 //use msg in the real-time thread context
 #define msg_nrt printf
@@ -72,13 +77,6 @@
 #define openair_free(y,x) free((y))
 #define PAGE_SIZE 4096
 
-//#ifdef SHRLIBDEV
-//extern int rxrescale;
-//#define RX_IQRESCALELEN rxrescale
-//#else
-//#define RX_IQRESCALELEN 15
-//#endif
-
 //! \brief Allocate \c size bytes of memory on the heap with alignment 16 and zero it afterwards.
 //! If no more memory is available, this function will terminate the program with an assertion error.
 static inline void* malloc16_clear( size_t size )
@@ -124,24 +122,68 @@ static inline void* malloc16_clear( size_t size )
 #include "PHY/TOOLS/defs.h"
 #include "platform_types.h"
 
-#ifdef OPENAIR_LTE
+#define MAX_NUM_RU_PER_eNB 64 
 
 #include "PHY/LTE_TRANSPORT/defs.h"
 #include <pthread.h>
 
 #include "targets/ARCH/COMMON/common_lib.h"
 
+#if defined(EXMIMO) || defined(OAI_USRP)
+#define NUMBER_OF_eNB_MAX 1
+#define NUMBER_OF_UE_MAX 16
+#define NUMBER_OF_RU_MAX 2
+#define NUMBER_OF_CONNECTED_eNB_MAX 3
+#else
+#ifdef LARGE_SCALE
+#define NUMBER_OF_eNB_MAX 2
+#define NUMBER_OF_UE_MAX 120
+#define NUMBER_OF_CONNECTED_eNB_MAX 1 // to save some memory
+#else
+#define NUMBER_OF_eNB_MAX 3
+#define NUMBER_OF_UE_MAX 16
+#define NUMBER_OF_RU_MAX 64
+#define NUMBER_OF_CONNECTED_eNB_MAX 1
+#endif
+#endif
+#define NUMBER_OF_SUBBANDS_MAX 13
+#define NUMBER_OF_HARQ_PID_MAX 8
+
+#define MAX_FRAME_NUMBER 0x400
+
+
+
+#define NUMBER_OF_RN_MAX 3
+typedef enum {no_relay=1,unicast_relay_type1,unicast_relay_type2, multicast_relay} relaying_type_t;
+
+
+
+#define MCS_COUNT 28
+#define MCS_TABLE_LENGTH_MAX 64
+
+
 #define NUM_DCI_MAX 32
 
 #define NUMBER_OF_eNB_SECTORS_MAX 3
 
 #define NB_BANDS_MAX 8
 
+#define MAX_BANDS_PER_RRU 4
+
+
 #ifdef OCP_FRAMEWORK
 #include <enums.h>
 #else
 typedef enum {normal_txrx=0,rx_calib_ue=1,rx_calib_ue_med=2,rx_calib_ue_byp=3,debug_prach=4,no_L2_connect=5,calib_prach_tx=6,rx_dump_frame=7,loop_through_memory=8} runmode_t;
 
+/*! \brief Extension Type */
+typedef enum {
+  CYCLIC_PREFIX,
+  CYCLIC_SUFFIX,
+  ZEROS,
+  NONE
+} Extension_t;
+	
 enum transmission_access_mode {
   NO_ACCESS=0,
   POSTPONED_ACCESS,
@@ -152,17 +194,18 @@ enum transmission_access_mode {
 
 typedef enum  {
   eNodeB_3GPP=0,   // classical eNodeB function
-  eNodeB_3GPP_BBU, // eNodeB with NGFI IF5
-  NGFI_RCC_IF4p5,  // NGFI_RCC (NGFI radio cloud center) 
-  NGFI_RAU_IF4p5,
+  NGFI_RAU_IF5,    // RAU with NGFI IF5
+  NGFI_RAU_IF4p5,  // RAU with NFGI IF4p5
   NGFI_RRU_IF5,    // NGFI_RRU (NGFI remote radio-unit,IF5)
-  NGFI_RRU_IF4p5   // NGFI_RRU (NGFI remote radio-unit,IF4p5) 
-} eNB_func_t;
+  NGFI_RRU_IF4p5,  // NGFI_RRU (NGFI remote radio-unit,IF4p5)
+  MBP_RRU_IF5      // Mobipass RRU
+} node_function_t;
 
 typedef enum {
   synch_to_ext_device=0,  // synch to RF or Ethernet device
-  synch_to_other          // synch to another source (timer, other RU)
-} RU_timing_t;
+  synch_to_other          // synch to another source_(timer, other RU)
+} node_timing_t;
+#endif
 
 typedef struct UE_SCAN_INFO_s {
   /// 10 best amplitudes (linear) for each pss signals
@@ -228,56 +271,104 @@ typedef struct {
   int G;
 } te_params;
 
-typedef struct pc_proc_t_s {
+typedef struct RU_proc_t_s {
+  /// Pointer to associated RU descriptor
+  struct RU_t_s *ru;
   /// timestamp received from HW
   openair0_timestamp timestamp_rx;
   /// timestamp to send to "slave rru"
   openair0_timestamp timestamp_tx;
   /// subframe to act upon for reception
   int subframe_rx;
+  /// subframe to act upon for transmission
+  int subframe_tx;
+  /// subframe to act upon for reception of prach
+  int subframe_prach;
   /// frame to act upon for reception
   int frame_rx;
+  /// frame to act upon for transmission
+  int frame_tx;
+  /// frame to act upon for reception of prach
+  int frame_prach;
+  /// frame offset for slave RUs (to correct for frame asynchronism at startup)
+  int frame_offset;
   /// \brief Instance count for FH processing thread.
   /// \internal This variable is protected by \ref mutex_FH.
   int instance_cnt_FH;
+  /// \internal This variable is protected by \ref mutex_prach.
+  int instance_cnt_prach;
+  /// \internal This variable is protected by \ref mutex_synch.
+  int instance_cnt_synch;
+  /// \internal This variable is protected by \ref mutex_eNBs.
+  int instance_cnt_eNBs;
   /// \brief Instance count for rx processing thread.
   /// \internal This variable is protected by \ref mutex_asynch_rxtx.
   int instance_cnt_asynch_rxtx;
-  /// pthread structure for FH processing thread
+  /// \internal This variable is protected by \ref mutex_fep
+  int instance_cnt_fep;
+  /// pthread structure for RU FH processing thread
   pthread_t pthread_FH;
-  /// pthread structure for eNB single processing thread
-  pthread_t pthread_single;
+  /// pthread structure for RU prach processing thread
+  pthread_t pthread_prach;
+  /// pthread struct for RU synch thread
+  pthread_t pthread_synch;
+  /// pthread struct for RU RX FEP thread
+  pthread_t pthread_fep;
   /// pthread structure for asychronous RX/TX processing thread
   pthread_t pthread_asynch_rxtx;
   /// flag to indicate first RX acquisition
   int first_rx;
   /// flag to indicate first TX transmission
   int first_tx;
-  /// pthread attributes for FH processing thread
+  /// pthread attributes for RU FH processing thread
   pthread_attr_t attr_FH;
-  /// pthread attributes for single eNB processing thread
-  pthread_attr_t attr_single;
+  /// pthread attributes for RU prach
+  pthread_attr_t attr_prach;
+  /// pthread attributes for RU synch thread
+  pthread_attr_t attr_synch;
   /// pthread attributes for asynchronous RX thread
   pthread_attr_t attr_asynch_rxtx;
-  /// scheduling parameters for FH thread
+  /// pthread attributes for parallel fep thread
+  pthread_attr_t attr_fep;
+  /// scheduling parameters for RU FH thread
   struct sched_param sched_param_FH;
-  /// scheduling parameters for single eNB thread
-  struct sched_param sched_param_single;
+  /// scheduling parameters for RU prach thread
+  struct sched_param sched_param_prach;
+  /// scheduling parameters for RU synch thread
+  struct sched_param sched_param_synch;
   /// scheduling parameters for asynch_rxtx thread
   struct sched_param sched_param_asynch_rxtx;
-  /// condition variable for FH thread
+  /// condition variable for RU FH thread
   pthread_cond_t cond_FH;
+  /// condition variable for RU prach thread
+  pthread_cond_t cond_prach;
+  /// condition variable for RU synch thread
+  pthread_cond_t cond_synch;
   /// condition variable for asynch RX/TX thread
   pthread_cond_t cond_asynch_rxtx;
-  /// mutex for FH
+  /// condition varaible for RU RX FEP thread
+  pthread_cond_t cond_fep;
+  /// condition variable for eNB signal
+  pthread_cond_t cond_eNBs;
+  /// mutex for RU FH
   pthread_mutex_t mutex_FH;
+  /// mutex for RU prach
+  pthread_mutex_t mutex_prach;
+  /// mutex for RU synch
+  pthread_mutex_t mutex_synch;
+  /// mutex for eNB signal
+  pthread_mutex_t mutex_eNBs;
   /// mutex for asynch RX/TX thread
   pthread_mutex_t mutex_asynch_rxtx;
+  /// mutex for fep RX
+  pthread_mutex_t mutex_fep;
+  /// symbol mask for IF4p5 reception per subframe
+  uint32_t symbol_mask[10];
   /// number of slave threads
   int                  num_slaves;
   /// array of pointers to slaves
-  struct pc_proc_t_s           **slave_proc;
-} pc_proc_t;
+  struct RU_proc_t_s           **slave_proc;
+} RU_proc_t;
 
 /// Context data structure for eNB subframe processing
 typedef struct eNB_proc_t_s {
@@ -291,27 +382,19 @@ typedef struct eNB_proc_t_s {
   openair0_timestamp timestamp_tx;
   /// subframe to act upon for reception
   int subframe_rx;
-  /// symbol mask for IF4p5 reception per subframe
-  uint32_t symbol_mask[10];
   /// subframe to act upon for PRACH
   int subframe_prach;
   /// frame to act upon for reception
   int frame_rx;
   /// frame to act upon for transmission
   int frame_tx;
-  /// frame offset for secondary eNBs (to correct for frame asynchronism at startup)
-  int frame_offset;
   /// frame to act upon for PRACH
   int frame_prach;
-  /// \internal This variable is protected by \ref mutex_fep.
-  int instance_cnt_fep;
   /// \internal This variable is protected by \ref mutex_td.
   int instance_cnt_td;
   /// \internal This variable is protected by \ref mutex_te.
   int instance_cnt_te;
   /// \brief Instance count for FH processing thread.
-  /// \internal This variable is protected by \ref mutex_FH.
-  int instance_cnt_FH;
   /// \brief Instance count for rx processing thread.
   /// \internal This variable is protected by \ref mutex_prach.
   int instance_cnt_prach;
@@ -319,8 +402,6 @@ typedef struct eNB_proc_t_s {
   int instance_cnt_synch;
   /// \internal This variable is protected by \ref mutex_asynch_rxtx.
   int instance_cnt_asynch_rxtx;
-  /// pthread structure for FH processing thread
-  pthread_t pthread_FH;
   /// pthread structure for eNB single processing thread
   pthread_t pthread_single;
   /// pthread structure for asychronous RX/TX processing thread
@@ -329,74 +410,46 @@ typedef struct eNB_proc_t_s {
   int first_rx;
   /// flag to indicate first TX transmission
   int first_tx;
-  /// pthread attributes for parallel fep thread
-  pthread_attr_t attr_fep;
   /// pthread attributes for parallel turbo-decoder thread
   pthread_attr_t attr_td;
   /// pthread attributes for parallel turbo-encoder thread
   pthread_attr_t attr_te;
-  /// pthread attributes for FH processing thread
-  pthread_attr_t attr_FH;
   /// pthread attributes for single eNB processing thread
   pthread_attr_t attr_single;
   /// pthread attributes for prach processing thread
   pthread_attr_t attr_prach;
-  /// pthread attributes for over-the-air synch thread
-  pthread_attr_t attr_synch;
   /// pthread attributes for asynchronous RX thread
   pthread_attr_t attr_asynch_rxtx;
-  /// scheduling parameters for parallel fep thread
-  struct sched_param sched_param_fep;
   /// scheduling parameters for parallel turbo-decoder thread
   struct sched_param sched_param_td;
   /// scheduling parameters for parallel turbo-encoder thread
   struct sched_param sched_param_te;
-  /// scheduling parameters for FH thread
-  struct sched_param sched_param_FH;
   /// scheduling parameters for single eNB thread
   struct sched_param sched_param_single;
   /// scheduling parameters for prach thread
   struct sched_param sched_param_prach;
-  /// scheduling parameters for over-the-air synchronization thread
-  struct sched_param sched_param_synch;
   /// scheduling parameters for asynch_rxtx thread
   struct sched_param sched_param_asynch_rxtx;
-  /// pthread structure for parallel fep thread
-  pthread_t pthread_fep;
   /// pthread structure for parallel turbo-decoder thread
   pthread_t pthread_td;
   /// pthread structure for parallel turbo-encoder thread
   pthread_t pthread_te;
   /// pthread structure for PRACH thread
   pthread_t pthread_prach;
-  /// pthread structure for eNB synch thread
-  pthread_t pthread_synch;
-  /// condition variable for parallel fep thread
-  pthread_cond_t cond_fep;
   /// condition variable for parallel turbo-decoder thread
   pthread_cond_t cond_td;
   /// condition variable for parallel turbo-encoder thread
   pthread_cond_t cond_te;
-  /// condition variable for FH thread
-  pthread_cond_t cond_FH;
   /// condition variable for PRACH processing thread;
   pthread_cond_t cond_prach;
-  // condition variable for over-the-air eNB synchronization
-  pthread_cond_t cond_synch;
   /// condition variable for asynch RX/TX thread
   pthread_cond_t cond_asynch_rxtx;
-  /// mutex for parallel fep thread
-  pthread_mutex_t mutex_fep;
   /// mutex for parallel turbo-decoder thread
   pthread_mutex_t mutex_td;
   /// mutex for parallel turbo-encoder thread
   pthread_mutex_t mutex_te;
-  /// mutex for FH
-  pthread_mutex_t mutex_FH;
   /// mutex for PRACH thread
   pthread_mutex_t mutex_prach;
-  // mutex for over-the-air eNB synchronization
-  pthread_mutex_t mutex_synch;
   /// mutex for asynch RX/TX thread
   pthread_mutex_t mutex_asynch_rxtx;
   /// parameters for turbo-decoding worker thread
@@ -405,10 +458,6 @@ typedef struct eNB_proc_t_s {
   te_params tep;
   /// set of scheduling variables RXn-TXnp4 threads
   eNB_rxtx_proc_t proc_rxtx[2];
-  /// number of slave threads
-  int                  num_slaves;
-  /// array of pointers to slaves
-  struct eNB_proc_t_s           **slave_proc;
 } eNB_proc_t;
 
 
@@ -468,36 +517,291 @@ typedef struct {
   pthread_cond_t cond_synch;
   /// mutex for UE synch thread
   pthread_mutex_t mutex_synch;
+  /// instance count for eNBs
+  int instance_cnt_eNBs;
   /// set of scheduling variables RXn-TXnp4 threads
   UE_rxtx_proc_t proc_rxtx[2];
 } UE_proc_t;
 
+typedef enum {
+  LOCAL_RF        =0,
+  REMOTE_IF5      =1,
+  REMOTE_MBP_IF5  =2,
+  REMOTE_IF4p5    =3,
+  MAX_RU_IF_TYPES =4
+} RU_if_south_t;
+
+typedef struct RU_t_s{
+  /// index of this ru
+  uint32_t idx;
+  /// southbound interface
+  RU_if_south_t if_south;
+  /// timing
+  node_timing_t if_timing;
+  /// function
+  node_function_t function;
+  /// Ethernet parameters for fronthaul interface
+  eth_params_t eth_params;
+  /// flag to indicate the RU is in synch with a master reference
+  int in_synch;
+  /// timing offset
+  int rx_offset;        
+  /// flag to indicate the RU is a slave to another source
+  int is_slave;
+  /// Total gain of receive chain
+  uint32_t             rx_total_gain_dB;
+  /// number of bands that this device can support
+  int num_bands;
+  /// band list
+  int band[MAX_BANDS_PER_RRU];
+  /// number of RX paths on device
+  int nb_rx;
+  /// number of TX paths on device
+  int nb_tx;
+  /// maximum PDSCH RS EPRE
+  int max_pdschReferenceSignalPower;
+  /// maximum RX gain
+  int max_rxgain;
+  /// Attenuation of RX paths on device
+  int att_rx;
+  /// Attenuation of TX paths on device
+  int att_tx;
+  /// flag to indicate precoding operation in RU
+  int do_precoding;
+  /// Frame parameters
+  LTE_DL_FRAME_PARMS frame_parms;
+  ///timing offset used in TDD
+  int              N_TA_offset; 
+  /// RF device descriptor
+  openair0_device rfdevice;
+  /// HW configuration
+  openair0_config_t openair0_cfg;
+  /// Number of eNBs using this RU
+  int num_eNB;
+  /// list of eNBs using this RU
+  struct PHY_VARS_eNB_s *eNB_list[NUMBER_OF_eNB_MAX];
+  /// Mapping of antenna ports to RF chain index
+  openair0_rf_map      rf_map;
+  /// IF device descriptor
+  openair0_device ifdevice;
+  /// Pointer for ifdevice buffer struct
+  if_buffer_t ifbuffer;
+  /// if prach processing is to be performed in RU
+  int                  do_prach;
+  /// function pointer to synchronous RX fronthaul function (RRU,3GPP_eNB)
+  void                 (*fh_south_in)(struct RU_t_s *ru,int *frame, int *subframe);
+  /// function pointer to synchronous TX fronthaul function
+  void                 (*fh_south_out)(struct RU_t_s *ru);
+  /// function pointer to synchronous RX fronthaul function (RRU)
+  void                 (*fh_north_in)(struct RU_t_s *ru,int *frame, int *subframe);
+  /// function pointer to synchronous RX fronthaul function (RRU)
+  void                 (*fh_north_out)(struct RU_t_s *ru);
+  /// function pointer to asynchronous fronthaul interface
+  void                 (*fh_north_asynch_in)(struct RU_t_s *ru,int *frame, int *subframe);
+  /// function pointer to asynchronous fronthaul interface
+  void                 (*fh_south_asynch_in)(struct RU_t_s *ru,int *frame, int *subframe);
+  /// function pointer to initialization function for radio interface
+  int                  (*start_rf)(struct RU_t_s *ru);
+  /// function pointer to initialization function for radio interface
+  int                  (*start_if)(struct RU_t_s *ru,struct PHY_VARS_eNB_s *eNB);
+  /// function pointer to RX front-end processing routine (DFTs/prefix removal or NULL)
+  void                 (*feprx)(struct RU_t_s *ru);
+  /// function pointer to TX front-end processing routine (IDFTs and prefix removal or NULL)
+  void                 (*feptx_ofdm)(struct RU_t_s *ru);
+  /// function pointer to TX front-end processing routine (PRECODING)
+  void                 (*feptx_prec)(struct RU_t_s *ru);
+  /// function pointer to wakeup routine in lte-enb.
+  int (*wakeup_rxtx)(struct PHY_VARS_eNB_s *eNB,int frame_rx,int subframe_rx);
+  /// function pointer to eNB entry routine
+  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;
+  /// RX and TX buffers for precoder output
+  RU_COMMON            common;
+  /// beamforming weight vectors per eNB
+  int32_t **beam_weights[NUMBER_OF_eNB_MAX][15];
+
+  /// received frequency-domain signal for PRACH (IF4p5 RRU) 
+  int16_t              **prach_rxsigF;
+  /// sequence number for IF5
+  uint8_t seqno;
+  /// initial timestamp used as an offset make first real timestamp 0
+  openair0_timestamp   ts_offset;
+  /// process scheduling variables
+  RU_proc_t            proc;
+} RU_t;
+
+
+typedef struct {
+  //unsigned int   rx_power[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX];     //! estimated received signal power (linear)
+  //unsigned short rx_power_dB[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX];  //! estimated received signal power (dB)
+  //unsigned short rx_avg_power_dB[NUMBER_OF_CONNECTED_eNB_MAX];              //! estimated avg received signal power (dB)
+
+  // RRC measurements
+  uint32_t rssi;
+  int n_adj_cells;
+  unsigned int adj_cell_id[6];
+  uint32_t rsrq[7];
+  uint32_t rsrp[7];
+  float rsrp_filtered[7]; // after layer 3 filtering
+  float rsrq_filtered[7];
+  // common measurements
+  //! estimated noise power (linear)
+  unsigned int   n0_power[NB_ANTENNAS_RX];
+  //! estimated noise power (dB)
+  unsigned short n0_power_dB[NB_ANTENNAS_RX];
+  //! total estimated noise power (linear)
+  unsigned int   n0_power_tot;
+  //! total estimated noise power (dB)
+  unsigned short n0_power_tot_dB;
+  //! average estimated noise power (linear)
+  unsigned int   n0_power_avg;
+  //! average estimated noise power (dB)
+  unsigned short n0_power_avg_dB;
+  //! total estimated noise power (dBm)
+  short n0_power_tot_dBm;
+
+  // UE measurements
+  //! estimated received spatial signal power (linear)
+  int            rx_spatial_power[NUMBER_OF_CONNECTED_eNB_MAX][2][2];
+  //! estimated received spatial signal power (dB)
+  unsigned short rx_spatial_power_dB[NUMBER_OF_CONNECTED_eNB_MAX][2][2];
+
+  /// estimated received signal power (sum over all TX antennas)
+  //int            wideband_cqi[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX];
+  int            rx_power[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX];
+  /// estimated received signal power (sum over all TX antennas)
+  //int            wideband_cqi_dB[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX];
+  unsigned short rx_power_dB[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX];
+
+  /// estimated received signal power (sum over all TX/RX antennas)
+  int            rx_power_tot[NUMBER_OF_CONNECTED_eNB_MAX]; //NEW
+  /// estimated received signal power (sum over all TX/RX antennas)
+  unsigned short rx_power_tot_dB[NUMBER_OF_CONNECTED_eNB_MAX]; //NEW
+
+  //! estimated received signal power (sum of all TX/RX antennas, time average)
+  int            rx_power_avg[NUMBER_OF_CONNECTED_eNB_MAX];
+  //! estimated received signal power (sum of all TX/RX antennas, time average, in dB)
+  unsigned short rx_power_avg_dB[NUMBER_OF_CONNECTED_eNB_MAX];
+
+  /// SINR (sum of all TX/RX antennas, in dB)
+  int            wideband_cqi_tot[NUMBER_OF_CONNECTED_eNB_MAX];
+  /// SINR (sum of all TX/RX antennas, time average, in dB)
+  int            wideband_cqi_avg[NUMBER_OF_CONNECTED_eNB_MAX];
+
+  //! estimated rssi (dBm)
+  short          rx_rssi_dBm[NUMBER_OF_CONNECTED_eNB_MAX];
+  //! estimated correlation (wideband linear) between spatial channels (computed in dlsch_demodulation)
+  int            rx_correlation[NUMBER_OF_CONNECTED_eNB_MAX][2];
+  //! estimated correlation (wideband dB) between spatial channels (computed in dlsch_demodulation)
+  int            rx_correlation_dB[NUMBER_OF_CONNECTED_eNB_MAX][2];
+
+  /// Wideband CQI (sum of all RX antennas, in dB, for precoded transmission modes (3,4,5,6), up to 4 spatial streams)
+  int            precoded_cqi_dB[NUMBER_OF_CONNECTED_eNB_MAX+1][4];
+  /// Subband CQI per RX antenna (= SINR)
+  int            subband_cqi[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX][NUMBER_OF_SUBBANDS_MAX];
+  /// Total Subband CQI  (= SINR)
+  int            subband_cqi_tot[NUMBER_OF_CONNECTED_eNB_MAX][NUMBER_OF_SUBBANDS_MAX];
+  /// Subband CQI in dB (= SINR dB)
+  int            subband_cqi_dB[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX][NUMBER_OF_SUBBANDS_MAX];
+  /// Total Subband CQI
+  int            subband_cqi_tot_dB[NUMBER_OF_CONNECTED_eNB_MAX][NUMBER_OF_SUBBANDS_MAX];
+  /// Wideband PMI for each RX antenna
+  int            wideband_pmi_re[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX];
+  /// Wideband PMI for each RX antenna
+  int            wideband_pmi_im[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX];
+  ///Subband PMI for each RX antenna
+  int            subband_pmi_re[NUMBER_OF_CONNECTED_eNB_MAX][NUMBER_OF_SUBBANDS_MAX][NB_ANTENNAS_RX];
+  ///Subband PMI for each RX antenna
+  int            subband_pmi_im[NUMBER_OF_CONNECTED_eNB_MAX][NUMBER_OF_SUBBANDS_MAX][NB_ANTENNAS_RX];
+  /// chosen RX antennas (1=Rx antenna 1, 2=Rx antenna 2, 3=both Rx antennas)
+  unsigned char           selected_rx_antennas[NUMBER_OF_CONNECTED_eNB_MAX][NUMBER_OF_SUBBANDS_MAX];
+  /// Wideband Rank indication
+  unsigned char  rank[NUMBER_OF_CONNECTED_eNB_MAX];
+  /// Number of RX Antennas
+  unsigned char  nb_antennas_rx;
+  /// DLSCH error counter
+  // short          dlsch_errors;
+
+} PHY_MEASUREMENTS;
+
+typedef struct {
+  //unsigned int   rx_power[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX];     //! estimated received signal power (linear)
+  //unsigned short rx_power_dB[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX];  //! estimated received signal power (dB)
+  //unsigned short rx_avg_power_dB[NUMBER_OF_CONNECTED_eNB_MAX];              //! estimated avg received signal power (dB)
+
+  // common measurements
+  //! estimated noise power (linear)
+  unsigned int   n0_power[MAX_NUM_RU_PER_eNB];
+  //! estimated noise power (dB)
+  unsigned short n0_power_dB[MAX_NUM_RU_PER_eNB];
+  //! total estimated noise power (linear)
+  unsigned int   n0_power_tot;
+  //! estimated avg noise power (dB)
+  unsigned short n0_power_tot_dB;
+  //! estimated avg noise power (dB)
+  short n0_power_tot_dBm;
+  //! estimated avg noise power per RB per RX ant (lin)
+  unsigned short n0_subband_power[MAX_NUM_RU_PER_eNB][100];
+  //! estimated avg noise power per RB per RX ant (dB)
+  unsigned short n0_subband_power_dB[MAX_NUM_RU_PER_eNB][100];
+  //! estimated avg noise power per RB (dB)
+  short n0_subband_power_tot_dB[100];
+  //! estimated avg noise power per RB (dBm)
+  short n0_subband_power_tot_dBm[100];
+  // eNB measurements (per user)
+  //! estimated received spatial signal power (linear)
+  unsigned int   rx_spatial_power[NUMBER_OF_UE_MAX][2][2];
+  //! estimated received spatial signal power (dB)
+  unsigned short rx_spatial_power_dB[NUMBER_OF_UE_MAX][2][2];
+  //! estimated rssi (dBm)
+  short          rx_rssi_dBm[NUMBER_OF_UE_MAX];
+  //! estimated correlation (wideband linear) between spatial channels (computed in dlsch_demodulation)
+  int            rx_correlation[NUMBER_OF_UE_MAX][2];
+  //! estimated correlation (wideband dB) between spatial channels (computed in dlsch_demodulation)
+  int            rx_correlation_dB[NUMBER_OF_UE_MAX][2];
+
+  /// Wideband CQI (= SINR)
+  int            wideband_cqi[NUMBER_OF_UE_MAX][MAX_NUM_RU_PER_eNB];
+  /// Wideband CQI in dB (= SINR dB)
+  int            wideband_cqi_dB[NUMBER_OF_UE_MAX][MAX_NUM_RU_PER_eNB];
+  /// Wideband CQI (sum of all RX antennas, in dB)
+  char           wideband_cqi_tot[NUMBER_OF_UE_MAX];
+  /// Subband CQI per RX antenna and RB (= SINR)
+  int            subband_cqi[NUMBER_OF_UE_MAX][MAX_NUM_RU_PER_eNB][100];
+  /// Total Subband CQI and RB (= SINR)
+  int            subband_cqi_tot[NUMBER_OF_UE_MAX][100];
+  /// Subband CQI in dB and RB (= SINR dB)
+  int            subband_cqi_dB[NUMBER_OF_UE_MAX][MAX_NUM_RU_PER_eNB][100];
+  /// Total Subband CQI and RB
+  int            subband_cqi_tot_dB[NUMBER_OF_UE_MAX][100];
+
+} PHY_MEASUREMENTS_eNB;
+
+
 /// Top-level PHY Data Structure for eNB
 typedef struct PHY_VARS_eNB_s {
   /// Module ID indicator for this instance
   module_id_t          Mod_id;
   uint8_t              CC_id;
   eNB_proc_t           proc;
-  eNB_func_t           node_function;
-  eNB_timing_t         node_timing;
-  eth_params_t         *eth_params;
   int                  single_thread_flag;
-  openair0_rf_map      rf_map;
   int                  abstraction_flag;
-  openair0_timestamp   ts_offset;
-  void                 (*do_prach)(struct PHY_VARS_eNB_s *eNB);
+  int                  num_RU;
+  RU_t                 *RU_list[MAX_NUM_RU_PER_eNB];
+  int                  rx_total_gain_dB;
+  //  void                 (*do_prach)(struct PHY_VARS_eNB_s *eNB,struct RU_t_s *ru,int frame, int subframe);
   int                  (*td)(struct PHY_VARS_eNB_s *eNB,int UE_id,int harq_pid,int llr8_flag);
   int                  (*te)(struct PHY_VARS_eNB_s *,uint8_t *,uint8_t,LTE_eNB_DLSCH_t *,int,uint8_t,time_stats_t *,time_stats_t *,time_stats_t *);
-  void                 (*proc_uespec_rx)(struct PHY_VARS_eNB_s *eNB,eNB_rxtx_proc_t *proc,const relaying_type_t r_type);
-  void                 (*proc_tx)(struct PHY_VARS_eNB_s *eNB,eNB_rxtx_proc_t *proc,relaying_type_t r_type,PHY_VARS_RN *rn);
-  void                 (*tx_fh)(struct PHY_VARS_eNB_s *eNB,eNB_rxtx_proc_t *proc);
-  void                 (*rx_fh)(struct PHY_VARS_eNB_s *eNB,int *frame, int *subframe);
-  int                  (*start_if)(struct PHY_VARS_eNB_s *eNB);
-  void                 (*fh_asynch)(struct PHY_VARS_eNB_s *eNB,int *frame, int *subframe);
+  //  void                 (*proc_uespec_rx)(struct PHY_VARS_eNB_s *eNB,eNB_rxtx_proc_t *proc,const relaying_type_t r_type);
+  //  void                 (*proc_tx)(struct PHY_VARS_eNB_s *eNB,eNB_rxtx_proc_t *proc,relaying_type_t r_type,PHY_VARS_RN *rn);
+  //  void                 (*tx_fh)(struct PHY_VARS_eNB_s *eNB,eNB_rxtx_proc_t *proc);
+  //  void                 (*rx_fh)(struct PHY_VARS_eNB_s *eNB,int *frame, int *subframe);
+  int                  (*start_if)(struct RU_t_s *ru,struct PHY_VARS_eNB_s *eNB);
+  //  void                 (*fh_asynch)(struct PHY_VARS_eNB_s *eNB,int *frame, int *subframe);
   uint8_t              local_flag;
-  uint32_t             rx_total_gain_dB;
   LTE_DL_FRAME_PARMS   frame_parms;
-  PHY_MEASUREMENTS_eNB measurements[NUMBER_OF_eNB_SECTORS_MAX]; /// Measurement variables
+  PHY_MEASUREMENTS_eNB measurements; 
   LTE_eNB_COMMON       common_vars;
   LTE_eNB_SRS          srs_vars[NUMBER_OF_UE_MAX];
   LTE_eNB_PBCH         pbch;
@@ -533,8 +837,6 @@ typedef struct PHY_VARS_eNB_s {
   uint32_t max_peak_val;
   int max_eNB_id, max_sync_pos;
 
-  int              N_TA_offset; ///timing offset used in TDD
-
   /// \brief sinr for all subcarriers of the current link (used only for abstraction).
   /// first index: ? [0..N_RB_DL*12[
   double *sinr_dB;
@@ -545,13 +847,11 @@ typedef struct PHY_VARS_eNB_s {
   unsigned char first_run_timing_advance[NUMBER_OF_UE_MAX];
   unsigned char first_run_I0_measurements;
 
-  unsigned char cooperation_flag; // for cooperative communication
-
+  
   unsigned char    is_secondary_eNB; // primary by default
   unsigned char    is_init_sync;     /// Flag to tell if initial synchronization is performed. This affects how often the secondary eNB will listen to the PSS from the primary system.
   unsigned char    has_valid_precoder; /// Flag to tell if secondary eNB has channel estimates to create NULL-beams from, and this B/F vector is created.
   unsigned char    PeNB_id;          /// id of Primary eNB
-  int              rx_offset;        /// Timing offset (used if is_secondary_eNB)
 
   /// hold the precoder for NULL beam to the primary user
   int              **dl_precoder_SeNB[3];
@@ -649,7 +949,6 @@ typedef struct PHY_VARS_eNB_s {
   time_stats_t dlsch_turbo_encoding_stats;
   time_stats_t dlsch_interleaving_stats;
 
-  time_stats_t ofdm_demod_stats;
   time_stats_t rx_dft_stats;
   time_stats_t ulsch_channel_estimation_stats;
   time_stats_t ulsch_freq_offset_estimation_stats;
@@ -945,66 +1244,34 @@ typedef struct {
   openair0_device rfdevice; 
 } PHY_VARS_UE;
 
-typedef enum {
-  LOCAL_RF=0,
-  REMOTE_IF5=1,
-  REMOTE_IF4p5=2,
-  REMOTE_IF1pp=3,
-  MAX_RU_IF_TYPES=4
-} RU_if_in_t;
 
-typedef struct {
 
-  /// input interface
-  RU_if_in_t RU_if_in;
-  /// timing
-  RU_if_timing_t RU_if_timing;
-  /// number of RX paths on device
-  int nb_rx;
-  /// number of TX paths on device
-  int nb_tx;
-  /// Radio Unit device descriptor
-  openair0_device rudevice;
-  /// Pointer for ifdevice buffer struct
-  if_buffer_t ifbuffer;
-} RU_desc_t;
 
-typedef struct PRECODER_t_s{
-  /// pointer to RAN context governing this precoder
-  RAN_CONTEXT *RC;
-  /// function pointer to synchronous TX fronthaul function
-  void                 (*tx_fh)(PRECODER_t_s *pc);
-  /// function pointer to synchronous RX fronthaul function
-  void                 (*rx_fh)(PRECODER_t_s *pc,int *frame, int *subframe);
-  /// function pointer to asynchronous fronthaul interface
-  void                 (*fh_asynch)(struct PRECODER_t_s *pc,int *frame, int *subframe);
-  /// function pointer to initialization function for radio interface
-  int                  (*start_rf)(struct PRECODER_t_s *pc);
-  /// function pointer to RX front-end processing routine (DFTs/prefix removal or NULL)
-  void                 (*fep_rx)(struct PRECODER_t_s *pc);
-  /// function pointer to TX front-end processing routine (PRECODING and/or IDFTs and prefix removal or NULL)
-  void                 (*fep_tx)(struct PRECODER_t_s *pc);
-  /// RX and TX buffers for precoder output
-  RU_TIME              ru_time;
-} PRECODER_t;
 
-typedef struct {
-  /// Number of eNB instances in this node
-  int nb_inst;
-  /// Number of Component Carriers per instance in this node
-  int *nb_CC;
-  /// Number of radio units
-  int nb_RU;
-  /// eNB context variables
-  PHY_VARS_eNB **eNB;
-  /// RU descriptors
-  RU_desc_t *ru_desc;
-  /// Precoding descriptor per radio unit. This describes what each radio unit is supposed to do and contains the necessary functions for fronthaul interfaces
-  PRECODER_t *pc;
-} RAN_CONTEXT_t;
 
 void exit_fun(const char* s);
 
+#include "UTIL/LOG/log_extern.h"
+extern pthread_cond_t sync_cond;
+extern pthread_mutex_t sync_mutex;
+extern int sync_var;
+
+
+
+static inline void wait_sync(char *thread_name) {
+
+  printf( "waiting for sync (%s)\n",thread_name);
+  pthread_mutex_lock( &sync_mutex );
+  
+  while (sync_var<0)
+    pthread_cond_wait( &sync_cond, &sync_mutex );
+  
+  pthread_mutex_unlock(&sync_mutex);
+  
+  printf( "got sync (%s)\n", thread_name);
+
+}
+
 static inline int wait_on_condition(pthread_mutex_t *mutex,pthread_cond_t *cond,int *instance_cnt,char *name) {
   if (pthread_mutex_lock(mutex) != 0) {
     LOG_E( PHY, "[SCHED][eNB] error locking mutex for %s\n",name);
@@ -1074,5 +1341,4 @@ static inline int release_thread(pthread_mutex_t *mutex,int *instance_cnt,char *
 #include "PHY/LTE_ESTIMATION/defs.h"
 
 #include "SIMULATION/ETH_TRANSPORT/defs.h"
-#endif
 #endif //  __PHY_DEFS__H__
diff --git a/openair1/PHY/extern.h b/openair1/PHY/extern.h
index 0eb5dc6c97..a9ed9e275f 100644
--- a/openair1/PHY/extern.h
+++ b/openair1/PHY/extern.h
@@ -24,6 +24,7 @@
 
 #include "PHY/defs.h"
 #include "PHY_INTERFACE/defs.h"
+#include "common/ran_context.h"
 
 extern  char* namepointer_chMag ;
 extern char* namepointer_log2;
@@ -38,11 +39,11 @@ extern unsigned int TX_DMA_BUFFER[4][NB_ANTENNAS_TX];
 extern unsigned int DAQ_MBOX;
 extern int number_of_cards;
 
-//extern PHY_CONFIG *PHY_config;
-//extern PHY_VARS *PHY_vars;
+
 #ifndef OCP_FRAMEWORK
 extern PHY_VARS_UE ***PHY_vars_UE_g;
-extern PHY_VARS_eNB ***PHY_vars_eNB_g;
+//extern PHY_VARS_eNB ***PHY_vars_eNB_g;
+extern RAN_CONTEXT_t RC;
 extern PHY_VARS_RN **PHY_vars_RN_g;
 extern LTE_DL_FRAME_PARMS *lte_frame_parms_g;
 #else
@@ -75,6 +76,7 @@ extern char mode_string[4][20];
 
 #include "PHY/LTE_TRANSPORT/extern.h"
 
+extern unsigned char NB_RU;
 
 #ifndef OPENAIR2
 extern unsigned char NB_eNB_INST;
@@ -112,7 +114,7 @@ extern double beta2_dlsch[6][MCS_COUNT];
 
 extern char eNB_functions[6][20];
 extern char eNB_timing[2][20];
-
+extern char ru_if_types[MAX_RU_IF_TYPES][20];
 
 extern int16_t unscrambling_lut[65536*16];
 extern uint8_t scrambling_lut[65536*16];
diff --git a/openair1/PHY/impl_defs_lte.h b/openair1/PHY/impl_defs_lte.h
index 031b67500d..9cd283c021 100644
--- a/openair1/PHY/impl_defs_lte.h
+++ b/openair1/PHY/impl_defs_lte.h
@@ -484,6 +484,16 @@ typedef struct {
   uint8_t N_RB_DL;
   /// Number of resource blocks (RB) in UL
   uint8_t N_RB_UL;
+  /// EUTRA Band
+  uint8_t eutra_band;
+  /// DL carrier frequency
+  uint32_t dl_CarrierFreq;
+  /// UL carrier frequency
+  uint32_t ul_CarrierFreq;
+  /// TX attenuation
+  uint32_t att_tx;
+  /// RX attenuation
+  uint32_t att_rx;
   ///  total Number of Resource Block Groups: this is ceil(N_PRB/P)
   uint8_t N_RBG;
   /// Total Number of Resource Block Groups SubSets: this is P
@@ -508,28 +518,6 @@ typedef struct {
   uint8_t srsX;
   /// indicates if node is a UE (NODE=2) or eNB (PRIMARY_CH=0).
   uint8_t node_id;
-  /// Frequency index of CBMIMO1 card
-  uint8_t freq_idx;
-  /// RX Frequency for ExpressMIMO/LIME
-  uint32_t carrier_freq[4];
-  /// TX Frequency for ExpressMIMO/LIME
-  uint32_t carrier_freqtx[4];
-  /// RX gain for ExpressMIMO/LIME
-  uint32_t rxgain[4];
-  /// TX gain for ExpressMIMO/LIME
-  uint32_t txgain[4];
-  /// RF mode for ExpressMIMO/LIME
-  uint32_t rfmode[4];
-  /// RF RX DC Calibration for ExpressMIMO/LIME
-  uint32_t rxdc[4];
-  /// RF TX DC Calibration for ExpressMIMO/LIME
-  uint32_t rflocal[4];
-  /// RF VCO calibration for ExpressMIMO/LIME
-  uint32_t rfvcolocal[4];
-  /// Turns on second TX of CBMIMO1 card
-  uint8_t dual_tx;
-  /// flag to indicate SISO transmission
-  uint8_t mode1_flag;
   /// Indicator that 20 MHz channel uses 3/4 sampling frequency
   uint8_t threequarter_fs;
   /// Size of FFT
@@ -623,12 +611,25 @@ typedef enum {
 } PRECODE_TYPE_t;
 
 typedef struct {
+  /// \brief Pointers (dynamic) to the received data in the time domain.
+  /// - first index: rx antenna [0..nb_antennas_rx[
+  /// - second index: ? [0..2*ofdm_symbol_size*frame_parms->symbols_per_tti[
+  int32_t **rxdata;
+  /// \brief Pointers (dynamic) to the received data in the frequency domain.
+  /// - first index: rx antenna [0..nb_antennas_rx[
+  /// - second index: ? [0..2*ofdm_symbol_size*frame_parms->symbols_per_tti[
+  int32_t **rxdataF;
   /// \brief holds the transmit data in the frequency domain.
   /// For IFFT_FPGA this points to the same memory as PHY_vars->rx_vars[a].RX_DMA_BUFFER. //?
   /// - first index: eNB id [0..2] (hard coded)
   /// - second index: tx antenna [0..14[ where 14 is the total supported antenna ports.
   /// - third index: sample [0..]
   int32_t **txdataF;
+  /// \brief Holds the beamforming weights
+  /// - first index: eNB id [0..2] (hard coded)
+  /// - second index: eNB antenna port index (hard coded)
+  /// - third index: tx antenna [0..nb_antennas_tx[
+  /// - fourth index: sample [0..]
 } LTE_eNB_COMMON;
 
 typedef struct {
@@ -637,10 +638,8 @@ typedef struct {
   /// - second index: ? [0..2*ofdm_symbol_size*frame_parms->symbols_per_tti[
   int32_t **txdata;
   /// \brief holds the transmit data after beamforming in the frequency domain.
-  /// For IFFT_FPGA this points to the same memory as PHY_vars->rx_vars[a].RX_DMA_BUFFER. //?
-  /// - first index: eNB id [0..2] (hard coded)
-  /// - second index: tx antenna [0..nb_antennas_tx[
-  /// - third index: sample [0..]
+  /// - first index: tx antenna [0..nb_antennas_tx[
+  /// - second index: sample [0..]
   int32_t **txdataF_BF;
   /// \brief Holds the receive data in the frequency domain.
   /// - first index: rx antenna [0..nb_antennas_rx[
@@ -656,13 +655,7 @@ typedef struct {
   int32_t **rxdataF;
   /// \brief Holds output of the sync correlator.
   /// - first index: sample [0..samples_per_tti*10[
-  uint32_t *sync_corr[3];
-  /// \brief Holds the beamforming weights
-  /// - first index: eNB id [0..2] (hard coded)
-  /// - second index: eNB antenna port index (hard coded)
-  /// - third index: tx antenna [0..nb_antennas_tx[
-  /// - fourth index: sample [0..]
-  int32_t **beam_weights[15];
+  uint32_t *sync_corr;
   /// \brief Holds the tdd reciprocity calibration coefficients 
   /// - first index: eNB id [0..2] (hard coded) 
   /// - second index: tx antenna [0..nb_antennas_tx[
diff --git a/openair1/PHY/impl_defs_top.h b/openair1/PHY/impl_defs_top.h
index dd09749fbf..26d90e5db8 100644
--- a/openair1/PHY/impl_defs_top.h
+++ b/openair1/PHY/impl_defs_top.h
@@ -107,6 +107,7 @@
  * @}
  */
 
+#include "defs.h"
 #include "types.h"
 
 
@@ -270,187 +271,8 @@ typedef struct {
   int *RX_DMA_BUFFER[2];
 } TX_RX_VARS;
 
-/*! \brief Extension Type */
-typedef enum {
-  CYCLIC_PREFIX,
-  CYCLIC_SUFFIX,
-  ZEROS,
-  NONE
-} Extension_t;
-	
-/// Measurement Variables
-
-#define NUMBER_OF_SUBBANDS_MAX 13
-#define NUMBER_OF_HARQ_PID_MAX 8
-
-#define MAX_FRAME_NUMBER 0x400
-#if defined(CBMIMO1) || defined(EXMIMO) || defined(OAI_USRP)
-#define NUMBER_OF_eNB_MAX 1
-#define NUMBER_OF_UE_MAX 16
-#define NUMBER_OF_CONNECTED_eNB_MAX 3
-#else
-#ifdef LARGE_SCALE
-#define NUMBER_OF_eNB_MAX 2
-#define NUMBER_OF_UE_MAX 120
-#define NUMBER_OF_CONNECTED_eNB_MAX 1 // to save some memory
-#else
-#define NUMBER_OF_eNB_MAX 7
-#define NUMBER_OF_UE_MAX 16
-#define NUMBER_OF_CONNECTED_eNB_MAX 3
-#endif
-#endif
 
-#define NUMBER_OF_RN_MAX 3
-typedef enum {no_relay=1,unicast_relay_type1,unicast_relay_type2, multicast_relay} relaying_type_t;
 
-typedef struct {
-  //unsigned int   rx_power[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX];     //! estimated received signal power (linear)
-  //unsigned short rx_power_dB[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX];  //! estimated received signal power (dB)
-  //unsigned short rx_avg_power_dB[NUMBER_OF_CONNECTED_eNB_MAX];              //! estimated avg received signal power (dB)
-
-  // RRC measurements
-  uint32_t rssi;
-  int n_adj_cells;
-  unsigned int adj_cell_id[6];
-  uint32_t rsrq[7];
-  uint32_t rsrp[7];
-  float rsrp_filtered[7]; // after layer 3 filtering
-  float rsrq_filtered[7];
-  // common measurements
-  //! estimated noise power (linear)
-  unsigned int   n0_power[NB_ANTENNAS_RX];
-  //! estimated noise power (dB)
-  unsigned short n0_power_dB[NB_ANTENNAS_RX];
-  //! total estimated noise power (linear)
-  unsigned int   n0_power_tot;
-  //! total estimated noise power (dB)
-  unsigned short n0_power_tot_dB;
-  //! average estimated noise power (linear)
-  unsigned int   n0_power_avg;
-  //! average estimated noise power (dB)
-  unsigned short n0_power_avg_dB;
-  //! total estimated noise power (dBm)
-  short n0_power_tot_dBm;
-
-  // UE measurements
-  //! estimated received spatial signal power (linear)
-  int            rx_spatial_power[NUMBER_OF_CONNECTED_eNB_MAX][2][2];
-  //! estimated received spatial signal power (dB)
-  unsigned short rx_spatial_power_dB[NUMBER_OF_CONNECTED_eNB_MAX][2][2];
-
-  /// estimated received signal power (sum over all TX antennas)
-  //int            wideband_cqi[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX];
-  int            rx_power[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX];
-  /// estimated received signal power (sum over all TX antennas)
-  //int            wideband_cqi_dB[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX];
-  unsigned short rx_power_dB[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX];
-
-  /// estimated received signal power (sum over all TX/RX antennas)
-  int            rx_power_tot[NUMBER_OF_CONNECTED_eNB_MAX]; //NEW
-  /// estimated received signal power (sum over all TX/RX antennas)
-  unsigned short rx_power_tot_dB[NUMBER_OF_CONNECTED_eNB_MAX]; //NEW
-
-  //! estimated received signal power (sum of all TX/RX antennas, time average)
-  int            rx_power_avg[NUMBER_OF_CONNECTED_eNB_MAX];
-  //! estimated received signal power (sum of all TX/RX antennas, time average, in dB)
-  unsigned short rx_power_avg_dB[NUMBER_OF_CONNECTED_eNB_MAX];
-
-  /// SINR (sum of all TX/RX antennas, in dB)
-  int            wideband_cqi_tot[NUMBER_OF_CONNECTED_eNB_MAX];
-  /// SINR (sum of all TX/RX antennas, time average, in dB)
-  int            wideband_cqi_avg[NUMBER_OF_CONNECTED_eNB_MAX];
-
-  //! estimated rssi (dBm)
-  short          rx_rssi_dBm[NUMBER_OF_CONNECTED_eNB_MAX];
-  //! estimated correlation (wideband linear) between spatial channels (computed in dlsch_demodulation)
-  int            rx_correlation[NUMBER_OF_CONNECTED_eNB_MAX][2];
-  //! estimated correlation (wideband dB) between spatial channels (computed in dlsch_demodulation)
-  int            rx_correlation_dB[NUMBER_OF_CONNECTED_eNB_MAX][2];
-
-  /// Wideband CQI (sum of all RX antennas, in dB, for precoded transmission modes (3,4,5,6), up to 4 spatial streams)
-  int            precoded_cqi_dB[NUMBER_OF_CONNECTED_eNB_MAX+1][4];
-  /// Subband CQI per RX antenna (= SINR)
-  int            subband_cqi[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX][NUMBER_OF_SUBBANDS_MAX];
-  /// Total Subband CQI  (= SINR)
-  int            subband_cqi_tot[NUMBER_OF_CONNECTED_eNB_MAX][NUMBER_OF_SUBBANDS_MAX];
-  /// Subband CQI in dB (= SINR dB)
-  int            subband_cqi_dB[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX][NUMBER_OF_SUBBANDS_MAX];
-  /// Total Subband CQI
-  int            subband_cqi_tot_dB[NUMBER_OF_CONNECTED_eNB_MAX][NUMBER_OF_SUBBANDS_MAX];
-  /// Wideband PMI for each RX antenna
-  int            wideband_pmi_re[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX];
-  /// Wideband PMI for each RX antenna
-  int            wideband_pmi_im[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX];
-  ///Subband PMI for each RX antenna
-  int            subband_pmi_re[NUMBER_OF_CONNECTED_eNB_MAX][NUMBER_OF_SUBBANDS_MAX][NB_ANTENNAS_RX];
-  ///Subband PMI for each RX antenna
-  int            subband_pmi_im[NUMBER_OF_CONNECTED_eNB_MAX][NUMBER_OF_SUBBANDS_MAX][NB_ANTENNAS_RX];
-  /// chosen RX antennas (1=Rx antenna 1, 2=Rx antenna 2, 3=both Rx antennas)
-  unsigned char           selected_rx_antennas[NUMBER_OF_CONNECTED_eNB_MAX][NUMBER_OF_SUBBANDS_MAX];
-  /// Wideband Rank indication
-  unsigned char  rank[NUMBER_OF_CONNECTED_eNB_MAX];
-  /// Number of RX Antennas
-  unsigned char  nb_antennas_rx;
-  /// DLSCH error counter
-  // short          dlsch_errors;
-
-} PHY_MEASUREMENTS;
-
-typedef struct {
-  //unsigned int   rx_power[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX];     //! estimated received signal power (linear)
-  //unsigned short rx_power_dB[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX];  //! estimated received signal power (dB)
-  //unsigned short rx_avg_power_dB[NUMBER_OF_CONNECTED_eNB_MAX];              //! estimated avg received signal power (dB)
-
-  // common measurements
-  //! estimated noise power (linear)
-  unsigned int   n0_power[NB_ANTENNAS_RX];
-  //! estimated noise power (dB)
-  unsigned short n0_power_dB[NB_ANTENNAS_RX];
-  //! total estimated noise power (linear)
-  unsigned int   n0_power_tot;
-  //! estimated avg noise power (dB)
-  unsigned short n0_power_tot_dB;
-  //! estimated avg noise power (dB)
-  short n0_power_tot_dBm;
-  //! estimated avg noise power per RB per RX ant (lin)
-  unsigned short n0_subband_power[NB_ANTENNAS_RX][100];
-  //! estimated avg noise power per RB per RX ant (dB)
-  unsigned short n0_subband_power_dB[NB_ANTENNAS_RX][100];
-  //! estimated avg noise power per RB (dB)
-  short n0_subband_power_tot_dB[100];
-  //! estimated avg noise power per RB (dBm)
-  short n0_subband_power_tot_dBm[100];
-  // eNB measurements (per user)
-  //! estimated received spatial signal power (linear)
-  unsigned int   rx_spatial_power[NUMBER_OF_UE_MAX][2][2];
-  //! estimated received spatial signal power (dB)
-  unsigned short rx_spatial_power_dB[NUMBER_OF_UE_MAX][2][2];
-  //! estimated rssi (dBm)
-  short          rx_rssi_dBm[NUMBER_OF_UE_MAX];
-  //! estimated correlation (wideband linear) between spatial channels (computed in dlsch_demodulation)
-  int            rx_correlation[NUMBER_OF_UE_MAX][2];
-  //! estimated correlation (wideband dB) between spatial channels (computed in dlsch_demodulation)
-  int            rx_correlation_dB[NUMBER_OF_UE_MAX][2];
-
-  /// Wideband CQI (= SINR)
-  int            wideband_cqi[NUMBER_OF_UE_MAX][NB_ANTENNAS_RX];
-  /// Wideband CQI in dB (= SINR dB)
-  int            wideband_cqi_dB[NUMBER_OF_UE_MAX][NB_ANTENNAS_RX];
-  /// Wideband CQI (sum of all RX antennas, in dB)
-  char           wideband_cqi_tot[NUMBER_OF_UE_MAX];
-  /// Subband CQI per RX antenna and RB (= SINR)
-  int            subband_cqi[NUMBER_OF_UE_MAX][NB_ANTENNAS_RX][100];
-  /// Total Subband CQI and RB (= SINR)
-  int            subband_cqi_tot[NUMBER_OF_UE_MAX][100];
-  /// Subband CQI in dB and RB (= SINR dB)
-  int            subband_cqi_dB[NUMBER_OF_UE_MAX][NB_ANTENNAS_RX][100];
-  /// Total Subband CQI and RB
-  int            subband_cqi_tot_dB[NUMBER_OF_UE_MAX][100];
-
-} PHY_MEASUREMENTS_eNB;
-
-#define MCS_COUNT 28
-#define MCS_TABLE_LENGTH_MAX 64
 
 #endif //__PHY_IMPLEMENTATION_DEFS_H__ 
 /**@} 
diff --git a/openair1/PHY/vars.h b/openair1/PHY/vars.h
index 9ea19ac272..a74813cb8f 100644
--- a/openair1/PHY/vars.h
+++ b/openair1/PHY/vars.h
@@ -25,15 +25,9 @@
 #include "PHY/types.h"
 #include "PHY/defs.h"
 
-#ifndef USER_MODE
-unsigned int RX_DMA_BUFFER[4][NB_ANTENNAS_RX];
-unsigned int TX_DMA_BUFFER[4][NB_ANTENNAS_TX];
-unsigned int DAQ_MBOX;
-#endif
 char* namepointer_chMag ;
 char fmageren_name2[512];
 char* namepointer_log2;
-//PHY_CONFIG *PHY_config;
 
 
 #include "PHY/LTE_REFSIG/primary_synch.h"
@@ -47,8 +41,10 @@ int16_t *primary_synch2_time;
 //PHY_VARS *PHY_vars;
 #ifndef OCP_FRAMEWORK
 PHY_VARS_UE ***PHY_vars_UE_g;
-PHY_VARS_eNB ***PHY_vars_eNB_g;
-PHY_VARS_RN **PHY_vars_RN_g;
+RAN_CONTEXT_t RC;
+
+//PHY_VARS_eNB ***PHY_vars_eNB_g;
+//PHY_VARS_RN **PHY_vars_RN_g;
 LTE_DL_FRAME_PARMS *lte_frame_parms_g;
 #else
 PHY_VARS_UE * PHY_vars_UE_g[MAX_UE][MAX_NUM_CCs]={NULL};
@@ -67,6 +63,7 @@ char mode_string[4][20] = {"NOT SYNCHED","PRACH","RAR","PUSCH"};
 
 #include "SIMULATION/ETH_TRANSPORT/vars.h"
 
+unsigned char NB_RU=0;
 
 #ifndef OPENAIR2
 unsigned char NB_eNB_INST=0;
@@ -140,9 +137,9 @@ double beta2_dlsch[6][MCS_COUNT] = { {2.52163, 0.83231, 0.77472, 1.36536, 1.1682
 #ifdef OCP_FRAMEWORK
 #include <enums.h>
 #else
-char eNB_functions[6][20]={"eNodeB_3GPP","eNodeB_3GPP_BBU","NGFI_RCC_IF4p5","NGFI_RAI_IF4p5","NGFI_RRU_IF5","NGFI_RRU_IF4p5",};
+char eNB_functions[6][20]={"eNodeB_3GPP","eNodeB_3GPP_BBU","NGFI_RAU_IF4p5","NGFI_RRU_IF5","NGFI_RRU_IF4p5",};
 char eNB_timing[2][20]={"synch_to_ext_device","synch_to_other"};
-char ru_if_types[MAX_RU_IF_TYPES][20]={"local RF","IF5 RRU","IF4p5 RRU","IF1pp RRU"};
+char ru_if_types[MAX_RU_IF_TYPES][20]={"local RF","IF5 RRU","IF5 Mobipass","IF4p5 RRU","IF1pp RRU"};
 #endif
 
 /// lookup table for unscrambling in RX
diff --git a/openair1/SCHED/phy_procedures_lte_common.c b/openair1/SCHED/phy_procedures_lte_common.c
index 93d3c94b11..8b1f9c32a2 100644
--- a/openair1/SCHED/phy_procedures_lte_common.c
+++ b/openair1/SCHED/phy_procedures_lte_common.c
@@ -632,7 +632,7 @@ dci_detect_mode_t dci_detect_mode_select(LTE_DL_FRAME_PARMS *frame_parms,uint8_t
 lte_subframe_t get_subframe_direction(uint8_t Mod_id,uint8_t CC_id,uint8_t subframe)
 {
 
-  return(subframe_select(&PHY_vars_eNB_g[Mod_id][CC_id]->frame_parms,subframe));
+  return(subframe_select(&RC.eNB[Mod_id][CC_id]->frame_parms,subframe));
 
 }
 
@@ -882,19 +882,19 @@ LTE_eNB_UE_stats* get_UE_stats(uint8_t Mod_id, uint8_t  CC_id,uint16_t rnti)
 {
   int8_t UE_id;
 
-  if ((PHY_vars_eNB_g == NULL) || (PHY_vars_eNB_g[Mod_id] == NULL) || (PHY_vars_eNB_g[Mod_id][CC_id]==NULL)) {
+  if ((RC.eNB == NULL) || (Mod_id > RC.nb_inst) || (CC_id > RC.nb_CC[Mod_id])) {
     LOG_E(PHY,"get_UE_stats: No eNB found (or not allocated) for Mod_id %d,CC_id %d\n",Mod_id,CC_id);
     return NULL;
   }
 
-  UE_id = find_ue(rnti, PHY_vars_eNB_g[Mod_id][CC_id]);
+  UE_id = find_ue(rnti, RC.eNB[Mod_id][CC_id]);
 
   if (UE_id == -1) {
     //    LOG_E(PHY,"get_UE_stats: UE with rnti %x not found\n",rnti);
     return NULL;
   }
 
-  return(&PHY_vars_eNB_g[Mod_id][CC_id]->UE_stats[(uint32_t)UE_id]);
+  return(&RC.eNB[Mod_id][CC_id]->UE_stats[(uint32_t)UE_id]);
 }
 
 int8_t find_ue(uint16_t rnti, PHY_VARS_eNB *eNB)
@@ -926,16 +926,16 @@ int8_t find_ue(uint16_t rnti, PHY_VARS_eNB *eNB)
 LTE_DL_FRAME_PARMS* get_lte_frame_parms(module_id_t Mod_id, uint8_t  CC_id)
 {
 
-  return(&PHY_vars_eNB_g[Mod_id][CC_id]->frame_parms);
+  return(&RC.eNB[Mod_id][CC_id]->frame_parms);
 
 }
 
 MU_MIMO_mode *get_mu_mimo_mode (module_id_t Mod_id, uint8_t  CC_id, rnti_t rnti)
 {
-  int8_t UE_id = find_ue( rnti, PHY_vars_eNB_g[Mod_id][CC_id] );
+  int8_t UE_id = find_ue( rnti, RC.eNB[Mod_id][CC_id] );
 
   if (UE_id == -1)
     return 0;
 
-  return &PHY_vars_eNB_g[Mod_id][CC_id]->mu_mimo_mode[UE_id];
+  return &RC.eNB[Mod_id][CC_id]->mu_mimo_mode[UE_id];
 }
diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c
index 5b49abbe21..9eb5f5eeb4 100644
--- a/openair1/SCHED/phy_procedures_lte_eNb.c
+++ b/openair1/SCHED/phy_procedures_lte_eNb.c
@@ -186,7 +186,7 @@ int mac_phy_remove_ue(module_id_t Mod_idP,rnti_t rntiP) {
   PHY_VARS_eNB *eNB;
 
   for (CC_id=0;CC_id<MAX_NUM_CCs;CC_id++) {
-    eNB = PHY_vars_eNB_g[Mod_idP][CC_id];
+    eNB = RC.eNB[Mod_idP][CC_id];
     for (i=0; i<NUMBER_OF_UE_MAX; i++) {
       if ((eNB->dlsch[i]==NULL) || (eNB->ulsch[i]==NULL)) {
 	MSC_LOG_EVENT(MSC_PHY_ENB, "0 Failed remove ue %"PRIx16" (ENOMEM)", rnti);
@@ -238,7 +238,7 @@ int get_ue_active_harq_pid(const uint8_t Mod_id,const uint8_t CC_id,const uint16
   LTE_eNB_ULSCH_t *ULSCH_ptr;
   uint8_t ulsch_subframe,ulsch_frame;
   int i;
-  int8_t UE_id = find_ue(rnti,PHY_vars_eNB_g[Mod_id][CC_id]);
+  int8_t UE_id = find_ue(rnti,RC.eNB[Mod_id][CC_id]);
 
   if (UE_id==-1) {
     LOG_D(PHY,"Cannot find UE with rnti %x (Mod_id %d, CC_id %d)\n",rnti, Mod_id, CC_id);
@@ -248,7 +248,7 @@ int get_ue_active_harq_pid(const uint8_t Mod_id,const uint8_t CC_id,const uint16
 
   if ((harq_flag == openair_harq_DL) || (harq_flag == openair_harq_RA))  {// this is a DL request
 
-    DLSCH_ptr = PHY_vars_eNB_g[Mod_id][CC_id]->dlsch[(uint32_t)UE_id][0];
+    DLSCH_ptr = RC.eNB[Mod_id][CC_id]->dlsch[(uint32_t)UE_id][0];
 
     if (harq_flag == openair_harq_RA) {
       if (DLSCH_ptr->harq_processes[0] != NULL) {
@@ -275,11 +275,11 @@ int get_ue_active_harq_pid(const uint8_t Mod_id,const uint8_t CC_id,const uint16
     }
   } else { // This is a UL request
 
-    ULSCH_ptr = PHY_vars_eNB_g[Mod_id][CC_id]->ulsch[(uint32_t)UE_id];
-    ulsch_subframe = pdcch_alloc2ul_subframe(&PHY_vars_eNB_g[Mod_id][CC_id]->frame_parms,subframe);
-    ulsch_frame    = pdcch_alloc2ul_frame(&PHY_vars_eNB_g[Mod_id][CC_id]->frame_parms,frame,subframe);
+    ULSCH_ptr = RC.eNB[Mod_id][CC_id]->ulsch[(uint32_t)UE_id];
+    ulsch_subframe = pdcch_alloc2ul_subframe(&RC.eNB[Mod_id][CC_id]->frame_parms,subframe);
+    ulsch_frame    = pdcch_alloc2ul_frame(&RC.eNB[Mod_id][CC_id]->frame_parms,frame,subframe);
     // Note this is for TDD configuration 3,4,5 only
-    *harq_pid = subframe2harq_pid(&PHY_vars_eNB_g[Mod_id][CC_id]->frame_parms,
+    *harq_pid = subframe2harq_pid(&RC.eNB[Mod_id][CC_id]->frame_parms,
                                   ulsch_frame,
                                   ulsch_subframe);
     *round    = ULSCH_ptr->harq_processes[*harq_pid]->round;
@@ -291,12 +291,12 @@ int get_ue_active_harq_pid(const uint8_t Mod_id,const uint8_t CC_id,const uint16
 
 int16_t get_target_pusch_rx_power(const module_id_t module_idP, const uint8_t CC_id)
 {
-  return PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.ul_power_control_config_common.p0_NominalPUSCH;
+  return RC.eNB[module_idP][CC_id]->frame_parms.ul_power_control_config_common.p0_NominalPUSCH;
 }
 
 int16_t get_target_pucch_rx_power(const module_id_t module_idP, const uint8_t CC_id)
 {
-  return PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.ul_power_control_config_common.p0_NominalPUCCH;
+  return RC.eNB[module_idP][CC_id]->frame_parms.ul_power_control_config_common.p0_NominalPUCCH;
 }
 
 #ifdef EMOS
@@ -373,7 +373,7 @@ void phy_procedures_emos_eNB_RX(unsigned char subframe,PHY_VARS_eNB *eNB)
     emos_dump_eNB.rx_total_gain_dB = eNB->rx_total_gain_dB;
     emos_dump_eNB.mimo_mode = eNB->transmission_mode[0];
     memcpy(&emos_dump_eNB.measurements,
-           &eNB->measurements[0],
+           &eNB->measurements,
            sizeof(PHY_MEASUREMENTS_eNB));
     memcpy(&emos_dump_eNB.UE_stats[0],&eNB->UE_stats[0],NUMBER_OF_UE_MAX*sizeof(LTE_eNB_UE_stats));
 
@@ -419,7 +419,7 @@ void pmch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,PHY_VARS_RN *rn,rel
   if (eNB->abstraction_flag==0) {
     // This is DL-Cell spec pilots in Control region
     generate_pilots_slot(eNB,
-			 eNB->common_vars.txdataF[0],
+			 eNB->common_vars.txdataF,
 			 AMP,
 			 subframe<<1,1);
   }
@@ -490,7 +490,7 @@ void pmch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,PHY_VARS_RN *rn,rel
 void common_signal_procedures (PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) {
 
   LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms;
-  int **txdataF = eNB->common_vars.txdataF[0];
+  int **txdataF = eNB->common_vars.txdataF;
   uint8_t *pbch_pdu=&eNB->pbch_pdu[0];
   int subframe = proc->subframe_tx;
   int frame = proc->frame_tx;
@@ -1104,7 +1104,7 @@ void pdsch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,LTE_eNB_DLSCH_t *d
 
 
     dlsch_modulation(eNB,
-		     eNB->common_vars.txdataF[0],
+		     eNB->common_vars.txdataF,
 		     AMP,
 		     subframe,
 		     num_pdcch_symbols,
@@ -1199,7 +1199,7 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB,
   // clear the transmit data array for the current subframe
   if (eNB->abstraction_flag==0) {
     for (aa=0; aa<fp->nb_antenna_ports_eNB; aa++) {      
-      memset(&eNB->common_vars.txdataF[0][aa][subframe*fp->ofdm_symbol_size*(fp->symbols_per_tti)],
+      memset(&eNB->common_vars.txdataF[aa][subframe*fp->ofdm_symbol_size*(fp->symbols_per_tti)],
              0,fp->ofdm_symbol_size*(fp->symbols_per_tti)*sizeof(int32_t));
     }
   }
@@ -1389,7 +1389,7 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB,
                                          0,
                                          AMP,
                                          fp,
-                                         eNB->common_vars.txdataF[0],
+                                         eNB->common_vars.txdataF,
                                          subframe);
 
   }
@@ -1950,17 +1950,22 @@ void prach_procedures(PHY_VARS_eNB *eNB) {
   int subframe = eNB->proc.subframe_prach;
   int frame = eNB->proc.frame_prach;
   uint8_t CC_id = eNB->CC_id;
+  RU_t *ru;
+  int aa=0;
+  int ru_aa;
 
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_PRACH_RX,1);
   memset(&preamble_energy_list[0],0,64*sizeof(uint16_t));
   memset(&preamble_delay_list[0],0,64*sizeof(uint16_t));
 
-  if (eNB->abstraction_flag == 0) {
-    LOG_D(PHY,"[eNB %d][RAPROC] Frame %d, Subframe %d : PRACH RX Signal Power : %d dBm\n",eNB->Mod_id, 
-          frame,subframe,dB_fixed(signal_energy(&eNB->common_vars.rxdata[0][0][subframe*fp->samples_per_tti],512)) - eNB->rx_total_gain_dB);
-
 
+  for (i=0;i<eNB->num_RU;i++) {
+    ru=eNB->RU_list[i];
+    for (ru_aa=0;ru_aa<ru->nb_rx;ru_aa++) eNB->prach_vars.rxsigF[aa++] = eNB->RU_list[i]->prach_rxsigF[ru_aa];
+  }
+  if (eNB->abstraction_flag == 0) {
     rx_prach(eNB,
+	     NULL,
              preamble_energy_list,
              preamble_delay_list,
              frame,
@@ -2433,16 +2438,12 @@ void cba_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,int UE_id,int harq_p
     
     if (eNB->abstraction_flag==0) {
       rx_ulsch(eNB,proc,
-	       eNB->UE_stats[UE_id].sector,  // this is the effective sector id
-	       UE_id,
-	       eNB->ulsch,
-	       0);
+	       UE_id);
     }
     
 #ifdef PHY_ABSTRACTION
     else {
       rx_ulsch_emul(eNB,proc,
-		    eNB->UE_stats[UE_id].sector,  // this is the effective sector id
 		    UE_id);
     }
     
@@ -2566,71 +2567,8 @@ void cba_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,int UE_id,int harq_p
 
 }
 
-typedef struct {
-  PHY_VARS_eNB *eNB;
-  int slot;
-} fep_task;
-
-void fep0(PHY_VARS_eNB *eNB,int slot) {
-
-  eNB_proc_t *proc       = &eNB->proc;
-  LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms;
-  int l;
-
-  //  printf("fep0: slot %d\n",slot);
-
-  remove_7_5_kHz(eNB,(slot&1)+(proc->subframe_rx<<1));
-  for (l=0; l<fp->symbols_per_tti/2; l++) {
-    slot_fep_ul(fp,
-		&eNB->common_vars,
-		l,
-		(slot&1)+(proc->subframe_rx<<1),
-		0,
-		0
-		);
-  }
-}
-
-
-
 extern int oai_exit;
 
-static void *fep_thread(void *param) {
-
-  PHY_VARS_eNB *eNB = (PHY_VARS_eNB *)param;
-  eNB_proc_t *proc  = &eNB->proc;
-  while (!oai_exit) {
-
-    if (wait_on_condition(&proc->mutex_fep,&proc->cond_fep,&proc->instance_cnt_fep,"fep thread")<0) break;  
-    fep0(eNB,0);
-    if (release_thread(&proc->mutex_fep,&proc->instance_cnt_fep,"fep thread")<0) break;
-
-    if (pthread_cond_signal(&proc->cond_fep) != 0) {
-      printf("[eNB] ERROR pthread_cond_signal for fep thread exit\n");
-      exit_fun( "ERROR pthread_cond_signal" );
-      return NULL;
-    }
-  }
-
-
-
-  return(NULL);
-}
-
-void init_fep_thread(PHY_VARS_eNB *eNB,pthread_attr_t *attr_fep) {
-
-  eNB_proc_t *proc = &eNB->proc;
-
-  proc->instance_cnt_fep         = -1;
-    
-  pthread_mutex_init( &proc->mutex_fep, NULL);
-  pthread_cond_init( &proc->cond_fep, NULL);
-
-  pthread_create(&proc->pthread_fep, attr_fep, fep_thread, (void*)eNB);
-
-
-}
-
 extern void *td_thread(void*);
 
 void init_td_thread(PHY_VARS_eNB *eNB,pthread_attr_t *attr_td) {
@@ -2664,101 +2602,6 @@ void init_te_thread(PHY_VARS_eNB *eNB,pthread_attr_t *attr_te) {
 
 }
 
-
-void eNB_fep_full_2thread(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc_rxtx) {
-
-  eNB_proc_t *proc = &eNB->proc;
-
-  struct timespec wait;
-
-  wait.tv_sec=0;
-  wait.tv_nsec=5000000L;
-
-  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_SLOT_FEP,1);
-  start_meas(&eNB->ofdm_demod_stats);
-
-  if (pthread_mutex_timedlock(&proc->mutex_fep,&wait) != 0) {
-    printf("[eNB] ERROR pthread_mutex_lock for fep thread (IC %d)\n", proc->instance_cnt_fep);
-    exit_fun( "error locking mutex_fep" );
-    return;
-  }
-
-  if (proc->instance_cnt_fep==0) {
-    printf("[eNB] FEP thread busy\n");
-    exit_fun("FEP thread busy");
-    pthread_mutex_unlock( &proc->mutex_fep );
-    return;
-  }
-  
-  ++proc->instance_cnt_fep;
-
-
-  if (pthread_cond_signal(&proc->cond_fep) != 0) {
-    printf("[eNB] ERROR pthread_cond_signal for fep thread\n");
-    exit_fun( "ERROR pthread_cond_signal" );
-    return;
-  }
-  
-  pthread_mutex_unlock( &proc->mutex_fep );
-
-  // call second slot in this symbol
-  fep0(eNB,1);
-
-  wait_on_busy_condition(&proc->mutex_fep,&proc->cond_fep,&proc->instance_cnt_fep,"fep thread");  
-
-  stop_meas(&eNB->ofdm_demod_stats);
-}
-
-
-
-void eNB_fep_full(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc_rxtx) {
-
-  int l;
-  LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms;
-
-  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_SLOT_FEP,1);
-  start_meas(&eNB->ofdm_demod_stats);
-  remove_7_5_kHz(eNB,proc_rxtx->subframe_rx<<1);
-  remove_7_5_kHz(eNB,1+(proc_rxtx->subframe_rx<<1));
-  for (l=0; l<fp->symbols_per_tti/2; l++) {
-    slot_fep_ul(fp,
-		&eNB->common_vars,
-		l,
-		(proc_rxtx->subframe_rx)<<1,
-		0,
-		0
-		);
-    slot_fep_ul(fp,
-		&eNB->common_vars,
-		l,
-		1+((proc_rxtx->subframe_rx)<<1),
-		0,
-		0
-		);
-  }
-  stop_meas(&eNB->ofdm_demod_stats);
-  
-  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_SLOT_FEP,0);
-  
-  if (eNB->node_function == NGFI_RRU_IF4p5) {
-    /// **** send_IF4 of rxdataF to RCC (no prach now) **** ///
-    LOG_D(PHY,"send_IF4p5 (PULFFT): frame %d, subframe %d\n",proc_rxtx->frame_rx,proc_rxtx->subframe_rx);
-    send_IF4p5(eNB, proc_rxtx->frame_rx, proc_rxtx->subframe_rx, IF4p5_PULFFT, 0);
-  }    
-}
-
-void eNB_fep_rru_if5(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc_rxtx) {
-
-  eNB_proc_t *proc=&eNB->proc;
-  uint8_t seqno=0;
-
-  /// **** send_IF5 of rxdata to BBU **** ///       
-  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_SEND_IF5, 1 );  
-  send_IF5(eNB, proc->timestamp_rx, proc->subframe_rx, &seqno, IF5_RRH_GW_UL);
-  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_SEND_IF5, 0 );          
-
-}
-
 void do_prach(PHY_VARS_eNB *eNB,int frame,int subframe) {
 
   eNB_proc_t *proc = &eNB->proc;
@@ -2801,6 +2644,7 @@ void do_prach(PHY_VARS_eNB *eNB,int frame,int subframe) {
 
 }
 
+/*
 void phy_procedures_eNB_common_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc){
 
 
@@ -2833,6 +2677,7 @@ void phy_procedures_eNB_common_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc){
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_ENB_RX_COMMON+offset, 0 );
 }
 
+*/
 
 void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,const relaying_type_t r_type)
 {
@@ -2971,17 +2816,15 @@ void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,const
 
       if (eNB->abstraction_flag==0) {
         rx_ulsch(eNB,proc,
-                 eNB->UE_stats[i].sector,  // this is the effective sector id
-                 i,
-                 eNB->ulsch,
-                 0);
+                 i);
+
+
       }
 
 #ifdef PHY_ABSTRACTION
       else {
         rx_ulsch_emul(eNB,proc,
-                      eNB->UE_stats[i].sector,  // this is the effective sector id
-                      i);
+		      i);
       }
 
 #endif
@@ -3017,8 +2860,8 @@ void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,const
             dB_fixed(eNB->pusch_vars[i]->ulsch_power[1]),
             eNB->UE_stats[i].UL_rssi[0],
             eNB->UE_stats[i].UL_rssi[1],
-            eNB->measurements->n0_power_dB[0],
-            eNB->measurements->n0_power_dB[1],
+            eNB->measurements.n0_power_dB[0],
+            eNB->measurements.n0_power_dB[1],
             eNB->ulsch[i]->harq_processes[harq_pid]->o_ACK[0],
             eNB->ulsch[i]->harq_processes[harq_pid]->o_ACK[1],
             ret);
@@ -3081,8 +2924,8 @@ void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,const
 		dB_fixed(eNB->pusch_vars[i]->ulsch_power[1]),
 		eNB->UE_stats[i].UL_rssi[0],
 		eNB->UE_stats[i].UL_rssi[1],
-		eNB->measurements->n0_power_dB[0],
-		eNB->measurements->n0_power_dB[1],
+		eNB->measurements.n0_power_dB[0],
+		eNB->measurements.n0_power_dB[1],
 		eNB->ulsch[i]->harq_processes[harq_pid]->o_ACK[0],
 		eNB->ulsch[i]->harq_processes[harq_pid]->o_ACK[1],
 		ret);
@@ -3190,8 +3033,8 @@ void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,const
 		dB_fixed(eNB->pusch_vars[i]->ulsch_power[1]),
 		eNB->UE_stats[i].UL_rssi[0],
 		eNB->UE_stats[i].UL_rssi[1],
-		eNB->measurements->n0_power_dB[0],
-		eNB->measurements->n0_power_dB[1],
+		eNB->measurements.n0_power_dB[0],
+		eNB->measurements.n0_power_dB[1],
 		eNB->ulsch[i]->harq_processes[harq_pid]->o_ACK[0],
 		eNB->ulsch[i]->harq_processes[harq_pid]->o_ACK[1],
 		ret);
diff --git a/openair1/SCHED/phy_procedures_lte_ue.c b/openair1/SCHED/phy_procedures_lte_ue.c
index e061effadb..0ef60b499f 100644
--- a/openair1/SCHED/phy_procedures_lte_ue.c
+++ b/openair1/SCHED/phy_procedures_lte_ue.c
@@ -2491,7 +2491,7 @@ void ue_pbch_procedures(uint8_t eNB_id,PHY_VARS_UE *ue,UE_rxtx_proc_t *proc, uin
 			    ue->pbch_vars[eNB_id],
 			    &ue->frame_parms,
 			    eNB_id,
-			    ue->frame_parms.mode1_flag==1?SISO:ALAMOUTI,
+			    ue->frame_parms.nb_antenna_ports_eNB==1?SISO:ALAMOUTI,
 			    ue->high_speed_flag,
 			    pbch_phase);
 
@@ -2593,11 +2593,11 @@ void ue_pbch_procedures(uint8_t eNB_id,PHY_VARS_UE *ue,UE_rxtx_proc_t *proc, uin
     }
 
 #ifdef DEBUG_PHY_PROC
-    LOG_D(PHY,"[UE %d] frame %d, subframe %d, Received PBCH (MIB): mode1_flag %d, tx_ant %d, frame_tx %d. N_RB_DL %d, phich_duration %d, phich_resource %d/6!\n",
+    LOG_D(PHY,"[UE %d] frame %d, subframe %d, Received PBCH (MIB): nb_antenna_ports_eNB %d, tx_ant %d, frame_tx %d. N_RB_DL %d, phich_duration %d, phich_resource %d/6!\n",
 	  ue->Mod_id,
 	  frame_rx,
 	  subframe_rx,
-	  ue->frame_parms.mode1_flag,
+	  ue->frame_parms.nb_antenna_ports_eNB,
 	  pbch_tx_ant,
 	  frame_tx,
 	  ue->frame_parms.N_RB_DL,
@@ -2682,7 +2682,7 @@ int ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint
 	     proc->frame_rx,
 	     subframe_rx,
 	     eNB_id,
-	     (ue->frame_parms.mode1_flag == 1) ? SISO : ALAMOUTI,
+	     (ue->frame_parms.nb_antenna_ports_eNB == 1) ? SISO : ALAMOUTI,
 	     ue->high_speed_flag,
 	     ue->is_secondary_ue);
 
@@ -2709,7 +2709,7 @@ int ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint
   else {
     for (i=0; i<NB_eNB_INST; i++) {
       for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++)
-	if (PHY_vars_eNB_g[i][CC_id]->frame_parms.Nid_cell == ue->frame_parms.Nid_cell)
+	if (RC.eNB[i][CC_id]->frame_parms.Nid_cell == ue->frame_parms.Nid_cell)
 	  break;
 
       if (CC_id < MAX_NUM_CCs)
@@ -2725,13 +2725,13 @@ int ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint
 
     LOG_D(PHY,"Calling dci_decoding_proc_emul ...\n");
     dci_cnt = dci_decoding_procedure_emul(ue->pdcch_vars,
-					  PHY_vars_eNB_g[i][CC_id]->num_ue_spec_dci[subframe_rx&1],
-					  PHY_vars_eNB_g[i][CC_id]->num_common_dci[subframe_rx&1],
-					  PHY_vars_eNB_g[i][CC_id]->dci_alloc[subframe_rx&1],
+					  RC.eNB[i][CC_id]->num_ue_spec_dci[subframe_rx&1],
+					  RC.eNB[i][CC_id]->num_common_dci[subframe_rx&1],
+					  RC.eNB[i][CC_id]->dci_alloc[subframe_rx&1],
 					  dci_alloc_rx,
 					  eNB_id);
     //    printf("DCI: dci_cnt %d\n",dci_cnt);
-    UE_id = (uint32_t)find_ue((int16_t)ue->pdcch_vars[eNB_id]->crnti,PHY_vars_eNB_g[i][CC_id]);
+    UE_id = (uint32_t)find_ue((int16_t)ue->pdcch_vars[eNB_id]->crnti,RC.eNB[i][CC_id]);
 
     if (UE_id>=0) {
       //      printf("Checking PHICH for UE  %d (eNB %d)\n",UE_id,i);
diff --git a/openair1/SCHED/pusch_pc.c b/openair1/SCHED/pusch_pc.c
index 6e3c600c76..a03dd7fd3c 100644
--- a/openair1/SCHED/pusch_pc.c
+++ b/openair1/SCHED/pusch_pc.c
@@ -90,14 +90,22 @@ int16_t get_hundred_times_delta_IF_eNB(PHY_VARS_eNB *eNB,uint8_t UE_id,uint8_t h
 
 int16_t get_hundred_times_delta_IF_mac(module_id_t module_idP, uint8_t CC_id, rnti_t rnti, uint8_t harq_pid)
 {
-  int8_t UE_id = find_ue( rnti, PHY_vars_eNB_g[module_idP][CC_id] );
+
+  int8_t UE_id;
+
+  if ((RC.eNB == NULL) || (module_idP > RC.nb_inst) || (CC_id > RC.nb_CC[module_idP])) {
+    LOG_E(PHY,"get_UE_stats: No eNB found (or not allocated) for Mod_id %d,CC_id %d\n",module_idP,CC_id);
+    return -1;
+  }
+
+  UE_id = find_ue( rnti, RC.eNB[module_idP][CC_id] );
 
   if (UE_id == -1) {
     // not found
     return 0;
   }
 
-  return get_hundred_times_delta_IF_eNB( PHY_vars_eNB_g[module_idP][CC_id], UE_id, harq_pid, 0 );
+  return get_hundred_times_delta_IF_eNB( RC.eNB[module_idP][CC_id], UE_id, harq_pid, 0 );
 }
 
 int16_t get_hundred_times_delta_IF(PHY_VARS_UE *ue,uint8_t eNB_id,uint8_t harq_pid)
diff --git a/openair1/SCHED/ru_procedures.c b/openair1/SCHED/ru_procedures.c
index 269f8e86f1..fe77dbbfc0 100644
--- a/openair1/SCHED/ru_procedures.c
+++ b/openair1/SCHED/ru_procedures.c
@@ -1,7 +1,64 @@
+/*
+ * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The OpenAirInterface Software Alliance licenses this file to You under
+ * the OAI Public License, Version 1.0  (the "License"); you may not use this file
+ * except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.openairinterface.org/?page_id=698
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *-------------------------------------------------------------------------------
+ * For more information about the OpenAirInterface (OAI) Software Alliance:
+ *      contact@openairinterface.org
+ */
+
+/*! \file ru_procedures.c
+ * \brief Implementation of RU procedures
+ * \author R. Knopp, F. Kaltenberger, N. Nikaein, X. Foukas
+ * \date 2011
+ * \version 0.1
+ * \company Eurecom
+ * \email: knopp@eurecom.fr,florian.kaltenberger@eurecom.fr,navid.nikaein@eurecom.fr, x.foukas@sms.ed.ac.uk
+ * \note
+ * \warning
+ */
+
+#include "PHY/defs.h"
+#include "PHY/extern.h"
+#include "SCHED/defs.h"
+#include "SCHED/extern.h"
+
+#include "PHY/LTE_TRANSPORT/if4_tools.h"
+#include "PHY/LTE_TRANSPORT/if5_tools.h"
+
+#ifdef EMOS
+#include "SCHED/phy_procedures_emos.h"
+#endif
+
+#include "LAYER2/MAC/extern.h"
+#include "LAYER2/MAC/defs.h"
+#include "UTIL/LOG/log.h"
+#include "UTIL/LOG/vcd_signal_dumper.h"
+
+#include "T.h"
+
+#include "assertions.h"
+#include "msc.h"
+
+#include <time.h>
 
 // RU OFDM Modulator, used in IF4p5 RRU, RCC/RAU with IF5, eNodeB
 
-void do_OFDM_mod_rt(int subframe,RU_t *ru) {
+extern openair0_config_t openair0_cfg[MAX_CARDS];
+
+void feptx_ofdm(RU_t *ru) {
      
   LTE_DL_FRAME_PARMS *fp=&ru->frame_parms;
 
@@ -12,11 +69,13 @@ void do_OFDM_mod_rt(int subframe,RU_t *ru) {
                    ((fp->Ncp==1) ? 6 : 7);
   int len,len2;
   int16_t *txdata;
+  int subframe = ru->proc.subframe_tx;
+
 //  int CC_id = ru->proc.CC_id;
 
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_SFGEN , 1 );
 
-  slot_offset_F = (subframe<<1)*slot_sizeF;
+  //  slot_offset_F = (subframe<<1)*slot_sizeF;
 
   slot_offset = subframe*fp->samples_per_tti;
 
@@ -26,26 +85,26 @@ void do_OFDM_mod_rt(int subframe,RU_t *ru) {
 
     for (aa=0; aa<ru->nb_tx; aa++) {
       if (fp->Ncp == EXTENDED) {
-        PHY_ofdm_mod(&ru->ru_time.txdataF[aa][slot_offset_F],
+        PHY_ofdm_mod(&ru->common.txdataF_BF[aa][0],
                      dummy_tx_b,
                      fp->ofdm_symbol_size,
                      6,
                      fp->nb_prefix_samples,
                      CYCLIC_PREFIX);
-        PHY_ofdm_mod(&ru->ru_time.txdataF[aa][slot_offset_F+slot_sizeF],
+        PHY_ofdm_mod(&ru->common.txdataF_BF[aa][slot_sizeF],
                      dummy_tx_b+(fp->samples_per_tti>>1),
                      fp->ofdm_symbol_size,
                      6,
                      fp->nb_prefix_samples,
                      CYCLIC_PREFIX);
       } else {
-        normal_prefix_mod(&ru->ru_time.txdataF[aa][slot_offset_F],
+        normal_prefix_mod(&ru->common.txdataF_BF[aa][slot_offset_F],
                           dummy_tx_b,
                           7,
                           fp);
 	// if S-subframe generate first slot only
 	if (subframe_select(fp,subframe) == SF_DL) 
-	  normal_prefix_mod(&ru->ru_time.txdataF[aa][slot_offset_F+slot_sizeF],
+	  normal_prefix_mod(&ru->common.txdataF_BF[aa][slot_offset_F+slot_sizeF],
 			    dummy_tx_b+(fp->samples_per_tti>>1),
 			    7,
 			    fp);
@@ -64,38 +123,38 @@ void do_OFDM_mod_rt(int subframe,RU_t *ru) {
 	dummy_tx_b[i+3] = 0xff000000;
 	}*/
       
-      if (slot_offset+time_offset[aa]<0) {
-	txdata = (int16_t*)&ru->ru_time.txdata[aa][(LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*fp->samples_per_tti)+tx_offset];
-        len2 = -(slot_offset+time_offset[aa]);
+      if (slot_offset<0) {
+	txdata = (int16_t*)&ru->common.txdata[aa][(LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*fp->samples_per_tti)+tx_offset];
+        len2 = -(slot_offset);
 	len2 = (len2>len) ? len : len2;
 	for (i=0; i<(len2<<1); i++) {
-	  txdata[i] = ((int16_t*)dummy_tx_b)[i]<<openair0_cfg[0].iq_txshift;
+	  txdata[i] = ((int16_t*)dummy_tx_b)[i];
 	}
 	if (len2<len) {
-	  txdata = (int16_t*)&ru->ru_time.txdata[aa][0];
+	  txdata = (int16_t*)&ru->common.txdata[aa][0];
 	  for (j=0; i<(len<<1); i++,j++) {
-	    txdata[j++] = ((int16_t*)dummy_tx_b)[i]<<openair0_cfg[0].iq_txshift;
+	    txdata[j++] = ((int16_t*)dummy_tx_b)[i];
 	  }
 	}
       }  
-      else if ((slot_offset+time_offset[aa]+len)>(LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*fp->samples_per_tti)) {
-	tx_offset = (int)slot_offset+time_offset[aa];
-	txdata = (int16_t*)&ru->ru_time.txdata[aa][tx_offset];
+      else 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]<<openair0_cfg[0].iq_txshift;
+	  txdata[i] = ((int16_t*)dummy_tx_b)[i];
 	}
-	txdata = (int16_t*)&ru->ru_time.txdata[aa][0];
+	txdata = (int16_t*)&ru->common.txdata[aa][0];
 	for (j=0; i<(len<<1); i++,j++) {
-	  txdata[j++] = ((int16_t*)dummy_tx_b)[i]<<openair0_cfg[0].iq_txshift;
+	  txdata[j++] = ((int16_t*)dummy_tx_b)[i];
 	}
       }
       else {
-	tx_offset = (int)slot_offset+time_offset[aa];
-	txdata = (int16_t*)&ru->ru_time.txdata[aa][tx_offset];
+	tx_offset = (int)slot_offset;
+	txdata = (int16_t*)&ru->common.txdata[aa][tx_offset];
 
 	for (i=0; i<(len<<1); i++) {
-	  txdata[i] = ((int16_t*)dummy_tx_b)[i]<<openair0_cfg[0].iq_txshift;
+	  txdata[i] = ((int16_t*)dummy_tx_b)[i];
 	}
       }
       
@@ -115,21 +174,53 @@ void do_OFDM_mod_rt(int subframe,RU_t *ru) {
        // 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++) {
-         tx_offset = (int)slot_offset+time_offset[aa]+i-ru->N_TA_offset/2;
+         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->ru_time.txdata[aa][tx_offset] = 0x00000000;
+         ru->common.txdata[aa][tx_offset] = 0x00000000;
        }
      }
+     LOG_I(PHY,"feptx_ofdm: frame %d, subframe %d: txp (time) %d dB, txp (freq) %d dB\n",
+	   ru->proc.frame_tx,subframe,dB_fixed(signal_energy(txdata,fp->samples_per_tti)),
+	   dB_fixed(signal_energy_nodc(ru->common.txdataF_BF[aa],2*slot_sizeF)));
     }
   }
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_SFGEN , 0 );
 }
 
+void feptx_prec(RU_t *ru) {
+
+  int l,i,aa;
+  PHY_VARS_eNB **eNB_list = ru->eNB_list,*eNB;
+  LTE_DL_FRAME_PARMS *fp;
+  int32_t ***bw;
+  int subframe = ru->proc.subframe_tx;
+
+  for (i=0;i<ru->num_eNB;i++) {
+    eNB = eNB_list[i];
+    fp  = &eNB->frame_parms;
+    bw  = ru->beam_weights[i];
+
+    for (l=0;l<fp->symbols_per_tti;l++) {
+      for (aa=0;aa<ru->nb_tx;aa++) {
+	beam_precoding(eNB->common_vars.txdataF,
+		       ru->common.txdataF_BF,
+		       fp,
+		       bw,
+		       subframe<<1,
+		       l,
+		       aa);
+      }
+    }
+    LOG_I(PHY,"feptx_prec: frame %d, subframe %d: txp (freq) %d dB\n",
+	  ru->proc.frame_tx,subframe,
+	  dB_fixed(signal_energy_nodc(ru->common.txdataF_BF[0],2*fp->symbols_per_tti*fp->ofdm_symbol_size)));
+  }
+}
 
 typedef struct {
   RU_t *ru;
@@ -138,8 +229,8 @@ typedef struct {
 
 void fep0(RU_t *ru,int slot) {
 
-  eNB_proc_t *proc       = &ru->proc;
-  LTE_DL_FRAME_PARMS *fp = ru->frame_parms;
+  RU_proc_t *proc       = &ru->proc;
+  LTE_DL_FRAME_PARMS *fp = &ru->frame_parms;
   int l;
 
   //  printf("fep0: slot %d\n",slot);
@@ -147,10 +238,9 @@ void fep0(RU_t *ru,int slot) {
   remove_7_5_kHz(ru,(slot&1)+(proc->subframe_rx<<1));
   for (l=0; l<fp->symbols_per_tti/2; l++) {
     slot_fep_ul(fp,
-		&ru->ru_time,
+		&ru->common,
 		l,
 		(slot&1)+(proc->subframe_rx<<1),
-		0,
 		0
 		);
   }
@@ -163,7 +253,7 @@ extern int oai_exit;
 static void *fep_thread(void *param) {
 
   RU_t *ru = (RU_t *)param;
-  ru_proc_t *proc  = &ru->proc;
+  RU_proc_t *proc  = &ru->proc;
   while (!oai_exit) {
 
     if (wait_on_condition(&proc->mutex_fep,&proc->cond_fep,&proc->instance_cnt_fep,"fep thread")<0) break;  
@@ -182,22 +272,22 @@ static void *fep_thread(void *param) {
   return(NULL);
 }
 
-void init_fep_thread(PHY_VARS_eNB *eNB,pthread_attr_t *attr_fep) {
+void init_fep_thread(RU_t *ru,pthread_attr_t *attr_fep) {
 
-  eNB_proc_t *proc = &eNB->proc;
+  RU_proc_t *proc = &ru->proc;
 
   proc->instance_cnt_fep         = -1;
     
   pthread_mutex_init( &proc->mutex_fep, NULL);
   pthread_cond_init( &proc->cond_fep, NULL);
 
-  pthread_create(&proc->pthread_fep, attr_fep, fep_thread, (void*)eNB);
+  pthread_create(&proc->pthread_fep, attr_fep, fep_thread, (void*)ru);
 
 
 }
 void ru_fep_full_2thread(RU_t *ru) {
 
-  ru_proc_t *proc = &ru->proc;
+  RU_proc_t *proc = &ru->proc;
 
   struct timespec wait;
 
@@ -241,31 +331,29 @@ void ru_fep_full_2thread(RU_t *ru) {
 
 
 
-void ru_fep_full(RU_t *ru) {
+void fep_full(RU_t *ru) {
 
-  ru_proc_t *proc = &ru->proc;
+  RU_proc_t *proc = &ru->proc;
   int l;
-  LTE_DL_FRAME_PARMS *fp=ru->frame_parms;
+  LTE_DL_FRAME_PARMS *fp=&ru->frame_parms;
 
   start_meas(&ru->ofdm_demod_stats);
 
-  if (ru == RC.ru_list[0]) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_SLOT_FEP,1);
+  if (ru == RC.ru[0]) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_SLOT_FEP,1);
 
   remove_7_5_kHz(ru,proc->subframe_rx<<1);
   remove_7_5_kHz(ru,1+(proc->subframe_rx<<1));
   for (l=0; l<fp->symbols_per_tti/2; l++) {
     slot_fep_ul(fp,
-		&ru->ru_time,
+		&ru->common,
 		l,
 		proc->subframe_rx<<1,
-		0,
 		0
 		);
     slot_fep_ul(fp,
-		&ru->ru_time,
+		&ru->common,
 		l,
 		1+(proc->subframe_rx<<1),
-		0,
 		0
 		);
   }
@@ -273,24 +361,21 @@ void ru_fep_full(RU_t *ru) {
   
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_SLOT_FEP,0);
   
-  if (ru->node_function == NGFI_RRU_IF4p5) {
-    /// **** send_IF4 of rxdataF to RCC (no prach now) **** ///
-    send_IF4p5(ru, proc->frame_rx, proc->subframe_rx, IF4p5_PULFFT, 0);
-  }    
 }
 
 
 void do_prach_ru(RU_t *ru) {
 
-  ru_proc_t *proc = &ru->proc;
-  LTE_DL_FRAME_PARMS *fp->frame_parms;
+  RU_proc_t *proc = &ru->proc;
+  LTE_DL_FRAME_PARMS *fp=&ru->frame_parms;
 
   // check if we have to detect PRACH first
-  if (is_prach_subframe(fp,proc->frame_rx,proc->subframe_rx)>0) { 
+  if (is_prach_subframe(fp,proc->frame_prach,proc->subframe_prach)>0) { 
     /* accept some delay in processing - up to 5ms */
     int i;
     for (i = 0; i < 10 && proc->instance_cnt_prach == 0; i++) {
-      LOG_W(PHY,"[eNB] Frame %d Subframe %d, eNB PRACH thread busy (IC %d)!!\n", proc->frame_rx,proc->subframe_rx,proc->instance_cnt_prach);
+      LOG_W(PHY,"Frame %d Subframe %d, PRACH thread busy (IC %d)!!\n", proc->frame_prach,proc->subframe_prach,
+	    proc->instance_cnt_prach);
       usleep(500);
     }
     if (proc->instance_cnt_prach == 0) {
@@ -300,19 +385,16 @@ void do_prach_ru(RU_t *ru) {
     
     // wake up thread for PRACH RX
     if (pthread_mutex_lock(&proc->mutex_prach) != 0) {
-      LOG_E( PHY, "[eNB] ERROR pthread_mutex_lock for eNB PRACH thread %d (IC %d)\n", proc->instance_cnt_prach );
+      LOG_E( PHY, "ERROR pthread_mutex_lock for PRACH thread (IC %d)\n", proc->instance_cnt_prach );
       exit_fun( "error locking mutex_prach" );
       return;
     }
     
     ++proc->instance_cnt_prach;
-    // set timing for prach thread
-    proc->frame_prach = proc->frame_rx;
-    proc->subframe_prach = proc->subframe_rx;
     
     // the thread can now be woken up
     if (pthread_cond_signal(&proc->cond_prach) != 0) {
-      LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB PRACH thread %d\n", proc->thread_index);
+      LOG_E( PHY, "ERROR pthread_cond_signal for PRACH thread\n");
       exit_fun( "ERROR pthread_cond_signal" );
       return;
     }
diff --git a/openair1/SIMULATION/ETH_TRANSPORT/emu_transport.c b/openair1/SIMULATION/ETH_TRANSPORT/emu_transport.c
index 6d3d4cabb3..ddee949732 100644
--- a/openair1/SIMULATION/ETH_TRANSPORT/emu_transport.c
+++ b/openair1/SIMULATION/ETH_TRANSPORT/emu_transport.c
@@ -31,6 +31,7 @@
 
 #include "PHY/defs.h"
 #include "PHY/extern.h"
+#include "common/ran_context.h"
 #include "defs.h"
 #include "extern.h"
 #include "proto.h"
@@ -288,13 +289,13 @@ void fill_phy_enb_vars(unsigned int enb_id, uint8_t CC_id,unsigned int next_slot
   // eNB
   // PBCH : copy payload
 
-  *(uint32_t *)PHY_vars_eNB_g[enb_id][CC_id]->pbch_pdu =
+  *(uint32_t *)RC.eNB[enb_id][CC_id]->pbch_pdu =
     eNB_transport_info[enb_id][CC_id].cntl.pbch_payload;
   /*  LOG_I(EMU," RX slot %d ENB TRANSPORT pbch payload %d pdu[0] %d  pdu[0] %d \n",
     next_slot ,
     eNB_transport_info[enb_id][CC_id].cntl.pbch_payload,
-    ((uint8_t*)PHY_vars_eNB_g[enb_id]->pbch_pdu)[0],
-    ((uint8_t*)PHY_vars_eNB_g[enb_id]->pbch_pdu)[1]);
+    ((uint8_t*)RC.eNB[enb_id]->pbch_pdu)[0],
+    ((uint8_t*)RC.eNB[enb_id]->pbch_pdu)[1]);
   */
   //  }
   //CFI
@@ -308,9 +309,9 @@ void fill_phy_enb_vars(unsigned int enb_id, uint8_t CC_id,unsigned int next_slot
                 eNB_transport_info[enb_id][CC_id].num_ue_spec_dci +
                 eNB_transport_info[enb_id][CC_id].num_common_dci;
 
-  PHY_vars_eNB_g[enb_id][CC_id]->num_ue_spec_dci[(next_slot>>1)&1] =
+  RC.eNB[enb_id][CC_id]->num_ue_spec_dci[(next_slot>>1)&1] =
     eNB_transport_info[enb_id][CC_id].num_ue_spec_dci;
-  PHY_vars_eNB_g[enb_id][CC_id]->num_common_dci[(next_slot>>1)&1]  =
+  RC.eNB[enb_id][CC_id]->num_common_dci[(next_slot>>1)&1]  =
     eNB_transport_info[enb_id][CC_id].num_common_dci;
 #ifdef DEBUG_EMU
   LOG_D(EMU, "Fill phy vars eNB %d for slot %d, DCI found %d  \n",
@@ -319,7 +320,7 @@ void fill_phy_enb_vars(unsigned int enb_id, uint8_t CC_id,unsigned int next_slot
 
   if (nb_total_dci >0) {
 
-    memcpy(PHY_vars_eNB_g[enb_id][CC_id]->dci_alloc[(next_slot>>1)&1],
+    memcpy(RC.eNB[enb_id][CC_id]->dci_alloc[(next_slot>>1)&1],
            eNB_transport_info[enb_id][CC_id].dci_alloc,
            (nb_total_dci) * sizeof(DCI_ALLOC_t));
 
@@ -341,7 +342,7 @@ void fill_phy_enb_vars(unsigned int enb_id, uint8_t CC_id,unsigned int next_slot
 
         switch (eNB_transport_info[enb_id][CC_id].dlsch_type[n_dci_dl]) {
         case 0: //SI:
-          memcpy(PHY_vars_eNB_g[enb_id][CC_id]->dlsch_SI->harq_processes[0]->b,
+          memcpy(RC.eNB[enb_id][CC_id]->dlsch_SI->harq_processes[0]->b,
                  &eNB_transport_info[enb_id][CC_id].transport_blocks[payload_offset],
                  eNB_transport_info[enb_id][CC_id].tbs[n_dci_dl]);
 #ifdef DEBUG_EMU
@@ -351,7 +352,7 @@ void fill_phy_enb_vars(unsigned int enb_id, uint8_t CC_id,unsigned int next_slot
           break;
 
         case 1: //RA:
-          memcpy(PHY_vars_eNB_g[enb_id][CC_id]->dlsch_ra->harq_processes[0]->b,
+          memcpy(RC.eNB[enb_id][CC_id]->dlsch_ra->harq_processes[0]->b,
                  &eNB_transport_info[enb_id][CC_id].transport_blocks[payload_offset],
                  eNB_transport_info[enb_id][CC_id].tbs[n_dci_dl]);
 #ifdef DEBUG_EMU
@@ -363,9 +364,9 @@ void fill_phy_enb_vars(unsigned int enb_id, uint8_t CC_id,unsigned int next_slot
         case 2://TB0:
           harq_pid  = eNB_transport_info[enb_id][CC_id].harq_pid[n_dci_dl];
           ue_id = eNB_transport_info[enb_id][CC_id].ue_id[n_dci_dl];
-          PHY_vars_eNB_g[enb_id][CC_id]->dlsch[ue_id][0]->rnti=
+          RC.eNB[enb_id][CC_id]->dlsch[ue_id][0]->rnti=
             eNB_transport_info[enb_id][CC_id].dci_alloc[n_dci_dl].rnti;
-          dlsch_eNB = PHY_vars_eNB_g[enb_id][CC_id]->dlsch[ue_id][0];
+          dlsch_eNB = RC.eNB[enb_id][CC_id]->dlsch[ue_id][0];
 #ifdef DEBUG_EMU
           LOG_D(EMU,
                 " enb_id %d ue id is %d rnti is %x dci index %d, harq_pid %d tbs %d \n",
@@ -386,9 +387,9 @@ void fill_phy_enb_vars(unsigned int enb_id, uint8_t CC_id,unsigned int next_slot
         case 3://TB1:
           harq_pid = eNB_transport_info[enb_id][CC_id].harq_pid[n_dci_dl];
           ue_id = eNB_transport_info[enb_id][CC_id].ue_id[n_dci_dl];
-          PHY_vars_eNB_g[enb_id][CC_id]->dlsch[ue_id][1]->rnti=
+          RC.eNB[enb_id][CC_id]->dlsch[ue_id][1]->rnti=
             eNB_transport_info[enb_id][CC_id].dci_alloc[n_dci_dl].rnti;
-          dlsch_eNB = PHY_vars_eNB_g[enb_id][CC_id]->dlsch[ue_id][1];
+          dlsch_eNB = RC.eNB[enb_id][CC_id]->dlsch[ue_id][1];
 
           memcpy(dlsch_eNB->harq_processes[harq_pid]->b,
                  &eNB_transport_info[enb_id][CC_id].transport_blocks[payload_offset],
@@ -396,7 +397,7 @@ void fill_phy_enb_vars(unsigned int enb_id, uint8_t CC_id,unsigned int next_slot
           break;
 
         case 5:
-          memcpy(PHY_vars_eNB_g[enb_id][CC_id]->dlsch_MCH->harq_processes[0]->b,
+          memcpy(RC.eNB[enb_id][CC_id]->dlsch_MCH->harq_processes[0]->b,
                  &eNB_transport_info[enb_id][CC_id].transport_blocks[payload_offset],
                  eNB_transport_info[enb_id][CC_id].tbs[n_dci_dl]);
 #ifdef DEBUG_EMU
diff --git a/openair1/SIMULATION/TOOLS/random_channel.c b/openair1/SIMULATION/TOOLS/random_channel.c
index 6e034332c0..d94a0d1daf 100644
--- a/openair1/SIMULATION/TOOLS/random_channel.c
+++ b/openair1/SIMULATION/TOOLS/random_channel.c
@@ -879,7 +879,7 @@ int random_channel(channel_desc_t *desc, uint8_t abstraction_flag)
   struct complex phase, alpha, beta;
 
   if ((desc->nb_tx>NB_ANTENNAS_TX) || (desc->nb_rx > NB_ANTENNAS_RX)) {
-    msg("random_channel.c: Error: temporary buffer for channel not big enough (%d,%d)\n",desc->nb_tx,desc->nb_rx);
+    LOG_E(PHY,"random_channel.c: Error: temporary buffer for channel not big enough (%d,%d)\n",desc->nb_tx,desc->nb_rx);
     return(-1);
   }
 
diff --git a/openair1/SIMULATION/TOOLS/rangen_double.c b/openair1/SIMULATION/TOOLS/rangen_double.c
index a1dee2a553..aaf41d8d94 100644
--- a/openair1/SIMULATION/TOOLS/rangen_double.c
+++ b/openair1/SIMULATION/TOOLS/rangen_double.c
@@ -44,7 +44,7 @@ void randominit(unsigned seed_init)
 {
   int i;
   // this need to be integrated with the existing rng, like taus: navid
-  msg("Initializing random number generator, seed %x\n",seed_init);
+  LOG_D(PHY,"Initializing random number generator, seed %x\n",seed_init);
 
   if (seed_init == 0) {
     srand((unsigned)time(NULL));
diff --git a/openair2/COMMON/mac_rrc_primitives.h b/openair2/COMMON/mac_rrc_primitives.h
index dfa641ee66..57835e1e7d 100644
--- a/openair2/COMMON/mac_rrc_primitives.h
+++ b/openair2/COMMON/mac_rrc_primitives.h
@@ -33,6 +33,7 @@
 #include "RadioResourceConfigCommonSIB.h"
 #include "RadioResourceConfigDedicated.h"
 #include "MeasGapConfig.h"
+#include "TDD-Config.h"
 #ifdef Rel10
 #include "MBSFN-AreaInfoList-r9.h"
 #include "MBSFN-SubframeConfigList.h"
diff --git a/openair2/COMMON/rrc_messages_types.h b/openair2/COMMON/rrc_messages_types.h
index 8a4c27f5eb..d7a42fd3dc 100644
--- a/openair2/COMMON/rrc_messages_types.h
+++ b/openair2/COMMON/rrc_messages_types.h
@@ -93,14 +93,8 @@ typedef struct RrcConfigurationReq_s {
   uint16_t            mnc;
   uint8_t             mnc_digit_length;
 
-  /*
-    paging_drx_t        default_drx;
-
-    lte_frame_type_t    frame_type;
-    uint8_t             tdd_config;
-    uint8_t             tdd_config_s;
-    int16_t             eutra_band;
-  */
+  
+  paging_drx_t            default_drx;
   int16_t                 nb_cc;
   lte_frame_type_t        frame_type[MAX_NUM_CCs];
   uint8_t                 tdd_config[MAX_NUM_CCs];
@@ -109,11 +103,9 @@ typedef struct RrcConfigurationReq_s {
   int16_t                 eutra_band[MAX_NUM_CCs];
   uint32_t                downlink_frequency[MAX_NUM_CCs];
   int32_t                 uplink_frequency_offset[MAX_NUM_CCs];
-
   int16_t                 Nid_cell[MAX_NUM_CCs];// for testing, change later
   int16_t                 N_RB_DL[MAX_NUM_CCs];// for testing, change later
-  int                   nb_antennas_tx[MAX_NUM_CCs];
-  int                     nb_antennas_rx[MAX_NUM_CCs];
+  int                     nb_antenna_ports[MAX_NUM_CCs];
   long                    prach_root[MAX_NUM_CCs];
   long                    prach_config_index[MAX_NUM_CCs];
   BOOLEAN_t               prach_high_speed[MAX_NUM_CCs];
diff --git a/openair2/ENB_APP/enb_app.c b/openair2/ENB_APP/enb_app.c
index 60415aad86..219bd4b43f 100644
--- a/openair2/ENB_APP/enb_app.c
+++ b/openair2/ENB_APP/enb_app.c
@@ -33,6 +33,7 @@
 #include "enb_app.h"
 #include "enb_config.h"
 #include "assertions.h"
+#include "common/ran_context.h"
 
 #include "log.h"
 #if defined(OAI_EMU)
@@ -56,6 +57,8 @@
 extern unsigned char NB_eNB_INST;
 #endif
 
+extern RAN_CONTEXT_t RC;
+
 #if defined(ENABLE_ITTI)
 
 /*------------------------------------------------------------------------------*/
@@ -64,6 +67,8 @@ extern unsigned char NB_eNB_INST;
 # endif
 
 /*------------------------------------------------------------------------------*/
+
+/*
 static void configure_phy(module_id_t enb_id, const Enb_properties_array_t* enb_properties)
 {
   MessageDef *msg_p;
@@ -84,15 +89,20 @@ static void configure_phy(module_id_t enb_id, const Enb_properties_array_t* enb_
 
   itti_send_msg_to_task (TASK_PHY_ENB, ENB_MODULE_ID_TO_INSTANCE(enb_id), msg_p);
 }
+*/
 
 /*------------------------------------------------------------------------------*/
-static void configure_rrc(uint32_t enb_id, const Enb_properties_array_t *enb_properties)
+static void configure_rrc(uint32_t enb_id)
 {
   MessageDef *msg_p = NULL;
-  int CC_id;
+  //  int CC_id;
 
   msg_p = itti_alloc_new_message (TASK_ENB_APP, RRC_CONFIGURATION_REQ);
 
+  if (RC.rrc[enb_id]) {
+    RCconfig_RRC(msg_p,enb_id,&RC.rrc[enb_id]);
+    
+  /*
   RRC_CONFIGURATION_REQ (msg_p).cell_identity =   enb_properties->properties[enb_id]->eNB_id;
   RRC_CONFIGURATION_REQ (msg_p).tac =             enb_properties->properties[enb_id]->tac;
   RRC_CONFIGURATION_REQ (msg_p).mcc =             enb_properties->properties[enb_id]->mcc;
@@ -187,13 +197,18 @@ static void configure_rrc(uint32_t enb_id, const Enb_properties_array_t *enb_pro
     RRC_CONFIGURATION_REQ (msg_p).ue_TransmissionMode[CC_id]                      = enb_properties->properties[enb_id]->ue_TransmissionMode[CC_id];
 
   }
+  */
+
+    LOG_I(ENB_APP,"Sending configuration message to RRC task\n");
+    itti_send_msg_to_task (TASK_RRC_ENB, ENB_MODULE_ID_TO_INSTANCE(enb_id), msg_p);
 
-  itti_send_msg_to_task (TASK_RRC_ENB, ENB_MODULE_ID_TO_INSTANCE(enb_id), msg_p);
+  }
+  else AssertFatal(0,"RRC context for eNB %d not allocated\n",enb_id);
 }
 
 /*------------------------------------------------------------------------------*/
 # if defined(ENABLE_USE_MME)
-static uint32_t eNB_app_register(uint32_t enb_id_start, uint32_t enb_id_end, const Enb_properties_array_t *enb_properties)
+static uint32_t eNB_app_register(uint32_t enb_id_start, uint32_t enb_id_end)//, const Enb_properties_array_t *enb_properties)
 {
   uint32_t         enb_id;
   uint32_t         mme_id;
@@ -217,9 +232,15 @@ static uint32_t eNB_app_register(uint32_t enb_id_start, uint32_t enb_id_end, con
       /* note:  there is an implicit relationship between the data structure and the message name */
       msg_p = itti_alloc_new_message (TASK_ENB_APP, S1AP_REGISTER_ENB_REQ);
 
+      RCconfig_S1(msg_p, enb_id);
+
+      if (enb_id == 0) RCconfig_gtpu();
+
       s1ap_register_eNB = &S1AP_REGISTER_ENB_REQ(msg_p);
+      LOG_I(ENB_APP,"default drx %d\n",s1ap_register_eNB->default_drx);
 
-      /* Some default/random parameters */
+      /*
+   
       s1ap_register_eNB->eNB_id           = enb_properties->properties[enb_id]->eNB_id;
       s1ap_register_eNB->cell_type        = enb_properties->properties[enb_id]->cell_type;
       s1ap_register_eNB->eNB_name         = enb_properties->properties[enb_id]->eNB_name;
@@ -230,6 +251,7 @@ static uint32_t eNB_app_register(uint32_t enb_id_start, uint32_t enb_id_end, con
       s1ap_register_eNB->default_drx      = enb_properties->properties[enb_id]->pcch_defaultPagingCycle[0];
 
       s1ap_register_eNB->nb_mme =         enb_properties->properties[enb_id]->nb_mme;
+
       AssertFatal (s1ap_register_eNB->nb_mme <= S1AP_MAX_NB_MME_IP_ADDRESS, "Too many MME for eNB %d (%d/%d)!", enb_id, s1ap_register_eNB->nb_mme,
                    S1AP_MAX_NB_MME_IP_ADDRESS);
 
@@ -254,6 +276,7 @@ static uint32_t eNB_app_register(uint32_t enb_id_start, uint32_t enb_id_end, con
       str = inet_ntoa(addr);
       strcpy(s1ap_register_eNB->enb_ip_address.ipv4_address, str);
 
+      */
       LOG_I(ENB_APP,"[eNB %d] eNB_app_register for instance %d\n", enb_id, ENB_MODULE_ID_TO_INSTANCE(enb_id));
 
       itti_send_msg_to_task (TASK_S1AP, ENB_MODULE_ID_TO_INSTANCE(enb_id), msg_p);
@@ -270,9 +293,8 @@ static uint32_t eNB_app_register(uint32_t enb_id_start, uint32_t enb_id_end, con
 /*------------------------------------------------------------------------------*/
 void *eNB_app_task(void *args_p)
 {
-  const Enb_properties_array_t   *enb_properties_p  = NULL;
 #if defined(ENABLE_ITTI)
-  uint32_t                        enb_nb = 1; /* Default number of eNB is 1 */
+  uint32_t                        enb_nb = RC.nb_inst; 
   uint32_t                        enb_id_start = 0;
   uint32_t                        enb_id_end = enb_id_start + enb_nb;
 # if defined(ENABLE_USE_MME)
@@ -303,15 +325,20 @@ void *eNB_app_task(void *args_p)
 #   endif
   # endif
 
-  enb_properties_p = enb_config_get();
 
-  AssertFatal (enb_nb <= enb_properties_p->number,
+  AssertFatal (enb_nb <= RC.nb_inst,
                "Number of eNB is greater than eNB defined in configuration file (%d/%d)!",
-               enb_nb, enb_properties_p->number);
+               enb_nb, RC.nb_inst);
+
+  LOG_I(ENB_APP,"Allocating eNB_RRC_INST for %d instances\n",RC.nb_inst);
+
+  RC.rrc = (eNB_RRC_INST **)malloc(RC.nb_inst*sizeof(eNB_RRC_INST *));
 
   for (enb_id = enb_id_start; (enb_id < enb_id_end) ; enb_id++) {
-    configure_phy(enb_id, enb_properties_p);
-    configure_rrc(enb_id, enb_properties_p);
+    //    configure_phy(enb_id);//
+    RC.rrc[enb_id] = (eNB_RRC_INST*)malloc(sizeof(eNB_RRC_INST));
+
+    configure_rrc(enb_id);//
   }
 
 #if defined (FLEXRAN_AGENT_SB_IF)
@@ -325,7 +352,7 @@ void *eNB_app_task(void *args_p)
 # if defined(ENABLE_USE_MME)
   /* Try to register each eNB */
   registered_enb = 0;
-  register_enb_pending = eNB_app_register (enb_id_start, enb_id_end, enb_properties_p);
+  register_enb_pending = eNB_app_register (enb_id_start, enb_id_end);//, enb_properties_p);
 # else
   /* Start L2L1 task */
   msg_p = itti_alloc_new_message(TASK_ENB_APP, INITIALIZE_MESSAGE);
@@ -395,7 +422,7 @@ void *eNB_app_task(void *args_p)
             sleep(ENB_REGISTER_RETRY_DELAY);
             /* Restart the registration process */
             registered_enb = 0;
-            register_enb_pending = eNB_app_register (enb_id_start, enb_id_end, enb_properties_p);
+            register_enb_pending = eNB_app_register (enb_id_start, enb_id_end);//, enb_properties_p);
           }
         }
       }
@@ -415,7 +442,7 @@ void *eNB_app_task(void *args_p)
       if (TIMER_HAS_EXPIRED (msg_p).timer_id == enb_register_retry_timer_id) {
         /* Restart the registration process */
         registered_enb = 0;
-        register_enb_pending = eNB_app_register (enb_id_start, enb_id_end, enb_properties_p);
+        register_enb_pending = eNB_app_register (enb_id_start, enb_id_end);//, enb_properties_p);
       }
 
       break;
@@ -432,8 +459,6 @@ void *eNB_app_task(void *args_p)
 
 #endif
 
-  /* for no gcc warnings */
-  (void)enb_properties_p;
 
   return NULL;
 }
diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c
index 2a48aefbaf..9cb96ce665 100644
--- a/openair2/ENB_APP/enb_config.c
+++ b/openair2/ENB_APP/enb_config.c
@@ -20,12 +20,12 @@
  */
 
 /*
-                                enb_config.c
-                             -------------------
+  enb_config.c
+  -------------------
   AUTHOR  : Lionel GAUTHIER, navid nikaein, Laurent Winckel
   COMPANY : EURECOM
   EMAIL   : Lionel.Gauthier@eurecom.fr, navid.nikaein@eurecom.fr
- */
+*/
 
 #include <string.h>
 #include <libconfig.h>
@@ -52,27 +52,28 @@
 #include "SystemInformationBlockType2.h"
 #include "LAYER2/MAC/extern.h"
 #include "PHY/extern.h"
+#include "targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.h"
 
 /* those macros are here to help diagnose problems in configuration files
  * if the lookup fails, a warning is printed
  * (yes we can use the function name for the macro itself, the C preprocessor
  * won't die in an infinite loop)
  */
-#define config_setting_lookup_int(setting, name, value) \
-    (config_setting_lookup_int(setting, name, value) || \
-    (printf("WARNING: setting '%s' not found in configuration file\n", name), 0))
-#define config_setting_lookup_int64(setting, name, value) \
-    (config_setting_lookup_int64(setting, name, value) || \
-    (printf("WARNING: setting '%s' not found in configuration file\n", name), 0))
-#define config_setting_lookup_float(setting, name, value) \
-    (config_setting_lookup_float(setting, name, value) || \
-    (printf("WARNING: setting '%s' not found in configuration file\n", name), 0))
-#define config_setting_lookup_bool(setting, name, value) \
-    (config_setting_lookup_bool(setting, name, value) || \
-    (printf("WARNING: setting '%s' not found in configuration file\n", name), 0))
-#define config_setting_lookup_string(setting, name, value) \
-    (config_setting_lookup_string(setting, name, value) || \
-    (printf("WARNING: setting '%s' not found in configuration file\n", name), 0))
+#define config_setting_lookup_int(setting, name, value)			\
+  (config_setting_lookup_int(setting, name, value) ||			\
+   (printf("WARNING: setting '%s' not found in configuration file\n", name), 0))
+#define config_setting_lookup_int64(setting, name, value)		\
+  (config_setting_lookup_int64(setting, name, value) ||			\
+   (printf("WARNING: setting '%s' not found in configuration file\n", name), 0))
+#define config_setting_lookup_float(setting, name, value)		\
+  (config_setting_lookup_float(setting, name, value) ||			\
+   (printf("WARNING: setting '%s' not found in configuration file\n", name), 0))
+#define config_setting_lookup_bool(setting, name, value)		\
+  (config_setting_lookup_bool(setting, name, value) ||			\
+   (printf("WARNING: setting '%s' not found in configuration file\n", name), 0))
+#define config_setting_lookup_string(setting, name, value)		\
+  (config_setting_lookup_string(setting, name, value) ||		\
+   (printf("WARNING: setting '%s' not found in configuration file\n", name), 0))
 
 #define ENB_CONFIG_STRING_ACTIVE_ENBS                   "Active_eNBs"
 
@@ -196,19 +197,6 @@
 #define ENB_CONFIG_STRING_FLEXRAN_AGENT_PORT                "FLEXRAN_AGENT_PORT"
 #define ENB_CONFIG_STRING_FLEXRAN_AGENT_CACHE               "FLEXRAN_AGENT_CACHE"
 
-#define ENB_CONFIG_STRING_RRH_GW_CONFIG                   "rrh_gw_config"
-#define ENB_CONFIG_STRING_RRH_GW_LOCAL_IF_NAME            "local_if_name"
-#define ENB_CONFIG_STRING_RRH_GW_LOCAL_ADDRESS            "local_address"
-#define ENB_CONFIG_STRING_RRH_GW_REMOTE_ADDRESS           "remote_address"
-#define ENB_CONFIG_STRING_RRH_GW_LOCAL_PORT               "local_port"
-#define ENB_CONFIG_STRING_RRH_GW_REMOTE_PORT              "remote_port"
-#define ENB_CONFIG_STRING_RRH_GW_ACTIVE                   "rrh_gw_active"
-#define ENB_CONFIG_STRING_RRH_GW_TRANSPORT_PREFERENCE     "tr_preference"
-#define ENB_CONFIG_STRING_RRH_GW_RF_TARGET_PREFERENCE     "rf_preference"
-#define ENB_CONFIG_STRING_RRH_GW_IQ_TXSHIFT               "iq_txshift"
-#define ENB_CONFIG_STRING_RRH_GW_TX_SAMPLE_ADVANCE        "tx_sample_advance"
-#define ENB_CONFIG_STRING_RRH_GW_TX_SCHEDULING_ADVANCE    "tx_scheduling_advance"
-
 #define ENB_CONFIG_STRING_ASN1_VERBOSITY                   "Asn1_verbosity"
 #define ENB_CONFIG_STRING_ASN1_VERBOSITY_NONE              "none"
 #define ENB_CONFIG_STRING_ASN1_VERBOSITY_ANNOYING          "annoying"
@@ -244,6 +232,26 @@
 #define ENB_CONFIG_STRING_OSA_LOG_VERBOSITY                "osa_log_verbosity"
 
 
+#define CONFIG_STRING_ACTIVE_RUS                   "Active_RUs"
+#define CONFIG_STRING_RU_LIST                      "RUs"
+
+#define CONFIG_STRING_RU_CONFIG                   "ru_config"
+#define CONFIG_STRING_RU_LOCAL_IF_NAME            "local_if_name"
+#define CONFIG_STRING_RU_LOCAL_ADDRESS            "local_address"
+#define CONFIG_STRING_RU_REMOTE_ADDRESS           "remote_address"
+#define CONFIG_STRING_RU_LOCAL_PORT               "local_port"
+#define CONFIG_STRING_RU_REMOTE_PORT              "remote_port"
+#define CONFIG_STRING_RU_LOCAL_RF                 "local_rf"
+#define CONFIG_STRING_RU_TRANSPORT_PREFERENCE     "tr_preference"
+#define CONFIG_STRING_RU_BAND_LIST                "bands"
+#define CONFIG_STRING_RU_ENB_LIST                 "eNB_instances"
+#define CONFIG_STRING_RU_NB_TX                    "nb_tx"
+#define CONFIG_STRING_RU_NB_RX                    "nb_rx"
+#define CONFIG_STRING_RU_ATT_TX                   "att_tx"
+#define CONFIG_STRING_RU_ATT_RX                   "att_rx"
+#define CONFIG_STRING_RU_MAX_RS_EPRE              "max_pdschReferenceSignalPower"
+#define CONFIG_STRING_RU_MAX_RXGAIN               "max_rxgain"
+
 #define KHz (1000UL)
 #define MHz (1000 * KHz)
 
@@ -289,197 +297,10 @@ static const eutra_band_t eutra_bands[] = {
   {44, 703    * MHz, 803    * MHz, 703    * MHz, 803    * MHz, TDD},
 };
 
-Enb_properties_array_t enb_properties;
-
-void enb_config_display(void)
-{
-  int i,j;
-
-  printf( "\n----------------------------------------------------------------------\n");
-  printf( " ENB CONFIG FILE CONTENT LOADED (TBC):\n");
-  printf( "----------------------------------------------------------------------\n");
-
-  for (i = 0; i < enb_properties.number; i++) {
-    printf( "ENB CONFIG for instance %u:\n\n", i);
-    printf( "\teNB name:           \t%s:\n",enb_properties.properties[i]->eNB_name);
-    printf( "\teNB ID:             \t%"PRIu32":\n",enb_properties.properties[i]->eNB_id);
-    printf( "\tCell type:          \t%s:\n",enb_properties.properties[i]->cell_type == CELL_MACRO_ENB ? "CELL_MACRO_ENB":"CELL_HOME_ENB");
-    printf( "\tTAC:                \t%"PRIu16":\n",enb_properties.properties[i]->tac);
-    printf( "\tMCC:                \t%"PRIu16":\n",enb_properties.properties[i]->mcc);
-
-    if (enb_properties.properties[i]->mnc_digit_length == 3) {
-      printf( "\tMNC:                \t%03"PRIu16":\n",enb_properties.properties[i]->mnc);
-    } else {
-      printf( "\tMNC:                \t%02"PRIu16":\n",enb_properties.properties[i]->mnc);
-    }
-    
-    for (j=0; j< enb_properties.properties[i]->nb_rrh_gw; j++) {
-      if (enb_properties.properties[i]->rrh_gw_config[j].active == 1 ){
-	printf( "\n\tRRH GW %d config for eNB %u:\n\n", j, i);
-        printf( "\tinterface name :       \t%s:\n",enb_properties.properties[i]->rrh_gw_config[j].rrh_gw_if_name);
-	printf( "\tlocal address  :       \t%s:\n",enb_properties.properties[i]->rrh_gw_config[j].local_address);
-	printf( "\tlocal port     :       \t%d:\n",enb_properties.properties[i]->rrh_gw_config[j].local_port);
-	printf( "\tremote address :       \t%s:\n",enb_properties.properties[i]->rrh_gw_config[j].remote_address);
-	printf( "\tremote port    :       \t%d:\n",enb_properties.properties[i]->rrh_gw_config[j].remote_port);
-	printf( "\ttx_scheduling_advance :\t%d:\n",enb_properties.properties[i]->rrh_gw_config[j].tx_scheduling_advance);
-	printf( "\ttx_sample_advance :    \t%d:\n",enb_properties.properties[i]->rrh_gw_config[j].tx_sample_advance);
-	printf( "\tiq_txshift :           \t%d:\n",enb_properties.properties[i]->rrh_gw_config[j].iq_txshift);
-	printf( "\ttransport  :           \t%s Ethernet:\n",(enb_properties.properties[i]->rrh_gw_config[j].raw == 1)? "RAW" : (enb_properties.properties[i]->rrh_gw_config[j].rawif4p5 == 1)? "RAW_IF4p5" : (enb_properties.properties[i]->rrh_gw_config[j].udpif4p5 == 1)? "UDP_IF4p5" : (enb_properties.properties[i]->rrh_gw_config[j].rawif5_mobipass == 1)? "RAW_IF5_MOBIPASS" : "UDP");
-	if (enb_properties.properties[i]->rrh_gw_config[j].exmimo == 1) {
-	  printf( "\tRF target  :           \tEXMIMO:\n");
-	} else if (enb_properties.properties[i]->rrh_gw_config[j].usrp_b200 == 1) {
-	  printf( "\tRF target  :           \tUSRP_B200:\n");
-	} else if (enb_properties.properties[i]->rrh_gw_config[j].usrp_x300 == 1) {
-	  printf( "\tRF target  :           \tUSRP_X300:\n");
-	} else if (enb_properties.properties[i]->rrh_gw_config[j].bladerf == 1) {
-	  printf( "\tRF target  :           \tBLADERF:\n");
-	} else if (enb_properties.properties[i]->rrh_gw_config[j].lmssdr == 1) {
-	  printf( "\tRF target  :           \tLMSSDR:\n");
-	} else {
-	  printf( "\tRF target  :           \tNONE:\n");
-	}
-      }
-    }
-
-#if defined(FLEXRAN_AGENT_SB_IF)
-    printf( "\nFLEXRAN AGENT CONFIG : \n\n");
-    printf( "\tInterface name:           \t%s:\n",enb_properties.properties[i]->flexran_agent_interface_name);
-    //    printf( "\tInterface IP Address:     \t%s:\n",enb_properties.properties[i]->flexran_agent_ipv4_address);
-    printf( "\tInterface PORT:           \t%d:\n\n",enb_properties.properties[i]->flexran_agent_port);
-    printf( "\tCache directory:          \t%s:\n",enb_properties.properties[i]->flexran_agent_cache);
-    
-#endif 
-
-    for (j=0; j< enb_properties.properties[i]->nb_cc; j++) {
-      // CC_ID node function/timing
-      printf( "\n\tnode_function for CC %d:      \t%s:\n",j,eNB_functions[enb_properties.properties[i]->cc_node_function[j]]);
-      printf( "\tnode_timing for CC %d:        \t%s:\n",j,eNB_timing[enb_properties.properties[i]->cc_node_timing[j]]);
-      printf( "\tnode_synch_ref for CC %d:     \t%d:\n",j,enb_properties.properties[i]->cc_node_synch_ref[j]);
-
-      printf( "\teutra band for CC %d:         \t%"PRId16":\n",j,enb_properties.properties[i]->eutra_band[j]);
-      printf( "\tdownlink freq for CC %d:      \t%"PRIu64":\n",j,enb_properties.properties[i]->downlink_frequency[j]);
-      printf( "\tuplink freq offset for CC %d: \t%"PRId32":\n",j,enb_properties.properties[i]->uplink_frequency_offset[j]);
-
-      printf( "\n\tCell ID for CC %d:\t%"PRId16":\n",j,enb_properties.properties[i]->Nid_cell[j]);
-      printf( "\tN_RB_DL for CC %d:\t%"PRId16":\n",j,enb_properties.properties[i]->N_RB_DL[j]);
-      printf( "\tnb_antenna_ports for CC %d:\t%d:\n",j,enb_properties.properties[i]->nb_antenna_ports[j]);
-      printf( "\tnb_antennas_tx for CC %d:\t%d:\n",j,enb_properties.properties[i]->nb_antennas_tx[j]);
-      printf( "\tnb_antennas_rx for CC %d:\t%d:\n",j,enb_properties.properties[i]->nb_antennas_rx[j]);
-      
-      // RACH-Config
-      printf( "\trach_numberOfRA_Preambles for CC %d:\t%ld:\n",j,enb_properties.properties[i]->rach_numberOfRA_Preambles[j]);
-      printf( "\trach_preamblesGroupAConfig for CC %d:\t%d:\n",j,enb_properties.properties[i]->rach_preamblesGroupAConfig[j]);
-
-      if (enb_properties.properties[i]->rach_preamblesGroupAConfig[j]) {
-        printf( "\trach_sizeOfRA_PreamblesGroupA for CC %d:\t%ld:\n",j,enb_properties.properties[i]->rach_sizeOfRA_PreamblesGroupA[j]);
-        printf( "\trach_messageSizeGroupA for CC %d:\t%ld:\n",j,enb_properties.properties[i]->rach_messageSizeGroupA[j]);
-        printf( "\trach_messagePowerOffsetGroupB for CC %d:\t%d:\n",j,enb_properties.properties[i]->rach_messagePowerOffsetGroupB[j]);
-      }
-
-      printf( "\trach_powerRampingStep for CC %d:\t%ld:\n",j,enb_properties.properties[i]->rach_powerRampingStep[j]);
-      printf( "\trach_preambleInitialReceivedTargetPower for CC %d:\t%ld:\n",j,enb_properties.properties[i]->rach_preambleInitialReceivedTargetPower[j]);
-      printf( "\trach_preambleTransMax for CC %d:\t%ld:\n",j,enb_properties.properties[i]->rach_preambleTransMax[j]);
-      printf( "\trach_raResponseWindowSize for CC %d:\t%ld:\n",j,enb_properties.properties[i]->rach_raResponseWindowSize[j]);
-      printf( "\trach_macContentionResolutionTimer for CC %d:\t%ld:\n",j,enb_properties.properties[i]->rach_macContentionResolutionTimer[j]);
-      printf( "\trach_maxHARQ_Msg3Tx for CC %d:\t%ld:\n",j,enb_properties.properties[i]->rach_maxHARQ_Msg3Tx[j]);
-
-      // BCCH-Config
-      printf( "\tbcch_modificationPeriodCoeff for CC %d:\t%ld:\n",j,enb_properties.properties[i]->bcch_modificationPeriodCoeff[j]);
-
-      // PCCH-Config
-      printf( "\tpcch_defaultPagingCycle for CC %d:\t%ld:\n",j,enb_properties.properties[i]->pcch_defaultPagingCycle[j]);
-      printf( "\tpcch_nB for CC %d:\t%ld:\n",j,enb_properties.properties[i]->pcch_nB[j]);
-
-      // PRACH-Config
-      printf( "\tprach_root for CC %d:\t%ld:\n",j,enb_properties.properties[i]->prach_root[j]);
-      printf( "\tprach_config_index for CC %d:\t%ld:\n",j,enb_properties.properties[i]->prach_config_index[j]);
-      printf( "\tprach_high_speed for CC %d:\t%d:\n",j,enb_properties.properties[i]->prach_high_speed[j]);
-      printf( "\tprach_zero_correlation for CC %d:\t%ld:\n",j,enb_properties.properties[i]->prach_zero_correlation[j]);
-      printf( "\tprach_freq_offset for CC %d:\t%ld:\n",j,enb_properties.properties[i]->prach_freq_offset[j]);
-
-      // PDSCH-Config
-      printf( "\tpdsch_referenceSignalPower for CC %d:\t%ld:\n",j,enb_properties.properties[i]->pdsch_referenceSignalPower[j]);
-      printf( "\tpdsch_p_b for CC %d:\t%ld:\n",j,enb_properties.properties[i]->pdsch_p_b[j]);
-
-      // PUSCH-Config
-      printf( "\tpusch_n_SB for CC %d:\t%ld:\n",j,enb_properties.properties[i]->pusch_n_SB[j]);
-      printf( "\tpusch_hoppingMode for CC %d:\t%ld:\n",j,enb_properties.properties[i]->pusch_hoppingMode[j]);
-      printf( "\tpusch_hoppingOffset for CC %d:\t%ld:\n",j,enb_properties.properties[i]->pusch_hoppingOffset[j]);
-      printf( "\tpusch_enable64QAM for CC %d:\t%d:\n",j,enb_properties.properties[i]->pusch_enable64QAM[j]);
-      printf( "\tpusch_groupHoppingEnabled for CC %d:\t%d:\n",j,enb_properties.properties[i]->pusch_groupHoppingEnabled[j]);
-      printf( "\tpusch_groupAssignment for CC %d:\t%ld:\n",j,enb_properties.properties[i]->pusch_groupAssignment[j]);
-      printf( "\tpusch_sequenceHoppingEnabled for CC %d:\t%d:\n",j,enb_properties.properties[i]->pusch_sequenceHoppingEnabled[j]);
-      printf( "\tpusch_nDMRS1 for CC %d:\t%ld:\n",j,enb_properties.properties[i]->pusch_nDMRS1[j]);
-
-      // PUCCH-Config
-
-      printf( "\tpucch_delta_shift for CC %d:\t%ld:\n",j,enb_properties.properties[i]->pucch_delta_shift[j]);
-      printf( "\tpucch_nRB_CQI for CC %d:\t%ld:\n",j,enb_properties.properties[i]->pucch_nRB_CQI[j]);
-      printf( "\tpucch_nCS_AN for CC %d:\t%ld:\n",j,enb_properties.properties[i]->pucch_nCS_AN[j]);
-#ifndef Rel10
-      printf( "\tpucch_n1_AN for CC %d:\t%ld:\n",j,enb_properties.properties[i]->pucch_n1_AN[j]);
-#endif
-
-      // SRS Config
-      printf( "\tsrs_enable for CC %d:\t%d:\n",j,enb_properties.properties[i]->srs_enable[j]);
-
-      if (enb_properties.properties[i]->srs_enable[j]) {
-        printf( "\tsrs_BandwidthConfig for CC %d:\t%ld:\n",j,enb_properties.properties[i]->srs_BandwidthConfig[j]);
-        printf( "\tsrs_BandwidthConfig for CC %d:\t%ld:\n",j,enb_properties.properties[i]->srs_SubframeConfig[j]);
-        printf( "\tsrs_ackNackST for CC %d:\t%d:\n",j,enb_properties.properties[i]->srs_ackNackST[j]);
-        printf( "\tsrs_MaxUpPts for CC %d:\t%d:\n",j,enb_properties.properties[i]->srs_MaxUpPts[j]);
-      }
-
-      // uplinkPowerControlCommon
-
-      printf( "\tpusch_p0_Nominal for CC %d:\t%ld:\n",j,enb_properties.properties[i]->pusch_p0_Nominal[j]);
-      printf( "\tpucch_p0_Nominal for CC %d:\t%ld:\n",j,enb_properties.properties[i]->pucch_p0_Nominal[j]);
-      printf( "\tpusch_alpha for CC %d:\t%ld:\n",j,enb_properties.properties[i]->pusch_alpha[j]);
-      printf( "\tpucch_deltaF_Format1 for CC %d:\t%d:\n",j,enb_properties.properties[i]->pucch_deltaF_Format1[j]);
-      printf( "\tpucch_deltaF_Format1b for CC %d:\t%d:\n",j,enb_properties.properties[i]->pucch_deltaF_Format1b[j]);
-      printf( "\tpucch_deltaF_Format2 for CC %d:\t%d:\n",j,enb_properties.properties[i]->pucch_deltaF_Format2[j]);
-      printf( "\tpucch_deltaF_Format2a for CC %d:\t%d:\n",j,enb_properties.properties[i]->pucch_deltaF_Format2a[j]);
-      printf( "\tpucch_deltaF_Format2b for CC %d:\t%d:\n",j,enb_properties.properties[i]->pucch_deltaF_Format2b[j]);
-      printf( "\tmsg3_delta_Preamble for CC %d:\t%ld:\n",j,enb_properties.properties[i]->msg3_delta_Preamble[j]);
-      printf( "\tul_CyclicPrefixLength for CC %d:\t%ld:\n",j,enb_properties.properties[i]->ul_CyclicPrefixLength[j]);
-
-      // UE Timers and Constants
-
-      printf( "\tue_TimersAndConstants_t300 for CC %d:\t%ld:\n",j,enb_properties.properties[i]->ue_TimersAndConstants_t300[j]);
-      printf( "\tue_TimersAndConstants_t301 for CC %d:\t%ld:\n",j,enb_properties.properties[i]->ue_TimersAndConstants_t301[j]);
-      printf( "\tue_TimersAndConstants_t310 for CC %d:\t%ld:\n",j,enb_properties.properties[i]->ue_TimersAndConstants_t310[j]);
-      printf( "\tue_TimersAndConstants_n310 for CC %d:\t%ld:\n",j,enb_properties.properties[i]->ue_TimersAndConstants_n310[j]);
-      printf( "\tue_TimersAndConstants_t311 for CC %d:\t%ld:\n",j,enb_properties.properties[i]->ue_TimersAndConstants_t311[j]);
-      printf( "\tue_TimersAndConstants_n311 for CC %d:\t%ld:\n",j,enb_properties.properties[i]->ue_TimersAndConstants_n311[j]);
-
-      printf( "\tue_TransmissionMode for CC %d:\t%ld:\n",j,enb_properties.properties[i]->ue_TransmissionMode[j]);
-
-    }
-
-    for (j=0; j < enb_properties.properties[i]->num_otg_elements; j++) {
-      printf( "\n\tOTG Destination UE ID:  \t%"PRIu16, enb_properties.properties[i]->otg_ue_id[j]);
-      printf( "\n\tOTG App Type:  \t%"PRIu8, enb_properties.properties[i]->otg_app_type[j]);
-      printf( "\n\tOTG Background Traffic:  \t%s\n", (enb_properties.properties[i]->otg_bg_traffic[j]==1) ? "Enabled" : "Disabled");
-    }
-
-    printf( "\n\tGlobal log level:  \t%s\n", map_int_to_str(log_level_names,enb_properties.properties[i]->glog_level));
-    printf( "\tHW log level:      \t%s\n", map_int_to_str(log_level_names,enb_properties.properties[i]->hw_log_level));
-    printf( "\tPHY log level:     \t%s\n", map_int_to_str(log_level_names,enb_properties.properties[i]->phy_log_level));
-    printf( "\tMAC log level:     \t%s\n", map_int_to_str(log_level_names,enb_properties.properties[i]->mac_log_level));
-    printf( "\tRLC log level:     \t%s\n", map_int_to_str(log_level_names,enb_properties.properties[i]->rlc_log_level));
-    printf( "\tPDCP log level:    \t%s\n", map_int_to_str(log_level_names,enb_properties.properties[i]->pdcp_log_level));
-    printf( "\tRRC log level:     \t%s\n", map_int_to_str(log_level_names,enb_properties.properties[i]->rrc_log_level));
-    printf( "\tUDP log level:     \t%s\n", map_int_to_str(log_level_names,enb_properties.properties[i]->udp_log_level));
-    printf( "\tGTP log level:     \t%s\n", map_int_to_str(log_level_names,enb_properties.properties[i]->gtpu_log_level));
-    printf( "\tOSA log level:     \t%s\n", map_int_to_str(log_level_names,enb_properties.properties[i]->osa_log_level));
-
-    printf( "\n--------------------------------------------------------\n");
-  }
-}
 
 
 static int enb_check_band_frequencies(char* lib_config_file_name_pP,
-                                      int enb_properties_index,
+                                      int ind,
                                       int16_t band,
                                       uint32_t downlink_frequency,
                                       int32_t uplink_frequency_offset,
@@ -496,21 +317,21 @@ static int enb_check_band_frequencies(char* lib_config_file_name_pP,
 
         AssertError (eutra_bands[band_index].dl_min < downlink_frequency, errors ++,
                      "Failed to parse eNB configuration file %s, enb %d downlink frequency %u too low (%u) for band %d!",
-                     lib_config_file_name_pP, enb_properties_index, downlink_frequency, eutra_bands[band_index].dl_min, band);
+                     lib_config_file_name_pP, ind, downlink_frequency, eutra_bands[band_index].dl_min, band);
         AssertError (downlink_frequency < eutra_bands[band_index].dl_max, errors ++,
                      "Failed to parse eNB configuration file %s, enb %d downlink frequency %u too high (%u) for band %d!",
-                     lib_config_file_name_pP, enb_properties_index, downlink_frequency, eutra_bands[band_index].dl_max, band);
+                     lib_config_file_name_pP, ind, downlink_frequency, eutra_bands[band_index].dl_max, band);
 
         AssertError (eutra_bands[band_index].ul_min < uplink_frequency, errors ++,
                      "Failed to parse eNB configuration file %s, enb %d uplink frequency %u too low (%u) for band %d!",
-                     lib_config_file_name_pP, enb_properties_index, uplink_frequency, eutra_bands[band_index].ul_min, band);
+                     lib_config_file_name_pP, ind, uplink_frequency, eutra_bands[band_index].ul_min, band);
         AssertError (uplink_frequency < eutra_bands[band_index].ul_max, errors ++,
                      "Failed to parse eNB configuration file %s, enb %d uplink frequency %u too high (%u) for band %d!",
-                     lib_config_file_name_pP, enb_properties_index, uplink_frequency, eutra_bands[band_index].ul_max, band);
+                     lib_config_file_name_pP, ind, uplink_frequency, eutra_bands[band_index].ul_max, band);
 
         AssertError (eutra_bands[band_index].frame_type == frame_type, errors ++,
                      "Failed to parse eNB configuration file %s, enb %d invalid frame type (%d/%d) for band %d!",
-                     lib_config_file_name_pP, enb_properties_index, eutra_bands[band_index].frame_type, frame_type, band);
+                     lib_config_file_name_pP, ind, eutra_bands[band_index].frame_type, frame_type, band);
       }
     }
   }
@@ -528,8 +349,237 @@ extern int asn1_xer_print;
 #else
 #define libconfig_int int
 #endif
-const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP)
-{
+
+typedef enum {
+  RU     = 0,
+  L1     = 1,
+  L2     = 2,
+  L3     = 3,
+  S1     = 4,
+  lastel = 5
+} RC_config_functions_t;
+
+void RCconfig_RU(void);
+void RCconfig_L1(void);
+void RCconfig_L2(void);
+int  RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc);
+int  RCconfig_S1(MessageDef *msg_p, uint32_t i);
+//void (*RCconfig[lastel])(void) = {RCconfig_RU,RCconfig_L1,RCconfig_L2,RCconfig_RRC,RCconfig_S1};
+
+int load_config_file(config_t *cfg) {
+
+  config_init(cfg);
+  
+  if (RC.config_file_name != NULL) {
+    // Read the file. If there is an error, report it and exit. 
+    if (! config_read_file(cfg, RC.config_file_name)) {
+      config_destroy(cfg);
+      AssertFatal (0, "Failed to parse eNB configuration file %s!\n", RC.config_file_name);
+    }
+  } else {
+    config_destroy(cfg);
+    AssertFatal (0, "No eNB configuration file provided!\n");
+  }
+
+}
+void RCconfig_RU() {
+
+  config_t          cfg;
+  config_setting_t *setting                       = NULL;
+  config_setting_t *setting_ru                    = NULL;
+  config_setting_t *setting_band                  = NULL;
+  config_setting_t *setting_band_elem             = NULL;
+  config_setting_t *setting_eNB_list              = NULL;
+  config_setting_t *setting_eNB_list_elem         = NULL;
+  char*             if_name                       = NULL;
+  char*             ipv4                          = NULL;
+  char*             ipv4_remote                   = NULL;
+  char              *local_rf                     = NULL;
+
+  char*             tr_preference                 = NULL;
+  libconfig_int     local_port                    = 0;
+  libconfig_int     remote_port                   = 0;
+
+  libconfig_int     nb_tx                         = 0;
+  libconfig_int     nb_rx                         = 0;
+  libconfig_int     att_tx                        = 0;
+  libconfig_int     att_rx                        = 0;
+  libconfig_int     max_pdschReferenceSignalPower = 0;
+  libconfig_int     max_rxgain                    = 0;
+  int               j                             = 0;
+  int               i                             = 0;
+  int               num_bands                     = 0;
+  libconfig_int     band[256];
+  int               num_eNB4RU                    = 0;
+  libconfig_int     eNB_list[256];
+
+  load_config_file(&cfg);
+
+  // Output a list of all RUs. 
+  setting = config_lookup(&cfg, CONFIG_STRING_RU_LIST);
+  
+  if (setting != NULL) {
+
+
+    if (RC.ru==NULL) RC.ru = (RU_t**)malloc(RC.nb_RU*sizeof(RU_t*));
+   
+    printf("Set RU mask to %x\n",RC.ru_mask);
+    RC.ru_mask=(1<<NB_RU) - 1;
+
+
+    for (j = 0; j < RC.nb_RU; j++) {
+      
+      setting_ru = config_setting_get_elem(setting, j);
+      printf("rru %d/%d\n",j,RC.nb_RU);
+				  
+      if (  !(
+	         config_setting_lookup_string(setting_ru, CONFIG_STRING_RU_LOCAL_IF_NAME,        (const char **)&if_name)
+	      && config_setting_lookup_string(setting_ru, CONFIG_STRING_RU_LOCAL_ADDRESS,        (const char **)&ipv4)
+	      && config_setting_lookup_string(setting_ru, CONFIG_STRING_RU_REMOTE_ADDRESS,       (const char **)&ipv4_remote)
+	      && config_setting_lookup_int   (setting_ru, CONFIG_STRING_RU_LOCAL_PORT,           &local_port)
+	      && config_setting_lookup_int   (setting_ru, CONFIG_STRING_RU_REMOTE_PORT,          &remote_port)
+	      && config_setting_lookup_string(setting_ru, CONFIG_STRING_RU_TRANSPORT_PREFERENCE, (const char **)&tr_preference)
+	      && config_setting_lookup_string(setting_ru, CONFIG_STRING_RU_LOCAL_RF,             (const char **)&local_rf)
+	      )
+	    ) {
+	AssertFatal (0,
+		     "Failed to parse configuration file %s, RU %d config !\n",
+		     RC.config_file_name, j);
+	continue; // FIXME will prevent segfaults below, not sure what happens at function exit...
+      }
+      if (strcmp(local_rf, "yes") == 0) { // this has a local RF unit so read in default params
+	if (  !(       config_setting_lookup_int(setting_ru, CONFIG_STRING_RU_NB_TX,       &nb_tx)
+		    && config_setting_lookup_int(setting_ru, CONFIG_STRING_RU_NB_RX,       &nb_rx)
+		    && config_setting_lookup_int(setting_ru, CONFIG_STRING_RU_MAX_RS_EPRE, &max_pdschReferenceSignalPower)
+		    && config_setting_lookup_int(setting_ru, CONFIG_STRING_RU_MAX_RXGAIN,  &max_rxgain)
+		    //		 && config_setting_lookup_int(setting_ru, CONFIG_STRING_RU_ATT_TX, &att_tx)
+		    //		 && config_setting_lookup_int(setting_ru, CONFIG_STRING_RU_ATT_RX, &att_rx)
+		 )
+	      ) {
+	  AssertFatal (0,
+		       "Failed to parse configuration file %s, RU %d config !\n",
+		       RC.config_file_name, j);
+	  continue; // FIXME will prevent segfaults below, not sure what happens at function exit...
+	}
+
+	AssertFatal((setting_band = config_setting_get_member(setting_ru, CONFIG_STRING_RU_BAND_LIST))!=NULL,"No allowable LTE bands\n");
+	
+	if (setting_band != NULL) num_bands    = config_setting_length(setting_band);
+	else num_bands=0;
+      
+	for (i=0;i<num_bands;i++) {
+	  setting_band_elem = config_setting_get_elem(setting_band,i);
+	  band[i] = config_setting_get_int(setting_band_elem);
+	  printf("RU %d: band %d\n",j,band[i]);
+	}
+      }
+      else {
+	AssertFatal((setting_eNB_list = config_setting_get_member(setting_ru, CONFIG_STRING_RU_ENB_LIST))!=NULL,"No RU<->eNB mappings\n");
+	
+	if (setting_eNB_list != NULL) num_eNB4RU    = config_setting_length(setting_eNB_list);
+	else num_eNB4RU=0;
+	AssertFatal(num_eNB4RU>0,"Number of eNBs is zero\n");
+
+	for (i=0;i<num_eNB4RU;i++) {
+	  setting_eNB_list_elem = config_setting_get_elem(setting_eNB_list,i);
+	  eNB_list[i] = config_setting_get_int(setting_eNB_list_elem);
+	  printf("RU %d: eNB %d\n",j,eNB_list[i]);
+	}
+	if (  !(       config_setting_lookup_int(setting_ru, CONFIG_STRING_RU_NB_TX,  &nb_tx)
+		       && config_setting_lookup_int(setting_ru, CONFIG_STRING_RU_NB_RX,  &nb_rx)
+		       && config_setting_lookup_int(setting_ru, CONFIG_STRING_RU_ATT_TX, &att_tx)
+		       && config_setting_lookup_int(setting_ru, CONFIG_STRING_RU_ATT_RX, &att_rx)
+		       )
+	      ) {
+	  AssertFatal (0,
+		       "Failed to parse configuration file %s, RU %d config !\n",
+		       RC.config_file_name, j);
+	  continue; // FIXME will prevent segfaults below, not sure what happens at function exit...
+	}
+
+      }
+      printf("RU %d: Transport %s\n",j,tr_preference);
+
+      if (RC.ru[j]==NULL) {
+	RC.ru[j]                                    = (RU_t*)malloc(sizeof(RU_t));
+	memset((void*)RC.ru[j],0,sizeof(RU_t));
+      }
+      RC.ru[j]->idx                                 = j;
+      RC.ru[j]->eth_params.local_if_name            = strdup(if_name);
+      RC.ru[j]->eth_params.my_addr                  = strdup(ipv4);
+      RC.ru[j]->eth_params.remote_addr              = strdup(ipv4_remote);
+      RC.ru[j]->eth_params.my_port                  = local_port;
+      RC.ru[j]->eth_params.remote_port              = remote_port;
+      RC.ru[j]->if_timing                           = synch_to_ext_device;
+      RC.ru[j]->num_eNB                             = num_eNB4RU;
+      if (strcmp(local_rf, "yes") == 0) {
+	if (strcmp(tr_preference, "udp") == 0) {
+	  RC.ru[j]->if_south                        = LOCAL_RF;
+	  RC.ru[j]->function                        = NGFI_RRU_IF5;
+	  RC.ru[j]->eth_params.transp_preference    = ETH_UDP_MODE;
+	} else if (strcmp(tr_preference, "raw") == 0) {
+	  RC.ru[j]->if_south                        = LOCAL_RF;
+	  RC.ru[j]->function                        = NGFI_RRU_IF5;
+	  RC.ru[j]->eth_params.transp_preference    = ETH_RAW_MODE;
+	} else if (strcmp(tr_preference, "udp_if4p5") == 0) {
+	  RC.ru[j]->if_south                        = LOCAL_RF;
+	  RC.ru[j]->function                        = NGFI_RRU_IF4p5;
+	  RC.ru[j]->eth_params.transp_preference    = ETH_UDP_IF4p5_MODE;
+	} else if (strcmp(tr_preference, "raw_if4p5") == 0) {
+	  RC.ru[j]->if_south                        = LOCAL_RF;
+	  RC.ru[j]->function                        = NGFI_RRU_IF4p5;
+	  RC.ru[j]->eth_params.transp_preference    = ETH_RAW_IF4p5_MODE;
+	}
+
+	RC.ru[j]->max_pdschReferenceSignalPower     = max_pdschReferenceSignalPower;
+	RC.ru[j]->max_rxgain                        = max_rxgain;
+	RC.ru[j]->num_bands                         = num_bands;
+	for (i=0;i<num_bands;i++) RC.ru[j]->band[i] = band[i]; 
+      }
+      else {
+
+	for (i=0;i<num_eNB4RU;i++) RC.ru[j]->eNB_list[i] = RC.eNB[eNB_list[i]][0];
+
+	if (strcmp(tr_preference, "udp") == 0) {
+	  RC.ru[j]->if_south                     = REMOTE_IF5;
+	  RC.ru[j]->function                     = NGFI_RAU_IF5;
+	  RC.ru[j]->eth_params.transp_preference = ETH_UDP_MODE;
+	} else if (strcmp(tr_preference, "raw") == 0) {
+	  RC.ru[j]->if_south                     = REMOTE_IF5;
+	  RC.ru[j]->function                     = NGFI_RAU_IF5;
+	  RC.ru[j]->eth_params.transp_preference = ETH_RAW_MODE;
+	} else if (strcmp(tr_preference, "udp_if4p5") == 0) {
+	  RC.ru[j]->if_south                     = REMOTE_IF4p5;
+	  RC.ru[j]->function                     = NGFI_RAU_IF4p5;
+	  RC.ru[j]->eth_params.transp_preference = ETH_UDP_IF4p5_MODE;
+	} else if (strcmp(tr_preference, "raw_if4p5") == 0) {
+	  RC.ru[j]->if_south                     = REMOTE_IF4p5;
+	  RC.ru[j]->function                     = NGFI_RAU_IF4p5;
+	  RC.ru[j]->eth_params.transp_preference = ETH_RAW_IF4p5_MODE;
+	} else if (strcmp(tr_preference, "raw_if5_mobipass") == 0) {
+	  RC.ru[j]->if_south                     = REMOTE_IF5;
+	  RC.ru[j]->function                     = NGFI_RAU_IF5;
+	  RC.ru[j]->if_timing                    = synch_to_other;
+	  RC.ru[j]->eth_params.transp_preference = ETH_RAW_IF5_MOBIPASS;
+	}
+	RC.ru[j]->att_tx                         = att_tx; 
+	RC.ru[j]->att_rx                         = att_rx; 
+      }
+
+      RC.ru[j]->nb_tx                             = nb_tx;
+      RC.ru[j]->nb_rx                             = nb_rx;
+      
+    }// j=0..num_rus
+  } else {
+    RC.nb_RU = 0;	    
+  } // setting != NULL
+
+  return;
+  
+}
+
+	       
+int RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc) {
   config_t          cfg;
   config_setting_t *setting                       = NULL;
   config_setting_t *subsetting                    = NULL;
@@ -538,26 +588,18 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP)
   config_setting_t *setting_srb1                  = NULL;
   config_setting_t *setting_mme_addresses         = NULL;
   config_setting_t *setting_mme_address           = NULL;
-  config_setting_t *setting_rrh_gws               = NULL;
-  config_setting_t *setting_rrh_gw                = NULL;
+  config_setting_t *setting_ru                    = NULL;
   config_setting_t *setting_enb                   = NULL;
   config_setting_t *setting_otg                   = NULL;
   config_setting_t *subsetting_otg                = NULL;
   int               parse_errors                  = 0;
-  int               num_enb_properties            = 0;
-  int               enb_properties_index          = 0;
   int               num_enbs                      = 0;
   int               num_mme_address               = 0;
-  int               num_rrh_gw                    = 0;
   int               num_otg_elements              = 0;
   int               num_component_carriers        = 0;
-  int               i                             = 0;
   int               j                             = 0;
   libconfig_int     enb_id                        = 0;
-
-  const char*       cc_node_function              = NULL; 
-  const char*       cc_node_timing                = NULL; 
-  int               cc_node_synch_ref             = 0;
+  int               nb_cc                         = 0;
 
   const char*       cell_type                     = NULL;
   const char*       tac                           = 0;
@@ -655,14 +697,11 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP)
   char*             ipv4                          = NULL;
   char*             ipv4_remote                   = NULL;
   char*             ipv6                          = NULL;
-  char*             active                        = NULL;
+  char*             local_rf                      = NULL;
   char*             preference                    = NULL;
+  char*             active                        = NULL;
 
   char*             tr_preference                 = NULL;
-  char*             rf_preference                 = NULL;
-  libconfig_int     tx_scheduling_advance         = 0;
-  libconfig_int     tx_sample_advance             = 0;
-  libconfig_int     iq_txshift                    = 0;
   libconfig_int     local_port                    = 0;
   libconfig_int     remote_port                   = 0;
   const char*       active_enb[MAX_ENB];
@@ -695,27 +734,23 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP)
   char*             pdcp_log_verbosity            = NULL;
   char*             rrc_log_level                 = NULL;
   char*             rrc_log_verbosity             = NULL;
-  char*             gtpu_log_level                = NULL;
-  char*             gtpu_log_verbosity            = NULL;
-  char*             udp_log_level                 = NULL;
   char*             udp_log_verbosity             = NULL;
   char*             osa_log_level                 = NULL;
   char*             osa_log_verbosity             = NULL;
 
-  /* for no gcc warnings */
+  // for no gcc warnings 
   (void)astring;
   (void)my_int;
 
-  memset((char*) (enb_properties.properties), 0 , MAX_ENB * sizeof(Enb_properties_t *));
   memset((char*)active_enb,     0 , MAX_ENB * sizeof(char*));
 
   config_init(&cfg);
 
-  if (lib_config_file_name_pP != NULL) {
-    /* Read the file. If there is an error, report it and exit. */
-    if (! config_read_file(&cfg, lib_config_file_name_pP)) {
+  if (RC.config_file_name != NULL) {
+    // Read the file. If there is an error, report it and exit. 
+    if (! config_read_file(&cfg, RC.config_file_name)) {
       config_destroy(&cfg);
-      AssertFatal (0, "Failed to parse eNB configuration file %s!\n", lib_config_file_name_pP);
+      AssertFatal (0, "Failed to parse eNB configuration file %s!\n", RC.config_file_name);
     }
   } else {
     config_destroy(&cfg);
@@ -741,2062 +776,2230 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP)
   }
 
 #endif
+
   // Get list of active eNBs, (only these will be configured)
   setting = config_lookup(&cfg, ENB_CONFIG_STRING_ACTIVE_ENBS);
 
   if (setting != NULL) {
     num_enbs = config_setting_length(setting);
-
-    for (i = 0; i < num_enbs; i++) {
-      setting_enb   = config_setting_get_elem(setting, i);
-      active_enb[i] = config_setting_get_string (setting_enb);
-      AssertFatal (active_enb[i] != NULL,
-                   "Failed to parse config file %s, %uth attribute %s \n",
-                   lib_config_file_name_pP, i, ENB_CONFIG_STRING_ACTIVE_ENBS);
-      active_enb[i] = strdup(active_enb[i]);
-      num_enb_properties += 1;
-    }
+    setting_enb   = config_setting_get_elem(setting, i);
+    active_enb[i] = config_setting_get_string (setting_enb);
+    AssertFatal (active_enb[i] != NULL,
+		 "Failed to parse config file %s, %uth attribute %s \n",
+		 RC.config_file_name, i, ENB_CONFIG_STRING_ACTIVE_ENBS);
+    active_enb[i] = strdup(active_enb[i]);
   }
+  
+  
+  if (num_enbs>0) {
+    // Output a list of all eNBs.
+    setting = config_lookup(&cfg, ENB_CONFIG_STRING_ENB_LIST);
+    
+    if (setting != NULL) {
+      num_enbs = config_setting_length(setting);
+      
 
-  /* Output a list of all eNBs. */
-  setting = config_lookup(&cfg, ENB_CONFIG_STRING_ENB_LIST);
-
-  if (setting != NULL) {
-    enb_properties_index = 0;
-    num_enbs = config_setting_length(setting);
-
-    for (i = 0; i < num_enbs; i++) {
       setting_enb = config_setting_get_elem(setting, i);
-
+      
       if (! config_setting_lookup_int(setting_enb, ENB_CONFIG_STRING_ENB_ID, &enb_id)) {
-        /* Calculate a default eNB ID */
+	// Calculate a default eNB ID
 # if defined(ENABLE_USE_MME)
-        uint32_t hash;
-
-        hash = s1ap_generate_eNB_id ();
-        enb_id = i + (hash & 0xFFFF8);
+	uint32_t hash;
+	
+	hash = s1ap_generate_eNB_id ();
+	enb_id = i + (hash & 0xFFFF8);
 # else
-        enb_id = i;
+	enb_id = i;
 # endif
       }
-
+      
       if (  !(       config_setting_lookup_string(setting_enb, ENB_CONFIG_STRING_CELL_TYPE,           &cell_type)
-                    && config_setting_lookup_string(setting_enb, ENB_CONFIG_STRING_ENB_NAME,            &enb_name)
-                    && config_setting_lookup_string(setting_enb, ENB_CONFIG_STRING_TRACKING_AREA_CODE,  &tac)
-                    && config_setting_lookup_string(setting_enb, ENB_CONFIG_STRING_MOBILE_COUNTRY_CODE, &mcc)
-                    && config_setting_lookup_string(setting_enb, ENB_CONFIG_STRING_MOBILE_NETWORK_CODE, &mnc)
-
-
-            )
-        ) {
-        AssertFatal (0,
-                     "Failed to parse eNB configuration file %s, %u th enb\n",
-                     lib_config_file_name_pP, i);
-        continue; // FIXME this prevents segfaults below, not sure what happens after function exit
+		     && config_setting_lookup_string(setting_enb, ENB_CONFIG_STRING_ENB_NAME,            &enb_name)
+		     && config_setting_lookup_string(setting_enb, ENB_CONFIG_STRING_TRACKING_AREA_CODE,  &tac)
+		     && config_setting_lookup_string(setting_enb, ENB_CONFIG_STRING_MOBILE_COUNTRY_CODE, &mcc)
+		     && config_setting_lookup_string(setting_enb, ENB_CONFIG_STRING_MOBILE_NETWORK_CODE, &mnc)
+		     
+		     
+		     )
+	    ) {
+	AssertFatal (0,
+		     "Failed to parse eNB configuration file %s, %u th enb\n",
+		     RC.config_file_name, i);
       }
-
+      
+      
       // search if in active list
-      for (j=0; j < num_enb_properties; j++) {
-        if (strcmp(active_enb[j], enb_name) == 0) {
-          enb_properties.properties[enb_properties_index] = calloc(1, sizeof(Enb_properties_t));
-
-          enb_properties.properties[enb_properties_index]->eNB_id   = enb_id;
-
-          if (strcmp(cell_type, "CELL_MACRO_ENB") == 0) {
-            enb_properties.properties[enb_properties_index]->cell_type = CELL_MACRO_ENB;
-          } else  if (strcmp(cell_type, "CELL_HOME_ENB") == 0) {
-            enb_properties.properties[enb_properties_index]->cell_type = CELL_HOME_ENB;
-          } else {
-            AssertFatal (0,
-                         "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for cell_type choice: CELL_MACRO_ENB or CELL_HOME_ENB !\n",
-                         lib_config_file_name_pP, i, cell_type);
-          }
-
-          enb_properties.properties[enb_properties_index]->eNB_name         = strdup(enb_name);
-          enb_properties.properties[enb_properties_index]->tac              = (uint16_t)atoi(tac);
-          enb_properties.properties[enb_properties_index]->mcc              = (uint16_t)atoi(mcc);
-          enb_properties.properties[enb_properties_index]->mnc              = (uint16_t)atoi(mnc);
-          enb_properties.properties[enb_properties_index]->mnc_digit_length = strlen(mnc);
-          AssertFatal((enb_properties.properties[enb_properties_index]->mnc_digit_length == 2) ||
-                      (enb_properties.properties[enb_properties_index]->mnc_digit_length == 3),
-                      "BAD MNC DIGIT LENGTH %d",
-                      enb_properties.properties[i]->mnc_digit_length);
-
-
-          // Parse optional physical parameters
-
-
-          setting_component_carriers = config_setting_get_member (setting_enb, ENB_CONFIG_STRING_COMPONENT_CARRIERS);
-          enb_properties.properties[enb_properties_index]->nb_cc = 0;
-
-          if (setting_component_carriers != NULL) {
-
-            num_component_carriers     = config_setting_length(setting_component_carriers);
-            printf("num component carrier %d \n", num_component_carriers);
-
-            //enb_properties.properties[enb_properties_index]->nb_cc = num_component_carriers;
-            for (j = 0; j < num_component_carriers /*&& j < MAX_NUM_CCs*/; j++) {
-              component_carrier = config_setting_get_elem(setting_component_carriers, j);
-
-              //printf("Component carrier %d\n",component_carrier);
-              if (!(config_setting_lookup_string(component_carrier, ENB_CONFIG_STRING_CC_NODE_FUNCTION, &cc_node_function)
-                   && config_setting_lookup_string(component_carrier, ENB_CONFIG_STRING_CC_NODE_TIMING, &cc_node_timing)
-                   && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_CC_NODE_SYNCH_REF, &cc_node_synch_ref)
-                   && config_setting_lookup_string(component_carrier, ENB_CONFIG_STRING_FRAME_TYPE, &frame_type)
-                   && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_TDD_CONFIG, &tdd_config)
-                   && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_TDD_CONFIG_S, &tdd_config_s)
-                   && config_setting_lookup_string(component_carrier, ENB_CONFIG_STRING_PREFIX_TYPE, &prefix_type)
-                   && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_EUTRA_BAND, &eutra_band)
-                   && config_setting_lookup_int64(component_carrier, ENB_CONFIG_STRING_DOWNLINK_FREQUENCY, &downlink_frequency)
-                   && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_UPLINK_FREQUENCY_OFFSET, &uplink_frequency_offset)
-                   && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_NID_CELL, &Nid_cell)
-                   && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_N_RB_DL, &N_RB_DL)
-                   && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_CELL_MBSFN, &Nid_cell_mbsfn)
-                   && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_NB_ANT_PORTS, &nb_antenna_ports)
-                   && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_NB_ANT_TX, &nb_antennas_tx)
-                   && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_NB_ANT_RX, &nb_antennas_rx)
-                   && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_TX_GAIN, &tx_gain)
-                   && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_RX_GAIN, &rx_gain)
-                   && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_PRACH_ROOT, &prach_root)
-                   && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_PRACH_CONFIG_INDEX, &prach_config_index)
-                   && config_setting_lookup_string(component_carrier, ENB_CONFIG_STRING_PRACH_HIGH_SPEED, &prach_high_speed)
-                   && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_PRACH_ZERO_CORRELATION, &prach_zero_correlation)
-                   && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_PRACH_FREQ_OFFSET, &prach_freq_offset)
-                   && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_PUCCH_DELTA_SHIFT, &pucch_delta_shift)
-                   && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_PUCCH_NRB_CQI, &pucch_nRB_CQI)
-                   && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_PUCCH_NCS_AN, &pucch_nCS_AN)
+      for (j=0; j < num_enbs; j++) {
+	if (strcmp(active_enb[j], enb_name) == 0) {
+	  
+	  RRC_CONFIGURATION_REQ (msg_p).cell_identity = enb_id;
+	  
+	  /*    
+		if (strcmp(cell_type, "CELL_MACRO_ENB") == 0) {
+		enb_properties_loc.properties[enb_properties_loc_index]->cell_type = CELL_MACRO_ENB;
+		} else  if (strcmp(cell_type, "CELL_HOME_ENB") == 0) {
+		enb_properties_loc.properties[enb_properties_loc_index]->cell_type = CELL_HOME_ENB;
+		} else {
+		AssertFatal (0,
+		"Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for cell_type choice: CELL_MACRO_ENB or CELL_HOME_ENB !\n",
+		lib_config_file_name_pP, i, cell_type);
+		}
+		
+		enb_properties_loc.properties[enb_properties_loc_index]->eNB_name         = strdup(enb_name);
+	  */
+	  RRC_CONFIGURATION_REQ (msg_p).tac              = (uint16_t)atoi(tac);
+	  RRC_CONFIGURATION_REQ (msg_p).mcc              = (uint16_t)atoi(mcc);
+	  RRC_CONFIGURATION_REQ (msg_p).mnc              = (uint16_t)atoi(mnc);
+	  RRC_CONFIGURATION_REQ (msg_p).mnc_digit_length = strlen(mnc);
+	  AssertFatal((RRC_CONFIGURATION_REQ (msg_p).mnc_digit_length == 2) ||
+		      (RRC_CONFIGURATION_REQ (msg_p).mnc_digit_length == 3),
+		      "BAD MNC DIGIT LENGTH %d",
+		      RRC_CONFIGURATION_REQ (msg_p).mnc_digit_length);
+	  
+	  LOG_I(RRC,"RRC config (%s,%s,%s)\n",mcc,mnc,tac);
+	  // Parse optional physical parameters
+	  
+	  
+	  setting_component_carriers = config_setting_get_member (setting_enb, ENB_CONFIG_STRING_COMPONENT_CARRIERS);
+	  nb_cc = 0;
+	  
+	  if (setting_component_carriers != NULL) {
+	    
+	    num_component_carriers     = config_setting_length(setting_component_carriers);
+	    LOG_I(RRC,"num component carriers %d \n", num_component_carriers);
+	    
+	    //enb_properties_loc.properties[enb_properties_loc_index]->nb_cc = num_component_carriers;
+	    for (j = 0; j < num_component_carriers ;j++) { // && j < MAX_NUM_CCs; j++) {
+	      component_carrier = config_setting_get_elem(setting_component_carriers, j);
+	      
+	      //printf("Component carrier %d\n",component_carrier);
+	      if (!(config_setting_lookup_string(component_carrier, ENB_CONFIG_STRING_FRAME_TYPE, &frame_type)
+		    && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_TDD_CONFIG, &tdd_config)
+		    && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_TDD_CONFIG_S, &tdd_config_s)
+		    && config_setting_lookup_string(component_carrier, ENB_CONFIG_STRING_PREFIX_TYPE, &prefix_type)
+		    && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_EUTRA_BAND, &eutra_band)
+		    && config_setting_lookup_int64(component_carrier, ENB_CONFIG_STRING_DOWNLINK_FREQUENCY, &downlink_frequency)
+		    && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_UPLINK_FREQUENCY_OFFSET, &uplink_frequency_offset)
+		    && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_NID_CELL, &Nid_cell)
+		    && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_N_RB_DL, &N_RB_DL)
+		    && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_CELL_MBSFN, &Nid_cell_mbsfn)
+		    && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_NB_ANT_PORTS, &nb_antenna_ports)
+		    && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_PRACH_ROOT, &prach_root)
+		    && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_PRACH_CONFIG_INDEX, &prach_config_index)
+		    && config_setting_lookup_string(component_carrier, ENB_CONFIG_STRING_PRACH_HIGH_SPEED, &prach_high_speed)
+		    && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_PRACH_ZERO_CORRELATION, &prach_zero_correlation)
+		    && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_PRACH_FREQ_OFFSET, &prach_freq_offset)
+		    && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_PUCCH_DELTA_SHIFT, &pucch_delta_shift)
+		    && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_PUCCH_NRB_CQI, &pucch_nRB_CQI)
+		    && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_PUCCH_NCS_AN, &pucch_nCS_AN)
 #ifndef Rel10
-                   && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_PUCCH_N1_AN, &pucch_n1_AN)
+		    && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_PUCCH_N1_AN, &pucch_n1_AN)
 #endif
-                   && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_PDSCH_RS_EPRE, &pdsch_referenceSignalPower)
-                   && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_PDSCH_PB, &pdsch_p_b)
-                   && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_PUSCH_N_SB, &pusch_n_SB)
-                   && config_setting_lookup_string(component_carrier, ENB_CONFIG_STRING_PUSCH_HOPPINGMODE, &pusch_hoppingMode)
-                   && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_PUSCH_HOPPINGOFFSET, &pusch_hoppingOffset)
-                   && config_setting_lookup_string(component_carrier, ENB_CONFIG_STRING_PUSCH_ENABLE64QAM, &pusch_enable64QAM)
-                   && config_setting_lookup_string(component_carrier, ENB_CONFIG_STRING_PUSCH_GROUP_HOPPING_EN, &pusch_groupHoppingEnabled)
-                   && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_PUSCH_GROUP_ASSIGNMENT, &pusch_groupAssignment)
-                   && config_setting_lookup_string(component_carrier, ENB_CONFIG_STRING_PUSCH_SEQUENCE_HOPPING_EN, &pusch_sequenceHoppingEnabled)
-                   && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_PUSCH_NDMRS1, &pusch_nDMRS1)
-                   && config_setting_lookup_string(component_carrier, ENB_CONFIG_STRING_PHICH_DURATION, &phich_duration)
-                   && config_setting_lookup_string(component_carrier, ENB_CONFIG_STRING_PHICH_RESOURCE, &phich_resource)
-                   && config_setting_lookup_string(component_carrier, ENB_CONFIG_STRING_SRS_ENABLE, &srs_enable)
-                   && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_PUSCH_PO_NOMINAL, &pusch_p0_Nominal)
-                   && config_setting_lookup_string(component_carrier, ENB_CONFIG_STRING_PUSCH_ALPHA, &pusch_alpha)
-                   && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_PUCCH_PO_NOMINAL, &pucch_p0_Nominal)
-                   && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_MSG3_DELTA_PREAMBLE, &msg3_delta_Preamble)
-                   && config_setting_lookup_string(component_carrier, ENB_CONFIG_STRING_PUCCH_DELTAF_FORMAT1, &pucch_deltaF_Format1)
-                   && config_setting_lookup_string(component_carrier, ENB_CONFIG_STRING_PUCCH_DELTAF_FORMAT1b, &pucch_deltaF_Format1b)
-                   && config_setting_lookup_string(component_carrier, ENB_CONFIG_STRING_PUCCH_DELTAF_FORMAT2, &pucch_deltaF_Format2)
-                   && config_setting_lookup_string(component_carrier, ENB_CONFIG_STRING_PUCCH_DELTAF_FORMAT2A, &pucch_deltaF_Format2a)
-                   && config_setting_lookup_string(component_carrier, ENB_CONFIG_STRING_PUCCH_DELTAF_FORMAT2B, &pucch_deltaF_Format2b)
-                   && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_RACH_NUM_RA_PREAMBLES, &rach_numberOfRA_Preambles)
-                   && config_setting_lookup_string(component_carrier, ENB_CONFIG_STRING_RACH_PREAMBLESGROUPACONFIG, &rach_preamblesGroupAConfig)
-                   && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_RACH_POWERRAMPINGSTEP, &rach_powerRampingStep)
-                   && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_RACH_PREAMBLEINITIALRECEIVEDTARGETPOWER, &rach_preambleInitialReceivedTargetPower)
-                   && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_RACH_PREAMBLETRANSMAX, &rach_preambleTransMax)
-                   && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_RACH_RARESPONSEWINDOWSIZE, &rach_raResponseWindowSize)
-                   && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_RACH_MACCONTENTIONRESOLUTIONTIMER, &rach_macContentionResolutionTimer)
-                   && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_RACH_MAXHARQMSG3TX, &rach_maxHARQ_Msg3Tx)
-                   && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_RACH_MAXHARQMSG3TX, &bcch_modificationPeriodCoeff)
-                   && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_PCCH_DEFAULT_PAGING_CYCLE,  &pcch_defaultPagingCycle)
-                   && config_setting_lookup_string(component_carrier, ENB_CONFIG_STRING_PCCH_NB,  &pcch_nB)
-                   && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_BCCH_MODIFICATIONPERIODCOEFF,  &bcch_modificationPeriodCoeff)
-                   && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_UETIMERS_T300,  &ue_TimersAndConstants_t300)
-                   && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_UETIMERS_T301,  &ue_TimersAndConstants_t301)
-                   && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_UETIMERS_T310,  &ue_TimersAndConstants_t310)
-                   && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_UETIMERS_T311,  &ue_TimersAndConstants_t311)
-                   && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_UETIMERS_N310,  &ue_TimersAndConstants_n310)
-                   && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_UETIMERS_N311,  &ue_TimersAndConstants_n311)
-                   && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_UE_TRANSMISSION_MODE,  &ue_TransmissionMode)
-
+		    && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_PDSCH_RS_EPRE, &pdsch_referenceSignalPower)
+		    && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_PDSCH_PB, &pdsch_p_b)
+		    && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_PUSCH_N_SB, &pusch_n_SB)
+		    && config_setting_lookup_string(component_carrier, ENB_CONFIG_STRING_PUSCH_HOPPINGMODE, &pusch_hoppingMode)
+		    && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_PUSCH_HOPPINGOFFSET, &pusch_hoppingOffset)
+		    && config_setting_lookup_string(component_carrier, ENB_CONFIG_STRING_PUSCH_ENABLE64QAM, &pusch_enable64QAM)
+		    && config_setting_lookup_string(component_carrier, ENB_CONFIG_STRING_PUSCH_GROUP_HOPPING_EN, &pusch_groupHoppingEnabled)
+		    && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_PUSCH_GROUP_ASSIGNMENT, &pusch_groupAssignment)
+		    && config_setting_lookup_string(component_carrier, ENB_CONFIG_STRING_PUSCH_SEQUENCE_HOPPING_EN, &pusch_sequenceHoppingEnabled)
+		    && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_PUSCH_NDMRS1, &pusch_nDMRS1)
+		    && config_setting_lookup_string(component_carrier, ENB_CONFIG_STRING_PHICH_DURATION, &phich_duration)
+		    && config_setting_lookup_string(component_carrier, ENB_CONFIG_STRING_PHICH_RESOURCE, &phich_resource)
+		    && config_setting_lookup_string(component_carrier, ENB_CONFIG_STRING_SRS_ENABLE, &srs_enable)
+		    && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_PUSCH_PO_NOMINAL, &pusch_p0_Nominal)
+		    && config_setting_lookup_string(component_carrier, ENB_CONFIG_STRING_PUSCH_ALPHA, &pusch_alpha)
+		    && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_PUCCH_PO_NOMINAL, &pucch_p0_Nominal)
+		    && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_MSG3_DELTA_PREAMBLE, &msg3_delta_Preamble)
+		    && config_setting_lookup_string(component_carrier, ENB_CONFIG_STRING_PUCCH_DELTAF_FORMAT1, &pucch_deltaF_Format1)
+		    && config_setting_lookup_string(component_carrier, ENB_CONFIG_STRING_PUCCH_DELTAF_FORMAT1b, &pucch_deltaF_Format1b)
+		    && config_setting_lookup_string(component_carrier, ENB_CONFIG_STRING_PUCCH_DELTAF_FORMAT2, &pucch_deltaF_Format2)
+		    && config_setting_lookup_string(component_carrier, ENB_CONFIG_STRING_PUCCH_DELTAF_FORMAT2A, &pucch_deltaF_Format2a)
+		    && config_setting_lookup_string(component_carrier, ENB_CONFIG_STRING_PUCCH_DELTAF_FORMAT2B, &pucch_deltaF_Format2b)
+		    && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_RACH_NUM_RA_PREAMBLES, &rach_numberOfRA_Preambles)
+		    && config_setting_lookup_string(component_carrier, ENB_CONFIG_STRING_RACH_PREAMBLESGROUPACONFIG, &rach_preamblesGroupAConfig)
+		    && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_RACH_POWERRAMPINGSTEP, &rach_powerRampingStep)
+		    && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_RACH_PREAMBLEINITIALRECEIVEDTARGETPOWER, &rach_preambleInitialReceivedTargetPower)
+		    && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_RACH_PREAMBLETRANSMAX, &rach_preambleTransMax)
+		    && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_RACH_RARESPONSEWINDOWSIZE, &rach_raResponseWindowSize)
+		    && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_RACH_MACCONTENTIONRESOLUTIONTIMER, &rach_macContentionResolutionTimer)
+		    && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_RACH_MAXHARQMSG3TX, &rach_maxHARQ_Msg3Tx)
+		    && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_RACH_MAXHARQMSG3TX, &bcch_modificationPeriodCoeff)
+		    && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_PCCH_DEFAULT_PAGING_CYCLE,  &pcch_defaultPagingCycle)
+		    && config_setting_lookup_string(component_carrier, ENB_CONFIG_STRING_PCCH_NB,  &pcch_nB)
+		    && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_BCCH_MODIFICATIONPERIODCOEFF,  &bcch_modificationPeriodCoeff)
+		    && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_UETIMERS_T300,  &ue_TimersAndConstants_t300)
+		    && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_UETIMERS_T301,  &ue_TimersAndConstants_t301)
+		    && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_UETIMERS_T310,  &ue_TimersAndConstants_t310)
+		    && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_UETIMERS_T311,  &ue_TimersAndConstants_t311)
+		    && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_UETIMERS_N310,  &ue_TimersAndConstants_n310)
+		    && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_UETIMERS_N311,  &ue_TimersAndConstants_n311)
+		    && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_UE_TRANSMISSION_MODE,  &ue_TransmissionMode)
+		    
 #ifdef Rel10
-
+		    
 #endif
-                  )) {
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, Component Carrier %d!\n",
-                             lib_config_file_name_pP, enb_properties.properties[enb_properties_index]->nb_cc++);
-                continue; // FIXME this prevents segfaults below, not sure what happens after function exit
-              }
-
-              enb_properties.properties[enb_properties_index]->nb_cc++;
-
-              if (strcmp(cc_node_function, "eNodeB_3GPP") == 0) {
-                enb_properties.properties[enb_properties_index]->cc_node_function[j] = eNodeB_3GPP;
-              } else if (strcmp(cc_node_function, "eNodeB_3GPP_BBU") == 0) {
-                enb_properties.properties[enb_properties_index]->cc_node_function[j] = eNodeB_3GPP_BBU;
-              } else if (strcmp(cc_node_function, "NGFI_RCC_IF4p5") == 0) {
-                enb_properties.properties[enb_properties_index]->cc_node_function[j] = NGFI_RCC_IF4p5;
-              } else if (strcmp(cc_node_function, "NGFI_RAU_IF4p5") == 0) {
-                enb_properties.properties[enb_properties_index]->cc_node_function[j] = NGFI_RAU_IF4p5;
-              } else if (strcmp(cc_node_function, "NGFI_RRU_IF4p5") == 0) {
-                enb_properties.properties[enb_properties_index]->cc_node_function[j] = NGFI_RRU_IF4p5;
-              } else if (strcmp(cc_node_function, "NGFI_RRU_IF5") == 0) {
-                enb_properties.properties[enb_properties_index]->cc_node_function[j] = NGFI_RRU_IF5;
-              } else {
-                AssertError (0, parse_errors ++,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for node_function choice: eNodeB_3GPP or eNodeB_3GPP_BBU or NGFI_IF4_RCC or NGFI_IF4_RRU or NGFI_IF5_RRU !\n",
-                             lib_config_file_name_pP, i, cc_node_function);
-              }
-
-              if (strcmp(cc_node_timing, "synch_to_ext_device") == 0) {
-                enb_properties.properties[enb_properties_index]->cc_node_timing[j] = synch_to_ext_device;
-              } else if (strcmp(cc_node_timing, "synch_to_other") == 0) {
-                enb_properties.properties[enb_properties_index]->cc_node_timing[j] = synch_to_other;
-              } else {
-                AssertError (0, parse_errors ++,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for node_function choice: SYNCH_TO_DEVICE or SYNCH_TO_OTHER !\n",
-                             lib_config_file_name_pP, i, cc_node_timing);
-              }
-
-              if ((cc_node_synch_ref >= -1) && (cc_node_synch_ref < num_component_carriers)) {  
-               enb_properties.properties[enb_properties_index]->cc_node_synch_ref[j] = (int16_t) cc_node_synch_ref; 
-              } else {
-                AssertError (0, parse_errors ++,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for node_synch_ref choice: valid CC_id or -1 !\n",
-                             lib_config_file_name_pP, i, cc_node_synch_ref);
-              }
-              
-              enb_properties.properties[enb_properties_index]->tdd_config[j] = tdd_config;
-              AssertFatal (tdd_config <= TDD_Config__subframeAssignment_sa6,
-                           "Failed to parse eNB configuration file %s, enb %d illegal tdd_config %d (should be 0-%d)!",
-                           lib_config_file_name_pP, i, tdd_config, TDD_Config__subframeAssignment_sa6);
-
-              enb_properties.properties[enb_properties_index]->tdd_config_s[j] = tdd_config_s;
-              AssertFatal (tdd_config_s <= TDD_Config__specialSubframePatterns_ssp8,
-                           "Failed to parse eNB configuration file %s, enb %d illegal tdd_config_s %d (should be 0-%d)!",
-                           lib_config_file_name_pP, i, tdd_config_s, TDD_Config__specialSubframePatterns_ssp8);
-
-              if (!prefix_type)
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d define %s: NORMAL,EXTENDED!\n",
-                             lib_config_file_name_pP, i, ENB_CONFIG_STRING_PREFIX_TYPE);
-              else if (strcmp(prefix_type, "NORMAL") == 0) {
-                enb_properties.properties[enb_properties_index]->prefix_type[j] = NORMAL;
-              } else  if (strcmp(prefix_type, "EXTENDED") == 0) {
-                enb_properties.properties[enb_properties_index]->prefix_type[j] = EXTENDED;
-              } else {
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for prefix_type choice: NORMAL or EXTENDED !\n",
-                             lib_config_file_name_pP, i, prefix_type);
-              }
+		    )) {
+		AssertFatal (0,
+			     "Failed to parse eNB configuration file %s, Component Carrier %d!\n",
+			     RC.config_file_name, nb_cc++);
+		continue; // FIXME this prevents segfaults below, not sure what happens after function exit
+	      }
+	      
+	      nb_cc++;
+	      /*
+		if (strcmp(cc_node_function, "eNodeB_3GPP") == 0) {
+		enb_properties_loc.properties[enb_properties_loc_index]->cc_node_function[j] = eNodeB_3GPP;
+		} else if (strcmp(cc_node_function, "eNodeB_3GPP_BBU") == 0) {
+		enb_properties_loc.properties[enb_properties_loc_index]->cc_node_function[j] = eNodeB_3GPP_BBU;
+		} else if (strcmp(cc_node_function, "NGFI_RCC_IF4p5") == 0) {
+		enb_properties_loc.properties[enb_properties_loc_index]->cc_node_function[j] = NGFI_RCC_IF4p5;
+		} else if (strcmp(cc_node_function, "NGFI_RAU_IF4p5") == 0) {
+		enb_properties_loc.properties[enb_properties_loc_index]->cc_node_function[j] = NGFI_RAU_IF4p5;
+		} else if (strcmp(cc_node_function, "NGFI_RRU_IF4p5") == 0) {
+		enb_properties_loc.properties[enb_properties_loc_index]->cc_node_function[j] = NGFI_RRU_IF4p5;
+		} else if (strcmp(cc_node_function, "NGFI_RRU_IF5") == 0) {
+		enb_properties_loc.properties[enb_properties_loc_index]->cc_node_function[j] = NGFI_RRU_IF5;
+		} else {
+		AssertError (0, parse_errors ++,
+		"Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for node_function choice: eNodeB_3GPP or eNodeB_3GPP_BBU or NGFI_IF4_RCC or NGFI_IF4_RRU or NGFI_IF5_RRU !\n",
+		lib_config_file_name_pP, i, cc_node_function);
+		}
+		
+		if (strcmp(cc_node_timing, "synch_to_ext_device") == 0) {
+		enb_properties_loc.properties[enb_properties_loc_index]->cc_node_timing[j] = synch_to_ext_device;
+		} else if (strcmp(cc_node_timing, "synch_to_other") == 0) {
+		enb_properties_loc.properties[enb_properties_loc_index]->cc_node_timing[j] = synch_to_other;
+		} else {
+		AssertError (0, parse_errors ++,
+		"Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for node_function choice: SYNCH_TO_DEVICE or SYNCH_TO_OTHER !\n",
+		lib_config_file_name_pP, i, cc_node_timing);
+		}
+		
+		if ((cc_node_synch_ref >= -1) && (cc_node_synch_ref < num_component_carriers)) {  
+		enb_properties_loc.properties[enb_properties_loc_index]->cc_node_synch_ref[j] = (int16_t) cc_node_synch_ref; 
+		} else {
+		AssertError (0, parse_errors ++,
+		"Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for node_synch_ref choice: valid CC_id or -1 !\n",
+		lib_config_file_name_pP, i, cc_node_synch_ref);
+		}
+	      */
+	      
+	      RRC_CONFIGURATION_REQ (msg_p).tdd_config[j] = tdd_config;
+	      
+	      AssertFatal (tdd_config <= TDD_Config__subframeAssignment_sa6,
+			   "Failed to parse eNB configuration file %s, enb %d illegal tdd_config %d (should be 0-%d)!",
+			   RC.config_file_name, i, tdd_config, TDD_Config__subframeAssignment_sa6);
+	      
+	      RRC_CONFIGURATION_REQ (msg_p).tdd_config_s[j] = tdd_config_s;
+	      AssertFatal (tdd_config_s <= TDD_Config__specialSubframePatterns_ssp8,
+			   "Failed to parse eNB configuration file %s, enb %d illegal tdd_config_s %d (should be 0-%d)!",
+			   RC.config_file_name, i, tdd_config_s, TDD_Config__specialSubframePatterns_ssp8);
+	      
+	      if (!prefix_type)
+		AssertFatal (0,
+			     "Failed to parse eNB configuration file %s, enb %d define %s: NORMAL,EXTENDED!\n",
+			     RC.config_file_name, i, ENB_CONFIG_STRING_PREFIX_TYPE);
+	      else if (strcmp(prefix_type, "NORMAL") == 0) {
+		RRC_CONFIGURATION_REQ (msg_p).prefix_type[j] = NORMAL;
+	      } else  if (strcmp(prefix_type, "EXTENDED") == 0) {
+		RRC_CONFIGURATION_REQ (msg_p).prefix_type[j] = EXTENDED;
+	      } else {
+		AssertFatal (0,
+			     "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for prefix_type choice: NORMAL or EXTENDED !\n",
+			     RC.config_file_name, i, prefix_type);
+	      }
               
-              enb_properties.properties[enb_properties_index]->eutra_band[j] = eutra_band;
-              enb_properties.properties[enb_properties_index]->downlink_frequency[j] = (uint32_t) downlink_frequency;
-              enb_properties.properties[enb_properties_index]->uplink_frequency_offset[j] = (unsigned int) uplink_frequency_offset;
-              enb_properties.properties[enb_properties_index]->Nid_cell[j]= Nid_cell;
-
-              if (Nid_cell>503) {
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for Nid_cell choice: 0...503 !\n",
-                             lib_config_file_name_pP, i, Nid_cell);
-              }
-
-              enb_properties.properties[enb_properties_index]->N_RB_DL[j]= N_RB_DL;
-
-              if ((N_RB_DL!=6) && (N_RB_DL!=15) && (N_RB_DL!=25) && (N_RB_DL!=50) && (N_RB_DL!=75) && (N_RB_DL!=100)) {
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for N_RB_DL choice: 6,15,25,50,75,100 !\n",
-                             lib_config_file_name_pP, i, N_RB_DL);
-              }
-
-              if (strcmp(frame_type, "FDD") == 0) {
-                enb_properties.properties[enb_properties_index]->frame_type[j] = FDD;
-              } else  if (strcmp(frame_type, "TDD") == 0) {
-                enb_properties.properties[enb_properties_index]->frame_type[j] = TDD;
-              } else {
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for frame_type choice: FDD or TDD !\n",
-                             lib_config_file_name_pP, i, frame_type);
-              }
-
+	      RRC_CONFIGURATION_REQ (msg_p).eutra_band[j] = eutra_band;
+	      RRC_CONFIGURATION_REQ (msg_p).downlink_frequency[j] = (uint32_t) downlink_frequency;
+	      RRC_CONFIGURATION_REQ (msg_p).uplink_frequency_offset[j] = (unsigned int) uplink_frequency_offset;
+	      RRC_CONFIGURATION_REQ (msg_p).Nid_cell[j]= Nid_cell;
+	      
+	      if (Nid_cell>503) {
+		AssertFatal (0,
+			     "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for Nid_cell choice: 0...503 !\n",
+			     RC.config_file_name, i, Nid_cell);
+	      }
+	      
+	      RRC_CONFIGURATION_REQ (msg_p).N_RB_DL[j]= N_RB_DL;
+	      
+	      if ((N_RB_DL!=6) && (N_RB_DL!=15) && (N_RB_DL!=25) && (N_RB_DL!=50) && (N_RB_DL!=75) && (N_RB_DL!=100)) {
+		AssertFatal (0,
+			     "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for N_RB_DL choice: 6,15,25,50,75,100 !\n",
+			     RC.config_file_name, i, N_RB_DL);
+	      }
+	      
+	      if (strcmp(frame_type, "FDD") == 0) {
+		RRC_CONFIGURATION_REQ (msg_p).frame_type[j] = FDD;
+	      } else  if (strcmp(frame_type, "TDD") == 0) {
+		RRC_CONFIGURATION_REQ (msg_p).frame_type[j] = TDD;
+	      } else {
+		AssertFatal (0,
+			     "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for frame_type choice: FDD or TDD !\n",
+			     RC.config_file_name, i, frame_type);
+	      }
+	      
+	      
+	      RRC_CONFIGURATION_REQ (msg_p).tdd_config[j] = tdd_config;
+	      AssertFatal (tdd_config <= TDD_Config__subframeAssignment_sa6,
+			   "Failed to parse eNB configuration file %s, enb %d illegal tdd_config %d (should be 0-%d)!",
+			   RC.config_file_name, i, tdd_config, TDD_Config__subframeAssignment_sa6);
+	      
+	      
+	      RRC_CONFIGURATION_REQ (msg_p).tdd_config_s[j] = tdd_config_s;
+	      AssertFatal (tdd_config_s <= TDD_Config__specialSubframePatterns_ssp8,
+			   "Failed to parse eNB configuration file %s, enb %d illegal tdd_config_s %d (should be 0-%d)!",
+			   RC.config_file_name, i, tdd_config_s, TDD_Config__specialSubframePatterns_ssp8);
+	      
+	      
+	      
+	      if (!prefix_type)
+		AssertFatal (0,
+			     "Failed to parse eNB configuration file %s, enb %d define %s: NORMAL,EXTENDED!\n",
+			     RC.config_file_name, i, ENB_CONFIG_STRING_PREFIX_TYPE);
+	      else if (strcmp(prefix_type, "NORMAL") == 0) {
+		RRC_CONFIGURATION_REQ (msg_p).prefix_type[j] = NORMAL;
+	      } else  if (strcmp(prefix_type, "EXTENDED") == 0) {
+		RRC_CONFIGURATION_REQ (msg_p).prefix_type[j] = EXTENDED;
+	      } else {
+		AssertFatal (0,
+			     "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for prefix_type choice: NORMAL or EXTENDED !\n",
+			     RC.config_file_name, i, prefix_type);
+	      }
+	      
+	      
+	      
+	      RRC_CONFIGURATION_REQ (msg_p).eutra_band[j] = eutra_band;
+	      // printf( "\teutra band:\t%d\n",RRC_CONFIGURATION_REQ (msg_p).eutra_band);
+	      
+	      
+	      
+	      RRC_CONFIGURATION_REQ (msg_p).downlink_frequency[j] = (uint32_t) downlink_frequency;
+	      //printf( "\tdownlink freq:\t%u\n",RRC_CONFIGURATION_REQ (msg_p).downlink_frequency);
+	      
+	      
+	      RRC_CONFIGURATION_REQ (msg_p).uplink_frequency_offset[j] = (unsigned int) uplink_frequency_offset;
+	      
+	      if (enb_check_band_frequencies(RC.config_file_name,
+					     j,
+					     RRC_CONFIGURATION_REQ (msg_p).eutra_band[j],
+					     RRC_CONFIGURATION_REQ (msg_p).downlink_frequency[j],
+					     RRC_CONFIGURATION_REQ (msg_p).uplink_frequency_offset[j],
+					     RRC_CONFIGURATION_REQ (msg_p).frame_type[j])) {
+		AssertFatal(0, "error calling enb_check_band_frequencies\n");
+	      }
+	      
+	      if ((nb_antenna_ports <1) || (nb_antenna_ports > 2))
+		AssertFatal (0,
+			     "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for nb_antenna_ports choice: 1..2 !\n",
+			     RC.config_file_name, i, nb_antenna_ports);
+	      
+	      RRC_CONFIGURATION_REQ (msg_p).nb_antenna_ports[j] = nb_antenna_ports;
+	      
+	      
+	      RRC_CONFIGURATION_REQ (msg_p).prach_root[j] =  prach_root;
+	      
+	      if ((prach_root <0) || (prach_root > 1023))
+		AssertFatal (0,
+			     "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for prach_root choice: 0..1023 !\n",
+			     RC.config_file_name, i, prach_root);
+	      
+	      RRC_CONFIGURATION_REQ (msg_p).prach_config_index[j] = prach_config_index;
+	      
+	      if ((prach_config_index <0) || (prach_config_index > 63))
+		AssertFatal (0,
+			     "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for prach_config_index choice: 0..1023 !\n",
+			     RC.config_file_name, i, prach_config_index);
+	      
+	      if (!prach_high_speed)
+		AssertFatal (0,
+			     "Failed to parse eNB configuration file %s, enb %d define %s: ENABLE,DISABLE!\n",
+			     RC.config_file_name, i, ENB_CONFIG_STRING_PRACH_HIGH_SPEED);
+	      else if (strcmp(prach_high_speed, "ENABLE") == 0) {
+		RRC_CONFIGURATION_REQ (msg_p).prach_high_speed[j] = TRUE;
+	      } else if (strcmp(prach_high_speed, "DISABLE") == 0) {
+		RRC_CONFIGURATION_REQ (msg_p).prach_high_speed[j] = FALSE;
+	      } else
+		AssertFatal (0,
+			     "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for prach_config choice: ENABLE,DISABLE !\n",
+			     RC.config_file_name, i, prach_high_speed);
+	      
+	      RRC_CONFIGURATION_REQ (msg_p).prach_zero_correlation[j] =prach_zero_correlation;
+	      
+	      if ((prach_zero_correlation <0) || (prach_zero_correlation > 15))
+		AssertFatal (0,
+			     "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for prach_zero_correlation choice: 0..15!\n",
+			     RC.config_file_name, i, prach_zero_correlation);
+	      
+	      RRC_CONFIGURATION_REQ (msg_p).prach_freq_offset[j] = prach_freq_offset;
+	      
+	      if ((prach_freq_offset <0) || (prach_freq_offset > 94))
+		AssertFatal (0,
+			     "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for prach_freq_offset choice: 0..94!\n",
+			     RC.config_file_name, i, prach_freq_offset);
+	      
+	      
+	      RRC_CONFIGURATION_REQ (msg_p).pucch_delta_shift[j] = pucch_delta_shift-1;
+	      
+	      if ((pucch_delta_shift <1) || (pucch_delta_shift > 3))
+		AssertFatal (0,
+			     "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pucch_delta_shift choice: 1..3!\n",
+			     RC.config_file_name, i, pucch_delta_shift);
+	      
+		RRC_CONFIGURATION_REQ (msg_p).pucch_nRB_CQI[j] = pucch_nRB_CQI;
 
-              enb_properties.properties[enb_properties_index]->tdd_config[j] = tdd_config;
-              AssertFatal (tdd_config <= TDD_Config__subframeAssignment_sa6,
-                           "Failed to parse eNB configuration file %s, enb %d illegal tdd_config %d (should be 0-%d)!",
-                           lib_config_file_name_pP, i, tdd_config, TDD_Config__subframeAssignment_sa6);
+		if ((pucch_nRB_CQI <0) || (pucch_nRB_CQI > 98))
+		  AssertFatal (0,
+			       "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pucch_nRB_CQI choice: 0..98!\n",
+			       RC.config_file_name, i, pucch_nRB_CQI);
 
+		RRC_CONFIGURATION_REQ (msg_p).pucch_nCS_AN[j] = pucch_nCS_AN;
 
-              enb_properties.properties[enb_properties_index]->tdd_config_s[j] = tdd_config_s;
-              AssertFatal (tdd_config_s <= TDD_Config__specialSubframePatterns_ssp8,
-                           "Failed to parse eNB configuration file %s, enb %d illegal tdd_config_s %d (should be 0-%d)!",
-                           lib_config_file_name_pP, i, tdd_config_s, TDD_Config__specialSubframePatterns_ssp8);
+		if ((pucch_nCS_AN <0) || (pucch_nCS_AN > 7))
+		  AssertFatal (0,
+			       "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pucch_nCS_AN choice: 0..7!\n",
+			       RC.config_file_name, i, pucch_nCS_AN);
 
+#ifndef Rel10
+		RRC_CONFIGURATION_REQ (msg_p).pucch_n1_AN[j] = pucch_n1_AN;
 
+		if ((pucch_n1_AN <0) || (pucch_n1_AN > 2047))
+		  AssertFatal (0,
+			       "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pucch_n1_AN choice: 0..2047!\n",
+			       RC.config_file_name, i, pucch_n1_AN);
 
-              if (!prefix_type)
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d define %s: NORMAL,EXTENDED!\n",
-                             lib_config_file_name_pP, i, ENB_CONFIG_STRING_PREFIX_TYPE);
-              else if (strcmp(prefix_type, "NORMAL") == 0) {
-                enb_properties.properties[enb_properties_index]->prefix_type[j] = NORMAL;
-              } else  if (strcmp(prefix_type, "EXTENDED") == 0) {
-                enb_properties.properties[enb_properties_index]->prefix_type[j] = EXTENDED;
-              } else {
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for prefix_type choice: NORMAL or EXTENDED !\n",
-                             lib_config_file_name_pP, i, prefix_type);
-              }
+#endif
+		RRC_CONFIGURATION_REQ (msg_p).pdsch_referenceSignalPower[j] = pdsch_referenceSignalPower;
+
+		if ((pdsch_referenceSignalPower <-60) || (pdsch_referenceSignalPower > 50))
+		  AssertFatal (0,
+			       "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pdsch_referenceSignalPower choice:-60..50!\n",
+			       RC.config_file_name, i, pdsch_referenceSignalPower);
+
+		RRC_CONFIGURATION_REQ (msg_p).pdsch_p_b[j] = pdsch_p_b;
+
+		if ((pdsch_p_b <0) || (pdsch_p_b > 3))
+		  AssertFatal (0,
+			       "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pdsch_p_b choice: 0..3!\n",
+			       RC.config_file_name, i, pdsch_p_b);
+
+		RRC_CONFIGURATION_REQ (msg_p).pusch_n_SB[j] = pusch_n_SB;
+
+		if ((pusch_n_SB <1) || (pusch_n_SB > 4))
+		  AssertFatal (0,
+			       "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pusch_n_SB choice: 1..4!\n",
+			       RC.config_file_name, i, pusch_n_SB);
+
+		if (!pusch_hoppingMode)
+		  AssertFatal (0,
+			       "Failed to parse eNB configuration file %s, enb %d define %s: interSubframe,intraAndInterSubframe!\n",
+			       RC.config_file_name, i, ENB_CONFIG_STRING_PUSCH_HOPPINGMODE);
+		else if (strcmp(pusch_hoppingMode,"interSubFrame")==0) {
+		  RRC_CONFIGURATION_REQ (msg_p).pusch_hoppingMode[j] = PUSCH_ConfigCommon__pusch_ConfigBasic__hoppingMode_interSubFrame;
+		}  else if (strcmp(pusch_hoppingMode,"intraAndInterSubFrame")==0) {
+		  RRC_CONFIGURATION_REQ (msg_p).pusch_hoppingMode[j] = PUSCH_ConfigCommon__pusch_ConfigBasic__hoppingMode_intraAndInterSubFrame;
+		} else
+		  AssertFatal (0,
+			       "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pusch_hoppingMode choice: interSubframe,intraAndInterSubframe!\n",
+			       RC.config_file_name, i, pusch_hoppingMode);
+
+		RRC_CONFIGURATION_REQ (msg_p).pusch_hoppingOffset[j] = pusch_hoppingOffset;
+
+		if ((pusch_hoppingOffset<0) || (pusch_hoppingOffset>98))
+		  AssertFatal (0,
+			       "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pusch_hoppingOffset choice: 0..98!\n",
+			       RC.config_file_name, i, pusch_hoppingMode);
+
+		if (!pusch_enable64QAM)
+		  AssertFatal (0, 
+			       "Failed to parse eNB configuration file %s, enb %d define %s: ENABLE,DISABLE!\n",
+			       RC.config_file_name, i, ENB_CONFIG_STRING_PUSCH_ENABLE64QAM);
+		else if (strcmp(pusch_enable64QAM, "ENABLE") == 0) {
+		  RRC_CONFIGURATION_REQ (msg_p).pusch_enable64QAM[j] = TRUE;
+		}  else if (strcmp(pusch_enable64QAM, "DISABLE") == 0) {
+		  RRC_CONFIGURATION_REQ (msg_p).pusch_enable64QAM[j] = FALSE;
+		} else
+		  AssertFatal (0,
+			       "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pusch_enable64QAM choice: ENABLE,DISABLE!\n",
+			       RC.config_file_name, i, pusch_enable64QAM);
+
+		if (!pusch_groupHoppingEnabled)
+		  AssertFatal (0,
+			       "Failed to parse eNB configuration file %s, enb %d define %s: ENABLE,DISABLE!\n",
+			       RC.config_file_name, i, ENB_CONFIG_STRING_PUSCH_GROUP_HOPPING_EN);
+		else if (strcmp(pusch_groupHoppingEnabled, "ENABLE") == 0) {
+		  RRC_CONFIGURATION_REQ (msg_p).pusch_groupHoppingEnabled[j] = TRUE;
+		}  else if (strcmp(pusch_groupHoppingEnabled, "DISABLE") == 0) {
+		  RRC_CONFIGURATION_REQ (msg_p).pusch_groupHoppingEnabled[j] = FALSE;
+		} else
+		  AssertFatal (0,
+			       "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pusch_groupHoppingEnabled choice: ENABLE,DISABLE!\n",
+			       RC.config_file_name, i, pusch_groupHoppingEnabled);
+
+
+		RRC_CONFIGURATION_REQ (msg_p).pusch_groupAssignment[j] = pusch_groupAssignment;
+
+		if ((pusch_groupAssignment<0)||(pusch_groupAssignment>29))
+		  AssertFatal (0,
+			       "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pusch_groupAssignment choice: 0..29!\n",
+			       RC.config_file_name, i, pusch_groupAssignment);
+
+		if (!pusch_sequenceHoppingEnabled)
+		  AssertFatal (0,
+			       "Failed to parse eNB configuration file %s, enb %d define %s: ENABLE,DISABLE!\n",
+			       RC.config_file_name, i, ENB_CONFIG_STRING_PUSCH_SEQUENCE_HOPPING_EN);
+		else if (strcmp(pusch_sequenceHoppingEnabled, "ENABLE") == 0) {
+		  RRC_CONFIGURATION_REQ (msg_p).pusch_sequenceHoppingEnabled[j] = TRUE;
+		}  else if (strcmp(pusch_sequenceHoppingEnabled, "DISABLE") == 0) {
+		  RRC_CONFIGURATION_REQ (msg_p).pusch_sequenceHoppingEnabled[j] = FALSE;
+		} else
+		  AssertFatal (0,
+			       "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pusch_sequenceHoppingEnabled choice: ENABLE,DISABLE!\n",
+			       RC.config_file_name, i, pusch_sequenceHoppingEnabled);
+
+		RRC_CONFIGURATION_REQ (msg_p).pusch_nDMRS1[j] = pusch_nDMRS1;  //cyclic_shift in RRC!
+
+		if ((pusch_nDMRS1 <0) || (pusch_nDMRS1>7))
+		  AssertFatal (0,
+			       "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pusch_nDMRS1 choice: 0..7!\n",
+			       RC.config_file_name, i, pusch_nDMRS1);
+
+		if (strcmp(phich_duration,"NORMAL")==0) {
+		  RRC_CONFIGURATION_REQ (msg_p).phich_duration[j] = normal;
+		} else if (strcmp(phich_duration,"EXTENDED")==0) {
+		  RRC_CONFIGURATION_REQ (msg_p).phich_duration[j] = extended;
+		} else
+		  AssertFatal (0,
+			       "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for phich_duration choice: NORMAL,EXTENDED!\n",
+			       RC.config_file_name, i, phich_duration);
+
+		if (strcmp(phich_resource,"ONESIXTH")==0) {
+		  RRC_CONFIGURATION_REQ (msg_p).phich_resource[j] = oneSixth;
+		} else if (strcmp(phich_resource,"HALF")==0) {
+		  RRC_CONFIGURATION_REQ (msg_p).phich_resource[j] = half;
+		} else if (strcmp(phich_resource,"ONE")==0) {
+		  RRC_CONFIGURATION_REQ (msg_p).phich_resource[j] = one;
+		} else if (strcmp(phich_resource,"TWO")==0) {
+		  RRC_CONFIGURATION_REQ (msg_p).phich_resource[j] = two;
+		} else
+		  AssertFatal (0,
+			       "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for phich_resource choice: ONESIXTH,HALF,ONE,TWO!\n",
+			       RC.config_file_name, i, phich_resource);
+
+		if (strcmp(srs_enable, "ENABLE") == 0) {
+		  RRC_CONFIGURATION_REQ (msg_p).srs_enable[j] = TRUE;
+		} else if (strcmp(srs_enable, "DISABLE") == 0) {
+		  RRC_CONFIGURATION_REQ (msg_p).srs_enable[j] = FALSE;
+		} else
+		  AssertFatal (0,
+			       "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for srs_BandwidthConfig choice: ENABLE,DISABLE !\n",
+			       RC.config_file_name, i, srs_enable);
+
+		if (RRC_CONFIGURATION_REQ (msg_p).srs_enable[j] == TRUE) {
+		  if (!(config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_SRS_BANDWIDTH_CONFIG, &srs_BandwidthConfig)
+			&& config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_SRS_SUBFRAME_CONFIG, &srs_SubframeConfig)
+			&& config_setting_lookup_string(component_carrier, ENB_CONFIG_STRING_SRS_ACKNACKST_CONFIG, &srs_ackNackST)
+			&& config_setting_lookup_string(component_carrier, ENB_CONFIG_STRING_SRS_MAXUPPTS, &srs_MaxUpPts)
+			))
+		    AssertFatal(0,
+				"Failed to parse eNB configuration file %s, enb %d unknown values for srs_BandwidthConfig, srs_SubframeConfig, srs_ackNackST, srs_MaxUpPts\n",
+				RC.config_file_name, i);
+
+		  RRC_CONFIGURATION_REQ (msg_p).srs_BandwidthConfig[j] = srs_BandwidthConfig;
+
+		  if ((srs_BandwidthConfig < 0) || (srs_BandwidthConfig >7))
+		    AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d unknown value %d for srs_BandwidthConfig choice: 0...7\n",
+				 RC.config_file_name, i, srs_BandwidthConfig);
+
+		  RRC_CONFIGURATION_REQ (msg_p).srs_SubframeConfig[j] = srs_SubframeConfig;
+
+		  if ((srs_SubframeConfig<0) || (srs_SubframeConfig>15))
+		    AssertFatal (0,
+				 "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for srs_SubframeConfig choice: 0..15 !\n",
+				 RC.config_file_name, i, srs_SubframeConfig);
+
+		  if (strcmp(srs_ackNackST, "ENABLE") == 0) {
+		    RRC_CONFIGURATION_REQ (msg_p).srs_ackNackST[j] = TRUE;
+		  } else if (strcmp(srs_ackNackST, "DISABLE") == 0) {
+		    RRC_CONFIGURATION_REQ (msg_p).srs_ackNackST[j] = FALSE;
+		  } else
+		    AssertFatal (0,
+				 "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for srs_BandwidthConfig choice: ENABLE,DISABLE !\n",
+				 RC.config_file_name, i, srs_ackNackST);
+
+		  if (strcmp(srs_MaxUpPts, "ENABLE") == 0) {
+		    RRC_CONFIGURATION_REQ (msg_p).srs_MaxUpPts[j] = TRUE;
+		  } else if (strcmp(srs_MaxUpPts, "DISABLE") == 0) {
+		    RRC_CONFIGURATION_REQ (msg_p).srs_MaxUpPts[j] = FALSE;
+		  } else
+		    AssertFatal (0,
+				 "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for srs_MaxUpPts choice: ENABLE,DISABLE !\n",
+				 RC.config_file_name, i, srs_MaxUpPts);
+		}
+
+		RRC_CONFIGURATION_REQ (msg_p).pusch_p0_Nominal[j] = pusch_p0_Nominal;
+
+		if ((pusch_p0_Nominal<-126) || (pusch_p0_Nominal>24))
+		  AssertFatal (0,
+			       "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pusch_p0_Nominal choice: -126..24 !\n",
+			       RC.config_file_name, i, pusch_p0_Nominal);
+
+		if (strcmp(pusch_alpha,"AL0")==0) {
+		  RRC_CONFIGURATION_REQ (msg_p).pusch_alpha[j] = UplinkPowerControlCommon__alpha_al0;
+		} else if (strcmp(pusch_alpha,"AL04")==0) {
+		  RRC_CONFIGURATION_REQ (msg_p).pusch_alpha[j] = UplinkPowerControlCommon__alpha_al04;
+		} else if (strcmp(pusch_alpha,"AL05")==0) {
+		  RRC_CONFIGURATION_REQ (msg_p).pusch_alpha[j] = UplinkPowerControlCommon__alpha_al05;
+		} else if (strcmp(pusch_alpha,"AL06")==0) {
+		  RRC_CONFIGURATION_REQ (msg_p).pusch_alpha[j] = UplinkPowerControlCommon__alpha_al06;
+		} else if (strcmp(pusch_alpha,"AL07")==0) {
+		  RRC_CONFIGURATION_REQ (msg_p).pusch_alpha[j] = UplinkPowerControlCommon__alpha_al07;
+		} else if (strcmp(pusch_alpha,"AL08")==0) {
+		  RRC_CONFIGURATION_REQ (msg_p).pusch_alpha[j] = UplinkPowerControlCommon__alpha_al08;
+		} else if (strcmp(pusch_alpha,"AL09")==0) {
+		  RRC_CONFIGURATION_REQ (msg_p).pusch_alpha[j] = UplinkPowerControlCommon__alpha_al09;
+		} else if (strcmp(pusch_alpha,"AL1")==0) {
+		  RRC_CONFIGURATION_REQ (msg_p).pusch_alpha[j] = UplinkPowerControlCommon__alpha_al1;
+		} else
+		  AssertFatal (0,
+			       "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pucch_Alpha choice: AL0,AL04,AL05,AL06,AL07,AL08,AL09,AL1!\n",
+			       RC.config_file_name, i, pusch_alpha);
+
+		RRC_CONFIGURATION_REQ (msg_p).pucch_p0_Nominal[j] = pucch_p0_Nominal;
+
+		if ((pucch_p0_Nominal<-127) || (pucch_p0_Nominal>-96))
+		  AssertFatal (0,
+			       "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pucch_p0_Nominal choice: -127..-96 !\n",
+			       RC.config_file_name, i, pucch_p0_Nominal);
+
+		RRC_CONFIGURATION_REQ (msg_p).msg3_delta_Preamble[j] = msg3_delta_Preamble;
+
+		if ((msg3_delta_Preamble<-1) || (msg3_delta_Preamble>6))
+		  AssertFatal (0,
+			       "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for msg3_delta_Preamble choice: -1..6 !\n",
+			       RC.config_file_name, i, msg3_delta_Preamble);
+
+
+		if (strcmp(pucch_deltaF_Format1,"deltaF_2")==0) {
+		  RRC_CONFIGURATION_REQ (msg_p).pucch_deltaF_Format1[j] = DeltaFList_PUCCH__deltaF_PUCCH_Format1_deltaF_2;
+		} else if (strcmp(pucch_deltaF_Format1,"deltaF0")==0) {
+		  RRC_CONFIGURATION_REQ (msg_p).pucch_deltaF_Format1[j] = DeltaFList_PUCCH__deltaF_PUCCH_Format1_deltaF0;
+		} else if (strcmp(pucch_deltaF_Format1,"deltaF2")==0) {
+		  RRC_CONFIGURATION_REQ (msg_p).pucch_deltaF_Format1[j] = DeltaFList_PUCCH__deltaF_PUCCH_Format1_deltaF2;
+		} else
+		  AssertFatal (0,
+			       "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pucch_deltaF_Format1 choice: deltaF_2,dltaF0,deltaF2!\n",
+			       RC.config_file_name, i, pucch_deltaF_Format1);
+
+		if (strcmp(pucch_deltaF_Format1b,"deltaF1")==0) {
+		  RRC_CONFIGURATION_REQ (msg_p).pucch_deltaF_Format1b[j] = DeltaFList_PUCCH__deltaF_PUCCH_Format1b_deltaF1;
+		} else if (strcmp(pucch_deltaF_Format1b,"deltaF3")==0) {
+		  RRC_CONFIGURATION_REQ (msg_p).pucch_deltaF_Format1b[j] = DeltaFList_PUCCH__deltaF_PUCCH_Format1b_deltaF3;
+		} else if (strcmp(pucch_deltaF_Format1b,"deltaF5")==0) {
+		  RRC_CONFIGURATION_REQ (msg_p).pucch_deltaF_Format1b[j] = DeltaFList_PUCCH__deltaF_PUCCH_Format1b_deltaF5;
+		} else
+		  AssertFatal (0,
+			       "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pucch_deltaF_Format1b choice: deltaF1,dltaF3,deltaF5!\n",
+			       RC.config_file_name, i, pucch_deltaF_Format1b);
+
+
+		if (strcmp(pucch_deltaF_Format2,"deltaF_2")==0) {
+		  RRC_CONFIGURATION_REQ (msg_p).pucch_deltaF_Format2[j] = DeltaFList_PUCCH__deltaF_PUCCH_Format2_deltaF_2;
+		} else if (strcmp(pucch_deltaF_Format2,"deltaF0")==0) {
+		  RRC_CONFIGURATION_REQ (msg_p).pucch_deltaF_Format2[j] = DeltaFList_PUCCH__deltaF_PUCCH_Format2_deltaF0;
+		} else if (strcmp(pucch_deltaF_Format2,"deltaF1")==0) {
+		  RRC_CONFIGURATION_REQ (msg_p).pucch_deltaF_Format2[j] = DeltaFList_PUCCH__deltaF_PUCCH_Format2_deltaF1;
+		} else if (strcmp(pucch_deltaF_Format2,"deltaF2")==0) {
+		  RRC_CONFIGURATION_REQ (msg_p).pucch_deltaF_Format2[j] = DeltaFList_PUCCH__deltaF_PUCCH_Format2_deltaF2;
+		} else
+		  AssertFatal (0,
+			       "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pucch_deltaF_Format2 choice: deltaF_2,dltaF0,deltaF1,deltaF2!\n",
+			       RC.config_file_name, i, pucch_deltaF_Format2);
+
+		if (strcmp(pucch_deltaF_Format2a,"deltaF_2")==0) {
+		  RRC_CONFIGURATION_REQ (msg_p).pucch_deltaF_Format2a[j] = DeltaFList_PUCCH__deltaF_PUCCH_Format2a_deltaF_2;
+		} else if (strcmp(pucch_deltaF_Format2a,"deltaF0")==0) {
+		  RRC_CONFIGURATION_REQ (msg_p).pucch_deltaF_Format2a[j] = DeltaFList_PUCCH__deltaF_PUCCH_Format2a_deltaF0;
+		} else if (strcmp(pucch_deltaF_Format2a,"deltaF2")==0) {
+		  RRC_CONFIGURATION_REQ (msg_p).pucch_deltaF_Format2a[j] = DeltaFList_PUCCH__deltaF_PUCCH_Format2a_deltaF2;
+		} else
+		  AssertFatal (0,
+			       "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pucch_deltaF_Format2a choice: deltaF_2,dltaF0,deltaF2!\n",
+			       RC.config_file_name, i, pucch_deltaF_Format2a);
+
+		if (strcmp(pucch_deltaF_Format2b,"deltaF_2")==0) {
+		  RRC_CONFIGURATION_REQ (msg_p).pucch_deltaF_Format2b[j] = DeltaFList_PUCCH__deltaF_PUCCH_Format2b_deltaF_2;
+		} else if (strcmp(pucch_deltaF_Format2b,"deltaF0")==0) {
+		  RRC_CONFIGURATION_REQ (msg_p).pucch_deltaF_Format2b[j] = DeltaFList_PUCCH__deltaF_PUCCH_Format2b_deltaF0;
+		} else if (strcmp(pucch_deltaF_Format2b,"deltaF2")==0) {
+		  RRC_CONFIGURATION_REQ (msg_p).pucch_deltaF_Format2b[j] = DeltaFList_PUCCH__deltaF_PUCCH_Format2b_deltaF2;
+		} else
+		  AssertFatal (0,
+			       "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pucch_deltaF_Format2b choice: deltaF_2,dltaF0,deltaF2!\n",
+			       RC.config_file_name, i, pucch_deltaF_Format2b);
+
+
+
+
+		RRC_CONFIGURATION_REQ (msg_p).rach_numberOfRA_Preambles[j] = (rach_numberOfRA_Preambles/4)-1;
+
+		if ((rach_numberOfRA_Preambles <4) || (rach_numberOfRA_Preambles>64) || ((rach_numberOfRA_Preambles&3)!=0))
+		  AssertFatal (0,
+			       "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_numberOfRA_Preambles choice: 4,8,12,...,64!\n",
+			       RC.config_file_name, i, rach_numberOfRA_Preambles);
+
+		if (strcmp(rach_preamblesGroupAConfig, "ENABLE") == 0) {
+		  RRC_CONFIGURATION_REQ (msg_p).rach_preamblesGroupAConfig[j] = TRUE;
+
+		  if (!(config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_RACH_SIZEOFRA_PREAMBLESGROUPA, &rach_sizeOfRA_PreamblesGroupA)
+			&& config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_RACH_MESSAGESIZEGROUPA, &rach_messageSizeGroupA)
+			&& config_setting_lookup_string(component_carrier, ENB_CONFIG_STRING_RACH_MESSAGEPOWEROFFSETGROUPB, &rach_messagePowerOffsetGroupB)))
+		    AssertFatal (0,
+				 "Failed to parse eNB configuration file %s, enb %d  rach_sizeOfRA_PreamblesGroupA, messageSizeGroupA,messagePowerOffsetGroupB!\n",
+				 RC.config_file_name, i);
+
+		  RRC_CONFIGURATION_REQ (msg_p).rach_sizeOfRA_PreamblesGroupA[j] = (rach_sizeOfRA_PreamblesGroupA/4)-1;
+
+		  if ((rach_numberOfRA_Preambles <4) || (rach_numberOfRA_Preambles>60) || ((rach_numberOfRA_Preambles&3)!=0))
+		    AssertFatal (0,
+				 "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_sizeOfRA_PreamblesGroupA choice: 4,8,12,...,60!\n",
+				 RC.config_file_name, i, rach_sizeOfRA_PreamblesGroupA);
+
+
+		  switch (rach_messageSizeGroupA) {
+		  case 56:
+		    RRC_CONFIGURATION_REQ (msg_p).rach_messageSizeGroupA[j] = RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messageSizeGroupA_b56;
+		    break;
+
+		  case 144:
+		    RRC_CONFIGURATION_REQ (msg_p).rach_messageSizeGroupA[j] = RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messageSizeGroupA_b144;
+		    break;
+
+		  case 208:
+		    RRC_CONFIGURATION_REQ (msg_p).rach_messageSizeGroupA[j] = RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messageSizeGroupA_b208;
+		    break;
+
+		  case 256:
+		    RRC_CONFIGURATION_REQ (msg_p).rach_messageSizeGroupA[j] = RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messageSizeGroupA_b256;
+		    break;
+
+		  default:
+		    AssertFatal (0,
+				 "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_messageSizeGroupA choice: 56,144,208,256!\n",
+				 RC.config_file_name, i, rach_messageSizeGroupA);
+		    break;
+		  }
+
+		  if (strcmp(rach_messagePowerOffsetGroupB,"minusinfinity")==0) {
+		    RRC_CONFIGURATION_REQ (msg_p).rach_messagePowerOffsetGroupB[j] = RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_minusinfinity;
+		  }
+
+		  else if (strcmp(rach_messagePowerOffsetGroupB,"dB0")==0) {
+		    RRC_CONFIGURATION_REQ (msg_p).rach_messagePowerOffsetGroupB[j] = RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB0;
+		  }
+
+		  else if (strcmp(rach_messagePowerOffsetGroupB,"dB5")==0) {
+		    RRC_CONFIGURATION_REQ (msg_p).rach_messagePowerOffsetGroupB[j] = RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB5;
+		  }
+
+		  else if (strcmp(rach_messagePowerOffsetGroupB,"dB8")==0) {
+		    RRC_CONFIGURATION_REQ (msg_p).rach_messagePowerOffsetGroupB[j] = RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB8;
+		  }
+
+		  else if (strcmp(rach_messagePowerOffsetGroupB,"dB10")==0) {
+		    RRC_CONFIGURATION_REQ (msg_p).rach_messagePowerOffsetGroupB[j] = RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB10;
+		  }
+
+		  else if (strcmp(rach_messagePowerOffsetGroupB,"dB12")==0) {
+		    RRC_CONFIGURATION_REQ (msg_p).rach_messagePowerOffsetGroupB[j] = RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB12;
+		  }
 
+		  else if (strcmp(rach_messagePowerOffsetGroupB,"dB15")==0) {
+		    RRC_CONFIGURATION_REQ (msg_p).rach_messagePowerOffsetGroupB[j] = RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB15;
+		  }
 
+		  else if (strcmp(rach_messagePowerOffsetGroupB,"dB18")==0) {
+		    RRC_CONFIGURATION_REQ (msg_p).rach_messagePowerOffsetGroupB[j] = RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB18;
+		  } else
+		    AssertFatal (0,
+				 "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for rach_messagePowerOffsetGroupB choice: minusinfinity,dB0,dB5,dB8,dB10,dB12,dB15,dB18!\n",
+				 RC.config_file_name, i, rach_messagePowerOffsetGroupB);
 
-              enb_properties.properties[enb_properties_index]->eutra_band[j] = eutra_band;
-              // printf( "\teutra band:\t%d\n",enb_properties.properties[enb_properties_index]->eutra_band);
+		} else if (strcmp(rach_preamblesGroupAConfig, "DISABLE") == 0) {
+		  RRC_CONFIGURATION_REQ (msg_p).rach_preamblesGroupAConfig[j] = FALSE;
+		} else
+		  AssertFatal (0,
+			       "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for rach_preamblesGroupAConfig choice: ENABLE,DISABLE !\n",
+			       RC.config_file_name, i, rach_preamblesGroupAConfig);
 
+		RRC_CONFIGURATION_REQ (msg_p).rach_preambleInitialReceivedTargetPower[j] = (rach_preambleInitialReceivedTargetPower+120)/2;
 
+		if ((rach_preambleInitialReceivedTargetPower<-120) || (rach_preambleInitialReceivedTargetPower>-90) || ((rach_preambleInitialReceivedTargetPower&1)!=0))
+		  AssertFatal (0,
+			       "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_preambleInitialReceivedTargetPower choice: -120,-118,...,-90 !\n",
+			       RC.config_file_name, i, rach_preambleInitialReceivedTargetPower);
 
-              enb_properties.properties[enb_properties_index]->downlink_frequency[j] = (uint32_t) downlink_frequency;
-              //printf( "\tdownlink freq:\t%u\n",enb_properties.properties[enb_properties_index]->downlink_frequency);
 
+		RRC_CONFIGURATION_REQ (msg_p).rach_powerRampingStep[j] = rach_powerRampingStep/2;
 
-              enb_properties.properties[enb_properties_index]->uplink_frequency_offset[j] = (unsigned int) uplink_frequency_offset;
+		if ((rach_powerRampingStep<0) || (rach_powerRampingStep>6) || ((rach_powerRampingStep&1)!=0))
+		  AssertFatal (0,
+			       "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_powerRampingStep choice: 0,2,4,6 !\n",
+			       RC.config_file_name, i, rach_powerRampingStep);
 
-              if (enb_check_band_frequencies(lib_config_file_name_pP,
-                              enb_properties_index,
-                              enb_properties.properties[enb_properties_index]->eutra_band[j],
-                              enb_properties.properties[enb_properties_index]->downlink_frequency[j],
-                              enb_properties.properties[enb_properties_index]->uplink_frequency_offset[j],
-                              enb_properties.properties[enb_properties_index]->frame_type[j])) {
-                AssertFatal(0, "error calling enb_check_band_frequencies\n");
-              }
 
-              enb_properties.properties[enb_properties_index]->nb_antennas_tx[j] = nb_antennas_tx;
 
-              if ((nb_antenna_ports <1) || (nb_antenna_ports > 2))
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for nb_antenna_ports choice: 1..2 !\n",
-                             lib_config_file_name_pP, i, nb_antenna_ports);
+		switch (rach_preambleTransMax) {
+		case 3:
+		  RRC_CONFIGURATION_REQ (msg_p).rach_preambleTransMax[j] =  RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n3;
+		  break;
 
-              enb_properties.properties[enb_properties_index]->nb_antenna_ports[j] = nb_antenna_ports;
+		case 4:
+		  RRC_CONFIGURATION_REQ (msg_p).rach_preambleTransMax[j] =  RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n4;
+		  break;
 
-              if ((nb_antennas_tx <1) || (nb_antennas_tx > 64))
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for nb_antennas_tx choice: 1..64 !\n",
-                             lib_config_file_name_pP, i, nb_antennas_tx);
+		case 5:
+		  RRC_CONFIGURATION_REQ (msg_p).rach_preambleTransMax[j] =  RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n5;
+		  break;
+
+		case 6:
+		  RRC_CONFIGURATION_REQ (msg_p).rach_preambleTransMax[j] =  RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n6;
+		  break;
+
+		case 7:
+		  RRC_CONFIGURATION_REQ (msg_p).rach_preambleTransMax[j] =  RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n7;
+		  break;
+
+		case 8:
+		  RRC_CONFIGURATION_REQ (msg_p).rach_preambleTransMax[j] =  RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n8;
+		  break;
+
+		case 10:
+		  RRC_CONFIGURATION_REQ (msg_p).rach_preambleTransMax[j] =  RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n10;
+		  break;
+
+		case 20:
+		  RRC_CONFIGURATION_REQ (msg_p).rach_preambleTransMax[j] =  RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n20;
+		  break;
+
+		case 50:
+		  RRC_CONFIGURATION_REQ (msg_p).rach_preambleTransMax[j] =  RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n50;
+		  break;
+
+		case 100:
+		  RRC_CONFIGURATION_REQ (msg_p).rach_preambleTransMax[j] =  RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n100;
+		  break;
+
+		case 200:
+		  RRC_CONFIGURATION_REQ (msg_p).rach_preambleTransMax[j] =  RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n200;
+		  break;
+
+		default:
+		  AssertFatal (0,
+			       "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_preambleTransMax choice: 3,4,5,6,7,8,10,20,50,100,200!\n",
+			       RC.config_file_name, i, rach_preambleTransMax);
+		  break;
+		}
+
+		RRC_CONFIGURATION_REQ (msg_p).rach_raResponseWindowSize[j] =  (rach_raResponseWindowSize==10)?7:rach_raResponseWindowSize-2;
+
+		if ((rach_raResponseWindowSize<0)||(rach_raResponseWindowSize==9)||(rach_raResponseWindowSize>10))
+		  AssertFatal (0,
+			       "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_raResponseWindowSize choice: 2,3,4,5,6,7,8,10!\n",
+			       RC.config_file_name, i, rach_preambleTransMax);
+
+
+		RRC_CONFIGURATION_REQ (msg_p).rach_macContentionResolutionTimer[j] = (rach_macContentionResolutionTimer/8)-1;
+
+		if ((rach_macContentionResolutionTimer<8) || (rach_macContentionResolutionTimer>64) || ((rach_macContentionResolutionTimer&7)!=0))
+		  AssertFatal (0,
+			       "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_macContentionResolutionTimer choice: 8,16,...,56,64!\n",
+			       RC.config_file_name, i, rach_preambleTransMax);
+
+		RRC_CONFIGURATION_REQ (msg_p).rach_maxHARQ_Msg3Tx[j] = rach_maxHARQ_Msg3Tx;
 
-              enb_properties.properties[enb_properties_index]->nb_antennas_rx[j] = nb_antennas_rx;
+		if ((rach_maxHARQ_Msg3Tx<0) || (rach_maxHARQ_Msg3Tx>8))
+		  AssertFatal (0,
+			       "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_maxHARQ_Msg3Tx choice: 1..8!\n",
+			       RC.config_file_name, i, rach_preambleTransMax);
 
-              if ((nb_antennas_rx <1) || (nb_antennas_rx > 64))
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for nb_antennas_rx choice: 1..64 !\n",
-                             lib_config_file_name_pP, i, nb_antennas_rx);
 
-              enb_properties.properties[enb_properties_index]->tx_gain[j] = tx_gain;
+		switch (pcch_defaultPagingCycle) {
+		case 32:
+		  RRC_CONFIGURATION_REQ (msg_p).pcch_defaultPagingCycle[j] = PCCH_Config__defaultPagingCycle_rf32;
+		  break;
 
-              if ((tx_gain <0) || (tx_gain > 127))
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for tx_gain choice: 0..127 !\n",
-                             lib_config_file_name_pP, i, tx_gain);
+		case 64:
+		  RRC_CONFIGURATION_REQ (msg_p).pcch_defaultPagingCycle[j] = PCCH_Config__defaultPagingCycle_rf64;
+		  break;
 
-              enb_properties.properties[enb_properties_index]->rx_gain[j] = rx_gain;
+		case 128:
+		  RRC_CONFIGURATION_REQ (msg_p).pcch_defaultPagingCycle[j] = PCCH_Config__defaultPagingCycle_rf128;
+		  break;
 
-              if ((rx_gain <0) || (rx_gain > 160))
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rx_gain choice: 0..160 !\n",
-                             lib_config_file_name_pP, i, rx_gain);
+		case 256:
+		  RRC_CONFIGURATION_REQ (msg_p).pcch_defaultPagingCycle[j] = PCCH_Config__defaultPagingCycle_rf256;
+		  break;
+
+		default:
+		  AssertFatal (0,
+			       "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pcch_defaultPagingCycle choice: 32,64,128,256!\n",
+			       RC.config_file_name, i, pcch_defaultPagingCycle);
+		  break;
+		}
+
+		if (strcmp(pcch_nB, "fourT") == 0) {
+		  RRC_CONFIGURATION_REQ (msg_p).pcch_nB[j] = PCCH_Config__nB_fourT;
+		} else if (strcmp(pcch_nB, "twoT") == 0) {
+		  RRC_CONFIGURATION_REQ (msg_p).pcch_nB[j] = PCCH_Config__nB_twoT;
+		} else if (strcmp(pcch_nB, "oneT") == 0) {
+		  RRC_CONFIGURATION_REQ (msg_p).pcch_nB[j] = PCCH_Config__nB_oneT;
+		} else if (strcmp(pcch_nB, "halfT") == 0) {
+		  RRC_CONFIGURATION_REQ (msg_p).pcch_nB[j] = PCCH_Config__nB_halfT;
+		} else if (strcmp(pcch_nB, "quarterT") == 0) {
+		  RRC_CONFIGURATION_REQ (msg_p).pcch_nB[j] = PCCH_Config__nB_quarterT;
+		} else if (strcmp(pcch_nB, "oneEighthT") == 0) {
+		  RRC_CONFIGURATION_REQ (msg_p).pcch_nB[j] = PCCH_Config__nB_oneEighthT;
+		} else if (strcmp(pcch_nB, "oneSixteenthT") == 0) {
+		  RRC_CONFIGURATION_REQ (msg_p).pcch_nB[j] = PCCH_Config__nB_oneSixteenthT;
+		} else if (strcmp(pcch_nB, "oneThirtySecondT") == 0) {
+		  RRC_CONFIGURATION_REQ (msg_p).pcch_nB[j] = PCCH_Config__nB_oneThirtySecondT;
+		} else
+		  AssertFatal (0,
+			       "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pcch_nB choice: fourT,twoT,oneT,halfT,quarterT,oneighthT,oneSixteenthT,oneThirtySecondT !\n",
+			       RC.config_file_name, i, pcch_defaultPagingCycle);
+
+
+
+		switch (bcch_modificationPeriodCoeff) {
+		case 2:
+		  RRC_CONFIGURATION_REQ (msg_p).bcch_modificationPeriodCoeff[j] = BCCH_Config__modificationPeriodCoeff_n2;
+		  break;
+
+		case 4:
+		  RRC_CONFIGURATION_REQ (msg_p).bcch_modificationPeriodCoeff[j] = BCCH_Config__modificationPeriodCoeff_n4;
+		  break;
+
+		case 8:
+		  RRC_CONFIGURATION_REQ (msg_p).bcch_modificationPeriodCoeff[j] = BCCH_Config__modificationPeriodCoeff_n8;
+		  break;
+
+		case 16:
+		  RRC_CONFIGURATION_REQ (msg_p).bcch_modificationPeriodCoeff[j] = BCCH_Config__modificationPeriodCoeff_n16;
+		  break;
+
+		default:
+		  AssertFatal (0,
+			       "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for bcch_modificationPeriodCoeff choice: 2,4,8,16",
+			       RC.config_file_name, i, bcch_modificationPeriodCoeff);
+
+		  break;
+		}
+
+
+		switch (ue_TimersAndConstants_t300) {
+		case 100:
+		  RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_t300[j] = UE_TimersAndConstants__t300_ms100;
+		  break;
+
+		case 200:
+		  RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_t300[j] = UE_TimersAndConstants__t300_ms200;
+		  break;
+
+		case 300:
+		  RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_t300[j] = UE_TimersAndConstants__t300_ms300;
+		  break;
+
+		case 400:
+		  RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_t300[j] = UE_TimersAndConstants__t300_ms400;
+		  break;
+
+		case 600:
+		  RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_t300[j] = UE_TimersAndConstants__t300_ms600;
+		  break;
+
+		case 1000:
+		  RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_t300[j] = UE_TimersAndConstants__t300_ms1000;
+		  break;
+
+		case 1500:
+		  RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_t300[j] = UE_TimersAndConstants__t300_ms1500;
+		  break;
+
+		case 2000:
+		  RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_t300[j] = UE_TimersAndConstants__t300_ms2000;
+		  break;
+
+		default:
+		  AssertFatal (0,
+			       "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for ue_TimersAndConstants_t300 choice: 100,200,300,400,600,1000,1500,2000 ",
+			       RC.config_file_name, i, ue_TimersAndConstants_t300);
+		  break;
+
+		}
+
+		switch (ue_TimersAndConstants_t301) {
+		case 100:
+		  RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_t301[j] = UE_TimersAndConstants__t301_ms100;
+		  break;
+
+		case 200:
+		  RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_t301[j] = UE_TimersAndConstants__t301_ms200;
+		  break;
+
+		case 300:
+		  RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_t301[j] = UE_TimersAndConstants__t301_ms300;
+		  break;
+
+		case 400:
+		  RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_t301[j] = UE_TimersAndConstants__t301_ms400;
+		  break;
+
+		case 600:
+		  RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_t301[j] = UE_TimersAndConstants__t301_ms600;
+		  break;
+
+		case 1000:
+		  RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_t301[j] = UE_TimersAndConstants__t301_ms1000;
+		  break;
 
-              enb_properties.properties[enb_properties_index]->prach_root[j] =  prach_root;
+		case 1500:
+		  RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_t301[j] = UE_TimersAndConstants__t301_ms1500;
+		  break;
 
-              if ((prach_root <0) || (prach_root > 1023))
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for prach_root choice: 0..1023 !\n",
-                             lib_config_file_name_pP, i, prach_root);
+		case 2000:
+		  RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_t301[j] = UE_TimersAndConstants__t301_ms2000;
+		  break;
 
-              enb_properties.properties[enb_properties_index]->prach_config_index[j] = prach_config_index;
+		default:
+		  AssertFatal (0,
+			       "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for ue_TimersAndConstants_t301 choice: 100,200,300,400,600,1000,1500,2000 ",
+			       RC.config_file_name, i, ue_TimersAndConstants_t301);
+		  break;
+
+		}
 
-              if ((prach_config_index <0) || (prach_config_index > 63))
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for prach_config_index choice: 0..1023 !\n",
-                             lib_config_file_name_pP, i, prach_config_index);
+		switch (ue_TimersAndConstants_t310) {
+		case 0:
+		  RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_t310[j] = UE_TimersAndConstants__t310_ms0;
+		  break;
 
-              if (!prach_high_speed)
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d define %s: ENABLE,DISABLE!\n",
-                             lib_config_file_name_pP, i, ENB_CONFIG_STRING_PRACH_HIGH_SPEED);
-              else if (strcmp(prach_high_speed, "ENABLE") == 0) {
-                enb_properties.properties[enb_properties_index]->prach_high_speed[j] = TRUE;
-              } else if (strcmp(prach_high_speed, "DISABLE") == 0) {
-                enb_properties.properties[enb_properties_index]->prach_high_speed[j] = FALSE;
-              } else
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for prach_config choice: ENABLE,DISABLE !\n",
-                             lib_config_file_name_pP, i, prach_high_speed);
+		case 50:
+		  RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_t310[j] = UE_TimersAndConstants__t310_ms50;
+		  break;
 
-              enb_properties.properties[enb_properties_index]->prach_zero_correlation[j] =prach_zero_correlation;
+		case 100:
+		  RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_t310[j] = UE_TimersAndConstants__t310_ms100;
+		  break;
 
-              if ((prach_zero_correlation <0) || (prach_zero_correlation > 15))
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for prach_zero_correlation choice: 0..15!\n",
-                             lib_config_file_name_pP, i, prach_zero_correlation);
+		case 200:
+		  RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_t310[j] = UE_TimersAndConstants__t310_ms200;
+		  break;
 
-              enb_properties.properties[enb_properties_index]->prach_freq_offset[j] = prach_freq_offset;
+		case 500:
+		  RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_t310[j] = UE_TimersAndConstants__t310_ms500;
+		  break;
+
+		case 1000:
+		  RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_t310[j] = UE_TimersAndConstants__t310_ms1000;
+		  break;
+
+		case 2000:
+		  RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_t310[j] = UE_TimersAndConstants__t310_ms2000;
+		  break;
+
+		default:
+		  AssertFatal (0,
+			       "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for ue_TimersAndConstants_t310 choice: 0,50,100,200,500,1000,1500,2000 ",
+			       RC.config_file_name, i, ue_TimersAndConstants_t310);
+		  break;
+
+		}
+
+		switch (ue_TimersAndConstants_t311) {
+		case 1000:
+		  RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_t311[j] = UE_TimersAndConstants__t311_ms1000;
+		  break;
+
+		case 3110:
+		  RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_t311[j] = UE_TimersAndConstants__t311_ms3000;
+		  break;
+
+		case 5000:
+		  RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_t311[j] = UE_TimersAndConstants__t311_ms5000;
+		  break;
+
+		case 10000:
+		  RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_t311[j] = UE_TimersAndConstants__t311_ms10000;
+		  break;
+
+		case 15000:
+		  RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_t311[j] = UE_TimersAndConstants__t311_ms15000;
+		  break;
+
+		case 20000:
+		  RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_t311[j] = UE_TimersAndConstants__t311_ms20000;
+		  break;
+
+		case 31100:
+		  RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_t311[j] = UE_TimersAndConstants__t311_ms30000;
+		  break;
+
+		default:
+		  AssertFatal (0,
+			       "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for ue_TimersAndConstants_t311 choice: 1000,3000,5000,10000,150000,20000,30000",
+			       RC.config_file_name, i, ue_TimersAndConstants_t311);
+		  break;
+
+		}
+
+		switch (ue_TimersAndConstants_n310) {
+		case 1:
+		  RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_n310[j] = UE_TimersAndConstants__n310_n1;
+		  break;
+
+		case 2:
+		  RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_n310[j] = UE_TimersAndConstants__n310_n2;
+		  break;
+
+		case 3:
+		  RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_n310[j] = UE_TimersAndConstants__n310_n3;
+		  break;
+
+		case 4:
+		  RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_n310[j] = UE_TimersAndConstants__n310_n4;
+		  break;
+
+		case 6:
+		  RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_n310[j] = UE_TimersAndConstants__n310_n6;
+		  break;
+
+		case 8:
+		  RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_n310[j] = UE_TimersAndConstants__n310_n8;
+		  break;
+
+		case 10:
+		  RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_n310[j] = UE_TimersAndConstants__n310_n10;
+		  break;
+
+		case 20:
+		  RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_n310[j] = UE_TimersAndConstants__n310_n20;
+		  break;
+
+		default:
+		  AssertFatal (0,
+			       "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for ue_TimersAndConstants_n310 choice: 1,2,3,4,6,6,8,10,20",
+			       RC.config_file_name, i, ue_TimersAndConstants_n311);
+		  break;
+
+		}
+
+		switch (ue_TimersAndConstants_n311) {
+		case 1:
+		  RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_n311[j] = UE_TimersAndConstants__n311_n1;
+		  break;
+
+		case 2:
+		  RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_n311[j] = UE_TimersAndConstants__n311_n2;
+		  break;
+
+		case 3:
+		  RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_n311[j] = UE_TimersAndConstants__n311_n3;
+		  break;
+
+		case 4:
+		  RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_n311[j] = UE_TimersAndConstants__n311_n4;
+		  break;
+
+		case 5:
+		  RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_n311[j] = UE_TimersAndConstants__n311_n5;
+		  break;
+
+		case 6:
+		  RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_n311[j] = UE_TimersAndConstants__n311_n6;
+		  break;
+
+		case 8:
+		  RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_n311[j] = UE_TimersAndConstants__n311_n8;
+		  break;
+
+		case 10:
+		  RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_n311[j] = UE_TimersAndConstants__n311_n10;
+		  break;
+
+		default:
+		  AssertFatal (0,
+			       "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for ue_TimersAndConstants_t311 choice: 1,2,3,4,5,6,8,10",
+			       RC.config_file_name, i, ue_TimersAndConstants_t311);
+		  break;
+
+		}
+
+		switch (ue_TransmissionMode) {
+		case 1:
+		  RRC_CONFIGURATION_REQ (msg_p).ue_TransmissionMode[j] = AntennaInfoDedicated__transmissionMode_tm1;
+		  break;
+		case 2:
+		  RRC_CONFIGURATION_REQ (msg_p).ue_TransmissionMode[j] = AntennaInfoDedicated__transmissionMode_tm2;
+		  break;
+		case 3:
+		  RRC_CONFIGURATION_REQ (msg_p).ue_TransmissionMode[j] = AntennaInfoDedicated__transmissionMode_tm3;
+		  break;
+		case 4:
+		  RRC_CONFIGURATION_REQ (msg_p).ue_TransmissionMode[j] = AntennaInfoDedicated__transmissionMode_tm4;
+		  break;
+		case 5:
+		  RRC_CONFIGURATION_REQ (msg_p).ue_TransmissionMode[j] = AntennaInfoDedicated__transmissionMode_tm5;
+		  break;
+		case 6:
+		  RRC_CONFIGURATION_REQ (msg_p).ue_TransmissionMode[j] = AntennaInfoDedicated__transmissionMode_tm6;
+		  break;
+		case 7:
+		  RRC_CONFIGURATION_REQ (msg_p).ue_TransmissionMode[j] = AntennaInfoDedicated__transmissionMode_tm7;
+		  break;
+		default:
+		  AssertFatal (0,
+			       "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for ue_TransmissionMode choice: 1,2,3,4,5,6,7",
+			       RC.config_file_name, i, ue_TransmissionMode);
+		  break;
+		}
+	      }
+	    }
+
+	    setting_srb1 = config_setting_get_member (setting_enb, ENB_CONFIG_STRING_SRB1);
+
+	    if (setting_srb1 != NULL) {
+	      if (!(config_setting_lookup_int(setting_srb1, ENB_CONFIG_STRING_SRB1_TIMER_POLL_RETRANSMIT, &srb1_timer_poll_retransmit)
+		    && config_setting_lookup_int(setting_srb1, ENB_CONFIG_STRING_SRB1_TIMER_REORDERING,      &srb1_timer_reordering)
+		    && config_setting_lookup_int(setting_srb1, ENB_CONFIG_STRING_SRB1_TIMER_STATUS_PROHIBIT, &srb1_timer_status_prohibit)
+		    && config_setting_lookup_int(setting_srb1, ENB_CONFIG_STRING_SRB1_MAX_RETX_THRESHOLD,    &srb1_max_retx_threshold)
+		    && config_setting_lookup_int(setting_srb1, ENB_CONFIG_STRING_SRB1_POLL_PDU,              &srb1_poll_pdu)
+		    && config_setting_lookup_int(setting_srb1, ENB_CONFIG_STRING_SRB1_POLL_BYTE,             &srb1_poll_byte)))
+		AssertFatal (0,
+			     "Failed to parse eNB configuration file %s, enb %d  timer_poll_retransmit, timer_reordering, "
+			     "timer_status_prohibit, poll_pdu, poll_byte, max_retx_threshold !\n",
+			     RC.config_file_name, i);
+
+	      switch (srb1_max_retx_threshold) {
+	      case 1:
+		rrc->srb1_max_retx_threshold = UL_AM_RLC__maxRetxThreshold_t1;
+		break;
 
-              if ((prach_freq_offset <0) || (prach_freq_offset > 94))
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for prach_freq_offset choice: 0..94!\n",
-                             lib_config_file_name_pP, i, prach_freq_offset);
+	      case 2:
+		rrc->srb1_max_retx_threshold = UL_AM_RLC__maxRetxThreshold_t2;
+		break;
 
+	      case 3:
+		rrc->srb1_max_retx_threshold = UL_AM_RLC__maxRetxThreshold_t3;
+		break;
 
-              enb_properties.properties[enb_properties_index]->pucch_delta_shift[j] = pucch_delta_shift-1;
+	      case 4:
+		rrc->srb1_max_retx_threshold = UL_AM_RLC__maxRetxThreshold_t4;
+		break;
 
-              if ((pucch_delta_shift <1) || (pucch_delta_shift > 3))
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pucch_delta_shift choice: 1..3!\n",
-                             lib_config_file_name_pP, i, pucch_delta_shift);
+	      case 6:
+		rrc->srb1_max_retx_threshold = UL_AM_RLC__maxRetxThreshold_t6;
+		break;
 
-              enb_properties.properties[enb_properties_index]->pucch_nRB_CQI[j] = pucch_nRB_CQI;
+	      case 8:
+		rrc->srb1_max_retx_threshold = UL_AM_RLC__maxRetxThreshold_t8;
+		break;
 
-              if ((pucch_nRB_CQI <0) || (pucch_nRB_CQI > 98))
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pucch_nRB_CQI choice: 0..98!\n",
-                             lib_config_file_name_pP, i, pucch_nRB_CQI);
+	      case 16:
+		rrc->srb1_max_retx_threshold = UL_AM_RLC__maxRetxThreshold_t16;
+		break;
 
-              enb_properties.properties[enb_properties_index]->pucch_nCS_AN[j] = pucch_nCS_AN;
+	      case 32:
+		rrc->srb1_max_retx_threshold = UL_AM_RLC__maxRetxThreshold_t32;
+		break;
 
-              if ((pucch_nCS_AN <0) || (pucch_nCS_AN > 7))
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pucch_nCS_AN choice: 0..7!\n",
-                             lib_config_file_name_pP, i, pucch_nCS_AN);
+	      default:
+		AssertFatal (0,
+			     "Bad config value when parsing eNB configuration file %s, enb %d  srb1_max_retx_threshold %u!\n",
+			     RC.config_file_name, i, srb1_max_retx_threshold);
+	      }
 
-#ifndef Rel10
-              enb_properties.properties[enb_properties_index]->pucch_n1_AN[j] = pucch_n1_AN;
+	      switch (srb1_poll_pdu) {
+	      case 4:
+		rrc->srb1_poll_pdu = PollPDU_p4;
+		break;
 
-              if ((pucch_n1_AN <0) || (pucch_n1_AN > 2047))
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pucch_n1_AN choice: 0..2047!\n",
-                             lib_config_file_name_pP, i, pucch_n1_AN);
+	      case 8:
+		rrc->srb1_poll_pdu = PollPDU_p8;
+		break;
 
-#endif
-              enb_properties.properties[enb_properties_index]->pdsch_referenceSignalPower[j] = pdsch_referenceSignalPower;
-
-              if ((pdsch_referenceSignalPower <-60) || (pdsch_referenceSignalPower > 50))
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pdsch_referenceSignalPower choice:-60..50!\n",
-                             lib_config_file_name_pP, i, pdsch_referenceSignalPower);
-
-              enb_properties.properties[enb_properties_index]->pdsch_p_b[j] = pdsch_p_b;
-
-              if ((pdsch_p_b <0) || (pdsch_p_b > 3))
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pdsch_p_b choice: 0..3!\n",
-                             lib_config_file_name_pP, i, pdsch_p_b);
-
-              enb_properties.properties[enb_properties_index]->pusch_n_SB[j] = pusch_n_SB;
-
-              if ((pusch_n_SB <1) || (pusch_n_SB > 4))
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pusch_n_SB choice: 1..4!\n",
-                             lib_config_file_name_pP, i, pusch_n_SB);
-
-              if (!pusch_hoppingMode)
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d define %s: interSubframe,intraAndInterSubframe!\n",
-                             lib_config_file_name_pP, i, ENB_CONFIG_STRING_PUSCH_HOPPINGMODE);
-              else if (strcmp(pusch_hoppingMode,"interSubFrame")==0) {
-                enb_properties.properties[enb_properties_index]->pusch_hoppingMode[j] = PUSCH_ConfigCommon__pusch_ConfigBasic__hoppingMode_interSubFrame;
-              }  else if (strcmp(pusch_hoppingMode,"intraAndInterSubFrame")==0) {
-                enb_properties.properties[enb_properties_index]->pusch_hoppingMode[j] = PUSCH_ConfigCommon__pusch_ConfigBasic__hoppingMode_intraAndInterSubFrame;
-              } else
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pusch_hoppingMode choice: interSubframe,intraAndInterSubframe!\n",
-                             lib_config_file_name_pP, i, pusch_hoppingMode);
-
-              enb_properties.properties[enb_properties_index]->pusch_hoppingOffset[j] = pusch_hoppingOffset;
-
-              if ((pusch_hoppingOffset<0) || (pusch_hoppingOffset>98))
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pusch_hoppingOffset choice: 0..98!\n",
-                             lib_config_file_name_pP, i, pusch_hoppingMode);
-
-              if (!pusch_enable64QAM)
-                AssertFatal (0, 
-                             "Failed to parse eNB configuration file %s, enb %d define %s: ENABLE,DISABLE!\n",
-                             lib_config_file_name_pP, i, ENB_CONFIG_STRING_PUSCH_ENABLE64QAM);
-              else if (strcmp(pusch_enable64QAM, "ENABLE") == 0) {
-                enb_properties.properties[enb_properties_index]->pusch_enable64QAM[j] = TRUE;
-              }  else if (strcmp(pusch_enable64QAM, "DISABLE") == 0) {
-                enb_properties.properties[enb_properties_index]->pusch_enable64QAM[j] = FALSE;
-              } else
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pusch_enable64QAM choice: ENABLE,DISABLE!\n",
-                             lib_config_file_name_pP, i, pusch_enable64QAM);
-
-              if (!pusch_groupHoppingEnabled)
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d define %s: ENABLE,DISABLE!\n",
-                             lib_config_file_name_pP, i, ENB_CONFIG_STRING_PUSCH_GROUP_HOPPING_EN);
-              else if (strcmp(pusch_groupHoppingEnabled, "ENABLE") == 0) {
-                enb_properties.properties[enb_properties_index]->pusch_groupHoppingEnabled[j] = TRUE;
-              }  else if (strcmp(pusch_groupHoppingEnabled, "DISABLE") == 0) {
-                enb_properties.properties[enb_properties_index]->pusch_groupHoppingEnabled[j] = FALSE;
-              } else
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pusch_groupHoppingEnabled choice: ENABLE,DISABLE!\n",
-                             lib_config_file_name_pP, i, pusch_groupHoppingEnabled);
-
-
-              enb_properties.properties[enb_properties_index]->pusch_groupAssignment[j] = pusch_groupAssignment;
-
-              if ((pusch_groupAssignment<0)||(pusch_groupAssignment>29))
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pusch_groupAssignment choice: 0..29!\n",
-                             lib_config_file_name_pP, i, pusch_groupAssignment);
-
-              if (!pusch_sequenceHoppingEnabled)
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d define %s: ENABLE,DISABLE!\n",
-                             lib_config_file_name_pP, i, ENB_CONFIG_STRING_PUSCH_SEQUENCE_HOPPING_EN);
-              else if (strcmp(pusch_sequenceHoppingEnabled, "ENABLE") == 0) {
-                enb_properties.properties[enb_properties_index]->pusch_sequenceHoppingEnabled[j] = TRUE;
-              }  else if (strcmp(pusch_sequenceHoppingEnabled, "DISABLE") == 0) {
-                enb_properties.properties[enb_properties_index]->pusch_sequenceHoppingEnabled[j] = FALSE;
-              } else
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pusch_sequenceHoppingEnabled choice: ENABLE,DISABLE!\n",
-                             lib_config_file_name_pP, i, pusch_sequenceHoppingEnabled);
-
-              enb_properties.properties[enb_properties_index]->pusch_nDMRS1[j] = pusch_nDMRS1;  //cyclic_shift in RRC!
-
-              if ((pusch_nDMRS1 <0) || (pusch_nDMRS1>7))
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pusch_nDMRS1 choice: 0..7!\n",
-                             lib_config_file_name_pP, i, pusch_nDMRS1);
-
-              if (strcmp(phich_duration,"NORMAL")==0) {
-                enb_properties.properties[enb_properties_index]->phich_duration[j] = normal;
-              } else if (strcmp(phich_duration,"EXTENDED")==0) {
-                enb_properties.properties[enb_properties_index]->phich_duration[j] = extended;
-              } else
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for phich_duration choice: NORMAL,EXTENDED!\n",
-                             lib_config_file_name_pP, i, phich_duration);
-
-              if (strcmp(phich_resource,"ONESIXTH")==0) {
-                enb_properties.properties[enb_properties_index]->phich_resource[j] = oneSixth;
-              } else if (strcmp(phich_resource,"HALF")==0) {
-                enb_properties.properties[enb_properties_index]->phich_resource[j] = half;
-              } else if (strcmp(phich_resource,"ONE")==0) {
-                enb_properties.properties[enb_properties_index]->phich_resource[j] = one;
-              } else if (strcmp(phich_resource,"TWO")==0) {
-                enb_properties.properties[enb_properties_index]->phich_resource[j] = two;
-              } else
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for phich_resource choice: ONESIXTH,HALF,ONE,TWO!\n",
-                             lib_config_file_name_pP, i, phich_resource);
-
-              if (strcmp(srs_enable, "ENABLE") == 0) {
-                enb_properties.properties[enb_properties_index]->srs_enable[j] = TRUE;
-              } else if (strcmp(srs_enable, "DISABLE") == 0) {
-                enb_properties.properties[enb_properties_index]->srs_enable[j] = FALSE;
-              } else
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for srs_BandwidthConfig choice: ENABLE,DISABLE !\n",
-                             lib_config_file_name_pP, i, srs_enable);
-
-              if (enb_properties.properties[enb_properties_index]->srs_enable[j] == TRUE) {
-                if (!(config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_SRS_BANDWIDTH_CONFIG, &srs_BandwidthConfig)
-                      && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_SRS_SUBFRAME_CONFIG, &srs_SubframeConfig)
-                      && config_setting_lookup_string(component_carrier, ENB_CONFIG_STRING_SRS_ACKNACKST_CONFIG, &srs_ackNackST)
-                      && config_setting_lookup_string(component_carrier, ENB_CONFIG_STRING_SRS_MAXUPPTS, &srs_MaxUpPts)
-                     ))
-                  AssertFatal(0,
-                              "Failed to parse eNB configuration file %s, enb %d unknown values for srs_BandwidthConfig, srs_SubframeConfig, srs_ackNackST, srs_MaxUpPts\n",
-                              lib_config_file_name_pP, i);
-
-                enb_properties.properties[enb_properties_index]->srs_BandwidthConfig[j] = srs_BandwidthConfig;
-
-                if ((srs_BandwidthConfig < 0) || (srs_BandwidthConfig >7))
-                  AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d unknown value %d for srs_BandwidthConfig choice: 0...7\n",
-                               lib_config_file_name_pP, i, srs_BandwidthConfig);
-
-                enb_properties.properties[enb_properties_index]->srs_SubframeConfig[j] = srs_SubframeConfig;
-
-                if ((srs_SubframeConfig<0) || (srs_SubframeConfig>15))
-                  AssertFatal (0,
-                               "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for srs_SubframeConfig choice: 0..15 !\n",
-                               lib_config_file_name_pP, i, srs_SubframeConfig);
-
-                if (strcmp(srs_ackNackST, "ENABLE") == 0) {
-                  enb_properties.properties[enb_properties_index]->srs_ackNackST[j] = TRUE;
-                } else if (strcmp(srs_ackNackST, "DISABLE") == 0) {
-                  enb_properties.properties[enb_properties_index]->srs_ackNackST[j] = FALSE;
-                } else
-                  AssertFatal (0,
-                               "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for srs_BandwidthConfig choice: ENABLE,DISABLE !\n",
-                               lib_config_file_name_pP, i, srs_ackNackST);
-
-                if (strcmp(srs_MaxUpPts, "ENABLE") == 0) {
-                  enb_properties.properties[enb_properties_index]->srs_MaxUpPts[j] = TRUE;
-                } else if (strcmp(srs_MaxUpPts, "DISABLE") == 0) {
-                  enb_properties.properties[enb_properties_index]->srs_MaxUpPts[j] = FALSE;
-                } else
-                  AssertFatal (0,
-                               "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for srs_MaxUpPts choice: ENABLE,DISABLE !\n",
-                               lib_config_file_name_pP, i, srs_MaxUpPts);
-              }
-
-              enb_properties.properties[enb_properties_index]->pusch_p0_Nominal[j] = pusch_p0_Nominal;
-
-              if ((pusch_p0_Nominal<-126) || (pusch_p0_Nominal>24))
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pusch_p0_Nominal choice: -126..24 !\n",
-                             lib_config_file_name_pP, i, pusch_p0_Nominal);
-
-              if (strcmp(pusch_alpha,"AL0")==0) {
-                enb_properties.properties[enb_properties_index]->pusch_alpha[j] = UplinkPowerControlCommon__alpha_al0;
-              } else if (strcmp(pusch_alpha,"AL04")==0) {
-                enb_properties.properties[enb_properties_index]->pusch_alpha[j] = UplinkPowerControlCommon__alpha_al04;
-              } else if (strcmp(pusch_alpha,"AL05")==0) {
-                enb_properties.properties[enb_properties_index]->pusch_alpha[j] = UplinkPowerControlCommon__alpha_al05;
-              } else if (strcmp(pusch_alpha,"AL06")==0) {
-                enb_properties.properties[enb_properties_index]->pusch_alpha[j] = UplinkPowerControlCommon__alpha_al06;
-              } else if (strcmp(pusch_alpha,"AL07")==0) {
-                enb_properties.properties[enb_properties_index]->pusch_alpha[j] = UplinkPowerControlCommon__alpha_al07;
-              } else if (strcmp(pusch_alpha,"AL08")==0) {
-                enb_properties.properties[enb_properties_index]->pusch_alpha[j] = UplinkPowerControlCommon__alpha_al08;
-              } else if (strcmp(pusch_alpha,"AL09")==0) {
-                enb_properties.properties[enb_properties_index]->pusch_alpha[j] = UplinkPowerControlCommon__alpha_al09;
-              } else if (strcmp(pusch_alpha,"AL1")==0) {
-                enb_properties.properties[enb_properties_index]->pusch_alpha[j] = UplinkPowerControlCommon__alpha_al1;
-              } else
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pucch_Alpha choice: AL0,AL04,AL05,AL06,AL07,AL08,AL09,AL1!\n",
-                             lib_config_file_name_pP, i, pusch_alpha);
-
-              enb_properties.properties[enb_properties_index]->pucch_p0_Nominal[j] = pucch_p0_Nominal;
-
-              if ((pucch_p0_Nominal<-127) || (pucch_p0_Nominal>-96))
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pucch_p0_Nominal choice: -127..-96 !\n",
-                             lib_config_file_name_pP, i, pucch_p0_Nominal);
-
-              enb_properties.properties[enb_properties_index]->msg3_delta_Preamble[j] = msg3_delta_Preamble;
-
-              if ((msg3_delta_Preamble<-1) || (msg3_delta_Preamble>6))
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for msg3_delta_Preamble choice: -1..6 !\n",
-                             lib_config_file_name_pP, i, msg3_delta_Preamble);
-
-
-              if (strcmp(pucch_deltaF_Format1,"deltaF_2")==0) {
-                enb_properties.properties[enb_properties_index]->pucch_deltaF_Format1[j] = DeltaFList_PUCCH__deltaF_PUCCH_Format1_deltaF_2;
-              } else if (strcmp(pucch_deltaF_Format1,"deltaF0")==0) {
-                enb_properties.properties[enb_properties_index]->pucch_deltaF_Format1[j] = DeltaFList_PUCCH__deltaF_PUCCH_Format1_deltaF0;
-              } else if (strcmp(pucch_deltaF_Format1,"deltaF2")==0) {
-                enb_properties.properties[enb_properties_index]->pucch_deltaF_Format1[j] = DeltaFList_PUCCH__deltaF_PUCCH_Format1_deltaF2;
-              } else
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pucch_deltaF_Format1 choice: deltaF_2,dltaF0,deltaF2!\n",
-                             lib_config_file_name_pP, i, pucch_deltaF_Format1);
-
-              if (strcmp(pucch_deltaF_Format1b,"deltaF1")==0) {
-                enb_properties.properties[enb_properties_index]->pucch_deltaF_Format1b[j] = DeltaFList_PUCCH__deltaF_PUCCH_Format1b_deltaF1;
-              } else if (strcmp(pucch_deltaF_Format1b,"deltaF3")==0) {
-                enb_properties.properties[enb_properties_index]->pucch_deltaF_Format1b[j] = DeltaFList_PUCCH__deltaF_PUCCH_Format1b_deltaF3;
-              } else if (strcmp(pucch_deltaF_Format1b,"deltaF5")==0) {
-                enb_properties.properties[enb_properties_index]->pucch_deltaF_Format1b[j] = DeltaFList_PUCCH__deltaF_PUCCH_Format1b_deltaF5;
-              } else
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pucch_deltaF_Format1b choice: deltaF1,dltaF3,deltaF5!\n",
-                             lib_config_file_name_pP, i, pucch_deltaF_Format1b);
-
-
-              if (strcmp(pucch_deltaF_Format2,"deltaF_2")==0) {
-                enb_properties.properties[enb_properties_index]->pucch_deltaF_Format2[j] = DeltaFList_PUCCH__deltaF_PUCCH_Format2_deltaF_2;
-              } else if (strcmp(pucch_deltaF_Format2,"deltaF0")==0) {
-                enb_properties.properties[enb_properties_index]->pucch_deltaF_Format2[j] = DeltaFList_PUCCH__deltaF_PUCCH_Format2_deltaF0;
-              } else if (strcmp(pucch_deltaF_Format2,"deltaF1")==0) {
-                enb_properties.properties[enb_properties_index]->pucch_deltaF_Format2[j] = DeltaFList_PUCCH__deltaF_PUCCH_Format2_deltaF1;
-              } else if (strcmp(pucch_deltaF_Format2,"deltaF2")==0) {
-                enb_properties.properties[enb_properties_index]->pucch_deltaF_Format2[j] = DeltaFList_PUCCH__deltaF_PUCCH_Format2_deltaF2;
-              } else
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pucch_deltaF_Format2 choice: deltaF_2,dltaF0,deltaF1,deltaF2!\n",
-                             lib_config_file_name_pP, i, pucch_deltaF_Format2);
-
-              if (strcmp(pucch_deltaF_Format2a,"deltaF_2")==0) {
-                enb_properties.properties[enb_properties_index]->pucch_deltaF_Format2a[j] = DeltaFList_PUCCH__deltaF_PUCCH_Format2a_deltaF_2;
-              } else if (strcmp(pucch_deltaF_Format2a,"deltaF0")==0) {
-                enb_properties.properties[enb_properties_index]->pucch_deltaF_Format2a[j] = DeltaFList_PUCCH__deltaF_PUCCH_Format2a_deltaF0;
-              } else if (strcmp(pucch_deltaF_Format2a,"deltaF2")==0) {
-                enb_properties.properties[enb_properties_index]->pucch_deltaF_Format2a[j] = DeltaFList_PUCCH__deltaF_PUCCH_Format2a_deltaF2;
-              } else
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pucch_deltaF_Format2a choice: deltaF_2,dltaF0,deltaF2!\n",
-                             lib_config_file_name_pP, i, pucch_deltaF_Format2a);
-
-              if (strcmp(pucch_deltaF_Format2b,"deltaF_2")==0) {
-                enb_properties.properties[enb_properties_index]->pucch_deltaF_Format2b[j] = DeltaFList_PUCCH__deltaF_PUCCH_Format2b_deltaF_2;
-              } else if (strcmp(pucch_deltaF_Format2b,"deltaF0")==0) {
-                enb_properties.properties[enb_properties_index]->pucch_deltaF_Format2b[j] = DeltaFList_PUCCH__deltaF_PUCCH_Format2b_deltaF0;
-              } else if (strcmp(pucch_deltaF_Format2b,"deltaF2")==0) {
-                enb_properties.properties[enb_properties_index]->pucch_deltaF_Format2b[j] = DeltaFList_PUCCH__deltaF_PUCCH_Format2b_deltaF2;
-              } else
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pucch_deltaF_Format2b choice: deltaF_2,dltaF0,deltaF2!\n",
-                             lib_config_file_name_pP, i, pucch_deltaF_Format2b);
-
-
-
-
-              enb_properties.properties[enb_properties_index]->rach_numberOfRA_Preambles[j] = (rach_numberOfRA_Preambles/4)-1;
-
-              if ((rach_numberOfRA_Preambles <4) || (rach_numberOfRA_Preambles>64) || ((rach_numberOfRA_Preambles&3)!=0))
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_numberOfRA_Preambles choice: 4,8,12,...,64!\n",
-                             lib_config_file_name_pP, i, rach_numberOfRA_Preambles);
-
-              if (strcmp(rach_preamblesGroupAConfig, "ENABLE") == 0) {
-                enb_properties.properties[enb_properties_index]->rach_preamblesGroupAConfig[j] = TRUE;
-
-                if (!(config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_RACH_SIZEOFRA_PREAMBLESGROUPA, &rach_sizeOfRA_PreamblesGroupA)
-                      && config_setting_lookup_int(component_carrier, ENB_CONFIG_STRING_RACH_MESSAGESIZEGROUPA, &rach_messageSizeGroupA)
-                      && config_setting_lookup_string(component_carrier, ENB_CONFIG_STRING_RACH_MESSAGEPOWEROFFSETGROUPB, &rach_messagePowerOffsetGroupB)))
-                  AssertFatal (0,
-                               "Failed to parse eNB configuration file %s, enb %d  rach_sizeOfRA_PreamblesGroupA, messageSizeGroupA,messagePowerOffsetGroupB!\n",
-                               lib_config_file_name_pP, i);
-
-                enb_properties.properties[enb_properties_index]->rach_sizeOfRA_PreamblesGroupA[j] = (rach_sizeOfRA_PreamblesGroupA/4)-1;
-
-                if ((rach_numberOfRA_Preambles <4) || (rach_numberOfRA_Preambles>60) || ((rach_numberOfRA_Preambles&3)!=0))
-                  AssertFatal (0,
-                               "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_sizeOfRA_PreamblesGroupA choice: 4,8,12,...,60!\n",
-                               lib_config_file_name_pP, i, rach_sizeOfRA_PreamblesGroupA);
-
-
-                switch (rach_messageSizeGroupA) {
-                case 56:
-                  enb_properties.properties[enb_properties_index]->rach_messageSizeGroupA[j] = RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messageSizeGroupA_b56;
-                  break;
-
-                case 144:
-                  enb_properties.properties[enb_properties_index]->rach_messageSizeGroupA[j] = RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messageSizeGroupA_b144;
-                  break;
-
-                case 208:
-                  enb_properties.properties[enb_properties_index]->rach_messageSizeGroupA[j] = RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messageSizeGroupA_b208;
-                  break;
-
-                case 256:
-                  enb_properties.properties[enb_properties_index]->rach_messageSizeGroupA[j] = RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messageSizeGroupA_b256;
-                  break;
-
-                default:
-                  AssertFatal (0,
-                               "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_messageSizeGroupA choice: 56,144,208,256!\n",
-                               lib_config_file_name_pP, i, rach_messageSizeGroupA);
-                  break;
-                }
-
-                if (strcmp(rach_messagePowerOffsetGroupB,"minusinfinity")==0) {
-                  enb_properties.properties[enb_properties_index]->rach_messagePowerOffsetGroupB[j] = RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_minusinfinity;
-                }
-
-                else if (strcmp(rach_messagePowerOffsetGroupB,"dB0")==0) {
-                  enb_properties.properties[enb_properties_index]->rach_messagePowerOffsetGroupB[j] = RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB0;
-                }
-
-                else if (strcmp(rach_messagePowerOffsetGroupB,"dB5")==0) {
-                  enb_properties.properties[enb_properties_index]->rach_messagePowerOffsetGroupB[j] = RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB5;
-                }
-
-                else if (strcmp(rach_messagePowerOffsetGroupB,"dB8")==0) {
-                  enb_properties.properties[enb_properties_index]->rach_messagePowerOffsetGroupB[j] = RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB8;
-                }
-
-                else if (strcmp(rach_messagePowerOffsetGroupB,"dB10")==0) {
-                  enb_properties.properties[enb_properties_index]->rach_messagePowerOffsetGroupB[j] = RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB10;
-                }
-
-                else if (strcmp(rach_messagePowerOffsetGroupB,"dB12")==0) {
-                  enb_properties.properties[enb_properties_index]->rach_messagePowerOffsetGroupB[j] = RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB12;
-                }
+	      case 16:
+		rrc->srb1_poll_pdu = PollPDU_p16;
+		break;
 
-                else if (strcmp(rach_messagePowerOffsetGroupB,"dB15")==0) {
-                  enb_properties.properties[enb_properties_index]->rach_messagePowerOffsetGroupB[j] = RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB15;
-                }
+	      case 32:
+		rrc->srb1_poll_pdu = PollPDU_p32;
+		break;
 
-                else if (strcmp(rach_messagePowerOffsetGroupB,"dB18")==0) {
-                  enb_properties.properties[enb_properties_index]->rach_messagePowerOffsetGroupB[j] = RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB18;
-                } else
-                  AssertFatal (0,
-                               "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for rach_messagePowerOffsetGroupB choice: minusinfinity,dB0,dB5,dB8,dB10,dB12,dB15,dB18!\n",
-                               lib_config_file_name_pP, i, rach_messagePowerOffsetGroupB);
+	      case 64:
+		rrc->srb1_poll_pdu = PollPDU_p64;
+		break;
 
-              } else if (strcmp(rach_preamblesGroupAConfig, "DISABLE") == 0) {
-                enb_properties.properties[enb_properties_index]->rach_preamblesGroupAConfig[j] = FALSE;
-              } else
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for rach_preamblesGroupAConfig choice: ENABLE,DISABLE !\n",
-                             lib_config_file_name_pP, i, rach_preamblesGroupAConfig);
+	      case 128:
+		rrc->srb1_poll_pdu = PollPDU_p128;
+		break;
 
-              enb_properties.properties[enb_properties_index]->rach_preambleInitialReceivedTargetPower[j] = (rach_preambleInitialReceivedTargetPower+120)/2;
+	      case 256:
+		rrc->srb1_poll_pdu = PollPDU_p256;
+		break;
 
-              if ((rach_preambleInitialReceivedTargetPower<-120) || (rach_preambleInitialReceivedTargetPower>-90) || ((rach_preambleInitialReceivedTargetPower&1)!=0))
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_preambleInitialReceivedTargetPower choice: -120,-118,...,-90 !\n",
-                             lib_config_file_name_pP, i, rach_preambleInitialReceivedTargetPower);
+	      default:
+		if (srb1_poll_pdu >= 10000)
+		  rrc->srb1_poll_pdu = PollPDU_pInfinity;
+		else
+		  AssertFatal (0,
+			       "Bad config value when parsing eNB configuration file %s, enb %d  srb1_poll_pdu %u!\n",
+			       RC.config_file_name, i, srb1_poll_pdu);
+	      }
 
+	      rrc->srb1_poll_byte             = srb1_poll_byte;
 
-              enb_properties.properties[enb_properties_index]->rach_powerRampingStep[j] = rach_powerRampingStep/2;
+	      switch (srb1_poll_byte) {
+	      case 25:
+		rrc->srb1_poll_byte = PollByte_kB25;
+		break;
 
-              if ((rach_powerRampingStep<0) || (rach_powerRampingStep>6) || ((rach_powerRampingStep&1)!=0))
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_powerRampingStep choice: 0,2,4,6 !\n",
-                             lib_config_file_name_pP, i, rach_powerRampingStep);
+	      case 50:
+		rrc->srb1_poll_byte = PollByte_kB50;
+		break;
 
+	      case 75:
+		rrc->srb1_poll_byte = PollByte_kB75;
+		break;
 
+	      case 100:
+		rrc->srb1_poll_byte = PollByte_kB100;
+		break;
 
-              switch (rach_preambleTransMax) {
-              case 3:
-                enb_properties.properties[enb_properties_index]->rach_preambleTransMax[j] =  RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n3;
-                break;
+	      case 125:
+		rrc->srb1_poll_byte = PollByte_kB125;
+		break;
 
-              case 4:
-                enb_properties.properties[enb_properties_index]->rach_preambleTransMax[j] =  RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n4;
-                break;
+	      case 250:
+		rrc->srb1_poll_byte = PollByte_kB250;
+		break;
 
-              case 5:
-                enb_properties.properties[enb_properties_index]->rach_preambleTransMax[j] =  RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n5;
-                break;
-
-              case 6:
-                enb_properties.properties[enb_properties_index]->rach_preambleTransMax[j] =  RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n6;
-                break;
-
-              case 7:
-                enb_properties.properties[enb_properties_index]->rach_preambleTransMax[j] =  RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n7;
-                break;
-
-              case 8:
-                enb_properties.properties[enb_properties_index]->rach_preambleTransMax[j] =  RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n8;
-                break;
-
-              case 10:
-                enb_properties.properties[enb_properties_index]->rach_preambleTransMax[j] =  RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n10;
-                break;
-
-              case 20:
-                enb_properties.properties[enb_properties_index]->rach_preambleTransMax[j] =  RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n20;
-                break;
-
-              case 50:
-                enb_properties.properties[enb_properties_index]->rach_preambleTransMax[j] =  RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n50;
-                break;
-
-              case 100:
-                enb_properties.properties[enb_properties_index]->rach_preambleTransMax[j] =  RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n100;
-                break;
-
-              case 200:
-                enb_properties.properties[enb_properties_index]->rach_preambleTransMax[j] =  RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n200;
-                break;
-
-              default:
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_preambleTransMax choice: 3,4,5,6,7,8,10,20,50,100,200!\n",
-                             lib_config_file_name_pP, i, rach_preambleTransMax);
-                break;
-              }
-
-              enb_properties.properties[enb_properties_index]->rach_raResponseWindowSize[j] =  (rach_raResponseWindowSize==10)?7:rach_raResponseWindowSize-2;
-
-              if ((rach_raResponseWindowSize<0)||(rach_raResponseWindowSize==9)||(rach_raResponseWindowSize>10))
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_raResponseWindowSize choice: 2,3,4,5,6,7,8,10!\n",
-                             lib_config_file_name_pP, i, rach_preambleTransMax);
-
-
-              enb_properties.properties[enb_properties_index]->rach_macContentionResolutionTimer[j] = (rach_macContentionResolutionTimer/8)-1;
-
-              if ((rach_macContentionResolutionTimer<8) || (rach_macContentionResolutionTimer>64) || ((rach_macContentionResolutionTimer&7)!=0))
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_macContentionResolutionTimer choice: 8,16,...,56,64!\n",
-                             lib_config_file_name_pP, i, rach_preambleTransMax);
-
-              enb_properties.properties[enb_properties_index]->rach_maxHARQ_Msg3Tx[j] = rach_maxHARQ_Msg3Tx;
+	      case 375:
+		rrc->srb1_poll_byte = PollByte_kB375;
+		break;
 
-              if ((rach_maxHARQ_Msg3Tx<0) || (rach_maxHARQ_Msg3Tx>8))
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_maxHARQ_Msg3Tx choice: 1..8!\n",
-                             lib_config_file_name_pP, i, rach_preambleTransMax);
+	      case 500:
+		rrc->srb1_poll_byte = PollByte_kB500;
+		break;
 
+	      case 750:
+		rrc->srb1_poll_byte = PollByte_kB750;
+		break;
 
-              switch (pcch_defaultPagingCycle) {
-              case 32:
-                enb_properties.properties[enb_properties_index]->pcch_defaultPagingCycle[j] = PCCH_Config__defaultPagingCycle_rf32;
-                break;
+	      case 1000:
+		rrc->srb1_poll_byte = PollByte_kB1000;
+		break;
 
-              case 64:
-                enb_properties.properties[enb_properties_index]->pcch_defaultPagingCycle[j] = PCCH_Config__defaultPagingCycle_rf64;
-                break;
+	      case 1250:
+		rrc->srb1_poll_byte = PollByte_kB1250;
+		break;
 
-              case 128:
-                enb_properties.properties[enb_properties_index]->pcch_defaultPagingCycle[j] = PCCH_Config__defaultPagingCycle_rf128;
-                break;
+	      case 1500:
+		rrc->srb1_poll_byte = PollByte_kB1500;
+		break;
 
-              case 256:
-                enb_properties.properties[enb_properties_index]->pcch_defaultPagingCycle[j] = PCCH_Config__defaultPagingCycle_rf256;
-                break;
-
-              default:
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pcch_defaultPagingCycle choice: 32,64,128,256!\n",
-                             lib_config_file_name_pP, i, pcch_defaultPagingCycle);
-                break;
-              }
-
-              if (strcmp(pcch_nB, "fourT") == 0) {
-                enb_properties.properties[enb_properties_index]->pcch_nB[j] = PCCH_Config__nB_fourT;
-              } else if (strcmp(pcch_nB, "twoT") == 0) {
-                enb_properties.properties[enb_properties_index]->pcch_nB[j] = PCCH_Config__nB_twoT;
-              } else if (strcmp(pcch_nB, "oneT") == 0) {
-                enb_properties.properties[enb_properties_index]->pcch_nB[j] = PCCH_Config__nB_oneT;
-              } else if (strcmp(pcch_nB, "halfT") == 0) {
-                enb_properties.properties[enb_properties_index]->pcch_nB[j] = PCCH_Config__nB_halfT;
-              } else if (strcmp(pcch_nB, "quarterT") == 0) {
-                enb_properties.properties[enb_properties_index]->pcch_nB[j] = PCCH_Config__nB_quarterT;
-              } else if (strcmp(pcch_nB, "oneEighthT") == 0) {
-                enb_properties.properties[enb_properties_index]->pcch_nB[j] = PCCH_Config__nB_oneEighthT;
-              } else if (strcmp(pcch_nB, "oneSixteenthT") == 0) {
-                enb_properties.properties[enb_properties_index]->pcch_nB[j] = PCCH_Config__nB_oneSixteenthT;
-              } else if (strcmp(pcch_nB, "oneThirtySecondT") == 0) {
-                enb_properties.properties[enb_properties_index]->pcch_nB[j] = PCCH_Config__nB_oneThirtySecondT;
-              } else
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pcch_nB choice: fourT,twoT,oneT,halfT,quarterT,oneighthT,oneSixteenthT,oneThirtySecondT !\n",
-                             lib_config_file_name_pP, i, pcch_defaultPagingCycle);
-
-
-
-              switch (bcch_modificationPeriodCoeff) {
-              case 2:
-                enb_properties.properties[enb_properties_index]->bcch_modificationPeriodCoeff[j] = BCCH_Config__modificationPeriodCoeff_n2;
-                break;
-
-              case 4:
-                enb_properties.properties[enb_properties_index]->bcch_modificationPeriodCoeff[j] = BCCH_Config__modificationPeriodCoeff_n4;
-                break;
-
-              case 8:
-                enb_properties.properties[enb_properties_index]->bcch_modificationPeriodCoeff[j] = BCCH_Config__modificationPeriodCoeff_n8;
-                break;
-
-              case 16:
-                enb_properties.properties[enb_properties_index]->bcch_modificationPeriodCoeff[j] = BCCH_Config__modificationPeriodCoeff_n16;
-                break;
-
-              default:
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for bcch_modificationPeriodCoeff choice: 2,4,8,16",
-                             lib_config_file_name_pP, i, bcch_modificationPeriodCoeff);
-
-                break;
-              }
-
-
-              switch (ue_TimersAndConstants_t300) {
-              case 100:
-                enb_properties.properties[enb_properties_index]->ue_TimersAndConstants_t300[j] = UE_TimersAndConstants__t300_ms100;
-                break;
-
-              case 200:
-                enb_properties.properties[enb_properties_index]->ue_TimersAndConstants_t300[j] = UE_TimersAndConstants__t300_ms200;
-                break;
-
-              case 300:
-                enb_properties.properties[enb_properties_index]->ue_TimersAndConstants_t300[j] = UE_TimersAndConstants__t300_ms300;
-                break;
-
-              case 400:
-                enb_properties.properties[enb_properties_index]->ue_TimersAndConstants_t300[j] = UE_TimersAndConstants__t300_ms400;
-                break;
-
-              case 600:
-                enb_properties.properties[enb_properties_index]->ue_TimersAndConstants_t300[j] = UE_TimersAndConstants__t300_ms600;
-                break;
-
-              case 1000:
-                enb_properties.properties[enb_properties_index]->ue_TimersAndConstants_t300[j] = UE_TimersAndConstants__t300_ms1000;
-                break;
-
-              case 1500:
-                enb_properties.properties[enb_properties_index]->ue_TimersAndConstants_t300[j] = UE_TimersAndConstants__t300_ms1500;
-                break;
-
-              case 2000:
-                enb_properties.properties[enb_properties_index]->ue_TimersAndConstants_t300[j] = UE_TimersAndConstants__t300_ms2000;
-                break;
-
-              default:
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for ue_TimersAndConstants_t300 choice: 100,200,300,400,600,1000,1500,2000 ",
-                             lib_config_file_name_pP, i, ue_TimersAndConstants_t300);
-                break;
-
-              }
-
-              switch (ue_TimersAndConstants_t301) {
-              case 100:
-                enb_properties.properties[enb_properties_index]->ue_TimersAndConstants_t301[j] = UE_TimersAndConstants__t301_ms100;
-                break;
-
-              case 200:
-                enb_properties.properties[enb_properties_index]->ue_TimersAndConstants_t301[j] = UE_TimersAndConstants__t301_ms200;
-                break;
-
-              case 300:
-                enb_properties.properties[enb_properties_index]->ue_TimersAndConstants_t301[j] = UE_TimersAndConstants__t301_ms300;
-                break;
-
-              case 400:
-                enb_properties.properties[enb_properties_index]->ue_TimersAndConstants_t301[j] = UE_TimersAndConstants__t301_ms400;
-                break;
-
-              case 600:
-                enb_properties.properties[enb_properties_index]->ue_TimersAndConstants_t301[j] = UE_TimersAndConstants__t301_ms600;
-                break;
-
-              case 1000:
-                enb_properties.properties[enb_properties_index]->ue_TimersAndConstants_t301[j] = UE_TimersAndConstants__t301_ms1000;
-                break;
+	      case 2000:
+		rrc->srb1_poll_byte = PollByte_kB2000;
+		break;
 
-              case 1500:
-                enb_properties.properties[enb_properties_index]->ue_TimersAndConstants_t301[j] = UE_TimersAndConstants__t301_ms1500;
-                break;
+	      case 3000:
+		rrc->srb1_poll_byte = PollByte_kB3000;
+		break;
 
-              case 2000:
-                enb_properties.properties[enb_properties_index]->ue_TimersAndConstants_t301[j] = UE_TimersAndConstants__t301_ms2000;
-                break;
+	      default:
+		if (srb1_poll_byte >= 10000)
+		  rrc->srb1_poll_byte = PollByte_kBinfinity;
+		else
+		  AssertFatal (0,
+			       "Bad config value when parsing eNB configuration file %s, enb %d  srb1_poll_byte %u!\n",
+			       RC.config_file_name, i, srb1_poll_byte);
+	      }
 
-              default:
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for ue_TimersAndConstants_t301 choice: 100,200,300,400,600,1000,1500,2000 ",
-                             lib_config_file_name_pP, i, ue_TimersAndConstants_t301);
-                break;
-
-              }
+	      if (srb1_timer_poll_retransmit <= 250) {
+		rrc->srb1_timer_poll_retransmit = (srb1_timer_poll_retransmit - 5)/5;
+	      } else if (srb1_timer_poll_retransmit <= 500) {
+		rrc->srb1_timer_poll_retransmit = (srb1_timer_poll_retransmit - 300)/50 + 50;
+	      } else {
+		AssertFatal (0,
+			     "Bad config value when parsing eNB configuration file %s, enb %d  srb1_timer_poll_retransmit %u!\n",
+			     RC.config_file_name, i, srb1_timer_poll_retransmit);
+	      }
 
-              switch (ue_TimersAndConstants_t310) {
-              case 0:
-                enb_properties.properties[enb_properties_index]->ue_TimersAndConstants_t310[j] = UE_TimersAndConstants__t310_ms0;
-                break;
+	      if (srb1_timer_status_prohibit <= 250) {
+		rrc->srb1_timer_status_prohibit = srb1_timer_status_prohibit/5;
+	      } else if ((srb1_timer_poll_retransmit >= 300) && (srb1_timer_poll_retransmit <= 500)) {
+		rrc->srb1_timer_status_prohibit = (srb1_timer_status_prohibit - 300)/50 + 51;
+	      } else {
+		AssertFatal (0,
+			     "Bad config value when parsing eNB configuration file %s, enb %d  srb1_timer_status_prohibit %u!\n",
+			     RC.config_file_name, i, srb1_timer_status_prohibit);
+	      }
 
-              case 50:
-                enb_properties.properties[enb_properties_index]->ue_TimersAndConstants_t310[j] = UE_TimersAndConstants__t310_ms50;
-                break;
+	      switch (srb1_timer_reordering) {
+	      case 0:
+		rrc->srb1_timer_reordering = T_Reordering_ms0;
+		break;
 
-              case 100:
-                enb_properties.properties[enb_properties_index]->ue_TimersAndConstants_t310[j] = UE_TimersAndConstants__t310_ms100;
-                break;
+	      case 5:
+		rrc->srb1_timer_reordering = T_Reordering_ms5;
+		break;
 
-              case 200:
-                enb_properties.properties[enb_properties_index]->ue_TimersAndConstants_t310[j] = UE_TimersAndConstants__t310_ms200;
-                break;
+	      case 10:
+		rrc->srb1_timer_reordering = T_Reordering_ms10;
+		break;
 
-              case 500:
-                enb_properties.properties[enb_properties_index]->ue_TimersAndConstants_t310[j] = UE_TimersAndConstants__t310_ms500;
-                break;
-
-              case 1000:
-                enb_properties.properties[enb_properties_index]->ue_TimersAndConstants_t310[j] = UE_TimersAndConstants__t310_ms1000;
-                break;
-
-              case 2000:
-                enb_properties.properties[enb_properties_index]->ue_TimersAndConstants_t310[j] = UE_TimersAndConstants__t310_ms2000;
-                break;
-
-              default:
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for ue_TimersAndConstants_t310 choice: 0,50,100,200,500,1000,1500,2000 ",
-                             lib_config_file_name_pP, i, ue_TimersAndConstants_t310);
-                break;
-
-              }
-
-              switch (ue_TimersAndConstants_t311) {
-              case 1000:
-                enb_properties.properties[enb_properties_index]->ue_TimersAndConstants_t311[j] = UE_TimersAndConstants__t311_ms1000;
-                break;
-
-              case 3110:
-                enb_properties.properties[enb_properties_index]->ue_TimersAndConstants_t311[j] = UE_TimersAndConstants__t311_ms3000;
-                break;
-
-              case 5000:
-                enb_properties.properties[enb_properties_index]->ue_TimersAndConstants_t311[j] = UE_TimersAndConstants__t311_ms5000;
-                break;
-
-              case 10000:
-                enb_properties.properties[enb_properties_index]->ue_TimersAndConstants_t311[j] = UE_TimersAndConstants__t311_ms10000;
-                break;
-
-              case 15000:
-                enb_properties.properties[enb_properties_index]->ue_TimersAndConstants_t311[j] = UE_TimersAndConstants__t311_ms15000;
-                break;
-
-              case 20000:
-                enb_properties.properties[enb_properties_index]->ue_TimersAndConstants_t311[j] = UE_TimersAndConstants__t311_ms20000;
-                break;
-
-              case 31100:
-                enb_properties.properties[enb_properties_index]->ue_TimersAndConstants_t311[j] = UE_TimersAndConstants__t311_ms30000;
-                break;
-
-              default:
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for ue_TimersAndConstants_t311 choice: 1000,3000,5000,10000,150000,20000,30000",
-                             lib_config_file_name_pP, i, ue_TimersAndConstants_t311);
-                break;
+	      case 15:
+		rrc->srb1_timer_reordering = T_Reordering_ms15;
+		break;
 
-              }
-
-              switch (ue_TimersAndConstants_n310) {
-              case 1:
-                enb_properties.properties[enb_properties_index]->ue_TimersAndConstants_n310[j] = UE_TimersAndConstants__n310_n1;
-                break;
+	      case 20:
+		rrc->srb1_timer_reordering = T_Reordering_ms20;
+		break;
 
-              case 2:
-                enb_properties.properties[enb_properties_index]->ue_TimersAndConstants_n310[j] = UE_TimersAndConstants__n310_n2;
-                break;
+	      case 25:
+		rrc->srb1_timer_reordering = T_Reordering_ms25;
+		break;
 
-              case 3:
-                enb_properties.properties[enb_properties_index]->ue_TimersAndConstants_n310[j] = UE_TimersAndConstants__n310_n3;
-                break;
+	      case 30:
+		rrc->srb1_timer_reordering = T_Reordering_ms30;
+		break;
 
-              case 4:
-                enb_properties.properties[enb_properties_index]->ue_TimersAndConstants_n310[j] = UE_TimersAndConstants__n310_n4;
-                break;
+	      case 35:
+		rrc->srb1_timer_reordering = T_Reordering_ms35;
+		break;
 
-              case 6:
-                enb_properties.properties[enb_properties_index]->ue_TimersAndConstants_n310[j] = UE_TimersAndConstants__n310_n6;
-                break;
+	      case 40:
+		rrc->srb1_timer_reordering = T_Reordering_ms40;
+		break;
 
-              case 8:
-                enb_properties.properties[enb_properties_index]->ue_TimersAndConstants_n310[j] = UE_TimersAndConstants__n310_n8;
-                break;
+	      case 45:
+		rrc->srb1_timer_reordering = T_Reordering_ms45;
+		break;
 
-              case 10:
-                enb_properties.properties[enb_properties_index]->ue_TimersAndConstants_n310[j] = UE_TimersAndConstants__n310_n10;
-                break;
+	      case 50:
+		rrc->srb1_timer_reordering = T_Reordering_ms50;
+		break;
 
-              case 20:
-                enb_properties.properties[enb_properties_index]->ue_TimersAndConstants_n310[j] = UE_TimersAndConstants__n310_n20;
-                break;
+	      case 55:
+		rrc->srb1_timer_reordering = T_Reordering_ms55;
+		break;
 
-              default:
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for ue_TimersAndConstants_n310 choice: 1,2,3,4,6,6,8,10,20",
-                             lib_config_file_name_pP, i, ue_TimersAndConstants_n311);
-                break;
+	      case 60:
+		rrc->srb1_timer_reordering = T_Reordering_ms60;
+		break;
 
-              }
+	      case 65:
+		rrc->srb1_timer_reordering = T_Reordering_ms65;
+		break;
 
-              switch (ue_TimersAndConstants_n311) {
-              case 1:
-                enb_properties.properties[enb_properties_index]->ue_TimersAndConstants_n311[j] = UE_TimersAndConstants__n311_n1;
-                break;
+	      case 70:
+		rrc->srb1_timer_reordering = T_Reordering_ms70;
+		break;
 
-              case 2:
-                enb_properties.properties[enb_properties_index]->ue_TimersAndConstants_n311[j] = UE_TimersAndConstants__n311_n2;
-                break;
+	      case 75:
+		rrc->srb1_timer_reordering = T_Reordering_ms75;
+		break;
 
-              case 3:
-                enb_properties.properties[enb_properties_index]->ue_TimersAndConstants_n311[j] = UE_TimersAndConstants__n311_n3;
-                break;
+	      case 80:
+		rrc->srb1_timer_reordering = T_Reordering_ms80;
+		break;
 
-              case 4:
-                enb_properties.properties[enb_properties_index]->ue_TimersAndConstants_n311[j] = UE_TimersAndConstants__n311_n4;
-                break;
+	      case 85:
+		rrc->srb1_timer_reordering = T_Reordering_ms85;
+		break;
 
-              case 5:
-                enb_properties.properties[enb_properties_index]->ue_TimersAndConstants_n311[j] = UE_TimersAndConstants__n311_n5;
-                break;
+	      case 90:
+		rrc->srb1_timer_reordering = T_Reordering_ms90;
+		break;
 
-              case 6:
-                enb_properties.properties[enb_properties_index]->ue_TimersAndConstants_n311[j] = UE_TimersAndConstants__n311_n6;
-                break;
+	      case 95:
+		rrc->srb1_timer_reordering = T_Reordering_ms95;
+		break;
 
-              case 8:
-                enb_properties.properties[enb_properties_index]->ue_TimersAndConstants_n311[j] = UE_TimersAndConstants__n311_n8;
-                break;
+	      case 100:
+		rrc->srb1_timer_reordering = T_Reordering_ms100;
+		break;
 
-              case 10:
-                enb_properties.properties[enb_properties_index]->ue_TimersAndConstants_n311[j] = UE_TimersAndConstants__n311_n10;
-                break;
+	      case 110:
+		rrc->srb1_timer_reordering = T_Reordering_ms110;
+		break;
 
-              default:
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for ue_TimersAndConstants_t311 choice: 1,2,3,4,5,6,8,10",
-                             lib_config_file_name_pP, i, ue_TimersAndConstants_t311);
-                break;
+	      case 120:
+		rrc->srb1_timer_reordering = T_Reordering_ms120;
+		break;
 
-              }
+	      case 130:
+		rrc->srb1_timer_reordering = T_Reordering_ms130;
+		break;
 
-	      switch (ue_TransmissionMode) {
-	      case 1:
-		enb_properties.properties[enb_properties_index]->ue_TransmissionMode[j] = AntennaInfoDedicated__transmissionMode_tm1;
+	      case 140:
+		rrc->srb1_timer_reordering = T_Reordering_ms140;
 		break;
-	      case 2:
-		enb_properties.properties[enb_properties_index]->ue_TransmissionMode[j] = AntennaInfoDedicated__transmissionMode_tm2;
+
+	      case 150:
+		rrc->srb1_timer_reordering = T_Reordering_ms150;
 		break;
-	      case 3:
-		enb_properties.properties[enb_properties_index]->ue_TransmissionMode[j] = AntennaInfoDedicated__transmissionMode_tm3;
+
+	      case 160:
+		rrc->srb1_timer_reordering = T_Reordering_ms160;
 		break;
-	      case 4:
-		enb_properties.properties[enb_properties_index]->ue_TransmissionMode[j] = AntennaInfoDedicated__transmissionMode_tm4;
+
+	      case 170:
+		rrc->srb1_timer_reordering = T_Reordering_ms170;
 		break;
-	      case 5:
-		enb_properties.properties[enb_properties_index]->ue_TransmissionMode[j] = AntennaInfoDedicated__transmissionMode_tm5;
+
+	      case 180:
+		rrc->srb1_timer_reordering = T_Reordering_ms180;
 		break;
-	      case 6:
-		enb_properties.properties[enb_properties_index]->ue_TransmissionMode[j] = AntennaInfoDedicated__transmissionMode_tm6;
+
+	      case 190:
+		rrc->srb1_timer_reordering = T_Reordering_ms190;
 		break;
-	      case 7:
-		enb_properties.properties[enb_properties_index]->ue_TransmissionMode[j] = AntennaInfoDedicated__transmissionMode_tm7;
+
+	      case 200:
+		rrc->srb1_timer_reordering = T_Reordering_ms200;
 		break;
+
 	      default:
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for ue_TransmissionMode choice: 1,2,3,4,5,6,7",
-                             lib_config_file_name_pP, i, ue_TransmissionMode);
-		break;
+		AssertFatal (0,
+			     "Bad config value when parsing eNB configuration file %s, enb %d  srb1_timer_reordering %u!\n",
+			     RC.config_file_name, i, srb1_timer_reordering);
 	      }
-            }
-          }
-
-          setting_srb1 = config_setting_get_member (setting_enb, ENB_CONFIG_STRING_SRB1);
-
-          if (setting_srb1 != NULL) {
-            if (!(config_setting_lookup_int(setting_srb1, ENB_CONFIG_STRING_SRB1_TIMER_POLL_RETRANSMIT, &srb1_timer_poll_retransmit)
-                  && config_setting_lookup_int(setting_srb1, ENB_CONFIG_STRING_SRB1_TIMER_REORDERING,      &srb1_timer_reordering)
-                  && config_setting_lookup_int(setting_srb1, ENB_CONFIG_STRING_SRB1_TIMER_STATUS_PROHIBIT, &srb1_timer_status_prohibit)
-                  && config_setting_lookup_int(setting_srb1, ENB_CONFIG_STRING_SRB1_MAX_RETX_THRESHOLD,    &srb1_max_retx_threshold)
-                  && config_setting_lookup_int(setting_srb1, ENB_CONFIG_STRING_SRB1_POLL_PDU,              &srb1_poll_pdu)
-                  && config_setting_lookup_int(setting_srb1, ENB_CONFIG_STRING_SRB1_POLL_BYTE,             &srb1_poll_byte)))
-              AssertFatal (0,
-                           "Failed to parse eNB configuration file %s, enb %d  timer_poll_retransmit, timer_reordering, "
-                           "timer_status_prohibit, poll_pdu, poll_byte, max_retx_threshold !\n",
-                           lib_config_file_name_pP, i);
-
-            switch (srb1_max_retx_threshold) {
-            case 1:
-              enb_properties.properties[enb_properties_index]->srb1_max_retx_threshold = UL_AM_RLC__maxRetxThreshold_t1;
-              break;
-
-            case 2:
-              enb_properties.properties[enb_properties_index]->srb1_max_retx_threshold = UL_AM_RLC__maxRetxThreshold_t2;
-              break;
-
-            case 3:
-              enb_properties.properties[enb_properties_index]->srb1_max_retx_threshold = UL_AM_RLC__maxRetxThreshold_t3;
-              break;
-
-            case 4:
-              enb_properties.properties[enb_properties_index]->srb1_max_retx_threshold = UL_AM_RLC__maxRetxThreshold_t4;
-              break;
-
-            case 6:
-              enb_properties.properties[enb_properties_index]->srb1_max_retx_threshold = UL_AM_RLC__maxRetxThreshold_t6;
-              break;
-
-            case 8:
-              enb_properties.properties[enb_properties_index]->srb1_max_retx_threshold = UL_AM_RLC__maxRetxThreshold_t8;
-              break;
-
-            case 16:
-              enb_properties.properties[enb_properties_index]->srb1_max_retx_threshold = UL_AM_RLC__maxRetxThreshold_t16;
-              break;
-
-            case 32:
-              enb_properties.properties[enb_properties_index]->srb1_max_retx_threshold = UL_AM_RLC__maxRetxThreshold_t32;
-              break;
-
-            default:
-              AssertFatal (0,
-                           "Bad config value when parsing eNB configuration file %s, enb %d  srb1_max_retx_threshold %u!\n",
-                           lib_config_file_name_pP, i, srb1_max_retx_threshold);
-            }
-
-            switch (srb1_poll_pdu) {
-            case 4:
-              enb_properties.properties[enb_properties_index]->srb1_poll_pdu = PollPDU_p4;
-              break;
-
-            case 8:
-              enb_properties.properties[enb_properties_index]->srb1_poll_pdu = PollPDU_p8;
-              break;
-
-            case 16:
-              enb_properties.properties[enb_properties_index]->srb1_poll_pdu = PollPDU_p16;
-              break;
-
-            case 32:
-              enb_properties.properties[enb_properties_index]->srb1_poll_pdu = PollPDU_p32;
-              break;
-
-            case 64:
-              enb_properties.properties[enb_properties_index]->srb1_poll_pdu = PollPDU_p64;
-              break;
-
-            case 128:
-              enb_properties.properties[enb_properties_index]->srb1_poll_pdu = PollPDU_p128;
-              break;
-
-            case 256:
-              enb_properties.properties[enb_properties_index]->srb1_poll_pdu = PollPDU_p256;
-              break;
-
-            default:
-              if (srb1_poll_pdu >= 10000)
-                enb_properties.properties[enb_properties_index]->srb1_poll_pdu = PollPDU_pInfinity;
-              else
-                AssertFatal (0,
-                             "Bad config value when parsing eNB configuration file %s, enb %d  srb1_poll_pdu %u!\n",
-                             lib_config_file_name_pP, i, srb1_poll_pdu);
-            }
-
-            enb_properties.properties[enb_properties_index]->srb1_poll_byte             = srb1_poll_byte;
-
-            switch (srb1_poll_byte) {
-            case 25:
-              enb_properties.properties[enb_properties_index]->srb1_poll_byte = PollByte_kB25;
-              break;
-
-            case 50:
-              enb_properties.properties[enb_properties_index]->srb1_poll_byte = PollByte_kB50;
-              break;
-
-            case 75:
-              enb_properties.properties[enb_properties_index]->srb1_poll_byte = PollByte_kB75;
-              break;
-
-            case 100:
-              enb_properties.properties[enb_properties_index]->srb1_poll_byte = PollByte_kB100;
-              break;
-
-            case 125:
-              enb_properties.properties[enb_properties_index]->srb1_poll_byte = PollByte_kB125;
-              break;
-
-            case 250:
-              enb_properties.properties[enb_properties_index]->srb1_poll_byte = PollByte_kB250;
-              break;
-
-            case 375:
-              enb_properties.properties[enb_properties_index]->srb1_poll_byte = PollByte_kB375;
-              break;
-
-            case 500:
-              enb_properties.properties[enb_properties_index]->srb1_poll_byte = PollByte_kB500;
-              break;
-
-            case 750:
-              enb_properties.properties[enb_properties_index]->srb1_poll_byte = PollByte_kB750;
-              break;
-
-            case 1000:
-              enb_properties.properties[enb_properties_index]->srb1_poll_byte = PollByte_kB1000;
-              break;
-
-            case 1250:
-              enb_properties.properties[enb_properties_index]->srb1_poll_byte = PollByte_kB1250;
-              break;
-
-            case 1500:
-              enb_properties.properties[enb_properties_index]->srb1_poll_byte = PollByte_kB1500;
-              break;
-
-            case 2000:
-              enb_properties.properties[enb_properties_index]->srb1_poll_byte = PollByte_kB2000;
-              break;
-
-            case 3000:
-              enb_properties.properties[enb_properties_index]->srb1_poll_byte = PollByte_kB3000;
-              break;
-
-            default:
-              if (srb1_poll_byte >= 10000)
-                enb_properties.properties[enb_properties_index]->srb1_poll_byte = PollByte_kBinfinity;
-              else
-                AssertFatal (0,
-                             "Bad config value when parsing eNB configuration file %s, enb %d  srb1_poll_byte %u!\n",
-                             lib_config_file_name_pP, i, srb1_poll_byte);
-            }
-
-            if (srb1_timer_poll_retransmit <= 250) {
-              enb_properties.properties[enb_properties_index]->srb1_timer_poll_retransmit = (srb1_timer_poll_retransmit - 5)/5;
-            } else if (srb1_timer_poll_retransmit <= 500) {
-              enb_properties.properties[enb_properties_index]->srb1_timer_poll_retransmit = (srb1_timer_poll_retransmit - 300)/50 + 50;
-            } else {
-              AssertFatal (0,
-                           "Bad config value when parsing eNB configuration file %s, enb %d  srb1_timer_poll_retransmit %u!\n",
-                           lib_config_file_name_pP, i, srb1_timer_poll_retransmit);
-            }
-
-            if (srb1_timer_status_prohibit <= 250) {
-              enb_properties.properties[enb_properties_index]->srb1_timer_status_prohibit = srb1_timer_status_prohibit/5;
-            } else if ((srb1_timer_poll_retransmit >= 300) && (srb1_timer_poll_retransmit <= 500)) {
-              enb_properties.properties[enb_properties_index]->srb1_timer_status_prohibit = (srb1_timer_status_prohibit - 300)/50 + 51;
-            } else {
-              AssertFatal (0,
-                           "Bad config value when parsing eNB configuration file %s, enb %d  srb1_timer_status_prohibit %u!\n",
-                           lib_config_file_name_pP, i, srb1_timer_status_prohibit);
-            }
-
-            switch (srb1_timer_reordering) {
-            case 0:
-              enb_properties.properties[enb_properties_index]->srb1_timer_reordering = T_Reordering_ms0;
-              break;
-
-            case 5:
-              enb_properties.properties[enb_properties_index]->srb1_timer_reordering = T_Reordering_ms5;
-              break;
-
-            case 10:
-              enb_properties.properties[enb_properties_index]->srb1_timer_reordering = T_Reordering_ms10;
-              break;
-
-            case 15:
-              enb_properties.properties[enb_properties_index]->srb1_timer_reordering = T_Reordering_ms15;
-              break;
-
-            case 20:
-              enb_properties.properties[enb_properties_index]->srb1_timer_reordering = T_Reordering_ms20;
-              break;
-
-            case 25:
-              enb_properties.properties[enb_properties_index]->srb1_timer_reordering = T_Reordering_ms25;
-              break;
-
-            case 30:
-              enb_properties.properties[enb_properties_index]->srb1_timer_reordering = T_Reordering_ms30;
-              break;
-
-            case 35:
-              enb_properties.properties[enb_properties_index]->srb1_timer_reordering = T_Reordering_ms35;
-              break;
-
-            case 40:
-              enb_properties.properties[enb_properties_index]->srb1_timer_reordering = T_Reordering_ms40;
-              break;
-
-            case 45:
-              enb_properties.properties[enb_properties_index]->srb1_timer_reordering = T_Reordering_ms45;
-              break;
-
-            case 50:
-              enb_properties.properties[enb_properties_index]->srb1_timer_reordering = T_Reordering_ms50;
-              break;
-
-            case 55:
-              enb_properties.properties[enb_properties_index]->srb1_timer_reordering = T_Reordering_ms55;
-              break;
-
-            case 60:
-              enb_properties.properties[enb_properties_index]->srb1_timer_reordering = T_Reordering_ms60;
-              break;
-
-            case 65:
-              enb_properties.properties[enb_properties_index]->srb1_timer_reordering = T_Reordering_ms65;
-              break;
-
-            case 70:
-              enb_properties.properties[enb_properties_index]->srb1_timer_reordering = T_Reordering_ms70;
-              break;
-
-            case 75:
-              enb_properties.properties[enb_properties_index]->srb1_timer_reordering = T_Reordering_ms75;
-              break;
-
-            case 80:
-              enb_properties.properties[enb_properties_index]->srb1_timer_reordering = T_Reordering_ms80;
-              break;
-
-            case 85:
-              enb_properties.properties[enb_properties_index]->srb1_timer_reordering = T_Reordering_ms85;
-              break;
-
-            case 90:
-              enb_properties.properties[enb_properties_index]->srb1_timer_reordering = T_Reordering_ms90;
-              break;
-
-            case 95:
-              enb_properties.properties[enb_properties_index]->srb1_timer_reordering = T_Reordering_ms95;
-              break;
-
-            case 100:
-              enb_properties.properties[enb_properties_index]->srb1_timer_reordering = T_Reordering_ms100;
-              break;
-
-            case 110:
-              enb_properties.properties[enb_properties_index]->srb1_timer_reordering = T_Reordering_ms110;
-              break;
-
-            case 120:
-              enb_properties.properties[enb_properties_index]->srb1_timer_reordering = T_Reordering_ms120;
-              break;
-
-            case 130:
-              enb_properties.properties[enb_properties_index]->srb1_timer_reordering = T_Reordering_ms130;
-              break;
-
-            case 140:
-              enb_properties.properties[enb_properties_index]->srb1_timer_reordering = T_Reordering_ms140;
-              break;
-
-            case 150:
-              enb_properties.properties[enb_properties_index]->srb1_timer_reordering = T_Reordering_ms150;
-              break;
-
-            case 160:
-              enb_properties.properties[enb_properties_index]->srb1_timer_reordering = T_Reordering_ms160;
-              break;
-
-            case 170:
-              enb_properties.properties[enb_properties_index]->srb1_timer_reordering = T_Reordering_ms170;
-              break;
-
-            case 180:
-              enb_properties.properties[enb_properties_index]->srb1_timer_reordering = T_Reordering_ms180;
-              break;
-
-            case 190:
-              enb_properties.properties[enb_properties_index]->srb1_timer_reordering = T_Reordering_ms190;
-              break;
-
-            case 200:
-              enb_properties.properties[enb_properties_index]->srb1_timer_reordering = T_Reordering_ms200;
-              break;
-
-            default:
-              AssertFatal (0,
-                           "Bad config value when parsing eNB configuration file %s, enb %d  srb1_timer_reordering %u!\n",
-                           lib_config_file_name_pP, i, srb1_timer_reordering);
-            }
-          } else {
-            enb_properties.properties[enb_properties_index]->srb1_timer_poll_retransmit = T_PollRetransmit_ms80;
-            enb_properties.properties[enb_properties_index]->srb1_timer_reordering      = T_Reordering_ms35;
-            enb_properties.properties[enb_properties_index]->srb1_timer_status_prohibit = T_StatusProhibit_ms0;
-            enb_properties.properties[enb_properties_index]->srb1_poll_pdu              = PollPDU_p4;
-            enb_properties.properties[enb_properties_index]->srb1_poll_byte             = PollByte_kBinfinity;
-            enb_properties.properties[enb_properties_index]->srb1_max_retx_threshold    = UL_AM_RLC__maxRetxThreshold_t8;
-          }
-
-          setting_mme_addresses = config_setting_get_member (setting_enb, ENB_CONFIG_STRING_MME_IP_ADDRESS);
-          num_mme_address     = config_setting_length(setting_mme_addresses);
-          enb_properties.properties[enb_properties_index]->nb_mme = 0;
-
-          for (j = 0; j < num_mme_address; j++) {
-            setting_mme_address = config_setting_get_elem(setting_mme_addresses, j);
-
-            if (  !(
-                   config_setting_lookup_string(setting_mme_address, ENB_CONFIG_STRING_MME_IPV4_ADDRESS, (const char **)&ipv4)
-                   && config_setting_lookup_string(setting_mme_address, ENB_CONFIG_STRING_MME_IPV6_ADDRESS, (const char **)&ipv6)
-                   && config_setting_lookup_string(setting_mme_address, ENB_CONFIG_STRING_MME_IP_ADDRESS_ACTIVE, (const char **)&active)
-                   && config_setting_lookup_string(setting_mme_address, ENB_CONFIG_STRING_MME_IP_ADDRESS_PREFERENCE, (const char **)&preference)
-                 )
-              ) {
-              AssertFatal (0,
-                           "Failed to parse eNB configuration file %s, %u th enb %u th mme address !\n",
-                           lib_config_file_name_pP, i, j);
-              continue; // FIXME will prevent segfaults below, not sure what happens at function exit...
-            }
-
-            enb_properties.properties[enb_properties_index]->nb_mme += 1;
-
-            enb_properties.properties[enb_properties_index]->mme_ip_address[j].ipv4_address = strdup(ipv4);
-            enb_properties.properties[enb_properties_index]->mme_ip_address[j].ipv6_address = strdup(ipv6);
-
-            if (strcmp(active, "yes") == 0) {
-              enb_properties.properties[enb_properties_index]->mme_ip_address[j].active = 1;
-#if defined(ENABLE_USE_MME)
-              EPC_MODE_ENABLED = 1;
-#endif
-            } // else { (calloc)
-
-            if (strcmp(preference, "ipv4") == 0) {
-              enb_properties.properties[enb_properties_index]->mme_ip_address[j].ipv4 = 1;
-            } else if (strcmp(preference, "ipv6") == 0) {
-              enb_properties.properties[enb_properties_index]->mme_ip_address[j].ipv6 = 1;
-            } else if (strcmp(preference, "no") == 0) {
-              enb_properties.properties[enb_properties_index]->mme_ip_address[j].ipv4 = 1;
-              enb_properties.properties[enb_properties_index]->mme_ip_address[j].ipv6 = 1;
-            }
-          }
-	  // RRH Config 
-	  setting_rrh_gws = config_setting_get_member (setting_enb, ENB_CONFIG_STRING_RRH_GW_CONFIG);
-	  if ( setting_rrh_gws != NULL) {
-          num_rrh_gw     = config_setting_length(setting_rrh_gws);
-          enb_properties.properties[enb_properties_index]->nb_rrh_gw = 0;
-
-          for (j = 0; j < num_rrh_gw; j++) {
-            setting_rrh_gw = config_setting_get_elem(setting_rrh_gws, j);
-
-            if (  !(
-                   config_setting_lookup_string(setting_rrh_gw, ENB_CONFIG_STRING_RRH_GW_LOCAL_IF_NAME, (const char **)&if_name)
-		   && config_setting_lookup_string(setting_rrh_gw, ENB_CONFIG_STRING_RRH_GW_LOCAL_ADDRESS, (const char **)&ipv4)
-                   && config_setting_lookup_string(setting_rrh_gw, ENB_CONFIG_STRING_RRH_GW_REMOTE_ADDRESS , (const char **)&ipv4_remote)
-                   && config_setting_lookup_int(setting_rrh_gw, ENB_CONFIG_STRING_RRH_GW_LOCAL_PORT, &local_port)
-                   && config_setting_lookup_int(setting_rrh_gw, ENB_CONFIG_STRING_RRH_GW_REMOTE_PORT, &remote_port)
-                   && config_setting_lookup_string(setting_rrh_gw, ENB_CONFIG_STRING_RRH_GW_ACTIVE, (const char **)&active)
-		   && config_setting_lookup_string(setting_rrh_gw, ENB_CONFIG_STRING_RRH_GW_TRANSPORT_PREFERENCE, (const char **)&tr_preference)
-		   && config_setting_lookup_string(setting_rrh_gw, ENB_CONFIG_STRING_RRH_GW_RF_TARGET_PREFERENCE, (const char **)&rf_preference)
-		   && config_setting_lookup_int(setting_rrh_gw, ENB_CONFIG_STRING_RRH_GW_IQ_TXSHIFT, &iq_txshift) 
-		   && config_setting_lookup_int(setting_rrh_gw, ENB_CONFIG_STRING_RRH_GW_TX_SAMPLE_ADVANCE, &tx_sample_advance)
-		   && config_setting_lookup_int(setting_rrh_gw, ENB_CONFIG_STRING_RRH_GW_TX_SCHEDULING_ADVANCE, &tx_scheduling_advance)
-                 )
-              ) {
-              AssertFatal (0,
-                           "Failed to parse eNB configuration file %s, %u th enb %u the RRH GW address !\n",
-                           lib_config_file_name_pP, i, j);
-              continue; // FIXME will prevent segfaults below, not sure what happens at function exit...
-            }
-
-            enb_properties.properties[enb_properties_index]->nb_rrh_gw += 1;
-
-            enb_properties.properties[enb_properties_index]->rrh_gw_config[j].rrh_gw_if_name = strdup(if_name);
-            enb_properties.properties[enb_properties_index]->rrh_gw_config[j].local_address  = strdup(ipv4);
-            enb_properties.properties[enb_properties_index]->rrh_gw_config[j].remote_address = strdup(ipv4_remote);
-	    enb_properties.properties[enb_properties_index]->rrh_gw_config[j].local_port = local_port;
-	    enb_properties.properties[enb_properties_index]->rrh_gw_config[j].remote_port = remote_port;
-	    enb_properties.properties[enb_properties_index]->rrh_gw_config[j].iq_txshift = iq_txshift;
-	    enb_properties.properties[enb_properties_index]->rrh_gw_config[j].tx_sample_advance = tx_sample_advance;
-	    enb_properties.properties[enb_properties_index]->rrh_gw_config[j].tx_scheduling_advance= tx_scheduling_advance;
-
-            if (strcmp(active, "yes") == 0) {
-              enb_properties.properties[enb_properties_index]->rrh_gw_config[j].active = 1;
-            } 
-
-            if (strcmp(tr_preference, "udp") == 0) {
-              enb_properties.properties[enb_properties_index]->rrh_gw_config[j].udp = 1;
-            } else if (strcmp(tr_preference, "raw") == 0) {
-              enb_properties.properties[enb_properties_index]->rrh_gw_config[j].raw = 1;
-            } else if (strcmp(tr_preference, "udp_if4p5") == 0) {
-              enb_properties.properties[enb_properties_index]->rrh_gw_config[j].udpif4p5 = 1; 
-            } else if (strcmp(tr_preference, "raw_if4p5") == 0) {
-              enb_properties.properties[enb_properties_index]->rrh_gw_config[j].rawif4p5 = 1;
-            } else if (strcmp(tr_preference, "raw_if5_mobipass") == 0) {
-              enb_properties.properties[enb_properties_index]->rrh_gw_config[j].rawif5_mobipass = 1;
-            } else {//if (strcmp(preference, "no") == 0) 
-              enb_properties.properties[enb_properties_index]->rrh_gw_config[j].udp = 1;
-	      enb_properties.properties[enb_properties_index]->rrh_gw_config[j].raw = 1;
-            }
-
-	    if (strcmp(rf_preference, "exmimo") == 0) {
-              enb_properties.properties[enb_properties_index]->rrh_gw_config[j].exmimo = 1;
-            } else if (strcmp(rf_preference, "usrp_b200") == 0) {
-              enb_properties.properties[enb_properties_index]->rrh_gw_config[j].usrp_b200 = 1;
-	    } else if (strcmp(rf_preference, "usrp_x300") == 0) {
-              enb_properties.properties[enb_properties_index]->rrh_gw_config[j].usrp_x300 = 1;
-            } else if (strcmp(rf_preference, "bladerf") == 0) {
-              enb_properties.properties[enb_properties_index]->rrh_gw_config[j].bladerf = 1;
-	    } else if (strcmp(rf_preference, "lmsdr") == 0) {
-              enb_properties.properties[enb_properties_index]->rrh_gw_config[j].lmssdr = 1;	      
-            } else {//if (strcmp(preference, "no") == 0) 
-	      
-	      enb_properties.properties[enb_properties_index]->rrh_gw_config[j].exmimo = 1;
-              enb_properties.properties[enb_properties_index]->rrh_gw_config[j].usrp_b200 = 1;
-              enb_properties.properties[enb_properties_index]->rrh_gw_config[j].usrp_x300 = 1;
-              enb_properties.properties[enb_properties_index]->rrh_gw_config[j].bladerf = 1;    
-              enb_properties.properties[enb_properties_index]->rrh_gw_config[j].lmssdr = 1;    
-
-            }
-          }
-	  } else {
-	    enb_properties.properties[enb_properties_index]->nb_rrh_gw = 0;	    
-            enb_properties.properties[enb_properties_index]->rrh_gw_config[j].rrh_gw_if_name = "none";
-            enb_properties.properties[enb_properties_index]->rrh_gw_config[j].local_address  = "0.0.0.0";
-            enb_properties.properties[enb_properties_index]->rrh_gw_config[j].remote_address = "0.0.0.0";
-	    enb_properties.properties[enb_properties_index]->rrh_gw_config[j].local_port= 0;
-	    enb_properties.properties[enb_properties_index]->rrh_gw_config[j].remote_port= 0;	    
-	    enb_properties.properties[enb_properties_index]->rrh_gw_config[j].active = 0;	    
-	    enb_properties.properties[enb_properties_index]->rrh_gw_config[j].udp = 0;
-	    enb_properties.properties[enb_properties_index]->rrh_gw_config[j].raw = 0;
-	    enb_properties.properties[enb_properties_index]->rrh_gw_config[j].tx_scheduling_advance = 0;
-	    enb_properties.properties[enb_properties_index]->rrh_gw_config[j].tx_sample_advance = 0;
-	    enb_properties.properties[enb_properties_index]->rrh_gw_config[j].iq_txshift = 0;
-	    enb_properties.properties[enb_properties_index]->rrh_gw_config[j].exmimo = 0;
-	    enb_properties.properties[enb_properties_index]->rrh_gw_config[j].usrp_b200 = 0;
-	    enb_properties.properties[enb_properties_index]->rrh_gw_config[j].usrp_x300 = 0;
-	    enb_properties.properties[enb_properties_index]->rrh_gw_config[j].bladerf = 0;
-	    enb_properties.properties[enb_properties_index]->rrh_gw_config[j].lmssdr = 0;
+	    } else {
+	      rrc->srb1_timer_poll_retransmit = T_PollRetransmit_ms80;
+	      rrc->srb1_timer_reordering      = T_Reordering_ms35;
+	      rrc->srb1_timer_status_prohibit = T_StatusProhibit_ms0;
+	      rrc->srb1_poll_pdu              = PollPDU_p4;
+	      rrc->srb1_poll_byte             = PollByte_kBinfinity;
+	      rrc->srb1_max_retx_threshold    = UL_AM_RLC__maxRetxThreshold_t8;
+	    }
+	    /*
+	    // Network Controller 
+	    subsetting = config_setting_get_member (setting_enb, ENB_CONFIG_STRING_NETWORK_CONTROLLER_CONFIG);
+
+	    if (subsetting != NULL) {
+	      if (  (
+		     config_setting_lookup_string( subsetting, ENB_CONFIG_STRING_FLEXRAN_AGENT_INTERFACE_NAME,
+						   (const char **)&flexran_agent_interface_name)
+		     && config_setting_lookup_string( subsetting, ENB_CONFIG_STRING_FLEXRAN_AGENT_IPV4_ADDRESS,
+						      (const char **)&flexran_agent_ipv4_address)
+		     && config_setting_lookup_int(subsetting, ENB_CONFIG_STRING_FLEXRAN_AGENT_PORT,
+						  &flexran_agent_port)
+		     && config_setting_lookup_string( subsetting, ENB_CONFIG_STRING_FLEXRAN_AGENT_CACHE,
+						      (const char **)&flexran_agent_cache)
+		     )
+		    ) {
+		enb_properties_loc.properties[enb_properties_loc_index]->flexran_agent_interface_name = strdup(flexran_agent_interface_name);
+		cidr = flexran_agent_ipv4_address;
+		address = strtok(cidr, "/");
+		//enb_properties_loc.properties[enb_properties_loc_index]->flexran_agent_ipv4_address = strdup(address);
+		if (address) {
+		  IPV4_STR_ADDR_TO_INT_NWBO (address, enb_properties_loc.properties[enb_properties_loc_index]->flexran_agent_ipv4_address, "BAD IP ADDRESS FORMAT FOR eNB Agent !\n" );
+		}
+
+		enb_properties_loc.properties[enb_properties_loc_index]->flexran_agent_port = flexran_agent_port;
+		enb_properties_loc.properties[enb_properties_loc_index]->flexran_agent_cache = strdup(flexran_agent_cache);
+	      }
+	    }
+	    */	  
+
+	    /*
+	    // OTG _CONFIG
+	    setting_otg = config_setting_get_member (setting_enb, ENB_CONF_STRING_OTG_CONFIG);
+
+	    if (setting_otg != NULL) {
+	      num_otg_elements  = config_setting_length(setting_otg);
+	      printf("num otg elements %d \n", num_otg_elements);
+	      enb_properties_loc.properties[enb_properties_loc_index]->num_otg_elements = 0;
+
+	      for (j = 0; j < num_otg_elements; j++) {
+		subsetting_otg=config_setting_get_elem(setting_otg, j);
+
+		if (config_setting_lookup_int(subsetting_otg, ENB_CONF_STRING_OTG_UE_ID, &otg_ue_id)) {
+		  enb_properties_loc.properties[enb_properties_loc_index]->otg_ue_id[j] = otg_ue_id;
+		} else {
+		  enb_properties_loc.properties[enb_properties_loc_index]->otg_ue_id[j] = 1;
+		}
+
+		if (config_setting_lookup_string(subsetting_otg, ENB_CONF_STRING_OTG_APP_TYPE, (const char **)&otg_app_type)) {
+		  if ((enb_properties_loc.properties[enb_properties_loc_index]->otg_app_type[j] = map_str_to_int(otg_app_type_names,otg_app_type))== -1) {
+		    enb_properties_loc.properties[enb_properties_loc_index]->otg_app_type[j] = BCBR;
+		  }
+		} else {
+		  enb_properties_loc.properties[enb_properties_loc_index]->otg_app_type[j] = NO_PREDEFINED_TRAFFIC; // 0
+		}
+
+		if (config_setting_lookup_string(subsetting_otg, ENB_CONF_STRING_OTG_BG_TRAFFIC, (const char **)&otg_bg_traffic)) {
+
+		  if ((enb_properties_loc.properties[enb_properties_loc_index]->otg_bg_traffic[j] = map_str_to_int(switch_names,otg_bg_traffic)) == -1) {
+		    enb_properties_loc.properties[enb_properties_loc_index]->otg_bg_traffic[j]=0;
+		  }
+		} else {
+		  enb_properties_loc.properties[enb_properties_loc_index]->otg_bg_traffic[j] = 0;
+		  printf("otg bg %s\n", otg_bg_traffic);
+		}
+
+		enb_properties_loc.properties[enb_properties_loc_index]->num_otg_elements+=1;
+
+	      }
+	    }
+
+	    // log_config
+	    subsetting = config_setting_get_member (setting_enb, ENB_CONFIG_STRING_LOG_CONFIG);
+
+	    if (subsetting != NULL) {
+	      // global
+	      if (config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_GLOBAL_LOG_LEVEL, (const char **)  &glog_level)) {
+		if ((enb_properties_loc.properties[enb_properties_loc_index]->glog_level = map_str_to_int(log_level_names, glog_level)) == -1) {
+		  enb_properties_loc.properties[enb_properties_loc_index]->glog_level = LOG_INFO;
+		}
+
+		//printf( "\tGlobal log level :\t%s->%d\n",glog_level, enb_properties_loc.properties[enb_properties_loc_index]->glog_level);
+	      } else {
+		enb_properties_loc.properties[enb_properties_loc_index]->glog_level = LOG_INFO;
+	      }
+
+	      if (config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_GLOBAL_LOG_VERBOSITY,(const char **)  &glog_verbosity)) {
+		if ((enb_properties_loc.properties[enb_properties_loc_index]->glog_verbosity = map_str_to_int(log_verbosity_names, glog_verbosity)) == -1) {
+		  enb_properties_loc.properties[enb_properties_loc_index]->glog_verbosity = LOG_MED;
+		}
+
+		//printf( "\tGlobal log verbosity:\t%s->%d\n",glog_verbosity, enb_properties_loc.properties[enb_properties_loc_index]->glog_verbosity);
+	      } else {
+		enb_properties_loc.properties[enb_properties_loc_index]->glog_verbosity = LOG_MED;
+	      }
+
+	      // HW
+	      if (config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_HW_LOG_LEVEL, (const char **) &hw_log_level)) {
+		if ((enb_properties_loc.properties[enb_properties_loc_index]->hw_log_level = map_str_to_int(log_level_names,hw_log_level)) == -1) {
+		  enb_properties_loc.properties[enb_properties_loc_index]->hw_log_level = LOG_INFO;
+		}
+
+		//printf( "\tHW log level :\t%s->%d\n",hw_log_level,enb_properties_loc.properties[enb_properties_loc_index]->hw_log_level);
+	      } else {
+		enb_properties_loc.properties[enb_properties_loc_index]->hw_log_level = LOG_INFO;
+	      }
+
+	      if (config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_HW_LOG_VERBOSITY, (const char **) &hw_log_verbosity)) {
+		if ((enb_properties_loc.properties[enb_properties_loc_index]->hw_log_verbosity = map_str_to_int(log_verbosity_names,hw_log_verbosity)) == -1) {
+		  enb_properties_loc.properties[enb_properties_loc_index]->hw_log_verbosity = LOG_MED;
+		}
+
+		//printf( "\tHW log verbosity:\t%s->%d\n",hw_log_verbosity, enb_properties_loc.properties[enb_properties_loc_index]->hw_log_verbosity);
+	      } else {
+		enb_properties_loc.properties[enb_properties_loc_index]->hw_log_verbosity = LOG_MED;
+	      }
+
+	      // phy
+	      if (config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_PHY_LOG_LEVEL,(const char **) &phy_log_level)) {
+		if ((enb_properties_loc.properties[enb_properties_loc_index]->phy_log_level = map_str_to_int(log_level_names,phy_log_level)) == -1) {
+		  enb_properties_loc.properties[enb_properties_loc_index]->phy_log_level = LOG_INFO;
+		}
+
+		//printf( "\tPHY log level :\t%s->%d\n",phy_log_level,enb_properties_loc.properties[enb_properties_loc_index]->phy_log_level);
+	      } else {
+		enb_properties_loc.properties[enb_properties_loc_index]->phy_log_level = LOG_INFO;
+	      }
+
+	      if (config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_PHY_LOG_VERBOSITY, (const char **)&phy_log_verbosity)) {
+		if ((enb_properties_loc.properties[enb_properties_loc_index]->phy_log_verbosity = map_str_to_int(log_verbosity_names,phy_log_verbosity)) == -1) {
+		  enb_properties_loc.properties[enb_properties_loc_index]->phy_log_verbosity = LOG_MED;
+		}
+
+		//printf( "\tPHY log verbosity:\t%s->%d\n",phy_log_level,enb_properties_loc.properties[enb_properties_loc_index]->phy_log_verbosity);
+	      } else {
+		enb_properties_loc.properties[enb_properties_loc_index]->phy_log_verbosity = LOG_MED;
+	      }
+
+	      //mac
+	      if (config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_MAC_LOG_LEVEL, (const char **)&mac_log_level)) {
+		if ((enb_properties_loc.properties[enb_properties_loc_index]->mac_log_level = map_str_to_int(log_level_names,mac_log_level)) == -1 ) {
+		  enb_properties_loc.properties[enb_properties_loc_index]->mac_log_level = LOG_INFO;
+		}
+
+		//printf( "\tMAC log level :\t%s->%d\n",mac_log_level,enb_properties_loc.properties[enb_properties_loc_index]->mac_log_level);
+	      } else {
+		enb_properties_loc.properties[enb_properties_loc_index]->mac_log_level = LOG_INFO;
+	      }
+
+	      if (config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_MAC_LOG_VERBOSITY, (const char **)&mac_log_verbosity)) {
+		if ((enb_properties_loc.properties[enb_properties_loc_index]->mac_log_verbosity = map_str_to_int(log_verbosity_names,mac_log_verbosity)) == -1) {
+		  enb_properties_loc.properties[enb_properties_loc_index]->mac_log_verbosity = LOG_MED;
+		}
+
+		//printf( "\tMAC log verbosity:\t%s->%d\n",mac_log_verbosity,enb_properties_loc.properties[enb_properties_loc_index]->mac_log_verbosity);
+	      } else {
+		enb_properties_loc.properties[enb_properties_loc_index]->mac_log_verbosity = LOG_MED;
+	      }
+
+	      //rlc
+	      if (config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_RLC_LOG_LEVEL, (const char **)&rlc_log_level)) {
+		if ((enb_properties_loc.properties[enb_properties_loc_index]->rlc_log_level = map_str_to_int(log_level_names,rlc_log_level)) == -1) {
+		  enb_properties_loc.properties[enb_properties_loc_index]->rlc_log_level = LOG_INFO;
+		}
+
+		//printf( "\tRLC log level :\t%s->%d\n",rlc_log_level, enb_properties_loc.properties[enb_properties_loc_index]->rlc_log_level);
+	      } else {
+		enb_properties_loc.properties[enb_properties_loc_index]->rlc_log_level = LOG_INFO;
+	      }
+
+	      if (config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_RLC_LOG_VERBOSITY, (const char **)&rlc_log_verbosity)) {
+		if ((enb_properties_loc.properties[enb_properties_loc_index]->rlc_log_verbosity = map_str_to_int(log_verbosity_names,rlc_log_verbosity)) == -1) {
+		  enb_properties_loc.properties[enb_properties_loc_index]->rlc_log_verbosity = LOG_MED;
+		}
+
+		//printf( "\tRLC log verbosity:\t%s->%d\n",rlc_log_verbosity, enb_properties_loc.properties[enb_properties_loc_index]->rlc_log_verbosity);
+	      } else {
+		enb_properties_loc.properties[enb_properties_loc_index]->rlc_log_verbosity = LOG_MED;
+	      }
+
+	      //pdcp
+	      if (config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_PDCP_LOG_LEVEL, (const char **)&pdcp_log_level)) {
+		if ((enb_properties_loc.properties[enb_properties_loc_index]->pdcp_log_level = map_str_to_int(log_level_names,pdcp_log_level)) == -1) {
+		  enb_properties_loc.properties[enb_properties_loc_index]->pdcp_log_level = LOG_INFO;
+		}
+
+		//printf( "\tPDCP log level :\t%s->%d\n",pdcp_log_level, enb_properties_loc.properties[enb_properties_loc_index]->pdcp_log_level);
+	      } else {
+		enb_properties_loc.properties[enb_properties_loc_index]->pdcp_log_level = LOG_INFO;
+	      }
+
+	      if (config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_PDCP_LOG_VERBOSITY, (const char **)&pdcp_log_verbosity)) {
+		enb_properties_loc.properties[enb_properties_loc_index]->pdcp_log_verbosity = map_str_to_int(log_verbosity_names,pdcp_log_verbosity);
+		//printf( "\tPDCP log verbosity:\t%s->%d\n",pdcp_log_verbosity, enb_properties_loc.properties[enb_properties_loc_index]->pdcp_log_verbosity);
+	      } else {
+		enb_properties_loc.properties[enb_properties_loc_index]->pdcp_log_verbosity = LOG_MED;
+	      }
+
+	      //rrc
+	      if (config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_RRC_LOG_LEVEL, (const char **)&rrc_log_level)) {
+		if ((enb_properties_loc.properties[enb_properties_loc_index]->rrc_log_level = map_str_to_int(log_level_names,rrc_log_level)) == -1 ) {
+		  enb_properties_loc.properties[enb_properties_loc_index]->rrc_log_level = LOG_INFO;
+		}
+
+		//printf( "\tRRC log level :\t%s->%d\n",rrc_log_level,enb_properties_loc.properties[enb_properties_loc_index]->rrc_log_level);
+	      } else {
+		enb_properties_loc.properties[enb_properties_loc_index]->rrc_log_level = LOG_INFO;
+	      }
+
+	      if (config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_RRC_LOG_VERBOSITY, (const char **)&rrc_log_verbosity)) {
+		if ((enb_properties_loc.properties[enb_properties_loc_index]->rrc_log_verbosity = map_str_to_int(log_verbosity_names,rrc_log_verbosity)) == -1) {
+		  enb_properties_loc.properties[enb_properties_loc_index]->rrc_log_verbosity = LOG_MED;
+		}
+
+		//printf( "\tRRC log verbosity:\t%s->%d\n",rrc_log_verbosity,enb_properties_loc.properties[enb_properties_loc_index]->rrc_log_verbosity);
+	      } else {
+		enb_properties_loc.properties[enb_properties_loc_index]->rrc_log_verbosity = LOG_MED;
+	      }
+
+	      if (config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_GTPU_LOG_LEVEL, (const char **)&gtpu_log_level)) {
+		if ((enb_properties_loc.properties[enb_properties_loc_index]->gtpu_log_level = map_str_to_int(log_level_names,gtpu_log_level)) == -1 ) {
+		  enb_properties_loc.properties[enb_properties_loc_index]->gtpu_log_level = LOG_INFO;
+		}
+
+		//printf( "\tGTPU log level :\t%s->%d\n",gtpu_log_level,enb_properties_loc.properties[enb_properties_loc_index]->gtpu_log_level);
+	      } else {
+		enb_properties_loc.properties[enb_properties_loc_index]->gtpu_log_level = LOG_INFO;
+	      }
+
+	      if (config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_GTPU_LOG_VERBOSITY, (const char **)&gtpu_log_verbosity)) {
+		if ((enb_properties_loc.properties[enb_properties_loc_index]->gtpu_log_verbosity = map_str_to_int(log_verbosity_names,gtpu_log_verbosity)) == -1) {
+		  enb_properties_loc.properties[enb_properties_loc_index]->gtpu_log_verbosity = LOG_MED;
+		}
+
+		//printf( "\tGTPU log verbosity:\t%s->%d\n",gtpu_log_verbosity,enb_properties_loc.properties[enb_properties_loc_index]->gtpu_log_verbosity);
+	      } else {
+		enb_properties_loc.properties[enb_properties_loc_index]->gtpu_log_verbosity = LOG_MED;
+	      }
+
+	      if (config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_UDP_LOG_LEVEL, (const char **)&udp_log_level)) {
+		if ((enb_properties_loc.properties[enb_properties_loc_index]->udp_log_level = map_str_to_int(log_level_names,udp_log_level)) == -1 ) {
+		  enb_properties_loc.properties[enb_properties_loc_index]->udp_log_level = LOG_INFO;
+		}
+
+		//printf( "\tUDP log level :\t%s->%d\n",udp_log_level,enb_properties_loc.properties[enb_properties_loc_index]->udp_log_level);
+	      } else {
+		enb_properties_loc.properties[enb_properties_loc_index]->udp_log_level = LOG_INFO;
+	      }
+
+	      if (config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_UDP_LOG_VERBOSITY, (const char **)&udp_log_verbosity)) {
+		if ((enb_properties_loc.properties[enb_properties_loc_index]->udp_log_verbosity = map_str_to_int(log_verbosity_names,udp_log_verbosity)) == -1) {
+		  enb_properties_loc.properties[enb_properties_loc_index]->udp_log_verbosity = LOG_MED;
+		}
+
+		//printf( "\tUDP log verbosity:\t%s->%d\n",udp_log_verbosity,enb_properties_loc.properties[enb_properties_loc_index]->gtpu_log_verbosity);
+	      } else {
+		enb_properties_loc.properties[enb_properties_loc_index]->udp_log_verbosity = LOG_MED;
+	      }
+
+	      if (config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_OSA_LOG_LEVEL, (const char **)&osa_log_level)) {
+		if ((enb_properties_loc.properties[enb_properties_loc_index]->osa_log_level = map_str_to_int(log_level_names,osa_log_level)) == -1 ) {
+		  enb_properties_loc.properties[enb_properties_loc_index]->osa_log_level = LOG_INFO;
+		}
+
+		//printf( "\tOSA log level :\t%s->%d\n",osa_log_level,enb_properties_loc.properties[enb_properties_loc_index]->osa_log_level);
+	      } else {
+		enb_properties_loc.properties[enb_properties_loc_index]->osa_log_level = LOG_INFO;
+	      }
+
+	      if (config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_OSA_LOG_VERBOSITY, (const char **)&osa_log_verbosity)) {
+		if ((enb_properties_loc.properties[enb_properties_loc_index]->osa_log_verbosity = map_str_to_int(log_verbosity_names,osa_log_verbosity)) == -1) {
+		  enb_properties_loc.properties[enb_properties_loc_index]->osa_log_verbosity = LOG_MED;
+		}
+
+		//printf( "\tOSA log verbosity:\t%s->%d\n",osa_log_verbosity,enb_properties_loc.properties[enb_properties_loc_index]->gosa_log_verbosity);
+	      } else {
+		enb_properties_loc.properties[enb_properties_loc_index]->osa_log_verbosity = LOG_MED;
+	      }
+
+	    } else { // not configuration is given
+	      enb_properties_loc.properties[enb_properties_loc_index]->glog_level         = LOG_INFO;
+	      enb_properties_loc.properties[enb_properties_loc_index]->glog_verbosity     = LOG_MED;
+	      enb_properties_loc.properties[enb_properties_loc_index]->hw_log_level       = LOG_INFO;
+	      enb_properties_loc.properties[enb_properties_loc_index]->hw_log_verbosity   = LOG_MED;
+	      enb_properties_loc.properties[enb_properties_loc_index]->phy_log_level      = LOG_INFO;
+	      enb_properties_loc.properties[enb_properties_loc_index]->phy_log_verbosity  = LOG_MED;
+	      enb_properties_loc.properties[enb_properties_loc_index]->mac_log_level      = LOG_INFO;
+	      enb_properties_loc.properties[enb_properties_loc_index]->mac_log_verbosity  = LOG_MED;
+	      enb_properties_loc.properties[enb_properties_loc_index]->rlc_log_level      = LOG_INFO;
+	      enb_properties_loc.properties[enb_properties_loc_index]->rlc_log_verbosity  = LOG_MED;
+	      enb_properties_loc.properties[enb_properties_loc_index]->pdcp_log_level     = LOG_INFO;
+	      enb_properties_loc.properties[enb_properties_loc_index]->pdcp_log_verbosity = LOG_MED;
+	      enb_properties_loc.properties[enb_properties_loc_index]->rrc_log_level      = LOG_INFO;
+	      enb_properties_loc.properties[enb_properties_loc_index]->rrc_log_verbosity  = LOG_MED;
+	      enb_properties_loc.properties[enb_properties_loc_index]->gtpu_log_level     = LOG_INFO;
+	      enb_properties_loc.properties[enb_properties_loc_index]->gtpu_log_verbosity = LOG_MED;
+	      enb_properties_loc.properties[enb_properties_loc_index]->udp_log_level      = LOG_INFO;
+	      enb_properties_loc.properties[enb_properties_loc_index]->udp_log_verbosity  = LOG_MED;
+	      enb_properties_loc.properties[enb_properties_loc_index]->osa_log_level      = LOG_INFO;
+	      enb_properties_loc.properties[enb_properties_loc_index]->osa_log_verbosity  = LOG_MED;
+	    }
+	    */
+	    break;
+	}
+      }
+    }
+  }
+}
+
+int RCconfig_gtpu() {
+  config_t          cfg;
+  config_setting_t *setting                       = NULL;
+  config_setting_t *subsetting                    = NULL;
+  config_setting_t *setting_enb                   = NULL;
+  int               num_enbs                      = 0;
+  libconfig_int     enb_id                        = 0;
+
+
+
+  char*             enb_interface_name_for_S1U    = NULL;
+  char*             enb_ipv4_address_for_S1U      = NULL;
+  libconfig_int     enb_port_for_S1U              = 0;
+  char             *address                       = NULL;
+  char             *cidr                          = NULL;
+  char             *astring                       = NULL;
+
+  // for no gcc warnings 
+  (void)astring;
+
+
+  LOG_I(GTPU,"Configuring GTPu\n");
+
+  config_init(&cfg);
+
+  if (RC.config_file_name != NULL) {
+    // Read the file. If there is an error, report it and exit. 
+    if (! config_read_file(&cfg, RC.config_file_name)) {
+      config_destroy(&cfg);
+      AssertFatal (0, "Failed to parse eNB configuration file %s!\n", RC.config_file_name);
+    }
+  } else {
+    config_destroy(&cfg);
+    AssertFatal (0, "No eNB configuration file provided!\n");
+  }
+
+  // Get list of active eNBs, (only these will be configured)
+  setting = config_lookup(&cfg, ENB_CONFIG_STRING_ACTIVE_ENBS);
+
+  if (setting != NULL) {
+    num_enbs = config_setting_length(setting);
+    setting_enb   = config_setting_get_elem(setting, 0);
+  }
+  
+  if (num_enbs>0) {
+    // Output a list of all eNBs.
+    setting = config_lookup(&cfg, ENB_CONFIG_STRING_ENB_LIST);
+    
+    if (setting != NULL) {
+
+
+      setting_enb = config_setting_get_elem(setting, 0);
+      subsetting = config_setting_get_member (setting_enb, ENB_CONFIG_STRING_NETWORK_INTERFACES_CONFIG);
+
+      if (subsetting != NULL) {
+	if (  (config_setting_lookup_string( subsetting, ENB_CONFIG_STRING_ENB_INTERFACE_NAME_FOR_S1U,
+					     (const char **)&enb_interface_name_for_S1U)
+	       && config_setting_lookup_string( subsetting, ENB_CONFIG_STRING_ENB_IPV4_ADDR_FOR_S1U,
+						(const char **)&enb_ipv4_address_for_S1U)
+	       && config_setting_lookup_int(subsetting, ENB_CONFIG_STRING_ENB_PORT_FOR_S1U,
+					    &enb_port_for_S1U)
+	       )
+	      ) {
+
+	  cidr = enb_ipv4_address_for_S1U;
+	  address = strtok(cidr, "/");
+	  
+	  if (address) {
+	    IPV4_STR_ADDR_TO_INT_NWBO ( address, RC.gtpv1u_data_g->enb_ip_address_for_S1u_S12_S4_up, "BAD IP ADDRESS FORMAT FOR eNB S1_U !\n" );
+
+	    LOG_I(GTPU,"Configuring GTPu address : %s -> %x\n",address,RC.gtpv1u_data_g->enb_ip_address_for_S1u_S12_S4_up);
+
 	  }
 
-          // SCTP SETTING
-          enb_properties.properties[enb_properties_index]->sctp_out_streams = SCTP_OUT_STREAMS;
-          enb_properties.properties[enb_properties_index]->sctp_in_streams  = SCTP_IN_STREAMS;
+	  RC.gtpv1u_data_g->enb_port_for_S1u_S12_S4_up = enb_port_for_S1U;
+
+	}
+      }
+    }
+  }
+}
+
+
+int RCconfig_S1(MessageDef *msg_p, uint32_t i) {
+  config_t          cfg;
+  config_setting_t *setting                       = NULL;
+  config_setting_t *subsetting                    = NULL;
+  config_setting_t *setting_mme_addresses         = NULL;
+  config_setting_t *setting_mme_address           = NULL;
+  config_setting_t *setting_enb                   = NULL;
+  config_setting_t *setting_otg                   = NULL;
+  config_setting_t *subsetting_otg                = NULL;
+  int               parse_errors                  = 0;
+  int               num_enbs                      = 0;
+  int               num_mme_address               = 0;
+  int               num_otg_elements              = 0;
+  int               num_component_carriers        = 0;
+  int               j                             = 0;
+  libconfig_int     enb_id                        = 0;
+
+
+  const char*       cell_type                     = NULL;
+  const char*       tac                           = 0;
+  const char*       enb_name                      = NULL;
+  const char*       mcc                           = 0;
+  const char*       mnc                           = 0;
+
+  libconfig_int     my_int;
+
+
+  char*             if_name                       = NULL;
+  char*             ipv4                          = NULL;
+  char*             ipv4_remote                   = NULL;
+  char*             ipv6                          = NULL;
+  char*             local_rf                      = NULL;
+  char*             preference                    = NULL;
+  char*             active                        = NULL;
+
+  char*             tr_preference                 = NULL;
+  libconfig_int     local_port                    = 0;
+  libconfig_int     remote_port                   = 0;
+  const char*       active_enb[MAX_ENB];
+  char*             enb_interface_name_for_S1U    = NULL;
+  char*             enb_ipv4_address_for_S1U      = NULL;
+  libconfig_int     enb_port_for_S1U              = 0;
+  char*             enb_interface_name_for_S1_MME = NULL;
+  char*             enb_ipv4_address_for_S1_MME   = NULL;
+  char             *address                       = NULL;
+  char             *cidr                          = NULL;
+  char             *astring                       = NULL;
+
+  // for no gcc warnings 
+  (void)astring;
+  (void)my_int;
+
+  memset((char*)active_enb,     0 , MAX_ENB * sizeof(char*));
+
+  config_init(&cfg);
+
+  if (RC.config_file_name != NULL) {
+    // Read the file. If there is an error, report it and exit. 
+    if (! config_read_file(&cfg, RC.config_file_name)) {
+      config_destroy(&cfg);
+      AssertFatal (0, "Failed to parse eNB configuration file %s!\n", RC.config_file_name);
+    }
+  } else {
+    config_destroy(&cfg);
+    AssertFatal (0, "No eNB configuration file provided!\n");
+  }
+
+#if defined(ENABLE_ITTI) && defined(ENABLE_USE_MME)
+
+  if (  (config_lookup_string( &cfg, ENB_CONFIG_STRING_ASN1_VERBOSITY, (const char **)&astring) )) {
+    if (strcasecmp(astring , ENB_CONFIG_STRING_ASN1_VERBOSITY_NONE) == 0) {
+      asn_debug      = 0;
+      asn1_xer_print = 0;
+    } else if (strcasecmp(astring , ENB_CONFIG_STRING_ASN1_VERBOSITY_INFO) == 0) {
+      asn_debug      = 1;
+      asn1_xer_print = 1;
+    } else if (strcasecmp(astring , ENB_CONFIG_STRING_ASN1_VERBOSITY_ANNOYING) == 0) {
+      asn_debug      = 1;
+      asn1_xer_print = 2;
+    } else {
+      asn_debug      = 0;
+      asn1_xer_print = 0;
+    }
+  }
+
+#endif
+
+  // Get list of active eNBs, (only these will be configured)
+  setting = config_lookup(&cfg, ENB_CONFIG_STRING_ACTIVE_ENBS);
+
+  if (setting != NULL) {
+    num_enbs = config_setting_length(setting);
+    setting_enb   = config_setting_get_elem(setting, i);
+    active_enb[i] = config_setting_get_string (setting_enb);
+    AssertFatal (active_enb[i] != NULL,
+		 "Failed to parse config file %s, %uth attribute %s \n",
+		 RC.config_file_name, i, ENB_CONFIG_STRING_ACTIVE_ENBS);
+    active_enb[i] = strdup(active_enb[i]);
+  }
+  
+  
+  if (num_enbs>0) {
+    // Output a list of all eNBs.
+    setting = config_lookup(&cfg, ENB_CONFIG_STRING_ENB_LIST);
+    
+    if (setting != NULL) {
+      num_enbs = config_setting_length(setting);
+      
+      for (i = 0; i < num_enbs; i++) {
+	setting_enb = config_setting_get_elem(setting, i);
+	
+	if (! config_setting_lookup_int(setting_enb, ENB_CONFIG_STRING_ENB_ID, &enb_id)) {
+	  // Calculate a default eNB ID
 # if defined(ENABLE_USE_MME)
-          subsetting = config_setting_get_member (setting_enb, ENB_CONFIG_STRING_SCTP_CONFIG);
+	  uint32_t hash;
+	  
+	  hash = s1ap_generate_eNB_id ();
+	  enb_id = i + (hash & 0xFFFF8);
+# else
+	  enb_id = i;
+# endif
+	}
+	
+	if (  !(       config_setting_lookup_string(setting_enb, ENB_CONFIG_STRING_CELL_TYPE,           &cell_type)
+		       && config_setting_lookup_string(setting_enb, ENB_CONFIG_STRING_ENB_NAME,            &enb_name)
+		       && config_setting_lookup_string(setting_enb, ENB_CONFIG_STRING_TRACKING_AREA_CODE,  &tac)
+		       && config_setting_lookup_string(setting_enb, ENB_CONFIG_STRING_MOBILE_COUNTRY_CODE, &mcc)
+		       && config_setting_lookup_string(setting_enb, ENB_CONFIG_STRING_MOBILE_NETWORK_CODE, &mnc)
+		       
+		       
+		       )
+	      ) {
+	  AssertFatal (0,
+		       "Failed to parse eNB configuration file %s, %u th enb\n",
+		       RC.config_file_name, i);
+	  continue; // FIXME this prevents segfaults below, not sure what happens after function exit
+	}
+	
+	// search if in active list
+	for (j=0; j < num_enbs; j++) {
+	  if (strcmp(active_enb[j], enb_name) == 0) {
+	    
+	    S1AP_REGISTER_ENB_REQ (msg_p).eNB_id = enb_id;
+	    
+	    if (strcmp(cell_type, "CELL_MACRO_ENB") == 0) {
+	      S1AP_REGISTER_ENB_REQ (msg_p).cell_type = CELL_MACRO_ENB;
+	    } else  if (strcmp(cell_type, "CELL_HOME_ENB") == 0) {
+	      S1AP_REGISTER_ENB_REQ (msg_p).cell_type = CELL_HOME_ENB;
+	    } else {
+	      AssertFatal (0,
+			   "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for cell_type choice: CELL_MACRO_ENB or CELL_HOME_ENB !\n",
+			   RC.config_file_name, i, cell_type);
+	    }
+	    
+	    S1AP_REGISTER_ENB_REQ (msg_p).eNB_name         = strdup(enb_name);
+	    S1AP_REGISTER_ENB_REQ (msg_p).tac              = (uint16_t)atoi(tac);
+	    S1AP_REGISTER_ENB_REQ (msg_p).mcc              = (uint16_t)atoi(mcc);
+	    S1AP_REGISTER_ENB_REQ (msg_p).mnc              = (uint16_t)atoi(mnc);
+	    S1AP_REGISTER_ENB_REQ (msg_p).mnc_digit_length = strlen(mnc);
+	    S1AP_REGISTER_ENB_REQ (msg_p).default_drx      = 0;
+	    AssertFatal((S1AP_REGISTER_ENB_REQ (msg_p).mnc_digit_length == 2) ||
+			(S1AP_REGISTER_ENB_REQ (msg_p).mnc_digit_length == 3),
+			"BAD MNC DIGIT LENGTH %d",
+			S1AP_REGISTER_ENB_REQ (msg_p).mnc_digit_length);
+	    
+	    
+
+	    setting_mme_addresses = config_setting_get_member (setting_enb, ENB_CONFIG_STRING_MME_IP_ADDRESS);
+	    num_mme_address     = config_setting_length(setting_mme_addresses);
+	    S1AP_REGISTER_ENB_REQ (msg_p).nb_mme = 0;
+
+	    for (j = 0; j < num_mme_address; j++) {
+	      setting_mme_address = config_setting_get_elem(setting_mme_addresses, j);
+
+	      if (  !(
+		      config_setting_lookup_string(setting_mme_address, ENB_CONFIG_STRING_MME_IPV4_ADDRESS, (const char **)&ipv4)
+		      && config_setting_lookup_string(setting_mme_address, ENB_CONFIG_STRING_MME_IPV6_ADDRESS, (const char **)&ipv6)
+		      && config_setting_lookup_string(setting_mme_address, ENB_CONFIG_STRING_MME_IP_ADDRESS_ACTIVE, (const char **)&active)
+		      && config_setting_lookup_string(setting_mme_address, ENB_CONFIG_STRING_MME_IP_ADDRESS_PREFERENCE, (const char **)&preference)
+		      )
+		    ) {
+		AssertFatal (0,
+			     "Failed to parse eNB configuration file %s, %u th enb %u th mme address !\n",
+			     RC.config_file_name, i, j);
+		continue; // FIXME will prevent segfaults below, not sure what happens at function exit...
+	      }
 
-          if (subsetting != NULL) {
-            if ( (config_setting_lookup_int( subsetting, ENB_CONFIG_STRING_SCTP_INSTREAMS, &my_int) )) {
-            	enb_properties.properties[enb_properties_index]->sctp_in_streams = (uint16_t)my_int;
-            }
+	      S1AP_REGISTER_ENB_REQ (msg_p).nb_mme += 1;
 
-            if ( (config_setting_lookup_int( subsetting, ENB_CONFIG_STRING_SCTP_OUTSTREAMS, &my_int) )) {
-            	enb_properties.properties[enb_properties_index]->sctp_out_streams = (uint16_t)my_int;
-            }
-          }
+	      strcpy(S1AP_REGISTER_ENB_REQ (msg_p).mme_ip_address[j].ipv4_address,ipv4);
+	      strcpy(S1AP_REGISTER_ENB_REQ (msg_p).mme_ip_address[j].ipv6_address,ipv6);
+
+	      if (strcmp(active, "yes") == 0) {
+#if defined(ENABLE_USE_MME)
+		EPC_MODE_ENABLED = 1;
 #endif
+	      } 
+	      if (strcmp(preference, "ipv4") == 0) {
+		S1AP_REGISTER_ENB_REQ (msg_p).mme_ip_address[j].ipv4 = 1;
+	      } else if (strcmp(preference, "ipv6") == 0) {
+		S1AP_REGISTER_ENB_REQ (msg_p).mme_ip_address[j].ipv6 = 1;
+	      } else if (strcmp(preference, "no") == 0) {
+		S1AP_REGISTER_ENB_REQ (msg_p).mme_ip_address[j].ipv4 = 1;
+		S1AP_REGISTER_ENB_REQ (msg_p).mme_ip_address[j].ipv6 = 1;
+	      }
+	    }
 
-          // NETWORK_INTERFACES
-          subsetting = config_setting_get_member (setting_enb, ENB_CONFIG_STRING_NETWORK_INTERFACES_CONFIG);
-
-          if (subsetting != NULL) {
-            if (  (
-                   config_setting_lookup_string( subsetting, ENB_CONFIG_STRING_ENB_INTERFACE_NAME_FOR_S1_MME,
-                                                 (const char **)&enb_interface_name_for_S1_MME)
-                   && config_setting_lookup_string( subsetting, ENB_CONFIG_STRING_ENB_IPV4_ADDRESS_FOR_S1_MME,
-                                                    (const char **)&enb_ipv4_address_for_S1_MME)
-                   && config_setting_lookup_string( subsetting, ENB_CONFIG_STRING_ENB_INTERFACE_NAME_FOR_S1U,
-                                                    (const char **)&enb_interface_name_for_S1U)
-                   && config_setting_lookup_string( subsetting, ENB_CONFIG_STRING_ENB_IPV4_ADDR_FOR_S1U,
-                                                    (const char **)&enb_ipv4_address_for_S1U)
-                   && config_setting_lookup_int(subsetting, ENB_CONFIG_STRING_ENB_PORT_FOR_S1U,
-                                                &enb_port_for_S1U)
-                 )
-              ) {
-              enb_properties.properties[enb_properties_index]->enb_interface_name_for_S1U = strdup(enb_interface_name_for_S1U);
-              cidr = enb_ipv4_address_for_S1U;
-              address = strtok(cidr, "/");
-
-              if (address) {
-                IPV4_STR_ADDR_TO_INT_NWBO ( address, enb_properties.properties[enb_properties_index]->enb_ipv4_address_for_S1U, "BAD IP ADDRESS FORMAT FOR eNB S1_U !\n" );
-              }
-
-              enb_properties.properties[enb_properties_index]->enb_port_for_S1U = enb_port_for_S1U;
-
-              enb_properties.properties[enb_properties_index]->enb_interface_name_for_S1_MME = strdup(enb_interface_name_for_S1_MME);
-              cidr = enb_ipv4_address_for_S1_MME;
-              address = strtok(cidr, "/");
-
-              if (address) {
-                IPV4_STR_ADDR_TO_INT_NWBO ( address, enb_properties.properties[enb_properties_index]->enb_ipv4_address_for_S1_MME, "BAD IP ADDRESS FORMAT FOR eNB S1_MME !\n" );
-              }
-            }
-          }
 	  
-	  // Network Controller 
-	  subsetting = config_setting_get_member (setting_enb, ENB_CONFIG_STRING_NETWORK_CONTROLLER_CONFIG);
-
-          if (subsetting != NULL) {
-            if (  (
-                   config_setting_lookup_string( subsetting, ENB_CONFIG_STRING_FLEXRAN_AGENT_INTERFACE_NAME,
-                                                 (const char **)&flexran_agent_interface_name)
-                   && config_setting_lookup_string( subsetting, ENB_CONFIG_STRING_FLEXRAN_AGENT_IPV4_ADDRESS,
-                                                    (const char **)&flexran_agent_ipv4_address)
-                   && config_setting_lookup_int(subsetting, ENB_CONFIG_STRING_FLEXRAN_AGENT_PORT,
-                                                &flexran_agent_port)
-		   && config_setting_lookup_string( subsetting, ENB_CONFIG_STRING_FLEXRAN_AGENT_CACHE,
-						    (const char **)&flexran_agent_cache)
-                 )
-              ) {
-              enb_properties.properties[enb_properties_index]->flexran_agent_interface_name = strdup(flexran_agent_interface_name);
-              cidr = flexran_agent_ipv4_address;
-              address = strtok(cidr, "/");
-	      //enb_properties.properties[enb_properties_index]->flexran_agent_ipv4_address = strdup(address);
-	      if (address) {
-                IPV4_STR_ADDR_TO_INT_NWBO (address, enb_properties.properties[enb_properties_index]->flexran_agent_ipv4_address, "BAD IP ADDRESS FORMAT FOR eNB Agent !\n" );
+	    // SCTP SETTING
+	    S1AP_REGISTER_ENB_REQ (msg_p).sctp_out_streams = SCTP_OUT_STREAMS;
+	    S1AP_REGISTER_ENB_REQ (msg_p).sctp_in_streams  = SCTP_IN_STREAMS;
+# if defined(ENABLE_USE_MME)
+	    subsetting = config_setting_get_member (setting_enb, ENB_CONFIG_STRING_SCTP_CONFIG);
+
+	    if (subsetting != NULL) {
+	      if ( (config_setting_lookup_int( subsetting, ENB_CONFIG_STRING_SCTP_INSTREAMS, &my_int) )) {
+            	S1AP_REGISTER_ENB_REQ (msg_p).sctp_in_streams = (uint16_t)my_int;
+	      }
+
+	      if ( (config_setting_lookup_int( subsetting, ENB_CONFIG_STRING_SCTP_OUTSTREAMS, &my_int) )) {
+            	S1AP_REGISTER_ENB_REQ (msg_p).sctp_out_streams = (uint16_t)my_int;
 	      }
+	    }
+#endif
 
-              enb_properties.properties[enb_properties_index]->flexran_agent_port = flexran_agent_port;
-	      enb_properties.properties[enb_properties_index]->flexran_agent_cache = strdup(flexran_agent_cache);
-            }
-          }
+	    // NETWORK_INTERFACES
+	    subsetting = config_setting_get_member (setting_enb, ENB_CONFIG_STRING_NETWORK_INTERFACES_CONFIG);
+
+	    if (subsetting != NULL) {
+	      if (  (
+		     config_setting_lookup_string( subsetting, ENB_CONFIG_STRING_ENB_INTERFACE_NAME_FOR_S1_MME,
+						   (const char **)&enb_interface_name_for_S1_MME)
+		     && config_setting_lookup_string( subsetting, ENB_CONFIG_STRING_ENB_IPV4_ADDRESS_FOR_S1_MME,
+						      (const char **)&enb_ipv4_address_for_S1_MME)
+		     && config_setting_lookup_string( subsetting, ENB_CONFIG_STRING_ENB_INTERFACE_NAME_FOR_S1U,
+						      (const char **)&enb_interface_name_for_S1U)
+		     && config_setting_lookup_string( subsetting, ENB_CONFIG_STRING_ENB_IPV4_ADDR_FOR_S1U,
+						      (const char **)&enb_ipv4_address_for_S1U)
+		     && config_setting_lookup_int(subsetting, ENB_CONFIG_STRING_ENB_PORT_FOR_S1U,
+						  &enb_port_for_S1U)
+		     )
+		    ) {
+		//		S1AP_REGISTER_ENB_REQ (msg_p).enb_interface_name_for_S1U = strdup(enb_interface_name_for_S1U);
+		cidr = enb_ipv4_address_for_S1U;
+		address = strtok(cidr, "/");
+
+		S1AP_REGISTER_ENB_REQ (msg_p).enb_ip_address.ipv6 = 0;
+		S1AP_REGISTER_ENB_REQ (msg_p).enb_ip_address.ipv4 = 1;
+
+		strcpy(S1AP_REGISTER_ENB_REQ (msg_p).enb_ip_address.ipv4_address, address);
+
+		/*
+		in_addr_t  ipv4_address;
+
+				if (address) {
+		  IPV4_STR_ADDR_TO_INT_NWBO ( address, ipv4_address, "BAD IP ADDRESS FORMAT FOR eNB S1_U !\n" );
+		}
+		strcpy(S1AP_REGISTER_ENB_REQ (msg_p).enb_ip_address.ipv4_address, inet_ntoa(ipv4_address));
+		//		S1AP_REGISTER_ENB_REQ (msg_p).enb_port_for_S1U = enb_port_for_S1U;
+
+
+		S1AP_REGISTER_ENB_REQ (msg_p).enb_interface_name_for_S1_MME = strdup(enb_interface_name_for_S1_MME);
+		cidr = enb_ipv4_address_for_S1_MME;
+		address = strtok(cidr, "/");
+		
+		if (address) {
+		  IPV4_STR_ADDR_TO_INT_NWBO ( address, S1AP_REGISTER_ENB_REQ(msg_p).enb_ipv4_address_for_S1_MME, "BAD IP ADDRESS FORMAT FOR eNB S1_MME !\n" );
+		}
+		*/
+	      }
+	    }
 	  
 
-          // OTG _CONFIG
-          setting_otg = config_setting_get_member (setting_enb, ENB_CONF_STRING_OTG_CONFIG);
-
-          if (setting_otg != NULL) {
-            num_otg_elements  = config_setting_length(setting_otg);
-            printf("num otg elements %d \n", num_otg_elements);
-            enb_properties.properties[enb_properties_index]->num_otg_elements = 0;
-
-            for (j = 0; j < num_otg_elements; j++) {
-              subsetting_otg=config_setting_get_elem(setting_otg, j);
-
-              if (config_setting_lookup_int(subsetting_otg, ENB_CONF_STRING_OTG_UE_ID, &otg_ue_id)) {
-                enb_properties.properties[enb_properties_index]->otg_ue_id[j] = otg_ue_id;
-              } else {
-                enb_properties.properties[enb_properties_index]->otg_ue_id[j] = 1;
-              }
-
-              if (config_setting_lookup_string(subsetting_otg, ENB_CONF_STRING_OTG_APP_TYPE, (const char **)&otg_app_type)) {
-                if ((enb_properties.properties[enb_properties_index]->otg_app_type[j] = map_str_to_int(otg_app_type_names,otg_app_type))== -1) {
-                  enb_properties.properties[enb_properties_index]->otg_app_type[j] = BCBR;
-                }
-              } else {
-                enb_properties.properties[enb_properties_index]->otg_app_type[j] = NO_PREDEFINED_TRAFFIC; // 0
-              }
-
-              if (config_setting_lookup_string(subsetting_otg, ENB_CONF_STRING_OTG_BG_TRAFFIC, (const char **)&otg_bg_traffic)) {
-
-                if ((enb_properties.properties[enb_properties_index]->otg_bg_traffic[j] = map_str_to_int(switch_names,otg_bg_traffic)) == -1) {
-                  enb_properties.properties[enb_properties_index]->otg_bg_traffic[j]=0;
-                }
-              } else {
-                enb_properties.properties[enb_properties_index]->otg_bg_traffic[j] = 0;
-                printf("otg bg %s\n", otg_bg_traffic);
-              }
-
-              enb_properties.properties[enb_properties_index]->num_otg_elements+=1;
-
-            }
-          }
-
-          // log_config
-          subsetting = config_setting_get_member (setting_enb, ENB_CONFIG_STRING_LOG_CONFIG);
-
-          if (subsetting != NULL) {
-            // global
-            if (config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_GLOBAL_LOG_LEVEL, (const char **)  &glog_level)) {
-              if ((enb_properties.properties[enb_properties_index]->glog_level = map_str_to_int(log_level_names, glog_level)) == -1) {
-                enb_properties.properties[enb_properties_index]->glog_level = LOG_INFO;
-              }
-
-              //printf( "\tGlobal log level :\t%s->%d\n",glog_level, enb_properties.properties[enb_properties_index]->glog_level);
-            } else {
-              enb_properties.properties[enb_properties_index]->glog_level = LOG_INFO;
-            }
-
-            if (config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_GLOBAL_LOG_VERBOSITY,(const char **)  &glog_verbosity)) {
-              if ((enb_properties.properties[enb_properties_index]->glog_verbosity = map_str_to_int(log_verbosity_names, glog_verbosity)) == -1) {
-                enb_properties.properties[enb_properties_index]->glog_verbosity = LOG_MED;
-              }
-
-              //printf( "\tGlobal log verbosity:\t%s->%d\n",glog_verbosity, enb_properties.properties[enb_properties_index]->glog_verbosity);
-            } else {
-              enb_properties.properties[enb_properties_index]->glog_verbosity = LOG_MED;
-            }
-
-            // HW
-            if (config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_HW_LOG_LEVEL, (const char **) &hw_log_level)) {
-              if ((enb_properties.properties[enb_properties_index]->hw_log_level = map_str_to_int(log_level_names,hw_log_level)) == -1) {
-                enb_properties.properties[enb_properties_index]->hw_log_level = LOG_INFO;
-              }
-
-              //printf( "\tHW log level :\t%s->%d\n",hw_log_level,enb_properties.properties[enb_properties_index]->hw_log_level);
-            } else {
-              enb_properties.properties[enb_properties_index]->hw_log_level = LOG_INFO;
-            }
-
-            if (config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_HW_LOG_VERBOSITY, (const char **) &hw_log_verbosity)) {
-              if ((enb_properties.properties[enb_properties_index]->hw_log_verbosity = map_str_to_int(log_verbosity_names,hw_log_verbosity)) == -1) {
-                enb_properties.properties[enb_properties_index]->hw_log_verbosity = LOG_MED;
-              }
-
-              //printf( "\tHW log verbosity:\t%s->%d\n",hw_log_verbosity, enb_properties.properties[enb_properties_index]->hw_log_verbosity);
-            } else {
-              enb_properties.properties[enb_properties_index]->hw_log_verbosity = LOG_MED;
-            }
-
-            // phy
-            if (config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_PHY_LOG_LEVEL,(const char **) &phy_log_level)) {
-              if ((enb_properties.properties[enb_properties_index]->phy_log_level = map_str_to_int(log_level_names,phy_log_level)) == -1) {
-                enb_properties.properties[enb_properties_index]->phy_log_level = LOG_INFO;
-              }
-
-              //printf( "\tPHY log level :\t%s->%d\n",phy_log_level,enb_properties.properties[enb_properties_index]->phy_log_level);
-            } else {
-              enb_properties.properties[enb_properties_index]->phy_log_level = LOG_INFO;
-            }
-
-            if (config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_PHY_LOG_VERBOSITY, (const char **)&phy_log_verbosity)) {
-              if ((enb_properties.properties[enb_properties_index]->phy_log_verbosity = map_str_to_int(log_verbosity_names,phy_log_verbosity)) == -1) {
-                enb_properties.properties[enb_properties_index]->phy_log_verbosity = LOG_MED;
-              }
-
-              //printf( "\tPHY log verbosity:\t%s->%d\n",phy_log_level,enb_properties.properties[enb_properties_index]->phy_log_verbosity);
-            } else {
-              enb_properties.properties[enb_properties_index]->phy_log_verbosity = LOG_MED;
-            }
-
-            //mac
-            if (config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_MAC_LOG_LEVEL, (const char **)&mac_log_level)) {
-              if ((enb_properties.properties[enb_properties_index]->mac_log_level = map_str_to_int(log_level_names,mac_log_level)) == -1 ) {
-                enb_properties.properties[enb_properties_index]->mac_log_level = LOG_INFO;
-              }
-
-              //printf( "\tMAC log level :\t%s->%d\n",mac_log_level,enb_properties.properties[enb_properties_index]->mac_log_level);
-            } else {
-              enb_properties.properties[enb_properties_index]->mac_log_level = LOG_INFO;
-            }
-
-            if (config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_MAC_LOG_VERBOSITY, (const char **)&mac_log_verbosity)) {
-              if ((enb_properties.properties[enb_properties_index]->mac_log_verbosity = map_str_to_int(log_verbosity_names,mac_log_verbosity)) == -1) {
-                enb_properties.properties[enb_properties_index]->mac_log_verbosity = LOG_MED;
-              }
-
-              //printf( "\tMAC log verbosity:\t%s->%d\n",mac_log_verbosity,enb_properties.properties[enb_properties_index]->mac_log_verbosity);
-            } else {
-              enb_properties.properties[enb_properties_index]->mac_log_verbosity = LOG_MED;
-            }
-
-            //rlc
-            if (config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_RLC_LOG_LEVEL, (const char **)&rlc_log_level)) {
-              if ((enb_properties.properties[enb_properties_index]->rlc_log_level = map_str_to_int(log_level_names,rlc_log_level)) == -1) {
-                enb_properties.properties[enb_properties_index]->rlc_log_level = LOG_INFO;
-              }
-
-              //printf( "\tRLC log level :\t%s->%d\n",rlc_log_level, enb_properties.properties[enb_properties_index]->rlc_log_level);
-            } else {
-              enb_properties.properties[enb_properties_index]->rlc_log_level = LOG_INFO;
-            }
-
-            if (config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_RLC_LOG_VERBOSITY, (const char **)&rlc_log_verbosity)) {
-              if ((enb_properties.properties[enb_properties_index]->rlc_log_verbosity = map_str_to_int(log_verbosity_names,rlc_log_verbosity)) == -1) {
-                enb_properties.properties[enb_properties_index]->rlc_log_verbosity = LOG_MED;
-              }
-
-              //printf( "\tRLC log verbosity:\t%s->%d\n",rlc_log_verbosity, enb_properties.properties[enb_properties_index]->rlc_log_verbosity);
-            } else {
-              enb_properties.properties[enb_properties_index]->rlc_log_verbosity = LOG_MED;
-            }
-
-            //pdcp
-            if (config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_PDCP_LOG_LEVEL, (const char **)&pdcp_log_level)) {
-              if ((enb_properties.properties[enb_properties_index]->pdcp_log_level = map_str_to_int(log_level_names,pdcp_log_level)) == -1) {
-                enb_properties.properties[enb_properties_index]->pdcp_log_level = LOG_INFO;
-              }
-
-              //printf( "\tPDCP log level :\t%s->%d\n",pdcp_log_level, enb_properties.properties[enb_properties_index]->pdcp_log_level);
-            } else {
-              enb_properties.properties[enb_properties_index]->pdcp_log_level = LOG_INFO;
-            }
-
-            if (config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_PDCP_LOG_VERBOSITY, (const char **)&pdcp_log_verbosity)) {
-              enb_properties.properties[enb_properties_index]->pdcp_log_verbosity = map_str_to_int(log_verbosity_names,pdcp_log_verbosity);
-              //printf( "\tPDCP log verbosity:\t%s->%d\n",pdcp_log_verbosity, enb_properties.properties[enb_properties_index]->pdcp_log_verbosity);
-            } else {
-              enb_properties.properties[enb_properties_index]->pdcp_log_verbosity = LOG_MED;
-            }
-
-            //rrc
-            if (config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_RRC_LOG_LEVEL, (const char **)&rrc_log_level)) {
-              if ((enb_properties.properties[enb_properties_index]->rrc_log_level = map_str_to_int(log_level_names,rrc_log_level)) == -1 ) {
-                enb_properties.properties[enb_properties_index]->rrc_log_level = LOG_INFO;
-              }
-
-              //printf( "\tRRC log level :\t%s->%d\n",rrc_log_level,enb_properties.properties[enb_properties_index]->rrc_log_level);
-            } else {
-              enb_properties.properties[enb_properties_index]->rrc_log_level = LOG_INFO;
-            }
-
-            if (config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_RRC_LOG_VERBOSITY, (const char **)&rrc_log_verbosity)) {
-              if ((enb_properties.properties[enb_properties_index]->rrc_log_verbosity = map_str_to_int(log_verbosity_names,rrc_log_verbosity)) == -1) {
-                enb_properties.properties[enb_properties_index]->rrc_log_verbosity = LOG_MED;
-              }
-
-              //printf( "\tRRC log verbosity:\t%s->%d\n",rrc_log_verbosity,enb_properties.properties[enb_properties_index]->rrc_log_verbosity);
-            } else {
-              enb_properties.properties[enb_properties_index]->rrc_log_verbosity = LOG_MED;
-            }
-
-            if (config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_GTPU_LOG_LEVEL, (const char **)&gtpu_log_level)) {
-              if ((enb_properties.properties[enb_properties_index]->gtpu_log_level = map_str_to_int(log_level_names,gtpu_log_level)) == -1 ) {
-                enb_properties.properties[enb_properties_index]->gtpu_log_level = LOG_INFO;
-              }
-
-              //printf( "\tGTPU log level :\t%s->%d\n",gtpu_log_level,enb_properties.properties[enb_properties_index]->gtpu_log_level);
-            } else {
-              enb_properties.properties[enb_properties_index]->gtpu_log_level = LOG_INFO;
-            }
-
-            if (config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_GTPU_LOG_VERBOSITY, (const char **)&gtpu_log_verbosity)) {
-              if ((enb_properties.properties[enb_properties_index]->gtpu_log_verbosity = map_str_to_int(log_verbosity_names,gtpu_log_verbosity)) == -1) {
-                enb_properties.properties[enb_properties_index]->gtpu_log_verbosity = LOG_MED;
-              }
-
-              //printf( "\tGTPU log verbosity:\t%s->%d\n",gtpu_log_verbosity,enb_properties.properties[enb_properties_index]->gtpu_log_verbosity);
-            } else {
-              enb_properties.properties[enb_properties_index]->gtpu_log_verbosity = LOG_MED;
-            }
-
-            if (config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_UDP_LOG_LEVEL, (const char **)&udp_log_level)) {
-              if ((enb_properties.properties[enb_properties_index]->udp_log_level = map_str_to_int(log_level_names,udp_log_level)) == -1 ) {
-                enb_properties.properties[enb_properties_index]->udp_log_level = LOG_INFO;
-              }
-
-              //printf( "\tUDP log level :\t%s->%d\n",udp_log_level,enb_properties.properties[enb_properties_index]->udp_log_level);
-            } else {
-              enb_properties.properties[enb_properties_index]->udp_log_level = LOG_INFO;
-            }
-
-            if (config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_UDP_LOG_VERBOSITY, (const char **)&udp_log_verbosity)) {
-              if ((enb_properties.properties[enb_properties_index]->udp_log_verbosity = map_str_to_int(log_verbosity_names,udp_log_verbosity)) == -1) {
-                enb_properties.properties[enb_properties_index]->udp_log_verbosity = LOG_MED;
-              }
-
-              //printf( "\tUDP log verbosity:\t%s->%d\n",udp_log_verbosity,enb_properties.properties[enb_properties_index]->gtpu_log_verbosity);
-            } else {
-              enb_properties.properties[enb_properties_index]->udp_log_verbosity = LOG_MED;
-            }
-
-            if (config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_OSA_LOG_LEVEL, (const char **)&osa_log_level)) {
-              if ((enb_properties.properties[enb_properties_index]->osa_log_level = map_str_to_int(log_level_names,osa_log_level)) == -1 ) {
-                enb_properties.properties[enb_properties_index]->osa_log_level = LOG_INFO;
-              }
-
-              //printf( "\tOSA log level :\t%s->%d\n",osa_log_level,enb_properties.properties[enb_properties_index]->osa_log_level);
-            } else {
-              enb_properties.properties[enb_properties_index]->osa_log_level = LOG_INFO;
-            }
-
-            if (config_setting_lookup_string(subsetting, ENB_CONFIG_STRING_OSA_LOG_VERBOSITY, (const char **)&osa_log_verbosity)) {
-              if ((enb_properties.properties[enb_properties_index]->osa_log_verbosity = map_str_to_int(log_verbosity_names,osa_log_verbosity)) == -1) {
-                enb_properties.properties[enb_properties_index]->osa_log_verbosity = LOG_MED;
-              }
-
-              //printf( "\tOSA log verbosity:\t%s->%d\n",osa_log_verbosity,enb_properties.properties[enb_properties_index]->gosa_log_verbosity);
-            } else {
-              enb_properties.properties[enb_properties_index]->osa_log_verbosity = LOG_MED;
-            }
-
-          } else { // not configuration is given
-            enb_properties.properties[enb_properties_index]->glog_level         = LOG_INFO;
-            enb_properties.properties[enb_properties_index]->glog_verbosity     = LOG_MED;
-            enb_properties.properties[enb_properties_index]->hw_log_level       = LOG_INFO;
-            enb_properties.properties[enb_properties_index]->hw_log_verbosity   = LOG_MED;
-            enb_properties.properties[enb_properties_index]->phy_log_level      = LOG_INFO;
-            enb_properties.properties[enb_properties_index]->phy_log_verbosity  = LOG_MED;
-            enb_properties.properties[enb_properties_index]->mac_log_level      = LOG_INFO;
-            enb_properties.properties[enb_properties_index]->mac_log_verbosity  = LOG_MED;
-            enb_properties.properties[enb_properties_index]->rlc_log_level      = LOG_INFO;
-            enb_properties.properties[enb_properties_index]->rlc_log_verbosity  = LOG_MED;
-            enb_properties.properties[enb_properties_index]->pdcp_log_level     = LOG_INFO;
-            enb_properties.properties[enb_properties_index]->pdcp_log_verbosity = LOG_MED;
-            enb_properties.properties[enb_properties_index]->rrc_log_level      = LOG_INFO;
-            enb_properties.properties[enb_properties_index]->rrc_log_verbosity  = LOG_MED;
-            enb_properties.properties[enb_properties_index]->gtpu_log_level     = LOG_INFO;
-            enb_properties.properties[enb_properties_index]->gtpu_log_verbosity = LOG_MED;
-            enb_properties.properties[enb_properties_index]->udp_log_level      = LOG_INFO;
-            enb_properties.properties[enb_properties_index]->udp_log_verbosity  = LOG_MED;
-            enb_properties.properties[enb_properties_index]->osa_log_level      = LOG_INFO;
-            enb_properties.properties[enb_properties_index]->osa_log_verbosity  = LOG_MED;
-          }
-
-          enb_properties_index += 1;
-          break;
-        }
+
+
+	    break;
+	  }
+	}
       }
     }
   }
+}
 
-  enb_properties.number = num_enb_properties;
+void RCConfig(const char *config_file_name) {
 
-  AssertFatal (enb_properties_index == num_enb_properties,
-               "Failed to parse eNB configuration file %s, mismatch between %u active eNBs and %u corresponding defined eNBs !\n",
-               lib_config_file_name_pP, num_enb_properties, enb_properties_index);
+  config_t          cfg;
+  config_setting_t *setting                       = NULL;
+  config_setting_t *setting_enb                   = NULL;
+  config_setting_t *setting_component_carriers    = NULL;
+  config_init(&cfg);
 
-  enb_config_display();
-  return &enb_properties;
+  if (config_file_name != NULL) {
 
-}
+    RC.config_file_name = config_file_name;
+    if (! config_read_file(&cfg, RC.config_file_name)) {
+      config_destroy(&cfg);
+      AssertFatal (0, "Failed to parse eNB configuration file %s!\n", RC.config_file_name);
+    }
+    // Get num eNB instances
+    setting = config_lookup(&cfg, ENB_CONFIG_STRING_ACTIVE_ENBS);
+    
+    if (setting != NULL) RC.nb_inst = config_setting_length(setting);
+    if (RC.nb_inst > 0) {
+      printf("Number of eNB instances %d\n",RC.nb_inst);
+      setting = config_lookup(&cfg, ENB_CONFIG_STRING_ENB_LIST);
+      RC.nb_CC = (int *)malloc((1+RC.nb_inst)*sizeof(int));
+      for (int i=0;i<RC.nb_inst;i++) {
+	setting_enb                  = config_setting_get_elem(setting, i);
+	setting_component_carriers   = config_setting_get_member (setting_enb, ENB_CONFIG_STRING_COMPONENT_CARRIERS);
+	AssertFatal(setting_component_carriers != NULL, "No component carrier definitions in %s\n",RC.config_file_name); 
+	RC.nb_CC[i]                = config_setting_length(setting_component_carriers);
+	printf("Setting nb_CC to %d for instance %d\n",RC.nb_CC[i],i);
 
-const Enb_properties_array_t *enb_config_get(void)
-{
-  return &enb_properties;
-}
+      }
+    }
 
+    // Get num RU instances
+    setting = config_lookup(&cfg, CONFIG_STRING_RU_LIST);
+    
+    if (setting != NULL) RC.nb_RU = config_setting_length(setting); 
+  }
+  else {
+    config_destroy(&cfg);
+    AssertFatal(0,"Configuration file is null\n");
+  }
+
+}
diff --git a/openair2/ENB_APP/enb_config.h b/openair2/ENB_APP/enb_config.h
index fd53395311..c14de0abb9 100644
--- a/openair2/ENB_APP/enb_config.h
+++ b/openair2/ENB_APP/enb_config.h
@@ -73,11 +73,14 @@ typedef struct mme_ip_address_s {
   char     *ipv6_address;
 } mme_ip_address_t;
 
-typedef struct rrh_gw_config_s {
+typedef struct ru_config_s {
+  // indicates if local or remote rf is used (1 == LOCAL)
+  unsigned  local_rf:1;
+  // indicates if UDP socket is used
   unsigned  udp:1;
+  // indicates if RAW socket is used
   unsigned  raw:1;
-  unsigned  active:1;
-  char      *rrh_gw_if_name;
+  char      *ru_if_name;
   char     *local_address;
   char     *remote_address;
   uint16_t  local_port;
@@ -85,15 +88,7 @@ typedef struct rrh_gw_config_s {
   uint8_t   udpif4p5;
   uint8_t   rawif4p5;
   uint8_t   rawif5_mobipass;
-  int tx_scheduling_advance;
-  int tx_sample_advance;
-  int iq_txshift;
-  unsigned  exmimo:1;
-  unsigned  usrp_b200:1;
-  unsigned  usrp_x300:1;
-  unsigned  bladerf:1; 
-  unsigned  lmssdr:1;  
-} rrh_gw_config_t;
+} ru_config_t;
 
 typedef struct Enb_properties_s {
   /* Unique eNB_id to identify the eNB within EPC.
@@ -127,8 +122,8 @@ typedef struct Enb_properties_s {
   /* Physical parameters */
   int16_t                 nb_cc;
 #ifndef OCP_FRAMEWORK
-  eNB_func_t              cc_node_function[1+MAX_NUM_CCs];
-  eNB_timing_t            cc_node_timing[1+MAX_NUM_CCs];
+  node_function_t         cc_node_function[1+MAX_NUM_CCs];
+  node_timing_t           cc_node_timing[1+MAX_NUM_CCs];
   int16_t                 cc_node_synch_ref[1+MAX_NUM_CCs];
   lte_frame_type_t        frame_type[1+MAX_NUM_CCs];
   uint8_t                 tdd_config[1+MAX_NUM_CCs];
@@ -233,11 +228,6 @@ typedef struct Enb_properties_s {
   tcp_udp_port_t      flexran_agent_port;
   char               *flexran_agent_cache;
 
-  /* Nb of RRH to connect to */
-  uint8_t             nb_rrh_gw;
-  char               *rrh_gw_if_name;
-  /* List of MME to connect to */
-  rrh_gw_config_t       rrh_gw_config[4];
 
 #ifndef OCP_FRAMEWORK
   // otg config
@@ -274,9 +264,12 @@ typedef struct Enb_properties_s {
 typedef struct Enb_properties_array_s {
   int                  number;
   Enb_properties_t    *properties[MAX_ENB];
+  int                  nb_ru;
+  ru_config_t         *ru_config[NUMBER_OF_RU_MAX];
 } Enb_properties_array_t;
 
 void                          enb_config_display(void);
+void                          ru_config_display(void);
 const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP);
 
 const Enb_properties_array_t *enb_config_get(void);
diff --git a/openair2/LAYER2/MAC/config.c b/openair2/LAYER2/MAC/config.c
index b5d613e4ae..50ba2bf5d6 100644
--- a/openair2/LAYER2/MAC/config.c
+++ b/openair2/LAYER2/MAC/config.c
@@ -1,3 +1,4 @@
+
 /*
  * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -42,6 +43,7 @@
 #include "extern.h"
 #include "UTIL/LOG/log.h"
 #include "UTIL/LOG/vcd_signal_dumper.h"
+#include "common/ran_context.h"
 #ifdef Rel10
 #include "MBSFN-AreaInfoList-r9.h"
 #include "MBSFN-AreaInfo-r9.h"
@@ -49,6 +51,8 @@
 #include "PMCH-InfoList-r9.h"
 #endif
 
+extern RAN_CONTEXT_t RC;
+
 /* sec 5.9, 36.321: MAC Reset Procedure */
 void ue_mac_reset(module_id_t module_idP,uint8_t eNB_index)
 {
@@ -84,77 +88,90 @@ void ue_mac_reset(module_id_t module_idP,uint8_t eNB_index)
 
 }
 
-int
-rrc_mac_config_req(
-  module_id_t                      Mod_idP,
-  int                              CC_idP,
-  eNB_flag_t                       eNB_flagP,
-  rnti_t                           rntiP,
-  uint8_t                          eNB_index,
-                       RadioResourceConfigCommonSIB_t  *radioResourceConfigCommon,
-                       struct PhysicalConfigDedicated  *physicalConfigDedicated,
+int rrc_mac_config_req_eNB(module_id_t                      Mod_idP,
+			   int                              CC_idP,
+			   int                              physCellId,
+			   int                              p_eNB,
+			   int                              Ncp,
+			   int                              eutra_band,
+			   uint32_t                         dl_CarrierFreq,
+			   BCCH_BCH_Message_t               *mib,
+			   RadioResourceConfigCommonSIB_t   *radioResourceConfigCommon,
+			   struct PhysicalConfigDedicated  *physicalConfigDedicated,
 #ifdef Rel10
-                       SCellToAddMod_r10_t *sCellToAddMod_r10,
-                       //struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10,
+			   SCellToAddMod_r10_t *sCellToAddMod_r10,
+			   //struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10,
 #endif
-                       MeasObjectToAddMod_t           **measObj,
-                       MAC_MainConfig_t                *mac_MainConfig,
-                       long                             logicalChannelIdentity,
-                       LogicalChannelConfig_t          *logicalChannelConfig,
-                       MeasGapConfig_t                 *measGapConfig,
-                       TDD_Config_t                    *tdd_Config,
-                       MobilityControlInfo_t           *mobilityControlInfo,
-                       uint8_t                              *SIwindowsize,
-                       uint16_t                             *SIperiod,
-                       ARFCN_ValueEUTRA_t              *ul_CarrierFreq,
-                       long                            *ul_Bandwidth,
-                       AdditionalSpectrumEmission_t    *additionalSpectrumEmission,
-                       struct MBSFN_SubframeConfigList *mbsfn_SubframeConfigList
+			   MeasObjectToAddMod_t           **measObj,
+			   MAC_MainConfig_t                *mac_MainConfig,
+			   long                             logicalChannelIdentity,
+			   LogicalChannelConfig_t          *logicalChannelConfig,
+			   MeasGapConfig_t                 *measGapConfig,
+			   TDD_Config_t                    *tdd_Config,
+			   MobilityControlInfo_t           *mobilityControlInfo,
+			   uint8_t                              *SIwindowsize,
+			   uint16_t                             *SIperiod,
+			   uint32_t                        ul_CarrierFreq,
+			   long                            *ul_Bandwidth,
+			   AdditionalSpectrumEmission_t    *additionalSpectrumEmission,
+			   struct MBSFN_SubframeConfigList *mbsfn_SubframeConfigList
 #ifdef Rel10
-                       ,uint8_t                              MBMS_Flag,
-                       MBSFN_AreaInfoList_r9_t         *mbsfn_AreaInfoList,
-                       PMCH_InfoList_r9_t              *pmch_InfoList
+			   ,uint8_t                              MBMS_Flag,
+			   MBSFN_AreaInfoList_r9_t         *mbsfn_AreaInfoList,
+			   PMCH_InfoList_r9_t              *pmch_InfoList
 #endif
 #ifdef CBA
-                       ,uint8_t                              num_active_cba_groups,
-                       uint16_t                              cba_rnti
-#endif
-                      )
-{
-
+			   ,uint8_t                              num_active_cba_groups,
+			   uint16_t                              cba_rnti
+#endif			   
+			   ) {
+			   
   int i;
 
   int UE_id = -1;
-  eNB_MAC_INST *eNB = &eNB_mac_inst[Mod_idP];
+  eNB_MAC_INST *eNB = RC.mac[Mod_idP];
   UE_list_t *UE_list= &eNB->UE_list;
 
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_MAC_CONFIG, VCD_FUNCTION_IN);
 
-  if (eNB_flagP==0) {
-    LOG_I(MAC,"[CONFIG][UE %d] Configuring MAC/PHY from eNB %d\n",Mod_idP,eNB_index);
-
-    if (tdd_Config != NULL) {
-      UE_mac_inst[Mod_idP].tdd_Config = tdd_Config;
-    }
-  } else {
-    UE_id = find_UE_id(Mod_idP, rntiP);
-    if (physicalConfigDedicated == NULL) {
-      LOG_I(MAC,"[CONFIG][eNB %d/%d] Configuring MAC/PHY\n", Mod_idP, CC_idP);
-    } else {
-      LOG_I(MAC,"[CONFIG][eNB %d/%d] Configuring MAC/PHY for UE %d (%x)\n", Mod_idP, CC_idP, UE_id, UE_RNTI(Mod_idP, UE_id));
-    }
+  if (mib!=NULL) {
+    if (RC.mac == NULL) 
+      l2_init_eNB(
+#ifdef Rel10 
+		  MBMS_Flag,
+#else
+		  0,
+#endif 
+		  NULL,0,0);
+
+    mac_top_init_eNB();
+
+    RC.mac[Mod_idP]->common_channels[CC_idP].mib            = mib;
+    RC.mac[Mod_idP]->common_channels[CC_idP].physCellId     = physCellId;
+    RC.mac[Mod_idP]->common_channels[CC_idP].p_eNB          = p_eNB;
+    RC.mac[Mod_idP]->common_channels[CC_idP].Ncp            = Ncp;
+    RC.mac[Mod_idP]->common_channels[CC_idP].eutra_band     = eutra_band;
+    RC.mac[Mod_idP]->common_channels[CC_idP].dl_CarrierFreq = dl_CarrierFreq;
+
+    mac_xface->phy_config_mib_eNB(Mod_idP,CC_idP,
+				  eutra_band,
+				  mib->message.dl_Bandwidth,
+				  &mib->message.phich_Config,
+				  physCellId,
+				  Ncp,
+				  p_eNB,
+				  dl_CarrierFreq,
+				  ul_CarrierFreq);
+    mac_init_cell_params(Mod_idP,CC_idP);
   }
-
-  if (tdd_Config && SIwindowsize && SIperiod) {
-    if (eNB_flagP == ENB_FLAG_YES) {
-      mac_xface->phy_config_sib1_eNB(Mod_idP, CC_idP, tdd_Config, *SIwindowsize, *SIperiod);
-    } else {
-      mac_xface->phy_config_sib1_ue(Mod_idP,0,eNB_index,tdd_Config,*SIwindowsize,*SIperiod);
-    }
+  if ((SIwindowsize!=NULL) && (SIperiod!=NULL))  {
+    RC.mac[Mod_idP]->common_channels[CC_idP].tdd_Config            = tdd_Config;    
+    RC.mac[Mod_idP]->common_channels[CC_idP].SIwindowsize          = *SIwindowsize;    
+    RC.mac[Mod_idP]->common_channels[CC_idP].SIperiod              = *SIperiod;    
+    mac_xface->phy_config_sib1_eNB(Mod_idP,CC_idP,tdd_Config,*SIwindowsize,*SIperiod);
   }
 
   if (radioResourceConfigCommon!=NULL) {
-    if (eNB_flagP==1) {
       LOG_I(MAC,"[CONFIG]SIB2/3 Contents (partial)\n");
       LOG_I(MAC,"[CONFIG]pusch_config_common.n_SB = %ld\n",radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.n_SB);
       LOG_I(MAC,"[CONFIG]pusch_config_common.hoppingMode = %ld\n",radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.hoppingMode);
@@ -164,402 +181,482 @@ rrc_mac_config_req(
       LOG_I(MAC,"[CONFIG]pusch_config_common.groupAssignmentPUSCH = %ld\n",radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH);
       LOG_I(MAC,"[CONFIG]pusch_config_common.sequenceHoppingEnabled = %d\n",radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled);
       LOG_I(MAC,"[CONFIG]pusch_config_common.cyclicShift  = %ld\n",radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.cyclicShift);
-      mac_xface->phy_config_sib2_eNB(Mod_idP, CC_idP, radioResourceConfigCommon, ul_CarrierFreq, ul_Bandwidth, additionalSpectrumEmission, mbsfn_SubframeConfigList);
-    } else {
-      UE_mac_inst[Mod_idP].radioResourceConfigCommon = radioResourceConfigCommon;
-      mac_xface->phy_config_sib2_ue(Mod_idP,0,eNB_index,radioResourceConfigCommon,ul_CarrierFreq,ul_Bandwidth,additionalSpectrumEmission,mbsfn_SubframeConfigList);
-    }
+
+      RC.mac[Mod_idP]->common_channels[CC_idP].radioResourceConfigCommon = radioResourceConfigCommon;
+      if (ul_CarrierFreq>0) RC.mac[Mod_idP]->common_channels[CC_idP].ul_CarrierFreq          = ul_CarrierFreq;
+      if (ul_Bandwidth) RC.mac[Mod_idP]->common_channels[CC_idP].ul_Bandwidth                = *ul_Bandwidth;
+      mac_xface->phy_config_sib2_eNB(Mod_idP, CC_idP, radioResourceConfigCommon, NULL, ul_Bandwidth, additionalSpectrumEmission, mbsfn_SubframeConfigList);
+
+
   }
 
   // SRB2_lchan_config->choice.explicitValue.ul_SpecificParameters->logicalChannelGroup
   if (logicalChannelConfig!= NULL) {
-    if (eNB_flagP==0) {
-      LOG_I(MAC,"[CONFIG][UE %d] Applying RRC logicalChannelConfig from eNB%d\n",Mod_idP,eNB_index);
-      UE_mac_inst[Mod_idP].logicalChannelConfig[logicalChannelIdentity]=logicalChannelConfig;
-      UE_mac_inst[Mod_idP].scheduling_info.Bj[logicalChannelIdentity]=0; // initilize the bucket for this lcid
-
-      if (logicalChannelConfig->ul_SpecificParameters) {
-        UE_mac_inst[Mod_idP].scheduling_info.bucket_size[logicalChannelIdentity]=logicalChannelConfig->ul_SpecificParameters->prioritisedBitRate *
-            logicalChannelConfig->ul_SpecificParameters->bucketSizeDuration; // set the max bucket size
-        if (logicalChannelConfig->ul_SpecificParameters->logicalChannelGroup != NULL) {
-            UE_mac_inst[Mod_idP].scheduling_info.LCGID[logicalChannelIdentity]=*logicalChannelConfig->ul_SpecificParameters->logicalChannelGroup;
-            LOG_D(MAC,"[CONFIG][UE %d] LCID %ld is attached to the LCGID %ld\n",Mod_idP,logicalChannelIdentity,*logicalChannelConfig->ul_SpecificParameters->logicalChannelGroup);
-        }
-        else {
-        	UE_mac_inst[Mod_idP].scheduling_info.LCGID[logicalChannelIdentity] = MAX_NUM_LCGID;
-        }
-        UE_mac_inst[Mod_idP].scheduling_info.LCID_buffer_remain[logicalChannelIdentity] = 0;
-      } else {
-        LOG_E(MAC,"[CONFIG][UE %d] LCID %ld NULL ul_SpecificParameters\n",Mod_idP,logicalChannelIdentity);
-        mac_xface->macphy_exit("NULL ul_SpecificParameters");
-      }
-    }
-    else {
-      if (UE_id == -1) {
-        LOG_E(MAC,"%s:%d:%s: ERROR, UE_id == -1\n", __FILE__, __LINE__, __FUNCTION__);
-      } else {
-        if (logicalChannelConfig)
-	  UE_list->UE_template[CC_idP][UE_id].lcgidmap[logicalChannelIdentity] = *logicalChannelConfig->ul_SpecificParameters->logicalChannelGroup;
-        else
-	  UE_list->UE_template[CC_idP][UE_id].lcgidmap[logicalChannelIdentity] = 0;
-      }
+    if (UE_id == -1) {
+      LOG_E(MAC,"%s:%d:%s: ERROR, UE_id == -1\n", __FILE__, __LINE__, __FUNCTION__);
+    } else {
+      if (logicalChannelConfig)
+	UE_list->UE_template[CC_idP][UE_id].lcgidmap[logicalChannelIdentity] = *logicalChannelConfig->ul_SpecificParameters->logicalChannelGroup;
+      else
+	UE_list->UE_template[CC_idP][UE_id].lcgidmap[logicalChannelIdentity] = 0;
     }
   }
+  
+
+  if (physicalConfigDedicated != NULL) {
+    if (UE_id == -1)
+      LOG_E(MAC,"%s:%d:%s: ERROR, UE_id == -1\n", __FILE__, __LINE__, __FUNCTION__);
+    else
+      mac_xface->phy_config_dedicated_eNB(Mod_idP, CC_idP, UE_RNTI(Mod_idP, UE_id), physicalConfigDedicated);
+  } 
 
-  if (mac_MainConfig != NULL) {
-    if (eNB_flagP==0) {
-      LOG_I(MAC,"[CONFIG][UE%d] Applying RRC macMainConfig from eNB%d\n",Mod_idP,eNB_index);
-      UE_mac_inst[Mod_idP].macConfig=mac_MainConfig;
-      UE_mac_inst[Mod_idP].measGapConfig=measGapConfig;
-
-      if (mac_MainConfig->ul_SCH_Config) {
-
-        if (mac_MainConfig->ul_SCH_Config->periodicBSR_Timer) {
-          UE_mac_inst[Mod_idP].scheduling_info.periodicBSR_Timer = (uint16_t) *mac_MainConfig->ul_SCH_Config->periodicBSR_Timer;
-        } else {
-          UE_mac_inst[Mod_idP].scheduling_info.periodicBSR_Timer = (uint16_t) MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_infinity;
-        }
-
-        if (mac_MainConfig->ul_SCH_Config->maxHARQ_Tx) {
-          UE_mac_inst[Mod_idP].scheduling_info.maxHARQ_Tx     = (uint16_t) *mac_MainConfig->ul_SCH_Config->maxHARQ_Tx;
-        } else {
-          UE_mac_inst[Mod_idP].scheduling_info.maxHARQ_Tx     = (uint16_t) MAC_MainConfig__ul_SCH_Config__maxHARQ_Tx_n5;
-        }
-        mac_xface->phy_config_harq_ue(Mod_idP,0,eNB_index,UE_mac_inst[Mod_idP].scheduling_info.maxHARQ_Tx);
-
-        if (mac_MainConfig->ul_SCH_Config->retxBSR_Timer) {
-          UE_mac_inst[Mod_idP].scheduling_info.retxBSR_Timer     = (uint16_t) mac_MainConfig->ul_SCH_Config->retxBSR_Timer;
-        } else {
-          UE_mac_inst[Mod_idP].scheduling_info.retxBSR_Timer     = (uint16_t)MAC_MainConfig__ul_SCH_Config__retxBSR_Timer_sf2560;
-      }
-      }
 
 #ifdef Rel10
 
-      if (mac_MainConfig->ext1 && mac_MainConfig->ext1->sr_ProhibitTimer_r9) {
-        UE_mac_inst[Mod_idP].scheduling_info.sr_ProhibitTimer  = (uint16_t) *mac_MainConfig->ext1->sr_ProhibitTimer_r9;
-      } else {
-        UE_mac_inst[Mod_idP].scheduling_info.sr_ProhibitTimer  = 0;
-      }
+  if (sCellToAddMod_r10 != NULL) {
 
-      if (mac_MainConfig->ext2 && mac_MainConfig->ext2->mac_MainConfig_v1020) {
-        if (mac_MainConfig->ext2->mac_MainConfig_v1020->extendedBSR_Sizes_r10) {
-          UE_mac_inst[Mod_idP].scheduling_info.extendedBSR_Sizes_r10 = (uint16_t) *mac_MainConfig->ext2->mac_MainConfig_v1020->extendedBSR_Sizes_r10;
-        } else {
-          UE_mac_inst[Mod_idP].scheduling_info.extendedBSR_Sizes_r10 = (uint16_t)0;
-        }
-        if (mac_MainConfig->ext2->mac_MainConfig_v1020->extendedPHR_r10) {
-          UE_mac_inst[Mod_idP].scheduling_info.extendedPHR_r10 = (uint16_t) *mac_MainConfig->ext2->mac_MainConfig_v1020->extendedPHR_r10;
-        } else {
-          UE_mac_inst[Mod_idP].scheduling_info.extendedPHR_r10 = (uint16_t)0;
-        }
-      } else {
-        UE_mac_inst[Mod_idP].scheduling_info.extendedBSR_Sizes_r10 = (uint16_t)0;
-        UE_mac_inst[Mod_idP].scheduling_info.extendedPHR_r10 = (uint16_t)0;
-      }
-#endif
-      UE_mac_inst[Mod_idP].scheduling_info.periodicBSR_SF  = MAC_UE_BSR_TIMER_NOT_RUNNING;
-      UE_mac_inst[Mod_idP].scheduling_info.retxBSR_SF     = MAC_UE_BSR_TIMER_NOT_RUNNING;
+    if (UE_id == -1)
+      LOG_E(MAC,"%s:%d:%s: ERROR, UE_id == -1\n", __FILE__, __LINE__, __FUNCTION__);
+    else
+      mac_xface->phy_config_dedicated_scell_eNB(Mod_idP,UE_RNTI(Mod_idP,UE_id),sCellToAddMod_r10,1);
+    
+  }
 
-       UE_mac_inst[Mod_idP].BSR_reporting_active = BSR_TRIGGER_NONE;
+#endif
 
-      LOG_D(MAC,"[UE %d]: periodic BSR %d (SF), retx BSR %d (SF)\n",
-            Mod_idP,
-            UE_mac_inst[Mod_idP].scheduling_info.periodicBSR_SF,
-            UE_mac_inst[Mod_idP].scheduling_info.retxBSR_SF);
 
-      UE_mac_inst[Mod_idP].scheduling_info.drx_config     = mac_MainConfig->drx_Config;
-      UE_mac_inst[Mod_idP].scheduling_info.phr_config     = mac_MainConfig->phr_Config;
 
-      if (mac_MainConfig->phr_Config) {
-        UE_mac_inst[Mod_idP].PHR_state = mac_MainConfig->phr_Config->present;
-        UE_mac_inst[Mod_idP].PHR_reconfigured = 1;
-        UE_mac_inst[Mod_idP].scheduling_info.periodicPHR_Timer = mac_MainConfig->phr_Config->choice.setup.periodicPHR_Timer;
-        UE_mac_inst[Mod_idP].scheduling_info.prohibitPHR_Timer = mac_MainConfig->phr_Config->choice.setup.prohibitPHR_Timer;
-        UE_mac_inst[Mod_idP].scheduling_info.PathlossChange = mac_MainConfig->phr_Config->choice.setup.dl_PathlossChange;
-      } else {
-        UE_mac_inst[Mod_idP].PHR_reconfigured = 0;
-        UE_mac_inst[Mod_idP].PHR_state = MAC_MainConfig__phr_Config_PR_setup;
-        UE_mac_inst[Mod_idP].scheduling_info.periodicPHR_Timer = MAC_MainConfig__phr_Config__setup__periodicPHR_Timer_sf20;
-        UE_mac_inst[Mod_idP].scheduling_info.prohibitPHR_Timer = MAC_MainConfig__phr_Config__setup__prohibitPHR_Timer_sf20;
-        UE_mac_inst[Mod_idP].scheduling_info.PathlossChange = MAC_MainConfig__phr_Config__setup__dl_PathlossChange_dB1;
-      }
 
-      UE_mac_inst[Mod_idP].scheduling_info.periodicPHR_SF =  get_sf_perioidicPHR_Timer(UE_mac_inst[Mod_idP].scheduling_info.periodicPHR_Timer);
-      UE_mac_inst[Mod_idP].scheduling_info.prohibitPHR_SF =  get_sf_prohibitPHR_Timer(UE_mac_inst[Mod_idP].scheduling_info.prohibitPHR_Timer);
-      UE_mac_inst[Mod_idP].scheduling_info.PathlossChange_db =  get_db_dl_PathlossChange(UE_mac_inst[Mod_idP].scheduling_info.PathlossChange);
-      UE_mac_inst[Mod_idP].PHR_reporting_active = 0;
-      LOG_D(MAC,"[UE %d] config PHR (%d): periodic %d (SF) prohibit %d (SF)  pathlosschange %d (db) \n",
-            Mod_idP,
-            (mac_MainConfig->phr_Config)?mac_MainConfig->phr_Config->present:-1,
-            UE_mac_inst[Mod_idP].scheduling_info.periodicPHR_SF,
-            UE_mac_inst[Mod_idP].scheduling_info.prohibitPHR_SF,
-            UE_mac_inst[Mod_idP].scheduling_info.PathlossChange_db);
-    }
-  }
-
-  if (physicalConfigDedicated != NULL) {
-    if (eNB_flagP==1) {
-      if (UE_id == -1)
-        LOG_E(MAC,"%s:%d:%s: ERROR, UE_id == -1\n", __FILE__, __LINE__, __FUNCTION__);
-      else
-        mac_xface->phy_config_dedicated_eNB(Mod_idP, CC_idP, UE_RNTI(Mod_idP, UE_id), physicalConfigDedicated);
-    } else {
-      mac_xface->phy_config_dedicated_ue(Mod_idP,0,eNB_index,physicalConfigDedicated);
-      UE_mac_inst[Mod_idP].physicalConfigDedicated=physicalConfigDedicated; // for SR proc
+  if (mbsfn_SubframeConfigList != NULL) {
+    LOG_I(MAC,"[eNB %d][CONFIG] Received %d subframe allocation pattern for MBSFN\n", Mod_idP, mbsfn_SubframeConfigList->list.count);
+    RC.mac[Mod_idP]->common_channels[0].num_sf_allocation_pattern= mbsfn_SubframeConfigList->list.count;
+    
+    for (i=0; i<mbsfn_SubframeConfigList->list.count; i++) {
+      RC.mac[Mod_idP]->common_channels[0].mbsfn_SubframeConfig[i] = mbsfn_SubframeConfigList->list.array[i];
+      LOG_I(MAC, "[eNB %d][CONFIG] MBSFN_SubframeConfig[%d] pattern is  %x\n", Mod_idP, i,
+	    RC.mac[Mod_idP]->common_channels[0].mbsfn_SubframeConfig[i]->subframeAllocation.choice.oneFrame.buf[0]);
     }
+    
+#ifdef Rel10
+    RC.mac[Mod_idP]->common_channels[0].MBMS_flag = MBMS_Flag;
+#endif
   }
 
 #ifdef Rel10
 
-  if (sCellToAddMod_r10 != NULL) {
+  if (mbsfn_AreaInfoList != NULL) {
+      // One eNB could be part of multiple mbsfn syc area, this could change over time so reset each time
+    LOG_I(MAC,"[eNB %d][CONFIG] Received %d MBSFN Area Info\n", Mod_idP, mbsfn_AreaInfoList->list.count);
+    RC.mac[Mod_idP]->common_channels[0].num_active_mbsfn_area = mbsfn_AreaInfoList->list.count;
+    
+    for (i =0; i< mbsfn_AreaInfoList->list.count; i++) {
+      RC.mac[Mod_idP]->common_channels[0].mbsfn_AreaInfo[i] = mbsfn_AreaInfoList->list.array[i];
+      LOG_I(MAC,"[eNB %d][CONFIG] MBSFN_AreaInfo[%d]: MCCH Repetition Period = %ld\n", Mod_idP,i,
+	    RC.mac[Mod_idP]->common_channels[0].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_RepetitionPeriod_r9);
+      mac_xface->phy_config_sib13_eNB(Mod_idP,0,i,RC.mac[Mod_idP]->common_channels[0].mbsfn_AreaInfo[i]->mbsfn_AreaId_r9);
+    }
+  } 
 
-    if (eNB_flagP==1) {
-      if (UE_id == -1)
-        LOG_E(MAC,"%s:%d:%s: ERROR, UE_id == -1\n", __FILE__, __LINE__, __FUNCTION__);
-      else
-        mac_xface->phy_config_dedicated_scell_eNB(Mod_idP,UE_RNTI(Mod_idP,UE_id),sCellToAddMod_r10,1);
-    } else {
+  if (pmch_InfoList != NULL) {
 
-	//#warning "phy_config_dedicated_scell_ue is empty"
-      mac_xface->phy_config_dedicated_scell_ue(Mod_idP,eNB_index,sCellToAddMod_r10,1);
-      UE_mac_inst[Mod_idP].physicalConfigDedicatedSCell_r10 = sCellToAddMod_r10->radioResourceConfigDedicatedSCell_r10->physicalConfigDedicatedSCell_r10; // using SCell index 0
+    //    LOG_I(MAC,"DUY: lcid when entering rrc_mac config_req is %02d\n",(pmch_InfoList->list.array[0]->mbms_SessionInfoList_r9.list.array[0]->logicalChannelIdentity_r9));
+
+    LOG_I(MAC, "[CONFIG] Number of PMCH in this MBSFN Area %d\n", pmch_InfoList->list.count);
+    
+    for (i =0; i< pmch_InfoList->list.count; i++) {
+      RC.mac[Mod_idP]->common_channels[0].pmch_Config[i] = &pmch_InfoList->list.array[i]->pmch_Config_r9;
+      
+      LOG_I(MAC, "[CONFIG] PMCH[%d]: This PMCH stop (sf_AllocEnd_r9) at subframe  %ldth\n", i,
+	    RC.mac[Mod_idP]->common_channels[0].pmch_Config[i]->sf_AllocEnd_r9);
+      LOG_I(MAC, "[CONFIG] PMCH[%d]: mch_Scheduling_Period = %ld\n", i,
+	    RC.mac[Mod_idP]->common_channels[0].pmch_Config[i]->mch_SchedulingPeriod_r9);
+      LOG_I(MAC, "[CONFIG] PMCH[%d]: dataMCS = %ld\n", i,
+	    RC.mac[Mod_idP]->common_channels[0].pmch_Config[i]->dataMCS_r9);
+      
+      // MBMS session info list in each MCH
+      RC.mac[Mod_idP]->common_channels[0].mbms_SessionList[i] = &pmch_InfoList->list.array[i]->mbms_SessionInfoList_r9;
+      LOG_I(MAC, "PMCH[%d] Number of session (MTCH) is: %d\n",i, RC.mac[Mod_idP]->common_channels[0].mbms_SessionList[i]->list.count);
     }
   }
 
 #endif
+#ifdef CBA
 
-  if (eNB_flagP == 0) {
-    if (measObj!= NULL) {
-      if (measObj[0]!= NULL) {
-        UE_mac_inst[Mod_idP].n_adj_cells = measObj[0]->measObject.choice.measObjectEUTRA.cellsToAddModList->list.count;
-        LOG_I(MAC,"Number of adjacent cells %d\n",UE_mac_inst[Mod_idP].n_adj_cells);
-
-        for (i=0; i<UE_mac_inst[Mod_idP].n_adj_cells; i++) {
-          UE_mac_inst[Mod_idP].adj_cell_id[i] = measObj[0]->measObject.choice.measObjectEUTRA.cellsToAddModList->list.array[i]->physCellId;
-          LOG_I(MAC,"Cell %d : Nid_cell %d\n",i,UE_mac_inst[Mod_idP].adj_cell_id[i]);
-        }
-
-        mac_xface->phy_config_meas_ue(Mod_idP,0,eNB_index,UE_mac_inst[Mod_idP].n_adj_cells,UE_mac_inst[Mod_idP].adj_cell_id);
+  if (cba_rnti) {
+    LOG_D(MAC,"[eNB %d] configure CBA RNTI for UE  %d (total active cba groups %d)\n",
+	  Mod_idP, UE_id, num_active_cba_groups);
+    RC.mac[Mod_idP]->common_channels[CC_idP].num_active_cba_groups=num_active_cba_groups;
+    
+    for (i=0; i < num_active_cba_groups; i ++) {
+      if (RC.mac[Mod_idP]->common_channels[CC_idP].cba_rnti[i] != cba_rnti + i) {
+	RC.mac[Mod_idP]->common_channels[CC_idP].cba_rnti[i] = cba_rnti + i;
       }
-
-      /*
-      if (quantityConfig != NULL) {
-      if (quantityConfig[0] != NULL) {
-      UE_mac_inst[Mod_idP].quantityConfig = quantityConfig[0];
-      LOG_I(MAC,"UE %d configured filterCoeff.",UE_mac_inst[Mod_idP].crnti);
-      mac_xface->phy_config_meas_ue
+      
+      //only configure UE ids up to num_active_cba_groups
+      //we use them as candidates for the transmission of dci format0)
+      if (UE_id%num_active_cba_groups == i) {
+	mac_xface->phy_config_cba_rnti(Mod_idP,CC_idP,eNB_flagP,UE_id,cba_rnti + i,i,num_active_cba_groups );
+	LOG_D(MAC,"[eNB %d] configure CBA groups %d with RNTI %x for UE  %d (total active cba groups %d)\n",
+	      Mod_idP, i, RC.mac[Mod_idP]->common_channels[CC_idP].cba_rnti[i],UE_id, num_active_cba_groups);
       }
-      }
-       */
     }
   }
+  
 
-  if (eNB_flagP==0) {
-    if(mobilityControlInfo != NULL) {
-
-      LOG_D(MAC,"[UE%d] MAC Reset procedure triggered by RRC eNB %d \n",Mod_idP,eNB_index);
-      ue_mac_reset(Mod_idP,eNB_index);
-
-      if(mobilityControlInfo->radioResourceConfigCommon.rach_ConfigCommon) {
-        memcpy((void *)&UE_mac_inst[Mod_idP].radioResourceConfigCommon->rach_ConfigCommon,
-               (void *)mobilityControlInfo->radioResourceConfigCommon.rach_ConfigCommon,
-               sizeof(RACH_ConfigCommon_t));
-      }
-
-      memcpy((void *)&UE_mac_inst[Mod_idP].radioResourceConfigCommon->prach_Config.prach_ConfigInfo,
-             (void *)mobilityControlInfo->radioResourceConfigCommon.prach_Config.prach_ConfigInfo,
-             sizeof(PRACH_ConfigInfo_t));
-      UE_mac_inst[Mod_idP].radioResourceConfigCommon->prach_Config.rootSequenceIndex = mobilityControlInfo->radioResourceConfigCommon.prach_Config.rootSequenceIndex;
-
-      if(mobilityControlInfo->radioResourceConfigCommon.pdsch_ConfigCommon) {
-        memcpy((void *)&UE_mac_inst[Mod_idP].radioResourceConfigCommon->pdsch_ConfigCommon,
-               (void *)mobilityControlInfo->radioResourceConfigCommon.pdsch_ConfigCommon,
-               sizeof(PDSCH_ConfigCommon_t));
-      }
+#endif
+  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_MAC_CONFIG, VCD_FUNCTION_OUT);
 
-      // not a pointer: mobilityControlInfo->radioResourceConfigCommon.pusch_ConfigCommon
-      memcpy((void *)&UE_mac_inst[Mod_idP].radioResourceConfigCommon->pusch_ConfigCommon,
-             (void *)&mobilityControlInfo->radioResourceConfigCommon.pusch_ConfigCommon,
-             sizeof(PUSCH_ConfigCommon_t));
+  return(0);			   
 
-      if(mobilityControlInfo->radioResourceConfigCommon.phich_Config) {
-        /* memcpy((void *)&UE_mac_inst[Mod_idP].radioResourceConfigCommon->phich_Config,
-        (void *)mobilityControlInfo->radioResourceConfigCommon.phich_Config,
-        sizeof(PHICH_Config_t)); */
-      }
+}
+int
+rrc_mac_config_req_ue(
+  module_id_t                      Mod_idP,
+  int                              CC_idP,
+  uint8_t                          eNB_index,
+  RadioResourceConfigCommonSIB_t  *radioResourceConfigCommon,
+  struct PhysicalConfigDedicated  *physicalConfigDedicated,
+#ifdef Rel10
+  SCellToAddMod_r10_t *sCellToAddMod_r10,
+  //struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10,
+#endif
+  MeasObjectToAddMod_t           **measObj,
+  MAC_MainConfig_t                *mac_MainConfig,
+  long                             logicalChannelIdentity,
+  LogicalChannelConfig_t          *logicalChannelConfig,
+  MeasGapConfig_t                 *measGapConfig,
+  TDD_Config_t                    *tdd_Config,
+  MobilityControlInfo_t           *mobilityControlInfo,
+  uint8_t                              *SIwindowsize,
+  uint16_t                             *SIperiod,
+  ARFCN_ValueEUTRA_t              *ul_CarrierFreq,
+  long                            *ul_Bandwidth,
+  AdditionalSpectrumEmission_t    *additionalSpectrumEmission,
+  struct MBSFN_SubframeConfigList *mbsfn_SubframeConfigList
+#ifdef Rel10
+  ,uint8_t                              MBMS_Flag,
+  MBSFN_AreaInfoList_r9_t         *mbsfn_AreaInfoList,
+  PMCH_InfoList_r9_t              *pmch_InfoList
+#endif
+#ifdef CBA
+  ,uint8_t                              num_active_cba_groups,
+  uint16_t                              cba_rnti
+#endif
+                      )
+{
 
-      if(mobilityControlInfo->radioResourceConfigCommon.pucch_ConfigCommon) {
-        memcpy((void *)&UE_mac_inst[Mod_idP].radioResourceConfigCommon->pucch_ConfigCommon,
-               (void *)mobilityControlInfo->radioResourceConfigCommon.pucch_ConfigCommon,
-               sizeof(PUCCH_ConfigCommon_t));
-      }
+  int i;
 
-      if(mobilityControlInfo->radioResourceConfigCommon.soundingRS_UL_ConfigCommon) {
-        memcpy((void *)&UE_mac_inst[Mod_idP].radioResourceConfigCommon->soundingRS_UL_ConfigCommon,
-               (void *)mobilityControlInfo->radioResourceConfigCommon.soundingRS_UL_ConfigCommon,
-               sizeof(SoundingRS_UL_ConfigCommon_t));
-      }
+  int UE_id = -1;
+ 
+  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_MAC_CONFIG, VCD_FUNCTION_IN);
 
-      if(mobilityControlInfo->radioResourceConfigCommon.uplinkPowerControlCommon) {
-        memcpy((void *)&UE_mac_inst[Mod_idP].radioResourceConfigCommon->uplinkPowerControlCommon,
-               (void *)mobilityControlInfo->radioResourceConfigCommon.uplinkPowerControlCommon,
-               sizeof(UplinkPowerControlCommon_t));
-      }
+  LOG_I(MAC,"[CONFIG][UE %d] Configuring MAC/PHY from eNB %d\n",Mod_idP,eNB_index);
+  
+  if (tdd_Config != NULL) {
+    UE_mac_inst[Mod_idP].tdd_Config = tdd_Config;
+  }
+ 
 
-      //configure antennaInfoCommon somewhere here..
-      if(mobilityControlInfo->radioResourceConfigCommon.p_Max) {
-        //to be configured
-      }
+  if (tdd_Config && SIwindowsize && SIperiod) {
+    mac_xface->phy_config_sib1_ue(Mod_idP,0,eNB_index,tdd_Config,*SIwindowsize,*SIperiod);
+  }
 
-      if(mobilityControlInfo->radioResourceConfigCommon.tdd_Config) {
-        UE_mac_inst[Mod_idP].tdd_Config = mobilityControlInfo->radioResourceConfigCommon.tdd_Config;
-      }
+  if (radioResourceConfigCommon!=NULL) {
+    UE_mac_inst[Mod_idP].radioResourceConfigCommon = radioResourceConfigCommon;
+    mac_xface->phy_config_sib2_ue(Mod_idP,0,eNB_index,radioResourceConfigCommon,ul_CarrierFreq,ul_Bandwidth,additionalSpectrumEmission,mbsfn_SubframeConfigList);
+  }
 
-      if(mobilityControlInfo->radioResourceConfigCommon.ul_CyclicPrefixLength) {
-        memcpy((void *)&UE_mac_inst[Mod_idP].radioResourceConfigCommon->ul_CyclicPrefixLength,
-               (void *)mobilityControlInfo->radioResourceConfigCommon.ul_CyclicPrefixLength,
-               sizeof(UL_CyclicPrefixLength_t));
+  // SRB2_lchan_config->choice.explicitValue.ul_SpecificParameters->logicalChannelGroup
+  if (logicalChannelConfig!= NULL) {
+    LOG_I(MAC,"[CONFIG][UE %d] Applying RRC logicalChannelConfig from eNB%d\n",Mod_idP,eNB_index);
+    UE_mac_inst[Mod_idP].logicalChannelConfig[logicalChannelIdentity]=logicalChannelConfig;
+    UE_mac_inst[Mod_idP].scheduling_info.Bj[logicalChannelIdentity]=0; // initilize the bucket for this lcid
+    
+    if (logicalChannelConfig->ul_SpecificParameters) {
+      UE_mac_inst[Mod_idP].scheduling_info.bucket_size[logicalChannelIdentity]=logicalChannelConfig->ul_SpecificParameters->prioritisedBitRate *
+	logicalChannelConfig->ul_SpecificParameters->bucketSizeDuration; // set the max bucket size
+      if (logicalChannelConfig->ul_SpecificParameters->logicalChannelGroup != NULL) {
+	UE_mac_inst[Mod_idP].scheduling_info.LCGID[logicalChannelIdentity]=*logicalChannelConfig->ul_SpecificParameters->logicalChannelGroup;
+	LOG_D(MAC,"[CONFIG][UE %d] LCID %ld is attached to the LCGID %ld\n",Mod_idP,logicalChannelIdentity,*logicalChannelConfig->ul_SpecificParameters->logicalChannelGroup);
       }
-
-      // store the previous rnti in case of failure, and set thenew rnti
-      UE_mac_inst[Mod_idP].crnti_before_ho = UE_mac_inst[Mod_idP].crnti;
-      UE_mac_inst[Mod_idP].crnti = ((mobilityControlInfo->newUE_Identity.buf[0])|(mobilityControlInfo->newUE_Identity.buf[1]<<8));
-      LOG_I(MAC,"[UE %d] Received new identity %x from %d\n", Mod_idP, UE_mac_inst[Mod_idP].crnti, eNB_index);
-      UE_mac_inst[Mod_idP].rach_ConfigDedicated = malloc(sizeof(*mobilityControlInfo->rach_ConfigDedicated));
-
-      if (mobilityControlInfo->rach_ConfigDedicated) {
-        memcpy((void*)UE_mac_inst[Mod_idP].rach_ConfigDedicated,
-               (void*)mobilityControlInfo->rach_ConfigDedicated,
-               sizeof(*mobilityControlInfo->rach_ConfigDedicated));
+      else {
+	UE_mac_inst[Mod_idP].scheduling_info.LCGID[logicalChannelIdentity] = MAX_NUM_LCGID;
       }
-
-      mac_xface->phy_config_afterHO_ue(Mod_idP,0,eNB_index,mobilityControlInfo,0);
+      UE_mac_inst[Mod_idP].scheduling_info.LCID_buffer_remain[logicalChannelIdentity] = 0;
+    } else {
+      LOG_E(MAC,"[CONFIG][UE %d] LCID %ld NULL ul_SpecificParameters\n",Mod_idP,logicalChannelIdentity);
+      mac_xface->macphy_exit("NULL ul_SpecificParameters");
     }
   }
 
-  if (mbsfn_SubframeConfigList != NULL) {
-    if (eNB_flagP == 1) {
-      LOG_I(MAC,"[eNB %d][CONFIG] Received %d subframe allocation pattern for MBSFN\n", Mod_idP, mbsfn_SubframeConfigList->list.count);
-      eNB_mac_inst[Mod_idP].common_channels[0].num_sf_allocation_pattern= mbsfn_SubframeConfigList->list.count;
-
-      for (i=0; i<mbsfn_SubframeConfigList->list.count; i++) {
-        eNB_mac_inst[Mod_idP].common_channels[0].mbsfn_SubframeConfig[i] = mbsfn_SubframeConfigList->list.array[i];
-        LOG_I(MAC, "[eNB %d][CONFIG] MBSFN_SubframeConfig[%d] pattern is  %x\n", Mod_idP, i,
-              eNB_mac_inst[Mod_idP].common_channels[0].mbsfn_SubframeConfig[i]->subframeAllocation.choice.oneFrame.buf[0]);
+  if (mac_MainConfig != NULL) {
+    LOG_I(MAC,"[CONFIG][UE%d] Applying RRC macMainConfig from eNB%d\n",Mod_idP,eNB_index);
+    UE_mac_inst[Mod_idP].macConfig=mac_MainConfig;
+    UE_mac_inst[Mod_idP].measGapConfig=measGapConfig;
+    
+    if (mac_MainConfig->ul_SCH_Config) {
+      
+      if (mac_MainConfig->ul_SCH_Config->periodicBSR_Timer) {
+	UE_mac_inst[Mod_idP].scheduling_info.periodicBSR_Timer = (uint16_t) *mac_MainConfig->ul_SCH_Config->periodicBSR_Timer;
+      } else {
+	UE_mac_inst[Mod_idP].scheduling_info.periodicBSR_Timer = (uint16_t) MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_infinity;
       }
-
-#ifdef Rel10
-      eNB_mac_inst[Mod_idP].common_channels[0].MBMS_flag = MBMS_Flag;
-#endif
-    } else { // UE
-      LOG_I(MAC,"[UE %d][CONFIG] Received %d subframe allocation pattern for MBSFN\n", Mod_idP, mbsfn_SubframeConfigList->list.count);
-      UE_mac_inst[Mod_idP].num_sf_allocation_pattern= mbsfn_SubframeConfigList->list.count;
-
-      for (i=0; i<mbsfn_SubframeConfigList->list.count; i++) {
-        LOG_I(MAC, "[UE %d] Configuring MBSFN_SubframeConfig %d from received SIB2 \n", Mod_idP, i);
-        UE_mac_inst[Mod_idP].mbsfn_SubframeConfig[i] = mbsfn_SubframeConfigList->list.array[i];
-        //  LOG_I("[UE %d] MBSFN_SubframeConfig[%d] pattern is  %ld\n", Mod_idP,
-        //    UE_mac_inst[Mod_idP].mbsfn_SubframeConfig[i]->subframeAllocation.choice.oneFrame.buf[0]);
+      
+      if (mac_MainConfig->ul_SCH_Config->maxHARQ_Tx) {
+	UE_mac_inst[Mod_idP].scheduling_info.maxHARQ_Tx     = (uint16_t) *mac_MainConfig->ul_SCH_Config->maxHARQ_Tx;
+      } else {
+	UE_mac_inst[Mod_idP].scheduling_info.maxHARQ_Tx     = (uint16_t) MAC_MainConfig__ul_SCH_Config__maxHARQ_Tx_n5;
+      }
+      mac_xface->phy_config_harq_ue(Mod_idP,0,eNB_index,UE_mac_inst[Mod_idP].scheduling_info.maxHARQ_Tx);
+      
+      if (mac_MainConfig->ul_SCH_Config->retxBSR_Timer) {
+	UE_mac_inst[Mod_idP].scheduling_info.retxBSR_Timer     = (uint16_t) mac_MainConfig->ul_SCH_Config->retxBSR_Timer;
+      } else {
+	UE_mac_inst[Mod_idP].scheduling_info.retxBSR_Timer     = (uint16_t)MAC_MainConfig__ul_SCH_Config__retxBSR_Timer_sf2560;
       }
     }
-  }
 
 #ifdef Rel10
-
-  if (mbsfn_AreaInfoList != NULL) {
-    if (eNB_flagP == 1) {
-      // One eNB could be part of multiple mbsfn syc area, this could change over time so reset each time
-      LOG_I(MAC,"[eNB %d][CONFIG] Received %d MBSFN Area Info\n", Mod_idP, mbsfn_AreaInfoList->list.count);
-      eNB_mac_inst[Mod_idP].common_channels[0].num_active_mbsfn_area = mbsfn_AreaInfoList->list.count;
-
-      for (i =0; i< mbsfn_AreaInfoList->list.count; i++) {
-        eNB_mac_inst[Mod_idP].common_channels[0].mbsfn_AreaInfo[i] = mbsfn_AreaInfoList->list.array[i];
-        LOG_I(MAC,"[eNB %d][CONFIG] MBSFN_AreaInfo[%d]: MCCH Repetition Period = %ld\n", Mod_idP,i,
-              eNB_mac_inst[Mod_idP].common_channels[0].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_RepetitionPeriod_r9);
-        mac_xface->phy_config_sib13_eNB(Mod_idP,0,i,eNB_mac_inst[Mod_idP].common_channels[0].mbsfn_AreaInfo[i]->mbsfn_AreaId_r9);
+    
+    if (mac_MainConfig->ext1 && mac_MainConfig->ext1->sr_ProhibitTimer_r9) {
+      UE_mac_inst[Mod_idP].scheduling_info.sr_ProhibitTimer  = (uint16_t) *mac_MainConfig->ext1->sr_ProhibitTimer_r9;
+    } else {
+      UE_mac_inst[Mod_idP].scheduling_info.sr_ProhibitTimer  = 0;
+    }
+    
+    if (mac_MainConfig->ext2 && mac_MainConfig->ext2->mac_MainConfig_v1020) {
+      if (mac_MainConfig->ext2->mac_MainConfig_v1020->extendedBSR_Sizes_r10) {
+	UE_mac_inst[Mod_idP].scheduling_info.extendedBSR_Sizes_r10 = (uint16_t) *mac_MainConfig->ext2->mac_MainConfig_v1020->extendedBSR_Sizes_r10;
+      } else {
+	UE_mac_inst[Mod_idP].scheduling_info.extendedBSR_Sizes_r10 = (uint16_t)0;
       }
-    } else { // UE
-      LOG_I(MAC,"[UE %d][CONFIG] Received %d MBSFN Area Info\n", Mod_idP, mbsfn_AreaInfoList->list.count);
-      UE_mac_inst[Mod_idP].num_active_mbsfn_area = mbsfn_AreaInfoList->list.count;
-
-      for (i =0; i< mbsfn_AreaInfoList->list.count; i++) {
-        UE_mac_inst[Mod_idP].mbsfn_AreaInfo[i] = mbsfn_AreaInfoList->list.array[i];
-        LOG_I(MAC,"[UE %d] MBSFN_AreaInfo[%d]: MCCH Repetition Period = %ld\n",Mod_idP, i,
-              UE_mac_inst[Mod_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_RepetitionPeriod_r9);
-        mac_xface->phy_config_sib13_ue(Mod_idP,0,eNB_index,i,UE_mac_inst[Mod_idP].mbsfn_AreaInfo[i]->mbsfn_AreaId_r9);
+      if (mac_MainConfig->ext2->mac_MainConfig_v1020->extendedPHR_r10) {
+	UE_mac_inst[Mod_idP].scheduling_info.extendedPHR_r10 = (uint16_t) *mac_MainConfig->ext2->mac_MainConfig_v1020->extendedPHR_r10;
+      } else {
+	UE_mac_inst[Mod_idP].scheduling_info.extendedPHR_r10 = (uint16_t)0;
       }
+    } else {
+      UE_mac_inst[Mod_idP].scheduling_info.extendedBSR_Sizes_r10 = (uint16_t)0;
+      UE_mac_inst[Mod_idP].scheduling_info.extendedPHR_r10 = (uint16_t)0;
     }
+#endif
+    UE_mac_inst[Mod_idP].scheduling_info.periodicBSR_SF  = MAC_UE_BSR_TIMER_NOT_RUNNING;
+    UE_mac_inst[Mod_idP].scheduling_info.retxBSR_SF     = MAC_UE_BSR_TIMER_NOT_RUNNING;
+    
+    UE_mac_inst[Mod_idP].BSR_reporting_active = BSR_TRIGGER_NONE;
+    
+    LOG_D(MAC,"[UE %d]: periodic BSR %d (SF), retx BSR %d (SF)\n",
+	  Mod_idP,
+	  UE_mac_inst[Mod_idP].scheduling_info.periodicBSR_SF,
+	  UE_mac_inst[Mod_idP].scheduling_info.retxBSR_SF);
+    
+    UE_mac_inst[Mod_idP].scheduling_info.drx_config     = mac_MainConfig->drx_Config;
+    UE_mac_inst[Mod_idP].scheduling_info.phr_config     = mac_MainConfig->phr_Config;
+    
+    if (mac_MainConfig->phr_Config) {
+      UE_mac_inst[Mod_idP].PHR_state = mac_MainConfig->phr_Config->present;
+      UE_mac_inst[Mod_idP].PHR_reconfigured = 1;
+      UE_mac_inst[Mod_idP].scheduling_info.periodicPHR_Timer = mac_MainConfig->phr_Config->choice.setup.periodicPHR_Timer;
+      UE_mac_inst[Mod_idP].scheduling_info.prohibitPHR_Timer = mac_MainConfig->phr_Config->choice.setup.prohibitPHR_Timer;
+      UE_mac_inst[Mod_idP].scheduling_info.PathlossChange = mac_MainConfig->phr_Config->choice.setup.dl_PathlossChange;
+    } else {
+      UE_mac_inst[Mod_idP].PHR_reconfigured = 0;
+      UE_mac_inst[Mod_idP].PHR_state = MAC_MainConfig__phr_Config_PR_setup;
+      UE_mac_inst[Mod_idP].scheduling_info.periodicPHR_Timer = MAC_MainConfig__phr_Config__setup__periodicPHR_Timer_sf20;
+      UE_mac_inst[Mod_idP].scheduling_info.prohibitPHR_Timer = MAC_MainConfig__phr_Config__setup__prohibitPHR_Timer_sf20;
+      UE_mac_inst[Mod_idP].scheduling_info.PathlossChange = MAC_MainConfig__phr_Config__setup__dl_PathlossChange_dB1;
+    }
+    
+    UE_mac_inst[Mod_idP].scheduling_info.periodicPHR_SF =  get_sf_perioidicPHR_Timer(UE_mac_inst[Mod_idP].scheduling_info.periodicPHR_Timer);
+    UE_mac_inst[Mod_idP].scheduling_info.prohibitPHR_SF =  get_sf_prohibitPHR_Timer(UE_mac_inst[Mod_idP].scheduling_info.prohibitPHR_Timer);
+    UE_mac_inst[Mod_idP].scheduling_info.PathlossChange_db =  get_db_dl_PathlossChange(UE_mac_inst[Mod_idP].scheduling_info.PathlossChange);
+    UE_mac_inst[Mod_idP].PHR_reporting_active = 0;
+    LOG_D(MAC,"[UE %d] config PHR (%d): periodic %d (SF) prohibit %d (SF)  pathlosschange %d (db) \n",
+	  Mod_idP,
+	  (mac_MainConfig->phr_Config)?mac_MainConfig->phr_Config->present:-1,
+	  UE_mac_inst[Mod_idP].scheduling_info.periodicPHR_SF,
+	  UE_mac_inst[Mod_idP].scheduling_info.prohibitPHR_SF,
+	  UE_mac_inst[Mod_idP].scheduling_info.PathlossChange_db);
   }
 
 
-  if (pmch_InfoList != NULL) {
+  if (physicalConfigDedicated != NULL) {
+    mac_xface->phy_config_dedicated_ue(Mod_idP,0,eNB_index,physicalConfigDedicated);
+    UE_mac_inst[Mod_idP].physicalConfigDedicated=physicalConfigDedicated; // for SR proc
+  }
 
-    //    LOG_I(MAC,"DUY: lcid when entering rrc_mac config_req is %02d\n",(pmch_InfoList->list.array[0]->mbms_SessionInfoList_r9.list.array[0]->logicalChannelIdentity_r9));
+#ifdef Rel10
 
-    if (eNB_flagP == 1) {
+  if (sCellToAddMod_r10 != NULL) {
 
-      LOG_I(MAC, "[CONFIG] Number of PMCH in this MBSFN Area %d\n", pmch_InfoList->list.count);
 
-      for (i =0; i< pmch_InfoList->list.count; i++) {
-        eNB_mac_inst[Mod_idP].common_channels[0].pmch_Config[i] = &pmch_InfoList->list.array[i]->pmch_Config_r9;
+    mac_xface->phy_config_dedicated_scell_ue(Mod_idP,eNB_index,sCellToAddMod_r10,1);
+    UE_mac_inst[Mod_idP].physicalConfigDedicatedSCell_r10 = sCellToAddMod_r10->radioResourceConfigDedicatedSCell_r10->physicalConfigDedicatedSCell_r10; // using SCell index 0
+  }
+  
 
-        LOG_I(MAC, "[CONFIG] PMCH[%d]: This PMCH stop (sf_AllocEnd_r9) at subframe  %ldth\n", i,
-              eNB_mac_inst[Mod_idP].common_channels[0].pmch_Config[i]->sf_AllocEnd_r9);
-        LOG_I(MAC, "[CONFIG] PMCH[%d]: mch_Scheduling_Period = %ld\n", i,
-              eNB_mac_inst[Mod_idP].common_channels[0].pmch_Config[i]->mch_SchedulingPeriod_r9);
-        LOG_I(MAC, "[CONFIG] PMCH[%d]: dataMCS = %ld\n", i,
-              eNB_mac_inst[Mod_idP].common_channels[0].pmch_Config[i]->dataMCS_r9);
+#endif
 
-        // MBMS session info list in each MCH
-        eNB_mac_inst[Mod_idP].common_channels[0].mbms_SessionList[i] = &pmch_InfoList->list.array[i]->mbms_SessionInfoList_r9;
-        LOG_I(MAC, "PMCH[%d] Number of session (MTCH) is: %d\n",i, eNB_mac_inst[Mod_idP].common_channels[0].mbms_SessionList[i]->list.count);
+  if (measObj!= NULL) {
+    if (measObj[0]!= NULL) {
+      UE_mac_inst[Mod_idP].n_adj_cells = measObj[0]->measObject.choice.measObjectEUTRA.cellsToAddModList->list.count;
+      LOG_I(MAC,"Number of adjacent cells %d\n",UE_mac_inst[Mod_idP].n_adj_cells);
+      
+      for (i=0; i<UE_mac_inst[Mod_idP].n_adj_cells; i++) {
+	UE_mac_inst[Mod_idP].adj_cell_id[i] = measObj[0]->measObject.choice.measObjectEUTRA.cellsToAddModList->list.array[i]->physCellId;
+	LOG_I(MAC,"Cell %d : Nid_cell %d\n",i,UE_mac_inst[Mod_idP].adj_cell_id[i]);
+      }
+      
+      mac_xface->phy_config_meas_ue(Mod_idP,0,eNB_index,UE_mac_inst[Mod_idP].n_adj_cells,UE_mac_inst[Mod_idP].adj_cell_id);
+    }
+    
+    /*
+      if (quantityConfig != NULL) {
+      if (quantityConfig[0] != NULL) {
+      UE_mac_inst[Mod_idP].quantityConfig = quantityConfig[0];
+      LOG_I(MAC,"UE %d configured filterCoeff.",UE_mac_inst[Mod_idP].crnti);
+      mac_xface->phy_config_meas_ue
       }
-    } else { // UE
-      LOG_I(MAC, "[UE %d] Configuring PMCH_config from MCCH MESSAGE \n",Mod_idP);
-
-      for (i =0; i< pmch_InfoList->list.count; i++) {
-        UE_mac_inst[Mod_idP].pmch_Config[i] = &pmch_InfoList->list.array[i]->pmch_Config_r9;
-        LOG_I(MAC, "[UE %d] PMCH[%d]: MCH_Scheduling_Period = %ld\n", Mod_idP, i,
-              UE_mac_inst[Mod_idP].pmch_Config[i]->mch_SchedulingPeriod_r9);
       }
+    */
+  }
+
 
-      UE_mac_inst[Mod_idP].mcch_status = 1;
+  if(mobilityControlInfo != NULL) {
+    
+    LOG_D(MAC,"[UE%d] MAC Reset procedure triggered by RRC eNB %d \n",Mod_idP,eNB_index);
+    ue_mac_reset(Mod_idP,eNB_index);
+    
+    if(mobilityControlInfo->radioResourceConfigCommon.rach_ConfigCommon) {
+      memcpy((void *)&UE_mac_inst[Mod_idP].radioResourceConfigCommon->rach_ConfigCommon,
+	     (void *)mobilityControlInfo->radioResourceConfigCommon.rach_ConfigCommon,
+	     sizeof(RACH_ConfigCommon_t));
+    }
+    
+    memcpy((void *)&UE_mac_inst[Mod_idP].radioResourceConfigCommon->prach_Config.prach_ConfigInfo,
+	   (void *)mobilityControlInfo->radioResourceConfigCommon.prach_Config.prach_ConfigInfo,
+	   sizeof(PRACH_ConfigInfo_t));
+    UE_mac_inst[Mod_idP].radioResourceConfigCommon->prach_Config.rootSequenceIndex = mobilityControlInfo->radioResourceConfigCommon.prach_Config.rootSequenceIndex;
+    
+    if(mobilityControlInfo->radioResourceConfigCommon.pdsch_ConfigCommon) {
+      memcpy((void *)&UE_mac_inst[Mod_idP].radioResourceConfigCommon->pdsch_ConfigCommon,
+	     (void *)mobilityControlInfo->radioResourceConfigCommon.pdsch_ConfigCommon,
+	     sizeof(PDSCH_ConfigCommon_t));
+    }
+    
+    // not a pointer: mobilityControlInfo->radioResourceConfigCommon.pusch_ConfigCommon
+    memcpy((void *)&UE_mac_inst[Mod_idP].radioResourceConfigCommon->pusch_ConfigCommon,
+	   (void *)&mobilityControlInfo->radioResourceConfigCommon.pusch_ConfigCommon,
+	   sizeof(PUSCH_ConfigCommon_t));
+    
+    if(mobilityControlInfo->radioResourceConfigCommon.phich_Config) {
+      /* memcpy((void *)&UE_mac_inst[Mod_idP].radioResourceConfigCommon->phich_Config,
+	 (void *)mobilityControlInfo->radioResourceConfigCommon.phich_Config,
+	 sizeof(PHICH_Config_t)); */
+    }
+    
+    if(mobilityControlInfo->radioResourceConfigCommon.pucch_ConfigCommon) {
+      memcpy((void *)&UE_mac_inst[Mod_idP].radioResourceConfigCommon->pucch_ConfigCommon,
+	     (void *)mobilityControlInfo->radioResourceConfigCommon.pucch_ConfigCommon,
+	     sizeof(PUCCH_ConfigCommon_t));
+    }
+    
+    if(mobilityControlInfo->radioResourceConfigCommon.soundingRS_UL_ConfigCommon) {
+      memcpy((void *)&UE_mac_inst[Mod_idP].radioResourceConfigCommon->soundingRS_UL_ConfigCommon,
+	     (void *)mobilityControlInfo->radioResourceConfigCommon.soundingRS_UL_ConfigCommon,
+	     sizeof(SoundingRS_UL_ConfigCommon_t));
+    }
+    
+    if(mobilityControlInfo->radioResourceConfigCommon.uplinkPowerControlCommon) {
+      memcpy((void *)&UE_mac_inst[Mod_idP].radioResourceConfigCommon->uplinkPowerControlCommon,
+	     (void *)mobilityControlInfo->radioResourceConfigCommon.uplinkPowerControlCommon,
+	     sizeof(UplinkPowerControlCommon_t));
+    }
+    
+    //configure antennaInfoCommon somewhere here..
+    if(mobilityControlInfo->radioResourceConfigCommon.p_Max) {
+      //to be configured
     }
+    
+    if(mobilityControlInfo->radioResourceConfigCommon.tdd_Config) {
+      UE_mac_inst[Mod_idP].tdd_Config = mobilityControlInfo->radioResourceConfigCommon.tdd_Config;
+    }
+    
+    if(mobilityControlInfo->radioResourceConfigCommon.ul_CyclicPrefixLength) {
+      memcpy((void *)&UE_mac_inst[Mod_idP].radioResourceConfigCommon->ul_CyclicPrefixLength,
+	     (void *)mobilityControlInfo->radioResourceConfigCommon.ul_CyclicPrefixLength,
+	     sizeof(UL_CyclicPrefixLength_t));
+    }
+    
+    // store the previous rnti in case of failure, and set thenew rnti
+    UE_mac_inst[Mod_idP].crnti_before_ho = UE_mac_inst[Mod_idP].crnti;
+    UE_mac_inst[Mod_idP].crnti = ((mobilityControlInfo->newUE_Identity.buf[0])|(mobilityControlInfo->newUE_Identity.buf[1]<<8));
+    LOG_I(MAC,"[UE %d] Received new identity %x from %d\n", Mod_idP, UE_mac_inst[Mod_idP].crnti, eNB_index);
+    UE_mac_inst[Mod_idP].rach_ConfigDedicated = malloc(sizeof(*mobilityControlInfo->rach_ConfigDedicated));
+    
+    if (mobilityControlInfo->rach_ConfigDedicated) {
+      memcpy((void*)UE_mac_inst[Mod_idP].rach_ConfigDedicated,
+	     (void*)mobilityControlInfo->rach_ConfigDedicated,
+	     sizeof(*mobilityControlInfo->rach_ConfigDedicated));
+    }
+    
+    mac_xface->phy_config_afterHO_ue(Mod_idP,0,eNB_index,mobilityControlInfo,0);
   }
 
-#endif
-#ifdef CBA
 
-  if (eNB_flagP == 0) {
-    if (cba_rnti) {
-      UE_mac_inst[Mod_idP].cba_rnti[num_active_cba_groups-1] = cba_rnti;
-      LOG_D(MAC,"[UE %d] configure CBA group %d RNTI %x for eNB %d (total active cba group %d)\n",
-            Mod_idP,Mod_idP%num_active_cba_groups, cba_rnti,eNB_index,num_active_cba_groups);
-      mac_xface->phy_config_cba_rnti(Mod_idP,CC_idP,eNB_flagP,eNB_index,cba_rnti,num_active_cba_groups-1, num_active_cba_groups);
+  if (mbsfn_SubframeConfigList != NULL) {
+    LOG_I(MAC,"[UE %d][CONFIG] Received %d subframe allocation pattern for MBSFN\n", Mod_idP, mbsfn_SubframeConfigList->list.count);
+    UE_mac_inst[Mod_idP].num_sf_allocation_pattern= mbsfn_SubframeConfigList->list.count;
+    
+    for (i=0; i<mbsfn_SubframeConfigList->list.count; i++) {
+      LOG_I(MAC, "[UE %d] Configuring MBSFN_SubframeConfig %d from received SIB2 \n", Mod_idP, i);
+      UE_mac_inst[Mod_idP].mbsfn_SubframeConfig[i] = mbsfn_SubframeConfigList->list.array[i];
+      //  LOG_I("[UE %d] MBSFN_SubframeConfig[%d] pattern is  %ld\n", Mod_idP,
+      //    UE_mac_inst[Mod_idP].mbsfn_SubframeConfig[i]->subframeAllocation.choice.oneFrame.buf[0]);
     }
-  } else {
-    if (cba_rnti) {
-      LOG_D(MAC,"[eNB %d] configure CBA RNTI for UE  %d (total active cba groups %d)\n",
-            Mod_idP, UE_id, num_active_cba_groups);
-      eNB_mac_inst[Mod_idP].common_channels[CC_idP].num_active_cba_groups=num_active_cba_groups;
-
-      for (i=0; i < num_active_cba_groups; i ++) {
-        if (eNB_mac_inst[Mod_idP].common_channels[CC_idP].cba_rnti[i] != cba_rnti + i) {
-          eNB_mac_inst[Mod_idP].common_channels[CC_idP].cba_rnti[i] = cba_rnti + i;
-        }
-
-        //only configure UE ids up to num_active_cba_groups
-        //we use them as candidates for the transmission of dci format0)
-        if (UE_id%num_active_cba_groups == i) {
-          mac_xface->phy_config_cba_rnti(Mod_idP,CC_idP,eNB_flagP,UE_id,cba_rnti + i,i,num_active_cba_groups );
-          LOG_D(MAC,"[eNB %d] configure CBA groups %d with RNTI %x for UE  %d (total active cba groups %d)\n",
-                Mod_idP, i, eNB_mac_inst[Mod_idP].common_channels[CC_idP].cba_rnti[i],UE_id, num_active_cba_groups);
-        }
-      }
+  }
+  
+
+#ifdef Rel10
+
+  if (mbsfn_AreaInfoList != NULL) {
+    LOG_I(MAC,"[UE %d][CONFIG] Received %d MBSFN Area Info\n", Mod_idP, mbsfn_AreaInfoList->list.count);
+    UE_mac_inst[Mod_idP].num_active_mbsfn_area = mbsfn_AreaInfoList->list.count;
+    
+    for (i =0; i< mbsfn_AreaInfoList->list.count; i++) {
+      UE_mac_inst[Mod_idP].mbsfn_AreaInfo[i] = mbsfn_AreaInfoList->list.array[i];
+      LOG_I(MAC,"[UE %d] MBSFN_AreaInfo[%d]: MCCH Repetition Period = %ld\n",Mod_idP, i,
+	    UE_mac_inst[Mod_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_RepetitionPeriod_r9);
+      mac_xface->phy_config_sib13_ue(Mod_idP,0,eNB_index,i,UE_mac_inst[Mod_idP].mbsfn_AreaInfo[i]->mbsfn_AreaId_r9);
+    }
+  }
+  
+  if (pmch_InfoList != NULL) {
+    
+    //    LOG_I(MAC,"DUY: lcid when entering rrc_mac config_req is %02d\n",(pmch_InfoList->list.array[0]->mbms_SessionInfoList_r9.list.array[0]->logicalChannelIdentity_r9));
+
+    LOG_I(MAC, "[UE %d] Configuring PMCH_config from MCCH MESSAGE \n",Mod_idP);
+    
+    for (i =0; i< pmch_InfoList->list.count; i++) {
+      UE_mac_inst[Mod_idP].pmch_Config[i] = &pmch_InfoList->list.array[i]->pmch_Config_r9;
+      LOG_I(MAC, "[UE %d] PMCH[%d]: MCH_Scheduling_Period = %ld\n", Mod_idP, i,
+	    UE_mac_inst[Mod_idP].pmch_Config[i]->mch_SchedulingPeriod_r9);
     }
+    
+    UE_mac_inst[Mod_idP].mcch_status = 1;
   }
 
+
+#endif
+#ifdef CBA
+
+  if (cba_rnti) {
+    UE_mac_inst[Mod_idP].cba_rnti[num_active_cba_groups-1] = cba_rnti;
+    LOG_D(MAC,"[UE %d] configure CBA group %d RNTI %x for eNB %d (total active cba group %d)\n",
+	  Mod_idP,Mod_idP%num_active_cba_groups, cba_rnti,eNB_index,num_active_cba_groups);
+    mac_xface->phy_config_cba_rnti(Mod_idP,CC_idP,eNB_flagP,eNB_index,cba_rnti,num_active_cba_groups-1, num_active_cba_groups);
+  }
 #endif
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_MAC_CONFIG, VCD_FUNCTION_OUT);
 
diff --git a/openair2/LAYER2/MAC/defs.h b/openair2/LAYER2/MAC/defs.h
index 3c0223e59e..3e8c3c3525 100644
--- a/openair2/LAYER2/MAC/defs.h
+++ b/openair2/LAYER2/MAC/defs.h
@@ -47,9 +47,13 @@
 
 //#include "COMMON/openair_defs.h"
 
+
+
+#include "PHY/defs.h"
+#include "PHY/LTE_TRANSPORT/defs.h"
 #include "COMMON/platform_constants.h"
 #include "COMMON/mac_rrc_primitives.h"
-#include "PHY/defs.h"
+#include "BCCH-BCH-Message.h"
 #include "RadioResourceConfigCommon.h"
 #include "RadioResourceConfigDedicated.h"
 #include "MeasGapConfig.h"
@@ -842,6 +846,7 @@ typedef struct {
 } SBMAP_CONF;
 /*! \brief UE list used by eNB to order UEs/CC for scheduling*/ 
 typedef struct {
+  struct PhysicalConfigDedicated  *physicalConfigDedicated[MAX_NUM_CCs][NUMBER_OF_UE_MAX];
   /// DLSCH pdu 
   DLSCH_PDU DLSCH_pdu[MAX_NUM_CCs][2][NUMBER_OF_UE_MAX];
   /// DCI template and MAC connection parameters for UEs
@@ -874,6 +879,18 @@ typedef struct {
 
 /*! \brief eNB common channels */ 
 typedef struct {
+  int                              physCellId;
+  int                              p_eNB;
+  int                              Ncp;
+  int                              eutra_band;
+  uint32_t                         dl_CarrierFreq;
+  BCCH_BCH_Message_t               *mib;
+  RadioResourceConfigCommonSIB_t   *radioResourceConfigCommon;  
+  TDD_Config_t                     *tdd_Config;
+  uint8_t                          SIwindowsize;
+  uint16_t                         SIperiod;
+  ARFCN_ValueEUTRA_t               ul_CarrierFreq;
+  long                             ul_Bandwidth;
   /// Outgoing DCI for PHY generated by eNB scheduler
   DCI_PDU DCI_pdu;
   /// Outgoing BCCH pdu for PHY
@@ -921,7 +938,7 @@ typedef struct {
 #endif
 } COMMON_channels_t;
 /*! \brief top level eNB MAC structure */ 
-typedef struct {
+typedef struct eNB_MAC_INST_s {
   ///
   uint16_t Node_id;
   /// frame counter
@@ -930,6 +947,7 @@ typedef struct {
   sub_frame_t subframe;
   /// Common cell resources
   COMMON_channels_t common_channels[MAX_NUM_CCs];
+
   UE_list_t UE_list;
 
   ///subband bitmap configuration
@@ -959,7 +977,6 @@ typedef struct {
   time_stats_t schedule_mch;
   /// processing time of eNB ULSCH reception
   time_stats_t rx_ulsch_sdu; // include rlc_data_ind
-
 } eNB_MAC_INST;
 
 /* 
diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c
index dee7c51a6e..e1402bcd13 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler.c
@@ -65,33 +65,15 @@
 
 #define ENABLE_MAC_PAYLOAD_DEBUG
 #define DEBUG_eNB_SCHEDULER 1
-//efine ENABLE_ENB_AGENT_DL_SCHEDULER
-//#define DISABLE_SF_TRIGGER
-//#define DISABLE_CONT_STATS
-
-//#define DEBUG_HEADER_PARSING 1
-//#define DEBUG_PACKET_TRACE 1
-
-/*
-  #ifndef USER_MODE
-  #define msg debug_msg
-  #endif
- */
-
-
-
-
-
 
+extern RAN_CONTEXT_t RC;
 
 void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, frame_t frameP, sub_frame_t subframeP)  //, int calibration_flag) {
 {
 
   int mbsfn_status[MAX_NUM_CCs];
   protocol_ctxt_t   ctxt;
-#ifdef EXMIMO
-  //int ret;
-#endif
+
 #if defined(ENABLE_ITTI)
   MessageDef   *msg_p;
   const char         *msg_name;
@@ -100,7 +82,7 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag,
 #endif
   DCI_PDU *DCI_pdu[MAX_NUM_CCs];
   int CC_id,i; //,next_i;
-  UE_list_t *UE_list=&eNB_mac_inst[module_idP].UE_list;
+  UE_list_t *UE_list=&RC.mac[module_idP]->UE_list;
   rnti_t rnti;
   void         *DLSCH_dci=NULL;
   int size_bits=0,size_bytes=0;
@@ -113,14 +95,14 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag,
 
   LOG_D(MAC,"[eNB %d] Frame %d, Subframe %d, entering MAC scheduler (UE_list->head %d)\n",module_idP, frameP, subframeP,UE_list->head);
 
-  start_meas(&eNB_mac_inst[module_idP].eNB_scheduler);
+  start_meas(&RC.mac[module_idP]->eNB_scheduler);
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER,VCD_FUNCTION_IN);
 
   for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
-    DCI_pdu[CC_id] = &eNB_mac_inst[module_idP].common_channels[CC_id].DCI_pdu;
+    DCI_pdu[CC_id] = &RC.mac[module_idP]->common_channels[CC_id].DCI_pdu;
     mbsfn_status[CC_id]=0;
     // clear vrb_map
-    memset(eNB_mac_inst[module_idP].common_channels[CC_id].vrb_map,0,100);
+    memset(RC.mac[module_idP]->common_channels[CC_id].vrb_map,0,100);
   }
 
   // clear DCI and BCCH contents before scheduling
@@ -128,10 +110,10 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag,
     DCI_pdu[CC_id]->Num_common_dci  = 0;
     DCI_pdu[CC_id]->Num_ue_spec_dci = 0;
 #ifdef Rel10
-    eNB_mac_inst[module_idP].common_channels[CC_id].mcch_active =0;
+    RC.mac[module_idP]->common_channels[CC_id].mcch_active =0;
 #endif
-    eNB_mac_inst[module_idP].frame    = frameP;
-    eNB_mac_inst[module_idP].subframe = subframeP;
+    RC.mac[module_idP]->frame    = frameP;
+    RC.mac[module_idP]->subframe = subframeP;
   }
 
   // refresh UE list based on UEs dropped by PHY in previous subframe
@@ -145,13 +127,13 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag,
 	    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);
 
-    PHY_vars_eNB_g[module_idP][CC_id]->pusch_stats_bsr[i][(frameP*10)+subframeP]=-63;
+    RC.eNB[module_idP][CC_id]->pusch_stats_bsr[i][(frameP*10)+subframeP]=-63;
     if (i==UE_list->head)
-      VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_BSR,PHY_vars_eNB_g[module_idP][CC_id]->pusch_stats_bsr[i][(frameP*10)+subframeP]); 
+      VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_BSR,RC.eNB[module_idP][CC_id]->pusch_stats_bsr[i][(frameP*10)+subframeP]); 
     // increment this, it is cleared when we receive an sdu
-    eNB_mac_inst[module_idP].UE_list.UE_sched_ctrl[i].ul_inactivity_timer++;
+    RC.mac[module_idP]->UE_list.UE_sched_ctrl[i].ul_inactivity_timer++;
 
-    eNB_mac_inst[module_idP].UE_list.UE_sched_ctrl[i].cqi_req_timer++;
+    RC.mac[module_idP]->UE_list.UE_sched_ctrl[i].cqi_req_timer++;
     eNB_UE_stats = mac_xface->get_eNB_UE_stats(module_idP,CC_id,rnti);
 
     if (eNB_UE_stats==NULL) {
@@ -177,8 +159,8 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag,
 	  LOG_D(MAC,"UE %d rnti %x: sending PDCCH order for RAPROC (failure timer %d) \n",i,rnti,UE_list->UE_sched_ctrl[i].ul_failure_timer);	    
 	  DLSCH_dci = (void *)UE_list->UE_template[CC_id][i].DLSCH_DCI[0];
 	  *(uint32_t*)DLSCH_dci = 0;
-	  if (PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.frame_type == TDD) {
-	    switch (PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.N_RB_DL) {
+	  if (RC.eNB[module_idP][CC_id]->frame_parms.frame_type == TDD) {
+	    switch (RC.eNB[module_idP][CC_id]->frame_parms.N_RB_DL) {
 	    case 6:
 	      ((DCI1A_1_5MHz_TDD_1_6_t*)DLSCH_dci)->type = 1;
 	      ((DCI1A_1_5MHz_TDD_1_6_t*)DLSCH_dci)->rballoc = 31;
@@ -206,7 +188,7 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag,
 	    }
 	  }
 	  else { // FDD
-	    switch (PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.N_RB_DL) {
+	    switch (RC.eNB[module_idP][CC_id]->frame_parms.N_RB_DL) {
 	    case 6:
 	      ((DCI1A_1_5MHz_FDD_t*)DLSCH_dci)->type = 1;
 	      ((DCI1A_1_5MHz_FDD_t*)DLSCH_dci)->rballoc = 31;
@@ -349,10 +331,10 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag,
 #ifdef Rel10
 
   for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
-    if (eNB_mac_inst[module_idP].common_channels[CC_id].MBMS_flag >0) {
-      start_meas(&eNB_mac_inst[module_idP].schedule_mch);
+    if (RC.mac[module_idP]->common_channels[CC_id].MBMS_flag >0) {
+      start_meas(&RC.mac[module_idP]->schedule_mch);
       mbsfn_status[CC_id] = schedule_MBMS(module_idP,CC_id,frameP,subframeP);
-      stop_meas(&eNB_mac_inst[module_idP].schedule_mch);
+      stop_meas(&RC.mac[module_idP]->schedule_mch);
     }
   }
 
@@ -1113,7 +1095,7 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag,
   LOG_D(MAC,"frameP %d, subframeP %d\n",frameP,subframeP);
   */
 
-  stop_meas(&eNB_mac_inst[module_idP].eNB_scheduler);
+  stop_meas(&RC.mac[module_idP]->eNB_scheduler);
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER,VCD_FUNCTION_OUT);
 
 }
diff --git a/openair2/LAYER2/MAC/eNB_scheduler_RA.c b/openair2/LAYER2/MAC/eNB_scheduler_RA.c
index 991f8bfbfa..8bcff96859 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_RA.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_RA.c
@@ -66,7 +66,7 @@ void schedule_RA(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP,un
 {
 
   int CC_id;
-  eNB_MAC_INST *eNB = &eNB_mac_inst[module_idP];
+  eNB_MAC_INST *eNB = RC.mac[module_idP];
 
 
   RA_TEMPLATE *RA_template;
@@ -112,8 +112,8 @@ void schedule_RA(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP,un
           vrb_map[first_rb+2] = 1;
           vrb_map[first_rb+3] = 1;
 
-          if (PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.frame_type == TDD) {
-            switch(PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.N_RB_DL) {
+          if (RC.eNB[module_idP][CC_id]->frame_parms.frame_type == TDD) {
+            switch(RC.eNB[module_idP][CC_id]->frame_parms.N_RB_DL) {
             case 6:
               ((DCI1A_1_5MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu1[0])->type=1;
               ((DCI1A_1_5MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu1[0])->vrb_type=0;
@@ -123,7 +123,7 @@ void schedule_RA(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP,un
               ((DCI1A_1_5MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu1[0])->harq_pid=0;
               ((DCI1A_1_5MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu1[0])->TPC=1;
               ((DCI1A_1_5MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu1[0])->padding=0;
-              ((DCI1A_1_5MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu1[0])->rballoc = mac_xface->computeRIV(PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.N_RB_DL,first_rb,4);
+              ((DCI1A_1_5MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu1[0])->rballoc = mac_xface->computeRIV(RC.eNB[module_idP][CC_id]->frame_parms.N_RB_DL,first_rb,4);
               rballoc[CC_id] |= mac_xface->get_rballoc(((DCI1A_1_5MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu1[0])->vrb_type,
                                 ((DCI1A_1_5MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu1[0])->rballoc);
               break;
@@ -137,7 +137,7 @@ void schedule_RA(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP,un
               ((DCI1A_5MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu1[0])->harq_pid=0;
               ((DCI1A_5MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu1[0])->TPC=1;
               ((DCI1A_5MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu1[0])->padding=0;
-              ((DCI1A_5MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu1[0])->rballoc = mac_xface->computeRIV(PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.N_RB_DL,first_rb,4);
+              ((DCI1A_5MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu1[0])->rballoc = mac_xface->computeRIV(RC.eNB[module_idP][CC_id]->frame_parms.N_RB_DL,first_rb,4);
               rballoc[CC_id] |= mac_xface->get_rballoc(((DCI1A_5MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu1[0])->vrb_type,
                                 ((DCI1A_5MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu1[0])->rballoc);
               break;
@@ -151,7 +151,7 @@ void schedule_RA(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP,un
               ((DCI1A_10MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu1[0])->harq_pid=0;
               ((DCI1A_10MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu1[0])->TPC=1;
               ((DCI1A_10MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu1[0])->padding=0;
-              ((DCI1A_10MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu1[0])->rballoc = mac_xface->computeRIV(PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.N_RB_DL,first_rb,4);
+              ((DCI1A_10MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu1[0])->rballoc = mac_xface->computeRIV(RC.eNB[module_idP][CC_id]->frame_parms.N_RB_DL,first_rb,4);
               rballoc[CC_id] |= mac_xface->get_rballoc(((DCI1A_10MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu1[0])->vrb_type,
                                 ((DCI1A_10MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu1[0])->rballoc);
               break;
@@ -165,7 +165,7 @@ void schedule_RA(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP,un
               ((DCI1A_20MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu1[0])->harq_pid=0;
               ((DCI1A_20MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu1[0])->TPC=1;
               ((DCI1A_20MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu1[0])->padding=0;
-              ((DCI1A_20MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu1[0])->rballoc = mac_xface->computeRIV(PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.N_RB_DL,first_rb,4);
+              ((DCI1A_20MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu1[0])->rballoc = mac_xface->computeRIV(RC.eNB[module_idP][CC_id]->frame_parms.N_RB_DL,first_rb,4);
               rballoc[CC_id] |= mac_xface->get_rballoc(((DCI1A_20MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu1[0])->vrb_type,
                                 ((DCI1A_20MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu1[0])->rballoc);
               break;
@@ -179,13 +179,13 @@ void schedule_RA(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP,un
               ((DCI1A_5MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu1[0])->harq_pid=0;
               ((DCI1A_5MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu1[0])->TPC=1;
               ((DCI1A_5MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu1[0])->padding=0;
-              ((DCI1A_5MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu1[0])->rballoc = mac_xface->computeRIV(PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.N_RB_DL,first_rb,4);
+              ((DCI1A_5MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu1[0])->rballoc = mac_xface->computeRIV(RC.eNB[module_idP][CC_id]->frame_parms.N_RB_DL,first_rb,4);
               rballoc[CC_id] |= mac_xface->get_rballoc(((DCI1A_5MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu1[0])->vrb_type,
                                 ((DCI1A_5MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu1[0])->rballoc);
               break;
             }
           } else {
-            switch(PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.N_RB_DL) {
+            switch(RC.eNB[module_idP][CC_id]->frame_parms.N_RB_DL) {
             case 6:
               ((DCI1A_1_5MHz_FDD_t*)&RA_template->RA_alloc_pdu1[0])->type=1;
               ((DCI1A_1_5MHz_FDD_t*)&RA_template->RA_alloc_pdu1[0])->vrb_type=0;
@@ -195,7 +195,7 @@ void schedule_RA(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP,un
               ((DCI1A_1_5MHz_FDD_t*)&RA_template->RA_alloc_pdu1[0])->harq_pid=0;
               ((DCI1A_1_5MHz_FDD_t*)&RA_template->RA_alloc_pdu1[0])->TPC=1;
               ((DCI1A_1_5MHz_FDD_t*)&RA_template->RA_alloc_pdu1[0])->padding=0;
-              ((DCI1A_1_5MHz_FDD_t*)&RA_template->RA_alloc_pdu1[0])->rballoc = mac_xface->computeRIV(PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.N_RB_DL,first_rb,4);
+              ((DCI1A_1_5MHz_FDD_t*)&RA_template->RA_alloc_pdu1[0])->rballoc = mac_xface->computeRIV(RC.eNB[module_idP][CC_id]->frame_parms.N_RB_DL,first_rb,4);
               rballoc[CC_id] |= mac_xface->get_rballoc(((DCI1A_1_5MHz_FDD_t*)&RA_template->RA_alloc_pdu1[0])->vrb_type,
                                 ((DCI1A_1_5MHz_FDD_t*)&RA_template->RA_alloc_pdu1[0])->rballoc);
               break;
@@ -209,7 +209,7 @@ void schedule_RA(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP,un
               ((DCI1A_5MHz_FDD_t*)&RA_template->RA_alloc_pdu1[0])->harq_pid=0;
               ((DCI1A_5MHz_FDD_t*)&RA_template->RA_alloc_pdu1[0])->TPC=1;
               ((DCI1A_5MHz_FDD_t*)&RA_template->RA_alloc_pdu1[0])->padding=0;
-              ((DCI1A_5MHz_FDD_t*)&RA_template->RA_alloc_pdu1[0])->rballoc = mac_xface->computeRIV(PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.N_RB_UL,first_rb,4);
+              ((DCI1A_5MHz_FDD_t*)&RA_template->RA_alloc_pdu1[0])->rballoc = mac_xface->computeRIV(RC.eNB[module_idP][CC_id]->frame_parms.N_RB_UL,first_rb,4);
               rballoc[CC_id] |= mac_xface->get_rballoc(((DCI1A_5MHz_FDD_t*)&RA_template->RA_alloc_pdu1[0])->vrb_type,
                                 ((DCI1A_5MHz_FDD_t*)&RA_template->RA_alloc_pdu1[0])->rballoc);
               break;
@@ -223,7 +223,7 @@ void schedule_RA(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP,un
               ((DCI1A_10MHz_FDD_t*)&RA_template->RA_alloc_pdu1[0])->harq_pid=0;
               ((DCI1A_10MHz_FDD_t*)&RA_template->RA_alloc_pdu1[0])->TPC=1;
               ((DCI1A_10MHz_FDD_t*)&RA_template->RA_alloc_pdu1[0])->padding=0;
-              ((DCI1A_10MHz_FDD_t*)&RA_template->RA_alloc_pdu1[0])->rballoc = mac_xface->computeRIV(PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.N_RB_DL,first_rb,4);
+              ((DCI1A_10MHz_FDD_t*)&RA_template->RA_alloc_pdu1[0])->rballoc = mac_xface->computeRIV(RC.eNB[module_idP][CC_id]->frame_parms.N_RB_DL,first_rb,4);
               rballoc[CC_id] |= mac_xface->get_rballoc(((DCI1A_10MHz_FDD_t*)&RA_template->RA_alloc_pdu1[0])->vrb_type,
                                 ((DCI1A_10MHz_FDD_t*)&RA_template->RA_alloc_pdu1[0])->rballoc);
               break;
@@ -237,7 +237,7 @@ void schedule_RA(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP,un
               ((DCI1A_20MHz_FDD_t*)&RA_template->RA_alloc_pdu1[0])->harq_pid=0;
               ((DCI1A_20MHz_FDD_t*)&RA_template->RA_alloc_pdu1[0])->TPC=1;
               ((DCI1A_20MHz_FDD_t*)&RA_template->RA_alloc_pdu1[0])->padding=0;
-              ((DCI1A_20MHz_FDD_t*)&RA_template->RA_alloc_pdu1[0])->rballoc = mac_xface->computeRIV(PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.N_RB_DL,first_rb,4);
+              ((DCI1A_20MHz_FDD_t*)&RA_template->RA_alloc_pdu1[0])->rballoc = mac_xface->computeRIV(RC.eNB[module_idP][CC_id]->frame_parms.N_RB_DL,first_rb,4);
               rballoc[CC_id] |= mac_xface->get_rballoc(((DCI1A_20MHz_FDD_t*)&RA_template->RA_alloc_pdu1[0])->vrb_type,
                                 ((DCI1A_20MHz_FDD_t*)&RA_template->RA_alloc_pdu1[0])->rballoc);
               break;
@@ -296,22 +296,6 @@ void schedule_RA(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP,un
             LOG_I(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Generating Msg4 with RRC Piggyback (RA proc %d, RNTI %x)\n",
                   module_idP, CC_id, frameP, subframeP,i,RA_template->rnti);
 
-            //msg("[MAC][eNB %d][RAPROC] Frame %d, subframeP %d: Received %d bytes for Msg4: \n",module_idP,frameP,subframeP,rrc_sdu_length);
-            //    for (j=0;j<rrc_sdu_length;j++)
-            //      msg("%x ",(unsigned char)eNB_mac_inst[module_idP][CC_id].CCCH_pdu.payload[j]);
-            //    msg("\n");
-            //    msg("[MAC][eNB] Frame %d, subframeP %d: Generated DLSCH (Msg4) DCI, format 1A, for UE %d\n",frameP, subframeP,UE_id);
-            // Schedule Reflection of Connection request
-
-	    /*
-	    // randomize frequency allocation for RA
-	    while (1) {
-	      first_rb = (unsigned char)(taus()%(PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.N_RB_DL-4));
-	      
-	      if ((vrb_map[first_rb] != 1) && (vrb_map[first_rb+3] != 1))
-		break;
-	    }
-	    */
 	    first_rb=0;
 
 	    vrb_map[first_rb] = 1;
@@ -354,7 +338,7 @@ void schedule_RA(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP,un
 		((DCI1A_1_5MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu2[0])->harq_pid=0;
 		((DCI1A_1_5MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu2[0])->TPC=1;
 		((DCI1A_1_5MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu2[0])->padding=0;
-		((DCI1A_1_5MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu2[0])->rballoc= mac_xface->computeRIV(PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.N_RB_DL,first_rb,4);
+		((DCI1A_1_5MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu2[0])->rballoc= mac_xface->computeRIV(RC.eNB[module_idP][CC_id]->frame_parms.N_RB_DL,first_rb,4);
 		rballoc[CC_id] |= mac_xface->get_rballoc(((DCI1A_1_5MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu2[0])->vrb_type,
 							 ((DCI1A_1_5MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu2[0])->rballoc);
 		
@@ -390,7 +374,7 @@ void schedule_RA(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP,un
 		((DCI1A_5MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu2[0])->harq_pid=0;
 		((DCI1A_5MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu2[0])->TPC=1;
 		((DCI1A_5MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu2[0])->padding=0;
-		((DCI1A_5MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu2[0])->rballoc= mac_xface->computeRIV(PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.N_RB_DL,first_rb,4);
+		((DCI1A_5MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu2[0])->rballoc= mac_xface->computeRIV(RC.eNB[module_idP][CC_id]->frame_parms.N_RB_DL,first_rb,4);
 		rballoc[CC_id] |= mac_xface->get_rballoc(((DCI1A_5MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu2[0])->vrb_type,
 							 ((DCI1A_5MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu2[0])->rballoc);
                 break;
@@ -424,7 +408,7 @@ void schedule_RA(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP,un
 		((DCI1A_10MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu2[0])->harq_pid=0;
 		((DCI1A_10MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu2[0])->TPC=1;
 		((DCI1A_10MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu2[0])->padding=0;
-		((DCI1A_10MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu2[0])->rballoc= mac_xface->computeRIV(PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.N_RB_DL,first_rb,4);
+		((DCI1A_10MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu2[0])->rballoc= mac_xface->computeRIV(RC.eNB[module_idP][CC_id]->frame_parms.N_RB_DL,first_rb,4);
 		rballoc[CC_id] |= mac_xface->get_rballoc(((DCI1A_10MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu2[0])->vrb_type,
 							 ((DCI1A_10MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu2[0])->rballoc);
 
@@ -459,7 +443,7 @@ void schedule_RA(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP,un
 		((DCI1A_20MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu2[0])->rv=0;
 		((DCI1A_20MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu2[0])->harq_pid=0;
 		((DCI1A_20MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu2[0])->TPC=1;
-		((DCI1A_20MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu2[0])->rballoc= mac_xface->computeRIV(PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.N_RB_DL,first_rb,4);
+		((DCI1A_20MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu2[0])->rballoc= mac_xface->computeRIV(RC.eNB[module_idP][CC_id]->frame_parms.N_RB_DL,first_rb,4);
 		rballoc[CC_id] |= mac_xface->get_rballoc(((DCI1A_20MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu2[0])->vrb_type,
 							 ((DCI1A_20MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu2[0])->rballoc);
                 break;
@@ -495,7 +479,7 @@ void schedule_RA(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP,un
 		((DCI1A_1_5MHz_FDD_t*)&RA_template->RA_alloc_pdu2[0])->harq_pid=0;
 		((DCI1A_1_5MHz_FDD_t*)&RA_template->RA_alloc_pdu2[0])->TPC=1;
 		((DCI1A_1_5MHz_FDD_t*)&RA_template->RA_alloc_pdu2[0])->padding=0;
-		((DCI1A_1_5MHz_FDD_t*)&RA_template->RA_alloc_pdu2[0])->rballoc= mac_xface->computeRIV(PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.N_RB_DL,first_rb,4);
+		((DCI1A_1_5MHz_FDD_t*)&RA_template->RA_alloc_pdu2[0])->rballoc= mac_xface->computeRIV(RC.eNB[module_idP][CC_id]->frame_parms.N_RB_DL,first_rb,4);
 		rballoc[CC_id] |= mac_xface->get_rballoc(((DCI1A_1_5MHz_FDD_t*)&RA_template->RA_alloc_pdu2[0])->vrb_type,
 							 ((DCI1A_1_5MHz_FDD_t*)&RA_template->RA_alloc_pdu2[0])->rballoc);
                 break;
@@ -529,7 +513,7 @@ void schedule_RA(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP,un
 		((DCI1A_5MHz_FDD_t*)&RA_template->RA_alloc_pdu2[0])->harq_pid=0;
 		((DCI1A_5MHz_FDD_t*)&RA_template->RA_alloc_pdu2[0])->TPC=1;
 		((DCI1A_5MHz_FDD_t*)&RA_template->RA_alloc_pdu2[0])->padding=0;
-		((DCI1A_5MHz_FDD_t*)&RA_template->RA_alloc_pdu2[0])->rballoc= mac_xface->computeRIV(PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.N_RB_DL,first_rb,4);
+		((DCI1A_5MHz_FDD_t*)&RA_template->RA_alloc_pdu2[0])->rballoc= mac_xface->computeRIV(RC.eNB[module_idP][CC_id]->frame_parms.N_RB_DL,first_rb,4);
 		rballoc[CC_id] |= mac_xface->get_rballoc(((DCI1A_5MHz_FDD_t*)&RA_template->RA_alloc_pdu2[0])->vrb_type,
 							 ((DCI1A_5MHz_FDD_t*)&RA_template->RA_alloc_pdu2[0])->rballoc);
                 break;
@@ -563,7 +547,7 @@ void schedule_RA(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP,un
 		((DCI1A_10MHz_FDD_t*)&RA_template->RA_alloc_pdu2[0])->harq_pid=0;
 		((DCI1A_10MHz_FDD_t*)&RA_template->RA_alloc_pdu2[0])->TPC=1;
 		((DCI1A_10MHz_FDD_t*)&RA_template->RA_alloc_pdu2[0])->padding=0;
-		((DCI1A_10MHz_FDD_t*)&RA_template->RA_alloc_pdu2[0])->rballoc= mac_xface->computeRIV(PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.N_RB_DL,first_rb,4);
+		((DCI1A_10MHz_FDD_t*)&RA_template->RA_alloc_pdu2[0])->rballoc= mac_xface->computeRIV(RC.eNB[module_idP][CC_id]->frame_parms.N_RB_DL,first_rb,4);
 		rballoc[CC_id] |= mac_xface->get_rballoc(((DCI1A_10MHz_FDD_t*)&RA_template->RA_alloc_pdu2[0])->vrb_type,
 							 ((DCI1A_10MHz_FDD_t*)&RA_template->RA_alloc_pdu2[0])->rballoc);
                 break;
@@ -596,7 +580,7 @@ void schedule_RA(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP,un
 		((DCI1A_20MHz_FDD_t*)&RA_template->RA_alloc_pdu2[0])->harq_pid=0;
 		((DCI1A_20MHz_FDD_t*)&RA_template->RA_alloc_pdu2[0])->TPC=1;
 		((DCI1A_20MHz_FDD_t*)&RA_template->RA_alloc_pdu2[0])->padding=0;
-		((DCI1A_20MHz_FDD_t*)&RA_template->RA_alloc_pdu2[0])->rballoc= mac_xface->computeRIV(PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.N_RB_DL,first_rb,4);
+		((DCI1A_20MHz_FDD_t*)&RA_template->RA_alloc_pdu2[0])->rballoc= mac_xface->computeRIV(RC.eNB[module_idP][CC_id]->frame_parms.N_RB_DL,first_rb,4);
 		rballoc[CC_id] |= mac_xface->get_rballoc(((DCI1A_20MHz_FDD_t*)&RA_template->RA_alloc_pdu2[0])->vrb_type,
 							 ((DCI1A_20MHz_FDD_t*)&RA_template->RA_alloc_pdu2[0])->rballoc);
                 break;
@@ -670,7 +654,7 @@ void schedule_RA(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP,un
 	if (round>0) {
 	  //RA_template->wait_ack_Msg4++;
 	  // we have to schedule a retransmission
-	  if (PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.frame_type == TDD) {
+	  if (RC.eNB[module_idP][CC_id]->frame_parms.frame_type == TDD) {
 	    ((DCI1A_5MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu2[0])->ndi=1;
 	  } else {
 	    ((DCI1A_5MHz_FDD_t*)&RA_template->RA_alloc_pdu2[0])->ndi=1;
@@ -679,7 +663,7 @@ void schedule_RA(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP,un
 	  /*
 	  // randomize frequency allocation for RA
 	  while (1) {
-	    first_rb = (unsigned char)(taus()%(PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.N_RB_DL-4));
+	    first_rb = (unsigned char)(taus()%(RC.eNB[module_idP][CC_id].frame_parms.N_RB_DL-4));
 	    
 	    if ((vrb_map[first_rb] != 1) && (vrb_map[first_rb+3] != 1))
 	      break;
@@ -691,12 +675,12 @@ void schedule_RA(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP,un
 	  vrb_map[first_rb+2] = 1;
 	  vrb_map[first_rb+3] = 1;
 	  
-	  if (PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.frame_type == TDD) {
-	    ((DCI1A_5MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu2[0])->rballoc = mac_xface->computeRIV(PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.N_RB_UL,first_rb,4);
+	  if (RC.eNB[module_idP][CC_id]->frame_parms.frame_type == TDD) {
+	    ((DCI1A_5MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu2[0])->rballoc = mac_xface->computeRIV(RC.eNB[module_idP][CC_id]->frame_parms.N_RB_UL,first_rb,4);
 	    rballoc[CC_id] |= mac_xface->get_rballoc(((DCI1A_5MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu2[0])->vrb_type,
 						     ((DCI1A_5MHz_TDD_1_6_t*)&RA_template->RA_alloc_pdu2[0])->rballoc);
 	  } else {
-	    ((DCI1A_5MHz_FDD_t*)&RA_template->RA_alloc_pdu2[0])->rballoc = mac_xface->computeRIV(PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.N_RB_UL,first_rb,4);
+	    ((DCI1A_5MHz_FDD_t*)&RA_template->RA_alloc_pdu2[0])->rballoc = mac_xface->computeRIV(RC.eNB[module_idP][CC_id]->frame_parms.N_RB_UL,first_rb,4);
 	    rballoc[CC_id] |= mac_xface->get_rballoc(((DCI1A_5MHz_FDD_t*)&RA_template->RA_alloc_pdu2[0])->vrb_type,
 						     ((DCI1A_5MHz_FDD_t*)&RA_template->RA_alloc_pdu2[0])->rballoc);
 	  }
@@ -728,7 +712,7 @@ printf("MAC: msg4 acknowledged for rnti %x fsf %d/%d, let's configure it\n", RA_
 	  RA_template->RA_active=FALSE;
 	  UE_id = find_UE_id(module_idP,RA_template->rnti);
 	  DevAssert( UE_id != -1 );
-	  eNB_mac_inst[module_idP].UE_list.UE_template[UE_PCCID(module_idP,UE_id)][UE_id].configured=TRUE;
+	  RC.mac[module_idP]->UE_list.UE_template[UE_PCCID(module_idP,UE_id)][UE_id].configured=TRUE;
 	  
 	}
       }
@@ -743,7 +727,7 @@ void initiate_ra_proc(module_id_t module_idP, int CC_id,frame_t frameP, uint16_t
 {
 
   uint8_t i;
-  RA_TEMPLATE *RA_template = (RA_TEMPLATE *)&eNB_mac_inst[module_idP].common_channels[CC_id].RA_template[0];
+  RA_TEMPLATE *RA_template = (RA_TEMPLATE *)&RC.mac[module_idP]->common_channels[CC_id].RA_template[0];
 
   LOG_D(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d Initiating RA procedure for preamble index %d\n",module_idP,CC_id,frameP,preamble_index);
 
@@ -787,7 +771,7 @@ void initiate_ra_proc(module_id_t module_idP, int CC_id,frame_t frameP, uint16_t
 void cancel_ra_proc(module_id_t module_idP, int CC_id, frame_t frameP, rnti_t rnti)
 {
   unsigned char i;
-  RA_TEMPLATE *RA_template = (RA_TEMPLATE *)&eNB_mac_inst[module_idP].common_channels[CC_id].RA_template[0];
+  RA_TEMPLATE *RA_template = (RA_TEMPLATE *)&RC.mac[module_idP]->common_channels[CC_id].RA_template[0];
 
   MSC_LOG_EVENT(MSC_PHY_ENB, "RA Cancelling procedure ue %"PRIx16" ", rnti);
   LOG_D(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d Cancelling RA procedure for UE rnti %x\n",module_idP,CC_id,frameP,rnti);
diff --git a/openair2/LAYER2/MAC/eNB_scheduler_bch.c b/openair2/LAYER2/MAC/eNB_scheduler_bch.c
index fb01532068..cc79cafbdc 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_bch.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_bch.c
@@ -75,7 +75,7 @@ schedule_SI(
   int mcs = -1;
   void *BCCH_alloc_pdu;
   int CC_id;
-  eNB_MAC_INST *eNB = &eNB_mac_inst[module_idP];
+  eNB_MAC_INST *eNB = RC.mac[module_idP];
   uint8_t *vrb_map;
   int first_rb = -1;
   int rballoc[MAX_NUM_CCs];
@@ -113,7 +113,7 @@ schedule_SI(
 	  break;
       }
       */
-      switch (PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.N_RB_DL) {
+      switch (RC.eNB[module_idP][CC_id]->frame_parms.N_RB_DL) {
       case 6:
 	first_rb = 0;
 	break;
@@ -159,11 +159,11 @@ schedule_SI(
 
 
 
-      if (PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.frame_type == TDD) {
-        switch (PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.N_RB_DL) {
+      if (RC.eNB[module_idP][CC_id]->frame_parms.frame_type == TDD) {
+        switch (RC.eNB[module_idP][CC_id]->frame_parms.N_RB_DL) {
         case 6:
           ((DCI1A_1_5MHz_TDD_1_6_t*)BCCH_alloc_pdu)->mcs = mcs;
-          ((DCI1A_1_5MHz_TDD_1_6_t*)BCCH_alloc_pdu)->rballoc = mac_xface->computeRIV(PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.N_RB_DL,first_rb,4);
+          ((DCI1A_1_5MHz_TDD_1_6_t*)BCCH_alloc_pdu)->rballoc = mac_xface->computeRIV(RC.eNB[module_idP][CC_id]->frame_parms.N_RB_DL,first_rb,4);
           ((DCI1A_1_5MHz_TDD_1_6_t*)BCCH_alloc_pdu)->type = 1;
           ((DCI1A_1_5MHz_TDD_1_6_t*)BCCH_alloc_pdu)->vrb_type = 0;
           ((DCI1A_1_5MHz_TDD_1_6_t*)BCCH_alloc_pdu)->ndi = 1;
@@ -178,7 +178,7 @@ schedule_SI(
 
         case 25:
           ((DCI1A_5MHz_TDD_1_6_t*)BCCH_alloc_pdu)->mcs = mcs;
-          ((DCI1A_5MHz_TDD_1_6_t*)BCCH_alloc_pdu)->rballoc = mac_xface->computeRIV(PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.N_RB_DL,first_rb,4);
+          ((DCI1A_5MHz_TDD_1_6_t*)BCCH_alloc_pdu)->rballoc = mac_xface->computeRIV(RC.eNB[module_idP][CC_id]->frame_parms.N_RB_DL,first_rb,4);
           ((DCI1A_5MHz_TDD_1_6_t*)BCCH_alloc_pdu)->type = 1;
           ((DCI1A_5MHz_TDD_1_6_t*)BCCH_alloc_pdu)->vrb_type = 0;
           ((DCI1A_5MHz_TDD_1_6_t*)BCCH_alloc_pdu)->ndi = 1;
@@ -193,7 +193,7 @@ schedule_SI(
 
         case 50:
           ((DCI1A_10MHz_TDD_1_6_t*)BCCH_alloc_pdu)->mcs = mcs;
-          ((DCI1A_10MHz_TDD_1_6_t*)BCCH_alloc_pdu)->rballoc = mac_xface->computeRIV(PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.N_RB_DL,first_rb,4);
+          ((DCI1A_10MHz_TDD_1_6_t*)BCCH_alloc_pdu)->rballoc = mac_xface->computeRIV(RC.eNB[module_idP][CC_id]->frame_parms.N_RB_DL,first_rb,4);
           ((DCI1A_10MHz_TDD_1_6_t*)BCCH_alloc_pdu)->type = 1;
           ((DCI1A_10MHz_TDD_1_6_t*)BCCH_alloc_pdu)->vrb_type = 0;
           ((DCI1A_10MHz_TDD_1_6_t*)BCCH_alloc_pdu)->ndi = 1;
@@ -208,7 +208,7 @@ schedule_SI(
 
         case 100:
           ((DCI1A_20MHz_TDD_1_6_t*)BCCH_alloc_pdu)->mcs = mcs;
-          ((DCI1A_20MHz_TDD_1_6_t*)BCCH_alloc_pdu)->rballoc = mac_xface->computeRIV(PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.N_RB_DL,first_rb,4);
+          ((DCI1A_20MHz_TDD_1_6_t*)BCCH_alloc_pdu)->rballoc = mac_xface->computeRIV(RC.eNB[module_idP][CC_id]->frame_parms.N_RB_DL,first_rb,4);
           ((DCI1A_20MHz_TDD_1_6_t*)BCCH_alloc_pdu)->type = 1;
           ((DCI1A_20MHz_TDD_1_6_t*)BCCH_alloc_pdu)->vrb_type = 0;
           ((DCI1A_20MHz_TDD_1_6_t*)BCCH_alloc_pdu)->ndi = 1;
@@ -223,10 +223,10 @@ schedule_SI(
         }
 
       } else {
-        switch (PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.N_RB_DL) {
+        switch (RC.eNB[module_idP][CC_id]->frame_parms.N_RB_DL) {
         case 6:
           ((DCI1A_1_5MHz_FDD_t*)BCCH_alloc_pdu)->mcs = mcs;
-          ((DCI1A_1_5MHz_FDD_t*)BCCH_alloc_pdu)->rballoc = mac_xface->computeRIV(PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.N_RB_DL,first_rb,4);
+          ((DCI1A_1_5MHz_FDD_t*)BCCH_alloc_pdu)->rballoc = mac_xface->computeRIV(RC.eNB[module_idP][CC_id]->frame_parms.N_RB_DL,first_rb,4);
           ((DCI1A_1_5MHz_FDD_t*)BCCH_alloc_pdu)->type = 1;
           ((DCI1A_1_5MHz_FDD_t*)BCCH_alloc_pdu)->vrb_type = 0;
           ((DCI1A_1_5MHz_FDD_t*)BCCH_alloc_pdu)->ndi = 1;
@@ -242,7 +242,7 @@ schedule_SI(
 
         case 25:
           ((DCI1A_5MHz_FDD_t*)BCCH_alloc_pdu)->mcs = mcs;
-          ((DCI1A_5MHz_FDD_t*)BCCH_alloc_pdu)->rballoc = mac_xface->computeRIV(PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.N_RB_DL,first_rb,4);
+          ((DCI1A_5MHz_FDD_t*)BCCH_alloc_pdu)->rballoc = mac_xface->computeRIV(RC.eNB[module_idP][CC_id]->frame_parms.N_RB_DL,first_rb,4);
           ((DCI1A_5MHz_FDD_t*)BCCH_alloc_pdu)->type = 1;
           ((DCI1A_5MHz_FDD_t*)BCCH_alloc_pdu)->vrb_type = 0;
           ((DCI1A_5MHz_FDD_t*)BCCH_alloc_pdu)->ndi = 1;
@@ -258,7 +258,7 @@ schedule_SI(
 
         case 50:
           ((DCI1A_10MHz_FDD_t*)BCCH_alloc_pdu)->mcs = mcs;
-          ((DCI1A_10MHz_FDD_t*)BCCH_alloc_pdu)->rballoc = mac_xface->computeRIV(PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.N_RB_DL,first_rb,4);
+          ((DCI1A_10MHz_FDD_t*)BCCH_alloc_pdu)->rballoc = mac_xface->computeRIV(RC.eNB[module_idP][CC_id]->frame_parms.N_RB_DL,first_rb,4);
           ((DCI1A_10MHz_FDD_t*)BCCH_alloc_pdu)->type = 1;
           ((DCI1A_10MHz_FDD_t*)BCCH_alloc_pdu)->vrb_type = 0;
           ((DCI1A_10MHz_FDD_t*)BCCH_alloc_pdu)->ndi = 1;
@@ -274,7 +274,7 @@ schedule_SI(
 
         case 100:
           ((DCI1A_20MHz_FDD_t*)BCCH_alloc_pdu)->mcs = mcs;
-          ((DCI1A_20MHz_FDD_t*)BCCH_alloc_pdu)->rballoc = mac_xface->computeRIV(PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.N_RB_DL,first_rb,4);
+          ((DCI1A_20MHz_FDD_t*)BCCH_alloc_pdu)->rballoc = mac_xface->computeRIV(RC.eNB[module_idP][CC_id]->frame_parms.N_RB_DL,first_rb,4);
           ((DCI1A_20MHz_FDD_t*)BCCH_alloc_pdu)->type = 1;
           ((DCI1A_20MHz_FDD_t*)BCCH_alloc_pdu)->vrb_type = 0;
           ((DCI1A_20MHz_FDD_t*)BCCH_alloc_pdu)->ndi = 1;
@@ -318,7 +318,7 @@ schedule_SI(
 	LOG_D(OPT,"[eNB %d][BCH] Frame %d trace pdu for CC_id %d rnti %x with size %d\n",
 	    module_idP, frameP, CC_id, 0xffff, bcch_sdu_length);
       }
-      if (PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.frame_type == TDD) {
+      if (RC.eNB[module_idP][CC_id]->frame_parms.frame_type == TDD) {
         LOG_D(MAC,"[eNB] Frame %d : Scheduling BCCH->DLSCH (TDD) for CC_id %d SI %d bytes (mcs %d, rb 3, TBS %d)\n",
               frameP,
               CC_id,
diff --git a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c
index 41a136d6b1..94ffd91380 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c
@@ -62,7 +62,7 @@
 #define ENABLE_MAC_PAYLOAD_DEBUG
 //#define DEBUG_eNB_SCHEDULER 1
 
-
+extern RAN_CONTEXT_t RC;
 
 //------------------------------------------------------------------------------
 void
@@ -96,7 +96,7 @@ schedule_next_dlue(
 {
 
   int next_ue;
-  UE_list_t *UE_list=&eNB_mac_inst[module_idP].UE_list;
+  UE_list_t *UE_list=&RC.mac[module_idP]->UE_list;
 
   for (next_ue=UE_list->head; next_ue>=0; next_ue=UE_list->next[next_ue] ) {
     if  (eNB_dlsch_info[module_idP][CC_id][next_ue].status == S_DL_WAITING) {
@@ -321,7 +321,7 @@ set_ul_DAI(
 //------------------------------------------------------------------------------
 {
 
-  eNB_MAC_INST         *eNB      = &eNB_mac_inst[module_idP];
+  eNB_MAC_INST         *eNB      = RC.mac[module_idP];
   UE_list_t            *UE_list  = &eNB->UE_list;
   unsigned char         DAI;
 
@@ -443,7 +443,7 @@ schedule_ue_spec(
   //  uint16_t              pre_nb_available_rbs[MAX_NUM_CCs][NUMBER_OF_UE_MAX];
   int                   mcs;
   int              min_rb_unit[MAX_NUM_CCs];
-  eNB_MAC_INST         *eNB      = &eNB_mac_inst[module_idP];
+  eNB_MAC_INST         *eNB      = RC.mac[module_idP];
   UE_list_t            *UE_list  = &eNB->UE_list;
   LTE_DL_FRAME_PARMS   *frame_parms[MAX_NUM_CCs];
   int                   continue_flag=0;
@@ -648,11 +648,11 @@ schedule_ue_spec(
           }
 
           nb_available_rb -= nb_rb;
-          PHY_vars_eNB_g[module_idP][CC_id]->mu_mimo_mode[UE_id].pre_nb_available_rbs = nb_rb;
-          PHY_vars_eNB_g[module_idP][CC_id]->mu_mimo_mode[UE_id].dl_pow_off = ue_sched_ctl->dl_pow_off[CC_id];
+          RC.eNB[module_idP][CC_id]->mu_mimo_mode[UE_id].pre_nb_available_rbs = nb_rb;
+          RC.eNB[module_idP][CC_id]->mu_mimo_mode[UE_id].dl_pow_off = ue_sched_ctl->dl_pow_off[CC_id];
 
           for(j=0; j<frame_parms[CC_id]->N_RBG; j++) {
-            PHY_vars_eNB_g[module_idP][CC_id]->mu_mimo_mode[UE_id].rballoc_sub[j] = UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j];
+            RC.eNB[module_idP][CC_id]->mu_mimo_mode[UE_id].rballoc_sub[j] = UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j];
           }
 
           switch (mac_xface->get_transmission_mode(module_idP,CC_id,rnti)) {
@@ -1039,11 +1039,11 @@ schedule_ue_spec(
             }
           }
 
-          PHY_vars_eNB_g[module_idP][CC_id]->mu_mimo_mode[UE_id].pre_nb_available_rbs = nb_rb;
-          PHY_vars_eNB_g[module_idP][CC_id]->mu_mimo_mode[UE_id].dl_pow_off = ue_sched_ctl->dl_pow_off[CC_id];
+          RC.eNB[module_idP][CC_id]->mu_mimo_mode[UE_id].pre_nb_available_rbs = nb_rb;
+          RC.eNB[module_idP][CC_id]->mu_mimo_mode[UE_id].dl_pow_off = ue_sched_ctl->dl_pow_off[CC_id];
 
           for(j=0; j<frame_parms[CC_id]->N_RBG; j++) {
-            PHY_vars_eNB_g[module_idP][CC_id]->mu_mimo_mode[UE_id].rballoc_sub[j] = UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j];
+            RC.eNB[module_idP][CC_id]->mu_mimo_mode[UE_id].rballoc_sub[j] = UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j];
 
           }
 
@@ -1087,7 +1087,6 @@ schedule_ue_spec(
 
 
           offset = generate_dlsch_header((unsigned char*)UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0],
-                                         // offset = generate_dlsch_header((unsigned char*)eNB_mac_inst[0].DLSCH_pdu[0][0].payload[0],
                                          num_sdus,              //num_sdus
                                          sdu_lengths,  //
                                          sdu_lcids,
@@ -1116,14 +1115,14 @@ schedule_ue_spec(
 #endif
           // cycle through SDUs and place in dlsch_buffer
           memcpy(&UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0][offset],dlsch_buffer,sdu_length_total);
-          // memcpy(&eNB_mac_inst[0].DLSCH_pdu[0][0].payload[0][offset],dcch_buffer,sdu_lengths[0]);
+          // memcpy(RC.mac[0].DLSCH_pdu[0][0].payload[0][offset],dcch_buffer,sdu_lengths[0]);
 
           // fill remainder of DLSCH with random data
           for (j=0; j<(TBS-sdu_length_total-offset); j++) {
             UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0][offset+sdu_length_total+j] = (char)(taus()&0xff);
           }
 
-          //eNB_mac_inst[0].DLSCH_pdu[0][0].payload[0][offset+sdu_lengths[0]+j] = (char)(taus()&0xff);
+
           if (opt_enabled == 1) {
             trace_pdu(1, (uint8_t *)UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0],
                       TBS, module_idP, 3, UE_RNTI(module_idP,UE_id),
@@ -1530,7 +1529,7 @@ fill_DLSCH_dci(
   //void         *BCCH_alloc_pdu;
   int           size_bits,size_bytes;
   int CC_id;
-  eNB_MAC_INST *eNB  =&eNB_mac_inst[module_idP];
+  eNB_MAC_INST *eNB  =RC.mac[module_idP];
   UE_list_t    *UE_list = &eNB->UE_list;
   //RA_TEMPLATE  *RA_template;
   LTE_eNB_UE_stats  *eNB_UE_stats   = NULL;
@@ -1565,7 +1564,7 @@ fill_DLSCH_dci(
 
 
         /// Synchronizing rballoc with rballoc_sub
-        for(i=0; i<PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.N_RBG; i++) {
+        for(i=0; i<RC.eNB[module_idP][CC_id]->frame_parms.N_RBG; i++) {
           rballoc_sub[i] = UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][i];
         }
 
@@ -1579,8 +1578,8 @@ fill_DLSCH_dci(
         case 7:
           LOG_D(MAC,"[eNB %d] CC_id %d Adding UE %d spec DCI for %d PRBS \n",module_idP, CC_id, UE_id, nb_rb);
 
-          if (PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.frame_type == TDD) {
-            switch (PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.N_RB_DL) {
+          if (RC.eNB[module_idP][CC_id]->frame_parms.frame_type == TDD) {
+            switch (RC.eNB[module_idP][CC_id]->frame_parms.N_RB_DL) {
             case 6:
               ((DCI1_1_5MHz_TDD_t*)DLSCH_dci)->rballoc = allocate_prbs_sub(nb_rb,rballoc_sub);
               ((DCI1_1_5MHz_TDD_t*)DLSCH_dci)->rah = 0;
@@ -1619,7 +1618,7 @@ fill_DLSCH_dci(
 
 
           } else {
-            switch(PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.N_RB_DL) {
+            switch(RC.eNB[module_idP][CC_id]->frame_parms.N_RB_DL) {
             case 6:
               ((DCI1_1_5MHz_FDD_t*)DLSCH_dci)->rballoc = allocate_prbs_sub(nb_rb,rballoc_sub);
               ((DCI1_1_5MHz_FDD_t*)DLSCH_dci)->rah = 0;
@@ -1675,8 +1674,8 @@ fill_DLSCH_dci(
           LOG_D(MAC,"[eNB %d] CC_id %d Adding Format 2A UE %d spec DCI for %d PRBS\n",
                 module_idP, CC_id, UE_id, nb_rb);
 
-          if (PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.frame_type == TDD) {
-            switch (PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.N_RB_DL) {
+          if (RC.eNB[module_idP][CC_id]->frame_parms.frame_type == TDD) {
+            switch (RC.eNB[module_idP][CC_id]->frame_parms.N_RB_DL) {
             case 6:
               ((DCI2A_1_5MHz_2A_TDD_t*)DLSCH_dci)->rballoc = allocate_prbs_sub(nb_rb,rballoc_sub);
               ((DCI2A_1_5MHz_2A_TDD_t*)DLSCH_dci)->rah = 0;
@@ -1715,7 +1714,7 @@ fill_DLSCH_dci(
 
 
           } else {
-            switch(PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.N_RB_DL) {
+            switch(RC.eNB[module_idP][CC_id]->frame_parms.N_RB_DL) {
             case 6:
               ((DCI2A_1_5MHz_2A_FDD_t*)DLSCH_dci)->rballoc = allocate_prbs_sub(nb_rb,rballoc_sub);
               ((DCI2A_1_5MHz_2A_FDD_t*)DLSCH_dci)->rah = 0;
@@ -1832,7 +1831,7 @@ get_dlsch_sdu(
 {
 
   int UE_id;
-  eNB_MAC_INST *eNB=&eNB_mac_inst[module_idP];
+  eNB_MAC_INST *eNB=RC.mac[module_idP];
 
   if (rntiP==SI_RNTI) {
     LOG_D(MAC,"[eNB %d] CC_id %d Frame %d Get DLSCH sdu for BCCH \n", module_idP, CC_id, frameP);
@@ -1863,7 +1862,7 @@ update_ul_dci(
 //------------------------------------------------------------------------------
 {
 
-  DCI_PDU             *DCI_pdu   = &eNB_mac_inst[module_idP].common_channels[CC_id].DCI_pdu;
+  DCI_PDU             *DCI_pdu   = &RC.mac[module_idP]->common_channels[CC_id].DCI_pdu;
   int                  i;
   DCI0_5MHz_TDD_1_6_t *ULSCH_dci = NULL;;
 
diff --git a/openair2/LAYER2/MAC/eNB_scheduler_mch.c b/openair2/LAYER2/MAC/eNB_scheduler_mch.c
index 1dac7af704..13041bdcda 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_mch.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_mch.c
@@ -60,6 +60,7 @@
 #define ENABLE_MAC_PAYLOAD_DEBUG
 #define DEBUG_eNB_SCHEDULER 1
 
+extern RAN_CONTEXT_t RC;
 
 #ifdef Rel10
 int8_t get_mbsfn_sf_alloction (module_id_t module_idP, uint8_t CC_id, uint8_t mbsfn_sync_area)
@@ -68,7 +69,7 @@ int8_t get_mbsfn_sf_alloction (module_id_t module_idP, uint8_t CC_id, uint8_t mb
   if (mbsfn_sync_area > MAX_MBSFN_AREA) {
     LOG_W(MAC,"[eNB %d] CC_id %d MBSFN synchronization area %d out of range\n ", module_idP, CC_id, mbsfn_sync_area);
     return -1;
-  } else if (eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_SubframeConfig[mbsfn_sync_area] != NULL) {
+  } else if (RC.mac[module_idP]->common_channels[CC_id].mbsfn_SubframeConfig[mbsfn_sync_area] != NULL) {
     return mbsfn_sync_area;
   } else {
     LOG_W(MAC,"[eNB %d] CC_id %d MBSFN Subframe Config pattern %d not found \n ", module_idP, CC_id, mbsfn_sync_area);
@@ -80,9 +81,9 @@ int schedule_MBMS(module_id_t module_idP, uint8_t CC_id, frame_t frameP, sub_fra
 {
 
   int mcch_flag=0,mtch_flag=0, msi_flag=0;
-  int mbsfn_period =0;// 1<<(eNB_mac_inst[module_idP].mbsfn_SubframeConfig[0]->radioframeAllocationPeriod);
-  int mcch_period = 0;//32<<(eNB_mac_inst[module_idP].mbsfn_AreaInfo[0]->mcch_Config_r9.mcch_RepetitionPeriod_r9);
-  int mch_scheduling_period = 8<<(eNB_mac_inst[module_idP].common_channels[CC_id].pmch_Config[0]->mch_SchedulingPeriod_r9);
+  int mbsfn_period =0;// 1<<(RC.mac[module_idP]->mbsfn_SubframeConfig[0]->radioframeAllocationPeriod);
+  int mcch_period = 0;//32<<(RC.mac[module_idP]->mbsfn_AreaInfo[0]->mcch_Config_r9.mcch_RepetitionPeriod_r9);
+  int mch_scheduling_period = 8<<(RC.mac[module_idP]->common_channels[CC_id].pmch_Config[0]->mch_SchedulingPeriod_r9);
   unsigned char mcch_sdu_length;
   unsigned char header_len_mcch=0,header_len_msi=0,header_len_mtch=0, header_len_mtch_temp=0, header_len_mcch_temp=0, header_len_msi_temp=0;
   int ii=0, msi_pos=0;
@@ -95,26 +96,26 @@ int schedule_MBMS(module_id_t module_idP, uint8_t CC_id, frame_t frameP, sub_fra
   uint16_t sdu_lengths[11], sdu_length_total=0;
   unsigned char mch_buffer[MAX_DLSCH_PAYLOAD_BYTES]; // check the max value, this is for dlsch only
 
-  eNB_mac_inst[module_idP].common_channels[CC_id].MCH_pdu.Pdu_size=0;
+  RC.mac[module_idP]->common_channels[CC_id].MCH_pdu.Pdu_size=0;
 
   for (i=0;
-       i< eNB_mac_inst[module_idP].common_channels[CC_id].num_active_mbsfn_area;
+       i< RC.mac[module_idP]->common_channels[CC_id].num_active_mbsfn_area;
        i++ ) {
     // assume, that there is always a mapping
     if ((j=get_mbsfn_sf_alloction(module_idP,CC_id,i)) == -1) {
       return 0;
     }
 
-    mbsfn_period = 1<<(eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_SubframeConfig[j]->radioframeAllocationPeriod);
-    mcch_period = 32<<(eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_RepetitionPeriod_r9);
+    mbsfn_period = 1<<(RC.mac[module_idP]->common_channels[CC_id].mbsfn_SubframeConfig[j]->radioframeAllocationPeriod);
+    mcch_period = 32<<(RC.mac[module_idP]->common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_RepetitionPeriod_r9);
     msi_pos=0;
     ii=0;
     LOG_D(MAC,"[eNB %d] CC_id %d Frame %d subframeP %d : Checking MBSFN Sync Area %d/%d with SF allocation %d/%d for MCCH and MTCH (mbsfn period %d, mcch period %d)\n",
-          module_idP, CC_id, frameP, subframeP,i,eNB_mac_inst[module_idP].common_channels[CC_id].num_active_mbsfn_area,
-          j,eNB_mac_inst[module_idP].common_channels[CC_id].num_sf_allocation_pattern,mbsfn_period,mcch_period);
+          module_idP, CC_id, frameP, subframeP,i,RC.mac[module_idP]->common_channels[CC_id].num_active_mbsfn_area,
+          j,RC.mac[module_idP]->common_channels[CC_id].num_sf_allocation_pattern,mbsfn_period,mcch_period);
 
 
-    switch (eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.signallingMCS_r9) {
+    switch (RC.mac[module_idP]->common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.signallingMCS_r9) {
     case 0:
       mcch_mcs = 2;
       break;
@@ -133,32 +134,32 @@ int schedule_MBMS(module_id_t module_idP, uint8_t CC_id, frame_t frameP, sub_fra
     }
 
     // 1st: Check the MBSFN subframes from SIB2 info (SF allocation pattern i, max 8 non-overlapping patterns exist)
-    if (frameP %  mbsfn_period == eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_SubframeConfig[j]->radioframeAllocationOffset) { // MBSFN frameP
-      if (eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_SubframeConfig[j]->subframeAllocation.present == MBSFN_SubframeConfig__subframeAllocation_PR_oneFrame) { // one-frameP format
+    if (frameP %  mbsfn_period == RC.mac[module_idP]->common_channels[CC_id].mbsfn_SubframeConfig[j]->radioframeAllocationOffset) { // MBSFN frameP
+      if (RC.mac[module_idP]->common_channels[CC_id].mbsfn_SubframeConfig[j]->subframeAllocation.present == MBSFN_SubframeConfig__subframeAllocation_PR_oneFrame) { // one-frameP format
 
         //  Find the first subframeP in this MCH to transmit MSI
-        if (frameP % mch_scheduling_period == eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_SubframeConfig[j]->radioframeAllocationOffset ) {
+        if (frameP % mch_scheduling_period == RC.mac[module_idP]->common_channels[CC_id].mbsfn_SubframeConfig[j]->radioframeAllocationOffset ) {
           while (ii == 0) {
-            ii = eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & (0x80>>msi_pos);
+            ii = RC.mac[module_idP]->common_channels[CC_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & (0x80>>msi_pos);
             msi_pos++;
           }
 
           LOG_D(MAC,"[eNB %d] CC_id %d Frame %d subframeP %d : sync area %d sf allocation pattern %d sf alloc %x msi pos is %d \n",
                 module_idP, CC_id, frameP, subframeP,i,j,
-                eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0], msi_pos);
+                RC.mac[module_idP]->common_channels[CC_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0], msi_pos);
         }
 
         // Check if the subframeP is for MSI, MCCH or MTCHs and Set the correspoding flag to 1
         switch (subframeP) {
         case 1:
           if (mac_xface->frame_parms->frame_type == FDD) {
-            if ((eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF1) == MBSFN_FDD_SF1) {
+            if ((RC.mac[module_idP]->common_channels[CC_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF1) == MBSFN_FDD_SF1) {
               if (msi_pos == 1) {
                 msi_flag = 1;
               }
 
-              if ( (frameP % mcch_period == eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) &&
-                   ((eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF1) == MBSFN_FDD_SF1) ) {
+              if ( (frameP % mcch_period == RC.mac[module_idP]->common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) &&
+                   ((RC.mac[module_idP]->common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF1) == MBSFN_FDD_SF1) ) {
                 mcch_flag = 1;
               }
 
@@ -170,13 +171,13 @@ int schedule_MBMS(module_id_t module_idP, uint8_t CC_id, frame_t frameP, sub_fra
 
         case 2:
           if (mac_xface->frame_parms->frame_type == FDD) {
-            if ((eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF2) == MBSFN_FDD_SF2) {
+            if ((RC.mac[module_idP]->common_channels[CC_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF2) == MBSFN_FDD_SF2) {
               if (msi_pos == 2) {
                 msi_flag = 1;
               }
 
-              if ( (frameP % mcch_period == eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) &&
-                   ((eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF2) == MBSFN_FDD_SF2) ) {
+              if ( (frameP % mcch_period == RC.mac[module_idP]->common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) &&
+                   ((RC.mac[module_idP]->common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF2) == MBSFN_FDD_SF2) ) {
                 mcch_flag = 1;
               }
 
@@ -188,26 +189,26 @@ int schedule_MBMS(module_id_t module_idP, uint8_t CC_id, frame_t frameP, sub_fra
 
         case 3:
           if (mac_xface->frame_parms->frame_type == TDD) { // TDD
-            if ((eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF3) == MBSFN_TDD_SF3) {
+            if ((RC.mac[module_idP]->common_channels[CC_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF3) == MBSFN_TDD_SF3) {
               if (msi_pos == 1) {
                 msi_flag = 1;
               }
 
-              if ( (frameP % mcch_period == eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) &&
-                   ((eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF3) == MBSFN_TDD_SF3) ) {
+              if ( (frameP % mcch_period == RC.mac[module_idP]->common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) &&
+                   ((RC.mac[module_idP]->common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF3) == MBSFN_TDD_SF3) ) {
                 mcch_flag = 1;
               }
 
               mtch_flag = 1;
             }
           } else { // FDD
-            if ((eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF3) == MBSFN_FDD_SF3) {
+            if ((RC.mac[module_idP]->common_channels[CC_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF3) == MBSFN_FDD_SF3) {
               if (msi_pos == 3) {
                 msi_flag = 1;
               }
 
-              if ( (frameP % mcch_period == eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) &&
-                   ((eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF3) == MBSFN_FDD_SF3) ) {
+              if ( (frameP % mcch_period == RC.mac[module_idP]->common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) &&
+                   ((RC.mac[module_idP]->common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF3) == MBSFN_FDD_SF3) ) {
                 mcch_flag = 1;
               }
 
@@ -219,13 +220,13 @@ int schedule_MBMS(module_id_t module_idP, uint8_t CC_id, frame_t frameP, sub_fra
 
         case 4:
           if (mac_xface->frame_parms->frame_type == TDD) {
-            if ((eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF4) == MBSFN_TDD_SF4) {
+            if ((RC.mac[module_idP]->common_channels[CC_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF4) == MBSFN_TDD_SF4) {
               if (msi_pos == 2) {
                 msi_flag = 1;
               }
 
-              if ( (frameP % mcch_period == eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) &&
-                   ((eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF4) == MBSFN_TDD_SF4) ) {
+              if ( (frameP % mcch_period == RC.mac[module_idP]->common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) &&
+                   ((RC.mac[module_idP]->common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF4) == MBSFN_TDD_SF4) ) {
                 mcch_flag = 1;
               }
 
@@ -237,13 +238,13 @@ int schedule_MBMS(module_id_t module_idP, uint8_t CC_id, frame_t frameP, sub_fra
 
         case 6:
           if (mac_xface->frame_parms->frame_type == FDD) {
-            if ((eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF6) == MBSFN_FDD_SF6) {
+            if ((RC.mac[module_idP]->common_channels[CC_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF6) == MBSFN_FDD_SF6) {
               if (msi_pos == 4) {
                 msi_flag = 1;
               }
 
-              if ( (frameP % mcch_period == eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) &&
-                   ((eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF6) == MBSFN_FDD_SF6) ) {
+              if ( (frameP % mcch_period == RC.mac[module_idP]->common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) &&
+                   ((RC.mac[module_idP]->common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF6) == MBSFN_FDD_SF6) ) {
                 mcch_flag = 1;
               }
 
@@ -255,26 +256,26 @@ int schedule_MBMS(module_id_t module_idP, uint8_t CC_id, frame_t frameP, sub_fra
 
         case 7:
           if (mac_xface->frame_parms->frame_type == TDD) { // TDD
-            if ((eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF7) == MBSFN_TDD_SF7) {
+            if ((RC.mac[module_idP]->common_channels[CC_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF7) == MBSFN_TDD_SF7) {
               if (msi_pos == 3) {
                 msi_flag = 1;
               }
 
-              if ( (frameP % mcch_period == eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) &&
-                   ((eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF7) == MBSFN_TDD_SF7) ) {
+              if ( (frameP % mcch_period == RC.mac[module_idP]->common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) &&
+                   ((RC.mac[module_idP]->common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF7) == MBSFN_TDD_SF7) ) {
                 mcch_flag = 1;
               }
 
               mtch_flag = 1;
             }
           } else { // FDD
-            if ((eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF7) == MBSFN_FDD_SF7) {
+            if ((RC.mac[module_idP]->common_channels[CC_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF7) == MBSFN_FDD_SF7) {
               if (msi_pos == 5) {
                 msi_flag = 1;
               }
 
-              if ( (frameP % mcch_period == eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) &&
-                   ((eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF7) == MBSFN_FDD_SF7) ) {
+              if ( (frameP % mcch_period == RC.mac[module_idP]->common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) &&
+                   ((RC.mac[module_idP]->common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF7) == MBSFN_FDD_SF7) ) {
                 mcch_flag = 1;
               }
 
@@ -286,26 +287,26 @@ int schedule_MBMS(module_id_t module_idP, uint8_t CC_id, frame_t frameP, sub_fra
 
         case 8:
           if (mac_xface->frame_parms->frame_type == TDD) { //TDD
-            if ((eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF8) == MBSFN_TDD_SF8) {
+            if ((RC.mac[module_idP]->common_channels[CC_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF8) == MBSFN_TDD_SF8) {
               if (msi_pos == 4) {
                 msi_flag = 1;
               }
 
-              if ( (frameP % mcch_period == eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) &&
-                   ((eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF8) == MBSFN_TDD_SF8) ) {
+              if ( (frameP % mcch_period == RC.mac[module_idP]->common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) &&
+                   ((RC.mac[module_idP]->common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF8) == MBSFN_TDD_SF8) ) {
                 mcch_flag = 1;
               }
 
               mtch_flag = 1;
             }
           } else { // FDD
-            if ((eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF8) == MBSFN_FDD_SF8) {
+            if ((RC.mac[module_idP]->common_channels[CC_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF8) == MBSFN_FDD_SF8) {
               if (msi_pos == 6) {
                 msi_flag = 1;
               }
 
-              if ( (frameP % mcch_period == eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) &&
-                   ((eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF8) == MBSFN_FDD_SF8) ) {
+              if ( (frameP % mcch_period == RC.mac[module_idP]->common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) &&
+                   ((RC.mac[module_idP]->common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF8) == MBSFN_FDD_SF8) ) {
                 mcch_flag = 1;
               }
 
@@ -317,13 +318,13 @@ int schedule_MBMS(module_id_t module_idP, uint8_t CC_id, frame_t frameP, sub_fra
 
         case 9:
           if (mac_xface->frame_parms->frame_type == TDD) {
-            if ((eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF9) == MBSFN_TDD_SF9) {
+            if ((RC.mac[module_idP]->common_channels[CC_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF9) == MBSFN_TDD_SF9) {
               if (msi_pos == 5) {
                 msi_flag = 1;
               }
 
-              if ( (frameP % mcch_period == eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) &&
-                   ((eNB_mac_inst[module_idP].common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF9) == MBSFN_TDD_SF9) ) {
+              if ( (frameP % mcch_period == RC.mac[module_idP]->common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) &&
+                   ((RC.mac[module_idP]->common_channels[CC_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF9) == MBSFN_TDD_SF9) ) {
                 mcch_flag = 1;
               }
 
@@ -345,15 +346,15 @@ int schedule_MBMS(module_id_t module_idP, uint8_t CC_id, frame_t frameP, sub_fra
     }
   } // end of for loop
 
-  eNB_mac_inst[module_idP].common_channels[CC_id].msi_active=0;
-  eNB_mac_inst[module_idP].common_channels[CC_id].mcch_active=0;
-  eNB_mac_inst[module_idP].common_channels[CC_id].mtch_active=0;
+  RC.mac[module_idP]->common_channels[CC_id].msi_active=0;
+  RC.mac[module_idP]->common_channels[CC_id].mcch_active=0;
+  RC.mac[module_idP]->common_channels[CC_id].mtch_active=0;
 
   // Calculate the mcs
   if ((msi_flag==1) || (mcch_flag==1)) {
-    eNB_mac_inst[module_idP].common_channels[CC_id].MCH_pdu.mcs = mcch_mcs;
+    RC.mac[module_idP]->common_channels[CC_id].MCH_pdu.mcs = mcch_mcs;
   } else if (mtch_flag == 1) { // only MTCH in this subframeP
-    eNB_mac_inst[module_idP].common_channels[CC_id].MCH_pdu.mcs = eNB_mac_inst[module_idP].common_channels[CC_id].pmch_Config[0]->dataMCS_r9;
+    RC.mac[module_idP]->common_channels[CC_id].MCH_pdu.mcs = RC.mac[module_idP]->common_channels[CC_id].pmch_Config[0]->dataMCS_r9;
   }
 
 
@@ -378,10 +379,10 @@ int schedule_MBMS(module_id_t module_idP, uint8_t CC_id, frame_t frameP, sub_fra
     msi_ptr+= sizeof(MSI_ELEMENT);
 
     //Header for MTCHs
-    num_mtch = eNB_mac_inst[module_idP].common_channels[CC_id].mbms_SessionList[0]->list.count;
+    num_mtch = RC.mac[module_idP]->common_channels[CC_id].mbms_SessionList[0]->list.count;
 
     for (k=0; k<num_mtch; k++) { // loop for all session in this MCH (MCH[0]) at this moment
-      ((MSI_ELEMENT *) msi_ptr)->lcid = eNB_mac_inst[module_idP].common_channels[CC_id].mbms_SessionList[0]->list.array[k]->logicalChannelIdentity_r9;//mtch_lcid;
+      ((MSI_ELEMENT *) msi_ptr)->lcid = RC.mac[module_idP]->common_channels[CC_id].mbms_SessionList[0]->list.array[k]->logicalChannelIdentity_r9;//mtch_lcid;
       ((MSI_ELEMENT *) msi_ptr)->stop_sf_MSB = 0; // last subframeP of this mtch (only one mtch now)
       ((MSI_ELEMENT *) msi_ptr)->stop_sf_LSB = 0xB;
       msi_ptr+=sizeof(MSI_ELEMENT);
@@ -410,7 +411,7 @@ int schedule_MBMS(module_id_t module_idP, uint8_t CC_id, frame_t frameP, sub_fra
     sdu_length_total += sdu_lengths[num_sdus];
     LOG_I(MAC,"[eNB %d] CC_id %d Create %d bytes for MSI\n", module_idP, CC_id, sdu_lengths[num_sdus]);
     num_sdus++;
-    eNB_mac_inst[module_idP].common_channels[CC_id].msi_active=1;
+    RC.mac[module_idP]->common_channels[CC_id].msi_active=1;
   }
 
   // there is MCCH
@@ -422,7 +423,7 @@ int schedule_MBMS(module_id_t module_idP, uint8_t CC_id, frame_t frameP, sub_fra
                                        CC_id,
                                        frameP,
                                        MCCH,1,
-                                       &eNB_mac_inst[module_idP].common_channels[CC_id].MCCH_pdu.payload[0],
+                                       &RC.mac[module_idP]->common_channels[CC_id].MCCH_pdu.payload[0],
                                        1,// this is eNB
                                        module_idP, // index
                                        i); // this is the mbsfn sync area index
@@ -447,10 +448,10 @@ int schedule_MBMS(module_id_t module_idP, uint8_t CC_id, frame_t frameP, sub_fra
               mcch_mcs);
       }
 
-      eNB_mac_inst[module_idP].common_channels[CC_id].mcch_active=1;
+      RC.mac[module_idP]->common_channels[CC_id].mcch_active=1;
 
       memcpy((char *)&mch_buffer[sdu_length_total],
-             &eNB_mac_inst[module_idP].common_channels[CC_id].MCCH_pdu.payload[0],
+             &RC.mac[module_idP]->common_channels[CC_id].MCCH_pdu.payload[0],
              mcch_sdu_length);
       sdu_lcids[num_sdus] = MCCH_LCHANID;
       sdu_lengths[num_sdus] = mcch_sdu_length;
@@ -465,11 +466,11 @@ int schedule_MBMS(module_id_t module_idP, uint8_t CC_id, frame_t frameP, sub_fra
     }
   }
 
-  TBS = mac_xface->get_TBS_DL(eNB_mac_inst[module_idP].common_channels[CC_id].MCH_pdu.mcs, mac_xface->frame_parms->N_RB_DL);
+  TBS = mac_xface->get_TBS_DL(RC.mac[module_idP]->common_channels[CC_id].MCH_pdu.mcs, mac_xface->frame_parms->N_RB_DL);
 #ifdef Rel10
   // do not let mcch and mtch multiplexing when relaying is active
   // for sync area 1, so not transmit data
-  //if ((i == 0) && ((eNB_mac_inst[module_idP].MBMS_flag != multicast_relay) || (eNB_mac_inst[module_idP].mcch_active==0))) {
+  //if ((i == 0) && ((RC.mac[module_idP]->MBMS_flag != multicast_relay) || (RC.mac[module_idP]->mcch_active==0))) {
 #endif
 
   // there is MTCHs, loop if there are more than 1
@@ -479,7 +480,7 @@ int schedule_MBMS(module_id_t module_idP, uint8_t CC_id, frame_t frameP, sub_fra
      TBS = mac_xface->get_TBS(mcch_mcs, mac_xface->frame_parms->N_RB_DL);
      }
      else { // only MTCH in this subframeP
-     TBS = mac_xface->get_TBS(eNB_mac_inst[module_idP].pmch_Config[0]->dataMCS_r9, mac_xface->frame_parms->N_RB_DL);
+     TBS = mac_xface->get_TBS(RC.mac[module_idP]->pmch_Config[0]->dataMCS_r9, mac_xface->frame_parms->N_RB_DL);
      }
 
     // get MTCH data from RLC (like for DTCH)
@@ -524,7 +525,7 @@ int schedule_MBMS(module_id_t module_idP, uint8_t CC_id, frame_t frameP, sub_fra
                                 (char*)&mch_buffer[sdu_length_total]);
       //sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP,frameP, MBMS_FLAG_NO,  MTCH+(MAX_NUM_RB*(NUMBER_OF_UE_MAX+1)), (char*)&mch_buffer[sdu_length_total]);
       LOG_I(MAC,"[eNB %d][MBMS USER-PLANE] CC_id %d Got %d bytes for MTCH %d\n",module_idP,CC_id,sdu_lengths[num_sdus],MTCH);
-      eNB_mac_inst[module_idP].common_channels[CC_id].mtch_active=1;
+      RC.mac[module_idP]->common_channels[CC_id].mtch_active=1;
       sdu_lcids[num_sdus] = MTCH;
       sdu_length_total += sdu_lengths[num_sdus];
 
@@ -546,10 +547,10 @@ int schedule_MBMS(module_id_t module_idP, uint8_t CC_id, frame_t frameP, sub_fra
   if ((sdu_length_total + header_len_msi + header_len_mcch + header_len_mtch) >0) {
     // Adjust the last subheader
     /*                                 if ((msi_flag==1) || (mcch_flag==1)) {
-                                       eNB_mac_inst[module_idP].MCH_pdu.mcs = mcch_mcs;
+                                       RC.mac[module_idP]->MCH_pdu.mcs = mcch_mcs;
                                         }
                                       else if (mtch_flag == 1) { // only MTCH in this subframeP
-                                     eNB_mac_inst[module_idP].MCH_pdu.mcs = eNB_mac_inst[module_idP].pmch_Config[0]->dataMCS_r9;
+                                     RC.mac[module_idP]->MCH_pdu.mcs = RC.mac[module_idP]->pmch_Config[0]->dataMCS_r9;
                                         }
      */
     header_len_mtch_temp = header_len_mtch;
@@ -588,7 +589,7 @@ int schedule_MBMS(module_id_t module_idP, uint8_t CC_id, frame_t frameP, sub_fra
 
     // Generate the MAC Header for MCH
     // here we use the function for DLSCH because DLSCH & MCH have the same Header structure
-    offset = generate_dlsch_header((unsigned char*)eNB_mac_inst[module_idP].common_channels[CC_id].MCH_pdu.payload,
+    offset = generate_dlsch_header((unsigned char*)RC.mac[module_idP]->common_channels[CC_id].MCH_pdu.payload,
                                    num_sdus,
                                    sdu_lengths,
                                    sdu_lcids,
@@ -598,48 +599,48 @@ int schedule_MBMS(module_id_t module_idP, uint8_t CC_id, frame_t frameP, sub_fra
                                    padding,
                                    post_padding);
 
-    eNB_mac_inst[module_idP].common_channels[CC_id].MCH_pdu.Pdu_size=TBS;
-    eNB_mac_inst[module_idP].common_channels[CC_id].MCH_pdu.sync_area=i;
-    eNB_mac_inst[module_idP].common_channels[CC_id].MCH_pdu.msi_active= eNB_mac_inst[module_idP].common_channels[CC_id].msi_active;
-    eNB_mac_inst[module_idP].common_channels[CC_id].MCH_pdu.mcch_active= eNB_mac_inst[module_idP].common_channels[CC_id].mcch_active;
-    eNB_mac_inst[module_idP].common_channels[CC_id].MCH_pdu.mtch_active= eNB_mac_inst[module_idP].common_channels[CC_id].mtch_active;
-    LOG_D(MAC," MCS for this sf is %d (mcch active %d, mtch active %d)\n", eNB_mac_inst[module_idP].common_channels[CC_id].MCH_pdu.mcs,
-          eNB_mac_inst[module_idP].common_channels[CC_id].MCH_pdu.mcch_active,eNB_mac_inst[module_idP].common_channels[CC_id].MCH_pdu.mtch_active );
+    RC.mac[module_idP]->common_channels[CC_id].MCH_pdu.Pdu_size=TBS;
+    RC.mac[module_idP]->common_channels[CC_id].MCH_pdu.sync_area=i;
+    RC.mac[module_idP]->common_channels[CC_id].MCH_pdu.msi_active= RC.mac[module_idP]->common_channels[CC_id].msi_active;
+    RC.mac[module_idP]->common_channels[CC_id].MCH_pdu.mcch_active= RC.mac[module_idP]->common_channels[CC_id].mcch_active;
+    RC.mac[module_idP]->common_channels[CC_id].MCH_pdu.mtch_active= RC.mac[module_idP]->common_channels[CC_id].mtch_active;
+    LOG_D(MAC," MCS for this sf is %d (mcch active %d, mtch active %d)\n", RC.mac[module_idP]->common_channels[CC_id].MCH_pdu.mcs,
+          RC.mac[module_idP]->common_channels[CC_id].MCH_pdu.mcch_active,RC.mac[module_idP]->common_channels[CC_id].MCH_pdu.mtch_active );
     LOG_I(MAC,
           "[eNB %d][MBMS USER-PLANE ] CC_id %d Generate header : sdu_length_total %d, num_sdus %d, sdu_lengths[0] %d, sdu_lcids[0] %d => payload offset %d,padding %d,post_padding %d (mcs %d, TBS %d), header MTCH %d, header MCCH %d, header MSI %d\n",
-          module_idP,CC_id,sdu_length_total,num_sdus,sdu_lengths[0],sdu_lcids[0],offset,padding,post_padding,eNB_mac_inst[module_idP].common_channels[CC_id].MCH_pdu.mcs,TBS,
+          module_idP,CC_id,sdu_length_total,num_sdus,sdu_lengths[0],sdu_lcids[0],offset,padding,post_padding,RC.mac[module_idP]->common_channels[CC_id].MCH_pdu.mcs,TBS,
           header_len_mtch, header_len_mcch, header_len_msi);
     // copy SDU to mch_pdu after the MAC Header
-    memcpy(&eNB_mac_inst[module_idP].common_channels[CC_id].MCH_pdu.payload[offset],mch_buffer,sdu_length_total);
+    memcpy(&RC.mac[module_idP]->common_channels[CC_id].MCH_pdu.payload[offset],mch_buffer,sdu_length_total);
 
     // filling remainder of MCH with random data if necessery
     for (j=0; j<(TBS-sdu_length_total-offset); j++) {
-      eNB_mac_inst[module_idP].common_channels[CC_id].MCH_pdu.payload[offset+sdu_length_total+j] = (char)(taus()&0xff);
+      RC.mac[module_idP]->common_channels[CC_id].MCH_pdu.payload[offset+sdu_length_total+j] = (char)(taus()&0xff);
     }
 
     /* Tracing of PDU is done on UE side */
     if (opt_enabled ==1 ) {
-      trace_pdu(1, (uint8_t *)eNB_mac_inst[module_idP].common_channels[CC_id].MCH_pdu.payload,
+      trace_pdu(1, (uint8_t *)RC.mac[module_idP]->common_channels[CC_id].MCH_pdu.payload,
                 TBS, module_idP, 6, 0xffff,  // M_RNTI = 6 in wirehsark
-                eNB_mac_inst[module_idP].frame, eNB_mac_inst[module_idP].subframe,0,0);
+                RC.mac[module_idP]->frame, RC.mac[module_idP]->subframe,0,0);
       LOG_D(OPT,"[eNB %d][MCH] CC_id %d Frame %d : MAC PDU with size %d\n",
             module_idP, CC_id, frameP, TBS);
     }
 
     /*
     for (j=0;j<sdu_length_total;j++)
-    printf("%2x.",eNB_mac_inst[module_idP].MCH_pdu.payload[j+offset]);
+    printf("%2x.",RC.mac[module_idP]->MCH_pdu.payload[j+offset]);
     printf(" \n");*/
     return 1;
   } else {
-    eNB_mac_inst[module_idP].common_channels[CC_id].MCH_pdu.Pdu_size=0;
-    eNB_mac_inst[module_idP].common_channels[CC_id].MCH_pdu.sync_area=0;
-    eNB_mac_inst[module_idP].common_channels[CC_id].MCH_pdu.msi_active=0;
-    eNB_mac_inst[module_idP].common_channels[CC_id].MCH_pdu.mcch_active=0;
-    eNB_mac_inst[module_idP].common_channels[CC_id].MCH_pdu.mtch_active=0;
+    RC.mac[module_idP]->common_channels[CC_id].MCH_pdu.Pdu_size=0;
+    RC.mac[module_idP]->common_channels[CC_id].MCH_pdu.sync_area=0;
+    RC.mac[module_idP]->common_channels[CC_id].MCH_pdu.msi_active=0;
+    RC.mac[module_idP]->common_channels[CC_id].MCH_pdu.mcch_active=0;
+    RC.mac[module_idP]->common_channels[CC_id].MCH_pdu.mtch_active=0;
     // for testing purpose, fill with random data
     //for (j=0;j<(TBS-sdu_length_total-offset);j++)
-    //  eNB_mac_inst[module_idP].MCH_pdu.payload[offset+sdu_length_total+j] = (char)(taus()&0xff);
+    //  RC.mac[module_idP]->MCH_pdu.payload[offset+sdu_length_total+j] = (char)(taus()&0xff);
     return 0;
   }
 
@@ -656,10 +657,10 @@ int schedule_MBMS(module_id_t module_idP, uint8_t CC_id, frame_t frameP, sub_fra
 
 MCH_PDU *get_mch_sdu(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t subframeP)
 {
-  //  eNB_mac_inst[module_idP].MCH_pdu.mcs=0;
-  //LOG_D(MAC," MCH_pdu.mcs is %d\n", eNB_mac_inst[module_idP].MCH_pdu.mcs);
+  //  RC.mac[module_idP]->MCH_pdu.mcs=0;
+  //LOG_D(MAC," MCH_pdu.mcs is %d\n", RC.mac[module_idP]->MCH_pdu.mcs);
 //#warning "MCH pdu should take the CC_id index"
-  return(&eNB_mac_inst[module_idP].common_channels[CC_id].MCH_pdu);
+  return(&RC.mac[module_idP]->common_channels[CC_id].MCH_pdu);
 }
 
 #endif
diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c
index da9e8572ba..0b01759e18 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c
@@ -99,7 +99,7 @@ DCI_PDU *get_dci_sdu(module_id_t module_idP, int CC_id,frame_t frameP, sub_frame
 //------------------------------------------------------------------------------
 {
 
-  return(&eNB_mac_inst[module_idP].common_channels[CC_id].DCI_pdu);
+  return(&RC.mac[module_idP]->common_channels[CC_id].DCI_pdu);
 
 }
 
@@ -108,7 +108,7 @@ int find_UE_id(module_id_t mod_idP, rnti_t rntiP)
 //------------------------------------------------------------------------------
 {
   int UE_id;
-  UE_list_t *UE_list = &eNB_mac_inst[mod_idP].UE_list;
+  UE_list_t *UE_list = &RC.mac[mod_idP]->UE_list;
 
   for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) {
     if (UE_list->active[UE_id] != TRUE) continue;
@@ -131,7 +131,7 @@ int UE_num_active_CC(UE_list_t *listP,int ue_idP)
 int UE_PCCID(module_id_t mod_idP,int ue_idP)
 //------------------------------------------------------------------------------
 {
-  return(eNB_mac_inst[mod_idP].UE_list.pCC_id[ue_idP]);
+  return(RC.mac[mod_idP]->UE_list.pCC_id[ue_idP]);
 }
 
 //------------------------------------------------------------------------------
@@ -139,7 +139,7 @@ rnti_t UE_RNTI(module_id_t mod_idP, int ue_idP)
 //------------------------------------------------------------------------------
 {
 
-  rnti_t rnti = eNB_mac_inst[mod_idP].UE_list.UE_template[UE_PCCID(mod_idP,ue_idP)][ue_idP].rnti;
+  rnti_t rnti = RC.mac[mod_idP]->UE_list.UE_template[UE_PCCID(mod_idP,ue_idP)][ue_idP].rnti;
 
   if (rnti>0) {
     return (rnti);
@@ -154,7 +154,7 @@ rnti_t UE_RNTI(module_id_t mod_idP, int ue_idP)
 boolean_t is_UE_active(module_id_t mod_idP, int ue_idP)
 //------------------------------------------------------------------------------
 {
-  return(eNB_mac_inst[mod_idP].UE_list.active[ue_idP]);
+  return(RC.mac[mod_idP]->UE_list.active[ue_idP]);
 }
 
 /*
@@ -227,7 +227,7 @@ uint8_t find_num_active_UEs_in_cbagroup(module_id_t module_idP, int CC_id,unsign
   unsigned char nb_ue_in_pusch=0;
   LTE_eNB_UE_stats* eNB_UE_stats;
 
-  for (UE_id=group_id;UE_id<NUMBER_OF_UE_MAX;UE_id+=eNB_mac_inst[module_idP].common_channels[CC_id].num_active_cba_groups) {
+  for (UE_id=group_id;UE_id<NUMBER_OF_UE_MAX;UE_id+=RC.mac[module_idP]->common_channels[CC_id].num_active_cba_groups) {
 
       if (((rnti=eNB_mac_inst[module_idP][CC_id].UE_template[UE_id].rnti) !=0) &&
           (eNB_mac_inst[module_idP][CC_id].UE_template[UE_id].ul_active==TRUE)    &&
@@ -266,7 +266,7 @@ int add_new_ue(module_id_t mod_idP, int cc_idP, rnti_t rntiP,int harq_pidP)
   int UE_id;
   int i, j;
 
-  UE_list_t *UE_list = &eNB_mac_inst[mod_idP].UE_list;
+  UE_list_t *UE_list = &RC.mac[mod_idP]->UE_list;
 
   LOG_D(MAC,"[eNB %d, CC_id %d] Adding UE with rnti %x (next avail %d, num_UEs %d)\n",mod_idP,cc_idP,rntiP,UE_list->avail,UE_list->num_UEs);
   dump_ue_list(UE_list,0);
@@ -309,7 +309,7 @@ int rrc_mac_remove_ue(module_id_t mod_idP,rnti_t rntiP)
 //------------------------------------------------------------------------------
 {
   int i;
-  UE_list_t *UE_list = &eNB_mac_inst[mod_idP].UE_list;
+  UE_list_t *UE_list = &RC.mac[mod_idP]->UE_list;
   int UE_id = find_UE_id(mod_idP,rntiP);
   int pCC_id;
 
@@ -348,7 +348,7 @@ printf("MAC: remove UE %d rnti %x\n", UE_id, rntiP);
   // check if this has an RA process active
   RA_TEMPLATE *RA_template;
   for (i=0;i<NB_RA_PROC_MAX;i++) {
-    RA_template = (RA_TEMPLATE *)&eNB_mac_inst[mod_idP].common_channels[pCC_id].RA_template[i];
+    RA_template = (RA_TEMPLATE *)&RC.mac[mod_idP]->common_channels[pCC_id].RA_template[i];
     if (RA_template->rnti == rntiP){
       RA_template->RA_active=FALSE;
       RA_template->generate_rar=0;
@@ -681,8 +681,8 @@ void add_ue_spec_dci(DCI_PDU *DCI_pdu,void *pdu,rnti_t rnti,unsigned char dci_si
 uint8_t UE_is_to_be_scheduled(module_id_t module_idP,int CC_id,uint8_t UE_id)
 {
 
-  UE_TEMPLATE *UE_template    = &eNB_mac_inst[module_idP].UE_list.UE_template[CC_id][UE_id];
-  UE_sched_ctrl *UE_sched_ctl = &eNB_mac_inst[module_idP].UE_list.UE_sched_ctrl[UE_id];
+  UE_TEMPLATE *UE_template    = &RC.mac[module_idP]->UE_list.UE_template[CC_id][UE_id];
+  UE_sched_ctrl *UE_sched_ctl = &RC.mac[module_idP]->UE_list.UE_sched_ctrl[UE_id];
 
 
   // do not schedule UE if UL is not working
@@ -905,7 +905,7 @@ int get_nb_subband(void)
 
 void init_CCE_table(int module_idP,int CC_idP)
 {
-  memset(eNB_mac_inst[module_idP].CCE_table[CC_idP],0,800*sizeof(int));
+  memset(RC.mac[module_idP]->CCE_table[CC_idP],0,800*sizeof(int));
 } 
 
 
@@ -1056,8 +1056,8 @@ int allocate_CCEs(int module_idP,
 		  int test_onlyP) {
 
 
-  int *CCE_table = eNB_mac_inst[module_idP].CCE_table[CC_idP];
-  DCI_PDU *DCI_pdu = &eNB_mac_inst[module_idP].common_channels[CC_idP].DCI_pdu;
+  int *CCE_table = RC.mac[module_idP]->CCE_table[CC_idP];
+  DCI_PDU *DCI_pdu = &RC.mac[module_idP]->common_channels[CC_idP].DCI_pdu;
   int nCCE_max = mac_xface->get_nCCE_max(module_idP,CC_idP,1,subframeP);
   int fCCE;
   int i,j;
@@ -1137,7 +1137,7 @@ boolean_t CCE_allocation_infeasible(int module_idP,
 				    int rnti) {
 
 
-  DCI_PDU *DCI_pdu = &eNB_mac_inst[module_idP].common_channels[CC_idP].DCI_pdu;
+  DCI_PDU *DCI_pdu = &RC.mac[module_idP]->common_channels[CC_idP].DCI_pdu;
   //DCI_ALLOC_t *dci_alloc;
   int ret;
   boolean_t res=FALSE;
@@ -1167,7 +1167,7 @@ void SR_indication(module_id_t mod_idP, int cc_idP, frame_t frameP, rnti_t rntiP
 {
  
   int UE_id = find_UE_id(mod_idP, rntiP);
-  UE_list_t *UE_list = &eNB_mac_inst[mod_idP].UE_list;
+  UE_list_t *UE_list = &RC.mac[mod_idP]->UE_list;
  
   if (UE_id  != -1) {
     if (mac_eNB_get_rrc_status(mod_idP,UE_RNTI(mod_idP,UE_id)) < RRC_CONNECTED)
@@ -1187,7 +1187,7 @@ void UL_failure_indication(module_id_t mod_idP, int cc_idP, frame_t frameP, rnti
 {
 
   int UE_id = find_UE_id(mod_idP, rntiP);
-  UE_list_t *UE_list = &eNB_mac_inst[mod_idP].UE_list;
+  UE_list_t *UE_list = &RC.mac[mod_idP]->UE_list;
 
   if (UE_id  != -1) {
     LOG_I(MAC,"[eNB %d][UE %d/%x] Frame %d subframeP %d Signaling UL Failure for UE %d on CC_id %d (timer %d)\n",
diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c
index 6d0044b346..282b802f3f 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c
@@ -79,7 +79,7 @@ void rx_sdu(const module_id_t enb_mod_idP,
   unsigned short rx_lengths[NB_RB_MAX];
   int    UE_id = find_UE_id(enb_mod_idP,rntiP);
   int ii,j;
-  eNB_MAC_INST *eNB = &eNB_mac_inst[enb_mod_idP];
+  eNB_MAC_INST *eNB = RC.mac[enb_mod_idP];
   UE_list_t *UE_list= &eNB->UE_list;
   int crnti_rx=0;
   int old_buffer_info;
@@ -186,9 +186,9 @@ void rx_sdu(const module_id_t enb_mod_idP,
 
 	UE_list->UE_template[CC_idP][UE_id].ul_total_buffer= UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[lcgid];
 
-	PHY_vars_eNB_g[enb_mod_idP][CC_idP]->pusch_stats_bsr[UE_id][(frameP*10)+subframeP] = (payload_ptr[0] & 0x3f);
+	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,PHY_vars_eNB_g[enb_mod_idP][CC_idP]->pusch_stats_bsr[UE_id][(frameP*10)+subframeP]);	
+	  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;
         }
@@ -614,7 +614,7 @@ void set_msg3_subframe(module_id_t Mod_id,
                        int Msg3_frame,
                        int Msg3_subframe)
 {
-  eNB_MAC_INST *eNB=&eNB_mac_inst[Mod_id];
+  eNB_MAC_INST *eNB=RC.mac[Mod_id];
   int i;
   for (i=0; i<NB_RA_PROC_MAX; i++) {
     if (eNB->common_channels[CC_id].RA_template[i].RA_active == TRUE &&
@@ -635,7 +635,7 @@ void schedule_ulsch(module_id_t module_idP,
 
   uint16_t first_rb[MAX_NUM_CCs],i;
   int CC_id;
-  eNB_MAC_INST *eNB=&eNB_mac_inst[module_idP];
+  eNB_MAC_INST *eNB=RC.mac[module_idP];
 
   start_meas(&eNB->schedule_ulsch);
 
@@ -715,7 +715,7 @@ void schedule_ulsch_rnti(module_id_t   module_idP,
   static int32_t          tpc_accumulated=0;
 
   int n,CC_id = 0;
-  eNB_MAC_INST      *eNB=&eNB_mac_inst[module_idP];
+  eNB_MAC_INST      *eNB=RC.mac[module_idP];
   UE_list_t         *UE_list=&eNB->UE_list;
   UE_TEMPLATE       *UE_template;
   UE_sched_ctrl     *UE_sched_ctrl;
@@ -817,8 +817,8 @@ abort();
           LOG_T(MAC,"[eNB %d] Frame %d, subframeP %d, UE %d CC %d : got harq pid %d  round %d (rnti %x,mode %s)\n",
                 module_idP,frameP,subframeP,UE_id,CC_id, harq_pid, round,rnti,mode_string[eNB_UE_stats->mode]);
 
-	PHY_vars_eNB_g[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,PHY_vars_eNB_g[module_idP][CC_id]->pusch_stats_BO[UE_id][(frameP*10)+subframeP]);	
+	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]);	
         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
         {
@@ -1195,7 +1195,7 @@ abort();
 void schedule_ulsch_cba_rnti(module_id_t module_idP, unsigned char cooperation_flag, frame_t frameP, sub_frame_t subframeP, unsigned char sched_subframe, uint16_t *first_rb)
 {
 
-  eNB_MAC_INST *eNB = &eNB_mac_inst[module_idP];
+  eNB_MAC_INST *eNB = RC.mac[module_idP];
   UE_list_t         *UE_list=&eNB->UE_list;
   //UE_TEMPLATE       *UE_template;
   void              *ULSCH_dci      = NULL;
@@ -1213,7 +1213,7 @@ void schedule_ulsch_cba_rnti(module_id_t module_idP, unsigned char cooperation_f
   uint8_t allocated_rbs=0;
   uint8_t total_UEs=UE_list->num_UEs;
   uint8_t active_UEs[NUM_MAX_CBA_GROUP];
-  uint8_t total_groups=eNB_mac_inst[module_idP].common_channels[CC_id].num_active_cba_groups;
+  uint8_t total_groups=RC.mac[module_idP]->common_channels[CC_id].num_active_cba_groups;
   int     min_rb_unit=2;
   uint8_t cba_policy=CBA_ES;
   int     UE_id;
@@ -1241,7 +1241,7 @@ void schedule_ulsch_cba_rnti(module_id_t module_idP, unsigned char cooperation_f
     frame_parms=mac_xface->get_lte_frame_parms(module_idP,CC_id);
     available_rbs=frame_parms->N_RB_DL-1-first_rb[CC_id];
     remaining_rbs=available_rbs;
-    total_groups=eNB_mac_inst[module_idP].common_channels[CC_id].num_active_cba_groups;
+    total_groups=RC.mac[module_idP]->common_channels[CC_id].num_active_cba_groups;
     min_rb_unit=get_min_rb_unit(module_idP,CC_id);
 
     if (available_rbs  < min_rb_unit )
@@ -1252,7 +1252,7 @@ void schedule_ulsch_cba_rnti(module_id_t module_idP, unsigned char cooperation_f
     // is scheduled, the correspodning group can't be used for CBA
     // this can be fixed later
     if (total_groups > 0)  {
-      DCI_pdu = &eNB_mac_inst[module_idP].common_channels[CC_id].DCI_pdu;
+      DCI_pdu = &RC.mac[module_idP]->common_channels[CC_id].DCI_pdu;
 
       for (cba_group=0;
            (cba_group<total_groups)   > (1<<aggregation));
@@ -1286,7 +1286,7 @@ void schedule_ulsch_cba_rnti(module_id_t module_idP, unsigned char cooperation_f
 
         // If the group needs some resource
         // determine the total number of allocations (one or multiple DCIs): to be refined
-        if ((active_UEs[cba_group] > 0) && (eNB_mac_inst[module_idP].common_channels[CC_id].cba_rnti[cba_group] != 0)) {
+        if ((active_UEs[cba_group] > 0) && (RC.mac[module_idP]->common_channels[CC_id].cba_rnti[cba_group] != 0)) {
           // to be refined in case of : total_UEs >> weight[cba_group]*available_rbs
 
           switch(cba_policy) {
@@ -1391,7 +1391,7 @@ void schedule_ulsch_cba_rnti(module_id_t module_idP, unsigned char cooperation_f
           first_rb[CC_id]+=rb_table[rb_table_index];
           LOG_N(MAC,
                 "[eNB %d] CC_id %d Frame %d, subframeP %d: schedule CBA access %d rnti %x, total/required/allocated/remaining rbs (%d/%d/%d/%d), mcs %d, rballoc %d\n",
-                module_idP, CC_id, frameP, subframeP, cba_group,eNB_mac_inst[module_idP].common_channels[CC_id].cba_rnti[cba_group],
+                module_idP, CC_id, frameP, subframeP, cba_group,RC.mac[module_idP]->common_channels[CC_id].cba_rnti[cba_group],
                 available_rbs, required_rbs[cba_group], allocated_rbs, remaining_rbs,
                 mcs[cba_group],rballoc);
 
@@ -1417,7 +1417,7 @@ void schedule_ulsch_cba_rnti(module_id_t module_idP, unsigned char cooperation_f
               //add_ue_spec_dci
               add_common_dci(DCI_pdu,
                              ULSCH_dci,
-                             eNB_mac_inst[module_idP].common_channels[CC_id].cba_rnti[cba_group],
+                             RC.mac[module_idP]->common_channels[CC_id].cba_rnti[cba_group],
                              sizeof(DCI0_5MHz_TDD_1_6_t),
                              aggregation,
                              sizeof_DCI0_5MHz_TDD_1_6_t,
@@ -1438,7 +1438,7 @@ void schedule_ulsch_cba_rnti(module_id_t module_idP, unsigned char cooperation_f
               //add_ue_spec_dci
               add_common_dci(DCI_pdu,
                              ULSCH_dci,
-                             eNB_mac_inst[module_idP].common_channels[CC_id].cba_rnti[cba_group],
+                             RC.mac[module_idP]->common_channels[CC_id].cba_rnti[cba_group],
                              sizeof(DCI0_5MHz_FDD_t),
                              aggregation,
                              sizeof_DCI0_5MHz_FDD_t,
@@ -1466,7 +1466,7 @@ void schedule_ulsch_cba_rnti(module_id_t module_idP, unsigned char cooperation_f
               //add_ue_spec_dci
               add_common_dci(DCI_pdu,
                              ULSCH_dci,
-                             eNB_mac_inst[module_idP].common_channels[CC_id].cba_rnti[cba_group],
+                             RC.mac[module_idP]->common_channels[CC_id].cba_rnti[cba_group],
                              sizeof(DCI0_10MHz_TDD_1_6_t),
                              aggregation,
                              sizeof_DCI0_10MHz_TDD_1_6_t,
@@ -1487,7 +1487,7 @@ void schedule_ulsch_cba_rnti(module_id_t module_idP, unsigned char cooperation_f
               //add_ue_spec_dci
               add_common_dci(DCI_pdu,
                              ULSCH_dci,
-                             eNB_mac_inst[module_idP].common_channels[CC_id].cba_rnti[cba_group],
+                             RC.mac[module_idP]->common_channels[CC_id].cba_rnti[cba_group],
                              sizeof(DCI0_10MHz_FDD_t),
                              aggregation,
                              sizeof_DCI0_10MHz_FDD_t,
diff --git a/openair2/LAYER2/MAC/extern.h b/openair2/LAYER2/MAC/extern.h
index 1da6fe5a69..4a3417d824 100644
--- a/openair2/LAYER2/MAC/extern.h
+++ b/openair2/LAYER2/MAC/extern.h
@@ -56,11 +56,8 @@ extern const uint8_t cqi2fmt1x_agg[MAX_SUPPORTED_BW][CQI_VALUE_RANGE];
 
 extern const uint8_t cqi2fmt2x_agg[MAX_SUPPORTED_BW][CQI_VALUE_RANGE];
 
-extern UE_MAC_INST *UE_mac_inst;
-extern eNB_MAC_INST *eNB_mac_inst;
-extern eNB_RRC_INST *eNB_rrc_inst;
 extern UE_RRC_INST *UE_rrc_inst;
-extern UE_MAC_INST *ue_mac_inst;
+extern UE_MAC_INST *UE_mac_inst;
 extern MAC_RLC_XFACE *Mac_rlc_xface;
 extern uint8_t Is_rrc_registered;
 
diff --git a/openair2/LAYER2/MAC/main.c b/openair2/LAYER2/MAC/main.c
index d812ec0087..dc5779185e 100644
--- a/openair2/LAYER2/MAC/main.c
+++ b/openair2/LAYER2/MAC/main.c
@@ -63,6 +63,10 @@
 
 #include "SCHED/defs.h"
 
+#include "common/ran_context.h"
+
+extern RAN_CONTEXT_t RC;
+
 void dl_phy_sync_success(module_id_t   module_idP,
                          frame_t       frameP,
                          unsigned char eNB_index,
@@ -82,27 +86,6 @@ void dl_phy_sync_success(module_id_t   module_idP,
 
 }
 
-void mrbch_phy_sync_failure(module_id_t module_idP, frame_t frameP, uint8_t free_eNB_index) //init as CH
-{
-
-  LOG_I(MAC,"[eNB %d] Frame %d: PHY Sync failure \n",module_idP,frameP);
-  layer2_init_eNB(module_idP, free_eNB_index);
-  openair_rrc_eNB_init(module_idP);
-}
-
-char layer2_init_eNB(module_id_t module_idP, unsigned char eNB_index)
-{
-
-  return 0;
-
-}
-
-char layer2_init_UE(module_id_t module_idP)
-{
-
-  return 0;
-}
-
 void mac_UE_out_of_sync_ind(module_id_t module_idP, frame_t frameP, uint16_t eNB_index)
 {
 
@@ -110,7 +93,7 @@ void mac_UE_out_of_sync_ind(module_id_t module_idP, frame_t frameP, uint16_t eNB
 }
 
 
-int mac_top_init(int eMBMS_active, char *uecap_xer, uint8_t cba_group_active, uint8_t HO_active)
+int mac_top_init_ue(int eMBMS_active, char *uecap_xer, uint8_t cba_group_active, uint8_t HO_active)
 {
 
   module_id_t    Mod_id,i,j;
@@ -145,22 +128,23 @@ int mac_top_init(int eMBMS_active, char *uecap_xer, uint8_t cba_group_active, ui
   LOG_I(MAC,"[MAIN] Init function start:Nb_eNB_INST=%d\n",NB_eNB_INST);
 
   if (NB_eNB_INST>0) {
-    eNB_mac_inst = (eNB_MAC_INST*)malloc16(NB_eNB_INST*sizeof(eNB_MAC_INST));
-
-    if (eNB_mac_inst == NULL) {
+    RC.mac = (eNB_MAC_INST**)malloc16(NB_eNB_INST*sizeof(eNB_MAC_INST*));
+    for (i=0;i<NB_eNB_INST;i++)
+      RC.mac[i] = (eNB_MAC_INST*)malloc16(sizeof(eNB_MAC_INST));
+    if (RC.mac == NULL) {
       LOG_D(MAC,"[MAIN] can't ALLOCATE %zu Bytes for %d eNB_MAC_INST with size %zu \n",NB_eNB_INST*sizeof(eNB_MAC_INST*),NB_eNB_INST,sizeof(eNB_MAC_INST));
       mac_xface->macphy_exit("[MAC][MAIN] not enough memory for eNB \n");
     } else {
-      LOG_D(MAC,"[MAIN] ALLOCATE %zu Bytes for %d eNB_MAC_INST @ %p\n",sizeof(eNB_MAC_INST),NB_eNB_INST,eNB_mac_inst);
-      bzero(eNB_mac_inst,NB_eNB_INST*sizeof(eNB_MAC_INST));
+      LOG_D(MAC,"[MAIN] ALLOCATE %zu Bytes for %d eNB_MAC_INST @ %p\n",sizeof(eNB_MAC_INST),NB_eNB_INST,RC.mac);
+      for (i=0;i<NB_eNB_INST;i++) bzero(RC.mac[i],sizeof(eNB_MAC_INST));
     }
   } else {
-    eNB_mac_inst = NULL;
+    RC.mac = NULL;
   }
 
   // Initialize Linked-List for Active UEs
   for(Mod_id=0; Mod_id<NB_eNB_INST; Mod_id++) {
-    UE_list = &eNB_mac_inst[Mod_id].UE_list;
+    UE_list = &RC.mac[Mod_id]->UE_list;
 
     UE_list->num_UEs=0;
     UE_list->head=-1;
@@ -174,47 +158,23 @@ int mac_top_init(int eMBMS_active, char *uecap_xer, uint8_t cba_group_active, ui
 
     UE_list->next[list_el]=-1;
     UE_list->next_ul[list_el]=-1;
-
-#ifdef PHY_EMUL
-    Mac_rlc_xface->Is_cluster_head[Mod_id]=2;//0: MR, 1: CH, 2: not CH neither MR
-#endif
-    /*#ifdef Rel10
-    int n;
-    for (n=0;n<4096;n++)
-    eNB_mac_inst[Mod_id].MCH_pdu.payload[n] = taus();
-    //    Mac_rlc_xface->Node_id[Mod_id]=NODE_ID[Mod_id];
-    #endif*/
   }
 
-  //  Mac_rlc_xface->frame=Mac_rlc_xface->frame;
-
-
   if (Is_rrc_registered == 1) {
     LOG_I(MAC,"[MAIN] calling RRC\n");
 #ifndef CELLULAR //nothing to be done yet for cellular
-    openair_rrc_top_init(eMBMS_active, uecap_xer, cba_group_active,HO_active);
+    openair_rrc_top_init_ue(eMBMS_active, uecap_xer, cba_group_active,HO_active);
 #endif
   } else {
     LOG_I(MAC,"[MAIN] Running without an RRC\n");
   }
-
-#ifndef USER_MODE
-#ifndef PHY_EMUL
-  LOG_I(MAC,"[MAIN] add openair2 proc\n");
-  ////  add_openair2_stats();
-#endif
-#endif
-
-  //init_transport_channels(2);
-
-  // Set up DCIs for TDD 5MHz Config 1..6
-
+  
   for (i=0; i<NB_eNB_INST; i++)
     for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
       LOG_D(MAC,"[MAIN][eNB %d] CC_id %d initializing RA_template\n",i, CC_id);
       LOG_D(MAC, "[MSC_NEW][FRAME 00000][MAC_eNB][MOD %02d][]\n", i);
 
-      RA_template = (RA_TEMPLATE *)&eNB_mac_inst[i].common_channels[CC_id].RA_template[0];
+      RA_template = (RA_TEMPLATE *)&RC.mac[i]->common_channels[CC_id].RA_template[0];
 
       for (j=0; j<NB_RA_PROC_MAX; j++) {
         if (mac_xface->frame_parms->frame_type == TDD) {
@@ -305,54 +265,189 @@ int mac_top_init(int eMBMS_active, char *uecap_xer, uint8_t cba_group_active, ui
         RA_template[j].RA_dci_fmt2        = format1A;
       }
 
-      memset (&eNB_mac_inst[i].eNB_stats,0,sizeof(eNB_STATS));
-      UE_template = (UE_TEMPLATE *)&eNB_mac_inst[i].UE_list.UE_template[CC_id][0];
+      memset (&RC.mac[i]->eNB_stats,0,sizeof(eNB_STATS));
+      UE_template = (UE_TEMPLATE *)&RC.mac[i]->UE_list.UE_template[CC_id][0];
 
       for (j=0; j<NUMBER_OF_UE_MAX; j++) {
         UE_template[j].rnti=0;
         // initiallize the eNB to UE statistics
-        memset (&eNB_mac_inst[i].UE_list.eNB_UE_stats[CC_id][j],0,sizeof(eNB_UE_STATS));
+        memset (&RC.mac[i]->UE_list.eNB_UE_stats[CC_id][j],0,sizeof(eNB_UE_STATS));
       }
     }
 
 
-  //ICIC init param
-#ifdef ICIC
-  uint8_t SB_size;
-  SB_size=mac_xface->get_SB_size(mac_xface->frame_parms->N_RB_DL);
 
-  srand (time(NULL));
+  LOG_I(MAC,"[MAIN][INIT] Init function finished\n");
 
-  for(j=0; j<NB_eNB_INST; j++)
-    for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
-      eNB_mac_inst[j][CC_id].sbmap_conf.first_subframe=0;
-      eNB_mac_inst[j][CC_id].sbmap_conf.periodicity=10;
-      eNB_mac_inst[j][CC_id].sbmap_conf.sb_size=SB_size;
-      eNB_mac_inst[j][CC_id].sbmap_conf.nb_active_sb=1;
+  return(0);
 
-      for(i=0; i<NUMBER_OF_SUBBANDS; i++) {
-        eNB_mac_inst[j][CC_id].sbmap_conf.sbmap[i]=1;
-      }
+}
+
+
+int mac_top_init_eNB()
+{
+
+  module_id_t    Mod_id,i;
+  int list_el;
+  UE_list_t *UE_list;
+  eNB_MAC_INST *mac;
 
-      eNB_mac_inst[j][CC_id].sbmap_conf.sbmap[rand()%NUMBER_OF_SUBBANDS]=0;
+  LOG_I(MAC,"[MAIN] Init function start:Nb_eNB_INST=%d\n",RC.nb_inst);
 
+  if (RC.nb_inst>0) {
+    RC.mac = (eNB_MAC_INST**)malloc16(RC.nb_inst*sizeof(eNB_MAC_INST*));
+    for (i=0;i<RC.nb_inst;i++)
+      RC.mac[i] = (eNB_MAC_INST*)malloc16(sizeof(eNB_MAC_INST));
+    if (RC.mac == NULL) {
+      LOG_D(MAC,"[MAIN] can't ALLOCATE %zu Bytes for %d eNB_MAC_INST with size %zu \n",RC.nb_inst*sizeof(eNB_MAC_INST*),RC.nb_inst,sizeof(eNB_MAC_INST));
+      mac_xface->macphy_exit("[MAC][MAIN] not enough memory for eNB \n");
+    } else {
+      LOG_D(MAC,"[MAIN] ALLOCATE %zu Bytes for %d eNB_MAC_INST @ %p\n",sizeof(eNB_MAC_INST),RC.nb_inst,RC.mac);
+      for (i=0;i<RC.nb_inst;i++) bzero(RC.mac[i],sizeof(eNB_MAC_INST));
     }
+  } else {
+    RC.mac = NULL;
+  }
 
-#endif
-  //end ALU's algo
+  // Initialize Linked-List for Active UEs
+  for(Mod_id=0; Mod_id<RC.nb_inst; Mod_id++) {
+    mac = RC.mac[Mod_id];
+    UE_list = &mac->UE_list;
 
-  LOG_I(MAC,"[MAIN][INIT] Init function finished\n");
+    UE_list->num_UEs=0;
+    UE_list->head=-1;
+    UE_list->head_ul=-1;
+    UE_list->avail=0;
 
-  return(0);
+    for (list_el=0; list_el<NUMBER_OF_UE_MAX-1; list_el++) {
+      UE_list->next[list_el]=list_el+1;
+      UE_list->next_ul[list_el]=list_el+1;
+    }
+
+    UE_list->next[list_el]=-1;
+    UE_list->next_ul[list_el]=-1;
+  }
 
 }
 
+void mac_init_cell_params(int Mod_idP,int CC_idP) {
 
-int mac_init_global_param(void)
+  int j;
+  RA_TEMPLATE *RA_template;
+  UE_TEMPLATE *UE_template;
+  int size_bytes1,size_bytes2,size_bits1,size_bits2;
+
+  LOG_D(MAC,"[MAIN][eNB %d] CC_id %d initializing RA_template\n",Mod_idP, CC_idP);
+  LOG_D(MAC, "[MSC_NEW][FRAME 00000][MAC_eNB][MOD %02d][]\n", Mod_idP);
+  COMMON_channels_t *cc = &RC.mac[Mod_idP]->common_channels[CC_idP];
+
+  RA_template = (RA_TEMPLATE *)&cc->RA_template[0];
+  
+  for (j=0; j<NB_RA_PROC_MAX; j++) {
+    if ( cc->tdd_Config != NULL) {
+      switch (cc->mib->message.dl_Bandwidth) {
+      case MasterInformationBlock__dl_Bandwidth_n6:
+	size_bytes1 = sizeof(DCI1A_1_5MHz_TDD_1_6_t);
+	size_bytes2 = sizeof(DCI1A_1_5MHz_TDD_1_6_t);
+	size_bits1 = sizeof_DCI1A_1_5MHz_TDD_1_6_t;
+	size_bits2 = sizeof_DCI1A_1_5MHz_TDD_1_6_t;
+	break;
+	
+      case MasterInformationBlock__dl_Bandwidth_n25:
+	size_bytes1 = sizeof(DCI1A_5MHz_TDD_1_6_t);
+	size_bytes2 = sizeof(DCI1A_5MHz_TDD_1_6_t);
+	size_bits1 = sizeof_DCI1A_5MHz_TDD_1_6_t;
+	size_bits2 = sizeof_DCI1A_5MHz_TDD_1_6_t;
+	break;
+	
+      case MasterInformationBlock__dl_Bandwidth_n50:
+	size_bytes1 = sizeof(DCI1A_10MHz_TDD_1_6_t);
+	size_bytes2 = sizeof(DCI1A_10MHz_TDD_1_6_t);
+	size_bits1 = sizeof_DCI1A_10MHz_TDD_1_6_t;
+	size_bits2 = sizeof_DCI1A_10MHz_TDD_1_6_t;
+	break;
+	
+      case MasterInformationBlock__dl_Bandwidth_n100:
+	size_bytes1 = sizeof(DCI1A_20MHz_TDD_1_6_t);
+	size_bytes2 = sizeof(DCI1A_20MHz_TDD_1_6_t);
+	size_bits1 = sizeof_DCI1A_20MHz_TDD_1_6_t;
+	size_bits2 = sizeof_DCI1A_20MHz_TDD_1_6_t;
+	break;
+	
+      default:
+	size_bytes1 = sizeof(DCI1A_1_5MHz_TDD_1_6_t);
+	size_bytes2 = sizeof(DCI1A_1_5MHz_TDD_1_6_t);
+	size_bits1 = sizeof_DCI1A_1_5MHz_TDD_1_6_t;
+	size_bits2 = sizeof_DCI1A_1_5MHz_TDD_1_6_t;
+	break;
+      }
+      
+    } else {
+      switch (cc->mib->message.dl_Bandwidth) {
+      case MasterInformationBlock__dl_Bandwidth_n6:
+	size_bytes1 = sizeof(DCI1A_1_5MHz_FDD_t);
+	size_bytes2 = sizeof(DCI1A_1_5MHz_FDD_t);
+	size_bits1 = sizeof_DCI1A_1_5MHz_FDD_t;
+	size_bits2 = sizeof_DCI1A_1_5MHz_FDD_t;
+	break;
+	
+      case MasterInformationBlock__dl_Bandwidth_n25:
+	size_bytes1 = sizeof(DCI1A_5MHz_FDD_t);
+	size_bytes2 = sizeof(DCI1A_5MHz_FDD_t);
+	size_bits1 = sizeof_DCI1A_5MHz_FDD_t;
+	size_bits2 = sizeof_DCI1A_5MHz_FDD_t;
+	break;
+	
+      case MasterInformationBlock__dl_Bandwidth_n50:
+	size_bytes1 = sizeof(DCI1A_10MHz_FDD_t);
+	size_bytes2 = sizeof(DCI1A_10MHz_FDD_t);
+	size_bits1 = sizeof_DCI1A_10MHz_FDD_t;
+	size_bits2 = sizeof_DCI1A_10MHz_FDD_t;
+	break;
+	
+      case MasterInformationBlock__dl_Bandwidth_n100:
+	size_bytes1 = sizeof(DCI1A_20MHz_FDD_t);
+	size_bytes2 = sizeof(DCI1A_20MHz_FDD_t);
+	size_bits1 = sizeof_DCI1A_20MHz_FDD_t;
+	size_bits2 = sizeof_DCI1A_20MHz_FDD_t;
+	break;
+	
+      default:
+	size_bytes1 = sizeof(DCI1A_1_5MHz_FDD_t);
+	size_bytes2 = sizeof(DCI1A_1_5MHz_FDD_t);
+	size_bits1 = sizeof_DCI1A_1_5MHz_FDD_t;
+	size_bits2 = sizeof_DCI1A_1_5MHz_FDD_t;
+	break;
+      }
+    }
+    
+    memcpy((void *)&RA_template[j].RA_alloc_pdu1[0],(void *)&RA_alloc_pdu,size_bytes1);
+    memcpy((void *)&RA_template[j].RA_alloc_pdu2[0],(void *)&DLSCH_alloc_pdu1A,size_bytes2);
+    RA_template[j].RA_dci_size_bytes1 = size_bytes1;
+    RA_template[j].RA_dci_size_bytes2 = size_bytes2;
+    RA_template[j].RA_dci_size_bits1  = size_bits1;
+    RA_template[j].RA_dci_size_bits2  = size_bits2;
+    
+    RA_template[j].RA_dci_fmt1        = format1A;
+    RA_template[j].RA_dci_fmt2        = format1A;
+  }
+  
+  memset (&RC.mac[Mod_idP]->eNB_stats,0,sizeof(eNB_STATS));
+  UE_template = (UE_TEMPLATE *)&RC.mac[Mod_idP]->UE_list.UE_template[CC_idP][0];
+  
+  for (j=0; j<NUMBER_OF_UE_MAX; j++) {
+    UE_template[j].rnti=0;
+    // initiallize the eNB to UE statistics
+    memset (&RC.mac[Mod_idP]->UE_list.eNB_UE_stats[CC_idP][j],0,sizeof(eNB_UE_STATS));
+  }
+
+}
+
+
+int rlcmac_init_global_param(void)
 {
 
 
-  Mac_rlc_xface = NULL;
   LOG_I(MAC,"[MAIN] CALLING RLC_MODULE_INIT...\n");
 
   if (rlc_module_init()!=0) {
@@ -372,38 +467,9 @@ int mac_init_global_param(void)
 
   LOG_I(MAC,"[MAIN] malloc16 OK, mac_rlc_xface @ %p\n",(void *)Mac_rlc_xface);
 
-  //  mac_xface->macphy_data_ind=macphy_data_ind;
-  mac_xface->mrbch_phy_sync_failure=mrbch_phy_sync_failure;
-  mac_xface->dl_phy_sync_success=dl_phy_sync_success;
-  mac_xface->out_of_sync_ind=rrc_out_of_sync_ind;
-
-  //  Mac_rlc_xface->macphy_exit=  mac_xface->macphy_exit;
-  //  Mac_rlc_xface->frame = 0;
-  //  Mac_rlc_xface->mac_config_req=mac_config_req;
-  //  Mac_rlc_xface->mac_meas_req=mac_meas_req;
-  //  Mac_rlc_xface->rrc_rlc_config_req=rrc_rlc_config_req;
-  //  Mac_rlc_xface->rrc_rlc_data_req=rrc_rlc_data_req;
-  //  Mac_rlc_xface->rrc_rlc_register_rrc=rrc_rlc_register_rrc;
-
-  //  Mac_rlc_xface->rrc_mac_config_req=rrc_mac_config_req;
-
-  //  LOG_I(MAC,"[MAIN] INIT_GLOBAL_PARAM: Mac_rlc_xface=%p,rrc_rlc_register_rrc =%p\n",Mac_rlc_xface,Mac_rlc_xface->rrc_rlc_register_rrc);
 
-  //  Mac_rlc_xface->mac_rlc_data_req=mac_rlc_data_req;
-  //  Mac_rlc_xface->mac_rlc_data_ind=mac_rlc_data_ind;
-  //  Mac_rlc_xface->mac_rlc_status_ind=mac_rlc_status_ind;
-  //  Mac_rlc_xface->pdcp_data_req=pdcp_data_req;
-  //  Mac_rlc_xface->mrbch_phy_sync_failure=mrbch_phy_sync_failure;
-  //  Mac_rlc_xface->dl_phy_sync_success=dl_phy_sync_success;
 
-  LOG_I(MAC,"[MAIN] RLC interface setup and init\n");
-  rrc_init_global_param();
-
-#ifdef USER_MODE
   pdcp_layer_init ();
-#else
-  pdcp_module_init ();
-#endif
 
   LOG_I(MAC,"[MAIN] Init Global Param Done\n");
 
@@ -422,14 +488,119 @@ void mac_top_cleanup(void)
     free (UE_mac_inst);
   }
 
-  if (NB_eNB_INST>0) {
-    free(eNB_mac_inst);
+  if (RC.nb_inst>0) {
+    free(RC.mac);
   }
 
   free( Mac_rlc_xface);
+
+  free(mac_xface);
+}
+
+int l2_init_ue(int eMBMS_active, char *uecap_xer,uint8_t cba_group_active, uint8_t HO_active)
+{
+
+
+
+  LOG_I(MAC,"[MAIN] MAC_INIT_GLOBAL_PARAM IN...\n");
+  //    NB_NODE=2;
+  //    NB_INST=2;
+
+  Is_rrc_registered=0;
+  rlcmac_init_global_param();
+  Is_rrc_registered=1;
+
+  mac_xface->dl_phy_sync_success=dl_phy_sync_success;
+  mac_xface->out_of_sync_ind=rrc_out_of_sync_ind;
+
+
+  mac_xface->macphy_init = mac_top_init_ue;
+#ifndef USER_MODE
+  mac_xface->macphy_exit = openair_sched_exit;
+#else
+  mac_xface->macphy_exit=(void (*)(const char*)) exit;
+#endif
+  LOG_I(MAC,"[MAIN] init UE MAC functions \n");
+  mac_xface->ue_decode_si              = ue_decode_si;
+  mac_xface->ue_decode_p               = ue_decode_p;
+  mac_xface->ue_send_sdu               = ue_send_sdu;
+#ifdef Rel10
+  mac_xface->ue_send_mch_sdu           = ue_send_mch_sdu;
+  mac_xface->ue_query_mch              = ue_query_mch;
+#endif
+  mac_xface->ue_get_SR                 = ue_get_SR;
+  mac_xface->ue_get_sdu                = ue_get_sdu;
+  mac_xface->ue_get_rach               = ue_get_rach;
+  mac_xface->ue_process_rar            = ue_process_rar;
+  mac_xface->ue_scheduler              = ue_scheduler;
+  mac_xface->process_timing_advance    = process_timing_advance;
+
+
+  LOG_I(MAC,"[MAIN] PHY Frame configuration \n");
+
+  mac_xface->get_ue_active_harq_pid = get_ue_active_harq_pid;
+  mac_xface->get_PL                 = get_PL;
+  mac_xface->get_RSRP               = get_RSRP;
+  mac_xface->get_RSRQ               = get_RSRQ;
+  mac_xface->get_RSSI               = get_RSSI;
+  mac_xface->get_n_adj_cells        = get_n_adj_cells;
+  mac_xface->get_rx_total_gain_dB   = get_rx_total_gain_dB;
+  mac_xface->get_Po_NOMINAL_PUSCH   = get_Po_NOMINAL_PUSCH;
+  mac_xface->get_num_prach_tdd      = get_num_prach_tdd;
+  mac_xface->get_fid_prach_tdd      = get_fid_prach_tdd;
+  mac_xface->get_deltaP_rampup      = get_deltaP_rampup;
+  mac_xface->computeRIV             = computeRIV;
+  mac_xface->get_TBS_DL             = get_TBS_DL;
+  mac_xface->get_TBS_UL             = get_TBS_UL;
+  mac_xface->get_nCCE_max           = get_nCCE_mac;
+  mac_xface->get_nCCE_offset        = get_nCCE_offset;
+  mac_xface->get_ue_mode            = get_ue_mode;
+  mac_xface->phy_config_sib1_ue     = phy_config_sib1_ue;
+
+  mac_xface->phy_config_sib2_ue         = phy_config_sib2_ue;
+  mac_xface->phy_config_afterHO_ue      = phy_config_afterHO_ue;
+#ifdef Rel10
+  mac_xface->phy_config_sib13_ue         = phy_config_sib13_ue;
+#endif
+#ifdef CBA
+  mac_xface->phy_config_cba_rnti         = phy_config_cba_rnti ;
+#endif
+  mac_xface->estimate_ue_tx_power        = estimate_ue_tx_power;
+  mac_xface->phy_config_meas_ue          = phy_config_meas_ue;
+  mac_xface->phy_reset_ue    = phy_reset_ue;
+
+  mac_xface->phy_config_dedicated_ue     = phy_config_dedicated_ue;
+  mac_xface->phy_config_harq_ue          = phy_config_harq_ue;
+
+  mac_xface->get_lte_frame_parms        = get_lte_frame_parms;
+  mac_xface->get_mu_mimo_mode           = get_mu_mimo_mode;
+
+  mac_xface->get_hundred_times_delta_TF = get_hundred_times_delta_IF_mac;
+  mac_xface->get_target_pusch_rx_power     = get_target_pusch_rx_power;
+  mac_xface->get_target_pucch_rx_power     = get_target_pucch_rx_power;
+
+  mac_xface->get_prach_prb_offset       = get_prach_prb_offset;
+  mac_xface->is_prach_subframe          = is_prach_subframe;
+
+#ifdef Rel10
+  mac_xface->get_mch_sdu                 = get_mch_sdu;
+  mac_xface->phy_config_dedicated_scell_ue= phy_config_dedicated_scell_ue;
+
+#endif
+
+  mac_xface->get_PHR = get_PHR;
+  LOG_D(MAC,"[MAIN] ALL INIT OK\n");
+
+  mac_xface->macphy_init(eMBMS_active,uecap_xer,cba_group_active,HO_active);
+
+  //Mac_rlc_xface->Is_cluster_head[0] = 1;
+  //Mac_rlc_xface->Is_cluster_head[1] = 0;
+
+
+  return(1);
 }
 
-int l2_init(LTE_DL_FRAME_PARMS *frame_parms,int eMBMS_active, char *uecap_xer,uint8_t cba_group_active, uint8_t HO_active)
+int l2_init_eNB()
 {
 
 
@@ -439,10 +610,12 @@ int l2_init(LTE_DL_FRAME_PARMS *frame_parms,int eMBMS_active, char *uecap_xer,ui
   //    NB_INST=2;
 
   Is_rrc_registered=0;
-  mac_init_global_param();
+  rlcmac_init_global_param();
   Is_rrc_registered=1;
 
-  mac_xface->macphy_init = mac_top_init;
+  mac_xface = (MAC_xface *)malloc(sizeof(MAC_xface));
+
+  mac_xface->macphy_init = mac_top_init_eNB;
 #ifndef USER_MODE
   mac_xface->macphy_exit = openair_sched_exit;
 #else
@@ -472,24 +645,7 @@ int l2_init(LTE_DL_FRAME_PARMS *frame_parms,int eMBMS_active, char *uecap_xer,ui
   mac_xface->ra_succeeded              = ra_succeeded;
   mac_xface->mac_phy_remove_ue         = mac_phy_remove_ue;
 
-  LOG_I(MAC,"[MAIN] init UE MAC functions \n");
-  mac_xface->ue_decode_si              = ue_decode_si;
-  mac_xface->ue_decode_p               = ue_decode_p;
-  mac_xface->ue_send_sdu               = ue_send_sdu;
-#ifdef Rel10
-  mac_xface->ue_send_mch_sdu           = ue_send_mch_sdu;
-  mac_xface->ue_query_mch              = ue_query_mch;
-#endif
-  mac_xface->ue_get_SR                 = ue_get_SR;
-  mac_xface->ue_get_sdu                = ue_get_sdu;
-  mac_xface->ue_get_rach               = ue_get_rach;
-  mac_xface->ue_process_rar            = ue_process_rar;
-  mac_xface->ue_scheduler              = ue_scheduler;
-  mac_xface->process_timing_advance    = process_timing_advance;
-
-
   LOG_I(MAC,"[MAIN] PHY Frame configuration \n");
-  mac_xface->frame_parms = frame_parms;
 
   mac_xface->get_ue_active_harq_pid = get_ue_active_harq_pid;
   mac_xface->get_PL                 = get_PL;
@@ -508,27 +664,20 @@ int l2_init(LTE_DL_FRAME_PARMS *frame_parms,int eMBMS_active, char *uecap_xer,ui
   mac_xface->get_nCCE_max           = get_nCCE_mac;
   mac_xface->get_nCCE_offset        = get_nCCE_offset;
   mac_xface->get_ue_mode            = get_ue_mode;
+  mac_xface->phy_config_mib_eNB     = phy_config_mib_eNB;
   mac_xface->phy_config_sib1_eNB    = phy_config_sib1_eNB;
   mac_xface->phy_config_sib1_ue     = phy_config_sib1_ue;
 
   mac_xface->phy_config_sib2_eNB        = phy_config_sib2_eNB;
-  mac_xface->phy_config_sib2_ue         = phy_config_sib2_ue;
-  mac_xface->phy_config_afterHO_ue      = phy_config_afterHO_ue;
 #ifdef Rel10
   mac_xface->phy_config_sib13_eNB        = phy_config_sib13_eNB;
-  mac_xface->phy_config_sib13_ue         = phy_config_sib13_ue;
 #endif
 #ifdef CBA
   mac_xface->phy_config_cba_rnti         = phy_config_cba_rnti ;
 #endif
   mac_xface->estimate_ue_tx_power        = estimate_ue_tx_power;
-  mac_xface->phy_config_meas_ue          = phy_config_meas_ue;
-  mac_xface->phy_reset_ue    = phy_reset_ue;
 
   mac_xface->phy_config_dedicated_eNB    = phy_config_dedicated_eNB;
-  mac_xface->phy_config_dedicated_ue     = phy_config_dedicated_ue;
-  mac_xface->phy_config_harq_ue          = phy_config_harq_ue;
-
   mac_xface->get_lte_frame_parms        = get_lte_frame_parms;
   mac_xface->get_mu_mimo_mode           = get_mu_mimo_mode;
 
@@ -549,7 +698,6 @@ int l2_init(LTE_DL_FRAME_PARMS *frame_parms,int eMBMS_active, char *uecap_xer,ui
   mac_xface->get_PHR = get_PHR;
   LOG_D(MAC,"[MAIN] ALL INIT OK\n");
 
-  mac_xface->macphy_init(eMBMS_active,uecap_xer,cba_group_active,HO_active);
 
   //Mac_rlc_xface->Is_cluster_head[0] = 1;
   //Mac_rlc_xface->Is_cluster_head[1] = 0;
diff --git a/openair2/LAYER2/MAC/openair2_proc.c b/openair2/LAYER2/MAC/openair2_proc.c
index 4b63571277..89eea810c9 100644
--- a/openair2/LAYER2/MAC/openair2_proc.c
+++ b/openair2/LAYER2/MAC/openair2_proc.c
@@ -38,11 +38,11 @@
 //#include "RRC/LITE/extern.h"
 //#include "LAYER2/PDCP/pdcp.h"
 #include "proto.h"
-#ifndef USER_MODE
-static int openair2_stats_read(char *buffer, char **my_buffer, off_t off, int length)
-#else
+
+extern RAN_CONTEXT_t RC;
+
 int openair2_stats_read(char *buffer, char **my_buffer, off_t off, int length)
-#endif
+
 {
 
   int len = 0,fg,Overhead, Sign;
diff --git a/openair2/LAYER2/MAC/pre_processor.c b/openair2/LAYER2/MAC/pre_processor.c
index 6e73e353f0..75cca833b9 100644
--- a/openair2/LAYER2/MAC/pre_processor.c
+++ b/openair2/LAYER2/MAC/pre_processor.c
@@ -86,7 +86,7 @@ void store_dlsch_buffer (module_id_t Mod_id,
   int                   UE_id,i;
   rnti_t                rnti;
   mac_rlc_status_resp_t rlc_status;
-  UE_list_t             *UE_list = &eNB_mac_inst[Mod_id].UE_list;
+  UE_list_t             *UE_list = &RC.mac[Mod_id]->UE_list;
   UE_TEMPLATE           *UE_template;
 
   for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) {
@@ -165,7 +165,7 @@ void assign_rbs_required (module_id_t Mod_id,
   uint16_t         TBS = 0;
   LTE_eNB_UE_stats *eNB_UE_stats[MAX_NUM_CCs];
   int              UE_id,n,i,j,CC_id,pCCid,tmp;
-  UE_list_t        *UE_list = &eNB_mac_inst[Mod_id].UE_list;
+  UE_list_t        *UE_list = &RC.mac[Mod_id]->UE_list;
   //  UE_TEMPLATE           *UE_template;
   LTE_DL_FRAME_PARMS   *frame_parms[MAX_NUM_CCs];
 
@@ -268,7 +268,7 @@ int maxround(module_id_t Mod_id,uint16_t rnti,int frame,sub_frame_t subframe,uin
 
   uint8_t round,round_max=0,UE_id;
   int CC_id;
-  UE_list_t *UE_list = &eNB_mac_inst[Mod_id].UE_list;
+  UE_list_t *UE_list = &RC.mac[Mod_id]->UE_list;
 
   for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
 
@@ -288,7 +288,7 @@ int maxcqi(module_id_t Mod_id,int32_t UE_id)
 {
 
   LTE_eNB_UE_stats *eNB_UE_stats = NULL;
-  UE_list_t *UE_list = &eNB_mac_inst[Mod_id].UE_list;
+  UE_list_t *UE_list = &RC.mac[Mod_id]->UE_list;
   int CC_id,n;
   int CQI = 0;
 
@@ -319,7 +319,7 @@ struct sort_ue_dl_params {
 static int ue_dl_compare(const void *_a, const void *_b, void *_params)
 {
   struct sort_ue_dl_params *params = _params;
-  UE_list_t *UE_list = &eNB_mac_inst[params->Mod_idP].UE_list;
+  UE_list_t *UE_list = &RC.mac[params->Mod_idP]->UE_list;
 
   int UE_id1 = *(const int *)_a;
   int UE_id2 = *(const int *)_b;
@@ -402,7 +402,7 @@ void sort_UEs (module_id_t Mod_idP,
   int               rnti;
   struct sort_ue_dl_params params = { Mod_idP, frameP, subframeP };
 
-  UE_list_t *UE_list = &eNB_mac_inst[Mod_idP].UE_list;
+  UE_list_t *UE_list = &RC.mac[Mod_idP]->UE_list;
 
   for (i = 0; i < NUMBER_OF_UE_MAX; i++) {
     rnti = UE_RNTI(Mod_idP, i);
@@ -436,7 +436,7 @@ void sort_UEs (module_id_t Mod_idP,
   int               i=0,ii=0;//,j=0;
   rnti_t            rnti1,rnti2;
 
-  UE_list_t *UE_list = &eNB_mac_inst[Mod_idP].UE_list;
+  UE_list_t *UE_list = &RC.mac[Mod_idP]->UE_list;
 
   for (i=UE_list->head; i>=0; i=UE_list->next[i]) {
 
@@ -517,7 +517,7 @@ void dlsch_scheduler_pre_processor (module_id_t   Mod_id,
   int                min_rb_unit[MAX_NUM_CCs];
   uint16_t r1=0;
   uint8_t CC_id;
-  UE_list_t *UE_list = &eNB_mac_inst[Mod_id].UE_list;
+  UE_list_t *UE_list = &RC.mac[Mod_id]->UE_list;
   LTE_DL_FRAME_PARMS   *frame_parms[MAX_NUM_CCs] = {0};
 
   int transmission_mode = 0;
@@ -901,11 +901,11 @@ void dlsch_scheduler_pre_processor_reset (int module_idP,
   
 {
   int i,j;
-  UE_list_t *UE_list=&eNB_mac_inst[module_idP].UE_list;
+  UE_list_t *UE_list=&RC.mac[module_idP]->UE_list;
   UE_sched_ctrl *ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id];
   rnti_t rnti = UE_RNTI(module_idP,UE_id);
-  uint8_t *vrb_map = eNB_mac_inst[module_idP].common_channels[CC_id].vrb_map;
-  int RBGsize = PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.N_RB_DL/N_RBG;
+  uint8_t *vrb_map = RC.mac[module_idP]->common_channels[CC_id].vrb_map;
+  int RBGsize = RC.eNB[module_idP][CC_id]->frame_parms.N_RB_DL/N_RBG;
 #ifdef SF05_LIMIT
   //int subframe05_limit=0;
   int sf05_upper=-1,sf05_lower=-1;
@@ -928,7 +928,7 @@ void dlsch_scheduler_pre_processor_reset (int module_idP,
     // WE SHOULD PROTECT the eNB_UE_stats with a mutex here ...
 
     ue_sched_ctl->ta_timer = 20;  // wait 20 subframes before taking TA measurement from PHY
-    switch (PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.N_RB_DL) {
+    switch (RC.eNB[module_idP][CC_id]->frame_parms.N_RB_DL) {
     case 6:
       ue_sched_ctl->ta_update = eNB_UE_stats->timing_advance_update;
       break;
@@ -950,7 +950,7 @@ void dlsch_scheduler_pre_processor_reset (int module_idP,
       break;
       
     case 100:
-      if (PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.threequarter_fs == 0)
+      if (RC.eNB[module_idP][CC_id]->frame_parms.threequarter_fs == 0)
 	ue_sched_ctl->ta_update = eNB_UE_stats->timing_advance_update/16;
       else
 	ue_sched_ctl->ta_update = eNB_UE_stats->timing_advance_update/12;
@@ -1034,7 +1034,7 @@ void dlsch_scheduler_pre_processor_allocate (module_id_t   Mod_id,
 {
 
   int i;
-  UE_list_t *UE_list=&eNB_mac_inst[Mod_id].UE_list;
+  UE_list_t *UE_list=&RC.mac[Mod_id]->UE_list;
   UE_sched_ctrl *ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id];
 
   for(i=0; i<N_RBG; i++) {
@@ -1091,7 +1091,7 @@ void ulsch_scheduler_pre_processor(module_id_t module_idP,
   int16_t            total_remaining_rbs[MAX_NUM_CCs];
   uint16_t           max_num_ue_to_be_scheduled=0,total_ue_count=0;
   rnti_t             rnti= -1;
-  UE_list_t          *UE_list = &eNB_mac_inst[module_idP].UE_list;
+  UE_list_t          *UE_list = &RC.mac[module_idP]->UE_list;
   UE_TEMPLATE        *UE_template = 0;
   LTE_DL_FRAME_PARMS   *frame_parms = 0;
 
@@ -1269,7 +1269,7 @@ void assign_max_mcs_min_rb(module_id_t module_idP,int frameP, sub_frame_t subfra
   rnti_t             rnti           = -1;
   int                mcs;
   int                rb_table_index=0,tbs,tx_power;
-  eNB_MAC_INST       *eNB = &eNB_mac_inst[module_idP];
+  eNB_MAC_INST       *eNB = RC.mac[module_idP];
   UE_list_t          *UE_list = &eNB->UE_list;
 
   UE_TEMPLATE       *UE_template;
@@ -1379,7 +1379,7 @@ struct sort_ue_ul_params {
 static int ue_ul_compare(const void *_a, const void *_b, void *_params)
 {
   struct sort_ue_ul_params *params = _params;
-  UE_list_t *UE_list = &eNB_mac_inst[params->module_idP].UE_list;
+  UE_list_t *UE_list = &RC.mac[params->module_idP]->UE_list;
 
   int UE_id1 = *(const int *)_a;
   int UE_id2 = *(const int *)_b;
@@ -1441,7 +1441,7 @@ void sort_ue_ul (module_id_t module_idP,int frameP, sub_frame_t subframeP)
   int               rnti;
   struct sort_ue_ul_params params = { module_idP, frameP, subframeP };
 
-  UE_list_t *UE_list = &eNB_mac_inst[module_idP].UE_list;
+  UE_list_t *UE_list = &RC.mac[module_idP]->UE_list;
 
   for (i = 0; i < NUMBER_OF_UE_MAX; i++) {
     rnti = UE_RNTI(module_idP, i);
@@ -1473,7 +1473,7 @@ void sort_ue_ul (module_id_t module_idP,int frameP, sub_frame_t subframeP)
   int               i=0,ii=0;
   rnti_t            rnti1,rnti2;
 
-  UE_list_t *UE_list = &eNB_mac_inst[module_idP].UE_list;
+  UE_list_t *UE_list = &RC.mac[module_idP]->UE_list;
 
   for (i=UE_list->head_ul; i>=0; i=UE_list->next_ul[i]) {
 
diff --git a/openair2/LAYER2/MAC/proto.h b/openair2/LAYER2/MAC/proto.h
index 77a60794cc..a7b2d82882 100644
--- a/openair2/LAYER2/MAC/proto.h
+++ b/openair2/LAYER2/MAC/proto.h
@@ -725,12 +725,10 @@ unsigned char generate_dlsch_header(unsigned char *mac_header,
                                     unsigned char short_padding,
                                     unsigned short post_padding);
 
-/** \brief RRC Configuration primitive for PHY/MAC.  Allows configuration of PHY/MAC resources based on System Information (SI), RRCConnectionSetup and RRCConnectionReconfiguration messages.
+/** \brief RRC eNB Configuration primitive for PHY/MAC.  Allows configuration of PHY/MAC resources based on System Information (SI), RRCConnectionSetup and RRCConnectionReconfiguration messages.
 @param Mod_id Instance ID of eNB
 @param CC_id Component Carrier of the eNB
-@param eNB_flag Indicates if this is a eNB or UE configuration
-@param rntiP id of UE if this is an eNB configuration
-@param eNB_id Index of eNB if this is a UE configuration
+@param mib Pointer to MIB
 @param radioResourceConfigCommon Structure from SIB2 for common radio parameters (if NULL keep existing configuration)
 @param physcialConfigDedicated Structure from RRCConnectionSetup or RRCConnectionReconfiguration for dedicated PHY parameters (if NULL keep existing configuration)
 @param measObj Structure from RRCConnectionReconfiguration for UE measurement procedures
@@ -747,16 +745,19 @@ unsigned char generate_dlsch_header(unsigned char *mac_header,
 @param mbsfn_AreaInfoList pointer to MBSFN Area Info list from SIB13
 @param pmch_InfoList pointer to PMCH_InfoList from MBSFNAreaConfiguration Message (MCCH Message)
 */
-int rrc_mac_config_req(module_id_t     module_idP,
-                       int             CC_id,
-                       eNB_flag_t eNB_flag,
-                       rnti_t          rntiP,
-                       uint8_t         eNB_index,
-                       RadioResourceConfigCommonSIB_t *radioResourceConfigCommon,
-                       struct PhysicalConfigDedicated *physicalConfigDedicated,
+int rrc_mac_config_req_eNB(module_id_t        module_idP,
+			   int                CC_id,
+			   int                physCellId,
+			   int                p_eNB,
+			   int                Ncp,
+			   int                eutra_band,
+			   uint32_t           dl_CarrierFreq,
+			   BCCH_BCH_Message_t *mib,
+ 			   RadioResourceConfigCommonSIB_t *radioResourceConfigCommon,
+			   struct PhysicalConfigDedicated *physicalConfigDedicated,
 #ifdef Rel10
-                       SCellToAddMod_r10_t *sCellToAddMod_r10,
-                       //struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10,
+			   SCellToAddMod_r10_t *sCellToAddMod_r10,
+			   //struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10,
 #endif
                        MeasObjectToAddMod_t **measObj,
                        MAC_MainConfig_t *mac_MainConfig,
@@ -767,7 +768,7 @@ int rrc_mac_config_req(module_id_t     module_idP,
                        MobilityControlInfo_t *mobilityControlInfo,
                        uint8_t *SIwindowsize,
                        uint16_t *SIperiod,
-                       ARFCN_ValueEUTRA_t *ul_CarrierFreq,
+                       uint32_t ul_CarrierFreq,
                        long *ul_Bandwidth,
                        AdditionalSpectrumEmission_t *additionalSpectrumEmission,
                        struct MBSFN_SubframeConfigList *mbsfn_SubframeConfigList
@@ -785,6 +786,62 @@ int rrc_mac_config_req(module_id_t     module_idP,
 #endif
                       );
 
+/** \brief RRC eNB Configuration primitive for PHY/MAC.  Allows configuration of PHY/MAC resources based on System Information (SI), RRCConnectionSetup and RRCConnectionReconfiguration messages.
+@param Mod_id Instance ID of ue
+@param CC_id Component Carrier of the ue
+@param eNB_id Index of eNB
+@param radioResourceConfigCommon Structure from SIB2 for common radio parameters (if NULL keep existing configuration)
+@param physcialConfigDedicated Structure from RRCConnectionSetup or RRCConnectionReconfiguration for dedicated PHY parameters (if NULL keep existing configuration)
+@param measObj Structure from RRCConnectionReconfiguration for UE measurement procedures
+@param mac_MainConfig Structure from RRCConnectionSetup or RRCConnectionReconfiguration for dedicated MAC parameters (if NULL keep existing configuration)
+@param logicalChannelIdentity Logical channel identity index of corresponding logical channel config
+@param logicalChannelConfig Pointer to logical channel configuration
+@param measGapConfig Measurement Gap configuration for MAC (if NULL keep existing configuration)
+@param tdd_Config TDD Configuration from SIB1 (if NULL keep existing configuration)
+@param mobilityControlInfo mobility control info received for Handover
+@param SIwindowsize SI Windowsize from SIB1 (if NULL keep existing configuration)
+@param SIperiod SI Period from SIB1 (if NULL keep existing configuration)
+@param MBMS_Flag indicates MBMS transmission
+@param mbsfn_SubframeConfigList pointer to mbsfn subframe configuration list from SIB2
+@param mbsfn_AreaInfoList pointer to MBSFN Area Info list from SIB13
+@param pmch_InfoList pointer to PMCH_InfoList from MBSFNAreaConfiguration Message (MCCH Message)
+*/
+int rrc_mac_config_req_ue(module_id_t     module_idP,
+			  int             CC_id,
+			  uint8_t         eNB_index,
+			  RadioResourceConfigCommonSIB_t *radioResourceConfigCommon,
+			  struct PhysicalConfigDedicated *physicalConfigDedicated,
+#ifdef Rel10
+			  SCellToAddMod_r10_t *sCellToAddMod_r10,
+			  //struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10,
+#endif
+			  MeasObjectToAddMod_t **measObj,
+			  MAC_MainConfig_t *mac_MainConfig,
+			  long logicalChannelIdentity,
+			  LogicalChannelConfig_t *logicalChannelConfig,
+			  MeasGapConfig_t *measGapConfig,
+			  TDD_Config_t *tdd_Config,
+			  MobilityControlInfo_t *mobilityControlInfo,
+			  uint8_t *SIwindowsize,
+			  uint16_t *SIperiod,
+			  ARFCN_ValueEUTRA_t *ul_CarrierFreq,
+			  long *ul_Bandwidth,
+			  AdditionalSpectrumEmission_t *additionalSpectrumEmission,
+			  struct MBSFN_SubframeConfigList *mbsfn_SubframeConfigList
+#ifdef Rel10
+			  ,
+			  uint8_t MBMS_Flag,
+			  MBSFN_AreaInfoList_r9_t *mbsfn_AreaInfoList,
+			  PMCH_InfoList_r9_t *pmch_InfoList
+			  
+#endif
+#ifdef CBA
+			  ,
+			  uint8_t num_active_cba_groups,
+			  uint16_t cba_rnti
+#endif
+			  );
+
 /** \brief get the estimated UE distance from the PHY->MAC layer.
 @param Mod_id Instance ID of eNB
 @param UE_id Index of UE if this is an eNB configuration
diff --git a/openair2/LAYER2/MAC/rar_tools.c b/openair2/LAYER2/MAC/rar_tools.c
index 2de22c067a..d1bd8a467f 100644
--- a/openair2/LAYER2/MAC/rar_tools.c
+++ b/openair2/LAYER2/MAC/rar_tools.c
@@ -36,6 +36,7 @@
 #include "OCG.h"
 #include "OCG_extern.h"
 #include "UTIL/OPT/opt.h"
+#include "common/ran_context.h"
 
 #define DEBUG_RAR
 
@@ -43,6 +44,7 @@ extern unsigned int  localRIV2alloc_LUT25[512];
 extern unsigned int  distRIV2alloc_LUT25[512];
 extern unsigned short RIV2nb_rb_LUT25[512];
 extern unsigned short RIV2first_rb_LUT25[512];
+extern RAN_CONTEXT_t RC;
 
 //------------------------------------------------------------------------------
 unsigned short fill_rar(
@@ -65,9 +67,9 @@ unsigned short fill_rar(
   AssertFatal(CC_id < MAX_NUM_CCs, "CC_id %u < MAX_NUM_CCs %u", CC_id, MAX_NUM_CCs);
 
   for (i=0; i<NB_RA_PROC_MAX; i++) {
-    if (eNB_mac_inst[module_idP].common_channels[CC_id].RA_template[i].generate_rar == 1) {
+    if (RC.mac[module_idP]->common_channels[CC_id].RA_template[i].generate_rar == 1) {
       ra_idx=i;
-      eNB_mac_inst[module_idP].common_channels[CC_id].RA_template[i].generate_rar = 0;
+      RC.mac[module_idP]->common_channels[CC_id].RA_template[i].generate_rar = 0;
       break;
     }
   }
@@ -79,7 +81,7 @@ unsigned short fill_rar(
   // subheader fixed
   rarh->E                     = 0; // First and last RAR
   rarh->T                     = 1; // 0 for E/T/R/R/BI subheader, 1 for E/T/RAPID subheader
-  rarh->RAPID                 = eNB_mac_inst[module_idP].common_channels[CC_id].RA_template[ra_idx].preamble_index; // Respond to Preamble 0 only for the moment
+  rarh->RAPID                 = RC.mac[module_idP]->common_channels[CC_id].RA_template[ra_idx].preamble_index; // Respond to Preamble 0 only for the moment
   /*
   rar->R                      = 0;
   rar->Timing_Advance_Command = eNB_mac_inst[module_idP].common_channels[CC_id].RA_template[ra_idx].timing_offset/4;
@@ -91,12 +93,12 @@ unsigned short fill_rar(
   rar->cqi_req                = 1;
   rar->t_crnti                = eNB_mac_inst[module_idP].common_channels[CC_id].RA_template[ra_idx].rnti;
    */
-  rar[4] = (uint8_t)(eNB_mac_inst[module_idP].common_channels[CC_id].RA_template[ra_idx].rnti>>8);
-  rar[5] = (uint8_t)(eNB_mac_inst[module_idP].common_channels[CC_id].RA_template[ra_idx].rnti&0xff);
-  //eNB_mac_inst[module_idP].common_channels[CC_id].RA_template[ra_idx].timing_offset = 0;
-  eNB_mac_inst[module_idP].common_channels[CC_id].RA_template[ra_idx].timing_offset /= 16; //T_A = N_TA/16, where N_TA should be on a 30.72Msps
-  rar[0] = (uint8_t)(eNB_mac_inst[module_idP].common_channels[CC_id].RA_template[ra_idx].timing_offset>>(2+4)); // 7 MSBs of timing advance + divide by 4
-  rar[1] = (uint8_t)(eNB_mac_inst[module_idP].common_channels[CC_id].RA_template[ra_idx].timing_offset<<(4-2))&0xf0; // 4 LSBs of timing advance + divide by 4
+  rar[4] = (uint8_t)(RC.mac[module_idP]->common_channels[CC_id].RA_template[ra_idx].rnti>>8);
+  rar[5] = (uint8_t)(RC.mac[module_idP]->common_channels[CC_id].RA_template[ra_idx].rnti&0xff);
+  //RC.mac[module_idP]->common_channels[CC_id].RA_template[ra_idx].timing_offset = 0;
+  RC.mac[module_idP]->common_channels[CC_id].RA_template[ra_idx].timing_offset /= 16; //T_A = N_TA/16, where N_TA should be on a 30.72Msps
+  rar[0] = (uint8_t)(RC.mac[module_idP]->common_channels[CC_id].RA_template[ra_idx].timing_offset>>(2+4)); // 7 MSBs of timing advance + divide by 4
+  rar[1] = (uint8_t)(RC.mac[module_idP]->common_channels[CC_id].RA_template[ra_idx].timing_offset<<(4-2))&0xf0; // 4 LSBs of timing advance + divide by 4
   rballoc = mac_xface->computeRIV(N_RB_UL,26,1); // first PRB only for UL Grant
   rar[1] |= (rballoc>>7)&7; // Hopping = 0 (bit 3), 3 MSBs of rballoc
   rar[2] = ((uint8_t)(rballoc&0xff))<<1; // 7 LSBs of rballoc
@@ -112,19 +114,19 @@ unsigned short fill_rar(
         frameP,
         *(uint8_t*)rarh,rar[0],rar[1],rar[2],rar[3],rar[4],rar[5],
         ra_idx,
-        eNB_mac_inst[module_idP].common_channels[CC_id].RA_template[ra_idx].rnti,
-        rarh->RAPID,eNB_mac_inst[module_idP].common_channels[CC_id].RA_template[0].preamble_index,
-        eNB_mac_inst[module_idP].common_channels[CC_id].RA_template[ra_idx].timing_offset);
+        RC.mac[module_idP]->common_channels[CC_id].RA_template[ra_idx].rnti,
+        rarh->RAPID,RC.mac[module_idP]->common_channels[CC_id].RA_template[0].preamble_index,
+        RC.mac[module_idP]->common_channels[CC_id].RA_template[ra_idx].timing_offset);
 
   if (opt_enabled) {
     trace_pdu(1, dlsch_buffer, input_buffer_length, module_idP, 2, 1,
-        eNB_mac_inst[module_idP].frame, eNB_mac_inst[module_idP].subframe, 0, 0);
+        RC.mac[module_idP]->frame, RC.mac[module_idP]->subframe, 0, 0);
     LOG_D(OPT,"[eNB %d][RAPROC] CC_id %d RAR Frame %d trace pdu for rnti %x and  rapid %d size %d\n",
-          module_idP, CC_id, frameP, eNB_mac_inst[module_idP].common_channels[CC_id].RA_template[ra_idx].rnti,
+          module_idP, CC_id, frameP, RC.mac[module_idP]->common_channels[CC_id].RA_template[ra_idx].rnti,
           rarh->RAPID, input_buffer_length);
   }
 
-  return(eNB_mac_inst[module_idP].common_channels[CC_id].RA_template[ra_idx].rnti);
+  return(RC.mac[module_idP]->common_channels[CC_id].RA_template[ra_idx].rnti);
 }
 
 //------------------------------------------------------------------------------
diff --git a/openair2/LAYER2/MAC/vars.h b/openair2/LAYER2/MAC/vars.h
index edd8548e64..61765149cf 100644
--- a/openair2/LAYER2/MAC/vars.h
+++ b/openair2/LAYER2/MAC/vars.h
@@ -92,7 +92,6 @@ MAC_xface *mac_xface;
 uint32_t RRC_CONNECTION_FLAG;
 
 UE_MAC_INST *UE_mac_inst; //[NB_MODULE_MAX];
-eNB_MAC_INST *eNB_mac_inst; //[NB_MODULE_MAX];
 MAC_RLC_XFACE *Mac_rlc_xface;
 
 /// Primary component carrier index of eNB
diff --git a/openair2/LAYER2/Makefile b/openair2/LAYER2/Makefile
deleted file mode 100644
index 5890cd548e..0000000000
--- a/openair2/LAYER2/Makefile
+++ /dev/null
@@ -1,159 +0,0 @@
-#/*________________________Makefile________________________
-
-# Authors : Hicham Anouar, Lionel Gauthier, Raymond Knopp
-# Company : EURECOM
-# Emails  : anouar@eurecom.fr, lionel.gauthier@eurecom.fr, knopp@eurecom.fr
-#________________________________________________________________*/
-
-
-
-
-
-include $(OPENAIR_HOME)/common/utils/Makefile.inc
-
-KERNEL_ARCH:=$(shell echo `uname -m`)
-SET_X64:=$(shell if [ $(KERNEL_ARCH) = 'x86_64' ]; then echo true ; fi)
-ifdef RTAI
-# Get the RTAI variables
-CCC = $(shell rtai-config --cc)
-RTAI_SUBVERSION=$(shell rtai-config --version | sed -e 's/^..\(.\).*$$/\1/')
-IS_RTAI_SUBVERSION_LESS_THAN_FIVE=$(shell if [ $(RTAI_SUBVERSION) -lt 5 ] ; then echo true ; fi)
-
-EXTRA_CFLAGS = $(shell rtai-config --module-cflags) -DRTAI_ENABLED -DPC_TARGET -D__KERNEL__ -DMODULE -D_LOOSE_KERNEL_NAMES -I$(KERNEL_DIR)/build/include -I$(KERNEL_DIR)/build/include/asm/mach-default -DNB_ANTENNAS_RX=2 -DNB_ANTENNAS_TX=2 -DNB_ANTENNAS_TXRX -DMAC_CONTEXT -I/usr/include $(if $(IS_RTAI_SUBVERSION_LESS_THAN_FIVE),-DRTAI_ISNT_POSIX,)
-endif
-
-
-
-
-
-####################################################
-#      SOURCE FOLDERS
-####################################################
-
-
-COMMON_DIR		      = ../COMMON
-AS_RLC_UM_DIR                 = RLC/UM_v6.1.0_LITE
-AS_RLC_AM_DIR                 = RLC/AM
-AS_RLC_TM_DIR                 = RLC/TM
-AS_RLC_DIR                    = RLC
-AS_PDCP_DIR                   = PDCP_v10.1.0
-AS_MEM_DIR                    = ../UTIL/MEM
-AS_LIST_DIR                   = ../UTIL/LISTS
-AS_FIFO_DIR	              = ../UTIL/FIFO
-AS_MATH_DIR                   = ../UTIL/MATH
-AS_TIMER_DIR                  = ../UTIL/TIMER
-PHY_INTERFACE_DIR	      = ../PHY_INTERFACE
-
-export AS_RLC_UM_DIR
-export AS_RLC_AM_DIR
-export AS_RLC_TM_DIR
-export AS_RLC_DIR
-export AS_PDCP_DIR
-export AS_MPLS_DIR
-export AS_MEM_DIR
-export AS_LIST_DIR
-export AS_FIFO_DIR
-export AS_MATH_DIR
-export AS_TIMER_DIR
-export AS_RRM_CONFIG_DIR
-
-
-
-obj-m += openair_l2.o
-
-
-
-
-openair_l2-objs += layer2_top.o MAC/layer2_scheduler.o MAC/main.o MAC/nodeb_control_plane_procedures.o MAC/ue_scheduler.o MAC/nodeb_scheduler.o MAC/ue_control_plane_procedures.o MAC/lchan_interface.o MAC/utils.o MAC/openair2_proc.o
-
-openair_l2-objs += register.o
-
-
-
-openair_l2-objs +=  $(AS_LIST_DIR)/list.o
-openair_l2-objs +=  $(AS_LIST_DIR)/list2.o
-
-openair_l2-objs +=  $(AS_TIMER_DIR)/umts_timer.o
-
-openair_l2-objs +=  $(AS_PDCP_DIR)/pdcp.o
-openair_l2-objs +=  $(AS_PDCP_DIR)/pdcp_fifo.o
-
-openair_l2-objs +=  $(AS_RLC_AM_DIR)/rlc_am.o
-openair_l2-objs +=  $(AS_RLC_AM_DIR)/rlc_am_segment.o
-openair_l2-objs +=  $(AS_RLC_AM_DIR)/rlc_am_fsm.o
-openair_l2-objs +=  $(AS_RLC_AM_DIR)/rlc_am_mux.o
-openair_l2-objs +=  $(AS_RLC_AM_DIR)/rlc_am_retrans.o
-openair_l2-objs +=  $(AS_RLC_AM_DIR)/rlc_am_util.o
-openair_l2-objs +=  $(AS_RLC_AM_DIR)/rlc_am_mac_status.o
-openair_l2-objs +=  $(AS_RLC_AM_DIR)/rlc_am_demux.o
-openair_l2-objs +=  $(AS_RLC_AM_DIR)/rlc_am_receiver.o
-openair_l2-objs +=  $(AS_RLC_AM_DIR)/rlc_am_reassembly.o
-openair_l2-objs +=  $(AS_RLC_AM_DIR)/rlc_am_discard_rx.o
-openair_l2-objs +=  $(AS_RLC_AM_DIR)/rlc_am_control_primitives.o
-openair_l2-objs +=  $(AS_RLC_AM_DIR)/rlc_am_reset.o
-openair_l2-objs +=  $(AS_RLC_AM_DIR)/rlc_am_status.o
-openair_l2-objs +=  $(AS_RLC_AM_DIR)/rlc_am_timers.o
-openair_l2-objs +=  $(AS_RLC_AM_DIR)/rlc_am_discard_notif.o
-openair_l2-objs +=  $(AS_RLC_AM_DIR)/rlc_am_discard_tx.o
-
-openair_l2-objs +=  $(AS_RLC_TM_DIR)/rlc_tm.o
-openair_l2-objs +=  $(AS_RLC_TM_DIR)/rlc_tm_control_primitives.o
-openair_l2-objs +=  $(AS_RLC_TM_DIR)/rlc_tm_fsm.o
-openair_l2-objs +=  $(AS_RLC_TM_DIR)/rlc_tm_segment.o
-openair_l2-objs +=  $(AS_RLC_TM_DIR)/rlc_tm_reassembly.o
-
-openair_l2-objs +=  $(AS_RLC_UM_DIR)/rlc_um.o
-openair_l2-objs +=  $(AS_RLC_UM_DIR)/rlc_um_fsm.o
-openair_l2-objs +=  $(AS_RLC_UM_DIR)/rlc_um_control_primitives.o
-openair_l2-objs +=  $(AS_RLC_UM_DIR)/rlc_um_segment.o
-openair_l2-objs +=  $(AS_RLC_UM_DIR)/rlc_um_reassembly.o
-openair_l2-objs +=  $(AS_RLC_UM_DIR)/rlc_um_receiver.o
-
-openair_l2-objs +=  $(AS_RLC_DIR)/rlc_mac.o
-openair_l2-objs +=  $(AS_RLC_DIR)/rlc.o
-openair_l2-objs +=  $(AS_RLC_DIR)/rlc_rrc.o
-openair_l2-objs +=  $(AS_RLC_DIR)/rlc_mpls.o
-
-
-openair_l2-objs +=  $(AS_MATH_DIR)/random.o
-openair_l2-objs +=  $(AS_MATH_DIR)/crc_byte.o
-
-openair_l2-objs +=  $(AS_MEM_DIR)/mem_block.o
-
-
-openair_l2-objs += $(PHY_INTERFACE_DIR)/mac_phy_primitives.o
-
-
-ifdef MASTER
-EXTRA_CFLAGS += -DNODE_RG
-else
-EXTRA_CFLAGS += -DNODE_MT
-endif
-
-
-ifdef NO_RRM
-EXTRA_CFLAGS += -DNO_RRM
-else
-ifndef USER_MODE
-EXTRA_CFLAGS += -DRRC_RRM_FIFOS_XFACE
-endif
-endif
-
-
-CCC=gcc
-
-ifdef PHYEMUL
-EXTRA_CFLAGS += -DPHY_EMUL
-else
-EXTRA_CFLAGS += -I$(OPENAIR1_DIR) -DOPENAIR1 -DOPENAIR2
-endif
-
-#--------------------------------------------------------
-EXTRA_CFLAGS +=   -DKERNEL$(KERNEL_MAIN_TYPE)  -DBIGPHYSAREA #-DNO_RRM  -DRRC_RRM_XFACE -DRRC_RRM_FIFOS_XFACE 
-
-
-EXTRA_CFLAGS += -Wall -Wstrict-prototypes  $(if $(SET_X64),-DARCH_64,) $(if $(SET_X64),-mcmodel=kernel,) $(if $(SET_X64),-m64,) -fno-common -fno-strict-aliasing -pipe -freg-struct-return -ffreestanding -maccumulate-outgoing-args -funroll-loops -mmmx -msse -msse2 -fomit-frame-pointer -nostdinc -DMODULE  -D_LOOSE_KERNEL_NAMES -O2  $(GT2629)
-
-
-EXTRA_CFLAGS += -I$(OPENAIR2_DIR)/COMMON -I$(OPENAIR2_DIR)/PHY_INTERFACE -I$(OPENAIR2_DIR)/UTIL/TIMER -I$(OPENAIR2_DIR)/UTIL/MATH -I$(OPENAIR2_DIR)/UTIL/LISTS -I$(OPENAIR2_DIR)/UTIL/MEM -I$(OPENAIR2_DIR)/LAYER2/RLC -I$(OPENAIR2_DIR)/LAYER2/RLC/UM_v6.1.0_LITE -I$(OPENAIR2_DIR)/LAYER2/RLC/TM -I$(OPENAIR2_DIR)/LAYER2/RLC/AM -I$(OPENAIR2_DIR)/LAYER2/PDCP -I$(OPENAIR2_DIR) -I$(OPENAIR3_DIR)/MESH -I$(OPENAIR3_DIR)/MESH/RRM 
-
diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c
index e380bc6098..11a23ad8ec 100644
--- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c
+++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c
@@ -177,11 +177,12 @@ int pdcp_fifo_flush_sdus(const protocol_ctxt_t* const  ctxt_pP)
       AssertFatal(0, "Now execution should not go here");
       LOG_D(PDCP,"Sending to GTPV1U %d bytes\n", ((pdcp_data_ind_header_t *)(sdu_p->data))->data_size);
       gtpv1u_new_data_req(
-        ctxt_pP->module_id, //gtpv1u_data_t *gtpv1u_data_p,
-        ctxt_pP->rnti,//rb_id/maxDRB, TO DO UE ID
-        ((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id + 4,
-        &(((uint8_t *) sdu_p->data)[sizeof (pdcp_data_ind_header_t)]),
-        ((pdcp_data_ind_header_t *)(sdu_p->data))->data_size);
+			  ctxt_pP->module_id, //gtpv1u_data_t *gtpv1u_data_p,
+			  ctxt_pP->rnti,//rb_id/maxDRB, TO DO UE ID
+			  ((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id + 4,
+			  &(((uint8_t *) sdu_p->data)[sizeof (pdcp_data_ind_header_t)]),
+			  ((pdcp_data_ind_header_t *)(sdu_p->data))->data_size,
+			  0);
 
       list_remove_head (&pdcp_sdu_list);
       free_mem_block (sdu_p, __func__);
diff --git a/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm.c b/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm.c
index 6e495bceff..077e9f403a 100644
--- a/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm.c
+++ b/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm.c
@@ -60,10 +60,10 @@ rlc_tm_send_sdu (
           PROTOCOL_RLC_TM_CTXT_ARGS(ctxt_pP, rlc_pP));
 
     for (index = 0; index < length_in_bytes; index++) {
-      msg ("%c", srcP[index]);
+      LOG_T (RLC,"%c", srcP[index]);
     }
 
-    msg ("\n");
+    LOG_T (RLC,"\n");
 #endif
 
     memcpy (&rlc_pP->output_sdu_in_construction->data[rlc_pP->output_sdu_size_to_write], srcP, length_in_bytes);
@@ -77,7 +77,7 @@ rlc_tm_send_sdu (
       rlc_pP->output_sdu_in_construction);
     rlc_pP->output_sdu_in_construction = NULL;
   } else {
-    msg ("[RLC_TM %p][SEND_SDU] ERROR  OUTPUT SDU IS NULL\n", rlc_pP);
+    LOG_D (RLC,"[RLC_TM %p][SEND_SDU] ERROR  OUTPUT SDU IS NULL\n", rlc_pP);
   }
 }
 //-----------------------------------------------------------------------------
diff --git a/openair2/LAYER2/RLC/rlc.c b/openair2/LAYER2/RLC/rlc.c
index 96057231a6..adbd897f85 100644
--- a/openair2/LAYER2/RLC/rlc.c
+++ b/openair2/LAYER2/RLC/rlc.c
@@ -422,7 +422,7 @@ rlc_op_status_t rlc_data_req     (const protocol_ctxt_t* const ctxt_pP,
 
     case RLC_MODE_AM:
 #ifdef DEBUG_RLC_DATA_REQ
-      msg("RLC_MODE_AM\n");
+      LOG_D(RLC,"RLC_MODE_AM\n");
 #endif
       new_sdu_p = get_free_mem_block (sdu_sizeP + sizeof (struct rlc_am_data_req_alloc), __func__);
 
diff --git a/openair2/LAYER2/layer2_top.c b/openair2/LAYER2/layer2_top.c
deleted file mode 100644
index 2837e25d7b..0000000000
--- a/openair2/LAYER2/layer2_top.c
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The OpenAirInterface Software Alliance licenses this file to You under
- * the OAI Public License, Version 1.0  (the "License"); you may not use this file
- * except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.openairinterface.org/?page_id=698
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *-------------------------------------------------------------------------------
- * For more information about the OpenAirInterface (OAI) Software Alliance:
- *      contact@openairinterface.org
- */
-
-/*________________________openair_w3g4free_top.c________________________
-
- Authors : Hicham Anouar, Raymond Knopp
- Company : EURECOM
- Emails  : anouar@eurecom.fr,  knopp@eurecom.fr
-________________________________________________________________*/
-
-#ifndef USER_MODE
-#define __NO_VERSION__
-
-#include <rtai.h>
-#include <rtai_fifos.h>
-
-
-#include <asm/io.h>
-#include <asm/bitops.h>
-#include <asm/uaccess.h>
-#include <asm/segment.h>
-#include <asm/page.h>
-#include <asm/delay.h>
-
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/pci.h>
-#include <linux/mm.h>
-#include <linux/mman.h>
-
-#include <linux/slab.h>
-//#include <linux/config.h>
-#include <linux/version.h>
-#include <linux/kernel.h>
-#include <linux/fs.h>
-
-#include <linux/errno.h>
-
-#ifdef KERNEL2_6
-//#include <linux/config.h>
-#include <linux/slab.h>
-#endif
-
-#ifdef KERNEL2_4
-#include <linux/malloc.h>
-#include <linux/wrapper.h>
-#endif
-
-#endif
-
-
-#include <linux/bigphysarea.h>
-
-//#include "defs.h"
-//#include "openair_types.h"
-#include "LAYER2/MAC/vars.h"
-#include "LAYER2/MAC/defs.h"
-
-extern void  macphy_scheduler(uint8_t);
-extern MAC_xface *mac_register(void *, void*, void*, void*,void*);
-extern int mac_unregister(MAC_xface *);
-extern MAC_xface *mac_xface;
-extern int mac_top_init();
-extern int mac_init_global_param(void);
-extern int pdcp_module_init(void);
-extern void pdcp_module_cleanup(void);
-
-/*------------------------------------------------*/
-void w3g4free_mac_init(void)
-{
-
-  int ret;
-
-#ifndef USER_MODE
-  printk("[OPENAIR][MAC][TOP] INIT...\n");
-#else
-  printf("[OPENAIR][MAC][TOP] INIT...\n");
-#endif// USER_MODE
-  // if(mac_xface->is_cluster_head)
-  // mac_top_init();
-  //else
-  mac_top_init();
-
-#ifndef USER_MODE
-  printk("[OPENAIR][MAC][TOP] INIT DONE.\n");
-#endif//USER_MODE
-
-
-
-}
-/*------------------------------------------------*/
-#ifndef USER_MODE
-
-/*------------------------------------------------*/
-/*   Prototypes                                   */
-/*------------------------------------------------*/
-#ifdef KERNEL2_4
-static int   init_module( void );
-static void  cleanup_module(void);
-#else
-static int   openair_mac_init_module( void );
-static void  openair_mac_cleanup_module(void);
-#endif
-
-#ifdef KERNEL2_6
-static int __init openair_mac_init_module( void )
-#else
-int init_module( void )
-#endif //KERNEL2_6
-{
-  printk("[OPENAIR][MAC][INIT] inserting module\n");
-
-  //    mac_init_global_param();
-
-  mac_xface=mac_register(macphy_scheduler,NULL,w3g4free_mac_init,mrbch_phy_sync_failure,chbch_phy_sync_success);
-
-  if( mac_xface == NULL ) {
-    printk("[OPENAIR][MAC][INIT] Could not get MAC descriptor\n");
-    return -1;
-  } else {
-    printk("[OPENAIR][MAC][INIT] Got MAC descriptor \n");
-
-    if(mac_init_global_param()==-1) {
-      mac_unregister(mac_xface);
-      return -1;
-    }
-  }
-
-  if (pdcp_module_init()!=0) {
-    mac_unregister(mac_xface);
-    return(-1);
-  } else {
-    printk("[OPENAIR][MAC][INIT] PDCP INIT OK\n");
-  }
-
-
-  return 0;
-}
-
-#ifdef KERNEL2_6
-static void __exit openair_mac_cleanup_module(void)
-#else
-void cleanup_module(void)
-#endif //KERNEL2_6
-{
-  printk("[OPENAIR][MAC][CLEANUP] cleanup module\n");
-  mac_unregister(mac_xface);
-  pdcp_module_cleanup();
-}
-
-MODULE_AUTHOR
-("Lionel GAUTHIER <lionel.gauthier@eurecom.fr>, Raymond KNOPP <raymond.knopp@eurecom.fr>, Aawatif MENOUNI <aawatif.menouni@eurecom.fr>,Dominique NUSSBAUM <dominique.nussbaum@eurecom.fr>, Michelle WETTERWALD <michelle.wetterwald@eurecom.fr>, Maxime GUILLAUD <maxime.guillaud@eurecom.fr, Hicham ANOUAR <hicham.anouar@eurecom.fr>");
-MODULE_DESCRIPTION ("openair MAC layer module");
-MODULE_LICENSE ("GPL");
-module_init (openair_mac_init_module);
-module_exit (openair_mac_cleanup_module);
-
-
-#endif //USER_MODE
-
-
diff --git a/openair2/LAYER2/openair2_proc.c b/openair2/LAYER2/openair2_proc.c
index 677d49bb65..90174d8c8a 100644
--- a/openair2/LAYER2/openair2_proc.c
+++ b/openair2/LAYER2/openair2_proc.c
@@ -50,6 +50,7 @@
 #include "LAYER2/MAC/extern.h"
 #include "LAYER2/PDCP_v10.1.0/pdcp.h"
 #include "UTIL/LOG/log.h"
+#include "common/ran_context.h"
 
 static mapping rrc_status_names[] = {
   {"RRC_INACTIVE", 0},
@@ -61,6 +62,8 @@ static mapping rrc_status_names[] = {
   {NULL, -1}
 };
 
+extern RAN_CONTEXT_t RC;
+
 int dump_eNB_l2_stats(char *buffer, int length)
 {
 
@@ -109,7 +112,7 @@ int dump_eNB_l2_stats(char *buffer, int length)
 
   for (eNB_id=0; eNB_id<number_of_cards; eNB_id++) {
     /* reset the values */
-    eNB = &eNB_mac_inst[eNB_id];
+    eNB = RC.mac[eNB_id];
     UE_list = &eNB->UE_list;
 
     for (CC_id=0 ; CC_id < MAX_NUM_CCs; CC_id++) {
diff --git a/openair2/PHY_INTERFACE/defs.h b/openair2/PHY_INTERFACE/defs.h
index 4973252054..fddb9879d4 100644
--- a/openair2/PHY_INTERFACE/defs.h
+++ b/openair2/PHY_INTERFACE/defs.h
@@ -98,6 +98,18 @@ typedef struct {
   void (*SR_indication)(module_id_t Mod_id,int CC_id,frame_t frameP,rnti_t rnti,sub_frame_t subframe);
   /// Indicate UL Failure to eNodeB MAC
   void (*UL_failure_indication)(module_id_t Mod_id,int CC_id,frame_t frameP,rnti_t rnti,sub_frame_t subframe);
+
+  /// Configure Common PHY parameters from SIB1
+  void (*phy_config_mib_eNB)(module_id_t Mod_id,int CC_id,
+			     int eutra_band,
+			     int N_RB_DL,
+			     PHICH_Config_t *phich_Config,
+			     int Nid_cell,
+			     int Ncp,
+			     int p_eNB,
+			     uint32_t      dl_CarrierFreq,
+			     uint32_t      ul_CarrierFreq);
+
   /// Configure Common PHY parameters from SIB1
   void (*phy_config_sib1_eNB)(module_id_t Mod_id,int CC_id,
                               TDD_Config_t *tdd_config,
diff --git a/openair2/RRC/LITE/L2_interface.c b/openair2/RRC/LITE/L2_interface.c
index fa5a4d6409..792b46e8a1 100644
--- a/openair2/RRC/LITE/L2_interface.c
+++ b/openair2/RRC/LITE/L2_interface.c
@@ -40,6 +40,7 @@
 #include "rrc_eNB_UE_context.h"
 #include "pdcp.h"
 #include "msc.h"
+#include "common/ran_context.h"
 
 #ifdef PHY_EMUL
 #include "SIMULATION/simulation_defs.h"
@@ -57,6 +58,8 @@ extern UE_MAC_INST *UE_mac_inst;
 
 mui_t mui=0;
 
+extern RAN_CONTEXT_t RC;
+
 //------------------------------------------------------------------------------
 int8_t
 mac_rrc_data_req(
@@ -83,25 +86,25 @@ mac_rrc_data_req(
   if( enb_flagP == ENB_FLAG_YES) {
 
     if((Srb_id & RAB_OFFSET) == BCCH) {
-      if(eNB_rrc_inst[Mod_idP].carrier[CC_id].SI.Active==0) {
+      if(RC.rrc[Mod_idP]->carrier[CC_id].SI.Active==0) {
         return 0;
       }
 
       // All even frames transmit SIB in SF 5
-      if (eNB_rrc_inst[Mod_idP].carrier[CC_id].sizeof_SIB1 == 255) {
+      if (RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB1 == 255) {
         LOG_E(RRC,"[eNB %d] MAC Request for SIB1 and SIB1 not initialized\n",Mod_idP);
         mac_xface->macphy_exit("mac_rrc_data_req:  MAC Request for SIB1 and SIB1 not initialized");
       }
 
       if ((frameP%2) == 0) {
         memcpy(&buffer_pP[0],
-               eNB_rrc_inst[Mod_idP].carrier[CC_id].SIB1,
-               eNB_rrc_inst[Mod_idP].carrier[CC_id].sizeof_SIB1);
+               RC.rrc[Mod_idP]->carrier[CC_id].SIB1,
+               RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB1);
 
 #if defined(ENABLE_ITTI)
         {
           MessageDef *message_p;
-          int sib1_size = eNB_rrc_inst[Mod_idP].carrier[CC_id].sizeof_SIB1;
+          int sib1_size = RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB1;
           int sdu_size = sizeof(RRC_MAC_BCCH_DATA_REQ (message_p).sdu);
 
           if (sib1_size > sdu_size) {
@@ -114,7 +117,7 @@ mac_rrc_data_req(
           RRC_MAC_BCCH_DATA_REQ (message_p).sdu_size = sib1_size;
           memset (RRC_MAC_BCCH_DATA_REQ (message_p).sdu, 0, BCCH_SDU_SIZE);
           memcpy (RRC_MAC_BCCH_DATA_REQ (message_p).sdu,
-                  eNB_rrc_inst[Mod_idP].carrier[CC_id].SIB1,
+                  RC.rrc[Mod_idP]->carrier[CC_id].SIB1,
                   sib1_size);
           RRC_MAC_BCCH_DATA_REQ (message_p).enb_index = eNB_index;
 
@@ -125,24 +128,24 @@ mac_rrc_data_req(
 #ifdef DEBUG_RRC
         LOG_T(RRC,"[eNB %d] Frame %d : BCCH request => SIB 1\n",Mod_idP,frameP);
 
-        for (i=0; i<eNB_rrc_inst[Mod_idP].carrier[CC_id].sizeof_SIB1; i++) {
+        for (i=0; i<RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB1; i++) {
           LOG_T(RRC,"%x.",buffer_pP[i]);
         }
 
         LOG_T(RRC,"\n");
 #endif
 
-        return (eNB_rrc_inst[Mod_idP].carrier[CC_id].sizeof_SIB1);
+        return (RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB1);
       } // All RFN mod 8 transmit SIB2-3 in SF 5
       else if ((frameP%8) == 1) {
         memcpy(&buffer_pP[0],
-               eNB_rrc_inst[Mod_idP].carrier[CC_id].SIB23,
-               eNB_rrc_inst[Mod_idP].carrier[CC_id].sizeof_SIB23);
+               RC.rrc[Mod_idP]->carrier[CC_id].SIB23,
+               RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB23);
 
 #if defined(ENABLE_ITTI)
         {
           MessageDef *message_p;
-          int sib23_size = eNB_rrc_inst[Mod_idP].carrier[CC_id].sizeof_SIB23;
+          int sib23_size = RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB23;
           int sdu_size = sizeof(RRC_MAC_BCCH_DATA_REQ (message_p).sdu);
 
           if (sib23_size > sdu_size) {
@@ -155,7 +158,7 @@ mac_rrc_data_req(
           RRC_MAC_BCCH_DATA_REQ (message_p).sdu_size = sib23_size;
           memset (RRC_MAC_BCCH_DATA_REQ (message_p).sdu, 0, BCCH_SDU_SIZE);
           memcpy (RRC_MAC_BCCH_DATA_REQ (message_p).sdu,
-                  eNB_rrc_inst[Mod_idP].carrier[CC_id].SIB23,
+                  RC.rrc[Mod_idP]->carrier[CC_id].SIB23,
                   sib23_size);
           RRC_MAC_BCCH_DATA_REQ (message_p).enb_index = eNB_index;
 
@@ -166,13 +169,13 @@ mac_rrc_data_req(
 #ifdef DEBUG_RRC
         LOG_T(RRC,"[eNB %d] Frame %d BCCH request => SIB 2-3\n",Mod_idP,frameP);
 
-        for (i=0; i<eNB_rrc_inst[Mod_idP].carrier[CC_id].sizeof_SIB23; i++) {
+        for (i=0; i<RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB23; i++) {
           LOG_T(RRC,"%x.",buffer_pP[i]);
         }
 
         LOG_T(RRC,"\n");
 #endif
-        return(eNB_rrc_inst[Mod_idP].carrier[CC_id].sizeof_SIB23);
+        return(RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB23);
       } else {
         return(0);
       }
@@ -181,12 +184,12 @@ mac_rrc_data_req(
     if( (Srb_id & RAB_OFFSET ) == CCCH) {
       LOG_T(RRC,"[eNB %d] Frame %d CCCH request (Srb_id %d)\n",Mod_idP,frameP, Srb_id);
 
-      if(eNB_rrc_inst[Mod_idP].carrier[CC_id].Srb0.Active==0) {
+      if(RC.rrc[Mod_idP]->carrier[CC_id].Srb0.Active==0) {
         LOG_E(RRC,"[eNB %d] CCCH Not active\n",Mod_idP);
         return -1;
       }
 
-      Srb_info=&eNB_rrc_inst[Mod_idP].carrier[CC_id].Srb0;
+      Srb_info=&RC.rrc[Mod_idP]->carrier[CC_id].Srb0;
 
       // check if data is there for MAC
       if(Srb_info->Tx_buffer.payload_size>0) { //Fill buffer
@@ -225,7 +228,7 @@ mac_rrc_data_req(
 #ifdef Rel10
 
     if((Srb_id & RAB_OFFSET) == MCCH) {
-      if(eNB_rrc_inst[Mod_idP].carrier[CC_id].MCCH_MESS[mbsfn_sync_area].Active==0) {
+      if(RC.rrc[Mod_idP]->carrier[CC_id].MCCH_MESS[mbsfn_sync_area].Active==0) {
         return 0;  // this parameter is set in function init_mcch in rrc_eNB.c
       }
 
@@ -239,7 +242,7 @@ mac_rrc_data_req(
 #if defined(ENABLE_ITTI)
       {
         MessageDef *message_p;
-        int mcch_size = eNB_rrc_inst[Mod_idP].carrier[CC_id].sizeof_MCCH_MESSAGE[mbsfn_sync_area];
+        int mcch_size = RC.rrc[Mod_idP]->carrier[CC_id].sizeof_MCCH_MESSAGE[mbsfn_sync_area];
         int sdu_size = sizeof(RRC_MAC_MCCH_DATA_REQ (message_p).sdu);
 
         if (mcch_size > sdu_size) {
@@ -252,7 +255,7 @@ mac_rrc_data_req(
         RRC_MAC_MCCH_DATA_REQ (message_p).sdu_size = mcch_size;
         memset (RRC_MAC_MCCH_DATA_REQ (message_p).sdu, 0, MCCH_SDU_SIZE);
         memcpy (RRC_MAC_MCCH_DATA_REQ (message_p).sdu,
-                eNB_rrc_inst[Mod_idP].carrier[CC_id].MCCH_MESSAGE[mbsfn_sync_area],
+                RC.rrc[Mod_idP]->carrier[CC_id].MCCH_MESSAGE[mbsfn_sync_area],
                 mcch_size);
         RRC_MAC_MCCH_DATA_REQ (message_p).enb_index = eNB_index;
         RRC_MAC_MCCH_DATA_REQ (message_p).mbsfn_sync_area = mbsfn_sync_area;
@@ -262,20 +265,20 @@ mac_rrc_data_req(
 #endif
 
       memcpy(&buffer_pP[0],
-             eNB_rrc_inst[Mod_idP].carrier[CC_id].MCCH_MESSAGE[mbsfn_sync_area],
-             eNB_rrc_inst[Mod_idP].carrier[CC_id].sizeof_MCCH_MESSAGE[mbsfn_sync_area]);
+             RC.rrc[Mod_idP]->carrier[CC_id].MCCH_MESSAGE[mbsfn_sync_area],
+             RC.rrc[Mod_idP]->carrier[CC_id].sizeof_MCCH_MESSAGE[mbsfn_sync_area]);
 
 #ifdef DEBUG_RRC
       LOG_D(RRC,"[eNB %d] Frame %d : MCCH request => MCCH_MESSAGE \n",Mod_idP,frameP);
 
-      for (i=0; i<eNB_rrc_inst[Mod_idP].carrier[CC_id].sizeof_MCCH_MESSAGE[mbsfn_sync_area]; i++) {
+      for (i=0; i<RC.rrc[Mod_idP]->carrier[CC_id].sizeof_MCCH_MESSAGE[mbsfn_sync_area]; i++) {
         LOG_T(RRC,"%x.",buffer_pP[i]);
       }
 
       LOG_T(RRC,"\n");
 #endif
 
-      return (eNB_rrc_inst[Mod_idP].carrier[CC_id].sizeof_MCCH_MESSAGE[mbsfn_sync_area]);
+      return (RC.rrc[Mod_idP]->carrier[CC_id].sizeof_MCCH_MESSAGE[mbsfn_sync_area]);
       //      }
       //else
       //return(0);
@@ -462,7 +465,7 @@ mac_rrc_data_ind(
 #endif // Rel10
 
   } else { // This is an eNB
-    Srb_info = &eNB_rrc_inst[module_idP].carrier[CC_id].Srb0;
+    Srb_info = &RC.rrc[module_idP]->carrier[CC_id].Srb0;
     LOG_T(RRC,"[eNB %d] Received SDU for CCCH on SRB %d\n",module_idP,Srb_info->Srb_id);
 
 #if defined(ENABLE_ITTI)
@@ -706,7 +709,7 @@ mac_eNB_get_rrc_status(
 {
   struct rrc_eNB_ue_context_s* ue_context_p = NULL;
   ue_context_p = rrc_eNB_get_ue_context(
-                   &eNB_rrc_inst[Mod_idP],
+                   RC.rrc[Mod_idP],
                    rntiP);
 
   if (ue_context_p != NULL) {
@@ -724,7 +727,7 @@ void mac_eNB_rrc_ul_failure(const module_id_t Mod_instP,
 {
   struct rrc_eNB_ue_context_s* ue_context_p = NULL;
   ue_context_p = rrc_eNB_get_ue_context(
-                   &eNB_rrc_inst[Mod_instP],
+                   RC.rrc[Mod_instP],
                    rntiP);
 
   if (ue_context_p != NULL) {
@@ -745,7 +748,7 @@ void mac_eNB_rrc_ul_in_sync(const module_id_t Mod_instP,
 {
   struct rrc_eNB_ue_context_s* ue_context_p = NULL;
   ue_context_p = rrc_eNB_get_ue_context(
-                   &eNB_rrc_inst[Mod_instP],
+                   RC.rrc[Mod_instP],
                    rntiP);
 
   if (ue_context_p != NULL) {
diff --git a/openair2/RRC/LITE/MESSAGES/asn1_msg.c b/openair2/RRC/LITE/MESSAGES/asn1_msg.c
index b4290e8b9d..079d100bde 100644
--- a/openair2/RRC/LITE/MESSAGES/asn1_msg.c
+++ b/openair2/RRC/LITE/MESSAGES/asn1_msg.c
@@ -64,6 +64,7 @@
 #endif
 
 #include "RRC/LITE/defs.h"
+#include "RRC/LITE/extern.h"
 #include "RRCConnectionSetupComplete.h"
 #include "RRCConnectionReconfigurationComplete.h"
 #include "RRCConnectionReconfiguration.h"
@@ -87,6 +88,8 @@
 # include "intertask_interface.h"
 #endif
 
+#include "common/ran_context.h"
+
 //#include "PHY/defs.h"
 #ifndef USER_MODE
 #define msg printk
@@ -101,7 +104,6 @@ int errno;
 
 //#define XER_PRINT
 
-extern Enb_properties_array_t enb_properties;
 typedef struct xer_sprint_string_s {
   char *string;
   size_t string_size;
@@ -111,6 +113,8 @@ typedef struct xer_sprint_string_s {
 extern unsigned char NB_eNB_INST;
 extern uint8_t usim_test;
 
+extern RAN_CONTEXT_t RC;
+
 uint16_t two_tier_hexagonal_cellIds[7] = {0,1,2,4,5,7,8};
 uint16_t two_tier_hexagonal_adjacent_cellIds[7][6] = {{1,2,4,5,7,8},    // CellId 0
   {11,18,2,0,8,15}, // CellId 1
@@ -186,186 +190,84 @@ uint8_t get_adjacent_cell_mod_id(uint16_t phyCellId)
   return 0xFF; //error!
 }
 
-/*
-uint8_t do_SIB1(LTE_DL_FRAME_PARMS *frame_parms, uint8_t *buffer,
-    SystemInformationBlockType1_t *sib1) {
-
-
-  PLMN_IdentityInfo_t PLMN_identity_info;
-  MCC_MNC_Digit_t dummy;
-  asn_enc_rval_t enc_rval;
-  SchedulingInfo_t schedulingInfo;
-  SIB_Type_t sib_type;
-
-  memset(sib1,0,sizeof(SystemInformationBlockType1_t));
-  memset(&PLMN_identity_info,0,sizeof(PLMN_IdentityInfo_t));
-  memset(&schedulingInfo,0,sizeof(SchedulingInfo_t));
-  memset(&sib_type,0,sizeof(SIB_Type_t));
-
-  PLMN_identity_info.plmn_Identity.mcc = CALLOC(1,sizeof(*PLMN_identity_info.plmn_Identity.mcc));
-  memset(PLMN_identity_info.plmn_Identity.mcc,0,sizeof(*PLMN_identity_info.plmn_Identity.mcc));
-
-  asn_set_empty(&PLMN_identity_info.plmn_Identity.mcc->list);//.size=0;
-
-  dummy=2;ASN_SEQUENCE_ADD(&PLMN_identity_info.plmn_Identity.mcc->list,&dummy);
-  dummy=6;ASN_SEQUENCE_ADD(&PLMN_identity_info.plmn_Identity.mcc->list,&dummy);
-  dummy=2;ASN_SEQUENCE_ADD(&PLMN_identity_info.plmn_Identity.mcc->list,&dummy);
-
-  PLMN_identity_info.plmn_Identity.mnc.list.size=0;
-  PLMN_identity_info.plmn_Identity.mnc.list.count=0;
-  dummy=8;ASN_SEQUENCE_ADD(&PLMN_identity_info.plmn_Identity.mnc.list,&dummy);
-  dummy=0;ASN_SEQUENCE_ADD(&PLMN_identity_info.plmn_Identity.mnc.list,&dummy);
-  //assign_enum(&PLMN_identity_info.cellReservedForOperatorUse,PLMN_IdentityInfo__cellReservedForOperatorUse_notReserved);
-  PLMN_identity_info.cellReservedForOperatorUse=PLMN_IdentityInfo__cellReservedForOperatorUse_notReserved;
-
-  ASN_SEQUENCE_ADD(&sib1->cellAccessRelatedInfo.plmn_IdentityList.list,&PLMN_identity_info);
-
-
-  // 16 bits
-  sib1->cellAccessRelatedInfo.trackingAreaCode.buf = MALLOC(2);
-  sib1->cellAccessRelatedInfo.trackingAreaCode.buf[0]=0x00;
-  sib1->cellAccessRelatedInfo.trackingAreaCode.buf[1]=0x10;
-  sib1->cellAccessRelatedInfo.trackingAreaCode.size=2;
-  sib1->cellAccessRelatedInfo.trackingAreaCode.bits_unused=0;
-
-  // 28 bits
-  sib1->cellAccessRelatedInfo.cellIdentity.buf = MALLOC(8);
-  sib1->cellAccessRelatedInfo.cellIdentity.buf[0]=0x01;
-  sib1->cellAccessRelatedInfo.cellIdentity.buf[1]=0x48;
-  sib1->cellAccessRelatedInfo.cellIdentity.buf[2]=0x0f;
-  sib1->cellAccessRelatedInfo.cellIdentity.buf[3]=0x03;
-  sib1->cellAccessRelatedInfo.cellIdentity.size=4;
-  sib1->cellAccessRelatedInfo.cellIdentity.bits_unused=4;
-
-  //  assign_enum(&sib1->cellAccessRelatedInfo.cellBarred,SystemInformationBlockType1__cellAccessRelatedInfo__cellBarred_notBarred);
-  sib1->cellAccessRelatedInfo.cellBarred=SystemInformationBlockType1__cellAccessRelatedInfo__cellBarred_notBarred;
-
-  //  assign_enum(&sib1->cellAccessRelatedInfo.intraFreqReselection,SystemInformationBlockType1__cellAccessRelatedInfo__intraFreqReselection_allowed);
-  sib1->cellAccessRelatedInfo.intraFreqReselection=SystemInformationBlockType1__cellAccessRelatedInfo__intraFreqReselection_allowed;
-  sib1->cellAccessRelatedInfo.csg_Indication=0;
-
-  sib1->cellSelectionInfo.q_RxLevMin=-70;
-  sib1->cellSelectionInfo.q_RxLevMinOffset=NULL;
-
-  sib1->freqBandIndicator = 2;
-
-  //  assign_enum(&schedulingInfo.si_Periodicity,SchedulingInfo__si_Periodicity_rf8);
-  schedulingInfo.si_Periodicity=SchedulingInfo__si_Periodicity_rf8;
-
-  //  assign_enum(&sib_type,SIB_Type_sibType3);
-  sib_type=SIB_Type_sibType3;
-
-  ASN_SEQUENCE_ADD(&schedulingInfo.sib_MappingInfo.list,&sib_type);
-  ASN_SEQUENCE_ADD(&sib1->schedulingInfoList.list,&schedulingInfo);
-
-  sib1->tdd_Config = CALLOC(1,sizeof(struct TDD_Config));
-
-  //assign_enum(&sib1->tdd_Config->subframeAssignment,TDD_Config__subframeAssignment_sa3);
-  sib1->tdd_Config->subframeAssignment=frame_parms->tdd_config; //TDD_Config__subframeAssignment_sa3;
-
-  //  assign_enum(&sib1->tdd_Config->specialSubframePatterns,TDD_Config__specialSubframePatterns_ssp0);
-  sib1->tdd_Config->specialSubframePatterns=frame_parms->tdd_config_S;//TDD_Config__specialSubframePatterns_ssp0;
-
-  //  assign_enum(&sib1->si_WindowLength,SystemInformationBlockType1__si_WindowLength_ms10);
-  sib1->si_WindowLength=SystemInformationBlockType1__si_WindowLength_ms10;
-  sib1->systemInfoValueTag=0;
-  //  sib1.nonCriticalExtension = calloc(1,sizeof(*sib1.nonCriticalExtension));
-
-#ifdef USER_MODE
-  xer_fprint(stdout, &asn_DEF_SystemInformationBlockType1, (void*)sib1);
-#endif
-
-  enc_rval = uper_encode_to_buffer(&asn_DEF_SystemInformationBlockType1,
-           (void*)sib1,
-           buffer,
-           200);
-#ifdef USER_MODE
-  LOG_D(RRC,"[eNB] SystemInformationBlockType1 Encoded %d bits (%d bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8);
-#endif
-
-  if (enc_rval.encoded==-1)
-    return(-1);
-  return((enc_rval.encoded+7)/8);
-}
-*/
-// AT4 packet
-uint8_t do_MIB(uint8_t Mod_id, LTE_DL_FRAME_PARMS *frame_parms, uint32_t frame, uint8_t *buffer)
+uint8_t do_MIB(rrc_eNB_carrier_data_t *carrier, uint32_t N_RB_DL, uint32_t phich_Resource, uint32_t phich_duration, uint32_t frame)
 {
 
   asn_enc_rval_t enc_rval;
-  BCCH_BCH_Message_t mib;
+  BCCH_BCH_Message_t *mib=&carrier->mib ;
   uint8_t sfn = (uint8_t)((frame>>2)&0xff);
   uint16_t spare=0;
 
-  switch (frame_parms->N_RB_DL) {
+  switch (N_RB_DL) {
 
   case 6:
-    mib.message.dl_Bandwidth = MasterInformationBlock__dl_Bandwidth_n6;
+    mib->message.dl_Bandwidth = MasterInformationBlock__dl_Bandwidth_n6;
     break;
 
   case 15:
-    mib.message.dl_Bandwidth = MasterInformationBlock__dl_Bandwidth_n15;
+    mib->message.dl_Bandwidth = MasterInformationBlock__dl_Bandwidth_n15;
     break;
 
   case 25:
-    mib.message.dl_Bandwidth = MasterInformationBlock__dl_Bandwidth_n25;
+    mib->message.dl_Bandwidth = MasterInformationBlock__dl_Bandwidth_n25;
     break;
 
   case 50:
-    mib.message.dl_Bandwidth = MasterInformationBlock__dl_Bandwidth_n50;
+    mib->message.dl_Bandwidth = MasterInformationBlock__dl_Bandwidth_n50;
     break;
 
   case 75:
-    mib.message.dl_Bandwidth = MasterInformationBlock__dl_Bandwidth_n75;
+    mib->message.dl_Bandwidth = MasterInformationBlock__dl_Bandwidth_n75;
     break;
 
   case 100:
-    mib.message.dl_Bandwidth = MasterInformationBlock__dl_Bandwidth_n100;
+    mib->message.dl_Bandwidth = MasterInformationBlock__dl_Bandwidth_n100;
     break;
 
   default:
-    mib.message.dl_Bandwidth = MasterInformationBlock__dl_Bandwidth_n6;
+    mib->message.dl_Bandwidth = MasterInformationBlock__dl_Bandwidth_n6;
     break;
   }
 
-  switch (frame_parms->phich_config_common.phich_resource) {
+  switch (phich_Resource) {
   case oneSixth:
-    mib.message.phich_Config.phich_Resource = 0;
+    mib->message.phich_Config.phich_Resource = 0;
     break;
 
   case half:
-    mib.message.phich_Config.phich_Resource = 1;
+    mib->message.phich_Config.phich_Resource = 1;
     break;
 
   case one:
-    mib.message.phich_Config.phich_Resource = 2;
+    mib->message.phich_Config.phich_Resource = 2;
     break;
 
   case two:
-    mib.message.phich_Config.phich_Resource = 3;
+    mib->message.phich_Config.phich_Resource = 3;
     break;
   }
 
-  printf("[MIB] systemBandwidth %x, phich_duration %x, phich_resource %x,sfn %x\n",
-         (uint32_t)mib.message.dl_Bandwidth,
-         (uint32_t)frame_parms->phich_config_common.phich_duration,
-         (uint32_t)mib.message.phich_Config.phich_Resource,
+  LOG_I(RRC,"[MIB] systemBandwidth %x, phich_duration %x, phich_resource %x,sfn %x\n",
+         (uint32_t)mib->message.dl_Bandwidth,
+         (uint32_t)phich_duration,
+         (uint32_t)phich_Resource,
          (uint32_t)sfn);
-  mib.message.phich_Config.phich_Duration = frame_parms->phich_config_common.phich_duration;
-  mib.message.systemFrameNumber.buf = &sfn;
-  mib.message.systemFrameNumber.size = 1;
-  mib.message.systemFrameNumber.bits_unused=0;
-  mib.message.spare.buf = (uint8_t *)&spare;
-  mib.message.spare.size = 2;
-  mib.message.spare.bits_unused = 6;  // This makes a spare of 10 bits
+  mib->message.phich_Config.phich_Duration = phich_duration;
+  mib->message.systemFrameNumber.buf = &sfn;
+  mib->message.systemFrameNumber.size = 1;
+  mib->message.systemFrameNumber.bits_unused=0;
+  mib->message.spare.buf = (uint8_t *)&spare;
+  mib->message.spare.size = 2;
+  mib->message.spare.bits_unused = 6;  // This makes a spare of 10 bits
 
   enc_rval = uper_encode_to_buffer(&asn_DEF_BCCH_BCH_Message,
-                                   (void*)&mib,
-                                   buffer,
+                                   (void*)mib,
+                                   &carrier->MIB,
                                    100);
   AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n",
                enc_rval.failed_type->name, enc_rval.encoded);
 
+  /*
 #if defined(ENABLE_ITTI)
 # if !defined(DISABLE_XER_SPRINT)
   {
@@ -379,31 +281,21 @@ uint8_t do_MIB(uint8_t Mod_id, LTE_DL_FRAME_PARMS *frame_parms, uint32_t frame,
       msg_p->ittiMsg.rrc_dl_bcch.size = message_string_size;
       memcpy(&msg_p->ittiMsg.rrc_dl_bcch.text, message_string, message_string_size);
 
-      itti_send_msg_to_task(TASK_UNKNOWN, Mod_id, msg_p);
+      itti_send_msg_to_task(TASK_UNKNOWN, enb_module_idP, msg_p);
     }
   }
 # endif
 #endif
-
+  */
   if (enc_rval.encoded==-1) {
     return(-1);
   }
 
   return((enc_rval.encoded+7)/8);
-  /*
-  printf("MIB: %x ((MIB>>10)&63)+(MIB&3<<6)=SFN %x, MIB>>2&3 = phich_resource %d, MIB>>4&1 = phich_duration %d, MIB>>5&7 = system_bandwidth %d)\n",*(uint32_t *)buffer,
-   (((*(uint32_t *)buffer)>>10)&0x3f)+(((*(uint32_t *)buffer)&3)<<6),
-   ((*(uint32_t *)buffer)>>2)&0x3,
-   ((*(uint32_t *)buffer)>>4)&0x1,
-   ((*(uint32_t *)buffer)>>5)&0x7
-   );
-  */
 }
 
-uint8_t do_SIB1(uint8_t Mod_id, int CC_id,
-                LTE_DL_FRAME_PARMS *frame_parms, uint8_t *buffer,
-                BCCH_DL_SCH_Message_t *bcch_message,
-                SystemInformationBlockType1_t **sib1
+uint8_t do_SIB1(rrc_eNB_carrier_data_t *carrier,
+		int Mod_id,int CC_id
 #if defined(ENABLE_ITTI)
                 , RrcConfigurationReq *configuration
 #endif
@@ -417,6 +309,11 @@ uint8_t do_SIB1(uint8_t Mod_id, int CC_id,
   SchedulingInfo_t schedulingInfo;
   SIB_Type_t sib_type;
 
+  uint8_t *buffer                      = carrier->SIB1;
+  BCCH_DL_SCH_Message_t *bcch_message  = &carrier->siblock1;
+  SystemInformationBlockType1_t **sib1 = &carrier->sib1;
+
+  
   memset(bcch_message,0,sizeof(BCCH_DL_SCH_Message_t));
   bcch_message->message.present = BCCH_DL_SCH_MessageType_PR_c1;
   bcch_message->message.choice.c1.present = BCCH_DL_SCH_MessageType__c1_PR_systemInformationBlockType1;
@@ -552,14 +449,14 @@ uint8_t do_SIB1(uint8_t Mod_id, int CC_id,
 #if defined(ENABLE_ITTI)
       configuration->tdd_config[CC_id];
 #else
-      frame_parms->tdd_config;
+      3;
 #endif
 
     (*sib1)->tdd_Config->specialSubframePatterns =
 #if defined(ENABLE_ITTI)
       configuration->tdd_config_s[CC_id];
 #else
-      frame_parms->tdd_config_S;
+    0;
 #endif
   }
 
@@ -589,7 +486,6 @@ uint8_t do_SIB1(uint8_t Mod_id, int CC_id,
       msg_p = itti_alloc_new_message_sized (TASK_RRC_ENB, RRC_DL_BCCH, message_string_size + sizeof (IttiMsgText));
       msg_p->ittiMsg.rrc_dl_bcch.size = message_string_size;
       memcpy(&msg_p->ittiMsg.rrc_dl_bcch.text, message_string, message_string_size);
-
       itti_send_msg_to_task(TASK_UNKNOWN, Mod_id, msg_p);
     }
   }
@@ -608,17 +504,7 @@ uint8_t do_SIB1(uint8_t Mod_id, int CC_id,
 }
 
 uint8_t do_SIB23(uint8_t Mod_id,
-                 int CC_id,
-                 LTE_DL_FRAME_PARMS *frame_parms,
-                 uint8_t *buffer,
-                 BCCH_DL_SCH_Message_t *bcch_message,
-                 SystemInformationBlockType2_t **sib2,
-                 SystemInformationBlockType3_t **sib3
-#ifdef Rel10
-                 ,
-                 SystemInformationBlockType13_r9_t **sib13,
-                 uint8_t MBMS_flag
-#endif
+                 int CC_id
 #if defined(ENABLE_ITTI)
                  , RrcConfigurationReq *configuration
 #endif
@@ -633,6 +519,15 @@ uint8_t do_SIB23(uint8_t Mod_id,
 #endif
   asn_enc_rval_t enc_rval;
 
+  uint8_t                           *buffer       = RC.rrc[Mod_id]->carrier[CC_id].SIB23;
+  BCCH_DL_SCH_Message_t             *bcch_message = &RC.rrc[Mod_id]->carrier[CC_id].systemInformation;
+  SystemInformationBlockType2_t     **sib2        = &RC.rrc[Mod_id]->carrier[CC_id].sib2;
+  SystemInformationBlockType3_t     **sib3        = &RC.rrc[Mod_id]->carrier[CC_id].sib3;
+#ifdef Rel10
+  SystemInformationBlockType13_r9_t **sib13       = &RC.rrc[Mod_id]->carrier[CC_id].sib13;
+  uint8_t                           MBMS_flag     = RC.rrc[Mod_id]->carrier[CC_id].MBMS_flag;
+#endif
+
   if (bcch_message) {
     memset(bcch_message,0,sizeof(BCCH_DL_SCH_Message_t));
   } else {
@@ -864,12 +759,8 @@ uint8_t do_SIB23(uint8_t Mod_id,
   // PDSCH-Config
   (*sib2)->radioResourceConfigCommon.pdsch_ConfigCommon.referenceSignalPower=0;  // corresponds to 24.7 dBm 5 MHz/ 27.7 10 MHz/ 30.7 20 MHz
 
-  if (frame_parms->mode1_flag==1) {
-    (*sib2)->radioResourceConfigCommon.pdsch_ConfigCommon.p_b=0;
-  } else {
-    (*sib2)->radioResourceConfigCommon.pdsch_ConfigCommon.p_b=1;
 
-  }
+  (*sib2)->radioResourceConfigCommon.pdsch_ConfigCommon.p_b=0;
 
   // PUSCH-Config
   (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.pusch_ConfigBasic.n_SB=1;
@@ -947,11 +838,7 @@ uint8_t do_SIB23(uint8_t Mod_id,
     sib2_mbsfn_SubframeConfig1->subframeAllocation.choice.oneFrame.size= 1;
     sib2_mbsfn_SubframeConfig1->subframeAllocation.choice.oneFrame.bits_unused= 2;
 
-    if (frame_parms->frame_type == TDD) {
-      sib2_mbsfn_SubframeConfig1->subframeAllocation.choice.oneFrame.buf[0]=0x08<<2;// shift 2 cuz 2last bits are unused.
-    } else { /// 111000
-      sib2_mbsfn_SubframeConfig1->subframeAllocation.choice.oneFrame.buf[0]=0x38<<2;
-    }
+    sib2_mbsfn_SubframeConfig1->subframeAllocation.choice.oneFrame.buf[0]=0x38<<2;
 
     ASN_SEQUENCE_ADD(&MBSFNSubframeConfigList->list,sib2_mbsfn_SubframeConfig1);
 
@@ -968,11 +855,8 @@ uint8_t do_SIB23(uint8_t Mod_id,
       sib2_mbsfn_SubframeConfig2->subframeAllocation.choice.oneFrame.size= 1;
       sib2_mbsfn_SubframeConfig2->subframeAllocation.choice.oneFrame.bits_unused= 2;
 
-      if (frame_parms->frame_type == TDD) {
-        sib2_mbsfn_SubframeConfig2->subframeAllocation.choice.oneFrame.buf[0]=0x08<<2;// shift 2 cuz 2last bits are unused.
-      } else { ///000111
-        sib2_mbsfn_SubframeConfig2->subframeAllocation.choice.oneFrame.buf[0]=0x07<<2;
-      }
+      sib2_mbsfn_SubframeConfig2->subframeAllocation.choice.oneFrame.buf[0]=0x07<<2;
+     
 
       ASN_SEQUENCE_ADD(&MBSFNSubframeConfigList->list,sib2_mbsfn_SubframeConfig2);
     }
@@ -1043,11 +927,8 @@ uint8_t do_SIB23(uint8_t Mod_id,
     MBSFN_Area1->mcch_Config_r9.sf_AllocInfo_r9.buf= MALLOC(1);
     MBSFN_Area1->mcch_Config_r9.sf_AllocInfo_r9.size= 1;
 
-    if (frame_parms->frame_type == TDD) {//TDD: SF7
-      MBSFN_Area1->mcch_Config_r9.sf_AllocInfo_r9.buf[0]=0x08<<2;
-    } else {
-      MBSFN_Area1->mcch_Config_r9.sf_AllocInfo_r9.buf[0]=0x20<<2;  // FDD: SF1
-    }
+    MBSFN_Area1->mcch_Config_r9.sf_AllocInfo_r9.buf[0]=0x20<<2;  // FDD: SF1
+    
 
     MBSFN_Area1->mcch_Config_r9.sf_AllocInfo_r9.bits_unused= 2;
 
@@ -1069,11 +950,8 @@ uint8_t do_SIB23(uint8_t Mod_id,
       MBSFN_Area2->mcch_Config_r9.sf_AllocInfo_r9.size= 1;
       MBSFN_Area2->mcch_Config_r9.sf_AllocInfo_r9.bits_unused= 2;
 
-      if (frame_parms->frame_type == TDD) {//TDD: SF7
-        MBSFN_Area2->mcch_Config_r9.sf_AllocInfo_r9.buf[0]=0x08<<2;
-      } else {
-        MBSFN_Area2->mcch_Config_r9.sf_AllocInfo_r9.buf[0]=0x04<<2;  // FDD: SF6
-      }
+      MBSFN_Area2->mcch_Config_r9.sf_AllocInfo_r9.buf[0]=0x04<<2;  // FDD: SF6
+     
 
       MBSFN_Area2->mcch_Config_r9.signallingMCS_r9= MBSFN_AreaInfo_r9__mcch_Config_r9__signallingMCS_r9_n7;
 
@@ -1388,10 +1266,10 @@ uint8_t
 do_RRCConnectionSetup(
   const protocol_ctxt_t*     const ctxt_pP,
   rrc_eNB_ue_context_t*      const ue_context_pP,
-  int                              CC_id,
+  int                        CC_id,
   uint8_t*                   const buffer,
-  const uint8_t                    transmission_mode,
-  const uint8_t                    Transaction_id,
+  const uint8_t              transmission_mode,
+  const uint8_t              Transaction_id,
   const LTE_DL_FRAME_PARMS* const frame_parms,
   SRB_ToAddModList_t  **SRB_configList,
   struct PhysicalConfigDedicated  **physicalConfigDedicated)
@@ -1399,6 +1277,7 @@ do_RRCConnectionSetup(
 
   asn_enc_rval_t enc_rval;
   uint8_t ecause=0;
+  eNB_RRC_INST *rrc = RC.rrc[ctxt_pP->module_id];
 
   long* logicalchannelgroup = NULL;
   struct SRB_ToAddMod* SRB1_config = NULL;
@@ -1442,12 +1321,12 @@ do_RRCConnectionSetup(
   SRB1_rlc_config->present = SRB_ToAddMod__rlc_Config_PR_explicitValue;
   SRB1_rlc_config->choice.explicitValue.present=RLC_Config_PR_am;
 #if defined(ENABLE_ITTI)
-  SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.t_PollRetransmit = enb_properties.properties[ctxt_pP->module_id]->srb1_timer_poll_retransmit;
-  SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.pollPDU          = enb_properties.properties[ctxt_pP->module_id]->srb1_poll_pdu;
-  SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.pollByte         = enb_properties.properties[ctxt_pP->module_id]->srb1_poll_byte;
-  SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.maxRetxThreshold = enb_properties.properties[ctxt_pP->module_id]->srb1_max_retx_threshold;
-  SRB1_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_Reordering     = enb_properties.properties[ctxt_pP->module_id]->srb1_timer_reordering;
-  SRB1_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_StatusProhibit = enb_properties.properties[ctxt_pP->module_id]->srb1_timer_status_prohibit;
+  SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.t_PollRetransmit = rrc->srb1_timer_poll_retransmit;
+  SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.pollPDU          = rrc->srb1_poll_pdu;
+  SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.pollByte         = rrc->srb1_poll_byte;
+  SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.maxRetxThreshold = rrc->srb1_max_retx_threshold;
+  SRB1_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_Reordering     = rrc->srb1_timer_reordering;
+  SRB1_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_StatusProhibit = rrc->srb1_timer_status_prohibit;
 #else 
   SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.t_PollRetransmit = T_PollRetransmit_ms20;;
   SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.pollPDU          = PollPDU_p4;;
@@ -1493,7 +1372,7 @@ do_RRCConnectionSetup(
   physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH         = CALLOC(1,sizeof(*physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH));
   physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH         = CALLOC(1,sizeof(*physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH));
   physicalConfigDedicated2->cqi_ReportConfig              = CALLOC(1,sizeof(*physicalConfigDedicated2->cqi_ReportConfig));
-  if (enb_properties.properties[ctxt_pP->module_id]->srs_enable[CC_id])
+  if (rrc->srs_enable[CC_id])
     physicalConfigDedicated2->soundingRS_UL_ConfigDedicated = CALLOC(1,sizeof(*physicalConfigDedicated2->soundingRS_UL_ConfigDedicated));
   else
     physicalConfigDedicated2->soundingRS_UL_ConfigDedicated = NULL;
@@ -1582,7 +1461,7 @@ do_RRCConnectionSetup(
     */
 
   //soundingRS-UL-ConfigDedicated
-  if (enb_properties.properties[ctxt_pP->module_id]->srs_enable[CC_id]) {
+  if (rrc->srs_enable[CC_id]) {
     physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->present = SoundingRS_UL_ConfigDedicated_PR_setup;
     physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.srs_Bandwidth =
                                                              SoundingRS_UL_ConfigDedicated__setup__srs_Bandwidth_bw0;
@@ -2759,36 +2638,3 @@ OAI_UECapability_t *fill_ue_capability(char *UE_EUTRA_Capability_xer_fname)
   return(&UECapability);
 }
 
-#ifndef USER_MODE
-int init_module(void)
-{
-  printk("Init asn1_msg module\n");
-
-  // A non 0 return means init_module failed; module can't be loaded.
-  return 0;
-}
-
-
-void cleanup_module(void)
-{
-  printk("Stopping asn1_msg module\n");
-}
-
-EXPORT_SYMBOL(do_SIB1);
-EXPORT_SYMBOL(do_SIB23);
-EXPORT_SYMBOL(do_RRCConnectionRequest);
-EXPORT_SYMBOL(do_RRCConnectionSetupComplete);
-EXPORT_SYMBOL(do_RRCConnectionReconfigurationComplete);
-EXPORT_SYMBOL(do_RRCConnectionSetup);
-EXPORT_SYMBOL(do_RRCConnectionReestablishmentReject);
-EXPORT_SYMBOL(do_RRCConnectionReconfiguration);
-EXPORT_SYMBOL(asn_DEF_UL_DCCH_Message);
-EXPORT_SYMBOL(asn_DEF_UL_CCCH_Message);
-EXPORT_SYMBOL(asn_DEF_SystemInformation);
-EXPORT_SYMBOL(asn_DEF_DL_DCCH_Message);
-EXPORT_SYMBOL(asn_DEF_SystemInformationBlockType1);
-EXPORT_SYMBOL(asn_DEF_DL_CCCH_Message);
-EXPORT_SYMBOL(uper_decode_complete);
-EXPORT_SYMBOL(uper_decode);
-EXPORT_SYMBOL(transmission_mode_rrc);
-#endif
diff --git a/openair2/RRC/LITE/MESSAGES/asn1_msg.h b/openair2/RRC/LITE/MESSAGES/asn1_msg.h
index 881a778030..3b67f1fb2d 100644
--- a/openair2/RRC/LITE/MESSAGES/asn1_msg.h
+++ b/openair2/RRC/LITE/MESSAGES/asn1_msg.h
@@ -60,19 +60,24 @@ uint16_t get_adjacent_cell_id(uint8_t Mod_id,uint8_t index);
 uint8_t get_adjacent_cell_mod_id(uint16_t phyCellId);
 
 /**
-\brief Generate a default configuration for SIB1 (eNB).
-@param frame_parms Used to store some basic parameters from PHY configuration
-@param buffer Pointer to PER-encoded ASN.1 description of SIB1
-@param sib1 Pointer to asn1c C representation of SIB1
+\brief Generate configuration for SIB1 (eNB).
+@param carrier pointer to Carrier information
+@param N_RB_DL Number of downlink PRBs
+@param phich_Resource PHICH resoure parameter
+@param phich_duration PHICH duration parameter
+@param frame radio frame number
 @return size of encoded bit stream in bytes*/
+uint8_t do_MIB(rrc_eNB_carrier_data_t *carrier, uint32_t N_RB_DL, uint32_t phich_Resource, uint32_t phich_duration, uint32_t frame);
 
-uint8_t do_SIB1(uint8_t Mod_id, int CC_id,
-                LTE_DL_FRAME_PARMS *frame_parms, uint8_t *buffer,
-                BCCH_DL_SCH_Message_t *bcch_message,
-                SystemInformationBlockType1_t **sib1
-#if defined(ENABLE_ITTI)
-                , RrcConfigurationReq *configuration
-#endif
+/**
+\brief Generate configuration for SIB1 (eNB).
+@param carrier pointer to Carrier information
+@param Mod_id Instance of eNB
+@param Component carrier Component carrier to configure
+@param configuration Pointer Configuration Request structure  
+@return size of encoded bit stream in bytes*/
+
+uint8_t do_SIB1(rrc_eNB_carrier_data_t *carrier,int Mod_id,int CC_id, RrcConfigurationReq *configuration
                );
 
 /**
@@ -87,17 +92,7 @@ uint8_t do_SIB1(uint8_t Mod_id, int CC_id,
 @return size of encoded bit stream in bytes*/
 
 uint8_t do_SIB23(uint8_t Mod_id,
-                 int CC_id,
-                 LTE_DL_FRAME_PARMS *frame_parms,
-                 uint8_t *buffer,
-                 BCCH_DL_SCH_Message_t *systemInformation,
-                 SystemInformationBlockType2_t **sib2,
-                 SystemInformationBlockType3_t **sib3
-#ifdef Rel10
-                 ,
-                 SystemInformationBlockType13_r9_t **sib13,
-                 uint8_t MBMS_flag
-#endif
+                 int CC_id
 #if defined(ENABLE_ITTI)
                  , RrcConfigurationReq *configuration
 #endif
diff --git a/openair2/RRC/LITE/defs.h b/openair2/RRC/LITE/defs.h
index 47f8a0080a..23d1d0fec4 100644
--- a/openair2/RRC/LITE/defs.h
+++ b/openair2/RRC/LITE/defs.h
@@ -388,11 +388,17 @@ typedef struct rrc_eNB_ue_context_s {
 } rrc_eNB_ue_context_t;
 
 typedef struct {
+  uint8_t                           *MIB;
+  uint8_t                           sizeof_MIB;
   uint8_t                           *SIB1;
   uint8_t                           sizeof_SIB1;
   uint8_t                           *SIB23;
   uint8_t                           sizeof_SIB23;
-  uint16_t                          physCellId;
+  int                               physCellId;
+  int                               Ncp;
+  int                               p_eNB;
+  uint32_t                          dl_CarrierFreq;
+  uint32_t                          ul_CarrierFreq;
   BCCH_BCH_Message_t                mib;
   BCCH_DL_SCH_Message_t             siblock1;
   BCCH_DL_SCH_Message_t             systemInformation;
@@ -445,6 +451,22 @@ typedef struct eNB_RRC_INST_s {
 #if defined(ENABLE_ITTI)
   RrcConfigurationReq configuration;
 #endif
+  // other PLMN parameters
+  /// Mobile country code
+  int mcc;
+  /// Mobile network code
+  int mnc;
+  /// number of mnc digits
+  int mnc_digit_length;
+
+  // other RAN parameters
+  int srb1_timer_poll_retransmit;
+  int srb1_poll_pdu;
+  int srb1_poll_byte;
+  int srb1_max_retx_threshold;
+  int srb1_timer_reordering;
+  int srb1_timer_status_prohibit;
+  int srs_enable[MAX_NUM_CCs];
 } eNB_RRC_INST;
 
 #define MAX_UE_CAPABILITY_SIZE 255
diff --git a/openair2/RRC/LITE/extern.h b/openair2/RRC/LITE/extern.h
index d4c8192a95..2791efcd13 100644
--- a/openair2/RRC/LITE/extern.h
+++ b/openair2/RRC/LITE/extern.h
@@ -37,27 +37,8 @@
 #include "LAYER2/RLC/rlc.h"
 
 extern UE_RRC_INST *UE_rrc_inst;
-extern eNB_RRC_INST *eNB_rrc_inst;
-//extern RRC_XFACE *Rrc_xface;
-#ifndef USER_MODE
-//extern MAC_RLC_XFACE *Mac_rlc_xface;
-extern int S_rrc;
-//extern int R_rrc;
-#else
-#include "LAYER2/MAC/extern.h"
-#ifndef NO_RRM
-extern sock_rrm_t S_rrc;
-#endif
-#endif
 
-#ifndef NO_RRM
-#ifndef USER_MODE
-extern char *Header_buf;
-extern char *Data;
-extern unsigned short Header_read_idx,Data_read_idx,Header_size;
-#endif
-extern unsigned short Data_to_read;
-#endif //NO_RRM
+#include "LAYER2/MAC/extern.h"
 
 extern uint8_t DRB2LCHAN[8];
 
diff --git a/openair2/RRC/LITE/proto.h b/openair2/RRC/LITE/proto.h
index 8433980be4..b0179bad8e 100644
--- a/openair2/RRC/LITE/proto.h
+++ b/openair2/RRC/LITE/proto.h
@@ -461,4 +461,5 @@ long binary_search_int(int elements[], long numElem, int value);
 
 long binary_search_float(float elements[], long numElem, float value);
 
+void openair_rrc_top_init_eNB(int eMBMS_active,uint8_t HO_active);
 /** @}*/
diff --git a/openair2/RRC/LITE/rrc_UE.c b/openair2/RRC/LITE/rrc_UE.c
index 8a8aaf73ba..3886b5b48b 100644
--- a/openair2/RRC/LITE/rrc_UE.c
+++ b/openair2/RRC/LITE/rrc_UE.c
@@ -818,38 +818,38 @@ rrc_ue_process_measConfig(
     }
 
     LOG_I(RRC,"call rrc_mac_config_req \n");
-    rrc_mac_config_req(ctxt_pP->module_id,0,ENB_FLAG_NO,0,eNB_index,
-                       (RadioResourceConfigCommonSIB_t *)NULL,
-                       (struct PhysicalConfigDedicated *)NULL,
+    rrc_mac_config_req_ue(ctxt_pP->module_id,0,eNB_index,
+			  (RadioResourceConfigCommonSIB_t *)NULL,
+			  (struct PhysicalConfigDedicated *)NULL,
 #ifdef Rel10
-                       (SCellToAddMod_r10_t *)NULL,
-                       //struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10,
+			  (SCellToAddMod_r10_t *)NULL,
+			  //struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10,
 #endif
-                       UE_rrc_inst[ctxt_pP->module_id].MeasObj[eNB_index],
-                       (MAC_MainConfig_t *)NULL,
-                       0,
-                       (struct LogicalChannelConfig *)NULL,
-                       (MeasGapConfig_t *)NULL,
-                       (TDD_Config_t *)NULL,
-                       (MobilityControlInfo_t *)NULL,
-                       NULL,
-                       NULL,
-                       NULL,
-                       NULL,
-                       NULL,
-                       NULL
+			  UE_rrc_inst[ctxt_pP->module_id].MeasObj[eNB_index],
+			  (MAC_MainConfig_t *)NULL,
+			  0,
+			  (struct LogicalChannelConfig *)NULL,
+			  (MeasGapConfig_t *)NULL,
+			  (TDD_Config_t *)NULL,
+			  (MobilityControlInfo_t *)NULL,
+			  NULL,
+			  NULL,
+			  NULL,
+			  NULL,
+			  NULL,
+			  NULL
 #ifdef Rel10
-                       ,
-                       0,
-                       (MBSFN_AreaInfoList_r9_t *)NULL,
-                       (PMCH_InfoList_r9_t *)NULL
+			  ,
+			  0,
+			  (MBSFN_AreaInfoList_r9_t *)NULL,
+			  (PMCH_InfoList_r9_t *)NULL
 #endif
 #ifdef CBA
-                       ,
-                       0,
-                       0
+			  ,
+			  0,
+			  0
 #endif
-                      );
+			  );
   }
 
   if (measConfig->reportConfigToRemoveList != NULL) {
@@ -1305,38 +1305,38 @@ rrc_ue_process_radioResourceConfigDedicated(
 
           LOG_I(RRC, "[FRAME %05d][RRC_UE][MOD %02d][][--- MAC_CONFIG_REQ  (SRB1 eNB %d) --->][MAC_UE][MOD %02d][]\n",
                 ctxt_pP->frame, ctxt_pP->module_id, eNB_index, ctxt_pP->module_id);
-          rrc_mac_config_req(ctxt_pP->module_id,0,ENB_FLAG_NO,0,eNB_index,
-                             (RadioResourceConfigCommonSIB_t *)NULL,
-                             UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index],
+          rrc_mac_config_req_ue(ctxt_pP->module_id,0,eNB_index,
+				(RadioResourceConfigCommonSIB_t *)NULL,
+				UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index],
 #ifdef Rel10
-                             (SCellToAddMod_r10_t *)NULL,
-                             //struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10,
+				(SCellToAddMod_r10_t *)NULL,
+				//struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10,
 #endif
-                             (MeasObjectToAddMod_t **)NULL,
-                             UE_rrc_inst[ctxt_pP->module_id].mac_MainConfig[eNB_index],
-                             1,
-                             SRB1_logicalChannelConfig,
-                             (MeasGapConfig_t *)NULL,
-                             NULL,
-                             NULL,
-                             NULL,
-                             NULL,
-                             NULL,
-                             NULL,
-                             NULL,
-                             NULL
+				(MeasObjectToAddMod_t **)NULL,
+				UE_rrc_inst[ctxt_pP->module_id].mac_MainConfig[eNB_index],
+				1,
+				SRB1_logicalChannelConfig,
+				(MeasGapConfig_t *)NULL,
+				NULL,
+				NULL,
+				NULL,
+				NULL,
+				NULL,
+				NULL,
+				NULL,
+				NULL
 #ifdef Rel10
-                             ,
-                             0,
-                             (MBSFN_AreaInfoList_r9_t *)NULL,
-                             (PMCH_InfoList_r9_t *)NULL
+				,
+				0,
+				(MBSFN_AreaInfoList_r9_t *)NULL,
+				(PMCH_InfoList_r9_t *)NULL
 #endif
 #ifdef CBA
-                             ,
-                             0,
-                             0
+				,
+				0,
+				0
 #endif
-                            );
+				);
         }
       } else {
         if (UE_rrc_inst[ctxt_pP->module_id].SRB2_config[eNB_index]) {
@@ -1363,38 +1363,38 @@ rrc_ue_process_radioResourceConfigDedicated(
                 ctxt_pP->module_id,
                 eNB_index,
                 ctxt_pP->module_id);
-          rrc_mac_config_req(ctxt_pP->module_id,0,ENB_FLAG_NO,0,eNB_index,
-                             (RadioResourceConfigCommonSIB_t *)NULL,
-                             UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index],
+          rrc_mac_config_req_ue(ctxt_pP->module_id,0,eNB_index,
+				(RadioResourceConfigCommonSIB_t *)NULL,
+				UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index],
 #ifdef Rel10
-                             (SCellToAddMod_r10_t *)NULL,
-                             //struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10,
+				(SCellToAddMod_r10_t *)NULL,
+				//struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10,
 #endif
-                             (MeasObjectToAddMod_t **)NULL,
-                             UE_rrc_inst[ctxt_pP->module_id].mac_MainConfig[eNB_index],
-                             2,
-                             SRB2_logicalChannelConfig,
-                             UE_rrc_inst[ctxt_pP->module_id].measGapConfig[eNB_index],
-                             (TDD_Config_t *)NULL,
-                             (MobilityControlInfo_t *)NULL,
-                             NULL,
-                             NULL,
-                             NULL,
-                             NULL,
-                             NULL,
-                             NULL
+				(MeasObjectToAddMod_t **)NULL,
+				UE_rrc_inst[ctxt_pP->module_id].mac_MainConfig[eNB_index],
+				2,
+				SRB2_logicalChannelConfig,
+				UE_rrc_inst[ctxt_pP->module_id].measGapConfig[eNB_index],
+				(TDD_Config_t *)NULL,
+				(MobilityControlInfo_t *)NULL,
+				NULL,
+				NULL,
+				NULL,
+				NULL,
+				NULL,
+				NULL
 #ifdef Rel10
-                             ,
-                             0,
-                             (MBSFN_AreaInfoList_r9_t *)NULL,
-                             (PMCH_InfoList_r9_t *)NULL
+				,
+				0,
+				(MBSFN_AreaInfoList_r9_t *)NULL,
+				(PMCH_InfoList_r9_t *)NULL
 #endif
 #ifdef CBA
-                             ,
-                             0,
-                             0
+				,
+				0,
+				0
 #endif
-                            );
+				);
         }
       }
     }
@@ -1470,43 +1470,43 @@ rrc_ue_process_radioResourceConfigDedicated(
               radioResourceConfigDedicated->drb_ToAddModList->list.array[i]->drb_Identity,
               eNB_index,
               ctxt_pP->module_id);
-        rrc_mac_config_req(ctxt_pP->module_id,0,ENB_FLAG_NO,0,eNB_index,
-                           (RadioResourceConfigCommonSIB_t *)NULL,
-                           UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index],
+        rrc_mac_config_req_ue(ctxt_pP->module_id,0,eNB_index,
+			      (RadioResourceConfigCommonSIB_t *)NULL,
+			      UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index],
 #ifdef Rel10
-                           (SCellToAddMod_r10_t *)NULL,
-                           //struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10,
+			      (SCellToAddMod_r10_t *)NULL,
+			      //struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10,
 #endif
-                           (MeasObjectToAddMod_t **)NULL,
-                           UE_rrc_inst[ctxt_pP->module_id].mac_MainConfig[eNB_index],
-                           *UE_rrc_inst[ctxt_pP->module_id].DRB_config[eNB_index][DRB_id]->logicalChannelIdentity,
-                           UE_rrc_inst[ctxt_pP->module_id].DRB_config[eNB_index][DRB_id]->logicalChannelConfig,
-                           UE_rrc_inst[ctxt_pP->module_id].measGapConfig[eNB_index],
-                           (TDD_Config_t*)NULL,
-                           (MobilityControlInfo_t *)NULL,
-                           NULL,
-                           NULL,
-                           NULL,
-                           NULL,
-                           NULL,
-                           NULL
+			      (MeasObjectToAddMod_t **)NULL,
+			      UE_rrc_inst[ctxt_pP->module_id].mac_MainConfig[eNB_index],
+			      *UE_rrc_inst[ctxt_pP->module_id].DRB_config[eNB_index][DRB_id]->logicalChannelIdentity,
+			      UE_rrc_inst[ctxt_pP->module_id].DRB_config[eNB_index][DRB_id]->logicalChannelConfig,
+			      UE_rrc_inst[ctxt_pP->module_id].measGapConfig[eNB_index],
+			      (TDD_Config_t*)NULL,
+			      (MobilityControlInfo_t *)NULL,
+			      NULL,
+			      NULL,
+			      NULL,
+			      NULL,
+			      NULL,
+			      NULL
 #ifdef Rel10
-                           ,
-                           0,
-                           (MBSFN_AreaInfoList_r9_t *)NULL,
-                           (PMCH_InfoList_r9_t *)NULL
+			      ,
+			      0,
+			      (MBSFN_AreaInfoList_r9_t *)NULL,
+			      (PMCH_InfoList_r9_t *)NULL
 #endif
 #ifdef CBA
-                           ,
-                           UE_rrc_inst[ue_mod_idP].num_active_cba_groups, //
-                           UE_rrc_inst[ue_mod_idP].cba_rnti[0]
+			      ,
+			      UE_rrc_inst[ue_mod_idP].num_active_cba_groups, //
+			      UE_rrc_inst[ue_mod_idP].cba_rnti[0]
 #endif
-                          );
-
+			      );
+	
       }
     }
   }
-
+  
   UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].State = RRC_CONNECTED;
   LOG_I(RRC,"[UE %d] State = RRC_CONNECTED (eNB %d)\n",ctxt_pP->module_id,eNB_index);
 #if !defined(ENABLE_USE_MME) && defined(OAI_EMU)
@@ -2028,41 +2028,39 @@ rrc_ue_process_mobilityControlInfo(
         ctxt_pP->frame, ctxt_pP->module_id, eNB_index, ctxt_pP->module_id);
 
   // Reset MAC and configure PHY
-  rrc_mac_config_req(ctxt_pP->module_id,
-                     0,
-                     ENB_FLAG_NO,
-                     0,
-                     eNB_index,
-                     (RadioResourceConfigCommonSIB_t *)NULL,
-                     (struct PhysicalConfigDedicated *)NULL,
+  rrc_mac_config_req_ue(ctxt_pP->module_id,
+			0,
+			eNB_index,
+			(RadioResourceConfigCommonSIB_t *)NULL,
+			(struct PhysicalConfigDedicated *)NULL,
 #ifdef Rel10
-                     (SCellToAddMod_r10_t *)NULL,
-                     //(struct PhysicalConfigDedicatedSCell_r10 *)NULL,
+			(SCellToAddMod_r10_t *)NULL,
+			//(struct PhysicalConfigDedicatedSCell_r10 *)NULL,
 #endif
-                     (MeasObjectToAddMod_t **)NULL,
-                     (MAC_MainConfig_t *)NULL,
-                     0,
-                     (struct LogicalChannelConfig *)NULL,
-                     (MeasGapConfig_t *)NULL,
-                     (TDD_Config_t *)NULL,
-                     mobilityControlInfo,
-                     (uint8_t *)NULL,
-                     (uint16_t *)NULL,
-                     NULL,
-                     NULL,
-                     NULL,
-                     NULL
+			(MeasObjectToAddMod_t **)NULL,
+			(MAC_MainConfig_t *)NULL,
+			0,
+			(struct LogicalChannelConfig *)NULL,
+			(MeasGapConfig_t *)NULL,
+			(TDD_Config_t *)NULL,
+			mobilityControlInfo,
+			(uint8_t *)NULL,
+			(uint16_t *)NULL,
+			NULL,
+			NULL,
+			NULL,
+			NULL
 #ifdef Rel10
-                     ,0,
-                     (MBSFN_AreaInfoList_r9_t *)NULL,
-                     (PMCH_InfoList_r9_t *)NULL
+			,0,
+			(MBSFN_AreaInfoList_r9_t *)NULL,
+			(PMCH_InfoList_r9_t *)NULL
 #endif
 #ifdef CBA
-                     ,0,
-                     0
+			,0,
+			0
 #endif
-                    );
-
+			);
+  
   // Re-establish PDCP for all RBs that are established
   // rrc_pdcp_config_req (ue_mod_idP+NB_eNB_INST, frameP, 0, CONFIG_ACTION_ADD, ue_mod_idP+DCCH);
   // rrc_pdcp_config_req (ue_mod_idP+NB_eNB_INST, frameP, 0, CONFIG_ACTION_ADD, ue_mod_idP+DCCH1);
@@ -2886,38 +2884,38 @@ static int decode_SIB1( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_
   LOG_I( RRC, "[FRAME unknown][RRC_UE][MOD %02"PRIu8"][][--- MAC_CONFIG_REQ (SIB1 params eNB %"PRIu8") --->][MAC_UE][MOD %02"PRIu8"][]\n",
          ctxt_pP->module_id, eNB_index, ctxt_pP->module_id );
 
-  rrc_mac_config_req(ctxt_pP->module_id, 0, ENB_FLAG_NO, 0, eNB_index,
-                      (RadioResourceConfigCommonSIB_t *)NULL,
-                      (struct PhysicalConfigDedicated *)NULL,
+  rrc_mac_config_req_ue(ctxt_pP->module_id, 0, eNB_index,
+			(RadioResourceConfigCommonSIB_t *)NULL,
+			(struct PhysicalConfigDedicated *)NULL,
 #ifdef Rel10
-                      (SCellToAddMod_r10_t *)NULL,
-                      //(struct PhysicalConfigDedicatedSCell_r10 *)NULL,
+			(SCellToAddMod_r10_t *)NULL,
+			//(struct PhysicalConfigDedicatedSCell_r10 *)NULL,
 #endif
-                      (MeasObjectToAddMod_t **)NULL,
-                      (MAC_MainConfig_t *)NULL,
-                      0,
-                      (struct LogicalChannelConfig *)NULL,
-                      (MeasGapConfig_t *)NULL,
-                      UE_rrc_inst[ctxt_pP->module_id].sib1[eNB_index]->tdd_Config,
-                      (MobilityControlInfo_t *) NULL,
-                      &UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIwindowsize,
-                      &UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIperiod,
-                      NULL,
-                      NULL,
-                      NULL,
-                      (MBSFN_SubframeConfigList_t *)NULL
+			(MeasObjectToAddMod_t **)NULL,
+			(MAC_MainConfig_t *)NULL,
+			0,
+			(struct LogicalChannelConfig *)NULL,
+			(MeasGapConfig_t *)NULL,
+			UE_rrc_inst[ctxt_pP->module_id].sib1[eNB_index]->tdd_Config,
+			(MobilityControlInfo_t *) NULL,
+			&UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIwindowsize,
+			&UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIperiod,
+			NULL,
+			NULL,
+			NULL,
+			(MBSFN_SubframeConfigList_t *)NULL
 #ifdef Rel10
-                      ,0,
-                      (MBSFN_AreaInfoList_r9_t *)NULL,
-                      (PMCH_InfoList_r9_t *)NULL
+			,0,
+			(MBSFN_AreaInfoList_r9_t *)NULL,
+			(PMCH_InfoList_r9_t *)NULL
 #endif
 #ifdef CBA
-                      ,
-                      0,
-                      0
+			,
+			0,
+			0
 #endif
-                    );
-
+			);
+  
   UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus = 1;
   UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIB1systemInfoValueTag = sib1->systemInfoValueTag;
 
@@ -3522,35 +3520,35 @@ static int decode_SI( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_in
 	dump_sib2( UE_rrc_inst[ctxt_pP->module_id].sib2[eNB_index] );
 	LOG_I( RRC, "[FRAME %05"PRIu32"][RRC_UE][MOD %02"PRIu8"][][--- MAC_CONFIG_REQ (SIB2 params  eNB %"PRIu8") --->][MAC_UE][MOD %02"PRIu8"][]\n",
 	       ctxt_pP->frame, ctxt_pP->module_id, eNB_index, ctxt_pP->module_id );
-	rrc_mac_config_req(ctxt_pP->module_id, 0, ENB_FLAG_NO, 0, eNB_index,
-			   &UE_rrc_inst[ctxt_pP->module_id].sib2[eNB_index]->radioResourceConfigCommon,
-			   (struct PhysicalConfigDedicated *)NULL,
+	rrc_mac_config_req_ue(ctxt_pP->module_id, 0, eNB_index,
+			      &UE_rrc_inst[ctxt_pP->module_id].sib2[eNB_index]->radioResourceConfigCommon,
+			      (struct PhysicalConfigDedicated *)NULL,
 #ifdef Rel10
-			   (SCellToAddMod_r10_t *)NULL,
+			      (SCellToAddMod_r10_t *)NULL,
 #endif
-			   (MeasObjectToAddMod_t **)NULL,
-			   (MAC_MainConfig_t *)NULL,
-			   0,
-			   (struct LogicalChannelConfig *)NULL,
-			   (MeasGapConfig_t *)NULL,
-			   (TDD_Config_t *)NULL,
-			   (MobilityControlInfo_t *)NULL,
-			   NULL,
-			   NULL,
-			   UE_rrc_inst[ctxt_pP->module_id].sib2[eNB_index]->freqInfo.ul_CarrierFreq,
-			   UE_rrc_inst[ctxt_pP->module_id].sib2[eNB_index]->freqInfo.ul_Bandwidth,
-			   &UE_rrc_inst[ctxt_pP->module_id].sib2[eNB_index]->freqInfo.additionalSpectrumEmission,
-			   UE_rrc_inst[ctxt_pP->module_id].sib2[eNB_index]->mbsfn_SubframeConfigList
+			      (MeasObjectToAddMod_t **)NULL,
+			      (MAC_MainConfig_t *)NULL,
+			      0,
+			      (struct LogicalChannelConfig *)NULL,
+			      (MeasGapConfig_t *)NULL,
+			      (TDD_Config_t *)NULL,
+			      (MobilityControlInfo_t *)NULL,
+			      NULL,
+			      NULL,
+			      UE_rrc_inst[ctxt_pP->module_id].sib2[eNB_index]->freqInfo.ul_CarrierFreq,
+			      UE_rrc_inst[ctxt_pP->module_id].sib2[eNB_index]->freqInfo.ul_Bandwidth,
+			      &UE_rrc_inst[ctxt_pP->module_id].sib2[eNB_index]->freqInfo.additionalSpectrumEmission,
+			      UE_rrc_inst[ctxt_pP->module_id].sib2[eNB_index]->mbsfn_SubframeConfigList
 #ifdef Rel10
-			   ,0,
-			   (MBSFN_AreaInfoList_r9_t *)NULL,
-			   (PMCH_InfoList_r9_t *)NULL
+			      ,0,
+			      (MBSFN_AreaInfoList_r9_t *)NULL,
+			      (PMCH_InfoList_r9_t *)NULL
 #endif
 #ifdef CBA
-			   ,0,
-			   0
+			      ,0,
+			      0
 #endif
-			   );
+			      );
 	// After SI is received, prepare RRCConnectionRequest
 #ifdef Rel10
 
@@ -3705,31 +3703,31 @@ static int decode_SI( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_in
 	// adding here function to store necessary parameters for using in decode_MCCH_Message + maybe transfer to PHY layer
 	LOG_I( RRC, "[FRAME %05"PRIu32"][RRC_UE][MOD %02"PRIu8"][][--- MAC_CONFIG_REQ (SIB13 params eNB %"PRIu8") --->][MAC_UE][MOD %02"PRIu8"][]\n",
 	       ctxt_pP->frame, ctxt_pP->module_id, eNB_index, ctxt_pP->module_id);
-	rrc_mac_config_req(ctxt_pP->module_id,0,ENB_FLAG_NO,0,eNB_index,
-			   (RadioResourceConfigCommonSIB_t *)NULL,
-			   (struct PhysicalConfigDedicated *)NULL,
-			   (SCellToAddMod_r10_t *)NULL,
-			   (MeasObjectToAddMod_t **)NULL,
-			   (MAC_MainConfig_t *)NULL,
-			   0,
-			   (struct LogicalChannelConfig *)NULL,
-			   (MeasGapConfig_t *)NULL,
-			   (TDD_Config_t *)NULL,
-			   (MobilityControlInfo_t *)NULL,
-			   NULL,
-			   NULL,
-			   NULL,
-			   NULL,
-			   NULL,
-			   (MBSFN_SubframeConfigList_t *)NULL,
-			   0,
-			   &UE_rrc_inst[ctxt_pP->module_id].sib13[eNB_index]->mbsfn_AreaInfoList_r9,
-			   (PMCH_InfoList_r9_t *)NULL
+	rrc_mac_config_req_ue(ctxt_pP->module_id,0,eNB_index,
+			      (RadioResourceConfigCommonSIB_t *)NULL,
+			      (struct PhysicalConfigDedicated *)NULL,
+			      (SCellToAddMod_r10_t *)NULL,
+			      (MeasObjectToAddMod_t **)NULL,
+			      (MAC_MainConfig_t *)NULL,
+			      0,
+			      (struct LogicalChannelConfig *)NULL,
+			      (MeasGapConfig_t *)NULL,
+			      (TDD_Config_t *)NULL,
+			      (MobilityControlInfo_t *)NULL,
+			      NULL,
+			      NULL,
+			      NULL,
+			      NULL,
+			      NULL,
+			      (MBSFN_SubframeConfigList_t *)NULL,
+			      0,
+			      &UE_rrc_inst[ctxt_pP->module_id].sib13[eNB_index]->mbsfn_AreaInfoList_r9,
+			      (PMCH_InfoList_r9_t *)NULL
 #ifdef CBA
-			   ,0,
-			   0
+			      ,0,
+			      0
 #endif
-			   );
+			      );
 	break;
       }
 #endif
@@ -4163,39 +4161,39 @@ static void decode_MBSFNAreaConfiguration( module_id_t ue_mod_idP, uint8_t eNB_i
   LOG_I(RRC,"[UE %d] Frame %d : Number of MCH(s) in the MBSFN Sync Area %d  is %d\n",
         ue_mod_idP, frameP, mbsfn_sync_area, UE_rrc_inst[ue_mod_idP].mcch_message[eNB_index]->pmch_InfoList_r9.list.count);
   //  store to MAC/PHY necessary parameters for receiving MTCHs
-  rrc_mac_config_req(ue_mod_idP,0,ENB_FLAG_NO,0,eNB_index,
-                     (RadioResourceConfigCommonSIB_t *)NULL,
-                     (struct PhysicalConfigDedicated *)NULL,
+  rrc_mac_config_req_ue(ue_mod_idP,0,eNB_index,
+			(RadioResourceConfigCommonSIB_t *)NULL,
+			(struct PhysicalConfigDedicated *)NULL,
 #ifdef Rel10
-                     (SCellToAddMod_r10_t *)NULL,
-                     //(struct PhysicalConfigDedicatedSCell_r10 *)NULL,
+			(SCellToAddMod_r10_t *)NULL,
+			//(struct PhysicalConfigDedicatedSCell_r10 *)NULL,
 #endif
-                     (MeasObjectToAddMod_t **)NULL,
-                     (MAC_MainConfig_t *)NULL,
-                     0,
-                     (struct LogicalChannelConfig *)NULL,
-                     (MeasGapConfig_t *)NULL,
-                     (TDD_Config_t *)NULL,
-                     (MobilityControlInfo_t *)NULL,
-                     NULL,
-                     NULL,
-                     NULL,
-                     NULL,
-                     NULL,
-                     (MBSFN_SubframeConfigList_t *)NULL
+			(MeasObjectToAddMod_t **)NULL,
+			(MAC_MainConfig_t *)NULL,
+			0,
+			(struct LogicalChannelConfig *)NULL,
+			(MeasGapConfig_t *)NULL,
+			(TDD_Config_t *)NULL,
+			(MobilityControlInfo_t *)NULL,
+			NULL,
+			NULL,
+			NULL,
+			NULL,
+			NULL,
+			(MBSFN_SubframeConfigList_t *)NULL
 #ifdef Rel10
-                     ,
-                     0,
-                     (MBSFN_AreaInfoList_r9_t *)NULL,
-                     &UE_rrc_inst[ue_mod_idP].mcch_message[eNB_index]->pmch_InfoList_r9
+			,
+			0,
+			(MBSFN_AreaInfoList_r9_t *)NULL,
+			&UE_rrc_inst[ue_mod_idP].mcch_message[eNB_index]->pmch_InfoList_r9
 #endif
 #ifdef CBA
-                     ,
-                     0,
-                     0
+			,
+			0,
+			0
 #endif
-                    );
-
+			);
+  
   UE_rrc_inst[ue_mod_idP].Info[eNB_index].MCCHStatus[mbsfn_sync_area] = 1;
 
   PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, ue_mod_idP, ENB_FLAG_NO, UE_rrc_inst[ue_mod_idP].Info[eNB_index].rnti, frameP, 0,eNB_index);
@@ -4713,3 +4711,66 @@ void *rrc_ue_task( void *args_p )
   }
 }
 #endif
+
+
+
+/*------------------------------------------------------------------------------*/
+void
+openair_rrc_top_init_ue(
+			int eMBMS_active,
+			char* uecap_xer,
+			uint8_t cba_group_active,
+			uint8_t HO_active
+)
+//-----------------------------------------------------------------------------
+{
+
+  module_id_t         module_id;
+  OAI_UECapability_t *UECap     = NULL;
+  int                 CC_id;
+
+  /* for no gcc warnings */
+  (void)CC_id;
+
+  LOG_D(RRC, "[OPENAIR][INIT] Init function start: NB_UE_INST=%d, NB_eNB_INST=%d\n", NB_UE_INST, NB_eNB_INST);
+
+  if (NB_UE_INST > 0) {
+    UE_rrc_inst = (UE_RRC_INST*) malloc16(NB_UE_INST*sizeof(UE_RRC_INST));
+    memset (UE_rrc_inst, 0, NB_UE_INST * sizeof(UE_RRC_INST));
+    LOG_D(RRC, "ALLOCATE %d Bytes for UE_RRC_INST @ %p\n", (unsigned int)(NB_UE_INST*sizeof(UE_RRC_INST)), UE_rrc_inst);
+
+    // fill UE capability
+    UECap = fill_ue_capability (uecap_xer);
+
+    for (module_id = 0; module_id < NB_UE_INST; module_id++) {
+      UE_rrc_inst[module_id].UECap = UECap;
+      UE_rrc_inst[module_id].UECapability = UECap->sdu;
+      UE_rrc_inst[module_id].UECapability_size = UECap->sdu_size;
+    }
+
+#ifdef Rel10
+    LOG_I(RRC,"[UE] eMBMS active state is %d \n", eMBMS_active);
+
+    for (module_id=0; module_id<NB_UE_INST; module_id++) {
+      UE_rrc_inst[module_id].MBMS_flag = (uint8_t)eMBMS_active;
+    }
+
+#endif
+  } else {
+    UE_rrc_inst = NULL;
+  }
+
+}
+
+//-----------------------------------------------------------------------------
+void
+rrc_top_cleanup_ue(
+  void
+)
+//-----------------------------------------------------------------------------
+{
+
+  if (NB_UE_INST > 0) free (UE_rrc_inst);
+  
+
+}
diff --git a/openair2/RRC/LITE/rrc_common.c b/openair2/RRC/LITE/rrc_common.c
index b039ecd8de..1046de1a81 100644
--- a/openair2/RRC/LITE/rrc_common.c
+++ b/openair2/RRC/LITE/rrc_common.c
@@ -41,13 +41,14 @@
 #include "pdcp.h"
 #include "UTIL/LOG/vcd_signal_dumper.h"
 #include "rrc_eNB_UE_context.h"
+#include "common/ran_context.h"
 
 #ifdef LOCALIZATION
 #include <sys/time.h>
 #endif
 
 #define DEBUG_RRC 1
-extern eNB_MAC_INST *eNB_mac_inst;
+extern RAN_CONTEXT_t RC;
 extern UE_MAC_INST *UE_mac_inst;
 
 extern mui_t rrc_eNB_mui;
@@ -67,10 +68,10 @@ openair_rrc_on(
     LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" OPENAIR RRC IN....\n",
           PROTOCOL_RRC_CTXT_ARGS(ctxt_pP));
     for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
-      rrc_config_buffer (&eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].SI, BCCH, 1);
-      eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].SI.Active = 1;
-      rrc_config_buffer (&eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].Srb0, CCCH, 1);
-      eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].Srb0.Active = 1;
+      rrc_config_buffer (&RC.rrc[ctxt_pP->module_id]->carrier[CC_id].SI, BCCH, 1);
+      RC.rrc[ctxt_pP->module_id]->carrier[CC_id].SI.Active = 1;
+      rrc_config_buffer (&RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0, CCCH, 1);
+      RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Active = 1;
     }
   } else {
     LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" OPENAIR RRC IN....\n",
@@ -231,130 +232,7 @@ rrc_config_buffer(
   Srb_info->Tx_buffer.payload_size = 0;
 }
 
-/*------------------------------------------------------------------------------*/
-void
-openair_rrc_top_init(
-  int eMBMS_active,
-  char* uecap_xer,
-  uint8_t cba_group_active,
-  uint8_t HO_active
-)
-//-----------------------------------------------------------------------------
-{
-
-  module_id_t         module_id;
-  OAI_UECapability_t *UECap     = NULL;
-  int                 CC_id;
-
-  /* for no gcc warnings */
-  (void)CC_id;
-
-  LOG_D(RRC, "[OPENAIR][INIT] Init function start: NB_UE_INST=%d, NB_eNB_INST=%d\n", NB_UE_INST, NB_eNB_INST);
-
-  if (NB_UE_INST > 0) {
-    UE_rrc_inst = (UE_RRC_INST*) malloc16(NB_UE_INST*sizeof(UE_RRC_INST));
-    memset (UE_rrc_inst, 0, NB_UE_INST * sizeof(UE_RRC_INST));
-    LOG_D(RRC, "ALLOCATE %d Bytes for UE_RRC_INST @ %p\n", (unsigned int)(NB_UE_INST*sizeof(UE_RRC_INST)), UE_rrc_inst);
-
-    // fill UE capability
-    UECap = fill_ue_capability (uecap_xer);
-
-    for (module_id = 0; module_id < NB_UE_INST; module_id++) {
-      UE_rrc_inst[module_id].UECap = UECap;
-      UE_rrc_inst[module_id].UECapability = UECap->sdu;
-      UE_rrc_inst[module_id].UECapability_size = UECap->sdu_size;
-    }
-
-#ifdef Rel10
-    LOG_I(RRC,"[UE] eMBMS active state is %d \n", eMBMS_active);
-
-    for (module_id=0; module_id<NB_UE_INST; module_id++) {
-      UE_rrc_inst[module_id].MBMS_flag = (uint8_t)eMBMS_active;
-    }
 
-#endif
-  } else {
-    UE_rrc_inst = NULL;
-  }
-
-  if (NB_eNB_INST > 0) {
-    eNB_rrc_inst = (eNB_RRC_INST*) malloc16(NB_eNB_INST*sizeof(eNB_RRC_INST));
-    memset (eNB_rrc_inst, 0, NB_eNB_INST * sizeof(eNB_RRC_INST));
-    LOG_I(RRC,"[eNB] handover active state is %d \n", HO_active);
-
-    for (module_id=0; module_id<NB_eNB_INST; module_id++) {
-      eNB_rrc_inst[module_id].HO_flag   = (uint8_t)HO_active;
-    }
-
-#ifdef Rel10
-    LOG_I(RRC,"[eNB] eMBMS active state is %d \n", eMBMS_active);
-
-    for (module_id=0; module_id<NB_eNB_INST; module_id++) {
-      for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
-        eNB_rrc_inst[module_id].carrier[CC_id].MBMS_flag = (uint8_t)eMBMS_active;
-      }
-    }
-
-#endif
-#ifdef CBA
-
-    for (module_id=0; module_id<NB_eNB_INST; module_id++) {
-      for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
-        eNB_rrc_inst[module_id].carrier[CC_id].num_active_cba_groups = cba_group_active;
-      }
-    }
-
-#endif
-#ifdef LOCALIZATION
-    /* later set this from xml or enb.config file*/
-    struct timeval ts; // time struct
-    gettimeofday(&ts, NULL); // get the current epoch timestamp
-
-    for (module_id=0; module_id<NB_eNB_INST; module_id++) {
-      eNB_rrc_inst[module_id].reference_timestamp_ms = ts.tv_sec * 1000 + ts.tv_usec / 1000;
-      initialize(&eNB_rrc_inst[module_id].loc_list);
-      eNB_rrc_inst[module_id].loc_type=0;
-      eNB_rrc_inst[module_id].aggregation_period_ms = 5000;
-    }
-
-#endif
-    LOG_D(RRC,
-          "ALLOCATE %d Bytes for eNB_RRC_INST @ %p\n", (unsigned int)(NB_eNB_INST*sizeof(eNB_RRC_INST)), eNB_rrc_inst);
-  } else {
-    eNB_rrc_inst = NULL;
-  }
-
-#ifndef NO_RRM
-#ifndef USER_MODE
-
-  Header_buf=(char*)malloc16(sizeof(msg_head_t));
-  Data=(char*)malloc16(2400);
-  Header_read_idx=0;
-  Data_read_idx=0;
-  Header_size=sizeof(msg_head_t);
-
-#endif //NO_RRM
-  Data_to_read = 0;
-#endif //USER_MODE
-}
-
-//-----------------------------------------------------------------------------
-void
-rrc_top_cleanup(
-  void
-)
-//-----------------------------------------------------------------------------
-{
-
-  if (NB_UE_INST > 0) {
-    free (UE_rrc_inst);
-  }
-
-  if (NB_eNB_INST > 0) {
-    free (eNB_rrc_inst);
-
-  }
-}
 
 
 //-----------------------------------------------------------------------------
@@ -517,7 +395,7 @@ rrc_rx_tx(
     // counetr, and get the value and aggregate
 
     // check for UL failure
-    RB_FOREACH(ue_context_p, rrc_ue_tree_s, &(eNB_rrc_inst[ctxt_pP->module_id].rrc_ue_head)) {
+    RB_FOREACH(ue_context_p, rrc_ue_tree_s, &(RC.rrc[ctxt_pP->module_id]->rrc_ue_head)) {
       if ((ctxt_pP->frame == 0) && (ctxt_pP->subframe==0)) {
 	if (ue_context_p->ue_context.Initialue_identity_s_TMSI.presence == TRUE) {
 	  LOG_I(RRC,"UE rnti %x:S-TMSI %x failure timer %d/20000\n",
@@ -558,16 +436,16 @@ rrc_rx_tx(
     /* for the localization, only primary CC_id might be relevant*/
     gettimeofday(&ts, NULL);
     current_timestamp_ms = ts.tv_sec * 1000 + ts.tv_usec / 1000;
-    ref_timestamp_ms = eNB_rrc_inst[ctxt_pP->module_id].reference_timestamp_ms;
-    RB_FOREACH(ue_context_p, rrc_ue_tree_s, &(eNB_rrc_inst[ctxt_pP->module_id].rrc_ue_head)) {
+    ref_timestamp_ms = RC.rrc[ctxt_pP->module_id]->reference_timestamp_ms;
+    RB_FOREACH(ue_context_p, rrc_ue_tree_s, &(RC.rrc[ctxt_pP->module_id]->rrc_ue_head)) {
       ctxt = *ctxt_pP;
       ctxt.rnti = ue_context_p->ue_context.rnti;
       estimated_distance = rrc_get_estimated_ue_distance(
                              &ctxt,
                              CC_id,
-                             eNB_rrc_inst[ctxt_pP->module_id].loc_type);
+                             RC.rrc[ctxt_pP->module_id]->loc_type);
 
-      if ((current_timestamp_ms - ref_timestamp_ms > eNB_rrc_inst[ctxt_pP->module_id].aggregation_period_ms) &&
+      if ((current_timestamp_ms - ref_timestamp_ms > RC.rrc[ctxt_pP->module_id]->aggregation_period_ms) &&
           estimated_distance != -1) {
         LOG_D(LOCALIZE, " RRC [UE/id %d -> eNB/id %d] timestamp %d frame %d estimated r = %f\n",
               ctxt.rnti,
@@ -576,9 +454,9 @@ rrc_rx_tx(
               ctxt_pP->frame,
               estimated_distance);
         LOG_D(LOCALIZE, " RRC status %d\n", ue_context_p->ue_context.Status);
-        push_front(&eNB_rrc_inst[ctxt_pP->module_id].loc_list,
+        push_front(&RC.rrc[ctxt_pP->module_id]->loc_list,
                    estimated_distance);
-        eNB_rrc_inst[ctxt_pP->module_id].reference_timestamp_ms = current_timestamp_ms;
+        RC.rrc[ctxt_pP->module_id]->reference_timestamp_ms = current_timestamp_ms;
       }
     }
 
diff --git a/openair2/RRC/LITE/rrc_eNB.c b/openair2/RRC/LITE/rrc_eNB.c
index 8b5b012ff1..5ff86de40a 100644
--- a/openair2/RRC/LITE/rrc_eNB.c
+++ b/openair2/RRC/LITE/rrc_eNB.c
@@ -33,6 +33,7 @@
 #include "defs.h"
 #include "extern.h"
 #include "assertions.h"
+#include "common/ran_context.h"
 #include "asn1_conversions.h"
 #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h"
 #include "LAYER2/RLC/rlc.h"
@@ -43,6 +44,7 @@
 #include "RRCConnectionRequest.h"
 #include "RRCConnectionReestablishmentRequest.h"
 //#include "ReestablishmentCause.h"
+#include "BCCH-BCH-Message.h"
 #include "UL-CCCH-Message.h"
 #include "DL-CCCH-Message.h"
 #include "UL-DCCH-Message.h"
@@ -98,6 +100,8 @@
 #endif
 //#define XER_PRINT
 
+extern RAN_CONTEXT_t RC;
+
 #ifdef PHY_EMUL
 extern EMULATION_VARS              *Emul_vars;
 #endif
@@ -128,54 +132,28 @@ init_SI(
 #ifdef Rel10
   int                                 i;
 #endif
-  /*
-     uint32_t mib=0;
-     int i;
-     int N_RB_DL,phich_resource;
-
-     do_MIB(enb_mod_idP, mac_xface->lte_frame_parms,0x321,&mib);
-
-     for (i=0;i<1024;i+=4)
-     do_MIB(enb_mod_idP, mac_xface->lte_frame_parms,i,&mib);
-
-     N_RB_DL=6;
-     while (N_RB_DL != 0) {
-     phich_resource = 1;
-     while (phich_resource != 0) {
-     for (i=0;i<2;i++) {
-     mac_xface->lte_frame_parms->N_RB_DL = N_RB_DL;
-     mac_xface->lte_frame_parms->phich_config_common.phich_duration=i;
-     mac_xface->lte_frame_parms->phich_config_common.phich_resource = phich_resource;
-     do_MIB(enb_mod_idP, mac_xface->lte_frame_parms,0,&mib);
-     }
-     if (phich_resource == 1)
-     phich_resource = 3;
-     else if (phich_resource == 3)
-     phich_resource = 6;
-     else if (phich_resource == 6)
-     phich_resource = 12;
-     else if (phich_resource == 12)
-     phich_resource = 0;
-     }
-     if (N_RB_DL == 6)
-     N_RB_DL = 15;
-     else if (N_RB_DL == 15)
-     N_RB_DL = 25;
-     else if (N_RB_DL == 25)
-     N_RB_DL = 50;
-     else if (N_RB_DL == 50)
-     N_RB_DL = 75;
-     else if (N_RB_DL == 75)
-     N_RB_DL = 100;
-     else if (N_RB_DL == 100)
-     N_RB_DL = 0;
-     }
-     exit(-1);
-   */
+  
 
-  eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].sizeof_SIB1 = 0;
-  eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].sizeof_SIB23 = 0;
-  eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].SIB1 = (uint8_t*) malloc16(32);
+  // copy basic parameters
+  RC.rrc[ctxt_pP->module_id]->carrier[CC_id].physCellId      = configuration->Nid_cell[CC_id];
+  RC.rrc[ctxt_pP->module_id]->carrier[CC_id].p_eNB           = configuration->nb_antenna_ports[CC_id];
+  RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Ncp             = configuration->prefix_type[CC_id];
+  RC.rrc[ctxt_pP->module_id]->carrier[CC_id].dl_CarrierFreq  = configuration->downlink_frequency[CC_id];
+  RC.rrc[ctxt_pP->module_id]->carrier[CC_id].ul_CarrierFreq  = configuration->downlink_frequency[CC_id]+ configuration->uplink_frequency_offset[CC_id];
+  do_MIB(&RC.rrc[ctxt_pP->module_id]->carrier[CC_id],
+#ifdef ENABLE_ITTI
+	 configuration->N_RB_DL[CC_id],
+	 configuration->phich_resource[CC_id],
+	 configuration->phich_duration[CC_id]
+#else
+	 50,0,0
+#endif
+	 ,0);
+  
+
+  RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sizeof_SIB1 = 0;
+  RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sizeof_SIB23 = 0;
+  RC.rrc[ctxt_pP->module_id]->carrier[CC_id].SIB1 = (uint8_t*) malloc16(32);
 
   /*
      printf ("before SIB1 init : Nid_cell %d\n", mac_xface->lte_frame_parms->Nid_cell);
@@ -184,14 +162,8 @@ init_SI(
      mac_xface->lte_frame_parms->tdd_config);
    */
 
-  if (eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].SIB1)
-    eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].sizeof_SIB1 = do_SIB1(
-          ctxt_pP->module_id,
-          CC_id,
-          mac_xface->frame_parms,
-          (uint8_t*)eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].SIB1,
-          &eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].siblock1,
-          &eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].sib1
+  if (RC.rrc[ctxt_pP->module_id]->carrier[CC_id].SIB1)
+    RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sizeof_SIB1 = do_SIB1(&RC.rrc[ctxt_pP->module_id]->carrier[CC_id],ctxt_pP->module_id,CC_id
 #if defined(ENABLE_ITTI)
           , configuration
 #endif
@@ -208,112 +180,93 @@ init_SI(
      mac_xface->lte_frame_parms->frame_type,
      mac_xface->lte_frame_parms->tdd_config);
    */
-  if (eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].sizeof_SIB1 == 255) {
-    mac_xface->macphy_exit("[RRC][init_SI] FATAL, eNB_rrc_inst[enb_mod_idP].carrier[CC_id].sizeof_SIB1 == 255");
+  if (RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sizeof_SIB1 == 255) {
+    mac_xface->macphy_exit("[RRC][init_SI] FATAL, RC.rrc[enb_mod_idP].carrier[CC_id].sizeof_SIB1 == 255");
   }
 
-  eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].SIB23 = (uint8_t*) malloc16(64);
+  RC.rrc[ctxt_pP->module_id]->carrier[CC_id].SIB23 = (uint8_t*) malloc16(64);
 
-  if (eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].SIB23) {
-    eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].sizeof_SIB23 = do_SIB23(
+  if (RC.rrc[ctxt_pP->module_id]->carrier[CC_id].SIB23) {
+    RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sizeof_SIB23 = do_SIB23(
           ctxt_pP->module_id,
-          CC_id,
-          mac_xface->frame_parms,
-          eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].SIB23,
-          &eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].systemInformation,
-          &eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].sib2,
-          &eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].sib3
-#ifdef Rel10
-          , &eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].sib13,
-          eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].MBMS_flag
-#endif
+          CC_id
 #if defined(ENABLE_ITTI)
           , configuration
 #endif
         );
 
-    /*
-       eNB_rrc_inst[ctxt_pP->module_id].sizeof_SIB23 = do_SIB2_AT4(ctxt_pP->module_id,
-       eNB_rrc_inst[ctxt_pP->module_id].SIB23,
-       &eNB_rrc_inst[ctxt_pP->module_id].systemInformation,
-       &eNB_rrc_inst[ctxt_pP->module_id].sib2,
-       #if defined(ENABLE_ITTI)
-       , configuration
-       #endif
-       );
-     */
-    if (eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].sizeof_SIB23 == 255) {
-      mac_xface->macphy_exit("[RRC][init_SI] FATAL, eNB_rrc_inst[mod].carrier[CC_id].sizeof_SIB23 == 255");
+    if (RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sizeof_SIB23 == 255) {
+      mac_xface->macphy_exit("[RRC][init_SI] FATAL, RC.rrc[mod].carrier[CC_id].sizeof_SIB23 == 255");
     }
 
     LOG_T(RRC, PROTOCOL_RRC_CTXT_FMT" SIB2/3 Contents (partial)\n",
           PROTOCOL_RRC_CTXT_ARGS(ctxt_pP));
     LOG_T(RRC, PROTOCOL_RRC_CTXT_FMT" pusch_config_common.n_SB = %ld\n",
           PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
-          eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon.
+          RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon.
           pusch_ConfigBasic.n_SB);
     LOG_T(RRC, PROTOCOL_RRC_CTXT_FMT" pusch_config_common.hoppingMode = %ld\n",
           PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
-          eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon.
+          RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon.
           pusch_ConfigBasic.hoppingMode);
     LOG_T(RRC, PROTOCOL_RRC_CTXT_FMT" pusch_config_common.pusch_HoppingOffset = %ld\n",
           PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
-          eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon.
+          RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon.
           pusch_ConfigBasic.pusch_HoppingOffset);
     LOG_T(RRC, PROTOCOL_RRC_CTXT_FMT" pusch_config_common.enable64QAM = %d\n",
           PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
-          (int)eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon.
+          (int)RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon.
           pusch_ConfigBasic.enable64QAM);
     LOG_T(RRC, PROTOCOL_RRC_CTXT_FMT" pusch_config_common.groupHoppingEnabled = %d\n",
           PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
-          (int)eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon.
+          (int)RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon.
           ul_ReferenceSignalsPUSCH.groupHoppingEnabled);
     LOG_T(RRC, PROTOCOL_RRC_CTXT_FMT" pusch_config_common.groupAssignmentPUSCH = %ld\n",
           PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
-          eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon.
+          RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon.
           ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH);
     LOG_T(RRC, PROTOCOL_RRC_CTXT_FMT" pusch_config_common.sequenceHoppingEnabled = %d\n",
           PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
-          (int)eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon.
+          (int)RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon.
           ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled);
     LOG_T(RRC, PROTOCOL_RRC_CTXT_FMT" pusch_config_common.cyclicShift  = %ld\n",
           PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
-          eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon.
+          RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon.
           ul_ReferenceSignalsPUSCH.cyclicShift);
 
 #ifdef Rel10
 
-    if (eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].MBMS_flag > 0) {
-      for (i = 0; i < eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].sib2->mbsfn_SubframeConfigList->list.count; i++) {
+    if (RC.rrc[ctxt_pP->module_id]->carrier[CC_id].MBMS_flag > 0) {
+      for (i = 0; i < RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->mbsfn_SubframeConfigList->list.count; i++) {
         // SIB 2
-        //   LOG_D(RRC, "[eNB %d] mbsfn_SubframeConfigList.list.count = %ld\n", enb_mod_idP, eNB_rrc_inst[enb_mod_idP].sib2->mbsfn_SubframeConfigList->list.count);
+        //   LOG_D(RRC, "[eNB %d] mbsfn_SubframeConfigList.list.count = %ld\n", enb_mod_idP, RC.rrc[enb_mod_idP].sib2->mbsfn_SubframeConfigList->list.count);
         LOG_D(RRC, PROTOCOL_RRC_CTXT_FMT" SIB13 contents for MBSFN subframe allocation %d/%d(partial)\n",
               PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
               i,
-              eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].sib2->mbsfn_SubframeConfigList->list.count);
+              RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->mbsfn_SubframeConfigList->list.count);
         LOG_D(RRC, PROTOCOL_RRC_CTXT_FMT" mbsfn_Subframe_pattern is  = %x\n",
               PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
-              eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].sib2->mbsfn_SubframeConfigList->list.array[i]->subframeAllocation.choice.oneFrame.buf[0] >> 0);
+              RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->mbsfn_SubframeConfigList->list.array[i]->subframeAllocation.choice.oneFrame.buf[0] >> 0);
         LOG_D(RRC, PROTOCOL_RRC_CTXT_FMT" radioframe_allocation_period  = %ld (just index number, not the real value)\n",
               PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
-              eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].sib2->mbsfn_SubframeConfigList->list.array[i]->radioframeAllocationPeriod);   // need to display the real value, using array of char (like in dumping SIB2)
+              RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->mbsfn_SubframeConfigList->list.array[i]->radioframeAllocationPeriod);   // need to display the real value, using array of char (like in dumping SIB2)
         LOG_D(RRC, PROTOCOL_RRC_CTXT_FMT" radioframe_allocation_offset  = %ld\n",
               PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
-              eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].sib2->mbsfn_SubframeConfigList->list.array[i]->radioframeAllocationOffset);
+              RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->mbsfn_SubframeConfigList->list.array[i]->radioframeAllocationOffset);
       }
 
       //   SIB13
-      for (i = 0; i < eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].sib13->mbsfn_AreaInfoList_r9.list.count; i++) {
+      for (i = 0; i < RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13->mbsfn_AreaInfoList_r9.list.count; i++) {
         LOG_D(RRC, PROTOCOL_RRC_CTXT_FMT" SIB13 contents for MBSFN sync area %d/%d (partial)\n",
               PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
               i,
-              eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].sib13->mbsfn_AreaInfoList_r9.list.count);
+              RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13->mbsfn_AreaInfoList_r9.list.count);
         LOG_D(RRC, PROTOCOL_RRC_CTXT_FMT" MCCH Repetition Period: %ld (just index number, not real value)\n",
               PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
-              eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].sib13->mbsfn_AreaInfoList_r9.list.array[i]->mcch_Config_r9.mcch_RepetitionPeriod_r9);
+              RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13->mbsfn_AreaInfoList_r9.list.array[i]->mcch_Config_r9.mcch_RepetitionPeriod_r9);
         LOG_D(RRC, PROTOCOL_RRC_CTXT_FMT" MCCH Offset: %ld\n",
               PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
-              eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].sib13->mbsfn_AreaInfoList_r9.list.array[i]->mcch_Config_r9.mcch_Offset_r9);
+              RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13->mbsfn_AreaInfoList_r9.list.array[i]->mcch_Config_r9.mcch_Offset_r9);
       }
     }
 
@@ -322,36 +275,43 @@ init_SI(
     LOG_D(RRC,
           PROTOCOL_RRC_CTXT_FMT" RRC_UE --- MAC_CONFIG_REQ (SIB1.tdd & SIB2 params) ---> MAC_UE\n",
           PROTOCOL_RRC_CTXT_ARGS(ctxt_pP));
-    rrc_mac_config_req(ctxt_pP->module_id, CC_id, ENB_FLAG_YES, 0, 0,
-                       (RadioResourceConfigCommonSIB_t *) &
-                       eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].sib2->radioResourceConfigCommon,
-                       (struct PhysicalConfigDedicated *)NULL,
+    rrc_mac_config_req_eNB(ctxt_pP->module_id, CC_id,
+			   RC.rrc[ctxt_pP->module_id]->carrier[CC_id].physCellId,
+			   RC.rrc[ctxt_pP->module_id]->carrier[CC_id].p_eNB,
+			   RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Ncp,
+			   RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1->freqBandIndicator,
+			   RC.rrc[ctxt_pP->module_id]->carrier[CC_id].dl_CarrierFreq,
+			   (BCCH_BCH_Message_t *)
+			   &RC.rrc[ctxt_pP->module_id]->carrier[CC_id].mib,
+			   (RadioResourceConfigCommonSIB_t *) &
+			   RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon,
+			   (struct PhysicalConfigDedicated *)NULL,
 #ifdef Rel10
-                       (SCellToAddMod_r10_t *)NULL,
-                       //(struct PhysicalConfigDedicatedSCell_r10 *)NULL,
+			   (SCellToAddMod_r10_t *)NULL,
+			   //(struct PhysicalConfigDedicatedSCell_r10 *)NULL,
 #endif
-                       (MeasObjectToAddMod_t **) NULL,
-                       (MAC_MainConfig_t *) NULL, 0,
-                       (struct LogicalChannelConfig *)NULL,
-                       (MeasGapConfig_t *) NULL,
-                       eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].sib1->tdd_Config,
-                       NULL,
-                       &SIwindowsize, &SIperiod,
-                       eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].sib2->freqInfo.ul_CarrierFreq,
-                       eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].sib2->freqInfo.ul_Bandwidth,
-                       &eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].sib2->freqInfo.additionalSpectrumEmission,
-                       (MBSFN_SubframeConfigList_t*) eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].sib2->mbsfn_SubframeConfigList
+			   (MeasObjectToAddMod_t **) NULL,
+			   (MAC_MainConfig_t *) NULL, 0,
+			   (struct LogicalChannelConfig *)NULL,
+			   (MeasGapConfig_t *) NULL,
+			   RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1->tdd_Config,
+			   NULL,
+			   &SIwindowsize, &SIperiod,
+			   RC.rrc[ctxt_pP->module_id]->carrier[CC_id].ul_CarrierFreq,
+			   RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->freqInfo.ul_Bandwidth,
+			   &RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->freqInfo.additionalSpectrumEmission,
+			   (MBSFN_SubframeConfigList_t*) RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->mbsfn_SubframeConfigList
 #ifdef Rel10
-                       ,
-                       eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].MBMS_flag,
-                       (MBSFN_AreaInfoList_r9_t*) & eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].sib13->mbsfn_AreaInfoList_r9,
-                       (PMCH_InfoList_r9_t *) NULL
+			   ,
+			   RC.rrc[ctxt_pP->module_id]->carrier[CC_id].MBMS_flag,
+			   (MBSFN_AreaInfoList_r9_t*) & RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13->mbsfn_AreaInfoList_r9,
+			   (PMCH_InfoList_r9_t *) NULL
 #endif
 #ifdef CBA
-                       , 0, //eNB_rrc_inst[ctxt_pP->module_id].num_active_cba_groups,
-                       0    //eNB_rrc_inst[ctxt_pP->module_id].cba_rnti[0]
+			   , 0, //RC.rrc[ctxt_pP->module_id]->num_active_cba_groups,
+			   0    //RC.rrc[ctxt_pP->module_id]->cba_rnti[0]
 #endif
-                      );
+			   );
   } else {
     LOG_E(RRC, PROTOCOL_RRC_CTXT_FMT" init_SI: FATAL, no memory for SIB2/3 allocated\n",
           PROTOCOL_RRC_CTXT_ARGS(ctxt_pP));
@@ -371,80 +331,81 @@ init_MCCH(
 
   int                                 sync_area = 0;
   // initialize RRC_eNB_INST MCCH entry
-  eNB_rrc_inst[enb_mod_idP].carrier[CC_id].MCCH_MESSAGE =
-    malloc(eNB_rrc_inst[enb_mod_idP].carrier[CC_id].num_mbsfn_sync_area * sizeof(uint8_t*));
+  RC.rrc[enb_mod_idP]->carrier[CC_id].MCCH_MESSAGE =
+    malloc(RC.rrc[enb_mod_idP]->carrier[CC_id].num_mbsfn_sync_area * sizeof(uint8_t*));
 
-  for (sync_area = 0; sync_area < eNB_rrc_inst[enb_mod_idP].carrier[CC_id].num_mbsfn_sync_area; sync_area++) {
+  for (sync_area = 0; sync_area < RC.rrc[enb_mod_idP]->carrier[CC_id].num_mbsfn_sync_area; sync_area++) {
 
-    eNB_rrc_inst[enb_mod_idP].carrier[CC_id].sizeof_MCCH_MESSAGE[sync_area] = 0;
-    eNB_rrc_inst[enb_mod_idP].carrier[CC_id].MCCH_MESSAGE[sync_area] = (uint8_t *) malloc16(32);
+    RC.rrc[enb_mod_idP]->carrier[CC_id].sizeof_MCCH_MESSAGE[sync_area] = 0;
+    RC.rrc[enb_mod_idP]->carrier[CC_id].MCCH_MESSAGE[sync_area] = (uint8_t *) malloc16(32);
 
-    if (eNB_rrc_inst[enb_mod_idP].carrier[CC_id].MCCH_MESSAGE[sync_area] == NULL) {
+    if (RC.rrc[enb_mod_idP]->carrier[CC_id].MCCH_MESSAGE[sync_area] == NULL) {
       LOG_E(RRC, "[eNB %d][MAIN] init_MCCH: FATAL, no memory for MCCH MESSAGE allocated \n", enb_mod_idP);
       mac_xface->macphy_exit("[RRC][init_MCCH] not enough memory\n");
     } else {
-      eNB_rrc_inst[enb_mod_idP].carrier[CC_id].sizeof_MCCH_MESSAGE[sync_area] = do_MBSFNAreaConfig(enb_mod_idP,
+      RC.rrc[enb_mod_idP]->carrier[CC_id].sizeof_MCCH_MESSAGE[sync_area] = do_MBSFNAreaConfig(enb_mod_idP,
           mac_xface->frame_parms,
           sync_area,
-          (uint8_t *)eNB_rrc_inst[enb_mod_idP].carrier[CC_id].MCCH_MESSAGE[sync_area],
-          &eNB_rrc_inst[enb_mod_idP].carrier[CC_id].mcch,
-          &eNB_rrc_inst[enb_mod_idP].carrier[CC_id].mcch_message);
+          (uint8_t *)RC.rrc[enb_mod_idP]->carrier[CC_id].MCCH_MESSAGE[sync_area],
+          &RC.rrc[enb_mod_idP]->carrier[CC_id].mcch,
+          &RC.rrc[enb_mod_idP]->carrier[CC_id].mcch_message);
 
       LOG_I(RRC, "mcch message pointer %p for sync area %d \n",
-            eNB_rrc_inst[enb_mod_idP].carrier[CC_id].MCCH_MESSAGE[sync_area],
+            RC.rrc[enb_mod_idP]->carrier[CC_id].MCCH_MESSAGE[sync_area],
             sync_area);
       LOG_D(RRC, "[eNB %d] MCCH_MESSAGE  contents for Sync Area %d (partial)\n", enb_mod_idP, sync_area);
       LOG_D(RRC, "[eNB %d] CommonSF_AllocPeriod_r9 %ld\n", enb_mod_idP,
-            eNB_rrc_inst[enb_mod_idP].carrier[CC_id].mcch_message->commonSF_AllocPeriod_r9);
+            RC.rrc[enb_mod_idP]->carrier[CC_id].mcch_message->commonSF_AllocPeriod_r9);
       LOG_D(RRC,
             "[eNB %d] CommonSF_Alloc_r9.list.count (number of MBSFN Subframe Pattern) %d\n",
-            enb_mod_idP, eNB_rrc_inst[enb_mod_idP].carrier[CC_id].mcch_message->commonSF_Alloc_r9.list.count);
+            enb_mod_idP, RC.rrc[enb_mod_idP]->carrier[CC_id].mcch_message->commonSF_Alloc_r9.list.count);
       LOG_D(RRC, "[eNB %d] MBSFN Subframe Pattern: %02x (in hex)\n",
             enb_mod_idP,
-            eNB_rrc_inst[enb_mod_idP].carrier[CC_id].mcch_message->commonSF_Alloc_r9.list.array[0]->subframeAllocation.
+            RC.rrc[enb_mod_idP]->carrier[CC_id].mcch_message->commonSF_Alloc_r9.list.array[0]->subframeAllocation.
             choice.oneFrame.buf[0]);
 
-      if (eNB_rrc_inst[enb_mod_idP].carrier[CC_id].sizeof_MCCH_MESSAGE[sync_area] == 255) {
-        mac_xface->macphy_exit("[RRC][init_MCCH] eNB_rrc_inst[enb_mod_idP].carrier[CC_id].sizeof_MCCH_MESSAGE[sync_area] == 255");
+      if (RC.rrc[enb_mod_idP]->carrier[CC_id].sizeof_MCCH_MESSAGE[sync_area] == 255) {
+        mac_xface->macphy_exit("[RRC][init_MCCH] RC.rrc[enb_mod_idP]->carrier[CC_id].sizeof_MCCH_MESSAGE[sync_area] == 255");
       } else {
-        eNB_rrc_inst[enb_mod_idP].carrier[CC_id].MCCH_MESS[sync_area].Active = 1;
+        RC.rrc[enb_mod_idP]->carrier[CC_id].MCCH_MESS[sync_area].Active = 1;
       }
     }
   }
 
-  //Set the eNB_rrc_inst[enb_mod_idP].MCCH_MESS.Active to 1 (allow to  transfer MCCH message RRC->MAC in function mac_rrc_data_req)
+  //Set the RC.rrc[enb_mod_idP]->MCCH_MESS.Active to 1 (allow to  transfer MCCH message RRC->MAC in function mac_rrc_data_req)
 
   // ??Configure MCCH logical channel
   // call mac_config_req with appropriate structure from ASN.1 description
 
-  //  LOG_I(RRC, "DUY: serviceID is %d\n",eNB_rrc_inst[enb_mod_idP].mcch_message->pmch_InfoList_r9.list.array[0]->mbms_SessionInfoList_r9.list.array[0]->tmgi_r9.serviceId_r9.buf[2]);
-  //  LOG_I(RRC, "DUY: session ID is %d\n",eNB_rrc_inst[enb_mod_idP].mcch_message->pmch_InfoList_r9.list.array[0]->mbms_SessionInfoList_r9.list.array[0]->sessionId_r9->buf[0]);
-  rrc_mac_config_req(enb_mod_idP, CC_id, ENB_FLAG_YES, 0, 0,
-                     (RadioResourceConfigCommonSIB_t *) NULL,
-                     (struct PhysicalConfigDedicated *)NULL,
+  //  LOG_I(RRC, "DUY: serviceID is %d\n",RC.rrc[enb_mod_idP]->mcch_message->pmch_InfoList_r9.list.array[0]->mbms_SessionInfoList_r9.list.array[0]->tmgi_r9.serviceId_r9.buf[2]);
+  //  LOG_I(RRC, "DUY: session ID is %d\n",RC.rrc[enb_mod_idP]->mcch_message->pmch_InfoList_r9.list.array[0]->mbms_SessionInfoList_r9.list.array[0]->sessionId_r9->buf[0]);
+  rrc_mac_config_req_eNB(enb_mod_idP, CC_id,
+			 0,0,0,0,0,(BCCH_BCH_Message_t *)NULL,
+			 (RadioResourceConfigCommonSIB_t *) NULL,
+			 (struct PhysicalConfigDedicated *)NULL,
 #ifdef Rel10
-                     (SCellToAddMod_r10_t *)NULL,
-                     //(struct PhysicalConfigDedicatedSCell_r10 *)NULL,
+			 (SCellToAddMod_r10_t *)NULL,
+			 //(struct PhysicalConfigDedicatedSCell_r10 *)NULL,
 #endif
-                     (MeasObjectToAddMod_t **) NULL,
-                     (MAC_MainConfig_t *) NULL,
-                     0,
-                     (struct LogicalChannelConfig *)NULL,
-                     (MeasGapConfig_t *) NULL,
-                     (TDD_Config_t *) NULL,
-                     NULL, (uint8_t *) NULL, (uint16_t *) NULL, NULL, NULL, NULL, (MBSFN_SubframeConfigList_t *) NULL
+			 (MeasObjectToAddMod_t **) NULL,
+			 (MAC_MainConfig_t *) NULL,
+			 0,
+			 (struct LogicalChannelConfig *)NULL,
+			 (MeasGapConfig_t *) NULL,
+			 (TDD_Config_t *) NULL,
+			 NULL, (uint8_t *) NULL, (uint16_t *) NULL, 0, NULL, NULL, (MBSFN_SubframeConfigList_t *) NULL
 #   ifdef Rel10
-                     ,
-                     0,
-                     (MBSFN_AreaInfoList_r9_t *) NULL,
-                     (PMCH_InfoList_r9_t *) & (eNB_rrc_inst[enb_mod_idP].carrier[CC_id].mcch_message->pmch_InfoList_r9)
+			 ,
+			 0,
+			 (MBSFN_AreaInfoList_r9_t *) NULL,
+			 (PMCH_InfoList_r9_t *) & (RC.rrc[enb_mod_idP]->carrier[CC_id].mcch_message->pmch_InfoList_r9)
 #   endif
 #   ifdef CBA
-                     , 0, 0
+			 , 0, 0
 #   endif
-                    );
-
-  //LOG_I(RRC,"DUY: lcid after rrc_mac_config_req is %02d\n",eNB_rrc_inst[enb_mod_idP].mcch_message->pmch_InfoList_r9.list.array[0]->mbms_SessionInfoList_r9.list.array[0]->logicalChannelIdentity_r9);
+			 );
+  
+  //LOG_I(RRC,"DUY: lcid after rrc_mac_config_req is %02d\n",RC.rrc[enb_mod_idP]->mcch_message->pmch_InfoList_r9.list.array[0]->mbms_SessionInfoList_r9.list.array[0]->logicalChannelIdentity_r9);
 
 }
 
@@ -459,7 +420,7 @@ static void init_MBMS(
   // init the configuration for MTCH
   protocol_ctxt_t               ctxt;
 
-  if (eNB_rrc_inst[enb_mod_idP].carrier[CC_id].MBMS_flag > 0) {
+  if (RC.rrc[enb_mod_idP]->carrier[CC_id].MBMS_flag > 0) {
     PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, enb_mod_idP, ENB_FLAG_YES, NOT_A_RNTI, frameP, 0,enb_mod_idP);
 
     LOG_D(RRC, "[eNB %d] Frame %d : Radio Bearer config request for MBMS\n", enb_mod_idP, frameP);   //check the lcid
@@ -474,7 +435,7 @@ static void init_MBMS(
                              NULL,  // key rrc integrity
                              NULL   // key encryption
 #   ifdef Rel10
-                             , &(eNB_rrc_inst[enb_mod_idP].carrier[CC_id].mcch_message->pmch_InfoList_r9)
+                             , &(RC.rrc[enb_mod_idP]->carrier[CC_id].mcch_message->pmch_InfoList_r9)
 #   endif
                              ,NULL);
 
@@ -482,7 +443,7 @@ static void init_MBMS(
                             NULL, // SRB_ToAddModList
                             NULL,   // DRB_ToAddModList
                             NULL,   // DRB_ToReleaseList
-                            &(eNB_rrc_inst[enb_mod_idP].carrier[CC_id].mcch_message->pmch_InfoList_r9));
+                            &(RC.rrc[enb_mod_idP]->carrier[CC_id].mcch_message->pmch_InfoList_r9));
 
     //rrc_mac_config_req();
   }
@@ -520,7 +481,7 @@ rrc_eNB_get_next_transaction_identifier(
 //    AssertFatal(enb_mod_idP < NB_eNB_INST, "eNB index invalid (%d/%d)!", enb_mod_idP, NB_eNB_INST);
 //
 //    for (i = 0; i < NUMBER_OF_UE_MAX; i++) {
-//        if (eNB_rrc_inst[enb_mod_idP].Info.UE_list[i] == UE_identity) {
+//        if (RC.rrc[enb_mod_idP]->Info.UE_list[i] == UE_identity) {
 //            // UE_identity already registered
 //            reg = TRUE;
 //            break;
@@ -544,7 +505,7 @@ rrc_eNB_ue_context_random_exist(
 //-----------------------------------------------------------------------------
 {
   struct rrc_eNB_ue_context_s*        ue_context_p = NULL;
-  RB_FOREACH(ue_context_p, rrc_ue_tree_s, &(eNB_rrc_inst[ctxt_pP->module_id].rrc_ue_head)) {
+  RB_FOREACH(ue_context_p, rrc_ue_tree_s, &(RC.rrc[ctxt_pP->module_id]->rrc_ue_head)) {
     if (ue_context_p->ue_context.random_ue_identity == ue_identityP)
       return ue_context_p;
   }
@@ -561,7 +522,7 @@ rrc_eNB_ue_context_stmsi_exist(
 //-----------------------------------------------------------------------------
 {
   struct rrc_eNB_ue_context_s*        ue_context_p = NULL;
-  RB_FOREACH(ue_context_p, rrc_ue_tree_s, &(eNB_rrc_inst[ctxt_pP->module_id].rrc_ue_head)) {
+  RB_FOREACH(ue_context_p, rrc_ue_tree_s, &(RC.rrc[ctxt_pP->module_id]->rrc_ue_head)) {
     LOG_I(RRC,"checking for UE S-TMSI %x, mme %x (%p): rnti %x",
 	  m_tmsiP, mme_codeP, ue_context_p, 
 	  ue_context_p->ue_context.rnti);
@@ -591,11 +552,11 @@ rrc_eNB_get_next_free_ue_context(
 {
   struct rrc_eNB_ue_context_s*        ue_context_p = NULL;
   ue_context_p = rrc_eNB_get_ue_context(
-                   &eNB_rrc_inst[ctxt_pP->module_id],
+                   RC.rrc[ctxt_pP->module_id],
                    ctxt_pP->rnti);
 
   if (ue_context_p == NULL) {
-    RB_FOREACH(ue_context_p, rrc_ue_tree_s, &(eNB_rrc_inst[ctxt_pP->module_id].rrc_ue_head)) {
+    RB_FOREACH(ue_context_p, rrc_ue_tree_s, &(RC.rrc[ctxt_pP->module_id]->rrc_ue_head)) {
       if (ue_context_p->ue_context.random_ue_identity == ue_identityP) {
         LOG_D(RRC,
               PROTOCOL_RRC_CTXT_UE_FMT" Cannot create new UE context, already exist rand UE id 0x%"PRIx64", uid %u\n",
@@ -605,7 +566,7 @@ rrc_eNB_get_next_free_ue_context(
         return NULL;
       }
     }
-    ue_context_p = rrc_eNB_allocate_new_UE_context(&eNB_rrc_inst[ctxt_pP->module_id]);
+    ue_context_p = rrc_eNB_allocate_new_UE_context(RC.rrc[ctxt_pP->module_id]);
 
     if (ue_context_p == NULL) {
       LOG_E(RRC,
@@ -617,7 +578,7 @@ rrc_eNB_get_next_free_ue_context(
     ue_context_p->ue_id_rnti                    = ctxt_pP->rnti; // here ue_id_rnti is just a key, may be something else
     ue_context_p->ue_context.rnti               = ctxt_pP->rnti; // yes duplicate, 1 may be removed
     ue_context_p->ue_context.random_ue_identity = ue_identityP;
-    RB_INSERT(rrc_ue_tree_s, &eNB_rrc_inst[ctxt_pP->module_id].rrc_ue_head, ue_context_p);
+    RB_INSERT(rrc_ue_tree_s, &RC.rrc[ctxt_pP->module_id]->rrc_ue_head, ue_context_p);
     LOG_D(RRC,
           PROTOCOL_RRC_CTXT_UE_FMT" Created new UE context uid %u\n",
           PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
@@ -651,15 +612,15 @@ void rrc_eNB_emulation_notify_ue_module_id(
       return;
     }
     for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
-      if (eNB_rrc_inst[enb_module_id].carrier[CC_id].sib1 != NULL) {
+      if (RC.rrc[enb_module_id].carrier[CC_id].sib1 != NULL) {
         if (
-          (eNB_rrc_inst[enb_module_id].carrier[CC_id].sib1->cellAccessRelatedInfo.cellIdentity.buf[0] == cell_identity_byte0P) &&
-          (eNB_rrc_inst[enb_module_id].carrier[CC_id].sib1->cellAccessRelatedInfo.cellIdentity.buf[1] == cell_identity_byte1P) &&
-          (eNB_rrc_inst[enb_module_id].carrier[CC_id].sib1->cellAccessRelatedInfo.cellIdentity.buf[2] == cell_identity_byte2P) &&
-          (eNB_rrc_inst[enb_module_id].carrier[CC_id].sib1->cellAccessRelatedInfo.cellIdentity.buf[3] == cell_identity_byte3P)
+          (RC.rrc[enb_module_id].carrier[CC_id].sib1->cellAccessRelatedInfo.cellIdentity.buf[0] == cell_identity_byte0P) &&
+          (RC.rrc[enb_module_id].carrier[CC_id].sib1->cellAccessRelatedInfo.cellIdentity.buf[1] == cell_identity_byte1P) &&
+          (RC.rrc[enb_module_id].carrier[CC_id].sib1->cellAccessRelatedInfo.cellIdentity.buf[2] == cell_identity_byte2P) &&
+          (RC.rrc[enb_module_id].carrier[CC_id].sib1->cellAccessRelatedInfo.cellIdentity.buf[3] == cell_identity_byte3P)
         ) {
           ue_context_p = rrc_eNB_get_ue_context(
-                           &eNB_rrc_inst[enb_module_id],
+                           RC.rrc[enb_module_id],
                            rntiP
                          );
 
@@ -806,7 +767,7 @@ rrc_eNB_free_UE(const module_id_t enb_mod_idP,const struct rrc_eNB_ue_context_s*
 
   AssertFatal(enb_mod_idP < NB_eNB_INST, "eNB inst invalid (%d/%d) for UE %x!", enb_mod_idP, NB_eNB_INST, rnti);
   /*  ue_context_p = rrc_eNB_get_ue_context(
-                   &eNB_rrc_inst[enb_mod_idP],
+                   &RC.rrc[enb_mod_idP],
                    rntiP
                  );
   */
@@ -838,7 +799,7 @@ rrc_eNB_free_UE(const module_id_t enb_mod_idP,const struct rrc_eNB_ue_context_s*
 
     rrc_eNB_remove_ue_context(
       &ctxt,
-      &eNB_rrc_inst[enb_mod_idP],
+      RC.rrc[enb_mod_idP],
       (struct rrc_eNB_ue_context_s*) ue_context_pP);
   }
 }
@@ -1015,15 +976,15 @@ rrc_eNB_generate_RRCConnectionReject(
   T(T_ENB_RRC_CONNECTION_REJECT, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
     T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
 
-  eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].Srb0.Tx_buffer.payload_size =
+  RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size =
     do_RRCConnectionReject(ctxt_pP->module_id,
-                          (uint8_t*) eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].Srb0.Tx_buffer.Payload);
+                          (uint8_t*) RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.Payload);
 
 #ifdef RRC_MSG_PRINT
   LOG_F(RRC,"[MSG] RRCConnectionReject\n");
 
-  for (cnt = 0; cnt < eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].Srb0.Tx_buffer.payload_size; cnt++) {
-    LOG_F(RRC,"%02x ", ((uint8_t*)eNB_rrc_inst[ctxt_pP->module_id].Srb0.Tx_buffer.Payload)[cnt]);
+  for (cnt = 0; cnt < RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size; cnt++) {
+    LOG_F(RRC,"%02x ", ((uint8_t*)RC.rrc[ctxt_pP->module_id]->Srb0.Tx_buffer.Payload)[cnt]);
   }
 
   LOG_F(RRC,"\n");
@@ -1032,17 +993,17 @@ rrc_eNB_generate_RRCConnectionReject(
   MSC_LOG_TX_MESSAGE(
     MSC_RRC_ENB,
     MSC_RRC_UE,
-    eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].Srb0.Tx_buffer.Header,
-    eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].Srb0.Tx_buffer.payload_size,
+    RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.Header,
+    RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size,
     MSC_AS_TIME_FMT" RRCConnectionReject UE %x size %u",
     MSC_AS_TIME_ARGS(ctxt_pP),
     ue_context_pP == NULL ? -1 : ue_context_pP->ue_context.rnti,
-    eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].Srb0.Tx_buffer.payload_size);
+    RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size);
 
   LOG_I(RRC,
         PROTOCOL_RRC_CTXT_UE_FMT" [RAPROC] Logical Channel DL-CCCH, Generating RRCConnectionReject (bytes %d)\n",
         PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
-        eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].Srb0.Tx_buffer.payload_size);
+        RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size);
 }
 
 //-----------------------------------------------------------------------------
@@ -1061,15 +1022,15 @@ rrc_eNB_generate_RRCConnectionReestablishmentReject(
   T(T_ENB_RRC_CONNECTION_REESTABLISHMENT_REJECT, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
     T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
 
-  eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].Srb0.Tx_buffer.payload_size =
+  RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size =
     do_RRCConnectionReestablishmentReject(ctxt_pP->module_id,
-                          (uint8_t*) eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].Srb0.Tx_buffer.Payload);
+                          (uint8_t*) RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.Payload);
 
 #ifdef RRC_MSG_PRINT
   LOG_F(RRC,"[MSG] RRCConnectionReestablishmentReject\n");
 
-  for (cnt = 0; cnt < eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].Srb0.Tx_buffer.payload_size; cnt++) {
-    LOG_F(RRC,"%02x ", ((uint8_t*)eNB_rrc_inst[ctxt_pP->module_id].Srb0.Tx_buffer.Payload)[cnt]);
+  for (cnt = 0; cnt < RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size; cnt++) {
+    LOG_F(RRC,"%02x ", ((uint8_t*)RC.rrc[ctxt_pP->module_id]->Srb0.Tx_buffer.Payload)[cnt]);
   }
 
   LOG_F(RRC,"\n");
@@ -1078,17 +1039,17 @@ rrc_eNB_generate_RRCConnectionReestablishmentReject(
   MSC_LOG_TX_MESSAGE(
     MSC_RRC_ENB,
     MSC_RRC_UE,
-    eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].Srb0.Tx_buffer.Header,
-    eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].Srb0.Tx_buffer.payload_size,
+    RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.Header,
+    RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size,
     MSC_AS_TIME_FMT" RRCConnectionReestablishmentReject UE %x size %u",
     MSC_AS_TIME_ARGS(ctxt_pP),
     ue_context_pP == NULL ? -1 : ue_context_pP->ue_context.rnti,
-    eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].Srb0.Tx_buffer.payload_size);
+    RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size);
 
   LOG_I(RRC,
         PROTOCOL_RRC_CTXT_UE_FMT" [RAPROC] Logical Channel DL-CCCH, Generating RRCConnectionReestablishmentReject (bytes %d)\n",
         PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
-        eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].Srb0.Tx_buffer.payload_size);
+        RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size);
 }
 
 //-----------------------------------------------------------------------------
@@ -1440,7 +1401,7 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons
   int                                 i;
 
   // configure SRB1/SRB2, PhysicalConfigDedicated, MAC_MainConfig for UE
-  eNB_RRC_INST*                       rrc_inst = &eNB_rrc_inst[ctxt_pP->module_id];
+  eNB_RRC_INST*                       rrc_inst = RC.rrc[ctxt_pP->module_id];
   struct PhysicalConfigDedicated**    physicalConfigDedicated = &ue_context_pP->ue_context.physicalConfigDedicated;
 
   struct SRB_ToAddMod                *SRB2_config                      = NULL;
@@ -2178,7 +2139,7 @@ rrc_eNB_generate_RRCConnectionReconfiguration_SCell(
 
   //   uint8_t sCellIndexToAdd;
   //   sCellIndexToAdd = rrc_find_free_SCell_index(enb_mod_idP, ue_mod_idP, 1);
-  //  if (eNB_rrc_inst[enb_mod_idP].sCell_config[ue_mod_idP][sCellIndexToAdd] ) {
+  //  if (RC.rrc[enb_mod_idP]->sCell_config[ue_mod_idP][sCellIndexToAdd] ) {
   if (ue_context_pP->ue_context.sCell_config != NULL) {
     ue_context_pP->ue_context.sCell_config[sCellIndexToAdd].cellIdentification_r10->dl_CarrierFreq_r10 = dl_CarrierFreq_r10;
   } else {
@@ -2314,7 +2275,7 @@ rrc_eNB_generate_HandoverPreparationInformation(
   /*
      uint8_t buffer[100];
      uint8_t size;
-     struct PhysicalConfigDedicated  **physicalConfigDedicated = &eNB_rrc_inst[enb_mod_idP].physicalConfigDedicated[ue_mod_idP];
+     struct PhysicalConfigDedicated  **physicalConfigDedicated = &RC.rrc[enb_mod_idP]->physicalConfigDedicated[ue_mod_idP];
      RadioResourceConfigDedicated_t *radioResourceConfigDedicated = CALLOC(1,sizeof(RadioResourceConfigDedicated_t));
    */
 
@@ -2325,7 +2286,7 @@ rrc_eNB_generate_HandoverPreparationInformation(
   handoverInfo->as_config.sourceDl_CarrierFreq = 36090;   //Verify!
 
   memcpy((void *)&handoverInfo->as_config.sourceMasterInformationBlock,
-         (void*)&eNB_rrc_inst[ctxt_pP->module_id].carrier[0] /* CROUX TBC */.mib, sizeof(MasterInformationBlock_t));
+         (void*)&RC.rrc[ctxt_pP->module_id]->carrier[0] /* CROUX TBC */.mib, sizeof(MasterInformationBlock_t));
   memcpy((void *)&handoverInfo->as_config.sourceMeasConfig,
          (void*)ue_context_pP->ue_context.measConfig, sizeof(MeasConfig_t));
 
@@ -2338,13 +2299,13 @@ rrc_eNB_generate_HandoverPreparationInformation(
          0, sizeof(SecurityAlgorithmConfig_t));
 
   memcpy((void*)&ue_context_pP->ue_context.handover_info->as_config.sourceSystemInformationBlockType1,
-         (void*)&eNB_rrc_inst[ctxt_pP->module_id].carrier[0] /* CROUX TBC */.SIB1, sizeof(SystemInformationBlockType1_t));
+         (void*)&RC.rrc[ctxt_pP->module_id]->carrier[0] /* CROUX TBC */.SIB1, sizeof(SystemInformationBlockType1_t));
   memcpy((void*)&ue_context_pP->ue_context.handover_info->as_config.sourceSystemInformationBlockType2,
-         (void*)&eNB_rrc_inst[ctxt_pP->module_id].carrier[0] /* CROUX TBC */.SIB23, sizeof(SystemInformationBlockType2_t));
+         (void*)&RC.rrc[ctxt_pP->module_id]->carrier[0] /* CROUX TBC */.SIB23, sizeof(SystemInformationBlockType2_t));
   ue_context_pP->ue_context.handover_info->as_context.reestablishmentInfo =
     CALLOC(1, sizeof(ReestablishmentInfo_t));
   ue_context_pP->ue_context.handover_info->as_context.reestablishmentInfo->sourcePhysCellId =
-    eNB_rrc_inst[ctxt_pP->module_id].carrier[0] /* CROUX TBC */.physCellId;
+    RC.rrc[ctxt_pP->module_id]->carrier[0] /* CROUX TBC */.physCellId;
   ue_context_pP->ue_context.handover_info->as_context.reestablishmentInfo->targetCellShortMAC_I.buf = NULL;  // Check values later
   ue_context_pP->ue_context.handover_info->as_context.reestablishmentInfo->targetCellShortMAC_I.size = 0;
   ue_context_pP->ue_context.handover_info->as_context.reestablishmentInfo->targetCellShortMAC_I.bits_unused = 0;
@@ -2356,22 +2317,22 @@ rrc_eNB_generate_HandoverPreparationInformation(
     //UE_id_target = rrc_find_free_ue_index(modid_target);
     ue_context_target_p =
       rrc_eNB_get_ue_context(
-        &eNB_rrc_inst[mod_id_target],
+        RC.rrc[mod_id_target],
         ue_context_pP->ue_context.rnti);
 
     /*UE_id_target = rrc_eNB_get_next_free_UE_index(
                     mod_id_target,
-                    eNB_rrc_inst[ctxt_pP->module_id].Info.UE_list[ue_mod_idP]);  //this should return a new index*/
+                    RC.rrc[ctxt_pP->module_id]->Info.UE_list[ue_mod_idP]);  //this should return a new index*/
 
     if (ue_context_target_p == NULL) { // if not already in target cell
-      ue_context_target_p = rrc_eNB_allocate_new_UE_context(&eNB_rrc_inst[ctxt_pP->module_id]);
+      ue_context_target_p = rrc_eNB_allocate_new_UE_context(RC.rrc[ctxt_pP->module_id]);
       ue_context_target_p->ue_id_rnti      = ue_context_pP->ue_context.rnti;             // LG: should not be the same
       ue_context_target_p->ue_context.rnti = ue_context_target_p->ue_id_rnti; // idem
       LOG_N(RRC,
             "[eNB %d] Frame %d : Emulate sending HandoverPreparationInformation msg from eNB source %d to eNB target %ld: source UE_id %x target UE_id %x source_modId: %d target_modId: %d\n",
             ctxt_pP->module_id,
             ctxt_pP->frame,
-            eNB_rrc_inst[ctxt_pP->module_id].carrier[0] /* CROUX TBC */.physCellId,
+            RC.rrc[ctxt_pP->module_id]->carrier[0] /* CROUX TBC */.physCellId,
             targetPhyId,
             ue_context_pP->ue_context.rnti,
             ue_context_target_p->ue_id_rnti,
@@ -2435,7 +2396,7 @@ check_handovers(
 {
   int                                 result;
   struct rrc_eNB_ue_context_s*        ue_context_p;
-  RB_FOREACH(ue_context_p, rrc_ue_tree_s, &eNB_rrc_inst[ctxt_pP->module_id].rrc_ue_head) {
+  RB_FOREACH(ue_context_p, rrc_ue_tree_s, &RC.rrc[ctxt_pP->module_id]->rrc_ue_head) {
     ctxt_pP->rnti  = ue_context_p->ue_id_rnti;
 
     if (ue_context_p->ue_context.handover_info != NULL) {
@@ -2499,7 +2460,7 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover(
   uint8_t                             rv[2];
   uint16_t                            Idx;
   // configure SRB1/SRB2, PhysicalConfigDedicated, MAC_MainConfig for UE
-  eNB_RRC_INST*                       rrc_inst = &eNB_rrc_inst[ctxt_pP->module_id];
+  eNB_RRC_INST*                       rrc_inst = RC.rrc[ctxt_pP->module_id];
   struct PhysicalConfigDedicated**    physicalConfigDedicated = &ue_context_pP->ue_context.physicalConfigDedicated;
 
   struct SRB_ToAddMod                *SRB2_config;
@@ -2771,39 +2732,37 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover(
   LOG_D(RRC,
         "handover_config [FRAME %05d][RRC_eNB][MOD %02d][][--- MAC_CONFIG_REQ  (SRB1 UE %x) --->][MAC_eNB][MOD %02d][]\n",
         ctxt_pP->frame, ctxt_pP->module_id, ue_context_pP->ue_context.rnti, ctxt_pP->module_id);
-  rrc_mac_config_req(
-    ctxt_pP->module_id,
-    ue_context_pP->ue_context.primaryCC_id,
-    ENB_FLAG_YES,
-    ue_context_pP->ue_context.rnti,
-    0,
-    (RadioResourceConfigCommonSIB_t*) NULL,
-    ue_context_pP->ue_context.physicalConfigDedicated,
+  rrc_mac_config_req_eNB(
+			 ctxt_pP->module_id,
+			 ue_context_pP->ue_context.primaryCC_id,
+			 0,0,0,0,0,(BCCH_BCH_Message_t *) NULL,
+			 (RadioResourceConfigCommonSIB_t*) NULL,
+			 ue_context_pP->ue_context.physicalConfigDedicated,
 #ifdef Rel10
-    (SCellToAddMod_r10_t *)NULL,
-    //(struct PhysicalConfigDedicatedSCell_r10 *)NULL,
+			 (SCellToAddMod_r10_t *)NULL,
+			 //(struct PhysicalConfigDedicatedSCell_r10 *)NULL,
 #endif
-    (MeasObjectToAddMod_t **) NULL,
-    ue_context_pP->ue_context.mac_MainConfig,
-    1,
-    SRB1_logicalChannelConfig,
-    ue_context_pP->ue_context.measGapConfig,
-    (TDD_Config_t*) NULL,
-    (MobilityControlInfo_t*) NULL,
-    (uint8_t*) NULL,
-    (uint16_t*) NULL,
-    NULL,
-    NULL,
-    NULL,
-    (MBSFN_SubframeConfigList_t *) NULL
+			 (MeasObjectToAddMod_t **) NULL,
+			 ue_context_pP->ue_context.mac_MainConfig,
+			 1,
+			 SRB1_logicalChannelConfig,
+			 ue_context_pP->ue_context.measGapConfig,
+			 (TDD_Config_t*) NULL,
+			 (MobilityControlInfo_t*) NULL,
+			 (uint8_t*) NULL,
+			 (uint16_t*) NULL,
+			 0,
+			 NULL,
+			 NULL,
+			 (MBSFN_SubframeConfigList_t *) NULL
 #ifdef Rel10
-    , 0, (MBSFN_AreaInfoList_r9_t *) NULL, (PMCH_InfoList_r9_t *) NULL
+			 , 0, (MBSFN_AreaInfoList_r9_t *) NULL, (PMCH_InfoList_r9_t *) NULL
 #endif
 #ifdef CBA
-    , eNB_rrc_inst[ctxt_pP->module_id].num_active_cba_groups, eNB_rrc_inst[ctxt_pP->module_id].cba_rnti[0]
+			 , RC.rrc[ctxt_pP->module_id]->num_active_cba_groups, RC.rrc[ctxt_pP->module_id]->cba_rnti[0]
 #endif
-  );
-
+			 );
+  
   // Configure target eNB SRB2
   /// SRB2
   SRB2_config = CALLOC(1, sizeof(*SRB2_config));
@@ -3327,9 +3286,9 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover(
         "[eNB %d] Frame %d, Logical Channel DL-DCCH, Generate RRCConnectionReconfiguration for handover (bytes %d, UE rnti %x)\n",
         ctxt_pP->module_id, ctxt_pP->frame, size, ue_context_pP->ue_context.rnti);
   // to be updated if needed
-  /*if (eNB_rrc_inst[ctxt_pP->module_id].SRB1_config[ue_mod_idP]->logicalChannelConfig) {
-     if (eNB_rrc_inst[ctxt_pP->module_id].SRB1_config[ue_mod_idP]->logicalChannelConfig->present == SRB_ToAddMod__logicalChannelConfig_PR_explicitValue) {
-     SRB1_logicalChannelConfig = &eNB_rrc_inst[ctxt_pP->module_id].SRB1_config[ue_mod_idP]->logicalChannelConfig->choice.explicitValue;
+  /*if (RC.rrc[ctxt_pP->module_id]->SRB1_config[ue_mod_idP]->logicalChannelConfig) {
+     if (RC.rrc[ctxt_pP->module_id]->SRB1_config[ue_mod_idP]->logicalChannelConfig->present == SRB_ToAddMod__logicalChannelConfig_PR_explicitValue) {
+     SRB1_logicalChannelConfig = &RC.rrc[ctxt_pP->module_id]->SRB1_config[ue_mod_idP]->logicalChannelConfig->choice.explicitValue;
      }
      else {
      SRB1_logicalChannelConfig = &SRB1_logicalChannelConfig_defaultValue;
@@ -3345,34 +3304,32 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover(
         ctxt_pP->frame, ctxt_pP->module_id, size, ue_context_pP->ue_context.rnti, rrc_eNB_mui, ctxt_pP->module_id, DCCH);
   //rrc_rlc_data_req(ctxt_pP->module_id,frameP, 1,(ue_mod_idP*NB_RB_MAX)+DCCH,rrc_eNB_mui++,0,size,(char*)buffer);
   //pdcp_data_req (ctxt_pP->module_id, frameP, 1, (ue_mod_idP * NB_RB_MAX) + DCCH,rrc_eNB_mui++, 0, size, (char *) buffer, 1);
-  rrc_mac_config_req(
-    ctxt_pP->module_id,
-    ue_context_pP->ue_context.primaryCC_id,
-    ENB_FLAG_YES,
-    ue_context_pP->ue_context.rnti,
-    0,
-    (RadioResourceConfigCommonSIB_t *) NULL,
-    ue_context_pP->ue_context.physicalConfigDedicated,
+  rrc_mac_config_req_eNB(
+			 ctxt_pP->module_id,
+			 ue_context_pP->ue_context.primaryCC_id,
+			 0,0,0,0,0,(BCCH_BCH_Message_t *) NULL,
+			 (RadioResourceConfigCommonSIB_t *) NULL,
+			 ue_context_pP->ue_context.physicalConfigDedicated,
 #ifdef Rel10
-    (SCellToAddMod_r10_t *)NULL,
-    //(struct PhysicalConfigDedicatedSCell_r10 *)NULL,
+			 (SCellToAddMod_r10_t *)NULL,
+			 //(struct PhysicalConfigDedicatedSCell_r10 *)NULL,
 #endif
-    (MeasObjectToAddMod_t **) NULL,
-    ue_context_pP->ue_context.mac_MainConfig,
-    1,
-    SRB1_logicalChannelConfig,
-    ue_context_pP->ue_context.measGapConfig,
-    (TDD_Config_t *) NULL,
-    (MobilityControlInfo_t *) mobilityInfo,
-    (uint8_t *) NULL, (uint16_t *) NULL, NULL, NULL, NULL, (MBSFN_SubframeConfigList_t *) NULL
+			 (MeasObjectToAddMod_t **) NULL,
+			 ue_context_pP->ue_context.mac_MainConfig,
+			 1,
+			 SRB1_logicalChannelConfig,
+			 ue_context_pP->ue_context.measGapConfig,
+			 (TDD_Config_t *) NULL,
+			 (MobilityControlInfo_t *) mobilityInfo,
+			 (uint8_t *) NULL, (uint16_t *) NULL, 0, NULL, NULL, (MBSFN_SubframeConfigList_t *) NULL
 #ifdef Rel10
-    , 0, (MBSFN_AreaInfoList_r9_t *) NULL, (PMCH_InfoList_r9_t *) NULL
+			 , 0, (MBSFN_AreaInfoList_r9_t *) NULL, (PMCH_InfoList_r9_t *) NULL
 #endif
 #ifdef CBA
-    , 0, 0
+			 , 0, 0
 #endif
-  );
-
+			 );
+  
   /*
      handoverCommand.criticalExtensions.present = HandoverCommand__criticalExtensions_PR_c1;
      handoverCommand.criticalExtensions.choice.c1.present = HandoverCommand__criticalExtensions__c1_PR_handoverCommand_r8;
@@ -3383,17 +3340,17 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover(
 #ifdef PROBLEM_COMPILATION_RESOLVED
 
   if (sourceModId != 0xFF) {
-    memcpy(eNB_rrc_inst[sourceModId].handover_info[eNB_rrc_inst[ctxt_pP->module_id].handover_info[ue_mod_idP]->ueid_s]->buf,
+    memcpy(RC.rrc[sourceModId].handover_info[RC.rrc[ctxt_pP->module_id]->handover_info[ue_mod_idP]->ueid_s]->buf,
            (void *)buffer, size);
-    eNB_rrc_inst[sourceModId].handover_info[eNB_rrc_inst[ctxt_pP->module_id].handover_info[ue_mod_idP]->ueid_s]->size = size;
-    eNB_rrc_inst[sourceModId].handover_info[eNB_rrc_inst[ctxt_pP->module_id].handover_info[ue_mod_idP]->ueid_s]->ho_complete =
+    RC.rrc[sourceModId].handover_info[RC.rrc[ctxt_pP->module_id]->handover_info[ue_mod_idP]->ueid_s]->size = size;
+    RC.rrc[sourceModId].handover_info[RC.rrc[ctxt_pP->module_id]->handover_info[ue_mod_idP]->ueid_s]->ho_complete =
       0xF1;
-    //eNB_rrc_inst[ctxt_pP->module_id].handover_info[ue_mod_idP]->ho_complete = 0xFF;
+    //RC.rrc[ctxt_pP->module_id]->handover_info[ue_mod_idP]->ho_complete = 0xFF;
     LOG_D(RRC, "[eNB %d] Frame %d: setting handover complete to 0xF1 for (%d,%d) and to 0xFF for (%d,%d)\n",
           ctxt_pP->module_id,
           ctxt_pP->frame,
           sourceModId,
-          eNB_rrc_inst[ctxt_pP->module_id].handover_info[ue_mod_idP]->ueid_s,
+          RC.rrc[ctxt_pP->module_id]->handover_info[ue_mod_idP]->ueid_s,
           ctxt_pP->module_id,
           ue_mod_idP);
   } else
@@ -3514,8 +3471,8 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete(
     SRB_configList, //NULL,  //LG-RK 14/05/2014 SRB_configList,
     DRB_configList, 
     (DRB_ToReleaseList_t *) NULL,
-    /*eNB_rrc_inst[ctxt_pP->module_id].ciphering_algorithm[ue_mod_idP] |
-             (eNB_rrc_inst[ctxt_pP->module_id].integrity_algorithm[ue_mod_idP] << 4),
+    /*RC.rrc[ctxt_pP->module_id]->ciphering_algorithm[ue_mod_idP] |
+             (RC.rrc[ctxt_pP->module_id]->integrity_algorithm[ue_mod_idP] << 4),
      */
     0xff, // already configured during the securitymodecommand
     kRRCenc,
@@ -3585,7 +3542,7 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete(
              rrc_pdcp_config_req (ctxt_pP->module_id, frameP, 1, CONFIG_ACTION_ADD,
              (ue_mod_idP * NB_RB_MAX) + *DRB_configList->list.array[i]->logicalChannelIdentity,UNDEF_SECURITY_MODE);
              rrc_rlc_config_req(ctxt_pP->module_id,frameP,1,CONFIG_ACTION_ADD,
-             (ue_mod_idP * NB_RB_MAX) + (int)*eNB_rrc_inst[ctxt_pP->module_id].DRB_config[ue_mod_idP][i]->logicalChannelIdentity,
+             (ue_mod_idP * NB_RB_MAX) + (int)*RC.rrc[ctxt_pP->module_id]->DRB_config[ue_mod_idP][i]->logicalChannelIdentity,
              RADIO_ACCESS_BEARER,Rlc_info_um);
            */
           ue_context_pP->ue_context.DRB_active[i] = 1;
@@ -3642,35 +3599,33 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete(
             DRB2LCHAN[i] = (uint8_t) * DRB_configList->list.array[i]->logicalChannelIdentity;
           }
 
-          rrc_mac_config_req(
-            ctxt_pP->module_id,
-            ue_context_pP->ue_context.primaryCC_id,
-            ENB_FLAG_YES,
-            ue_context_pP->ue_context.rnti,
-            0,
-            (RadioResourceConfigCommonSIB_t *) NULL,
-            ue_context_pP->ue_context.physicalConfigDedicated,
+          rrc_mac_config_req_eNB(
+				 ctxt_pP->module_id,
+				 ue_context_pP->ue_context.primaryCC_id,
+				 0,0,0,0,0,(BCCH_BCH_Message_t *) NULL,
+				 (RadioResourceConfigCommonSIB_t *) NULL,
+				 ue_context_pP->ue_context.physicalConfigDedicated,
 #ifdef Rel10
-            (SCellToAddMod_r10_t *)NULL,
-            //(struct PhysicalConfigDedicatedSCell_r10 *)NULL,
+				 (SCellToAddMod_r10_t *)NULL,
+				 //(struct PhysicalConfigDedicatedSCell_r10 *)NULL,
 #endif
-            (MeasObjectToAddMod_t **) NULL,
-            ue_context_pP->ue_context.mac_MainConfig,
-            DRB2LCHAN[i],
-            DRB_configList->list.array[i]->logicalChannelConfig,
-            ue_context_pP->ue_context.measGapConfig,
-            (TDD_Config_t *) NULL,
-            NULL,
-            (uint8_t *) NULL,
-            (uint16_t *) NULL, NULL, NULL, NULL, (MBSFN_SubframeConfigList_t *) NULL
+				 (MeasObjectToAddMod_t **) NULL,
+				 ue_context_pP->ue_context.mac_MainConfig,
+				 DRB2LCHAN[i],
+				 DRB_configList->list.array[i]->logicalChannelConfig,
+				 ue_context_pP->ue_context.measGapConfig,
+				 (TDD_Config_t *) NULL,
+				 NULL,
+				 (uint8_t *) NULL,
+				 (uint16_t *) NULL, 0, NULL, NULL, (MBSFN_SubframeConfigList_t *) NULL
 #ifdef Rel10
-            , 0, (MBSFN_AreaInfoList_r9_t *) NULL, (PMCH_InfoList_r9_t *) NULL
+				 , 0, (MBSFN_AreaInfoList_r9_t *) NULL, (PMCH_InfoList_r9_t *) NULL
 #endif
 #ifdef CBA
-            , eNB_rrc_inst[ctxt_pP->module_id].num_active_cba_groups, eNB_rrc_inst[ctxt_pP->module_id].cba_rnti[0]
+				 , RC.rrc[ctxt_pP->module_id]->num_active_cba_groups, RC.rrc[ctxt_pP->module_id]->cba_rnti[0]
 #endif
-          );
-
+				 );
+	  
         } else {        // remove LCHAN from MAC/PHY
 
           if (ue_context_pP->ue_context.DRB_active[i] == 1) {
@@ -3691,31 +3646,29 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete(
           LOG_D(RRC,
                 PROTOCOL_RRC_CTXT_UE_FMT" RRC_eNB --- MAC_CONFIG_REQ  (DRB) ---> MAC_eNB\n",
                 PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP));
-          rrc_mac_config_req(ctxt_pP->module_id,
-                             ue_context_pP->ue_context.primaryCC_id,
-                             ENB_FLAG_YES,
-                             ue_context_pP->ue_context.rnti,
-                             0,
-                             (RadioResourceConfigCommonSIB_t *) NULL,
-                             ue_context_pP->ue_context.physicalConfigDedicated,
+          rrc_mac_config_req_eNB(ctxt_pP->module_id,
+				 ue_context_pP->ue_context.primaryCC_id,
+				 0,0,0,0,0,(BCCH_BCH_Message_t *) NULL,
+				 (RadioResourceConfigCommonSIB_t *) NULL,
+				 ue_context_pP->ue_context.physicalConfigDedicated,
 #ifdef Rel10
-                             (SCellToAddMod_r10_t *)NULL,
-                             //(struct PhysicalConfigDedicatedSCell_r10 *)NULL,
+				 (SCellToAddMod_r10_t *)NULL,
+				 //(struct PhysicalConfigDedicatedSCell_r10 *)NULL,
 #endif
-                             (MeasObjectToAddMod_t **) NULL,
-                             ue_context_pP->ue_context.mac_MainConfig,
-                             DRB2LCHAN[i],
-                             (LogicalChannelConfig_t *) NULL,
-                             (MeasGapConfig_t *) NULL,
-                             (TDD_Config_t *) NULL,
-                             NULL, (uint8_t *) NULL, (uint16_t *) NULL, NULL, NULL, NULL, NULL
+				 (MeasObjectToAddMod_t **) NULL,
+				 ue_context_pP->ue_context.mac_MainConfig,
+				 DRB2LCHAN[i],
+				 (LogicalChannelConfig_t *) NULL,
+				 (MeasGapConfig_t *) NULL,
+				 (TDD_Config_t *) NULL,
+				 NULL, (uint8_t *) NULL, (uint16_t *) NULL, 0, NULL, NULL, NULL
 #ifdef Rel10
-                             , 0, (MBSFN_AreaInfoList_r9_t *) NULL, (PMCH_InfoList_r9_t *) NULL
+				 , 0, (MBSFN_AreaInfoList_r9_t *) NULL, (PMCH_InfoList_r9_t *) NULL
 #endif
 #ifdef CBA
-                             , 0, 0
+				 , 0, 0
 #endif
-                            );
+				 );
         }
       }
     }
@@ -3742,11 +3695,11 @@ rrc_eNB_generate_RRCConnectionSetup(
     T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
 
   SRB_configList = &ue_context_pP->ue_context.SRB_configList;
-  eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].Srb0.Tx_buffer.payload_size =
+  RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size =
     do_RRCConnectionSetup(ctxt_pP,
                           ue_context_pP,
                           CC_id,
-                          (uint8_t*) eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].Srb0.Tx_buffer.Payload,
+                          (uint8_t*) RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.Payload,
 			  (fp->nb_antenna_ports_eNB==2)?2:1, //at this point we do not have the UE capability information, so it can only be TM1 or TM2
                           rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id),
                           fp,
@@ -3756,8 +3709,8 @@ rrc_eNB_generate_RRCConnectionSetup(
 #ifdef RRC_MSG_PRINT
   LOG_F(RRC,"[MSG] RRC Connection Setup\n");
 
-  for (cnt = 0; cnt < eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].Srb0.Tx_buffer.payload_size; cnt++) {
-    LOG_F(RRC,"%02x ", ((uint8_t*)eNB_rrc_inst[ctxt_pP->module_id].Srb0.Tx_buffer.Payload)[cnt]);
+  for (cnt = 0; cnt < RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size; cnt++) {
+    LOG_F(RRC,"%02x ", ((uint8_t*)RC.rrc[ctxt_pP->module_id]->Srb0.Tx_buffer.Payload)[cnt]);
   }
 
   LOG_F(RRC,"\n");
@@ -3785,34 +3738,32 @@ rrc_eNB_generate_RRCConnectionSetup(
         LOG_D(RRC,
               PROTOCOL_RRC_CTXT_UE_FMT" RRC_eNB --- MAC_CONFIG_REQ  (SRB1) ---> MAC_eNB\n",
               PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP));
-        rrc_mac_config_req(
-          ctxt_pP->module_id,
-          ue_context_pP->ue_context.primaryCC_id,
-          ENB_FLAG_YES,
-          ue_context_pP->ue_context.rnti,
-          0,
-          (RadioResourceConfigCommonSIB_t *) NULL,
-          ue_context_pP->ue_context.physicalConfigDedicated,
+        rrc_mac_config_req_eNB(
+			       ctxt_pP->module_id,
+			       ue_context_pP->ue_context.primaryCC_id,
+			       0,0,0,0,0,(BCCH_BCH_Message_t *) NULL,
+			       (RadioResourceConfigCommonSIB_t *) NULL,
+			       ue_context_pP->ue_context.physicalConfigDedicated,
 #ifdef Rel10
-          (SCellToAddMod_r10_t *)NULL,
-          //(struct PhysicalConfigDedicatedSCell_r10 *)NULL,
+			       (SCellToAddMod_r10_t *)NULL,
+			       //(struct PhysicalConfigDedicatedSCell_r10 *)NULL,
 #endif
-          (MeasObjectToAddMod_t **) NULL,
-          ue_context_pP->ue_context.mac_MainConfig,
-          1,
-          SRB1_logicalChannelConfig,
-          ue_context_pP->ue_context.measGapConfig,
-          (TDD_Config_t *) NULL,
-          NULL,
-          (uint8_t *) NULL,
-          (uint16_t *) NULL, NULL, NULL, NULL, (MBSFN_SubframeConfigList_t *) NULL
+			       (MeasObjectToAddMod_t **) NULL,
+			       ue_context_pP->ue_context.mac_MainConfig,
+			       1,
+			       SRB1_logicalChannelConfig,
+			       ue_context_pP->ue_context.measGapConfig,
+			       (TDD_Config_t *) NULL,
+			       NULL,
+			       (uint8_t *) NULL,
+			       (uint16_t *) NULL, 0, NULL, NULL, (MBSFN_SubframeConfigList_t *) NULL
 #ifdef Rel10
-          , 0, (MBSFN_AreaInfoList_r9_t *) NULL, (PMCH_InfoList_r9_t *) NULL
+			       , 0, (MBSFN_AreaInfoList_r9_t *) NULL, (PMCH_InfoList_r9_t *) NULL
 #endif
 #ifdef CBA
-          , 0, 0
+			       , 0, 0
 #endif
-        );
+			       );
         break;
       }
     }
@@ -3821,18 +3772,18 @@ rrc_eNB_generate_RRCConnectionSetup(
   MSC_LOG_TX_MESSAGE(
     MSC_RRC_ENB,
     MSC_RRC_UE,
-    eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].Srb0.Tx_buffer.Header, // LG WARNING
-    eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].Srb0.Tx_buffer.payload_size,
+    RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.Header, // LG WARNING
+    RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size,
     MSC_AS_TIME_FMT" RRCConnectionSetup UE %x size %u",
     MSC_AS_TIME_ARGS(ctxt_pP),
     ue_context_pP->ue_context.rnti,
-    eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].Srb0.Tx_buffer.payload_size);
+    RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size);
 
 
   LOG_I(RRC,
         PROTOCOL_RRC_CTXT_UE_FMT" [RAPROC] Logical Channel DL-CCCH, Generating RRCConnectionSetup (bytes %d)\n",
         PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
-        eNB_rrc_inst[ctxt_pP->module_id].carrier[CC_id].Srb0.Tx_buffer.payload_size);
+        RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size);
 
   // activate release timer, if RRCSetupComplete not received after 10 frames, remove UE
   ue_context_pP->ue_context.ue_release_timer=1;
@@ -3840,18 +3791,6 @@ rrc_eNB_generate_RRCConnectionSetup(
   ue_context_pP->ue_context.ue_release_timer_thres=100;
 }
 
-#if defined(ENABLE_ITTI)
-char
-//-----------------------------------------------------------------------------
-openair_rrc_eNB_init(
-  const module_id_t enb_mod_idP
-)
-//-----------------------------------------------------------------------------
-{
-  /* Dummy function, initialization will be done through ITTI messaging */
-  return 0;
-}
-#endif
 
 #if defined(ENABLE_ITTI)
 //-----------------------------------------------------------------------------
@@ -3877,16 +3816,16 @@ openair_rrc_eNB_init(
         PROTOCOL_RRC_CTXT_ARGS(&ctxt));
 
 #if OCP_FRAMEWORK
-while ( eNB_rrc_inst == NULL ) {
-  LOG_E(RRC, "eNB_rrc_inst not yet initialized, waiting 1 second\n");
+while ( RC.rrc[enb_mod_idP] == NULL ) {
+  LOG_E(RRC, "RC.rrc not yet initialized, waiting 1 second\n");
   sleep(1);
 }
 #endif 
-  AssertFatal(eNB_rrc_inst != NULL, "eNB_rrc_inst not initialized!");
+  AssertFatal(RC.rrc[enb_mod_idP] != NULL, "RC.rrc not initialized!");
   AssertFatal(NUMBER_OF_UE_MAX < (module_id_t)0xFFFFFFFFFFFFFFFF, " variable overflow");
 
   //    for (j = 0; j < NUMBER_OF_UE_MAX; j++)
-  //        eNB_rrc_inst[ctxt.module_id].Info.UE[j].Status = RRC_IDLE;  //CH_READY;
+  //        RC.rrc[ctxt.module_id].Info.UE[j].Status = RRC_IDLE;  //CH_READY;
   //
   //#if defined(ENABLE_USE_MME)
   //    // Connect eNB to MME
@@ -3895,28 +3834,28 @@ while ( eNB_rrc_inst == NULL ) {
   //    {
   //        /* Init security parameters */
   //        for (j = 0; j < NUMBER_OF_UE_MAX; j++) {
-  //            eNB_rrc_inst[ctxt.module_id].ciphering_algorithm[j] = SecurityAlgorithmConfig__cipheringAlgorithm_eea0;
-  //            eNB_rrc_inst[ctxt.module_id].integrity_algorithm[j] = SecurityAlgorithmConfig__integrityProtAlgorithm_eia2;
+  //            RC.rrc[ctxt.module_id].ciphering_algorithm[j] = SecurityAlgorithmConfig__cipheringAlgorithm_eea0;
+  //            RC.rrc[ctxt.module_id].integrity_algorithm[j] = SecurityAlgorithmConfig__integrityProtAlgorithm_eia2;
   //            rrc_eNB_init_security(enb_mod_idP, j);
   //        }
   //    }
-  eNB_rrc_inst[ctxt.module_id].Nb_ue = 0;
+  RC.rrc[ctxt.module_id]->Nb_ue = 0;
 
   for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
-    eNB_rrc_inst[ctxt.module_id].carrier[CC_id].Srb0.Active = 0;
+    RC.rrc[ctxt.module_id]->carrier[CC_id].Srb0.Active = 0;
   }
 
-  uid_linear_allocator_init(&eNB_rrc_inst[ctxt.module_id].uid_allocator);
-  RB_INIT(&eNB_rrc_inst[ctxt.module_id].rrc_ue_head);
+  uid_linear_allocator_init(&RC.rrc[ctxt.module_id]->uid_allocator);
+  RB_INIT(&RC.rrc[ctxt.module_id]->rrc_ue_head);
   //    for (j = 0; j < (NUMBER_OF_UE_MAX + 1); j++) {
-  //        eNB_rrc_inst[enb_mod_idP].Srb2[j].Active = 0;
+  //        RC.rrc[enb_mod_idP]->Srb2[j].Active = 0;
   //    }
 
 
-  eNB_rrc_inst[ctxt.module_id].initial_id2_s1ap_ids = hashtable_create (NUMBER_OF_UE_MAX * 2, NULL, NULL);
-  eNB_rrc_inst[ctxt.module_id].s1ap_id2_s1ap_ids    = hashtable_create (NUMBER_OF_UE_MAX * 2, NULL, NULL);
+  RC.rrc[ctxt.module_id]->initial_id2_s1ap_ids = hashtable_create (NUMBER_OF_UE_MAX * 2, NULL, NULL);
+  RC.rrc[ctxt.module_id]->s1ap_id2_s1ap_ids    = hashtable_create (NUMBER_OF_UE_MAX * 2, NULL, NULL);
 
-  memcpy(&eNB_rrc_inst[ctxt.module_id].configuration,configuration,sizeof(RrcConfigurationReq));
+  memcpy(&RC.rrc[ctxt.module_id]->configuration,configuration,sizeof(RrcConfigurationReq));
 
   /// System Information INIT
 
@@ -3924,11 +3863,14 @@ while ( eNB_rrc_inst == NULL ) {
         PROTOCOL_RRC_CTXT_ARGS(&ctxt));
 #ifdef Rel10
 
+  // can clear it at runtime
+  RC.rrc[ctxt.module_id]->carrier[0].MBMS_flag = 0;
+
   // This has to come from some top-level configuration
   // only CC_id 0 is logged
   LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" Rel10 RRC detected, MBMS flag %d\n",
         PROTOCOL_RRC_CTXT_ARGS(&ctxt),
-        eNB_rrc_inst[ctxt.module_id].carrier[0].MBMS_flag);
+        RC.rrc[ctxt.module_id]->carrier[0].MBMS_flag);
 
 #else
   LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" Rel8 RRC\n", PROTOCOL_RRC_CTXT_ARGS(&ctxt));
@@ -3937,21 +3879,21 @@ while ( eNB_rrc_inst == NULL ) {
 
   for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
     for (j = 0; j < NUM_MAX_CBA_GROUP; j++) {
-      eNB_rrc_inst[ctxt.module_id].carrier[CC_id].cba_rnti[j] = CBA_OFFSET + j;
+      RC.rrc[ctxt.module_id]->carrier[CC_id].cba_rnti[j] = CBA_OFFSET + j;
     }
 
-    if (eNB_rrc_inst[ctxt.module_id].carrier[CC_id].num_active_cba_groups > NUM_MAX_CBA_GROUP) {
-      eNB_rrc_inst[ctxt.module_id].carrier[CC_id].num_active_cba_groups = NUM_MAX_CBA_GROUP;
+    if (RC.rrc[ctxt.module_id]->carrier[CC_id].num_active_cba_groups > NUM_MAX_CBA_GROUP) {
+      RC.rrc[ctxt.module_id]->carrier[CC_id].num_active_cba_groups = NUM_MAX_CBA_GROUP;
     }
 
     LOG_D(RRC,
           PROTOCOL_RRC_CTXT_FMT" Initialization of 4 cba_RNTI values (%x %x %x %x) num active groups %d\n",
           PROTOCOL_RRC_CTXT_ARGS(&ctxt),
-          enb_mod_idP, eNB_rrc_inst[ctxt.module_id].carrier[CC_id].cba_rnti[0],
-          eNB_rrc_inst[ctxt.module_id].carrier[CC_id].cba_rnti[1],
-          eNB_rrc_inst[ctxt.module_id].carrier[CC_id].cba_rnti[2],
-          eNB_rrc_inst[ctxt.module_id].carrier[CC_id].cba_rnti[3],
-          eNB_rrc_inst[ctxt.module_id].carrier[CC_id].num_active_cba_groups);
+          enb_mod_idP, RC.rrc[ctxt.module_id]->carrier[CC_id].cba_rnti[0],
+          RC.rrc[ctxt.module_id]->carrier[CC_id].cba_rnti[1],
+          RC.rrc[ctxt.module_id]->carrier[CC_id].cba_rnti[2],
+          RC.rrc[ctxt.module_id]->carrier[CC_id].cba_rnti[3],
+          RC.rrc[ctxt.module_id]->carrier[CC_id].num_active_cba_groups);
   }
 
 #endif
@@ -3965,44 +3907,42 @@ while ( eNB_rrc_inst == NULL ) {
            );
   }
 
-#ifdef Rel10
+
+  rrc_init_global_param();
 
   for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
-    switch (eNB_rrc_inst[ctxt.module_id].carrier[CC_id].MBMS_flag) {
+
+#ifdef Rel10
+    switch (RC.rrc[ctxt.module_id]->carrier[CC_id].MBMS_flag) {
     case 1:
     case 2:
     case 3:
       LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" Configuring 1 MBSFN sync area\n", PROTOCOL_RRC_CTXT_ARGS(&ctxt));
-      eNB_rrc_inst[ctxt.module_id].carrier[CC_id].num_mbsfn_sync_area = 1;
+      RC.rrc[ctxt.module_id]->carrier[CC_id].num_mbsfn_sync_area = 1;
       break;
 
     case 4:
       LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" Configuring 2 MBSFN sync area\n", PROTOCOL_RRC_CTXT_ARGS(&ctxt));
-      eNB_rrc_inst[ctxt.module_id].carrier[CC_id].num_mbsfn_sync_area = 2;
+      RC.rrc[ctxt.module_id]->carrier[CC_id].num_mbsfn_sync_area = 2;
       break;
 
     default:
-      eNB_rrc_inst[ctxt.module_id].carrier[CC_id].num_mbsfn_sync_area = 0;
+      RC.rrc[ctxt.module_id]->carrier[CC_id].num_mbsfn_sync_area = 0;
       break;
     }
 
-    // if we are here the eNB_rrc_inst[enb_mod_idP].MBMS_flag > 0,
+    // if we are here the RC.rrc[enb_mod_idP]->MBMS_flag > 0,
     /// MCCH INIT
-    if (eNB_rrc_inst[ctxt.module_id].carrier[CC_id].MBMS_flag > 0) {
+    if (RC.rrc[ctxt.module_id]->carrier[CC_id].MBMS_flag > 0) {
       init_MCCH(ctxt.module_id, CC_id);
       /// MTCH data bearer init
       init_MBMS(ctxt.module_id, CC_id, 0);
     }
-  }
-
 #endif
 
-#ifdef NO_RRM                   //init ch SRB0, SRB1 & BDTCH
+    openair_rrc_top_init_eNB(RC.rrc[ctxt.module_id]->carrier[CC_id].MBMS_flag,0);
+  }
   openair_rrc_on(&ctxt);
-#else
-  eNB_rrc_inst[ctxt.module_id].Last_scan_req = 0;
-  send_msg(&S_rrc, msg_rrc_phy_synch_to_MR_ind(ctxt.module_id, eNB_rrc_inst[ctxt.module_id].Mac_id));
-#endif
 
   return 0;
 
@@ -4131,7 +4071,7 @@ rrc_eNB_decode_ccch(
       ue_mod_id = rrc_eNB_get_UE_index(enb_mod_idP, c_rnti);
       }
 
-      if ((eNB_rrc_inst[enb_mod_idP].phyCellId == rrcConnectionReestablishmentRequest.UE_identity.physCellId) &&
+      if ((RC.rrc[enb_mod_idP]->phyCellId == rrcConnectionReestablishmentRequest.UE_identity.physCellId) &&
       (ue_mod_id != UE_INDEX_INVALID)){
       rrc_eNB_generate_RRCConnectionReestablishment(enb_mod_idP, frameP, ue_mod_id);
       }else {
@@ -4140,7 +4080,7 @@ rrc_eNB_decode_ccch(
       */
       /* reject all reestablishment attempts for the moment */
       rrc_eNB_generate_RRCConnectionReestablishmentReject(ctxt_pP,
-                       rrc_eNB_get_ue_context(&eNB_rrc_inst[ctxt_pP->module_id], ctxt_pP->rnti),
+                       rrc_eNB_get_ue_context(RC.rrc[ctxt_pP->module_id], ctxt_pP->rnti),
                        CC_id);
       break;
 
@@ -4161,7 +4101,7 @@ rrc_eNB_decode_ccch(
             PROTOCOL_RRC_CTXT_UE_FMT"MAC_eNB --- MAC_DATA_IND  (rrcConnectionRequest on SRB0) --> RRC_eNB\n",
             PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP));
       ue_context_p = rrc_eNB_get_ue_context(
-                       &eNB_rrc_inst[ctxt_pP->module_id],
+                       RC.rrc[ctxt_pP->module_id],
                        ctxt_pP->rnti);
 
       if (ue_context_p != NULL) {
@@ -4211,11 +4151,11 @@ rrc_eNB_decode_ccch(
 	      stmsi_received=1;
               /* replace rnti in the context */
               /* for that, remove the context from the RB tree */
-              RB_REMOVE(rrc_ue_tree_s, &eNB_rrc_inst[ctxt_pP->module_id].rrc_ue_head, ue_context_p);
+              RB_REMOVE(rrc_ue_tree_s, &RC.rrc[ctxt_pP->module_id]->rrc_ue_head, ue_context_p);
               /* and insert again, after changing rnti everywhere it has to be changed */
               ue_context_p->ue_id_rnti = ctxt_pP->rnti;
 	      ue_context_p->ue_context.rnti = ctxt_pP->rnti;
-              RB_INSERT(rrc_ue_tree_s, &eNB_rrc_inst[ctxt_pP->module_id].rrc_ue_head, ue_context_p);
+              RB_INSERT(rrc_ue_tree_s, &RC.rrc[ctxt_pP->module_id]->rrc_ue_head, ue_context_p);
               /* reset timers */
               ue_context_p->ue_context.ul_failure_timer = 0;
               ue_context_p->ue_context.ue_release_timer = 0;
@@ -4251,7 +4191,7 @@ rrc_eNB_decode_ccch(
                   PROTOCOL_RRC_CTXT_UE_FMT" RRCConnectionRequest without random UE identity or S-TMSI not supported, let's reject the UE\n",
                   PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP));
             rrc_eNB_generate_RRCConnectionReject(ctxt_pP,
-                             rrc_eNB_get_ue_context(&eNB_rrc_inst[ctxt_pP->module_id], ctxt_pP->rnti),
+                             rrc_eNB_get_ue_context(RC.rrc[ctxt_pP->module_id], ctxt_pP->rnti),
                              CC_id);
             break;
           }
@@ -4286,7 +4226,7 @@ rrc_eNB_decode_ccch(
                 ue_context_p->ue_context.random_ue_identity);
 #endif
           if (stmsi_received == 0)
-	    eNB_rrc_inst[ctxt_pP->module_id].Nb_ue++;
+	    RC.rrc[ctxt_pP->module_id]->Nb_ue++;
 
         } else {
           // no context available
@@ -4472,7 +4412,7 @@ rrc_eNB_decode_dcch(
   }
 
   ue_context_p = rrc_eNB_get_ue_context(
-                   &eNB_rrc_inst[ctxt_pP->module_id],
+                   RC.rrc[ctxt_pP->module_id],
                    ctxt_pP->rnti);
 
   if (ul_dcch_msg->message.present == UL_DCCH_MessageType_PR_c1) {
@@ -4819,7 +4759,7 @@ rrc_eNB_decode_dcch(
 
       rrc_eNB_generate_defaultRRCConnectionReconfiguration(ctxt_pP,
           ue_context_p,
-          eNB_rrc_inst[ctxt_pP->module_id].HO_flag);
+          RC.rrc[ctxt_pP->module_id]->HO_flag);
       break;
 
     case UL_DCCH_MessageType__c1_PR_ulHandoverPreparationTransfer:
@@ -5004,7 +4944,7 @@ rrc_enb_task(
             msg_name_p);
 
       CC_id = RRC_MAC_CCCH_DATA_IND(msg_p).CC_id;
-      srb_info_p = &eNB_rrc_inst[instance].carrier[CC_id].Srb0;
+      srb_info_p = &RC.rrc[instance]->carrier[CC_id].Srb0;
 
       memcpy(srb_info_p->Rx_buffer.Payload,
              RRC_MAC_CCCH_DATA_IND(msg_p).sdu,
@@ -5081,30 +5021,6 @@ rrc_enb_task(
       openair_rrc_eNB_configuration(ENB_INSTANCE_TO_MODULE_ID(instance), &RRC_CONFIGURATION_REQ(msg_p));
       break;
 
-#   if ENABLE_RAL
-
-    case RRC_RAL_CONFIGURE_THRESHOLD_REQ:
-      rrc_enb_ral_handle_configure_threshold_request(instance, msg_p);
-      break;
-
-      //SPECTRA: Add the RRC connection reconfiguration with Second cell configuration
-    case RRC_RAL_CONNECTION_RECONFIGURATION_REQ:
-      //                 ue_mod_id = 0; /* TODO force ue_mod_id to first UE, NAS UE not virtualized yet */
-//#warning "TODO GET RIGHT RNTI"
-      PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt,
-                                    instance,
-                                    ENB_FLAG_YES,
-                                    NOT_A_RNTI, // TO DO GET RIGHT RNTI
-                                    msg_p->ittiMsgHeader.lte_time.frame,
-                                    msg_p->ittiMsgHeader.lte_time.slot);
-      LOG_I(RRC, "[eNB %d] Send RRC_RAL_CONNECTION_RECONFIGURATION_REQ to UE %s\n", instance, msg_name_p);
-      //Method RRC connection reconfiguration command with Second cell configuration
-      //rrc_eNB_generate_RRCConnectionReconfiguration_SCell(instance, 0/* TODO put frameP number ! */, /*ue_mod_id force ue_mod_id to first UE*/0, 36126);
-      //rrc_eNB_generate_defaultRRCConnectionReconfiguration(instance, 0/* TODO put frameP number ! */, /*ue_mod_id force ue_mod_id to first UE*/0,
-      //                                                     eNB_rrc_inst[instance].HO_flag);
-      break;
-#   endif
-
     default:
       LOG_E(RRC, "[eNB %d] Received unexpected message %s\n", instance, msg_name_p);
       break;
@@ -5117,6 +5033,60 @@ rrc_enb_task(
 }
 #endif
 
-#ifndef USER_MODE
-EXPORT_SYMBOL(Rlc_info_am_config);
+/*------------------------------------------------------------------------------*/
+void
+openair_rrc_top_init_eNB(int eMBMS_active,uint8_t HO_active)
+//-----------------------------------------------------------------------------
+{
+
+  module_id_t         module_id;
+  int                 CC_id;
+
+  /* for no gcc warnings */
+  (void)CC_id;
+
+  LOG_D(RRC, "[OPENAIR][INIT] Init function start: NB_eNB_INST=%d\n", RC.nb_inst);
+
+  if (RC.nb_inst > 0) {
+    LOG_I(RRC,"[eNB] handover active state is %d \n", HO_active);
+
+    for (module_id=0; module_id<NB_eNB_INST; module_id++) {
+      RC.rrc[module_id]->HO_flag   = (uint8_t)HO_active;
+    }
+
+#ifdef Rel10
+    LOG_I(RRC,"[eNB] eMBMS active state is %d \n", eMBMS_active);
+
+    for (module_id=0; module_id<NB_eNB_INST; module_id++) {
+      for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
+        RC.rrc[module_id]->carrier[CC_id].MBMS_flag = (uint8_t)eMBMS_active;
+      }
+    }
+
+#endif
+#ifdef CBA
+
+    for (module_id=0; module_id<RC.nb_inst; module_id++) {
+      for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
+        RC.rrc[module_id]->carrier[CC_id].num_active_cba_groups = cba_group_active;
+      }
+    }
+
 #endif
+  } 
+
+
+}
+
+//-----------------------------------------------------------------------------
+void
+rrc_top_cleanup_eNB(
+  void
+)
+//-----------------------------------------------------------------------------
+{
+
+  for (int i=0;i<RC.nb_inst;i++) free (RC.rrc[i]);
+  free(RC.rrc);
+}
+
diff --git a/openair2/RRC/LITE/rrc_eNB_GTPV1U.c b/openair2/RRC/LITE/rrc_eNB_GTPV1U.c
index 8b1110475f..568af04fc7 100644
--- a/openair2/RRC/LITE/rrc_eNB_GTPV1U.c
+++ b/openair2/RRC/LITE/rrc_eNB_GTPV1U.c
@@ -40,6 +40,10 @@
 #   include "intertask_interface.h"
 # endif
 
+# include "common/ran_context.h"
+
+extern RAN_CONTEXT_t RC;
+
 int
 rrc_eNB_process_GTPV1U_CREATE_TUNNEL_RESP(
   const protocol_ctxt_t* const ctxt_pP,
@@ -57,7 +61,7 @@ rrc_eNB_process_GTPV1U_CREATE_TUNNEL_RESP(
 
     rnti = create_tunnel_resp_pP->rnti;
     ue_context_p = rrc_eNB_get_ue_context(
-                     &eNB_rrc_inst[ctxt_pP->module_id],
+                     RC.rrc[ctxt_pP->module_id],
                      ctxt_pP->rnti);
 
     for (i = 0; i < create_tunnel_resp_pP->num_tunnels; i++) {
diff --git a/openair2/RRC/LITE/rrc_eNB_S1AP.c b/openair2/RRC/LITE/rrc_eNB_S1AP.c
index 8984eb933c..4fb2390350 100644
--- a/openair2/RRC/LITE/rrc_eNB_S1AP.c
+++ b/openair2/RRC/LITE/rrc_eNB_S1AP.c
@@ -37,6 +37,7 @@
 # include "rrc_eNB_UE_context.h"
 # include "rrc_eNB_S1AP.h"
 # include "enb_config.h"
+# include "common/ran_context.h"
 
 # if defined(ENABLE_ITTI)
 #   include "asn1_conversions.h"
@@ -58,6 +59,8 @@
 #include "gtpv1u_eNB_task.h"
 #include "RRC/LITE/rrc_eNB_GTPV1U.h"
 
+extern RAN_CONTEXT_t RC;
+
 /* Value to indicate an invalid UE initial id */
 static const uint16_t UE_INITIAL_ID_INVALID = 0;
 
@@ -116,7 +119,7 @@ rrc_eNB_S1AP_get_ue_ids(
 		    		               result2);
             if (h_rc != HASH_TABLE_OK) {
               LOG_E(S1AP, "[eNB %ld] Error while hashtable_insert in s1ap_id2_s1ap_ids eNB_ue_s1ap_id %"PRIu32"\n",
-		    		  rrc_instance_pP - eNB_rrc_inst, eNB_ue_s1ap_id);
+		    		  rrc_instance_pP - RC.rrc[0], eNB_ue_s1ap_id);
             }
 		  }
 		}
@@ -209,14 +212,14 @@ rrc_eNB_get_ue_context_from_s1ap_ids(
   rrc_ue_s1ap_ids_t* temp = NULL;
   temp =
     rrc_eNB_S1AP_get_ue_ids(
-      &eNB_rrc_inst[ENB_INSTANCE_TO_MODULE_ID(instanceP)],
+      RC.rrc[ENB_INSTANCE_TO_MODULE_ID(instanceP)],
       ue_initial_idP,
       eNB_ue_s1ap_idP);
 
   if (temp) {
 
     return rrc_eNB_get_ue_context(
-             &eNB_rrc_inst[ENB_INSTANCE_TO_MODULE_ID(instanceP)],
+             RC.rrc[ENB_INSTANCE_TO_MODULE_ID(instanceP)],
              temp->ue_rnti);
   }
 
@@ -627,7 +630,10 @@ rrc_eNB_send_S1AP_NAS_FIRST_REQ(
   RRCConnectionSetupComplete_r8_IEs_t* rrcConnectionSetupComplete
 )
 //------------------------------------------------------------------------------
+
+
 {
+  eNB_RRC_INST *rrc=RC.rrc[ctxt_pP->module_id];
 #if defined(ENABLE_ITTI)
   {
     MessageDef*         message_p         = NULL;
@@ -645,7 +651,7 @@ rrc_eNB_send_S1AP_NAS_FIRST_REQ(
     rrc_ue_s1ap_ids_p->eNB_ue_s1ap_id = UE_INITIAL_ID_INVALID;
     rrc_ue_s1ap_ids_p->ue_rnti        = ctxt_pP->rnti;
 
-    h_rc = hashtable_insert(eNB_rrc_inst[ctxt_pP->module_id].initial_id2_s1ap_ids,
+    h_rc = hashtable_insert(RC.rrc[ctxt_pP->module_id]->initial_id2_s1ap_ids,
     		               (hash_key_t)ue_context_pP->ue_context.ue_initial_id,
     		               rrc_ue_s1ap_ids_p);
     if (h_rc != HASH_TABLE_OK) {
@@ -708,13 +714,13 @@ rrc_eNB_send_S1AP_NAS_FIRST_REQ(
                   ue_context_pP->ue_context.rnti);
           }
         } else {
-          const Enb_properties_array_t   *enb_properties_p  = NULL;
-          enb_properties_p = enb_config_get();
+	  //          const Enb_properties_array_t   *enb_properties_p  = NULL;
+	  //          enb_properties_p = enb_config_get();
 
           // actually the eNB configuration contains only one PLMN (can be up to 6)
-          S1AP_NAS_FIRST_REQ (message_p).ue_identity.gummei.mcc = enb_properties_p->properties[ctxt_pP->module_id]->mcc;
-          S1AP_NAS_FIRST_REQ (message_p).ue_identity.gummei.mnc = enb_properties_p->properties[ctxt_pP->module_id]->mnc;
-          S1AP_NAS_FIRST_REQ (message_p).ue_identity.gummei.mnc_len = enb_properties_p->properties[ctxt_pP->module_id]->mnc_digit_length;
+          S1AP_NAS_FIRST_REQ (message_p).ue_identity.gummei.mcc = rrc->mcc;
+          S1AP_NAS_FIRST_REQ (message_p).ue_identity.gummei.mnc = rrc->mnc;
+          S1AP_NAS_FIRST_REQ (message_p).ue_identity.gummei.mnc_len = rrc->mnc_digit_length;
         }
 
         S1AP_NAS_FIRST_REQ (message_p).ue_identity.gummei.mme_code     = BIT_STRING_to_uint8 (&r_mme->mmec);
@@ -1172,13 +1178,13 @@ int rrc_eNB_process_S1AP_UE_CONTEXT_RELEASE_COMMAND (MessageDef *msg_p, const ch
     itti_send_msg_to_task(TASK_S1AP, instance, msg_complete_p);
 
     rrc_ue_s1ap_ids = rrc_eNB_S1AP_get_ue_ids(
-    		&eNB_rrc_inst[instance],
+    		RC.rrc[instance],
     		UE_INITIAL_ID_INVALID,
     		eNB_ue_s1ap_id);
 
     if (NULL != rrc_ue_s1ap_ids) {
       rrc_eNB_S1AP_remove_ue_ids(
-    		  &eNB_rrc_inst[instance],
+    		  RC.rrc[instance],
     		  rrc_ue_s1ap_ids);
     }
     return (-1);
@@ -1236,13 +1242,13 @@ int rrc_eNB_process_S1AP_UE_CONTEXT_RELEASE_COMMAND (MessageDef *msg_p, const ch
       itti_send_msg_to_task(TASK_S1AP, instance, msg_complete_p);
 
       rrc_ue_s1ap_ids = rrc_eNB_S1AP_get_ue_ids(
-      		&eNB_rrc_inst[instance],
+      		RC.rrc[instance],
       		UE_INITIAL_ID_INVALID,
       		eNB_ue_s1ap_id);
 
       if (NULL != rrc_ue_s1ap_ids) {
         rrc_eNB_S1AP_remove_ue_ids(
-      		  &eNB_rrc_inst[instance],
+      		  RC.rrc[instance],
       		  rrc_ue_s1ap_ids);
       }
     }
diff --git a/openair2/RRC/LITE/vars.h b/openair2/RRC/LITE/vars.h
index 5431504738..09382b3de1 100644
--- a/openair2/RRC/LITE/vars.h
+++ b/openair2/RRC/LITE/vars.h
@@ -36,31 +36,8 @@
 #include "COMMON/mac_rrc_primitives.h"
 #include "LAYER2/MAC/defs.h"
 
-eNB_RRC_INST *eNB_rrc_inst;
 UE_RRC_INST *UE_rrc_inst;
-//RRC_XFACE *Rrc_xface;
-#ifndef USER_MODE
-//MAC_RLC_XFACE *Mac_rlc_xface;
-#ifndef NO_RRM
-int S_rrc= RRC2RRM_FIFO;
-#endif //NO_RRM
-//int R_rrc= RRM2RRC_FIFO;
-#else
 #include "LAYER2/MAC/extern.h"
-#ifndef NO_RRM
-sock_rrm_t S_rrc;
-#endif
-#endif
-
-#ifndef NO_RRM
-#ifndef USER_MODE
-char *Header_buf;
-char *Data;
-unsigned short Header_read_idx,Data_read_idx,Header_size;
-#endif
-unsigned short Data_to_read;
-#endif //NO_RRM
-
 #define MAX_U32 0xFFFFFFFF
 
 uint8_t DRB2LCHAN[8];
diff --git a/openair2/UTIL/MEM/mem_block.c b/openair2/UTIL/MEM/mem_block.c
index 150f19b71c..606bc7f30f 100644
--- a/openair2/UTIL/MEM/mem_block.c
+++ b/openair2/UTIL/MEM/mem_block.c
@@ -178,7 +178,7 @@ free_mem_block (mem_block_t * leP, const char* caller)
   //-----------------------------------------------------------------------------
 
   if (!(leP)) {
-    msg ("[MEM_MNGT][FREE] WARNING FREE NULL MEM_BLOCK\n");
+    LOG_W (RLC,"[MEM_MNGT][FREE] WARNING FREE NULL MEM_BLOCK\n");
     return;
   }
 
@@ -187,7 +187,7 @@ free_mem_block (mem_block_t * leP, const char* caller)
 #endif
 
 #ifdef DEBUG_MEM_MNGT_FREE
-  msg ("[MEM_MNGT][FREE] free_mem_block() %p pool: %d\n", leP, leP->pool_id);
+  LOG_D (RLC,"[MEM_MNGT][FREE] free_mem_block() %p pool: %d\n", leP, leP->pool_id);
 #endif
 #ifdef DEBUG_MEM_MNGT_ALLOC
   check_free_mem_block (leP);
@@ -197,7 +197,7 @@ free_mem_block (mem_block_t * leP, const char* caller)
     list_add_tail_eurecom (leP, &mem_block_var.mem_lists[leP->pool_id]);
 #ifdef DEBUG_MEM_MNGT_ALLOC
     counters[leP->pool_id] -= 1;
-    msg ("[%s][MEM_MNGT][INFO] after pool[%2d] freed: counters = {%2d %2d %2d %2d %2d %2d %2d %2d %2d %2d %2d %2d}\n",
+    LGO_D (RLC,"[%s][MEM_MNGT][INFO] after pool[%2d] freed: counters = {%2d %2d %2d %2d %2d %2d %2d %2d %2d %2d %2d %2d}\n",
         caller, leP->pool_id,
         counters[0],counters[1],counters[2],counters[3],counters[4],
         counters[5],counters[6],counters[7],counters[8],counters[9],
@@ -205,7 +205,7 @@ free_mem_block (mem_block_t * leP, const char* caller)
 #endif
     leP = NULL;                 // this prevent from freeing the block twice
   } else {
-    msg ("[MEM_MNGT][FREE] ERROR free_mem_block() unknown pool_id : %d\n", leP->pool_id);
+    LOG_E (RLC,"[MEM_MNGT][FREE] ERROR free_mem_block() unknown pool_id : %d\n", leP->pool_id);
   }
 
 #ifdef MEMBLOCK_BIG_LOCK
@@ -223,7 +223,7 @@ get_free_mem_block (uint32_t sizeP, const char* caller)
   int             size;
 
   if (sizeP > MEM_MNGT_MB12_BLOCK_SIZE) {
-    msg ("[MEM_MNGT][ERROR][FATAL] size requested %d out of bounds\n", sizeP);
+    LOG_E (RLC,"[MEM_MNGT][ERROR][FATAL] size requested %d out of bounds\n", sizeP);
     display_mem_load ();
     mac_xface->macphy_exit("[MEM_MNGT][ERROR][FATAL] get_free_mem_block size requested out of bounds");
     return NULL;
@@ -247,7 +247,7 @@ get_free_mem_block (uint32_t sizeP, const char* caller)
     if ((le = list_remove_head (&mem_block_var.mem_lists[pool_selected]))) {
 #ifdef DEBUG_MEM_MNGT_ALLOC
       counters[pool_selected] += 1;
-      msg ("[%s][MEM_MNGT][INFO] after pool[%2d] allocated: counters = {%2d %2d %2d %2d %2d %2d %2d %2d %2d %2d %2d %2d}\n",
+      LOG_D (RLC,"[%s][MEM_MNGT][INFO] after pool[%2d] allocated: counters = {%2d %2d %2d %2d %2d %2d %2d %2d %2d %2d %2d %2d}\n",
           caller,
           pool_selected,
           counters[0],counters[1],counters[2],counters[3],counters[4],
@@ -255,7 +255,7 @@ get_free_mem_block (uint32_t sizeP, const char* caller)
           counters[10],counters[11]);
 #endif
 #ifdef DEBUG_MEM_MNGT_ALLOC_SIZE
-      msg ("[MEM_MNGT][INFO] ALLOC MEM_BLOCK SIZE %d bytes pool %d (%p)\n", sizeP, pool_selected,le);
+      LOG_D (RLC,"[MEM_MNGT][INFO] ALLOC MEM_BLOCK SIZE %d bytes pool %d (%p)\n", sizeP, pool_selected,le);
 #endif
 
       AssertFatal(le->pool_id == pool_selected, "Unexpected pool ID!");
@@ -268,7 +268,7 @@ get_free_mem_block (uint32_t sizeP, const char* caller)
     }
 
 #ifdef DEBUG_MEM_MNGT_ALLOC
-    msg ("[MEM_MNGT][ERROR][MINOR] memory pool %d is empty trying next pool alloc count = %d\n", pool_selected, counters[pool_selected]);
+    LOG_E (RLC,"[MEM_MNGT][ERROR][MINOR] memory pool %d is empty trying next pool alloc count = %d\n", pool_selected, counters[pool_selected]);
 #ifdef USER_MODE
     //    display_mem_load ();
     //    check_mem_area ((void *)&mem_block_var);
@@ -300,18 +300,18 @@ get_free_copy_mem_block (void)
 
   if ((le = list_remove_head (&mem_block_var.mem_lists[MEM_MNGT_POOL_ID_COPY]))) {
 #ifdef DEBUG_MEM_MNGT_ALLOC_SIZE
-    msg ("[MEM_MNGT][INFO] ALLOC COPY MEM BLOCK (%p)\n",le);
+    LOG_D (RLC,"[MEM_MNGT][INFO] ALLOC COPY MEM BLOCK (%p)\n",le);
 #endif
 #ifdef DEBUG_MEM_MNGT_ALLOC
       counters[MEM_MNGT_POOL_ID_COPY] += 1;
-      msg ("[MEM_MNGT][INFO] pool counters = {%2d %2d %2d %2d %2d %2d %2d %2d %2d %2d %2d %2d}\n",
+      LOG_D (RLC,"[MEM_MNGT][INFO] pool counters = {%2d %2d %2d %2d %2d %2d %2d %2d %2d %2d %2d %2d}\n",
           counters[0],counters[1],counters[2],counters[3],counters[4],
           counters[5],counters[6],counters[7],counters[8],counters[9],
           counters[10],counters[11]);
 #endif
     return le;
   } else {
-    msg ("[MEM_MNGT][ERROR] POOL COPY IS EMPTY\n");
+    LOG_E (RLC,"[MEM_MNGT][ERROR] POOL COPY IS EMPTY\n");
     //#ifdef DEBUG_MEM_MNGT_ALLOC
     check_mem_area ();
     //    break_point ();
@@ -335,7 +335,7 @@ copy_mem_block (mem_block_t * leP, mem_block_t * destP)
   if ((destP != NULL) && (leP != NULL) && (destP->pool_id == MEM_MNGT_POOL_ID_COPY)) {
     destP->data = leP->data;
   } else {
-    msg ("[MEM_MNGT][COPY] copy_mem_block() pool dest src or dest is NULL\n");
+    LOG_E (RLC,"[MEM_MNGT][COPY] copy_mem_block() pool dest src or dest is NULL\n");
   }
 
   return destP;
@@ -352,33 +352,33 @@ display_mem_load (void)
 
   mem_pool       *memory = (mem_pool *) &mem_block_var;
 
-  msg ("POOL 0 (%d elements of %d Bytes): ", MEM_MNGT_MB0_NB_BLOCKS, MEM_MNGT_MB0_BLOCK_SIZE);
+  LOG_D (RLC,"POOL 0 (%d elements of %d Bytes): ", MEM_MNGT_MB0_NB_BLOCKS, MEM_MNGT_MB0_BLOCK_SIZE);
   list_display (&memory->mem_lists[MEM_MNGT_POOL_ID0]);
-  msg ("POOL 1 (%d elements of %d Bytes): ", MEM_MNGT_MB1_NB_BLOCKS, MEM_MNGT_MB1_BLOCK_SIZE);
+  LOG_D (RLC,"POOL 1 (%d elements of %d Bytes): ", MEM_MNGT_MB1_NB_BLOCKS, MEM_MNGT_MB1_BLOCK_SIZE);
   list_display (&memory->mem_lists[MEM_MNGT_POOL_ID1]);
-  msg ("POOL 2 (%d elements of %d Bytes): ", MEM_MNGT_MB2_NB_BLOCKS, MEM_MNGT_MB2_BLOCK_SIZE);
+  LOG_D (RLC,"POOL 2 (%d elements of %d Bytes): ", MEM_MNGT_MB2_NB_BLOCKS, MEM_MNGT_MB2_BLOCK_SIZE);
   list_display (&memory->mem_lists[MEM_MNGT_POOL_ID2]);
-  msg ("POOL 3 (%d elements of %d Bytes): ", MEM_MNGT_MB3_NB_BLOCKS, MEM_MNGT_MB3_BLOCK_SIZE);
+  LOG_D (RLC,"POOL 3 (%d elements of %d Bytes): ", MEM_MNGT_MB3_NB_BLOCKS, MEM_MNGT_MB3_BLOCK_SIZE);
   list_display (&memory->mem_lists[MEM_MNGT_POOL_ID3]);
-  msg ("POOL 4 (%d elements of %d Bytes): ", MEM_MNGT_MB4_NB_BLOCKS, MEM_MNGT_MB4_BLOCK_SIZE);
+  LOG_D (RLC,"POOL 4 (%d elements of %d Bytes): ", MEM_MNGT_MB4_NB_BLOCKS, MEM_MNGT_MB4_BLOCK_SIZE);
   list_display (&memory->mem_lists[MEM_MNGT_POOL_ID4]);
-  msg ("POOL 5 (%d elements of %d Bytes): ", MEM_MNGT_MB5_NB_BLOCKS, MEM_MNGT_MB5_BLOCK_SIZE);
+  LOG_D (RLC,"POOL 5 (%d elements of %d Bytes): ", MEM_MNGT_MB5_NB_BLOCKS, MEM_MNGT_MB5_BLOCK_SIZE);
   list_display (&memory->mem_lists[MEM_MNGT_POOL_ID5]);
-  msg ("POOL 6 (%d elements of %d Bytes): ", MEM_MNGT_MB6_NB_BLOCKS, MEM_MNGT_MB6_BLOCK_SIZE);
+  LOG_D (RLC,"POOL 6 (%d elements of %d Bytes): ", MEM_MNGT_MB6_NB_BLOCKS, MEM_MNGT_MB6_BLOCK_SIZE);
   list_display (&memory->mem_lists[MEM_MNGT_POOL_ID6]);
-  msg ("POOL 7 (%d elements of %d Bytes): ", MEM_MNGT_MB7_NB_BLOCKS, MEM_MNGT_MB7_BLOCK_SIZE);
+  LOG_D (RLC,"POOL 7 (%d elements of %d Bytes): ", MEM_MNGT_MB7_NB_BLOCKS, MEM_MNGT_MB7_BLOCK_SIZE);
   list_display (&memory->mem_lists[MEM_MNGT_POOL_ID7]);
-  msg ("POOL 8 (%d elements of %d Bytes): ", MEM_MNGT_MB8_NB_BLOCKS, MEM_MNGT_MB8_BLOCK_SIZE);
+  LOG_D (RLC,"POOL 8 (%d elements of %d Bytes): ", MEM_MNGT_MB8_NB_BLOCKS, MEM_MNGT_MB8_BLOCK_SIZE);
   list_display (&memory->mem_lists[MEM_MNGT_POOL_ID8]);
-  msg ("POOL 9 (%d elements of %d Bytes): ", MEM_MNGT_MB9_NB_BLOCKS, MEM_MNGT_MB9_BLOCK_SIZE);
+  LOG_D (RLC,"POOL 9 (%d elements of %d Bytes): ", MEM_MNGT_MB9_NB_BLOCKS, MEM_MNGT_MB9_BLOCK_SIZE);
   list_display (&memory->mem_lists[MEM_MNGT_POOL_ID9]);
-  msg ("POOL 10 (%d elements of %d Bytes): ", MEM_MNGT_MB10_NB_BLOCKS, MEM_MNGT_MB10_BLOCK_SIZE);
+  LOG_D (RLC,"POOL 10 (%d elements of %d Bytes): ", MEM_MNGT_MB10_NB_BLOCKS, MEM_MNGT_MB10_BLOCK_SIZE);
   list_display (&memory->mem_lists[MEM_MNGT_POOL_ID10]);
-  msg ("POOL 11 (%d elements of %d Bytes): ", MEM_MNGT_MB11_NB_BLOCKS, MEM_MNGT_MB11_BLOCK_SIZE);
+  LOG_D (RLC,"POOL 11 (%d elements of %d Bytes): ", MEM_MNGT_MB11_NB_BLOCKS, MEM_MNGT_MB11_BLOCK_SIZE);
   list_display (&memory->mem_lists[MEM_MNGT_POOL_ID11]);
-  msg ("POOL 12 (%d elements of %d Bytes): ", MEM_MNGT_MB12_NB_BLOCKS, MEM_MNGT_MB12_BLOCK_SIZE);
+  LOG_D (RLC,"POOL 12 (%d elements of %d Bytes): ", MEM_MNGT_MB12_NB_BLOCKS, MEM_MNGT_MB12_BLOCK_SIZE);
   list_display (&memory->mem_lists[MEM_MNGT_POOL_ID12]);
-  msg ("POOL C (%d elements): ", MEM_MNGT_MBCOPY_NB_BLOCKS);
+  LOG_D (RLC,"POOL C (%d elements): ", MEM_MNGT_MBCOPY_NB_BLOCKS);
   list_display (&memory->mem_lists[MEM_MNGT_POOL_ID_COPY]);
 }
 
@@ -396,7 +396,7 @@ check_mem_area (void)
 
   for (index = 0; index < MEM_MNGT_MB0_NB_BLOCKS; index++) {
     if ((memory->mem_blocks[index].data != (unsigned char*)&(memory->mem_pool0[index][0])) && (memory->mem_blocks[index].pool_id != MEM_MNGT_POOL_ID0)) {
-      msg ("[MEM] ERROR POOL0 block index %d\n", index);
+      LOG_D (RLC,"[MEM] ERROR POOL0 block index %d\n", index);
     }
   }
 
@@ -405,7 +405,7 @@ check_mem_area (void)
   for (index = 0; index < MEM_MNGT_MB1_NB_BLOCKS; index++) {
     if ((memory->mem_blocks[mb_index + index].data != (unsigned char*)&(memory->mem_pool1[index][0]))
         && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID1)) {
-      msg ("[MEM] ERROR POOL1 block index %d\n", index);
+      LOG_D (RLC,"[MEM] ERROR POOL1 block index %d\n", index);
     }
   }
 
@@ -414,7 +414,7 @@ check_mem_area (void)
   for (index = 0; index < MEM_MNGT_MB2_NB_BLOCKS; index++) {
     if ((memory->mem_blocks[mb_index + index].data != (unsigned char*)&(memory->mem_pool2[index][0]))
         && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID2)) {
-      msg ("[MEM] ERROR POOL2 block index %d\n", index);
+      LOG_D (RLC,"[MEM] ERROR POOL2 block index %d\n", index);
     }
   }
 
@@ -423,7 +423,7 @@ check_mem_area (void)
   for (index = 0; index < MEM_MNGT_MB3_NB_BLOCKS; index++) {
     if ((memory->mem_blocks[mb_index + index].data != (unsigned char*)&(memory->mem_pool3[index][0]))
         && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID3)) {
-      msg ("[MEM] ERROR POOL3 block index %d\n", index);
+      LOG_D (RLC,"[MEM] ERROR POOL3 block index %d\n", index);
     }
   }
 
@@ -432,7 +432,7 @@ check_mem_area (void)
   for (index = 0; index < MEM_MNGT_MB4_NB_BLOCKS; index++) {
     if ((memory->mem_blocks[mb_index + index].data != (unsigned char*)&(memory->mem_pool4[index][0]))
         && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID4)) {
-      msg ("[MEM] ERROR POOL4 block index %d\n", index);
+      LOG_D (RLC,"[MEM] ERROR POOL4 block index %d\n", index);
     }
   }
 
@@ -441,7 +441,7 @@ check_mem_area (void)
   for (index = 0; index < MEM_MNGT_MB5_NB_BLOCKS; index++) {
     if ((memory->mem_blocks[mb_index + index].data != (unsigned char*)&(memory->mem_pool5[index][0]))
         && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID5)) {
-      msg ("[MEM] ERROR POOL5 block index %d\n", index);
+      LOG_D (RLC,"[MEM] ERROR POOL5 block index %d\n", index);
     }
   }
 
@@ -450,7 +450,7 @@ check_mem_area (void)
   for (index = 0; index < MEM_MNGT_MB6_NB_BLOCKS; index++) {
     if ((memory->mem_blocks[mb_index + index].data != (unsigned char*)&(memory->mem_pool6[index][0]))
         && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID6)) {
-      msg ("[MEM] ERROR POOL6 block index %d\n", index);
+      LOG_D (RLC,"[MEM] ERROR POOL6 block index %d\n", index);
     }
   }
 
@@ -459,7 +459,7 @@ check_mem_area (void)
   for (index = 0; index < MEM_MNGT_MB7_NB_BLOCKS; index++) {
     if ((memory->mem_blocks[mb_index + index].data != (unsigned char*)&(memory->mem_pool7[index][0]))
         && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID7)) {
-      msg ("[MEM] ERROR POOL7 block index %d\n", index);
+      LOG_D (RLC,"[MEM] ERROR POOL7 block index %d\n", index);
     }
   }
 
@@ -468,7 +468,7 @@ check_mem_area (void)
   for (index = 0; index < MEM_MNGT_MB8_NB_BLOCKS; index++) {
     if ((memory->mem_blocks[mb_index + index].data != (unsigned char*)&(memory->mem_pool8[index][0]))
         && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID8)) {
-      msg ("[MEM] ERROR POOL8 block index %d\n", index);
+      LOG_D (RLC,"[MEM] ERROR POOL8 block index %d\n", index);
     }
   }
 
@@ -477,7 +477,7 @@ check_mem_area (void)
   for (index = 0; index < MEM_MNGT_MB9_NB_BLOCKS; index++) {
     if ((memory->mem_blocks[mb_index + index].data != (unsigned char*)&(memory->mem_pool9[index][0]))
         && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID9)) {
-      msg ("[MEM] ERROR POOL9 block index %d\n", index);
+      LOG_D (RLC,"[MEM] ERROR POOL9 block index %d\n", index);
     }
   }
 
@@ -486,7 +486,7 @@ check_mem_area (void)
   for (index = mb_index; index < MEM_MNGT_MB10_NB_BLOCKS; index++) {
     if ((memory->mem_blocks[mb_index + index].data != (unsigned char*)&(memory->mem_pool10[index][0]))
         && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID10)) {
-      msg ("[MEM] ERROR POOL10 block index %d\n", index);
+      LOG_D (RLC,"[MEM] ERROR POOL10 block index %d\n", index);
     }
   }
 
@@ -495,7 +495,7 @@ check_mem_area (void)
   for (index = mb_index; index < MEM_MNGT_MB11_NB_BLOCKS; index++) {
     if ((memory->mem_blocks[mb_index + index].data != (unsigned char*)&(memory->mem_pool11[index][0]))
         && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID11)) {
-      msg ("[MEM] ERROR POOL11 block index %d\n", index);
+      LOG_D (RLC,"[MEM] ERROR POOL11 block index %d\n", index);
     }
   }
 
@@ -504,7 +504,7 @@ check_mem_area (void)
   for (index = mb_index; index < MEM_MNGT_MB12_NB_BLOCKS; index++) {
     if ((memory->mem_blocks[mb_index + index].data != (unsigned char*)&(memory->mem_pool12[index][0]))
         && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID12)) {
-      msg ("[MEM] ERROR POOL12 block index %d\n", index);
+      LOG_D (RLC,"[MEM] ERROR POOL12 block index %d\n", index);
     }
   }
 
@@ -512,7 +512,7 @@ check_mem_area (void)
 
   for (index = mb_index; index < MEM_MNGT_NB_ELEMENTS; index++) {
     if ((memory->mem_blocks[index].data != NULL) && (memory->mem_blocks[index].pool_id != MEM_MNGT_POOL_ID_COPY)) {
-      msg ("[MEM] ERROR POOL COPY block index %d\n", index);
+      LOG_D (RLC,"[MEM] ERROR POOL COPY block index %d\n", index);
     }
   }
 }
@@ -535,7 +535,7 @@ check_free_mem_block (mem_block_t * leP)
 
     if (block_index < MEM_MNGT_MB0_NB_BLOCKS) {
       if ((leP->data != (unsigned char*)mem_block_var.mem_pool0[block_index]) && (leP->pool_id != MEM_MNGT_POOL_ID0)) {
-        msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n");
+        LOG_D (RLC,"[MEM][ERROR][FATAL] free mem block is corrupted\n");
       }
 
       return;
@@ -545,7 +545,7 @@ check_free_mem_block (mem_block_t * leP)
 
     if (block_index < MEM_MNGT_MB1_NB_BLOCKS) {
       if ((leP->data != (unsigned char*)mem_block_var.mem_pool1[block_index]) && (leP->pool_id != MEM_MNGT_POOL_ID1)) {
-        msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n");
+        LOG_D (RLC,"[MEM][ERROR][FATAL] free mem block is corrupted\n");
       }
 
       return;
@@ -555,7 +555,7 @@ check_free_mem_block (mem_block_t * leP)
 
     if (block_index < MEM_MNGT_MB2_NB_BLOCKS) {
       if ((leP->data != (unsigned char*)mem_block_var.mem_pool2[block_index]) && (leP->pool_id != MEM_MNGT_POOL_ID2)) {
-        msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n");
+        LOG_D (RLC,"[MEM][ERROR][FATAL] free mem block is corrupted\n");
       }
 
       return;
@@ -565,7 +565,7 @@ check_free_mem_block (mem_block_t * leP)
 
     if (block_index < MEM_MNGT_MB3_NB_BLOCKS) {
       if ((leP->data != (unsigned char*)mem_block_var.mem_pool3[block_index]) && (leP->pool_id != MEM_MNGT_POOL_ID3)) {
-        msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n");
+        LOG_D (RLC,"[MEM][ERROR][FATAL] free mem block is corrupted\n");
       }
 
       return;
@@ -575,7 +575,7 @@ check_free_mem_block (mem_block_t * leP)
 
     if (block_index < MEM_MNGT_MB4_NB_BLOCKS) {
       if ((leP->data != (unsigned char*)mem_block_var.mem_pool4[block_index]) && (leP->pool_id != MEM_MNGT_POOL_ID4)) {
-        msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n");
+        LOG_D (RLC,"[MEM][ERROR][FATAL] free mem block is corrupted\n");
       }
 
       return;
@@ -585,7 +585,7 @@ check_free_mem_block (mem_block_t * leP)
 
     if (block_index < MEM_MNGT_MB5_NB_BLOCKS) {
       if ((leP->data != (unsigned char*)mem_block_var.mem_pool5[block_index]) && (leP->pool_id != MEM_MNGT_POOL_ID5)) {
-        msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n");
+        LOG_D (RLC,"[MEM][ERROR][FATAL] free mem block is corrupted\n");
       }
 
       return;
@@ -595,7 +595,7 @@ check_free_mem_block (mem_block_t * leP)
 
     if (block_index < MEM_MNGT_MB6_NB_BLOCKS) {
       if ((leP->data != (unsigned char*)mem_block_var.mem_pool6[block_index]) && (leP->pool_id != MEM_MNGT_POOL_ID6)) {
-        msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n");
+        LOG_D (RLC,"[MEM][ERROR][FATAL] free mem block is corrupted\n");
       }
 
       return;
@@ -605,7 +605,7 @@ check_free_mem_block (mem_block_t * leP)
 
     if (block_index < MEM_MNGT_MB7_NB_BLOCKS) {
       if ((leP->data != (unsigned char*)mem_block_var.mem_pool7[block_index]) && (leP->pool_id != MEM_MNGT_POOL_ID7)) {
-        msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n");
+        LOG_D (RLC,"[MEM][ERROR][FATAL] free mem block is corrupted\n");
       }
 
       return;
@@ -615,7 +615,7 @@ check_free_mem_block (mem_block_t * leP)
 
     if (block_index < MEM_MNGT_MB8_NB_BLOCKS) {
       if ((leP->data != (unsigned char*)mem_block_var.mem_pool8[block_index]) && (leP->pool_id != MEM_MNGT_POOL_ID8)) {
-        msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n");
+        LOG_D (RLC,"[MEM][ERROR][FATAL] free mem block is corrupted\n");
       }
 
       return;
@@ -625,7 +625,7 @@ check_free_mem_block (mem_block_t * leP)
 
     if (block_index < MEM_MNGT_MB9_NB_BLOCKS) {
       if ((leP->data != (unsigned char*)mem_block_var.mem_pool9[block_index]) && (leP->pool_id != MEM_MNGT_POOL_ID9)) {
-        msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n");
+        LOG_D (RLC,"[MEM][ERROR][FATAL] free mem block is corrupted\n");
       }
 
       return;
@@ -635,7 +635,7 @@ check_free_mem_block (mem_block_t * leP)
 
     if (block_index < MEM_MNGT_MB10_NB_BLOCKS) {
       if ((leP->data != (unsigned char*)mem_block_var.mem_pool10[block_index]) && (leP->pool_id != MEM_MNGT_POOL_ID10)) {
-        msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n");
+        LOG_D (RLC,"[MEM][ERROR][FATAL] free mem block is corrupted\n");
       }
 
       return;
@@ -645,7 +645,7 @@ check_free_mem_block (mem_block_t * leP)
 
     if (block_index < MEM_MNGT_MB11_NB_BLOCKS) {
       if ((leP->data != (unsigned char*)mem_block_var.mem_pool11[block_index]) && (leP->pool_id != MEM_MNGT_POOL_ID11)) {
-        msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n");
+        LOG_D (RLC,"[MEM][ERROR][FATAL] free mem block is corrupted\n");
       }
 
       return;
@@ -655,13 +655,13 @@ check_free_mem_block (mem_block_t * leP)
 
     if (block_index < MEM_MNGT_MB12_NB_BLOCKS) {
       if ((leP->data != (unsigned char*)mem_block_var.mem_pool12[block_index]) && (leP->pool_id != MEM_MNGT_POOL_ID12)) {
-        msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n");
+        LOG_D (RLC,"[MEM][ERROR][FATAL] free mem block is corrupted\n");
       }
 
       return;
     }
   } else {
-    msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n");
+    LOG_D (RLC,"[MEM][ERROR][FATAL] free mem block is corrupted\n");
   }
 
   // the block is ok
diff --git a/openair2/UTIL/OCG/OCG.h b/openair2/UTIL/OCG/OCG.h
index bd53c179ff..241148b0ab 100644
--- a/openair2/UTIL/OCG/OCG.h
+++ b/openair2/UTIL/OCG/OCG.h
@@ -645,6 +645,8 @@ typedef struct {
   unsigned char nb_ue_remote;
   unsigned char nb_enb_local;
   unsigned char nb_enb_remote;
+  unsigned char nb_ru_local;
+  unsigned char nb_ru_remote;
   unsigned char nb_rn_local;
   unsigned char nb_rn_remote;
   module_id_t   first_enb_local;
@@ -700,8 +702,8 @@ typedef struct {
   // phy related params
   unsigned int n_frames;
   unsigned int n_frames_flag; // if set, then let the emulation goes to infinity
-  eNB_func_t node_function[MAX_NUM_CCs];
-  eNB_timing_t node_timing[MAX_NUM_CCs];
+  node_function_t node_function[MAX_NUM_CCs];
+  node_timing_t node_timing[MAX_NUM_CCs];
   unsigned char frame_type[MAX_NUM_CCs]; //! LTE frame type (TDD=1, FDD=0). \note this should be converted to \ref lte_frame_type_t (header file reorganization needed)
   char * frame_type_name[MAX_NUM_CCs];
   unsigned char tdd_config[MAX_NUM_CCs];
diff --git a/openair3/GTPV1-U/gtpv1u_eNB.c b/openair3/GTPV1-U/gtpv1u_eNB.c
index e273ac0712..b665f12738 100644
--- a/openair3/GTPV1-U/gtpv1u_eNB.c
+++ b/openair3/GTPV1-U/gtpv1u_eNB.c
@@ -48,7 +48,7 @@
 #include "COMMON/platform_types.h"
 #include "COMMON/platform_constants.h"
 #include "UTIL/LOG/vcd_signal_dumper.h"
-
+#include "common/ran_context.h"
 
 #undef GTP_DUMP_SOCKET
 
@@ -63,6 +63,7 @@ extern boolean_t pdcp_data_req(
   const pdcp_transmission_mode_t modeP);
 
 extern unsigned char NB_eNB_INST;
+extern RAN_CONTEXT_t RC;
 
 static int
 gtpv1u_eNB_send_init_udp(
@@ -152,7 +153,7 @@ gtpv1u_eNB_init(void);
 void *
 gtpv1u_eNB_task(void *args);
 
-static gtpv1u_data_t gtpv1u_data_g;
+//static gtpv1u_data_t gtpv1u_data_g;
 
 #if defined(GTP_DUMP_SOCKET) && GTP_DUMP_SOCKET > 0
 #include <linux/if.h>
@@ -221,9 +222,9 @@ static int gtpv1u_eNB_send_init_udp(uint16_t port_number)
   UDP_INIT(message_p).port = port_number;
   //LG UDP_INIT(message_p).address = "0.0.0.0"; //ANY address
 
-  addr.s_addr = gtpv1u_data_g.enb_ip_address_for_S1u_S12_S4_up;
+  addr.s_addr = RC.gtpv1u_data_g->enb_ip_address_for_S1u_S12_S4_up;
   UDP_INIT(message_p).address = inet_ntoa(addr);
-  LOG_D(GTPU, "Tx UDP_INIT IP addr %s\n", UDP_INIT(message_p).address);
+  LOG_I(GTPU, "Tx UDP_INIT IP addr %s (%x)\n", UDP_INIT(message_p).address,RC.gtpv1u_data_g->enb_ip_address_for_S1u_S12_S4_up);
 
   MSC_LOG_EVENT(
 	  MSC_GTPU_ENB,
@@ -314,7 +315,7 @@ NwGtpv1uRcT gtpv1u_eNB_process_stack_req(
     //-----------------------
     // GTPV1U->PDCP mapping
     //-----------------------
-    hash_rc = hashtable_get(gtpv1u_data_g.teid_mapping, teid, (void**)&gtpv1u_teid_data_p);
+    hash_rc = hashtable_get(RC.gtpv1u_data_g->teid_mapping, teid, (void**)&gtpv1u_teid_data_p);
 
     if (hash_rc == HASH_TABLE_OK) {
 #if defined(LOG_GTPU) && LOG_GTPU > 0
@@ -597,7 +598,7 @@ gtpv1u_new_data_req(
   AssertFatal((rab_idP - GTPV1U_BEARER_OFFSET)< GTPV1U_MAX_BEARERS_ID, "Bad parameter rab id %u\n", rab_idP);
   AssertFatal((rab_idP - GTPV1U_BEARER_OFFSET) >= 0 , "Bad parameter rab id %u\n", rab_idP);
 
-  gtpv1u_data_p = &gtpv1u_data_g;
+  gtpv1u_data_p = RC.gtpv1u_data_g;
   /* Check that UE context is present in ue map. */
   hash_rc = hashtable_get(gtpv1u_data_p->ue_mapping, (uint64_t)ue_rntiP, (void**)&ue_inst_p);
 
@@ -716,27 +717,27 @@ gtpv1u_create_s1u_tunnel(
       stack_req.apiInfo.createTunnelEndPointInfo.hUlpSession   = 0;
       stack_req.apiInfo.createTunnelEndPointInfo.hStackSession = 0;
 
-      rc = nwGtpv1uProcessUlpReq(gtpv1u_data_g.gtpv1u_stack, &stack_req);
+      rc = nwGtpv1uProcessUlpReq(RC.gtpv1u_data_g->gtpv1u_stack, &stack_req);
       LOG_D(GTPU, ".\n");
     } while (rc != NW_GTPV1U_OK);
 
     //-----------------------
     // PDCP->GTPV1U mapping
     //-----------------------
-    hash_rc = hashtable_get(gtpv1u_data_g.ue_mapping, create_tunnel_req_pP->rnti, (void **)&gtpv1u_ue_data_p);
+    hash_rc = hashtable_get(RC.gtpv1u_data_g->ue_mapping, create_tunnel_req_pP->rnti, (void **)&gtpv1u_ue_data_p);
 
     if ((hash_rc == HASH_TABLE_KEY_NOT_EXISTS) || (hash_rc == HASH_TABLE_OK)) {
 
       if (hash_rc == HASH_TABLE_KEY_NOT_EXISTS) {
         gtpv1u_ue_data_p = calloc (1, sizeof(gtpv1u_ue_data_t));
-        hash_rc = hashtable_insert(gtpv1u_data_g.ue_mapping, create_tunnel_req_pP->rnti, gtpv1u_ue_data_p);
+        hash_rc = hashtable_insert(RC.gtpv1u_data_g->ue_mapping, create_tunnel_req_pP->rnti, gtpv1u_ue_data_p);
         AssertFatal(hash_rc == HASH_TABLE_OK, "Error inserting ue_mapping in GTPV1U hashtable");
       }
 
       gtpv1u_ue_data_p->ue_id       = create_tunnel_req_pP->rnti;
       gtpv1u_ue_data_p->instance_id = 0; // TO DO
       memcpy(&create_tunnel_resp_pP->enb_addr.buffer,
-             &gtpv1u_data_g.enb_ip_address_for_S1u_S12_S4_up,
+             &RC.gtpv1u_data_g->enb_ip_address_for_S1u_S12_S4_up,
              sizeof (in_addr_t));
       create_tunnel_resp_pP->enb_addr.length = sizeof (in_addr_t);
 
@@ -778,14 +779,14 @@ gtpv1u_create_s1u_tunnel(
     //-----------------------
     // GTPV1U->PDCP mapping
     //-----------------------
-    hash_rc = hashtable_get(gtpv1u_data_g.teid_mapping, s1u_teid, (void**)&gtpv1u_teid_data_p);
+    hash_rc = hashtable_get(RC.gtpv1u_data_g->teid_mapping, s1u_teid, (void**)&gtpv1u_teid_data_p);
 
     if (hash_rc == HASH_TABLE_KEY_NOT_EXISTS) {
       gtpv1u_teid_data_p = calloc (1, sizeof(gtpv1u_teid_data_t));
       gtpv1u_teid_data_p->enb_id        = 0; // TO DO
       gtpv1u_teid_data_p->ue_id         = create_tunnel_req_pP->rnti;
       gtpv1u_teid_data_p->eps_bearer_id = eps_bearer_id;
-      hash_rc = hashtable_insert(gtpv1u_data_g.teid_mapping, s1u_teid, gtpv1u_teid_data_p);
+      hash_rc = hashtable_insert(RC.gtpv1u_data_g->teid_mapping, s1u_teid, gtpv1u_teid_data_p);
       AssertFatal(hash_rc == HASH_TABLE_OK, "Error inserting teid mapping in GTPV1U hashtable");
     } else {
       create_tunnel_resp_pP->enb_S1u_teid[i] = 0;
@@ -827,7 +828,7 @@ static int gtpv1u_delete_s1u_tunnel(
   GTPV1U_ENB_DELETE_TUNNEL_RESP(message_p).status       = 0;
 
 
-  hash_rc = hashtable_get(gtpv1u_data_g.ue_mapping, req_pP->rnti, (void**)&gtpv1u_ue_data_p);
+  hash_rc = hashtable_get(RC.gtpv1u_data_g->ue_mapping, req_pP->rnti, (void**)&gtpv1u_ue_data_p);
 
   if (hash_rc == HASH_TABLE_OK) {
 
@@ -844,7 +845,7 @@ static int gtpv1u_delete_s1u_tunnel(
               teid_eNB);
         stack_req.apiInfo.destroyTunnelEndPointInfo.hStackSessionHandle   = gtpv1u_ue_data_p->bearers[req_pP->eps_bearer_id[erab_index] - GTPV1U_BEARER_OFFSET].teid_eNB_stack_session;
 
-        rc = nwGtpv1uProcessUlpReq(gtpv1u_data_g.gtpv1u_stack, &stack_req);
+        rc = nwGtpv1uProcessUlpReq(RC.gtpv1u_data_g->gtpv1u_stack, &stack_req);
         LOG_D(GTPU, ".\n");
       }
 
@@ -863,14 +864,14 @@ static int gtpv1u_delete_s1u_tunnel(
       gtpv1u_ue_data_p->num_bearers -= 1;
 
       if (gtpv1u_ue_data_p->num_bearers == 0) {
-        hash_rc = hashtable_remove(gtpv1u_data_g.ue_mapping, req_pP->rnti);
+        hash_rc = hashtable_remove(RC.gtpv1u_data_g->ue_mapping, req_pP->rnti);
         LOG_D(GTPU, "Removed user rnti %x,no more bearers configured\n", req_pP->rnti);
       }
 
       //-----------------------
       // GTPV1U->PDCP mapping
       //-----------------------
-      hash_rc = hashtable_remove(gtpv1u_data_g.teid_mapping, teid_eNB);
+      hash_rc = hashtable_remove(RC.gtpv1u_data_g->teid_mapping, teid_eNB);
 
       if (hash_rc != HASH_TABLE_OK) {
         LOG_D(GTPU, "Removed user rnti %x , enb S1U teid %u not found\n", req_pP->rnti, teid_eNB);
@@ -895,6 +896,7 @@ static int gtpv1u_delete_s1u_tunnel(
   return itti_send_msg_to_task(TASK_RRC_ENB, instanceP, message_p);
 }
 
+
 //-----------------------------------------------------------------------------
 static int gtpv1u_eNB_init(void)
 {
@@ -906,32 +908,34 @@ static int gtpv1u_eNB_init(void)
   NwGtpv1uTimerMgrEntityT tmr;
   Enb_properties_t       *enb_properties_p  = NULL;
 
-  enb_properties_p = enb_config_get()->properties[0];
+  //  enb_properties_p = enb_config_get()->properties[0];
+  RC.gtpv1u_data_g = (gtpv1u_data_t*)malloc(sizeof(gtpv1u_data_t));
+  memset(RC.gtpv1u_data_g, 0, sizeof(gtpv1u_data_t));
 
+  RCconfig_gtpu();
 
-  memset(&gtpv1u_data_g, 0, sizeof(gtpv1u_data_g));
 
-  LOG_I(GTPU, "Initializing GTPU stack %p\n",&gtpv1u_data_g);
+  LOG_I(GTPU, "Initializing GTPU stack %p\n",&RC.gtpv1u_data_g);
   //gtpv1u_data_g.gtpv1u_stack;
   /* Initialize UE hashtable */
-  gtpv1u_data_g.ue_mapping      = hashtable_create (32, NULL, NULL);
-  AssertFatal(gtpv1u_data_g.ue_mapping != NULL, " ERROR Initializing TASK_GTPV1_U task interface: in hashtable_create returned %p\n", gtpv1u_data_g.ue_mapping);
-  gtpv1u_data_g.teid_mapping    = hashtable_create (256, NULL, NULL);
-  AssertFatal(gtpv1u_data_g.teid_mapping != NULL, " ERROR Initializing TASK_GTPV1_U task interface: in hashtable_create\n");
-  gtpv1u_data_g.enb_ip_address_for_S1u_S12_S4_up         = enb_properties_p->enb_ipv4_address_for_S1U;
-  gtpv1u_data_g.ip_addr         = NULL;
-  gtpv1u_data_g.enb_port_for_S1u_S12_S4_up = enb_properties_p->enb_port_for_S1U;
+  RC.gtpv1u_data_g->ue_mapping      = hashtable_create (32, NULL, NULL);
+  AssertFatal(RC.gtpv1u_data_g->ue_mapping != NULL, " ERROR Initializing TASK_GTPV1_U task interface: in hashtable_create returned %p\n", RC.gtpv1u_data_g->ue_mapping);
+  RC.gtpv1u_data_g->teid_mapping    = hashtable_create (256, NULL, NULL);
+  AssertFatal(RC.gtpv1u_data_g->teid_mapping != NULL, " ERROR Initializing TASK_GTPV1_U task interface: in hashtable_create\n");
+//  RC.gtpv1u_data_g.enb_ip_address_for_S1u_S12_S4_up         = enb_properties_p->enb_ipv4_address_for_S1U;
+  RC.gtpv1u_data_g->ip_addr         = NULL;
+
   //gtpv1u_data_g.udp_data;
-  gtpv1u_data_g.seq_num         = 0;
-  gtpv1u_data_g.restart_counter = 0;
+  RC.gtpv1u_data_g->seq_num         = 0;
+  RC.gtpv1u_data_g->restart_counter = 0;
 
   /* Initializing GTPv1-U stack */
-  if ((rc = nwGtpv1uInitialize(&gtpv1u_data_g.gtpv1u_stack, GTPU_STACK_ENB)) != NW_GTPV1U_OK) {
+  if ((rc = nwGtpv1uInitialize(&RC.gtpv1u_data_g->gtpv1u_stack, GTPU_STACK_ENB)) != NW_GTPV1U_OK) {
     LOG_E(GTPU, "Failed to setup nwGtpv1u stack %x\n", rc);
     return -1;
   }
 
-  if ((rc = nwGtpv1uSetLogLevel(gtpv1u_data_g.gtpv1u_stack,
+  if ((rc = nwGtpv1uSetLogLevel(RC.gtpv1u_data_g->gtpv1u_stack,
                                 NW_LOG_LEVEL_DEBG)) != NW_GTPV1U_OK) {
     LOG_E(GTPU, "Failed to setup loglevel for stack %x\n", rc);
     return -1;
@@ -943,7 +947,7 @@ static int gtpv1u_eNB_init(void)
    */
   ulp.ulpReqCallback = gtpv1u_eNB_process_stack_req;
 
-  if ((rc = nwGtpv1uSetUlpEntity(gtpv1u_data_g.gtpv1u_stack, &ulp)) != NW_GTPV1U_OK) {
+  if ((rc = nwGtpv1uSetUlpEntity(RC.gtpv1u_data_g->gtpv1u_stack, &ulp)) != NW_GTPV1U_OK) {
     LOG_E(GTPU, "nwGtpv1uSetUlpEntity: %x", rc);
     return -1;
   }
@@ -953,14 +957,14 @@ static int gtpv1u_eNB_init(void)
    */
   udp.udpDataReqCallback = gtpv1u_eNB_send_udp_msg;
 
-  if ((rc = nwGtpv1uSetUdpEntity(gtpv1u_data_g.gtpv1u_stack, &udp)) != NW_GTPV1U_OK) {
+  if ((rc = nwGtpv1uSetUdpEntity(RC.gtpv1u_data_g->gtpv1u_stack, &udp)) != NW_GTPV1U_OK) {
     LOG_E(GTPU, "nwGtpv1uSetUdpEntity: %x", rc);
     return -1;
   }
 
   log.logReqCallback = gtpv1u_eNB_log_request;
 
-  if ((rc = nwGtpv1uSetLogMgrEntity(gtpv1u_data_g.gtpv1u_stack, &log)) != NW_GTPV1U_OK) {
+  if ((rc = nwGtpv1uSetLogMgrEntity(RC.gtpv1u_data_g->gtpv1u_stack, &log)) != NW_GTPV1U_OK) {
     LOG_E(GTPU, "nwGtpv1uSetLogMgrEntity: %x", rc);
     return -1;
   }
@@ -972,7 +976,7 @@ static int gtpv1u_eNB_init(void)
   tmr.tmrStartCallback = gtpv1u_start_timer_wrapper;
   tmr.tmrStopCallback  = gtpv1u_stop_timer_wrapper;
 
-  if ((rc = nwGtpv1uSetTimerMgrEntity(gtpv1u_data_g.gtpv1u_stack, &tmr)) != NW_GTPV1U_OK) {
+  if ((rc = nwGtpv1uSetTimerMgrEntity(RC.gtpv1u_data_g->gtpv1u_stack, &tmr)) != NW_GTPV1U_OK) {
     LOG_E(GTPU, "nwGtpv1uSetTimerMgrEntity: %x", rc);
     return -1;
   }
@@ -984,7 +988,7 @@ static int gtpv1u_eNB_init(void)
   }
 
 #endif
-  ret = gtpv1u_eNB_send_init_udp(gtpv1u_data_g.enb_port_for_S1u_S12_S4_up);
+  ret = gtpv1u_eNB_send_init_udp(RC.gtpv1u_data_g->enb_port_for_S1u_S12_S4_up);
 
   if (ret < 0) {
     return ret;
@@ -1031,7 +1035,7 @@ void *gtpv1u_eNB_task(void *args)
     case UDP_DATA_IND: {
       udp_data_ind_t *udp_data_ind_p;
       udp_data_ind_p = &received_message_p->ittiMsg.udp_data_ind;
-      nwGtpv1uProcessUdpReq(gtpv1u_data_g.gtpv1u_stack,
+      nwGtpv1uProcessUdpReq(RC.gtpv1u_data_g->gtpv1u_stack,
                             udp_data_ind_p->buffer,
                             udp_data_ind_p->buffer_length,
                             udp_data_ind_p->peer_port,
@@ -1059,7 +1063,7 @@ void *gtpv1u_eNB_task(void *args)
 #endif
       memset(&stack_req, 0, sizeof(NwGtpv1uUlpApiT));
 
-      hash_rc = hashtable_get(gtpv1u_data_g.ue_mapping, (uint64_t)data_req_p->rnti, (void**)&gtpv1u_ue_data_p);
+      hash_rc = hashtable_get(RC.gtpv1u_data_g->ue_mapping, (uint64_t)data_req_p->rnti, (void**)&gtpv1u_ue_data_p);
 
       if (hash_rc == HASH_TABLE_KEY_NOT_EXISTS) {
         LOG_E(GTPU, "nwGtpv1uProcessUlpReq failed: while getting ue rnti %x in hashtable ue_mapping\n", data_req_p->rnti);
@@ -1072,10 +1076,10 @@ void *gtpv1u_eNB_task(void *args)
           stack_req.apiInfo.sendtoInfo.ipAddr = gtpv1u_ue_data_p->bearers[data_req_p->rab_id - GTPV1U_BEARER_OFFSET].sgw_ip_addr;
 
           rc = nwGtpv1uGpduMsgNew(
-                 gtpv1u_data_g.gtpv1u_stack,
+                 RC.gtpv1u_data_g->gtpv1u_stack,
                  sgw_s1u_teid,
                  NW_FALSE,
-                 gtpv1u_data_g.seq_num++,
+                 RC.gtpv1u_data_g->seq_num++,
                  data_req_p->buffer,
                  data_req_p->length,
                  data_req_p->offset,
@@ -1087,7 +1091,7 @@ void *gtpv1u_eNB_task(void *args)
             		enb_s1u_teid,sgw_s1u_teid,data_req_p->length);
             (void)enb_s1u_teid; /* avoid gcc warning "set but not used" */
           } else {
-            rc = nwGtpv1uProcessUlpReq(gtpv1u_data_g.gtpv1u_stack, &stack_req);
+            rc = nwGtpv1uProcessUlpReq(RC.gtpv1u_data_g->gtpv1u_stack, &stack_req);
 
             if (rc != NW_GTPV1U_OK) {
               LOG_E(GTPU, "nwGtpv1uProcessUlpReq failed: 0x%x\n", rc);
@@ -1107,7 +1111,7 @@ void *gtpv1u_eNB_task(void *args)
 
             }
 
-            rc = nwGtpv1uMsgDelete(gtpv1u_data_g.gtpv1u_stack,
+            rc = nwGtpv1uMsgDelete(RC.gtpv1u_data_g->gtpv1u_stack,
                                    stack_req.apiInfo.sendtoInfo.hMsg);
 
             if (rc != NW_GTPV1U_OK) {
@@ -1124,12 +1128,12 @@ void *gtpv1u_eNB_task(void *args)
     break;
 
     case TERMINATE_MESSAGE: {
-      if (gtpv1u_data_g.ue_mapping != NULL) {
-        hashtable_destroy (gtpv1u_data_g.ue_mapping);
+      if (RC.gtpv1u_data_g->ue_mapping != NULL) {
+        hashtable_destroy (RC.gtpv1u_data_g->ue_mapping);
       }
 
-      if (gtpv1u_data_g.teid_mapping != NULL) {
-        hashtable_destroy (gtpv1u_data_g.teid_mapping);
+      if (RC.gtpv1u_data_g->teid_mapping != NULL) {
+        hashtable_destroy (RC.gtpv1u_data_g->teid_mapping);
       }
 
       itti_exit_task();
diff --git a/openair3/GTPV1-U/gtpv1u_eNB_task.h b/openair3/GTPV1-U/gtpv1u_eNB_task.h
index d69917aea3..880719a0ad 100644
--- a/openair3/GTPV1-U/gtpv1u_eNB_task.h
+++ b/openair3/GTPV1-U/gtpv1u_eNB_task.h
@@ -31,13 +31,16 @@
 
 #include "messages_types.h"
 
+/*
 int
 gtpv1u_new_data_req(
   uint8_t enb_id,
   uint8_t ue_id,
   uint8_t rab_id,
   uint8_t *buffer,
-  uint32_t buf_len);
+  uint32_t buf_len,
+  uint32_t buf_offset);*/
+
 void *gtpv1u_eNB_task(void *args);
 
 int
diff --git a/targets/ARCH/COMMON/common_lib.c b/targets/ARCH/COMMON/common_lib.c
index 7433b5d618..6bb64f143f 100644
--- a/targets/ARCH/COMMON/common_lib.c
+++ b/targets/ARCH/COMMON/common_lib.c
@@ -42,25 +42,25 @@ int set_device(openair0_device *device) {
   switch (device->type) {
     
   case EXMIMO_DEV:
-    printf("[%s] has loaded EXPRESS MIMO device.\n",((device->host_type == BBU_HOST) ? "BBU": "RRH"));
+    printf("[%s] has loaded EXPRESS MIMO device.\n",((device->host_type == RAU_HOST) ? "RAU": "RRU"));
     break;
   case USRP_B200_DEV:
-    printf("[%s] has loaded USRP B200 device.\n",((device->host_type == BBU_HOST) ? "BBU": "RRH")); 
+    printf("[%s] has loaded USRP B200 device.\n",((device->host_type == RAU_HOST) ? "RAU": "RRU")); 
     break;
 case USRP_X300_DEV:
-    printf("[%s] has loaded USRP X300 device.\n",((device->host_type == BBU_HOST) ? "BBU": "RRH")); 
+    printf("[%s] has loaded USRP X300 device.\n",((device->host_type == RAU_HOST) ? "RAU": "RRU")); 
     break;
   case BLADERF_DEV:
-    printf("[%s] has loaded BLADERF device.\n",((device->host_type == BBU_HOST) ? "BBU": "RRH")); 
+    printf("[%s] has loaded BLADERF device.\n",((device->host_type == RAU_HOST) ? "RAU": "RRU")); 
     break;
   case LMSSDR_DEV:
-    printf("[%s] has loaded LMSSDR device.\n",((device->host_type == BBU_HOST) ? "BBU": "RRH")); 
+    printf("[%s] has loaded LMSSDR device.\n",((device->host_type == RAU_HOST) ? "RAU": "RRU")); 
     break;
   case NONE_DEV:
-    printf("[%s] has not loaded a HW device.\n",((device->host_type == BBU_HOST) ? "BBU": "RRH"));
+    printf("[%s] has not loaded a HW device.\n",((device->host_type == RAU_HOST) ? "RAU": "RRU"));
     break;    
   default:
-    printf("[%s] invalid HW device.\n",((device->host_type == BBU_HOST) ? "BBU": "RRH")); 
+    printf("[%s] invalid HW device.\n",((device->host_type == RAU_HOST) ? "RAU": "RRU")); 
     return -1;
   }
   return 0;
@@ -71,15 +71,15 @@ int set_transport(openair0_device *device) {
   switch (device->transp_type) {
     
   case ETHERNET_TP:
-    printf("[%s] has loaded ETHERNET trasport protocol.\n",((device->host_type == BBU_HOST) ? "BBU": "RRH"));
+    printf("[%s] has loaded ETHERNET trasport protocol.\n",((device->host_type == RAU_HOST) ? "RAU": "RRU"));
     return 0;     
     break;
   case NONE_TP:
-    printf("[%s] has not loaded a transport protocol.\n",((device->host_type == BBU_HOST) ? "BBU": "RRH"));
+    printf("[%s] has not loaded a transport protocol.\n",((device->host_type == RAU_HOST) ? "RAU": "RRU"));
     return 0; 
     break;    
   default:
-    printf("[%s] invalid transport protocol.\n",((device->host_type == BBU_HOST) ? "BBU": "RRH")); 
+    printf("[%s] invalid transport protocol.\n",((device->host_type == RAU_HOST) ? "RAU": "RRU")); 
     return -1;
     break;
   }
@@ -94,7 +94,7 @@ int load_lib(openair0_device *device, openair0_config_t *openair0_cfg, eth_param
   oai_transport_initfunc_t tp ;
   int ret=0;
 
-  if (flag == BBU_LOCAL_RADIO_HEAD) {
+  if (flag == RAU_LOCAL_RADIO_HEAD) {
       lib_handle = dlopen(OAI_RF_LIBNAME, RTLD_LAZY);
       if (!lib_handle) {
 	fprintf(stderr,"Unable to locate %s: HW device set to NONE_DEV.\n", OAI_RF_LIBNAME);
@@ -144,7 +144,7 @@ int openair0_device_load(openair0_device *device, openair0_config_t *openair0_cf
   int device_init(openair0_device *device, openair0_config_t *openair0_cfg);
   rc = device_init(device, openair0_cfg);
   #else
-  rc=load_lib(device, openair0_cfg, NULL,BBU_LOCAL_RADIO_HEAD );
+  rc=load_lib(device, openair0_cfg, NULL,RAU_LOCAL_RADIO_HEAD );
   if ( rc >= 0) {       
     if ( set_device(device) < 0) {
       fprintf(stderr, "%s %d:Unsupported radio head\n",__FILE__, __LINE__);
@@ -157,7 +157,7 @@ int openair0_device_load(openair0_device *device, openair0_config_t *openair0_cf
 
 int openair0_transport_load(openair0_device *device, openair0_config_t *openair0_cfg, eth_params_t * eth_params) {
   int rc;
-  rc=load_lib(device, openair0_cfg, eth_params, BBU_REMOTE_RADIO_HEAD);
+  rc=load_lib(device, openair0_cfg, eth_params, RAU_REMOTE_RADIO_HEAD);
   if ( rc >= 0) {       
     if ( set_transport(device) < 0) {
       fprintf(stderr, "%s %d:Unsupported transport protocol\n",__FILE__, __LINE__);
diff --git a/targets/ARCH/COMMON/common_lib.h b/targets/ARCH/COMMON/common_lib.h
index 2eb0a506be..fe60dd9fc1 100644
--- a/targets/ARCH/COMMON/common_lib.h
+++ b/targets/ARCH/COMMON/common_lib.h
@@ -41,8 +41,8 @@
 #define OAI_TP_LIBNAME        "liboai_transpro.so"
 
 /* flags for BBU to determine whether the attached radio head is local or remote */
-#define BBU_LOCAL_RADIO_HEAD  0
-#define BBU_REMOTE_RADIO_HEAD 1
+#define RAU_LOCAL_RADIO_HEAD  0
+#define RAU_REMOTE_RADIO_HEAD 1
 
 #ifndef MAX_CARDS
 #define MAX_CARDS 8
@@ -118,10 +118,10 @@ typedef enum {
 /*!\brief  openair0 device host type */
 typedef enum {
   MIN_HOST_TYPE = 0,
- /*!\brief device functions within a BBU */
-  BBU_HOST,
- /*!\brief device functions within a RRH */
-  RRH_HOST,
+ /*!\brief device functions within a RAU */
+  RAU_HOST,
+ /*!\brief device functions within a RRU */
+  RRU_HOST,
   MAX_HOST_TYPE
 
 }host_type_t;
@@ -203,14 +203,6 @@ typedef struct {
   //! the two following parameters are used to convert iqs 
   int iq_txshift;
   int iq_rxrescale;
-  //! remote IP/MAC addr for Ethernet interface
-  char *remote_addr;
-  //! remote port number for Ethernet interface
-  unsigned int remote_port;
-  //! local IP/MAC addr for Ethernet interface (eNB/BBU, UE)
-  char *my_addr;
-  //! local port number for Ethernet interface (eNB/BBU, UE)
-  unsigned int my_port;
   //! Configuration file for LMS7002M
   char *configFilename;
 } openair0_config_t;
@@ -228,11 +220,11 @@ typedef struct {
   char *remote_addr;
   //! remote port number for Ethernet interface
   uint16_t remote_port;
-  //! local IP/MAC addr for Ethernet interface (eNB/BBU, UE)
+  //! local IP/MAC addr for Ethernet interface (eNB/RAU, UE)
   char *my_addr;
-  //! local port number for Ethernet interface (eNB/BBU, UE)
+  //! local port number for Ethernet interface (eNB/RAU, UE)
   uint16_t  my_port;
-  //! local Ethernet interface (eNB/BBU, UE)
+  //! local Ethernet interface (eNB/RAU, UE)
   char *local_if_name;
   //! tx_sample_advance for RF + ETH
   uint8_t tx_sample_advance;
@@ -271,12 +263,15 @@ struct openair0_device_t {
   /*!brief Transport protocol type that the device suppports (in case I/Q samples need to be transported) */
   transport_type_t transp_type;
 
-   /*!brief Type of the device's host (BBU/RRH) */
+   /*!brief Type of the device's host (RAU/RRU) */
   host_type_t host_type;
 
   /* !brief RF frontend parameters set by application */
   openair0_config_t *openair0_cfg;
 
+  /* !brief ETH params set by application */
+  eth_params_t *eth_params;
+
   /*!brief Can be used by driver to hold internal structure*/
   void *priv;
 
@@ -287,16 +282,16 @@ struct openair0_device_t {
   */
   int (*trx_start_func)(openair0_device *device);
 
-  /*! \brief Called to send a request message between BBU-RRH
+  /*! \brief Called to send a request message between RAU-RRU
       @param device pointer to the device structure specific to the RF hardware target
-      @param msg pointer to the message structure passed between BBU-RRH
+      @param msg pointer to the message structure passed between RAU-RRU
       @param msg_len length of the message  
   */  
   int (*trx_request_func)(openair0_device *device, void *msg, ssize_t msg_len);
 
-  /*! \brief Called to send a reply  message between BBU-RRH
+  /*! \brief Called to send a reply  message between RAU-RRU
       @param device pointer to the device structure specific to the RF hardware target
-      @param msg pointer to the message structure passed between BBU-RRH
+      @param msg pointer to the message structure passed between RAU-RRU
       @param msg_len length of the message  
   */  
   int (*trx_reply_func)(openair0_device *device, void *msg, ssize_t msg_len);
@@ -362,6 +357,11 @@ struct openair0_device_t {
    */
   int (*trx_set_gains_func)(openair0_device* device, openair0_config_t *openair0_cfg);
 
+  /*! \brief RRU Configuration callback
+   * \param idx RU index
+   * \param arg pointer to capabilities or configuration
+   */
+  int (*configure_rru)(int idx, void* arg);
 };
 
 /* type of device init function, implemented in shared lib */
diff --git a/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_raw.c b/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_raw.c
index 5815f2b1a6..2e9d9a32ff 100644
--- a/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_raw.c
+++ b/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_raw.c
@@ -60,15 +60,15 @@ int eth_socket_init_raw(openair0_device *device) {
   int sock_type=0;
   int sock_proto=0;  
  
-  if (device->host_type == RRH_HOST ) {  /* RRH doesn't know remote MAC(will be retrieved from first packet send from BBU) and remote port(don't care) */
-    local_mac = device->openair0_cfg->my_addr; 
+  if (device->host_type == RRU_HOST ) {  /* RRU doesn't know remote MAC(will be retrieved from first packet send from RAU) and remote port(don't care) */
+    local_mac = device->eth_params->my_addr; 
     remote_mac = malloc(ETH_ALEN);
     memset((void*)remote_mac,0,ETH_ALEN);
-    printf("[%s] local MAC addr %s remote MAC addr %s\n","RRH", local_mac,remote_mac);    
+    printf("[%s] local MAC addr %s remote MAC addr %s\n","RRU", local_mac,remote_mac);    
   } else {
-    local_mac = device->openair0_cfg->my_addr;
-    remote_mac = device->openair0_cfg->remote_addr;
-    printf("[%s] local MAC addr %s remote MAC addr %s\n","BBU", local_mac,remote_mac);    
+    local_mac = device->eth_params->my_addr;
+    remote_mac = device->eth_params->remote_addr;
+    printf("[%s] local MAC addr %s remote MAC addr %s\n","RAU", local_mac,remote_mac);    
   }
    
   
@@ -96,7 +96,7 @@ int eth_socket_init_raw(openair0_device *device) {
   if (eth->flags == ETH_RAW_IF5_MOBIPASS) {
      eth->local_addr_ll.sll_protocol = htons(0xbffe);
   } else{ 
-     eth->local_addr_ll.sll_protocol = htons((short)device->openair0_cfg->my_port);
+     eth->local_addr_ll.sll_protocol = htons((short)device->eth_params->my_port);
   }
   eth->local_addr_ll.sll_halen    = ETH_ALEN;
   eth->local_addr_ll.sll_pkttype  = PACKET_OTHERHOST;
@@ -113,9 +113,9 @@ int eth_socket_init_raw(openair0_device *device) {
  if (eth->flags == ETH_RAW_IF5_MOBIPASS) {
    eth->eh.ether_type = htons(0xbffe);
  } else {
-   eth->eh.ether_type = htons((short)device->openair0_cfg->my_port);
+   eth->eh.ether_type = htons((short)device->eth_params->my_port);
  } 
- printf("[%s] binding to hardware address %x:%x:%x:%x:%x:%x\n",((device->host_type == BBU_HOST) ? "BBU": "RRH"),eth->eh.ether_shost[0],eth->eh.ether_shost[1],eth->eh.ether_shost[2],eth->eh.ether_shost[3],eth->eh.ether_shost[4],eth->eh.ether_shost[5]);
+ printf("[%s] binding to hardware address %x:%x:%x:%x:%x:%x\n",((device->host_type == RAU_HOST) ? "RAU": "RRU"),eth->eh.ether_shost[0],eth->eh.ether_shost[1],eth->eh.ether_shost[2],eth->eh.ether_shost[3],eth->eh.ether_shost[4],eth->eh.ether_shost[5]);
  
  return 0;
 }
@@ -146,7 +146,7 @@ int trx_eth_write_raw(openair0_device *device, openair0_timestamp timestamp, voi
     *(int16_t *)(buff2 + MAC_HEADER_SIZE_BYTES + sizeof(int16_t))=1+(i<<1);
     *(openair0_timestamp *)(buff2 + MAC_HEADER_SIZE_BYTES + sizeof(int32_t)) = timestamp;
     
-    /*printf("[RRH]write mod_%d %d , len %d, buff %p \n",
+    /*printf("[RRU]write mod_%d %d , len %d, buff %p \n",
       Mod_id,eth->sockfd[Mod_id],RAW_PACKET_SIZE_BYTES(nsamps), buff2);*/
     
     while(bytes_sent < RAW_PACKET_SIZE_BYTES(nsamps)) {
@@ -172,7 +172,7 @@ int trx_eth_write_raw(openair0_device *device, openair0_timestamp timestamp, voi
 	       *(int16_t *)(buff2 + MAC_HEADER_SIZE_BYTES + sizeof(int16_t)),
 	       *(openair0_timestamp *)(buff2 + MAC_HEADER_SIZE_BYTES + sizeof(int32_t)), 
 	       bytes_sent);
-    dump_packet((device->host_type == BBU_HOST)? "BBU":"RRH", buff2, RAW_PACKET_SIZE_BYTES(nsamps), TX_FLAG);
+    dump_packet((device->host_type == RAU_HOST)? "RAU":"RRU", buff2, RAW_PACKET_SIZE_BYTES(nsamps), TX_FLAG);
 #endif
     eth->tx_actual_nsamps=bytes_sent>>2;
     eth->tx_count++;
@@ -280,7 +280,7 @@ int trx_eth_read_raw(openair0_device *device, openair0_timestamp *timestamp, voi
 	     *(int16_t *)(buff2 + MAC_HEADER_SIZE_BYTES + sizeof(int16_t)),
 	     *(openair0_timestamp *)(buff2 + MAC_HEADER_SIZE_BYTES + sizeof(int32_t)),
 	     bytes_received);
-      dump_packet((device->host_type == BBU_HOST)? "BBU":"RRH", buff2, RAW_PACKET_SIZE_BYTES(nsamps),RX_FLAG);	  
+      dump_packet((device->host_type == RAU_HOST)? "RAU":"RRU", buff2, RAW_PACKET_SIZE_BYTES(nsamps),RX_FLAG);	  
 
 #endif  
 
@@ -433,7 +433,7 @@ int eth_set_dev_conf_raw(openair0_device *device) {
   void 	      *msg;
   ssize_t      msg_len;
   
-  /* a BBU client sends to RRH a set of configuration parameters (openair0_config_t)
+  /* a RAU client sends to RRU a set of configuration parameters (openair0_config_t)
      so that RF front end is configured appropriately and
      frame/packet size etc. can be set */ 
   
@@ -464,7 +464,7 @@ int eth_set_dev_conf_raw_IF4p5(openair0_device *device) {
   void 	      *msg;
   ssize_t      msg_len;
   
-  /* a BBU client sends to RRH a set of configuration parameters (openair0_config_t)
+  /* a RAU client sends to RRU a set of configuration parameters (openair0_config_t)
      so that RF front end is configured appropriately and
      frame/packet size etc. can be set */ 
   
@@ -496,7 +496,7 @@ int eth_get_dev_conf_raw(openair0_device *device) {
   msg = malloc(MAC_HEADER_SIZE_BYTES + sizeof(openair0_config_t));
   msg_len = MAC_HEADER_SIZE_BYTES + sizeof(openair0_config_t);
   
-  /* RRH receives from BBU openair0_config_t */
+  /* RRU receives from RAU openair0_config_t */
   if (recv(eth->sockfd,
 	   msg,
 	   msg_len,
@@ -505,11 +505,11 @@ int eth_get_dev_conf_raw(openair0_device *device) {
     exit(0);
   }
   
-  /* RRH stores the remote MAC address */
+  /* RRU stores the remote MAC address */
   memcpy(eth->eh.ether_dhost,(msg+ETH_ALEN),ETH_ALEN);	
   //memcpy((void*)&device->openair0_cfg,(msg + MAC_HEADER_SIZE_BYTES), sizeof(openair0_config_t));
   device->openair0_cfg=(openair0_config_t *)(msg + MAC_HEADER_SIZE_BYTES);
-  printf("[%s] binding mod to hardware address %x:%x:%x:%x:%x:%x           hardware address %x:%x:%x:%x:%x:%x\n",((device->host_type == BBU_HOST) ? "BBU": "RRH"),eth->eh.ether_shost[0],eth->eh.ether_shost[1],eth->eh.ether_shost[2],eth->eh.ether_shost[3],eth->eh.ether_shost[4],eth->eh.ether_shost[5],eth->eh.ether_dhost[0],eth->eh.ether_dhost[1],eth->eh.ether_dhost[2],eth->eh.ether_dhost[3],eth->eh.ether_dhost[4],eth->eh.ether_dhost[5]);
+  printf("[%s] binding mod to hardware address %x:%x:%x:%x:%x:%x           hardware address %x:%x:%x:%x:%x:%x\n",((device->host_type == RAU_HOST) ? "RAU": "RRU"),eth->eh.ether_shost[0],eth->eh.ether_shost[1],eth->eh.ether_shost[2],eth->eh.ether_shost[3],eth->eh.ether_shost[4],eth->eh.ether_shost[5],eth->eh.ether_dhost[0],eth->eh.ether_dhost[1],eth->eh.ether_dhost[2],eth->eh.ether_dhost[3],eth->eh.ether_dhost[4],eth->eh.ether_dhost[5]);
  	  
   return 0;
 }
@@ -525,7 +525,7 @@ int eth_get_dev_conf_raw_IF4p5(openair0_device *device) {
   msg = malloc(MAC_HEADER_SIZE_BYTES + sizeof(openair0_config_t));
   msg_len = MAC_HEADER_SIZE_BYTES + sizeof(openair0_config_t);
   
-  /* RRH receives from BBU openair0_config_t */
+  /* RRU receives from RAU openair0_config_t */
   if (recv(eth->sockfd,
 	   msg,
 	   msg_len,
@@ -534,11 +534,11 @@ int eth_get_dev_conf_raw_IF4p5(openair0_device *device) {
     exit(0);
   }
   
-  /* RRH stores the remote MAC address */
+  /* RRU stores the remote MAC address */
   memcpy(eth->eh.ether_dhost,(msg+ETH_ALEN),ETH_ALEN);	
   //memcpy((void*)&device->openair0_cfg,(msg + MAC_HEADER_SIZE_BYTES), sizeof(openair0_config_t));
   //device->openair0_cfg=(openair0_config_t *)(msg + MAC_HEADER_SIZE_BYTES);
-  printf("[%s] binding mod to hardware address %x:%x:%x:%x:%x:%x           hardware address %x:%x:%x:%x:%x:%x\n",((device->host_type == BBU_HOST) ? "BBU": "RRH"),eth->eh.ether_shost[0],eth->eh.ether_shost[1],eth->eh.ether_shost[2],eth->eh.ether_shost[3],eth->eh.ether_shost[4],eth->eh.ether_shost[5],eth->eh.ether_dhost[0],eth->eh.ether_dhost[1],eth->eh.ether_dhost[2],eth->eh.ether_dhost[3],eth->eh.ether_dhost[4],eth->eh.ether_dhost[5]);
+  printf("[%s] binding mod to hardware address %x:%x:%x:%x:%x:%x           hardware address %x:%x:%x:%x:%x:%x\n",((device->host_type == RAU_HOST) ? "RAU": "RRU"),eth->eh.ether_shost[0],eth->eh.ether_shost[1],eth->eh.ether_shost[2],eth->eh.ether_shost[3],eth->eh.ether_shost[4],eth->eh.ether_shost[5],eth->eh.ether_dhost[0],eth->eh.ether_dhost[1],eth->eh.ether_dhost[2],eth->eh.ether_dhost[3],eth->eh.ether_dhost[4],eth->eh.ether_dhost[5]);
  	  
   return 0;
 }
diff --git a/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c b/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c
index c151ab11ff..41507565cc 100644
--- a/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c
+++ b/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c
@@ -45,6 +45,7 @@
 
 #include "common_lib.h"
 #include "ethernet_lib.h"
+#include "common/ran_context.h"
 
 #define DEBUG 0
 //struct sockaddr_in dest_addr[MAX_INST];
@@ -59,6 +60,8 @@ uint16_t pck_seq_num_prev=0;
 int eth_socket_init_udp(openair0_device *device) {
 
   eth_state_t *eth = (eth_state_t*)device->priv;
+  eth_params_t *eth_params = device->eth_params;
+ 
   char str_local[INET_ADDRSTRLEN];
   char str_remote[INET_ADDRSTRLEN];
   const char *local_ip, *remote_ip;
@@ -68,18 +71,18 @@ int eth_socket_init_udp(openair0_device *device) {
   int sock_proto=0;
   int enable=1;
 
-  if (device->host_type == RRH_HOST ) {
-    local_ip   = device->openair0_cfg->my_addr;   
-    local_port = device->openair0_cfg->my_port;
+  if (device->host_type == RRU_HOST ) {
+    local_ip    = eth_params->my_addr;   
+    local_port  = eth_params->my_port;
     remote_ip   = "0.0.0.0";   
     remote_port =  0;   
-    printf("[%s] local ip addr %s port %d\n", "RRH", local_ip, local_port);    
+    printf("[%s] local ip addr %s port %d\n", "RRU", local_ip, local_port);    
   } else {
-    local_ip   = device->openair0_cfg->my_addr;   
-    local_port = device->openair0_cfg->my_port;
-    remote_ip   = device->openair0_cfg->remote_addr;
-    remote_port = device->openair0_cfg->remote_port;  
-    printf("[%s] local ip addr %s port %d\n","BBU", local_ip, local_port);    
+    local_ip    = eth_params->my_addr;   
+    local_port  = eth_params->my_port;
+    remote_ip   = eth_params->remote_addr;   
+    remote_port = eth_params->remote_port;   
+    printf("[%s] local ip addr %s port %d\n","RAU", local_ip, local_port);    
   }
   
   /* Open socket to send on */
@@ -122,7 +125,7 @@ int eth_socket_init_udp(openair0_device *device) {
       perror("ETHERNET: Cannot bind to socket");
       exit(0);
     } else {
-      printf("[%s] binding to %s:%d\n","RRH",str_local,ntohs(eth->local_addr.sin_port));
+      printf("[%s] binding to %s:%d\n","RAU",str_local,ntohs(eth->local_addr.sin_port));
     }
  
   return 0;
@@ -202,6 +205,10 @@ int trx_eth_write_udp_IF4p5(openair0_device *device, openair0_timestamp timestam
   eth_state_t *eth = (eth_state_t*)device->priv;
   
   ssize_t packet_size;
+
+  char str[INET_ADDRSTRLEN];
+
+  inet_ntop(AF_INET, &(eth->dest_addr.sin_addr), str, INET_ADDRSTRLEN);
   
   if (flags == IF4p5_PDLFFT) {
     packet_size = UDP_IF4p5_PDLFFT_SIZE_BYTES(nblocks);    
@@ -217,6 +224,8 @@ int trx_eth_write_udp_IF4p5(openair0_device *device, openair0_timestamp timestam
   }
    
   eth->tx_nsamps = nblocks;
+  printf("Sending %d bytes to %s\n",packet_size,str);
+
   bytes_sent = sendto(eth->sockfd,
 		      buff[0], 
 		      packet_size,
@@ -232,7 +241,6 @@ int trx_eth_write_udp_IF4p5(openair0_device *device, openair0_timestamp timestam
     eth->tx_actual_nsamps = bytes_sent>>1;
     eth->tx_count++;
   }
-  
   return (bytes_sent);  	  
 }
 
@@ -294,7 +302,7 @@ int trx_eth_write_udp(openair0_device *device, openair0_timestamp timestamp, voi
 	   *(int16_t *)(buff2 + sizeof(int16_t)),
 	   *(openair0_timestamp *)(buff2 + sizeof(int32_t)),
 	   bytes_sent);
-    dump_packet((device->host_type == BBU_HOST)? "BBU":"RRH", buff2, UDP_PACKET_SIZE_BYTES(nsamps), TX_FLAG);
+    dump_packet((device->host_type == RAU_HOST)? "RAU":"RAU", buff2, UDP_PACKET_SIZE_BYTES(nsamps), TX_FLAG);
 #endif
     eth->tx_actual_nsamps=bytes_sent>>2;
     eth->tx_count++;
@@ -382,7 +390,7 @@ int trx_eth_read_udp(openair0_device *device, openair0_timestamp *timestamp, voi
 		  *(int16_t *)(buff2 + sizeof(int16_t)),
 		  *(openair0_timestamp *)(buff2 + sizeof(int32_t)),
 		  bytes_received);
-	   dump_packet((device->host_type == BBU_HOST)? "BBU":"RRH", buff2, UDP_PACKET_SIZE_BYTES(nsamps),RX_FLAG);	  
+	   dump_packet((device->host_type == RAU_HOST)? "RAU":"RRU", buff2, UDP_PACKET_SIZE_BYTES(nsamps),RX_FLAG);	  
 #endif  
 	   
 	   /* store the timestamp value from packet's header */
@@ -420,19 +428,70 @@ int trx_eth_read_udp(openair0_device *device, openair0_timestamp *timestamp, voi
 int eth_set_dev_conf_udp(openair0_device *device) {
 
   eth_state_t *eth = (eth_state_t*)device->priv;
-  void 	      *msg;
-  ssize_t      msg_len;
+  ssize_t      msg_len,len;
+  RRU_CONFIG_msg_t rru_config_msg;
+  int received_capabilities=0;
+  char str[INET_ADDRSTRLEN];
 
-  
-  /* a BBU client sents to RRH a set of configuration parameters (openair0_config_t)
-     so that RF front end is configured appropriately and
-     frame/packet size etc. can be set */ 
-
-  msg=malloc(sizeof(openair0_config_t));
-  msg_len=sizeof(openair0_config_t);
-  memcpy(msg,(void*)device->openair0_cfg,msg_len);	
+  inet_ntop(AF_INET, &(eth->dest_addr.sin_addr), str, INET_ADDRSTRLEN);
 
-  if (sendto(eth->sockfd,msg,msg_len,0,(struct sockaddr *)&eth->dest_addr,eth->addr_len)==-1) {
+  // Wait for capabilities
+  while (received_capabilities==0) {
+    
+    rru_config_msg.type = RAU_tick; 
+    rru_config_msg.len  = sizeof(RRU_CONFIG_msg_t)-MAX_RRU_CONFIG_SIZE;
+    printf("Sending RAU tick to RRU on %s\n",str);
+    if (sendto(eth->sockfd,&rru_config_msg,rru_config_msg.len,0,(struct sockaddr *)&eth->dest_addr,eth->addr_len)==-1) {
+      perror("ETHERNET: sendto conf_udp");
+      printf("addr_len : %d, msg_len %d\n",eth->addr_len,msg_len);
+      exit(0);
+    }
+    
+    msg_len  = sizeof(RRU_CONFIG_msg_t)-MAX_RRU_CONFIG_SIZE+sizeof(RRU_capabilities_t);
+
+    // wait for answer with timeout  
+    if (len = recvfrom(eth->sockfd,
+		       &rru_config_msg,
+		       msg_len,
+		       0,
+		       (struct sockaddr *)&eth->dest_addr,
+		       (socklen_t *)&eth->addr_len)<0) {
+      printf("Waiting for RRU on %s\n",str);     
+    }
+    else if (rru_config_msg.type == RRU_capabilities) {
+      AssertFatal(rru_config_msg.len==msg_len,"Received capabilities with incorrect length (%d!=%d)\n",rru_config_msg.len,msg_len);
+      printf("Received capabilities from RRU on %s (len %d/%d, num_bands %d,max_pdschReferenceSignalPower %d, max_rxgain %d, nb_tx %d, nb_rx %d)\n",str,
+	     rru_config_msg.len,msg_len,
+	     ((RRU_capabilities_t*)&rru_config_msg.msg[0])->num_bands,
+	     ((RRU_capabilities_t*)&rru_config_msg.msg[0])->max_pdschReferenceSignalPower[0],
+	     ((RRU_capabilities_t*)&rru_config_msg.msg[0])->max_rxgain[0],
+	     ((RRU_capabilities_t*)&rru_config_msg.msg[0])->nb_tx[0],
+	     ((RRU_capabilities_t*)&rru_config_msg.msg[0])->nb_rx[0]);
+      received_capabilities=1;
+    }
+    else {
+      printf("Received incorrect message %d from RRU on %s\n",rru_config_msg.type,str); 
+    }
+  }
+  AssertFatal(device->configure_rru!=NULL,"device->configure_rru is null for RRU %d, shouldn't be ...\n",device->Mod_id);
+  device->configure_rru(device->Mod_id,
+			(RRU_capabilities_t *)&rru_config_msg.msg[0]);
+		    
+  rru_config_msg.type = RRU_config;
+  rru_config_msg.len  = sizeof(RRU_CONFIG_msg_t)-MAX_RRU_CONFIG_SIZE+sizeof(RRU_config_t);
+  printf("Sending Configuration to RRU on %s (num_bands %d,band0 %d,txfreq %u,rxfreq %u,att_tx %d,att_rx %d,N_RB_DL %d,N_RB_UL %d,3/4FS %d, prach_FO %d, prach_CI %d)\n",str,
+	 ((RRU_config_t *)&rru_config_msg.msg[0])->num_bands,
+	 ((RRU_config_t *)&rru_config_msg.msg[0])->band_list[0],
+	 ((RRU_config_t *)&rru_config_msg.msg[0])->tx_freq[0],
+	 ((RRU_config_t *)&rru_config_msg.msg[0])->rx_freq[0],
+	 ((RRU_config_t *)&rru_config_msg.msg[0])->att_tx[0],
+	 ((RRU_config_t *)&rru_config_msg.msg[0])->att_rx[0],
+	 ((RRU_config_t *)&rru_config_msg.msg[0])->N_RB_DL[0],
+	 ((RRU_config_t *)&rru_config_msg.msg[0])->N_RB_UL[0],
+	 ((RRU_config_t *)&rru_config_msg.msg[0])->threequarter_fs[0],
+	 ((RRU_config_t *)&rru_config_msg.msg[0])->prach_FreqOffset[0],
+	 ((RRU_config_t *)&rru_config_msg.msg[0])->prach_ConfigIndex[0]);
+  if (sendto(eth->sockfd,&rru_config_msg,rru_config_msg.len,0,(struct sockaddr *)&eth->dest_addr,eth->addr_len)==-1) {
     perror("ETHERNET: sendto conf_udp");
     printf("addr_len : %d, msg_len %d\n",eth->addr_len,msg_len);
     exit(0);
@@ -441,30 +500,115 @@ int eth_set_dev_conf_udp(openair0_device *device) {
   return 0;
 }
 
+extern RAN_CONTEXT_t RC;
+
 int eth_get_dev_conf_udp(openair0_device *device) {
 
-  eth_state_t   *eth = (eth_state_t*)device->priv;
-  char 		str1[INET_ADDRSTRLEN],str[INET_ADDRSTRLEN];
-  void 		*msg;
-  ssize_t	msg_len;
-  
-  msg=malloc(sizeof(openair0_config_t));
-  msg_len=sizeof(openair0_config_t);
+  eth_state_t        *eth = (eth_state_t*)device->priv;
+  char 		     str1[INET_ADDRSTRLEN],str[INET_ADDRSTRLEN];
+  void 		     *msg;
+  RRU_CONFIG_msg_t   rru_config_msg;
+  ssize_t	     msg_len;
+  int                tick_received          = 0;
+  int                configuration_received = 0;
+  RRU_capabilities_t *cap;
+  RU_t               *ru                    = RC.ru[0];
+  int                i;
 
   inet_ntop(AF_INET, &(eth->local_addr.sin_addr), str, INET_ADDRSTRLEN);
   inet_ntop(AF_INET, &(eth->dest_addr.sin_addr), str1, INET_ADDRSTRLEN);
+  
 
-  /* RRH receives from BBU openair0_config_t */
-  if (recvfrom(eth->sockfd,
-	       msg,
-	       msg_len,
-	       0,
-	       (struct sockaddr *)&eth->dest_addr,
-	       (socklen_t *)&eth->addr_len)==-1) {
-    perror("ETHERNET: recv_from conf_udp");
+  // wait for RAU_tick
+  while (tick_received == 0) {
+
+    msg_len  = sizeof(RRU_CONFIG_msg_t)-MAX_RRU_CONFIG_SIZE;
+
+    if (recvfrom(eth->sockfd,
+		 &rru_config_msg,
+		 msg_len,
+		 0,
+		 (struct sockaddr *)&eth->dest_addr,
+		 (socklen_t *)&eth->addr_len)<0) {
+      printf("RRU on %s Waiting for RAU on %s\n",str,str1);
+
+    }
+    else {
+      if (rru_config_msg.type == RAU_tick) {
+	printf("Tick received from RAU on %s\n",str1);
+	tick_received = 1;
+      }
+    }
+  }
+
+  // send capabilities
+
+  rru_config_msg.type = RRU_capabilities; 
+  rru_config_msg.len  = sizeof(RRU_CONFIG_msg_t)-MAX_RRU_CONFIG_SIZE+sizeof(RRU_capabilities_t);
+  cap                 = (RRU_capabilities_t*)&rru_config_msg.msg[0];
+  printf("Sending Capabilities (len %d, num_bands %d,max_pdschReferenceSignalPower %d, max_rxgain %d, nb_tx %d, nb_rx %d)\n",
+	 rru_config_msg.len,ru->num_bands,ru->max_pdschReferenceSignalPower,ru->max_rxgain,ru->nb_tx,ru->nb_rx);
+  switch (ru->function) {
+  case NGFI_RRU_IF4p5:
+    cap->FH_fmt                                   = OAI_IF4p5_only;
+    break;
+  case NGFI_RRU_IF5:
+    cap->FH_fmt                                   = OAI_IF5_only;
+    break;
+  case MBP_RRU_IF5:
+    cap->FH_fmt                                   = MBP_IF5;
+    break;
+  default:
+    AssertFatal(1==0,"RU_function is unknown %d\n",RC.ru[0]->function);
+    break;
+  }
+  cap->num_bands                                  = ru->num_bands;
+  for (i=0;i<ru->num_bands;i++) {
+    cap->band_list[i]                             = ru->band[i];
+    cap->nb_rx[i]                                 = ru->nb_rx;
+    cap->nb_tx[i]                                 = ru->nb_tx;
+    cap->max_pdschReferenceSignalPower[i]         = ru->max_pdschReferenceSignalPower;
+    cap->max_rxgain[i]                            = ru->max_rxgain;
+  }
+  if (sendto(eth->sockfd,&rru_config_msg,rru_config_msg.len,0,(struct sockaddr *)&eth->dest_addr,eth->addr_len)==-1) {
+    perror("ETHERNET: sendto conf_udp");
+    printf("addr_len : %d, msg_len %d\n",eth->addr_len,msg_len);
     exit(0);
   }
-  device->openair0_cfg=(openair0_config_t *)msg;
+
+  // wait for configuration
+  rru_config_msg.len  = sizeof(RRU_CONFIG_msg_t)-MAX_RRU_CONFIG_SIZE+sizeof(RRU_config_t);
+  while (configuration_received == 0) {
+    
+    if (recvfrom(eth->sockfd,
+		 &rru_config_msg,
+		 rru_config_msg.len,
+		 0,
+		 (struct sockaddr *)&eth->dest_addr,
+		 (socklen_t *)&eth->addr_len)==-1) {
+      printf("Waiting for configuration from RAU on %s\n",str1);
+    }
+    else {
+      printf("Configuration received from RAU on %s (num_bands %d,band0 %d,txfreq %u,rxfreq %u,att_tx %d,att_rx %d,N_RB_DL %d,N_RB_UL %d,3/4FS %d, prach_FO %d, prach_CI %d)\n",str,
+	 ((RRU_config_t *)&rru_config_msg.msg[0])->num_bands,
+	 ((RRU_config_t *)&rru_config_msg.msg[0])->band_list[0],
+	 ((RRU_config_t *)&rru_config_msg.msg[0])->tx_freq[0],
+	 ((RRU_config_t *)&rru_config_msg.msg[0])->rx_freq[0],
+	 ((RRU_config_t *)&rru_config_msg.msg[0])->att_tx[0],
+	 ((RRU_config_t *)&rru_config_msg.msg[0])->att_rx[0],
+	 ((RRU_config_t *)&rru_config_msg.msg[0])->N_RB_DL[0],
+	 ((RRU_config_t *)&rru_config_msg.msg[0])->N_RB_UL[0],
+	 ((RRU_config_t *)&rru_config_msg.msg[0])->threequarter_fs[0],
+	 ((RRU_config_t *)&rru_config_msg.msg[0])->prach_FreqOffset[0],
+	 ((RRU_config_t *)&rru_config_msg.msg[0])->prach_ConfigIndex[0]);
+	     
+      AssertFatal(device->configure_rru!=NULL,"device->configure_rru is null for RRU %d\n",device->Mod_id);
+      device->configure_rru(device->Mod_id,
+			    (void*)&rru_config_msg.msg[0]);
+      configuration_received = 1;
+    }
+  }
+  //  device->openair0_cfg=(openair0_config_t *)msg;
 
    /* get remote ip address and port */
    /* inet_ntop(AF_INET, &(eth->dest_addr.sin_addr), str1, INET_ADDRSTRLEN); */
@@ -476,6 +620,6 @@ int eth_get_dev_conf_udp(openair0_device *device) {
    /* device->openair0_cfg->my_port =ntohs(eth->local_addr.sin_port); */
    /* device->openair0_cfg->my_addr =str; */
 
-   /*  printf("[RRH] mod_%d socket %d connected to BBU %s:%d  %s:%d\n", Mod_id, eth->sockfd,str1, device->openair0_cfg->remote_port, str, device->openair0_cfg->my_port);  */
+   /*  printf("[RRU] mod_%d socket %d connected to BBU %s:%d  %s:%d\n", Mod_id, eth->sockfd,str1, device->openair0_cfg->remote_port, str, device->openair0_cfg->my_port);  */
    return 0;
 }
diff --git a/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c b/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c
index d30f8faed8..c989b763f2 100644
--- a/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c
+++ b/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c
@@ -53,8 +53,12 @@ int trx_eth_start(openair0_device *device) {
   if (eth->flags == ETH_RAW_MODE) {
     printf("Setting ETHERNET to ETH_RAW_IF5_MODE\n");
     if (eth_socket_init_raw(device)!=0)   return -1;
-    /* RRH gets openair0 device configuration - BBU sets openair0 device configuration*/
-    if (device->host_type == BBU_HOST) {
+    /* RRU gets device configuration - RAU sets device configuration*/
+
+    printf("Setting Timenout to 999999 usecs\n");
+    if(ethernet_tune (device,RCV_TIMEOUT,999999)!=0)  return -1;
+
+    if (device->host_type == RAU_HOST) {
       if(eth_set_dev_conf_raw(device)!=0)  return -1;
     } else {
       if(eth_get_dev_conf_raw(device)!=0)  return -1;
@@ -66,20 +70,27 @@ int trx_eth_start(openair0_device *device) {
     
     printf("Setting ETHERNET to ETH_RAW_IF4p5_MODE\n");
     if (eth_socket_init_raw(device)!=0)   return -1;
-    /* RRH gets openair0 device configuration - BBU sets openair0 device configuration*/
-    if (device->host_type == BBU_HOST) {
+
+    printf("Setting Timenout to 999999 usecs\n");
+    if(ethernet_tune (device,RCV_TIMEOUT,999999)!=0)  return -1;
+
+    /* RRU gets openair0 device configuration - RAU sets openair0 device configuration*/
+    if (device->host_type == RAU_HOST) {
       if(eth_set_dev_conf_raw_IF4p5(device)!=0)  return -1;
     } else {
       if(eth_get_dev_conf_raw_IF4p5(device)!=0)  return -1;
     }
     /* adjust MTU wrt number of samples per packet */
     if(ethernet_tune (device,MTU_SIZE,RAW_IF4p5_PRACH_SIZE_BYTES)!=0)  return -1;
-    
     if(ethernet_tune (device,RCV_TIMEOUT,999999)!=0)  return -1;
   } else if (eth->flags == ETH_UDP_IF4p5_MODE) {
     printf("Setting ETHERNET to UDP_IF4p5_MODE\n");
     if (eth_socket_init_udp(device)!=0)   return -1;
-    if (device->host_type == BBU_HOST) {
+    printf("Setting Timenout to 999999 usecs\n");
+    if(ethernet_tune (device,RCV_TIMEOUT,999999)!=0)  return -1;
+
+
+    if (device->host_type == RAU_HOST) {
       if(eth_set_dev_conf_udp(device)!=0)  return -1;
     } else {
       if(eth_get_dev_conf_udp(device)!=0)  return -1;
@@ -87,9 +98,10 @@ int trx_eth_start(openair0_device *device) {
 
     /* adjust MTU wrt number of samples per packet */
     /*if(ethernet_tune (device,MTU_SIZE,UDP_IF4p5_PRACH_SIZE_BYTES)!=0)  return -1;
-    
-    if(ethernet_tune (device,RCV_TIMEOUT,999999)!=0)  return -1;*/
+     */
+
 
+    
   } else if (eth->flags == ETH_RAW_IF5_MOBIPASS) {
     printf("Setting ETHERNET to RAW_IF5_MODE\n");
     if (eth_socket_init_raw(device)!=0)   return -1;
@@ -98,8 +110,8 @@ int trx_eth_start(openair0_device *device) {
   } else {
     printf("Setting ETHERNET to UDP_IF5_MODE\n");
     if (eth_socket_init_udp(device)!=0)   return -1;
-    /* RRH gets openair0 device configuration - BBU sets openair0 device configuration*/
-    if (device->host_type == BBU_HOST) {
+    /* RRU gets openair0 device configuration - RAU sets openair0 device configuration*/
+    if (device->host_type == RAU_HOST) {
       if(eth_set_dev_conf_udp(device)!=0)  return -1;
     } else {
       if(eth_get_dev_conf_udp(device)!=0)  return -1;
@@ -126,7 +138,7 @@ void trx_eth_end(openair0_device *device) {
     perror("ETHERNET: Failed to close socket");
     exit(0);
    } else {
-    printf("[%s] socket has been successfully closed.\n",(device->host_type == BBU_HOST)? "BBU":"RRH");
+    printf("[%s] socket has been successfully closed.\n",(device->host_type == RAU_HOST)? "RAU":"RRU");
    }
 }
 
@@ -135,7 +147,7 @@ int trx_eth_request(openair0_device *device, void *msg, ssize_t msg_len) {
 
   eth_state_t *eth = (eth_state_t*)device->priv;
  
-  /* BBU sends a message to RRH */
+  /* RAU sends a message to RRU */
   
   if (sendto(eth->sockfd,msg,msg_len,0,(struct sockaddr *)&eth->dest_addr,eth->addr_len)==-1) {
     perror("ETHERNET: ");
@@ -149,7 +161,7 @@ int trx_eth_reply(openair0_device *device, void *msg, ssize_t msg_len) {
 
   eth_state_t   *eth = (eth_state_t*)device->priv;
 
-  /* RRH receives from BBU a message */
+  /* RRU receives from RAU a message */
 
   if (recvfrom(eth->sockfd,
 	       msg,
@@ -349,7 +361,7 @@ int transport_init(openair0_device *device, openair0_config_t *openair0_cfg, eth
     eth->flags = ETH_RAW_MODE;
   }
   
-  printf("[ETHERNET]: Initializing openair0_device for %s ...\n", ((device->host_type == BBU_HOST) ? "BBU": "RRH"));
+  printf("[ETHERNET]: Initializing openair0_device for %s ...\n", ((device->host_type == RAU_HOST) ? "RAU": "RRU"));
   device->Mod_id           = 0;//num_devices_eth++;
   device->transp_type      = ETHERNET_TP;
   device->trx_start_func   = trx_eth_start;
@@ -390,9 +402,10 @@ int transport_init(openair0_device *device, openair0_config_t *openair0_cfg, eth
   openair0_cfg[0].iq_txshift = eth_params->iq_txshift;// shift
   openair0_cfg[0].tx_sample_advance = eth_params->tx_sample_advance;
 
-  /* RRH does not have any information to make this configuration atm */
-  if (device->host_type == BBU_HOST) {
-    /*Note scheduling advance values valid only for case 7680000 */    
+  /* RRU does not have any information to make this configuration atm */
+  /*
+  if (device->host_type == RAU_HOST) {
+   
     switch ((int)openair0_cfg[0].sample_rate) {
     case 30720000:
       openair0_cfg[0].samples_per_packet    = 3840;     
@@ -414,7 +427,8 @@ int transport_init(openair0_device *device, openair0_config_t *openair0_cfg, eth
       exit(-1);
       break;
     }
-  }
+    }*/
+
   device->openair0_cfg=&openair0_cfg[0];
   return 0;
 }
@@ -455,7 +469,7 @@ void dump_dev(openair0_device *device) {
     printf("       Log level is %i :\n" ,device->openair0_cfg->log_level);
     printf("       RB number: %i, sample rate: %lf \n" ,
            device->openair0_cfg->num_rb_dl, device->openair0_cfg->sample_rate);
-    printf("       BBU configured for %i tx/%i rx channels)\n",
+    printf("       RAU configured for %i tx/%i rx channels)\n",
            device->openair0_cfg->tx_num_channels,device->openair0_cfg->rx_num_channels);
     printf("       Running flags: %s %s (\n",
            ((eth->flags & ETH_RAW_MODE)  ? "RAW socket mode - ":""),
diff --git a/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.h b/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.h
index 9f555beaa9..efdeadfc05 100644
--- a/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.h
+++ b/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.h
@@ -158,6 +158,80 @@ typedef enum {
   MAX_OPT
 } eth_opt_t;
 
+#define MAX_RRU_CONFIG_SIZE 1024
+typedef enum {
+  RAU_tick=0,
+  RRU_capabilities=1,
+  RRU_config=2,
+  RRU_MSG_max_num=3
+} rru_config_msg_type_t;
+
+typedef struct RRU_CONFIG_msg_s {
+  rru_config_msg_type_t type;
+  ssize_t len;
+  uint8_t msg[MAX_RRU_CONFIG_SIZE];
+} RRU_CONFIG_msg_t;
+
+typedef enum {
+  OAI_IF5_only      =0,
+  OAI_IF4p5_only    =1,
+  OAI_IF5_and_IF4p5 =2,
+  MBP_IF5           =3,
+  MAX_FH_FMTs       =4
+} FH_fmt_options_t;
+
+#define MAX_BANDS_PER_RRU 4
+
+typedef struct RRU_capabilities_s {
+  /// Fronthaul format
+  FH_fmt_options_t FH_fmt;
+  /// number of EUTRA bands (<=4) supported by RRU
+  uint8_t          num_bands;
+  /// EUTRA band list supported by RRU
+  uint8_t          band_list[MAX_BANDS_PER_RRU];
+  /// Number of concurrent bands (component carriers)
+  uint8_t          num_concurrent_bands;
+  /// Maximum TX EPRE of each band
+  int8_t           max_pdschReferenceSignalPower[MAX_BANDS_PER_RRU];
+  /// Maximum RX gain of each band
+  uint8_t          max_rxgain[MAX_BANDS_PER_RRU];
+  /// Number of RX ports of each band
+  uint8_t          nb_rx[MAX_BANDS_PER_RRU];
+  /// Number of TX ports of each band
+  uint8_t          nb_tx[MAX_BANDS_PER_RRU]; 
+  /// max DL bandwidth (1,6,15,25,50,75,100)
+  uint8_t          N_RB_DL[MAX_BANDS_PER_RRU];
+  /// max UL bandwidth (1,6,15,25,50,75,100)
+  uint8_t          N_RB_UL[MAX_BANDS_PER_RRU];
+} RRU_capabilities_t;
+
+typedef struct RRU_config_s {
+  /// Fronthaul format
+  RU_if_south_t FH_fmt;
+  /// number of EUTRA bands (<=4) configured in RRU
+  uint8_t num_bands;
+  /// EUTRA band list configured in RRU
+  uint8_t band_list[MAX_BANDS_PER_RRU];
+  /// TX frequency
+  uint32_t tx_freq[MAX_BANDS_PER_RRU];
+  /// RX frequency
+  uint32_t rx_freq[MAX_BANDS_PER_RRU];
+  /// TX attenation w.r.t. max
+  uint8_t att_tx[MAX_BANDS_PER_RRU];
+  /// RX attenuation w.r.t. max
+  uint8_t att_rx[MAX_BANDS_PER_RRU];
+  /// DL bandwidth
+  uint8_t N_RB_DL[MAX_BANDS_PER_RRU];
+  /// UL bandwidth
+  uint8_t N_RB_UL[MAX_BANDS_PER_RRU];
+  /// 3/4 sampling rate
+  uint8_t threequarter_fs[MAX_BANDS_PER_RRU];
+  /// prach_FreqOffset for IF4p5
+  int prach_FreqOffset[MAX_BANDS_PER_RRU];
+  /// prach_ConfigIndex for IF4p5
+  int prach_ConfigIndex[MAX_BANDS_PER_RRU];
+} RRU_config_t;
+
 /*
 #define SND_BUF_SIZE	1
 #define RCV_BUF_SIZE	1<<1
diff --git a/targets/ARCH/LMSSDR/USERSPACE/LIB/lms_lib.cpp b/targets/ARCH/LMSSDR/USERSPACE/LIB/lms_lib.cpp
index 3a9878e82b..06548b37f4 100644
--- a/targets/ARCH/LMSSDR/USERSPACE/LIB/lms_lib.cpp
+++ b/targets/ARCH/LMSSDR/USERSPACE/LIB/lms_lib.cpp
@@ -343,7 +343,7 @@ extern "C" {
 int device_init(openair0_device *device, openair0_config_t *openair0_cfg){
 
   device->type=LMSSDR_DEV;
-  printf("LMSSDR: Initializing openair0_device for %s ...\n", ((device->host_type == BBU_HOST) ? "BBU": "RRH"));
+  printf("LMSSDR: Initializing openair0_device for %s ...\n", ((device->host_type == RAU_HOST) ? "RAU": "RRU"));
 
   switch ((int)openair0_cfg[0].sample_rate) {
   case 30720000:
diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.25PRB.lo.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.25PRB.lo.conf
index 5aad9973bb..f99de3dc3a 100644
--- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.25PRB.lo.conf
+++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.25PRB.lo.conf
@@ -154,21 +154,7 @@ eNBs =
         ENB_PORT_FOR_S1U                         = 2152; # Spec 2152
     };
 
-    rrh_gw_config = (
-    {			  
-      	local_if_name = "lo";			  
-   	remote_address = "127.0.0.1";
-    	local_address = "127.0.0.2";    
-    	local_port = 50000;	#for raw option local port must be the same to remote	       
-    	remote_port = 50000; 
-    	rrh_gw_active = "yes";
-    	tr_preference = "udp_if4p5";
-    	rf_preference = "usrp_b200";
-    	iq_txshift = 4;
-    	tx_sample_advance = 80;	
-    	tx_scheduling_advance = 9; 	                
-    }
-    );  
+
 
     log_config :
     {
@@ -187,5 +173,18 @@ eNBs =
       rrc_log_level                         ="info";
       rrc_log_verbosity                     ="medium";
    };
-  }
+  }	
 );
+
+RUs = (
+  ru_config = (
+  {			  
+    	local_rf = "no";
+      	local_if_name = "lo";			  
+   	remote_address = "127.0.0.1";
+    	local_address = "127.0.0.2";    
+    	local_port = 50000;	#for raw option local port must be the same to remote	       
+    	remote_port = 50000; 
+  }
+  );
+);  
\ No newline at end of file
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 918e7825cc..7f9bc0d705 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
@@ -154,21 +154,7 @@ eNBs =
         ENB_PORT_FOR_S1U                         = 2152; # Spec 2152
     };
 
-    rrh_gw_config = (
-    {			  
-      	local_if_name = "lo";			  
-   	remote_address = "127.0.0.1";
-    	local_address = "127.0.0.2";    
-    	local_port = 50000;	#for raw option local port must be the same to remote	       
-    	remote_port = 50000; 
-    	rrh_gw_active = "yes";
-    	tr_preference = "udp_if4p5";
-    	rf_preference = "usrp_b200";
-    	iq_txshift = 4;
-    	tx_sample_advance = 80;	
-    	tx_scheduling_advance = 9; 	                
-    }
-    );  
+
 
     log_config :
     {
@@ -189,3 +175,20 @@ eNBs =
    };
   }
 );
+
+RUs = (
+    {		  
+      	local_if_name  = "lo";			  
+      	remote_address = "127.0.0.1";
+    	local_address  = "127.0.0.2"; 
+    	local_port     = 50000;	#for raw option local port must be the same to remote	       
+    	remote_port    = 50001;
+	local_rf       = "no"
+    	tr_preference  = "udp_if4p5"
+	nb_tx          = 1
+	nb_rx          = 1
+	att_tx         = 0
+	att_rx         = 0;
+	eNB_instances  = [0];
+    }
+);  
diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.if4p5.25PRB.oaisim.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.if4p5.25PRB.oaisim.conf
index 26ecfb64f2..799087c996 100644
--- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.if4p5.25PRB.oaisim.conf
+++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.if4p5.25PRB.oaisim.conf
@@ -1,193 +1,12 @@
-Active_eNBs = ( "eNB_Eurecom_LTEBox");
-# Asn1_verbosity, choice in: none, info, annoying
-Asn1_verbosity = "none";
-
-eNBs =
-(
- {
-    ////////// Identification parameters:
-    eNB_ID    =  0xe00;
-
-    cell_type =  "CELL_MACRO_ENB";
-
-    eNB_name  =  "eNB_Eurecom_LTEBox";
-
-    // Tracking area code, 0x0000 and 0xfffe are reserved values
-    tracking_area_code  =  "1";
-
-    mobile_country_code =  "208";
-
-    mobile_network_code =  "93";
-
-       ////////// Physical parameters:
-
-    component_carriers = (
-      {
-      node_function     = "NGFI_RRU_IF4p5";
-      node_timing       = "synch_to_ext_device";
-      node_synch_ref    = 0;  
-      frame_type					      = "FDD";
-      tdd_config 					      = 3;
-      tdd_config_s            			      = 0;
-      prefix_type             			      = "NORMAL";
-      eutra_band              			      = 7;
-      downlink_frequency      			      = 2685000000L;
-      uplink_frequency_offset 			      = -120000000;
-      Nid_cell					      = 0;
-      N_RB_DL                 			      = 25;
-      Nid_cell_mbsfn          			      = 0;
-      nb_antenna_ports                                = 1;
-      nb_antennas_tx          			      = 1;
-      nb_antennas_rx          			      = 1;
-      tx_gain                                            = 90;
-      rx_gain                                            = 120;
-      prach_root              			      = 0;
-      prach_config_index      			      = 0;
-      prach_high_speed        			      = "DISABLE";
-      prach_zero_correlation  			      = 1;
-      prach_freq_offset       			      = 2;
-      pucch_delta_shift       			      = 1;
-      pucch_nRB_CQI           			      = 1;
-      pucch_nCS_AN            			      = 0;
-      pucch_n1_AN             			      = 32;
-      pdsch_referenceSignalPower 			      = -29;
-      pdsch_p_b                  			      = 0;
-      pusch_n_SB                 			      = 1;
-      pusch_enable64QAM          			      = "DISABLE";
-      pusch_hoppingMode                                  = "interSubFrame";
-      pusch_hoppingOffset                                = 0;
-      pusch_groupHoppingEnabled  			      = "ENABLE";
-      pusch_groupAssignment      			      = 0;
-      pusch_sequenceHoppingEnabled		   	      = "DISABLE";
-      pusch_nDMRS1                                       = 1;
-      phich_duration                                     = "NORMAL";
-      phich_resource                                     = "ONESIXTH";
-      srs_enable                                         = "DISABLE";
-      /*  srs_BandwidthConfig                                =;
-      srs_SubframeConfig                                 =;
-      srs_ackNackST                                      =;
-      srs_MaxUpPts                                       =;*/
-
-      pusch_p0_Nominal                                   = -95;
-      pusch_alpha                                        = "AL1";
-      pucch_p0_Nominal                                   = -104;
-      msg3_delta_Preamble                                = 6;
-      pucch_deltaF_Format1                               = "deltaF2";
-      pucch_deltaF_Format1b                              = "deltaF3";
-      pucch_deltaF_Format2                               = "deltaF0";
-      pucch_deltaF_Format2a                              = "deltaF0";
-      pucch_deltaF_Format2b		    	      = "deltaF0";
-
-      rach_numberOfRA_Preambles                          = 64;
-      rach_preamblesGroupAConfig                         = "DISABLE";
-      /*
-      rach_sizeOfRA_PreamblesGroupA                      = ;
-      rach_messageSizeGroupA                             = ;
-      rach_messagePowerOffsetGroupB                      = ;
-      */
-      rach_powerRampingStep                              = 4;
-      rach_preambleInitialReceivedTargetPower            = -104;
-      rach_preambleTransMax                              = 10;
-      rach_raResponseWindowSize                          = 10;
-      rach_macContentionResolutionTimer                  = 48;
-      rach_maxHARQ_Msg3Tx                                = 4;
-
-      pcch_default_PagingCycle                           = 128;
-      pcch_nB                                            = "oneT";
-      bcch_modificationPeriodCoeff			      = 2;
-      ue_TimersAndConstants_t300			      = 1000;
-      ue_TimersAndConstants_t301			      = 1000;
-      ue_TimersAndConstants_t310			      = 1000;
-      ue_TimersAndConstants_t311			      = 10000;
-      ue_TimersAndConstants_n310			      = 20;
-      ue_TimersAndConstants_n311			      = 1;
-
-      ue_TransmissionMode	   			      = 1;
-
-      }
-    );
-
-
-    srb1_parameters :
-    {
-        # timer_poll_retransmit = (ms) [5, 10, 15, 20,... 250, 300, 350, ... 500]
-        timer_poll_retransmit    = 80;
-
-        # timer_reordering = (ms) [0,5, ... 100, 110, 120, ... ,200]
-        timer_reordering         = 35;
-
-        # timer_reordering = (ms) [0,5, ... 250, 300, 350, ... ,500]
-        timer_status_prohibit    = 0;
-
-        # poll_pdu = [4, 8, 16, 32 , 64, 128, 256, infinity(>10000)]
-        poll_pdu                 =  4;
-
-        # poll_byte = (kB) [25,50,75,100,125,250,375,500,750,1000,1250,1500,2000,3000,infinity(>10000)]
-        poll_byte                =  99999;
-
-        # max_retx_threshold = [1, 2, 3, 4 , 6, 8, 16, 32]
-        max_retx_threshold       =  4;
-    }
-
-    # ------- SCTP definitions
-    SCTP :
-    {
-        # Number of streams to use in input/output
-        SCTP_INSTREAMS  = 2;
-        SCTP_OUTSTREAMS = 2;
-    };
-
-
-    ////////// MME parameters:
-    mme_ip_address      = ( { ipv4       = "192.168.12.11";
-                              ipv6       = "192:168:30::17";
-                              active     = "yes";
-                              preference = "ipv4";
-                            }
-                          );
-
-    NETWORK_INTERFACES :
-    {
-
-        ENB_INTERFACE_NAME_FOR_S1_MME            = "eth3";
-        ENB_IPV4_ADDRESS_FOR_S1_MME              = "192.168.12.215/24";
-        ENB_INTERFACE_NAME_FOR_S1U               = "eth3";
-        ENB_IPV4_ADDRESS_FOR_S1U                 = "192.168.12.215/24";
-        ENB_PORT_FOR_S1U                         = 2152; # Spec 2152
-    };
-
-    rrh_gw_config = (
-    {			  
+RUs = (
+    {		  
       	local_if_name = "lo";			  
       	remote_address = "127.0.0.2";
     	local_address = "127.0.0.1"; 
     	local_port = 50000;	#for raw option local port must be the same to remote	       
-    	remote_port = 50000; 
-    	rrh_gw_active = "yes";
+    	remote_port = 50000;
+	local_rf = "yes"
     	tr_preference = "udp_if4p5";
-    	rf_preference = "usrp_b200";
-    	iq_txshift = 4;
-    	tx_sample_advance = 80;	
-    	tx_scheduling_advance = 9; 	                
     }
-    );  
+);  
 
-    log_config :
-    {
-      global_log_level                      ="info";
-      global_log_verbosity                  ="medium";
-      hw_log_level                          ="info";
-      hw_log_verbosity                      ="medium";
-      phy_log_level                         ="info";
-      phy_log_verbosity                     ="medium";
-      mac_log_level                         ="info";
-      mac_log_verbosity                     ="high";
-      rlc_log_level                         ="info";
-      rlc_log_verbosity                     ="medium";
-      pdcp_log_level                        ="info";
-      pdcp_log_verbosity                    ="medium";
-      rrc_log_level                         ="info";
-      rrc_log_verbosity                     ="medium";
-   };
-  }
-);
diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c
index 877ac196cf..f9dc62d29f 100644
--- a/targets/RT/USER/lte-enb.c
+++ b/targets/RT/USER/lte-enb.c
@@ -29,26 +29,14 @@
  * \note
  * \warning
  */
-#define _GNU_SOURCE
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <sys/ioctl.h>
-#include <sys/types.h>
-#include <sys/mman.h>
-#include <sched.h>
-#include <linux/sched.h>
-#include <signal.h>
-#include <execinfo.h>
-#include <getopt.h>
-#include <sys/sysinfo.h>
-#include "rt_wrapper.h"
+
 
 #undef MALLOC //there are two conflicting definitions, so we better make sure we don't use it at all
 
+#include "rt_wrapper.h"
+
 #include "assertions.h"
-#include "msc.h"
+
 
 #include "PHY/types.h"
 
@@ -116,6 +104,7 @@ struct timing_info_t {
 // Fix per CC openair rf/if device update
 // extern openair0_device openair0;
 
+extern void do_prach(PHY_VARS_eNB *eNB,RU_t *ru,int frame,int subframe);
 #if defined(ENABLE_ITTI)
 extern volatile int             start_eNB;
 extern volatile int             start_UE;
@@ -124,10 +113,6 @@ extern volatile int                    oai_exit;
 
 extern openair0_config_t openair0_cfg[MAX_CARDS];
 
-extern pthread_cond_t sync_cond;
-extern pthread_mutex_t sync_mutex;
-extern int sync_var;
-
 extern int transmission_mode;
 
 extern int oaisim_flag;
@@ -159,407 +144,10 @@ extern double cpuf;
 
 void exit_fun(const char* s);
 
-void init_eNB(eNB_func_t node_function[], eNB_timing_t node_timing[],int nb_inst,eth_params_t *,int,int);
+void init_eNB(int,int);
 void stop_eNB(int nb_inst);
 
 
-static inline void thread_top_init(char *thread_name,
-				   int affinity,
-				   uint64_t runtime,
-				   uint64_t deadline,
-				   uint64_t period) {
-
-  MSC_START_USE();
-
-#ifdef DEADLINE_SCHEDULER
-  struct sched_attr attr;
-
-  unsigned int flags = 0;
-
-  attr.size = sizeof(attr);
-  attr.sched_flags = 0;
-  attr.sched_nice = 0;
-  attr.sched_priority = 0;
-
-  attr.sched_policy   = SCHED_DEADLINE;
-  attr.sched_runtime  = runtime;
-  attr.sched_deadline = deadline;
-  attr.sched_period   = period; 
-
-  if (sched_setattr(0, &attr, flags) < 0 ) {
-    perror("[SCHED] eNB tx thread: sched_setattr failed\n");
-    exit(1);
-  }
-
-#else //LOW_LATENCY
-  int policy, s, j;
-  struct sched_param sparam;
-  char cpu_affinity[1024];
-  cpu_set_t cpuset;
-
-  /* Set affinity mask to include CPUs 1 to MAX_CPUS */
-  /* CPU 0 is reserved for UHD threads */
-  /* CPU 1 is reserved for all RX_TX threads */
-  /* Enable CPU Affinity only if number of CPUs >2 */
-  CPU_ZERO(&cpuset);
-
-#ifdef CPU_AFFINITY
-  if (get_nprocs() > 2)
-  {
-    if (affinity == 0)
-      CPU_SET(0,&cpuset);
-    else
-      for (j = 1; j < get_nprocs(); j++)
-        CPU_SET(j, &cpuset);
-    s = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
-    if (s != 0)
-    {
-      perror( "pthread_setaffinity_np");
-      exit_fun("Error setting processor affinity");
-    }
-  }
-#endif //CPU_AFFINITY
-
-  /* Check the actual affinity mask assigned to the thread */
-  s = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
-  if (s != 0) {
-    perror( "pthread_getaffinity_np");
-    exit_fun("Error getting processor affinity ");
-  }
-  memset(cpu_affinity,0,sizeof(cpu_affinity));
-  for (j = 0; j < CPU_SETSIZE; j++)
-    if (CPU_ISSET(j, &cpuset)) {  
-      char temp[1024];
-      sprintf (temp, " CPU_%d", j);
-      strcat(cpu_affinity, temp);
-    }
-
-  memset(&sparam, 0, sizeof(sparam));
-  sparam.sched_priority = sched_get_priority_max(SCHED_FIFO);
-  policy = SCHED_FIFO ; 
-  
-  s = pthread_setschedparam(pthread_self(), policy, &sparam);
-  if (s != 0) {
-    perror("pthread_setschedparam : ");
-    exit_fun("Error setting thread priority");
-  }
-  
-  s = pthread_getschedparam(pthread_self(), &policy, &sparam);
-  if (s != 0) {
-    perror("pthread_getschedparam : ");
-    exit_fun("Error getting thread priority");
-  }
-
-  LOG_I(HW, "[SCHED][eNB] %s started on CPU %d TID %ld, sched_policy = %s , priority = %d, CPU Affinity=%s \n",thread_name,sched_getcpu(),gettid(),
-                   (policy == SCHED_FIFO)  ? "SCHED_FIFO" :
-                   (policy == SCHED_RR)    ? "SCHED_RR" :
-                   (policy == SCHED_OTHER) ? "SCHED_OTHER" :
-                   "???",
-                   sparam.sched_priority, cpu_affinity );
-
-#endif //LOW_LATENCY
-
-  mlockall(MCL_CURRENT | MCL_FUTURE);
-
-}
-
-static inline void wait_sync(char *thread_name) {
-
-  printf( "waiting for sync (%s)\n",thread_name);
-  pthread_mutex_lock( &sync_mutex );
-  
-  while (sync_var<0)
-    pthread_cond_wait( &sync_cond, &sync_mutex );
-  
-  pthread_mutex_unlock(&sync_mutex);
-  
-  printf( "got sync (%s)\n", thread_name);
-
-}
-
-
-void do_OFDM_mod_rt(int subframe,PHY_VARS_eNB *phy_vars_eNB)
-{
-
-  int CC_id = phy_vars_eNB->proc.CC_id;
-  unsigned int aa,slot_offset;
-  //int dummy_tx_b[7680*4] __attribute__((aligned(32)));
-  int i, tx_offset;
-  //int slot_sizeF = (phy_vars_eNB->frame_parms.ofdm_symbol_size)* ((phy_vars_eNB->frame_parms.Ncp==1) ? 6 : 7);
-  int len;
-  //int slot_offset_F = (subframe<<1)*slot_sizeF;
-
-  slot_offset = subframe*phy_vars_eNB->frame_parms.samples_per_tti;
-
-  if ((subframe_select(&phy_vars_eNB->frame_parms,subframe)==SF_DL)||
-      ((subframe_select(&phy_vars_eNB->frame_parms,subframe)==SF_S))) {
-    //    LOG_D(HW,"Frame %d: Generating slot %d\n",frame,next_slot);
-
-    VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_OFDM_MODULATION,1);
-
-    do_OFDM_mod_symbol(&phy_vars_eNB->common_vars,
-		       0,
-		       subframe<<1,
-		       &phy_vars_eNB->frame_parms,
-		       phy_vars_eNB->do_precoding);
- 
-    // if S-subframe generate first slot only 
-    if (subframe_select(&phy_vars_eNB->frame_parms,subframe) == SF_DL) {
-      do_OFDM_mod_symbol(&phy_vars_eNB->common_vars,
-			 0,
-			 1+(subframe<<1),
-			 &phy_vars_eNB->frame_parms,
-			 phy_vars_eNB->do_precoding);
-    }
-
-    VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_OFDM_MODULATION,0);
-    
-
-/*
-    for (aa=0; aa<phy_vars_eNB->frame_parms.nb_antennas_tx; aa++) {
-      if (phy_vars_eNB->frame_parms.Ncp == EXTENDED) {
-        PHY_ofdm_mod(&phy_vars_eNB->common_vars.txdataF[0][aa][slot_offset_F],
-                     dummy_tx_b,
-                     phy_vars_eNB->frame_parms.ofdm_symbol_size,
-                     6,
-                     phy_vars_eNB->frame_parms.nb_prefix_samples,
-                     CYCLIC_PREFIX);
-	if (subframe_select(&phy_vars_eNB->frame_parms,subframe) == SF_DL) 
-	  PHY_ofdm_mod(&phy_vars_eNB->common_vars.txdataF[0][aa][slot_offset_F+slot_sizeF],
-		       dummy_tx_b+(phy_vars_eNB->frame_parms.samples_per_tti>>1),
-		       phy_vars_eNB->frame_parms.ofdm_symbol_size,
-		       6,
-		       phy_vars_eNB->frame_parms.nb_prefix_samples,
-		       CYCLIC_PREFIX);
-      } else {
-        normal_prefix_mod(&phy_vars_eNB->common_vars.txdataF[0][aa][slot_offset_F],
-                          dummy_tx_b,
-                          7,
-                          &(phy_vars_eNB->frame_parms));
-	// if S-subframe generate first slot only
-	if (subframe_select(&phy_vars_eNB->frame_parms,subframe) == SF_DL)
-	  normal_prefix_mod(&phy_vars_eNB->common_vars.txdataF[0][aa][slot_offset_F+slot_sizeF],
-			    dummy_tx_b+(phy_vars_eNB->frame_parms.samples_per_tti>>1),
-			    7,
-			    &(phy_vars_eNB->frame_parms));
-      }
-    } */
-
-    for (aa=0; aa<phy_vars_eNB->frame_parms.nb_antennas_tx; aa++) {
-      // if S-subframe generate first slot only
-      if (subframe_select(&phy_vars_eNB->frame_parms,subframe) == SF_S)
-	len = phy_vars_eNB->frame_parms.samples_per_tti>>1;
-      else
-	len = phy_vars_eNB->frame_parms.samples_per_tti;
-      /*
-      for (i=0;i<len;i+=4) {
-	dummy_tx_b[i] = 0x100;
-	dummy_tx_b[i+1] = 0x01000000;
-	dummy_tx_b[i+2] = 0xff00;
-	dummy_tx_b[i+3] = 0xff000000;
-	}*/
-      for (i=0; i<len; i++) {
-        tx_offset = (int)slot_offset+time_offset[aa]+i;
-
-	
-        if (tx_offset<0)
-          tx_offset += LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*phy_vars_eNB->frame_parms.samples_per_tti;
-
-        if (tx_offset>=(LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*phy_vars_eNB->frame_parms.samples_per_tti))
-          tx_offset -= LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*phy_vars_eNB->frame_parms.samples_per_tti;
-
-/*	((short*)&phy_vars_eNB->common_vars.txdata[0][aa][tx_offset])[0] = ((short*)dummy_tx_b)[2*i]<<openair0_cfg[0].iq_txshift;
-	
-	((short*)&phy_vars_eNB->common_vars.txdata[0][aa][tx_offset])[1] = ((short*)dummy_tx_b)[2*i+1]<<openair0_cfg[0].iq_txshift; */
-
-	((short*)&phy_vars_eNB->common_vars.txdata[0][aa][tx_offset])[0] = ((short*)&phy_vars_eNB->common_vars.txdata[0][aa][tx_offset])[0]<<openair0_cfg[CC_id].iq_txshift;
-	
-	((short*)&phy_vars_eNB->common_vars.txdata[0][aa][tx_offset])[1] = ((short*)&phy_vars_eNB->common_vars.txdata[0][aa][tx_offset])[1]<<openair0_cfg[CC_id].iq_txshift;
-     }
-     // if S-subframe switch to RX in second subframe
-     if (subframe_select(&phy_vars_eNB->frame_parms,subframe) == SF_S) {
-       for (i=0; i<len; i++) {
-	 phy_vars_eNB->common_vars.txdata[0][aa][tx_offset++] = 0x00010001;
-       }
-     }
-
-     if ((((phy_vars_eNB->frame_parms.tdd_config==0) ||
-	  (phy_vars_eNB->frame_parms.tdd_config==1) ||
-	  (phy_vars_eNB->frame_parms.tdd_config==2) ||
-	  (phy_vars_eNB->frame_parms.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,phy_vars_eNB->N_TA_offset,slot_offset);
-       for (i=0; i<phy_vars_eNB->N_TA_offset; i++) {
-         tx_offset = (int)slot_offset+time_offset[aa]+i-phy_vars_eNB->N_TA_offset;
-         if (tx_offset<0)
-           tx_offset += LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*phy_vars_eNB->frame_parms.samples_per_tti;
-	 
-	 if (tx_offset>=(LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*phy_vars_eNB->frame_parms.samples_per_tti))
-	   tx_offset -= LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*phy_vars_eNB->frame_parms.samples_per_tti;
-	 
-	 phy_vars_eNB->common_vars.txdata[0][aa][tx_offset] = 0x00000000;
-       }
-     }
-    }
-  }
-}
-
-
-void tx_fh_if5(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) {
-  VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, proc->timestamp_tx&0xffffffff );
-  if ((eNB->frame_parms.frame_type==FDD) ||
-      ((eNB->frame_parms.frame_type==TDD) &&
-       (subframe_select(&eNB->frame_parms,proc->subframe_tx) != SF_UL)))    
-    send_IF5(eNB, proc->timestamp_tx, proc->subframe_tx, &seqno, IF5_RRH_GW_DL);
-}
-
-void tx_fh_if5_mobipass(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) {
-  VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, proc->timestamp_tx&0xffffffff );
-  if ((eNB->frame_parms.frame_type==FDD) ||
-      ((eNB->frame_parms.frame_type==TDD) &&
-       (subframe_select(&eNB->frame_parms,proc->subframe_tx) != SF_UL)))    
-    send_IF5(eNB, proc->timestamp_tx, proc->subframe_tx, &seqno, IF5_MOBIPASS); 
-}
-
-void tx_fh_if4p5(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) {
-  if ((eNB->frame_parms.frame_type==FDD) ||
-      ((eNB->frame_parms.frame_type==TDD) &&
-       (subframe_select(&eNB->frame_parms,proc->subframe_tx) != SF_UL)))    
-    send_IF4p5(eNB,proc->frame_tx,proc->subframe_tx, IF4p5_PDLFFT, 0);
-}
-
-void proc_tx_high0(PHY_VARS_eNB *eNB,
-		   eNB_rxtx_proc_t *proc,
-		   relaying_type_t r_type,
-		   PHY_VARS_RN *rn) {
-
-  int offset = proc == &eNB->proc.proc_rxtx[0] ? 0 : 1;
-
-  VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_ENB+offset, proc->frame_tx );
-  VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_TX0_ENB+offset, proc->subframe_tx );
-
-  phy_procedures_eNB_TX(eNB,proc,r_type,rn,1);
-
-  /* we're done, let the next one proceed */
-  if (pthread_mutex_lock(&sync_phy_proc.mutex_phy_proc_tx) != 0) {
-    LOG_E(PHY, "[SCHED][eNB] error locking PHY proc mutex for eNB TX proc\n");
-    exit_fun("nothing to add");
-  }	
-  sync_phy_proc.phy_proc_CC_id++;
-  sync_phy_proc.phy_proc_CC_id %= MAX_NUM_CCs;
-  pthread_cond_broadcast(&sync_phy_proc.cond_phy_proc_tx);
-  if (pthread_mutex_unlock(&sync_phy_proc.mutex_phy_proc_tx) != 0) {
-    LOG_E(PHY, "[SCHED][eNB] error unlocking PHY proc mutex for eNB TX proc\n");
-    exit_fun("nothing to add");
-  }
-
-}
-
-void proc_tx_high(PHY_VARS_eNB *eNB,
-		  eNB_rxtx_proc_t *proc,
-		  relaying_type_t r_type,
-		  PHY_VARS_RN *rn) {
-
-
-  // do PHY high
-  proc_tx_high0(eNB,proc,r_type,rn);
-
-  // if TX fronthaul go ahead 
-  if (eNB->tx_fh) eNB->tx_fh(eNB,proc);
-
-}
-
-void proc_tx_full(PHY_VARS_eNB *eNB,
-		  eNB_rxtx_proc_t *proc,
-		  relaying_type_t r_type,
-		  PHY_VARS_RN *rn) {
-
-
-  // do PHY high
-  proc_tx_high0(eNB,proc,r_type,rn);
-  // do OFDM modulation
-  do_OFDM_mod_rt(proc->subframe_tx,eNB);
-  // if TX fronthaul go ahead 
-  if (eNB->tx_fh) eNB->tx_fh(eNB,proc);
-
-  /*
-  if (proc->frame_tx>1000) {
-    write_output("/tmp/txsig0.m","txs0", &eNB->common_vars.txdata[eNB->Mod_id][0][0], eNB->frame_parms.samples_per_tti*10,1,1);
-    write_output("/tmp/txsigF0.m","txsF0", &eNB->common_vars.txdataF[eNB->Mod_id][0][0],eNB->frame_parms.symbols_per_tti*eNB->frame_parms.ofdm_symbol_size*10,1,1);
-    write_output("/tmp/txsig1.m","txs1", &eNB->common_vars.txdata[eNB->Mod_id][1][0], eNB->frame_parms.samples_per_tti*10,1,1);
-    write_output("/tmp/txsigF1.m","txsF1", &eNB->common_vars.txdataF[eNB->Mod_id][1][0],eNB->frame_parms.symbols_per_tti*eNB->frame_parms.ofdm_symbol_size*10,1,1);
-    if (transmission_mode == 7) 
-      write_output("/tmp/txsigF5.m","txsF5", &eNB->common_vars.txdataF[eNB->Mod_id][5][0],eNB->frame_parms.symbols_per_tti*eNB->frame_parms.ofdm_symbol_size*10,1,1);
-    exit_fun("");
-  }
-  */
-}
-
-void proc_tx_rru_if4p5(PHY_VARS_eNB *eNB,
-		       eNB_rxtx_proc_t *proc,
-		       relaying_type_t r_type,
-		       PHY_VARS_RN *rn) {
-
-  uint32_t symbol_number=0;
-  uint32_t symbol_mask, symbol_mask_full;
-  uint16_t packet_type;
-
-  int offset = proc == &eNB->proc.proc_rxtx[0] ? 0 : 1;
-
-  VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_ENB+offset, proc->frame_tx );
-  VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_TX0_ENB+offset, proc->subframe_tx );
-
-  /// **** recv_IF4 of txdataF from RCC **** ///             
-  symbol_number = 0;
-  symbol_mask = 0;
-  symbol_mask_full = (1<<eNB->frame_parms.symbols_per_tti)-1;
-  
-
-  do { 
-    recv_IF4p5(eNB, &proc->frame_tx, &proc->subframe_tx, &packet_type, &symbol_number);
-    symbol_mask = symbol_mask | (1<<symbol_number);
-  } while (symbol_mask != symbol_mask_full); 
-
-  do_OFDM_mod_rt(proc->subframe_tx, eNB);
-}
-
-void proc_tx_rru_if5(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) {
-  int offset = proc == &eNB->proc.proc_rxtx[0] ? 0 : 1;
-
-  VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_ENB+offset, proc->frame_tx );
-  VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_TX0_ENB+offset, proc->subframe_tx );
-  /// **** recv_IF5 of txdata from BBU **** ///       
-  recv_IF5(eNB, &proc->timestamp_tx, proc->subframe_tx, IF5_RRH_GW_DL);
-}
-
-int wait_CCs(eNB_rxtx_proc_t *proc) {
-
-  struct timespec wait;
-
-  wait.tv_sec=0;
-  wait.tv_nsec=5000000L;
-
-  if (pthread_mutex_timedlock(&sync_phy_proc.mutex_phy_proc_tx,&wait) != 0) {
-    LOG_E(PHY, "[SCHED][eNB] error locking PHY proc mutex for eNB TX\n");
-    exit_fun("nothing to add");
-    return(-1);
-  }
-  
-  // wait for our turn or oai_exit
-  while (sync_phy_proc.phy_proc_CC_id != proc->CC_id && !oai_exit) {
-    pthread_cond_wait(&sync_phy_proc.cond_phy_proc_tx,
-		      &sync_phy_proc.mutex_phy_proc_tx);
-  }
-  
-  if (pthread_mutex_unlock(&sync_phy_proc.mutex_phy_proc_tx) != 0) {
-    LOG_E(PHY, "[SCHED][eNB] error unlocking PHY proc mutex for eNB TX\n");
-    exit_fun("nothing to add");
-    return(-1);
-  }
-  return(0);
-}
-
 static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_name) {
 
   start_meas(&softmodem_stats_rxtx_sf);
@@ -567,12 +155,12 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam
   // ****************************************
   // Common RX procedures subframe n
 
-  if ((eNB->do_prach)&&((eNB->node_function != NGFI_RCC_IF4p5)))
-    eNB->do_prach(eNB,proc->frame_rx,proc->subframe_rx);
-  phy_procedures_eNB_common_RX(eNB,proc);
+
+  do_prach(eNB,NULL,proc->frame_rx,proc->subframe_rx);
+  //  phy_procedures_eNB_common_RX(eNB,proc);
   
   // UE-specific RX processing for subframe n
-  if (eNB->proc_uespec_rx) eNB->proc_uespec_rx(eNB, proc, no_relay );
+  phy_procedures_eNB_uespec_RX(eNB, proc, no_relay );
   
   // *****************************************
   // TX processing for subframe n+4
@@ -583,7 +171,7 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam
   
   if (oai_exit) return(-1);
   
-  if (eNB->proc_tx)	eNB->proc_tx(eNB, proc, no_relay, NULL );
+  phy_procedures_eNB_TX(eNB, proc, no_relay, NULL, 1);
   
   if (release_thread(&proc->mutex_rxtx,&proc->instance_cnt_rxtx,thread_name)<0) return(-1);
 
@@ -592,17 +180,19 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam
   return(0);
 }
 
+
 /*!
  * \brief The RX UE-specific and TX thread of eNB.
  * \param param is a \ref eNB_proc_t structure which contains the info what to process.
  * \returns a pointer to an int. The storage is not on the heap and must not be freed.
  */
+
 static void* eNB_thread_rxtx( void* param ) {
 
   static int eNB_thread_rxtx_status;
 
   eNB_rxtx_proc_t *proc = (eNB_rxtx_proc_t*)param;
-  PHY_VARS_eNB *eNB = PHY_vars_eNB_g[0][proc->CC_id];
+  PHY_VARS_eNB *eNB = RC.eNB[0][proc->CC_id];
 
   char thread_name[100];
 
@@ -638,6 +228,7 @@ static void* eNB_thread_rxtx( void* param ) {
   return &eNB_thread_rxtx_status;
 }
 
+
 #if defined(ENABLE_ITTI) && defined(ENABLE_USE_MME)
 /* Wait for eNB application initialization to be complete (eNB registration to MME) */
 static void wait_system_ready (char *message, volatile int *start_flag) {
@@ -658,506 +249,37 @@ static void wait_system_ready (char *message, volatile int *start_flag) {
 #endif
 
 
-// asynchronous UL with IF5 (RCC,RAU,eNodeB_BBU)
-void fh_if5_asynch_UL(PHY_VARS_eNB *eNB,int *frame,int *subframe) {
-
-  eNB_proc_t *proc       = &eNB->proc;
-  LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms;
-
-  recv_IF5(eNB, &proc->timestamp_rx, *subframe, IF5_MOBIPASS); 
-
-  int offset_mobipass = 40120;
-  pthread_mutex_lock(&proc->mutex_asynch_rxtx);
-  proc->subframe_rx = ((proc->timestamp_rx-offset_mobipass)/fp->samples_per_tti)%10;
-  proc->frame_rx    = ((proc->timestamp_rx-offset_mobipass)/(fp->samples_per_tti*10))&1023;
-  
-  if (proc->first_rx == 1) {
-    proc->first_rx =2;
-    *subframe = proc->subframe_rx;
-    *frame    = proc->frame_rx; 
-    LOG_E(PHY,"[Mobipass]timestamp_rx:%llu, frame_rx %d, subframe: %d\n",proc->timestamp_rx,proc->frame_rx,proc->subframe_rx);
-  }
-  else {
-    if (proc->subframe_rx != *subframe) {
-        proc->first_rx++;
-       LOG_E(PHY,"[Mobipass]timestamp:%llu, subframe_rx %d is not what we expect %d, first_rx:%d\n",proc->timestamp_rx, proc->subframe_rx,*subframe, proc->first_rx);
-      //exit_fun("Exiting");
-    }
-    if (proc->frame_rx != *frame) {
-        proc->first_rx++;
-       LOG_E(PHY,"[Mobipass]timestamp:%llu, frame_rx %d is not what we expect %d, first_rx:%d\n",proc->timestamp_rx,proc->frame_rx,*frame, proc->first_rx);  
-     // exit_fun("Exiting");
-    }
-    // temporary solution
-      *subframe = proc->subframe_rx;
-      *frame    = proc->frame_rx;
-  }
-
-  pthread_mutex_unlock(&proc->mutex_asynch_rxtx);
-
-} // eNodeB_3GPP_BBU 
-
-// asynchronous UL with IF4p5 (RCC,RAU,eNodeB_BBU)
-void fh_if4p5_asynch_UL(PHY_VARS_eNB *eNB,int *frame,int *subframe) {
-
-  LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms;
-  eNB_proc_t *proc       = &eNB->proc;
-
-  uint16_t packet_type;
-  uint32_t symbol_number,symbol_mask,symbol_mask_full,prach_rx;
-
-
-  symbol_number = 0;
-  symbol_mask = 0;
-  symbol_mask_full = (1<<fp->symbols_per_tti)-1;
-  prach_rx = 0;
-
-  do {   // Blocking, we need a timeout on this !!!!!!!!!!!!!!!!!!!!!!!
-    recv_IF4p5(eNB, &proc->frame_rx, &proc->subframe_rx, &packet_type, &symbol_number);
-    if (proc->first_rx != 0) {
-      *frame = proc->frame_rx;
-      *subframe = proc->subframe_rx;
-      proc->first_rx--;
-    }
-    else {
-      if (proc->frame_rx != *frame) {
-	LOG_E(PHY,"fh_if4p5_asynch_UL: frame_rx %d is not what we expect %d\n",proc->frame_rx,*frame);
-	exit_fun("Exiting");
-      }
-      if (proc->subframe_rx != *subframe) {
-	LOG_E(PHY,"fh_if4p5_asynch_UL: subframe_rx %d is not what we expect %d\n",proc->subframe_rx,*subframe);
-	exit_fun("Exiting");
-      }
-    }
-    if (packet_type == IF4p5_PULFFT) {
-      symbol_mask = symbol_mask | (1<<symbol_number);
-      prach_rx = (is_prach_subframe(fp, proc->frame_rx, proc->subframe_rx)>0) ? 1 : 0;                            
-    } else if (packet_type == IF4p5_PRACH) {
-      prach_rx = 0;
-    }
-  } while( (symbol_mask != symbol_mask_full) || (prach_rx == 1));    
-  
-
-} 
-
-
-void fh_if5_asynch_DL(PHY_VARS_eNB *eNB,int *frame,int *subframe) {
-
-  LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms;
-  eNB_proc_t *proc       = &eNB->proc;
-  int subframe_tx,frame_tx;
-  openair0_timestamp timestamp_tx;
-
-  recv_IF5(eNB, &timestamp_tx, *subframe, IF5_RRH_GW_DL); 
-  //printf("Received subframe %d (TS %llu) from RCC\n",subframe_tx,timestamp_tx);
-
-  subframe_tx = (timestamp_tx/fp->samples_per_tti)%10;
-  frame_tx    = (timestamp_tx/(fp->samples_per_tti*10))&1023;
 
-  VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_ENB, frame_tx );
-  VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_TX0_ENB, subframe_tx );
 
-  if (proc->first_tx != 0) {
-    *subframe = subframe_tx;
-    *frame    = frame_tx;
-    proc->first_tx = 0;
-  }
-  else {
-    if (subframe_tx != *subframe) {
-      LOG_E(PHY,"fh_if5_asynch_DL: subframe_tx %d is not what we expect %d\n",subframe_tx,*subframe);
-      exit_fun("Exiting");
-    }
-    if (frame_tx != *frame) { 
-      LOG_E(PHY,"fh_if5_asynch_DL: frame_tx %d is not what we expect %d\n",frame_tx,*frame);
-      exit_fun("Exiting");
-    }
-  }
-}
-
-void fh_if4p5_asynch_DL(PHY_VARS_eNB *eNB,int *frame,int *subframe) {
-
-  LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms;
-  eNB_proc_t *proc       = &eNB->proc;
-
-  uint16_t packet_type;
-  uint32_t symbol_number,symbol_mask_full;
-  int subframe_tx,frame_tx;
-
-  symbol_number = 0;
-
-  LOG_D(PHY,"fh_asynch_DL_IF4p5: in, frame %d, subframe %d\n",*frame,*subframe);
-
-  // correct for TDD
-  if (fp->frame_type == TDD) {
-    while (subframe_select(fp,*subframe) == SF_UL) {
-      *subframe=*subframe+1;
-      if (*subframe==10) {
-	*subframe=0;
-	*frame=*frame+1;
-      }
-    }
-  }
-
-  LOG_D(PHY,"fh_asynch_DL_IF4p5: after TDD correction, frame %d, subframe %d\n",*frame,*subframe);
-
-  symbol_mask_full = ((subframe_select(fp,*subframe) == SF_S) ? (1<<fp->dl_symbols_in_S_subframe) : (1<<fp->symbols_per_tti))-1;
-  do {   // Blocking, we need a timeout on this !!!!!!!!!!!!!!!!!!!!!!!
-    recv_IF4p5(eNB, &frame_tx, &subframe_tx, &packet_type, &symbol_number);
-    if (proc->first_tx != 0) {
-      *frame    = frame_tx;
-      *subframe = subframe_tx;
-      proc->first_tx = 0;
-      proc->frame_offset = frame_tx - proc->frame_tx;
-      symbol_mask_full = ((subframe_select(fp,*subframe) == SF_S) ? (1<<fp->dl_symbols_in_S_subframe) : (1<<fp->symbols_per_tti))-1;
-
-    }
-    else {
-      if (frame_tx != *frame) {
-	LOG_E(PHY,"fh_if4p5_asynch_DL: frame_tx %d is not what we expect %d\n",frame_tx,*frame);
-	exit_fun("Exiting");
-      }
-      if (subframe_tx != *subframe) {
-	LOG_E(PHY,"fh_if4p5_asynch_DL: (frame %d) subframe_tx %d is not what we expect %d\n",frame_tx,subframe_tx,*subframe);
-	//*subframe = subframe_tx;
-	exit_fun("Exiting");
-      }
-    }
-    if (packet_type == IF4p5_PDLFFT) {
-      proc->symbol_mask[subframe_tx] =proc->symbol_mask[subframe_tx] | (1<<symbol_number);
-    }
-    else {
-      LOG_E(PHY,"Illegal IF4p5 packet type (should only be IF4p5_PDLFFT%d\n",packet_type);
-      exit_fun("Exiting");
-    }
-  } while (proc->symbol_mask[*subframe] != symbol_mask_full);    
-
-  *frame = frame_tx;
-
-
-  VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_ENB, frame_tx );
-  VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_TX0_ENB, subframe_tx );
-
-  // intialize this to zero after we're done with the subframe
-  proc->symbol_mask[*subframe] = 0;
-  
-  do_OFDM_mod_rt(*subframe, eNB);
-} 
-
-/*!
- * \brief The Asynchronous RX/TX FH thread of RAU/RCC/eNB/RRU.
- * This handles the RX FH for an asynchronous RRU/UE
- * \param param is a \ref eNB_proc_t structure which contains the info what to process.
- * \returns a pointer to an int. The storage is not on the heap and must not be freed.
- */
-static void* eNB_thread_asynch_rxtx( void* param ) {
-
-  static int eNB_thread_asynch_rxtx_status;
-
-  eNB_proc_t *proc = (eNB_proc_t*)param;
-  PHY_VARS_eNB *eNB = PHY_vars_eNB_g[0][proc->CC_id];
-
-
-
-  int subframe=0, frame=0; 
-
-  thread_top_init("thread_asynch",1,870000L,1000000L,1000000L);
-
-  // wait for top-level synchronization and do one acquisition to get timestamp for setting frame/subframe
-
-  wait_sync("thread_asynch");
-
-  // wait for top-level synchronization and do one acquisition to get timestamp for setting frame/subframe
-  printf( "waiting for devices (eNB_thread_asynch_rx)\n");
-
-  wait_on_condition(&proc->mutex_asynch_rxtx,&proc->cond_asynch_rxtx,&proc->instance_cnt_asynch_rxtx,"thread_asynch");
-
-  printf( "devices ok (eNB_thread_asynch_rx)\n");
-
-
-  while (!oai_exit) { 
-   
-    if (oai_exit) break;   
-
-    if (subframe==9) { 
-      subframe=0;
-      frame++;
-      frame&=1023;
-    } else {
-      subframe++;
-    }      
-
-    if (eNB->fh_asynch) eNB->fh_asynch(eNB,&frame,&subframe);
-    else AssertFatal(1==0, "Unknown eNB->node_function %d",eNB->node_function);
-    
-  }
-
-  eNB_thread_asynch_rxtx_status=0;
-  return(&eNB_thread_asynch_rxtx_status);
-}
-
-
-
-
-
-void rx_rf(PHY_VARS_eNB *eNB,int *frame,int *subframe) {
-
-  eNB_proc_t *proc = &eNB->proc;
-  LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms;
-  void *rxp[fp->nb_antennas_rx],*txp[fp->nb_antennas_tx]; 
-  unsigned int rxs,txs;
-  int i;
-  int tx_sfoffset = (eNB->single_thread_flag == 1) ? 3 : 2;
-  openair0_timestamp ts,old_ts;
-
-  if (proc->first_rx==0) {
-    
-    // Transmit TX buffer based on timestamp from RX
-    //    printf("trx_write -> USRP TS %llu (sf %d)\n", (proc->timestamp_rx+(3*fp->samples_per_tti)),(proc->subframe_rx+2)%10);
-    VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, (proc->timestamp_rx+(tx_sfoffset*fp->samples_per_tti)-openair0_cfg[0].tx_sample_advance)&0xffffffff );
-    // prepare tx buffer pointers
-
-    lte_subframe_t SF_type     = subframe_select(fp,(proc->subframe_rx+tx_sfoffset)%10);
-    lte_subframe_t prevSF_type = subframe_select(fp,(proc->subframe_rx+tx_sfoffset+9)%10);
-    lte_subframe_t nextSF_type = subframe_select(fp,(proc->subframe_rx+tx_sfoffset+1)%10);
-    if ((SF_type == SF_DL) ||
-	(SF_type == SF_S)) {
-
-      for (i=0; i<fp->nb_antennas_tx; i++)
-	txp[i] = (void*)&eNB->common_vars.txdata[0][i][((proc->subframe_rx+tx_sfoffset)%10)*fp->samples_per_tti]; 
-
-      int siglen=fp->samples_per_tti,flags=1;
-
-      if (SF_type == SF_S) {
-	siglen = fp->dl_symbols_in_S_subframe*(fp->ofdm_symbol_size+fp->nb_prefix_samples0);
-	flags=3; // end of burst
-      }
-      if ((fp->frame_type == TDD) &&
-	  (SF_type == SF_DL)&&
-	  (prevSF_type == SF_UL) &&
-	  (nextSF_type == SF_DL))
-	flags = 2; // start of burst
-
-      if ((fp->frame_type == TDD) &&
-	  (SF_type == SF_DL)&&
-	  (prevSF_type == SF_UL) &&
-	  (nextSF_type == SF_UL))
-	flags = 4; // start of burst and end of burst (only one DL SF between two UL)
-     
-      VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 1 );
-      VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_WRITE_FLAGS,flags); 
-      txs = eNB->rfdevice.trx_write_func(&eNB->rfdevice,
-					 proc->timestamp_rx+eNB->ts_offset+(tx_sfoffset*fp->samples_per_tti)-openair0_cfg[0].tx_sample_advance,
-					 txp,
-					 siglen,
-					 fp->nb_antennas_tx,
-					 flags);
-      
-      VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 0 );
-      
-      
-      
-      if (txs !=  siglen) {
-	LOG_E(PHY,"TX : Timeout (sent %d/%d)\n",txs, fp->samples_per_tti);
-	exit_fun( "problem transmitting samples" );
-      }	
-    }
-  }
-
-  for (i=0; i<fp->nb_antennas_rx; i++)
-    rxp[i] = (void*)&eNB->common_vars.rxdata[0][i][*subframe*fp->samples_per_tti];
-  
-  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ, 1 );
-
-  old_ts = proc->timestamp_rx;
-
-  rxs = eNB->rfdevice.trx_read_func(&eNB->rfdevice,
-				    &ts,
-				    rxp,
-				    fp->samples_per_tti,
-				    fp->nb_antennas_rx);
-
-  proc->timestamp_rx = ts-eNB->ts_offset;
-
-  if (rxs != fp->samples_per_tti)
-    LOG_E(PHY,"rx_rf: Asked for %d samples, got %d from USRP\n",fp->samples_per_tti,rxs);
-
-  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ, 0 );
- 
-  if (proc->first_rx == 1) {
-    eNB->ts_offset = proc->timestamp_rx;
-    proc->timestamp_rx=0;
-  }
-  else {
-
-    if (proc->timestamp_rx - old_ts != fp->samples_per_tti) {
-      LOG_I(PHY,"rx_rf: rfdevice timing drift of %d samples\n",proc->timestamp_rx - old_ts - fp->samples_per_tti);
-      eNB->ts_offset += (proc->timestamp_rx - old_ts - fp->samples_per_tti);
-      proc->timestamp_rx = ts-eNB->ts_offset;
-    }
-  }
-  proc->frame_rx    = (proc->timestamp_rx / (fp->samples_per_tti*10))&1023;
-  proc->subframe_rx = (proc->timestamp_rx / fp->samples_per_tti)%10;
-  proc->frame_rx    = (proc->frame_rx+proc->frame_offset)&1023;
-  proc->frame_tx    = proc->frame_rx;
-  if (proc->subframe_rx > 5) proc->frame_tx=(proc->frame_tx+1)&1023;
-  // synchronize first reception to frame 0 subframe 0
-
-  proc->timestamp_tx = proc->timestamp_rx+(4*fp->samples_per_tti);
-  //  printf("trx_read <- USRP TS %lu (offset %d sf %d, f %d, first_rx %d)\n", proc->timestamp_rx,eNB->ts_offset,proc->subframe_rx,proc->frame_rx,proc->first_rx);  
-  
-  if (proc->first_rx == 0) {
-    if (proc->subframe_rx != *subframe){
-      LOG_E(PHY,"rx_rf: Received Timestamp (%llu) doesn't correspond to the time we think it is (proc->subframe_rx %d, subframe %d)\n",proc->timestamp_rx,proc->subframe_rx,*subframe);
-      exit_fun("Exiting");
-    }
-    int f2 = (*frame+proc->frame_offset)&1023;    
-    if (proc->frame_rx != f2) {
-      LOG_E(PHY,"rx_rf: Received Timestamp (%llu) doesn't correspond to the time we think it is (proc->frame_rx %d frame %d, frame_offset %d, f2 %d)\n",proc->timestamp_rx,proc->frame_rx,*frame,proc->frame_offset,f2);
-      exit_fun("Exiting");
-    }
-  } else {
-    proc->first_rx--;
-    *frame = proc->frame_rx;
-    *subframe = proc->subframe_rx;        
-  }
-  
-  //printf("timestamp_rx %lu, frame %d(%d), subframe %d(%d)\n",proc->timestamp_rx,proc->frame_rx,frame,proc->subframe_rx,subframe);
-  
-  VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TS, proc->timestamp_rx&0xffffffff );
-  
-  if (rxs != fp->samples_per_tti)
-    exit_fun( "problem receiving samples" );
-  
-
-  
-}
-
-void rx_fh_if5(PHY_VARS_eNB *eNB,int *frame, int *subframe) {
-
-  LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms;
-  eNB_proc_t *proc = &eNB->proc;
-
-  recv_IF5(eNB, &proc->timestamp_rx, *subframe, IF5_RRH_GW_UL); 
-
-  proc->frame_rx    = (proc->timestamp_rx / (fp->samples_per_tti*10))&1023;
-  proc->subframe_rx = (proc->timestamp_rx / fp->samples_per_tti)%10;
-  
-  if (proc->first_rx == 0) {
-    if (proc->subframe_rx != *subframe){
-      LOG_E(PHY,"rx_fh_if5: Received Timestamp doesn't correspond to the time we think it is (proc->subframe_rx %d, subframe %d)\n",proc->subframe_rx,*subframe);
-      exit_fun("Exiting");
-    }
-    
-    if (proc->frame_rx != *frame) {
-      LOG_E(PHY,"rx_fh_if5: Received Timestamp doesn't correspond to the time we think it is (proc->frame_rx %d frame %d)\n",proc->frame_rx,*frame);
-      exit_fun("Exiting");
-    }
-  } else {
-    proc->first_rx--;
-    *frame = proc->frame_rx;
-    *subframe = proc->subframe_rx;        
-  }      
-
-
-
-  proc->timestamp_tx = proc->timestamp_rx +  (4*fp->samples_per_tti);
-  
-  VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TS, proc->timestamp_rx&0xffffffff );
-
-}
-
-
-void rx_fh_if4p5(PHY_VARS_eNB *eNB,int *frame,int *subframe) {
-
-  LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms;
-  eNB_proc_t *proc = &eNB->proc;
-  int f,sf;
-
-  uint16_t packet_type;
-  uint32_t symbol_number=0;
-  uint32_t symbol_mask_full;
-
-  if ((fp->frame_type == TDD) && (subframe_select(fp,*subframe)==SF_S))
-    symbol_mask_full = (1<<fp->ul_symbols_in_S_subframe)-1;
-  else 
-    symbol_mask_full = (1<<fp->symbols_per_tti)-1;
-
-  if (eNB->CC_id==1) LOG_I(PHY,"rx_fh_if4p5: frame %d, subframe %d\n",*frame,*subframe);
-  do {   // Blocking, we need a timeout on this !!!!!!!!!!!!!!!!!!!!!!!
-    recv_IF4p5(eNB, &f, &sf, &packet_type, &symbol_number);
+void eNB_top(PHY_VARS_eNB *eNB, int frame_rx, int subframe_rx, char *string) {
 
-    //proc->frame_rx = (proc->frame_rx + proc->frame_offset)&1023;
-    if (packet_type == IF4p5_PULFFT) {
-      LOG_D(PHY,"rx_fh_if4p5: frame %d, subframe %d, PULFFT symbol %d\n",f,sf,symbol_number);
-
-      proc->symbol_mask[sf] = proc->symbol_mask[sf] | (1<<symbol_number);
-    } else if (packet_type == IF4p5_PULTICK) {
-    
-      if ((proc->first_rx==0) && (f!=*frame))
-	LOG_E(PHY,"rx_fh_if4p5: PULTICK received frame %d != expected %d\n",f,*frame);
-      if ((proc->first_rx==0) && (sf!=*subframe))
-	LOG_E(PHY,"rx_fh_if4p5: PULTICK received subframe %d != expected %d (first_rx %d)\n",sf,*subframe,proc->first_rx);
-      break;
-    } else if (packet_type == IF4p5_PRACH) {
-      LOG_D(PHY,"rx_fh:if4p5: frame %d, subframe %d, PRACH\n",f,sf);
-      // wakeup prach processing
-      if (eNB->do_prach) eNB->do_prach(eNB,f,sf);
-    }
-
-    if (eNB->CC_id==1) LOG_I(PHY,"rx_fh_if4p5: symbol_mask[%d] %x\n",*subframe,proc->symbol_mask[*subframe]);
-
-  } while(proc->symbol_mask[*subframe] != symbol_mask_full);    
-
-  proc->subframe_rx = sf;
-  proc->frame_rx    = f;
-
-  proc->symbol_mask[*subframe] = 0;
-  proc->symbol_mask[(9+*subframe)%10]= 0; // to handle a resynchronization event
-
-  if (eNB->CC_id==1) LOG_I(PHY,"Clearing symbol_mask[%d]\n",*subframe);
-
-  //caculate timestamp_rx, timestamp_tx based on frame and subframe
-  proc->timestamp_rx = ((proc->frame_rx * 10)  + proc->subframe_rx ) * fp->samples_per_tti ;
-  proc->timestamp_tx = proc->timestamp_rx +  (4*fp->samples_per_tti);
-  
- 
-  if (proc->first_rx == 0) {
-    if (proc->subframe_rx != *subframe){
-      LOG_E(PHY,"rx_fh_if4p5, CC_id %d: Received Timestamp doesn't correspond to the time we think it is (proc->subframe_rx %d, subframe %d,CCid %d)\n",eNB->CC_id,proc->subframe_rx,*subframe,eNB->CC_id);
-    }
-    if (proc->frame_rx != *frame) {
-      if (proc->frame_rx == proc->frame_offset) // This means that the RRU has adjusted its frame timing
-	proc->frame_offset = 0;
-      else 
-	LOG_E(PHY,"rx_fh_if4p5: Received Timestamp doesn't correspond to the time we think it is (proc->frame_rx %d frame %d,CCid %d)\n",proc->frame_rx,*frame,eNB->CC_id);
-    }
-  } else {
-    proc->first_rx = 0;
-    if (eNB->CC_id==0)
-      proc->frame_offset = 0;
-    else
-      proc->frame_offset = PHY_vars_eNB_g[0][0]->proc.frame_rx;
+  eNB_proc_t *proc           = &eNB->proc;
+  eNB_rxtx_proc_t *proc_rxtx = &proc->proc_rxtx[0];
 
-    *frame = proc->frame_rx;//(proc->frame_rx + proc->frame_offset)&1023;
-    *subframe = proc->subframe_rx;        
-  }
-  
 
 
-  if (eNB->CC_id==0) VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TS, proc->timestamp_rx&0xffffffff );
+  proc->frame_rx    = frame_rx;
+  proc->subframe_rx = subframe_rx;
   
-}
+  if (!oai_exit) {
+
 
-void rx_fh_slave(PHY_VARS_eNB *eNB,int *frame,int *subframe) {
-  // This case is for synchronization to another thread
-  // it just waits for an external event.  The actual rx_fh is handle by the asynchronous RX thread
-  eNB_proc_t *proc=&eNB->proc;
+    if (eNB->CC_id==1) 
+	LOG_D(PHY,"eNB thread single %p (proc %p, CC_id %d), frame %d, subframe %d\n",
+	  pthread_self(), proc, eNB->CC_id, proc->frame_rx,proc->subframe_rx);
+ 
 
-  if (wait_on_condition(&proc->mutex_FH,&proc->cond_FH,&proc->instance_cnt_FH,"rx_fh_slave") < 0)
-    return;
+    T(T_ENB_MASTER_TICK, T_INT(0), T_INT(proc->frame_rx), T_INT(proc->subframe_rx));
 
-  release_thread(&proc->mutex_FH,&proc->instance_cnt_FH,"rx_fh_slave");
+    proc_rxtx->subframe_rx = proc->subframe_rx;
+    proc_rxtx->frame_rx    = proc->frame_rx;
+    proc_rxtx->subframe_tx = (proc->subframe_rx+4)%10;
+    proc_rxtx->frame_tx    = (proc->subframe_rx>5) ? (1+proc->frame_rx)&1023 : proc->frame_rx;
+    proc->frame_tx         = proc_rxtx->frame_tx;
+    proc_rxtx->timestamp_tx = proc->timestamp_tx;
 
+    if (rxtx(eNB,proc_rxtx,string) < 0) LOG_E(PHY,"eNB %d CC_id %d failed during execution\n",eNB->Mod_id,eNB->CC_id);
+  }
   
 }
 
@@ -1214,252 +336,6 @@ int wakeup_rxtx(eNB_proc_t *proc,eNB_rxtx_proc_t *proc_rxtx,LTE_DL_FRAME_PARMS *
   return(0);
 }
 
-void wakeup_slaves(eNB_proc_t *proc) {
-
-  int i;
-  struct timespec wait;
-  
-  wait.tv_sec=0;
-  wait.tv_nsec=5000000L;
-  
-  for (i=0;i<proc->num_slaves;i++) {
-    eNB_proc_t *slave_proc = proc->slave_proc[i];
-    // wake up slave FH thread
-    // lock the FH mutex and make sure the thread is ready
-    if (pthread_mutex_timedlock(&slave_proc->mutex_FH,&wait) != 0) {
-      /* TODO: fix this log, what is 'IC'? */
-      /*LOG_E( PHY, "[eNB] ERROR pthread_mutex_lock for eNB CCid %d slave CCid %d (IC %d)\n",proc->CC_id,slave_proc->CC_id);*/
-      LOG_E( PHY, "[eNB] ERROR pthread_mutex_lock for eNB CCid %d slave CCid %d\n",proc->CC_id,slave_proc->CC_id);
-      exit_fun( "error locking mutex_rxtx" );
-      break;
-    }
-   
-    while (slave_proc->instance_cnt_FH == 0) {
-     // LOG_W( PHY,"[eNB] Frame:%d , eNB rx_fh_slave thread busy!! (cnt_FH %i)\n", proc->frame_rx,slave_proc->instance_cnt_FH );
-      usleep(500);
-    } 
-
-    int cnt_slave            = ++slave_proc->instance_cnt_FH;
-    slave_proc->frame_rx     = proc->frame_rx;
-    slave_proc->subframe_rx  = proc->subframe_rx;
-    //slave_proc->timestamp_rx = proc->timestamp_rx;
-    slave_proc->timestamp_tx = proc->timestamp_tx; 
-
-    pthread_mutex_unlock( &slave_proc->mutex_FH );
-    
-    if (cnt_slave == 0) {
-      // the thread was presumably waiting where it should and can now be woken up
-      if (pthread_cond_signal(&slave_proc->cond_FH) != 0) {
-	LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB CCid %d, slave CCid %d\n",proc->CC_id,slave_proc->CC_id);
-          exit_fun( "ERROR pthread_cond_signal" );
-	  break;
-      }
-    } else {
-      LOG_W( PHY,"[eNB] Frame %d, slave CC_id %d thread busy!! (cnt_FH %i)\n",slave_proc->frame_rx,slave_proc->CC_id, cnt_slave);
-      exit_fun( "FH thread busy" );
-      break;
-    }             
-  }
-}
-
-uint32_t sync_corr[307200] __attribute__((aligned(32)));
-
-// This thread run the initial synchronization like a UE
-void *eNB_thread_synch(void *arg) {
-
-  PHY_VARS_eNB *eNB = (PHY_VARS_eNB*)arg;
-  LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms;
-  int32_t sync_pos,sync_pos2;
-  uint32_t peak_val;
-
-  thread_top_init("eNB_thread_synch",0,5000000,10000000,10000000);
-
-  wait_sync("eNB_thread_synch");
-
-  // initialize variables for PSS detection
-  lte_sync_time_init(&eNB->frame_parms);
-
-  while (!oai_exit) {
-
-    // wait to be woken up
-    pthread_mutex_lock(&eNB->proc.mutex_synch);
-    while (eNB->proc.instance_cnt_synch < 0)
-      pthread_cond_wait(&eNB->proc.cond_synch,&eNB->proc.mutex_synch);
-    pthread_mutex_unlock(&eNB->proc.mutex_synch);
-
-    // if we're not in synch, then run initial synch
-    if (eNB->in_synch == 0) { 
-      // run intial synch like UE
-      LOG_I(PHY,"Running initial synchronization\n");
-      
-      sync_pos = lte_sync_time_eNB(eNB->common_vars.rxdata[0],
-				   fp,
-				   fp->samples_per_tti*5,
-				   &peak_val,
-				   sync_corr);
-      LOG_I(PHY,"eNB synch: %d, val %d\n",sync_pos,peak_val);
-
-      if (sync_pos >= 0) {
-	if (sync_pos >= fp->nb_prefix_samples)
-	  sync_pos2 = sync_pos - fp->nb_prefix_samples;
-	else
-	  sync_pos2 = sync_pos + (fp->samples_per_tti*10) - fp->nb_prefix_samples;
-	
-	if (fp->frame_type == FDD) {
-	  
-	  // PSS is hypothesized in last symbol of first slot in Frame
-	  int sync_pos_slot = (fp->samples_per_tti>>1) - fp->ofdm_symbol_size - fp->nb_prefix_samples;
-	  
-	  if (sync_pos2 >= sync_pos_slot)
-	    eNB->rx_offset = sync_pos2 - sync_pos_slot;
-	  else
-	    eNB->rx_offset = (fp->samples_per_tti*10) + sync_pos2 - sync_pos_slot;
-	}
-	else {
-	  
-	}
-
-	LOG_I(PHY,"Estimated sync_pos %d, peak_val %d => timing offset %d\n",sync_pos,peak_val,eNB->rx_offset);
-	
-	/*
-	if ((peak_val > 300000) && (sync_pos > 0)) {
-	//      if (sync_pos++ > 3) {
-	write_output("eNB_sync.m","sync",(void*)&sync_corr[0],fp->samples_per_tti*5,1,2);
-	write_output("eNB_rx.m","rxs",(void*)eNB->common_vars.rxdata[0][0],fp->samples_per_tti*10,1,1);
-	exit(-1);
-	}
-	*/
-	eNB->in_synch=1;
-      }
-    }
-
-    // release thread
-    pthread_mutex_lock(&eNB->proc.mutex_synch);
-    eNB->proc.instance_cnt_synch--;
-    pthread_mutex_unlock(&eNB->proc.mutex_synch);
-  } // oai_exit
-
-  lte_sync_time_free();
-
-  return NULL;
-}
-
-int wakeup_synch(PHY_VARS_eNB *eNB){
-
-  struct timespec wait;
-  
-  wait.tv_sec=0;
-  wait.tv_nsec=5000000L;
-
-  // wake up synch thread
-  // lock the synch mutex and make sure the thread is ready
-  if (pthread_mutex_timedlock(&eNB->proc.mutex_synch,&wait) != 0) {
-    LOG_E( PHY, "[eNB] ERROR pthread_mutex_lock for eNB synch thread (IC %d)\n", eNB->proc.instance_cnt_synch );
-    exit_fun( "error locking mutex_synch" );
-    return(-1);
-  }
-  
-  ++eNB->proc.instance_cnt_synch;
-  
-  // the thread can now be woken up
-  if (pthread_cond_signal(&eNB->proc.cond_synch) != 0) {
-    LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB synch thread\n");
-    exit_fun( "ERROR pthread_cond_signal" );
-    return(-1);
-  }
-  
-  pthread_mutex_unlock( &eNB->proc.mutex_synch );
-
-  return(0);
-}
-
-/*!
- * \brief The Fronthaul thread of RRU/RAU/RCC/eNB
- * In the case of RRU/eNB, handles interface with external RF
- * In the case of RAU/RCC, handles fronthaul interface with RRU/RAU
- * \param param is a \ref eNB_proc_t structure which contains the info what to process.
- * \returns a pointer to an int. The storage is not on the heap and must not be freed.
- */
-
-static void* eNB_thread_FH( void* param ) {
-  
-  static int eNB_thread_FH_status;
-
-  eNB_proc_t *proc = (eNB_proc_t*)param;
-  PHY_VARS_eNB *eNB = PHY_vars_eNB_g[0][proc->CC_id];
-  LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms;
-
-  int subframe=0, frame=0; 
-
-  // set default return value
-  eNB_thread_FH_status = 0;
-
-  thread_top_init("eNB_thread_FH",0,870000,1000000,1000000);
-
-  wait_sync("eNB_thread_FH");
-
-#if defined(ENABLE_ITTI) && defined(ENABLE_USE_MME)
-  if (eNB->node_function < NGFI_RRU_IF5)
-    wait_system_ready ("Waiting for eNB application to be ready %s\r", &start_eNB);
-#endif 
-
-  // Start IF device if any
-  if (eNB->start_if) 
-    if (eNB->start_if(eNB) != 0)
-      LOG_E(HW,"Could not start the IF device\n");
-
-  // Start RF device if any
-  if (eNB->start_rf)
-    if (eNB->start_rf(eNB) != 0)
-      LOG_E(HW,"Could not start the RF device\n");
-
-  // wakeup asnych_rxtx thread because the devices are ready at this point
-  pthread_mutex_lock(&proc->mutex_asynch_rxtx);
-  proc->instance_cnt_asynch_rxtx=0;
-  pthread_mutex_unlock(&proc->mutex_asynch_rxtx);
-  pthread_cond_signal(&proc->cond_asynch_rxtx);
-
-  // This is a forever while loop, it loops over subframes which are scheduled by incoming samples from HW devices
-  while (!oai_exit) {
-
-    // these are local subframe/frame counters to check that we are in synch with the fronthaul timing.
-    // They are set on the first rx/tx in the underly FH routines.
-    if (subframe==9) { 
-      subframe=0;
-      frame++;
-      frame&=1023;
-    } else {
-      subframe++;
-    }      
-
- 
-    // synchronization on FH interface, acquire signals/data and block
-    if (eNB->rx_fh) eNB->rx_fh(eNB,&frame,&subframe);
-    else AssertFatal(1==0, "No fronthaul interface : eNB->node_function %d",eNB->node_function);
-
-    T(T_ENB_MASTER_TICK, T_INT(0), T_INT(proc->frame_rx), T_INT(proc->subframe_rx));
-
-    // At this point, all information for subframe has been received on FH interface
-    // If this proc is to provide synchronization, do so
-    wakeup_slaves(proc);
-      
-    // wake up RXn_TXnp4 thread for the subframe
-    // choose even or odd thread for RXn-TXnp4 processing 
-    if (wakeup_rxtx(proc,&proc->proc_rxtx[proc->subframe_rx&1],fp) < 0)
-      break;
-
-    // artifical sleep for very slow fronthaul
-    if (eNB->frame_parms.N_RB_DL==6)
-      rt_sleep_ns(800000LL);
-  }
-    
-  printf( "Exiting FH thread \n");
- 
-  eNB_thread_FH_status = 0;
-  return &eNB_thread_FH_status;
-}
-
-
 /*!
  * \brief The prach receive thread of eNB.
  * \param param is a \ref eNB_proc_t structure which contains the info what to process.
@@ -1468,8 +344,9 @@ static void* eNB_thread_FH( void* param ) {
 static void* eNB_thread_prach( void* param ) {
   static int eNB_thread_prach_status;
 
-  eNB_proc_t *proc = (eNB_proc_t*)param;
-  PHY_VARS_eNB *eNB= PHY_vars_eNB_g[0][proc->CC_id];
+
+  PHY_VARS_eNB *eNB= (PHY_VARS_eNB *)param;
+  eNB_proc_t *proc = &eNB->proc;
 
   // set default return value
   eNB_thread_prach_status = 0;
@@ -1493,166 +370,6 @@ static void* eNB_thread_prach( void* param ) {
   return &eNB_thread_prach_status;
 }
 
-static void* eNB_thread_single( void* param ) {
-
-  static int eNB_thread_single_status;
-
-  eNB_proc_t *proc = (eNB_proc_t*)param;
-  eNB_rxtx_proc_t *proc_rxtx = &proc->proc_rxtx[0];
-
-  PHY_VARS_eNB *eNB = RC.eNB[0][proc->CC_id];
-  LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms;
-  eNB->CC_id =  proc->CC_id;
-
-  void *rxp[2],*rxp2[2];
-
-  int subframe=0, frame=0; 
-
-  int32_t dummy_rx[fp->nb_antennas_rx][fp->samples_per_tti] __attribute__((aligned(32)));
-
-  int ic;
-
-  int rxs;
-
-  int i;
-
-  // initialize the synchronization buffer to the common_vars.rxdata
-  for (int i=0;i<fp->nb_antennas_rx;i++)
-    rxp[i] = &eNB->common_vars.rxdata[0][i][0];
-
-  // set default return value
-  eNB_thread_single_status = 0;
-
-  thread_top_init("eNB_thread_single",0,870000,1000000,1000000);
-
-  wait_sync("eNB_thread_single");
-
-#if defined(ENABLE_ITTI) && defined(ENABLE_USE_MME)
-  if (eNB->node_function < NGFI_RRU_IF5)
-    wait_system_ready ("Waiting for eNB application to be ready %s\r", &start_eNB);
-#endif 
-
-
-  // wakeup asnych_rxtx thread because the devices are ready at this point
-  pthread_mutex_lock(&proc->mutex_asynch_rxtx);
-  proc->instance_cnt_asynch_rxtx=0;
-  pthread_mutex_unlock(&proc->mutex_asynch_rxtx);
-  pthread_cond_signal(&proc->cond_asynch_rxtx);
-
-
-
-  // if this is a slave eNB, try to synchronize on the DL frequency
-  if ((eNB->is_slave) &&
-      ((eNB->node_function >= NGFI_RRU_IF5))) {
-    // if FDD, switch RX on DL frequency
-    
-    double temp_freq1 = eNB->rfdevice.openair0_cfg->rx_freq[0];
-    double temp_freq2 = eNB->rfdevice.openair0_cfg->tx_freq[0];
-    for (i=0;i<4;i++) {
-      eNB->rfdevice.openair0_cfg->rx_freq[i] = eNB->rfdevice.openair0_cfg->tx_freq[i];
-      eNB->rfdevice.openair0_cfg->tx_freq[i] = temp_freq1;
-    }
-    eNB->rfdevice.trx_set_freq_func(&eNB->rfdevice,eNB->rfdevice.openair0_cfg,0);
-
-    while ((eNB->in_synch ==0)&&(!oai_exit)) {
-      // read in frame
-      rxs = eNB->rfdevice.trx_read_func(&eNB->rfdevice,
-					&(proc->timestamp_rx),
-					rxp,
-					fp->samples_per_tti*10,
-					fp->nb_antennas_rx);
-
-      if (rxs != (fp->samples_per_tti*10))
-	exit_fun("Problem receiving samples\n");
-
-      // wakeup synchronization processing thread
-      wakeup_synch(eNB);
-      ic=0;
-      
-      while ((ic>=0)&&(!oai_exit)) {
-	// continuously read in frames, 1ms at a time, 
-	// until we are done with the synchronization procedure
-	
-	for (i=0; i<fp->nb_antennas_rx; i++)
-	  rxp2[i] = (void*)&dummy_rx[i][0];
-	for (i=0;i<10;i++)
-	  rxs = eNB->rfdevice.trx_read_func(&eNB->rfdevice,
-					    &(proc->timestamp_rx),
-					    rxp2,
-					    fp->samples_per_tti,
-					    fp->nb_antennas_rx);
-	if (rxs != fp->samples_per_tti)
-	  exit_fun( "problem receiving samples" );
-
-	pthread_mutex_lock(&eNB->proc.mutex_synch);
-	ic = eNB->proc.instance_cnt_synch;
-	pthread_mutex_unlock(&eNB->proc.mutex_synch);
-      } // ic>=0
-    } // in_synch==0
-    // read in rx_offset samples
-    LOG_I(PHY,"Resynchronizing by %d samples\n",eNB->rx_offset);
-    rxs = eNB->rfdevice.trx_read_func(&eNB->rfdevice,
-				      &(proc->timestamp_rx),
-				      rxp,
-				      eNB->rx_offset,
-				      fp->nb_antennas_rx);
-    if (rxs != eNB->rx_offset)
-      exit_fun( "problem receiving samples" );
-
-    for (i=0;i<4;i++) {
-      eNB->rfdevice.openair0_cfg->rx_freq[i] = temp_freq1;
-      eNB->rfdevice.openair0_cfg->tx_freq[i] = temp_freq2;
-    }
-    eNB->rfdevice.trx_set_freq_func(&eNB->rfdevice,eNB->rfdevice.openair0_cfg,1);
-  } // if RRU and slave
-
-
-  // This is a forever while loop, it loops over subframes which are scheduled by incoming samples from HW devices
-  while (!oai_exit) {
-
-    // these are local subframe/frame counters to check that we are in synch with the fronthaul timing.
-    // They are set on the first rx/tx in the underly FH routines.
-    if (subframe==9) { 
-      subframe=0;
-      frame++;
-      frame&=1023;
-    } else {
-      subframe++;
-    }      
-
-    if (eNB->CC_id==1) 
-	LOG_D(PHY,"eNB thread single %p (proc %p, CC_id %d), frame %d (%p), subframe %d (%p)\n",
-	  pthread_self(), proc, eNB->CC_id, frame,&frame,subframe,&subframe);
- 
-    // synchronization on FH interface, acquire signals/data and block
-    if (eNB->rx_fh) eNB->rx_fh(eNB,&frame,&subframe);
-    else AssertFatal(1==0, "No fronthaul interface : eNB->node_function %d",eNB->node_function);
-
-    T(T_ENB_MASTER_TICK, T_INT(0), T_INT(proc->frame_rx), T_INT(proc->subframe_rx));
-
-    proc_rxtx->subframe_rx = proc->subframe_rx;
-    proc_rxtx->frame_rx    = proc->frame_rx;
-    proc_rxtx->subframe_tx = (proc->subframe_rx+4)%10;
-    proc_rxtx->frame_tx    = (proc->subframe_rx>5) ? (1+proc->frame_rx)&1023 : proc->frame_rx;
-    proc->frame_tx         = proc_rxtx->frame_tx;
-    proc_rxtx->timestamp_tx = proc->timestamp_tx;
-    // adjust for timing offset between RRU
-    if (eNB->CC_id!=0) proc_rxtx->frame_tx = (proc_rxtx->frame_tx+proc->frame_offset)&1023;
-
-    // At this point, all information for subframe has been received on FH interface
-    // If this proc is to provide synchronization, do so
-    wakeup_slaves(proc);
-
-    if (rxtx(eNB,proc_rxtx,"eNB_thread_single") < 0) break;
-  }
-  
-
-  printf( "Exiting eNB_single thread \n");
- 
-  eNB_thread_single_status = 0;
-  return &eNB_thread_single_status;
-
-}
 
 extern void init_fep_thread(PHY_VARS_eNB *, pthread_attr_t *);
 extern void init_td_thread(PHY_VARS_eNB *, pthread_attr_t *);
@@ -1668,26 +385,21 @@ void init_eNB_proc(int inst) {
   pthread_attr_t *attr0=NULL,*attr1=NULL,*attr_FH=NULL,*attr_prach=NULL,*attr_asynch=NULL,*attr_single=NULL,*attr_fep=NULL,*attr_td=NULL,*attr_te=NULL,*attr_synch=NULL;
 
   for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
-    eNB = PHY_vars_eNB_g[inst][CC_id];
+    eNB = RC.eNB[inst][CC_id];
 #ifndef OCP_FRAMEWORK
-    LOG_I(PHY,"Initializing eNB %d CC_id %d (%s,%s),\n",inst,CC_id,eNB_functions[eNB->node_function],eNB_timing[eNB->node_timing]);
+    LOG_I(PHY,"Initializing eNB processes %d CC_id %d \n",inst,CC_id);
 #endif
     proc = &eNB->proc;
 
-    proc_rxtx = proc->proc_rxtx;
+    proc_rxtx                      = proc->proc_rxtx;
     proc_rxtx[0].instance_cnt_rxtx = -1;
     proc_rxtx[1].instance_cnt_rxtx = -1;
     proc->instance_cnt_prach       = -1;
-    proc->instance_cnt_FH          = -1;
     proc->instance_cnt_asynch_rxtx = -1;
-    proc->CC_id = CC_id;    
-    proc->instance_cnt_synch        =  -1;
+    proc->CC_id                    = CC_id;    
 
     proc->first_rx=1;
     proc->first_tx=1;
-    proc->frame_offset = 0;
-
-    for (i=0;i<10;i++) proc->symbol_mask[i]=0;
 
     pthread_mutex_init( &proc_rxtx[0].mutex_rxtx, NULL);
     pthread_mutex_init( &proc_rxtx[1].mutex_rxtx, NULL);
@@ -1696,19 +408,13 @@ void init_eNB_proc(int inst) {
 
     pthread_mutex_init( &proc->mutex_prach, NULL);
     pthread_mutex_init( &proc->mutex_asynch_rxtx, NULL);
-    pthread_mutex_init( &proc->mutex_synch,NULL);
 
     pthread_cond_init( &proc->cond_prach, NULL);
-    pthread_cond_init( &proc->cond_FH, NULL);
     pthread_cond_init( &proc->cond_asynch_rxtx, NULL);
-    pthread_cond_init( &proc->cond_synch,NULL);
 
-    pthread_attr_init( &proc->attr_FH);
     pthread_attr_init( &proc->attr_prach);
-    pthread_attr_init( &proc->attr_synch);
     pthread_attr_init( &proc->attr_asynch_rxtx);
     pthread_attr_init( &proc->attr_single);
-    pthread_attr_init( &proc->attr_fep);
     pthread_attr_init( &proc->attr_td);
     pthread_attr_init( &proc->attr_te);
     pthread_attr_init( &proc_rxtx[0].attr_rxtx);
@@ -1716,49 +422,25 @@ void init_eNB_proc(int inst) {
 #ifndef DEADLINE_SCHEDULER
     attr0       = &proc_rxtx[0].attr_rxtx;
     attr1       = &proc_rxtx[1].attr_rxtx;
-    attr_FH     = &proc->attr_FH;
     attr_prach  = &proc->attr_prach;
-    attr_synch  = &proc->attr_synch;
     attr_asynch = &proc->attr_asynch_rxtx;
     attr_single = &proc->attr_single;
-    attr_fep    = &proc->attr_fep;
     attr_td     = &proc->attr_td;
     attr_te     = &proc->attr_te; 
 #endif
 
-    if (eNB->single_thread_flag==0) {
-      pthread_create( &proc_rxtx[0].pthread_rxtx, attr0, eNB_thread_rxtx, &proc_rxtx[0] );
-      pthread_create( &proc_rxtx[1].pthread_rxtx, attr1, eNB_thread_rxtx, &proc_rxtx[1] );
-      pthread_create( &proc->pthread_FH, attr_FH, eNB_thread_FH, &eNB->proc );
-    }
-    else {
-      pthread_create(&proc->pthread_single, attr_single, eNB_thread_single, &eNB->proc);
-      init_fep_thread(eNB,attr_fep);
-      init_td_thread(eNB,attr_td);
-      init_te_thread(eNB,attr_te);
-    }
-    pthread_create( &proc->pthread_prach, attr_prach, eNB_thread_prach, &eNB->proc );
-    pthread_create( &proc->pthread_synch, attr_synch, eNB_thread_synch, eNB);
-    if ((eNB->node_timing == synch_to_other) ||
-	(eNB->node_function == NGFI_RRU_IF5) ||
-	(eNB->node_function == NGFI_RRU_IF4p5))
-
-
-      pthread_create( &proc->pthread_asynch_rxtx, attr_asynch, eNB_thread_asynch_rxtx, &eNB->proc );
+    pthread_create( &proc_rxtx[0].pthread_rxtx, attr0, eNB_thread_rxtx, &proc_rxtx[0] );
+    pthread_create( &proc_rxtx[1].pthread_rxtx, attr1, eNB_thread_rxtx, &proc_rxtx[1] );
+    pthread_create( &proc->pthread_prach, attr_prach, eNB_thread_prach, eNB );
 
     char name[16];
-    if (eNB->single_thread_flag == 0) {
-      snprintf( name, sizeof(name), "RXTX0 %d", i );
-      pthread_setname_np( proc_rxtx[0].pthread_rxtx, name );
-      snprintf( name, sizeof(name), "RXTX1 %d", i );
-      pthread_setname_np( proc_rxtx[1].pthread_rxtx, name );
-      snprintf( name, sizeof(name), "FH %d", i );
-      pthread_setname_np( proc->pthread_FH, name );
-    }
-    else {
-      snprintf( name, sizeof(name), " %d", i );
-      pthread_setname_np( proc->pthread_single, name );
-    }
+    snprintf( name, sizeof(name), "RXTX0 %d", i );
+    pthread_setname_np( proc_rxtx[0].pthread_rxtx, name );
+    snprintf( name, sizeof(name), "RXTX1 %d", i );
+    pthread_setname_np( proc_rxtx[1].pthread_rxtx, name );
+    //    snprintf( name, sizeof(name), "FH %d", i );
+    //    pthread_setname_np( proc->pthread_FH, name );
+    
   }
 
   //for multiple CCs: setup master and slaves
@@ -1796,7 +478,7 @@ void kill_eNB_proc(int inst) {
   eNB_proc_t *proc;
   eNB_rxtx_proc_t *proc_rxtx;
   for (int CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
-    eNB=PHY_vars_eNB_g[inst][CC_id];
+    eNB=RC.eNB[inst][CC_id];
     
     proc = &eNB->proc;
     proc_rxtx = &proc->proc_rxtx[0];
@@ -1808,17 +490,10 @@ void kill_eNB_proc(int inst) {
     proc_rxtx[0].instance_cnt_rxtx = 0; // FIXME data race!
     proc_rxtx[1].instance_cnt_rxtx = 0; // FIXME data race!
     proc->instance_cnt_prach = 0;
-    proc->instance_cnt_FH = 0;
     pthread_cond_signal( &proc_rxtx[0].cond_rxtx );    
     pthread_cond_signal( &proc_rxtx[1].cond_rxtx );
     pthread_cond_signal( &proc->cond_prach );
-    pthread_cond_signal( &proc->cond_FH );
     pthread_cond_broadcast(&sync_phy_proc.cond_phy_proc_tx);
-
-    pthread_join( proc->pthread_FH, (void**)&status ); 
-    pthread_mutex_destroy( &proc->mutex_FH );
-    pthread_cond_destroy( &proc->cond_FH );
-            
     pthread_join( proc->pthread_prach, (void**)&status );    
     pthread_mutex_destroy( &proc->mutex_prach );
     pthread_cond_destroy( &proc->cond_prach );         
@@ -1833,99 +508,6 @@ void kill_eNB_proc(int inst) {
 }
 
 
-/* this function maps the phy_vars_eNB tx and rx buffers to the available rf chains.
-   Each rf chain is is addressed by the card number and the chain on the card. The
-   rf_map specifies for each CC, on which rf chain the mapping should start. Multiple
-   antennas are mapped to successive RF chains on the same card. */
-int setup_eNB_buffers(PHY_VARS_eNB **phy_vars_eNB, openair0_config_t *openair0_cfg) {
-
-  int i,j; 
-  int CC_id,card,ant;
-
-  //uint16_t N_TA_offset = 0;
-
-  LTE_DL_FRAME_PARMS *frame_parms;
-
-  for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
-    if (phy_vars_eNB[CC_id]) {
-      frame_parms = &(phy_vars_eNB[CC_id]->frame_parms);
-      printf("setup_eNB_buffers: frame_parms = %p\n",frame_parms);
-    } else {
-      printf("phy_vars_eNB[%d] not initialized\n", CC_id);
-      return(-1);
-    }
-
-    /*
-    if (frame_parms->frame_type == TDD) {
-      if (frame_parms->N_RB_DL == 100)
-        N_TA_offset = 624;
-      else if (frame_parms->N_RB_DL == 50)
-        N_TA_offset = 624/2;
-      else if (frame_parms->N_RB_DL == 25)
-        N_TA_offset = 624/4;
-    }
-    */
- 
-
-    if (openair0_cfg[CC_id].mmapped_dma == 1) {
-    // replace RX signal buffers with mmaped HW versions
-      
-      for (i=0; i<frame_parms->nb_antennas_rx; i++) {
-	card = i/4;
-	ant = i%4;
-	printf("Mapping eNB CC_id %d, rx_ant %d, on card %d, chain %d\n",CC_id,i,phy_vars_eNB[CC_id]->rf_map.card+card, phy_vars_eNB[CC_id]->rf_map.chain+ant);
-	free(phy_vars_eNB[CC_id]->common_vars.rxdata[0][i]);
-	phy_vars_eNB[CC_id]->common_vars.rxdata[0][i] = openair0_cfg[phy_vars_eNB[CC_id]->rf_map.card+card].rxbase[phy_vars_eNB[CC_id]->rf_map.chain+ant];
-	
-	printf("rxdata[%d] @ %p\n",i,phy_vars_eNB[CC_id]->common_vars.rxdata[0][i]);
-	for (j=0; j<16; j++) {
-	  printf("rxbuffer %d: %x\n",j,phy_vars_eNB[CC_id]->common_vars.rxdata[0][i][j]);
-	  phy_vars_eNB[CC_id]->common_vars.rxdata[0][i][j] = 16-j;
-	}
-      }
-      
-      for (i=0; i<frame_parms->nb_antennas_tx; i++) {
-	card = i/4;
-	ant = i%4;
-	printf("Mapping eNB CC_id %d, tx_ant %d, on card %d, chain %d\n",CC_id,i,phy_vars_eNB[CC_id]->rf_map.card+card, phy_vars_eNB[CC_id]->rf_map.chain+ant);
-	free(phy_vars_eNB[CC_id]->common_vars.txdata[0][i]);
-	phy_vars_eNB[CC_id]->common_vars.txdata[0][i] = openair0_cfg[phy_vars_eNB[CC_id]->rf_map.card+card].txbase[phy_vars_eNB[CC_id]->rf_map.chain+ant];
-	
-	printf("txdata[%d] @ %p\n",i,phy_vars_eNB[CC_id]->common_vars.txdata[0][i]);
-	
-	for (j=0; j<16; j++) {
-	  printf("txbuffer %d: %x\n",j,phy_vars_eNB[CC_id]->common_vars.txdata[0][i][j]);
-	  phy_vars_eNB[CC_id]->common_vars.txdata[0][i][j] = 16-j;
-	}
-      }
-    }
-    else {  // not memory-mapped DMA 
-      //nothing to do, everything already allocated in lte_init
-      /*
-      rxdata = (int32_t**)malloc16(frame_parms->nb_antennas_rx*sizeof(int32_t*));
-      txdata = (int32_t**)malloc16(frame_parms->nb_antennas_tx*sizeof(int32_t*));
-      
-      for (i=0; i<frame_parms->nb_antennas_rx; i++) {
-	free(phy_vars_eNB[CC_id]->common_vars.rxdata[0][i]);
-	rxdata[i] = (int32_t*)(32 + malloc16(32+frame_parms->samples_per_tti*10*sizeof(int32_t))); // FIXME broken memory allocation
-	phy_vars_eNB[CC_id]->common_vars.rxdata[0][i] = rxdata[i]; //-N_TA_offset; // N_TA offset for TDD         FIXME! N_TA_offset > 16 => access of unallocated memory
-	memset(rxdata[i], 0, frame_parms->samples_per_tti*10*sizeof(int32_t));
-	printf("rxdata[%d] @ %p (%p) (N_TA_OFFSET %d)\n", i, phy_vars_eNB[CC_id]->common_vars.rxdata[0][i],rxdata[i],N_TA_offset);      
-      }
-      
-      for (i=0; i<frame_parms->nb_antennas_tx; i++) {
-	free(phy_vars_eNB[CC_id]->common_vars.txdata[0][i]);
-	txdata[i] = (int32_t*)(32 + malloc16(32 + frame_parms->samples_per_tti*10*sizeof(int32_t))); // FIXME broken memory allocation
-	phy_vars_eNB[CC_id]->common_vars.txdata[0][i] = txdata[i];
-	memset(txdata[i],0, frame_parms->samples_per_tti*10*sizeof(int32_t));
-	printf("txdata[%d] @ %p\n", i, phy_vars_eNB[CC_id]->common_vars.txdata[0][i]);
-      }
-      */
-    }
-  }
-
-  return(0);
-}
 
 
 void reset_opp_meas(void) {
@@ -1952,407 +534,143 @@ void print_opp_meas(void) {
     print_meas(&softmodem_stats_rx_sf,"[eNB][total_phy_proc_rx]",NULL,NULL);
   }
 }
- 
-int start_if(PHY_VARS_eNB *eNB) {
-  return(eNB->ifdevice.trx_start_func(&eNB->ifdevice));
-}
 
-int start_rf(PHY_VARS_eNB *eNB) {
-  return(eNB->rfdevice.trx_start_func(&eNB->rfdevice));
-}
-
-extern void eNB_fep_rru_if5(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc);
-extern void eNB_fep_full(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc);
-extern void eNB_fep_full_2thread(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc);
-extern void do_prach(PHY_VARS_eNB *eNB,int frame,int subframe);
+void init_transport(PHY_VARS_eNB *eNB) {
 
-/*
-void init_RU(RAN_CONTEXT *rc,RU_if_in_t ru_if_in[], RU_if_timing_t ru_if_timing[], eth_params_t *eth_params) {
-  
-  int ru_id;
+  int i;
+  int j;
+  LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms;
 
-  for (ru_id=0;ru_id<rc->nb_RU;ru_id++) {
-    ru = &rc.ru_desc[ru_id];
-    ru->RU_if_in[ru_id]     = ru_if_in[ru_id];
-    ru->RU_if_timing        = ru_if_timing[ru_id];
-    LOG_I(PHY,"Initializing RRU descriptor %d : (%s,%s)\n",ru_id,ru_if_types[ru_if_in[ru_id]],eNB_timing[ru_timing[ru_id]]);
-    
-    switch (ru->RU_if_in[ru_id]) {
-    case REMOTE_IF5:
-      pc->fep                   = pc_fep_rru_if5;
-      eNB->rx_fh                = rx_rf;
-      eNB->start_rf             = start_rf;
-      eNB->start_if             = start_if;
-      eNB->fh_asynch            = fh_if5_asynch_DL;
-      ret = openair0_device_load(&eNB->rfdevice, &openair0_cfg[CC_id]);
-      if (ret<0) {
-	printf("Exiting, cannot initialize rf device\n");
-	exit(-1);
-      }
-      eNB->rfdevice.host_type   = RRH_HOST;
-      eNB->ifdevice.host_type   = RRH_HOST;
-      ret = openair0_transport_load(&eNB->ifdevice, &openair0_cfg[CC_id], (eth_params+CC_id));
-      printf("openair0_transport_init returns %d for CC_id %d\n",ret,CC_id);
-      if (ret<0) {
-	printf("Exiting, cannot initialize transport protocol\n");
-	exit(-1);
-      }
-      break;
-    case NGFI_RRU_IF4p5:
-      eNB->do_prach             = do_prach;
-      eNB->fep                  = eNB_fep_full;//(single_thread_flag==1) ? eNB_fep_full_2thread : eNB_fep_full;
-      eNB->td                   = NULL;
-      eNB->te                   = NULL;
-      eNB->proc_uespec_rx       = NULL;
-      eNB->proc_tx              = NULL;//proc_tx_rru_if4p5;
-      eNB->tx_fh                = NULL;
-      eNB->rx_fh                = rx_rf;
-      eNB->fh_asynch            = fh_if4p5_asynch_DL;
-      eNB->start_rf             = start_rf;
-      eNB->start_if             = start_if;
-      ret = openair0_device_load(&eNB->rfdevice, &openair0_cfg[CC_id]);
-      if (ret<0) {
-	printf("Exiting, cannot initialize rf device\n");
-	exit(-1);
-      }
-      eNB->rfdevice.host_type   = RRH_HOST;
-      eNB->ifdevice.host_type   = RRH_HOST;
-      ret = openair0_transport_load(&eNB->ifdevice, &openair0_cfg[CC_id], (eth_params+CC_id));
-      printf("openair0_transport_init returns %d for CC_id %d\n",ret,CC_id);
-      if (ret<0) {
-	printf("Exiting, cannot initialize transport protocol\n");
-	exit(-1);
-      }
-      
-      malloc_IF4p5_buffer(eNB);
-      
-      break;
-    case eNodeB_3GPP:
-      eNB->do_prach             = do_prach;
-      eNB->fep                  = eNB_fep_full;//(single_thread_flag==1) ? eNB_fep_full_2thread : eNB_fep_full;
-      eNB->td                   = ulsch_decoding_data;//(single_thread_flag==1) ? ulsch_decoding_data_2thread : ulsch_decoding_data;
-      eNB->te                   = dlsch_encoding;//(single_thread_flag==1) ? dlsch_encoding_2threads : dlsch_encoding;
-      eNB->proc_uespec_rx       = phy_procedures_eNB_uespec_RX;
-      eNB->proc_tx              = proc_tx_full;
-      eNB->tx_fh                = NULL;
-      eNB->rx_fh                = rx_rf;
-      eNB->start_rf             = start_rf;
-      eNB->start_if             = NULL;
-      eNB->fh_asynch            = NULL;
-      ret = openair0_device_load(&eNB->rfdevice, &openair0_cfg[CC_id]);
-      if (ret<0) {
-	printf("Exiting, cannot initialize rf device\n");
+  for (i=0; i<NUMBER_OF_UE_MAX; i++) {
+    LOG_I(PHY,"Allocating Transport Channel Buffers for DLSCH, UE %d\n",i);
+    for (j=0; j<2; j++) {
+      eNB->dlsch[i][j] = new_eNB_dlsch(1,8,NSOFT,fp->N_RB_DL,0,fp);
+      if (!eNB->dlsch[i][j]) {
+	LOG_E(PHY,"Can't get eNB dlsch structures for UE %d \n", i);
 	exit(-1);
-      }
-      eNB->rfdevice.host_type   = BBU_HOST;
-      eNB->ifdevice.host_type   = BBU_HOST;
-      break;
-    case eNodeB_3GPP_BBU:
-      eNB->do_prach       = do_prach;
-      eNB->fep            = eNB_fep_full;//(single_thread_flag==1) ? eNB_fep_full_2thread : eNB_fep_full;
-      eNB->td             = ulsch_decoding_data;//(single_thread_flag==1) ? ulsch_decoding_data_2thread : ulsch_decoding_data;
-      eNB->te             = dlsch_encoding;//(single_thread_flag==1) ? dlsch_encoding_2threads : dlsch_encoding;
-      eNB->proc_uespec_rx = phy_procedures_eNB_uespec_RX;
-      eNB->proc_tx        = proc_tx_full;
-      if (eNB->node_timing == synch_to_other) {
-	eNB->tx_fh          = tx_fh_if5_mobipass;
-	eNB->rx_fh          = rx_fh_slave;
-	eNB->fh_asynch      = fh_if5_asynch_UL;
-	
-      }
-      else {
-	eNB->tx_fh          = tx_fh_if5;
-	eNB->rx_fh          = rx_fh_if5;
-	eNB->fh_asynch      = NULL;
-      }
-      
-      eNB->start_rf       = NULL;
-	eNB->start_if       = start_if;
-	eNB->rfdevice.host_type   = BBU_HOST;
-	
-	eNB->ifdevice.host_type   = BBU_HOST;
-
-        ret = openair0_transport_load(&eNB->ifdevice, &openair0_cfg[CC_id], (eth_params+CC_id));
-        printf("openair0_transport_init returns %d for CC_id %d\n",ret,CC_id);
-        if (ret<0) {
-          printf("Exiting, cannot initialize transport protocol\n");
-          exit(-1);
-        }
-	break;
-      case NGFI_RCC_IF4p5:
-	eNB->do_prach             = do_prach;
-	eNB->fep                  = NULL;
-	eNB->td                   = ulsch_decoding_data;//(single_thread_flag==1) ? ulsch_decoding_data_2thread : ulsch_decoding_data;
-	eNB->te                   = dlsch_encoding;//(single_thread_flag==1) ? dlsch_encoding_2threads : dlsch_encoding;
-	eNB->proc_uespec_rx       = phy_procedures_eNB_uespec_RX;
-	eNB->proc_tx              = proc_tx_high;
-	eNB->tx_fh                = tx_fh_if4p5;
-	eNB->rx_fh                = rx_fh_if4p5;
-	eNB->start_rf             = NULL;
-	eNB->start_if             = start_if;
-        eNB->fh_asynch            = (eNB->node_timing == synch_to_other) ? fh_if4p5_asynch_UL : NULL;
-	eNB->rfdevice.host_type   = BBU_HOST;
-	eNB->ifdevice.host_type   = BBU_HOST;
-        ret = openair0_transport_load(&eNB->ifdevice, &openair0_cfg[CC_id], (eth_params+CC_id));
-        printf("openair0_transport_init returns %d for CC_id %d\n",ret,CC_id);
-        if (ret<0) {
-          printf("Exiting, cannot initialize transport protocol\n");
-          exit(-1);
-        }
-	malloc_IF4p5_buffer(eNB);
-
-	break;
-      case NGFI_RAU_IF4p5:
-	eNB->do_prach       = do_prach;
-	eNB->fep            = NULL;
-
-	eNB->td             = ulsch_decoding_data;//(single_thread_flag==1) ? ulsch_decoding_data_2thread : ulsch_decoding_data;
-	eNB->te             = dlsch_encoding;//(single_thread_flag==1) ? dlsch_encoding_2threads : dlsch_encoding;
-	eNB->proc_uespec_rx = phy_procedures_eNB_uespec_RX;
-	eNB->proc_tx        = proc_tx_high;
-	eNB->tx_fh          = tx_fh_if4p5; 
-	eNB->rx_fh          = rx_fh_if4p5; 
-        eNB->fh_asynch      = (eNB->node_timing == synch_to_other) ? fh_if4p5_asynch_UL : NULL;
-	eNB->start_rf       = NULL;
-	eNB->start_if       = start_if;
-
-	eNB->rfdevice.host_type   = BBU_HOST;
-	eNB->ifdevice.host_type   = BBU_HOST;
-        ret = openair0_transport_load(&eNB->ifdevice, &openair0_cfg[CC_id], (eth_params+CC_id));
-        printf("openair0_transport_init returns %d for CC_id %d\n",ret,CC_id);
-        if (ret<0) {
-          printf("Exiting, cannot initialize transport protocol\n");
-          exit(-1);
-        }
-	break;	
-	malloc_IF4p5_buffer(eNB);
-
+      } else {
+	LOG_D(PHY,"dlsch[%d][%d] => %p\n",i,j,eNB->dlsch[i][j]);
+	eNB->dlsch[i][j]->rnti=0;
       }
     }
-
-    if (setup_eNB_buffers(PHY_vars_eNB_g[inst],&openair0_cfg[CC_id])!=0) {
-      printf("Exiting, cannot initialize eNodeB Buffers\n");
+    
+    LOG_I(PHY,"Allocating Transport Channel Buffer for ULSCH, UE %d\n",i);
+    eNB->ulsch[1+i] = new_eNB_ulsch(MAX_TURBO_ITERATIONS,fp->N_RB_UL, 0);
+    
+    if (!eNB->ulsch[1+i]) {
+      LOG_E(PHY,"Can't get eNB ulsch structures\n");
       exit(-1);
     }
-
-    init_eNB_proc(inst);
+    
+    // this is the transmission mode for the signalling channels
+    // this will be overwritten with the real transmission mode by the RRC once the UE is connected
+    eNB->transmission_mode[i] = fp->nb_antenna_ports_eNB==1 ? 1 : 2;
   }
-
-  sleep(1);
-  LOG_D(HW,"[lte-softmodem.c] eNB threads created\n");
+  // ULSCH for RA
+  eNB->ulsch[0] = new_eNB_ulsch(MAX_TURBO_ITERATIONS, fp->N_RB_UL, 0);
+  
+  if (!eNB->ulsch[0]) {
+    LOG_E(PHY,"Can't get eNB ulsch structures\n");
+    exit(-1);
+  }
+  eNB->dlsch_SI  = new_eNB_dlsch(1,8,NSOFT,fp->N_RB_DL, 0, fp);
+  LOG_D(PHY,"eNB %d.%d : SI %p\n",eNB->Mod_id,eNB->CC_id,eNB->dlsch_SI);
+  eNB->dlsch_ra  = new_eNB_dlsch(1,8,NSOFT,fp->N_RB_DL, 0, fp);
+  LOG_D(PHY,"eNB %d.%d : RA %p\n",eNB->Mod_id,eNB->CC_id,eNB->dlsch_ra);
+  eNB->dlsch_MCH = new_eNB_dlsch(1,8,NSOFT,fp->N_RB_DL, 0, fp);
+  LOG_D(PHY,"eNB %d.%d : MCH %p\n",eNB->Mod_id,eNB->CC_id,eNB->dlsch_MCH);
+  
+  
+  eNB->rx_total_gain_dB=130;
   
+  for(i=0; i<NUMBER_OF_UE_MAX; i++)
+    eNB->mu_mimo_mode[i].dl_pow_off = 2;
+  
+  eNB->check_for_total_transmissions = 0;
+  
+  eNB->check_for_MUMIMO_transmissions = 0;
+  
+  eNB->FULL_MUMIMO_transmissions = 0;
+  
+  eNB->check_for_SUMIMO_transmissions = 0;
+  
+  fp->pucch_config_common.deltaPUCCH_Shift = 1;
+    
+} 
+void init_eNB_afterRU() {
 
-}
-*/
+  int inst,CC_id,ru_id,i,aa;
+  PHY_VARS_eNB *eNB;
 
 
-void init_eNB(eNB_func_t node_function[], eNB_timing_t node_timing[],int nb_inst,eth_params_t *eth_params,int single_thread_flag,int wait_for_sync) {
+  for (inst=0;inst<RC.nb_inst;inst++) {
+    for (CC_id=0;CC_id<RC.nb_CC[inst];CC_id++) {
+      eNB                                  =  RC.eNB[inst][CC_id];
+      phy_init_lte_eNB(eNB,0,0);
+
+      // map antennas and PRACH signals to eNB RX
+      AssertFatal(eNB->num_RU>0,"Number of RU attached to eNB %d is zero\n",eNB->Mod_id);
+      LOG_I(PHY,"Mapping RX ports from %d RUs to eNB %d\n",eNB->num_RU,eNB->Mod_id);
+      for (ru_id=0,aa=0;ru_id<eNB->num_RU;ru_id++) {
+	eNB->frame_parms.nb_antennas_rx    += eNB->RU_list[ru_id]->nb_rx;
+	for (i=0;i<eNB->RU_list[ru_id]->nb_rx;aa++,i++) { 
+	  LOG_I(PHY,"Attaching RU %d antenna %d to eNB antenna %d\n",eNB->RU_list[ru_id]->idx,i,aa);
+	  eNB->prach_vars.rxsigF[aa]       =  eNB->RU_list[ru_id]->prach_rxsigF[i];
+	  eNB->common_vars.rxdataF[aa]     =  eNB->RU_list[ru_id]->common.rxdataF[i];
+	}
+      }
+
+      AssertFatal(eNB->frame_parms.nb_antennas_rx <= sizeof(eNB->prach_vars.prach_ifft) / sizeof(eNB->prach_vars.prach_ifft[0]),
+		  "nb_antennas_rx too large");
+      for (i=0; i<eNB->frame_parms.nb_antennas_rx; i++) {
+	eNB->prach_vars.prach_ifft[i] = (int16_t*)malloc16_clear(1024*2*sizeof(int16_t));
+	LOG_D(PHY,"[INIT] prach_vars->prach_ifft[%d] = %p\n",i,eNB->prach_vars.prach_ifft[i]);
+      }
+      init_transport(eNB);
+      init_precoding_weights(RC.eNB[inst][CC_id]);
+    }
+    init_eNB_proc(inst);
+  }
 
+  for (ru_id=0;ru_id<RC.nb_RU;ru_id++) {
+    
+    if (RC.ru[ru_id]==NULL) RC.ru[ru_id] = (RU_t*)malloc(sizeof(RU_t));
+    
+    RC.ru[ru_id]->wakeup_rxtx = wakeup_rxtx;
+    RC.ru[ru_id]->eNB_top     = eNB_top;
+  }
+}
+void init_eNB(int single_thread_flag,int wait_for_sync) {
   
   int CC_id;
   int inst;
   PHY_VARS_eNB *eNB;
   int ret;
 
-  for (inst=0;inst<nb_inst;inst++) {
-    for (CC_id=0;CC_id<MAX_NUM_CCs;CC_id++) {
-      eNB = PHY_vars_eNB_g[inst][CC_id]; 
-      eNB->node_function      = node_function[CC_id];
-      eNB->node_timing        = node_timing[CC_id];
-      eNB->eth_params         = eth_params+CC_id;
+  if (RC.eNB == NULL) RC.eNB = (PHY_VARS_eNB***) malloc(RC.nb_inst*sizeof(PHY_VARS_eNB **));
+  for (inst=0;inst<RC.nb_inst;inst++) {
+    if (RC.eNB[inst] == NULL) RC.eNB[inst] = (PHY_VARS_eNB*) malloc(RC.nb_CC[inst]*sizeof(PHY_VARS_eNB *));
+    for (CC_id=0;CC_id<RC.nb_CC[inst];CC_id++) {
+      if (RC.eNB[inst][CC_id] == NULL) RC.eNB[inst][CC_id] = (PHY_VARS_eNB*) malloc(sizeof(PHY_VARS_eNB));
+      eNB                     = RC.eNB[inst][CC_id]; 
       eNB->abstraction_flag   = 0;
       eNB->single_thread_flag = single_thread_flag;
-      eNB->ts_offset          = 0;
-      eNB->in_synch           = 0;
-      eNB->is_slave           = (wait_for_sync>0) ? 1 : 0;
 
 
 #ifndef OCP_FRAMEWORK
-      LOG_I(PHY,"Initializing eNB %d CC_id %d : (%s,%s)\n",inst,CC_id,eNB_functions[node_function[CC_id]],eNB_timing[node_timing[CC_id]]);
+      LOG_I(PHY,"Initializing eNB %d CC_id %d\n",inst,CC_id);
 #endif
 
-      switch (node_function[CC_id]) {
-      case NGFI_RRU_IF5:
-	eNB->do_prach             = NULL;
-	eNB->do_precoding         = 0;
-	eNB->fep                  = eNB_fep_rru_if5;
-	eNB->td                   = NULL;
-	eNB->te                   = NULL;
-	eNB->proc_uespec_rx       = NULL;
-	eNB->proc_tx              = NULL;
-	eNB->tx_fh                = NULL;
-	eNB->rx_fh                = rx_rf;
-	eNB->start_rf             = start_rf;
-	eNB->start_if             = start_if;
-	eNB->fh_asynch            = fh_if5_asynch_DL;
-	if (oaisim_flag == 0) {
-	  ret = openair0_device_load(&eNB->rfdevice, &openair0_cfg[CC_id]);
-	  if (ret<0) {
-	    printf("Exiting, cannot initialize rf device\n");
-	    exit(-1);
-	  }
-	}
-	eNB->rfdevice.host_type   = RRH_HOST;
-	eNB->ifdevice.host_type   = RRH_HOST;
-        ret = openair0_transport_load(&eNB->ifdevice, &openair0_cfg[CC_id], eNB->eth_params);
-	printf("openair0_transport_init returns %d for CC_id %d\n",ret,CC_id);
-        if (ret<0) {
-          printf("Exiting, cannot initialize transport protocol\n");
-          exit(-1);
-        }
-	break;
-      case NGFI_RRU_IF4p5:
-	eNB->do_precoding         = 0;
-	eNB->do_prach             = do_prach;
-	eNB->fep                  = eNB_fep_full;//(single_thread_flag==1) ? eNB_fep_full_2thread : eNB_fep_full;
-	eNB->td                   = NULL;
-	eNB->te                   = NULL;
-	eNB->proc_uespec_rx       = NULL;
-	eNB->proc_tx              = NULL;//proc_tx_rru_if4p5;
-	eNB->tx_fh                = NULL;
-	eNB->rx_fh                = rx_rf;
-	eNB->fh_asynch            = fh_if4p5_asynch_DL;
-	eNB->start_rf             = start_rf;
-	eNB->start_if             = start_if;
-	if (oaisim_flag == 0) {
-	  ret = openair0_device_load(&eNB->rfdevice, &openair0_cfg[CC_id]);
-	  if (ret<0) {
-	    printf("Exiting, cannot initialize rf device\n");
-	    exit(-1);
-	  }
-	}
-	eNB->rfdevice.host_type   = RRH_HOST;
-	eNB->ifdevice.host_type   = RRH_HOST;
-	printf("loading transport interface ...\n");
-        ret = openair0_transport_load(&eNB->ifdevice, &openair0_cfg[CC_id], eNB->eth_params);
-	printf("openair0_transport_init returns %d for CC_id %d\n",ret,CC_id);
-        if (ret<0) {
-          printf("Exiting, cannot initialize transport protocol\n");
-          exit(-1);
-        }
-
-	malloc_IF4p5_buffer(eNB);
-
-	break;
-      case eNodeB_3GPP:
-	eNB->do_precoding         = eNB->frame_parms.nb_antennas_tx!=eNB->frame_parms.nb_antenna_ports_eNB;
-	eNB->do_prach             = do_prach;
-	eNB->fep                  = eNB_fep_full;//(single_thread_flag==1) ? eNB_fep_full_2thread : eNB_fep_full;
-	eNB->td                   = ulsch_decoding_data;//(single_thread_flag==1) ? ulsch_decoding_data_2thread : ulsch_decoding_data;
-	eNB->te                   = dlsch_encoding;//(single_thread_flag==1) ? dlsch_encoding_2threads : dlsch_encoding;
-	eNB->proc_uespec_rx       = phy_procedures_eNB_uespec_RX;
-	eNB->proc_tx              = proc_tx_full;
-	eNB->tx_fh                = NULL;
-	eNB->rx_fh                = rx_rf;
-	eNB->start_rf             = start_rf;
-	eNB->start_if             = NULL;
-        eNB->fh_asynch            = NULL;
-        if (oaisim_flag == 0) {
-  	  ret = openair0_device_load(&eNB->rfdevice, &openair0_cfg[CC_id]);
-          if (ret<0) {
-            printf("Exiting, cannot initialize rf device\n");
-            exit(-1);
-          }
-        }
-	eNB->rfdevice.host_type   = BBU_HOST;
-	eNB->ifdevice.host_type   = BBU_HOST;
-	break;
-      case eNodeB_3GPP_BBU:
-	eNB->do_precoding         = eNB->frame_parms.nb_antennas_tx!=eNB->frame_parms.nb_antenna_ports_eNB;
-	eNB->do_prach             = do_prach;
-	eNB->fep                  = eNB_fep_full;//(single_thread_flag==1) ? eNB_fep_full_2thread : eNB_fep_full;
-	eNB->td                   = ulsch_decoding_data;//(single_thread_flag==1) ? ulsch_decoding_data_2thread : ulsch_decoding_data;
-	eNB->te                   = dlsch_encoding;//(single_thread_flag==1) ? dlsch_encoding_2threads : dlsch_encoding;
-	eNB->proc_uespec_rx       = phy_procedures_eNB_uespec_RX;
-	eNB->proc_tx              = proc_tx_full;
-        if (eNB->node_timing == synch_to_other) {
-           eNB->tx_fh             = tx_fh_if5_mobipass;
-           eNB->rx_fh             = rx_fh_slave;
-           eNB->fh_asynch         = fh_if5_asynch_UL;
-
-        }
-        else {
-           eNB->tx_fh             = tx_fh_if5;
-           eNB->rx_fh             = rx_fh_if5;
-           eNB->fh_asynch         = NULL;
-        }
-
-	eNB->start_rf             = NULL;
-	eNB->start_if             = start_if;
-	eNB->rfdevice.host_type   = BBU_HOST;
-
-	eNB->ifdevice.host_type   = BBU_HOST;
-
-        ret = openair0_transport_load(&eNB->ifdevice, &openair0_cfg[CC_id], eNB->eth_params);
-        printf("openair0_transport_init returns %d for CC_id %d\n",ret,CC_id);
-        if (ret<0) {
-          printf("Exiting, cannot initialize transport protocol\n");
-          exit(-1);
-        }
-	break;
-      case NGFI_RCC_IF4p5:
-	eNB->do_precoding         = 0;
-	eNB->do_prach             = do_prach;
-	eNB->fep                  = NULL;
-	eNB->td                   = ulsch_decoding_data;//(single_thread_flag==1) ? ulsch_decoding_data_2thread : ulsch_decoding_data;
-	eNB->te                   = dlsch_encoding;//(single_thread_flag==1) ? dlsch_encoding_2threads : dlsch_encoding;
-	eNB->proc_uespec_rx       = phy_procedures_eNB_uespec_RX;
-	eNB->proc_tx              = proc_tx_high;
-	eNB->tx_fh                = tx_fh_if4p5;
-	eNB->rx_fh                = rx_fh_if4p5;
-	eNB->start_rf             = NULL;
-	eNB->start_if             = start_if;
-        eNB->fh_asynch            = (eNB->node_timing == synch_to_other) ? fh_if4p5_asynch_UL : NULL;
-	eNB->rfdevice.host_type   = BBU_HOST;
-	eNB->ifdevice.host_type   = BBU_HOST;
-        ret = openair0_transport_load(&eNB->ifdevice, &openair0_cfg[CC_id], eNB->eth_params);
-        printf("openair0_transport_init returns %d for CC_id %d\n",ret,CC_id);
-        if (ret<0) {
-          printf("Exiting, cannot initialize transport protocol\n");
-          exit(-1);
-        }
-	malloc_IF4p5_buffer(eNB);
-
-	break;
-      case NGFI_RAU_IF4p5:
-	eNB->do_precoding   = 0;
-	eNB->do_prach       = do_prach;
-	eNB->fep            = NULL;
-
-	eNB->td             = ulsch_decoding_data;//(single_thread_flag==1) ? ulsch_decoding_data_2thread : ulsch_decoding_data;
-	eNB->te             = dlsch_encoding;//(single_thread_flag==1) ? dlsch_encoding_2threads : dlsch_encoding;
-	eNB->proc_uespec_rx = phy_procedures_eNB_uespec_RX;
-	eNB->proc_tx        = proc_tx_high;
-	eNB->tx_fh          = tx_fh_if4p5; 
-	eNB->rx_fh          = rx_fh_if4p5; 
-        eNB->fh_asynch      = (eNB->node_timing == synch_to_other) ? fh_if4p5_asynch_UL : NULL;
-	eNB->start_rf       = NULL;
-	eNB->start_if       = start_if;
-
-	eNB->rfdevice.host_type   = BBU_HOST;
-	eNB->ifdevice.host_type   = BBU_HOST;
-        ret = openair0_transport_load(&eNB->ifdevice, &openair0_cfg[CC_id], eNB->eth_params);
-        printf("openair0_transport_init returns %d for CC_id %d\n",ret,CC_id);
-        if (ret<0) {
-          printf("Exiting, cannot initialize transport protocol\n");
-          exit(-1);
-        }
-	break;	
-	malloc_IF4p5_buffer(eNB);
-
-      }
-    }
+      eNB->td                   = ulsch_decoding_data;//(single_thread_flag==1) ? ulsch_decoding_data_2thread : ulsch_decoding_data;
+      eNB->te                   = dlsch_encoding;//(single_thread_flag==1) ? dlsch_encoding_2threads : dlsch_encoding;
 
-    if (setup_eNB_buffers(PHY_vars_eNB_g[inst],&openair0_cfg[CC_id])!=0) {
-      printf("Exiting, cannot initialize eNodeB Buffers\n");
-      exit(-1);
+      
     }
 
-    init_eNB_proc(inst);
   }
 
-  sleep(1);
-  LOG_D(HW,"[lte-softmodem.c] eNB threads created\n");
+
+  LOG_D(HW,"[lte-softmodem.c] eNB structure allocated\n");
   
 
 }
diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c
index d166729e0c..aa46ae3caa 100644
--- a/targets/RT/USER/lte-ru.c
+++ b/targets/RT/USER/lte-ru.c
@@ -65,7 +65,7 @@
 
 
 #include "../../ARCH/COMMON/common_lib.h"
-
+#include "../../ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.h"
 
 #include "PHY/LTE_TRANSPORT/if4_tools.h"
 #include "PHY/LTE_TRANSPORT/if5_tools.h"
@@ -112,166 +112,33 @@ unsigned short config_frames[4] = {2,9,11,13};
 
 extern volatile int                    oai_exit;
 
-extern openair0_config_t openair0_cfg[MAX_CARDS];
-
-
-static int                      time_offset[4] = {0,0,0,0};
 
-void init_RU(eNB_func_t node_function, RU_if_in_t ru_if_in[], RU_if_timing_t ru_if_timing[], eth_params_t *eth_params);
+void init_RU(const char*);
 void stop_RU(RU_t *ru);
+void do_ru_sync(RU_t *ru);
 
 
 
-// RU OFDM Modulator, used in IF4p5 RRU, RCC/RAU with IF5, eNodeB
-
-void do_OFDM_mod_rt(int subframe,RU_t *ru) {
-     
-  LTE_DL_FRAME_PARMS *fp=&ru->frame_parms;
-
-  unsigned int aa,slot_offset, slot_offset_F;
-  int dummy_tx_b[7680*4] __attribute__((aligned(32)));
-  int i,j, tx_offset;
-  int slot_sizeF = (fp->ofdm_symbol_size)*
-                   ((fp->Ncp==1) ? 6 : 7);
-  int len,len2;
-  int16_t *txdata;
-//  int CC_id = ru->proc.CC_id;
-
-  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_SFGEN , 1 );
-
-  slot_offset_F = (subframe<<1)*slot_sizeF;
-
-  slot_offset = subframe*fp->samples_per_tti;
-
-  if ((subframe_select(fp,subframe)==SF_DL)||
-      ((subframe_select(fp,subframe)==SF_S))) {
-    //    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->ru_time.txdataF[aa][slot_offset_F],
-                     dummy_tx_b,
-                     fp->ofdm_symbol_size,
-                     6,
-                     fp->nb_prefix_samples,
-                     CYCLIC_PREFIX);
-        PHY_ofdm_mod(&ru->ru_time.txdataF[aa][slot_offset_F+slot_sizeF],
-                     dummy_tx_b+(fp->samples_per_tti>>1),
-                     fp->ofdm_symbol_size,
-                     6,
-                     fp->nb_prefix_samples,
-                     CYCLIC_PREFIX);
-      } else {
-        normal_prefix_mod(&ru->ru_time.txdataF[aa][slot_offset_F],
-                          dummy_tx_b,
-                          7,
-                          fp);
-	// if S-subframe generate first slot only
-	if (subframe_select(fp,subframe) == SF_DL) 
-	  normal_prefix_mod(&ru->ru_time.txdataF[aa][slot_offset_F+slot_sizeF],
-			    dummy_tx_b+(fp->samples_per_tti>>1),
-			    7,
-			    fp);
-      }
-
-      // if S-subframe generate first slot only
-      if (subframe_select(fp,subframe) == SF_S)
-	len = fp->samples_per_tti>>1;
-      else
-	len = fp->samples_per_tti;
-      /*
-      for (i=0;i<len;i+=4) {
-	dummy_tx_b[i] = 0x100;
-	dummy_tx_b[i+1] = 0x01000000;
-	dummy_tx_b[i+2] = 0xff00;
-	dummy_tx_b[i+3] = 0xff000000;
-	}*/
-      
-      if (slot_offset+time_offset[aa]<0) {
-	txdata = (int16_t*)&ru->ru_time.txdata[aa][(LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*fp->samples_per_tti)+tx_offset];
-        len2 = -(slot_offset+time_offset[aa]);
-	len2 = (len2>len) ? len : len2;
-	for (i=0; i<(len2<<1); i++) {
-	  txdata[i] = ((int16_t*)dummy_tx_b)[i]<<openair0_cfg[0].iq_txshift;
-	}
-	if (len2<len) {
-	  txdata = (int16_t*)&ru->ru_time.txdata[aa][0];
-	  for (j=0; i<(len<<1); i++,j++) {
-	    txdata[j++] = ((int16_t*)dummy_tx_b)[i]<<openair0_cfg[0].iq_txshift;
-	  }
-	}
-      }  
-      else if ((slot_offset+time_offset[aa]+len)>(LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*fp->samples_per_tti)) {
-	tx_offset = (int)slot_offset+time_offset[aa];
-	txdata = (int16_t*)&ru->ru_time.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]<<openair0_cfg[0].iq_txshift;
-	}
-	txdata = (int16_t*)&ru->ru_time.txdata[aa][0];
-	for (j=0; i<(len<<1); i++,j++) {
-	  txdata[j++] = ((int16_t*)dummy_tx_b)[i]<<openair0_cfg[0].iq_txshift;
-	}
-      }
-      else {
-	tx_offset = (int)slot_offset+time_offset[aa];
-	txdata = (int16_t*)&ru->ru_time.txdata[aa][tx_offset];
-
-	for (i=0; i<(len<<1); i++) {
-	  txdata[i] = ((int16_t*)dummy_tx_b)[i]<<openair0_cfg[0].iq_txshift;
-	}
-      }
-      
-     // if S-subframe switch to RX in second subframe
-      /*
-     if (subframe_select(fp,subframe) == SF_S) {
-       for (i=0; i<len; i++) {
-	 ru->common_vars.txdata[0][aa][tx_offset++] = 0x00010001;
-       }
-     }
-      */
-     if ((((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++) {
-         tx_offset = (int)slot_offset+time_offset[aa]+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->ru_time.txdata[aa][tx_offset] = 0x00000000;
-       }
-     }
-    }
-  }
-  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_SFGEN , 0 );
-}
-
 /*************************************************************/
 /* Southbound Fronthaul functions, RCC/RAU                   */
 
 // southbound IF5 fronthaul for 16-bit OAI format
 static inline void fh_if5_south_out(RU_t *ru) {
-  if (ru == RC.ru_list[0]) VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, ru->proc.timestamp_tx&0xffffffff );
-  send_IF5(eNB, ru->proc.timestamp_txp ru->proc.subframe_tx, &ru->seqno, IF5_RRH_GW_DL);
+  if (ru == RC.ru[0]) VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, ru->proc.timestamp_tx&0xffffffff );
+  send_IF5(ru, ru->proc.timestamp_tx, ru->proc.subframe_tx, &ru->seqno, IF5_RRH_GW_DL);
 }
 
 // southbound IF5 fronthaul for Mobipass packet format
 static inline void fh_if5_mobipass_south_out(RU_t *ru) {
-  if (ru == RC.ru_list[0]) VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, ru->proc.timestamp_tx&0xffffffff );
-  send_IF5(eNB, ru->proc.timestamp_tx, ru->proc.subframe_tx, &ru->seqno, IF5_MOBIPASS); 
+  if (ru == RC.ru[0]) VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, ru->proc.timestamp_tx&0xffffffff );
+  send_IF5(ru, ru->proc.timestamp_tx, ru->proc.subframe_tx, &ru->seqno, IF5_MOBIPASS); 
 }
 
 // southbound IF4p5 fronthaul
 static inline void fh_if4p5_south_out(RU_t *ru) {
-  if (ru == RC.ru_list[0]) VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, ru->proc.timestamp_tx&0xffffffff );    
-  send_IF4p5(eNB,proc->frame_tx, proc->subframe_tx, IF4p5_PDLFFT, 0);
+  if (ru == RC.ru[0]) VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, ru->proc.timestamp_tx&0xffffffff );
+  LOG_I(PHY,"Sending IF4p5 for frame %d subframe %d\n",ru->proc.frame_tx,ru->proc.subframe_tx);
+  send_IF4p5(ru,ru->proc.frame_tx, ru->proc.subframe_tx, IF4p5_PDLFFT, 0);
 }
 
 /*************************************************************/
@@ -281,21 +148,21 @@ static inline void fh_if4p5_south_out(RU_t *ru) {
 void fh_if5_south_in(RU_t *ru,int *frame, int *subframe) {
 
   LTE_DL_FRAME_PARMS *fp = &ru->frame_parms;
-  ru_proc_t *proc = &ru->proc;
+  RU_proc_t *proc = &ru->proc;
 
-  recv_IF5(ru, &ru->timestamp_rx, *subframe, IF5_RRH_GW_UL); 
+  recv_IF5(ru, &proc->timestamp_rx, *subframe, IF5_RRH_GW_UL); 
 
   proc->frame_rx    = (proc->timestamp_rx / (fp->samples_per_tti*10))&1023;
   proc->subframe_rx = (proc->timestamp_rx / fp->samples_per_tti)%10;
   
   if (proc->first_rx == 0) {
     if (proc->subframe_rx != *subframe){
-      LOG_E(PHY,"Received Timestamp doesn't correspond to the time we think it is (proc->subframe_rx %d, subframe %d)\n",proc->subframe_rx,subframe);
+      LOG_E(PHY,"Received Timestamp doesn't correspond to the time we think it is (proc->subframe_rx %d, subframe %d)\n",proc->subframe_rx,*subframe);
       exit_fun("Exiting");
     }
     
     if (proc->frame_rx != *frame) {
-      LOG_E(PHY,"Received Timestamp doesn't correspond to the time we think it is (proc->frame_rx %d frame %d)\n",proc->frame_rx,frame);
+      LOG_E(PHY,"Received Timestamp doesn't correspond to the time we think it is (proc->frame_rx %d frame %d)\n",proc->frame_rx,*frame);
       exit_fun("Exiting");
     }
   } else {
@@ -312,34 +179,50 @@ void fh_if5_south_in(RU_t *ru,int *frame, int *subframe) {
 void fh_if4p5_south_in(RU_t *ru,int *frame,int *subframe) {
 
   LTE_DL_FRAME_PARMS *fp = &ru->frame_parms;
-  ru_proc_t *proc = &ru->proc;
+  RU_proc_t *proc = &ru->proc;
+  int f,sf;
 
-  int prach_rx;
 
   uint16_t packet_type;
   uint32_t symbol_number=0;
-  uint32_t symbol_mask, symbol_mask_full;
+  uint32_t symbol_mask_full;
+  int      prach_received=0;
+
+  if ((fp->frame_type == TDD) && (subframe_select(fp,*subframe)==SF_S))  
+    symbol_mask_full = (1<<fp->ul_symbols_in_S_subframe)-1;   
+  else     
+    symbol_mask_full = (1<<fp->symbols_per_tti)-1; 
 
-  symbol_mask = 0;
-  symbol_mask_full = (1<<fp->symbols_per_tti)-1;
-  prach_rx = 0;
 
   do {   // Blocking, we need a timeout on this !!!!!!!!!!!!!!!!!!!!!!!
-    recv_IF4p5(ru, &proc->frame_rx, &proc->subframe_rx, &packet_type, &symbol_number);
+    recv_IF4p5(ru, &f, &sf, &packet_type, &symbol_number);
 
     if (packet_type == IF4p5_PULFFT) {
-      symbol_mask = symbol_mask | (1<<symbol_number);
-      prach_rx = (is_prach_subframe(fp, proc->frame_rx, proc->subframe_rx)>0) ? 1 : 0;                            
+      proc->symbol_mask[sf] = proc->symbol_mask[sf] | (1<<symbol_number);
+
+    } else if (packet_type == IF4p5_PULTICK) {           
+      if ((proc->first_rx==0) && (f!=*frame)) 	
+	LOG_E(PHY,"rx_fh_if4p5: PULTICK received frame %d != expected %d\n",f,*frame);       
+      if ((proc->first_rx==0) && (sf!=*subframe)) 	
+	LOG_E(PHY,"rx_fh_if4p5: PULTICK received subframe %d != expected %d (first_rx %d)\n",sf,*subframe,proc->first_rx);       
+      break;     
     } else if (packet_type == IF4p5_PRACH) {
-      prach_rx = 0;
+      if (ru->do_prach==1) {
+	proc->subframe_prach = sf;
+	proc->frame_prach    = f;
+	do_prach_ru(ru);
+      }
     }
 
-  } while( (symbol_mask != symbol_mask_full) || (prach_rx == 1));    
+  } while(proc->symbol_mask[*subframe] != symbol_mask_full);    
 
   //caculate timestamp_rx, timestamp_tx based on frame and subframe
-   proc->timestamp_rx = ((proc->frame_rx * 10)  + proc->subframe_rx ) * fp->samples_per_tti ;
-   proc->timestamp_tx = proc->timestamp_rx +  (4*fp->samples_per_tti);
- 
+  proc->subframe_rx = sf;
+  proc->frame_rx    = f;
+  proc->timestamp_rx = ((proc->frame_rx * 10)  + proc->subframe_rx ) * fp->samples_per_tti ;
+  proc->timestamp_tx = proc->timestamp_rx +  (4*fp->samples_per_tti);
+  proc->subframe_tx = (sf+4)%10;
+  proc->frame_tx    = (sf>5) ? (f+1)&1023 : f;
  
   if (proc->first_rx == 0) {
     if (proc->subframe_rx != *subframe){
@@ -355,7 +238,8 @@ void fh_if4p5_south_in(RU_t *ru,int *frame,int *subframe) {
     *frame = proc->frame_rx;
     *subframe = proc->subframe_rx;        
   }
-  
+
+  proc->symbol_mask[sf] = 0;  
   VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TS, proc->timestamp_rx&0xffffffff );
   
 }
@@ -364,7 +248,7 @@ void fh_if4p5_south_in(RU_t *ru,int *frame,int *subframe) {
 void fh_slave_south_in(RU_t *ru,int *frame,int *subframe) {
   // This case is for synchronization to another thread
   // it just waits for an external event.  The actual rx_fh is handle by the asynchronous RX thread
-  ru_proc_t *proc=&ru->proc;
+  RU_proc_t *proc=&ru->proc;
 
   if (wait_on_condition(&proc->mutex_FH,&proc->cond_FH,&proc->instance_cnt_FH,"fh_slave_south_in") < 0)
     return;
@@ -374,39 +258,54 @@ void fh_slave_south_in(RU_t *ru,int *frame,int *subframe) {
   
 }
 
-// asynchronous inbound if5 fronthaul from south
-void fh_if5_south_asynch_in(RU_t *ru,int *frame,int *subframe) {
+// asynchronous inbound if5 fronthaul from south (Mobipass)
+void fh_if5_south_asynch_in_mobipass(RU_t *ru,int *frame,int *subframe) {
 
-  eNB_proc_t *proc       = &eNB->proc;
-  LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms;
+  RU_proc_t *proc       = &ru->proc;
+  LTE_DL_FRAME_PARMS *fp = &ru->frame_parms;
 
-  recv_IF5(eNB, &ru->timestamp_rx, *subframe, IF5_RRH_GW_UL); 
+  recv_IF5(ru, &proc->timestamp_rx, *subframe, IF5_MOBIPASS); 
+  pthread_mutex_lock(&proc->mutex_asynch_rxtx);
+  int offset_mobipass = 40120;
+  pthread_mutex_lock(&proc->mutex_asynch_rxtx);
+  proc->subframe_rx = ((proc->timestamp_rx-offset_mobipass)/fp->samples_per_tti)%10;
+  proc->frame_rx    = ((proc->timestamp_rx-offset_mobipass)/(fp->samples_per_tti*10))&1023;
 
-  proc->subframe_rx = (ru->timestamp_rx/fp->samples_per_tti)%10;
-  proc->frame_rx    = (ru->timestamp_rx/(10*fp->samples_per_tti))&1023;
+  proc->subframe_rx = (proc->timestamp_rx/fp->samples_per_tti)%10;
+  proc->frame_rx    = (proc->timestamp_rx/(10*fp->samples_per_tti))&1023;
 
-  if (proc->first_rx != 0) {
-    proc->first_rx = 0;
+  if (proc->first_rx == 1) {
+    proc->first_rx =2;
     *subframe = proc->subframe_rx;
     *frame    = proc->frame_rx; 
+    LOG_E(PHY,"[Mobipass]timestamp_rx:%llu, frame_rx %d, subframe: %d\n",(unsigned long long int)proc->timestamp_rx,proc->frame_rx,proc->subframe_rx);
   }
   else {
     if (proc->subframe_rx != *subframe) {
-      LOG_E(PHY,"subframe_rx %d is not what we expect %d\n",proc->subframe_rx,*subframe);
-      exit_fun("Exiting");
+        proc->first_rx++;
+	LOG_E(PHY,"[Mobipass]timestamp:%llu, subframe_rx %d is not what we expect %d, first_rx:%d\n",(unsigned long long int)proc->timestamp_rx, proc->subframe_rx,*subframe, proc->first_rx);
+      //exit_fun("Exiting");
     }
     if (proc->frame_rx != *frame) {
-      LOG_E(PHY,"subframe_rx %d is not what we expect %d\n",proc->frame_rx,*frame);  
-      exit_fun("Exiting");
+        proc->first_rx++;
+       LOG_E(PHY,"[Mobipass]timestamp:%llu, frame_rx %d is not what we expect %d, first_rx:%d\n",(unsigned long long int)proc->timestamp_rx,proc->frame_rx,*frame, proc->first_rx);  
+     // exit_fun("Exiting");
     }
+    // temporary solution
+      *subframe = proc->subframe_rx;
+      *frame    = proc->frame_rx;
   }
+
+  pthread_mutex_unlock(&proc->mutex_asynch_rxtx);
+
+
 } // eNodeB_3GPP_BBU 
 
 // asynchronous inbound if4p5 fronthaul from south
 void fh_if4p5_south_asynch_in(RU_t *ru,int *frame,int *subframe) {
 
   LTE_DL_FRAME_PARMS *fp = &ru->frame_parms;
-  ru_proc_t *proc       = &ru->proc;
+  RU_proc_t *proc       = &ru->proc;
 
   uint16_t packet_type;
   uint32_t symbol_number,symbol_mask,symbol_mask_full,prach_rx;
@@ -452,46 +351,34 @@ void fh_if4p5_south_asynch_in(RU_t *ru,int *frame,int *subframe) {
   
 // RRU IF4p5 TX fronthaul receiver. Assumes an if_device on input and if or rf device on output 
 // receives one subframe's worth of IF4p5 OFDM symbols and OFDM modulates
-void fh_if4p5_north_in(RU_t *ru) {
+void fh_if4p5_north_in(RU_t *ru,int *frame,int *subframe) {
 
   uint32_t symbol_number=0;
   uint32_t symbol_mask, symbol_mask_full;
   uint16_t packet_type;
-  ru_proc_t = &ru->proc;
 
-  // dump VCD output for first RU in list
-  if (ru == RC.ru_list[0]) {
-    VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_ENB, proc->frame_tx );
-    VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_TX0_ENB, proc->subframe_tx );
-  }
+
   /// **** incoming IF4p5 from remote RCC/RAU **** ///             
   symbol_number = 0;
   symbol_mask = 0;
   symbol_mask_full = (1<<ru->frame_parms.symbols_per_tti)-1;
   
   do { 
-    recv_IF4p5(ru, &proc->frame_tx, &proc->subframe_tx, &packet_type, &symbol_number);
+    recv_IF4p5(ru, frame, subframe, &packet_type, &symbol_number);
     symbol_mask = symbol_mask | (1<<symbol_number);
   } while (symbol_mask != symbol_mask_full); 
-}
 
-void fh_if5_north_in(RU_t *ru) {
-  
-
-  if (ru == RC.ru_list[0]) {
-    VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_ENB, ru->proc.frame_tx );
-    VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_TX0_ENB, ru->proc.subframe_tx );
+  // dump VCD output for first RU in list
+  if (ru == RC.ru[0]) {
+    VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_ENB, *frame );
+    VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_TX0_ENB, *subframe );
   }
-
-  /// **** recv_IF5 of txdata from BBU **** ///       
-  recv_IF5(ru, &ru->timestamp_tx, proc->subframe_tx, IF5_RRH_GW_DL);
-
 }
 
 void fh_if5_north_asynch_in(RU_t *ru,int *frame,int *subframe) {
 
   LTE_DL_FRAME_PARMS *fp = &ru->frame_parms;
-  ru_proc_t *proc        = &ru->proc;
+  RU_proc_t *proc        = &ru->proc;
   int subframe_tx,frame_tx;
   openair0_timestamp timestamp_tx;
 
@@ -521,7 +408,7 @@ void fh_if5_north_asynch_in(RU_t *ru,int *frame,int *subframe) {
 void fh_if4p5_north_asynch_in(RU_t *ru,int *frame,int *subframe) {
 
   LTE_DL_FRAME_PARMS *fp = &ru->frame_parms;
-  ru_proc_t *proc        = &ru->proc;
+  RU_proc_t *proc        = &ru->proc;
 
   uint16_t packet_type;
   uint32_t symbol_number,symbol_mask,symbol_mask_full;
@@ -556,53 +443,65 @@ void fh_if4p5_north_asynch_in(RU_t *ru,int *frame,int *subframe) {
       exit_fun("Exiting");
     }
   } while (symbol_mask != symbol_mask_full);    
-  
-  do_OFDM_mod_rt(subframe_tx, eNB);
+
+  proc->subframe_tx = subframe_tx;
+
+  if (ru->feptx_ofdm) ru->feptx_ofdm(ru);
+  if (ru->fh_south_out) ru->fh_south_out(ru);
 } 
 
+void fh_if5_north_out(RU_t *ru) {
+
+  RU_proc_t *proc=&ru->proc;
+  uint8_t seqno=0;
+
+  /// **** send_IF5 of rxdata to BBU **** ///       
+  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_SEND_IF5, 1 );  
+  send_IF5(ru, proc->timestamp_rx, proc->subframe_rx, &seqno, IF5_RRH_GW_UL);
+  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_SEND_IF5, 0 );          
+
+}
+
+// RRU IF4p5 northbound interface (RX)
+void fh_if4p5_north_out(RU_t *ru) {
+
+  RU_proc_t *proc=&ru->proc;
+  LTE_DL_FRAME_PARMS *fp = &ru->frame_parms;
+  const int subframe     = proc->subframe_rx;
+  if (ru->idx==0) VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_RX0_ENB, proc->subframe_rx );
+
+  if ((fp->frame_type == TDD) && (subframe_select(fp,subframe)!=SF_UL)) {
+    /// **** in TDD during DL send_IF4 of ULTICK to RCC **** ///
+    send_IF4p5(ru, proc->frame_rx, proc->subframe_rx, IF4p5_PULTICK, 0);
+    return;
+  }
+  if (ru->idx == 0) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_ENB_RX_COMMON, 1 ); 
+
+  AssertFatal(ru->feprx!=NULL,"No northbound FEP function, exiting\n");
+  if (ru->feprx) { 
+    LOG_D(PHY,"Doing FEP/IF4p5 for frame %d, subframe %d\n",proc->frame_rx,proc->subframe_rx);
+    ru->feprx(ru);
+    send_IF4p5(ru, proc->frame_rx, proc->subframe_rx, IF4p5_PULFFT, 0);
+  }
+
+  if (ru->idx == 0) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_ENB_RX_COMMON, 0 );
+}
 void rx_rf(RU_t *ru,int *frame,int *subframe) {
 
-  ru_proc_t *proc = &ru->proc;
+  RU_proc_t *proc = &ru->proc;
   LTE_DL_FRAME_PARMS *fp = &ru->frame_parms;
-  void *rxp[fp->nb_antennas_rx],*txp[fp->nb_antennas_tx]; 
-  unsigned int rxs,txs;
+  void *rxp[fp->nb_antennas_rx];
+  unsigned int rxs;
   int i;
-  int tx_sfoffset = 3;//(eNB->single_thread_flag == 1) ? 3 : 3;
-  if (proc->first_rx==0) {
-    
-    // Transmit TX buffer based on timestamp from RX
-    //    printf("trx_write -> USRP TS %llu (sf %d)\n", (ru->timestamp_rx+(3*fp->samples_per_tti)),(proc->subframe_rx+2)%10);
-    VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, (ru->timestamp_rx+(tx_sfoffset*fp->samples_per_tti)-openair0_cfg[0].tx_sample_advance)&0xffffffff );
-    VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 1 );
-    // prepare tx buffer pointers
-	
-    for (i=0; i<fp->nb_antennas_tx; i++)
-      txp[i] = (void*)&ru->ru_time.txdata[0][i][((proc->subframe_rx+tx_sfoffset)%10)*fp->samples_per_tti];
-    
-    txs = eNB->rfdevice.trx_write_func(&ru->rfdevice,
-				       ru->timestamp_rx+(tx_sfoffset*fp->samples_per_tti)-openair0_cfg[0].tx_sample_advance,
-				       txp,
-				       fp->samples_per_tti,
-				       fp->nb_antennas_tx,
-				       1);
-    
-    VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 0 );
-    
-    
+
     
-    if (txs !=  fp->samples_per_tti) {
-      LOG_E(PHY,"TX : Timeout (sent %d/%d)\n",txs, fp->samples_per_tti);
-      exit_fun( "problem transmitting samples" );
-    }	
-  }
-  
   for (i=0; i<fp->nb_antennas_rx; i++)
-    rxp[i] = (void*)&ru->ru_time.rxdata[0][i][*subframe*fp->samples_per_tti];
+    rxp[i] = (void*)&ru->common.rxdata[i][*subframe*fp->samples_per_tti];
   
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ, 1 );
 
   rxs = ru->rfdevice.trx_read_func(&ru->rfdevice,
-				   &(ru->timestamp_rx),
+				   &(proc->timestamp_rx),
 				   rxp,
 				   fp->samples_per_tti,
 				   fp->nb_antennas_rx);
@@ -610,23 +509,25 @@ void rx_rf(RU_t *ru,int *frame,int *subframe) {
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ, 0 );
  
   if (proc->first_rx == 1)
-    ru->ts_offset = ru->timestamp_rx;
+    ru->ts_offset = proc->timestamp_rx;
  
-  proc->frame_rx    = ((ru->timestamp_rx-eNB->ts_offset) / (fp->samples_per_tti*10))&1023;
-  proc->subframe_rx = ((ru->timestamp_rx-eNB->ts_offset) / fp->samples_per_tti)%10;
+  proc->frame_rx     = ((proc->timestamp_rx-ru->ts_offset) / (fp->samples_per_tti*10))&1023;
+  proc->subframe_rx  = ((proc->timestamp_rx-ru->ts_offset) / fp->samples_per_tti)%10;
   // synchronize first reception to frame 0 subframe 0
 
-  ru->timestamp_tx = ru->timestamp_rx+(4*fp->samples_per_tti);
-  //printf("trx_read <- USRP TS %llu (sf %d, f %d, first_rx %d)\n", ru->timestamp_rx,proc->subframe_rx,proc->frame_rx,proc->first_rx);  
+  proc->timestamp_tx = proc->timestamp_rx+(4*fp->samples_per_tti);
+  proc->subframe_tx  = (proc->subframe_rx+4)%10;
+  proc->frame_tx     = (proc->subframe_rx>5) ? (proc->frame_rx+1)&1023 : proc->frame_rx;
+
   
   if (proc->first_rx == 0) {
     if (proc->subframe_rx != *subframe){
-      LOG_E(PHY,"Received Timestamp (%llu) doesn't correspond to the time we think it is (proc->subframe_rx %d, subframe %d)\n",ru->timestamp_rx,proc->subframe_rx,*subframe);
+      LOG_E(PHY,"Received Timestamp (%llu) doesn't correspond to the time we think it is (proc->subframe_rx %d, subframe %d)\n",(long long unsigned int)proc->timestamp_rx,proc->subframe_rx,*subframe);
       exit_fun("Exiting");
     }
     
     if (proc->frame_rx != *frame) {
-      LOG_E(PHY,"Received Timestamp (%llu) doesn't correspond to the time we think it is (proc->frame_rx %d frame %d)\n",ru->timestamp_rx,proc->frame_rx,*frame);
+      LOG_E(PHY,"Received Timestamp (%llu) doesn't correspond to the time we think it is (proc->frame_rx %d frame %d)\n",(long long unsigned int)proc->timestamp_rx,proc->frame_rx,*frame);
       exit_fun("Exiting");
     }
   } else {
@@ -637,7 +538,7 @@ void rx_rf(RU_t *ru,int *frame,int *subframe) {
   
   //printf("timestamp_rx %lu, frame %d(%d), subframe %d(%d)\n",ru->timestamp_rx,proc->frame_rx,frame,proc->subframe_rx,subframe);
   
-  VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TS, ru->timestamp_rx&0xffffffff );
+  VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TS, proc->timestamp_rx&0xffffffff );
   
   if (rxs != fp->samples_per_tti)
     exit_fun( "problem receiving samples" );
@@ -647,6 +548,39 @@ void rx_rf(RU_t *ru,int *frame,int *subframe) {
 }
 
 
+void tx_rf(RU_t *ru) {
+
+  RU_proc_t *proc = &ru->proc;
+  LTE_DL_FRAME_PARMS *fp = &ru->frame_parms;
+  void *txp[fp->nb_antennas_tx]; 
+  unsigned int txs;
+  int i;
+
+  VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, (proc->timestamp_tx-ru->openair0_cfg.tx_sample_advance)&0xffffffff );
+  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 1 );
+  // prepare tx buffer pointers
+  
+  for (i=0; i<fp->nb_antennas_tx; i++)
+    txp[i] = (void*)&ru->common.txdata[i][proc->subframe_tx*fp->samples_per_tti];
+  
+  txs = ru->rfdevice.trx_write_func(&ru->rfdevice,
+				    proc->timestamp_tx-ru->openair0_cfg.tx_sample_advance,
+				    txp,
+				    fp->samples_per_tti,
+				    fp->nb_antennas_tx,
+				    1);
+  
+  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 0 );
+  
+    
+    
+  if (txs !=  fp->samples_per_tti) {
+    LOG_E(PHY,"TX : Timeout (sent %d/%d)\n",txs, fp->samples_per_tti);
+    exit_fun( "problem transmitting samples" );
+  }	
+}
+
+
 /*!
  * \brief The Asynchronous RX/TX FH thread of RAU/RCC/eNB/RRU.
  * This handles the RX FH for an asynchronous RRU/UE
@@ -657,24 +591,25 @@ static void* ru_thread_asynch_rxtx( void* param ) {
 
   static int ru_thread_asynch_rxtx_status;
 
-  eNB_proc_t *proc = (ru_proc_t*)param;
-  RU_t *ru         = PHY_vars_eNB_g[0][proc->CC_id];
+  RU_t *ru         = (RU_t*)param;
+  RU_proc_t *proc  = &ru->proc;
+
 
 
   int subframe=0, frame=0; 
 
-  thread_top_init("thread_asynch",1,870000L,1000000L,1000000L);
+  thread_top_init("ru_thread_asynch_rxtx",1,870000L,1000000L,1000000L);
 
   // wait for top-level synchronization and do one acquisition to get timestamp for setting frame/subframe
 
-  wait_sync("thread_asynch");
+  wait_sync("ru_thread_asynch_rxtx");
 
   // wait for top-level synchronization and do one acquisition to get timestamp for setting frame/subframe
-  printf( "waiting for devices (eNB_thread_asynch_rx)\n");
+  printf( "waiting for devices (ru_thread_asynch_rx)\n");
 
   wait_on_condition(&proc->mutex_asynch_rxtx,&proc->cond_asynch_rxtx,&proc->instance_cnt_asynch_rxtx,"thread_asynch");
 
-  printf( "devices ok (eNB_thread_asynch_rx)\n");
+  printf( "devices ok (ru_thread_asynch_rx)\n");
 
 
   while (!oai_exit) { 
@@ -688,10 +623,12 @@ static void* ru_thread_asynch_rxtx( void* param ) {
     } else {
       subframe++;
     }      
-
-    if (eNB->fh_asynch) eNB->fh_asynch(eNB,&frame,&subframe);
-    else AssertFatal(1==0, "Unknown eNB->node_function %d",eNB->node_function);
-    
+    LOG_I(PHY,"ru_thread_asynch_rxtx: Waiting on incoming fronthaul\n");
+    // asynchronous receive from south (Mobipass)
+    if (ru->fh_south_asynch_in) ru->fh_south_asynch_in(ru,&frame,&subframe);
+    // asynchronous receive from north (RRU IF4/IF5)
+    else if (ru->fh_north_asynch_in) ru->fh_north_asynch_in(ru,&frame,&subframe);
+    else AssertFatal(1==0,"Unknown function in ru_thread_asynch_rxtx\n");
   }
 
   ru_thread_asynch_rxtx_status=0;
@@ -701,61 +638,7 @@ static void* ru_thread_asynch_rxtx( void* param ) {
 
 
 
-// wakeup local eNB process
-
-int wakeup_rxtx(eNB_proc_t *proc,eNB_rxtx_proc_t *proc_rxtx,LTE_DL_FRAME_PARMS *fp) {
-
-  int i;
-  struct timespec wait;
-  
-  wait.tv_sec=0;
-  wait.tv_nsec=5000000L;
-
-  /* accept some delay in processing - up to 5ms */
-  for (i = 0; i < 10 && proc_rxtx->instance_cnt_rxtx == 0; i++) {
-    LOG_W( PHY,"[eNB] Frame %d, eNB RXn-TXnp4 thread busy!! (cnt_rxtx %i)\n", proc_rxtx->frame_tx, proc_rxtx->instance_cnt_rxtx);
-    usleep(500);
-  }
-  if (proc_rxtx->instance_cnt_rxtx == 0) {
-    exit_fun( "TX thread busy" );
-    return(-1);
-  }
-
-  // wake up TX for subframe n+4
-  // lock the TX mutex and make sure the thread is ready
-  if (pthread_mutex_timedlock(&proc_rxtx->mutex_rxtx,&wait) != 0) {
-    LOG_E( PHY, "[eNB] ERROR pthread_mutex_lock for eNB RXTX thread %d (IC %d)\n", proc_rxtx->subframe_rx&1,proc_rxtx->instance_cnt_rxtx );
-    exit_fun( "error locking mutex_rxtx" );
-    return(-1);
-  }
-  
-  ++proc_rxtx->instance_cnt_rxtx;
-  
-  // We have just received and processed the common part of a subframe, say n. 
-  // TS_rx is the last received timestamp (start of 1st slot), TS_tx is the desired 
-  // transmitted timestamp of the next TX slot (first).
-  // The last (TS_rx mod samples_per_frame) was n*samples_per_tti, 
-  // we want to generate subframe (n+4), so TS_tx = TX_rx+4*samples_per_tti,
-  // and proc->subframe_tx = proc->subframe_rx+4
-  proc_rxtx->timestamp_tx = proc->timestamp_rx + (4*fp->samples_per_tti);
-  proc_rxtx->frame_rx     = proc->frame_rx;
-  proc_rxtx->subframe_rx  = proc->subframe_rx;
-  proc_rxtx->frame_tx     = (proc_rxtx->subframe_rx > 5) ? (proc_rxtx->frame_rx+1)&1023 : proc_rxtx->frame_rx;
-  proc_rxtx->subframe_tx  = (proc_rxtx->subframe_rx + 4)%10;
-  
-  // the thread can now be woken up
-  if (pthread_cond_signal(&proc_rxtx->cond_rxtx) != 0) {
-    LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB RXn-TXnp4 thread\n");
-    exit_fun( "ERROR pthread_cond_signal" );
-    return(-1);
-  }
-  
-  pthread_mutex_unlock( &proc_rxtx->mutex_rxtx );
-
-  return(0);
-}
-
-void wakeup_slaves(ru_proc_t *proc) {
+void wakeup_slaves(RU_proc_t *proc) {
 
   int i;
   struct timespec wait;
@@ -764,11 +647,11 @@ void wakeup_slaves(ru_proc_t *proc) {
   wait.tv_nsec=5000000L;
   
   for (i=0;i<proc->num_slaves;i++) {
-    ru_proc_t *slave_proc = proc->slave_proc[i];
+    RU_proc_t *slave_proc = proc->slave_proc[i];
     // wake up slave FH thread
     // lock the FH mutex and make sure the thread is ready
     if (pthread_mutex_timedlock(&slave_proc->mutex_FH,&wait) != 0) {
-      LOG_E( PHY, "[eNB] ERROR pthread_mutex_lock for eNB CCid %d slave CCid %d (IC %d)\n",proc->CC_id,slave_proc->CC_id);
+      LOG_E( PHY, "ERROR pthread_mutex_lock for RU %d slave %d (IC %d)\n",proc->ru->idx,slave_proc->ru->idx,slave_proc->instance_cnt_FH);
       exit_fun( "error locking mutex_rxtx" );
       break;
     }
@@ -784,12 +667,12 @@ void wakeup_slaves(ru_proc_t *proc) {
     if (cnt_slave == 0) {
       // the thread was presumably waiting where it should and can now be woken up
       if (pthread_cond_signal(&slave_proc->cond_FH) != 0) {
-	LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB CCid %d, slave CCid %d\n",proc->CC_id,slave_proc->CC_id);
+	LOG_E( PHY, "ERROR pthread_cond_signal for RU %d, slave RU %d\n",proc->ru->idx,slave_proc->ru->idx);
           exit_fun( "ERROR pthread_cond_signal" );
 	  break;
       }
     } else {
-      LOG_W( PHY,"[RU] Frame %d, slave CC_id %d thread busy!! (cnt_FH %i)\n",slave_proc->frame_rx,slave_proc->CC_id, cnt_slave);
+      LOG_W( PHY,"[RU] Frame %d, slave %d thread busy!! (cnt_FH %i)\n",slave_proc->frame_rx,slave_proc->ru->idx, cnt_slave);
       exit_fun( "FH thread busy" );
       break;
     }             
@@ -798,52 +681,85 @@ void wakeup_slaves(ru_proc_t *proc) {
 
 /*!
  * \brief The prach receive thread of RU.
- * \param param is a \ref ru_proc_t structure which contains the info what to process.
+ * \param param is a \ref RU_proc_t structure which contains the info what to process.
  * \returns a pointer to an int. The storage is not on the heap and must not be freed.
  */
 static void* ru_thread_prach( void* param ) {
+
   static int ru_thread_prach_status;
 
-  eNB_proc_t *proc = (eNB_proc_t*)param;
-  PHY_VARS_eNB *eNB= PHY_vars_eNB_g[0][proc->CC_id];
+  RU_t *ru        = (RU_t*)param;
+  RU_proc_t *proc = (RU_proc_t*)&ru->proc;
 
   // set default return value
-  eNB_thread_prach_status = 0;
+  ru_thread_prach_status = 0;
 
-  thread_top_init("eNB_thread_prach",1,500000L,1000000L,20000000L);
+  thread_top_init("ru_thread_prach",1,500000L,1000000L,20000000L);
 
   while (!oai_exit) {
     
     if (oai_exit) break;
 
-    if (wait_on_condition(&proc->mutex_prach,&proc->cond_prach,&proc->instance_cnt_prach,"eNB_prach_thread") < 0) break;
-    
-    prach_procedures(eNB);
+    if (wait_on_condition(&proc->mutex_prach,&proc->cond_prach,&proc->instance_cnt_prach,"ru_prach_thread") < 0) break;
     
-    if (release_thread(&proc->mutex_prach,&proc->instance_cnt_prach,"eNB_prach_thread") < 0) break;
+    rx_prach(NULL,
+	     ru,
+             NULL,
+             NULL,
+             proc->frame_prach,
+             0);
+    if (release_thread(&proc->mutex_prach,&proc->instance_cnt_prach,"ru_prach_thread") < 0) break;
   }
 
-  printf( "Exiting eNB thread PRACH\n");
+  printf( "Exiting RU thread PRACH\n");
 
-  eNB_thread_prach_status = 0;
-  return &eNB_thread_prach_status;
+  ru_thread_prach_status = 0;
+  return &ru_thread_prach_status;
 }
 
-void do_ru_sync(RU_t *ru) {
+int wakeup_synch(RU_t *ru){
 
-  LTE_DL_FRAME_PARMS *fp  = &ru->frame_parms;
-  ru_proc_t *proc         = ru->proc;
+  struct timespec wait;
+  
+  wait.tv_sec=0;
+  wait.tv_nsec=5000000L;
 
+  // wake up synch thread
+  // lock the synch mutex and make sure the thread is ready
+  if (pthread_mutex_timedlock(&ru->proc.mutex_synch,&wait) != 0) {
+    LOG_E( PHY, "[RU] ERROR pthread_mutex_lock for RU synch thread (IC %d)\n", ru->proc.instance_cnt_synch );
+    exit_fun( "error locking mutex_synch" );
+    return(-1);
+  }
+  
+  ++ru->proc.instance_cnt_synch;
+  
+  // the thread can now be woken up
+  if (pthread_cond_signal(&ru->proc.cond_synch) != 0) {
+    LOG_E( PHY, "[RU] ERROR pthread_cond_signal for RU synch thread\n");
+    exit_fun( "ERROR pthread_cond_signal" );
+    return(-1);
+  }
+  
+  pthread_mutex_unlock( &ru->proc.mutex_synch );
+
+  return(0);
+}
+
+void do_ru_synch(RU_t *ru) {
+
+  LTE_DL_FRAME_PARMS *fp  = &ru->frame_parms;
+  RU_proc_t *proc         = &ru->proc;
+  int i;
   void *rxp[2],*rxp2[2];
   int32_t dummy_rx[ru->nb_rx][fp->samples_per_tti] __attribute__((aligned(32)));
+  int rxs;
+  int ic;
 
   // initialize the synchronization buffer to the common_vars.rxdata
   for (int i=0;i<ru->nb_rx;i++)
-    rxp[i] = &ru->ru_time.rxdata[i][0];
+    rxp[i] = &ru->common.rxdata[i][0];
 
-  // if FDD, switch RX on DL frequency
-  if (ru->rfdevice == NULL) AssertFatal(1==0,"RU doesn't have a local RF device\n");
-  
   double temp_freq1 = ru->rfdevice.openair0_cfg->rx_freq[0];
   double temp_freq2 = ru->rfdevice.openair0_cfg->tx_freq[0];
   for (i=0;i<4;i++) {
@@ -859,6 +775,8 @@ void do_ru_sync(RU_t *ru) {
 				     rxp,
 				     fp->samples_per_tti*10,
 				     ru->nb_rx);
+    if (rxs != fp->samples_per_tti*10) LOG_E(PHY,"requested %d samples, got %d\n",fp->samples_per_tti*10,rxs);
+ 
     // wakeup synchronization processing thread
     wakeup_synch(ru);
     ic=0;
@@ -875,9 +793,9 @@ void do_ru_sync(RU_t *ru) {
 					 rxp2,
 					 fp->samples_per_tti,
 					 ru->nb_rx);
-      pthread_mutex_lock(&eNB->proc.mutex_synch);
-      ic = eNB->proc.instance_cnt_synch;
-      pthread_mutex_unlock(&eNB->proc.mutex_synch);
+      pthread_mutex_lock(&ru->proc.mutex_synch);
+      ic = ru->proc.instance_cnt_synch;
+      pthread_mutex_unlock(&ru->proc.mutex_synch);
     } // ic>=0
   } // in_synch==0
     // read in rx_offset samples
@@ -896,16 +814,66 @@ void do_ru_sync(RU_t *ru) {
 
 }
 
+
+
+void wakeup_eNBs(RU_t *ru) {
+
+  int i;
+  PHY_VARS_eNB **eNB_list = ru->eNB_list;
+
+  if (ru->num_eNB==1) {
+    // call eNB function directly
+
+    char string[20];
+    sprintf(string,"Incoming RU %d",ru->idx);
+    LOG_D(PHY,"RU %d Waking up eNB\n",ru->idx);
+    ru->eNB_top(eNB_list[0],ru->proc.frame_rx,ru->proc.subframe_rx,string);
+  }
+  else {
+
+    for (i=0;i<ru->num_eNB;i++)
+      if (ru->wakeup_rxtx(eNB_list[i],ru->proc.frame_rx,ru->proc.subframe_rx) < 0)
+	LOG_E(PHY,"could not wakeup eNB rxtx process for subframe %d\n", ru->proc.subframe_rx);
+  }
+}
+
+static inline int wakeup_prach(RU_t *ru) {
+
+  struct timespec wait;
+  
+  wait.tv_sec=0;
+  wait.tv_nsec=5000000L;
+
+  if (pthread_mutex_timedlock(&ru->proc.mutex_prach,&wait) !=0) {
+    LOG_E( PHY, "[RU] ERROR pthread_mutex_lock for RU prach thread (IC %d)\n", ru->proc.instance_cnt_prach);
+    exit_fun( "error locking mutex_rxtx" );
+    return(-1);
+  }
+  ++ru->proc.instance_cnt_prach;
+  ru->proc.frame_prach    = ru->proc.frame_rx;
+  ru->proc.subframe_prach = ru->proc.subframe_rx;
+  
+  // the thread can now be woken up
+  if (pthread_cond_signal(&ru->proc.cond_prach) != 0) {
+    LOG_E( PHY, "[RU] ERROR pthread_cond_signal for RU prach thread\n");
+    exit_fun( "ERROR pthread_cond_signal" );
+    return(-1);
+  }
+  
+  pthread_mutex_unlock( &ru->proc.mutex_prach );
+
+  return(0);
+}
+
 static void* ru_thread( void* param ) {
 
   static int ru_thread_status;
 
   RU_t *ru                = (RU_t*)param;
+  RU_proc_t *proc         = &ru->proc;
   LTE_DL_FRAME_PARMS *fp  = &ru->frame_parms;
-  ru_proc_t *proc         = ru->proc;
 
   int subframe=0, frame=0; 
-
   // set default return value
   ru_thread_status = 0;
 
@@ -913,18 +881,51 @@ static void* ru_thread( void* param ) {
   // set default return value
   thread_top_init("ru_thread",0,870000,1000000,1000000);
 
+  LOG_I(PHY,"Starting RU %d (%s,%s),\n",ru->idx,eNB_functions[ru->function],eNB_timing[ru->if_timing]);
+
+
+  // Start IF device if any
+  if (ru->start_if) {
+    LOG_I(PHY,"Starting IF interface for RU %d\n",ru->idx);
+    if (ru->start_if(ru,NULL) != 0) {
+      LOG_E(PHY,"Could not start the IF device\n");
+    }
+    else { // wakeup the top thread to configure RU parameters
+      LOG_I(PHY, "Signaling main thread that RU %d is ready\n",ru->idx);
+      pthread_mutex_lock(&RC.ru_mutex);
+      RC.ru_mask &= ~(1<<ru->idx);
+      pthread_cond_signal(&RC.ru_cond);
+      pthread_mutex_unlock(&RC.ru_mutex);
+    }
+  }
+
   wait_sync("ru_thread");
 
-  // wakeup asnych_rxtx thread because the devices are ready at this point
-  pthread_mutex_lock(&proc->mutex_asynch_rxtx);
-  proc->instance_cnt_asynch_rxtx=0;
-  pthread_mutex_unlock(&proc->mutex_asynch_rxtx);
-  pthread_cond_signal(&proc->cond_asynch_rxtx);
 
-  
-  // if this is a slave RRU, try to synchronize on the DL frequency
-  if ((ru->is_slave) && (ru->RU_if_in == LOCAL_RF)) do_rru_synch(ru);
+  // Start RF device if any
+  if (ru->start_rf) {
+    if (ru->start_rf(ru) != 0)
+      LOG_E(HW,"Could not start the RF device\n");
+    else LOG_I(PHY,"RU %d rf device ready\n",ru->idx);
+  }
+  else LOG_I(PHY,"RU %d no rf device\n",ru->idx);
+
+
+  // if an asnych_rxtx thread exists
+  // wakeup the thread because the devices are ready at this point
  
+  if ((ru->fh_south_asynch_in)||(ru->fh_north_asynch_in)) {
+    pthread_mutex_lock(&proc->mutex_asynch_rxtx);
+    proc->instance_cnt_asynch_rxtx=0;
+    pthread_mutex_unlock(&proc->mutex_asynch_rxtx);
+    pthread_cond_signal(&proc->cond_asynch_rxtx);
+  }
+  else LOG_I(PHY,"RU %d no asynch_south interface\n",ru->idx);
+
+  // if this is a slave RRU, try to synchronize on the DL frequency
+  if ((ru->is_slave) && (ru->if_south == LOCAL_RF)) do_ru_synch(ru);
+
+
   // This is a forever while loop, it loops over subframes which are scheduled by incoming samples from HW devices
   while (!oai_exit) {
 
@@ -938,15 +939,30 @@ static void* ru_thread( void* param ) {
       subframe++;
     }      
 
-    LOG_D(PHY,"RU thread %p (proc %p), frame %d (%p), subframe %d (%p)\n",
-	  pthread_self(), proc, frame,&frame,subframe,&subframe);
- 
+    LOG_D(PHY,"RU thread (proc %p), frame %d (%p), subframe %d (%p)\n",
+	  proc, frame,&frame,subframe,&subframe);
+
+
     // synchronization on input FH interface, acquire signals/data and block
-    if (ru->fh_south_in) ru->rx_south_in(ru,&frame,&subframe);
+    if (ru->fh_south_in) ru->fh_south_in(ru,&frame,&subframe);
     else AssertFatal(1==0, "No fronthaul interface at south port");
 
+
+    LOG_D(PHY,"RU thread (proc %p), received frame %d (%p), subframe %d (%p)\n",
+	  proc, proc->frame_tx,&frame,subframe,&subframe);
+ 
+    if ((ru->do_prach>0) && (is_prach_subframe(fp, proc->frame_rx, proc->subframe_rx)>0))
+      wakeup_prach(ru);
+
+
+
+    // adjust for timing offset between RU
+    if (ru->idx!=0) proc->frame_tx = (proc->frame_tx+proc->frame_offset)&1023;
+
+
     // do RX front-end processing (frequency-shift, dft) if needed
-    if (ru->fep_rx) ru->fep_rx(ru);
+    if (ru->feprx) ru->feprx(ru);
+
 
     T(T_ENB_MASTER_TICK, T_INT(0), T_INT(proc->frame_rx), T_INT(proc->subframe_rx));
 
@@ -955,16 +971,24 @@ static void* ru_thread( void* param ) {
     wakeup_slaves(proc);
 
     // wakeup all eNB processes waiting for this RU
-    if (ru->eNB_list) wakeup_eNBs(ru);
+    if (ru->num_eNB>0) wakeup_eNBs(ru);
+
 
     // wait until eNBs are finished subframe RX n and TX n+4
     wait_on_condition(&proc->mutex_eNBs,&proc->cond_eNBs,&proc->instance_cnt_eNBs,"ru_thread");
 
+
     // do TX front-end processing if needed (precoding and/or IDFTs)
-    if (ru->fep_tx) ru->fep_tx(ru);
+    if (ru->feptx_prec) ru->feptx_prec(ru);
+   
+    // do OFDM if needed
+    if ((ru->fh_north_asynch_in == NULL) && (ru->feptx_ofdm)) ru->feptx_ofdm(ru);
+    // do outgoing fronthaul (south) if needed
+    if ((ru->fh_north_asynch_in == NULL) && (ru->fh_south_out)) ru->fh_south_out(ru);
+
+
 
-    // do outgoing fronthaul if needed
-    if (ru->fh_south_out) ru->fh_south_out(ru,&frame,&subframe);
+    if (ru->fh_north_out) ru->fh_north_out(ru);
   }
   
 
@@ -984,7 +1008,7 @@ void *ru_thread_synch(void *arg) {
   int32_t sync_pos,sync_pos2;
   uint32_t peak_val;
   uint32_t sync_corr[307200] __attribute__((aligned(32)));
-
+  static int ru_thread_synch_status;
 
 
   thread_top_init("ru_thread_synch",0,5000000,10000000,10000000);
@@ -992,19 +1016,19 @@ void *ru_thread_synch(void *arg) {
   wait_sync("ru_thread_synch");
 
   // initialize variables for PSS detection
-  lte_sync_time_init(&eNB->frame_parms);
+  lte_sync_time_init(&ru->frame_parms);
 
   while (!oai_exit) {
 
     // wait to be woken up
-    if (wait_on_condition(&ru->proc.mutex_synch,&ru->proccont_synch,&ru->proc.instance_cnt_synch,"ru_thread_synch")<0) break;
+    if (wait_on_condition(&ru->proc.mutex_synch,&ru->proc.cond_synch,&ru->proc.instance_cnt_synch,"ru_thread_synch")<0) break;
 
     // if we're not in synch, then run initial synch
     if (ru->in_synch == 0) { 
       // run intial synch like UE
       LOG_I(PHY,"Running initial synchronization\n");
       
-      sync_pos = lte_sync_time_eNB(ru->ru_time.rxdata[0],
+      sync_pos = lte_sync_time_eNB(ru->common.rxdata,
 				   fp,
 				   fp->samples_per_tti*5,
 				   &peak_val,
@@ -1050,124 +1074,514 @@ void *ru_thread_synch(void *arg) {
 
   lte_sync_time_free();
 
+  ru_thread_synch_status = 0;
+  return &ru_thread_synch_status;
+
 }
 
-int wakeup_synch(RU_t *ru){
 
-  struct timespec wait;
+ 
+int start_if(struct RU_t_s *ru,struct PHY_VARS_eNB_s *eNB) {
+  return(ru->ifdevice.trx_start_func(&ru->ifdevice));
+}
+
+int start_rf(RU_t *ru) {
+  return(ru->rfdevice.trx_start_func(&ru->rfdevice));
+}
+
+extern void fep_full(RU_t *ru);
+extern void fep_full_2thread(RU_t *ru);
+extern void feptx_ofdm(RU_t *ru);
+extern void feptx_prec(RU_t *ru);
+
+void init_RU_proc(RU_t *ru) {
+   
+  int i=0;
+  RU_proc_t *proc;
+  pthread_attr_t *attr_FH=NULL,*attr_prach=NULL,*attr_asynch=NULL,*attr_synch=NULL;
+  //pthread_attr_t *attr_fep=NULL;
+
+  char name[100];
+
+#ifndef OCP_FRAMEWORK
+  LOG_I(PHY,"Initializing RU %d (%s,%s),\n",ru->idx,eNB_functions[ru->function],eNB_timing[ru->if_timing]);
+#endif
+  proc = &ru->proc;
+  memset((void*)proc,0,sizeof(RU_proc_t));
+
+  proc->ru = ru;
+  proc->instance_cnt_prach       = -1;
+  proc->instance_cnt_synch       = -1;
+  proc->instance_cnt_FH          = -1;
+  proc->instance_cnt_asynch_rxtx = -1;
+  proc->first_rx                 = 1;
+  proc->first_tx                 = 1;
+  proc->frame_offset             = 0;
+  proc->num_slaves               = 0;
+  for (i=0;i<10;i++) proc->symbol_mask[i]=0;
   
-  wait.tv_sec=0;
-  wait.tv_nsec=5000000L;
+  pthread_mutex_init( &proc->mutex_prach, NULL);
+  pthread_mutex_init( &proc->mutex_asynch_rxtx, NULL);
+  pthread_mutex_init( &proc->mutex_synch,NULL);
+  pthread_mutex_init( &proc->mutex_FH,NULL);
+  
+  pthread_cond_init( &proc->cond_prach, NULL);
+  pthread_cond_init( &proc->cond_FH, NULL);
+  pthread_cond_init( &proc->cond_asynch_rxtx, NULL);
+  pthread_cond_init( &proc->cond_synch,NULL);
+  
+  pthread_attr_init( &proc->attr_FH);
+  pthread_attr_init( &proc->attr_prach);
+  pthread_attr_init( &proc->attr_synch);
+  pthread_attr_init( &proc->attr_asynch_rxtx);
+  pthread_attr_init( &proc->attr_fep);
+  
+  
+#ifndef DEADLINE_SCHEDULER
+  attr_FH     = &proc->attr_FH;
+  attr_prach  = &proc->attr_prach;
+  attr_synch  = &proc->attr_synch;
+  attr_asynch = &proc->attr_asynch_rxtx;
+  //  attr_fep    = &proc->attr_fep;
+#endif
+  
+  pthread_create( &proc->pthread_FH, attr_FH, ru_thread, (void*)ru );
 
-  // wake up synch thread
-  // lock the synch mutex and make sure the thread is ready
-  if (pthread_mutex_timedlock(&ru->proc.mutex_synch,&wait) != 0) {
-    LOG_E( PHY, "[RU] ERROR pthread_mutex_lock for RU synch thread (IC %d)\n", ru->proc.instance_cnt_synch );
-    exit_fun( "error locking mutex_synch" );
-    return(-1);
+  if (ru->function == NGFI_RRU_IF4p5) {
+    pthread_create( &proc->pthread_prach, attr_prach, ru_thread_prach, (void*)ru );
+  
+    if (ru->is_slave == 1) pthread_create( &proc->pthread_synch, attr_synch, ru_thread_synch, (void*)ru);
+    
+    
+    if ((ru->if_timing == synch_to_other) ||
+	(ru->function == NGFI_RRU_IF5) ||
+	(ru->function == NGFI_RRU_IF4p5))
+      
+      
+      pthread_create( &proc->pthread_asynch_rxtx, attr_asynch, ru_thread_asynch_rxtx, (void*)ru );
+    
+    
+    
+    snprintf( name, sizeof(name), "ru_thread_FH %d", ru->idx );
+    pthread_setname_np( proc->pthread_FH, name );
+    
   }
   
-  ++RU->proc.instance_cnt_synch;
   
-  // the thread can now be woken up
-  if (pthread_cond_signal(&ru->proc.cond_synch) != 0) {
-    LOG_E( PHY, "[RU] ERROR pthread_cond_signal for RU synch thread\n");
-    exit_fun( "ERROR pthread_cond_signal" );
+}
+
+/* this function maps the RU tx and rx buffers to the available rf chains.
+   Each rf chain is is addressed by the card number and the chain on the card. The
+   rf_map specifies for each antenna port, on which rf chain the mapping should start. Multiple
+   antennas are mapped to successive RF chains on the same card. */
+int setup_RU_buffers(RU_t *ru) {
+
+  int i,j; 
+  int card,ant;
+
+  //uint16_t N_TA_offset = 0;
+
+  LTE_DL_FRAME_PARMS *frame_parms;
+  
+  if (ru) {
+    frame_parms = &ru->frame_parms;
+    printf("setup_RU_buffers: frame_parms = %p\n",frame_parms);
+  } else {
+    printf("RU[%d] not initialized\n", ru->idx);
     return(-1);
   }
   
-  pthread_mutex_unlock( &RU->proc.mutex_synch );
-
+  /*
+    if (frame_parms->frame_type == TDD) {
+    if (frame_parms->N_RB_DL == 100)
+    N_TA_offset = 624;
+    else if (frame_parms->N_RB_DL == 50)
+    N_TA_offset = 624/2;
+    else if (frame_parms->N_RB_DL == 25)
+    N_TA_offset = 624/4;
+    }
+  */
+  
+  
+  if (ru->openair0_cfg.mmapped_dma == 1) {
+    // replace RX signal buffers with mmaped HW versions
+    
+    for (i=0; i<ru->nb_rx; i++) {
+      card = i/4;
+      ant = i%4;
+      printf("Mapping RU id %d, rx_ant %d, on card %d, chain %d\n",ru->idx,i,ru->rf_map.card+card, ru->rf_map.chain+ant);
+      free(ru->common.rxdata[i]);
+      ru->common.rxdata[i] = ru->openair0_cfg.rxbase[ru->rf_map.chain+ant];
+      
+      printf("rxdata[%d] @ %p\n",i,ru->common.rxdata[i]);
+      for (j=0; j<16; j++) {
+	printf("rxbuffer %d: %x\n",j,ru->common.rxdata[i][j]);
+	ru->common.rxdata[i][j] = 16-j;
+      }
+    }
+    
+    for (i=0; i<ru->nb_tx; i++) {
+      card = i/4;
+      ant = i%4;
+      printf("Mapping RU id %d, tx_ant %d, on card %d, chain %d\n",ru->idx,i,ru->rf_map.card+card, ru->rf_map.chain+ant);
+      free(ru->common.txdata[i]);
+      ru->common.txdata[i] = ru->openair0_cfg.txbase[ru->rf_map.chain+ant];
+      
+      printf("txdata[%d] @ %p\n",i,ru->common.txdata[i]);
+      
+      for (j=0; j<16; j++) {
+	printf("txbuffer %d: %x\n",j,ru->common.txdata[i][j]);
+	ru->common.txdata[i][j] = 16-j;
+      }
+    }
+  }
+  else {  // not memory-mapped DMA 
+    //nothing to do, everything already allocated in lte_init
+  }
   return(0);
 }
 
- 
-int start_if(RU_t *ru) {
-  return(ru->ifdevice.trx_start_func(&ru->ifdevice));
+// this is for RU with local RF unit
+void fill_rf_config(RU_t *ru,const char *rf_config_file) {
+
+  int i;
+
+  LTE_DL_FRAME_PARMS *fp   = &ru->frame_parms;
+  openair0_config_t *cfg   = &ru->openair0_cfg;
+
+  if(fp->N_RB_DL == 100) {
+    if (fp->threequarter_fs) {
+      cfg->sample_rate=23.04e6;
+      cfg->samples_per_frame = 230400; 
+      cfg->tx_bw = 10e6;
+      cfg->rx_bw = 10e6;
+    }
+    else {
+      cfg->sample_rate=30.72e6;
+      cfg->samples_per_frame = 307200; 
+      cfg->tx_bw = 10e6;
+      cfg->rx_bw = 10e6;
+    }
+  } else if(fp->N_RB_DL == 50) {
+    cfg->sample_rate=15.36e6;
+    cfg->samples_per_frame = 153600;
+    cfg->tx_bw = 5e6;
+    cfg->rx_bw = 5e6;
+  } else if (fp->N_RB_DL == 25) {
+    cfg->sample_rate=7.68e6;
+    cfg->samples_per_frame = 76800;
+    cfg->tx_bw = 2.5e6;
+    cfg->rx_bw = 2.5e6;
+  } else if (fp->N_RB_DL == 6) {
+    cfg->sample_rate=1.92e6;
+    cfg->samples_per_frame = 19200;
+    cfg->tx_bw = 1.5e6;
+    cfg->rx_bw = 1.5e6;
+  }
+
+  if (fp->frame_type==TDD)
+    cfg->duplex_mode = duplex_mode_TDD;
+  else //FDD
+    cfg->duplex_mode = duplex_mode_FDD;
+
+  cfg->Mod_id = 0;
+  cfg->num_rb_dl=fp->N_RB_DL;
+  cfg->tx_num_channels=ru->nb_tx;
+  cfg->rx_num_channels=ru->nb_rx;
+  
+  for (i=0; i<ru->nb_tx; i++) {
+    
+    cfg->tx_freq[i] = (double)fp->dl_CarrierFreq;
+    cfg->rx_freq[i] = (double)fp->ul_CarrierFreq;
+
+    cfg->tx_gain[i] = (double)fp->att_tx;
+    cfg->rx_gain[i] = (double)fp->att_rx;
+
+    cfg->configFilename = rf_config_file;
+    printf("channel %d, Setting tx_gain %f, rx_gain %f, tx_freq %f, rx_freq %f\n",
+	   i, cfg->tx_gain[i],
+	   cfg->rx_gain[i],
+	   cfg->tx_freq[i],
+	   cfg->rx_freq[i]);
+  }
 }
 
-int start_rf(RU_t *ru) {
-  return(ru->rfdevice.trx_start_func(&ru->rfdevice));
+int check_capabilities(RU_t *ru,RRU_capabilities_t *cap) {
+
+  FH_fmt_options_t fmt = cap->FH_fmt;
+
+  int i;
+  int found_band=0;
+
+  LOG_I(PHY,"RRU %d, num_bands %d, looking for band %d\n",ru->idx,cap->num_bands,ru->frame_parms.eutra_band);
+  for (i=0;i<cap->num_bands;i++) {
+    LOG_I(PHY,"band %d on RRU %d\n",cap->band_list[i],ru->idx);
+    if (ru->frame_parms.eutra_band == cap->band_list[i]) {
+      found_band=1;
+      break;
+    }
+  }
+
+  if (found_band == 0) {
+    LOG_I(PHY,"Couldn't find target EUTRA band %d on RRU %d\n",ru->frame_parms.eutra_band,ru->idx);
+    return(-1);
+  }
+
+  switch (ru->if_south) {
+  case LOCAL_RF:
+    AssertFatal(1==0, "This RU should not have a local RF, exiting\n");
+    return(0);
+    break;
+  case REMOTE_IF5:
+    if (fmt == OAI_IF5_only || fmt == OAI_IF5_and_IF4p5) return(0);
+    break;
+  case REMOTE_IF4p5:
+    if (fmt == OAI_IF4p5_only || fmt == OAI_IF5_and_IF4p5) return(0);
+    break;
+  case REMOTE_MBP_IF5:
+    if (fmt == MBP_IF5) return(0);
+    break;
+  default:
+    LOG_I(PHY,"No compatible Fronthaul interface found for RRU %d\n", ru->idx);
+    return(-1);
+  }
+
 }
 
-extern void ru_fep_if5(PHY_VARS_eNB *eNB);
-extern void ru_fep_full(PHY_VARS_eNB *eNB);
-extern void ru_fep_full_2thread(PHY_VARS_eNB *eNB);
-extern void do_prach(PHY_VARS_eNB *eNB,RU_t *ru);
 
-void init_RU(eNB_func_t node_function, RU_if_in_t ru_if_in[], RU_if_timing_t ru_if_timing[], eth_params_t *eth_params) {
+char rru_format_options[4][20] = {"OAI_IF5_only","OAI_IF4p5_only","OAI_IF5_and_IF4p5","MBP_IF5"};
+char rru_formats[3][20] = {"OAI_IF5","MBP_IF5","OAI_IF4p5"};
+
+void configure_ru(int idx,
+		  void *arg) {
+
+  RU_t               *ru           = RC.ru[idx];
+  RRU_config_t       *config       = (RRU_config_t *)arg;
+  RRU_capabilities_t *capabilities = (RRU_capabilities_t*)arg;
+  int ret;
+
+  LOG_I(PHY, "Received capabilities from RRU %d\n",idx);
+
+
+  if (capabilities->FH_fmt < MAX_FH_FMTs) LOG_I(PHY, "RU FH options %s\n",rru_format_options[capabilities->FH_fmt]);
+  if ((ret=check_capabilities(ru,capabilities)) == 0) {
+    // Pass configuration to RRU
+    LOG_I(PHY, "Using %s fronthaul, band %d \n",rru_formats[ru->if_south],ru->frame_parms.eutra_band);
+    config->FH_fmt                 = ru->if_south;
+    config->num_bands              = 1;
+    config->band_list[0]           = ru->frame_parms.eutra_band;
+    config->tx_freq[0]             = ru->frame_parms.dl_CarrierFreq;      
+    config->rx_freq[0]             = ru->frame_parms.ul_CarrierFreq;      
+    config->att_tx[0]              = ru->att_tx;
+    config->att_rx[0]              = ru->att_rx;
+    config->N_RB_DL[0]             = ru->frame_parms.N_RB_DL;
+    config->N_RB_UL[0]             = ru->frame_parms.N_RB_UL;
+    config->threequarter_fs[0]     = ru->frame_parms.threequarter_fs;
+    if (ru->if_south==REMOTE_IF4p5) {
+      config->prach_FreqOffset[0]  = ru->frame_parms.prach_config_common.prach_ConfigInfo.prach_FreqOffset;
+      config->prach_ConfigIndex[0] = ru->frame_parms.prach_config_common.prach_ConfigInfo.prach_ConfigIndex;
+    }
+    // take antenna capabilities of RRU
+    ru->nb_tx                      = capabilities->nb_tx[0];
+    ru->nb_rx                      = capabilities->nb_rx[0];
+  }
+  else {
+    LOG_I(PHY,"Cannot configure RRU %d, check_capabilities returned %d\n", idx,ret);
+  }
+
+  init_frame_parms(&ru->frame_parms,1);
+  phy_init_RU(ru);
+
+  return(0);
+}
+
+int configure_rru(int idx,
+		  void *arg) {
+
+  RRU_config_t *config = (RRU_config_t *)arg;
+  RU_t         *ru         = RC.ru[idx];
+
+  ru->frame_parms.eutra_band                                               = config->band_list[0];
+  ru->frame_parms.dl_CarrierFreq                                           = config->tx_freq[0];
+  ru->frame_parms.ul_CarrierFreq                                           = config->rx_freq[0];
+  ru->att_tx                                                               = config->att_tx[0];
+  ru->att_rx                                                               = config->att_rx[0];
+  ru->frame_parms.N_RB_DL                                                  = config->N_RB_DL[0];
+  ru->frame_parms.N_RB_UL                                                  = config->N_RB_UL[0];
+  ru->frame_parms.threequarter_fs                                          = config->threequarter_fs[0];
+  ru->frame_parms.pdsch_config_common.referenceSignalPower                 = ru->max_pdschReferenceSignalPower-config->att_tx[0];
+  if (ru->function==NGFI_RRU_IF4p5) {
+    ru->frame_parms.prach_config_common.prach_ConfigInfo.prach_FreqOffset  = config->prach_FreqOffset[0]; 
+    ru->frame_parms.prach_config_common.prach_ConfigInfo.prach_ConfigIndex = config->prach_ConfigIndex[0]; 
+  }
+  
+  init_frame_parms(&ru->frame_parms,1);
+
+
+  phy_init_RU(ru);
+
+  return(0);
+}
+
+void init_precoding_weights(PHY_VARS_eNB *eNB) {
+
+  int layer,ru_id,aa,re,ue,tb;
+  LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms;
+  RU_t *ru;
+  LTE_eNB_DLSCH_t *dlsch;
+
+  // init precoding weigths
+  for (ue=0;ue<NUMBER_OF_UE_MAX;ue++) {
+    for (tb=0;tb<2;tb++) {
+      dlsch = eNB->dlsch[ue][tb];
+      for (layer=0; layer<4; layer++) {
+	for (ru_id=0;ru_id<RC.nb_RU;ru_id++) {
+	  ru = RC.ru[ru_id];
+	  dlsch->ue_spec_bf_weights[ru_id][layer] = (int32_t**)malloc16(ru->nb_tx*sizeof(int32_t*));
+	  
+	  for (aa=0; aa<ru->nb_tx; aa++) {
+	    dlsch->ue_spec_bf_weights[ru_id][layer][aa] = (int32_t *)malloc16(fp->ofdm_symbol_size*sizeof(int32_t));
+	    for (re=0;re<fp->ofdm_symbol_size; re++) {
+	      dlsch->ue_spec_bf_weights[ru_id][layer][aa][re] = 0x00007fff;
+	    }
+	  }
+	}
+      }
+    }
+  }
+}
+
+void init_RU(const char *rf_config_file) {
   
   int ru_id;
+  RU_t *ru;
+  int ret;
+  PHY_VARS_eNB *eNB0;
+  int i;
+  int CC_id;
+
+  // create status mask
+  RC.ru_mask = 0;
+  pthread_mutex_init(&RC.ru_mutex,NULL);
+  pthread_cond_init(&RC.ru_cond,NULL);
+
+  // read in configuration file
+  RCconfig_RU();
+
+  for (i=0;i<RC.nb_inst;i++) 
+    for (CC_id=0;CC_id<RC.nb_CC[i];CC_id++) RC.eNB[i][CC_id]->num_RU=0;
+
+  for (ru_id=0;ru_id<RC.nb_RU;ru_id++) {
+    ru               = RC.ru[ru_id];
+    ru->idx          = ru_id;              
+    ru->ts_offset    = 0;
+    // use eNB_list[0] as a reference for RU frame parameters
+    // NOTE: multiple CC_id are not handled here yet!
 
-  for (ru_id=0;ru_id<rc->nb_RU;ru_id++) {
-    ru               = &RC.ru_desc[ru_id];
-    ru->RU_if_in     = ru_if_in[ru_id];
-    ru->RU_if_timing = ru_if_timing[ru_id];
-    LOG_I(PHY,"Initializing RRU descriptor %d : (%s,%s)\n",ru_id,ru_if_types[ru_if_in[ru_id]],eNB_timing[ru_timing[ru_id]]);
     
-    switch (ru->RU_if_in) {
+    eNB0             = ru->eNB_list[0];
+
+    if (eNB0) memcpy((void*)&ru->frame_parms,(void*)&eNB0->frame_parms,sizeof(LTE_DL_FRAME_PARMS));
+
+    // attach all RU to all eNBs in its list/
+    for (i=0;i<ru->num_eNB;i++) {
+      eNB0 = ru->eNB_list[i];
+      eNB0->RU_list[eNB0->num_RU++] = ru;
+    }
+    LOG_I(PHY,"Initializing RRU descriptor %d : (%s,%s,%d)\n",ru_id,ru_if_types[ru->if_south],eNB_timing[ru->if_timing],ru->function);
+
+    
+    switch (ru->if_south) {
     case LOCAL_RF:   // this is an RU with integrated RF (RRU, eNB)
-      if (node_function ==  NGFI_RRU_IF5) {                 // IF5 RRU
-	ru->do_prach              = NULL;                   // no prach processing
+      if (ru->function ==  NGFI_RRU_IF5) {                 // IF5 RRU
+	ru->do_prach              = 0;                      // no prach processing in RU
 	ru->fh_north_in           = NULL;                   // no synchronous incoming fronthaul from north
-	ru->fh_north_out          = fh_if5_north_out        // need only to do send_IF5 on reception
-	ru->fh_north_asynch_in    = fh_if5_north_in;        // TX packets come asynchronously 
-	ru->fep_rx                = NULL;                   // nothing (this is a time-domain signal)
-	ru->fep_tx                = NULL;                   // nothing (this is a time-domain signal)
+	ru->fh_north_out          = fh_if5_north_out;       // need only to do send_IF5  reception
+	ru->fh_south_out          = tx_rf;                  // send output to RF
+	ru->fh_north_asynch_in    = fh_if5_north_asynch_in; // TX packets come asynchronously 
+	ru->feprx                 = NULL;                   // nothing (this is a time-domain signal)
+	ru->feptx_ofdm            = NULL;                   // nothing (this is a time-domain signal)
+	ru->feptx_prec            = NULL;                   // nothing (this is a time-domain signal)
 	ru->start_if              = start_if;               // need to start the if interface for if5
-	ru->ifdevice.host_type    = RRH_HOST;
-	ru->rfdevice.host_type    = RRH_HOST;
+	ru->ifdevice.host_type    = RRU_HOST;
+	ru->rfdevice.host_type    = RRU_HOST;
+	ru->ifdevice.eth_params   = &ru->eth_params;
+
+	ret = openair0_transport_load(&ru->ifdevice,&ru->openair0_cfg,&ru->eth_params);
+	printf("openair0_transport_init returns %d for ru_id %d\n",ret,ru_id);
+	if (ret<0) {
+	  printf("Exiting, cannot initialize transport protocol\n");
+	  exit(-1);
+	}
       }
-      else if (node_function == NGFI_RRU_IF4p5) {
-	ru->do_prach              = do_prach;               // IF4p5 needs to do part of prach processing in RRU
-	ru->fh_north_in           = NULL;                   // no synchronous incoming fronthaul from north
-	ru->fh_north_out          = fh_if4p5_north_out;     // send_IF4p5 on reception
-	ru->fh_north_asynch_in    = fh_if4p5_north_in;      // TX packets come asynchronously
-	ru->fep_rx                = fep_dft;                // RX DFTs
-	ru->fep_tx                = fep_idft;               // this is fep with idft only (no precoding in RRU)
-	ru->start_if              = start_if;               // need to start the if interface for if4p5
-	ru->ifdevice.host_type    = RRH_HOST;
-	ru->rfdevice.host_type    = RRH_HOST;
+      else if (ru->function == NGFI_RRU_IF4p5) {
+	ru->do_prach              = 1;                        // do part of prach processing in RU
+	ru->fh_north_in           = NULL;                     // no synchronous incoming fronthaul from north
+	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->feptx_prec            = NULL;
+	ru->start_if              = start_if;                 // need to start the if interface for if4p5
+	ru->ifdevice.host_type    = RRU_HOST;
+	ru->rfdevice.host_type    = RRU_HOST;
+	ru->ifdevice.eth_params   = &ru->eth_params;
+
+	ret = openair0_transport_load(&ru->ifdevice,&ru->openair0_cfg,&ru->eth_params);
+	printf("openair0_transport_init returns %d for ru_id %d\n",ret,ru_id);
+	if (ret<0) {
+	  printf("Exiting, cannot initialize transport protocol\n");
+	  exit(-1);
+	}
+	malloc_IF4p5_buffer(ru);
       }
-      else if (node_function == eNodeB_3GPP) {              
-	ru->do_prach             = NULL;                    // prach is done completely in eNB processing
-	ru->fep_rx               = fep_dft;                 // RX DFTs
-	ru->fep_tx               = fep_idft_prec;           // this is fep with idft and precoding
+      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->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
 	ru->start_if             = NULL;                    // no if interface
-	ru->rfdevice.host_type   = BBU_HOST;
+	ru->rfdevice.host_type   = RAU_HOST;
       }
       ru->fh_south_in            = rx_rf;                               // local synchronous RF RX
-      ru->fh_south_out           = NULL;                                // nothing connected directly to radio
+      ru->fh_south_out           = tx_rf;                               // local synchronous RF TX
       ru->start_rf               = start_rf;                            // need to start the local RF interface
+      ru->ifdevice.configure_rru = configure_rru;
+      fill_rf_config(ru,rf_config_file);
+      
 
-      ret = openair0_device_load(&ru->rfdevice, &openair0_cfg[ru_id]);
-      if (setup_RU_buffers(rc,ru_id,&openair0_cfg[ru_id])!=0) {
-	printf("Exiting, cannot initialize eNodeB Buffers\n");
+      ret = openair0_device_load(&ru->rfdevice,&ru->openair0_cfg);
+      if (setup_RU_buffers(ru)!=0) {
+	printf("Exiting, cannot initialize RU Buffers\n");
 	exit(-1);
       }
       break;
 
     case REMOTE_IF5: // the remote unit is IF5 RRU
-      ru->do_prach              = NULL;                       // no prach processing in RU
-      ru->fep_rx                = fep_dft;                    // this is frequency-shift + DFTs
-      ru->fep_tx                = fep_prec_idft;              // need to do transmit Precoding + IDFTs 
-      if (ru->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
-	ru->fh_south_asynch_in  = fh_if5_asynch_UL;    // UL is asynchronous
+      ru->do_prach               = 0;
+      ru->feprx                  = 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 
+      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
+	ru->fh_south_asynch_in   = fh_if5_south_asynch_in_mobipass;    // UL is asynchronous
       }
       else {
-	ru->fh_south_in         = fh_if5_south_in;     // synchronous IF5 reception
-	ru->fh_south_out        = fh_if5_south_out;    // synchronous IF5 transmission
-	ru->fh_south_asynch_in  = NULL;                // no asynchronous UL
+	ru->fh_south_in          = fh_if5_south_in;     // synchronous IF5 reception
+	ru->fh_south_out         = fh_if5_south_out;    // synchronous IF5 transmission
+	ru->fh_south_asynch_in   = NULL;                // no asynchronous UL
       }
-      ru->start_rf             = NULL;                 // no local RF
-      ru->start_if             = start_if;             // need to start if interface for IF5 
-      ru->ifdevice.host_type   = BBU_HOST;
+      ru->start_rf               = NULL;                 // no local RF
+      ru->start_if               = start_if;             // need to start if interface for IF5 
+      ru->ifdevice.host_type     = RAU_HOST;
+      ru->ifdevice.eth_params    = &ru->eth_params;
+      ru->ifdevice.configure_rru = configure_ru;
 
-      ret = openair0_transport_load(&ru->ifdevice, &openair0_cfg[ru_id], (eth_params+ru_id));
+      ret = openair0_transport_load(&ru->ifdevice,&ru->openair0_cfg,&ru->eth_params);
       printf("openair0_transport_init returns %d for ru_id %d\n",ret,ru_id);
       if (ret<0) {
 	printf("Exiting, cannot initialize transport protocol\n");
@@ -1176,39 +1590,47 @@ void init_RU(eNB_func_t node_function, RU_if_in_t ru_if_in[], RU_if_timing_t ru_
       break;
 
     case REMOTE_IF4p5:
-      ru->do_prach              = NULL;                // no prach processing in RU
-      ru->fep_rx                = NULL;                // DFTs
-      ru->fep_tx                = fep_prec;            // need to do transmit Precoding (no IDFTs)
-      ru->fh_south_in           = fh_if4p5_south_in;   // synchronous IF4p5 reception
-      ru->fh_south_out          = fh_if4p5_south_out;  // synchronous IF4p5 transmission
-      ru->fh_south_asynch_in    = (ru->RU_if_timing == synch_to_other) ? fh_if4p5_south_in : NULL;                // asynchronous UL if synch_to_other
-      
-      ru->start_rf              = NULL;                // no local RF
-      ru->start_if              = start_if;            // need to start if interface for IF4p5 
-      ru->fh_asynch             = fh_if5_asynch_DL;
-      ru->ifdevice.host_type    = BBU_HOST;
-
-      ret = openair0_transport_load(&ru->ifdevice, &openair0_cfg[ru_id], (eth_params+ru_id));
+      ru->do_prach               = 0;
+      ru->feprx                  = NULL;                // DFTs
+      ru->feptx_prec             = feptx_prec;          // Precoding operation
+      ru->feptx_ofdm             = NULL;                // no OFDM mod
+      ru->fh_south_in            = fh_if4p5_south_in;   // synchronous IF4p5 reception
+      ru->fh_south_out           = fh_if4p5_south_out;  // synchronous IF4p5 transmission
+      ru->fh_south_asynch_in     = (ru->if_timing == synch_to_other) ? fh_if4p5_south_in : NULL;                // asynchronous UL if synch_to_other
+      ru->fh_north_out           = NULL;
+      ru->fh_north_asynch_in     = NULL;
+      ru->start_rf               = NULL;                // no local RF
+      ru->start_if               = start_if;            // need to start if interface for IF4p5 
+      ru->ifdevice.host_type     = RAU_HOST;
+      ru->ifdevice.eth_params    = &ru->eth_params;
+      ru->ifdevice.configure_rru = configure_ru;
+
+      ret = openair0_transport_load(&ru->ifdevice, &ru->openair0_cfg, &ru->eth_params);
       printf("openair0_transport_init returns %d for ru_id %d\n",ret,ru_id);
       if (ret<0) {
 	printf("Exiting, cannot initialize transport protocol\n");
 	exit(-1);
       }
       
-      malloc_IF4p5_buffer(eNB);
+      malloc_IF4p5_buffer(ru);
       
       break;
 
-    case REMOTE_IF1pp:
-      LOG_E(PHY,"RU with IF1pp not supported yet\n");
+    default:
+      LOG_E(PHY,"RU with invalid or unknown southbound interface type %d\n",ru->if_south);
       break;
-
     } // switch on interface type 
 
+    LOG_I(PHY,"Starting ru_thread %d\n",ru_id);
+
+    init_RU_proc(ru);
+
+
+
   } // for ru_id
 
   sleep(1);
-  LOG_D(HW,"[lte-softmodem.c] eNB threads created\n");
+  LOG_D(HW,"[lte-softmodem.c] RU threads created\n");
   
 
 }
@@ -1221,3 +1643,4 @@ void stop_ru(RU_t *ru) {
   printf("Stopping RU %p processing threads\n",(void*)ru);
   
 }
+
diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c
index 5342a1b665..e93ddf6c9c 100644
--- a/targets/RT/USER/lte-softmodem.c
+++ b/targets/RT/USER/lte-softmodem.c
@@ -56,6 +56,8 @@
 #include "PHY/types.h"
 
 #include "PHY/defs.h"
+#include "common/ran_context.h"
+
 #undef MALLOC //there are two conflicting definitions, so we better make sure we don't use it at all
 //#undef FRAME_LENGTH_COMPLEX_SAMPLES //there are two conflicting definitions, so we better make sure we don't use it at all
 
@@ -110,16 +112,18 @@ extern int netlink_init(void);
 #include "stats.h"
 #endif
 
+// In lte-ru.c
+extern void init_RU(const char*);
+
 // In lte-enb.c
-extern int setup_eNB_buffers(PHY_VARS_eNB **phy_vars_eNB, openair0_config_t *openair0_cfg);
-extern void init_eNB(eNB_func_t *, eNB_timing_t *,int,eth_params_t *,int,int);
+extern void init_eNB(int,int);
 extern void stop_eNB(int);
 extern void kill_eNB_proc(void);
 
 // In lte-ue.c
 extern int setup_ue_buffers(PHY_VARS_UE **phy_vars_ue, openair0_config_t *openair0_cfg);
 extern void fill_ue_band_info(void);
-extern void init_UE(int);
+extern void init_UE(int,int,int);
 
 #ifdef XFORMS
 // current status is that every UE has a DL scope for a SINGLE eNB (eNB_id=0)
@@ -223,19 +227,22 @@ int                             otg_enabled;
 #endif
 //int                             number_of_cards =   1;
 
+/*
 
-static LTE_DL_FRAME_PARMS      *frame_parms[MAX_NUM_CCs];
-eNB_func_t node_function[MAX_NUM_CCs];
-eNB_timing_t node_timing[MAX_NUM_CCs];
-int16_t   node_synch_ref[MAX_NUM_CCs];
+node_function_t node_function[MAX_NUM_CCs];
+node_timing_t node_timing[MAX_NUM_CCs];
+int16_t  node_synch_ref[MAX_NUM_CCs];
+RU_if_in_t ru_if_in[NUMBER_OF_RU_MAX];
 
+*/
+
+static LTE_DL_FRAME_PARMS      *frame_parms[MAX_NUM_CCs];
 uint32_t target_dl_mcs = 28; //maximum allowed mcs
 uint32_t target_ul_mcs = 20;
 uint32_t timing_advance = 0;
 uint8_t exit_missed_slots=1;
 uint64_t num_missed_slots=0; // counter for the number of missed slots
 
-
 extern void reset_opp_meas(void);
 extern void print_opp_meas(void);
 int transmission_mode=1;
@@ -270,12 +277,6 @@ int16_t           osa_log_verbosity  = LOG_MED;
 
 
 
-char *rrh_UE_ip = "127.0.0.1";
-int rrh_UE_port = 51000;
-
-
-/* flag set by eNB conf file to specify if the radio head is local or remote (default option is local) */
-uint8_t local_remote_radio = BBU_LOCAL_RADIO_HEAD;
 /* struct for ethernet specific parameters given in eNB conf file */
 eth_params_t *eth_params;
 
@@ -283,7 +284,8 @@ openair0_config_t openair0_cfg[MAX_CARDS];
 
 double cpuf;
 
-char uecap_xer[1024],uecap_xer_in=0;
+extern char uecap_xer[1024];
+char uecap_xer_in=0;
 
 int oaisim_flag=0;
 
@@ -416,19 +418,28 @@ void help (void) {
 void exit_fun(const char* s)
 {
   int CC_id;
+  int ru_id;
 
   if (s != NULL) {
     printf("%s %s() Exiting OAI softmodem: %s\n",__FILE__, __FUNCTION__, s);
   }
 
   oai_exit = 1;
-  
+
+  if (UE_flag==0) {
+    for (ru_id=0; ru_id<RC.nb_RU;ru_id++) {
+      if (RC.ru[ru_id]->rfdevice.trx_end_func)
+	RC.ru[ru_id]->rfdevice.trx_end_func(&RC.ru[ru_id]->rfdevice);
+      if (RC.ru[ru_id]->ifdevice.trx_end_func)
+	RC.ru[ru_id]->ifdevice.trx_end_func(&RC.ru[ru_id]->ifdevice);  
+    }
+  }
+
   for(CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
     if (UE_flag == 0) {
-      if (PHY_vars_eNB_g[0][CC_id]->rfdevice.trx_end_func)
-	PHY_vars_eNB_g[0][CC_id]->rfdevice.trx_end_func(&PHY_vars_eNB_g[0][CC_id]->rfdevice);
-      if (PHY_vars_eNB_g[0][CC_id]->ifdevice.trx_end_func)
-	PHY_vars_eNB_g[0][CC_id]->ifdevice.trx_end_func(&PHY_vars_eNB_g[0][CC_id]->ifdevice);  
+      /*      Note: This is for later, when eNB can be split at IF2
+	      if (RC.eNB[0][CC_id]->ifdevice.trx_end_func)
+	        RC.eNB[0][CC_id]->ifdevice.trx_end_func(&RC.eNB[0][CC_id]->ifdevice); */  
     }
     else {
       if (PHY_vars_UE_g[0][CC_id]->rfdevice.trx_end_func)
@@ -449,7 +460,7 @@ void exit_fun(const char* s)
 void reset_stats(FL_OBJECT *button, long arg)
 {
   int i,j,k;
-  PHY_VARS_eNB *phy_vars_eNB = PHY_vars_eNB_g[0][0];
+  PHY_VARS_eNB *phy_vars_eNB = RC.eNB[0][0];
 
   for (i=0; i<NUMBER_OF_UE_MAX; i++) {
     for (k=0; k<8; k++) { //harq_processes
@@ -515,16 +526,16 @@ static void *scope_thread(void *arg)
                    0,7);
 
     } else {
-      if (PHY_vars_eNB_g[0][0]->mac_enabled==1) {
+      if (RC.eNB[0][0]->mac_enabled==1) {
 	len = dump_eNB_l2_stats (stats_buffer, 0);
 	//fl_set_object_label(form_stats_l2->stats_text, stats_buffer);
 	fl_clear_browser(form_stats_l2->stats_text);
 	fl_add_browser_line(form_stats_l2->stats_text, stats_buffer);
       }
-      len = dump_eNB_stats (PHY_vars_eNB_g[0][0], stats_buffer, 0);
+      len = dump_eNB_stats (RC.eNB[0][0], stats_buffer, 0);
 
       if (MAX_NUM_CCs>1)
-        len += dump_eNB_stats (PHY_vars_eNB_g[0][1], &stats_buffer[len], 0);
+        len += dump_eNB_stats (RC.eNB[0][1], &stats_buffer[len], 0);
 
       //fl_set_object_label(form_stats->stats_text, stats_buffer);
       fl_clear_browser(form_stats->stats_text);
@@ -533,10 +544,10 @@ static void *scope_thread(void *arg)
       ue_cnt=0;
       for(UE_id=0; UE_id<NUMBER_OF_UE_MAX; UE_id++) {
 	for(CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
-	  //	  if ((PHY_vars_eNB_g[0][CC_id]->dlsch[UE_id][0]->rnti>0) && (ue_cnt<scope_enb_num_ue)) {
+	  //	  if ((RC.eNB[0][CC_id]->dlsch[UE_id][0]->rnti>0) && (ue_cnt<scope_enb_num_ue)) {
 	  if ((ue_cnt<scope_enb_num_ue)) {
 	    phy_scope_eNB(form_enb[CC_id][ue_cnt],
-			  PHY_vars_eNB_g[0][CC_id],
+			  RC.eNB[0][CC_id],
 			  UE_id);
 	    ue_cnt++;
 	  }
@@ -671,7 +682,6 @@ static void get_options (int argc, char **argv)
 
 
 
-  const Enb_properties_array_t *enb_properties;
 
   enum long_option_e {
     LONG_OPTION_START = 0x100, /* Start after regular single char options */
@@ -1064,161 +1074,37 @@ static void get_options (int argc, char **argv)
     AssertFatal(conf_config_file_name != NULL,"Please provide a configuration file\n");
 
   if ((UE_flag == 0) && (conf_config_file_name != NULL)) {
-    int i,j;
-
-    NB_eNB_INST = 1;
-
-    /* Read eNB configuration file */
-    enb_properties = enb_config_init(conf_config_file_name);
-
-    AssertFatal (NB_eNB_INST <= enb_properties->number,
-                 "Number of eNB is greater than eNB defined in configuration file %s (%d/%d)!",
-                 conf_config_file_name, NB_eNB_INST, enb_properties->number);
-
-    /* Update some simulation parameters */
-    for (i=0; i < enb_properties->number; i++) {
-      AssertFatal (MAX_NUM_CCs == enb_properties->properties[i]->nb_cc,
-                   "lte-softmodem compiled with MAX_NUM_CCs=%d, but only %d CCs configured for eNB %d!",
-                   MAX_NUM_CCs, enb_properties->properties[i]->nb_cc, i);
-      eth_params = (eth_params_t*)malloc(enb_properties->properties[i]->nb_rrh_gw * sizeof(eth_params_t));
-      memset(eth_params, 0, enb_properties->properties[i]->nb_rrh_gw * sizeof(eth_params_t));
-
-      for (j=0; j<enb_properties->properties[i]->nb_rrh_gw; j++) {
-        	
-        if (enb_properties->properties[i]->rrh_gw_config[j].active == 1 ) {
-          local_remote_radio = BBU_REMOTE_RADIO_HEAD;
-          (eth_params+j)->local_if_name             = enb_properties->properties[i]->rrh_gw_config[j].rrh_gw_if_name;
-          (eth_params+j)->my_addr                   = enb_properties->properties[i]->rrh_gw_config[j].local_address;
-          (eth_params+j)->my_port                   = enb_properties->properties[i]->rrh_gw_config[j].local_port;
-          (eth_params+j)->remote_addr               = enb_properties->properties[i]->rrh_gw_config[j].remote_address;
-          (eth_params+j)->remote_port               = enb_properties->properties[i]->rrh_gw_config[j].remote_port;
-          
-          if (enb_properties->properties[i]->rrh_gw_config[j].raw == 1) {
-            (eth_params+j)->transp_preference       = ETH_RAW_MODE; 
-          } else if (enb_properties->properties[i]->rrh_gw_config[j].rawif4p5 == 1) {
-            (eth_params+j)->transp_preference       = ETH_RAW_IF4p5_MODE;             
-          } else if (enb_properties->properties[i]->rrh_gw_config[j].udpif4p5 == 1) {
-            (eth_params+j)->transp_preference       = ETH_UDP_IF4p5_MODE;             
-          } else if (enb_properties->properties[i]->rrh_gw_config[j].rawif5_mobipass == 1) {
-            (eth_params+j)->transp_preference       = ETH_RAW_IF5_MOBIPASS;             
-          } else {
-            (eth_params+j)->transp_preference       = ETH_UDP_MODE;	 
-          }
-          
-          (eth_params+j)->iq_txshift                = enb_properties->properties[i]->rrh_gw_config[j].iq_txshift;
-          (eth_params+j)->tx_sample_advance         = enb_properties->properties[i]->rrh_gw_config[j].tx_sample_advance;
-          (eth_params+j)->tx_scheduling_advance     = enb_properties->properties[i]->rrh_gw_config[j].tx_scheduling_advance;
-          if (enb_properties->properties[i]->rrh_gw_config[j].exmimo == 1) {
-            (eth_params+j)->rf_preference          = EXMIMO_DEV;
-          } else if (enb_properties->properties[i]->rrh_gw_config[j].usrp_b200 == 1) {
-            (eth_params+j)->rf_preference          = USRP_B200_DEV;
-          } else if (enb_properties->properties[i]->rrh_gw_config[j].usrp_x300 == 1) {
-            (eth_params+j)->rf_preference          = USRP_X300_DEV;
-          } else if (enb_properties->properties[i]->rrh_gw_config[j].bladerf == 1) {
-            (eth_params+j)->rf_preference          = BLADERF_DEV;
-          } else if (enb_properties->properties[i]->rrh_gw_config[j].lmssdr == 1) {
-            //(eth_params+j)->rf_preference          = LMSSDR_DEV;
-          } else {
-            (eth_params+j)->rf_preference          = 0;
-          } 
-        } else {
-          local_remote_radio = BBU_LOCAL_RADIO_HEAD; 
-        }
-	
-      }
-
-      for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
-	
-
-        node_function[CC_id]  = enb_properties->properties[i]->cc_node_function[CC_id];
-        node_timing[CC_id]    = enb_properties->properties[i]->cc_node_timing[CC_id];
-        node_synch_ref[CC_id] = enb_properties->properties[i]->cc_node_synch_ref[CC_id];
-
-        frame_parms[CC_id]->frame_type =       enb_properties->properties[i]->frame_type[CC_id];
-        frame_parms[CC_id]->tdd_config =       enb_properties->properties[i]->tdd_config[CC_id];
-        frame_parms[CC_id]->tdd_config_S =     enb_properties->properties[i]->tdd_config_s[CC_id];
-        frame_parms[CC_id]->Ncp =              enb_properties->properties[i]->prefix_type[CC_id];
-
-        //for (j=0; j < enb_properties->properties[i]->nb_cc; j++ ){
-        frame_parms[CC_id]->Nid_cell            =  enb_properties->properties[i]->Nid_cell[CC_id];
-        frame_parms[CC_id]->N_RB_DL             =  enb_properties->properties[i]->N_RB_DL[CC_id];
-        frame_parms[CC_id]->N_RB_UL             =  enb_properties->properties[i]->N_RB_DL[CC_id];
-        frame_parms[CC_id]->nb_antennas_tx      =  enb_properties->properties[i]->nb_antennas_tx[CC_id];
-        frame_parms[CC_id]->nb_antenna_ports_eNB  =  enb_properties->properties[i]->nb_antenna_ports[CC_id];
-        frame_parms[CC_id]->nb_antennas_rx      =  enb_properties->properties[i]->nb_antennas_rx[CC_id];
-
-	frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.prach_ConfigIndex = enb_properties->properties[i]->prach_config_index[CC_id];
-	frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.prach_FreqOffset  = enb_properties->properties[i]->prach_freq_offset[CC_id];
-
-	frame_parms[CC_id]->mode1_flag         = (frame_parms[CC_id]->nb_antenna_ports_eNB == 1) ? 1 : 0;
-	frame_parms[CC_id]->threequarter_fs    = threequarter_fs;
-
-        //} // j
-      }
-
-
-      init_all_otg(0);
-      g_otg->seed = 0;
-      init_seeds(g_otg->seed);
-
-      for (k=0; k<enb_properties->properties[i]->num_otg_elements; k++) {
-        j=enb_properties->properties[i]->otg_ue_id[k]; // ue_id
-        g_otg->application_idx[i][j] = 1;
-        //g_otg->packet_gen_type=SUBSTRACT_STRING;
-        g_otg->background[i][j][0] =enb_properties->properties[i]->otg_bg_traffic[k];
-        g_otg->application_type[i][j][0] =enb_properties->properties[i]->otg_app_type[k];// BCBR; //MCBR, BCBR
-
-        printf("[OTG] configuring traffic type %d for  eNB %d UE %d (Background traffic is %s)\n",
-               g_otg->application_type[i][j][0], i, j,(g_otg->background[i][j][0]==1)?"Enabled":"Disabled");
-      }
-
-      init_predef_traffic(enb_properties->properties[i]->num_otg_elements, 1);
-
-
-      glog_level                     = enb_properties->properties[i]->glog_level;
-      glog_verbosity                 = enb_properties->properties[i]->glog_verbosity;
-      hw_log_level                   = enb_properties->properties[i]->hw_log_level;
-      hw_log_verbosity               = enb_properties->properties[i]->hw_log_verbosity ;
-      phy_log_level                  = enb_properties->properties[i]->phy_log_level;
-      phy_log_verbosity              = enb_properties->properties[i]->phy_log_verbosity;
-      mac_log_level                  = enb_properties->properties[i]->mac_log_level;
-      mac_log_verbosity              = enb_properties->properties[i]->mac_log_verbosity;
-      rlc_log_level                  = enb_properties->properties[i]->rlc_log_level;
-      rlc_log_verbosity              = enb_properties->properties[i]->rlc_log_verbosity;
-      pdcp_log_level                 = enb_properties->properties[i]->pdcp_log_level;
-      pdcp_log_verbosity             = enb_properties->properties[i]->pdcp_log_verbosity;
-      rrc_log_level                  = enb_properties->properties[i]->rrc_log_level;
-      rrc_log_verbosity              = enb_properties->properties[i]->rrc_log_verbosity;
-# if defined(ENABLE_USE_MME)
-      gtpu_log_level                 = enb_properties->properties[i]->gtpu_log_level;
-      gtpu_log_verbosity             = enb_properties->properties[i]->gtpu_log_verbosity;
-      udp_log_level                  = enb_properties->properties[i]->udp_log_level;
-      udp_log_verbosity              = enb_properties->properties[i]->udp_log_verbosity;
-#endif
-#if defined (ENABLE_SECURITY)
-      osa_log_level                  = enb_properties->properties[i]->osa_log_level;
-      osa_log_verbosity              = enb_properties->properties[i]->osa_log_verbosity;
-#endif
 
-      // adjust the log
-      for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
-        for (k = 0 ; k < 4; k++) {
-          downlink_frequency[CC_id][k]      =       enb_properties->properties[i]->downlink_frequency[CC_id];
-          uplink_frequency_offset[CC_id][k] =  enb_properties->properties[i]->uplink_frequency_offset[CC_id];
-          rx_gain[CC_id][k]                 =  (double)enb_properties->properties[i]->rx_gain[CC_id];
-          tx_gain[CC_id][k]                 =  (double)enb_properties->properties[i]->tx_gain[CC_id];
-        }
 
-        printf("Downlink frequency/ uplink offset of CC_id %d set to %ju/%d\n", CC_id,
-               enb_properties->properties[i]->downlink_frequency[CC_id],
-               enb_properties->properties[i]->uplink_frequency_offset[CC_id]);
-
-      } // CC_id
-    }// i
-
-    //this is needed for phy-test option
-    transmission_mode = enb_properties->properties[0]->ue_TransmissionMode[0]+1;
 
+    /* Read RC configuration file */
+    RCConfig(conf_config_file_name);
+    
+    NB_eNB_INST = RC.nb_inst;
+    NB_RU       = RC.nb_RU;
+
+    printf("Read in %s : nb_inst %d, nb_ru %d\n",conf_config_file_name,NB_eNB_INST,NB_RU);
+
+    /*    
+    init_all_otg(0);
+    g_otg->seed = 0;
+    init_seeds(g_otg->seed);
+
+    for (k=0; k<enb_properties->properties[i]->num_otg_elements; k++) {
+      j=enb_properties->properties[i]->otg_ue_id[k]; // ue_id
+      g_otg->application_idx[i][j] = 1;
+      //g_otg->packet_gen_type=SUBSTRACT_STRING;
+      g_otg->background[i][j][0] =enb_properties->properties[i]->otg_bg_traffic[k];
+      g_otg->application_type[i][j][0] =enb_properties->properties[i]->otg_app_type[k];// BCBR; //MCBR, BCBR
+      
+      printf("[OTG] configuring traffic type %d for  eNB %d UE %d (Background traffic is %s)\n",
+	     g_otg->application_type[i][j][0], i, j,(g_otg->background[i][j][0]==1)?"Enabled":"Disabled");
+    }
+    
+    init_predef_traffic(enb_properties->properties[i]->num_otg_elements, 1);
+    
+    */
+    
   } else if (UE_flag == 1) {
     if (conf_config_file_name != NULL) {
       
@@ -1330,31 +1216,17 @@ void init_openair0() {
     else //FDD
       openair0_cfg[card].duplex_mode = duplex_mode_FDD;
 
-    
-    if (local_remote_radio == BBU_REMOTE_RADIO_HEAD) {      
-      openair0_cfg[card].remote_addr    = (eth_params+card)->remote_addr;
-      openair0_cfg[card].remote_port    = (eth_params+card)->remote_port;
-      openair0_cfg[card].my_addr        = (eth_params+card)->my_addr;
-      openair0_cfg[card].my_port        = (eth_params+card)->my_port;    
-    } 
-    
     printf("HW: Configuring card %d, nb_antennas_tx/rx %d/%d\n",card,
-           ((UE_flag==0) ? PHY_vars_eNB_g[0][0]->frame_parms.nb_antennas_tx : PHY_vars_UE_g[0][0]->frame_parms.nb_antennas_tx),
-           ((UE_flag==0) ? PHY_vars_eNB_g[0][0]->frame_parms.nb_antennas_rx : PHY_vars_UE_g[0][0]->frame_parms.nb_antennas_rx));
+           ((UE_flag==0) ? RC.eNB[0][0]->frame_parms.nb_antennas_tx : PHY_vars_UE_g[0][0]->frame_parms.nb_antennas_tx),
+           ((UE_flag==0) ? RC.eNB[0][0]->frame_parms.nb_antennas_rx : PHY_vars_UE_g[0][0]->frame_parms.nb_antennas_rx));
     openair0_cfg[card].Mod_id = 0;
 
-    if (UE_flag) {
-      printf("ETHERNET: Configuring UE ETH for %s:%d\n",rrh_UE_ip,rrh_UE_port);
-      openair0_cfg[card].remote_addr   = &rrh_UE_ip[0];
-      openair0_cfg[card].remote_port = rrh_UE_port;
-    } 
-
     openair0_cfg[card].num_rb_dl=frame_parms[0]->N_RB_DL;
 
     openair0_cfg[card].clock_source = clock_source;
 
-    openair0_cfg[card].tx_num_channels=min(2,((UE_flag==0) ? PHY_vars_eNB_g[0][0]->frame_parms.nb_antennas_tx : PHY_vars_UE_g[0][0]->frame_parms.nb_antennas_tx));
-    openair0_cfg[card].rx_num_channels=min(2,((UE_flag==0) ? PHY_vars_eNB_g[0][0]->frame_parms.nb_antennas_rx : PHY_vars_UE_g[0][0]->frame_parms.nb_antennas_rx));
+    openair0_cfg[card].tx_num_channels=min(2,((UE_flag==0) ? RC.eNB[0][0]->frame_parms.nb_antennas_tx : PHY_vars_UE_g[0][0]->frame_parms.nb_antennas_tx));
+    openair0_cfg[card].rx_num_channels=min(2,((UE_flag==0) ? RC.eNB[0][0]->frame_parms.nb_antennas_rx : PHY_vars_UE_g[0][0]->frame_parms.nb_antennas_rx));
 
     for (i=0; i<4; i++) {
 
@@ -1371,7 +1243,7 @@ void init_openair0() {
       openair0_cfg[card].autocal[i] = 1;
       openair0_cfg[card].tx_gain[i] = tx_gain[0][i];
       if (UE_flag == 0) {
-	openair0_cfg[card].rx_gain[i] = PHY_vars_eNB_g[0][0]->rx_total_gain_dB;
+	openair0_cfg[card].rx_gain[i] = RC.eNB[0][0]->rx_total_gain_dB;
       }
       else {
 	openair0_cfg[card].rx_gain[i] = PHY_vars_UE_g[0][0]->rx_total_gain_dB - rx_gain_off;
@@ -1387,6 +1259,23 @@ void init_openair0() {
   }
 }
 
+void wait_RUs() {
+
+  LOG_I(PHY,"Waiting for RUs to be configured ...\n");
+
+  // wait for all RUs to be configured over fronthaul
+  pthread_mutex_lock(&RC.ru_mutex);
+
+
+
+  while (RC.ru_mask>0) {
+    pthread_cond_wait(&RC.ru_cond,&RC.ru_mutex);
+  }
+
+  LOG_I(PHY,"RUs configured\n");
+}
+
+
 int main( int argc, char **argv )
 {
   int i,j,k,aa,re;
@@ -1395,6 +1284,7 @@ int main( int argc, char **argv )
 #endif
 
   int CC_id;
+  int ru_id;
   uint8_t  abstraction_flag=0;
   uint8_t beta_ACK=0,beta_RI=0,beta_CQI=2;
 
@@ -1416,11 +1306,12 @@ int main( int argc, char **argv )
   set_latency_target();
 
   // set default parameters
-  set_default_frame_parms(frame_parms);
+  if (UE_flag == 1) set_default_frame_parms(frame_parms);
 
   // initialize logging
   logInit();
 
+  printf("Reading in command-line options\n");
   // get options and fill parameters from configuration file
   get_options (argc, argv); //Command-line options, enb_properties
 
@@ -1455,7 +1346,7 @@ int main( int argc, char **argv )
 # endif
 #endif
   } else {
-    printf("configuring for eNB\n");
+    printf("configuring for RAU\n");
 
     set_comp_log(HW,      hw_log_level, hw_log_verbosity, 1);
     set_comp_log(PHY,     phy_log_level,   phy_log_verbosity, 1);
@@ -1551,12 +1442,13 @@ int main( int argc, char **argv )
       frame_parms[CC_id]->nb_antennas_tx     = 1;
       frame_parms[CC_id]->nb_antennas_rx     = 1;
       frame_parms[CC_id]->nb_antenna_ports_eNB = 1; //initial value overwritten by initial sync later
-    }
+    
 
-    init_ul_hopping(frame_parms[CC_id]);
-    init_frame_parms(frame_parms[CC_id],1);
-    //   phy_init_top(frame_parms[CC_id]);
-    phy_init_lte_top(frame_parms[CC_id]);
+      init_ul_hopping(frame_parms[CC_id]);
+      init_frame_parms(frame_parms[CC_id],1);
+      //   phy_init_top(frame_parms[CC_id]);
+      phy_init_lte_top(frame_parms[CC_id]);
+    }
   }
 
 
@@ -1630,67 +1522,6 @@ int main( int argc, char **argv )
 
     //  printf("tx_max_power = %d -> amp %d\n",tx_max_power,get_tx_amp(tx_max_poHwer,tx_max_power));
   } else {
-    //this is eNB
-    PHY_vars_eNB_g = malloc(sizeof(PHY_VARS_eNB**));
-    PHY_vars_eNB_g[0] = malloc(sizeof(PHY_VARS_eNB*));
-
-    for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
-      PHY_vars_eNB_g[0][CC_id] = init_lte_eNB(frame_parms[CC_id],0,frame_parms[CC_id]->Nid_cell,node_function[CC_id],abstraction_flag);
-      PHY_vars_eNB_g[0][CC_id]->ue_dl_rb_alloc=0x1fff;
-      PHY_vars_eNB_g[0][CC_id]->target_ue_dl_mcs=target_dl_mcs;
-      PHY_vars_eNB_g[0][CC_id]->ue_ul_nb_rb=6;
-      PHY_vars_eNB_g[0][CC_id]->target_ue_ul_mcs=target_ul_mcs;
-      // initialization for phy-test
-      for (k=0;k<NUMBER_OF_UE_MAX;k++) {
-	PHY_vars_eNB_g[0][CC_id]->transmission_mode[k] = transmission_mode;
-	if (transmission_mode==7) 
-	  lte_gold_ue_spec_port5(PHY_vars_eNB_g[0][CC_id]->lte_gold_uespec_port5_table[k],frame_parms[CC_id]->Nid_cell,0x1235+k);
-      }
-      if ((transmission_mode==1) || (transmission_mode==7)) {
-	  for (j=0; j<frame_parms[CC_id]->nb_antennas_tx; j++) 
-	    for (re=0; re<frame_parms[CC_id]->ofdm_symbol_size; re++) 
-	      PHY_vars_eNB_g[0][CC_id]->common_vars.beam_weights[0][0][j][re] = 0x00007fff/frame_parms[CC_id]->nb_antennas_tx; 
-      }
-
-      if (phy_test==1) PHY_vars_eNB_g[0][CC_id]->mac_enabled = 0;
-      else PHY_vars_eNB_g[0][CC_id]->mac_enabled = 1;
-      
-      if (PHY_vars_eNB_g[0][CC_id]->mac_enabled == 0) { //set default parameters for testing mode
-	for (i=0; i<NUMBER_OF_UE_MAX; i++) {
-	    PHY_vars_eNB_g[0][CC_id]->pusch_config_dedicated[i].betaOffset_ACK_Index = beta_ACK;
-	    PHY_vars_eNB_g[0][CC_id]->pusch_config_dedicated[i].betaOffset_RI_Index  = beta_RI;
-	    PHY_vars_eNB_g[0][CC_id]->pusch_config_dedicated[i].betaOffset_CQI_Index = beta_CQI;
-	    
-	    PHY_vars_eNB_g[0][CC_id]->scheduling_request_config[i].sr_PUCCH_ResourceIndex = i;
-	    PHY_vars_eNB_g[0][CC_id]->scheduling_request_config[i].sr_ConfigIndex = 7+(i%3);
-	    PHY_vars_eNB_g[0][CC_id]->scheduling_request_config[i].dsr_TransMax = sr_n4;
-	}
-      }
-      
-      compute_prach_seq(&PHY_vars_eNB_g[0][CC_id]->frame_parms.prach_config_common,
-			PHY_vars_eNB_g[0][CC_id]->frame_parms.frame_type,
-			PHY_vars_eNB_g[0][CC_id]->X_u);
-    
-      
-      PHY_vars_eNB_g[0][CC_id]->rx_total_gain_dB = (int)rx_gain[CC_id][0];
-
-      if (frame_parms[CC_id]->frame_type==FDD) {
-        PHY_vars_eNB_g[0][CC_id]->N_TA_offset = 0;
-      }
-      else {
-        if (frame_parms[CC_id]->N_RB_DL == 100)
-          PHY_vars_eNB_g[0][CC_id]->N_TA_offset = 624;
-        else if (frame_parms[CC_id]->N_RB_DL == 50)
-          PHY_vars_eNB_g[0][CC_id]->N_TA_offset = 624/2;
-        else if (frame_parms[CC_id]->N_RB_DL == 25)
-          PHY_vars_eNB_g[0][CC_id]->N_TA_offset = 624/4;
-      }
-
-    }
-  
-
-    NB_eNB_INST=1;
-    NB_INST=1;
 
   }
 
@@ -1698,9 +1529,9 @@ int main( int argc, char **argv )
   cpuf=get_cpu_freq_GHz();
 
 
-  dump_frame_parms(frame_parms[0]);
 
-  init_openair0();
+
+  //  init_openair0();
 
 
 
@@ -1751,32 +1582,24 @@ int main( int argc, char **argv )
   
 
 
-  int eMBMS_active=0;
-  if (node_function[0] <= NGFI_RAU_IF4p5) { // don't initialize L2 for RRU
-    LOG_I(PHY,"Intializing L2\n");
-    mac_xface = malloc(sizeof(MAC_xface));  
-    l2_init(frame_parms[0],eMBMS_active,(uecap_xer_in==1)?uecap_xer:NULL,
-	    0,// cba_group_active
-	    0); // HO flag
-    mac_xface->macphy_exit = &exit_fun;
-  }
-  else if (node_function[0] == NGFI_RRU_IF4p5) { // Initialize PRACH in this case
-
-  }
-
 
 
 #if defined(ENABLE_ITTI)
 
   if ((UE_flag == 1)||
-      (node_function[0]<NGFI_RAU_IF4p5))
+      (RC.nb_inst > 0))  {
+
     // don't create if node doesn't connect to RRC/S1/GTP
     if (create_tasks(UE_flag ? 0 : 1, UE_flag ? 1 : 0) < 0) {
       printf("cannot create ITTI tasks\n");
       exit(-1); // need a softer mode
     }
 
-  printf("ITTI tasks created\n");
+    printf("ITTI tasks created\n");
+  }
+  else {
+    printf("No ITTI\n");
+  }
 #endif
 
   if (phy_test==0) {
@@ -1784,8 +1607,7 @@ int main( int argc, char **argv )
       printf("Filling UE band info\n");
       fill_ue_band_info();
       mac_xface->dl_phy_sync_success (0, 0, 0, 1);
-    } else if (node_function[0]>NGFI_RRU_IF4p5)
-      mac_xface->mrbch_phy_sync_failure (0, 0, 0);
+    } 
   }
 
 
@@ -1856,9 +1678,10 @@ int main( int argc, char **argv )
 
 
 
-  // start the main thread
+  // start the main threads
   if (UE_flag == 1) {
-    init_UE(1);
+    int eMBMS_active = 0;
+    init_UE(1,eMBMS_active,uecap_xer_in);
     number_of_cards = 1;
     
     for(CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
@@ -1867,15 +1690,25 @@ int main( int argc, char **argv )
     }
   }
   else { 
-    printf("Initializing eNB threads\n");
-    init_eNB(node_function,node_timing,1,eth_params,single_thread_flag,wait_for_sync);
-
-    number_of_cards = 1;
-    
-    for(CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
-      PHY_vars_eNB_g[0][CC_id]->rf_map.card=0;
-      PHY_vars_eNB_g[0][CC_id]->rf_map.chain=CC_id+chain_offset;
+    number_of_cards = 1;    
+    if (RC.nb_inst > 0) {
+      printf("Initializing eNB threads\n");
+      init_eNB(single_thread_flag,wait_for_sync);
     }
+    if (RC.nb_RU >0) {
+      printf("Initializing RU threads\n");
+      init_RU(rf_config_file);
+      for (ru_id=0;ru_id<RC.nb_RU;ru_id++) {
+	RC.ru[ru_id]->rf_map.card=0;
+	RC.ru[ru_id]->rf_map.chain=CC_id+chain_offset;
+      }
+    }
+
+    wait_RUs();
+    // once all RUs are ready intiailize the rest of the eNBs (dependence on final RU parameters after configuration)
+    init_eNB_afterRU();
+
+
   }
 
   // connect the TX/RX buffers
@@ -1911,28 +1744,36 @@ int main( int argc, char **argv )
 
 
 
-
+    /*
     printf("Setting eNB buffer to all-RX\n");
 
     // Set LSBs for antenna switch (ExpressMIMO)
     for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
-      PHY_vars_eNB_g[0][CC_id]->hw_timing_advance = 0;
-      for (i=0; i<frame_parms[CC_id]->samples_per_tti*10; i++)
-        for (aa=0; aa<frame_parms[CC_id]->nb_antennas_tx; aa++)
-          PHY_vars_eNB_g[0][CC_id]->common_vars.txdata[0][aa][i] = 0x00010001;
+      RC.eNB[0][CC_id]->hw_timing_advance = 0;
+    }
+    for (ru_id=0;ru_id<NB_RU;ru_id++) {
+      for (i=0; i<RC.ru[ru_id]->frame_parms.samples_per_tti*10; i++)
+	for (aa=0; aa<RC.ru[ru_id]->nb_tx; aa++)
+	  RC.ru[0]->common.txdata[aa][i] = 0x00010001;
     }
+    */
   }
-  sleep(3);
 
 
-  printf("Sending sync to all threads\n");
 
+  sleep(3);
+  
+
+  
+  printf("Sending sync to all threads\n");
+  
   pthread_mutex_lock(&sync_mutex);
   sync_var=0;
   pthread_cond_broadcast(&sync_cond);
   pthread_mutex_unlock(&sync_mutex);
+  
 
-  // wait for end of program
+    // wait for end of program
   printf("TYPE <CTRL-C> TO TERMINATE\n");
   //getchar();
 
@@ -1993,11 +1834,11 @@ int main( int argc, char **argv )
       PHY_vars_UE_g[0][0]->rfdevice.trx_end_func(&PHY_vars_UE_g[0][0]->rfdevice);
   }
   else {
-    for(CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
-      if (PHY_vars_eNB_g[0][CC_id]->rfdevice.trx_end_func)
-	PHY_vars_eNB_g[0][CC_id]->rfdevice.trx_end_func(&PHY_vars_eNB_g[0][CC_id]->rfdevice);  
-      if (PHY_vars_eNB_g[0][CC_id]->ifdevice.trx_end_func)
-	PHY_vars_eNB_g[0][CC_id]->ifdevice.trx_end_func(&PHY_vars_eNB_g[0][CC_id]->ifdevice);  
+    for(ru_id=0; ru_id<NB_RU; ru_id++) {
+      if (RC.ru[ru_id]->rfdevice.trx_end_func)
+	RC.ru[ru_id]->rfdevice.trx_end_func(&RC.ru[ru_id]->rfdevice);  
+      if (RC.ru[ru_id]->ifdevice.trx_end_func)
+	RC.ru[ru_id]->ifdevice.trx_end_func(&RC.ru[ru_id]->ifdevice);  
     }
   }
   if (ouput_vcd)
diff --git a/targets/RT/USER/lte-ue.c b/targets/RT/USER/lte-ue.c
index ed93f44aa9..b2b7ab278e 100644
--- a/targets/RT/USER/lte-ue.c
+++ b/targets/RT/USER/lte-ue.c
@@ -88,7 +88,7 @@ typedef enum {
 
 void init_UE_threads(int nb_inst);
 void *UE_thread(void *arg);
-void init_UE(int nb_inst);
+void init_UE(int nb_inst,int,int);
 
 extern pthread_cond_t sync_cond;
 extern pthread_mutex_t sync_mutex;
@@ -165,18 +165,78 @@ static const eutra_band_t eutra_bands[] = {
   {44, 703    * MHz, 803    * MHz, 703    * MHz, 803    * MHz, TDD},
 };
 
+
+
 pthread_t                       main_ue_thread;
 pthread_attr_t                  attr_UE_thread;
 struct sched_param              sched_param_UE_thread;
 
-void init_UE(int nb_inst) {
+
+PHY_VARS_UE* init_lte_UE(LTE_DL_FRAME_PARMS *frame_parms,
+                         uint8_t UE_id,
+                         uint8_t abstraction_flag)
+
+{
+
+  int i,j;
+  PHY_VARS_UE* PHY_vars_UE = malloc(sizeof(PHY_VARS_UE));
+  memset(PHY_vars_UE,0,sizeof(PHY_VARS_UE));
+  PHY_vars_UE->Mod_id=UE_id;
+  memcpy(&(PHY_vars_UE->frame_parms), frame_parms, sizeof(LTE_DL_FRAME_PARMS));
+  phy_init_lte_ue(PHY_vars_UE,1,abstraction_flag);
+
+  for (i=0; i<NUMBER_OF_CONNECTED_eNB_MAX; i++) {
+    for (j=0; j<2; j++) {
+      PHY_vars_UE->dlsch[i][j]  = new_ue_dlsch(1,NUMBER_OF_HARQ_PID_MAX,NSOFT,MAX_TURBO_ITERATIONS,frame_parms->N_RB_DL, abstraction_flag);
+
+      if (!PHY_vars_UE->dlsch[i][j]) {
+        LOG_E(PHY,"Can't get ue dlsch structures\n");
+        exit(-1);
+      } else
+        LOG_D(PHY,"dlsch[%d][%d] => %p\n",UE_id,i,PHY_vars_UE->dlsch[i][j]);
+    }
+
+
+
+    PHY_vars_UE->ulsch[i]  = new_ue_ulsch(frame_parms->N_RB_UL, abstraction_flag);
+
+    if (!PHY_vars_UE->ulsch[i]) {
+      LOG_E(PHY,"Can't get ue ulsch structures\n");
+      exit(-1);
+    }
+
+    PHY_vars_UE->dlsch_SI[i]  = new_ue_dlsch(1,1,NSOFT,MAX_TURBO_ITERATIONS,frame_parms->N_RB_DL, abstraction_flag);
+    PHY_vars_UE->dlsch_ra[i]  = new_ue_dlsch(1,1,NSOFT,MAX_TURBO_ITERATIONS,frame_parms->N_RB_DL, abstraction_flag);
+
+    PHY_vars_UE->transmission_mode[i] = frame_parms->nb_antenna_ports_eNB==1 ? 1 : 2;
+  }
+
+  PHY_vars_UE->frame_parms.pucch_config_common.deltaPUCCH_Shift = 1;
+
+  PHY_vars_UE->dlsch_MCH[0]  = new_ue_dlsch(1,NUMBER_OF_HARQ_PID_MAX,NSOFT,MAX_TURBO_ITERATIONS_MBSFN,frame_parms->N_RB_DL,0);
+
+  return (PHY_vars_UE);
+}
+
+char uecap_xer[1024];
+
+void init_UE(int nb_inst,int eMBMS_active, int uecap_xer_in) {
 
   int error_code;
   int inst;
   PHY_VARS_UE *UE;
   int ret;
 
+  LOG_I(PHY,"UE %d: Calling Layer 2 for initialization\n",inst);
+    
+  if (mac_xface==NULL) mac_xface = malloc(sizeof(MAC_xface));  
+  l2_init_ue(eMBMS_active,(uecap_xer_in==1)?uecap_xer:NULL,
+	     0,// cba_group_active
+	     0); // HO flag
+  mac_xface->macphy_exit = &exit_fun;
+
   for (inst=0;inst<nb_inst;inst++) {
+
     printf("Intializing UE Threads for instance %d ...\n",inst);
     init_UE_threads(inst);
     sleep(1);
@@ -188,7 +248,7 @@ void init_UE(int nb_inst) {
 	exit_fun("Error loading device library");
       }
     }
-    UE->rfdevice.host_type = BBU_HOST;
+    UE->rfdevice.host_type = RAU_HOST;
     //    UE->rfdevice.type      = NONE_DEV;
     error_code = pthread_create(&UE->proc.pthread_ue, &UE->proc.attr_ue, UE_thread, NULL);
     
@@ -235,6 +295,16 @@ static void *UE_thread_synch(void *arg)
   printf("UE_thread_sync in with PHY_vars_UE %p\n",arg);
   printf("waiting for sync (UE_thread_synch) \n");
 
+  printf("waiting for sync (UE_thread)\n");
+  pthread_mutex_lock(&sync_mutex);
+  printf("Locked sync_mutex, waiting (UE_thread)\n");
+
+  while (sync_var<0)
+    pthread_cond_wait(&sync_cond, &sync_mutex);
+
+  pthread_mutex_unlock(&sync_mutex);
+  printf("unlocked sync_mutex, waiting (UE_thread)\n");
+
 #ifndef DEADLINE_SCHEDULER
   int policy, s, j;
   struct sched_param sparam;
@@ -317,7 +387,7 @@ static void *UE_thread_synch(void *arg)
       current_band = eutra_bands[ind].band;
       printf( "Scanning band %d, dl_min %"PRIu32", ul_min %"PRIu32"\n", current_band, eutra_bands[ind].dl_min,eutra_bands[ind].ul_min);
 
-      if ((eutra_bands[ind].dl_min <= downlink_frequency[0][0]) && (eutra_bands[ind].dl_max >= downlink_frequency[0][0])) {
+      if ((eutra_bands[ind].dl_min <= UE->frame_parms.dl_CarrierFreq) && (eutra_bands[ind].dl_max >= UE->frame_parms.dl_CarrierFreq)) {
 	for (i=0; i<4; i++)
 	  uplink_frequency_offset[CC_id][i] = eutra_bands[ind].ul_min - eutra_bands[ind].dl_min;
 
@@ -338,11 +408,11 @@ static void *UE_thread_synch(void *arg)
 
 
 
-    LOG_I( PHY, "[SCHED][UE] Check absolute frequency DL %"PRIu32", UL %"PRIu32" (oai_exit %d, rx_num_channels %d)\n", downlink_frequency[0][0], downlink_frequency[0][0]+uplink_frequency_offset[0][0],oai_exit, openair0_cfg[0].rx_num_channels);
+    LOG_I( PHY, "[SCHED][UE] Check absolute frequency DL %"PRIu32", UL %"PRIu32" (oai_exit %d, rx_num_channels %d)\n", UE->frame_parms.dl_CarrierFreq, UE->frame_parms.ul_CarrierFreq,oai_exit, openair0_cfg[0].rx_num_channels);
 
     for (i=0;i<openair0_cfg[UE->rf_map.card].rx_num_channels;i++) {
-      openair0_cfg[UE->rf_map.card].rx_freq[UE->rf_map.chain+i] = downlink_frequency[CC_id][i];
-      openair0_cfg[UE->rf_map.card].tx_freq[UE->rf_map.chain+i] = downlink_frequency[CC_id][i]+uplink_frequency_offset[CC_id][i];
+      openair0_cfg[UE->rf_map.card].rx_freq[UE->rf_map.chain+i] = UE->frame_parms.dl_CarrierFreq;
+      openair0_cfg[UE->rf_map.card].tx_freq[UE->rf_map.chain+i] = UE->frame_parms.ul_CarrierFreq;
       openair0_cfg[UE->rf_map.card].autocal[UE->rf_map.chain+i] = 1;
       if (uplink_frequency_offset[CC_id][i] != 0) // 
 	openair0_cfg[UE->rf_map.card].duplex_mode = duplex_mode_FDD;
@@ -443,8 +513,8 @@ static void *UE_thread_synch(void *arg)
           hw_slot_offset,
           freq_offset,
           UE->rx_total_gain_dB,
-          downlink_frequency[0][0]+freq_offset,
-          downlink_frequency[0][0]+uplink_frequency_offset[0][0]+freq_offset,
+          UE->frame_parms.dl_CarrierFreq+freq_offset,
+          UE->frame_parms.ul_CarrierFreq+freq_offset,
           UE->UE_scan_carrier );
 
 	if (UE->UE_scan_carrier == 1) {
@@ -462,7 +532,7 @@ static void *UE_thread_synch(void *arg)
 	        openair0_cfg[UE->rf_map.card].rx_freq[UE->rf_map.chain+i] -= UE->common_vars.freq_offset;
 	    }
 	    openair0_cfg[UE->rf_map.card].tx_freq[UE->rf_map.chain+i] =  openair0_cfg[UE->rf_map.card].rx_freq[UE->rf_map.chain+i]+uplink_frequency_offset[CC_id][i];
-	    downlink_frequency[CC_id][i] = openair0_cfg[CC_id].rx_freq[i];
+	    UE->frame_parms.dl_CarrierFreq = openair0_cfg[CC_id].rx_freq[i];
 	    freq_offset=0;	    
 	  }
 
@@ -562,12 +632,12 @@ static void *UE_thread_synch(void *arg)
         LOG_I( PHY, "[initial_sync] trying carrier off %d Hz, rxgain %d (DL %u, UL %u)\n", 
 	       freq_offset,
                UE->rx_total_gain_dB,
-               downlink_frequency[0][0]+freq_offset,
-               downlink_frequency[0][0]+uplink_frequency_offset[0][0]+freq_offset );
+               UE->frame_parms.dl_CarrierFreq+freq_offset,
+               UE->frame_parms.ul_CarrierFreq+freq_offset );
 
 	for (i=0; i<openair0_cfg[UE->rf_map.card].rx_num_channels; i++) {
-	  openair0_cfg[UE->rf_map.card].rx_freq[UE->rf_map.chain+i] = downlink_frequency[CC_id][i]+freq_offset;
-	  openair0_cfg[UE->rf_map.card].tx_freq[UE->rf_map.chain+i] = downlink_frequency[CC_id][i]+uplink_frequency_offset[CC_id][i]+freq_offset;
+	  openair0_cfg[UE->rf_map.card].rx_freq[UE->rf_map.chain+i] = UE->frame_parms.dl_CarrierFreq+freq_offset;
+	  openair0_cfg[UE->rf_map.card].tx_freq[UE->rf_map.chain+i] = UE->frame_parms.ul_CarrierFreq+freq_offset;
 	  
 	  openair0_cfg[UE->rf_map.card].rx_gain[UE->rf_map.chain+i] = UE->rx_total_gain_dB;//-USRP_GAIN_OFFSET;
 	  
diff --git a/targets/RT/USER/rt_wrapper.c b/targets/RT/USER/rt_wrapper.c
index 06a625d1ea..e50b0ae34f 100644
--- a/targets/RT/USER/rt_wrapper.c
+++ b/targets/RT/USER/rt_wrapper.c
@@ -29,12 +29,21 @@
 * \note
 * \warning
 */
-
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <string.h>
 #include <unistd.h>
-
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <sched.h>
+#include <linux/sched.h>
+#include <signal.h>
+#include <execinfo.h>
+#include <getopt.h>
+#include <sys/sysinfo.h>
 #include "rt_wrapper.h"
+
 static int latency_target_fd = -1;
 static int32_t latency_target_value = 0;
 /* Latency trick - taken from cyclictest.c
@@ -247,7 +256,104 @@ int sched_getattr(pid_t pid,struct sched_attr *attr,unsigned int size, unsigned
 
 #endif
 
+void thread_top_init(char *thread_name,
+		     int affinity,
+		     uint64_t runtime,
+		     uint64_t deadline,
+		     uint64_t period) {
+  
+  MSC_START_USE();
+
+#ifdef DEADLINE_SCHEDULER
+  struct sched_attr attr;
+
+  unsigned int flags = 0;
+
+  attr.size = sizeof(attr);
+  attr.sched_flags = 0;
+  attr.sched_nice = 0;
+  attr.sched_priority = 0;
+
+  attr.sched_policy   = SCHED_DEADLINE;
+  attr.sched_runtime  = runtime;
+  attr.sched_deadline = deadline;
+  attr.sched_period   = period; 
+
+  if (sched_setattr(0, &attr, flags) < 0 ) {
+    perror("[SCHED] eNB tx thread: sched_setattr failed\n");
+    exit(1);
+  }
+
+#else //LOW_LATENCY
+  int policy, s, j;
+  struct sched_param sparam;
+  char cpu_affinity[1024];
+  cpu_set_t cpuset;
+
+  /* Set affinity mask to include CPUs 1 to MAX_CPUS */
+  /* CPU 0 is reserved for UHD threads */
+  /* CPU 1 is reserved for all RX_TX threads */
+  /* Enable CPU Affinity only if number of CPUs >2 */
+  CPU_ZERO(&cpuset);
+
+#ifdef CPU_AFFINITY
+  if (get_nprocs() > 2)
+  {
+    if (affinity == 0)
+      CPU_SET(0,&cpuset);
+    else
+      for (j = 1; j < get_nprocs(); j++)
+        CPU_SET(j, &cpuset);
+    s = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
+    if (s != 0)
+    {
+      perror( "pthread_setaffinity_np");
+      exit_fun("Error setting processor affinity");
+    }
+  }
+#endif //CPU_AFFINITY
 
+  /* Check the actual affinity mask assigned to the thread */
+  s = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
+  if (s != 0) {
+    perror( "pthread_getaffinity_np");
+    exit_fun("Error getting processor affinity ");
+  }
+  memset(cpu_affinity,0,sizeof(cpu_affinity));
+  for (j = 0; j < 1024; j++)
+    if (CPU_ISSET(j, &cpuset)) {  
+      char temp[1024];
+      sprintf (temp, " CPU_%d", j);
+      strcat(cpu_affinity, temp);
+    }
 
+  memset(&sparam, 0, sizeof(sparam));
+  sparam.sched_priority = sched_get_priority_max(SCHED_FIFO);
+  policy = SCHED_FIFO ; 
+  
+  s = pthread_setschedparam(pthread_self(), policy, &sparam);
+  if (s != 0) {
+    perror("pthread_setschedparam : ");
+    exit_fun("Error setting thread priority");
+  }
+  
+  s = pthread_getschedparam(pthread_self(), &policy, &sparam);
+  if (s != 0) {
+    perror("pthread_getschedparam : ");
+    exit_fun("Error getting thread priority");
+  }
+
+  LOG_I(HW, "[SCHED][eNB] %s started on CPU %d, sched_policy = %s , priority = %d, CPU Affinity=%s \n",thread_name,sched_getcpu(),
+                   (policy == SCHED_FIFO)  ? "SCHED_FIFO" :
+                   (policy == SCHED_RR)    ? "SCHED_RR" :
+                   (policy == SCHED_OTHER) ? "SCHED_OTHER" :
+                   "???",
+                   sparam.sched_priority, cpu_affinity );
+
+#endif //LOW_LATENCY
+
+  mlockall(MCL_CURRENT | MCL_FUTURE);
+
+}
 
 
diff --git a/targets/RT/USER/rt_wrapper.h b/targets/RT/USER/rt_wrapper.h
index ca0507e003..f0efe6a0c4 100644
--- a/targets/RT/USER/rt_wrapper.h
+++ b/targets/RT/USER/rt_wrapper.h
@@ -121,3 +121,8 @@ int sched_getattr(pid_t pid,struct sched_attr *attr,unsigned int size, unsigned
 
 #define gettid() syscall(__NR_gettid) // for gettid
 
+void thread_top_init(char *thread_name,
+		     int affinity,
+		     uint64_t runtime,
+		     uint64_t deadline,
+		     uint64_t period);
diff --git a/targets/SIMU/USER/channel_sim.c b/targets/SIMU/USER/channel_sim.c
index 370e50d145..52a8f9732f 100644
--- a/targets/SIMU/USER/channel_sim.c
+++ b/targets/SIMU/USER/channel_sim.c
@@ -72,15 +72,15 @@ double r_re_DL[NUMBER_OF_UE_MAX][2][30720];
 double r_im_DL[NUMBER_OF_UE_MAX][2][30720];
 double r_re_UL[NUMBER_OF_eNB_MAX][2][30720];
 double r_im_UL[NUMBER_OF_eNB_MAX][2][30720];
-int eNB_output_mask[NUMBER_OF_UE_MAX];
-int UE_output_mask[NUMBER_OF_eNB_MAX];
-pthread_mutex_t eNB_output_mutex[NUMBER_OF_UE_MAX];
-pthread_mutex_t UE_output_mutex[NUMBER_OF_eNB_MAX];
+int RU_output_mask[NUMBER_OF_UE_MAX];
+int UE_output_mask[NUMBER_OF_RU_MAX];
+pthread_mutex_t RU_output_mutex[NUMBER_OF_UE_MAX];
+pthread_mutex_t UE_output_mutex[NUMBER_OF_RU_MAX];
 
-void do_DL_sig(channel_desc_t *eNB2UE[NUMBER_OF_eNB_MAX][NUMBER_OF_UE_MAX][MAX_NUM_CCs],
-	       node_desc_t *enb_data[NUMBER_OF_eNB_MAX],
+void do_DL_sig(channel_desc_t *RU2UE[NUMBER_OF_RU_MAX][NUMBER_OF_UE_MAX][MAX_NUM_CCs],
+	       node_desc_t *enb_data[NUMBER_OF_RU_MAX],
 	       node_desc_t *ue_data[NUMBER_OF_UE_MAX],
-	       uint16_t subframe,uint8_t abstraction_flag,LTE_DL_FRAME_PARMS *frame_parms,
+	       uint16_t subframe,uint8_t abstraction_flag,LTE_DL_FRAME_PARMS *ue_frame_parms,
 	       uint8_t UE_id,
 	       int CC_id)
 {
@@ -88,7 +88,7 @@ void do_DL_sig(channel_desc_t *eNB2UE[NUMBER_OF_eNB_MAX][NUMBER_OF_UE_MAX][MAX_N
   int32_t att_eNB_id=-1;
   int32_t **txdata,**rxdata;
 
-  uint8_t eNB_id=0;
+  uint32_t eNB_id,ru_id=0;
   double tx_pwr;
   double rx_pwr;
   int32_t rx_pwr2;
@@ -97,21 +97,22 @@ void do_DL_sig(channel_desc_t *eNB2UE[NUMBER_OF_eNB_MAX][NUMBER_OF_UE_MAX][MAX_N
 
   double min_path_loss=-200;
   uint8_t hold_channel=0;
-  uint8_t nb_antennas_rx = eNB2UE[0][0][CC_id]->nb_rx; // number of rx antennas at UE
-  uint8_t nb_antennas_tx = eNB2UE[0][0][CC_id]->nb_tx; // number of tx antennas at eNB
+  uint8_t nb_antennas_rx = RU2UE[0][0][CC_id]->nb_rx; // number of rx antennas at UE
+  uint8_t nb_antennas_tx = RU2UE[0][0][CC_id]->nb_tx; // number of tx antennas at eNB
 
-  double s_re0[30720];//PHY_vars_UE_g[UE_id][CC_id]->frame_parms.samples_per_tti];
-  double s_re1[30720];//PHY_vars_UE_g[UE_id][CC_id]->frame_parms.samples_per_tti];
+  double s_re0[30720];
+  double s_re1[30720];
   double *s_re[2];
-  double s_im0[30720];//PHY_vars_UE_g[UE_id][CC_id]->frame_parms.samples_per_tti];
-  double s_im1[30720];//PHY_vars_UE_g[UE_id][CC_id]->frame_parms.samples_per_tti];
+  double s_im0[30720];
+  double s_im1[30720];
   double *s_im[2];
-  double r_re00[30720];//PHY_vars_UE_g[UE_id][CC_id]->frame_parms.samples_per_tti];
-  double r_re01[30720];//PHY_vars_UE_g[UE_id][CC_id]->frame_parms.samples_per_tti];
+  double r_re00[30720];
+  double r_re01[30720];
   double *r_re0[2];
-  double r_im00[30720];//PHY_vars_UE_g[UE_id][CC_id]->frame_parms.samples_per_tti];
-  double r_im01[30720];//PHY_vars_UE_g[UE_id][CC_id]->frame_parms.samples_per_tti];
+  double r_im00[30720];
+  double r_im01[30720];
   double *r_im0[2];
+  LTE_DL_FRAME_PARMS *frame_parms;
 
   s_re[0] = s_re0;
   s_im[0] = s_im0;
@@ -132,20 +133,20 @@ void do_DL_sig(channel_desc_t *eNB2UE[NUMBER_OF_eNB_MAX][NUMBER_OF_UE_MAX][MAX_N
     //for (UE_id=0;UE_id<NB_UE_INST;UE_id++) {
 
     if (!hold_channel) {
-      // calculate the random channel from each eNB
-      for (eNB_id=0; eNB_id<NB_eNB_INST; eNB_id++) {
+      // calculate the random channel from each RU
+      for (ru_id=0; ru_id<RC.nb_RU; ru_id++) {
 
-        random_channel(eNB2UE[eNB_id][UE_id][CC_id],abstraction_flag);
+        random_channel(RU2UE[ru_id][UE_id][CC_id],abstraction_flag);
         /*
-        for (i=0;i<eNB2UE[eNB_id][UE_id]->nb_taps;i++)
-        printf("eNB2UE[%d][%d]->a[0][%d] = (%f,%f)\n",eNB_id,UE_id,i,eNB2UE[eNB_id][UE_id]->a[0][i].x,eNB2UE[eNB_id][UE_id]->a[0][i].y);
+        for (i=0;i<RU2UE[eNB_id][UE_id]->nb_taps;i++)
+        printf("RU2UE[%d][%d]->a[0][%d] = (%f,%f)\n",eNB_id,UE_id,i,RU2UE[eNB_id][UE_id]->a[0][i].x,RU2UE[eNB_id][UE_id]->a[0][i].y);
         */
-        freq_channel(eNB2UE[eNB_id][UE_id][CC_id], frame_parms->N_RB_DL,frame_parms->N_RB_DL*12+1);
+        freq_channel(RU2UE[ru_id][UE_id][CC_id], frame_parms->N_RB_DL,frame_parms->N_RB_DL*12+1);
       }
 
       // find out which eNB the UE is attached to
-      for (eNB_id=0; eNB_id<NB_eNB_INST; eNB_id++) {
-        if (find_ue(PHY_vars_UE_g[UE_id][CC_id]->pdcch_vars[0]->crnti,PHY_vars_eNB_g[eNB_id][CC_id])>=0) {
+      for (eNB_id=0; eNB_id<RC.nb_inst; eNB_id++) {
+        if (find_ue(PHY_vars_UE_g[UE_id][CC_id]->pdcch_vars[0]->crnti,RC.eNB[eNB_id][CC_id])>=0) {
           // UE with UE_id is connected to eNb with eNB_id
           att_eNB_id=eNB_id;
           LOG_D(OCM,"A: UE attached to eNB (UE%d->eNB%d)\n",UE_id,eNB_id);
@@ -155,11 +156,14 @@ void do_DL_sig(channel_desc_t *eNB2UE[NUMBER_OF_eNB_MAX][NUMBER_OF_UE_MAX][MAX_N
       // if UE is not attached yet, find assume its the eNB with the smallest pathloss
       if (att_eNB_id<0) {
         for (eNB_id=0; eNB_id<NB_eNB_INST; eNB_id++) {
-          if (min_path_loss<eNB2UE[eNB_id][UE_id][CC_id]->path_loss_dB) {
-            min_path_loss = eNB2UE[eNB_id][UE_id][CC_id]->path_loss_dB;
-            att_eNB_id=eNB_id;
-            LOG_D(OCM,"B: UE attached to eNB (UE%d->eNB%d)\n",UE_id,eNB_id);
-          }
+	  for (int ru=0;ru<RC.nb_RU;ru++) {
+	    ru_id = RC.eNB[eNB_id][CC_id]->RU_list[ru]->idx;
+	    if (min_path_loss<RU2UE[ru_id][UE_id][CC_id]->path_loss_dB) {
+	      min_path_loss = RU2UE[ru_id][UE_id][CC_id]->path_loss_dB;
+	      att_eNB_id=eNB_id;
+	      LOG_D(OCM,"B: UE attached to eNB (UE%d->eNB%d)\n",UE_id,eNB_id);
+	    }
+	  }
         }
       }
 
@@ -169,20 +173,20 @@ void do_DL_sig(channel_desc_t *eNB2UE[NUMBER_OF_eNB_MAX][NUMBER_OF_UE_MAX][MAX_N
       }
 
 #ifdef DEBUG_SIM
-      rx_pwr = signal_energy_fp2(eNB2UE[att_eNB_id][UE_id][CC_id]->ch[0],
-                                 eNB2UE[att_eNB_id][UE_id][CC_id]->channel_length)*eNB2UE[att_eNB_id][UE_id][CC_id]->channel_length;
+      rx_pwr = signal_energy_fp2(RU2UE[att_eNB_id][UE_id][CC_id]->ch[0],
+                                 RU2UE[att_eNB_id][UE_id][CC_id]->channel_length)*RU2UE[att_eNB_id][UE_id][CC_id]->channel_length;
       LOG_D(OCM,"Channel (CCid %d) eNB %d => UE %d : tx_power %d dBm, path_loss %f dB\n",
             CC_id,att_eNB_id,UE_id,
             frame_parms->pdsch_config_common.referenceSignalPower,
-            eNB2UE[att_eNB_id][UE_id][CC_id]->path_loss_dB);
+            RU2UE[att_eNB_id][UE_id][CC_id]->path_loss_dB);
 #endif
 
       //dlsch_abstraction(PHY_vars_UE_g[UE_id]->sinr_dB, rb_alloc, 8);
       // fill in perfect channel estimates
-      channel_desc_t *desc1 = eNB2UE[att_eNB_id][UE_id][CC_id];
+      channel_desc_t *desc1 = RU2UE[att_eNB_id][UE_id][CC_id];
       int32_t **dl_channel_est = PHY_vars_UE_g[UE_id][CC_id]->common_vars.common_vars_rx_data_per_thread[subframe&0x1].dl_ch_estimates[0];
-      //      double scale = pow(10.0,(enb_data[att_eNB_id]->tx_power_dBm + eNB2UE[att_eNB_id][UE_id]->path_loss_dB + (double) PHY_vars_UE_g[UE_id]->rx_total_gain_dB)/20.0);
-      double scale = pow(10.0,(frame_parms->pdsch_config_common.referenceSignalPower+eNB2UE[att_eNB_id][UE_id][CC_id]->path_loss_dB + (double) PHY_vars_UE_g[UE_id][CC_id]->rx_total_gain_dB)/20.0);
+      //      double scale = pow(10.0,(enb_data[att_eNB_id]->tx_power_dBm + RU2UE[att_eNB_id][UE_id]->path_loss_dB + (double) PHY_vars_UE_g[UE_id]->rx_total_gain_dB)/20.0);
+      double scale = pow(10.0,(frame_parms->pdsch_config_common.referenceSignalPower+RU2UE[att_eNB_id][UE_id][CC_id]->path_loss_dB + (double) PHY_vars_UE_g[UE_id][CC_id]->rx_total_gain_dB)/20.0);
       LOG_D(OCM,"scale =%lf (%d dB)\n",scale,(int) (20*log10(scale)));
       // freq_channel(desc1,frame_parms->N_RB_DL,nb_samples);
       //write_output("channel.m","ch",desc1->ch[0],desc1->channel_length,1,8);
@@ -202,14 +206,15 @@ void do_DL_sig(channel_desc_t *eNB2UE[NUMBER_OF_eNB_MAX][NUMBER_OF_UE_MAX][MAX_N
       }
 
       // calculate the SNR for the attached eNB (this assumes eNB always uses PMI stored in eNB_UE_stats; to be improved)
-      init_snr(eNB2UE[att_eNB_id][UE_id][CC_id], enb_data[att_eNB_id], ue_data[UE_id], PHY_vars_UE_g[UE_id][CC_id]->sinr_dB, &PHY_vars_UE_g[UE_id][CC_id]->N0,
-               PHY_vars_UE_g[UE_id][CC_id]->transmission_mode[att_eNB_id], PHY_vars_eNB_g[att_eNB_id][CC_id]->UE_stats[UE_id].DL_pmi_single,
-	       PHY_vars_eNB_g[att_eNB_id][CC_id]->mu_mimo_mode[UE_id].dl_pow_off,PHY_vars_eNB_g[att_eNB_id][CC_id]->frame_parms.N_RB_DL);
+      init_snr(RU2UE[att_eNB_id][UE_id][CC_id], enb_data[att_eNB_id], ue_data[UE_id], PHY_vars_UE_g[UE_id][CC_id]->sinr_dB, &PHY_vars_UE_g[UE_id][CC_id]->N0,
+               PHY_vars_UE_g[UE_id][CC_id]->transmission_mode[att_eNB_id], RC.eNB[att_eNB_id][CC_id]->UE_stats[UE_id].DL_pmi_single,
+	       RC.eNB[att_eNB_id][CC_id]->mu_mimo_mode[UE_id].dl_pow_off,RC.eNB[att_eNB_id][CC_id]->frame_parms.N_RB_DL);
 
       // calculate sinr here
       for (eNB_id = 0; eNB_id < NB_eNB_INST; eNB_id++) {
         if (att_eNB_id != eNB_id) {
-          calculate_sinr(eNB2UE[eNB_id][UE_id][CC_id], enb_data[eNB_id], ue_data[UE_id], PHY_vars_UE_g[UE_id][CC_id]->sinr_dB,PHY_vars_eNB_g[att_eNB_id][CC_id]->frame_parms.N_RB_DL);
+          calculate_sinr(RU2UE[eNB_id][UE_id][CC_id], enb_data[eNB_id], ue_data[UE_id], PHY_vars_UE_g[UE_id][CC_id]->sinr_dB,
+			 RC.eNB[att_eNB_id][CC_id]->frame_parms.N_RB_DL);
         }
       }
     } // hold channel
@@ -217,19 +222,21 @@ void do_DL_sig(channel_desc_t *eNB2UE[NUMBER_OF_eNB_MAX][NUMBER_OF_UE_MAX][MAX_N
   else { //abstraction_flag
 
 
-    pthread_mutex_lock(&eNB_output_mutex[UE_id]);
+    pthread_mutex_lock(&RU_output_mutex[UE_id]);
  
-    if (eNB_output_mask[UE_id] == 0) {  //  This is the first eNodeB for this UE, clear the buffer
+    if (RU_output_mask[UE_id] == 0) {  //  This is the first eNodeB for this UE, clear the buffer
       
       for (aa=0; aa<nb_antennas_rx; aa++) {
-	memset((void*)r_re_DL[UE_id][aa],0,(frame_parms->samples_per_tti)*sizeof(double));
-	memset((void*)r_im_DL[UE_id][aa],0,(frame_parms->samples_per_tti)*sizeof(double));
+	memset((void*)r_re_DL[UE_id][aa],0,(RC.ru[0]->frame_parms.samples_per_tti)*sizeof(double));
+	memset((void*)r_im_DL[UE_id][aa],0,(RC.ru[0]->frame_parms.samples_per_tti)*sizeof(double));
       }
     }
-    pthread_mutex_unlock(&eNB_output_mutex[UE_id]);
+    pthread_mutex_unlock(&RU_output_mutex[UE_id]);
+
+    for (ru_id=0; ru_id<RC.nb_RU; ru_id++) {
+      txdata = RC.ru[ru_id]->common.txdata;
+      frame_parms = &RC.ru[ru_id]->frame_parms;
 
-    for (eNB_id=0; eNB_id<NB_eNB_INST; eNB_id++) {
-      txdata = PHY_vars_eNB_g[eNB_id][CC_id]->common_vars.txdata[0];
       sf_offset = subframe*frame_parms->samples_per_tti;
       tx_pwr = dac_fixed_gain(s_re,
                               s_im,
@@ -244,52 +251,52 @@ void do_DL_sig(channel_desc_t *eNB2UE[NUMBER_OF_eNB_MAX][NUMBER_OF_UE_MAX][MAX_N
                               frame_parms->N_RB_DL*12);
 
 #ifdef DEBUG_SIM
-      LOG_D(OCM,"[SIM][DL] eNB %d (CCid %d): tx_pwr %.1f dBm/RE (target %d dBm/RE), for subframe %d\n",
-            eNB_id,CC_id,
+      LOG_D(OCM,"[SIM][DL] RU %d (CCid %d): tx_pwr %.1f dBm/RE (target %d dBm/RE), for subframe %d\n",
+            ru_id,CC_id,
             10*log10(tx_pwr),
             frame_parms->pdsch_config_common.referenceSignalPower,
             subframe);
 
 #endif
-      //eNB2UE[eNB_id][UE_id]->path_loss_dB = 0;
-      multipath_channel(eNB2UE[eNB_id][UE_id][CC_id],s_re,s_im,r_re0,r_im0,
+      //RU2UE[eNB_id][UE_id]->path_loss_dB = 0;
+      multipath_channel(RU2UE[ru_id][UE_id][CC_id],s_re,s_im,r_re0,r_im0,
                         frame_parms->samples_per_tti,hold_channel);
 #ifdef DEBUG_SIM
-      rx_pwr = signal_energy_fp2(eNB2UE[eNB_id][UE_id][CC_id]->ch[0],
-                                 eNB2UE[eNB_id][UE_id][CC_id]->channel_length)*eNB2UE[eNB_id][UE_id][CC_id]->channel_length;
-      LOG_D(OCM,"[SIM][DL] Channel eNB %d => UE %d (CCid %d): Channel gain %f dB (%f)\n",eNB_id,UE_id,CC_id,10*log10(rx_pwr),rx_pwr);
+      rx_pwr = signal_energy_fp2(RU2UE[ru_id][UE_id][CC_id]->ch[0],
+                                 RU2UE[ru_id][UE_id][CC_id]->channel_length)*RU2UE[ru_id][UE_id][CC_id]->channel_length;
+      LOG_D(OCM,"[SIM][DL] Channel RU %d => UE %d (CCid %d): Channel gain %f dB (%f)\n",ru_id,UE_id,CC_id,10*log10(rx_pwr),rx_pwr);
 #endif
 
 
 #ifdef DEBUG_SIM
 
-      for (i=0; i<eNB2UE[eNB_id][UE_id][CC_id]->channel_length; i++)
-        LOG_D(OCM,"channel(%d,%d)[%d] : (%f,%f)\n",eNB_id,UE_id,i,eNB2UE[eNB_id][UE_id][CC_id]->ch[0][i].x,eNB2UE[eNB_id][UE_id][CC_id]->ch[0][i].y);
+      for (i=0; i<RU2UE[ru_id][UE_id][CC_id]->channel_length; i++)
+        LOG_D(OCM,"channel(%d,%d)[%d] : (%f,%f)\n",ru_id,UE_id,i,RU2UE[ru_id][UE_id][CC_id]->ch[0][i].x,RU2UE[ru_id][UE_id][CC_id]->ch[0][i].y);
 
 #endif
 
       LOG_D(OCM,"[SIM][DL] Channel eNB %d => UE %d (CCid %d): tx_power %.1f dBm/RE, path_loss %1.f dB\n",
-            eNB_id,UE_id,CC_id,
+            ru_id,UE_id,CC_id,
             (double)frame_parms->pdsch_config_common.referenceSignalPower,
             //         enb_data[eNB_id]->tx_power_dBm,
-            eNB2UE[eNB_id][UE_id][CC_id]->path_loss_dB);
+            RU2UE[ru_id][UE_id][CC_id]->path_loss_dB);
 
 #ifdef DEBUG_SIM
       rx_pwr = signal_energy_fp(r_re0,r_im0,nb_antennas_rx,
                                 frame_parms->ofdm_symbol_size,
-                                sf_offset)/(12.0*frame_parms->N_RB_DL);
+                                0)/(12.0*frame_parms->N_RB_DL);
       LOG_D(OCM,"[SIM][DL] UE %d : rx_pwr %f dBm/RE (%f dBm RSSI)for subframe %d\n",UE_id,
             10*log10(rx_pwr),
             10*log10(rx_pwr*(double)frame_parms->N_RB_DL*12),subframe);
-      LOG_D(OCM,"[SIM][DL] UE %d : rx_pwr (noise) -132 dBm/RE (N0fs = %.1f dBm, N0B = %.1f dBm) for slot %d (subframe %d)\n",
+      LOG_D(OCM,"[SIM][DL] UE %d : rx_pwr (noise) -132 dBm/RE (N0fs = %.1f dBm, N0B = %.1f dBm) for subframe %d\n",
             UE_id,
-            10*log10(eNB2UE[eNB_id][UE_id][CC_id]->sampling_rate*1e6)-174,
-            10*log10(eNB2UE[eNB_id][UE_id][CC_id]->sampling_rate*1e6*12*frame_parms->N_RB_DL/(double)frame_parms->ofdm_symbol_size)-174,
+            10*log10(RU2UE[ru_id][UE_id][CC_id]->sampling_rate*1e6)-174,
+            10*log10(RU2UE[ru_id][UE_id][CC_id]->sampling_rate*1e6*12*frame_parms->N_RB_DL/(double)frame_parms->ofdm_symbol_size)-174,
             subframe);
 #endif
 
-      if (eNB2UE[eNB_id][UE_id][CC_id]->first_run == 1)
-        eNB2UE[eNB_id][UE_id][CC_id]->first_run = 0;
+      if (RU2UE[ru_id][UE_id][CC_id]->first_run == 1)
+        RU2UE[ru_id][UE_id][CC_id]->first_run = 0;
 
 
       // RF model
@@ -302,36 +309,36 @@ void do_DL_sig(channel_desc_t *eNB2UE[NUMBER_OF_eNB_MAX][NUMBER_OF_UE_MAX][MAX_N
                    r_im0,
                    nb_antennas_rx,
                    frame_parms->samples_per_tti,
-                   1e3/eNB2UE[eNB_id][UE_id][CC_id]->sampling_rate,  // sampling time (ns)
+                   1e3/RU2UE[ru_id][UE_id][CC_id]->sampling_rate,  // sampling time (ns)
                    (double)PHY_vars_UE_g[UE_id][CC_id]->rx_total_gain_dB - 66.227);   // rx_gain (dB) (66.227 = 20*log10(pow2(11)) = gain from the adc that will be applied later)
 
 #ifdef DEBUG_SIM
       rx_pwr = signal_energy_fp(r_re0,r_im0,
                                 nb_antennas_rx,
                                 frame_parms->ofdm_symbol_size,
-                                sf_offset)/(12.0*frame_parms->N_RB_DL);
+                                0)/(12.0*frame_parms->N_RB_DL);
       LOG_D(OCM,"[SIM][DL] UE %d : ADC in (eNB %d) %f dBm/RE for subframe %d\n",
-            UE_id,eNB_id,
+            UE_id,ru_id,
             10*log10(rx_pwr),subframe);
 #endif
       
-      pthread_mutex_lock(&eNB_output_mutex[UE_id]);
+      pthread_mutex_lock(&RU_output_mutex[UE_id]);
       for (i=0; i<frame_parms->samples_per_tti; i++) {
         for (aa=0; aa<nb_antennas_rx; aa++) {
           r_re_DL[UE_id][aa][i]+=r_re0[aa][i];
           r_im_DL[UE_id][aa][i]+=r_im0[aa][i];
         }
       }
-      eNB_output_mask[UE_id] |= (1<<eNB_id);
-      if (eNB_output_mask[UE_id] == (1<<NB_eNB_INST)-1) {
-	eNB_output_mask[UE_id]=0;
+      RU_output_mask[UE_id] |= (1<<ru_id);
+      if (RU_output_mask[UE_id] == (1<<NB_eNB_INST)-1) {
+	RU_output_mask[UE_id]=0;
       
 
-	double *r_re_p[2] = {r_re_DL[eNB_id][0],r_re_DL[eNB_id][1]};
-	double *r_im_p[2] = {r_im_DL[eNB_id][0],r_im_DL[eNB_id][1]};
+	double *r_re_p[2] = {r_re_DL[ru_id][0],r_re_DL[ru_id][1]};
+	double *r_im_p[2] = {r_im_DL[ru_id][0],r_im_DL[ru_id][1]};
 
 #ifdef DEBUG_SIM
-	rx_pwr = signal_energy_fp(r_re_p,r_im_p,nb_antennas_rx,frame_parms->ofdm_symbol_size,sf_offset)/(12.0*frame_parms->N_RB_DL);
+	rx_pwr = signal_energy_fp(r_re_p,r_im_p,nb_antennas_rx,frame_parms->ofdm_symbol_size,0)/(12.0*frame_parms->N_RB_DL);
 	LOG_D(OCM,"[SIM][DL] UE %d : ADC in %f dBm for subframe %d\n",UE_id,10*log10(rx_pwr),subframe);
 #endif
 	
@@ -357,19 +364,19 @@ void do_DL_sig(channel_desc_t *eNB2UE[NUMBER_OF_eNB_MAX][NUMBER_OF_UE_MAX][MAX_N
 	UNUSED_VARIABLE(rx_pwr);
 #endif
 		
-      } // eNB_output_mask
-      pthread_mutex_unlock(&eNB_output_mutex[UE_id]);      
-    } // eNB_id
+      } // RU_output_mask
+      pthread_mutex_unlock(&RU_output_mutex[UE_id]);      
+    } // ru_id
 
   }
 
 }
 
 
-void do_UL_sig(channel_desc_t *UE2eNB[NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX][MAX_NUM_CCs],
-               node_desc_t *enb_data[NUMBER_OF_eNB_MAX],node_desc_t *ue_data[NUMBER_OF_UE_MAX],
+void do_UL_sig(channel_desc_t *UE2RU[NUMBER_OF_UE_MAX][NUMBER_OF_RU_MAX][MAX_NUM_CCs],
+               node_desc_t *enb_data[NUMBER_OF_RU_MAX],node_desc_t *ue_data[NUMBER_OF_UE_MAX],
 	       uint16_t subframe,uint8_t abstraction_flag,LTE_DL_FRAME_PARMS *frame_parms, 
-	       uint32_t frame,int eNB_id,uint8_t CC_id)
+	       uint32_t frame,int ru_id,uint8_t CC_id)
 {
 
   int32_t **txdata,**rxdata;
@@ -378,8 +385,8 @@ void do_UL_sig(channel_desc_t *UE2eNB[NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX][MAX_N
 #endif
   uint8_t UE_id=0;
 
-  uint8_t nb_antennas_rx = UE2eNB[0][0][CC_id]->nb_rx; // number of rx antennas at eNB
-  uint8_t nb_antennas_tx = UE2eNB[0][0][CC_id]->nb_tx; // number of tx antennas at UE
+  uint8_t nb_antennas_rx = UE2RU[0][0][CC_id]->nb_rx; // number of rx antennas at eNB
+  uint8_t nb_antennas_tx = UE2RU[0][0][CC_id]->nb_tx; // number of tx antennas at UE
 
   double tx_pwr, rx_pwr;
   int32_t rx_pwr2;
@@ -396,17 +403,17 @@ void do_UL_sig(channel_desc_t *UE2eNB[NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX][MAX_N
   int ulfrrb2 ;
   uint8_t harq_pid;
 #endif
-  double s_re0[30720];//PHY_vars_UE_g[UE_id][CC_id]->frame_parms.samples_per_tti];
-  double s_re1[30720];//PHY_vars_UE_g[UE_id][CC_id]->frame_parms.samples_per_tti];
+  double s_re0[30720];
+  double s_re1[30720];
   double *s_re[2];
-  double s_im0[30720];//PHY_vars_UE_g[UE_id][CC_id]->frame_parms.samples_per_tti];
-  double s_im1[30720];//PHY_vars_UE_g[UE_id][CC_id]->frame_parms.samples_per_tti];
+  double s_im0[30720];
+  double s_im1[30720];
   double *s_im[2];
-  double r_re00[30720];//PHY_vars_UE_g[UE_id][CC_id]->frame_parms.samples_per_tti];
-  double r_re01[30720];//PHY_vars_UE_g[UE_id][CC_id]->frame_parms.samples_per_tti];
+  double r_re00[30720];
+  double r_re01[30720];
   double *r_re0[2];
-  double r_im00[30720];//PHY_vars_UE_g[UE_id][CC_id]->frame_parms.samples_per_tti];
-  double r_im01[30720];//PHY_vars_UE_g[UE_id][CC_id]->frame_parms.samples_per_tti];
+  double r_im00[30720];
+  double r_im01[30720];
   double *r_im0[2];
 
   s_re[0] = s_re0;
@@ -418,31 +425,33 @@ void do_UL_sig(channel_desc_t *UE2eNB[NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX][MAX_N
   r_im0[0] = r_im00;
   r_re0[1] = r_re01;
   r_im0[1] = r_im01;
-
+  
   if (abstraction_flag!=0)  {
 #ifdef PHY_ABSTRACTION_UL
+    // wire this to 0 until we figure this out
+    int eNB_id=0;
 
     for (UE_id=0; UE_id<NB_UE_INST; UE_id++) {
       if (!hold_channel) {
-	random_channel(UE2eNB[UE_id][eNB_id][CC_id],abstraction_flag);
-	freq_channel(UE2eNB[UE_id][eNB_id][CC_id], frame_parms->N_RB_UL,frame_parms->N_RB_UL*12+1);
+	random_channel(UE2RU[UE_id][eNB_id][CC_id],abstraction_flag);
+	freq_channel(UE2RU[UE_id][eNB_id][CC_id], frame_parms->N_RB_UL,frame_parms->N_RB_UL*12+1);
 	
 	// REceived power at the eNB
-	rx_pwr = signal_energy_fp2(UE2eNB[UE_id][eNB_id][CC_id]->ch[0],
-				   UE2eNB[UE_id][eNB_id][CC_id]->channel_length)*UE2eNB[UE_id][att_eNB_id][CC_id]->channel_length; // calculate the rx power at the eNB
+	rx_pwr = signal_energy_fp2(UE2RU[UE_id][eNB_id][CC_id]->ch[0],
+				   UE2RU[UE_id][eNB_id][CC_id]->channel_length)*UE2RU[UE_id][att_eNB_id][CC_id]->channel_length; // calculate the rx power at the eNB
       }
       
       //  write_output("SINRch.m","SINRch",PHY_vars_eNB_g[att_eNB_id]->sinr_dB_eNB,frame_parms->N_RB_UL*12+1,1,1);
       if(subframe>1 && subframe <5) {
 	harq_pid = subframe2harq_pid(frame_parms,frame,subframe);
-	ul_nb_rb = PHY_vars_eNB_g[att_eNB_id][CC_id]->ulsch_eNB[(uint8_t)UE_id]->harq_processes[harq_pid]->nb_rb;
-	ul_fr_rb = PHY_vars_eNB_g[att_eNB_id][CC_id]->ulsch_eNB[(uint8_t)UE_id]->harq_processes[harq_pid]->first_rb;
+	ul_nb_rb = RC.eNB[att_eNB_id][CC_id].ulsch_eNB[(uint8_t)UE_id]->harq_processes[harq_pid]->nb_rb;
+	ul_fr_rb = RC.eNB[att_eNB_id][CC_id].ulsch_eNB[(uint8_t)UE_id]->harq_processes[harq_pid]->first_rb;
       }
       
       if(ul_nb_rb>1 && (ul_fr_rb < 25 && ul_fr_rb > -1)) {
 	number_rb_ul = ul_nb_rb;
 	first_rbUL = ul_fr_rb;
-	init_snr_up(UE2eNB[UE_id][att_eNB_id][CC_id],enb_data[att_eNB_id], ue_data[UE_id],PHY_vars_eNB_g[att_eNB_id][CC_id]->sinr_dB,&PHY_vars_UE_g[att_eNB_id][CC_id]->N0,ul_nb_rb,ul_fr_rb);
+	init_snr_up(UE2RU[UE_id][att_eNB_id][CC_id],enb_data[att_eNB_id], ue_data[UE_id],PHY_vars_eNB_g[att_eNB_id][CC_id]->sinr_dB,&PHY_vars_UE_g[att_eNB_id][CC_id]->N0,ul_nb_rb,ul_fr_rb);
 	
       }
     } //UE_id
@@ -452,24 +461,24 @@ void do_UL_sig(channel_desc_t *UE2eNB[NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX][MAX_N
 #endif
   } else { //without abstraction
 
-    pthread_mutex_lock(&UE_output_mutex[eNB_id]);
+    pthread_mutex_lock(&UE_output_mutex[ru_id]);
     // Clear RX signal for eNB = eNB_id
     for (i=0; i<frame_parms->samples_per_tti; i++) {
       for (aa=0; aa<nb_antennas_rx; aa++) {
-	r_re_UL[eNB_id][aa][i]=0.0;
-	r_im_UL[eNB_id][aa][i]=0.0;
+	r_re_UL[ru_id][aa][i]=0.0;
+	r_im_UL[ru_id][aa][i]=0.0;
       }
     }
-    pthread_mutex_unlock(&UE_output_mutex[eNB_id]);
+    pthread_mutex_unlock(&UE_output_mutex[ru_id]);
 
     // Compute RX signal for eNB = eNB_id
     for (UE_id=0; UE_id<NB_UE_INST; UE_id++) {
       
-      txdata = PHY_vars_UE_g[UE_id][CC_id]->common_vars.txdata;
+      txdata = RC.ru[ru_id]->common.txdata;
+      AssertFatal(txdata != NULL,"txdata is null\n");
       sf_offset = subframe*frame_parms->samples_per_tti;
-      
       if (((double)PHY_vars_UE_g[UE_id][CC_id]->tx_power_dBm[subframe] +
-	   UE2eNB[UE_id][eNB_id][CC_id]->path_loss_dB) <= -125.0) {
+	   UE2RU[UE_id][ru_id][CC_id]->path_loss_dB) <= -125.0) {
 	// don't simulate a UE that is too weak
 	LOG_D(OCM,"[SIM][UL] UE %d tx_pwr %d dBm (num_RE %d) for subframe %d (sf_offset %d)\n",
 	      UE_id,
@@ -496,53 +505,53 @@ void do_UL_sig(channel_desc_t *UE2eNB[NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX][MAX_N
 	      subframe,sf_offset);
        
 		
-	multipath_channel(UE2eNB[UE_id][eNB_id][CC_id],s_re,s_im,r_re0,r_im0,
+	multipath_channel(UE2RU[UE_id][ru_id][CC_id],s_re,s_im,r_re0,r_im0,
 			  frame_parms->samples_per_tti,hold_channel);
 	
 
-	rx_pwr = signal_energy_fp2(UE2eNB[UE_id][eNB_id][CC_id]->ch[0],
-				   UE2eNB[UE_id][eNB_id][CC_id]->channel_length)*UE2eNB[UE_id][eNB_id][CC_id]->channel_length;
+	rx_pwr = signal_energy_fp2(UE2RU[UE_id][ru_id][CC_id]->ch[0],
+				   UE2RU[UE_id][ru_id][CC_id]->channel_length)*UE2RU[UE_id][ru_id][CC_id]->channel_length;
 
-	LOG_D(OCM,"[SIM][UL] subframe %d Channel UE %d => eNB %d : %f dB (hold %d,length %d, PL %f)\n",subframe,UE_id,eNB_id,10*log10(rx_pwr),
-	      hold_channel,UE2eNB[UE_id][eNB_id][CC_id]->channel_length,
-	      UE2eNB[UE_id][eNB_id][CC_id]->path_loss_dB);
+	LOG_D(OCM,"[SIM][UL] subframe %d Channel UE %d => RU %d : %f dB (hold %d,length %d, PL %f)\n",subframe,UE_id,ru_id,10*log10(rx_pwr),
+	      hold_channel,UE2RU[UE_id][ru_id][CC_id]->channel_length,
+	      UE2RU[UE_id][ru_id][CC_id]->path_loss_dB);
 
 	rx_pwr = signal_energy_fp(r_re0,r_im0,nb_antennas_rx,frame_parms->samples_per_tti,0);
 	LOG_D(OCM,"[SIM][UL] eNB %d : rx_pwr %f dBm (%f) for subframe %d, sptti %d\n",
-	      eNB_id,10*log10(rx_pwr),rx_pwr,subframe,frame_parms->samples_per_tti);
+	      ru_id,10*log10(rx_pwr),rx_pwr,subframe,frame_parms->samples_per_tti);
 	
 	
-	if (UE2eNB[UE_id][eNB_id][CC_id]->first_run == 1)
-	  UE2eNB[UE_id][eNB_id][CC_id]->first_run = 0;
+	if (UE2RU[UE_id][ru_id][CC_id]->first_run == 1)
+	  UE2RU[UE_id][ru_id][CC_id]->first_run = 0;
 	
 	
-	pthread_mutex_lock(&UE_output_mutex[eNB_id]);
+	pthread_mutex_lock(&UE_output_mutex[ru_id]);
 	for (aa=0; aa<nb_antennas_rx; aa++) {
 	  for (i=0; i<frame_parms->samples_per_tti; i++) {
-	    r_re_UL[eNB_id][aa][i]+=r_re0[aa][i];
-	    r_im_UL[eNB_id][aa][i]+=r_im0[aa][i];
+	    r_re_UL[ru_id][aa][i]+=r_re0[aa][i];
+	    r_im_UL[ru_id][aa][i]+=r_im0[aa][i];
 	  }
 	}
-	pthread_mutex_unlock(&UE_output_mutex[eNB_id]);
+	pthread_mutex_unlock(&UE_output_mutex[ru_id]);
       }
     } //UE_id
     
-    double *r_re_p[2] = {r_re_UL[eNB_id][0],r_re_UL[eNB_id][1]};
-    double *r_im_p[2] = {r_im_UL[eNB_id][0],r_im_UL[eNB_id][1]};
+    double *r_re_p[2] = {r_re_UL[ru_id][0],r_re_UL[ru_id][1]};
+    double *r_im_p[2] = {r_im_UL[ru_id][0],r_im_UL[ru_id][1]};
 
     rf_rx_simple(r_re_p,
 		 r_im_p,
 		 nb_antennas_rx,
 		 frame_parms->samples_per_tti,
-		 1e3/UE2eNB[0][eNB_id][CC_id]->sampling_rate,  // sampling time (ns)
-		 (double)PHY_vars_eNB_g[eNB_id][CC_id]->rx_total_gain_dB - 66.227);   // rx_gain (dB) (66.227 = 20*log10(pow2(11)) = gain from the adc that will be applied later)
+		 1e3/UE2RU[0][ru_id][CC_id]->sampling_rate,  // sampling time (ns)
+		 (double)RC.ru[ru_id]->max_rxgain-(double)RC.ru[ru_id]->att_rx - 66.227);   // rx_gain (dB) (66.227 = 20*log10(pow2(11)) = gain from the adc that will be applied later)
     
 #ifdef DEBUG_SIM
     rx_pwr = signal_energy_fp(r_re_p,r_im_p,nb_antennas_rx,frame_parms->samples_per_tti,0)*(double)frame_parms->ofdm_symbol_size/(12.0*frame_parms->N_RB_DL);
     LOG_D(OCM,"[SIM][UL] rx_pwr (ADC in) %f dB for subframe %d\n",10*log10(rx_pwr),subframe);
 #endif
     
-    rxdata = PHY_vars_eNB_g[eNB_id][CC_id]->common_vars.rxdata[0];
+    rxdata = RC.ru[ru_id]->common.rxdata;
     sf_offset = subframe*frame_parms->samples_per_tti;
 
     
@@ -557,7 +566,7 @@ void do_UL_sig(channel_desc_t *UE2eNB[NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX][MAX_N
     
 #ifdef DEBUG_SIM
     rx_pwr2 = signal_energy(rxdata[0]+sf_offset,frame_parms->samples_per_tti)*(double)frame_parms->ofdm_symbol_size/(12.0*frame_parms->N_RB_DL);
-    LOG_D(OCM,"[SIM][UL] eNB %d rx_pwr (ADC out) %f dB (%d) for subframe %d (offset %d)\n",eNB_id,10*log10((double)rx_pwr2),rx_pwr2,subframe,sf_offset);
+    LOG_D(OCM,"[SIM][UL] RU %d rx_pwr (ADC out) %f dB (%d) for subframe %d (offset %d)\n",ru_id,10*log10((double)rx_pwr2),rx_pwr2,subframe,sf_offset);
 #else
     UNUSED_VARIABLE(tx_pwr);
     UNUSED_VARIABLE(rx_pwr);
@@ -574,11 +583,11 @@ void init_channel_vars(LTE_DL_FRAME_PARMS *frame_parms, double ***s_re,double **
 
   int i;
 
-  memset(eNB_output_mask,0,sizeof(int)*NUMBER_OF_UE_MAX);
+  memset(RU_output_mask,0,sizeof(int)*NUMBER_OF_UE_MAX);
   for (i=0;i<NB_UE_INST;i++)
-    pthread_mutex_init(&eNB_output_mutex[i],NULL);
+    pthread_mutex_init(&RU_output_mutex[i],NULL);
 
-  memset(UE_output_mask,0,sizeof(int)*NUMBER_OF_eNB_MAX);
+  memset(UE_output_mask,0,sizeof(int)*NUMBER_OF_RU_MAX);
   for (i=0;i<NB_eNB_INST;i++)
     pthread_mutex_init(&UE_output_mutex[i],NULL);
 
diff --git a/targets/SIMU/USER/init_lte.c b/targets/SIMU/USER/init_lte.c
index 62273185b2..df57f388f2 100644
--- a/targets/SIMU/USER/init_lte.c
+++ b/targets/SIMU/USER/init_lte.c
@@ -37,11 +37,11 @@
 #include "PHY_INTERFACE/extern.h"
 
 
-
+/*
 PHY_VARS_eNB* init_lte_eNB(LTE_DL_FRAME_PARMS *frame_parms,
                            uint8_t eNB_id,
                            uint8_t Nid_cell,
-			   eNB_func_t node_function,
+			   node_function_t node_function,
                            uint8_t abstraction_flag)
 {
 
@@ -49,7 +49,6 @@ PHY_VARS_eNB* init_lte_eNB(LTE_DL_FRAME_PARMS *frame_parms,
   PHY_VARS_eNB* PHY_vars_eNB = malloc(sizeof(PHY_VARS_eNB));
   memset(PHY_vars_eNB,0,sizeof(PHY_VARS_eNB));
   PHY_vars_eNB->Mod_id=eNB_id;
-  PHY_vars_eNB->cooperation_flag=0;//cooperation_flag;
   memcpy(&(PHY_vars_eNB->frame_parms), frame_parms, sizeof(LTE_DL_FRAME_PARMS));
   PHY_vars_eNB->frame_parms.Nid_cell = ((Nid_cell/3)*3)+((eNB_id+Nid_cell)%3);
   PHY_vars_eNB->frame_parms.nushift = PHY_vars_eNB->frame_parms.Nid_cell%6;
@@ -81,7 +80,7 @@ PHY_VARS_eNB* init_lte_eNB(LTE_DL_FRAME_PARMS *frame_parms,
       }
     }
     
-    LOG_I(PHY,"Allocating Transport Channel Buffer for ULSCH, UE %d\n");
+    LOG_I(PHY,"Allocating Transport Channel Buffer for ULSCH, UE %d\n",i);
     PHY_vars_eNB->ulsch[1+i] = new_eNB_ulsch(MAX_TURBO_ITERATIONS,frame_parms->N_RB_UL, abstraction_flag);
     
     if (!PHY_vars_eNB->ulsch[1+i]) {
@@ -147,52 +146,10 @@ PHY_VARS_eNB* init_lte_eNB(LTE_DL_FRAME_PARMS *frame_parms,
 
   return (PHY_vars_eNB);
 }
+*/
 
-PHY_VARS_UE* init_lte_UE(LTE_DL_FRAME_PARMS *frame_parms,
-                         uint8_t UE_id,
-                         uint8_t abstraction_flag)
-
-{
-
-  int i,j;
-  PHY_VARS_UE* PHY_vars_UE = malloc(sizeof(PHY_VARS_UE));
-  memset(PHY_vars_UE,0,sizeof(PHY_VARS_UE));
-  PHY_vars_UE->Mod_id=UE_id;
-  memcpy(&(PHY_vars_UE->frame_parms), frame_parms, sizeof(LTE_DL_FRAME_PARMS));
-  phy_init_lte_ue(PHY_vars_UE,1,abstraction_flag);
-
-  for (i=0; i<NUMBER_OF_CONNECTED_eNB_MAX; i++) {
-    for (j=0; j<2; j++) {
-      PHY_vars_UE->dlsch[i][j]  = new_ue_dlsch(1,NUMBER_OF_HARQ_PID_MAX,NSOFT,MAX_TURBO_ITERATIONS,frame_parms->N_RB_DL, abstraction_flag);
-
-      if (!PHY_vars_UE->dlsch[i][j]) {
-        LOG_E(PHY,"Can't get ue dlsch structures\n");
-        exit(-1);
-      } else
-        LOG_D(PHY,"dlsch[%d][%d] => %p\n",UE_id,i,PHY_vars_UE->dlsch[i][j]);
-    }
-
-
-
-    PHY_vars_UE->ulsch[i]  = new_ue_ulsch(frame_parms->N_RB_UL, abstraction_flag);
-
-    if (!PHY_vars_UE->ulsch[i]) {
-      LOG_E(PHY,"Can't get ue ulsch structures\n");
-      exit(-1);
-    }
-
-    PHY_vars_UE->dlsch_SI[i]  = new_ue_dlsch(1,1,NSOFT,MAX_TURBO_ITERATIONS,frame_parms->N_RB_DL, abstraction_flag);
-    PHY_vars_UE->dlsch_ra[i]  = new_ue_dlsch(1,1,NSOFT,MAX_TURBO_ITERATIONS,frame_parms->N_RB_DL, abstraction_flag);
 
-    PHY_vars_UE->transmission_mode[i] = frame_parms->nb_antenna_ports_eNB==1 ? 1 : 2;
-  }
-
-  PHY_vars_UE->frame_parms.pucch_config_common.deltaPUCCH_Shift = 1;
-
-  PHY_vars_UE->dlsch_MCH[0]  = new_ue_dlsch(1,NUMBER_OF_HARQ_PID_MAX,NSOFT,MAX_TURBO_ITERATIONS_MBSFN,frame_parms->N_RB_DL,0);
-
-  return (PHY_vars_UE);
-}
+/*
 PHY_VARS_RN* init_lte_RN(LTE_DL_FRAME_PARMS *frame_parms,
                          uint8_t RN_id,
                          uint8_t eMBMS_active_state)
@@ -215,6 +172,7 @@ PHY_VARS_RN* init_lte_RN(LTE_DL_FRAME_PARMS *frame_parms,
 
   return (PHY_vars_RN);
 }
+
 void init_lte_vars(LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs],
                    uint8_t frame_type,
                    uint8_t tdd_config,
@@ -231,7 +189,9 @@ void init_lte_vars(LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs],
 		   uint8_t eMBMS_active_state)
 {
 
-  uint8_t eNB_id,UE_id,RN_id,CC_id;
+  uint8_t eNB_id,UE_id,CC_id;
+  int i;
+
 
   mac_xface = malloc(sizeof(MAC_xface));
 
@@ -271,15 +231,21 @@ void init_lte_vars(LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs],
 
   phy_init_lte_top(frame_parms[0]);
 
-  PHY_vars_eNB_g = (PHY_VARS_eNB***)malloc(NB_eNB_INST*sizeof(PHY_VARS_eNB**));
+  RC.nb_inst = NB_eNB_INST;
+  RC.nb_CC = (int *)malloc(MAX_NUM_CCs*sizeof(int));
+  RC.nb_RU = NB_RU;
+  for (i=0;i<NB_eNB_INST;i++) RC.nb_CC[i] = MAX_NUM_CCs;
+
+  RC.eNB = (PHY_VARS_eNB***)malloc(NB_eNB_INST*sizeof(PHY_VARS_eNB**));
 
   for (eNB_id=0; eNB_id<NB_eNB_INST; eNB_id++) {
-    PHY_vars_eNB_g[eNB_id] = (PHY_VARS_eNB**) malloc(MAX_NUM_CCs*sizeof(PHY_VARS_eNB*));
+    
+    RC.eNB[eNB_id] = (PHY_VARS_eNB**) malloc(MAX_NUM_CCs*sizeof(PHY_VARS_eNB*));
 
     for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
-      PHY_vars_eNB_g[eNB_id][CC_id] = init_lte_eNB(frame_parms[CC_id],eNB_id,Nid_cell,eNodeB_3GPP,abstraction_flag);
-      PHY_vars_eNB_g[eNB_id][CC_id]->Mod_id=eNB_id;
-      PHY_vars_eNB_g[eNB_id][CC_id]->CC_id=CC_id;
+      RC.eNB[eNB_id][CC_id] = init_lte_eNB(frame_parms[CC_id],eNB_id,Nid_cell,eNodeB_3GPP,abstraction_flag);
+      RC.eNB[eNB_id][CC_id]->Mod_id=eNB_id;
+      RC.eNB[eNB_id][CC_id]->CC_id=CC_id;
     }
   }
 
@@ -297,13 +263,14 @@ void init_lte_vars(LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs],
       PHY_vars_UE_g[UE_id][CC_id]->CC_id=CC_id;
     }
   }
+  
+//  if (NB_RN_INST > 0) {
+//    PHY_vars_RN_g = malloc(NB_RN_INST*sizeof(PHY_VARS_RN*));
 
-  if (NB_RN_INST > 0) {
-    PHY_vars_RN_g = malloc(NB_RN_INST*sizeof(PHY_VARS_RN*));
-
-    for (RN_id=0; RN_id<NB_RN_INST; RN_id++) {
-      PHY_vars_RN_g[RN_id] = init_lte_RN(*frame_parms,RN_id,eMBMS_active_state);
-    }
-  }
-
+//    for (RN_id=0; RN_id<NB_RN_INST; RN_id++) {
+//      PHY_vars_RN_g[RN_id] = init_lte_RN(*frame_parms,RN_id,eMBMS_active_state);
+//    }
+//  }
+  
 }
+*/
diff --git a/targets/SIMU/USER/init_lte.h b/targets/SIMU/USER/init_lte.h
index e49c24a15b..87974b33bd 100644
--- a/targets/SIMU/USER/init_lte.h
+++ b/targets/SIMU/USER/init_lte.h
@@ -25,7 +25,7 @@
 PHY_VARS_eNB* init_lte_eNB(LTE_DL_FRAME_PARMS *frame_parms,
                            uint8_t eNB_id,
                            uint8_t Nid_cell,
-			   eNB_func_t node_function,
+			   node_function_t node_function,
                            uint8_t abstraction_flag);
 
 PHY_VARS_UE* init_lte_UE(LTE_DL_FRAME_PARMS *frame_parms,
diff --git a/targets/SIMU/USER/oaisim.c b/targets/SIMU/USER/oaisim.c
index 71bfce44cb..caa495cc17 100644
--- a/targets/SIMU/USER/oaisim.c
+++ b/targets/SIMU/USER/oaisim.c
@@ -131,10 +131,10 @@ uint8_t usim_test = 0;
 
 frame_t frame = 0;
 char stats_buffer[16384];
-channel_desc_t *eNB2UE[NUMBER_OF_eNB_MAX][NUMBER_OF_UE_MAX][MAX_NUM_CCs];
-channel_desc_t *UE2eNB[NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX][MAX_NUM_CCs];
+channel_desc_t *RU2UE[NUMBER_OF_RU_MAX][NUMBER_OF_UE_MAX][MAX_NUM_CCs];
+channel_desc_t *UE2RU[NUMBER_OF_UE_MAX][NUMBER_OF_RU_MAX][MAX_NUM_CCs];
 //Added for PHY abstraction
-node_desc_t *enb_data[NUMBER_OF_eNB_MAX];
+node_desc_t *enb_data[NUMBER_OF_RU_MAX];
 node_desc_t *ue_data[NUMBER_OF_UE_MAX];
 
 pthread_cond_t sync_cond;
@@ -142,7 +142,7 @@ pthread_mutex_t sync_mutex;
 int sync_var=-1;
 
 pthread_mutex_t subframe_mutex;
-int subframe_eNB_mask=0,subframe_UE_mask=0;
+int subframe_ru_mask=0,subframe_UE_mask=0;
 
 openair0_config_t openair0_cfg[MAX_CARDS];
 uint32_t          downlink_frequency[MAX_NUM_CCs][4];
@@ -179,8 +179,6 @@ extern uint8_t abstraction_flag;
 extern uint8_t ethernet_flag;
 extern uint16_t Nid_cell;
 
-extern LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs];
-
 
 
 //#ifdef XFORMS
@@ -372,19 +370,19 @@ int omv_write(int pfd, node_list* enb_node_list, node_list* ue_node_list, Data_F
       enb_node_list = enb_node_list->next;
       omv_data.geo[i].Neighbors = 0;
 
-      for (j = NB_eNB_INST; j < NB_UE_INST + NB_eNB_INST; j++) {
-        if (is_UE_active (i, j - NB_eNB_INST) == 1) {
+      for (j = NB_RU; j < NB_UE_INST + NB_RU; j++) {
+        if (is_UE_active (i, j - NB_RU) == 1) {
           omv_data.geo[i].Neighbor[omv_data.geo[i].Neighbors] = j;
           omv_data.geo[i].Neighbors++;
           LOG_D(
 		OMG,
-		"[eNB %d][UE %d] is_UE_active(i,j) %d geo (x%d, y%d) num neighbors %d\n", i, j-NB_eNB_INST, is_UE_active(i,j-NB_eNB_INST), omv_data.geo[i].x, omv_data.geo[i].y, omv_data.geo[i].Neighbors);
+		"[RU %d][UE %d] is_UE_active(i,j) %d geo (x%d, y%d) num neighbors %d\n", i, j-NB_RU, is_UE_active(i,j-NB_RU), omv_data.geo[i].x, omv_data.geo[i].y, omv_data.geo[i].Neighbors);
         }
       }
     }
   }
 
-  for (i = NB_eNB_INST; i < NB_UE_INST + NB_eNB_INST; i++) {
+  for (i = NB_RU; i < NB_UE_INST + NB_RU; i++) {
     if (ue_node_list != NULL) {
       omv_data.geo[i].x = (ue_node_list->node->x_pos < 0.0) ? 0.0 : ue_node_list->node->x_pos;
       omv_data.geo[i].y = (ue_node_list->node->y_pos < 0.0) ? 0.0 : ue_node_list->node->y_pos;
@@ -408,13 +406,13 @@ int omv_write(int pfd, node_list* enb_node_list, node_list* ue_node_list, Data_F
       ue_node_list = ue_node_list->next;
       omv_data.geo[i].Neighbors = 0;
 
-      for (j = 0; j < NB_eNB_INST; j++) {
-        if (is_UE_active (j, i - NB_eNB_INST) == 1) {
+      for (j = 0; j < NB_RU; j++) {
+        if (is_UE_active (j, i - NB_RU) == 1) {
           omv_data.geo[i].Neighbor[omv_data.geo[i].Neighbors] = j;
           omv_data.geo[i].Neighbors++;
           LOG_D(
 		OMG,
-		"[UE %d][eNB %d] is_UE_active  %d geo (x%d, y%d) num neighbors %d\n", i-NB_eNB_INST, j, is_UE_active(j,i-NB_eNB_INST), omv_data.geo[i].x, omv_data.geo[i].y, omv_data.geo[i].Neighbors);
+		"[UE %d][RU %d] is_UE_active  %d geo (x%d, y%d) num neighbors %d\n", i-NB_RU, j, is_UE_active(j,i-NB_RU), omv_data.geo[i].x, omv_data.geo[i].y, omv_data.geo[i].Neighbors);
         }
       }
     }
@@ -446,6 +444,7 @@ static Data_Flow_Unit omv_data;
 #endif //ALU
 static module_id_t UE_inst = 0;
 static module_id_t eNB_inst = 0;
+static module_id_t ru_id;
 
 Packet_OTG_List_t *otg_pdcp_buffer;
 
@@ -455,7 +454,7 @@ typedef enum l2l1_task_state_e {
 
 l2l1_task_state_t l2l1_state = L2L1_WAITTING;
 
-extern openair0_timestamp current_eNB_rx_timestamp[NUMBER_OF_eNB_MAX][MAX_NUM_CCs];
+extern openair0_timestamp current_ru_rx_timestamp[NUMBER_OF_RU_MAX][MAX_NUM_CCs];
 extern openair0_timestamp current_UE_rx_timestamp[NUMBER_OF_UE_MAX][MAX_NUM_CCs];
 
 
@@ -617,9 +616,7 @@ l2l1_task (void *args_p)
 #endif
   module_id_t enb_id;
   module_id_t UE_id;
-  for (enb_id = 0; enb_id < NB_eNB_INST; enb_id++)
-    mac_xface->mrbch_phy_sync_failure (enb_id, 0, enb_id);
-  
+
   if (abstraction_flag == 1) {
     for (UE_id = 0; UE_id < NB_UE_INST; UE_id++)
       mac_xface->dl_phy_sync_success (UE_id, 0, 0,1);   //UE_id%NB_eNB_INST);
@@ -692,7 +689,7 @@ l2l1_task (void *args_p)
     //oai_emulation.info.time_ms += 1;
     oai_emulation.info.time_s += 0.01; // emu time in s, each frame lasts for 10 ms // JNote: TODO check the coherency of the time and frame (I corrected it to 10 (instead of 0.01)
 
-     update_omg (frame); // frequency is defined in the omg_global params configurable by the user
+    update_omg (frame); // frequency is defined in the omg_global params configurable by the user
     update_omg_ocm ();
 
 #ifdef OPENAIR2
@@ -704,7 +701,7 @@ l2l1_task (void *args_p)
 
 #endif
 
-    update_ocm ();
+
 
     for (sf = 0; sf < 10; sf++) {
       LOG_D(EMU,"************************* Subframe %d\n",sf);
@@ -722,7 +719,7 @@ l2l1_task (void *args_p)
 #ifdef PROC
 
     if(Channel_Flag==1)
-      Channel_Func(s_re2,s_im2,r_re2,r_im2,r_re02,r_im02,r_re0_d,r_im0_d,r_re0_u,r_im0_u,eNB2UE,UE2eNB,enb_data,ue_data,abstraction_flag,frame_parms,sf<<1);
+      Channel_Func(s_re2,s_im2,r_re2,r_im2,r_re02,r_im02,r_re0_d,r_im0_d,r_re0_u,r_im0_u,RU2UE,UE2RU,enb_data,ue_data,abstraction_flag,frame_parms,sf<<1);
 
     if(Channel_Flag==0)
 #endif
@@ -737,11 +734,11 @@ l2l1_task (void *args_p)
         int all_done=0;
         while (all_done==0) {
           pthread_mutex_lock(&subframe_mutex);
-          int subframe_eNB_mask_local = subframe_eNB_mask;
+          int subframe_ru_mask_local = subframe_ru_mask;
           int subframe_UE_mask_local  = subframe_UE_mask;
           pthread_mutex_unlock(&subframe_mutex);
-          LOG_D(EMU,"Frame %d, Subframe %d: Checking masks %x,%x\n",frame,sf,subframe_eNB_mask,subframe_UE_mask);
-          if ((subframe_eNB_mask_local == ((1<<NB_eNB_INST)-1)) &&
+          LOG_D(EMU,"Frame %d, Subframe %d: Checking masks %x,%x\n",frame,sf,subframe_ru_mask,subframe_UE_mask);
+          if ((subframe_ru_mask_local == ((1<<NB_RU)-1)) &&
               (subframe_UE_mask_local == ((1<<NB_UE_INST)-1)))
              all_done=1;
           else
@@ -750,18 +747,20 @@ l2l1_task (void *args_p)
 
         //clear subframe masks for next round
         pthread_mutex_lock(&subframe_mutex);
-        subframe_eNB_mask=0;
+        subframe_ru_mask=0;
         subframe_UE_mask=0;
         pthread_mutex_unlock(&subframe_mutex);
 
         // increment timestamps
-        for (eNB_inst = oai_emulation.info.first_enb_local;
-             (eNB_inst
+	/*
+        for (ru_id = oai_emulation.info.first_enb_local;
+             (ru_id
               < (oai_emulation.info.first_enb_local
                  + oai_emulation.info.nb_enb_local));
-             eNB_inst++) {
-	  
-	  current_eNB_rx_timestamp[eNB_inst][CC_id] += PHY_vars_eNB_g[eNB_inst][CC_id]->frame_parms.samples_per_tti;
+             ru_id++) {
+	*/
+	for (ru_id=0;ru_id<NB_RU;ru_id++) {
+	  current_ru_rx_timestamp[ru_id][CC_id] += RC.ru[ru_id]->frame_parms.samples_per_tti;
         }
         for (UE_inst = 0; UE_inst<NB_UE_INST;UE_inst++) {
 	  current_UE_rx_timestamp[UE_inst][CC_id] += PHY_vars_UE_g[UE_inst][CC_id]->frame_parms.samples_per_tti;
@@ -816,11 +815,11 @@ l2l1_task (void *args_p)
 
             if((sf==9) && frame%10==0)
               if(eNB_avg_thr)
-                fprintf(eNB_avg_thr,"%d %d\n",PHY_vars_eNB_g[eNB_inst][0]->proc.proc_rxtx[sf&1].frame_tx,
-                        (PHY_vars_eNB_g[eNB_inst][0]->total_system_throughput)/((PHY_vars_eNB_g[eNB_inst][0]->proc.proc_rxtx[sf&1].frame_tx+1)*10));
+                fprintf(eNB_avg_thr,"%d %d\n",RC.eNB[eNB_inst][0]->proc.proc_rxtx[sf&1].frame_tx,
+                        (RC.eNB[eNB_inst][0]->total_system_throughput)/((RC.eNB[eNB_inst][0]->proc.proc_rxtx[sf&1].frame_tx+1)*10));
 
             if (eNB_stats[eNB_inst]) {
-              len = dump_eNB_stats(PHY_vars_eNB_g[eNB_inst][0], stats_buffer, 0);
+              len = dump_eNB_stats(RC.eNB[eNB_inst][0], stats_buffer, 0);
               rewind (eNB_stats[eNB_inst]);
               fwrite (stats_buffer, 1, len, eNB_stats[eNB_inst]);
               fflush(eNB_stats[eNB_inst]);
@@ -1069,7 +1068,7 @@ l2l1_task (void *args_p)
 			6 * 12 * 4, 1, 1);
 	  write_output ("pbch_rxF_llr.m", "pbch_llr",
 			PHY_vars_UE_g[0][0]->pbch_vars[0]->llr,
-			(frame_parms[0]->Ncp == 0) ? 1920 : 1728, 1,
+			(PHY_vars_UE_g[0][0]->frame_parms.Ncp == 0) ? 1920 : 1728, 1,
 			4);
 	}
     
@@ -1078,6 +1077,7 @@ l2l1_task (void *args_p)
 
 
     }
+    update_ocm ();
     /*
     if ((frame >= 10) && (frame <= 11) && (abstraction_flag == 0)
 #ifdef PROC
@@ -1139,10 +1139,10 @@ l2l1_task (void *args_p)
 		   UE_inst,
 		   7);
 	}
-
-	phy_scope_eNB(form_enb[UE_inst],
-		      PHY_vars_eNB_g[eNB_inst][0],
-		      UE_inst);
+	if (RC.eNB && RC.eNB[eNB_inst] && RC.eNB[eNB_inst][0] )
+	  phy_scope_eNB(form_enb[UE_inst],
+			RC.eNB[eNB_inst][0],
+			UE_inst);
 	
       }
     }
@@ -1198,6 +1198,44 @@ int T_port = 2021;    /* default port to listen to to wait for the tracer */
 int T_dont_fork = 0;  /* default is to fork, see 'T_init' to understand */
 #endif
 
+void wait_RUs() {
+
+  int i;
+
+  // wait for all RUs to be configured over fronthaul
+  pthread_mutex_lock(&RC.ru_mutex);
+
+
+
+  while (RC.ru_mask>0) {
+    pthread_cond_wait(&RC.ru_cond,&RC.ru_mutex);
+  }
+
+  // copy frame parameters from RU to UEs
+  for (i=0;i<NB_UE_INST;i++) {
+    PHY_vars_UE_g[i][0]->frame_parms.N_RB_DL              = RC.ru[0]->frame_parms.N_RB_DL;
+    PHY_vars_UE_g[i][0]->frame_parms.nb_antennas_tx       = 1;
+    PHY_vars_UE_g[i][0]->frame_parms.nb_antennas_rx       = 1;
+    PHY_vars_UE_g[i][0]->frame_parms.nb_antenna_ports_eNB = RC.ru[0]->frame_parms.nb_antenna_ports_eNB;
+    PHY_vars_UE_g[i][0]->frame_parms.dl_CarrierFreq       = RC.ru[0]->frame_parms.dl_CarrierFreq;
+    PHY_vars_UE_g[i][0]->frame_parms.ul_CarrierFreq       = RC.ru[0]->frame_parms.ul_CarrierFreq;
+    PHY_vars_UE_g[i][0]->frame_parms.eutra_band           = RC.ru[0]->frame_parms.eutra_band;
+    init_ul_hopping(&PHY_vars_UE_g[i][0]->frame_parms);
+    init_frame_parms(&PHY_vars_UE_g[i][0]->frame_parms,1);
+    phy_init_lte_top(&PHY_vars_UE_g[i][0]->frame_parms);
+    phy_init_lte_ue(PHY_vars_UE_g[i][0],1,0);
+    current_UE_rx_timestamp[i][0] = PHY_vars_UE_g[i][0]->frame_parms.samples_per_tti;
+
+  }
+  
+  for (ru_id=0;ru_id<RC.nb_RU;ru_id++) current_ru_rx_timestamp[ru_id][0] = RC.ru[ru_id]->frame_parms.samples_per_tti;
+
+  printf("RUs are ready, let's go\n");
+}
+
+void init_UE(int,int,int);
+void init_RU(const char*);
+
 /*------------------------------------------------------------------------------*/
 int
 main (int argc, char **argv)
@@ -1287,34 +1325,27 @@ main (int argc, char **argv)
 
   init_seed (set_seed);
 
-  init_openair1 ();
+  init_devices ();
+  init_RU(NULL);
+  init_UE(NB_UE_INST,0,0);
 
-  init_openair2 ();
+  //  init_openair2 ();
 
-  init_openair0();
+  //  init_openair0();
 
-  init_ocm ();
 
-#if defined(ENABLE_ITTI)
-  // Handle signals until all tasks are terminated
 
-  // Note: Cannot handle both RRU/RAU and eNB at the same time, if the first "eNB" is an RRU/RAU, no NAS
-  if (oai_emulation.info.node_function[0] < NGFI_RAU_IF4p5) { 
-    if (create_tasks(oai_emulation.info.nb_enb_local, 
-		     oai_emulation.info.nb_ue_local) < 0) 
+  if (create_tasks(0, 
+		   oai_emulation.info.nb_ue_local) < 0) 
       exit(-1); // need a softer mode
-  }
-  else {
-    if (create_tasks(0, 
-		     oai_emulation.info.nb_ue_local) < 0) 
-      exit(-1); // need a softer mode
-  }
-#endif
-  
-  // wait for all threads to startup 
-  sleep(3);
+
+
+  printf("Waiting for RUs to get set up\n"); 
+  wait_RUs();
+  init_ocm ();
   printf("Sending sync to all threads\n");
 
+
   pthread_mutex_lock(&sync_mutex);
   sync_var=0;
   pthread_cond_broadcast(&sync_cond);
@@ -1391,7 +1422,7 @@ reset_opp_meas_oaisim (void)
     reset_meas (&PHY_vars_UE_g[UE_id][0]->phy_proc_rx);
     reset_meas (&PHY_vars_UE_g[UE_id][0]->phy_proc_tx);
 
-    reset_meas (&PHY_vars_UE_g[UE_id][0]->ofdm_demod_stats);
+    //    reset_meas (&PHY_vars_UE_g[UE_id][0]->ofdm_demod_stats);
     reset_meas (&PHY_vars_UE_g[UE_id][0]->rx_dft_stats);
     reset_meas (&PHY_vars_UE_g[UE_id][0]->dlsch_channel_estimation_stats);
     reset_meas (&PHY_vars_UE_g[UE_id][0]->dlsch_freq_offset_estimation_stats);
@@ -1445,64 +1476,64 @@ reset_opp_meas_oaisim (void)
   for (eNB_id = 0; eNB_id < NB_eNB_INST; eNB_id++) {
 
     for (UE_id = 0; UE_id < NB_UE_INST; UE_id++) {
-      reset_meas (&eNB2UE[eNB_id][UE_id][0]->random_channel);
-      reset_meas (&eNB2UE[eNB_id][UE_id][0]->interp_time);
-      reset_meas (&eNB2UE[eNB_id][UE_id][0]->interp_freq);
-      reset_meas (&eNB2UE[eNB_id][UE_id][0]->convolution);
-      reset_meas (&UE2eNB[UE_id][eNB_id][0]->random_channel);
-      reset_meas (&UE2eNB[UE_id][eNB_id][0]->interp_time);
-      reset_meas (&UE2eNB[UE_id][eNB_id][0]->interp_freq);
-      reset_meas (&UE2eNB[UE_id][eNB_id][0]->convolution);
+      reset_meas (&RU2UE[eNB_id][UE_id][0]->random_channel);
+      reset_meas (&RU2UE[eNB_id][UE_id][0]->interp_time);
+      reset_meas (&RU2UE[eNB_id][UE_id][0]->interp_freq);
+      reset_meas (&RU2UE[eNB_id][UE_id][0]->convolution);
+      reset_meas (&UE2RU[UE_id][eNB_id][0]->random_channel);
+      reset_meas (&UE2RU[UE_id][eNB_id][0]->interp_time);
+      reset_meas (&UE2RU[UE_id][eNB_id][0]->interp_freq);
+      reset_meas (&UE2RU[UE_id][eNB_id][0]->convolution);
     }
 
-    reset_meas (&PHY_vars_eNB_g[eNB_id][0]->phy_proc);
-    reset_meas (&PHY_vars_eNB_g[eNB_id][0]->phy_proc_rx);
-    reset_meas (&PHY_vars_eNB_g[eNB_id][0]->phy_proc_tx);
-    reset_meas (&PHY_vars_eNB_g[eNB_id][0]->rx_prach);
-
-    reset_meas (&PHY_vars_eNB_g[eNB_id][0]->ofdm_mod_stats);
-    reset_meas (&PHY_vars_eNB_g[eNB_id][0]->dlsch_encoding_stats);
-    reset_meas (&PHY_vars_eNB_g[eNB_id][0]->dlsch_modulation_stats);
-    reset_meas (&PHY_vars_eNB_g[eNB_id][0]->dlsch_scrambling_stats);
-    reset_meas (&PHY_vars_eNB_g[eNB_id][0]->dlsch_rate_matching_stats);
-    reset_meas (&PHY_vars_eNB_g[eNB_id][0]->dlsch_turbo_encoding_stats);
-    reset_meas (&PHY_vars_eNB_g[eNB_id][0]->dlsch_interleaving_stats);
-
-    reset_meas (&PHY_vars_eNB_g[eNB_id][0]->ofdm_demod_stats);
-    //reset_meas(&PHY_vars_eNB_g[eNB_id]->rx_dft_stats);
-    //reset_meas(&PHY_vars_eNB_g[eNB_id]->ulsch_channel_estimation_stats);
-    //reset_meas(&PHY_vars_eNB_g[eNB_id]->ulsch_freq_offset_estimation_stats);
-    reset_meas (&PHY_vars_eNB_g[eNB_id][0]->ulsch_decoding_stats);
-    reset_meas (&PHY_vars_eNB_g[eNB_id][0]->ulsch_demodulation_stats);
-    reset_meas (&PHY_vars_eNB_g[eNB_id][0]->ulsch_rate_unmatching_stats);
-    reset_meas (&PHY_vars_eNB_g[eNB_id][0]->ulsch_turbo_decoding_stats);
-    reset_meas (&PHY_vars_eNB_g[eNB_id][0]->ulsch_deinterleaving_stats);
-    reset_meas (&PHY_vars_eNB_g[eNB_id][0]->ulsch_demultiplexing_stats);
-    reset_meas (&PHY_vars_eNB_g[eNB_id][0]->ulsch_llr_stats);
-    reset_meas (&PHY_vars_eNB_g[eNB_id][0]->ulsch_tc_init_stats);
-    reset_meas (&PHY_vars_eNB_g[eNB_id][0]->ulsch_tc_alpha_stats);
-    reset_meas (&PHY_vars_eNB_g[eNB_id][0]->ulsch_tc_beta_stats);
-    reset_meas (&PHY_vars_eNB_g[eNB_id][0]->ulsch_tc_gamma_stats);
-    reset_meas (&PHY_vars_eNB_g[eNB_id][0]->ulsch_tc_ext_stats);
-    reset_meas (&PHY_vars_eNB_g[eNB_id][0]->ulsch_tc_intl1_stats);
-    reset_meas (&PHY_vars_eNB_g[eNB_id][0]->ulsch_tc_intl2_stats);
+    reset_meas (&RC.eNB[eNB_id][0]->phy_proc);
+    reset_meas (&RC.eNB[eNB_id][0]->phy_proc_rx);
+    reset_meas (&RC.eNB[eNB_id][0]->phy_proc_tx);
+    reset_meas (&RC.eNB[eNB_id][0]->rx_prach);
+
+    reset_meas (&RC.eNB[eNB_id][0]->ofdm_mod_stats);
+    reset_meas (&RC.eNB[eNB_id][0]->dlsch_encoding_stats);
+    reset_meas (&RC.eNB[eNB_id][0]->dlsch_modulation_stats);
+    reset_meas (&RC.eNB[eNB_id][0]->dlsch_scrambling_stats);
+    reset_meas (&RC.eNB[eNB_id][0]->dlsch_rate_matching_stats);
+    reset_meas (&RC.eNB[eNB_id][0]->dlsch_turbo_encoding_stats);
+    reset_meas (&RC.eNB[eNB_id][0]->dlsch_interleaving_stats);
+
+    //    reset_meas (&RC.eNB[eNB_id][0]->ofdm_demod_stats);
+    //reset_meas(&RC.eNB[eNB_id]->rx_dft_stats);
+    //reset_meas(&RC.eNB[eNB_id]->ulsch_channel_estimation_stats);
+    //reset_meas(&RC.eNB[eNB_id]->ulsch_freq_offset_estimation_stats);
+    reset_meas (&RC.eNB[eNB_id][0]->ulsch_decoding_stats);
+    reset_meas (&RC.eNB[eNB_id][0]->ulsch_demodulation_stats);
+    reset_meas (&RC.eNB[eNB_id][0]->ulsch_rate_unmatching_stats);
+    reset_meas (&RC.eNB[eNB_id][0]->ulsch_turbo_decoding_stats);
+    reset_meas (&RC.eNB[eNB_id][0]->ulsch_deinterleaving_stats);
+    reset_meas (&RC.eNB[eNB_id][0]->ulsch_demultiplexing_stats);
+    reset_meas (&RC.eNB[eNB_id][0]->ulsch_llr_stats);
+    reset_meas (&RC.eNB[eNB_id][0]->ulsch_tc_init_stats);
+    reset_meas (&RC.eNB[eNB_id][0]->ulsch_tc_alpha_stats);
+    reset_meas (&RC.eNB[eNB_id][0]->ulsch_tc_beta_stats);
+    reset_meas (&RC.eNB[eNB_id][0]->ulsch_tc_gamma_stats);
+    reset_meas (&RC.eNB[eNB_id][0]->ulsch_tc_ext_stats);
+    reset_meas (&RC.eNB[eNB_id][0]->ulsch_tc_intl1_stats);
+    reset_meas (&RC.eNB[eNB_id][0]->ulsch_tc_intl2_stats);
 #ifdef LOCALIZATION
-    reset_meas(&PHY_vars_eNB_g[eNB_id][0]->localization_stats);
+    reset_meas(&RC.eNB[eNB_id][0]->localization_stats);
 #endif
 
     /*
      * L2 functions
      */
     // eNB MAC
-    reset_meas (&eNB_mac_inst[eNB_id].eNB_scheduler); // total
-    reset_meas (&eNB_mac_inst[eNB_id].schedule_si); // only schedule + tx
-    reset_meas (&eNB_mac_inst[eNB_id].schedule_ra); // only ra
-    reset_meas (&eNB_mac_inst[eNB_id].schedule_ulsch); // onlu ulsch
-    reset_meas (&eNB_mac_inst[eNB_id].fill_DLSCH_dci); // only dci
-    reset_meas (&eNB_mac_inst[eNB_id].schedule_dlsch_preprocessor); // include rlc_data_req + MAC header gen
-    reset_meas (&eNB_mac_inst[eNB_id].schedule_dlsch); // include rlc_data_req + MAC header gen + pre-processor
-    reset_meas (&eNB_mac_inst[eNB_id].schedule_mch); // only embms
-    reset_meas (&eNB_mac_inst[eNB_id].rx_ulsch_sdu); // include rlc_data_ind + mac header parser
+    reset_meas (&RC.mac[eNB_id]->eNB_scheduler); // total
+    reset_meas (&RC.mac[eNB_id]->schedule_si); // only schedule + tx
+    reset_meas (&RC.mac[eNB_id]->schedule_ra); // only ra
+    reset_meas (&RC.mac[eNB_id]->schedule_ulsch); // onlu ulsch
+    reset_meas (&RC.mac[eNB_id]->fill_DLSCH_dci); // only dci
+    reset_meas (&RC.mac[eNB_id]->schedule_dlsch_preprocessor); // include rlc_data_req + MAC header gen
+    reset_meas (&RC.mac[eNB_id]->schedule_dlsch); // include rlc_data_req + MAC header gen + pre-processor
+    reset_meas (&RC.mac[eNB_id]->schedule_mch); // only embms
+    reset_meas (&RC.mac[eNB_id]->rx_ulsch_sdu); // include rlc_data_ind + mac header parser
 
     reset_meas (&eNB_pdcp_stats[eNB_id].pdcp_run);
     reset_meas (&eNB_pdcp_stats[eNB_id].data_req);
@@ -1532,23 +1563,23 @@ print_opp_meas_oaisim (void)
               &oaisim_stats_f);
 
   for (UE_id = 0; UE_id < NB_UE_INST; UE_id++) {
-    for (eNB_id = 0; eNB_id < NB_eNB_INST; eNB_id++) {
-      print_meas (&eNB2UE[eNB_id][UE_id][0]->random_channel,
+    for (ru_id = 0; ru_id < NB_RU; ru_id++) {
+      print_meas (&RU2UE[ru_id][UE_id][0]->random_channel,
                   "[DL][random_channel]", &oaisim_stats, &oaisim_stats_f);
-      print_meas (&eNB2UE[eNB_id][UE_id][0]->interp_time,
+      print_meas (&RU2UE[ru_id][UE_id][0]->interp_time,
                   "[DL][interp_time]", &oaisim_stats, &oaisim_stats_f);
-      print_meas (&eNB2UE[eNB_id][UE_id][0]->interp_freq,
+      print_meas (&RU2UE[ru_id][UE_id][0]->interp_freq,
                   "[DL][interp_freq]", &oaisim_stats, &oaisim_stats_f);
-      print_meas (&eNB2UE[eNB_id][UE_id][0]->convolution,
+      print_meas (&RU2UE[ru_id][UE_id][0]->convolution,
                   "[DL][convolution]", &oaisim_stats, &oaisim_stats_f);
 
-      print_meas (&UE2eNB[UE_id][eNB_id][0]->random_channel,
+      print_meas (&UE2RU[UE_id][ru_id][0]->random_channel,
                   "[UL][random_channel]", &oaisim_stats, &oaisim_stats_f);
-      print_meas (&UE2eNB[UE_id][eNB_id][0]->interp_time,
+      print_meas (&UE2RU[UE_id][ru_id][0]->interp_time,
                   "[UL][interp_time]", &oaisim_stats, &oaisim_stats_f);
-      print_meas (&UE2eNB[UE_id][eNB_id][0]->interp_freq,
+      print_meas (&UE2RU[UE_id][ru_id][0]->interp_freq,
                   "[UL][interp_freq]", &oaisim_stats, &oaisim_stats_f);
-      print_meas (&UE2eNB[UE_id][eNB_id][0]->convolution,
+      print_meas (&UE2RU[UE_id][ru_id][0]->convolution,
                   "[UL][convolution]", &oaisim_stats, &oaisim_stats_f);
     }
   }
@@ -1559,8 +1590,8 @@ print_opp_meas_oaisim (void)
 
     print_meas (&PHY_vars_UE_g[UE_id][0]->phy_proc_rx,
                 "[UE][total_phy_proc_rx]", &oaisim_stats, &oaisim_stats_f);
-    print_meas (&PHY_vars_UE_g[UE_id][0]->ofdm_demod_stats,
-                "[UE][ofdm_demod]", &oaisim_stats, &oaisim_stats_f);
+    //    print_meas (&PHY_vars_UE_g[UE_id][0]->ofdm_demod_stats,
+    //                "[UE][ofdm_demod]", &oaisim_stats, &oaisim_stats_f);
     print_meas (&PHY_vars_UE_g[UE_id][0]->rx_dft_stats, "[UE][rx_dft]",
                 &oaisim_stats, &oaisim_stats_f);
     print_meas (&PHY_vars_UE_g[UE_id][0]->dlsch_channel_estimation_stats,
@@ -1616,65 +1647,65 @@ print_opp_meas_oaisim (void)
   }
 
   for (eNB_id = 0; eNB_id < NB_eNB_INST; eNB_id++) {
-    print_meas (&PHY_vars_eNB_g[eNB_id][0]->phy_proc,
+    print_meas (&RC.eNB[eNB_id][0]->phy_proc,
                 "[eNB][total_phy_proc]", &oaisim_stats, &oaisim_stats_f);
 
-    print_meas (&PHY_vars_eNB_g[eNB_id][0]->phy_proc_tx,
+    print_meas (&RC.eNB[eNB_id][0]->phy_proc_tx,
                 "[eNB][total_phy_proc_tx]", &oaisim_stats, &oaisim_stats_f);
-    print_meas (&PHY_vars_eNB_g[eNB_id][0]->ofdm_mod_stats,
+    print_meas (&RC.eNB[eNB_id][0]->ofdm_mod_stats,
                 "[eNB][ofdm_mod]", &oaisim_stats, &oaisim_stats_f);
-    print_meas (&PHY_vars_eNB_g[eNB_id][0]->dlsch_modulation_stats,
+    print_meas (&RC.eNB[eNB_id][0]->dlsch_modulation_stats,
                 "[eNB][modulation]", &oaisim_stats, &oaisim_stats_f);
-    print_meas (&PHY_vars_eNB_g[eNB_id][0]->dlsch_scrambling_stats,
+    print_meas (&RC.eNB[eNB_id][0]->dlsch_scrambling_stats,
                 "[eNB][scrambling]", &oaisim_stats, &oaisim_stats_f);
-    print_meas (&PHY_vars_eNB_g[eNB_id][0]->dlsch_encoding_stats,
+    print_meas (&RC.eNB[eNB_id][0]->dlsch_encoding_stats,
                 "[eNB][encoding]", &oaisim_stats, &oaisim_stats_f);
-    print_meas (&PHY_vars_eNB_g[eNB_id][0]->dlsch_interleaving_stats,
+    print_meas (&RC.eNB[eNB_id][0]->dlsch_interleaving_stats,
                 "[eNB][|_interleaving]", &oaisim_stats, &oaisim_stats_f);
-    print_meas (&PHY_vars_eNB_g[eNB_id][0]->dlsch_rate_matching_stats,
+    print_meas (&RC.eNB[eNB_id][0]->dlsch_rate_matching_stats,
                 "[eNB][|_rate_matching]", &oaisim_stats, &oaisim_stats_f);
-    print_meas (&PHY_vars_eNB_g[eNB_id][0]->dlsch_turbo_encoding_stats,
+    print_meas (&RC.eNB[eNB_id][0]->dlsch_turbo_encoding_stats,
                 "[eNB][|_turbo_encoding]", &oaisim_stats, &oaisim_stats_f);
 
-    print_meas (&PHY_vars_eNB_g[eNB_id][0]->phy_proc_rx,
+    print_meas (&RC.eNB[eNB_id][0]->phy_proc_rx,
                 "[eNB][total_phy_proc_rx]", &oaisim_stats, &oaisim_stats_f);
-    print_meas (&PHY_vars_eNB_g[eNB_id][0]->ofdm_demod_stats,
-                "[eNB][ofdm_demod]", &oaisim_stats, &oaisim_stats_f);
-    //print_meas(&PHY_vars_eNB_g[eNB_id][0]->ulsch_channel_estimation_stats,"[eNB][channel_est]");
-    //print_meas(&PHY_vars_eNB_g[eNB_id][0]->ulsch_freq_offset_estimation_stats,"[eNB][freq_offset]");
-    //print_meas(&PHY_vars_eNB_g[eNB_id][0]->rx_dft_stats,"[eNB][rx_dft]");
-    print_meas (&PHY_vars_eNB_g[eNB_id][0]->ulsch_demodulation_stats,
+    //    print_meas (&RC.eNB[eNB_id][0]->ofdm_demod_stats,
+    //                "[eNB][ofdm_demod]", &oaisim_stats, &oaisim_stats_f);
+    //print_meas(&RC.eNB[eNB_id][0]->ulsch_channel_estimation_stats,"[eNB][channel_est]");
+    //print_meas(&RC.eNB[eNB_id][0]->ulsch_freq_offset_estimation_stats,"[eNB][freq_offset]");
+    //print_meas(&RC.eNB[eNB_id][0]->rx_dft_stats,"[eNB][rx_dft]");
+    print_meas (&RC.eNB[eNB_id][0]->ulsch_demodulation_stats,
                 "[eNB][demodulation]", &oaisim_stats, &oaisim_stats_f);
-    print_meas (&PHY_vars_eNB_g[eNB_id][0]->ulsch_decoding_stats,
+    print_meas (&RC.eNB[eNB_id][0]->ulsch_decoding_stats,
                 "[eNB][decoding]", &oaisim_stats, &oaisim_stats_f);
-    print_meas (&PHY_vars_eNB_g[eNB_id][0]->ulsch_deinterleaving_stats,
+    print_meas (&RC.eNB[eNB_id][0]->ulsch_deinterleaving_stats,
                 "[eNB][|_deinterleaving]", &oaisim_stats, &oaisim_stats_f);
-    print_meas (&PHY_vars_eNB_g[eNB_id][0]->ulsch_demultiplexing_stats,
+    print_meas (&RC.eNB[eNB_id][0]->ulsch_demultiplexing_stats,
                 "[eNB][|_demultiplexing]", &oaisim_stats, &oaisim_stats_f);
-    print_meas (&PHY_vars_eNB_g[eNB_id][0]->ulsch_rate_unmatching_stats,
+    print_meas (&RC.eNB[eNB_id][0]->ulsch_rate_unmatching_stats,
                 "[eNB][|_rate_unmatching]", &oaisim_stats, &oaisim_stats_f);
-    print_meas (&PHY_vars_eNB_g[eNB_id][0]->ulsch_turbo_decoding_stats,
+    print_meas (&RC.eNB[eNB_id][0]->ulsch_turbo_decoding_stats,
                 "[eNB][|_turbo_decoding]", &oaisim_stats, &oaisim_stats_f);
-    print_meas (&PHY_vars_eNB_g[eNB_id][0]->ulsch_tc_init_stats,
+    print_meas (&RC.eNB[eNB_id][0]->ulsch_tc_init_stats,
                 "[eNB][ |_tc_init]", &oaisim_stats, &oaisim_stats_f);
-    print_meas (&PHY_vars_eNB_g[eNB_id][0]->ulsch_tc_alpha_stats,
+    print_meas (&RC.eNB[eNB_id][0]->ulsch_tc_alpha_stats,
                 "[eNB][ |_tc_alpha]", &oaisim_stats, &oaisim_stats_f);
-    print_meas (&PHY_vars_eNB_g[eNB_id][0]->ulsch_tc_beta_stats,
+    print_meas (&RC.eNB[eNB_id][0]->ulsch_tc_beta_stats,
                 "[eNB][ |_tc_beta]", &oaisim_stats, &oaisim_stats_f);
-    print_meas (&PHY_vars_eNB_g[eNB_id][0]->ulsch_tc_gamma_stats,
+    print_meas (&RC.eNB[eNB_id][0]->ulsch_tc_gamma_stats,
                 "[eNB][ |_tc_gamma]", &oaisim_stats, &oaisim_stats_f);
-    print_meas (&PHY_vars_eNB_g[eNB_id][0]->ulsch_tc_ext_stats,
+    print_meas (&RC.eNB[eNB_id][0]->ulsch_tc_ext_stats,
                 "[eNB][ |_tc_ext]", &oaisim_stats, &oaisim_stats_f);
-    print_meas (&PHY_vars_eNB_g[eNB_id][0]->ulsch_tc_intl1_stats,
+    print_meas (&RC.eNB[eNB_id][0]->ulsch_tc_intl1_stats,
                 "[eNB][ |_tc_intl1]", &oaisim_stats, &oaisim_stats_f);
-    print_meas (&PHY_vars_eNB_g[eNB_id][0]->ulsch_tc_intl2_stats,
+    print_meas (&RC.eNB[eNB_id][0]->ulsch_tc_intl2_stats,
                 "[eNB][ |_tc_intl2]", &oaisim_stats, &oaisim_stats_f);
 
-    print_meas (&PHY_vars_eNB_g[eNB_id][0]->rx_prach, "[eNB][rx_prach]",
+    print_meas (&RC.eNB[eNB_id][0]->rx_prach, "[eNB][rx_prach]",
                 &oaisim_stats, &oaisim_stats_f);
 
 #ifdef LOCALIZATION
-    print_meas(&PHY_vars_eNB_g[eNB_id][0]->localization_stats, "[eNB][LOCALIZATION]",&oaisim_stats,&oaisim_stats_f);
+    print_meas(&RC.eNB[eNB_id][0]->localization_stats, "[eNB][LOCALIZATION]",&oaisim_stats,&oaisim_stats_f);
 #endif
   }
 
@@ -1714,24 +1745,24 @@ print_opp_meas_oaisim (void)
 
   for (eNB_id = 0; eNB_id < NB_eNB_INST; eNB_id++) {
 
-    print_meas (&eNB_mac_inst[eNB_id].eNB_scheduler, "[eNB][mac_scheduler]",
+    print_meas (&RC.mac[eNB_id]->eNB_scheduler, "[eNB][mac_scheduler]",
                 &oaisim_stats, &oaisim_stats_f);
-    print_meas (&eNB_mac_inst[eNB_id].schedule_si, "[eNB][DL][SI]",
+    print_meas (&RC.mac[eNB_id]->schedule_si, "[eNB][DL][SI]",
                 &oaisim_stats, &oaisim_stats_f);
-    print_meas (&eNB_mac_inst[eNB_id].schedule_ra, "[eNB][DL][RA]",
+    print_meas (&RC.mac[eNB_id]->schedule_ra, "[eNB][DL][RA]",
                 &oaisim_stats, &oaisim_stats_f);
-    print_meas (&eNB_mac_inst[eNB_id].fill_DLSCH_dci,
+    print_meas (&RC.mac[eNB_id]->fill_DLSCH_dci,
                 "[eNB][DL/UL][fill_DCI]", &oaisim_stats, &oaisim_stats_f);
-    print_meas (&eNB_mac_inst[eNB_id].schedule_dlsch_preprocessor,
+    print_meas (&RC.mac[eNB_id]->schedule_dlsch_preprocessor,
                 "[eNB][DL][preprocessor]", &oaisim_stats, &oaisim_stats_f);
-    print_meas (&eNB_mac_inst[eNB_id].schedule_dlsch,
+    print_meas (&RC.mac[eNB_id]->schedule_dlsch,
                 "[eNB][DL][schedule_tx_dlsch]", &oaisim_stats,
                 &oaisim_stats_f);
-    print_meas (&eNB_mac_inst[eNB_id].schedule_mch, "[eNB][DL][mch]",
+    print_meas (&RC.mac[eNB_id]->schedule_mch, "[eNB][DL][mch]",
                 &oaisim_stats, &oaisim_stats_f);
-    print_meas (&eNB_mac_inst[eNB_id].schedule_ulsch, "[eNB][UL][ULSCH]",
+    print_meas (&RC.mac[eNB_id]->schedule_ulsch, "[eNB][UL][ULSCH]",
                 &oaisim_stats, &oaisim_stats_f);
-    print_meas (&eNB_mac_inst[eNB_id].rx_ulsch_sdu,
+    print_meas (&RC.mac[eNB_id]->rx_ulsch_sdu,
                 "[eNB][UL][rx_ulsch_sdu]", &oaisim_stats, &oaisim_stats_f);
 
     print_meas (&eNB_pdcp_stats[eNB_id].pdcp_run, "[eNB][pdcp_run]",
@@ -1922,7 +1953,7 @@ oai_shutdown (void)
 eNB_MAC_INST*
 get_eNB_mac_inst (module_id_t module_idP)
 {
-  return (&eNB_mac_inst[module_idP]);
+  return (RC.mac[module_idP]);
 }
 
 OAI_Emulation*
diff --git a/targets/SIMU/USER/oaisim.h b/targets/SIMU/USER/oaisim.h
index d68e34462e..d405e0493b 100644
--- a/targets/SIMU/USER/oaisim.h
+++ b/targets/SIMU/USER/oaisim.h
@@ -42,13 +42,13 @@ eNB_MAC_INST* get_eNB_mac_inst(module_id_t module_idP);
 OAI_Emulation* get_OAI_emulation(void);
 void init_channel_vars(LTE_DL_FRAME_PARMS *frame_parms, double ***s_re,double ***s_im,double ***r_re,double ***r_im,double ***r_re0,double ***r_im0);
 
-void do_UL_sig(channel_desc_t *UE2eNB[NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX][MAX_NUM_CCs],
-               node_desc_t *enb_data[NUMBER_OF_eNB_MAX],node_desc_t *ue_data[NUMBER_OF_UE_MAX],
+void do_UL_sig(channel_desc_t *UE2RU[NUMBER_OF_UE_MAX][NUMBER_OF_RU_MAX][MAX_NUM_CCs],
+               node_desc_t *enb_data[NUMBER_OF_RU_MAX],node_desc_t *ue_data[NUMBER_OF_UE_MAX],
 	       uint16_t subframe,uint8_t abstraction_flag,LTE_DL_FRAME_PARMS *frame_parms, 
 	       uint32_t frame,int eNB_id,uint8_t CC_id);
 
-void do_DL_sig(channel_desc_t *eNB2UE[NUMBER_OF_eNB_MAX][NUMBER_OF_UE_MAX][MAX_NUM_CCs],
-               node_desc_t *enb_data[NUMBER_OF_eNB_MAX],node_desc_t *ue_data[NUMBER_OF_UE_MAX],uint16_t subframe,uint8_t abstraction_flag,LTE_DL_FRAME_PARMS *frame_parms,uint8_t UE_id,int CC_id);
+void do_DL_sig(channel_desc_t *RU2UE[NUMBER_OF_RU_MAX][NUMBER_OF_UE_MAX][MAX_NUM_CCs],
+               node_desc_t *enb_data[NUMBER_OF_RU_MAX],node_desc_t *ue_data[NUMBER_OF_UE_MAX],uint16_t subframe,uint8_t abstraction_flag,LTE_DL_FRAME_PARMS *frame_parms,uint8_t UE_id,int CC_id);
 
 void init_ue(node_desc_t  *ue_data, UE_Antenna ue_ant);//Abstraction changes
 void init_enb(node_desc_t  *enb_data, eNB_Antenna enb_ant);//Abstraction changes
diff --git a/targets/SIMU/USER/oaisim_config.c b/targets/SIMU/USER/oaisim_config.c
index e3aac4f481..cc8e7370fa 100644
--- a/targets/SIMU/USER/oaisim_config.c
+++ b/targets/SIMU/USER/oaisim_config.c
@@ -247,7 +247,8 @@ void init_oai_emulation(void)
   oai_emulation.info.first_rn_local=0;
   oai_emulation.info.master_id=0;
   oai_emulation.info.nb_ue_local= 1;//default 1 UE
-  oai_emulation.info.nb_enb_local= 1;//default 1 eNB
+  oai_emulation.info.nb_enb_local= 0;//default 0 eNB (to be loaded from config)
+  oai_emulation.info.nb_ru_local= 0;//default 0 ru (to be loaded from config)
   oai_emulation.info.nb_rn_local= 0;//default 0 RN : currently only applicable for eMBMS
   oai_emulation.info.ethernet_flag=0;
   oai_emulation.info.ocm_enabled=1;// flag ?
diff --git a/targets/SIMU/USER/oaisim_functions.c b/targets/SIMU/USER/oaisim_functions.c
index 7fa29843be..163c141dcb 100644
--- a/targets/SIMU/USER/oaisim_functions.c
+++ b/targets/SIMU/USER/oaisim_functions.c
@@ -91,7 +91,6 @@ extern char smbv_ip[16];
 #define K 2                  // averaging coefficient
 #define TARGET_SF_TIME_NS 1000000       // 1ms = 1000000 ns
 
-#define min(a,b) ((a)<(b)?(a):(b))
 
 int           otg_times             = 0;
 int           if_times              = 0;
@@ -115,7 +114,7 @@ uint8_t            beta_ACK              = 0;
 uint8_t            beta_RI               = 0;
 uint8_t            beta_CQI              = 2;
 uint8_t            target_ul_mcs         = 16;
-LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs];
+//LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs];
 int           map1,map2;
 double      **ShaF                  = NULL;
 // pointers signal buffers (s = transmit, r,r0 = receive)
@@ -155,10 +154,10 @@ char tdd_config[10];
 
 Packet_OTG_List_t *otg_pdcp_buffer = NULL;
 
-extern node_desc_t *enb_data[NUMBER_OF_eNB_MAX];
+extern node_desc_t *enb_data[NUMBER_OF_RU_MAX];
 extern node_desc_t *ue_data[NUMBER_OF_UE_MAX];
-extern channel_desc_t *eNB2UE[NUMBER_OF_eNB_MAX][NUMBER_OF_UE_MAX][MAX_NUM_CCs];
-extern channel_desc_t *UE2eNB[NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX][MAX_NUM_CCs];
+extern channel_desc_t *RU2UE[NUMBER_OF_RU_MAX][NUMBER_OF_UE_MAX][MAX_NUM_CCs];
+extern channel_desc_t *UE2RU[NUMBER_OF_UE_MAX][NUMBER_OF_RU_MAX][MAX_NUM_CCs];
 
 extern mapping small_scale_names[];
 #if defined(Rel10)
@@ -175,19 +174,12 @@ extern int xforms;
 extern uint32_t          downlink_frequency[MAX_NUM_CCs][4];
 extern int32_t           uplink_frequency_offset[MAX_NUM_CCs][4];
 
-eth_params_t *eth_params;
-
-void init_eNB(eNB_func_t node_function[], eNB_timing_t node_timing[],int nb_inst,eth_params_t *,int,int);
-void stop_eNB(int nb_inst);
-
-const Enb_properties_array_t *enb_properties;
-
 int oaisim_flag=1;
 
+
 void get_simulation_options(int argc, char *argv[])
 {
   int                           option;
-  char  *conf_config_file_name = NULL;
 
   enum long_option_e {
     LONG_OPTION_START = 0x100, /* Start after regular single char options */
@@ -279,9 +271,9 @@ void get_simulation_options(int argc, char *argv[])
 
     case LONG_OPTION_ENB_CONF:
       if (optarg) {
-        free(conf_config_file_name); // prevent memory leak if option is used multiple times
-        conf_config_file_name = strdup(optarg);
-        printf("eNB configuration file is %s\n", conf_config_file_name);
+        free(RC.config_file_name); // prevent memory leak if option is used multiple times
+        RC.config_file_name = strdup(optarg);
+        printf("eNB configuration file is %s\n", RC.config_file_name);
       }
 
       break;
@@ -609,8 +601,8 @@ void get_simulation_options(int argc, char *argv[])
 
     case 'O':
       if (optarg) {
-        free(conf_config_file_name); // prevent memory leak if option is used multiple times
-        conf_config_file_name = strdup(optarg);
+        free(RC.config_file_name); // prevent memory leak if option is used multiple times
+        RC.config_file_name = strdup(optarg);
       }
 
       break;
@@ -789,55 +781,68 @@ void get_simulation_options(int argc, char *argv[])
     }
   }
 
-  if ((oai_emulation.info.nb_enb_local > 0) && (conf_config_file_name != NULL)) {
+  
+  if (RC.config_file_name != NULL) {
     /* Read eNB configuration file */
-    enb_properties = enb_config_init(conf_config_file_name);
-
-    AssertFatal (oai_emulation.info.nb_enb_local <= enb_properties->number,
-                 "Number of eNB is greater than eNB defined in configuration file %s (%d/%d)!",
-                 conf_config_file_name, oai_emulation.info.nb_enb_local, enb_properties->number);
-
-    eth_params = (eth_params_t*)malloc(enb_properties->properties[0]->nb_rrh_gw * sizeof(eth_params_t));
-    memset(eth_params, 0, enb_properties->properties[0]->nb_rrh_gw * sizeof(eth_params_t));
-    
-    for (int j=0; j<enb_properties->properties[0]->nb_rrh_gw; j++) {
+    RCConfig(RC.config_file_name);
+    printf("returned with %d eNBs, %d rus\n",RC.nb_inst,RC.nb_RU);
+    oai_emulation.info.nb_enb_local = RC.nb_inst;
+    oai_emulation.info.nb_ru_local = RC.nb_RU;
+   
+    /*    
+    for (int j=0; j<enb_properties->nb_ru; j++) {
       
-      if (enb_properties->properties[0]->rrh_gw_config[j].active == 1 ) {
-	//	local_remote_radio = BBU_REMOTE_RADIO_HEAD;
-	(eth_params+j)->local_if_name             = enb_properties->properties[0]->rrh_gw_config[j].rrh_gw_if_name;
-	(eth_params+j)->my_addr                   = enb_properties->properties[0]->rrh_gw_config[j].local_address;
-	(eth_params+j)->my_port                   = enb_properties->properties[0]->rrh_gw_config[j].local_port;
-	(eth_params+j)->remote_addr               = enb_properties->properties[0]->rrh_gw_config[j].remote_address;
-	(eth_params+j)->remote_port               = enb_properties->properties[0]->rrh_gw_config[j].remote_port;
-        
-	if (enb_properties->properties[0]->rrh_gw_config[j].raw == 1) {
-	  (eth_params+j)->transp_preference       = ETH_RAW_MODE; 
-	} else if (enb_properties->properties[0]->rrh_gw_config[j].rawif4p5 == 1) {
-	  (eth_params+j)->transp_preference       = ETH_RAW_IF4p5_MODE;             
-	} else if (enb_properties->properties[0]->rrh_gw_config[j].udpif4p5 == 1) {
-	  (eth_params+j)->transp_preference       = ETH_UDP_IF4p5_MODE;             
-	} else if (enb_properties->properties[0]->rrh_gw_config[j].rawif5_mobipass == 1) {
-	  (eth_params+j)->transp_preference       = ETH_RAW_IF5_MOBIPASS;             
-	} else {
-	  (eth_params+j)->transp_preference       = ETH_UDP_MODE;	 
-	}
+      //	local_remote_radio = BBU_REMOTE_RADIO_HEAD;
+      (eth_params+j)->local_if_name             = enb_properties->ru_config[j]->ru_if_name;
+      (eth_params+j)->my_addr                   = enb_properties->ru_config[j]->local_address;
+      (eth_params+j)->my_port                   = enb_properties->ru_config[j]->local_port;
+      (eth_params+j)->remote_addr               = enb_properties->ru_config[j]->remote_address;
+      (eth_params+j)->remote_port               = enb_properties->ru_config[j]->remote_port;
+      
+      if (enb_properties->ru_config[j]->raw == 1) {
+	(eth_params+j)->transp_preference       = ETH_RAW_MODE;
+	ru_if_in[j] = REMOTE_IF5;
+	node_function[j] = NGFI_RRU_IF5;
+      } else if (enb_properties->ru_config[j]->rawif4p5 == 1) {
+	(eth_params+j)->transp_preference       = ETH_RAW_IF4p5_MODE;
+	ru_if_in[j] = REMOTE_IF4p5;    
+	node_function[j] = NGFI_RRU_IF4p5; 
+      } else if (enb_properties->ru_config[j]->udpif4p5 == 1) {
+	(eth_params+j)->transp_preference       = ETH_UDP_IF4p5_MODE;
+	ru_if_in[j] = REMOTE_IF4p5;    
+	node_function[j] = NGFI_RRU_IF4p5;         
+      } else if (enb_properties->ru_config[j]->rawif5_mobipass == 1) {
+	(eth_params+j)->transp_preference       = ETH_RAW_IF5_MOBIPASS;             
+	ru_if_in[j] = REMOTE_IF5;      
+	LOG_E(EMU,"Don't use 8-bit IF5 format with oaisim, please change in configuration file\n");
+      } else {
+	(eth_params+j)->transp_preference       = ETH_UDP_MODE;	 
+	ru_if_in[j] = REMOTE_IF5;            
+	node_function[j] = NGFI_RRU_IF5;
       }
-    }
-    /* Update some simulation parameters */
-    oai_emulation.info.frame_type[0]           = enb_properties->properties[0]->frame_type[0];
-    oai_emulation.info.tdd_config[0]           = enb_properties->properties[0]->tdd_config[0];
-    oai_emulation.info.tdd_config_S[0]         = enb_properties->properties[0]->tdd_config_s[0];
-    oai_emulation.info.extended_prefix_flag[0] = enb_properties->properties[0]->prefix_type[0];
-
-    oai_emulation.info.node_function[0]        = enb_properties->properties[0]->cc_node_function[0];
-    oai_emulation.info.node_timing[0]          = enb_properties->properties[0]->cc_node_timing[0];
-    downlink_frequency[0][0]                   = enb_properties->properties[0]->downlink_frequency[0];
-    uplink_frequency_offset[0][0]              = enb_properties->properties[0]->uplink_frequency_offset[0];
-    oai_emulation.info.N_RB_DL[0]              = enb_properties->properties[0]->N_RB_DL[0];
+      node_timing[j] = synch_to_ext_device;
+
+      if (enb_properties->number > 0) {
+	//Update some simulation parameters 
+	oai_emulation.info.frame_type[0]           = enb_properties->properties[0]->frame_type[0];
+	oai_emulation.info.tdd_config[0]           = enb_properties->properties[0]->tdd_config[0];
+	oai_emulation.info.tdd_config_S[0]         = enb_properties->properties[0]->tdd_config_s[0];
+	oai_emulation.info.extended_prefix_flag[0] = enb_properties->properties[0]->prefix_type[0];
+	
+	oai_emulation.info.node_function[0]        = enb_properties->properties[0]->cc_node_function[0];
+	oai_emulation.info.node_timing[0]          = enb_properties->properties[0]->cc_node_timing[0];
+	downlink_frequency[0][0]                   = enb_properties->properties[0]->downlink_frequency[0];
+	uplink_frequency_offset[0][0]              = enb_properties->properties[0]->uplink_frequency_offset[0];
+	oai_emulation.info.N_RB_DL[0]              = enb_properties->properties[0]->N_RB_DL[0];
+	LOG_E(EMU,"Please use only RRU with oaisim, remove eNB descriptors in configuration file\n");
+	exit(-1);
+      }
+      }*/
+  }
+  else {
+    printf("Please provide a configuration file\n");
+    exit(-1);
   }
-
-  free(conf_config_file_name);
-  conf_config_file_name = 0;
 }
 
 void check_and_adjust_params(void)
@@ -910,6 +915,7 @@ void check_and_adjust_params(void)
   NB_UE_INST = oai_emulation.info.nb_ue_local + oai_emulation.info.nb_ue_remote;
   NB_eNB_INST = oai_emulation.info.nb_enb_local + oai_emulation.info.nb_enb_remote;
   NB_RN_INST = oai_emulation.info.nb_rn_local + oai_emulation.info.nb_rn_remote;
+  NB_RU = oai_emulation.info.nb_ru_local + oai_emulation.info.nb_ru_remote;
 
 #if defined(PDCP_USE_NETLINK_QUEUES) && defined(OPENAIR2)
   pdcp_netlink_init();
@@ -994,35 +1000,35 @@ void init_seed(uint8_t set_seed)
   }
 }
 
-openair0_timestamp current_eNB_rx_timestamp[NUMBER_OF_eNB_MAX][MAX_NUM_CCs];
+openair0_timestamp current_ru_rx_timestamp[NUMBER_OF_RU_MAX][MAX_NUM_CCs];
 openair0_timestamp current_UE_rx_timestamp[NUMBER_OF_UE_MAX][MAX_NUM_CCs];
-openair0_timestamp last_eNB_rx_timestamp[NUMBER_OF_eNB_MAX][MAX_NUM_CCs];
+openair0_timestamp last_ru_rx_timestamp[NUMBER_OF_RU_MAX][MAX_NUM_CCs];
 openair0_timestamp last_UE_rx_timestamp[NUMBER_OF_UE_MAX][MAX_NUM_CCs];
 
-int eNB_trx_start(openair0_device *device) {
+int ru_trx_start(openair0_device *device) {
   return(0);
 }
 
-void eNB_trx_end(openair0_device *device) {
+void ru_trx_end(openair0_device *device) {
   return;
 }
 
-int eNB_trx_stop(openair0_device *device) {
+int ru_trx_stop(openair0_device *device) {
   return(0);
 }
 int UE_trx_start(openair0_device *device) {
   return(0);
 }
-int UE_trx_end(openair0_device *device) {
-  return(0);
+void UE_trx_end(openair0_device *device) {
+  return;
 }
 int UE_trx_stop(openair0_device *device) {
   return(0);
 }
-int eNB_trx_set_freq(openair0_device *device, openair0_config_t *openair0_cfg, int dummy) {
+int ru_trx_set_freq(openair0_device *device, openair0_config_t *openair0_cfg, int dummy) {
   return(0);
 }
-int eNB_trx_set_gains(openair0_device *device, openair0_config_t *openair0_cfg) {
+int ru_trx_set_gains(openair0_device *device, openair0_config_t *openair0_cfg) {
   return(0);
 }
 int UE_trx_set_freq(openair0_device *device, openair0_config_t *openair0_cfg, int dummy) {
@@ -1033,53 +1039,53 @@ int UE_trx_set_gains(openair0_device *device, openair0_config_t *openair0_cfg) {
 }
 
 extern pthread_mutex_t subframe_mutex;
-extern int subframe_eNB_mask,subframe_UE_mask;
+extern int subframe_ru_mask,subframe_UE_mask;
 
-int eNB_trx_read(openair0_device *device, openair0_timestamp *ptimestamp, void **buff, int nsamps, int cc) {
+int ru_trx_read(openair0_device *device, openair0_timestamp *ptimestamp, void **buff, int nsamps, int cc) {
 
-  int eNB_id = device->Mod_id;
+  int ru_id  = device->Mod_id;
   int CC_id  = device->CC_id;
 
   int subframe;
   int sample_count=0;
 
-  *ptimestamp = last_eNB_rx_timestamp[eNB_id][CC_id];
+  *ptimestamp = last_ru_rx_timestamp[ru_id][CC_id];
 
-  LOG_D(EMU,"eNB_trx_read nsamps %d TS(%llu,%llu) => subframe %d\n",nsamps,
-        (unsigned long long)current_eNB_rx_timestamp[eNB_id][CC_id],
-        (unsigned long long)last_eNB_rx_timestamp[eNB_id][CC_id],
-	(*ptimestamp/PHY_vars_eNB_g[eNB_id][CC_id]->frame_parms.samples_per_tti)%10);
-  // if we're at a subframe boundary generate UL signals for this eNB
+  LOG_D(EMU,"RU_trx_read nsamps %d TS(%llu,%llu) => subframe %d\n",nsamps,
+        (unsigned long long)current_ru_rx_timestamp[ru_id][CC_id],
+        (unsigned long long)last_ru_rx_timestamp[ru_id][CC_id],
+	(int)((*ptimestamp/RC.ru[ru_id]->frame_parms.samples_per_tti)%10));
+  // if we're at a subframe boundary generate UL signals for this ru
 
   while (sample_count<nsamps) {
-    while (current_eNB_rx_timestamp[eNB_id][CC_id]<
-	   (nsamps+last_eNB_rx_timestamp[eNB_id][CC_id])) {
-      //      LOG_D(EMU,"eNB: current TS %llu, last TS %llu, sleeping\n",current_eNB_rx_timestamp[eNB_id][CC_id],last_eNB_rx_timestamp[eNB_id][CC_id]);
+    while (current_ru_rx_timestamp[ru_id][CC_id]<
+	   (nsamps+last_ru_rx_timestamp[ru_id][CC_id])) {
+      LOG_D(EMU,"eNB: current TS %llu, last TS %llu, sleeping\n",current_ru_rx_timestamp[ru_id][CC_id],last_ru_rx_timestamp[ru_id][CC_id]);
       usleep(500);
     }
 
     // tell top-level we are busy
     pthread_mutex_lock(&subframe_mutex);
-    subframe_eNB_mask|=(1<<eNB_id);
+    subframe_ru_mask|=(1<<ru_id);
     pthread_mutex_unlock(&subframe_mutex); 
     
-    subframe = (last_eNB_rx_timestamp[eNB_id][CC_id]/PHY_vars_eNB_g[eNB_id][CC_id]->frame_parms.samples_per_tti)%10;
-    LOG_D(EMU,"eNB_trx_read generating UL subframe %d (Ts %llu, current TS %llu)\n",
+    subframe = (last_ru_rx_timestamp[ru_id][CC_id]/RC.ru[ru_id]->frame_parms.samples_per_tti)%10;
+    LOG_D(EMU,"RU_trx_read generating UL subframe %d (Ts %llu, current TS %llu)\n",
 	  subframe,(unsigned long long)*ptimestamp,
-	  (unsigned long long)current_eNB_rx_timestamp[eNB_id][CC_id]);
+	  (unsigned long long)current_ru_rx_timestamp[ru_id][CC_id]);
     
-    do_UL_sig(UE2eNB,
+    do_UL_sig(UE2RU,
 	      enb_data,
 	      ue_data,
 	      subframe,
 	      0,  // abstraction_flag
-	      &PHY_vars_eNB_g[eNB_id][CC_id]->frame_parms,
+	      &RC.ru[ru_id]->frame_parms,
 	      0,  // frame is only used for abstraction
-	      eNB_id,
+	      ru_id,
 	      CC_id);
   
-    last_eNB_rx_timestamp[eNB_id][CC_id] += PHY_vars_eNB_g[eNB_id][CC_id]->frame_parms.samples_per_tti;
-    sample_count += PHY_vars_eNB_g[eNB_id][CC_id]->frame_parms.samples_per_tti;
+    last_ru_rx_timestamp[ru_id][CC_id] += RC.ru[ru_id]->frame_parms.samples_per_tti;
+    sample_count += RC.ru[ru_id]->frame_parms.samples_per_tti;
   }
   
 
@@ -1137,7 +1143,7 @@ int UE_trx_read(openair0_device *device, openair0_timestamp *ptimestamp, void **
     LOG_D(PHY,"UE_trx_read generating DL subframe %d (Ts %llu, current TS %llu)\n",
 	  subframe,(unsigned long long)*ptimestamp,
 	  (unsigned long long)current_UE_rx_timestamp[UE_id][CC_id]);    
-    do_DL_sig(eNB2UE,
+    do_DL_sig(RU2UE,
 	      enb_data,
 	      ue_data,
 	      subframe,
@@ -1153,7 +1159,7 @@ int UE_trx_read(openair0_device *device, openair0_timestamp *ptimestamp, void **
   return(nsamps);
 }
 
-int eNB_trx_write(openair0_device *device,openair0_timestamp timestamp, void **buff, int nsamps, int cc, int flags) {
+int ru_trx_write(openair0_device *device,openair0_timestamp timestamp, void **buff, int nsamps, int cc, int flags) {
 
   return(nsamps);
 }
@@ -1163,10 +1169,11 @@ int UE_trx_write(openair0_device *device,openair0_timestamp timestamp, void **bu
   return(nsamps);
 }
 
-void init_openair0(void);
+//void init_openair0(void);
 
-openair0_config_t openair0_cfg[MAX_CARDS];
+//openair0_config_t openair0_cfg[MAX_CARDS];
 
+/*
 void init_openair0() {
 
   int card;
@@ -1219,19 +1226,19 @@ void init_openair0() {
      
     
     printf("HW: Configuring card %d, nb_antennas_tx/rx %d/%d\n",card,
-           PHY_vars_eNB_g[0][0]->frame_parms.nb_antennas_tx,
-           PHY_vars_eNB_g[0][0]->frame_parms.nb_antennas_rx);
+           RC.ru[0]->nb_tx,
+           RC.ru[0]->nb_rx);
     openair0_cfg[card].Mod_id = 0;
 
 
 
     openair0_cfg[card].num_rb_dl=frame_parms[0]->N_RB_DL;
-    openair0_cfg[card].tx_num_channels=min(2,PHY_vars_eNB_g[0][0]->frame_parms.nb_antennas_tx);
-    openair0_cfg[card].rx_num_channels=min(2,PHY_vars_eNB_g[0][0]->frame_parms.nb_antennas_rx);
+    openair0_cfg[card].tx_num_channels=min(2,RC.ru[0]->nb_tx);
+    openair0_cfg[card].rx_num_channels=min(2,RC.ru[0]->nb_rx);
 
     for (i=0; i<4; i++) {
 
-      openair0_cfg[card].rx_gain[i] = PHY_vars_eNB_g[0][0]->rx_total_gain_dB;
+      openair0_cfg[card].rx_gain[i] = RC.ru[0]->rx_total_gain_dB;
       
       printf("Card %d, channel %d, Setting tx_gain %f, rx_gain %f, tx_freq %f, rx_freq %f\n",
              card,i, openair0_cfg[card].tx_gain[i],
@@ -1241,230 +1248,65 @@ void init_openair0() {
     }
   }
 }
+*/
 
 void init_devices(void){
 
-  module_id_t UE_id, eNB_id;
-  uint8_t CC_id;
-
-  for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
-    for (eNB_id=0;eNB_id<NB_eNB_INST;eNB_id++) {
-      PHY_vars_eNB_g[eNB_id][CC_id]->rfdevice.Mod_id             = eNB_id;
-      PHY_vars_eNB_g[eNB_id][CC_id]->rfdevice.CC_id              = CC_id;
-      PHY_vars_eNB_g[eNB_id][CC_id]->rfdevice.trx_start_func     = eNB_trx_start;
-      PHY_vars_eNB_g[eNB_id][CC_id]->rfdevice.trx_read_func      = eNB_trx_read;
-      PHY_vars_eNB_g[eNB_id][CC_id]->rfdevice.trx_write_func     = eNB_trx_write;
-      PHY_vars_eNB_g[eNB_id][CC_id]->rfdevice.trx_end_func       = eNB_trx_end;
-      PHY_vars_eNB_g[eNB_id][CC_id]->rfdevice.trx_stop_func      = eNB_trx_stop;
-      PHY_vars_eNB_g[eNB_id][CC_id]->rfdevice.trx_set_freq_func  = eNB_trx_set_freq;
-      PHY_vars_eNB_g[eNB_id][CC_id]->rfdevice.trx_set_gains_func = eNB_trx_set_gains;
-      current_eNB_rx_timestamp[eNB_id][CC_id] = PHY_vars_eNB_g[eNB_id][CC_id]->frame_parms.samples_per_tti;
-      last_eNB_rx_timestamp[eNB_id][CC_id] = 0;
-    }
-    for (UE_id=0;UE_id<NB_UE_INST;UE_id++) {
-      PHY_vars_UE_g[UE_id][CC_id]->rfdevice.Mod_id               = UE_id;
-      PHY_vars_UE_g[UE_id][CC_id]->rfdevice.CC_id                = CC_id;
-      PHY_vars_UE_g[UE_id][CC_id]->rfdevice.trx_start_func       = UE_trx_start;
-      PHY_vars_UE_g[UE_id][CC_id]->rfdevice.trx_read_func        = UE_trx_read;
-      PHY_vars_UE_g[UE_id][CC_id]->rfdevice.trx_write_func       = UE_trx_write;
-      PHY_vars_UE_g[UE_id][CC_id]->rfdevice.trx_end_func         = UE_trx_end;
-      PHY_vars_UE_g[UE_id][CC_id]->rfdevice.trx_stop_func        = UE_trx_stop;
-      PHY_vars_UE_g[UE_id][CC_id]->rfdevice.trx_set_freq_func    = UE_trx_set_freq;
-      PHY_vars_UE_g[UE_id][CC_id]->rfdevice.trx_set_gains_func   = UE_trx_set_gains;
-      current_UE_rx_timestamp[UE_id][CC_id] = PHY_vars_UE_g[UE_id][CC_id]->frame_parms.samples_per_tti;
-      last_UE_rx_timestamp[UE_id][CC_id] = 0;
-
-    }
-  }
-}
-
-void init_openair1(void)
-{
-  module_id_t UE_id, eNB_id;
+  module_id_t UE_id, ru_id;
   uint8_t CC_id;
-#if ENABLE_RAL
-  int list_index;
-#endif
-
-  // change the nb_connected_eNB
-  for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
-    init_lte_vars (&frame_parms[CC_id], 
-		   oai_emulation.info.frame_type[CC_id], 
-		   oai_emulation.info.tdd_config[CC_id], 
-		   oai_emulation.info.tdd_config_S[CC_id],
-		   oai_emulation.info.extended_prefix_flag[CC_id],
-                   oai_emulation.info.N_RB_DL[CC_id], 
-		   enb_properties->properties[0]->Nid_cell[CC_id], 
-		   cooperation_flag, 
-		   enb_properties->properties[0]->nb_antenna_ports[CC_id], 
-		   abstraction_flag,
-		   enb_properties->properties[0]->nb_antennas_rx[CC_id],
-		   enb_properties->properties[0]->nb_antennas_tx[CC_id],
-		   nb_antennas_rx_ue,
-		   oai_emulation.info.eMBMS_active_state);
-
-    // This is for IF4p5 RRU, gets done by RRC configuration of eNB
-    PHY_vars_eNB_g[eNB_id][CC_id]->frame_parms.prach_config_common.prach_ConfigInfo.prach_ConfigIndex = enb_properties->properties[0]->prach_config_index[CC_id];
-    PHY_vars_eNB_g[eNB_id][CC_id]->frame_parms.prach_config_common.prach_ConfigInfo.prach_FreqOffset  = enb_properties->properties[0]->prach_freq_offset[CC_id];
-
+  RU_t *ru;
+
+  // allocate memory for RU if not already done
+  if (RC.ru==NULL) RC.ru = (RU_t**)malloc(RC.nb_RU*sizeof(RU_t*));
+
+  for (ru_id=0;ru_id<RC.nb_RU;ru_id++) {
+    LOG_I(EMU,"Initiaizing rfdevice for RU %d\n",ru_id);
+    if (RC.ru[ru_id]==NULL) RC.ru[ru_id] = (RU_t*)malloc(sizeof(RU_t));
+    ru               = RC.ru[ru_id];
+    ru->rfdevice.Mod_id             = ru_id;
+    ru->rfdevice.CC_id              = 0;
+    ru->rfdevice.trx_start_func     = ru_trx_start;
+    ru->rfdevice.trx_read_func      = ru_trx_read;
+    ru->rfdevice.trx_write_func     = ru_trx_write;
+    ru->rfdevice.trx_end_func       = ru_trx_end;
+    ru->rfdevice.trx_stop_func      = ru_trx_stop;
+    ru->rfdevice.trx_set_freq_func  = ru_trx_set_freq;
+    ru->rfdevice.trx_set_gains_func = ru_trx_set_gains;
+    last_ru_rx_timestamp[ru_id][0] = 0;
   }
-
-  for (eNB_id=0; eNB_id<NB_eNB_INST; eNB_id++) {
-    for (UE_id=0; UE_id<NB_UE_INST; UE_id++) {
-      for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
-        PHY_vars_eNB_g[eNB_id][CC_id]->pusch_config_dedicated[UE_id].betaOffset_ACK_Index = beta_ACK;
-        PHY_vars_eNB_g[eNB_id][CC_id]->pusch_config_dedicated[UE_id].betaOffset_RI_Index  = beta_RI;
-        PHY_vars_eNB_g[eNB_id][CC_id]->pusch_config_dedicated[UE_id].betaOffset_CQI_Index = beta_CQI;
-        PHY_vars_eNB_g[eNB_id][CC_id]->frame_parms.pdsch_config_common.p_b = (frame_parms[CC_id]->nb_antenna_ports_eNB>1) ? 1 : 0; // rho_A = rho_B
-
-        PHY_vars_UE_g[UE_id][CC_id]->pusch_config_dedicated[eNB_id].betaOffset_ACK_Index = beta_ACK;
-        PHY_vars_UE_g[UE_id][CC_id]->pusch_config_dedicated[eNB_id].betaOffset_RI_Index  = beta_RI;
-        PHY_vars_UE_g[UE_id][CC_id]->pusch_config_dedicated[eNB_id].betaOffset_CQI_Index = beta_CQI;
-        PHY_vars_UE_g[UE_id][CC_id]->frame_parms.pdsch_config_common.p_b = (frame_parms[CC_id]->nb_antenna_ports_eNB>1) ? 1 : 0; // rho_A = rho_B
+  if (PHY_vars_UE_g==NULL) {
+    PHY_vars_UE_g = (PHY_VARS_UE ***)malloc((1+NB_UE_INST)*sizeof(PHY_VARS_UE*));
+    for (UE_id=0;UE_id<NB_UE_INST;UE_id++) {
+      PHY_vars_UE_g[UE_id] = (PHY_VARS_UE **)malloc((1+MAX_NUM_CCs)*sizeof(PHY_VARS_UE*));
+      for (CC_id=0;CC_id<MAX_NUM_CCs;CC_id++) {
+	PHY_vars_UE_g[UE_id][CC_id] = (PHY_VARS_UE *)malloc(sizeof(PHY_VARS_UE));
+	PHY_vars_UE_g[UE_id][CC_id]->rfdevice.Mod_id               = UE_id;
+	PHY_vars_UE_g[UE_id][CC_id]->rfdevice.CC_id                = CC_id;
+	PHY_vars_UE_g[UE_id][CC_id]->rfdevice.trx_start_func       = UE_trx_start;
+	PHY_vars_UE_g[UE_id][CC_id]->rfdevice.trx_read_func        = UE_trx_read;
+	PHY_vars_UE_g[UE_id][CC_id]->rfdevice.trx_write_func       = UE_trx_write;
+	PHY_vars_UE_g[UE_id][CC_id]->rfdevice.trx_end_func         = UE_trx_end;
+	PHY_vars_UE_g[UE_id][CC_id]->rfdevice.trx_stop_func        = UE_trx_stop;
+	PHY_vars_UE_g[UE_id][CC_id]->rfdevice.trx_set_freq_func    = UE_trx_set_freq;
+	PHY_vars_UE_g[UE_id][CC_id]->rfdevice.trx_set_gains_func   = UE_trx_set_gains;
+	last_UE_rx_timestamp[UE_id][CC_id] = 0;
+	
       }
     }
   }
-
-  printf ("AFTER init: MAX_NUM_CCs %d, Nid_cell %d frame_type %d,tdd_config %d\n",
-          MAX_NUM_CCs,
-          PHY_vars_eNB_g[0][0]->frame_parms.Nid_cell,
-          PHY_vars_eNB_g[0][0]->frame_parms.frame_type,
-          PHY_vars_eNB_g[0][0]->frame_parms.tdd_config);
-
-  number_of_cards = 1;
-
-//  openair_daq_vars.rx_rf_mode = 1;
-//  openair_daq_vars.tdd = 1;
-//  openair_daq_vars.rx_gain_mode = DAQ_AGC_ON;
-
-//  openair_daq_vars.dlsch_transmission_mode = oai_emulation.info.transmission_mode[0];
-//#warning "NN->FK: OAI EMU channel abstraction does not work for MCS higher than"
-//  openair_daq_vars.target_ue_dl_mcs = cmin(target_dl_mcs,16);
-//  openair_daq_vars.target_ue_ul_mcs = target_ul_mcs;
-//  openair_daq_vars.ue_dl_rb_alloc=0x1fff;
-//  openair_daq_vars.ue_ul_nb_rb=6;
-//  openair_daq_vars.dlsch_rate_adaptation = rate_adaptation_flag;
-
-  //N_TA_offset
-  for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
-    for (UE_id=0; UE_id<NB_UE_INST; UE_id++) {
-
-      PHY_vars_UE_g[UE_id][CC_id]->use_ia_receiver      = 0;
-      PHY_vars_UE_g[UE_id][CC_id]->mode                 = normal_txrx;
-      PHY_vars_UE_g[UE_id][CC_id]->mac_enabled          = 1;
-      PHY_vars_UE_g[UE_id][CC_id]->no_timing_correction = 1;
-
-      if (PHY_vars_UE_g[UE_id][CC_id]->frame_parms.frame_type == TDD) {
-        if (PHY_vars_UE_g[UE_id][CC_id]->frame_parms.N_RB_DL == 100)
-          PHY_vars_UE_g[UE_id][CC_id]->N_TA_offset = 624;
-        else if (PHY_vars_UE_g[UE_id][CC_id]->frame_parms.N_RB_DL == 50)
-          PHY_vars_UE_g[UE_id][CC_id]->N_TA_offset = 624/2;
-        else if (PHY_vars_UE_g[UE_id][CC_id]->frame_parms.N_RB_DL == 25)
-          PHY_vars_UE_g[UE_id][CC_id]->N_TA_offset = 624/4;
-      } else {
-        PHY_vars_UE_g[UE_id][CC_id]->N_TA_offset = 0;
-      }
-    }
-
-    for (eNB_id=0; eNB_id<NB_eNB_INST; eNB_id++) {
-      if (PHY_vars_eNB_g[eNB_id][CC_id]->frame_parms.frame_type == TDD) {
-        if (PHY_vars_eNB_g[eNB_id][CC_id]->frame_parms.N_RB_DL == 100)
-          PHY_vars_eNB_g[eNB_id][CC_id]->N_TA_offset = 624;
-        else if (PHY_vars_eNB_g[eNB_id][CC_id]->frame_parms.N_RB_DL == 50)
-          PHY_vars_eNB_g[eNB_id][CC_id]->N_TA_offset = 624/2;
-        else if (PHY_vars_eNB_g[eNB_id][CC_id]->frame_parms.N_RB_DL == 25)
-          PHY_vars_eNB_g[eNB_id][CC_id]->N_TA_offset = 624/4;
-      } else {
-        PHY_vars_eNB_g[eNB_id][CC_id]->N_TA_offset = 0;
-      }
-    } // eNB_id
-  } // CC_id
-
-  for (eNB_id=0; eNB_id<NB_eNB_INST; eNB_id++) {
-    for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
-      if (phy_test==1)
-	PHY_vars_eNB_g[eNB_id][CC_id]->mac_enabled=0;
-      else
-	PHY_vars_eNB_g[eNB_id][CC_id]->mac_enabled=1;
-    }
-  }
-
-  init_devices ();
-
-  init_eNB(oai_emulation.info.node_function,oai_emulation.info.node_timing,NB_eNB_INST,eth_params,1,0);
-
-  // init_ue_status();
-  for (UE_id=0; UE_id<NB_UE_INST; UE_id++) {
-    for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
-      
-      PHY_vars_UE_g[UE_id][CC_id]->tx_power_max_dBm=10;
-      
-      PHY_vars_UE_g[UE_id][CC_id]->rx_total_gain_dB=100;
-
-      // update UE_mode for each eNB_id not just 0
-      if (abstraction_flag == 0) {
-	if (phy_test==0) PHY_vars_UE_g[UE_id][CC_id]->UE_mode[0] = NOT_SYNCHED;
-	else PHY_vars_UE_g[UE_id][CC_id]->UE_mode[0] = PUSCH;
-      } else {
-        // 0 is the index of the connected eNB
-        PHY_vars_UE_g[UE_id][CC_id]->UE_mode[0] = PRACH;
-      }
-
-      if (phy_test==1)
-	PHY_vars_UE_g[UE_id][CC_id]->mac_enabled=0;
-      else
-	PHY_vars_UE_g[UE_id][CC_id]->mac_enabled=1;
-
-      PHY_vars_UE_g[UE_id][CC_id]->pdcch_vars[0]->crnti = 0x1235 + UE_id;
-      PHY_vars_UE_g[UE_id][CC_id]->current_dlsch_cqi[0] = 10;
-
-      LOG_I(EMU, "UE %d mode is initialized to %d\n", UE_id, PHY_vars_UE_g[UE_id][CC_id]->UE_mode[0] );
-#if ENABLE_RAL
-      PHY_vars_UE_g[UE_id][CC_id]->ral_thresholds_timed = hashtable_create (64, NULL, NULL);
-
-      for (list_index = 0; list_index < RAL_LINK_PARAM_GEN_MAX; list_index++) {
-        SLIST_INIT(&PHY_vars_UE_g[UE_id][CC_id]->ral_thresholds_gen_polled[list_index]);
-      }
-
-      for (list_index = 0; list_index < RAL_LINK_PARAM_LTE_MAX; list_index++) {
-        SLIST_INIT(&PHY_vars_UE_g[UE_id][CC_id]->ral_thresholds_lte_polled[list_index]);
-      }
-
-#endif
-
-    } // CC_id
-  } // UE_id
-  init_UE(NB_UE_INST);
-    }
-
-void init_openair2(void)
-{
-#ifdef OPENAIR2
-  int CC_id;
-//#warning "eNB index is hard coded to zero"
-
-  for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++)
-    l2_init (&PHY_vars_eNB_g[0][CC_id]->frame_parms,
-             oai_emulation.info.eMBMS_active_state,
-             NULL,
-             oai_emulation.info.cba_group_active,
-             oai_emulation.info.handover_active);
-
-  mac_xface->macphy_exit = exit_fun;
-
-#endif
 }
 
 void init_ocm(void)
 {
-  module_id_t UE_id, eNB_id;
+  module_id_t UE_id, ru_id;
   int CC_id;
 
   /* Added for PHY abstraction */
 
   char* frame_type = "unknown";
+  LTE_DL_FRAME_PARMS *fp = &RC.ru[0]->frame_parms;
 
-  switch (oai_emulation.info.frame_type[0]) {
+  switch (fp->frame_type) {
   case FDD:
     frame_type = "FDD";
     break;
@@ -1474,10 +1316,6 @@ void init_ocm(void)
     break;
   }
 
-  LOG_I(OCM,"Running with frame_type %d (%s), Nid_cell %d, N_RB_DL %d, EP %d, mode %d, target dl_mcs %d, rate adaptation %d, nframes %d, abstraction %d, channel %s\n",
-        oai_emulation.info.frame_type[0], frame_type, Nid_cell, oai_emulation.info.N_RB_DL[0], oai_emulation.info.extended_prefix_flag[0], oai_emulation.info.transmission_mode[0],target_dl_mcs,
-        rate_adaptation_flag,oai_emulation.info.n_frames,abstraction_flag,oai_emulation.environment_system_config.fading.small_scale.selected_option);
-
   if (abstraction_flag) {
 
     get_beta_map();
@@ -1490,9 +1328,9 @@ void init_ocm(void)
   }
 
 
-  for (eNB_id = 0; eNB_id < NB_eNB_INST; eNB_id++) {
-    enb_data[eNB_id] = (node_desc_t *)malloc(sizeof(node_desc_t));
-    init_enb(enb_data[eNB_id],oai_emulation.environment_system_config.antenna.eNB_antenna);
+  for (ru_id = 0; ru_id < RC.nb_RU; ru_id++) {
+    enb_data[ru_id] = (node_desc_t *)malloc(sizeof(node_desc_t));
+    init_enb(enb_data[ru_id],oai_emulation.environment_system_config.antenna.eNB_antenna);
   }
 
   for (UE_id = 0; UE_id < NB_UE_INST; UE_id++) {
@@ -1516,43 +1354,43 @@ void init_ocm(void)
   }
 
   if (abstraction_flag == 0)
-    init_channel_vars (frame_parms[0], &s_re, &s_im, &r_re, &r_im, &r_re0, &r_im0);
+    init_channel_vars (fp, &s_re, &s_im, &r_re, &r_im, &r_re0, &r_im0);
 
   // initialize channel descriptors
-  for (eNB_id = 0; eNB_id < NB_eNB_INST; eNB_id++) {
+  for (ru_id = 0; ru_id < RC.nb_RU; ru_id++) {
     for (UE_id = 0; UE_id < NB_UE_INST; UE_id++) {
       for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
         LOG_D(OCM,"Initializing channel (%s, %d) from eNB %d to UE %d\n", oai_emulation.environment_system_config.fading.small_scale.selected_option,
-              map_str_to_int(small_scale_names,oai_emulation.environment_system_config.fading.small_scale.selected_option), eNB_id, UE_id);
+              map_str_to_int(small_scale_names,oai_emulation.environment_system_config.fading.small_scale.selected_option), ru_id, UE_id);
 
 
-        eNB2UE[eNB_id][UE_id][CC_id] = 
-	  new_channel_desc_scm(PHY_vars_eNB_g[eNB_id][CC_id]->frame_parms.nb_antennas_tx,
+        RU2UE[ru_id][UE_id][CC_id] = 
+	  new_channel_desc_scm(RC.ru[ru_id]->nb_tx,
 			       PHY_vars_UE_g[UE_id][CC_id]->frame_parms.nb_antennas_rx,
 			       map_str_to_int(small_scale_names,oai_emulation.environment_system_config.fading.small_scale.selected_option),
-			       N_RB2sampling_rate(PHY_vars_eNB_g[eNB_id][CC_id]->frame_parms.N_RB_DL),
-			       N_RB2channel_bandwidth(PHY_vars_eNB_g[eNB_id][CC_id]->frame_parms.N_RB_DL),
+			       N_RB2sampling_rate(RC.ru[ru_id]->frame_parms.N_RB_DL),
+			       N_RB2channel_bandwidth(RC.ru[ru_id]->frame_parms.N_RB_DL),
 			       forgetting_factor,
 			       0,
 			       0);
-        random_channel(eNB2UE[eNB_id][UE_id][CC_id],abstraction_flag);
-        LOG_D(OCM,"[SIM] Initializing channel (%s, %d) from UE %d to eNB %d\n", oai_emulation.environment_system_config.fading.small_scale.selected_option,
-              map_str_to_int(small_scale_names, oai_emulation.environment_system_config.fading.small_scale.selected_option),UE_id, eNB_id);
+        random_channel(RU2UE[ru_id][UE_id][CC_id],abstraction_flag);
+        LOG_D(OCM,"[SIM] Initializing channel (%s, %d) from UE %d to ru %d\n", oai_emulation.environment_system_config.fading.small_scale.selected_option,
+              map_str_to_int(small_scale_names, oai_emulation.environment_system_config.fading.small_scale.selected_option),UE_id, ru_id);
 
-        UE2eNB[UE_id][eNB_id][CC_id] = 
+        UE2RU[UE_id][ru_id][CC_id] = 
 	  new_channel_desc_scm(PHY_vars_UE_g[UE_id][CC_id]->frame_parms.nb_antennas_tx,
-			       PHY_vars_eNB_g[eNB_id][CC_id]->frame_parms.nb_antennas_rx,
+			       RC.ru[ru_id]->nb_rx,
 			       map_str_to_int(small_scale_names, oai_emulation.environment_system_config.fading.small_scale.selected_option),
-			       N_RB2sampling_rate(PHY_vars_eNB_g[eNB_id][CC_id]->frame_parms.N_RB_UL),
-			       N_RB2channel_bandwidth(PHY_vars_eNB_g[eNB_id][CC_id]->frame_parms.N_RB_UL),
+			       N_RB2sampling_rate(RC.ru[ru_id]->frame_parms.N_RB_UL),
+			       N_RB2channel_bandwidth(RC.ru[ru_id]->frame_parms.N_RB_UL),
 			       forgetting_factor,
 			       0,
 			       0);
 
-        random_channel(UE2eNB[UE_id][eNB_id][CC_id],abstraction_flag);
+        random_channel(UE2RU[UE_id][ru_id][CC_id],abstraction_flag);
 
         // to make channel reciprocal uncomment following line instead of previous. However this only works for SISO at the moment. For MIMO the channel would need to be transposed.
-        //UE2eNB[UE_id][eNB_id] = eNB2UE[eNB_id][UE_id];
+        //UE2RU[UE_id][ru_id] = RU2UE[ru_id][UE_id];
       }
     }
   }
@@ -1609,22 +1447,24 @@ void update_omg_ocm()
 
 void update_ocm()
 {
-  module_id_t UE_id, eNB_id;
+  module_id_t UE_id, ru_id;
   int CC_id;
 
-  for (eNB_id = 0; eNB_id < NB_eNB_INST; eNB_id++)
-    enb_data[eNB_id]->tx_power_dBm = PHY_vars_eNB_g[eNB_id][0]->frame_parms.pdsch_config_common.referenceSignalPower;
-
-  for (UE_id = 0; UE_id < NB_UE_INST; UE_id++)
-    ue_data[UE_id]->tx_power_dBm = PHY_vars_UE_g[UE_id][0]->tx_power_dBm[0];
 
 
   /* check if the openair channel model is activated used for PHY abstraction : path loss*/
   if ((oai_emulation.info.ocm_enabled == 1)&& (ethernet_flag == 0 )) {
+    
+    for (ru_id = 0; ru_id < RC.nb_RU; ru_id++)
+      enb_data[ru_id]->tx_power_dBm = RC.ru[ru_id]->frame_parms.pdsch_config_common.referenceSignalPower;
+    
+    for (UE_id = 0; UE_id < NB_UE_INST; UE_id++)
+      ue_data[UE_id]->tx_power_dBm = PHY_vars_UE_g[UE_id][0]->tx_power_dBm[0];
+
     //LOG_D(OMG," extracting position of eNb...\n");
     //display_node_list(enb_node_list);
     //  display_node_list(ue_node_list);
-    extract_position(enb_node_list, enb_data, NB_eNB_INST);
+    extract_position(enb_node_list, enb_data, RC.nb_RU);
     //extract_position_fixed_enb(enb_data, NB_eNB_INST,frame);
     //LOG_D(OMG," extracting position of UE...\n");
     //      if (oai_emulation.info.omg_model_ue == TRACE)
@@ -1634,21 +1474,21 @@ void update_ocm()
        LOG_N(OCM,"Path loss for TTI %d : \n", frame);
     */
     for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
-      for (eNB_id = 0; eNB_id < NB_eNB_INST; eNB_id++) {
+      for (ru_id = 0; ru_id < RC.nb_RU; ru_id++) {
         for (UE_id = 0; UE_id < NB_UE_INST; UE_id++) {
-          calc_path_loss (enb_data[eNB_id], ue_data[UE_id], eNB2UE[eNB_id][UE_id][CC_id], oai_emulation.environment_system_config,ShaF);
-          //calc_path_loss (enb_data[eNB_id], ue_data[UE_id], eNB2UE[eNB_id][UE_id], oai_emulation.environment_system_config,0);
-          UE2eNB[UE_id][eNB_id][CC_id]->path_loss_dB = eNB2UE[eNB_id][UE_id][CC_id]->path_loss_dB;
+          calc_path_loss (enb_data[ru_id], ue_data[UE_id], RU2UE[ru_id][UE_id][CC_id], oai_emulation.environment_system_config,ShaF);
+          //calc_path_loss (enb_data[ru_id], ue_data[UE_id], RU2UE[ru_id][UE_id], oai_emulation.environment_system_config,0);
+          UE2RU[UE_id][ru_id][CC_id]->path_loss_dB = RU2UE[ru_id][UE_id][CC_id]->path_loss_dB;
           //    if (frame % 50 == 0)
           LOG_D(OCM,"Path loss (CCid %d) between eNB %d at (%f,%f) and UE %d at (%f,%f) is %f, angle %f\n",
-                CC_id,eNB_id,enb_data[eNB_id]->x,enb_data[eNB_id]->y,UE_id,ue_data[UE_id]->x,ue_data[UE_id]->y,
-                eNB2UE[eNB_id][UE_id][CC_id]->path_loss_dB, eNB2UE[eNB_id][UE_id][CC_id]->aoa);
+                CC_id,ru_id,enb_data[ru_id]->x,enb_data[ru_id]->y,UE_id,ue_data[UE_id]->x,ue_data[UE_id]->y,
+                RU2UE[ru_id][UE_id][CC_id]->path_loss_dB, RU2UE[ru_id][UE_id][CC_id]->aoa);
           //double dx, dy, distance;
-          //dx = enb_data[eNB_id]->x - ue_data[UE_id]->x;
-          //dy = enb_data[eNB_id]->y - ue_data[UE_id]->y;
+          //dx = enb_data[ru_id]->x - ue_data[UE_id]->x;
+          //dy = enb_data[ru_id]->y - ue_data[UE_id]->y;
           //distance = sqrt(dx * dx + dy * dy);
           /*LOG_D(LOCALIZE, " OCM distance between eNB %d at (%f,%f) and UE %d at (%f,%f) is %f \n",
-                  eNB_id, enb_data[eNB_id]->x,enb_data[eNB_id]->y,
+                  ru_id, enb_data[ru_id]->x,enb_data[ru_id]->y,
                   UE_id, ue_data[UE_id]->x,ue_data[UE_id]->y,
                   distance);*/
         }
@@ -1657,26 +1497,28 @@ void update_ocm()
   }
 
   else {
-    for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
-      for (eNB_id = 0; eNB_id < NB_eNB_INST; eNB_id++) {
+      for (ru_id = 0; ru_id < RC.nb_RU; ru_id++) {
         for (UE_id = 0; UE_id < NB_UE_INST; UE_id++) {
-
-          //pathloss: -132.24 dBm/15kHz RE + target SNR - eNB TX power per RE
-          if (eNB_id == (UE_id % NB_eNB_INST)) {
-            eNB2UE[eNB_id][UE_id][CC_id]->path_loss_dB = -132.24 + snr_dB - PHY_vars_eNB_g[eNB_id][CC_id]->frame_parms.pdsch_config_common.referenceSignalPower;
-            UE2eNB[UE_id][eNB_id][CC_id]->path_loss_dB = -132.24 + snr_dB - PHY_vars_eNB_g[eNB_id][CC_id]->frame_parms.pdsch_config_common.referenceSignalPower; 
-          } else {
-            eNB2UE[eNB_id][UE_id][CC_id]->path_loss_dB = -132.24 + sinr_dB - PHY_vars_eNB_g[eNB_id][CC_id]->frame_parms.pdsch_config_common.referenceSignalPower;
-            UE2eNB[UE_id][eNB_id][CC_id]->path_loss_dB = -132.24 + sinr_dB - PHY_vars_eNB_g[eNB_id][CC_id]->frame_parms.pdsch_config_common.referenceSignalPower;
-          }
-
-          LOG_D(OCM,"Path loss from eNB %d to UE %d (CCid %d)=> %f dB (eNB TX %d, SNR %f)\n",eNB_id,UE_id,CC_id,
-                eNB2UE[eNB_id][UE_id][CC_id]->path_loss_dB,
-                PHY_vars_eNB_g[eNB_id][CC_id]->frame_parms.pdsch_config_common.referenceSignalPower,snr_dB);
-        
-        }
+	  for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
+
+	    AssertFatal(RU2UE[ru_id][UE_id][CC_id]!=NULL,"RU2UE[%d][%d][%d] is null\n",ru_id,UE_id,CC_id);
+	    AssertFatal(UE2RU[ru_id][UE_id][CC_id]!=NULL,"RU2UE[%d][%d][%d] is null\n",ru_id,UE_id,CC_id);
+	    //pathloss: -132.24 dBm/15kHz RE + target SNR - eNB TX power per RE
+	    if (ru_id == (UE_id % RC.nb_RU)) {
+	      RU2UE[ru_id][UE_id][CC_id]->path_loss_dB = -132.24 + snr_dB - RC.ru[ru_id]->frame_parms.pdsch_config_common.referenceSignalPower;
+	      UE2RU[UE_id][ru_id][CC_id]->path_loss_dB = -132.24 + snr_dB - RC.ru[ru_id]->frame_parms.pdsch_config_common.referenceSignalPower; 
+	    } else {
+	      RU2UE[ru_id][UE_id][CC_id]->path_loss_dB = -132.24 + sinr_dB - RC.ru[ru_id]->frame_parms.pdsch_config_common.referenceSignalPower;
+	      UE2RU[UE_id][ru_id][CC_id]->path_loss_dB = -132.24 + sinr_dB - RC.ru[ru_id]->frame_parms.pdsch_config_common.referenceSignalPower;
+	    }
+	    
+	    LOG_D(OCM,"Path loss from eNB %d to UE %d (CCid %d)=> %f dB (eNB TX %d, SNR %f)\n",ru_id,UE_id,CC_id,
+		  RU2UE[ru_id][UE_id][CC_id]->path_loss_dB,
+		  RC.ru[ru_id]->frame_parms.pdsch_config_common.referenceSignalPower,snr_dB);
+	    
+	  }
+	}
       }
-    }
   }
 }
 
@@ -1715,7 +1557,7 @@ void update_otg_eNB(module_id_t enb_module_idP, unsigned int ctime)
             (otg_pkt->otg_pkt).mode = PDCP_TRANSMISSION_MODE_DATA;
             //Adding the packet to the OTG-PDCP buffer
             pkt_list_add_tail_eurecom(otg_pkt, &(otg_pdcp_buffer[enb_module_idP]));
-            LOG_I(EMU,"[eNB %d] ADD pkt to OTG buffer with size %d for dst %d on rb_id %d for app id %d \n",
+            LOG_D(EMU,"[eNB %d] ADD pkt to OTG buffer with size %d for dst %d on rb_id %d for app id %d \n",
                   (otg_pkt->otg_pkt).module_id, otg_pkt->otg_pkt.sdu_buffer_size, (otg_pkt->otg_pkt).dst_id,(otg_pkt->otg_pkt).rb_id, app_id);
           } else {
             free(otg_pkt);
@@ -1749,7 +1591,7 @@ void update_otg_eNB(module_id_t enb_module_idP, unsigned int ctime)
               //Adding the packet to the OTG-PDCP buffer
               (otg_pkt->otg_pkt).mode       = PDCP_TRANSMISSION_MODE_TRANSPARENT;
               pkt_list_add_tail_eurecom(otg_pkt, &(otg_pdcp_buffer[enb_module_idP]));
-              LOG_I(EMU, "[eNB %d] ADD packet (%p) multicast to OTG buffer for dst %d on rb_id %d\n",
+              LOG_D(EMU, "[eNB %d] ADD packet (%p) multicast to OTG buffer for dst %d on rb_id %d\n",
                     (otg_pkt->otg_pkt).module_id, otg_pkt, (otg_pkt->otg_pkt).dst_id,(otg_pkt->otg_pkt).rb_id);
             } else {
               //LOG_I(EMU, "OTG returns null \n");
@@ -1812,7 +1654,7 @@ void update_otg_eNB(module_id_t enb_module_idP, unsigned int ctime)
           (otg_pkt->otg_pkt).mode      = PDCP_TRANSMISSION_MODE_DATA;
           //Adding the packet to the OTG-PDCP buffer
           pkt_list_add_tail_eurecom(otg_pkt, &(otg_pdcp_buffer[module_idP]));
-          LOG_I(EMU, "[eNB %d] ADD pkt to OTG buffer for dst %d on rb_id %d\n", (otg_pkt->otg_pkt).module_id, (otg_pkt->otg_pkt).dst_id,(otg_pkt->otg_pkt).rb_id);
+          LOG_D(EMU, "[eNB %d] ADD pkt to OTG buffer for dst %d on rb_id %d\n", (otg_pkt->otg_pkt).module_id, (otg_pkt->otg_pkt).dst_id,(otg_pkt->otg_pkt).rb_id);
         } else {
           //LOG_I(EMU, "OTG returns null \n");
           free(otg_pkt);
@@ -1860,7 +1702,7 @@ void update_otg_UE(module_id_t ue_mod_idP, unsigned int ctime)
 	    //Adding the packet to the OTG-PDCP buffer
 	    (otg_pkt->otg_pkt).mode      = PDCP_TRANSMISSION_MODE_DATA;
 	    pkt_list_add_tail_eurecom(otg_pkt, &(otg_pdcp_buffer[module_id]));
-	    LOG_I(EMU, "[UE %d] ADD pkt to OTG buffer with size %d for dst %d on rb_id %d \n",
+	    LOG_D(EMU, "[UE %d] ADD pkt to OTG buffer with size %d for dst %d on rb_id %d \n",
 		  (otg_pkt->otg_pkt).module_id, otg_pkt->otg_pkt.sdu_buffer_size, (otg_pkt->otg_pkt).dst_id,(otg_pkt->otg_pkt).rb_id);
 	  } else {
 	    free(otg_pkt);
diff --git a/targets/SIMU/USER/sinr_sim.c b/targets/SIMU/USER/sinr_sim.c
index fbd15abaae..6d26d2fa5d 100644
--- a/targets/SIMU/USER/sinr_sim.c
+++ b/targets/SIMU/USER/sinr_sim.c
@@ -371,7 +371,7 @@ void init_snr(channel_desc_t* eNB2UE, node_desc_t *enb_data, node_desc_t *ue_dat
             break;
 
           default:
-            msg("Problem in SINR Calculation for TM5 \n");
+            LOG_E(EMU,"Problem in SINR Calculation for TM5 \n");
             break;
 
           }//switch(q)
@@ -451,7 +451,7 @@ void init_snr(channel_desc_t* eNB2UE, node_desc_t *enb_data, node_desc_t *ue_dat
             break;
 
           default:
-            msg("Problem in SINR Calculation for TM6 \n");
+            LOG_E(EMU,"Problem in SINR Calculation for TM6 \n");
             break;
 
           }//switch(q)
@@ -470,7 +470,7 @@ void init_snr(channel_desc_t* eNB2UE, node_desc_t *enb_data, node_desc_t *ue_dat
     break;
 
   default:
-    msg("Problem in SINR Initialization in sinr_sim.c\n");
+    LOG_E(EMU,"Problem in SINR Initialization in sinr_sim.c\n");
     break;
   }//switch
 }//function ends
@@ -726,7 +726,7 @@ void get_MIESM_param()
         break;
 
       default:
-        msg("Error, bad input, quitting\n");
+        LOG_E(EMU,"Error, bad input, quitting\n");
         break;
       }
 
-- 
GitLab