diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt
index 215f7525d91cd443f761bba953263dbea3ded88b..dbc129f3f7514ae257d1c053ee264f1a6d6f466b 100644
--- a/cmake_targets/CMakeLists.txt
+++ b/cmake_targets/CMakeLists.txt
@@ -635,12 +635,6 @@ add_boolean_option(DEBUG_PHY               False "Enable PHY layer debugging opt
 add_boolean_option(DEBUG_PHY_PROC          False "Enable debugging of PHY layer procedures")
 add_boolean_option(DEBUG_DLSCH             False "Enable debugging of DLSCH physical layer channel")
 
-##########################
-# 802.21 options
-##########################
-add_boolean_option(ENABLE_RAL              False "ENABLE 802.21 INTERFACE")
-add_boolean_option(USE_3GPP_ADDR_AS_LINK_ADDR False "As per attribute name")
-
 ##########################
 # NAS LAYER OPTIONS
 ##########################
@@ -743,9 +737,6 @@ include_directories("${OPENAIR2_DIR}/LAYER2/RLC/TM_v9.3.0")
 include_directories("${OPENAIR2_DIR}/LAYER2/PDCP_v10.1.0")
 include_directories("${OPENAIR2_DIR}/RRC/LTE/MESSAGES")
 include_directories("${OPENAIR2_DIR}/RRC/LTE")
-include_directories("${OPENAIR3_DIR}/RAL-LTE/INTERFACE-802.21/INCLUDE")
-include_directories("${OPENAIR3_DIR}/RAL-LTE/LTE_RAL_ENB/INCLUDE")
-include_directories("${OPENAIR3_DIR}/RAL-LTE/LTE_RAL_UE/INCLUDE")
 include_directories("${OPENAIR_DIR}/common/utils")
 include_directories("${OPENAIR_DIR}/common/utils/itti")
 include_directories("${OPENAIR3_DIR}/NAS/COMMON")
@@ -963,17 +954,21 @@ set(SECU_CN_SRC
   )
 add_library(SECU_CN ${SECU_CN_SRC})
 
-# Scheduler
+# Physical Channel Procedures Scheduling  
 ################################"
 set(SCHED_SRC
   ${OPENAIR1_DIR}/SCHED/fapi_l1.c
   ${OPENAIR1_DIR}/SCHED/phy_procedures_lte_eNb.c
   ${OPENAIR1_DIR}/SCHED/phy_procedures_lte_common.c
-  ${OPENAIR1_DIR}/SCHED/prach_procedures.c
-  ${OPENAIR1_DIR}/SCHED/ru_procedures.c
 )
 add_library(SCHED_LIB ${SCHED_SRC})
 
+set(SCHED_SRC_RU
+  ${OPENAIR1_DIR}/SCHED/ru_procedures.c
+  ${OPENAIR1_DIR}/SCHED/prach_procedures.c
+)
+add_library(SCHED_RU_LIB ${SCHED_SRC_RU})
+
 set(SCHED_SRC_UE
   ${OPENAIR1_DIR}/SCHED_UE/phy_procedures_lte_ue.c
   ${OPENAIR1_DIR}/SCHED/phy_procedures_lte_common.c
@@ -1114,24 +1109,29 @@ set(PHY_SRC
   ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/phich.c
   ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/pcfich.c
   ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/pucch.c
-  ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/prach.c
   ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/pmch.c
   ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/ulsch_demodulation.c
   ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/ulsch_decoding.c
   ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/rar_tools.c
-  ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/if4_tools.c
-  ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/if5_tools.c
   ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/uci_tools.c
-  ${OPENAIR1_DIR}/PHY/MODULATION/slot_fep_ul.c
-  ${OPENAIR1_DIR}/PHY/MODULATION/ul_7_5_kHz.c
-  ${OPENAIR1_DIR}/PHY/MODULATION/beamforming.c
-  ${OPENAIR1_DIR}/PHY/MODULATION/compute_bf_weights.c
   ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/freq_equalization.c
   ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_adjust_sync_eNB.c
   ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c
   ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_eNB_measurements.c
   ${OPENAIR1_DIR}/PHY/INIT/lte_init.c
+  )
+
+set(PHY_SRC_RU
+  # actual source
+  ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/if4_tools.c
+  ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/if5_tools.c
+  ${OPENAIR1_DIR}/PHY/MODULATION/slot_fep_ul.c
+  ${OPENAIR1_DIR}/PHY/MODULATION/ul_7_5_kHz.c
+  ${OPENAIR1_DIR}/PHY/MODULATION/beamforming.c
+  ${OPENAIR1_DIR}/PHY/MODULATION/compute_bf_weights.c
   ${OPENAIR1_DIR}/PHY/INIT/lte_init_ru.c
+  ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/prach.c
+
   )
 
 set(PHY_SRC_UE
@@ -1181,6 +1181,7 @@ endif ()
 add_library(PHY_COMMON ${PHY_SRC_COMMON})
 add_library(PHY ${PHY_SRC})
 add_library(PHY_UE ${PHY_SRC_UE})
+add_library(PHY_RU ${PHY_SRC_RU})
 
 #Layer 2 library
 #####################
@@ -1333,32 +1334,6 @@ include_directories(${NFAPI_USER_DIR})
 # L3 Libs
 ##########################
 
-set(RAL_LTE_DIR ${OPENAIR3_DIR}/RAL-LTE/)
-if (${ENABLE_RAL})
-  set(RAL_LTE_SRC
-    ${RRC_DIR}/rrc_UE_ral.c
-    ${RRC_DIR}/rrc_eNB_ral.c
-    ${RAL_LTE_DIR}LTE_RAL_ENB/SRC/lteRALenb_action.c
-    ${RAL_LTE_DIR}LTE_RAL_ENB/SRC/lteRALenb_main.c
-    ${RAL_LTE_DIR}LTE_RAL_ENB/SRC/lteRALenb_mih_msg.c
-    ${RAL_LTE_DIR}LTE_RAL_ENB/SRC/lteRALenb_parameters.c
-    ${RAL_LTE_DIR}LTE_RAL_ENB/SRC/lteRALenb_process.c
-    ${RAL_LTE_DIR}LTE_RAL_ENB/SRC/lteRALenb_rrc_msg.c
-    ${RAL_LTE_DIR}LTE_RAL_ENB/SRC/lteRALenb_subscribe.c
-    ${RAL_LTE_DIR}LTE_RAL_ENB/SRC/lteRALenb_thresholds.c
-    ${RAL_LTE_DIR}LTE_RAL_UE/SRC/lteRALue_action.c
-    ${RAL_LTE_DIR}LTE_RAL_UE/SRC/lteRALue_main.c
-    ${RAL_LTE_DIR}LTE_RAL_UE/SRC/lteRALue_mih_msg.c
-    ${RAL_LTE_DIR}LTE_RAL_UE/SRC/lteRALue_parameters.c
-    ${RAL_LTE_DIR}LTE_RAL_UE/SRC/lteRALue_process.c
-    ${RAL_LTE_DIR}LTE_RAL_UE/SRC/lteRALue_rrc_msg.c
-    ${RAL_LTE_DIR}LTE_RAL_UE/SRC/lteRALue_subscribe.c
-    ${RAL_LTE_DIR}LTE_RAL_UE/SRC/lteRALue_thresholds.c
-    )
-  add_library(RAL ${RAL_LTE_SRC})
-  set(RAL_LIB RAL)
-endif()
-
 # CN libs
 ##########################
 
@@ -1909,7 +1884,7 @@ add_executable(lte-softmodem
 
 target_link_libraries (lte-softmodem
   -Wl,--start-group
-  RRC_LIB S1AP_LIB S1AP_ENB GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB PHY_COMMON PHY LFDS L2 
+  RRC_LIB S1AP_LIB S1AP_ENB GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB SCHED_RU_LIB PHY_COMMON PHY PHY_RU LFDS L2 
   ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} LFDS7
   NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB
   -Wl,--end-group z dl)
@@ -1945,7 +1920,7 @@ add_executable(lte-softmodem-nos1
   )
 target_link_libraries (lte-softmodem-nos1
   -Wl,--start-group
-  RRC_LIB SECU_CN SECU_OSA UTIL HASHTABLE SCHED_LIB PHY_COMMON PHY LFDS L2 ${MSC_LIB} ${RAL_LIB} ${ITTI_LIB} 
+  RRC_LIB SECU_CN SECU_OSA UTIL HASHTABLE SCHED_LIB SCHED_RU_LIB PHY_COMMON PHY PHY_RU LFDS L2 ${MSC_LIB} ${RAL_LIB} ${ITTI_LIB} 
   ${MIH_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} LFDS7
   NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB
   -Wl,--end-group z dl )
@@ -1981,7 +1956,7 @@ add_executable(lte-uesoftmodem
 
 target_link_libraries (lte-uesoftmodem
   -Wl,--start-group
-  RRC_LIB S1AP_LIB S1AP_ENB GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT UDP SCHED_UE_LIB PHY_COMMON PHY_UE LFDS L2_UE 
+  RRC_LIB S1AP_LIB S1AP_ENB GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT UDP SCHED_RU_LIB SCHED_UE_LIB PHY_COMMON PHY_UE PHY_RU LFDS L2_UE 
   ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} LFDS7
   -Wl,--end-group z dl)
 
@@ -2014,7 +1989,7 @@ add_executable(lte-uesoftmodem-nos1
   )
 target_link_libraries (lte-uesoftmodem-nos1
   -Wl,--start-group
-  RRC_LIB SECU_CN SECU_OSA UTIL HASHTABLE SCHED_UE_LIB PHY_COMMON PHY_UE LFDS L2_UE ${MSC_LIB} ${RAL_LIB} ${ITTI_LIB} 
+  RRC_LIB SECU_CN SECU_OSA UTIL HASHTABLE SCHED_RU_LIB SCHED_UE_LIB PHY_COMMON PHY_UE PHY_RU LFDS L2_UE ${MSC_LIB} ${RAL_LIB} ${ITTI_LIB} 
   ${MIH_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} LFDS7
   -Wl,--end-group z dl )
 
@@ -2056,12 +2031,12 @@ add_executable(oaisim
   ${rrc_h}
   ${s1ap_h}
   ${x2ap_h}
-#  ${OPENAIR_BIN_DIR}/messages_xml.h
+  ${OPENAIR_BIN_DIR}/messages_xml.h
   ${OPENAIR_TARGETS}/RT/USER/lte-ue.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/oaisim_config.c
+#  ${OPENAIR_TARGETS}/SIMU/USER/oaisim_config.c
   ${OPENAIR_TARGETS}/SIMU/USER/sinr_sim.c
   ${OPENAIR_TARGETS}/SIMU/USER/cor_SF_sim.c
   ${OPENAIR_TARGETS}/SIMU/USER/oaisim_functions.c
@@ -2084,7 +2059,7 @@ add_executable(oaisim
 target_include_directories(oaisim PUBLIC  ${OPENAIR_TARGETS}/SIMU/USER)
 target_link_libraries (oaisim
   -Wl,-ldl,--start-group
-  RRC_LIB S1AP_LIB S1AP_ENB X2AP_LIB SECU_CN UTIL HASHTABLE SCTP_CLIENT UDP SCHED_UE_LIB PHY_COMMON PHY_UE LFDS L2_UE ${MSC_LIB} LIB_NAS_UE SIMU SECU_OSA ${ITTI_LIB}  ${MIH_LIB}
+  RRC_LIB S1AP_LIB S1AP_ENB X2AP_LIB SECU_CN UTIL HASHTABLE SCTP_CLIENT UDP SCHED_RU_LIB SCHED_UE_LIB PHY_COMMON PHY_UE PHY_RU LFDS L2_UE ${MSC_LIB} LIB_NAS_UE SIMU SECU_OSA ${ITTI_LIB}  ${MIH_LIB}
   ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} LFDS7
   -Wl,--end-group z dl)
 
@@ -2102,12 +2077,13 @@ add_executable(oaisim_nos1
   ${rrc_h}
   ${s1ap_h}
   ${x2ap_h}
-#  ${OPENAIR_BIN_DIR}/messages_xml.h
+  ${OPENAIR_BIN_DIR}/messages_xml.h
   ${OPENAIR_TARGETS}/RT/USER/lte-ue.c
   ${OPENAIR_TARGETS}/RT/USER/lte-ru.c
+  ${OPENAIR1_DIR}/SCHED/prach_procedures.c
   ${OPENAIR_TARGETS}/RT/USER/rt_wrapper.c
   ${OPENAIR_TARGETS}/SIMU/USER/channel_sim.c
-  ${OPENAIR_TARGETS}/SIMU/USER/oaisim_config.c
+#  ${OPENAIR_TARGETS}/SIMU/USER/oaisim_config.c
   ${OPENAIR_TARGETS}/SIMU/USER/sinr_sim.c
   ${OPENAIR_TARGETS}/SIMU/USER/cor_SF_sim.c
   ${OPENAIR_TARGETS}/SIMU/USER/oaisim_functions.c
@@ -2126,7 +2102,7 @@ add_executable(oaisim_nos1
 target_include_directories(oaisim_nos1 PUBLIC  ${OPENAIR_TARGETS}/SIMU/USER)
 target_link_libraries (oaisim_nos1
   -Wl,--start-group
-  RRC_LIB X2AP_LIB SECU_CN UTIL HASHTABLE SCHED_UE_LIB PHY_COMMON PHY_UE LFDS ${MSC_LIB} ${ITTI_LIB} SIMU L2_UE ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} LFDS7
+  RRC_LIB X2AP_LIB SECU_CN UTIL HASHTABLE SCHED_RU_LIB SCHED_UE_LIB PHY_COMMON PHY_UE PHY_RU LFDS ${MSC_LIB} ${ITTI_LIB} SIMU L2_UE ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} LFDS7
   -Wl,--end-group z dl )
 
 target_link_libraries (oaisim_nos1 ${LIBXML2_LIBRARIES} ${LAPACK_LIBRARIES})
@@ -2151,7 +2127,7 @@ add_executable(dlsim_tm4
   ${T_SOURCE}
   )
 target_link_libraries (dlsim_tm4
-  -Wl,--start-group SIMU UTIL SCHED_LIB PHY LFDS ${ITTI_LIB} -Wl,--end-group
+  -Wl,--start-group SIMU UTIL SCHED_LIB SCHED_RU_LIB PHY LFDS ${ITTI_LIB} -Wl,--end-group
   pthread m rt ${CONFIG_LIBRARIES} ${ATLAS_LIBRARIES} ${XFORMS_LIBRARIES} ${T_LIB}
   )
 
@@ -2167,7 +2143,7 @@ foreach(myExe dlsim dlsim_tm7 ulsim pbchsim scansim mbmssim pdcchsim pucchsim pr
     )
   target_link_libraries (${myExe}
 
-    -Wl,--start-group SIMU UTIL SCHED_LIB SCHED_UE_LIB PHY_COMMON PHY PHY_UE LFDS ${ITTI_LIB} LFDS7 -Wl,--end-group
+    -Wl,--start-group SIMU UTIL SCHED_LIB SCHED_RU_LIB SCHED_UE_LIB PHY_COMMON PHY PHY_UE LFDS ${ITTI_LIB} LFDS7 -Wl,--end-group
     pthread m rt ${CONFIG_LIBRARIES} ${ATLAS_LIBRARIES} ${XFORMS_LIBRARIES} ${T_LIB} dl
     )
 endforeach(myExe)
diff --git a/nfapi/oai_integration/nfapi_pnf.c b/nfapi/oai_integration/nfapi_pnf.c
index 0497912af2dca7f49942cb21de766776edabfd4c..cd8d5a89e1566290a367ffd2f40510355e2eba0e 100644
--- a/nfapi/oai_integration/nfapi_pnf.c
+++ b/nfapi/oai_integration/nfapi_pnf.c
@@ -49,6 +49,9 @@ extern RAN_CONTEXT_t RC;
 #include "UTIL/LOG/log.h"
 #include "openair2/LAYER2/MAC/mac_proto.h"
 
+#include "PHY/INIT/phy_init.h"
+#include "PHY/LTE_TRANSPORT/transport_proto.h"
+
 #define NUM_P5_PHY 2
 
 #define _GNU_SOURCE
diff --git a/openair1/PHY/CODING/3gpplte_turbo_decoder_sse_16bit.c b/openair1/PHY/CODING/3gpplte_turbo_decoder_sse_16bit.c
index 1b2d565b22cc5a9f84b5337a75a557e6254be0ba..7daa86b8bb296218b17955532c96267c2688c24d 100644
--- a/openair1/PHY/CODING/3gpplte_turbo_decoder_sse_16bit.c
+++ b/openair1/PHY/CODING/3gpplte_turbo_decoder_sse_16bit.c
@@ -41,6 +41,7 @@
 #include "PHY/sse_intrin.h"
 
 #ifndef TEST_DEBUG
+#include "PHY/impl_defs_top.h"
 #include "PHY/defs_common.h"
 #include "PHY/CODING/coding_defs.h"
 #include "PHY/CODING/lte_interleaver_inline.h"
diff --git a/openair1/PHY/INIT/init_top.c b/openair1/PHY/INIT/init_top.c
index 5f804bfabc1688779103bacb8a7512efc3846bed..f033a7e5c17d3db534b91d2008fe49913c2c0c07 100644
--- a/openair1/PHY/INIT/init_top.c
+++ b/openair1/PHY/INIT/init_top.c
@@ -23,6 +23,9 @@
 #include "phy_init.h"
 #include "PHY/phy_extern.h"
 #include "PHY/CODING/coding_extern.h"
+#include "PHY/LTE_ESTIMATION/lte_estimation.h"
+#include "PHY/LTE_REFSIG/lte_refsig.h"
+#include "PHY/LTE_TRANSPORT/transport_common_proto.h"
 
 void generate_64qam_table(void)
 {
diff --git a/openair1/PHY/INIT/lte_init.c b/openair1/PHY/INIT/lte_init.c
index 4f3de5bce00c5bbd85e5edb8b249e5790a6b5eb9..c226099da90be0ceab3e9a7490208e172794b2bb 100644
--- a/openair1/PHY/INIT/lte_init.c
+++ b/openair1/PHY/INIT/lte_init.c
@@ -25,6 +25,7 @@
 #include "PHY/phy_extern.h"
 #include "PHY/LTE_TRANSPORT/transport_proto.h"
 #include "PHY/LTE_UE_TRANSPORT/transport_proto_ue.h"
+#include "PHY/LTE_REFSIG/lte_refsig.h"
 #include "SIMULATION/TOOLS/sim.h"
 #include "RadioResourceConfigCommonSIB.h"
 #include "RadioResourceConfigDedicated.h"
diff --git a/openair1/PHY/INIT/lte_param_init.c b/openair1/PHY/INIT/lte_param_init.c
index a10240490aceec149da831a67819dbadaf1f28bd..0830058a8fb4bda41bb692a4e29b9aa460fb7104 100644
--- a/openair1/PHY/INIT/lte_param_init.c
+++ b/openair1/PHY/INIT/lte_param_init.c
@@ -30,6 +30,9 @@
 #include "PHY/defs_eNB.h"
 #include "PHY/defs_UE.h"
 #include "PHY/phy_extern.h"
+#include "phy_init.h"
+#include "PHY/LTE_REFSIG/lte_refsig.h"
+#include "PHY/LTE_TRANSPORT/transport_common_proto.h"
 
 extern PHY_VARS_eNB *eNB;
 extern PHY_VARS_UE *UE;
diff --git a/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync.c b/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync.c
index 737327a72a9c8ccd64260679280e52df30b951cd..3e1311734f1ec2cfe7841a3d9853d5a450682e70 100644
--- a/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync.c
+++ b/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync.c
@@ -24,7 +24,7 @@
 #include "PHY/phy_extern_ue.h"
 
 #include "UTIL/LOG/vcd_signal_dumper.h"
-#include "lte_estimation_defs.h"
+#include "lte_estimation.h"
 
 #define DEBUG_PHY
 
diff --git a/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync_ue.c b/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync_ue.c
index b7179960411ad88bf743e69803751dc261a917f0..327d07b730384c5471dcf31bfe973be4f3849d62 100644
--- a/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync_ue.c
+++ b/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync_ue.c
@@ -21,7 +21,7 @@
 
 #include "PHY/types.h"
 #include "PHY/defs_UE.h"
-#include "PHY/LTE_ESTIMATION/lte_estimation_defs.h"
+#include "PHY/LTE_ESTIMATION/lte_estimation.h"
 #include "PHY/impl_defs_top.h"
 
 #include "UTIL/LOG/vcd_signal_dumper.h"
diff --git a/openair1/PHY/LTE_ESTIMATION/lte_estimation_defs.h b/openair1/PHY/LTE_ESTIMATION/lte_estimation.h
similarity index 100%
rename from openair1/PHY/LTE_ESTIMATION/lte_estimation_defs.h
rename to openair1/PHY/LTE_ESTIMATION/lte_estimation.h
diff --git a/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c b/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c
index 3c5d3c78efc5173e23f3eec9b426dad32944dbb1..74ef6798c78c57baaada40d1044b137988a60774 100644
--- a/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c
+++ b/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c
@@ -26,7 +26,7 @@
 #include "UTIL/LOG/log.h"
 #include "PHY/LTE_TRANSPORT/transport_common_proto.h"
 #include "T.h"
-#include "lte_estimation_defs.h"
+#include "lte_estimation.h"
 
 // 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};
diff --git a/openair1/PHY/LTE_TRANSPORT/dci.c b/openair1/PHY/LTE_TRANSPORT/dci.c
index 768f7d661e796cb2d128f2a6881c443dd050d8dc..2bf3ec50155da7189aef47cf60756379191b57af 100755
--- a/openair1/PHY/LTE_TRANSPORT/dci.c
+++ b/openair1/PHY/LTE_TRANSPORT/dci.c
@@ -44,6 +44,7 @@
 #include "UTIL/LOG/log.h"
 #include "UTIL/LOG/vcd_signal_dumper.h"
 #include "PHY/LTE_TRANSPORT/transport_extern.h"
+#include "PHY/LTE_REFSIG/lte_refsig.h"
 
 //#define DEBUG_DCI_ENCODING 1
 //#define DEBUG_DCI_DECODING 1
diff --git a/openair1/PHY/LTE_TRANSPORT/dci_tools.c b/openair1/PHY/LTE_TRANSPORT/dci_tools.c
index ed7def3489917076169f28725bf26153538a3a5d..048eb200683208c4f624cd497da72355c58084ef 100644
--- a/openair1/PHY/LTE_TRANSPORT/dci_tools.c
+++ b/openair1/PHY/LTE_TRANSPORT/dci_tools.c
@@ -46,7 +46,7 @@
 
 //#define DEBUG_DCI
 #include "dci_tools_common_extern.h"
-
+#include "transport_proto.h"
 
 int8_t find_dlsch(uint16_t rnti, PHY_VARS_eNB *eNB,find_type_t type)
 {
diff --git a/openair1/PHY/LTE_TRANSPORT/dci_tools_common.c b/openair1/PHY/LTE_TRANSPORT/dci_tools_common.c
index a27250f7ea32c51221f4caaf1cf1029b66e709ed..8f0f8a6cab6fc308be46b61e562c149de5f74f66 100644
--- a/openair1/PHY/LTE_TRANSPORT/dci_tools_common.c
+++ b/openair1/PHY/LTE_TRANSPORT/dci_tools_common.c
@@ -38,7 +38,8 @@
 #endif
 #include "assertions.h"
 #include "nfapi_interface.h"
-
+#include "transport_common_proto.h"
+#include "SCHED/sched_common.h"
 //#define DEBUG_HARQ
 
 
diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c b/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c
index c1112b8e02ce853aeff99983e9ee6133439464e4..a2f8f08073827072f130f0424bc019a3e7e4c97c 100644
--- a/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c
+++ b/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c
@@ -36,6 +36,7 @@
 #include "PHY/CODING/lte_interleaver_inline.h"
 #include "PHY/LTE_TRANSPORT/transport_eNB.h"
 #include "UTIL/LOG/vcd_signal_dumper.h"
+#include "PHY/LTE_TRANSPORT/transport_proto.h"
 
 //#define DEBUG_DLSCH_MODULATION
 #define NEW_ALLOC_RE
diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_scrambling.c b/openair1/PHY/LTE_TRANSPORT/dlsch_scrambling.c
index 8f0de76b2ace3bb16cb8327c0c887a9345441533..21a7018d609ad4359f751cce98014ce03b2602cd 100644
--- a/openair1/PHY/LTE_TRANSPORT/dlsch_scrambling.c
+++ b/openair1/PHY/LTE_TRANSPORT/dlsch_scrambling.c
@@ -189,7 +189,7 @@ void dlsch_scrambling(LTE_DL_FRAME_PARMS *frame_parms,
 
 
 
-void init_scrambling_lut() {
+void init_scrambling_lut(void) {
 
   uint32_t s;
   int i=0,j;
@@ -242,7 +242,7 @@ void dlsch_unscrambling(LTE_DL_FRAME_PARMS *frame_parms,
   }
 }
 
-void init_unscrambling_lut() {
+void init_unscrambling_lut(void) {
 
   uint32_t s;
   int i=0,j;
diff --git a/openair1/PHY/LTE_TRANSPORT/edci.c b/openair1/PHY/LTE_TRANSPORT/edci.c
index 9b46ffdc561e602900127fb9f0c2e92599fe286d..bf1309900430282e3c716bde160644774ea89df2 100755
--- a/openair1/PHY/LTE_TRANSPORT/edci.c
+++ b/openair1/PHY/LTE_TRANSPORT/edci.c
@@ -42,6 +42,7 @@
 #include "assertions.h" 
 #include "T.h"
 #include "UTIL/LOG/log.h"
+#include "PHY/LTE_REFSIG/lte_refsig.h"
 
 //#define DEBUG_DCI_ENCODING 1
 //#define DEBUG_DCI_DECODING 1
diff --git a/openair1/PHY/LTE_TRANSPORT/group_hopping.c b/openair1/PHY/LTE_TRANSPORT/group_hopping.c
index cae68f05b888279f79922cb22babe559e600ec60..6fc1f0a3e44ade5363eeaa05ce409ec711f135ee 100644
--- a/openair1/PHY/LTE_TRANSPORT/group_hopping.c
+++ b/openair1/PHY/LTE_TRANSPORT/group_hopping.c
@@ -30,6 +30,7 @@
 * \warning
 */
 #include "PHY/defs_common.h"
+#include "PHY/LTE_REFSIG/lte_refsig.h"
 
 //#define DEBUG_GROUPHOP 1
 
diff --git a/openair1/PHY/LTE_TRANSPORT/pbch.c b/openair1/PHY/LTE_TRANSPORT/pbch.c
index 18f62e3283029ae90e4447bccb3780a9445c4484..eae88a6afeb794deade5d27373be0bebf142a91f 100644
--- a/openair1/PHY/LTE_TRANSPORT/pbch.c
+++ b/openair1/PHY/LTE_TRANSPORT/pbch.c
@@ -36,6 +36,7 @@
 #include "transport_proto.h"
 #include "PHY/phy_extern.h"
 #include "PHY/sse_intrin.h"
+#include "PHY/LTE_REFSIG/lte_refsig.h"
 
 //#define DEBUG_PBCH 1
 //#define DEBUG_PBCH_ENCODING
diff --git a/openair1/PHY/LTE_TRANSPORT/pcfich.c b/openair1/PHY/LTE_TRANSPORT/pcfich.c
index cc4f652a2e55ff2a87e29081a07e5383127d84f7..18a156c3fbc004f0421c67eb635c08102833d5e8 100644
--- a/openair1/PHY/LTE_TRANSPORT/pcfich.c
+++ b/openair1/PHY/LTE_TRANSPORT/pcfich.c
@@ -31,6 +31,7 @@
 */
 #include "PHY/impl_defs_top.h"
 #include "PHY/defs_eNB.h"
+#include "PHY/LTE_REFSIG/lte_refsig.h"
 
 //#define DEBUG_PCFICH
 extern uint8_t pcfich_b[4][32];
diff --git a/openair1/PHY/LTE_TRANSPORT/phich.c b/openair1/PHY/LTE_TRANSPORT/phich.c
index f16e2b2f94bc2e6fd315f01910307cedbc7f0515..2e8a6e410c3a9804d109fb0c72b22f8a610e9df4 100644
--- a/openair1/PHY/LTE_TRANSPORT/phich.c
+++ b/openair1/PHY/LTE_TRANSPORT/phich.c
@@ -34,6 +34,8 @@
 #include "PHY/defs_eNB.h"
 #include "PHY/impl_defs_top.h"
 #include "T.h"
+#include "PHY/LTE_REFSIG/lte_refsig.h"
+#include "transport_common_proto.h"
 
 //#define DEBUG_PHICH 1
 
diff --git a/openair1/PHY/LTE_TRANSPORT/pilots.c b/openair1/PHY/LTE_TRANSPORT/pilots.c
index 72d8d0cbfcac3e7eaebe80a1ef09aa768b30a0c8..921f93ddb103ccf41017644057f97c92137ba320 100644
--- a/openair1/PHY/LTE_TRANSPORT/pilots.c
+++ b/openair1/PHY/LTE_TRANSPORT/pilots.c
@@ -30,6 +30,7 @@
 * \warning
 */
 #include "PHY/defs_eNB.h"
+#include "PHY/LTE_REFSIG/lte_refsig.h"
 
 void generate_pilots(PHY_VARS_eNB *eNB,
                      int32_t **txdataF,
diff --git a/openair1/PHY/LTE_TRANSPORT/pilots_mbsfn.c b/openair1/PHY/LTE_TRANSPORT/pilots_mbsfn.c
index 7b8cc068cef6dfa2833420165e9ea1540242e904..fddc29b5242f4d005851fedf1b95b6d639619d24 100644
--- a/openair1/PHY/LTE_TRANSPORT/pilots_mbsfn.c
+++ b/openair1/PHY/LTE_TRANSPORT/pilots_mbsfn.c
@@ -31,7 +31,7 @@
 */
 
 #include "PHY/defs_eNB.h"
-
+#include "PHY/LTE_REFSIG/lte_refsig.h"
 
 int generate_mbsfn_pilot(PHY_VARS_eNB *eNB,
 			 eNB_rxtx_proc_t *proc,
diff --git a/openair1/PHY/LTE_TRANSPORT/pucch_common.c b/openair1/PHY/LTE_TRANSPORT/pucch_common.c
index f5aeacd0981aed8193c151a92042f09fa6759298..a9181a8b3dfe8107f42ad5b880b5eba3b5171d00 100644
--- a/openair1/PHY/LTE_TRANSPORT/pucch_common.c
+++ b/openair1/PHY/LTE_TRANSPORT/pucch_common.c
@@ -35,6 +35,7 @@
 
 #include "UTIL/LOG/log.h"
 #include "UTIL/LOG/vcd_signal_dumper.h"
+#include "PHY/LTE_REFSIG/lte_refsig.h"
 
 #include "T.h"
 
diff --git a/openair1/PHY/LTE_TRANSPORT/transport_common_proto.h b/openair1/PHY/LTE_TRANSPORT/transport_common_proto.h
index 7fd176fd04f59e08c3a8bb0cd80046cbdd9a7c37..ebf0d99c4e45a9966f47c39dc0dd736d713e343f 100644
--- a/openair1/PHY/LTE_TRANSPORT/transport_common_proto.h
+++ b/openair1/PHY/LTE_TRANSPORT/transport_common_proto.h
@@ -157,6 +157,8 @@ void generate_pcfich_reg_mapping(LTE_DL_FRAME_PARMS *frame_parms);
 
 void generate_phich_reg_mapping(LTE_DL_FRAME_PARMS *frame_parms);
 
+uint32_t check_phich_reg(LTE_DL_FRAME_PARMS *frame_parms,uint32_t kprime,uint8_t lprime,uint8_t mi);
+
 void generate_RIV_tables(void);
 
 /** \brief  This routine provides the relationship between a PHICH TXOp and its corresponding PUSCH subframe (Table 8.3.-1 from 36.213).
@@ -267,9 +269,16 @@ uint64_t pmi2hex_2Ar1(uint32_t pmi);
 
 uint64_t pmi2hex_2Ar2(uint32_t pmi);
 
+uint8_t get_pmi(uint8_t N_RB_DL,MIMO_mode_t mode, uint32_t pmi_alloc,uint16_t rb);
+
 // DL power control functions
 double get_pa_dB(uint8_t pa);
 
+void init_scrambling_lut(void);
+
+void init_unscrambling_lut(void);
+
+
 uint8_t get_prach_prb_offset(LTE_DL_FRAME_PARMS *frame_parms, 
 			     uint8_t prach_ConfigIndex, 
 			     uint8_t n_ra_prboffset,
diff --git a/openair1/PHY/LTE_TRANSPORT/transport_proto.h b/openair1/PHY/LTE_TRANSPORT/transport_proto.h
index 83e7f74c76de74fb1ab9bf2367a23734c3bba7bc..5547c308e9c320d1ea2c003b927f2f9e1776d3e0 100644
--- a/openair1/PHY/LTE_TRANSPORT/transport_proto.h
+++ b/openair1/PHY/LTE_TRANSPORT/transport_proto.h
@@ -535,6 +535,7 @@ void pdcch_unscrambling(LTE_DL_FRAME_PARMS *frame_parms,
                         int8_t* llr,
                         uint32_t length);
 
+
 void dlsch_scrambling(LTE_DL_FRAME_PARMS *frame_parms,
                       int mbsfn_flag,
                       LTE_eNB_DLSCH_t *dlsch,
@@ -606,6 +607,9 @@ double computeRhoB_eNB(uint8_t pa,
 
 
 
+void conv_eMTC_rballoc(uint16_t resource_block_coding,
+		       uint32_t N_RB_DL,
+		       uint32_t *rb_alloc);
 
 int8_t find_dlsch(uint16_t rnti, PHY_VARS_eNB *eNB,find_type_t type);
 
diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c
index 97cf5b827a71e36069c0adb29e35eb49815d5485..50f469011f0237923c090dc48c0c59d8492d0cf7 100644
--- a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c
+++ b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c
@@ -43,6 +43,7 @@
 #include "UTIL/LOG/vcd_signal_dumper.h"
 //#define DEBUG_ULSCH_DECODING
 #include "targets/RT/USER/rt_wrapper.h"
+#include "transport_proto.h"
 
 extern int codingw;
 
diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c b/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c
index cd80728b7c627f235f5a595784b0f1fc45ca01ca..0ffe3d735b23f86748fac00508501f9d24c07c65 100644
--- a/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c
+++ b/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c
@@ -35,6 +35,9 @@
 #include "transport_eNB.h"
 //#define DEBUG_ULSCH
 #include "PHY/sse_intrin.h"
+#include "transport_common_proto.h"
+#include "PHY/LTE_ESTIMATION/lte_estimation.h"
+#include "PHY/MODULATION/modulation_eNB.h"
 
 #include "T.h"
 
@@ -1103,7 +1106,7 @@ void ulsch_channel_level(int32_t **drs_ch_estimates_ext,
 
 int ulsch_power_LUT[750];
 
-void init_ulsch_power_LUT() {
+void init_ulsch_power_LUT(void) {
   
   int i;
 
diff --git a/openair1/PHY/LTE_UE_TRANSPORT/dci_tools_ue.c b/openair1/PHY/LTE_UE_TRANSPORT/dci_tools_ue.c
index 28f908c726007c58378b268b603776db0af77380..82dedd9bc999895101ce99aeb0b00879227e8867 100644
--- a/openair1/PHY/LTE_UE_TRANSPORT/dci_tools_ue.c
+++ b/openair1/PHY/LTE_UE_TRANSPORT/dci_tools_ue.c
@@ -1263,7 +1263,7 @@ void compute_llr_offset(LTE_DL_FRAME_PARMS *frame_parms,
 
     pdsch_vars->llr_offset[pdcch_vars->num_pdcch_symbols] = 0;
 
-    LOG_I(PHY,"compute_llr_offset:  nb RB %d - Qm %d \n", nb_rb_alloc, dlsch0_harq->Qm);
+    LOG_D(PHY,"compute_llr_offset:  nb RB %d - Qm %d \n", nb_rb_alloc, dlsch0_harq->Qm);
 
     //dlsch0_harq->rb_alloc_even;
     //dlsch0_harq->rb_alloc_odd;
@@ -1293,14 +1293,14 @@ void compute_llr_offset(LTE_DL_FRAME_PARMS *frame_parms,
         if(symbol < (frame_parms->symbols_per_tti-1))
           pdsch_vars->llr_offset[symbol+1] = pdsch_vars->llr_offset[symbol] + llr_offset;
 
-	LOG_I(PHY,"Granted Re subframe %d / symbol %d => %d (%d RBs)\n", subframe, symbol_mod, granted_re,dlsch0_harq->nb_rb);
-	LOG_I(PHY,"Pbch/PSS/SSS Re subframe %d / symbol %d => %d \n", subframe, symbol_mod, pbch_pss_sss_re);
-	LOG_I(PHY,"CRS Re Per PRB subframe %d / symbol %d => %d \n", subframe, symbol_mod, crs_re);
-	LOG_I(PHY,"Data Re subframe %d / symbol %d => %d \n", subframe, symbol_mod, data_re);
+	LOG_D(PHY,"Granted Re subframe %d / symbol %d => %d (%d RBs)\n", subframe, symbol_mod, granted_re,dlsch0_harq->nb_rb);
+	LOG_D(PHY,"Pbch/PSS/SSS Re subframe %d / symbol %d => %d \n", subframe, symbol_mod, pbch_pss_sss_re);
+	LOG_D(PHY,"CRS Re Per PRB subframe %d / symbol %d => %d \n", subframe, symbol_mod, crs_re);
+	LOG_D(PHY,"Data Re subframe %d / symbol %d => %d \n", subframe, symbol_mod, data_re);
 
 
 
-        LOG_I(PHY,"Data Re subframe %d-symbol %d => llr length %d, llr offset %d \n", subframe, symbol,
+        LOG_D(PHY,"Data Re subframe %d-symbol %d => llr length %d, llr offset %d \n", subframe, symbol,
               pdsch_vars->llr_length[symbol], pdsch_vars->llr_offset[symbol]);
     }
 }
diff --git a/openair1/PHY/LTE_UE_TRANSPORT/dci_ue.c b/openair1/PHY/LTE_UE_TRANSPORT/dci_ue.c
index e0c71281ad3fec875ec15c9a9a7e2cedb08e5c45..f7afb08286ddb8f58e359bec492d0bdbfca0258d 100755
--- a/openair1/PHY/LTE_UE_TRANSPORT/dci_ue.c
+++ b/openair1/PHY/LTE_UE_TRANSPORT/dci_ue.c
@@ -39,6 +39,8 @@
 #include "SIMULATION/TOOLS/sim.h" // for taus
 #include "PHY/sse_intrin.h"
 #include "PHY/LTE_TRANSPORT/transport_extern.h"
+#include "PHY/LTE_REFSIG/lte_refsig.h"
+#include "SCHED/sched_common.h"
 
 #include "assertions.h"
 #include "T.h"
@@ -155,11 +157,11 @@ void pdcch_demapping(uint16_t *llr,uint16_t *wbar,LTE_DL_FRAME_PARMS *frame_parm
 
       // if REG is allocated to PHICH, skip it
       if (check_phich_reg(frame_parms,kprime,lprime,mi) == 1) {
-	//        printf("dci_demapping : skipping REG %d (RE %d)\n",(lprime==0)?kprime/6 : kprime>>2,kprime);
+//	        printf("dci_demapping : skipping REG %d (RE %d)\n",(lprime==0)?kprime/6 : kprime>>2,kprime);
 	if ((lprime == 0)&&((kprime%6)==0))
 	  re_offset0+=4;
       } else { // not allocated to PHICH/PCFICH
-	//        printf("dci_demapping: REG %d\n",(lprime==0)?kprime/6 : kprime>>2);
+	//	        printf("dci_demapping: REG %d\n",(lprime==0)?kprime/6 : kprime>>2);
         if (lprime == 0) {
           // first symbol, or second symbol+4 TX antennas skip pilots
           kprime_mod12 = kprime%12;
@@ -170,7 +172,7 @@ void pdcch_demapping(uint16_t *llr,uint16_t *wbar,LTE_DL_FRAME_PARMS *frame_parm
             for (i=0; i<4; i++) {
               wbar[mprime] = llr[tti_offset0+i];
 #ifdef DEBUG_DCI_DECODING
-//              LOG_I(PHY,"PDCCH demapping mprime %d.%d <= llr %d (symbol %d re %d) -> (%d,%d)\n",mprime/4,i,tti_offset0+i,symbol_offset,re_offset0,*(char*)&wbar[mprime],*(1+(char*)&wbar[mprime]));
+              LOG_I(PHY,"PDCCH demapping mprime %d.%d <= llr %d (symbol %d re %d) -> (%d,%d)\n",mprime/4,i,tti_offset0+i,symbol_offset,re_offset0,*(char*)&wbar[mprime],*(1+(char*)&wbar[mprime]));
 #endif
               mprime++;
               re_offset0++;
@@ -335,7 +337,7 @@ int32_t pdcch_llr(LTE_DL_FRAME_PARMS *frame_parms,
     else
       *pdcch_llr8 = (char)(*rxF);
 
-    //    printf("%d %d => %d\n",i,*rxF,*pdcch_llr8);
+    //    printf("rxF->llr : %d %d => %d\n",i,*rxF,*pdcch_llr8);
     rxF++;
     pdcch_llr8++;
   }
@@ -396,7 +398,7 @@ void pdcch_channel_level(int32_t **dl_ch_estimates_ext,
                              ((int32_t*)&avg128P)[2] +
                              ((int32_t*)&avg128P)[3])/(nb_rb*12);
 
-      //            printf("Channel level : %d\n",avg[(aatx<<1)+aarx]);
+      //      printf("Channel level : %d\n",avg[(aatx<<1)+aarx]);
     }
 
 #if defined(__x86_64__) || defined(__i386__)
@@ -510,7 +512,6 @@ void pdcch_extract_rbs_single(int32_t **rxdataF,
 
   int nushiftmod3 = frame_parms->nushift%3;
   uint8_t symbol_mod;
-
   symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol;
 #ifdef DEBUG_DCI_DECODING
   LOG_I(PHY, "extract_rbs_single: symbol_mod %d\n",symbol_mod);
@@ -563,9 +564,9 @@ void pdcch_extract_rbs_single(int32_t **rxdataF,
                 (i!=(nushiftmod3+6)) &&
                 (i!=(nushiftmod3+9))) {
               rxF_ext[j]=rxF[i];
-              //                        printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j],*(1+(short*)&rxF_ext[j]));
+	      //printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j],*(1+(short*)&rxF_ext[j]));
               dl_ch0_ext[j++]=dl_ch0[i];
-              //                printf("ch %d => (%d,%d)\n",i,*(short *)&dl_ch0[i],*(1+(short*)&dl_ch0[i]));
+	      //printf("ch %d => (%d,%d)\n",i,*(short *)&dl_ch0[i],*(1+(short*)&dl_ch0[i]));
             }
           }
 
@@ -1289,8 +1290,7 @@ int32_t rx_pdcch(PHY_VARS_UE *ue,
                  uint8_t subframe,
                  uint8_t eNB_id,
                  MIMO_mode_t mimo_mode,
-                 uint32_t high_speed_flag,
-                 uint8_t is_secondary_ue)
+                 uint32_t high_speed_flag)
 {
 
   LTE_UE_COMMON *common_vars      = &ue->common_vars;
@@ -1302,34 +1302,26 @@ int32_t rx_pdcch(PHY_VARS_UE *ue,
   uint8_t n_pdcch_symbols;
   uint8_t mi = get_mi(frame_parms,subframe);
 
-  //printf("In rx_pdcch, subframe %d, eNB_id %d, pdcch_vars %d \n",subframe,eNB_id,pdcch_vars);
+  //  printf("In rx_pdcch, subframe %d, eNB_id %d, pdcch_vars %d, handling symbol 0 \n",subframe,eNB_id,pdcch_vars);
   // procress ofdm symbol 0
-    if (is_secondary_ue == 1) {
-      pdcch_extract_rbs_single(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF,
-                               common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id+1], //add 1 to eNB_id to compensate for the shifted B/F'd pilots from the SeNB
-                               pdcch_vars[eNB_id]->rxdataF_ext,
-                               pdcch_vars[eNB_id]->dl_ch_estimates_ext,
-                               0,
-                               high_speed_flag,
-                               frame_parms);
-    } else if (frame_parms->nb_antenna_ports_eNB>1) {
-      pdcch_extract_rbs_dual(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF,
-                             common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id],
-                             pdcch_vars[eNB_id]->rxdataF_ext,
-                             pdcch_vars[eNB_id]->dl_ch_estimates_ext,
-                             0,
-                             high_speed_flag,
-                             frame_parms);
-    } else {
-      pdcch_extract_rbs_single(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF,
-                               common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id],
-                               pdcch_vars[eNB_id]->rxdataF_ext,
-                               pdcch_vars[eNB_id]->dl_ch_estimates_ext,
-                               0,
-                               high_speed_flag,
-                               frame_parms);
-    }
-
+  if (frame_parms->nb_antenna_ports_eNB>1) {
+    pdcch_extract_rbs_dual(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF,
+			   common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id],
+			   pdcch_vars[eNB_id]->rxdataF_ext,
+			   pdcch_vars[eNB_id]->dl_ch_estimates_ext,
+			   0,
+			   high_speed_flag,
+			   frame_parms);
+  } else {
+    pdcch_extract_rbs_single(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF,
+			     common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id],
+			     pdcch_vars[eNB_id]->rxdataF_ext,
+			     pdcch_vars[eNB_id]->dl_ch_estimates_ext,
+			     0,
+			     high_speed_flag,
+			     frame_parms);
+  }
+  
 
   // compute channel level based on ofdm symbol 0
   pdcch_channel_level(pdcch_vars[eNB_id]->dl_ch_estimates_ext,
@@ -1345,7 +1337,7 @@ int32_t rx_pdcch(PHY_VARS_UE *ue,
 
   log2_maxh = (log2_approx(avgs)/2) + 5;  //+frame_parms->nb_antennas_rx;
 #ifdef UE_DEBUG_TRACE
-  LOG_D(PHY,"subframe %d: pdcch log2_maxh = %d (%d,%d)\n",subframe,log2_maxh,avgP[0],avgs);
+  LOG_I(PHY,"subframe %d: pdcch log2_maxh = %d (%d,%d)\n",subframe,log2_maxh,avgP[0],avgs);
 #endif
 
   T(T_UE_PHY_PDCCH_ENERGY, T_INT(eNB_id),  T_INT(frame%1024), T_INT(subframe),
@@ -1363,9 +1355,10 @@ int32_t rx_pdcch(PHY_VARS_UE *ue,
 
 #ifdef DEBUG_PHY
 
-  if (subframe==5)
-      write_output("rxF_comp_d.m","rxF_c_d",&pdcch_vars[eNB_id]->rxdataF_comp[0][s*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);
-
+    if (subframe==5) {
+      printf("Writing output s0\n");
+      write_output("rxF_comp_d0.m","rxF_c_d",&pdcch_vars[eNB_id]->rxdataF_comp[0][0*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);
+    }
 #endif
 
   if (frame_parms->nb_antennas_rx > 1) {
@@ -1379,6 +1372,10 @@ int32_t rx_pdcch(PHY_VARS_UE *ue,
   else
       pdcch_alamouti(frame_parms,pdcch_vars[eNB_id]->rxdataF_comp,0);
 
+  pdcch_llr(frame_parms,
+	    pdcch_vars[eNB_id]->rxdataF_comp,
+	    (char *)pdcch_vars[eNB_id]->llr,
+	    0);
 
 
   // decode pcfich here and find out pdcch ofdm symbol number
@@ -1387,6 +1384,7 @@ int32_t rx_pdcch(PHY_VARS_UE *ue,
                               pdcch_vars[eNB_id],
                               mimo_mode);
 
+  //  printf("In rx_pdcch, subframe %d, num_pdcch_symbols %d \n",subframe,n_pdcch_symbols);
 
   if (n_pdcch_symbols>3)
     n_pdcch_symbols=1;
@@ -1400,54 +1398,47 @@ int32_t rx_pdcch(PHY_VARS_UE *ue,
 
 #ifdef DEBUG_DCI_DECODING
 
-  LOG_I(PHY,"demapping: subframe %d, mi %d, tdd_config %d\n",subframe,get_mi(frame_parms,subframe),frame_parms->tdd_config);
+    if (subframe==5) LOG_I(PHY,"demapping: subframe %d, num_pdcch_symbols %d\n",subframe,n_pdcch_symbols);
 #endif
 
   // process pdcch ofdm symbol 1 and 2 if necessary
-  for (int s=1; s<n_pdcch_symbols; s++){
-      if (is_secondary_ue == 1) {
-          pdcch_extract_rbs_single(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF,
-                  common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id+1], //add 1 to eNB_id to compensate for the shifted B/F'd pilots from the SeNB
-                  pdcch_vars[eNB_id]->rxdataF_ext,
-                  pdcch_vars[eNB_id]->dl_ch_estimates_ext,
-                  s,
-                  high_speed_flag,
-                  frame_parms);
-      } else if (frame_parms->nb_antenna_ports_eNB>1) {
-          pdcch_extract_rbs_dual(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF,
-                  common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id],
-                  pdcch_vars[eNB_id]->rxdataF_ext,
-                  pdcch_vars[eNB_id]->dl_ch_estimates_ext,
-                  s,
-                  high_speed_flag,
-                  frame_parms);
+    for (int s=1; s<n_pdcch_symbols; s++){
+      //      printf("In rx_pdcch, subframe %d, eNB_id %d, pdcch_vars %d, handling symbol %d \n",subframe,eNB_id,pdcch_vars,s);
+      if (frame_parms->nb_antenna_ports_eNB>1) {
+	pdcch_extract_rbs_dual(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF,
+			       common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id],
+			       pdcch_vars[eNB_id]->rxdataF_ext,
+			       pdcch_vars[eNB_id]->dl_ch_estimates_ext,
+			       s,
+			       high_speed_flag,
+			       frame_parms);
       } else {
-          pdcch_extract_rbs_single(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF,
-                  common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id],
-                  pdcch_vars[eNB_id]->rxdataF_ext,
-                  pdcch_vars[eNB_id]->dl_ch_estimates_ext,
-                  s,
-                  high_speed_flag,
-                  frame_parms);
+	pdcch_extract_rbs_single(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF,
+				 common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id],
+				 pdcch_vars[eNB_id]->rxdataF_ext,
+				 pdcch_vars[eNB_id]->dl_ch_estimates_ext,
+				 s,
+				 high_speed_flag,
+				 frame_parms);
       }
-
-
+      
+      
       pdcch_channel_compensation(pdcch_vars[eNB_id]->rxdataF_ext,
-              pdcch_vars[eNB_id]->dl_ch_estimates_ext,
-              pdcch_vars[eNB_id]->rxdataF_comp,
-              (aatx>1) ? pdcch_vars[eNB_id]->rho : NULL,
-                      frame_parms,
-                      s,
-                      log2_maxh); // log2_maxh+I0_shift
-
-
-#ifdef DEBUG_PHY
+				 pdcch_vars[eNB_id]->dl_ch_estimates_ext,
+				 pdcch_vars[eNB_id]->rxdataF_comp,
+				 (aatx>1) ? pdcch_vars[eNB_id]->rho : NULL,
+				 frame_parms,
+				 s,
+				 log2_maxh); // log2_maxh+I0_shift
       
-      if (subframe==5)
-	write_output("rxF_comp_d.m","rxF_c_d",&pdcch_vars[eNB_id]->rxdataF_comp[0][s*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);
       
+#ifdef DEBUG_PHY
+	
+      if (subframe==5) {
+	write_output("rxF_comp_ds.m","rxF_c_ds",&pdcch_vars[eNB_id]->rxdataF_comp[0][s*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);
+      }
 #endif
-      
+	
       
       
       if (frame_parms->nb_antennas_rx > 1) {
@@ -1456,44 +1447,44 @@ int32_t rx_pdcch(PHY_VARS_UE *ue,
 			    s);
 	
       }
-
- if (mimo_mode == SISO)
-   pdcch_siso(frame_parms,pdcch_vars[eNB_id]->rxdataF_comp,s);
- else
-   pdcch_alamouti(frame_parms,pdcch_vars[eNB_id]->rxdataF_comp,s);
- 
-
-
-    pdcch_llr(frame_parms,
-            pdcch_vars[eNB_id]->rxdataF_comp,
-            (char *)pdcch_vars[eNB_id]->llr,
-            s);
-    /*#ifdef DEBUG_PHY
+      
+      if (mimo_mode == SISO)
+	pdcch_siso(frame_parms,pdcch_vars[eNB_id]->rxdataF_comp,s);
+      else
+	pdcch_alamouti(frame_parms,pdcch_vars[eNB_id]->rxdataF_comp,s);
+      
+      
+      //      printf("subframe %d computing llrs for symbol %d : %p\n",subframe,s,pdcch_vars[eNB_id]->llr);
+      pdcch_llr(frame_parms,
+		pdcch_vars[eNB_id]->rxdataF_comp,
+		(char *)pdcch_vars[eNB_id]->llr,
+		s);
+      /*#ifdef DEBUG_PHY
         write_output("llr8_seq.m","llr8",&pdcch_vars[eNB_id]->llr[s*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,4);
         #endif*/
-
-  }
-
-  pdcch_demapping(pdcch_vars[eNB_id]->llr,
-                  pdcch_vars[eNB_id]->wbar,
-                  frame_parms,
-                  n_pdcch_symbols,
-                  get_mi(frame_parms,subframe));
-
-  pdcch_deinterleaving(frame_parms,
-                       (uint16_t*)pdcch_vars[eNB_id]->e_rx,
-                       pdcch_vars[eNB_id]->wbar,
-                       n_pdcch_symbols,
-                       mi);
-
-  pdcch_unscrambling(frame_parms,
-                     subframe,
-                     pdcch_vars[eNB_id]->e_rx,
-                     get_nCCE(n_pdcch_symbols,frame_parms,mi)*72);
-
-  pdcch_vars[eNB_id]->num_pdcch_symbols = n_pdcch_symbols;
-
-  return(0);
+    }
+  
+    pdcch_demapping(pdcch_vars[eNB_id]->llr,
+		    pdcch_vars[eNB_id]->wbar,
+		    frame_parms,
+		    n_pdcch_symbols,
+		    get_mi(frame_parms,subframe));
+    
+    pdcch_deinterleaving(frame_parms,
+			 (uint16_t*)pdcch_vars[eNB_id]->e_rx,
+			 pdcch_vars[eNB_id]->wbar,
+			 n_pdcch_symbols,
+			 mi);
+    
+    pdcch_unscrambling(frame_parms,
+		       subframe,
+		       pdcch_vars[eNB_id]->e_rx,
+		       get_nCCE(n_pdcch_symbols,frame_parms,mi)*72);
+    
+    pdcch_vars[eNB_id]->num_pdcch_symbols = n_pdcch_symbols;
+
+    //    if ((frame&1) ==0 && subframe==5) exit(-1);
+    return(0);
 }
 
 
@@ -1520,10 +1511,10 @@ void pdcch_unscrambling(LTE_DL_FRAME_PARMS *frame_parms,
     }
 
 
-    //    printf("unscrambling %d : e %d, c %d => ",i,llr[i],((s>>(i&0x1f))&1));
+    //    if (subframe == 5) printf("unscrambling %d : e %d, c %d => ",i,llr[i],((s>>(i&0x1f))&1));
     if (((s>>(i%32))&1)==0)
       llr[i] = -llr[i];
-    //    printf("%d\n",llr[i]);
+    //    if (subframe == 5) printf("%d\n",llr[i]);
 
   }
 }
@@ -1637,7 +1628,7 @@ void dci_decoding(uint8_t DCI_LENGTH,
 
 
 #ifdef DEBUG_DCI_DECODING
-  LOG_I(PHY," Doing DCI Rate Matching RCC %d, w %p\n",RCC,w);
+  LOG_I(PHY," Doing DCI Rate Matching RCC %d, w %p\n",RCC,w_rx);
 #endif
 
   lte_rate_matching_cc_rx(RCC,coded_bits,w_rx,dummy_w_rx,e);
@@ -1647,10 +1638,10 @@ void dci_decoding(uint8_t DCI_LENGTH,
                               &w_rx[0]);
 
 #ifdef DEBUG_DCI_DECODING
-
-  for (i=0; i<16+DCI_LENGTH; i++)
-    LOG_I(PHY," DCI %d : (%d,%d,%d)\n",i,*(d_rx+96+(3*i)),*(d_rx+97+(3*i)),*(d_rx+98+(3*i)));
-
+  if (DCI_LENGTH==27 && ((1<<aggregation_level) == 4))
+    for (int i=0; i<16+DCI_LENGTH; i++)
+      LOG_I(PHY," DCI %d : (%d,%d,%d)\n",i,*(d_rx+96+(3*i)),*(d_rx+97+(3*i)),*(d_rx+98+(3*i)));
+  
 #endif
   memset(decoded_output,0,2+((16+DCI_LENGTH)>>3));
 
diff --git a/openair1/PHY/LTE_UE_TRANSPORT/dlsch_decoding.c b/openair1/PHY/LTE_UE_TRANSPORT/dlsch_decoding.c
index a031dad8a7172502fe3680bba9ed0837d36e0daa..30f7733be24ad0459eacc25df2d2e0a385a6bb1e 100644
--- a/openair1/PHY/LTE_UE_TRANSPORT/dlsch_decoding.c
+++ b/openair1/PHY/LTE_UE_TRANSPORT/dlsch_decoding.c
@@ -36,6 +36,7 @@
 #include "SCHED/sched_common_extern.h"
 #include "SIMULATION/TOOLS/sim.h"
 #include "UTIL/LOG/vcd_signal_dumper.h"
+#include "PHY/LTE_UE_TRANSPORT/transport_proto_ue.h"
 //#define DEBUG_DLSCH_DECODING
 //#define UE_DEBUG_TRACE 1
 
diff --git a/openair1/PHY/LTE_UE_TRANSPORT/prach_ue.c b/openair1/PHY/LTE_UE_TRANSPORT/prach_ue.c
index 9a26c5e44a811b90b920ef2852304a803f1d82cd..c9763465cdfbc55c8091289fc2773e2aa8e7a6a1 100644
--- a/openair1/PHY/LTE_UE_TRANSPORT/prach_ue.c
+++ b/openair1/PHY/LTE_UE_TRANSPORT/prach_ue.c
@@ -98,7 +98,7 @@ int32_t generate_prach( PHY_VARS_UE *ue, uint8_t eNB_id, uint8_t subframe, uint1
 
 #else //normal case (simulation)
   prach_start = subframe*ue->frame_parms.samples_per_tti-ue->N_TA_offset;
-  LOG_I(PHY,"[UE %d] prach_start %d, rx_offset %d, hw_timing_advance %d, N_TA_offset %d\n", ue->Mod_id,
+  LOG_D(PHY,"[UE %d] prach_start %d, rx_offset %d, hw_timing_advance %d, N_TA_offset %d\n", ue->Mod_id,
     prach_start,
     ue->rx_offset,
     ue->hw_timing_advance,
diff --git a/openair1/PHY/LTE_UE_TRANSPORT/transport_proto_ue.h b/openair1/PHY/LTE_UE_TRANSPORT/transport_proto_ue.h
index ba065b8e6fa342372d2da6f5463c5291ec6121e5..dfba1f1c58819c6e5b9a8c1824fb032ae3bc8942 100644
--- a/openair1/PHY/LTE_UE_TRANSPORT/transport_proto_ue.h
+++ b/openair1/PHY/LTE_UE_TRANSPORT/transport_proto_ue.h
@@ -19,7 +19,7 @@
  *      contact@openairinterface.org
  */
 
-/*! \file PHY/LTE_TRANSPORT/proto.h
+/*! \file PHY/LTE_UE_TRANSPORT/transport_proto_ue.h
  * \brief Function prototypes for PHY physical/transport channel processing and generation V8.6 2009-03
  * \author R. Knopp, F. Kaltenberger
  * \date 2011
@@ -32,6 +32,7 @@
 #ifndef __LTE_TRANSPORT_PROTO_UE__H__
 #define __LTE_TRANSPORT_PROTO_UE__H__
 #include "PHY/defs_UE.h"
+#include "PHY/LTE_TRANSPORT/transport_common_proto.h"
 #include <math.h>
 #include "nfapi_interface.h"
 
@@ -64,6 +65,7 @@ void free_ue_ulsch(LTE_UE_ULSCH_t *ulsch);
 
 LTE_UE_ULSCH_t *new_ue_ulsch(unsigned char N_RB_UL, uint8_t abstraction_flag);
 
+void fill_UE_dlsch_MCH(PHY_VARS_UE *ue,int mcs,int ndi,int rvidx,int eNB_id);
 
 int rx_pmch(PHY_VARS_UE *phy_vars_ue,
             unsigned char eNB_id,
@@ -1026,8 +1028,7 @@ int32_t rx_pdcch(PHY_VARS_UE *ue,
                  uint8_t subframe,
                  uint8_t eNB_id,
                  MIMO_mode_t mimo_mode,
-                 uint32_t high_speed_flag,
-                 uint8_t is_secondary_ue);
+                 uint32_t high_speed_flag);
 
 /*! \brief Extract PSS and SSS resource elements
   @param phy_vars_ue Pointer to UE variables
diff --git a/openair1/PHY/MODULATION/modulation_common.h b/openair1/PHY/MODULATION/modulation_common.h
index 1c4e3746779e50682809756f2380645261727293..2ac0dc23b3012b5bc76aa8ad7acbdf9f4fedd318 100644
--- a/openair1/PHY/MODULATION/modulation_common.h
+++ b/openair1/PHY/MODULATION/modulation_common.h
@@ -19,8 +19,8 @@
  *      contact@openairinterface.org
  */
 
-#ifndef __MODULATION_DEFS__H__
-#define __MODULATION_DEFS__H__
+#ifndef __MODULATION_COMMON__H__
+#define __MODULATION_COMMON__H__
 #include "PHY/defs_common.h"
 /** @addtogroup _PHY_MODULATION_
  * @{
diff --git a/openair1/PHY/MODULATION/ofdm_mod.c b/openair1/PHY/MODULATION/ofdm_mod.c
index a5b17abdca3cd25960cd9a1203ed7818c563c393..dfb6c85f33abe7f7309a7b23173506fd125490bc 100644
--- a/openair1/PHY/MODULATION/ofdm_mod.c
+++ b/openair1/PHY/MODULATION/ofdm_mod.c
@@ -34,7 +34,7 @@ This section deals with basic functions for OFDM Modulation.
 #include "UTIL/LOG/log.h"
 #include "UTIL/LOG/vcd_signal_dumper.h"
 #include "modulation_common.h"
-
+#include "PHY/LTE_TRANSPORT/transport_common_proto.h"
 //#define DEBUG_OFDM_MOD
 
 
diff --git a/openair1/SCHED/phy_procedures_lte_common.c b/openair1/SCHED/phy_procedures_lte_common.c
index 4aa44c21adb5f0cb71882cb93aa42fcfcf3311b8..81679f199c64b506de424bfb20bcf03ababa2deb 100644
--- a/openair1/SCHED/phy_procedures_lte_common.c
+++ b/openair1/SCHED/phy_procedures_lte_common.c
@@ -32,6 +32,7 @@
 #include "PHY/defs_eNB.h"
 #include "PHY/defs_UE.h"
 #include "SCHED/sched_common_extern.h"
+#include "PHY/LTE_TRANSPORT/transport_common_proto.h"
 
 void get_Msg3_alloc(LTE_DL_FRAME_PARMS *frame_parms,
                     unsigned char current_subframe,
diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c
index 3a73f2d6542831a137a69404ad8eb79d1ebb2158..233d4f06ef3d07925f285278f41d463114595b9a 100644
--- a/openair1/SCHED/phy_procedures_lte_eNb.c
+++ b/openair1/SCHED/phy_procedures_lte_eNb.c
@@ -34,6 +34,7 @@
 #include "PHY/phy_extern.h"
 #include "SCHED/sched_eNB.h"
 #include "SCHED/sched_common_extern.h"
+#include "PHY/LTE_ESTIMATION/lte_estimation.h"
 #include "nfapi_interface.h"
 #include "fapi_l1.h"
 #include "UTIL/LOG/log.h"
@@ -139,7 +140,6 @@ void pmch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) {
 
 #if defined(Rel10) || defined(Rel14)
   MCH_PDU *mch_pduP=NULL;
-  MCH_PDU  mch_pdu;
   //  uint8_t sync_area=255;
 #endif
 
diff --git a/openair1/SCHED/ru_procedures.c b/openair1/SCHED/ru_procedures.c
index 3d200fbd6166a168fedfba43f6a0951ef23229a0..d5a78c7f98e05be2c8a72687643f9ba1c3e92313 100644
--- a/openair1/SCHED/ru_procedures.c
+++ b/openair1/SCHED/ru_procedures.c
@@ -33,9 +33,10 @@
 #include "PHY/defs_eNB.h"
 #include "PHY/phy_extern.h"
 #include "SCHED/sched_eNB.h"
-
+#include "PHY/MODULATION/modulation_eNB.h"
 #include "PHY/LTE_TRANSPORT/if4_tools.h"
 #include "PHY/LTE_TRANSPORT/if5_tools.h"
+#include "PHY/LTE_TRANSPORT/transport_common_proto.h"
 
 #include "LAYER2/MAC/mac.h"
 #include "UTIL/LOG/log.h"
diff --git a/openair1/SCHED/sched_eNB.h b/openair1/SCHED/sched_eNB.h
index a386fbf976dba093a76a2b16feae9cef36a077cd..e03b7f6b62be7579cdefd02a17b69db3e2809c95 100644
--- a/openair1/SCHED/sched_eNB.h
+++ b/openair1/SCHED/sched_eNB.h
@@ -30,6 +30,7 @@
 
 #include "PHY/defs_eNB.h"
 #include "PHY_INTERFACE/phy_interface.h"
+#include "sched_common.h"
 
 enum THREAD_INDEX { OPENAIR_THREAD_INDEX = 0,
                     TOP_LEVEL_SCHEDULER_THREAD_INDEX,
diff --git a/openair1/SCHED_UE/phy_procedures_lte_ue.c b/openair1/SCHED_UE/phy_procedures_lte_ue.c
index d4d2617a3ce402bb77cb4269e15d2f069b634099..eba42fa43fae6912a1396e0b5d8d6fdf478f28f8 100644
--- a/openair1/SCHED_UE/phy_procedures_lte_ue.c
+++ b/openair1/SCHED_UE/phy_procedures_lte_ue.c
@@ -40,6 +40,9 @@
 
 #include "PHY/LTE_UE_TRANSPORT/transport_proto_ue.h"
 #include "SCHED_UE/sched_UE.h"
+#include "PHY/MODULATION/modulation_UE.h"
+#include "PHY/LTE_ESTIMATION/lte_estimation.h"
+
 //#define DEBUG_PHY_PROC
 
 #ifndef PUCCH
@@ -1408,7 +1411,7 @@ void ue_prach_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uin
       ue->prach_resources[eNB_id]->ra_PreambleIndex = 19;
     }
     
-    LOG_I(PHY,"[UE  %d][RAPROC] Frame %d, Subframe %d : Generating PRACH, preamble %d,PL %d,  P0_PRACH %d, TARGET_RECEIVED_POWER %d dBm, PRACH TDD Resource index %d, RA-RNTI %d\n",
+    LOG_D(PHY,"[UE  %d][RAPROC] Frame %d, Subframe %d : Generating PRACH, preamble %d,PL %d,  P0_PRACH %d, TARGET_RECEIVED_POWER %d dBm, PRACH TDD Resource index %d, RA-RNTI %d\n",
 	  ue->Mod_id,
 	  frame_tx,
 	  subframe_tx,
@@ -2767,15 +2770,17 @@ int ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint
 	   subframe_rx,
 	   eNB_id,
 	   ue->frame_parms.nb_antenna_ports_eNB==1?SISO:ALAMOUTI,
-	   ue->high_speed_flag,
-	   ue->is_secondary_ue);
+	   ue->high_speed_flag);
   
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RX_PDCCH, VCD_FUNCTION_OUT);
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DCI_DECODING, VCD_FUNCTION_IN);
   
   
-  //printf("Decode SIB frame param agregation + DCI %d %d \n",agregationLevel,dciFormat);
-  
+  /*printf("Decode SIB frame param aggregation + DCI %d %d, num_pdcch_symbols %d\n",
+	 ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->agregationLevel,
+	 ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->dciFormat,
+	 ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->num_pdcch_symbols);
+  */
   //agregation level == FF means no configuration on
   if(ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->agregationLevel == 0xFF || ue->decode_SIB)
     {
diff --git a/openair1/SCHED_UE/pucch_pc.c b/openair1/SCHED_UE/pucch_pc.c
index 6fa510d99ee3b4d4a76428fb238b9b95c3767c30..f03cd93d34995b4313c1104aebd30f439b6afc8f 100644
--- a/openair1/SCHED_UE/pucch_pc.c
+++ b/openair1/SCHED_UE/pucch_pc.c
@@ -34,7 +34,7 @@
 #include "SCHED_UE/sched_UE.h"
 #include "SCHED/sched_common_extern.h"
 #include "PHY/LTE_UE_TRANSPORT/transport_proto_ue.h"
-
+#include "PHY/LTE_ESTIMATION/lte_estimation.h"
 
 int16_t pucch_power_cntl(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t subframe,uint8_t eNB_id,PUCCH_FMT_t pucch_fmt)
 {
diff --git a/openair1/SCHED_UE/pusch_pc.c b/openair1/SCHED_UE/pusch_pc.c
index a597a95f202b0edefcdfa8823059d11c4f7ad860..588720f18cbeb1eb7e32dd27b1654a4e191e405e 100644
--- a/openair1/SCHED_UE/pusch_pc.c
+++ b/openair1/SCHED_UE/pusch_pc.c
@@ -35,6 +35,7 @@
 #include "PHY/defs_UE.h"
 #include "PHY/LTE_UE_TRANSPORT/transport_proto_ue.h"
 #include "PHY/phy_extern_ue.h"
+#include "PHY/LTE_ESTIMATION/lte_estimation.h"
 
 int16_t get_hundred_times_delta_IF(PHY_VARS_UE *ue,uint8_t eNB_id,uint8_t harq_pid)
 {
diff --git a/openair1/SCHED_UE/srs_pc.c b/openair1/SCHED_UE/srs_pc.c
index 1f5aa8ecbc7347435c9852d81aefd2fb2107dd71..9463db2cd62b594db9fad1adeb7514fbcd34516e 100644
--- a/openair1/SCHED_UE/srs_pc.c
+++ b/openair1/SCHED_UE/srs_pc.c
@@ -33,6 +33,7 @@
 #include "PHY/defs_UE.h"
 #include "PHY/LTE_UE_TRANSPORT/transport_proto_ue.h"
 #include "PHY/phy_extern_ue.h"
+#include "PHY/LTE_ESTIMATION/lte_estimation.h"
 
 void srs_power_cntl(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t *pnb_rb_srs, uint8_t abstraction_flag)
 {
diff --git a/openair1/SIMULATION/TOOLS/random_channel.c b/openair1/SIMULATION/TOOLS/random_channel.c
index b19572892eb2cacd6e0c4abeb3efd07747e912f9..dc8df153159c58cd75506054941237c4701439fe 100644
--- a/openair1/SIMULATION/TOOLS/random_channel.c
+++ b/openair1/SIMULATION/TOOLS/random_channel.c
@@ -32,6 +32,8 @@
 #include "UTIL/LOG/log.h"
 //#define DEBUG_CH
 
+#include "assertions.h"
+
 extern void print_shorts(char *s,__m128i *x);
 
 void fill_channel_desc(channel_desc_t *chan_desc,
@@ -1210,10 +1212,8 @@ int random_channel(channel_desc_t *desc, uint8_t abstraction_flag) {
   struct complex anew[NB_ANTENNAS_TX*NB_ANTENNAS_RX],acorr[NB_ANTENNAS_TX*NB_ANTENNAS_RX];
   struct complex phase, alpha, beta;
 
-  if ((desc->nb_tx>NB_ANTENNAS_TX) || (desc->nb_rx > NB_ANTENNAS_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);
-  }
+  AssertFatal(desc->nb_tx<=NB_ANTENNAS_TX && desc->nb_rx <= NB_ANTENNAS_RX,
+	      "random_channel.c: Error: temporary buffer for channel not big enough (%d,%d)\n",desc->nb_tx,desc->nb_rx);
 
   start_meas(&desc->random_channel);
   for (i=0;i<(int)desc->nb_taps;i++) {
@@ -1372,8 +1372,7 @@ double N_RB2sampling_rate(uint16_t N_RB)
     break;
 
   default:
-    LOG_E(PHY,"Unknown N_PRB\n");
-    return(-1);
+    AssertFatal(1==0,"Unknown N_PRB %d",N_RB);
   }
 
   return(sampling_rate);
diff --git a/openair2/COMMON/platform_constants.h b/openair2/COMMON/platform_constants.h
index 687f2b2f1d5e39432db90ff7485185fd6bea9e2a..20a7d5ecd20c52e114546305d77382bed796a3af 100644
--- a/openair2/COMMON/platform_constants.h
+++ b/openair2/COMMON/platform_constants.h
@@ -69,9 +69,11 @@
 
 #ifdef LARGE_SCALE
 #    define MAX_MOBILES_PER_ENB         128
+#    define MAX_MOBILES_PER_ENB_NB_IoT  128
 #    define MAX_eNB                      2
 #else
 #    define MAX_MOBILES_PER_ENB         16
+#    define MAX_MOBILES_PER_ENB_NB_IoT  16
 #    define MAX_eNB                      2
 #endif
 
diff --git a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c
index c5c41d2e60149d2aca70892dbda22cb496c48041..0545eeb3be11e59522aebcafb3161b4aaa61e60a 100644
--- a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c
+++ b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c
@@ -836,7 +836,7 @@ int flexran_agent_mac_sf_trigger(mid_t mod_id, const void *params, Protocol__Fle
   Protocol__FlexHeader *header = NULL;
   int i, j, UE_id;
 
-  int available_harq[NUMBER_OF_UE_MAX];
+  int available_harq[MAX_MOBILES_PER_ENB];
 
   const int xid = *((int *)params);
 
@@ -854,7 +854,7 @@ int flexran_agent_mac_sf_trigger(mid_t mod_id, const void *params, Protocol__Fle
   frame_t frame;
   sub_frame_t subframe;
 
-  for (i = 0; i < NUMBER_OF_UE_MAX; i++) {
+  for (i = 0; i < MAX_MOBILES_PER_ENB; i++) {
     available_harq[i] = -1;
   }
 
@@ -878,7 +878,7 @@ int flexran_agent_mac_sf_trigger(mid_t mod_id, const void *params, Protocol__Fle
 
   sf_trigger_msg->n_dl_info = 0;
 
-  for (i = 0; i < NUMBER_OF_UE_MAX; i++) {
+  for (i = 0; i < MAX_MOBILES_PER_ENB; i++) {
     for (j = 0; j < 8; j++) {
       if (RC.mac && RC.mac[mod_id] && RC.mac[mod_id]->UE_list.eNB_UE_stats[UE_PCCID(mod_id,i)][i].harq_pid == 1) {
 	available_harq[i] = j;
@@ -904,7 +904,7 @@ int flexran_agent_mac_sf_trigger(mid_t mod_id, const void *params, Protocol__Fle
       goto error;
     i = -1;
     //Fill the status of the current HARQ process for each UE
-    for(UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) {
+    for(UE_id = 0; UE_id < MAX_MOBILES_PER_ENB; UE_id++) {
       if (available_harq[UE_id] < 0) {
 	continue;
       } else {
@@ -1262,7 +1262,7 @@ void flexran_agent_init_mac_agent(mid_t mod_id) {
   //Allow RINGBUFFER_SIZE messages to be stored in the ringbuffer at any time
   dl_mac_config_array[mod_id] = malloc( sizeof(struct lfds700_ringbuffer_element) *  num_elements);
   lfds700_ringbuffer_init_valid_on_current_logical_core( &ringbuffer_state[mod_id], dl_mac_config_array[mod_id], num_elements, &ps[mod_id], NULL );
-  for (i = 0; i < NUMBER_OF_UE_MAX; i++) {
+  for (i = 0; i < MAX_MOBILES_PER_ENB; i++) {
     for (j = 0; j < 8; j++) {
       if (RC.mac && RC.mac[mod_id])
         RC.mac[mod_id]->UE_list.eNB_UE_stats[UE_PCCID(mod_id,i)][i].harq_pid = 0;
diff --git a/openair2/ENB_APP/CONTROL_MODULES/PDCP/flexran_agent_pdcp.c b/openair2/ENB_APP/CONTROL_MODULES/PDCP/flexran_agent_pdcp.c
index 43455fa32a4043edeac6eda7c869b0fe2c783348..b2723f718126973f96d972a3284b995c5e99c3e2 100644
--- a/openair2/ENB_APP/CONTROL_MODULES/PDCP/flexran_agent_pdcp.c
+++ b/openair2/ENB_APP/CONTROL_MODULES/PDCP/flexran_agent_pdcp.c
@@ -37,7 +37,7 @@ unsigned int pdcp_agent_registered[NUM_MAX_ENB];
 /*Array containing the Agent-PDCP interfaces*/
 AGENT_PDCP_xface *agent_pdcp_xface[NUM_MAX_ENB];
 
-// NUMBER_OF_UE_MAX
+// MAX_MOBILES_PER_ENB
 
 void flexran_agent_pdcp_aggregate_stats(const mid_t mod_id,
 					const mid_t ue_id,
diff --git a/openair2/ENB_APP/enb_app.c b/openair2/ENB_APP/enb_app.c
index 481bfaa521e961ce08466ff427be69c58e6a259d..b3471d2637193b5be594ede68816fecf78cb5dc6 100644
--- a/openair2/ENB_APP/enb_app.c
+++ b/openair2/ENB_APP/enb_app.c
@@ -46,6 +46,7 @@
 #   include "gtpv1u_eNB_task.h"
 # endif
 
+#include "openair1/PHY/INIT/phy_init.h"
 extern unsigned char NB_eNB_INST;
 #endif
 
diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c
index 628f7d55d69a02376644aceedddf77f5d43e462d..f561ceab13b129d23c1dc358989704d0fb10f69d 100644
--- a/openair2/ENB_APP/enb_config.c
+++ b/openair2/ENB_APP/enb_config.c
@@ -48,6 +48,7 @@
 #include "LAYER2/MAC/mac_extern.h"
 #include "LAYER2/MAC/mac_proto.h"
 #include "PHY/phy_extern.h"
+#include "PHY/INIT/phy_init.h"
 #include "targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.h"
 #include "nfapi_vnf.h"
 #include "nfapi_pnf.h"
@@ -295,8 +296,10 @@ void RCconfig_macrlc() {
 
     RC.nb_macrlc_inst=MacRLC_ParamList.numelt; 
     mac_top_init_eNB();   
-    for (j=0;j<RC.nb_macrlc_inst;j++) {
+    RC.nb_mac_CC = (int*)malloc(RC.nb_macrlc_inst*sizeof(int));
 
+    for (j=0;j<RC.nb_macrlc_inst;j++) {
+      RC.nb_mac_CC[j] = *(MacRLC_ParamList.paramarray[j][MACRLC_CC_IDX].iptr);
       //RC.mac[j]->phy_test = *(MacRLC_ParamList.paramarray[j][MACRLC_PHY_TEST_IDX].iptr);
       //printf("PHY_TEST = %d,%d\n", RC.mac[j]->phy_test, j);
 
diff --git a/openair2/ENB_APP/flexran_agent_ran_api.c b/openair2/ENB_APP/flexran_agent_ran_api.c
index 3200f55f16fa1100e75140b87c98b6f257786701..d2d8174dd4f7edb9994920ea864f570dd50d747c 100644
--- a/openair2/ENB_APP/flexran_agent_ran_api.c
+++ b/openair2/ENB_APP/flexran_agent_ran_api.c
@@ -1207,7 +1207,7 @@ void flexran_set_pdcp_rx_stat_window(const mid_t mod_id, const mid_t ue_id, uint
 
 /*PDCP num tx pdu status flexRAN*/
 uint32_t flexran_get_pdcp_tx(const mid_t mod_id,  const mid_t ue_id, const lcid_t lcid){
-  if (mod_id <0 || mod_id> MAX_NUM_CCs || ue_id<0 || ue_id> NUMBER_OF_UE_MAX || lcid<0 || lcid>NB_RB_MAX)
+  if (mod_id <0 || mod_id> MAX_NUM_CCs || ue_id<0 || ue_id> MAX_MOBILES_PER_ENB || lcid<0 || lcid>NB_RB_MAX)
     return -1;
   return Pdcp_stats_tx[mod_id][ue_id][lcid];
 }
diff --git a/openair2/LAYER2/MAC/defs_NB_IoT.h b/openair2/LAYER2/MAC/defs_NB_IoT.h
index 77c0828b283076bd4edce975379dfe99f4bbd321..02f9c47ea5cdc7d0443cd13c64492460014d4adb 100644
--- a/openair2/LAYER2/MAC/defs_NB_IoT.h
+++ b/openair2/LAYER2/MAC/defs_NB_IoT.h
@@ -98,7 +98,7 @@ typedef enum{
   DL
 }message_direction_t;
 
-#define MAX_NUMBER_OF_UE_MAX_NB_IoT 20
+#define MAX_MAX_MOBILES_PER_ENB_NB_IoT 20
 #define SCH_PAYLOAD_SIZE_MAX_NB_IoT 320
 #define MAX_NUMBER_OF_SIBs_NB_IoT 16
 
@@ -233,17 +233,17 @@ typedef struct{
 typedef struct {
 
   /// DCI template and MAC connection parameters for UEs
-  UE_TEMPLATE_NB_IoT UE_template_NB_IoT[MAX_NUMBER_OF_UE_MAX_NB_IoT];
+  UE_TEMPLATE_NB_IoT UE_template_NB_IoT[MAX_MAX_MOBILES_PER_ENB_NB_IoT];
 
   /// NPDCCH Period and searching space info
   NPDCCH_config_dedicated_NB_IoT_t NPDCCH_config_dedicated;
-  //int next[MAX_NUMBER_OF_UE_MAX_NB_IoT];
+  //int next[MAX_MAX_MOBILES_PER_ENB_NB_IoT];
   // -1:No UE in list
   int head;
   // -1:No UE in list
   int tail;
   int num_UEs;
-  //boolean_t active[MAX_NUMBER_OF_UE_MAX_NB_IoT];
+  //boolean_t active[MAX_MAX_MOBILES_PER_ENB_NB_IoT];
 
 } UE_list_NB_IoT_t;
 
@@ -261,7 +261,7 @@ typedef struct{
   // flag to indicate scheduling type1 NPDCCH CSS with different CE level
   uint8_t flag_type1_css[3];
   // flag to indicate scheduling NPDCCH USS with UE list
-  uint8_t flag_uss[MAX_NUMBER_OF_UE_MAX_NB_IoT];
+  uint8_t flag_uss[MAX_MAX_MOBILES_PER_ENB_NB_IoT];
   // flag to indicate scheduling sib1/MIB
   uint8_t flag_fix_scheduling;
   // number of the type2 css to schedule in this period
@@ -494,7 +494,7 @@ typedef struct eNB_MAC_INST_NB_IoT_s {
   RA_template_list_t RA_msg3_list;
   RA_template_list_t RA_msg4_list;
 
-  RA_TEMPLATE_NB_IoT RA_template[MAX_NUMBER_OF_UE_MAX_NB_IoT];
+  RA_TEMPLATE_NB_IoT RA_template[MAX_MAX_MOBILES_PER_ENB_NB_IoT];
 
   //int32_t last_tx_subframe;
 
diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c
index 5d9add510e394705d86405fedfe13e38bc6b9d7a..f2aed56146e8dcff7b282fe42433a729cacd3aba 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler.c
@@ -105,9 +105,8 @@ schedule_SRS(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP)
       
       if ((1 << tmp) & deltaTSFC) {
 	// This is an SRS subframe, loop over UEs
-	for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) {
-	  if (RC.mac[module_idP]->UE_list.active[UE_id] != TRUE)
-	    continue;
+	for (UE_id = 0; UE_id < MAX_MOBILES_PER_ENB; UE_id++) {
+	  if (!RC.mac[module_idP]->UE_list.active[UE_id]) continue;
 	  ul_req = &RC.mac[module_idP]->UL_req[CC_id].ul_config_request_body;
 	  // drop the allocation if the UE hasn't send RRCConnectionSetupComplete yet
 	  if (mac_eNB_get_rrc_status(module_idP,UE_RNTI(module_idP, UE_id)) < RRC_CONNECTED) continue;
@@ -167,9 +166,8 @@ schedule_CSI(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP)
   for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
 
     cc = &eNB->common_channels[CC_id];
-    for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) {
-      if (UE_list->active[UE_id] != TRUE)
-	continue;
+    for (UE_id = 0; UE_id < MAX_MOBILES_PER_ENB; UE_id++) {
+      if (!UE_list->active[UE_id]) continue;
 
       ul_req = &RC.mac[module_idP]->UL_req[CC_id].ul_config_request_body;
 
@@ -253,8 +251,8 @@ schedule_SR(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP)
   for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
     RC.mac[module_idP]->UL_req[CC_id].sfn_sf = (frameP << 4) + subframeP;
 
-    for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) {
-      if (RC.mac[module_idP]->UE_list.active[UE_id] != TRUE) continue;
+    for (UE_id = 0; UE_id < MAX_MOBILES_PER_ENB; UE_id++) {
+      if (!RC.mac[module_idP]->UE_list.active[UE_id]) continue;
 
       ul_req        = &RC.mac[module_idP]->UL_req[CC_id];
       ul_req_body   = &ul_req->ul_config_request_body;
@@ -532,92 +530,91 @@ eNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frameP,
   }
 
   // refresh UE list based on UEs dropped by PHY in previous subframe
-  for (i = 0; i < NUMBER_OF_UE_MAX; i++) {
-    if (UE_list->active[i] != TRUE)
-      continue;
+  for (i = 0; i < MAX_MOBILES_PER_ENB; i++) {
+    if (UE_list->active[i]) {
 
-    rnti = UE_RNTI(module_idP, i);
-    CC_id = UE_PCCID(module_idP, i);
-
-    if (((frameP&127) == 0) && (subframeP == 0)) {
-      LOG_I(MAC,
-            "UE  rnti %x : %s, PHR %d dB DL CQI %d PUSCH SNR %d PUCCH SNR %d\n",
-            rnti,
-            UE_list->UE_sched_ctrl[i].ul_out_of_sync ==
-            0 ? "in synch" : "out of sync",
-            UE_list->UE_template[CC_id][i].phr_info,
-            UE_list->UE_sched_ctrl[i].dl_cqi[CC_id],
-            (UE_list->UE_sched_ctrl[i].pusch_snr[CC_id] - 128) / 2,
-            (UE_list->UE_sched_ctrl[i].pucch1_snr[CC_id] - 128) / 2);
-    }
-
-    RC.eNB[module_idP][CC_id]->pusch_stats_bsr[i][(frameP * 10) +
-						  subframeP] = -63;
-    if (i == UE_list->head)
-      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
-    RC.mac[module_idP]->UE_list.UE_sched_ctrl[i].ul_inactivity_timer++;
-    
-    RC.mac[module_idP]->UE_list.UE_sched_ctrl[i].cqi_req_timer++;
-    LOG_D(MAC, "UE %d/%x : ul_inactivity %d, cqi_req %d\n", i, rnti,
-	  RC.mac[module_idP]->UE_list.UE_sched_ctrl[i].
-	  ul_inactivity_timer,
-	  RC.mac[module_idP]->UE_list.UE_sched_ctrl[i].cqi_req_timer);
-    check_ul_failure(module_idP, CC_id, i, frameP, subframeP);
-    
-    if (RC.mac[module_idP]->UE_list.UE_sched_ctrl[i].ue_reestablishment_reject_timer > 0) {
-      RC.mac[module_idP]->UE_list.UE_sched_ctrl[i].ue_reestablishment_reject_timer++;
-      if(RC.mac[module_idP]->UE_list.UE_sched_ctrl[i].ue_reestablishment_reject_timer >=
-	 RC.mac[module_idP]->UE_list.UE_sched_ctrl[i].ue_reestablishment_reject_timer_thres) {
-	RC.mac[module_idP]->UE_list.UE_sched_ctrl[i].ue_reestablishment_reject_timer = 0;
-	for (int ue_id_l = 0; ue_id_l < NUMBER_OF_UE_MAX; ue_id_l++) {
-	  if (reestablish_rnti_map[ue_id_l][0] == rnti) {
-	    // clear currentC-RNTI from map
-	    reestablish_rnti_map[ue_id_l][0] = 0;
-	    reestablish_rnti_map[ue_id_l][1] = 0;
-	    break;
+      rnti = UE_RNTI(module_idP, i);
+      CC_id = UE_PCCID(module_idP, i);
+      
+      if (((frameP&127) == 0) && (subframeP == 0)) {
+	LOG_I(MAC,
+	      "UE  rnti %x : %s, PHR %d dB DL CQI %d PUSCH SNR %d PUCCH SNR %d\n",
+	      rnti,
+	      UE_list->UE_sched_ctrl[i].ul_out_of_sync ==
+	      0 ? "in synch" : "out of sync",
+	      UE_list->UE_template[CC_id][i].phr_info,
+	      UE_list->UE_sched_ctrl[i].dl_cqi[CC_id],
+	      (UE_list->UE_sched_ctrl[i].pusch_snr[CC_id] - 128) / 2,
+	      (UE_list->UE_sched_ctrl[i].pucch1_snr[CC_id] - 128) / 2);
+      }
+      
+      RC.eNB[module_idP][CC_id]->pusch_stats_bsr[i][(frameP * 10) +
+						    subframeP] = -63;
+      if (i == UE_list->head)
+	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
+      RC.mac[module_idP]->UE_list.UE_sched_ctrl[i].ul_inactivity_timer++;
+      
+      RC.mac[module_idP]->UE_list.UE_sched_ctrl[i].cqi_req_timer++;
+      LOG_D(MAC, "UE %d/%x : ul_inactivity %d, cqi_req %d\n", i, rnti,
+	    RC.mac[module_idP]->UE_list.UE_sched_ctrl[i].
+	    ul_inactivity_timer,
+	    RC.mac[module_idP]->UE_list.UE_sched_ctrl[i].cqi_req_timer);
+      check_ul_failure(module_idP, CC_id, i, frameP, subframeP);
+      
+      if (RC.mac[module_idP]->UE_list.UE_sched_ctrl[i].ue_reestablishment_reject_timer > 0) {
+	RC.mac[module_idP]->UE_list.UE_sched_ctrl[i].ue_reestablishment_reject_timer++;
+	if(RC.mac[module_idP]->UE_list.UE_sched_ctrl[i].ue_reestablishment_reject_timer >=
+	   RC.mac[module_idP]->UE_list.UE_sched_ctrl[i].ue_reestablishment_reject_timer_thres) {
+	  RC.mac[module_idP]->UE_list.UE_sched_ctrl[i].ue_reestablishment_reject_timer = 0;
+	  for (int ue_id_l = 0; ue_id_l < MAX_MOBILES_PER_ENB; ue_id_l++) {
+	    if (reestablish_rnti_map[ue_id_l][0] == rnti) {
+	      // clear currentC-RNTI from map
+	      reestablish_rnti_map[ue_id_l][0] = 0;
+	      reestablish_rnti_map[ue_id_l][1] = 0;
+	      break;
+	    }
 	  }
-	}
-	// Note: This should not be done in the MAC!
-	for (int ii=0; ii<NUMBER_OF_UE_MAX; ii++) {
-	  LTE_eNB_ULSCH_t *ulsch = RC.eNB[module_idP][CC_id]->ulsch[ii];
-	  if((ulsch != NULL) && (ulsch->rnti == rnti)){
-	    LOG_I(MAC, "clean_eNb_ulsch UE %x \n", rnti);
-	    clean_eNb_ulsch(ulsch);
+	  // Note: This should not be done in the MAC!
+	  for (int ii=0; ii<MAX_MOBILES_PER_ENB; ii++) {
+	    LTE_eNB_ULSCH_t *ulsch = RC.eNB[module_idP][CC_id]->ulsch[ii];
+	    if((ulsch != NULL) && (ulsch->rnti == rnti)){
+	      LOG_I(MAC, "clean_eNb_ulsch UE %x \n", rnti);
+	      clean_eNb_ulsch(ulsch);
+	    }
 	  }
-	}
-	for (int ii=0; ii<NUMBER_OF_UE_MAX; ii++) {
-	  LTE_eNB_DLSCH_t *dlsch = RC.eNB[module_idP][CC_id]->dlsch[ii][0];
-	  if((dlsch != NULL) && (dlsch->rnti == rnti)){
-	    LOG_I(MAC, "clean_eNb_dlsch UE %x \n", rnti);
-	    clean_eNb_dlsch(dlsch);
+	  for (int ii=0; ii<MAX_MOBILES_PER_ENB; ii++) {
+	    LTE_eNB_DLSCH_t *dlsch = RC.eNB[module_idP][CC_id]->dlsch[ii][0];
+	    if((dlsch != NULL) && (dlsch->rnti == rnti)){
+	      LOG_I(MAC, "clean_eNb_dlsch UE %x \n", rnti);
+	      clean_eNb_dlsch(dlsch);
+	    }
 	  }
-	}
-	
-	for(int j = 0; j < 10; j++){
-	  nfapi_ul_config_request_body_t *ul_req_tmp = NULL;
-	  ul_req_tmp = &RC.mac[module_idP]->UL_req_tmp[CC_id][j].ul_config_request_body;
-	  if(ul_req_tmp){
-	    int pdu_number = ul_req_tmp->number_of_pdus;
-	    for(int pdu_index = pdu_number-1; pdu_index >= 0; pdu_index--){
-	      if(ul_req_tmp->ul_config_pdu_list[pdu_index].ulsch_pdu.ulsch_pdu_rel8.rnti == rnti){
-		LOG_I(MAC, "remove UE %x from ul_config_pdu_list %d/%d\n", rnti, pdu_index, pdu_number);
-		if(pdu_index < pdu_number -1){
-		  memcpy(&ul_req_tmp->ul_config_pdu_list[pdu_index], &ul_req_tmp->ul_config_pdu_list[pdu_index+1], (pdu_number-1-pdu_index) * sizeof(nfapi_ul_config_request_pdu_t));
+	  
+	  for(int j = 0; j < 10; j++){
+	    nfapi_ul_config_request_body_t *ul_req_tmp = NULL;
+	    ul_req_tmp = &RC.mac[module_idP]->UL_req_tmp[CC_id][j].ul_config_request_body;
+	    if(ul_req_tmp){
+	      int pdu_number = ul_req_tmp->number_of_pdus;
+	      for(int pdu_index = pdu_number-1; pdu_index >= 0; pdu_index--){
+		if(ul_req_tmp->ul_config_pdu_list[pdu_index].ulsch_pdu.ulsch_pdu_rel8.rnti == rnti){
+		  LOG_I(MAC, "remove UE %x from ul_config_pdu_list %d/%d\n", rnti, pdu_index, pdu_number);
+		  if(pdu_index < pdu_number -1){
+		    memcpy(&ul_req_tmp->ul_config_pdu_list[pdu_index], &ul_req_tmp->ul_config_pdu_list[pdu_index+1], (pdu_number-1-pdu_index) * sizeof(nfapi_ul_config_request_pdu_t));
+		  }
+		  ul_req_tmp->number_of_pdus--;
 		}
-		ul_req_tmp->number_of_pdus--;
 	      }
 	    }
 	  }
-	}
 	rrc_mac_remove_ue(module_idP,rnti);
+	}
       }
     }
   }
-
   PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, ENB_FLAG_YES,
 				 NOT_A_RNTI, frameP, subframeP,
 				 module_idP);
diff --git a/openair2/LAYER2/MAC/eNB_scheduler_RA.c b/openair2/LAYER2/MAC/eNB_scheduler_RA.c
index 59eabe8b809b234e6b545f7bc05c52e43630ecfa..d9aee92a91437c3a78548728842dd7ca93e6009b 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_RA.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_RA.c
@@ -1476,18 +1476,18 @@ initiate_ra_proc(module_id_t module_idP,
             /* TODO: find better procedure to allocate RNTI */
 	    do {
 #if defined(USRP_REC_PLAY) // deterministic rnti in usrp record/playback mode
-	        static int drnti[NUMBER_OF_UE_MAX] = { 0xbda7, 0x71da, 0x9c40, 0xc350, 0x2710, 0x4e20, 0x7530, 0x1388, 0x3a98, 0x61a8, 0x88b8, 0xafc8, 0xd6d8, 0x1b58, 0x4268, 0x6978 };
+	        static int drnti[MAX_MOBILES_PER_ENB] = { 0xbda7, 0x71da, 0x9c40, 0xc350, 0x2710, 0x4e20, 0x7530, 0x1388, 0x3a98, 0x61a8, 0x88b8, 0xafc8, 0xd6d8, 0x1b58, 0x4268, 0x6978 };
 	        int j = 0;
 		int nb_ue = 0;
-		for (j = 0; j < NUMBER_OF_UE_MAX; j++) {
+		for (j = 0; j < MAX_MOBILES_PER_ENB; j++) {
 		    if (UE_RNTI(module_idP, j) > 0) {
 		        nb_ue++;
 		    } else {
 		        break;
 		    }
 		}
-		if (nb_ue >= NUMBER_OF_UE_MAX) {
-		    printf("No more free RNTI available, increase NUMBER_OF_UE_MAX\n");
+		if (nb_ue >= MAX_MOBILES_PER_ENB) {
+		    printf("No more free RNTI available, increase MAX_MOBILES_PER_ENB\n");
 		    abort();
 		}
 		ra[i].rnti = drnti[nb_ue];
diff --git a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c
index 66b3c57610a5a5407972775818b7ce5f87aba1e6..ba5d43899c962c327e6f017d6f7ae8e66163574a 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c
@@ -1773,7 +1773,7 @@ void schedule_PCH(module_id_t module_idP,frame_t frameP,sub_frame_t subframeP)
     vrb_map         = (void*)&cc->vrb_map;
     n_rb_dl         = to_prb(cc->mib->message.dl_Bandwidth);
     dl_req          = &eNB->DL_req[CC_id].dl_config_request_body;
-    for (uint16_t i = 0; i < NUMBER_OF_UE_MAX; i++) {
+    for (uint16_t i = 0; i < MAX_MOBILES_PER_ENB; i++) {
       if (UE_PF_PO[CC_id][i].enable_flag != TRUE) {
         continue;
       }
diff --git a/openair2/LAYER2/MAC/eNB_scheduler_mch.c b/openair2/LAYER2/MAC/eNB_scheduler_mch.c
index 5997596119ec5822ad683426d36e74a3b9d50c02..ccaceba0794f84d2899b21b7f26e2a6683840034 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_mch.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_mch.c
@@ -647,7 +647,7 @@ schedule_MBMS(module_id_t module_idP, uint8_t CC_id, frame_t frameP,
 						     (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]);
+	    //sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP,frameP, MBMS_FLAG_NO,  MTCH+(MAX_NUM_RB*(MAX_MOBILES_PER_ENB+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);
diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c
index 6a11c776180884607392dbd87811f5636df7753b..ae8524dd5932825e8125d37513783bf88e707887 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c
@@ -1667,7 +1667,7 @@ void init_ue_sched_info(void)
 
   for (i = 0; i < NUMBER_OF_eNB_MAX; i++) {
     for (k = 0; k < MAX_NUM_CCs; k++) {
-      for (j = 0; j < NUMBER_OF_UE_MAX; j++) {
+      for (j = 0; j < MAX_MOBILES_PER_ENB; j++) {
 	// init DL
 	eNB_dlsch_info[i][k][j].weight = 0;
 	eNB_dlsch_info[i][k][j].subframe = 0;
@@ -1698,7 +1698,7 @@ int find_UE_id(module_id_t mod_idP, rnti_t rntiP)
   int UE_id;
   UE_list_t *UE_list = &RC.mac[mod_idP]->UE_list;
 
-  for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) {
+  for (UE_id = 0; UE_id < MAX_MOBILES_PER_ENB; UE_id++) {
     if (UE_list->active[UE_id] != TRUE)
       continue;
     if (UE_list->UE_template[UE_PCCID(mod_idP, UE_id)][UE_id].rnti ==
@@ -1839,7 +1839,7 @@ int add_new_ue(module_id_t mod_idP, int cc_idP, rnti_t rntiP, int harq_pidP
 	mod_idP, cc_idP, rntiP, UE_list->avail, UE_list->num_UEs);
   dump_ue_list(UE_list, 0);
 
-  for (i = 0; i < NUMBER_OF_UE_MAX; i++) {
+  for (i = 0; i < MAX_MOBILES_PER_ENB; i++) {
     if (UE_list->active[i] == TRUE)
       continue;
     UE_id = i;
@@ -2325,9 +2325,7 @@ int get_bw_index(module_id_t module_id, uint8_t CC_id)
 {
   int bw_index = 0;
 
-  int N_RB_DL =
-    to_prb(RC.mac[module_id]->common_channels[CC_id].mib->
-	   message.dl_Bandwidth);
+  int N_RB_DL = to_prb(RC.mac[module_id]->common_channels[CC_id].mib->message.dl_Bandwidth);
 
   switch (N_RB_DL) {
   case 6:			// 1.4 MHz
@@ -2360,9 +2358,7 @@ int get_bw_index(module_id_t module_id, uint8_t CC_id)
 int get_min_rb_unit(module_id_t module_id, uint8_t CC_id)
 {
   int min_rb_unit = 0;
-  int N_RB_DL =
-    to_prb(RC.mac[module_id]->common_channels[CC_id].mib->
-	   message.dl_Bandwidth);
+  int N_RB_DL = to_prb(RC.mac[module_id]->common_channels[CC_id].mib->message.dl_Bandwidth);
 
   switch (N_RB_DL) {
   case 6:			// 1.4 MHz
diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c
index ba98f85268ae25b51d45cbfbc28a725cfc302f7d..fd2817e3418b9ae79dca316c06c2a28ae29bb094 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c
@@ -140,7 +140,7 @@ rx_sdu(const module_id_t enb_mod_idP,
 
   start_meas(&mac->rx_ulsch_sdu);
 
-  if ((UE_id > NUMBER_OF_UE_MAX) || (UE_id == -1))
+  if ((UE_id > MAX_MOBILES_PER_ENB) || (UE_id == -1))
     for (ii = 0; ii < NB_RB_MAX; ii++) {
       rx_lengths[ii] = 0;
     }
diff --git a/openair2/LAYER2/MAC/mac_extern.h b/openair2/LAYER2/MAC/mac_extern.h
index 618075aed92bec77b35acbbabbefceb5cf96e3e2..4ac7cf4d58e79ca0363cd9d813232135b551b9f1 100644
--- a/openair2/LAYER2/MAC/mac_extern.h
+++ b/openair2/LAYER2/MAC/mac_extern.h
@@ -52,8 +52,8 @@ extern UE_RRC_INST *UE_rrc_inst;
 extern UE_MAC_INST *UE_mac_inst;
 
 
-extern eNB_ULSCH_INFO eNB_ulsch_info[NUMBER_OF_eNB_MAX][MAX_NUM_CCs][NUMBER_OF_UE_MAX];	// eNBxUE = 8x8
-extern eNB_DLSCH_INFO eNB_dlsch_info[NUMBER_OF_eNB_MAX][MAX_NUM_CCs][NUMBER_OF_UE_MAX];	// eNBxUE = 8x8
+extern eNB_ULSCH_INFO eNB_ulsch_info[NUMBER_OF_eNB_MAX][MAX_NUM_CCs][MAX_MOBILES_PER_ENB];	// eNBxUE = 8x8
+extern eNB_DLSCH_INFO eNB_dlsch_info[NUMBER_OF_eNB_MAX][MAX_NUM_CCs][MAX_MOBILES_PER_ENB];	// eNBxUE = 8x8
 
 
 
diff --git a/openair2/LAYER2/MAC/mac_vars.h b/openair2/LAYER2/MAC/mac_vars.h
index 549e6394d1f32906db2b480001c6096b4aab8a37..f90ba1ec9e1c2e2d86abae45b8173eccc6a779e1 100644
--- a/openair2/LAYER2/MAC/mac_vars.h
+++ b/openair2/LAYER2/MAC/mac_vars.h
@@ -103,8 +103,8 @@ int pCC_id[NUMBER_OF_eNB_MAX];
 
 
 
-eNB_ULSCH_INFO eNB_ulsch_info[NUMBER_OF_eNB_MAX][MAX_NUM_CCs][NUMBER_OF_UE_MAX];	// eNBxUE = 8x8
-eNB_DLSCH_INFO eNB_dlsch_info[NUMBER_OF_eNB_MAX][MAX_NUM_CCs][NUMBER_OF_UE_MAX];	// eNBxUE = 8x8
+eNB_ULSCH_INFO eNB_ulsch_info[NUMBER_OF_eNB_MAX][MAX_NUM_CCs][MAX_MOBILES_PER_ENB];	// eNBxUE = 8x8
+eNB_DLSCH_INFO eNB_dlsch_info[NUMBER_OF_eNB_MAX][MAX_NUM_CCs][MAX_MOBILES_PER_ENB];	// eNBxUE = 8x8
 
 
 #ifdef OPENAIR2
diff --git a/openair2/LAYER2/MAC/main.c b/openair2/LAYER2/MAC/main.c
index 819523dcf8a27cb01d12ca28d5e590b9ab835f54..062ead2a206d1e6db672afc02d60785e3b628abd 100644
--- a/openair2/LAYER2/MAC/main.c
+++ b/openair2/LAYER2/MAC/main.c
@@ -120,7 +120,7 @@ void mac_top_init_eNB(void)
 	UE_list->head_ul = -1;
 	UE_list->avail = 0;
 
-	for (list_el = 0; list_el < NUMBER_OF_UE_MAX - 1; list_el++) {
+	for (list_el = 0; list_el < MAX_MOBILES_PER_ENB - 1; list_el++) {
 	    UE_list->next[list_el] = list_el + 1;
 	    UE_list->next_ul[list_el] = list_el + 1;
 	}
@@ -144,7 +144,7 @@ void mac_init_cell_params(int Mod_idP, int CC_idP)
     UE_template =
 	(UE_TEMPLATE *) & RC.mac[Mod_idP]->UE_list.UE_template[CC_idP][0];
 
-    for (j = 0; j < NUMBER_OF_UE_MAX; j++) {
+    for (j = 0; j < MAX_MOBILES_PER_ENB; 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,
diff --git a/openair2/LAYER2/MAC/pre_processor.c b/openair2/LAYER2/MAC/pre_processor.c
index 7c2a17eff2c569ea6314d6782af19f8b00adda5b..0e052a2b62495044c2975186d16453fc7fcda9f5 100644
--- a/openair2/LAYER2/MAC/pre_processor.c
+++ b/openair2/LAYER2/MAC/pre_processor.c
@@ -307,7 +307,7 @@ maxround(module_id_t Mod_id, uint16_t rnti, int frame,
     UE_list_t *UE_list = &RC.mac[Mod_id]->UE_list;
     COMMON_channels_t *cc;
 
-    for (CC_id = 0; CC_id < NFAPI_CC_MAX; CC_id++) {
+    for (CC_id = 0; CC_id < RC.nb_mac_CC[Mod_id]; CC_id++) {
 
 	cc = &RC.mac[Mod_id]->common_channels[CC_id];
 
@@ -617,7 +617,7 @@ void dlsch_scheduler_pre_processor_accounting(module_id_t Mod_id,
   UE_sched_ctrl *ue_sched_ctl;
   COMMON_channels_t *cc;
 
-  for (CC_id = 0; CC_id < NFAPI_CC_MAX; CC_id++) {
+  for (CC_id = 0; CC_id < RC.nb_mac_CC[Mod_id]; CC_id++) {
     total_ue_count[CC_id] = 0;
     total_rbs_used[CC_id] = 0;
     average_rbs_per_user[CC_id] = 0;
@@ -1020,7 +1020,7 @@ dlsch_scheduler_pre_processor(module_id_t Mod_id,
   UE_sched_ctrl *ue_sched_ctl1, *ue_sched_ctl2;
 #endif
 
-  for (CC_id = 0; CC_id < NFAPI_CC_MAX; CC_id++) {
+  for (CC_id = 0; CC_id < RC.nb_mac_CC[Mod_id]; CC_id++) {
 
     if (mbsfn_flag[CC_id] > 0)    // If this CC is allocated for MBSFN skip it here
       continue;
@@ -1071,7 +1071,7 @@ dlsch_scheduler_pre_processor(module_id_t Mod_id,
 
 #ifdef TM5
   // This has to be revisited!!!!
-  for (CC_id = 0; CC_id < NFAPI_CC_MAX; CC_id++) {
+  for (CC_id = 0; CC_id < RC.nb_mac_CC[Mod_id]; CC_id++) {
   i1 = 0;
   i2 = 0;
   i3 = 0;
@@ -1428,7 +1428,7 @@ ulsch_scheduler_pre_processor(module_id_t module_idP,
 
     // we need to distribute RBs among UEs
     // step1:  reset the vars
-    for (CC_id = 0; CC_id < NFAPI_CC_MAX; CC_id++) {
+    for (CC_id = 0; CC_id < RC.nb_mac_CC[module_idP]; CC_id++) {
       total_allocated_rbs[CC_id] = 0;
       total_remaining_rbs[CC_id] = 0;
       average_rbs_per_user[CC_id] = 0;
@@ -1601,7 +1601,7 @@ ulsch_scheduler_pre_processor(module_id_t module_idP,
     /* this logging is wrong, ue_sched_ctl may not be valid here
      * TODO: fix
      */
-    for (CC_id = 0; CC_id < NFAPI_CC_MAX; CC_id++) {
+    for (CC_id = 0; CC_id < RC.nb_mac_CC[module_idP]; CC_id++) {
 
 	if (total_allocated_rbs[CC_id] > 0) {
 	    LOG_D(MAC, "[eNB %d] total RB allocated for all UEs = %d/%d\n",
@@ -1660,12 +1660,9 @@ assign_max_mcs_min_rb(module_id_t module_idP, int slice_id, int frameP,
       // This is the actual CC_id in the list
       CC_id = UE_list->ordered_ULCCids[n][UE_id];
 
-      if (CC_id >= NFAPI_CC_MAX) {
-        LOG_E(MAC, "CC_id %u should be < %u, loop n=%u < numactiveULCCs[%u]=%u",
-              CC_id, NFAPI_CC_MAX, n, UE_id, UE_list->numactiveULCCs[UE_id]);
-      }
 
-      AssertFatal(CC_id < NFAPI_CC_MAX,
+
+      AssertFatal(CC_id < RC.nb_mac_CC[module_idP],
                   "CC_id %u should be < %u, loop n=%u < numactiveULCCs[%u]=%u",
                   CC_id, NFAPI_CC_MAX, n, UE_id,
                   UE_list->numactiveULCCs[UE_id]);
diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c
index 51817a02e1388da90ef96e04fd57bc86a4166ff1..67571f873643c361eb0d17cf50eed3494f7d4a8c 100644
--- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c
+++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c
@@ -393,7 +393,7 @@ boolean_t pdcp_data_req(
    * so we return TRUE afterwards
    */
   
-  for (pdcp_uid=0; pdcp_uid< NUMBER_OF_UE_MAX;pdcp_uid++){
+  for (pdcp_uid=0; pdcp_uid< MAX_MOBILES_PER_ENB;pdcp_uid++){
     if (pdcp_enb[ctxt_pP->module_id].rnti[pdcp_uid] == ctxt_pP->rnti ) 
       break;
   }
@@ -808,7 +808,7 @@ pdcp_data_ind(
    * XXX Following two actions are identical, is there a merge error?
    */
   
-  for (pdcp_uid=0; pdcp_uid< NUMBER_OF_UE_MAX;pdcp_uid++){
+  for (pdcp_uid=0; pdcp_uid< MAX_MOBILES_PER_ENB;pdcp_uid++){
     if (pdcp_enb[ctxt_pP->module_id].rnti[pdcp_uid] == ctxt_pP->rnti ){
       break;
     }
@@ -856,7 +856,7 @@ void pdcp_update_stats(const protocol_ctxt_t* const  ctxt_pP){
   
  // these stats are measured for both eNB and UE on per seond basis 
   for (rb_id =0; rb_id < NB_RB_MAX; rb_id ++){
-    for (pdcp_uid=0; pdcp_uid< NUMBER_OF_UE_MAX;pdcp_uid++){
+    for (pdcp_uid=0; pdcp_uid< MAX_MOBILES_PER_ENB;pdcp_uid++){
       //printf("frame %d and subframe %d \n", pdcp_enb[ctxt_pP->module_id].frame, pdcp_enb[ctxt_pP->module_id].subframe);
       // tx stats
       if (Pdcp_stats_tx_window_ms[ctxt_pP->module_id][pdcp_uid] > 0 &&
@@ -1060,14 +1060,14 @@ pdcp_run (
 
 void pdcp_add_UE(const protocol_ctxt_t* const  ctxt_pP){
   int i, ue_flag=1; //, ret=-1; to be decied later
-  for (i=0; i < NUMBER_OF_UE_MAX; i++){
+  for (i=0; i < MAX_MOBILES_PER_ENB; i++){
     if (pdcp_enb[ctxt_pP->module_id].rnti[i] == ctxt_pP->rnti) {
       ue_flag=-1;
       break;
     }
   }
   if (ue_flag == 1 ){
-    for (i=0; i < NUMBER_OF_UE_MAX ; i++){
+    for (i=0; i < MAX_MOBILES_PER_ENB ; i++){
       if (pdcp_enb[ctxt_pP->module_id].rnti[i] == 0 ){
 	pdcp_enb[ctxt_pP->module_id].rnti[i]=ctxt_pP->rnti;
 	pdcp_enb[ctxt_pP->module_id].uid[i]=i;
@@ -1095,7 +1095,7 @@ pdcp_remove_UE(
   int i; 
    // check and remove SRBs first
 
-  for(int i = 0;i<NUMBER_OF_UE_MAX;i++){
+  for(int i = 0;i<MAX_MOBILES_PER_ENB;i++){
     if(pdcp_eNB_UE_instance_to_rnti[i] == ctxt_pP->rnti){
       pdcp_eNB_UE_instance_to_rnti[i] = NOT_A_RNTI;
       break;
@@ -1116,7 +1116,7 @@ pdcp_remove_UE(
   (void)h_rc; /* remove gcc warning "set but not used" */
 
   // remove ue for pdcp enb inst
-   for (i=0; i < NUMBER_OF_UE_MAX; i++) {
+   for (i=0; i < MAX_MOBILES_PER_ENB; i++) {
     if (pdcp_enb[ctxt_pP->module_id].rnti[i] == ctxt_pP->rnti ) {
       LOG_I(PDCP, "remove uid is %d/%d %x\n", i,
 	    pdcp_enb[ctxt_pP->module_id].uid[i],
@@ -1553,16 +1553,16 @@ pdcp_config_req_asn1 (
       //pdcp_eNB_UE_instance_to_rnti[ctxtP->module_id] = ctxt_pP->rnti;
 //      pdcp_eNB_UE_instance_to_rnti[pdcp_eNB_UE_instance_to_rnti_index] = ctxt_pP->rnti;
       if( srb_flagP == SRB_FLAG_NO ) {
-          for(int i = 0;i<NUMBER_OF_UE_MAX;i++){
+          for(int i = 0;i<MAX_MOBILES_PER_ENB;i++){
               if(pdcp_eNB_UE_instance_to_rnti[pdcp_eNB_UE_instance_to_rnti_index] == NOT_A_RNTI){
                   break;
               }
-              pdcp_eNB_UE_instance_to_rnti_index = (pdcp_eNB_UE_instance_to_rnti_index + 1) % NUMBER_OF_UE_MAX;
+              pdcp_eNB_UE_instance_to_rnti_index = (pdcp_eNB_UE_instance_to_rnti_index + 1) % MAX_MOBILES_PER_ENB;
           }
           pdcp_eNB_UE_instance_to_rnti[pdcp_eNB_UE_instance_to_rnti_index] = ctxt_pP->rnti;
-          pdcp_eNB_UE_instance_to_rnti_index = (pdcp_eNB_UE_instance_to_rnti_index + 1) % NUMBER_OF_UE_MAX;
+          pdcp_eNB_UE_instance_to_rnti_index = (pdcp_eNB_UE_instance_to_rnti_index + 1) % MAX_MOBILES_PER_ENB;
       }
-      //pdcp_eNB_UE_instance_to_rnti_index = (pdcp_eNB_UE_instance_to_rnti_index + 1) % NUMBER_OF_UE_MAX;
+      //pdcp_eNB_UE_instance_to_rnti_index = (pdcp_eNB_UE_instance_to_rnti_index + 1) % MAX_MOBILES_PER_ENB;
     } else {
       pdcp_pP->is_ue = TRUE;
       pdcp_UE_UE_module_id_to_rnti[ctxt_pP->module_id] = ctxt_pP->rnti;
@@ -2009,7 +2009,7 @@ void pdcp_layer_init(void)
   pdcp_coll_p = hashtable_create ((maxDRB + 2) * 16, NULL, pdcp_free);
   AssertFatal(pdcp_coll_p != NULL, "UNRECOVERABLE error, PDCP hashtable_create failed");
 
-  for (instance = 0; instance < NUMBER_OF_UE_MAX; instance++) {
+  for (instance = 0; instance < MAX_MOBILES_PER_ENB; instance++) {
 #if defined(Rel10) || defined(Rel14)
 
     for (service_id = 0; service_id < maxServiceCount; service_id++) {
@@ -2047,7 +2047,7 @@ void pdcp_layer_init(void)
   memset(Pdcp_stats_tx_window_ms, 0, sizeof(Pdcp_stats_tx_window_ms));
   memset(Pdcp_stats_rx_window_ms, 0, sizeof(Pdcp_stats_rx_window_ms));
   for (i =0; i< MAX_NUM_CCs ; i ++){
-    for (j=0; j< NUMBER_OF_UE_MAX;j++){
+    for (j=0; j< MAX_MOBILES_PER_ENB;j++){
       Pdcp_stats_tx_window_ms[i][j]=100;
       Pdcp_stats_rx_window_ms[i][j]=100;
     }
diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.h b/openair2/LAYER2/PDCP_v10.1.0/pdcp.h
index 12076c1b6c47563b5b4543ec4baa8b4c1c62cbe9..ed5e1c6b42861fd3d91ffc364a90644281ff6c37 100644
--- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.h
+++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.h
@@ -94,34 +94,34 @@ extern int             pdcp_instance_cnt;
 int init_pdcp_thread(void);
 void cleanup_pdcp_thread(void);
 
-public_pdcp(uint32_t Pdcp_stats_tx_window_ms[MAX_NUM_CCs][NUMBER_OF_UE_MAX]);
-public_pdcp(uint32_t Pdcp_stats_tx_bytes[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]);
-public_pdcp(uint32_t Pdcp_stats_tx_bytes_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]);
-public_pdcp(uint32_t Pdcp_stats_tx_bytes_tmp_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]);
-public_pdcp(uint32_t Pdcp_stats_tx[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]);
-public_pdcp(uint32_t Pdcp_stats_tx_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]);
-public_pdcp(uint32_t Pdcp_stats_tx_tmp_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]);
-public_pdcp(uint32_t Pdcp_stats_tx_sn[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]);
-public_pdcp(uint32_t Pdcp_stats_tx_throughput_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]);
-public_pdcp(uint32_t Pdcp_stats_tx_aiat[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]);
-public_pdcp(uint32_t Pdcp_stats_tx_aiat_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]);
-public_pdcp(uint32_t Pdcp_stats_tx_aiat_tmp_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]);
-public_pdcp(uint32_t Pdcp_stats_tx_iat[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]);
-
-public_pdcp(uint32_t Pdcp_stats_rx_window_ms[MAX_NUM_CCs][NUMBER_OF_UE_MAX]);
-public_pdcp(uint32_t Pdcp_stats_rx[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]);
-public_pdcp(uint32_t Pdcp_stats_rx_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]);
-public_pdcp(uint32_t Pdcp_stats_rx_tmp_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]);
-public_pdcp(uint32_t Pdcp_stats_rx_bytes[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]);
-public_pdcp(uint32_t Pdcp_stats_rx_bytes_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]);
-public_pdcp(uint32_t Pdcp_stats_rx_bytes_tmp_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]);
-public_pdcp(uint32_t Pdcp_stats_rx_sn[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]);
-public_pdcp(uint32_t Pdcp_stats_rx_goodput_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]);
-public_pdcp(uint32_t Pdcp_stats_rx_aiat[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]);
-public_pdcp(uint32_t Pdcp_stats_rx_aiat_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]);
-public_pdcp(uint32_t Pdcp_stats_rx_aiat_tmp_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]);
-public_pdcp(uint32_t Pdcp_stats_rx_iat[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]);
-public_pdcp(uint32_t Pdcp_stats_rx_outoforder[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]);
+public_pdcp(uint32_t Pdcp_stats_tx_window_ms[MAX_NUM_CCs][MAX_MOBILES_PER_ENB]);
+public_pdcp(uint32_t Pdcp_stats_tx_bytes[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]);
+public_pdcp(uint32_t Pdcp_stats_tx_bytes_w[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]);
+public_pdcp(uint32_t Pdcp_stats_tx_bytes_tmp_w[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]);
+public_pdcp(uint32_t Pdcp_stats_tx[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]);
+public_pdcp(uint32_t Pdcp_stats_tx_w[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]);
+public_pdcp(uint32_t Pdcp_stats_tx_tmp_w[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]);
+public_pdcp(uint32_t Pdcp_stats_tx_sn[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]);
+public_pdcp(uint32_t Pdcp_stats_tx_throughput_w[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]);
+public_pdcp(uint32_t Pdcp_stats_tx_aiat[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]);
+public_pdcp(uint32_t Pdcp_stats_tx_aiat_w[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]);
+public_pdcp(uint32_t Pdcp_stats_tx_aiat_tmp_w[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]);
+public_pdcp(uint32_t Pdcp_stats_tx_iat[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]);
+
+public_pdcp(uint32_t Pdcp_stats_rx_window_ms[MAX_NUM_CCs][MAX_MOBILES_PER_ENB]);
+public_pdcp(uint32_t Pdcp_stats_rx[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]);
+public_pdcp(uint32_t Pdcp_stats_rx_w[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]);
+public_pdcp(uint32_t Pdcp_stats_rx_tmp_w[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]);
+public_pdcp(uint32_t Pdcp_stats_rx_bytes[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]);
+public_pdcp(uint32_t Pdcp_stats_rx_bytes_w[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]);
+public_pdcp(uint32_t Pdcp_stats_rx_bytes_tmp_w[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]);
+public_pdcp(uint32_t Pdcp_stats_rx_sn[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]);
+public_pdcp(uint32_t Pdcp_stats_rx_goodput_w[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]);
+public_pdcp(uint32_t Pdcp_stats_rx_aiat[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]);
+public_pdcp(uint32_t Pdcp_stats_rx_aiat_w[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]);
+public_pdcp(uint32_t Pdcp_stats_rx_aiat_tmp_w[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]);
+public_pdcp(uint32_t Pdcp_stats_rx_iat[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]);
+public_pdcp(uint32_t Pdcp_stats_rx_outoforder[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]);
 
 public_pdcp(void pdcp_update_perioidical_stats(const protocol_ctxt_t* const  ctxt_pP));
 
@@ -131,8 +131,8 @@ public_pdcp(void pdcp_update_perioidical_stats(const protocol_ctxt_t* const  ctx
 //public_pdcp(uint64_t *pdcp_size_packet);
 typedef struct pdcp_enb_s {
   // used for eNB stats generation
-  uint16_t uid[NUMBER_OF_UE_MAX];
-  rnti_t rnti[NUMBER_OF_UE_MAX];
+  uint16_t uid[MAX_MOBILES_PER_ENB];
+  rnti_t rnti[MAX_MOBILES_PER_ENB];
   uint16_t num_ues;
   
   uint64_t sfn;
@@ -482,19 +482,19 @@ typedef struct pdcp_missing_pdu_info_t {
 
 
 protected_pdcp(signed int             pdcp_2_nas_irq;)
-public_pdcp(pdcp_stats_t              UE_pdcp_stats[NUMBER_OF_UE_MAX];)
+public_pdcp(pdcp_stats_t              UE_pdcp_stats[MAX_MOBILES_PER_ENB];)
 public_pdcp(pdcp_stats_t              eNB_pdcp_stats[NUMBER_OF_eNB_MAX];)
-//protected_pdcp(pdcp_t                 pdcp_array_srb_ue[NUMBER_OF_UE_MAX][2];)
-//protected_pdcp(pdcp_t                 pdcp_array_drb_ue[NUMBER_OF_UE_MAX][maxDRB];)
-//public_pdcp(pdcp_t                    pdcp_array_srb_eNB[NUMBER_OF_eNB_MAX][NUMBER_OF_UE_MAX][2];)
-//protected_pdcp(pdcp_t                 pdcp_array_drb_eNB[NUMBER_OF_eNB_MAX][NUMBER_OF_UE_MAX][maxDRB];)
+//protected_pdcp(pdcp_t                 pdcp_array_srb_ue[MAX_MOBILES_PER_ENB][2];)
+//protected_pdcp(pdcp_t                 pdcp_array_drb_ue[MAX_MOBILES_PER_ENB][maxDRB];)
+//public_pdcp(pdcp_t                    pdcp_array_srb_eNB[NUMBER_OF_eNB_MAX][MAX_MOBILES_PER_ENB][2];)
+//protected_pdcp(pdcp_t                 pdcp_array_drb_eNB[NUMBER_OF_eNB_MAX][MAX_MOBILES_PER_ENB][maxDRB];)
 
 // for UE code conly
-protected_pdcp(rnti_t                 pdcp_UE_UE_module_id_to_rnti[NUMBER_OF_UE_MAX];)
-protected_pdcp(rnti_t                 pdcp_eNB_UE_instance_to_rnti[NUMBER_OF_UE_MAX];) // for noS1 mode
+protected_pdcp(rnti_t                 pdcp_UE_UE_module_id_to_rnti[MAX_MOBILES_PER_ENB];)
+protected_pdcp(rnti_t                 pdcp_eNB_UE_instance_to_rnti[MAX_MOBILES_PER_ENB];) // for noS1 mode
 protected_pdcp(unsigned int           pdcp_eNB_UE_instance_to_rnti_index;)
 #if defined(Rel10) || defined(Rel14)
-public_pdcp(pdcp_mbms_t               pdcp_mbms_array_ue[NUMBER_OF_UE_MAX][maxServiceCount][maxSessionPerPMCH];)   // some constants from openair2/RRC/LITE/MESSAGES/asn1_constants.h
+public_pdcp(pdcp_mbms_t               pdcp_mbms_array_ue[MAX_MOBILES_PER_ENB][maxServiceCount][maxSessionPerPMCH];)   // some constants from openair2/RRC/LITE/MESSAGES/asn1_constants.h
 public_pdcp(pdcp_mbms_t               pdcp_mbms_array_eNB[NUMBER_OF_eNB_MAX][maxServiceCount][maxSessionPerPMCH];) // some constants from openair2/RRC/LITE/MESSAGES/asn1_constants.h
 #endif
 protected_pdcp(sdu_size_t             pdcp_output_sdu_bytes_to_write;)
diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c
index 86f68cc9497e797f90ea141de7e83b45ba4e6add..d564b7cad69b071337a9ad30959f4ca82db8d761 100644
--- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c
+++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c
@@ -73,7 +73,7 @@ extern struct nlmsghdr *nas_nlh_rx;
 extern struct iovec nas_iov_tx;
 extern struct iovec nas_iov_rx;
 #ifdef UE_NAS_USE_TUN
-extern int nas_sock_fd[NUMBER_OF_UE_MAX];
+extern int nas_sock_fd[MAX_MOBILES_PER_ENB];
 #else
 extern int nas_sock_fd;
 #endif
@@ -852,7 +852,7 @@ void pdcp_fifo_read_input_sdus_from_otg (const protocol_ctxt_t* const  ctxt_pP)
       ctxt_pP->subframe,
       ctxt_pP->module_id);
 
-    for (dst_id = 0; dst_id<NUMBER_OF_UE_MAX; dst_id++) {
+    for (dst_id = 0; dst_id<MAX_MOBILES_PER_ENB; dst_id++) {
       ctxt.rnti = oai_emulation.info.eNB_ue_module_id_to_rnti[ctxt.module_id][dst_id];
 
     }
diff --git a/openair2/LAYER2/RLC/rlc.c b/openair2/LAYER2/RLC/rlc.c
index 4f7e4812e98fa8deeea53744c4bec940fda8fba9..2db98fc3cac835473a9d7697d8820180860446ed 100644
--- a/openair2/LAYER2/RLC/rlc.c
+++ b/openair2/LAYER2/RLC/rlc.c
@@ -615,7 +615,7 @@ rlc_module_init (void)
   rlc_coll_p = hashtable_create ((maxDRB + 2) * 16, NULL, rb_free_rlc_union);
   AssertFatal(rlc_coll_p != NULL, "UNRECOVERABLE error, RLC hashtable_create failed");
 
-  for (module_id1=0; module_id1 < NUMBER_OF_UE_MAX; module_id1++) {
+  for (module_id1=0; module_id1 < MAX_MOBILES_PER_ENB; module_id1++) {
 #if defined(Rel10) || defined(Rel14)
 
     for (k=0; k < RLC_MAX_MBMS_LC; k++) {
diff --git a/openair2/LAYER2/RLC/rlc.h b/openair2/LAYER2/RLC/rlc.h
index b70583e51bc8b57419b92f8d043530f42073c30d..5ab33d1cd53dd164c7fa03011ba0c26dfb1d631c 100644
--- a/openair2/LAYER2/RLC/rlc.h
+++ b/openair2/LAYER2/RLC/rlc.h
@@ -234,7 +234,7 @@ typedef struct rlc_mbms_id_s {
 #        define maxSessionPerPMCH 1
 #    endif
 #endif
-//public_rlc(rlc_mbms_t           rlc_mbms_array_ue[NUMBER_OF_UE_MAX][maxServiceCount][maxSessionPerPMCH];)   // some constants from openair2/RRC/LITE/MESSAGES/asn1_constants.h
+//public_rlc(rlc_mbms_t           rlc_mbms_array_ue[MAX_MOBILES_PER_ENB][maxServiceCount][maxSessionPerPMCH];)   // some constants from openair2/RRC/LITE/MESSAGES/asn1_constants.h
 //public_rlc(rlc_mbms_t           rlc_mbms_array_eNB[NUMBER_OF_eNB_MAX][maxServiceCount][maxSessionPerPMCH];) // some constants from openair2/RRC/LITE/MESSAGES/asn1_constants.h
 public_rlc(rlc_mbms_id_t        rlc_mbms_lcid2service_session_id_ue[MAX_MOBILES_PER_ENB][RLC_MAX_MBMS_LC];)    // some constants from openair2/RRC/LITE/MESSAGES/asn1_constants.h
 public_rlc(rlc_mbms_id_t        rlc_mbms_lcid2service_session_id_eNB[MAX_eNB][RLC_MAX_MBMS_LC];)  // some constants from openair2/RRC/LITE/MESSAGES/asn1_constants.h
diff --git a/openair2/NETWORK_DRIVER/UE_IP/constant.h b/openair2/NETWORK_DRIVER/UE_IP/constant.h
index faff970dcdb3cb32e8ade1d2a3e8ee0cae1e3600..0746651d073f8a0b108be6c8f9bfdbfd42e5a76b 100644
--- a/openair2/NETWORK_DRIVER/UE_IP/constant.h
+++ b/openair2/NETWORK_DRIVER/UE_IP/constant.h
@@ -52,7 +52,7 @@
 
 
 
-#define UE_IP_NB_INSTANCES_MAX       NUMBER_OF_UE_MAX
+#define UE_IP_NB_INSTANCES_MAX       MAX_MOBILES_PER_ENB
 
 
 #endif
diff --git a/openair2/RRC/LTE/defs_NB_IoT.h b/openair2/RRC/LTE/defs_NB_IoT.h
index c8565d52bd59beed4d64b822ef04bea122acfc39..a4e4938814a11a2c4c94eb510f64fe6e613eb1bf 100644
--- a/openair2/RRC/LTE/defs_NB_IoT.h
+++ b/openair2/RRC/LTE/defs_NB_IoT.h
@@ -88,7 +88,7 @@
 /*I will change the name of the structure for compile purposes--> hope not to undo this process*/
 
 typedef unsigned int uid_NB_IoT_t;
-#define UID_LINEAR_ALLOCATOR_BITMAP_SIZE_NB_IoT (((NUMBER_OF_UE_MAX_NB_IoT/8)/sizeof(unsigned int)) + 1)
+#define UID_LINEAR_ALLOCATOR_BITMAP_SIZE_NB_IoT (((MAX_MOBILES_PER_ENB_NB_IoT/8)/sizeof(unsigned int)) + 1)
 
 typedef struct uid_linear_allocator_NB_IoT_s {
   unsigned int   bitmap[UID_LINEAR_ALLOCATOR_BITMAP_SIZE_NB_IoT];
@@ -150,7 +150,7 @@ typedef struct UE_RRC_INFO_NB_IoT_s {
 
 // HO_STATE is not supported by NB-IoT
 
-//#define NUMBER_OF_UE_MAX MAX_MOBILES_PER_RG
+//#define MAX_MOBILES_PER_ENB MAX_MOBILES_PER_RG
 #define RRM_FREE(p)       if ( (p) != NULL) { free(p) ; p=NULL ; }
 #define RRM_MALLOC(t,n)   (t *) malloc16( sizeof(t) * n )
 #define RRM_CALLOC(t,n)   (t *) malloc16( sizeof(t) * n)
diff --git a/openair2/RRC/LTE/rrc_UE.c b/openair2/RRC/LTE/rrc_UE.c
index 71072cc03e389fc1497b371251c93d0bd7957d9a..98b7b4b5af823da510c5014aaae3175733284fbe 100644
--- a/openair2/RRC/LTE/rrc_UE.c
+++ b/openair2/RRC/LTE/rrc_UE.c
@@ -37,6 +37,7 @@
 #include "rrc_defs.h"
 #include "rrc_extern.h"
 #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h"
+#include "openair1/PHY/LTE_ESTIMATION/lte_estimation.h"
 #include "LAYER2/RLC/rlc.h"
 #include "COMMON/mac_rrc_primitives.h"
 #include "UTIL/LOG/log.h"
diff --git a/openair2/RRC/LTE/rrc_defs.h b/openair2/RRC/LTE/rrc_defs.h
index 9a2653e0458aac3afe9da6cf54415062ceb46e77..616fc8a0140d53465d2ab02fd5026c0d18b14cb8 100644
--- a/openair2/RRC/LTE/rrc_defs.h
+++ b/openair2/RRC/LTE/rrc_defs.h
@@ -171,7 +171,7 @@
 
 //--------
 typedef unsigned int uid_t;
-#define UID_LINEAR_ALLOCATOR_BITMAP_SIZE (((NUMBER_OF_UE_MAX/8)/sizeof(unsigned int)) + 1)
+#define UID_LINEAR_ALLOCATOR_BITMAP_SIZE (((MAX_MOBILES_PER_ENB/8)/sizeof(unsigned int)) + 1)
 typedef struct uid_linear_allocator_s {
   unsigned int   bitmap[UID_LINEAR_ALLOCATOR_BITMAP_SIZE];
 } uid_allocator_t;
@@ -219,7 +219,7 @@ typedef enum HO_STATE_e {
   HO_COMPLETE // initiated by the target eNB
 } HO_STATE_t;
 
-//#define NUMBER_OF_UE_MAX MAX_MOBILES_PER_RG
+//#define MAX_MOBILES_PER_ENB MAX_MOBILES_PER_RG
 #define RRM_FREE(p)       if ( (p) != NULL) { free(p) ; p=NULL ; }
 #define RRM_MALLOC(t,n)   (t *) malloc16( sizeof(t) * n )
 #define RRM_CALLOC(t,n)   (t *) malloc16( sizeof(t) * n)
@@ -521,8 +521,8 @@ typedef struct {
 #endif
   SRB_INFO                          SI;
   SRB_INFO                          Srb0;
-  uint8_t                           *paging[NUMBER_OF_UE_MAX];
-  uint32_t                           sizeof_paging[NUMBER_OF_UE_MAX];
+  uint8_t                           *paging[MAX_MOBILES_PER_ENB];
+  uint32_t                           sizeof_paging[MAX_MOBILES_PER_ENB];
 } rrc_eNB_carrier_data_t;
 
 typedef struct eNB_RRC_INST_s {
diff --git a/openair2/RRC/LTE/rrc_eNB.c b/openair2/RRC/LTE/rrc_eNB.c
index 3fd2b8d79d1cadc325597c6ee69b1146b72fe72f..6bc8d51f1184c64fd405922362dc0409226dabe2 100644
--- a/openair2/RRC/LTE/rrc_eNB.c
+++ b/openair2/RRC/LTE/rrc_eNB.c
@@ -515,7 +515,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++) {
+//    for (i = 0; i < MAX_MOBILES_PER_ENB; i++) {
 //        if (RC.rrc[enb_mod_idP]->Info.UE_list[i] == UE_identity) {
 //            // UE_identity already registered
 //            reg = TRUE;
@@ -854,14 +854,14 @@ rrc_eNB_free_UE(const module_id_t enb_mod_idP,const struct rrc_eNB_ue_context_s*
 #endif
     for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
       eNB_PHY = RC.eNB[enb_mod_idP][CC_id];
-      for (i=0; i<NUMBER_OF_UE_MAX; i++) {
+      for (i=0; i<MAX_MOBILES_PER_ENB; i++) {
         ulsch = eNB_PHY->ulsch[i];
         if((ulsch != NULL) && (ulsch->rnti == rnti)){
           LOG_I(RRC, "clean_eNb_ulsch UE %x \n", rnti);
           clean_eNb_ulsch(ulsch);
         }
       }
-      for (i=0; i<NUMBER_OF_UE_MAX; i++) {
+      for (i=0; i<MAX_MOBILES_PER_ENB; i++) {
         dlsch = eNB_PHY->dlsch[i][0];
         if((dlsch != NULL) && (dlsch->rnti == rnti)){
           LOG_I(RRC, "clean_eNb_dlsch UE %x \n", rnti);
@@ -1812,7 +1812,7 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete(
   eNB_MAC_INST *eNB_MAC = RC.mac[ctxt_prior.module_id];
   for (int CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
     eNB_PHY = RC.eNB[ctxt_prior.module_id][CC_id];
-    for (int i=0; i<NUMBER_OF_UE_MAX; i++) {
+    for (int i=0; i<MAX_MOBILES_PER_ENB; i++) {
       ulsch = eNB_PHY->ulsch[i];
       if((ulsch != NULL) && (ulsch->rnti == ctxt_prior.rnti)){
         LOG_I(RRC, "clean_eNb_ulsch UE %x \n", ctxt_prior.rnti);
@@ -5708,11 +5708,11 @@ openair_rrc_eNB_init(
   }
 #endif 
   AssertFatal(RC.rrc[enb_mod_idP] != NULL, "RC.rrc not initialized!");
-  AssertFatal(NUMBER_OF_UE_MAX < (module_id_t)0xFFFFFFFFFFFFFFFF, " variable overflow");
+  AssertFatal(MAX_MOBILES_PER_ENB < (module_id_t)0xFFFFFFFFFFFFFFFF, " variable overflow");
 #ifdef ENABLE_ITTI
   AssertFatal(configuration!=NULL,"configuration input is null\n");
 #endif
-  //    for (j = 0; j < NUMBER_OF_UE_MAX; j++)
+  //    for (j = 0; j < MAX_MOBILES_PER_ENB; j++)
   //        RC.rrc[ctxt.module_id].Info.UE[j].Status = RRC_IDLE;  //CH_READY;
   //
   //#if defined(ENABLE_USE_MME)
@@ -5721,7 +5721,7 @@ openair_rrc_eNB_init(
   //#endif
   //    {
   //        /* Init security parameters */
-  //        for (j = 0; j < NUMBER_OF_UE_MAX; j++) {
+  //        for (j = 0; j < MAX_MOBILES_PER_ENB; j++) {
   //            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);
@@ -5735,13 +5735,13 @@ openair_rrc_eNB_init(
 
   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++) {
+  //    for (j = 0; j < (MAX_MOBILES_PER_ENB + 1); j++) {
   //        RC.rrc[enb_mod_idP]->Srb2[j].Active = 0;
   //    }
 
 
-  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);
+  RC.rrc[ctxt.module_id]->initial_id2_s1ap_ids = hashtable_create (MAX_MOBILES_PER_ENB * 2, NULL, NULL);
+  RC.rrc[ctxt.module_id]->s1ap_id2_s1ap_ids    = hashtable_create (MAX_MOBILES_PER_ENB * 2, NULL, NULL);
 
   memcpy(&RC.rrc[ctxt.module_id]->configuration,configuration,sizeof(RrcConfigurationReq));
 
@@ -5797,7 +5797,7 @@ openair_rrc_eNB_init(
             , configuration
 #endif
            );
-    for (int ue_id = 0; ue_id < NUMBER_OF_UE_MAX; ue_id++) {
+    for (int ue_id = 0; ue_id < MAX_MOBILES_PER_ENB; ue_id++) {
         RC.rrc[ctxt.module_id]->carrier[CC_id].sizeof_paging[ue_id] = 0;
         RC.rrc[ctxt.module_id]->carrier[CC_id].paging[ue_id] = (uint8_t*) malloc16(256);
     }
@@ -6041,7 +6041,7 @@ rrc_eNB_decode_ccch(
       ue_context_p->ue_context.ue_release_timer = 0;
 
       // insert C-RNTI to map
-      for (i = 0; i < NUMBER_OF_UE_MAX; i++) {
+      for (i = 0; i < MAX_MOBILES_PER_ENB; i++) {
         if (reestablish_rnti_map[i][0] == 0) {
           reestablish_rnti_map[i][0] = ctxt_pP->rnti;
           reestablish_rnti_map[i][1] = c_rnti;
@@ -6665,7 +6665,7 @@ if (ue_context_p->ue_context.nb_of_modify_e_rabs > 0) {
         RC.mac[ctxt_pP->module_id]->UE_list.UE_sched_ctrl[UE_id].ue_reestablishment_reject_timer = 0;
         rnti_t reestablish_rnti = 0;
         // select C-RNTI from map
-        for (i = 0; i < NUMBER_OF_UE_MAX; i++) {
+        for (i = 0; i < MAX_MOBILES_PER_ENB; i++) {
           if (reestablish_rnti_map[i][0] == ctxt_pP->rnti) {
             reestablish_rnti = reestablish_rnti_map[i][1];
             ue_context_p = rrc_eNB_get_ue_context(
diff --git a/openair2/RRC/LTE/rrc_eNB_S1AP.c b/openair2/RRC/LTE/rrc_eNB_S1AP.c
index 130574041c37f861919d0991bf85504064bf5ea5..153b5d693dfc5da9d574b7023f0915a86c7ef202 100644
--- a/openair2/RRC/LTE/rrc_eNB_S1AP.c
+++ b/openair2/RRC/LTE/rrc_eNB_S1AP.c
@@ -1994,7 +1994,7 @@ int rrc_eNB_process_PAGING_IND(MessageDef *msg_p, const char *msg_name, instance
               /* insert data to UE_PF_PO or update data in UE_PF_PO */
               pthread_mutex_lock(&ue_pf_po_mutex);
               uint8_t i = 0;
-              for (i = 0; i < NUMBER_OF_UE_MAX; i++) {
+              for (i = 0; i < MAX_MOBILES_PER_ENB; i++) {
                 if ((UE_PF_PO[CC_id][i].enable_flag == TRUE && UE_PF_PO[CC_id][i].ue_index_value == (uint16_t)(S1AP_PAGING_IND(msg_p).ue_index_value))
                     || (UE_PF_PO[CC_id][i].enable_flag != TRUE)) {
                     /* set T = min(Tc,Tue) */
diff --git a/openair2/RRC/LTE/rrc_extern.h b/openair2/RRC/LTE/rrc_extern.h
index f97b02105f2a65996eaa3b31213fa8e265472bf9..6c19fa9c7076202b934664657e2e9cc3c3c1508a 100644
--- a/openair2/RRC/LTE/rrc_extern.h
+++ b/openair2/RRC/LTE/rrc_extern.h
@@ -75,10 +75,10 @@ extern uint32_t timeToTrigger_ms[16];
 extern float RSRP_meas_mapping[98];
 extern float RSRQ_meas_mapping[35];
 
-extern UE_PF_PO_t UE_PF_PO[MAX_NUM_CCs][NUMBER_OF_UE_MAX];
+extern UE_PF_PO_t UE_PF_PO[MAX_NUM_CCs][MAX_MOBILES_PER_ENB];
 extern pthread_mutex_t ue_pf_po_mutex;
 
-extern uint16_t reestablish_rnti_map[NUMBER_OF_UE_MAX][2];
+extern uint16_t reestablish_rnti_map[MAX_MOBILES_PER_ENB][2];
 
 #endif
 
diff --git a/openair2/RRC/LTE/rrc_vars.h b/openair2/RRC/LTE/rrc_vars.h
index 089cb02d5bb5662b7a6897775e5010bda1bf1f09..dcd608a76a719cda6c2963d5df51d4a018efc6b0 100644
--- a/openair2/RRC/LTE/rrc_vars.h
+++ b/openair2/RRC/LTE/rrc_vars.h
@@ -36,7 +36,7 @@
 #include "COMMON/mac_rrc_primitives.h"
 #include "LAYER2/MAC/mac.h"
 
-UE_PF_PO_t UE_PF_PO[MAX_NUM_CCs][NUMBER_OF_UE_MAX];
+UE_PF_PO_t UE_PF_PO[MAX_NUM_CCs][MAX_MOBILES_PER_ENB];
 pthread_mutex_t ue_pf_po_mutex;
 UE_RRC_INST *UE_rrc_inst;
 #include "LAYER2/MAC/mac_extern.h"
@@ -242,6 +242,6 @@ float RSRQ_meas_mapping[35] = {
 // [0]: current C-RNTI, [1]: prior C-RNTI
 // insert one when eNB received RRCConnectionReestablishmentRequest message
 // delete one when eNB received RRCConnectionReestablishmentComplete message
-uint16_t reestablish_rnti_map[NUMBER_OF_UE_MAX][2] = {{0}};
+uint16_t reestablish_rnti_map[MAX_MOBILES_PER_ENB][2] = {{0}};
 
 #endif
diff --git a/openair2/UTIL/OTG/otg_defs.h b/openair2/UTIL/OTG/otg_defs.h
index fad0d9510ece3fc190b76889f819cb71aab4d080..6c9944014fd99f08e01e53f2ef4e4330446bf8e3 100644
--- a/openair2/UTIL/OTG/otg_defs.h
+++ b/openair2/UTIL/OTG/otg_defs.h
@@ -33,7 +33,7 @@
 #ifndef __OTG_DEFS_H__
 # define __OTG_DEFS_H__
 
-/* \brief To define the NUMBER_OF_eNB_MAX and NUMBER_OF_UE_MAX */
+/* \brief To define the NUMBER_OF_eNB_MAX and MAX_MOBILES_PER_ENB */
 #if STANDALONE==1
 	#include "openairinterface5g_limits.h"
 #else
@@ -313,13 +313,13 @@ typedef struct { /*this structure constitutes a whole bg-stream with multiple bg
 typedef struct {
 
   int application_type[NUMBER_OF_eNB_MAX + NUMBER_OF_SERVICE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_SERVICE_MAX][MAX_NUM_APPLICATION];  /*!\brief It identify the application of the simulated traffic, could be cbr, m2m, gaming,etc*/
-  int trans_proto[NUMBER_OF_eNB_MAX + NUMBER_OF_SERVICE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION];
-  int ip_v[NUMBER_OF_eNB_MAX + NUMBER_OF_SERVICE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION];
+  int trans_proto[NUMBER_OF_eNB_MAX + NUMBER_OF_SERVICE_MAX][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION];
+  int ip_v[NUMBER_OF_eNB_MAX + NUMBER_OF_SERVICE_MAX][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION];
 
-  int flow_start[NUMBER_OF_eNB_MAX + NUMBER_OF_SERVICE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; /*!\brief Duration of traffic generation or use the emuulation time instead */
-  int flow_duration[NUMBER_OF_eNB_MAX + NUMBER_OF_SERVICE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; /*!\brief Duration of traffic generation or use the emuulation time instead */
+  int flow_start[NUMBER_OF_eNB_MAX + NUMBER_OF_SERVICE_MAX][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; /*!\brief Duration of traffic generation or use the emuulation time instead */
+  int flow_duration[NUMBER_OF_eNB_MAX + NUMBER_OF_SERVICE_MAX][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; /*!\brief Duration of traffic generation or use the emuulation time instead */
 
-  int idt_dist[NUMBER_OF_eNB_MAX + NUMBER_OF_SERVICE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; /*!\brief Inter Departure Time distribution */
+  int idt_dist[NUMBER_OF_eNB_MAX + NUMBER_OF_SERVICE_MAX][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; /*!\brief Inter Departure Time distribution */
   int idt_min[NUMBER_OF_eNB_MAX + NUMBER_OF_SERVICE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_SERVICE_MAX][MAX_NUM_APPLICATION];   /*!\brief Min Inter Departure Time, for uniform distrib  */
   int idt_max[NUMBER_OF_eNB_MAX + NUMBER_OF_SERVICE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_SERVICE_MAX][MAX_NUM_APPLICATION];   /*!\brief idt, Max Inter Departure Time, for uniform distrib  */
 
@@ -338,69 +338,69 @@ typedef struct {
  */
 typedef struct {
   int max_nb_frames; /*!< \brief  Max Number of frames*/
-  int application_type[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION];  /*!\brief It identify the application of the simulated traffic, could be cbr, m2m, gaming,etc*/
+  int application_type[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION];  /*!\brief It identify the application of the simulated traffic, could be cbr, m2m, gaming,etc*/
   /*!\header info */
-  int trans_proto[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION];   /*!\brief Transport Protocol*/
-  int ip_v[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION];  /*!\brief Ip version */
+  int trans_proto[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION];   /*!\brief Transport Protocol*/
+  int ip_v[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION];  /*!\brief Ip version */
   //int header_compression;         /*!\brief Specify if header compression is used or not */
   int num_nodes;            /*!\brief Number of used nodes in the simulation */
   int packet_gen_type;             /*!\brief define how the payload is generated: fixed, predefined, random position, random see  ALPHABET_GEN */
-  unsigned int background[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; /*!\brief enable or disable background traffic  */
-  unsigned int aggregation_level[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; /* define packet aggregation level for the case of gateway*/
+  unsigned int background[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; /*!\brief enable or disable background traffic  */
+  unsigned int aggregation_level[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; /* define packet aggregation level for the case of gateway*/
   // src id , dst id, and state             // think to the case of several streams per node !!!!!
-  int idt_dist[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief Inter Departure Time distribution */
-  int idt_min[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE];  /*!\brief Min Inter Departure Time, for uniform distrib  */
-  int idt_max[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE];  /*!\brief idt, Max Inter Departure Time, for uniform distrib  */
+  int idt_dist[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief Inter Departure Time distribution */
+  int idt_min[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE];  /*!\brief Min Inter Departure Time, for uniform distrib  */
+  int idt_max[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE];  /*!\brief idt, Max Inter Departure Time, for uniform distrib  */
 
-  double idt_std_dev[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE];   /*!\brief idt, Standard Deviation, for guassian distrib */
-  double idt_lambda[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE];     /*!\brief idt, lambda, for exponential/poisson  distrib */
-  double idt_scale[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE];   /*!\brief scale :parameter for Pareto, Gamma, Weibull and Cauchy distribution*/
-  double idt_shape[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE];   /*!\brief shape :parameter for Pareto, Gamma, Weibull and Cauchy distribution*/
+  double idt_std_dev[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE];   /*!\brief idt, Standard Deviation, for guassian distrib */
+  double idt_lambda[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE];     /*!\brief idt, lambda, for exponential/poisson  distrib */
+  double idt_scale[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE];   /*!\brief scale :parameter for Pareto, Gamma, Weibull and Cauchy distribution*/
+  double idt_shape[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE];   /*!\brief shape :parameter for Pareto, Gamma, Weibull and Cauchy distribution*/
 
-  int size_dist[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE];  /*!\brief Paylolad size distribution */
-  int size_min[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief Min Payload size, for uniform distrib  */
-  int size_max[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE];   /*!\brief payload, Max Inter Departure Time, for uniform distrib  */
-  double size_std_dev[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE];  /*!\brief payload, Standard Deviation, for guassian distrib */
-  double size_lambda[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE];     /*!\brief payload, lambda, for exponential/poisson  distrib */
+  int size_dist[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE];  /*!\brief Paylolad size distribution */
+  int size_min[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief Min Payload size, for uniform distrib  */
+  int size_max[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE];   /*!\brief payload, Max Inter Departure Time, for uniform distrib  */
+  double size_std_dev[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE];  /*!\brief payload, Standard Deviation, for guassian distrib */
+  double size_lambda[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE];     /*!\brief payload, lambda, for exponential/poisson  distrib */
 
-  double size_scale[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE];    /*!\brief scale :parameter for Pareto, Gamma, Weibull and Cauchy distribution */
-  double size_shape[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE];  /*!\brief shape :parameter for Pareto, Gamma, Weibull and Cauchy distribution*/
+  double size_scale[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE];    /*!\brief scale :parameter for Pareto, Gamma, Weibull and Cauchy distribution */
+  double size_shape[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE];  /*!\brief shape :parameter for Pareto, Gamma, Weibull and Cauchy distribution*/
 
   // info for state-based traffic gen
-  int num_state [NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; /*!\brief Number of states for source node*/
-  //  int state_dist[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_TRAFFIC_STATE]; /*!\brief States distribution */
-  double state_prob[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_TRAFFIC_STATE]; /*!\brief State probablity: prob to move from one state to the other one */
+  int num_state [NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; /*!\brief Number of states for source node*/
+  //  int state_dist[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_TRAFFIC_STATE]; /*!\brief States distribution */
+  double state_prob[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_TRAFFIC_STATE]; /*!\brief State probablity: prob to move from one state to the other one */
 
   // num stream for each src
-  // int stream [NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; // this requires multi thread for parallel stream for a givcen src
+  // int stream [NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; // this requires multi thread for parallel stream for a givcen src
   // emu info
-  int flow_start_flag[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; /*!\brief flow start time flag for traffic generation or use the emuulation time instead */
-  int flow_start[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; /*!\brief flow start time of traffic generation or use the emuulation time instead */
-  int flow_duration[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; /*!\brief flow duration of traffic generation or use the emuulation time instead */
+  int flow_start_flag[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; /*!\brief flow start time flag for traffic generation or use the emuulation time instead */
+  int flow_start[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; /*!\brief flow start time of traffic generation or use the emuulation time instead */
+  int flow_duration[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; /*!\brief flow duration of traffic generation or use the emuulation time instead */
   int seed; /*!\brief The seed used to generate the random positions*/
 
 
-  int  dst_port[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; /*!\brief Destination port number, for the socket mode*/
-  char *dst_ip[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; /*!\brief Destination IP address, for the socket mode*/
+  int  dst_port[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; /*!\brief Destination port number, for the socket mode*/
+  char *dst_ip[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; /*!\brief Destination IP address, for the socket mode*/
 
-  int trans_proto_background[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; /*!\brief define the transport protocol and IP version for background traffic*/
+  int trans_proto_background[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; /*!\brief define the transport protocol and IP version for background traffic*/
 
 
 
-  double prob_off_pu[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION];
-  double prob_off_ed[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION];
-  double prob_off_pe[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION];
-  double prob_pu_ed[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION];
-  double prob_pu_pe[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION];
-  double prob_ed_pe[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION];
-  double prob_ed_pu[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION];
-  unsigned int holding_time_off_ed[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION];
-  unsigned int holding_time_off_pu[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION];
-  unsigned int holding_time_off_pe[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION];
-  unsigned int holding_time_pe_off[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION];
-  unsigned int pu_size_pkts[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION];
-  unsigned int ed_size_pkts[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION];
-  unsigned int m2m[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION];
+  double prob_off_pu[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION];
+  double prob_off_ed[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION];
+  double prob_off_pe[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION];
+  double prob_pu_ed[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION];
+  double prob_pu_pe[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION];
+  double prob_ed_pe[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION];
+  double prob_ed_pu[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION];
+  unsigned int holding_time_off_ed[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION];
+  unsigned int holding_time_off_pu[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION];
+  unsigned int holding_time_off_pe[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION];
+  unsigned int holding_time_pe_off[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION];
+  unsigned int pu_size_pkts[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION];
+  unsigned int ed_size_pkts[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION];
+  unsigned int m2m[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION];
 
 
   unsigned int throughput_metric;
@@ -409,7 +409,7 @@ typedef struct {
   unsigned int curve;
   unsigned int owd_radio_access;
   unsigned int background_stats;
-  unsigned int application_idx[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX];
+  unsigned int application_idx[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB];
 
 
 } otg_t;
@@ -485,8 +485,8 @@ typedef struct {
   unsigned int rx_total_bytes_dl;
 
   /*TARMA parameteres*/
-  tarmaStream_t *mtarma_stream[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION];
-  tarmaVideo_t *mtarma_video[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION];
+  tarmaStream_t *mtarma_stream[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION];
+  tarmaVideo_t *mtarma_video[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION];
 
 } otg_multicast_info_t;
 
@@ -505,71 +505,71 @@ typedef struct {
   int ctime;                        /*!< \brief Simulation time in ms*/
   int ptime_background_ul;                    /*!< \brief time of last sent background UL data (time in ms)*/
   int ptime_background_dl;                    /*!< \brief time of last sent background DL data (time in ms)*/
-  int ptime[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION];       /*!< \brief time of last sent data (time in ms)*/
-  int seq_num[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC];   /*!< \brief the sequence number of the sender  */
-  int seq_num_background[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX];     /*!< \brief the sequence number for background traffic of the sender  */
-  int seq_num_rx[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC];    /*!< \brief the sequence number of the receiver */
-  int seq_num_rx_background[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX];  /*!< \brief the sequence number for background traffic of the receiver */
+  int ptime[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION];       /*!< \brief time of last sent data (time in ms)*/
+  int seq_num[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC];   /*!< \brief the sequence number of the sender  */
+  int seq_num_background[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB];     /*!< \brief the sequence number for background traffic of the sender  */
+  int seq_num_rx[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC];    /*!< \brief the sequence number of the receiver */
+  int seq_num_rx_background[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB];  /*!< \brief the sequence number for background traffic of the receiver */
 
 
-  int idt_background[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX];         /*!< \brief  Inter Departure Time for background traffic in ms*/
-  int size_background[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX];        /*!< \brief  payload size for background traffic*/
-  int idt[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION];     /*!< \brief  Inter Departure Time in ms*/
-  int header_type[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX];    /*!< \brief  Define the type of header: Transport layer + IP version*/
+  int idt_background[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB];         /*!< \brief  Inter Departure Time for background traffic in ms*/
+  int size_background[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB];        /*!< \brief  payload size for background traffic*/
+  int idt[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION];     /*!< \brief  Inter Departure Time in ms*/
+  int header_type[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB];    /*!< \brief  Define the type of header: Transport layer + IP version*/
 
   /*!< \brief Statics part: vars updated at each iteration of otg_tx */
-  int tx_num_pkt[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC];    /*!< \brief  Number of data packet in the tx*/
-  int tx_num_bytes[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC];    /*!< \brief  Number of bytes in the tx*/ // get the size and calculate the avg throughput
+  int tx_num_pkt[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC];    /*!< \brief  Number of data packet in the tx*/
+  int tx_num_bytes[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC];    /*!< \brief  Number of bytes in the tx*/ // get the size and calculate the avg throughput
   // vars updated at each iteration of otg_rx
-  int rx_num_pkt[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC];    /*!< \brief  Number of data packet in the rx */
-  int rx_num_bytes[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC];    /*!< \brief  Number of bytes in the rx */
-  float rx_pkt_owd[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX];     /*!< \brief  One way delay: rx_ctime - tx_ctime, */
-  float rx_owd_min[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC];      /*!< \brief  One way delay min*/
-  float rx_owd_max[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC];    /*!< \brief  One way delay max*/
-  float rx_pkt_owd_e2e[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX];     /*!< \brief  One way delay: rx_ctime - tx_ctime, */
-  float rx_owd_min_e2e[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC];      /*!< \brief  One way delay min*/
-  float rx_owd_max_e2e[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC];    /*!< \brief  One way delay max*/
-  float rx_pkt_owd_history[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][2];    /*!< \brief  One way delay histoy used for jitter calculation: rx_ctime - tx_ctime, [2] to keep the owd for the current and previous pkt */
-  float rx_pkt_owd_history_e2e[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][2];    /*!< \brief  One way delay histoy used for jitter calculation: rx_ctime - tx_ctime, [2] to keep the owd for the current and previous pkt */
-  float rx_pkt_jitter[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX];    /*!< \brief  One way delay: rx_ctime - tx_ctime */
-  float rx_jitter_min[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC];     /*!< \brief  One way delay min*/
-  float rx_jitter_max[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC];     /*!< \brief  One way delay max*/
-  float rx_jitter_avg[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC];     /*!< \brief  One way delay max*/
-  float rx_pkt_jitter_e2e[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX];    /*!< \brief  One way delay: rx_ctime - tx_ctime */
-  float rx_jitter_min_e2e[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC];     /*!< \brief  One way delay min*/
-  float rx_jitter_max_e2e[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC];     /*!< \brief  One way delay max*/
-  float rx_jitter_avg_e2e[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC];     /*!< \brief  One way delay max*/
-  int rx_jitter_sample[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC];    /*!< \brief  One way delay max*/
-  int nb_loss_pkts_ul[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC];   /*!< \brief  Number of data packets losses for UL*/
-  int nb_loss_pkts_dl[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC];   /*!< \brief  Number of data packets losses for DL*/
-  float owd_const[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION];   /*!< \brief  One way delay constant*/
+  int rx_num_pkt[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC];    /*!< \brief  Number of data packet in the rx */
+  int rx_num_bytes[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC];    /*!< \brief  Number of bytes in the rx */
+  float rx_pkt_owd[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB];     /*!< \brief  One way delay: rx_ctime - tx_ctime, */
+  float rx_owd_min[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC];      /*!< \brief  One way delay min*/
+  float rx_owd_max[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC];    /*!< \brief  One way delay max*/
+  float rx_pkt_owd_e2e[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB];     /*!< \brief  One way delay: rx_ctime - tx_ctime, */
+  float rx_owd_min_e2e[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC];      /*!< \brief  One way delay min*/
+  float rx_owd_max_e2e[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC];    /*!< \brief  One way delay max*/
+  float rx_pkt_owd_history[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][2];    /*!< \brief  One way delay histoy used for jitter calculation: rx_ctime - tx_ctime, [2] to keep the owd for the current and previous pkt */
+  float rx_pkt_owd_history_e2e[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][2];    /*!< \brief  One way delay histoy used for jitter calculation: rx_ctime - tx_ctime, [2] to keep the owd for the current and previous pkt */
+  float rx_pkt_jitter[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB];    /*!< \brief  One way delay: rx_ctime - tx_ctime */
+  float rx_jitter_min[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC];     /*!< \brief  One way delay min*/
+  float rx_jitter_max[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC];     /*!< \brief  One way delay max*/
+  float rx_jitter_avg[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC];     /*!< \brief  One way delay max*/
+  float rx_pkt_jitter_e2e[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB];    /*!< \brief  One way delay: rx_ctime - tx_ctime */
+  float rx_jitter_min_e2e[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC];     /*!< \brief  One way delay min*/
+  float rx_jitter_max_e2e[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC];     /*!< \brief  One way delay max*/
+  float rx_jitter_avg_e2e[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC];     /*!< \brief  One way delay max*/
+  int rx_jitter_sample[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC];    /*!< \brief  One way delay max*/
+  int nb_loss_pkts_ul[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC];   /*!< \brief  Number of data packets losses for UL*/
+  int nb_loss_pkts_dl[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC];   /*!< \brief  Number of data packets losses for DL*/
+  float owd_const[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION];   /*!< \brief  One way delay constant*/
   /*!< \brief KPI part: calculate the KPIs, total */
-  double tx_throughput[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC];  /*!< \brief  Tx throughput: (size of transmitted data)/ctime*/
-  double rx_goodput[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC];     /*!< \brief  Rx goodput: (size of received data)/ctime*/
-  float rx_loss_rate[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC];  /*!< \brief  Rx Loss Rate: ratio, unit: bytes*/
-  //int rx_latency[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX];     /*!< \brief  Rx Latency */
+  double tx_throughput[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC];  /*!< \brief  Tx throughput: (size of transmitted data)/ctime*/
+  double rx_goodput[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC];     /*!< \brief  Rx goodput: (size of received data)/ctime*/
+  float rx_loss_rate[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC];  /*!< \brief  Rx Loss Rate: ratio, unit: bytes*/
+  //int rx_latency[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB];     /*!< \brief  Rx Latency */
 
   /*!< \brief Background traffic part: SATS + KPIs */
-  int tx_num_pkt_background[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX];  /*!< \brief  Number of background data packet in the rx */
-  int tx_num_bytes_background[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX];  /*!< \brief  Number of background bytes in the rx */
-  int rx_num_pkt_background[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX];  /*!< \brief  Number of background data packet in the tx */
-  int rx_num_bytes_background[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX];  /*!< \brief  Number of background bytes in the tx */
-  int nb_loss_pkts_background_ul[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; /*!< \brief  Number of background packets losses for UL*/
-  int nb_loss_pkts_background_dl[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; /*!< \brief  Number of background packets losses for DL*/
-  double tx_throughput_background[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX];  /*!< \brief  Tx throughput: (size of transmitted data)/ctime*/
-  double rx_goodput_background[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX];   /*!< \brief  Rx goodput: (size of received data)/ctime*/
-  float rx_loss_rate_background[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX];  /*!< \brief  Rx Loss Rate: ratio, unit: bytes*/
-
-  float radio_access_delay[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX];
-  int nb_loss_pkts_otg[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX];
-  unsigned int aggregation_level[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX];
-
-  unsigned int state[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION];                      /*!< \brief  current state of src node */
-  float state_transition_prob[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION];
-  unsigned int start_holding_time_off[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION];
-  unsigned int c_holding_time_off[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION];
-  unsigned int c_holding_time_pe_off[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION];
-  unsigned int start_holding_time_pe_off[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION];
+  int tx_num_pkt_background[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB];  /*!< \brief  Number of background data packet in the rx */
+  int tx_num_bytes_background[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB];  /*!< \brief  Number of background bytes in the rx */
+  int rx_num_pkt_background[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB];  /*!< \brief  Number of background data packet in the tx */
+  int rx_num_bytes_background[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB];  /*!< \brief  Number of background bytes in the tx */
+  int nb_loss_pkts_background_ul[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; /*!< \brief  Number of background packets losses for UL*/
+  int nb_loss_pkts_background_dl[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; /*!< \brief  Number of background packets losses for DL*/
+  double tx_throughput_background[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB];  /*!< \brief  Tx throughput: (size of transmitted data)/ctime*/
+  double rx_goodput_background[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB];   /*!< \brief  Rx goodput: (size of received data)/ctime*/
+  float rx_loss_rate_background[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB];  /*!< \brief  Rx Loss Rate: ratio, unit: bytes*/
+
+  float radio_access_delay[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB];
+  int nb_loss_pkts_otg[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB];
+  unsigned int aggregation_level[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB];
+
+  unsigned int state[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION];                      /*!< \brief  current state of src node */
+  float state_transition_prob[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION];
+  unsigned int start_holding_time_off[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION];
+  unsigned int c_holding_time_off[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION];
+  unsigned int c_holding_time_pe_off[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION];
+  unsigned int start_holding_time_pe_off[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION];
   unsigned int tx_total_bytes_dl;
   unsigned int tx_total_bytes_ul;
   unsigned int rx_total_bytes_dl;
@@ -582,32 +582,32 @@ typedef struct {
   float average_jitter_ul_e2e;
 
   /* VOIP tarffic parameters*/
-  float voip_transition_prob[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION];
-  unsigned int voip_state[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION];
-  unsigned int start_voip_silence[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION];
-  unsigned int c_holding_time_silence[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION];
-  unsigned int start_voip_talk[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION];
-  unsigned int c_holding_time_talk[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION];
-  unsigned int silence_time[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION];
-  unsigned int simple_talk_time[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION];
+  float voip_transition_prob[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION];
+  unsigned int voip_state[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION];
+  unsigned int start_voip_silence[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION];
+  unsigned int c_holding_time_silence[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION];
+  unsigned int start_voip_talk[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION];
+  unsigned int c_holding_time_talk[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION];
+  unsigned int silence_time[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION];
+  unsigned int simple_talk_time[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION];
 
   /*TARMA parameteres*/
-  tarmaStream_t *tarma_stream[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION];
-  tarmaVideo_t *tarma_video[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION];
+  tarmaStream_t *tarma_stream[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION];
+  tarmaVideo_t *tarma_video[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION];
   /*BACKGROUND_USERS parameters*/
-  backgroundStream_t *background_stream[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION];
-
-  unsigned int header_size_app[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION];
-  unsigned int header_size[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX];
-  unsigned int m2m_aggregation[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX];
-  unsigned int flow_id[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX];
-  unsigned int traffic_type[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX];
-  unsigned int traffic_type_background[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX];
+  backgroundStream_t *background_stream[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION];
+
+  unsigned int header_size_app[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION];
+  unsigned int header_size[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB];
+  unsigned int m2m_aggregation[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB];
+  unsigned int flow_id[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB];
+  unsigned int traffic_type[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB];
+  unsigned int traffic_type_background[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB];
   //  unsigned int traffic_type_multicast[NUMBER_OF_eNB_MAX + NUMBER_OF_SERVICE_MAX_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_SERVICE_MAX];
-  unsigned int hdr_size[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX];
-  unsigned int header_type_app[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; ;
+  unsigned int hdr_size[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB];
+  unsigned int header_type_app[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; ;
   unsigned int gen_pkts;
-  unsigned int header_size_background[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX];
+  unsigned int header_size_background[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB];
 } otg_info_t;
 
 
@@ -640,14 +640,14 @@ typedef struct {
   int init_forms;
   int is_data_plot_ul;
   int is_data_plot_dl;
-  float data_owd_ul[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_SAMPLES];
-  float data_throughput_ul[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_SAMPLES];
-  float data_ctime_ul[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_SAMPLES];
-  int idx_ul[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX];
-  float data_owd_dl[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_SAMPLES];
-  float data_throughput_dl[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_SAMPLES];
-  float data_ctime_dl[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_SAMPLES];
-  int idx_dl[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX];
+  float data_owd_ul[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_SAMPLES];
+  float data_throughput_ul[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_SAMPLES];
+  float data_ctime_ul[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_SAMPLES];
+  int idx_ul[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB];
+  float data_owd_dl[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_SAMPLES];
+  float data_throughput_dl[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_SAMPLES];
+  float data_ctime_dl[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_SAMPLES];
+  int idx_dl[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB];
 } otg_forms_info_t;
 
 
diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c
index 4db66da4dc1d1af4e041fde8fa538248c1d9fbfd..d8971f5da641c712be4fd74099e1db1a0856dbb2 100644
--- a/targets/RT/USER/lte-ru.c
+++ b/targets/RT/USER/lte-ru.c
@@ -72,7 +72,10 @@
 
 #include "PHY/phy_extern.h"
 #include "LAYER2/MAC/mac_extern.h"
-
+#include "PHY/LTE_TRANSPORT/transport_proto.h"
+#include "SCHED/sched_eNB.h"
+#include "PHY/LTE_ESTIMATION/lte_estimation.h"
+#include "PHY/INIT/phy_init.h"
 
 #include "LAYER2/MAC/mac.h"
 #include "LAYER2/MAC/mac_extern.h"
diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c
index fa0a1d82611efc8c4b04688ce7fec397aa65e98f..cbaa909301b334b0693aa5423f81f8cd54b01cff 100644
--- a/targets/RT/USER/lte-softmodem.c
+++ b/targets/RT/USER/lte-softmodem.c
@@ -90,6 +90,8 @@ unsigned short config_frames[4] = {2,9,11,13};
 #include "create_tasks.h"
 #endif
 
+#include "PHY/INIT/phy_init.h"
+
 #include "system.h"
 
 #ifdef XFORMS
@@ -1092,7 +1094,7 @@ int main( int argc, char **argv )
 
   // init UE_PF_PO and mutex lock
   pthread_mutex_init(&ue_pf_po_mutex, NULL);
-  memset (&UE_PF_PO[0][0], 0, sizeof(UE_PF_PO_t)*NUMBER_OF_UE_MAX*MAX_NUM_CCs);
+  memset (&UE_PF_PO[0][0], 0, sizeof(UE_PF_PO_t)*MAX_MOBILES_PER_ENB*MAX_NUM_CCs);
   
   mlockall(MCL_CURRENT | MCL_FUTURE);
   
diff --git a/targets/SIMU/USER/channel_sim.c b/targets/SIMU/USER/channel_sim.c
index 553d4807824625f102c74a4850822a2c5d50ae66..3018dbe1fb10e7565303323d9e599daf072b38c5 100644
--- a/targets/SIMU/USER/channel_sim.c
+++ b/targets/SIMU/USER/channel_sim.c
@@ -26,32 +26,24 @@
 #include <stdio.h>
 #include <time.h>
 
-#include "SIMULATION/TOOLS/defs.h"
-#include "SIMULATION/RF/defs.h"
+#include "SIMULATION/TOOLS/sim.h"
+#include "SIMULATION/RF/rf.h"
 #include "PHY/types.h"
-#include "PHY/defs.h"
-#include "PHY/extern.h"
+#include "PHY/defs_eNB.h"
+#include "PHY/phy_extern.h"
+#include "PHY/phy_extern_ue.h"
 
-#ifdef OPENAIR2
-#include "LAYER2/MAC/defs.h"
-#include "LAYER2/MAC/extern.h"
+#include "LAYER2/MAC/mac.h"
+#include "LAYER2/MAC/mac_extern.h"
 #include "UTIL/LOG/log_if.h"
 #include "UTIL/LOG/log_extern.h"
-#include "RRC/LITE/extern.h"
-#include "PHY_INTERFACE/extern.h"
+#include "RRC/LTE/rrc_extern.h"
+#include "PHY_INTERFACE/phy_interface_extern.h"
 #include "UTIL/OCG/OCG.h"
 #include "UTIL/OPT/opt.h" // to test OPT
-#endif
 
 #include "UTIL/FIFO/types.h"
 
-#ifdef IFFT_FPGA
-#include "PHY/LTE_REFSIG/mod_table.h"
-#endif
-
-#include "SCHED/defs.h"
-#include "SCHED/extern.h"
-
 #ifdef XFORMS
 #include "forms.h"
 #include "phy_procedures_sim_form.h"
diff --git a/targets/SIMU/USER/oaisim.c b/targets/SIMU/USER/oaisim.c
index 71436347634e00e060c1ae3b193e5153f6aa8ce3..1847db1d7185627b15ca36e9d80385fb5e5961c4 100644
--- a/targets/SIMU/USER/oaisim.c
+++ b/targets/SIMU/USER/oaisim.c
@@ -41,24 +41,23 @@
 #include <execinfo.h>
 
 #include "event_handler.h"
-#include "SIMULATION/RF/defs.h"
+#include "SIMULATION/RF/rf.h"
 #include "PHY/types.h"
-#include "PHY/defs.h"
-#include "PHY/LTE_TRANSPORT/proto.h"
-#include "PHY/vars.h"
-
-#include "SIMULATION/ETH_TRANSPORT/proto.h"
-
-//#ifdef OPENAIR2
-#include "LAYER2/MAC/defs.h"
-#include "LAYER2/MAC/proto.h"
-#include "LAYER2/MAC/vars.h"
+#include "PHY/defs_eNB.h"
+#include "PHY/defs_UE.h"
+#include "PHY/LTE_TRANSPORT/transport_proto.h"
+#include "PHY/LTE_UE_TRANSPORT/transport_proto_ue.h"
+#include "PHY/phy_vars.h"
+#include "PHY/phy_vars_ue.h"
+#include "SCHED/sched_common_vars.h"
+
+#include "LAYER2/MAC/mac.h"
+#include "LAYER2/MAC/mac_proto.h"
+#include "LAYER2/MAC/mac_vars.h"
 #include "pdcp.h"
-#include "RRC/LITE/vars.h"
+#include "RRC/LTE/rrc_vars.h"
 #include "RRC/NAS/nas_config.h"
 
-#include "SCHED/defs.h"
-#include "SCHED/vars.h"
 #include "system.h"
 
 
@@ -101,6 +100,7 @@ char smbv_ip[16];
 #if defined(ENABLE_ITTI)
 # include "intertask_interface.h"
 # include "create_tasks.h"
+# include "intertask_interface_init.h"
 #endif
 
 #include "T.h"
@@ -627,12 +627,8 @@ l2l1_task (void *args_p)
   }
 
 #endif
-  module_id_t UE_id;
+  
 
-  if (abstraction_flag == 1) {
-    for (UE_id = 0; UE_id < NB_UE_INST; UE_id++)
-      dl_phy_sync_success (UE_id, 0, 0,1);   //UE_id%NB_eNB_INST);
-  }
   
   start_meas (&oaisim_stats);
 
@@ -701,8 +697,8 @@ 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_ocm ();
+    //update_omg (frame); // frequency is defined in the omg_global params configurable by the user
+    //update_omg_ocm ();
 
 #ifdef OPENAIR2
 
@@ -796,15 +792,6 @@ l2l1_task (void *args_p)
 		  PHY_vars_eNB_g[eNB_inst][0]->frame_parms.Nid_cell);
             
 	    */
-#ifdef OPENAIR2
-	    //Application: traffic gen
-            update_otg_eNB (eNB_inst, oai_emulation.info.time_ms);
-
-            //IP/OTG to PDCP and PDCP to IP operation
-            //        pdcp_run (frame, 1, 0, eNB_inst); //PHY_vars_eNB_g[eNB_id]->Mod_id
-#endif
-           
-
 #ifdef PRINT_STATS
 
             if((sf==9) && frame%10==0)
@@ -874,7 +861,7 @@ l2l1_task (void *args_p)
 
 
     }
-    update_ocm ();
+    //update_ocm ();
     /*
     if ((frame >= 10) && (frame <= 11) && (abstraction_flag == 0)
 #ifdef PROC
@@ -1110,6 +1097,7 @@ int main (int argc, char **argv)
   oai_emulation.info.n_frames = MAX_FRAME_NUMBER; //1024;          //10;
   oai_emulation.info.n_frames_flag = 0; //fixme
   snr_dB = 30;
+  NB_UE_INST = 1;
 
   //Default values if not changed by the user in get_simulation_options();
   pdcp_period = 1;
@@ -1126,7 +1114,7 @@ int main (int argc, char **argv)
   // start thread for log gen
   log_thread_init ();
 
-  init_oai_emulation (); // to initialize everything !!!
+  //init_oai_emulation (); // to initialize everything !!!
 
   // get command-line options
   get_simulation_options (argc, argv); //Command-line options
@@ -1163,7 +1151,37 @@ int main (int argc, char **argv)
 
 #endif
   // configure oaisim with OCG
-  oaisim_config (); // config OMG and OCG, OPT, OTG, OLG
+  //oaisim_config (); // config OMG and OCG, OPT, OTG, OLG
+  logInit();
+
+#if defined(ENABLE_ITTI)
+  itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info, messages_definition_xml, oai_emulation.info.itti_dump_file);
+  MSC_INIT(MSC_E_UTRAN, THREAD_MAX+TASK_MAX);
+#endif
+
+  set_glog(LOG_INFO, 0x15);
+
+
+   //set_log(OCG,  LOG_DEBUG, 1);
+   //set_log(EMU,  LOG_INFO,  20);
+   set_log(MAC,  LOG_DEBUG, 1);
+   set_log(RLC,  LOG_TRACE, 1);
+   //set_log(PHY,  LOG_DEBUG, 1);
+   set_log(PDCP, LOG_TRACE, 1);
+   set_log(RRC,  LOG_DEBUG, 1);
+   //set_log(OCM,  LOG_INFO, 20);
+   //set_log(OTG,  LOG_INFO, 1);
+   set_comp_log(OCG,  LOG_ERR, 0x15,1);
+   set_comp_log(EMU,  LOG_DEBUG,  0x15,20);
+   set_comp_log(MAC,  LOG_TRACE, 0x15,1);
+   set_comp_log(RLC,  LOG_TRACE, 0x15,1);
+   set_comp_log(PHY,  LOG_TRACE, 0x15, 1);
+   set_comp_log(PDCP, LOG_DEBUG, 0x15,1);
+   set_comp_log(RRC,  LOG_DEBUG, 0x15,1);
+   set_comp_log(OCM,  LOG_DEBUG, 0x15,20);
+   set_comp_log(OTG,  LOG_DEBUG, 0x15,1);
+   set_comp_log(OMG,  LOG_NOTICE, 0x15,1);
+   set_comp_log(OPT,  LOG_ERR, 0x15,1);
 
   if (ue_connection_test == 1) {
     snr_direction = -snr_step;
@@ -1175,15 +1193,11 @@ int main (int argc, char **argv)
   pthread_mutex_init(&sync_mutex, NULL);
   pthread_mutex_init(&subframe_mutex, NULL);
 
-#ifdef OPENAIR2
-  init_omv ();
-#endif
   //Before this call, NB_UE_INST and NB_eNB_INST are not set correctly
   check_and_adjust_params ();
 
   set_seed = oai_emulation.emulation_config.seed.value;
 
-  init_otg_pdcp_buffer ();
 
   init_seed (set_seed);
 
@@ -1198,7 +1212,7 @@ int main (int argc, char **argv)
 
 
 
-  if (create_tasks_ue(oai_emulation.info.nb_ue_local) < 0) 
+  if (create_tasks_ue(NB_UE_INST) < 0) 
       exit(-1); // need a softer mode
 
 
@@ -1211,6 +1225,7 @@ int main (int argc, char **argv)
 
 
   init_ocm ();
+
   printf("Sending sync to all threads\n");
 
 
@@ -1219,12 +1234,6 @@ int main (int argc, char **argv)
   pthread_cond_broadcast(&sync_cond);
   pthread_mutex_unlock(&sync_mutex);
 
-#ifdef SMBV
-  // Rohde&Schwarz SMBV100A vector signal generator
-  smbv_init_config(smbv_fname, smbv_nframes);
-  smbv_write_config_from_frame_parms(smbv_fname, &PHY_vars_eNB_g[0][0]->frame_parms);
-#endif
-
   /* #if defined (FLEXRAN_AGENT_SB_IF)
   flexran_agent_start();
   #endif */ 
@@ -1733,11 +1742,6 @@ oai_shutdown (void)
 
 #endif
 
-  //Perform KPI measurements
-  if (oai_emulation.info.otg_enabled == 1){
-    LOG_N(EMU,"calling OTG kpi gen .... \n");
-    kpi_gen ();
-  }
   if (oai_emulation.info.opp_enabled == 1)
     print_opp_meas_oaisim ();
 
@@ -1793,15 +1797,6 @@ oai_shutdown (void)
   } //End of PHY abstraction changes
 
 
-  // stop OMG
-  stop_mobility_generator (omg_param_list); //omg_param_list.mobility_type
-#ifdef OPENAIR2
-
-  if (oai_emulation.info.omv_enabled == 1)
-    omv_end (pfd[1], omv_data);
-
-#endif
-
   if ((oai_emulation.info.ocm_enabled == 1) && (ethernet_flag == 0)
       && (ShaF != NULL)) {
     destroyMat (ShaF, map1, map2);
@@ -1811,9 +1806,6 @@ oai_shutdown (void)
   if (opt_enabled == 1)
     terminate_opt ();
 
-  if (oai_emulation.info.cli_enabled)
-    cli_server_cleanup ();
-
   for (int i = 0; i < NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX; i++)
     if (oai_emulation.info.oai_ifup[i] == 1) {
       char interfaceName[8];
diff --git a/targets/SIMU/USER/oaisim.h b/targets/SIMU/USER/oaisim.h
index 0fdc4002e47cd053fd8ffe56a4b4d7d5f2bd94d8..1ddc09398322cbb2cd91463e818a5d12ae4efc0f 100644
--- a/targets/SIMU/USER/oaisim.h
+++ b/targets/SIMU/USER/oaisim.h
@@ -26,15 +26,16 @@
 #include <stdio.h>
 #include <time.h>
 
-#include "SIMULATION/TOOLS/defs.h"
-#include "SIMULATION/RF/defs.h"
+#include "SIMULATION/TOOLS/sim.h"
+#include "SIMULATION/RF/rf.h"
 #include "PHY/types.h"
-#include "PHY/defs.h"
+#include "PHY/defs_eNB.h"
+#include "PHY/defs_UE.h"
 #include "oaisim_config.h"
 #include "init_lte.h"
 
 #ifdef OPENAIR2
-#include "LAYER2/MAC/defs.h"
+#include "LAYER2/MAC/mac.h"
 #include "UTIL/OMV/structures.h"
 #endif
 
diff --git a/targets/SIMU/USER/oaisim_config.h b/targets/SIMU/USER/oaisim_config.h
index fe1309b7a48531033474e6bf7413bd54a9b0642c..a403252d06430f214ba3c30e521f1e4652e8f000 100644
--- a/targets/SIMU/USER/oaisim_config.h
+++ b/targets/SIMU/USER/oaisim_config.h
@@ -49,10 +49,8 @@ The current sturcture of oaisim is shown by the figure.
 #include "UTIL/OPT/opt.h" // to test OPT
 #include "UTIL/OMG/omg.h"
 #include "UTIL/CLI/cli_if.h"
-#include "PHY/defs.h"
-#include "PHY/extern.h"
-#include "SIMULATION/ETH_TRANSPORT/defs.h"
-#include "PHY/defs.h"
+#include "PHY/defs_eNB.h"
+#include "PHY/phy_extern.h"
 
 /** @defgroup _init_oai Initial oaisim
  *  @ingroup _fn
diff --git a/targets/SIMU/USER/oaisim_functions.c b/targets/SIMU/USER/oaisim_functions.c
index 5900170480ed339009e85baef66d303d6535eff2..2bddfdd8fc23d9e4f15ae4ae2a36f0d26219f69c 100644
--- a/targets/SIMU/USER/oaisim_functions.c
+++ b/targets/SIMU/USER/oaisim_functions.c
@@ -43,29 +43,22 @@
 #include "assertions.h"
 #include "oaisim_functions.h"
 
-#include "PHY/extern.h"
-#include "LAYER2/MAC/extern.h"
-#ifdef OPENAIR2
-#include "LAYER2/MAC/proto.h"
-#endif
+#include "PHY/phy_extern.h"
+#include "PHY/phy_extern_ue.h"
+#include "LAYER2/MAC/mac_extern.h"
+#include "LAYER2/MAC/mac_proto.h"
 #include "LAYER2/PDCP_v10.1.0/pdcp.h"
 #include "LAYER2/PDCP_v10.1.0/pdcp_primitives.h"
-#include "RRC/LITE/extern.h"
+#include "RRC/LTE/rrc_extern.h"
 #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h"
-#include "PHY_INTERFACE/extern.h"
+#include "PHY_INTERFACE/phy_interface_extern.h"
 //#include "ARCH/CBMIMO1/DEVICE_DRIVER/extern.h"
-#include "SCHED/extern.h"
 #include "SIMULATION/ETH_TRANSPORT/proto.h"
 #include "UTIL/OCG/OCG_extern.h"
 #include "UTIL/LOG/vcd_signal_dumper.h"
 #include "UTIL/OPT/opt.h"
 #include "UTIL/OTG/otg_config.h"
 #include "UTIL/OTG/otg_tx.h"
-#if ENABLE_RAL
-#include "lteRALenb.h"
-#include "lteRALue.h"
-#endif
-
 #include "cor_SF_sim.h"
 #include "enb_config.h"
 
@@ -83,11 +76,6 @@
 #include "ENB_APP/enb_paramdef.h"
 #include "common/config/config_userapi.h"
 
-#ifdef SMBV
-extern uint8_t config_smbv;
-extern char smbv_ip[16];
-#endif
-
 //constant for OAISIM soft realtime calibration
 #define SF_DEVIATION_OFFSET_NS 100000 //= 0.1ms : should be as a number of UE
 #define SLEEP_STEP_US       100 //  = 0.01ms could be adaptive, should be as a number of UE
@@ -137,34 +125,14 @@ int             sleep_time_us       = 0;
 
 int phy_test = 0;
 
-#ifdef OPENAIR2
-// omv related info
-//pid_t omv_pid;
-char full_name[200];
-extern int pfd[2]; // fd for omv : fixme: this could be a local var
-char fdstr[10];
-char frames[10];
-char num_enb[10];
-char num_ue[10];
-//area_x, area_y and area_z for omv
-char x_area[20];
-char y_area[20];
-char z_area[20];
-char nb_antenna[20];
-char frame_type[10];
-char tdd_config[10];
-#endif
-
-Packet_OTG_List_t *otg_pdcp_buffer = NULL;
-
 extern node_desc_t *enb_data[NUMBER_OF_RU_MAX];
-extern node_desc_t *ue_data[NUMBER_OF_UE_MAX];
-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 node_desc_t *ue_data[MAX_MOBILES_PER_ENB];
+extern channel_desc_t *RU2UE[NUMBER_OF_RU_MAX][MAX_MOBILES_PER_ENB][MAX_NUM_CCs];
+extern channel_desc_t *UE2RU[MAX_MOBILES_PER_ENB][NUMBER_OF_RU_MAX][MAX_NUM_CCs];
 
 extern mapping small_scale_names[];
 #if defined(Rel10) || defined(Rel14)
-extern pdcp_mbms_t pdcp_mbms_array_ue[NUMBER_OF_UE_MAX][maxServiceCount][maxSessionPerPMCH];
+extern pdcp_mbms_t pdcp_mbms_array_ue[MAX_MOBILES_PER_ENB][maxServiceCount][maxSessionPerPMCH];
 extern pdcp_mbms_t pdcp_mbms_array_eNB[NUMBER_OF_eNB_MAX][maxServiceCount][maxSessionPerPMCH];
 #endif
 
@@ -701,7 +669,7 @@ void get_simulation_options(int argc, char *argv[])
       break;
 
     case 'u':
-      oai_emulation.info.nb_ue_local = atoi (optarg);
+      NB_UE_INST = atoi (optarg);
       break;
 
     case 'U':
@@ -870,13 +838,13 @@ void check_and_adjust_params(void)
   int32_t ret;
   //int i,j;
 
-  if (oai_emulation.info.nb_ue_local  + oai_emulation.info.nb_rn_local > NUMBER_OF_UE_MAX) {
-    LOG_E(EMU,"Enter fewer than %d UEs/RNs for the moment or change the NUMBER_OF_UE_MAX\n", NUMBER_OF_UE_MAX);
+  if (oai_emulation.info.nb_ue_local  + oai_emulation.info.nb_rn_local > MAX_MOBILES_PER_ENB) {
+    LOG_E(EMU,"Enter fewer than %d UEs/RNs for the moment or change the MAX_MOBILES_PER_ENB\n", MAX_MOBILES_PER_ENB);
     exit(EXIT_FAILURE);
   }
 
   if (oai_emulation.info.nb_enb_local + oai_emulation.info.nb_rn_local > NUMBER_OF_eNB_MAX) {
-    LOG_E(EMU,"Enter fewer than %d eNBs/RNs for the moment or change the NUMBER_OF_UE_MAX\n", NUMBER_OF_eNB_MAX);
+    LOG_E(EMU,"Enter fewer than %d eNBs/RNs for the moment or change the MAX_MOBILES_PER_ENB\n", NUMBER_OF_eNB_MAX);
     exit(EXIT_FAILURE);
   }
 
@@ -931,79 +899,14 @@ void check_and_adjust_params(void)
   } // ethernet flag
   */
   //
-  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;
+
+  NB_RU = RC.nb_RU;
 
 #if defined(PDCP_USE_NETLINK_QUEUES) && defined(OPENAIR2)
   pdcp_netlink_init();
 #endif
 
-  if (NB_RN_INST > 0 ) {
-    LOG_N(EMU,"Total number of RN %d (local %d, remote %d) mobility (the same as eNB) %s  \n", NB_RN_INST,oai_emulation.info.nb_rn_local,oai_emulation.info.nb_rn_remote,
-          oai_emulation.topology_config.mobility.eNB_mobility.eNB_mobility_type.selected_option);
-
-    LOG_N(EMU,"Adjust the number of eNB inst (%d->%d) and UE inst (%d->%d)\n ",
-          NB_eNB_INST, NB_eNB_INST+NB_RN_INST,
-          NB_UE_INST, NB_UE_INST+NB_RN_INST);
-    NB_eNB_INST+=NB_RN_INST;
-    NB_UE_INST+=NB_RN_INST;
-  }
-
-  LOG_I(EMU,"Total number of UE %d (first local %d , num local %d, remote %d, relay %d) mobility %s \n",
-        NB_UE_INST,oai_emulation.info.first_ue_local, oai_emulation.info.nb_ue_local,oai_emulation.info.nb_ue_remote,
-        NB_RN_INST,
-        oai_emulation.topology_config.mobility.UE_mobility.UE_mobility_type.selected_option);
-
-  LOG_I(EMU,"Total number of eNB %d (local %d, remote %d, relay %d) mobility %s \n",
-        NB_eNB_INST,oai_emulation.info.nb_enb_local,oai_emulation.info.nb_enb_remote,
-        NB_RN_INST,
-        oai_emulation.topology_config.mobility.eNB_mobility.eNB_mobility_type.selected_option);
-
-}
-
-#ifdef OPENAIR2
-void init_omv(void)
-{
-  if (oai_emulation.info.omv_enabled == 1) {
-
-    if(pipe(pfd) == -1)
-      perror("pipe error \n");
-
-    snprintf( full_name, sizeof(full_name), "%s/UTIL/OMV/OMV",getenv("OPENAIR2_DIR") );
-    LOG_I(EMU,"Stating the OMV path %s pfd[0] %d pfd[1] %d \n", full_name, pfd[0],pfd[1]);
-
-    switch(fork()) {
-    case -1 :
-      perror("fork failed \n");
-      break;
-
-    case 0 : // child is going to be the omv, it is the reader
-      if(close(pfd[1]) == -1 ) // we close the write desc.
-        perror("close on write\n" );
-
-      sprintf(fdstr, "%d", pfd[0] );
-      sprintf(num_enb, "%d", NB_eNB_INST);
-      sprintf(num_ue, "%d", NB_UE_INST);
-      sprintf(x_area, "%f", oai_emulation.topology_config.area.x_m );
-      sprintf(y_area, "%f", oai_emulation.topology_config.area.y_m );
-      sprintf(z_area, "%f", 200.0 );
-      sprintf(frames, "%d", oai_emulation.info.n_frames);
-      sprintf(nb_antenna, "%d", 4);
-      sprintf(frame_type, "%s", (oai_emulation.info.frame_type[0] == 0) ? "FDD" : "TDD");
-      sprintf(tdd_config, "%d", oai_emulation.info.tdd_config[0]);
-      // execl is used to launch the visualisor
-      execl(full_name,"OMV", fdstr, frames, num_enb, num_ue, x_area, y_area, z_area, nb_antenna, frame_type, tdd_config,NULL );
-      perror( "error in execl the OMV" );
-    }
-
-    //parent
-    if(close( pfd[0] ) == -1 ) // we close the write desc.
-      perror("close on read\n" );
-  }
 }
-#endif
 
 void init_seed(uint8_t set_seed)
 {
@@ -1020,9 +923,9 @@ void init_seed(uint8_t set_seed)
 }
 
 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 current_UE_rx_timestamp[MAX_MOBILES_PER_ENB][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];
+openair0_timestamp last_UE_rx_timestamp[MAX_MOBILES_PER_ENB][MAX_NUM_CCs];
 
 int ru_trx_start(openair0_device *device) {
   return(0);
@@ -1369,63 +1272,16 @@ void init_ocm(void)
   //char* frame_type = "unknown";
   LTE_DL_FRAME_PARMS *fp = &RC.ru[0]->frame_parms;
 
-#if 0
-  switch (fp->frame_type) {
-  case FDD:
-    frame_type = "FDD";
-    break;
-
-  case TDD:
-    frame_type = "TDD";
-    break;
-  }
-#endif
-
-  if (abstraction_flag) {
-
-    get_beta_map();
-    get_MIESM_param();
-
-    //load_pbch_desc();
-  }
-
-
-  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++) {
-    ue_data[UE_id] = (node_desc_t *)malloc(sizeof(node_desc_t));
-    init_ue(ue_data[UE_id],oai_emulation.environment_system_config.antenna.UE_antenna);
-  }
-
-  if ((oai_emulation.info.ocm_enabled == 1)&& (ethernet_flag == 0 ) &&
-      (oai_emulation.environment_system_config.fading.shadowing.decorrelation_distance_m>0) &&
-      (oai_emulation.environment_system_config.fading.shadowing.variance_dB>0)) {
-
-    // init SF map here!!!
-    map1 =(int)oai_emulation.topology_config.area.x_m;
-    map2 =(int)oai_emulation.topology_config.area.y_m;
-    ShaF = init_SF(map1,map2,oai_emulation.environment_system_config.fading.shadowing.decorrelation_distance_m,oai_emulation.environment_system_config.fading.shadowing.variance_dB);
-
-    // size of area to generate shadow fading map
-    LOG_D(EMU,"Simulation area x=%f, y=%f\n",
-          oai_emulation.topology_config.area.x_m,
-          oai_emulation.topology_config.area.y_m);
-  }
-
-  if (abstraction_flag == 0)
-    init_channel_vars (fp, &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
+  LOG_I(PHY,"Initializing channel descriptors (nb_RU %d, nb_UE %d)\n",RC.nb_RU,NB_UE_INST);
   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_I(OCM,"Initializing channel (%s, %d) from RU %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), ru_id, UE_id);
-
 
+	LOG_I(PHY,"Initializing channel descriptors (RU %d, UE %d) for N_RB_DL %d\n",ru_id,UE_id,
+	      RC.ru[ru_id]->frame_parms.N_RB_DL);
         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,
@@ -1454,22 +1310,29 @@ void init_ocm(void)
 
         // 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.
         //UE2RU[UE_id][ru_id] = RU2UE[ru_id][UE_id];
-      }
-    }
-  }
-}
 
-void init_otg_pdcp_buffer(void)
-{
-  module_id_t i;
-  otg_pdcp_buffer = malloc((NB_UE_INST + NB_eNB_INST) * sizeof(Packet_OTG_List_t));
+	AssertFatal(RU2UE[ru_id][UE_id][CC_id]!=NULL,"RU2UE[%d][%d][%d] is null\n",ru_id,UE_id,CC_id);
+	AssertFatal(UE2RU[UE_id][ru_id][CC_id]!=NULL,"UE2RU[%d][%d][%d] is null\n",UE_id,ru_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);
+	
 
-  for (i = 0; i < NB_UE_INST + NB_eNB_INST; i++) {
-    pkt_list_init(&(otg_pdcp_buffer[i]));
-    //LOG_I(EMU,"HEAD of otg_pdcp_buffer[%d] is %p\n", i, pkt_list_get_head(&(otg_pdcp_buffer[i])));
+      }
+    }
   }
 }
 
+/*
 void update_omg (frame_t frameP)
 {
   module_id_t UE_id, eNB_id;
@@ -1515,7 +1378,7 @@ void update_ocm()
 
 
 
-  /* check if the openair channel model is activated used for PHY abstraction : path loss*/
+  // 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++)
@@ -1533,9 +1396,6 @@ void update_ocm()
     //      if (oai_emulation.info.omg_model_ue == TRACE)
     //extract_position(ue_node_list, ue_data, NB_UE_INST);
 
-    /* if (frame % 50 == 0)
-       LOG_N(OCM,"Path loss for TTI %d : \n", frame);
-    */
     for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
       for (ru_id = 0; ru_id < RC.nb_RU; ru_id++) {
         for (UE_id = 0; UE_id < NB_UE_INST; UE_id++) {
@@ -1550,10 +1410,10 @@ void update_ocm()
           //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",
-                  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);*/
+          ///LOG_D(LOCALIZE, " OCM distance between eNB %d at (%f,%f) and UE %d at (%f,%f) is %f \n",
+          //        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);
         }
       }
     }
@@ -1585,6 +1445,7 @@ void update_ocm()
   }
 }
 
+
 #ifdef OPENAIR2
 void update_otg_eNB(module_id_t enb_module_idP, unsigned int ctime)
 {
@@ -1592,13 +1453,12 @@ void update_otg_eNB(module_id_t enb_module_idP, unsigned int ctime)
 #if defined(USER_MODE) && defined(OAI_EMU)
 
   //int rrc_state=0;
-/*
   if (oai_emulation.info.otg_enabled ==1 ) {
 
     int dst_id, app_id;
     Packet_otg_elt_t *otg_pkt;
 
-    for (dst_id = 0; dst_id < NUMBER_OF_UE_MAX; dst_id++) {
+    for (dst_id = 0; dst_id < MAX_MOBILES_PER_ENB; dst_id++) {
       for_times += 1;
 
       // generate traffic if the ue is rrc reconfigured state
@@ -1663,9 +1523,9 @@ void update_otg_eNB(module_id_t enb_module_idP, unsigned int ctime)
               otg_pkt=NULL;
             }
 
-*/
+
             // old version
-            /*      // MBSM multicast traffic
+                  // MBSM multicast traffic
             #if defined(Rel10) || defined(Rel14)
             if (frame >= 46) {// only generate when UE can receive MTCH (need to control this value)
             for (service_id = 0; service_id < 2 ; service_id++) { //maxServiceCount
@@ -1688,15 +1548,15 @@ void update_otg_eNB(module_id_t enb_module_idP, unsigned int ctime)
             }
             } // end multicast traffic
             #endif
-             */
-/*
+
+
 
           }
         }
       }
 
     } // end multicast traffic
-*/
+
 
 #endif
   }
@@ -1706,7 +1566,7 @@ void update_otg_eNB(module_id_t enb_module_idP, unsigned int ctime)
   if (otg_enabled==1) {
     ctime = frame * 100;
 
-    for (dst_id = 0; dst_id < NUMBER_OF_UE_MAX; dst_id++) {
+    for (dst_id = 0; dst_id < MAX_MOBILES_PER_ENB; dst_id++) {
       if (mac_get_rrc_status(eNB_index, eNB_flag, dst_id ) > 2) {
         otg_pkt = malloc (sizeof(Packet_otg_elt_t));
         (otg_pkt->otg_pkt).sdu_buffer = packet_gen(module_instP, dst_id, ctime, &pkt_size);
@@ -1735,6 +1595,7 @@ void update_otg_UE(module_id_t ue_mod_idP, unsigned int ctime)
 {
 }
 #endif
+*/
 
 int init_slot_isr(void)
 {
diff --git a/targets/SIMU/USER/sinr_sim.c b/targets/SIMU/USER/sinr_sim.c
index 7c752ce432f2b268cc7d11b2efd1f770a2c2482b..2dc86b844301977c9983430ac51e7f89b2725072 100644
--- a/targets/SIMU/USER/sinr_sim.c
+++ b/targets/SIMU/USER/sinr_sim.c
@@ -27,27 +27,26 @@
 #include <time.h>
 #include <cblas.h>
 
-#include "SIMULATION/TOOLS/defs.h"
-#include "SIMULATION/RF/defs.h"
+#include "SIMULATION/TOOLS/sim.h"
+#include "SIMULATION/RF/rf.h"
 #include "PHY/types.h"
-#include "PHY/defs.h"
-#include "PHY/extern.h"
+#include "PHY/defs_eNB.h"
+#include "PHY/defs_UE.h"
+#include "PHY/phy_extern.h"
 #include "oaisim_config.h"
 
 #ifdef OPENAIR2
-#include "LAYER2/MAC/defs.h"
-#include "LAYER2/MAC/extern.h"
+#include "LAYER2/MAC/mac.h"
+#include "LAYER2/MAC/mac_extern.h"
 #include "UTIL/LOG/log_if.h"
 #include "UTIL/LOG/log_extern.h"
-#include "RRC/LITE/extern.h"
-#include "PHY_INTERFACE/extern.h"
+#include "RRC/LTE/rrc_extern.h"
+#include "PHY_INTERFACE/phy_interface_extern.h"
 #include "UTIL/OCG/OCG.h"
 #include "UTIL/OMG/omg.h"
 #include "UTIL/OPT/opt.h" // to test OPT
 #endif
 
-#include "SCHED/defs.h"
-#include "SCHED/extern.h"
 
 #include "oaisim.h"