diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt
index b84ffd38a0a18f6729e9299e9ea8d0bd590f017f..038309d74cd4259b2b4e61bed4138d70e59fd379 100644
--- a/cmake_targets/CMakeLists.txt
+++ b/cmake_targets/CMakeLists.txt
@@ -2458,7 +2458,7 @@ add_executable(lte-softmodem
   ${OPENAIR_TARGETS}/RT/USER/lte-ru.c
   ${OPENAIR_TARGETS}/RT/USER/ru_control.c
   ${OPENAIR_TARGETS}/RT/USER/lte-softmodem.c
-  ${OPENAIR_TARGETS}/RT/USER/lte-softmodem-common.c
+  ${OPENAIR_DIR}/executables/softmodem-common.c
   ${OPENAIR2_DIR}/ENB_APP/NB_IoT_interface.c
   ${OPENAIR1_DIR}/SIMULATION/TOOLS/taus.c
   ${OPENAIR_TARGETS}/COMMON/create_tasks.c
@@ -2527,7 +2527,7 @@ add_executable(lte-uesoftmodem
   ${OPENAIR_TARGETS}/RT/USER/rt_wrapper.c
   ${OPENAIR_TARGETS}/RT/USER/lte-ue.c
   ${OPENAIR_TARGETS}/RT/USER/lte-uesoftmodem.c
-  ${OPENAIR_TARGETS}/RT/USER/lte-softmodem-common.c
+  ${OPENAIR_DIR}/executables/softmodem-common.c
   ${OPENAIR_TARGETS}/RT/USER/lte-ru.c
   ${OPENAIR_TARGETS}/RT/USER/ru_control.c
   ${OPENAIR_TARGETS}/RT/USER/rfsim.c
@@ -2576,7 +2576,7 @@ add_executable(nr-softmodem
   ${OPENAIR_DIR}/executables/nr-gnb.c
   ${OPENAIR_DIR}/executables/nr-ru.c
   ${OPENAIR_DIR}/executables/nr-softmodem.c
-  ${OPENAIR_TARGETS}/RT/USER/lte-softmodem-common.c
+  ${OPENAIR_DIR}/executables/softmodem-common.c
   ${OPENAIR1_DIR}/SIMULATION/TOOLS/taus.c
   ${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c
   ${OPENAIR2_DIR}/RRC/NAS/nas_config.c
@@ -2615,7 +2615,7 @@ add_executable(nr-uesoftmodem
   ${OPENAIR_DIR}/common/utils/threadPool/thread-pool.c
   ${OPENAIR_DIR}/executables/nr-uesoftmodem.c
   ${OPENAIR_DIR}/executables/nr-ue.c
-  ${OPENAIR_TARGETS}/RT/USER/lte-softmodem-common.c
+  ${OPENAIR_DIR}/executables/softmodem-common.c
   ${OPENAIR1_DIR}/SIMULATION/TOOLS/taus.c
   ${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c
   ${OPENAIR2_DIR}/RRC/NAS/nas_config.c
diff --git a/executables/nr-ru.c b/executables/nr-ru.c
index a90bf9308a11b8e8d368782a82edd1a2f6b903c3..e375be4f21f90e424275d824662791ed861733f0 100644
--- a/executables/nr-ru.c
+++ b/executables/nr-ru.c
@@ -81,7 +81,7 @@
 #include "common/utils/LOG/vcd_signal_dumper.h"
 
 #include "enb_config.h"
-#include <executables/nr-softmodem.h>
+#include <executables/softmodem-common.h>
 
 #ifdef SMBV
 #include "PHY/TOOLS/smbv.h"
diff --git a/executables/nr-softmodem-common.h b/executables/nr-softmodem-common.h
index ad9b38ce7edf8fa2bfff2148daf0752cb3b4b7af..5353178f0ebb1a64a1e478ca2096c7ce8661d2c3 100644
--- a/executables/nr-softmodem-common.h
+++ b/executables/nr-softmodem-common.h
@@ -131,7 +131,6 @@ extern uint64_t downlink_frequency[MAX_NUM_CCs][4];
 extern int32_t uplink_frequency_offset[MAX_NUM_CCs][4];
 
 extern int rx_input_level_dBm;
-extern uint8_t exit_missed_slots;
 extern uint64_t num_missed_slots; // counter for the number of missed slots
 
 extern int oaisim_flag;
diff --git a/executables/nr-softmodem.c b/executables/nr-softmodem.c
index 8a4440d4d6ee5a418cf1f0904138ab827a12e45d..68b8b8aa297c2f46a4f55d6b442b2f1f2dd9735a 100644
--- a/executables/nr-softmodem.c
+++ b/executables/nr-softmodem.c
@@ -149,11 +149,9 @@ double bw = 10.0e6;
 
 static int tx_max_power[MAX_NUM_CCs]; /* =  {0,0}*/;
 
-char rf_config_file[1024]="/usr/local/etc/syriq/ue.band7.tm1.PRB100.NR40.dat";
 
 int chain_offset=0;
-int phy_test = 0;
-uint8_t usim_test = 0;
+
 
 uint8_t dci_Format = 0;
 uint8_t agregation_Level =0xFF;
@@ -177,7 +175,6 @@ int otg_enabled;
 uint32_t target_dl_mcs = 28; //maximum allowed mcs
 uint32_t target_ul_mcs = 20;
 uint32_t timing_advance = 0;
-uint8_t exit_missed_slots=1;
 uint64_t num_missed_slots=0; // counter for the number of missed slots
 
 
@@ -190,7 +187,6 @@ int transmission_mode=1;
 int emulate_rf = 0;
 int numerology = 0;
 
-static softmodem_params_t softmodem_params;
 
 static char *parallel_config = NULL;
 static char *worker_config = NULL;
@@ -271,39 +267,13 @@ unsigned int build_rfdc(int dcoff_i_rxfe, int dcoff_q_rxfe) {
   return (dcoff_i_rxfe + (dcoff_q_rxfe<<8));
 }
 
-#if !defined(ENABLE_ITTI)
-void signal_handler(int sig) {
-  void *array[10];
-  size_t size;
-
-  if (sig==SIGSEGV) {
-    // get void*'s for all entries on the stack
-    size = backtrace(array, 10);
-    // print out all the frames to stderr
-    fprintf(stderr, "Error: signal %d:\n", sig);
-    backtrace_symbols_fd(array, size, 2);
-    exit(-1);
-  } else {
-    printf("trying to exit gracefully...\n");
-    oai_exit = 1;
-  }
-}
-#endif
+
 #define KNRM  "\x1B[0m"
 #define KRED  "\x1B[31m"
 #define KGRN  "\x1B[32m"
 #define KBLU  "\x1B[34m"
 #define RESET "\033[0m"
 
-#if defined(ENABLE_ITTI)
-void signal_handler_itti(int sig) {
-  // Call exit function
-  char msg[256];
-  memset(msg, 0, 256);
-  sprintf(msg, "caught signal %s\n", strsignal(sig));
-  exit_function(__FILE__, __FUNCTION__, __LINE__, msg);
-}
-#endif
 
 void exit_function(const char *file, const char *function, const int line, const char *s) {
   int ru_id;
@@ -330,9 +300,6 @@ void exit_function(const char *file, const char *function, const int line, const
   }
 
   sleep(1); //allow lte-softmodem threads to exit first
-#if defined(ENABLE_ITTI)
-  itti_terminate_tasks (TASK_UNKNOWN);
-#endif
   exit(1);
 }
 
@@ -482,36 +449,13 @@ int create_gNB_tasks(uint32_t gnb_nb) {
 
 
 static void get_options(void) {
-  int tddflag, nonbiotflag;
-  uint32_t online_log_messages;
-  uint32_t glog_level, glog_verbosity;
-  uint32_t start_telnetsrv = 0;
-  uint32_t noS1;
-  uint32_t nokrnmod;
-  paramdef_t cmdline_params[] = CMDLINE_PARAMS_DESC_GNB ;
-  paramdef_t cmdline_logparams[] = CMDLINE_LOGPARAMS_DESC_NR ;
-  config_process_cmdline( cmdline_params,sizeof(cmdline_params)/sizeof(paramdef_t),NULL);
-
-
 
-  config_process_cmdline( cmdline_logparams,sizeof(cmdline_logparams)/sizeof(paramdef_t),NULL);
 
-  if(config_isparamset(cmdline_logparams,CMDLINE_ONLINELOG_IDX)) {
-    set_glog_onlinelog(online_log_messages);
-  }
+  paramdef_t cmdline_params[] = CMDLINE_PARAMS_DESC_GNB ;
 
-  if(config_isparamset(cmdline_logparams,CMDLINE_GLOGLEVEL_IDX)) {
-    set_glog(glog_level);
-  }
+  config_process_cmdline( cmdline_params,sizeof(cmdline_params)/sizeof(paramdef_t),NULL);
 
-  if (start_telnetsrv) {
-    load_module_shlib("telnetsrv",NULL,0,NULL);
-  }
 
-#if T_TRACER
-  paramdef_t cmdline_ttraceparams[] =CMDLINE_TTRACEPARAMS_DESC ;
-  config_process_cmdline( cmdline_ttraceparams,sizeof(cmdline_ttraceparams)/sizeof(paramdef_t),NULL);
-#endif
 
   if ( !(CONFIG_ISFLAGSET(CONFIG_ABORT)) ) {
     memset((void *)&RC,0,sizeof(RC));
@@ -529,14 +473,6 @@ static void get_options(void) {
 }
 
 
-#if T_TRACER
-  int T_nowait = 0;     /* by default we wait for the tracer */
-  int T_port = 2021;    /* default port to listen to to wait for the tracer */
-  int T_dont_fork = 0;  /* default is to fork, see 'T_init' to understand */
-#endif
-
-
-
 void set_default_frame_parms(nfapi_nr_config_request_scf_t *config[MAX_NUM_CCs],
 		             NR_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs])
 {
@@ -666,7 +602,7 @@ void init_openair0(void) {
       openair0_cfg[card].rx_gain[i] = RC.gNB[0]->rx_total_gain_dB;
 
 
-      openair0_cfg[card].configFilename = rf_config_file;
+      openair0_cfg[card].configFilename = get_softmodem_params()->rf_config_file;
       printf("Card %d, channel %d, Setting tx_gain %f, rx_gain %f, tx_freq %f, rx_freq %f\n",
        card,i, openair0_cfg[card].tx_gain[i],
        openair0_cfg[card].rx_gain[i],
@@ -875,7 +811,7 @@ int main( int argc, char **argv )
   if ( load_configmodule(argc,argv,CONFIG_ENABLECMDLINEONLY) == NULL) {
     exit_fun("[SOFTMODEM] Error, configuration module init failed\n");
   }
-
+  set_softmodem_sighandler();
 #ifdef DEBUG_CONSOLE
   setvbuf(stdout, NULL, _IONBF, 0);
   setvbuf(stderr, NULL, _IONBF, 0);
@@ -923,11 +859,7 @@ init_opt();
   pdcp_netlink_init();
 #endif
 #endif
-#if !defined(ENABLE_ITTI)
-  // to make a graceful exit when ctrl-c is pressed
-  signal(SIGSEGV, signal_handler);
-  signal(SIGINT, signal_handler);
-#endif
+
 #ifndef PACKAGE_VERSION
 #  define PACKAGE_VERSION "UNKNOWN-EXPERIMENTAL"
 #endif
@@ -1012,7 +944,7 @@ init_opt();
 
   if (RC.nb_RU >0) {
     printf("Initializing RU threads\n");
-    init_NR_RU(rf_config_file);
+    init_NR_RU(get_softmodem_params()->rf_config_file);
 
     for (ru_id=0; ru_id<RC.nb_RU; ru_id++) {
       RC.ru[ru_id]->rf_map.card=0;
diff --git a/executables/nr-softmodem.h b/executables/nr-softmodem.h
index d7b121ecd27f16326d38047019c6eb22e46d8482..27e3ba1e3e328758f452df56460efc43b8cac554 100644
--- a/executables/nr-softmodem.h
+++ b/executables/nr-softmodem.h
@@ -18,10 +18,6 @@
 /*   optname                helpstr                 paramflags        XXXptr                              defXXXval                   type         numelt               */
 /*----------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
 #define CMDLINE_PARAMS_DESC_GNB {  \
-    {"rf-config-file",        CONFIG_HLP_RFCFGF,      0,                strptr:(char **)&rf_config_file,    defstrval:NULL,                TYPE_STRING, sizeof(rf_config_file)},\
-    {"ulsch-max-errors",      CONFIG_HLP_ULMAXE,      0,                uptr:&ULSCH_max_consecutive_errors, defuintval:0,                  TYPE_UINT,   0},        \
-    {"phy-test",              CONFIG_HLP_PHYTST,      PARAMFLAG_BOOL,   iptr:&phy_test,                     defintval:0,                   TYPE_INT,    0},        \
-    {"usim-test",             CONFIG_HLP_USIM,        PARAMFLAG_BOOL,   u8ptr:&usim_test,                   defintval:0,                   TYPE_UINT8,  0},        \
     {"mmapped-dma",           CONFIG_HLP_DMAMAP,      PARAMFLAG_BOOL,   uptr:&mmapped_dma,                  defintval:0,                   TYPE_INT,    0},        \
     {"wait-for-sync",         NULL,                   PARAMFLAG_BOOL,   iptr:&wait_for_sync,                defintval:0,                   TYPE_INT,    0},        \
     {"single-thread-disable", CONFIG_HLP_NOSNGLT,     PARAMFLAG_BOOL,   iptr:&single_thread_flag,           defintval:1,                   TYPE_INT,    0},        \
@@ -34,34 +30,13 @@
     {"m" ,                    CONFIG_HLP_DLMCS,       0,                uptr:&target_dl_mcs,                defintval:0,                   TYPE_UINT,   0},        \
     {"t" ,                    CONFIG_HLP_ULMCS,       0,                uptr:&target_ul_mcs,                defintval:0,                   TYPE_UINT,   0},        \
     {"q" ,                    CONFIG_HLP_STMON,       PARAMFLAG_BOOL,   iptr:&opp_enabled,                  defintval:0,                   TYPE_INT,    0},        \
-    {"S" ,                    CONFIG_HLP_MSLOTS,      PARAMFLAG_BOOL,   u8ptr:&exit_missed_slots,           defintval:1,                   TYPE_UINT8,  0},        \
-    {"T" ,                    CONFIG_HLP_TDD,         PARAMFLAG_BOOL,   iptr:&tddflag,                      defintval:0,                   TYPE_INT,    0},        \
     {"numerology" ,           CONFIG_HLP_NUMEROLOGY,  PARAMFLAG_BOOL,   iptr:&numerology,                   defintval:0,                   TYPE_INT,    0},        \
     {"emulate-rf" ,           CONFIG_HLP_EMULATE_RF,  PARAMFLAG_BOOL,   iptr:&emulate_rf,                   defintval:0,                   TYPE_INT,    0},        \
     {"parallel-config",       CONFIG_HLP_PARALLEL_CMD,0,                strptr:(char **)&parallel_config,   defstrval:NULL,                TYPE_STRING, 0},        \
     {"worker-config",         CONFIG_HLP_WORKER_CMD,  0,                strptr:(char **)&worker_config,     defstrval:NULL,                TYPE_STRING, 0},        \
     {"s" ,                    CONFIG_HLP_SNR,         0,                dblptr:&snr_dB,                     defdblval:25,                  TYPE_DOUBLE, 0},        \
-    {"nbiot-disable",         CONFIG_HLP_DISABLNBIOT, PARAMFLAG_BOOL,   iptr:&nonbiotflag,                  defintval:0,                   TYPE_INT,    0},        \
-    {"noS1",                  CONFIG_HLP_NOS1,        PARAMFLAG_BOOL,   uptr:&noS1,                         defintval:0,                   TYPE_INT,    0},        \
-    {"nokrnmod",              CONFIG_HLP_NOKRNMOD,    PARAMFLAG_BOOL,   uptr:&nokrnmod,                     defintval:0,                   TYPE_INT,    0}         \
   }
 
-#define SOFTMODEM_NOS1_BIT            (1<<0)
-#define SOFTMODEM_NOKRNMOD_BIT        (1<<1)
-#define SOFTMODEM_RFSIM_BIT           (1<<10)
-
-#define IS_SOFTMODEM_NOS1            ( get_softmodem_optmask() & SOFTMODEM_NOS1_BIT)
-#define IS_SOFTMODEM_NOKRNMOD        ( get_softmodem_optmask() & SOFTMODEM_NOKRNMOD_BIT)
-
-#define IS_SOFTMODEM_RFSIM           ( get_softmodem_optmask() & SOFTMODEM_RFSIM_BIT)
-extern uint64_t get_softmodem_optmask(void);
-extern void get_common_options(void);
-
-extern int T_port;
-extern int T_nowait;
-extern int T_dont_fork;
-
-
 #include "threads_t.h"
 extern threads_t threads;
 
diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c
index fb0f18f2f50134bc2978e1e83617fdb019da7d08..4201a84ddcee8d5ad3663e1f3d1e4dfe8012fab6 100644
--- a/executables/nr-uesoftmodem.c
+++ b/executables/nr-uesoftmodem.c
@@ -163,11 +163,9 @@ double bw = 10.0e6;
 
 static int  tx_max_power[MAX_NUM_CCs] = {0};
 
-char rf_config_file[1024];
 
 int chain_offset=0;
-int phy_test = 0;
-uint8_t usim_test = 0;
+
 
 uint8_t dci_Format = 0;
 uint8_t agregation_Level =0xFF;
@@ -178,7 +176,6 @@ uint8_t nb_antenna_rx = 1;
 char ref[128] = "internal";
 char channels[128] = "0";
 
-static softmodem_params_t softmodem_params;
 
 static char *parallel_config = NULL;
 static char *worker_config = NULL;
@@ -197,7 +194,6 @@ int16_t node_synch_ref[MAX_NUM_CCs];
 uint32_t target_dl_mcs = 28; //maximum allowed mcs
 uint32_t target_ul_mcs = 20;
 uint32_t timing_advance = 0;
-uint8_t exit_missed_slots=1;
 uint64_t num_missed_slots=0; // counter for the number of missed slots
 
 
@@ -275,7 +271,7 @@ void exit_function(const char *file, const char *function, const int line, const
   }
 
   sleep(1); //allow lte-softmodem threads to exit first
-  itti_terminate_tasks (TASK_UNKNOWN);
+  exit(1);
 }
 
 
@@ -388,28 +384,12 @@ static void get_options(void) {
   int tddflag=0, nonbiotflag, vcdflag=0;
   char *loopfile=NULL;
   int dumpframe=0;
-  uint32_t online_log_messages;
-  uint32_t glog_level, glog_verbosity;
-  uint32_t start_telnetsrv=0;
+
   //uint32_t noS1;
   //uint32_t nokrnmod;
   paramdef_t cmdline_params[] =CMDLINE_PARAMS_DESC_UE ;
-  paramdef_t cmdline_logparams[] =CMDLINE_LOGPARAMS_DESC_NR ;
   config_process_cmdline( cmdline_params,sizeof(cmdline_params)/sizeof(paramdef_t),NULL);
 
-  config_process_cmdline( cmdline_logparams,sizeof(cmdline_logparams)/sizeof(paramdef_t),NULL);
-
-  if(config_isparamset(cmdline_logparams,CMDLINE_ONLINELOG_IDX)) {
-    set_glog_onlinelog(online_log_messages);
-  }
-
-  if(config_isparamset(cmdline_logparams,CMDLINE_GLOGLEVEL_IDX)) {
-    set_glog(glog_level);
-  }
-
-  if (start_telnetsrv) {
-    load_module_shlib("telnetsrv",NULL,0,NULL);
-  }
 
   paramdef_t cmdline_uemodeparams[] = CMDLINE_UEMODEPARAMS_DESC;
   paramdef_t cmdline_ueparams[] = CMDLINE_NRUEPARAMS_DESC;
@@ -478,10 +458,6 @@ static void get_options(void) {
     tx_gain[0][CC_id] = tx_gain[0][0];
   }
 
-#if T_TRACER
-  paramdef_t cmdline_ttraceparams[] =CMDLINE_TTRACEPARAMS_DESC ;
-  config_process_cmdline( cmdline_ttraceparams,sizeof(cmdline_ttraceparams)/sizeof(paramdef_t),NULL);
-#endif
 
   if ( !(CONFIG_ISFLAGSET(CONFIG_ABORT))  && (!(CONFIG_ISFLAGSET(CONFIG_NOOOPT))) ) {
     // Here the configuration file is the XER encoded UE capabilities
@@ -492,11 +468,6 @@ static void get_options(void) {
   } /* UE with config file  */
 }
 
-#if T_TRACER
-  int T_nowait = 0;       /* by default we wait for the tracer */
-  int T_port = 2021;    /* default port to listen to to wait for the tracer */
-  int T_dont_fork = 0;  /* default is to fork, see 'T_init' to understand */
-#endif
 
 void set_default_frame_parms(NR_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]) {
   int CC_id;
@@ -637,7 +608,7 @@ void init_openair0(void) {
       openair0_cfg[card].autocal[i] = 1;
       openair0_cfg[card].tx_gain[i] = tx_gain[0][i];
       openair0_cfg[card].rx_gain[i] = PHY_vars_UE_g[0][0]->rx_total_gain_dB - rx_gain_off;
-      openair0_cfg[card].configFilename = rf_config_file;
+      openair0_cfg[card].configFilename = get_softmodem_params()->rf_config_file;
       printf("Card %d, channel %d, Setting tx_gain %f, rx_gain %f, tx_freq %f, rx_freq %f\n",
              card,i, openair0_cfg[card].tx_gain[i],
              openair0_cfg[card].rx_gain[i],
@@ -680,7 +651,7 @@ int main( int argc, char **argv ) {
   if ( load_configmodule(argc,argv,CONFIG_ENABLECMDLINEONLY) == NULL) {
     exit_fun("[SOFTMODEM] Error, configuration module init failed\n");
   }
-
+  set_softmodem_sighandler();
   CONFIG_SETRTFLAG(CONFIG_NOEXITONHELP);
   set_default_frame_parms(frame_parms);
   mode = normal_txrx;
@@ -759,6 +730,11 @@ int main( int argc, char **argv ) {
    
     init_nr_ue_vars(UE[CC_id],frame_parms[CC_id],0,abstraction_flag);
 
+    if (get_softmodem_params()->phy_test==1)
+      UE[CC_id]->mac_enabled = 0;
+    else
+      UE[CC_id]->mac_enabled = 1;
+
     UE[CC_id]->mac_enabled = 1;
     UE[CC_id]->if_inst = nr_ue_if_module_init(0);
     UE[CC_id]->UE_scan = UE_scan;
diff --git a/executables/nr-uesoftmodem.h b/executables/nr-uesoftmodem.h
index 891b97514c2bc51e51c0369e6df1916b0eee576b..3194839dcf7b36ac175fa16a1cb691c5c64cb0a6 100644
--- a/executables/nr-uesoftmodem.h
+++ b/executables/nr-uesoftmodem.h
@@ -61,10 +61,6 @@
 /*   optname                helpstr                 paramflags      XXXptr                                 defXXXval              type         numelt */
 /*----------------------------------------------------------------------------------------------------------------------------------------------------*/
 #define CMDLINE_PARAMS_DESC_UE {  \
-  {"rf-config-file",        CONFIG_HLP_RFCFGF,      0,              strptr:(char **)&rf_config_file,       defstrval:NULL,        TYPE_STRING, sizeof(rf_config_file)},\
-  {"ulsch-max-errors",      CONFIG_HLP_ULMAXE,      0,              uptr:&ULSCH_max_consecutive_errors,    defuintval:0,          TYPE_UINT,   0}, \
-  {"phy-test",              CONFIG_HLP_PHYTST,      PARAMFLAG_BOOL, iptr:&phy_test,                        defintval:0,           TYPE_INT,    0}, \
-  {"usim-test",             CONFIG_HLP_USIM,        PARAMFLAG_BOOL, u8ptr:&usim_test,                      defintval:0,           TYPE_UINT8,  0}, \
   {"clock-source",          CONFIG_HLP_EXCCLK,      0,              iptr:&clock_source,                    defintval:0,           TYPE_INT,    0}, \
   {"single-thread-disable", CONFIG_HLP_NOSNGLT,     PARAMFLAG_BOOL, iptr:&single_thread_flag,              defintval:1,           TYPE_INT,    0}, \
   {"nr-dlsch-demod-shift",  CONFIG_HLP_DLSHIFT,     0,              iptr:(int32_t *)&nr_dlsch_demod_shift, defintval:0,           TYPE_INT,    0}, \
@@ -76,7 +72,6 @@
   {"m" ,                    CONFIG_HLP_DLMCS,       0,              uptr:&target_dl_mcs,                   defintval:0,           TYPE_UINT,   0}, \
   {"t" ,                    CONFIG_HLP_ULMCS,       0,              uptr:&target_ul_mcs,                   defintval:0,           TYPE_UINT,   0}, \
   {"q" ,                    CONFIG_HLP_STMON,       PARAMFLAG_BOOL, iptr:&opp_enabled,                     defintval:0,           TYPE_INT,    0}, \
-  {"S" ,                    CONFIG_HLP_MSLOTS,      PARAMFLAG_BOOL, u8ptr:&exit_missed_slots,              defintval:1,           TYPE_UINT8,  0}, \
   {"T" ,                    CONFIG_HLP_TDD,         PARAMFLAG_BOOL, iptr:&tddflag,                         defintval:0,           TYPE_INT,    0}, \
   {"V" ,                    CONFIG_HLP_VCD,         PARAMFLAG_BOOL, iptr:&vcdflag,                         defintval:0,           TYPE_INT,    0}, \
   {"numerology" ,           CONFIG_HLP_NUMEROLOGY,  0,              iptr:&numerology,                      defintval:0,           TYPE_INT,    0}, \
diff --git a/targets/RT/USER/lte-softmodem-common.c b/executables/softmodem-common.c
similarity index 59%
rename from targets/RT/USER/lte-softmodem-common.c
rename to executables/softmodem-common.c
index 6bd8835a9230c042a1b9504a545758f44ec93cd9..00b974e3ae0b342e6303bfe2a4c01528651121d7 100644
--- a/targets/RT/USER/lte-softmodem-common.c
+++ b/executables/softmodem-common.c
@@ -20,26 +20,33 @@
  */
 
 /*! \file lte-softmodem-common.c
- * \brief Top-level threads for eNodeB
+ * \brief common code for 5G and LTE softmodem main xNB and UEs source (nr-softmodem.c, lte-softmodem.c...)
  * \author Nokia BellLabs France, francois Taburet
- * \date 2012
+ * \date 2020
  * \version 0.1
- * \company Eurecom
+ * \company Nokia BellLabs France
  * \email: francois.taburet@nokia-bell-labs.com
  * \note
  * \warning
  */
-
-#include "lte-softmodem.h"
+#include <time.h>
+#include <dlfcn.h>
+#include <sys/resource.h>
 #include "UTIL/OPT/opt.h"
 #include "common/config/config_userapi.h"
 #include "common/utils/load_module_shlib.h"
+#include "common/utils/telnetsrv/telnetsrv.h"
 #include "executables/thread-common.h"
-#include <dlfcn.h>
+#include "softmodem-common.h"
+
 static softmodem_params_t softmodem_params;
 char *parallel_config=NULL;
 char *worker_config=NULL;
 
+
+
+static struct timespec start;
+
 uint64_t get_softmodem_optmask(void) {
   return softmodem_params.optmask;
 }
@@ -92,7 +99,7 @@ void get_common_options(void) {
   }
 
   if (nokrnmod) {
-	  printf("nokrnmod bit enabled \n");
+    printf("nokrnmod bit enabled \n");
     set_softmodem_optmask(SOFTMODEM_NOKRNMOD_BIT);
   }
 
@@ -112,21 +119,67 @@ void get_common_options(void) {
     set_softmodem_optmask(SOFTMODEM_DOFORMS_BIT);
   }
 
-#if BASIC_SIMULATOR
-  set_softmodem_optmask(SOFTMODEM_BASICSIM_BIT);
-#endif
-
   if(parallel_config != NULL) set_parallel_conf(parallel_config);
 
   if(worker_config != NULL)   set_worker_conf(worker_config);
 }
 
-unsigned int is_nos1exec(char *exepath) {
-  if ( strcmp( basename(exepath), "lte-softmodem-nos1") == 0)
-    return 1;
+void softmodem_printresources(int sig, telnet_printfunc_t pf) {
+   struct rusage usage;
+   struct timespec stop;
+
+   clock_gettime(CLOCK_BOOTTIME, &stop);
+
+   uint64_t elapse = (stop.tv_sec - start.tv_sec) ;   // in seconds
+
+
+   int st = getrusage(RUSAGE_SELF,&usage);
+   if (!st) {
+   	 pf("\nRun time: %lluh %llus\n",(unsigned long long)elapse/3600,(unsigned long long)(elapse - (elapse/3600)));
+     pf("\tTime executing user inst.: %lds %ldus\n",(long)usage.ru_utime.tv_sec,(long)usage.ru_utime.tv_usec);
+     pf("\tTime executing system inst.: %lds %ldus\n",(long)usage.ru_stime.tv_sec,(long)usage.ru_stime.tv_usec);
+     pf("\tMax. Phy. memory usage: %ldkB\n",(long)usage.ru_maxrss);
+     pf("\tPage fault number (no io): %ld\n",(long)usage.ru_minflt);
+     pf("\tPage fault number (requiring io): %ld\n",(long)usage.ru_majflt);
+     pf("\tNumber of file system read: %ld\n",(long)usage.ru_inblock);
+     pf("\tNumber of filesystem write: %ld\n",(long)usage.ru_oublock);
+     pf("\tNumber of context switch (process origin, io...): %ld\n",(long)usage.ru_nvcsw);
+     pf("\tNumber of context switch (os origin, priority...): %ld\n",(long)usage.ru_nivcsw);
+   } 
+}
+
+void signal_handler(int sig) {
+  void *array[10];
+  size_t size;
+
+  if (sig==SIGSEGV) {
+    // get void*'s for all entries on the stack
+    size = backtrace(array, 10);
+    // print out all the frames to stderr
+    fprintf(stderr, "Error: signal %d:\n", sig);
+    backtrace_symbols_fd(array, size, 2);
+    exit(-1);
+  } else {
+  	if(sig==SIGINT ||sig==SOFTMODEM_RTSIGNAL)
+  		softmodem_printresources(sig,(telnet_printfunc_t)printf);
+  	if (sig != SOFTMODEM_RTSIGNAL) {
+      printf("Linux signal %s...\n",strsignal(sig));
+      exit_function(__FILE__, __FUNCTION__, __LINE__,"softmodem starting exit procedure\n");
+    }
+  }
+}
+
 
-  if ( strcmp( basename(exepath), "lte-uesoftmodem-nos1") == 0)
-    return 1;
 
-  return 0;
+void set_softmodem_sighandler(void) {
+  struct sigaction	act,oldact;
+  clock_gettime(CLOCK_BOOTTIME, &start);
+  memset(&act,0,sizeof(act));
+  act.sa_handler=signal_handler;
+  sigaction(SOFTMODEM_RTSIGNAL,&act,&oldact);
+  printf("Send signal %d to display resource usage...\n",SIGRTMIN+1);
+  signal(SIGSEGV, signal_handler);
+  signal(SIGINT,  signal_handler);
+  signal(SIGTERM, signal_handler);
+  signal(SIGABRT, signal_handler);	
 }
diff --git a/executables/softmodem-common.h b/executables/softmodem-common.h
index f6ba3a6beb8425b55764142acd2e72f8d9ef203e..13fa7b7eac7d51fce6d17ef7a2bd00377c537142 100644
--- a/executables/softmodem-common.h
+++ b/executables/softmodem-common.h
@@ -1,9 +1,182 @@
+/*
+ * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The OpenAirInterface Software Alliance licenses this file to You under
+ * the OAI Public License, Version 1.1  (the "License"); you may not use this file
+ * except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.openairinterface.org/?page_id=698
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *-------------------------------------------------------------------------------
+ * For more information about the OpenAirInterface (OAI) Software Alliance:
+ *      contact@openairinterface.org
+ */
+
+/*! \file lte-softmodem-common.h
+ * \brief Top-level threads for eNodeB
+ * \author 
+ * \date 2012
+ * \version 0.1
+ * \company Eurecom
+ * \email: 
+ * \note
+ * \warning
+ */
 #ifndef SOFTMODEM_COMMON_H
 #define SOFTMODEM_COMMON_H
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* help strings definition for command line options, used in CMDLINE_XXX_DESC macros and printed when -h option is used */
+#define CONFIG_HLP_RFCFGF        "Configuration file for front-end (e.g. LMS7002M)\n"
+#define CONFIG_HLP_ULMAXE        "set the eNodeB max ULSCH erros\n"
+#define CONFIG_HLP_CALUER        "set UE RX calibration\n"
+#define CONFIG_HLP_CALUERM       ""
+#define CONFIG_HLP_CALUERB       ""
+#define CONFIG_HLP_DBGUEPR       "UE run normal prach power ramping, but don't continue random-access\n"
+#define CONFIG_HLP_CALPRACH      "UE run normal prach with maximum power, but don't continue random-access\n"
+#define CONFIG_HLP_NOL2CN        "bypass L2 and upper layers\n"
+
+
+#define CONFIG_HLP_DUMPFRAME     "dump UE received frame to rxsig_frame0.dat and exit\n"
+#define CONFIG_HLP_UELOOP        "get softmodem (UE) to loop through memory instead of acquiring from HW\n"
+#define CONFIG_HLP_PHYTST        "test UE phy layer, mac disabled\n"
+#define CONFIG_HLP_EXTS          "tells hardware to use an external timing reference\n"
+#define CONFIG_HLP_DMRSSYNC      "tells RU to insert DMRS in subframe 1 slot 0"
+#define CONFIG_HLP_CLK           "tells hardware to use a clock reference (0:internal, 1:external, 2:gpsdo)\n"
+#define CONFIG_HLP_USIM          "use XOR autentication algo in case of test usim mode\n"
+#define CONFIG_HLP_NOSNGLT       "Disables single-thread mode in lte-softmodem\n"
+#define CONFIG_HLP_DLF           "Set the downlink frequency for all component carriers\n"
+#define CONFIG_HLP_CHOFF         "Channel id offset\n"
+#define CONFIG_HLP_SOFTS         "Enable soft scope and L1 and L2 stats (Xforms)\n"
+#define CONFIG_HLP_EXMCAL        "Calibrate the EXMIMO borad, available files: exmimo2_2arxg.lime exmimo2_2brxg.lime \n"
+#define CONFIG_HLP_ITTIL         "Generate ITTI analyzser logs (similar to wireshark logs but with more details)\n"
+#define CONFIG_HLP_DLMCS         "Set the maximum downlink MCS\n"
+#define CONFIG_HLP_STMON         "Enable processing timing measurement of lte softmodem on per subframe basis \n"
+
+
+//#define CONFIG_HLP_NUMUES        "Set the number of UEs for the emulation"
+#define CONFIG_HLP_MSLOTS        "Skip the missed slots/subframes \n"
+#define CONFIG_HLP_ULMCS         "Set the maximum uplink MCS\n"
+
+#define CONFIG_HLP_UE            "Set the lte softmodem as a UE\n"
+#define CONFIG_HLP_TQFS          "Apply three-quarter of sampling frequency, 23.04 Msps to reduce the data rate on USB/PCIe transfers (only valid for 20 MHz)\n"
+#define CONFIG_HLP_TPORT         "tracer port\n"
+#define CONFIG_HLP_NOTWAIT       "don't wait for tracer, start immediately\n"
+#define CONFIG_HLP_TNOFORK       "to ease debugging with gdb\n"
+
+#define CONFIG_HLP_NUMEROLOGY    "adding numerology for 5G\n"
+#define CONFIG_HLP_EMULATE_RF    "Emulated RF enabled(disable by defult)\n"
+#define CONFIG_HLP_PARALLEL_CMD  "three config for level of parallelism 'PARALLEL_SINGLE_THREAD', 'PARALLEL_RU_L1_SPLIT', or 'PARALLEL_RU_L1_TRX_SPLIT'\n"
+#define CONFIG_HLP_WORKER_CMD    "two option for worker 'WORKER_DISABLE' or 'WORKER_ENABLE'\n"
+#define CONFIG_HLP_NOS1          "Disable s1 interface\n"
+#define CONFIG_HLP_RFSIM         "Run in rf simulator mode (also known as basic simulator)\n"
+#define CONFIG_HLP_NOKRNMOD      "(noS1 only): Use tun instead of namesh module \n"
+#define CONFIG_HLP_DISABLNBIOT   "disable nb-iot, even if defined in config\n"
+
+/*-----------------------------------------------------------------------------------------------------------------------------------------------------*/
+/*                                            command line parameters common to eNodeB and UE                                                          */
+/*   optname                 helpstr                  paramflags      XXXptr                              defXXXval              type         numelt   */
+/*-----------------------------------------------------------------------------------------------------------------------------------------------------*/
+#define RF_CONFIG_FILE      softmodem_params.rf_config_file
+#define PHY_TEST            softmodem_params.phy_test
+#define WAIT_FOR_SYNC       softmodem_params.wait_for_sync
+#define SINGLE_THREAD_FLAG  softmodem_params.single_thread_flag
+#define CHAIN_OFFSET        softmodem_params.chain_offset
+#define NUMEROLOGY          softmodem_params.numerology
+#define EMULATE_RF          softmodem_params.emulate_rf
+#define CLOCK_SOURCE        softmodem_params.clock_source
+#define TIMING_SOURCE       softmodem_params.timing_source
+#define SEND_DMRSSYNC       softmodem_params.send_dmrs_sync
+#define USIM_TEST           softmodem_params.usim_test
+
+#define DEFAULT_RFCONFIG_FILE    "/usr/local/etc/syriq/ue.band7.tm1.PRB100.NR40.dat";
+
+#define CMDLINE_PARAMS_DESC {  \
+    {"rf-config-file",       CONFIG_HLP_RFCFGF,       0,              strptr:(char **)&RF_CONFIG_FILE,    defstrval:NULL,        TYPE_STRING, sizeof(RF_CONFIG_FILE)},\
+    {"phy-test",             CONFIG_HLP_PHYTST,       PARAMFLAG_BOOL, iptr:&PHY_TEST,                     defintval:0,           TYPE_INT,    0},                     \
+    {"usim-test",            CONFIG_HLP_USIM,         PARAMFLAG_BOOL, u8ptr:&USIM_TEST,                   defintval:0,           TYPE_UINT8,  0},                     \
+    {"clock",                CONFIG_HLP_CLK,          0,              uptr:&CLOCK_SOURCE,                 defintval:0,           TYPE_UINT,   0},                     \
+    {"wait-for-sync",        NULL,                    PARAMFLAG_BOOL, iptr:&WAIT_FOR_SYNC,                defintval:0,           TYPE_INT,    0},                     \
+    {"single-thread-enable", CONFIG_HLP_NOSNGLT,      PARAMFLAG_BOOL, iptr:&SINGLE_THREAD_FLAG,           defintval:0,           TYPE_INT,    0},                     \
+    {"C" ,                   CONFIG_HLP_DLF,          0,              u64ptr:&(downlink_frequency[0][0]),   defuintval:2680000000, TYPE_UINT64,   0},                     \
+    {"a" ,                   CONFIG_HLP_CHOFF,        0,              iptr:&CHAIN_OFFSET,                 defintval:0,           TYPE_INT,    0},                     \
+    {"d" ,                   CONFIG_HLP_SOFTS,        PARAMFLAG_BOOL, uptr:(uint32_t *)&do_forms,         defintval:0,           TYPE_INT8,   0},                     \
+    {"q" ,                   CONFIG_HLP_STMON,        PARAMFLAG_BOOL, iptr:&opp_enabled,                  defintval:0,           TYPE_INT,    0},                     \
+    {"numerology" ,          CONFIG_HLP_NUMEROLOGY,   PARAMFLAG_BOOL, iptr:&NUMEROLOGY,                   defintval:0,           TYPE_INT,    0},                     \
+    {"emulate-rf" ,          CONFIG_HLP_EMULATE_RF,   PARAMFLAG_BOOL, iptr:&EMULATE_RF,                   defintval:0,           TYPE_INT,    0},                     \
+    {"parallel-config",      CONFIG_HLP_PARALLEL_CMD, 0,              strptr:(char **)&parallel_config,   defstrval:NULL,        TYPE_STRING, 0},                     \
+    {"worker-config",        CONFIG_HLP_WORKER_CMD,   0,              strptr:(char **)&worker_config,     defstrval:NULL,        TYPE_STRING, 0},                     \
+    {"noS1",                 CONFIG_HLP_NOS1,         PARAMFLAG_BOOL, uptr:&noS1,                         defintval:0,           TYPE_INT,    0},                     \
+    {"rfsim",                CONFIG_HLP_RFSIM,        PARAMFLAG_BOOL, uptr:&rfsim,                        defintval:0,           TYPE_INT,    0},                     \
+    {"basicsim",             CONFIG_HLP_RFSIM,        PARAMFLAG_BOOL, uptr:&basicsim,                     defintval:0,           TYPE_INT,    0},                     \
+    {"nokrnmod",             CONFIG_HLP_NOKRNMOD,     PARAMFLAG_BOOL, uptr:&nokrnmod,                     defintval:0,           TYPE_INT,    0},                     \
+    {"nbiot-disable",        CONFIG_HLP_DISABLNBIOT,  PARAMFLAG_BOOL, uptr:&nonbiot,                      defuintval:0,          TYPE_INT,    0},                     \
+  }
+
+  
+#define CONFIG_HLP_FLOG          "Enable online log \n"
+#define CONFIG_HLP_LOGL          "Set the global log level, valid options: (4:trace, 3:debug, 2:info, 1:warn, (0:error))\n"
+#define CONFIG_HLP_LOGV          "Set the global log verbosity \n"
+#define CONFIG_HLP_TELN          "Start embedded telnet server \n"
+#define CONFIG_HLP_MSC           "Enable the MSC tracing utility \n"
+/*----------------------------------------------------------------------------------------------------------------------------*/
+/*                                            command line parameters for LOG utility                                         */
+/*   optname         helpstr          paramflags        XXXptr                     defXXXval            type           numelt */
+/*----------------------------------------------------------------------------------------------------------------------------*/
+#define START_MSC                softmodem_params.start_msc
+#define CMDLINE_LOGPARAMS_DESC {  \
+    {"R" ,           CONFIG_HLP_FLOG, 0,                uptr:&online_log_messages, defintval:1,         TYPE_INT,      0},     \
+    {"g" ,           CONFIG_HLP_LOGL, 0,                uptr:&glog_level,          defintval:0,         TYPE_UINT,     0},     \
+	{"telnetsrv",    CONFIG_HLP_TELN, PARAMFLAG_BOOL,   uptr:&start_telnetsrv,     defintval:0,         TYPE_UINT,     0},     \
+    {"msc",          CONFIG_HLP_MSC,  PARAMFLAG_BOOL,   uptr:&START_MSC,           defintval:0,         TYPE_UINT,     0},     \
+	{"log-mem",      NULL,            0,      strptr:(char **)&logmem_filename,    defstrval:NULL,      TYPE_STRING,   0},     \
+  }
+
+#define CMDLINE_ONLINELOG_IDX     0
+#define CMDLINE_GLOGLEVEL_IDX     1
+#define CMDLINE_GLOGVERBO_IDX     2
+#define CMDLINE_STARTTELN_IDX     3
+
+/* check function for global log level */
+#define CMDLINE_LOGPARAMS_CHECK_DESC { \
+    { .s5= {NULL} } ,                       \
+    { .s2= {config_check_intrange, {0,4}}}, \
+    { .s5= {NULL} } ,                       \
+    { .s5= {NULL} } ,                       \
+    { .s5= {NULL} } ,                       \
+  }
+
+/***************************************************************************************************************************************/
+
+#define SOFTMODEM_NOS1_BIT            (1<<0)
+#define SOFTMODEM_NOKRNMOD_BIT        (1<<1)
+#define SOFTMODEM_NONBIOT_BIT         (1<<2)
+#define SOFTMODEM_RFSIM_BIT           (1<<10)
+#define SOFTMODEM_BASICSIM_BIT        (1<<11)
+#define SOFTMODEM_SIML1_BIT           (1<<12)
+#define SOFTMODEM_DOFORMS_BIT         (1<<15)
+
+#define IS_SOFTMODEM_NOS1            ( get_softmodem_optmask() & SOFTMODEM_NOS1_BIT)
+#define IS_SOFTMODEM_NOKRNMOD        ( get_softmodem_optmask() & SOFTMODEM_NOKRNMOD_BIT)
+#define IS_SOFTMODEM_NONBIOT         ( get_softmodem_optmask() & SOFTMODEM_NONBIOT_BIT)
+#define IS_SOFTMODEM_RFSIM           ( get_softmodem_optmask() & SOFTMODEM_RFSIM_BIT)
+#define IS_SOFTMODEM_BASICSIM        ( get_softmodem_optmask() & SOFTMODEM_BASICSIM_BIT)
+#define IS_SOFTMODEM_SIML1           ( get_softmodem_optmask() & SOFTMODEM_SIML1_BIT)
+#define IS_SOFTMODEM_DOFORMS         ( get_softmodem_optmask() & SOFTMODEM_DOFORMS_BIT)
+
 
 typedef struct {
   uint64_t       optmask;
-  THREAD_STRUCT  thread_struct;
+  //THREAD_STRUCT  thread_struct;
   char           rf_config_file[1024];
   int            phy_test;
   uint8_t        usim_test;
@@ -19,4 +192,14 @@ typedef struct {
   uint32_t       send_dmrs_sync;
 } softmodem_params_t;
 
+extern uint64_t get_softmodem_optmask(void);
+extern uint64_t set_softmodem_optmask(uint64_t bitmask);
+extern softmodem_params_t *get_softmodem_params(void);
+extern void get_common_options(void);
+#define SOFTMODEM_RTSIGNAL  (SIGRTMIN+1)
+extern void set_softmodem_sighandler(void);
+extern uint64_t downlink_frequency[MAX_NUM_CCs][4];
+#ifdef __cplusplus
+}
+#endif
 #endif
diff --git a/openair1/PHY/CODING/nrLDPC_encoder/ldpc_encoder2.c b/openair1/PHY/CODING/nrLDPC_encoder/ldpc_encoder2.c
index fb516549ed199e64cbb54a933672672bbb8aa660..ef207b6cdcd683dbc18c6a0f6541033635312315 100644
--- a/openair1/PHY/CODING/nrLDPC_encoder/ldpc_encoder2.c
+++ b/openair1/PHY/CODING/nrLDPC_encoder/ldpc_encoder2.c
@@ -35,6 +35,7 @@
 #include <string.h>
 #include <types.h>
 #include "assertions.h"
+#include "common/utils/LOG/log.h"
 #include "PHY/TOOLS/time_meas.h"
 #include "defs.h"
 
@@ -482,11 +483,12 @@ int ldpc_encoder_optim_8seg_multi(unsigned char **test_input,unsigned char **cha
   //Table of possible lifting sizes
   char temp;
   int simd_size;
-  int macro_segment, macro_segment_end;
-
+  unsigned int macro_segment, macro_segment_end;
 
+  
   macro_segment = 8*macro_num;
-  macro_segment_end = (n_segments > 8*(macro_num+1)) ? 8*(macro_num+1) : n_segments;
+  // macro_segment_end = (n_segments > 8*(macro_num+1)) ? 8*(macro_num+1) : n_segments;
+  macro_segment_end = macro_segment + (n_segments > 8 ? 8 : n_segments);
   ///printf("macro_segment: %d\n", macro_segment);
   ///printf("macro_segment_end: %d\n", macro_segment_end );
 
@@ -506,7 +508,7 @@ int ldpc_encoder_optim_8seg_multi(unsigned char **test_input,unsigned char **cha
   masks[7] = _mm256_set1_epi8(0x80);
 #endif
 
-  ///AssertFatal(n_segments>0&&n_segments<=8,"0 < n_segments %d <= 8\n",n_segments);
+
 
   //determine number of bits in codeword
   if (BG==1)
@@ -562,7 +564,7 @@ int ldpc_encoder_optim_8seg_multi(unsigned char **test_input,unsigned char **cha
   for (i=0; i<block_length>>5; i++) {
     c256 = _mm256_and_si256(_mm256_cmpeq_epi8(_mm256_andnot_si256(_mm256_shuffle_epi8(_mm256_set1_epi32(((uint32_t*)test_input[macro_segment])[i]), shufmask),andmask),zero256),masks[0]);
     //for (j=1; j<n_segments; j++) {
-    for (j=macro_segment+1; j < macro_segment_end; j++) {
+    for (j=macro_segment+1; j < macro_segment_end; j++) {    
       c256 = _mm256_or_si256(_mm256_and_si256(_mm256_cmpeq_epi8(_mm256_andnot_si256(_mm256_shuffle_epi8(_mm256_set1_epi32(((uint32_t*)test_input[j])[i]), shufmask),andmask),zero256),masks[j-macro_segment]),c256);
     }
     ((__m256i *)c)[i] = c256;
diff --git a/openair1/PHY/TOOLS/tools_defs.h b/openair1/PHY/TOOLS/tools_defs.h
index 1012ef43106e224221557a03267a77ecc4424a81..d753b501b6e7de816f201e98101b483c57211a91 100644
--- a/openair1/PHY/TOOLS/tools_defs.h
+++ b/openair1/PHY/TOOLS/tools_defs.h
@@ -29,6 +29,10 @@
 
 */
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include <stdint.h>
 #include "PHY/sse_intrin.h"
 
@@ -441,4 +445,8 @@ double interp(double x, double *xs, double *ys, int count);
 
 int write_output(const char *fname,const char *vname,void *data,int length,int dec,char format);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif //__PHY_TOOLS_DEFS__H__
diff --git a/openair1/PHY/phy_extern.h b/openair1/PHY/phy_extern.h
index 4280b684f9bd65ec4ce40842c833cfef64462d1b..deb7087c8cf4cc4c969629ce50a2c3949839c8f7 100644
--- a/openair1/PHY/phy_extern.h
+++ b/openair1/PHY/phy_extern.h
@@ -69,7 +69,6 @@ extern uint16_t NB_UE_INST;
 extern unsigned char NB_RN_INST;
 #endif
 
-extern unsigned int ULSCH_max_consecutive_errors;
 extern int flag_LA;
 extern double sinr_bler_map[MCS_COUNT][2][MCS_TABLE_LENGTH_MAX];
 extern double sinr_bler_map_up[MCS_COUNT][2][16];
diff --git a/openair1/PHY/phy_extern_nr_ue.h b/openair1/PHY/phy_extern_nr_ue.h
index 2a4292a7795dbcf3e4a7297dc795e2123bb27897..569bec68515e3fe71525493ef33617e3ad5e6d07 100644
--- a/openair1/PHY/phy_extern_nr_ue.h
+++ b/openair1/PHY/phy_extern_nr_ue.h
@@ -66,7 +66,6 @@ extern uint16_t NB_UE_INST;
 extern unsigned char NB_RN_INST;
 #endif
 
-extern unsigned int ULSCH_max_consecutive_errors;
 extern int flag_LA;
 extern double sinr_bler_map[MCS_COUNT][2][MCS_TABLE_LENGTH_MAX];
 extern double sinr_bler_map_up[MCS_COUNT][2][16];
diff --git a/openair1/PHY/phy_extern_ue.h b/openair1/PHY/phy_extern_ue.h
index 490d7b578f64d7a1b6f71e6dc5f75429b6729e7c..4f9ed0f26bec1ebd0983797d495b741d1b38ced9 100644
--- a/openair1/PHY/phy_extern_ue.h
+++ b/openair1/PHY/phy_extern_ue.h
@@ -66,7 +66,6 @@ extern uint16_t NB_UE_INST;
 extern unsigned char NB_RN_INST;
 #endif
 
-extern unsigned int ULSCH_max_consecutive_errors;
 extern int flag_LA;
 extern double sinr_bler_map[MCS_COUNT][2][MCS_TABLE_LENGTH_MAX];
 extern double sinr_bler_map_up[MCS_COUNT][2][16];
diff --git a/openair1/PHY/phy_vars.h b/openair1/PHY/phy_vars.h
index 492abe7e8d3a600638b53e0d4882aaa1ea533640..26540f6fc885ee3b6424cf1cc3bc1f4f52068bc0 100644
--- a/openair1/PHY/phy_vars.h
+++ b/openair1/PHY/phy_vars.h
@@ -65,8 +65,6 @@ unsigned char NB_RN_INST=0;
 unsigned char NB_INST=0;
 #endif
 
-unsigned int ULSCH_max_consecutive_errors = 20;
-
 int number_of_cards;
 
 
diff --git a/openair1/PHY/phy_vars_nr_ue.h b/openair1/PHY/phy_vars_nr_ue.h
index 7f9d20e624e4a043b64bf27697abb2ca5ec82a84..bd077b5b0c77997a1fb547648d84b0702a626f6c 100644
--- a/openair1/PHY/phy_vars_nr_ue.h
+++ b/openair1/PHY/phy_vars_nr_ue.h
@@ -64,7 +64,6 @@ unsigned char NB_RN_INST=0;
 unsigned char NB_INST=0;
 #endif
 
-unsigned int ULSCH_max_consecutive_errors = 20;
 
 int number_of_cards;
 
diff --git a/openair1/PHY/phy_vars_ue.h b/openair1/PHY/phy_vars_ue.h
index ccce93c41feb221188014b91fc035caa64406643..05f2e1b8f1960718fe9687e39699db305ca1ca48 100644
--- a/openair1/PHY/phy_vars_ue.h
+++ b/openair1/PHY/phy_vars_ue.h
@@ -57,7 +57,6 @@ short conjugate2[8]__attribute__((aligned(16))) = {1,-1,1,-1,1,-1,1,-1};
   unsigned char NB_INST=0;
 #endif
 
-unsigned int ULSCH_max_consecutive_errors = 20;
 
 int number_of_cards;
 
diff --git a/openair2/ENB_APP/MACRLC_paramdef.h b/openair2/ENB_APP/MACRLC_paramdef.h
index ef7d5987852bfaa90c3c17d72f3445e2879e6e53..724dde6557e01bffc2c1a33f905b1dd5c7311577 100644
--- a/openair2/ENB_APP/MACRLC_paramdef.h
+++ b/openair2/ENB_APP/MACRLC_paramdef.h
@@ -54,7 +54,6 @@
 #define CONFIG_STRING_MACRLC_LOCAL_S_PORTD                 "local_s_portd"
 #define CONFIG_STRING_MACRLC_REMOTE_S_PORTD                "remote_s_portd"
 #define CONFIG_STRING_MACRLC_SCHED_MODE                    "scheduler_mode"
-#define CONFIG_STRING_MACRLC_PHY_TEST_MODE                 "phy_test_mode"
 #define CONFIG_MACRLC_PUSCH10xSNR                          "puSch10xSnr"
 #define CONFIG_MACRLC_PUCCH10xSNR                          "puCch10xSnr"
 
@@ -81,7 +80,6 @@
 {CONFIG_STRING_MACRLC_LOCAL_S_PORTD,                     NULL,     0,          uptr:NULL,           defintval:50021,           TYPE_UINT,     0},        \
 {CONFIG_STRING_MACRLC_REMOTE_S_PORTD,                    NULL,     0,          uptr:NULL,           defintval:50021,           TYPE_UINT,     0},        \
 {CONFIG_STRING_MACRLC_SCHED_MODE,                        NULL,     0,          strptr:NULL,         defstrval:"default",       TYPE_STRING,   0},        \
-{CONFIG_STRING_MACRLC_PHY_TEST_MODE,                     NULL,     0,          uptr:NULL,           defintval:1,               TYPE_UINT,     0},        \
 {CONFIG_MACRLC_PUSCH10xSNR,  		                 NULL,     0,          iptr:NULL,           defintval:200,             TYPE_INT,      0},        \
 {CONFIG_MACRLC_PUCCH10xSNR,  		                 NULL,     0,          iptr:NULL,           defintval:200,             TYPE_INT,      0},        \
 }
@@ -103,7 +101,6 @@
 #define MACRLC_LOCAL_S_PORTD_IDX                               15
 #define MACRLC_REMOTE_S_PORTD_IDX                              16
 #define MACRLC_SCHED_MODE_IDX                                  17
-#define MACRLC_PHY_TEST_IDX                                    18
-#define MACRLC_PUSCH10xSNR_IDX                                 19
-#define MACRLC_PUCCH10xSNR_IDX                                 20
+#define MACRLC_PUSCH10xSNR_IDX                                 18
+#define MACRLC_PUCCH10xSNR_IDX                                 19 
 /*---------------------------------------------------------------------------------------------------------------------------------------------------------*/
diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c
index 2e04b51fe80b2848ba24e15ece585b0fb7add152..6dcc57474683b68b2c4d87c7c5c292c4fac51a9b 100644
--- a/openair2/ENB_APP/enb_config.c
+++ b/openair2/ENB_APP/enb_config.c
@@ -214,8 +214,6 @@ void RCconfig_macrlc(int macrlc_has_f1[MAX_MAC_INST]) {
       RC.mac[j]->puSch10xSnr = *(MacRLC_ParamList.paramarray[j][MACRLC_PUSCH10xSNR_IDX ].iptr);
       RC.mac[j]->puCch10xSnr = *(MacRLC_ParamList.paramarray[j][MACRLC_PUCCH10xSNR_IDX ].iptr);
       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);
 
       if (strcmp(*(MacRLC_ParamList.paramarray[j][MACRLC_TRANSPORT_N_PREFERENCE_IDX].strptr), "local_RRC") == 0) {
         // check number of instances is same as RRC/PDCP
diff --git a/openair2/ENB_APP/enb_paramdef.h b/openair2/ENB_APP/enb_paramdef.h
index 963326c874fea48e6ee45ad6e8ecc143dfb99876..c20072c8bf6bf671e79709eacccf22a312316b52 100644
--- a/openair2/ENB_APP/enb_paramdef.h
+++ b/openair2/ENB_APP/enb_paramdef.h
@@ -1175,7 +1175,6 @@ typedef struct srb1_params_s {
 #define CONFIG_STRING_MACRLC_LOCAL_S_PORTD                 "local_s_portd"
 #define CONFIG_STRING_MACRLC_REMOTE_S_PORTD                "remote_s_portd"
 #define CONFIG_STRING_MACRLC_SCHED_MODE                    "scheduler_mode"
-#define CONFIG_STRING_MACRLC_PHY_TEST_MODE                 "phy_test_mode"
 
 #define MACRLC_CC_IDX                                          0
 #define MACRLC_TRANSPORT_N_PREFERENCE_IDX                      1
@@ -1195,7 +1194,6 @@ typedef struct srb1_params_s {
 #define MACRLC_LOCAL_S_PORTD_IDX                               15
 #define MACRLC_REMOTE_S_PORTD_IDX                              16
 #define MACRLC_SCHED_MODE_IDX                                  17
-#define MACRLC_PHY_TEST_IDX                                    18
 /*---------------------------------------------------------------------------------------------------------------------------------------------------------*/
 
 /* thread configuration parameters section name */
diff --git a/openair2/GNB_APP/gnb_config.c b/openair2/GNB_APP/gnb_config.c
index 9845adbeaa59844ce2da1faeaab8a9c9ea432b8b..935551707261e1535d4dbc8acebb1a9b3fb046eb 100644
--- a/openair2/GNB_APP/gnb_config.c
+++ b/openair2/GNB_APP/gnb_config.c
@@ -464,8 +464,6 @@ void RCconfig_nr_macrlc() {
 
     for (j=0;j<RC.nb_nr_macrlc_inst;j++) {
       RC.nb_nr_mac_CC[j] = *(MacRLC_ParamList.paramarray[j][MACRLC_CC_IDX].iptr);
-      //RC.nrmac[j]->phy_test = *(MacRLC_ParamList.paramarray[j][MACRLC_PHY_TEST_IDX].iptr);
-      //printf("PHY_TEST = %d,%d\n", RC.nrmac[j]->phy_test, j);
 
       if (strcmp(*(MacRLC_ParamList.paramarray[j][MACRLC_TRANSPORT_N_PREFERENCE_IDX].strptr), "local_RRC") == 0) {
   // check number of instances is same as RRC/PDCP
diff --git a/openair2/GNB_APP/gnb_paramdef.h b/openair2/GNB_APP/gnb_paramdef.h
index 25e70919ed6d1c6aa4e21971e17a2fcbc4e013d5..63faa141f1aff8e3680159c97666e3562e05f2d7 100644
--- a/openair2/GNB_APP/gnb_paramdef.h
+++ b/openair2/GNB_APP/gnb_paramdef.h
@@ -386,7 +386,6 @@ typedef struct ccparams_nr_x2 {
 #define CONFIG_STRING_MACRLC_REMOTE_S_PORTC                "remote_s_portc"
 #define CONFIG_STRING_MACRLC_LOCAL_S_PORTD                 "local_s_portd"
 #define CONFIG_STRING_MACRLC_REMOTE_S_PORTD                "remote_s_portd"
-#define CONFIG_STRING_MACRLC_PHY_TEST_MODE                 "phy_test_mode"
 
 
 #define MACRLC_CC_IDX                                          0
@@ -407,7 +406,6 @@ typedef struct ccparams_nr_x2 {
 #define MACRLC_LOCAL_S_PORTD_IDX                               15
 #define MACRLC_REMOTE_S_PORTD_IDX                              16
 #define MACRLC_SCHED_MODE_IDX                                  17
-#define MACRLC_PHY_TEST_IDX                                    18
 
 
 /* thread configuration parameters section name */
diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_extern.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_extern.h
index 10df4567c41608f09c12820805872a27f630b595..2cfce4766f7234e50249f2560e725cfd8f89a7d8 100644
--- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_extern.h
+++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_extern.h
@@ -59,7 +59,6 @@ extern unsigned short NODE_ID[1];
 
 /* Scheduler */
 extern RAN_CONTEXT_t RC;
-extern int phy_test;
 extern uint8_t nfapi_mode;
 
 /*#if defined(PRE_SCD_THREAD)
diff --git a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c
index be1e85236087a4a84e3827dcba529f345480fc52..61f9ab601e9ac71954e29d912c6f93407af573a1 100644
--- a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c
+++ b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c
@@ -32,7 +32,14 @@
 
 //#include "defs.h"
 #include "mac_proto.h"
-#include "executables/nr-softmodem.h"
+#include "../../ARCH/COMMON/common_lib.h"
+//#undef MALLOC
+#include "assertions.h"
+#include "PHY/types.h"
+#include "PHY/defs_UE.h"
+#include "openair2/LAYER2/RLC/rlc.h"
+#include "openair2/LAYER2/PDCP_v10.1.0/pdcp.h"
+#include "executables/softmodem-common.h"
 
 static NR_UE_MAC_INST_t *nr_ue_mac_inst; 
 
diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c
index 55ac0953989d135b687447dc5ecd142d9fe7f93f..dffca69222988735f938ac43219a648637cfd361 100644
--- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c
+++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c
@@ -30,7 +30,6 @@
  * \warning
  */
 
-#include "executables/nr-softmodem.h"
 
 /* MAC related headers */
 #include "mac_proto.h"
@@ -52,7 +51,7 @@
 /*Openair Packet Tracer */
 #include "UTIL/OPT/opt.h"
 #include "OCG.h"
-
+#include "executables/softmodem-common.h"
 /* log utils */
 #include "common/utils/LOG/log.h"
 #include "common/utils/LOG/vcd_signal_dumper.h"
@@ -2679,6 +2678,25 @@ void nr_ue_send_sdu(module_id_t module_idP,
 
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SEND_SDU, VCD_FUNCTION_IN);
 
+  //LOG_D(MAC,"sdu: %x.%x.%x\n",sdu[0],sdu[1],sdu[2]);
+
+  /*
+  #ifdef DEBUG_HEADER_PARSING
+    LOG_D(MAC, "[UE %d] ue_send_sdu : Frame %d gNB_index %d : num_ce %d num_sdu %d\n",
+      module_idP, frameP, gNB_index, num_ce, num_sdu);
+  #endif
+  */
+
+  /*
+  #if defined(ENABLE_MAC_PAYLOAD_DEBUG)
+    LOG_T(MAC, "[UE %d] First 32 bytes of DLSCH : \n", module_idP);
+    for (i = 0; i < 32; i++) {
+      LOG_T(MAC, "%x.", sdu[i]);
+    }
+    LOG_T(MAC, "\n");
+  #endif
+  */
+
   // Processing MAC PDU
   // it parses MAC CEs subheaders, MAC CEs, SDU subheaderds and SDUs
   if (pduP != NULL)
diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c
index ace9551d2f4ba603053b4086d4007b1bba3f42d6..e831b9f56824deb5c8fd7c4a00310bd4991b4610 100644
--- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c
+++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c
@@ -59,11 +59,7 @@
 #include "intertask_interface.h"
 #endif
 
-#include "assertions.h"
-#include <openair1/PHY/LTE_TRANSPORT/transport_proto.h>
-
-#define ENABLE_MAC_PAYLOAD_DEBUG
-#define DEBUG_eNB_SCHEDULER 1
+#include "executables/softmodem-common.h"
 
 uint16_t nr_pdcch_order_table[6] = { 31, 31, 511, 2047, 2047, 8191 };
 
@@ -380,7 +376,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP,
   }
 
   // Phytest scheduling
-  if (phy_test && slot_txP==1){
+  if (get_softmodem_params()->phy_test && slot_txP==1){
     nr_schedule_uss_dlsch_phytest(module_idP, frame_txP, slot_txP,NULL);
     // resetting ta flag
     gNB->ta_len = 0;
@@ -395,7 +391,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP,
   } //is_nr_DL_slot
 
   if (is_nr_UL_slot(cc->ServingCellConfigCommon,slot_rxP)) { 
-    if (phy_test && slot_rxP==8){
+    if (get_softmodem_params()->phy_test && slot_rxP==8){
       nr_schedule_uss_ulsch_phytest(module_idP, frame_rxP, slot_rxP);
     }
   }
diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c
index 55a73851438876408e184ec048871dbd00758c67..8572ec4a0a6d7b7ff69d056421a20e745f63d4c1 100644
--- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c
+++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c
@@ -34,8 +34,7 @@
 #include "nr_mac_common.h"
 #include "PHY/NR_TRANSPORT/nr_dlsch.h"
 #include "PHY/NR_TRANSPORT/nr_dci.h"
-#include "executables/nr-softmodem.h"
-#include "common/utils/nr/nr_common.h"
+#include "executables/softmodem-common.h"
 
 #include "NR_SCS-SpecificCarrier.h"
 #include "NR_TDD-UL-DL-ConfigCommon.h"
diff --git a/openair2/LAYER2/NR_MAC_gNB/main.c b/openair2/LAYER2/NR_MAC_gNB/main.c
index ff552d0bfd597a96b02f4fd3eeb0518857be5bd5..9e8415776b641e9675a42efb320541c0e169f6cb 100644
--- a/openair2/LAYER2/NR_MAC_gNB/main.c
+++ b/openair2/LAYER2/NR_MAC_gNB/main.c
@@ -40,7 +40,7 @@
 //#include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h"
 
 #include "common/ran_context.h"
-#include "executables/nr-softmodem.h"
+#include "executables/softmodem-common.h"
 
 extern RAN_CONTEXT_t RC;
 
diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c
index 9c5c17e2235e631e441ca4bb3a8a6b5fb9cddc7c..4ebd12c26f2673ef2032d28488f7490f9f45e1a0 100644
--- a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c
+++ b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c
@@ -471,7 +471,7 @@ rb_found:
 #endif
 }
 
-static void add_srb(int rnti, struct LTE_SRB_ToAddMod *s)
+__attribute__ ((unused)) static void add_srb(int rnti, struct LTE_SRB_ToAddMod *s)
 {
   nr_rlc_entity_t            *nr_rlc_am;
   nr_rlc_ue_t                *ue;
@@ -739,7 +739,7 @@ static void add_drb_um(int rnti, struct LTE_DRB_ToAddMod *s)
   nr_rlc_manager_unlock(nr_rlc_ue_manager);
 }
 
-static void add_drb(int rnti, struct LTE_DRB_ToAddMod *s)
+__attribute__ ((unused)) static void add_drb(int rnti, struct LTE_DRB_ToAddMod *s)
 {
   switch (s->rlc_Config->present) {
   case LTE_RLC_Config_PR_am:
diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c
index 4e6c0d8979b2980604f692967bfd4672807d6491..64a814bcdb9ef2358082910fe65420d3381efa58 100644
--- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c
+++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c
@@ -36,7 +36,7 @@
 #include "assertions.h"
 #include "LAYER2/NR_MAC_UE/mac_extern.h"
 #include "SCHED_NR_UE/fapi_nr_ue_l1.h"
-#include "executables/nr-softmodem.h"
+#include "executables/softmodem-common.h"
 
 #include <stdio.h>
 
diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c
index c7b28f2125b4797dbe2d32035084df33a40baeda..d95507547a3207bff08984f5b7496d5565c826d3 100644
--- a/openair2/RRC/NR/MESSAGES/asn1_msg.c
+++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c
@@ -128,7 +128,6 @@ typedef struct xer_sprint_string_s {
 //replace LTE
 //extern unsigned char NB_eNB_INST;
 extern unsigned char NB_gNB_INST;
-extern uint8_t usim_test;
 
 extern RAN_CONTEXT_t RC;
 
diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c
index d32c6d6f3c9a878c7f918dd2cc54c05cc634249a..dc0a0dca346146e6f39a9140d2d1e891ef1d5200 100644
--- a/openair2/RRC/NR/rrc_gNB.c
+++ b/openair2/RRC/NR/rrc_gNB.c
@@ -77,9 +77,10 @@
 
 #   include "intertask_interface.h"
 
-
 #include "SIMULATION/TOOLS/sim.h" // for taus
 
+#include "executables/softmodem-common.h"
+
 //#define XER_PRINT
 
 
@@ -178,7 +179,6 @@ void rrc_gNB_generate_SgNBAdditionRequestAcknowledge(
 ///---------------------------------------------------------------------------------------------------------------///
 ///---------------------------------------------------------------------------------------------------------------///
 
-extern int phy_test;
 
 static void init_NR_SI(gNB_RRC_INST *rrc) {
 
@@ -204,7 +204,7 @@ static void init_NR_SI(gNB_RRC_INST *rrc) {
                          );
 
 
-  if (phy_test > 0) {
+  if (get_softmodem_params()->phy_test > 0) {
     // This is for phytest only, emulate first X2 message if uecap.raw file is present
     FILE *fd;
 
diff --git a/openair2/RRC/NR/rrc_gNB_reconfig.c b/openair2/RRC/NR/rrc_gNB_reconfig.c
index 6d52f47a18d7fa90fd1e983d2af879d8ef7c88d3..faabbb1400488702854a94fa2f67c6a8ba45583d 100644
--- a/openair2/RRC/NR/rrc_gNB_reconfig.c
+++ b/openair2/RRC/NR/rrc_gNB_reconfig.c
@@ -41,10 +41,12 @@
 #include "BOOLEAN.h"
 #include "assertions.h"
 #include "common/utils/nr/nr_common.h"
+
+#include "executables/softmodem-common.h"
+
 #define false 0
 #define true 1
 
-extern int phy_test;
 
 void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellconfigcommon,
 				     NR_CellGroupConfig_t *secondaryCellGroup,
@@ -148,7 +150,7 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco
   *secondaryCellGroup->spCellConfig->servCellIndex = servCellIndex;
   secondaryCellGroup->spCellConfig->reconfigurationWithSync=calloc(1,sizeof(*secondaryCellGroup->spCellConfig->reconfigurationWithSync));
   secondaryCellGroup->spCellConfig->reconfigurationWithSync->spCellConfigCommon=servingcellconfigcommon;
-  secondaryCellGroup->spCellConfig->reconfigurationWithSync->newUE_Identity=(phy_test==1) ? 0x1234 : (taus()&0xffff);
+  secondaryCellGroup->spCellConfig->reconfigurationWithSync->newUE_Identity=(get_softmodem_params()->phy_test==1) ? 0x1234 : (taus()&0xffff);
   secondaryCellGroup->spCellConfig->reconfigurationWithSync->t304=NR_ReconfigurationWithSync__t304_ms2000;
   secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated = NULL;
   secondaryCellGroup->spCellConfig->reconfigurationWithSync->ext1                 = NULL;
diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c
index 38163a68b81512457931c755f6f22ab978fdd2b4..1975bfba1a35f2c4c7094f65a1b37c999ab0c71d 100755
--- a/openair2/RRC/NR_UE/rrc_UE.c
+++ b/openair2/RRC/NR_UE/rrc_UE.c
@@ -44,8 +44,8 @@
 #include "rrc_vars.h"
 #include "mac_proto.h"
 
+#include "executables/softmodem-common.h"
 
-extern int phy_test;
 
 // from LTE-RRC DL-DCCH RRCConnectionReconfiguration nr-secondary-cell-group-config (encoded)
 int8_t nr_rrc_ue_decode_secondary_cellgroup_config(
@@ -319,7 +319,7 @@ NR_UE_RRC_INST_t* openair_rrc_top_init_ue_nr(char* rrc_config_path){
         RRC_LIST_INIT(NR_UE_rrc_inst->CSI_ResourceConfig_list, NR_maxNrofCSI_ResourceConfigurations);
         RRC_LIST_INIT(NR_UE_rrc_inst->CSI_ReportConfig_list, NR_maxNrofCSI_ReportConfigurations);
 
-	if (phy_test==1) {
+	if (get_softmodem_params()->phy_test==1) {
 	  // read in files for RRCReconfiguration and RBconfig
 	  FILE *fd;
 	  char filename[1024];
diff --git a/targets/ARCH/LMSSDR/USERSPACE/LIB/lms_lib.cpp b/targets/ARCH/LMSSDR/USERSPACE/LIB/lms_lib.cpp
index a57ebf8b6d85b5c8b1e28fccef6aa06ac448f120..9fcfbdf5712a2da59f123b471e49b0ef12ee3c09 100644
--- a/targets/ARCH/LMSSDR/USERSPACE/LIB/lms_lib.cpp
+++ b/targets/ARCH/LMSSDR/USERSPACE/LIB/lms_lib.cpp
@@ -178,7 +178,7 @@ int trx_lms_start(openair0_device *device){
     }
 
     LMS_Init(lms_device);
-    LMS_EnableCalibCache(lms_device,false);
+    LMS_EnableCache(lms_device,false);
 
     if (LMS_LoadConfig(lms_device,device->openair0_cfg[0].configFilename) != 0)
     {
@@ -277,6 +277,7 @@ int trx_lms_stop(openair0_device *device) {
     LMS_DestroyStream(lms_device,&rx_stream);
     LMS_DestroyStream(lms_device,&tx_stream);
     LMS_Close(lms_device);
+    return 0;
 }
 
 /*! \brief Set frequencies (TX/RX)
diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c
index 0eb007d5b5de9bd1bd9ddae95eac30a6226b867a..ede331c7166ca03fe8cd2df0ed08e28436db7e47 100644
--- a/targets/RT/USER/lte-softmodem.c
+++ b/targets/RT/USER/lte-softmodem.c
@@ -150,7 +150,6 @@ char channels[128] = "0";
 int rx_input_level_dBm;
 int otg_enabled;
 
-uint8_t exit_missed_slots=1;
 uint64_t num_missed_slots=0; // counter for the number of missed slots
 
 
@@ -235,24 +234,6 @@ unsigned int build_rfdc(int dcoff_i_rxfe, int dcoff_q_rxfe) {
 }
 
 
-void signal_handler(int sig) {
-  void *array[10];
-  size_t size;
-
-  if (sig==SIGSEGV) {
-    // get void*'s for all entries on the stack
-    size = backtrace(array, 10);
-    // print out all the frames to stderr
-    fprintf(stderr, "Error: signal %d:\n", sig);
-    backtrace_symbols_fd(array, size, 2);
-    exit(-1);
-  } else {
-    printf("Linux signal %s...\n",strsignal(sig));
-    exit_function(__FILE__, __FUNCTION__, __LINE__,"softmodem starting exit procedure\n");
-  }
-}
-
-
 void exit_function(const char *file, const char *function, const int line, const char *s) {
   int ru_id;
 
@@ -537,9 +518,6 @@ int main ( int argc, char **argv )
   printf("Reading in command-line options\n");
   get_options ();
 
-  if (is_nos1exec(argv[0]) )
-    set_softmodem_optmask(SOFTMODEM_NOS1_BIT);
-
   EPC_MODE_ENABLED = !IS_SOFTMODEM_NOS1;
 
   if (CONFIG_ISFLAGSET(CONFIG_ABORT) ) {
@@ -570,10 +548,7 @@ int main ( int argc, char **argv )
   MSC_INIT(MSC_E_UTRAN, THREAD_MAX+TASK_MAX);
   init_opt();
   // to make a graceful exit when ctrl-c is pressed
-  signal(SIGSEGV, signal_handler);
-  signal(SIGINT, signal_handler);
-  signal(SIGTERM, signal_handler);
-  signal(SIGABRT, signal_handler);
+  set_softmodem_sighandler();
   check_clock();
 #ifndef PACKAGE_VERSION
 #  define PACKAGE_VERSION "UNKNOWN-EXPERIMENTAL"
diff --git a/targets/RT/USER/lte-softmodem.h b/targets/RT/USER/lte-softmodem.h
index d97d86611ca208e964357fd7c327cae9dcb67cb2..5e1bf3616052630c081ba5c9bd0b8d4c78b4b815 100644
--- a/targets/RT/USER/lte-softmodem.h
+++ b/targets/RT/USER/lte-softmodem.h
@@ -35,63 +35,7 @@
 #include "proto_agent.h"
 #include "executables/softmodem-common.h"
 
-/* help strings definition for command line options, used in CMDLINE_XXX_DESC macros and printed when -h option is used */
-#define CONFIG_HLP_RFCFGF        "Configuration file for front-end (e.g. LMS7002M)\n"
-#define CONFIG_HLP_ULMAXE        "set the eNodeB max ULSCH erros\n"
-#define CONFIG_HLP_CALUER        "set UE RX calibration\n"
-#define CONFIG_HLP_CALUERM       ""
-#define CONFIG_HLP_CALUERB       ""
-#define CONFIG_HLP_DBGUEPR       "UE run normal prach power ramping, but don't continue random-access\n"
-#define CONFIG_HLP_CALPRACH      "UE run normal prach with maximum power, but don't continue random-access\n"
-#define CONFIG_HLP_NOL2CN        "bypass L2 and upper layers\n"
-#define CONFIG_HLP_SIML1         "activate RF simulator instead of HW\n"
-#define CONFIG_HLP_NUMUE         "number of UE instances\n"
-#define CONFIG_HLP_UERXG         "set UE RX gain\n"
-#define CONFIG_HLP_UERXGOFF      "external UE amplifier offset\n"
-#define CONFIG_HLP_UETXG         "set UE TX gain\n"
-#define CONFIG_HLP_UENANTR       "set UE number of rx antennas\n"
-#define CONFIG_HLP_UENANTT       "set UE number of tx antennas\n"
-#define CONFIG_HLP_UESCAN        "set UE to scan around carrier\n"
-#define CONFIG_HLP_DUMPFRAME     "dump UE received frame to rxsig_frame0.dat and exit\n"
-#define CONFIG_HLP_DLSHIFT       "dynamic shift for LLR compuation for TM3/4 (default 0)\n"
-#define CONFIG_HLP_UELOOP        "get softmodem (UE) to loop through memory instead of acquiring from HW\n"
-#define CONFIG_HLP_PHYTST        "test UE phy layer, mac disabled\n"
-#define CONFIG_HLP_DMAMAP        "sets flag for improved EXMIMO UE performance\n"
-#define CONFIG_HLP_EXTS          "tells hardware to use an external timing reference\n"
-#define CONFIG_HLP_DMRSSYNC      "tells RU to insert DMRS in subframe 1 slot 0"
-#define CONFIG_HLP_CLK           "tells hardware to use a clock reference (0:internal, 1:external, 2:gpsdo)\n"
-#define CONFIG_HLP_USIM          "use XOR autentication algo in case of test usim mode\n"
-#define CONFIG_HLP_NOSNGLT       "Disables single-thread mode in lte-softmodem\n"
-#define CONFIG_HLP_TADV          "Set timing_advance\n"
-#define CONFIG_HLP_DLF           "Set the downlink frequency for all component carriers\n"
-#define CONFIG_HLP_CHOFF         "Channel id offset\n"
-#define CONFIG_HLP_SOFTS         "Enable soft scope and L1 and L2 stats (Xforms)\n"
-#define CONFIG_HLP_EXMCAL        "Calibrate the EXMIMO borad, available files: exmimo2_2arxg.lime exmimo2_2brxg.lime \n"
-#define CONFIG_HLP_ITTIL         "Generate ITTI analyzser logs (similar to wireshark logs but with more details)\n"
-#define CONFIG_HLP_DLMCS         "Set the maximum downlink MCS\n"
-#define CONFIG_HLP_STMON         "Enable processing timing measurement of lte softmodem on per subframe basis \n"
-#define CONFIG_HLP_PRB           "Set the PRB, valid values: 6, 25, 50, 100  \n"
-#define CONFIG_HLP_EMULIFACE     "Set the interface name for the multicast transport for emulation mode (e.g. eth0, lo, etc.)  \n"
-//#define CONFIG_HLP_NUMUES        "Set the number of UEs for the emulation"
-#define CONFIG_HLP_MSLOTS        "Skip the missed slots/subframes \n"
-#define CONFIG_HLP_ULMCS         "Set the maximum uplink MCS\n"
-#define CONFIG_HLP_TDD           "Set hardware to TDD mode (default: FDD). Used only with -U (otherwise set in config file).\n"
-#define CONFIG_HLP_UE            "Set the lte softmodem as a UE\n"
-#define CONFIG_HLP_TQFS          "Apply three-quarter of sampling frequency, 23.04 Msps to reduce the data rate on USB/PCIe transfers (only valid for 20 MHz)\n"
-#define CONFIG_HLP_TPORT         "tracer port\n"
-#define CONFIG_HLP_NOTWAIT       "don't wait for tracer, start immediately\n"
-#define CONFIG_HLP_TNOFORK       "to ease debugging with gdb\n"
-
-#define CONFIG_HLP_NUMEROLOGY    "adding numerology for 5G\n"
-#define CONFIG_HLP_EMULATE_RF    "Emulated RF enabled(disable by defult)\n"
-#define CONFIG_HLP_PARALLEL_CMD  "three config for level of parallelism 'PARALLEL_SINGLE_THREAD', 'PARALLEL_RU_L1_SPLIT', or 'PARALLEL_RU_L1_TRX_SPLIT'\n"
-#define CONFIG_HLP_WORKER_CMD    "two option for worker 'WORKER_DISABLE' or 'WORKER_ENABLE'\n"
-#define CONFIG_HLP_NOS1          "Disable s1 interface\n"
-#define CONFIG_HLP_RFSIM         "Run in rf simulator mode (also known as basic simulator)\n"
-#define CONFIG_HLP_NOKRNMOD      "(noS1 only): Use tun instead of namesh module \n"
-#define CONFIG_HLP_DISABLNBIOT   "disable nb-iot, even if defined in config\n"
 
-#define CONFIG_HLP_USRP_ARGS     "set the arguments to identify USRP (same syntax as in UHD)\n"
 
 /***************************************************************************************************************************************/
 /* command line options definitions, CMDLINE_XXXX_DESC macros are used to initialize paramdef_t arrays which are then used as argument
@@ -121,6 +65,31 @@
 #define CMDLINE_MEMLOOP_IDX                     6
 #define CMDLINE_DUMPMEMORY_IDX                  7
 /*------------------------------------------------------------------------------------------------------------------------------------------*/
+/* help strings definition for command line options, used in CMDLINE_XXX_DESC macros and printed when -h option is used */
+
+
+#define CONFIG_HLP_SIML1         "activate RF simulator instead of HW\n"
+#define CONFIG_HLP_NUMUE         "number of UE instances\n"
+#define CONFIG_HLP_UERXG         "set UE RX gain\n"
+#define CONFIG_HLP_UERXGOFF      "external UE amplifier offset\n"
+#define CONFIG_HLP_UETXG         "set UE TX gain\n"
+#define CONFIG_HLP_UENANTR       "set UE number of rx antennas\n"
+#define CONFIG_HLP_UENANTT       "set UE number of tx antennas\n"
+#define CONFIG_HLP_UESCAN        "set UE to scan around carrier\n"
+#define CONFIG_HLP_EMULIFACE     "Set the interface name for the multicast transport for emulation mode (e.g. eth0, lo, etc.)  \n"
+#define CONFIG_HLP_PRB           "Set the PRB, valid values: 6, 25, 50, 100  \n"
+#define CONFIG_HLP_DLSHIFT       "dynamic shift for LLR compuation for TM3/4 (default 0)\n"
+#define CONFIG_HLP_USRP_ARGS     "set the arguments to identify USRP (same syntax as in UHD)\n"
+#define CONFIG_HLP_DMAMAP        "sets flag for improved EXMIMO UE performance\n"
+#define CONFIG_HLP_CLK           "tells hardware to use a clock reference (0:internal, 1:external, 2:gpsdo)\n"
+#define CONFIG_HLP_TDD           "Set hardware to TDD mode (default: FDD). Used only with -U (otherwise set in config file).\n"
+#define CONFIG_HLP_TADV          "Set timing_advance\n"
+
+
+
+
+
+
 
 
 /*-------------------------------------------------------------------------------------------------------------------------------------------------------*/
@@ -166,99 +135,7 @@
 
 #define DEFAULT_DLF 2680000000
 
-/*-----------------------------------------------------------------------------------------------------------------------------------------------------*/
-/*                                            command line parameters common to eNodeB and UE                                                          */
-/*   optname                 helpstr                  paramflags      XXXptr                              defXXXval              type         numelt   */
-/*-----------------------------------------------------------------------------------------------------------------------------------------------------*/
-#define RF_CONFIG_FILE      softmodem_params.rf_config_file
-#define PHY_TEST            softmodem_params.phy_test
-#define WAIT_FOR_SYNC       softmodem_params.wait_for_sync
-#define SINGLE_THREAD_FLAG  softmodem_params.single_thread_flag
-#define CHAIN_OFFSET        softmodem_params.chain_offset
-#define NUMEROLOGY          softmodem_params.numerology
-#define EMULATE_RF          softmodem_params.emulate_rf
-#define CLOCK_SOURCE        softmodem_params.clock_source
-#define TIMING_SOURCE       softmodem_params.timing_source
-#define SEND_DMRSSYNC       softmodem_params.send_dmrs_sync
-#define USIM_TEST           softmodem_params.usim_test
-#define CMDLINE_PARAMS_DESC {  \
-    {"rf-config-file",       CONFIG_HLP_RFCFGF,       0,              strptr:(char **)&RF_CONFIG_FILE,    defstrval:NULL,        TYPE_STRING, sizeof(RF_CONFIG_FILE)},\
-    {"ulsch-max-errors",     CONFIG_HLP_ULMAXE,       0,              uptr:&ULSCH_max_consecutive_errors, defuintval:0,          TYPE_UINT,   0},                     \
-    {"phy-test",             CONFIG_HLP_PHYTST,       PARAMFLAG_BOOL, iptr:&PHY_TEST,                     defintval:0,           TYPE_INT,    0},                     \
-    {"usim-test",            CONFIG_HLP_USIM,         PARAMFLAG_BOOL, u8ptr:&USIM_TEST,                   defintval:0,           TYPE_UINT8,  0},                     \
-    {"clock",                CONFIG_HLP_CLK,          0,              uptr:&CLOCK_SOURCE,                 defintval:0,           TYPE_UINT,   0},                     \
-    {"wait-for-sync",        NULL,                    PARAMFLAG_BOOL, iptr:&WAIT_FOR_SYNC,                defintval:0,           TYPE_INT,    0},                     \
-    {"single-thread-enable", CONFIG_HLP_NOSNGLT,      PARAMFLAG_BOOL, iptr:&SINGLE_THREAD_FLAG,           defintval:0,           TYPE_INT,    0},                     \
-    {"C" ,                   CONFIG_HLP_DLF,          0,              u64ptr:&(downlink_frequency[0][0]), defuintval:2680000000, TYPE_UINT64, 0},                     \
-    {"a" ,                   CONFIG_HLP_CHOFF,        0,              iptr:&CHAIN_OFFSET,                 defintval:0,           TYPE_INT,    0},                     \
-    {"d" ,                   CONFIG_HLP_SOFTS,        PARAMFLAG_BOOL, uptr:(uint32_t *)&do_forms,         defintval:0,           TYPE_INT8,   0},                     \
-    {"q" ,                   CONFIG_HLP_STMON,        PARAMFLAG_BOOL, iptr:&opp_enabled,                  defintval:0,           TYPE_INT,    0},                     \
-    {"S" ,                   CONFIG_HLP_MSLOTS,       PARAMFLAG_BOOL, u8ptr:&exit_missed_slots,           defintval:1,           TYPE_UINT8,  0},                     \
-    {"numerology" ,          CONFIG_HLP_NUMEROLOGY,   PARAMFLAG_BOOL, iptr:&NUMEROLOGY,                   defintval:0,           TYPE_INT,    0},                     \
-    {"emulate-rf" ,          CONFIG_HLP_EMULATE_RF,   PARAMFLAG_BOOL, iptr:&EMULATE_RF,                   defintval:0,           TYPE_INT,    0},                     \
-    {"parallel-config",      CONFIG_HLP_PARALLEL_CMD, 0,              strptr:(char **)&parallel_config,   defstrval:NULL,        TYPE_STRING, 0},                     \
-    {"worker-config",        CONFIG_HLP_WORKER_CMD,   0,              strptr:(char **)&worker_config,     defstrval:NULL,        TYPE_STRING, 0},                     \
-    {"noS1",                 CONFIG_HLP_NOS1,         PARAMFLAG_BOOL, uptr:&noS1,                         defintval:0,           TYPE_INT,    0},                     \
-    {"rfsim",                CONFIG_HLP_RFSIM,        PARAMFLAG_BOOL, uptr:&rfsim,                        defintval:0,           TYPE_INT,    0},                     \
-    {"basicsim",             CONFIG_HLP_RFSIM,        PARAMFLAG_BOOL, uptr:&basicsim,                     defintval:0,           TYPE_INT,    0},                     \
-    {"nokrnmod",             CONFIG_HLP_NOKRNMOD,     PARAMFLAG_BOOL, uptr:&nokrnmod,                     defintval:0,           TYPE_INT,    0},                     \
-    {"nbiot-disable",        CONFIG_HLP_DISABLNBIOT,  PARAMFLAG_BOOL, uptr:&nonbiot,                      defuintval:0,          TYPE_INT,    0},                     \
-  }
-
-#define CONFIG_HLP_FLOG          "Enable online log \n"
-#define CONFIG_HLP_LOGL          "Set the global log level, valid options: (4:trace, 3:debug, 2:info, 1:warn, (0:error))\n"
-#define CONFIG_HLP_LOGV          "Set the global log verbosity \n"
-#define CONFIG_HLP_TELN          "Start embedded telnet server \n"
-#define CONFIG_HLP_MSC           "Enable the MSC tracing utility \n"
-/*----------------------------------------------------------------------------------------------------------------------------*/
-/*                                            command line parameters for LOG utility                                         */
-/*   optname         helpstr          paramflags        XXXptr                     defXXXval            type           numelt */
-/*----------------------------------------------------------------------------------------------------------------------------*/
-#define START_MSC                softmodem_params.start_msc
-#define CMDLINE_LOGPARAMS_DESC {  \
-    {"R" ,           CONFIG_HLP_FLOG, 0,                uptr:&online_log_messages, defintval:1,         TYPE_INT,      0},     \
-    {"g" ,           CONFIG_HLP_LOGL, 0,                uptr:&glog_level,          defintval:0,         TYPE_UINT,     0},     \
-	{"telnetsrv",    CONFIG_HLP_TELN, PARAMFLAG_BOOL,   uptr:&start_telnetsrv,     defintval:0,         TYPE_UINT,     0},     \
-    {"msc",          CONFIG_HLP_MSC,  PARAMFLAG_BOOL,   uptr:&START_MSC,           defintval:0,         TYPE_UINT,     0},     \
-	{"log-mem",      NULL,            0,      strptr:(char **)&logmem_filename,    defstrval:NULL,      TYPE_STRING,   0},     \
-  }
-
-#define CMDLINE_ONLINELOG_IDX     0
-#define CMDLINE_GLOGLEVEL_IDX     1
-#define CMDLINE_GLOGVERBO_IDX     2
-#define CMDLINE_STARTTELN_IDX     3
-
-/* check function for global log level */
-#define CMDLINE_LOGPARAMS_CHECK_DESC { \
-    { .s5= {NULL} } ,                       \
-    { .s2= {config_check_intrange, {0,4}}}, \
-    { .s5= {NULL} } ,                       \
-    { .s5= {NULL} } ,                       \
-    { .s5= {NULL} } ,                       \
-  }
-
-/***************************************************************************************************************************************/
 
-#define SOFTMODEM_NOS1_BIT            (1<<0)
-#define SOFTMODEM_NOKRNMOD_BIT        (1<<1)
-#define SOFTMODEM_NONBIOT_BIT         (1<<2)
-#define SOFTMODEM_RFSIM_BIT           (1<<10)
-#define SOFTMODEM_BASICSIM_BIT        (1<<11)
-#define SOFTMODEM_SIML1_BIT           (1<<12)
-#define SOFTMODEM_DOFORMS_BIT         (1<<15)
-
-#define IS_SOFTMODEM_NOS1            ( get_softmodem_optmask() & SOFTMODEM_NOS1_BIT)
-#define IS_SOFTMODEM_NOKRNMOD        ( get_softmodem_optmask() & SOFTMODEM_NOKRNMOD_BIT)
-#define IS_SOFTMODEM_NONBIOT         ( get_softmodem_optmask() & SOFTMODEM_NONBIOT_BIT)
-#define IS_SOFTMODEM_RFSIM           ( get_softmodem_optmask() & SOFTMODEM_RFSIM_BIT)
-#define IS_SOFTMODEM_BASICSIM        ( get_softmodem_optmask() & SOFTMODEM_BASICSIM_BIT)
-#define IS_SOFTMODEM_SIML1           ( get_softmodem_optmask() & SOFTMODEM_SIML1_BIT)
-#define IS_SOFTMODEM_DOFORMS         ( get_softmodem_optmask() & SOFTMODEM_DOFORMS_BIT)
-extern uint64_t get_softmodem_optmask(void);
-extern uint64_t set_softmodem_optmask(uint64_t bitmask);
-extern void get_common_options(void);
-extern softmodem_params_t *get_softmodem_params(void);
-extern unsigned int is_nos1exec(char *exepath) ;
 uint64_t get_pdcp_optmask(void);
 extern pthread_cond_t sync_cond;
 extern pthread_mutex_t sync_mutex;
@@ -268,7 +145,6 @@ extern uint64_t downlink_frequency[MAX_NUM_CCs][4];
 extern int32_t  uplink_frequency_offset[MAX_NUM_CCs][4];
 
 extern int rx_input_level_dBm;
-extern uint8_t exit_missed_slots;
 extern uint64_t num_missed_slots; // counter for the number of missed slots
 
 extern int oaisim_flag;
diff --git a/targets/RT/USER/lte-uesoftmodem.c b/targets/RT/USER/lte-uesoftmodem.c
index cd0db857d76178ec422a6fad0bc33f9e0ad410bb..da6ee92665bb2d8ada147938560c6434fdadc863 100644
--- a/targets/RT/USER/lte-uesoftmodem.c
+++ b/targets/RT/USER/lte-uesoftmodem.c
@@ -169,7 +169,6 @@ int                      rx_input_level_dBm;
 
 static LTE_DL_FRAME_PARMS      *frame_parms[MAX_NUM_CCs];
 
-uint8_t exit_missed_slots=1;
 uint64_t num_missed_slots=0; // counter for the number of missed slots
 
 // prototypes from function implemented in lte-ue.c, probably should be elsewhere in a include file.
@@ -264,26 +263,6 @@ unsigned int build_rfdc(int dcoff_i_rxfe, int dcoff_q_rxfe) {
 }
 
 
-
-void signal_handler(int sig) {
-  void *array[10];
-  size_t size;
-
-  if (sig==SIGSEGV) {
-    // get void*'s for all entries on the stack
-    size = backtrace(array, 10);
-    // print out all the frames to stderr
-    fprintf(stderr, "Error: signal %d:\n", sig);
-    backtrace_symbols_fd(array, size, 2);
-    exit(-1);
-  } else {
-    char msg[64];
-    sprintf(msg,"Received linux signal %s...\n",strsignal(sig));
-    exit_function(__FILE__, __FUNCTION__, __LINE__,msg);
-  }
-}
-
-
 void exit_function(const char *file, const char *function, const int line, const char *s) {
   int CC_id;
   logClean();
@@ -596,9 +575,6 @@ int main( int argc, char **argv ) {
 
   get_options ();
 
-  if (is_nos1exec(argv[0]) )
-    set_softmodem_optmask(SOFTMODEM_NOS1_BIT);
-
   EPC_MODE_ENABLED = !IS_SOFTMODEM_NOS1;
   printf("Running with %d UE instances\n",NB_UE_INST);
 
@@ -645,10 +621,7 @@ int main( int argc, char **argv ) {
   printf ("PDCP PC5S socket\n");
   pdcp_pc5_socket_init();
   // to make a graceful exit when ctrl-c is pressed
-  signal(SIGSEGV, signal_handler);
-  signal(SIGINT, signal_handler);
-  signal(SIGTERM, signal_handler);
-  signal(SIGABRT, signal_handler);
+  set_softmodem_sighandler();
   check_clock();
 #ifndef PACKAGE_VERSION
 #  define PACKAGE_VERSION "UNKNOWN-EXPERIMENTAL"