diff --git a/openair1/PHY/LTE_TRANSPORT/defs.h b/openair1/PHY/LTE_TRANSPORT/defs.h
index a13ccb20e6face8c52cd36f9d340f8d7fce942dc..e4d9b47986f7ad1edf4f34bc9f6e230688f33f24 100644
--- a/openair1/PHY/LTE_TRANSPORT/defs.h
+++ b/openair1/PHY/LTE_TRANSPORT/defs.h
@@ -252,7 +252,7 @@ typedef struct {
 
   // decode phich
   uint8_t decode_phich;
-} LTE_UL_UE_HARQ_t; 
+} LTE_UL_UE_HARQ_t;
 
 #ifdef Rel14
 typedef enum {
@@ -265,7 +265,7 @@ typedef struct {
   /// TX buffers for UE-spec transmission (antenna ports 5 or 7..14, prior to precoding)
   int32_t *txdataF[8];
   /// beamforming weights for UE-spec transmission (antenna ports 5 or 7..14), for each codeword, maximum 4 layers?
-  int32_t **ue_spec_bf_weights[4]; 
+  int32_t **ue_spec_bf_weights[4];
   /// dl channel estimates (estimated from ul channel estimates)
   int32_t **calib_dl_ch_estimates;
   /// Allocated RNTI (0 means DLSCH_t is not currently used)
@@ -413,7 +413,7 @@ typedef struct {
   /// is done after a new scheduling
   uint16_t previous_first_rb;
   /// Current Number of RBs
-  uint16_t nb_rb; 
+  uint16_t nb_rb;
   /// Current Modulation order
   uint8_t Qm;
   /// Transport block size
@@ -531,7 +531,7 @@ typedef enum {
   HARQ_SR,
   HARQ_CQI,
   SR_CQI,
-  HARQ_SR_CQI  
+  HARQ_SR_CQI
 } UCI_type_t;
 
 #ifdef Rel14
@@ -556,7 +556,7 @@ typedef struct {
   uint8_t     srs_active;
   /// PUCCH format to use
   PUCCH_FMT_t pucch_fmt;
-  /// number of PUCCH antenna ports 
+  /// number of PUCCH antenna ports
   uint8_t     num_antenna_ports;
   /// number of PUCCH resources
   uint8_t     num_pucch_resources;
@@ -878,7 +878,7 @@ typedef struct {
 
 typedef struct {
   // SL Configuration
-  /// Number of SL resource blocks (1-100) 
+  /// Number of SL resource blocks (1-100)
   uint32_t N_SL_RB;
   /// prb-start (0-99)
   uint32_t prb_Start;
@@ -911,7 +911,7 @@ typedef struct {
 
   // SLSCH Parameters
   /// Number of Subbands (36.213 14.1.1.2)
-  uint32_t Nsb; 
+  uint32_t Nsb;
   /// N_RB_HO (36.213 14.1.1.2)
   uint32_t N_RB_HO;
   /// n_ss_PSSCH (36.211 9.2.4)
@@ -930,17 +930,16 @@ typedef struct {
   uint32_t n_prime_PRB;
   /// m_nprime_PRB_PSSCH (36.213 14.1.3)
   uint32_t m_nprime_PRB_PSCCH;
-  /// payload length 
+  /// payload length
   int payload_length;
   /// pointer to payload
   uint8_t *payload;
 } SLSCH_t;
 
 typedef struct {
-  /// payload length 
+  /// payload length
   int payload_length;
-  /// pointer to payload
-  uint8_t *payload;
+	uint8_t payload[100];
 } SLDCH_t;
 
 #define TTI_SYNC 0
@@ -954,13 +953,13 @@ typedef struct UE_tport_header_s {
 } UE_tport_header_t;
 
 typedef struct UE_tport_s {
-  UE_tport_header_t header; 
+  UE_tport_header_t header;
   union {
     SLSS_t slss;
     SLDCH_t sldch;
     SLSCH_t slsch;
   };
-  uint8_t payload[1500];  
+  uint8_t payload[1500];
 } UE_tport_t;
 
 #endif
diff --git a/openair1/PHY/LTE_TRANSPORT/sldch.c b/openair1/PHY/LTE_TRANSPORT/sldch.c
index c14a1b87a961626ef66ea8862fd3e3cf7770a5ba..dc68b70e956b6f07792771bd2f607f7c9c96c6e0 100644
--- a/openair1/PHY/LTE_TRANSPORT/sldch.c
+++ b/openair1/PHY/LTE_TRANSPORT/sldch.c
@@ -42,14 +42,13 @@ void generate_sldch(PHY_VARS_UE *ue,SLDCH_t *sldch,int frame_tx,int subframe_tx)
   pdu.header.packet_type = SLDCH;
   pdu.header.absSF = (frame_tx*10)+subframe_tx;
 
-  memcpy((void*)&pdu.sldch,(void*)sldch,sizeof(SLDCH_t)-sizeof(uint8_t*));
 
   AssertFatal(sldch->payload_length <=1500-sldch_header_len - sizeof(SLDCH_t) + sizeof(uint8_t*),
                 "SLDCH payload length > %d\n",
                 1500-sldch_header_len - sizeof(SLDCH_t) + sizeof(uint8_t*));
-  memcpy((void*)&pdu.payload[0],
-         (void*)sldch->payload,
-         sldch->payload_length);
+  memcpy((void*)&pdu.sldch,
+         (void*)sldch,
+         sizeof(SLDCH_t));
 
   LOG_I(PHY,"SLDCH configuration %d bytes, TBS payload %d bytes => %d bytes\n",
         sizeof(SLDCH_t)-sizeof(uint8_t*),
@@ -58,7 +57,7 @@ void generate_sldch(PHY_VARS_UE *ue,SLDCH_t *sldch,int frame_tx,int subframe_tx)
 
   multicast_link_write_sock(0,
                             &pdu,
-                            sldch_header_len+sizeof(SLDCH_t)-sizeof(uint8_t*)+sldch->payload_length);
+                            sldch_header_len+sizeof(SLDCH_t));
 
 }
 
diff --git a/openair2/LAYER2/MAC/defs.h b/openair2/LAYER2/MAC/defs.h
index c57ebfc47a164abba02b267aa1b84e29cc2c1a8e..9d575340b4da9fd134ce81067b07f56668a28bc4 100644
--- a/openair2/LAYER2/MAC/defs.h
+++ b/openair2/LAYER2/MAC/defs.h
@@ -134,7 +134,7 @@
 /*!\brief size of buffer status report table */
 #define BSR_TABLE_SIZE 64
 /*!\brief The power headroom reporting range is from -23 ...+40 dB and beyond, with step 1 */
-#define PHR_MAPPING_OFFSET 23  // if ( x>= -23 ) val = floor (x + 23) 
+#define PHR_MAPPING_OFFSET 23  // if ( x>= -23 ) val = floor (x + 23)
 /*!\brief maximum number of resource block groups */
 #define N_RBG_MAX 25 // for 20MHz channel BW
 /*!\brief minimum value for channel quality indicator */
@@ -142,9 +142,9 @@
 /*!\brief maximum value for channel quality indicator */
 #define MAX_CQI_VALUE  15
 /*!\briefmaximum number of supported bandwidth (1.4, 5, 10, 20 MHz) */
-#define MAX_SUPPORTED_BW  4  
+#define MAX_SUPPORTED_BW  4
 /*!\brief CQI values range from 1 to 15 (4 bits) */
-#define CQI_VALUE_RANGE 16 
+#define CQI_VALUE_RANGE 16
 
 /*!\brief value for indicating BSR Timer is not running */
 #define MAC_UE_BSR_TIMER_NOT_RUNNING   (0xFFFF)
@@ -159,16 +159,16 @@
 #define MIN_MAC_HDR_RLC_SIZE    (1 + MIN_RLC_PDU_SIZE)
 
 /*!\brief maximum number of slices / groups */
-#define MAX_NUM_SLICES 4 
+#define MAX_NUM_SLICES 4
 
-/* 
- * eNB part 
- */ 
+/*
+ * eNB part
+ */
 
 
-/* 
- * UE/ENB common part 
- */ 
+/*
+ * UE/ENB common part
+ */
 /*!\brief MAC header of Random Access Response for Random access preamble identifier (RAPID) */
 typedef struct {
   uint8_t RAPID:6;
@@ -241,7 +241,7 @@ typedef struct {
 
 /*!\brief  MAC subheader long  with 24bit DST field */
 typedef struct {
-  uint8_t   R0:4; 
+  uint8_t   R0:4;
   uint8_t   V:4;//Version number: Possible values "0001", "0010", "0011" based on TS36.321 section 6.2.3.
   uint8_t  SRC07; //Prose UE source ID. Size 24 bits.
   uint8_t  SRC815; //Prose UE source ID. Size 24 bits.
@@ -252,13 +252,13 @@ typedef struct {
   uint8_t  LCID:5;
   uint8_t  E:1;
   uint8_t  R1:2;
-  uint8_t  L:7;	// Length field indicating the size of the corresponding SDU in bytes. 
+  uint8_t  L:7;	// Length field indicating the size of the corresponding SDU in bytes.
   uint8_t  F:1;
 }__attribute__((__packed__))SLSCH_SUBHEADER_24_Bit_DST_SHORT;
 
 /*!\brief  MAC subheader long  with 24bit DST field */
 typedef struct {
-  uint8_t   R0:4; 
+  uint8_t   R0:4;
   uint8_t   V:4;//Version number: Possible values "0001", "0010", "0011" based on TS36.321 section 6.2.3.
   uint8_t  SRC07; //Prose UE source ID. Size 24 bits.
   uint8_t  SRC815; //Prose UE source ID. Size 24 bits.
@@ -269,14 +269,14 @@ typedef struct {
   uint8_t  LCID:5;
   uint8_t  E:1;
   uint8_t  R1:2;
-  uint8_t  L_MSB:7;	// Length field indicating the size of the corresponding SDU in bytes. 
+  uint8_t  L_MSB:7;	// Length field indicating the size of the corresponding SDU in bytes.
   uint8_t  F:1;
   uint8_t  L_LSB:8;
 }__attribute__((__packed__))SLSCH_SUBHEADER_24_Bit_DST_LONG;
 
 /*!\brief  MAC subheader long  with 24bit DST field */
 typedef struct {
-  uint8_t   R0:4; 
+  uint8_t   R0:4;
   uint8_t   V:4;//Version number: Possible values "0001", "0010", "0011" based on TS36.321 section 6.2.3.
   uint8_t  SRC07; //Prose UE source ID. Size 24 bits.
   uint8_t  SRC815; //Prose UE source ID. Size 24 bits.
@@ -285,13 +285,13 @@ typedef struct {
   uint8_t  LCID:5;
   uint8_t  E:1;
   uint8_t  R1:2;
-  uint8_t  L:7;	// Length field indicating the size of the corresponding SDU in bytes. 
+  uint8_t  L:7;	// Length field indicating the size of the corresponding SDU in bytes.
   uint8_t  F:1;
 }__attribute__((__packed__))SLSCH_SUBHEADER_16_Bit_DST_SHORT;
 
 /*!\brief  MAC subheader long  with 24bit DST field */
 typedef struct {
-  uint8_t   R0:4; 
+  uint8_t   R0:4;
   uint8_t   V:4;//Version number: Possible values "0001", "0010", "0011" based on TS36.321 section 6.2.3.
   uint8_t  SRC07; //Prose UE source ID. Size 24 bits.
   uint8_t  SRC815; //Prose UE source ID. Size 24 bits.
@@ -301,7 +301,7 @@ typedef struct {
   uint8_t  LCID:5;
   uint8_t  E:1;
   uint8_t  R1:2;
-  uint8_t  L_MSB:7;	// Length field indicating the size of the corresponding SDU in bytes. 
+  uint8_t  L_MSB:7;	// Length field indicating the size of the corresponding SDU in bytes.
   uint8_t  F:1;
   uint8_t  L_LSB:8;
 }__attribute__((__packed__))SLSCH_SUBHEADER_16_Bit_DST_LONG;
@@ -401,18 +401,18 @@ typedef struct {
   uint8_t stop_sf_LSB:8;
 } __attribute__((__packed__))MSI_ELEMENT;
 #endif
-/*! \brief Values of CCCH LCID for DLSCH */ 
+/*! \brief Values of CCCH LCID for DLSCH */
 #define CCCH_LCHANID 0
 /*!\brief Values of BCCH logical channel (fake)*/
-#define BCCH 3  // SI 
+#define BCCH 3  // SI
 /*!\brief Values of PCCH logical channel (fake)*/
-#define PCCH 4  // Paging 
+#define PCCH 4  // Paging
 /*!\brief Values of PCCH logical channel (fake) */
-#define MIBCH 5  // MIB 
+#define MIBCH 5  // MIB
 /*!\brief Values of BCCH SIB1_BR logical channel (fake) */
-#define BCCH_SIB1_BR 6  // SIB1_BR 
+#define BCCH_SIB1_BR 6  // SIB1_BR
 /*!\brief Values of BCCH SIB_BR logical channel (fake) */
-#define BCCH_SI_BR 7  // SI-BR 
+#define BCCH_SI_BR 7  // SI-BR
 /*!\brief Value of CCCH / SRB0 logical channel */
 #define CCCH 0  // srb0
 /*!\brief DCCH / SRB1 logical channel */
@@ -422,9 +422,9 @@ typedef struct {
 /*!\brief DTCH DRB1  logical channel */
 #define DTCH 3 // LCID
 /*!\brief MCCH logical channel */
-#define MCCH 4 
+#define MCCH 4
 /*!\brief MTCH logical channel */
-#define MTCH 1 
+#define MTCH 1
 // DLSCH LCHAN ID
 /*!\brief LCID of UE contention resolution identity for DLSCH*/
 #define UE_CONT_RES 28
@@ -545,20 +545,20 @@ typedef struct {
 } eNB_DLSCH_INFO;
 /*! \brief eNB overall statistics */
 typedef struct {
-  /// num BCCH PDU per CC 
+  /// num BCCH PDU per CC
   uint32_t total_num_bcch_pdu;
-  /// BCCH buffer size  
+  /// BCCH buffer size
   uint32_t bcch_buffer;
-  /// total BCCH buffer size  
+  /// total BCCH buffer size
   uint32_t total_bcch_buffer;
   /// BCCH MCS
   uint32_t bcch_mcs;
 
-  /// num CCCH PDU per CC 
+  /// num CCCH PDU per CC
   uint32_t total_num_ccch_pdu;
-  /// BCCH buffer size  
+  /// BCCH buffer size
   uint32_t ccch_buffer;
-  /// total BCCH buffer size  
+  /// total BCCH buffer size
   uint32_t total_ccch_buffer;
   /// BCCH MCS
   uint32_t ccch_mcs;
@@ -585,22 +585,22 @@ typedef struct {
   uint32_t total_dlsch_bytes_tx;
   //
   uint32_t total_dlsch_pdus_tx;
-  
+
   // here for RX
   //
   uint32_t ulsch_bitrate;
   //
   uint32_t ulsch_bytes_rx;
   //
-  uint64_t ulsch_pdus_rx; 
+  uint64_t ulsch_pdus_rx;
 
   uint32_t total_ulsch_bitrate;
   //
   uint32_t total_ulsch_bytes_rx;
   //
   uint32_t total_ulsch_pdus_rx;
-  
-  
+
+
   /// MAC agent-related stats
   /// total number of scheduling decisions
   int sched_decisions;
@@ -704,9 +704,9 @@ typedef struct {
   uint32_t rbs_used_retx_rx;
   ///  total rb used for a new uplink transmission
   uint32_t total_rbs_used_rx;
-  /// normalized rx power 
+  /// normalized rx power
   int32_t      normalized_rx_power;
-   /// target rx power 
+   /// target rx power
   int32_t    target_rx_power;
 
   /// num rx pdu
@@ -717,7 +717,7 @@ typedef struct {
   //  uint32_t tti_goodput[NB_RB_MAX];
   /// errors
   uint32_t num_errors_rx;
-  
+
   uint64_t overhead_bytes_rx;
   /// headers+ CE +  padding bytes for a MAC PDU
   uint64_t total_overhead_bytes_rx;
@@ -832,12 +832,12 @@ typedef struct {
   uint32_t dl_buffer_head_sdu_creation_time[MAX_NUM_LCID];
   /// maximum creation time of the downlink buffer head across all LCID
   uint32_t  dl_buffer_head_sdu_creation_time_max;
-  /// a flag indicating that the downlink head SDU is segmented  
+  /// a flag indicating that the downlink head SDU is segmented
   uint8_t    dl_buffer_head_sdu_is_segmented[MAX_NUM_LCID];
   /// size of remaining size to send for the downlink head SDU
   uint32_t dl_buffer_head_sdu_remaining_size_to_send[MAX_NUM_LCID];
 
-  /// total uplink buffer size 
+  /// total uplink buffer size
   uint32_t ul_total_buffer;
   /// uplink buffer creation time for each LCID
   uint32_t ul_buffer_creation_time[MAX_NUM_LCGID];
@@ -898,7 +898,7 @@ typedef struct {
   uint16_t priority[MAX_NUM_LCID];
 
   // resource scheduling information
-  
+
   /// Current DL harq round per harq_pid on each CC
   uint8_t       round[MAX_NUM_CCs][10];
   /// Current Active TBs per harq_pid on each CC
@@ -914,7 +914,7 @@ typedef struct {
   int32_t       context_active_timer;
   int32_t       cqi_req_timer;
   int32_t       ul_inactivity_timer;
-  int32_t       ul_failure_timer; 
+  int32_t       ul_failure_timer;
   int32_t       ul_scheduled;
   int32_t       ra_pdcch_order_sent;
   int32_t       ul_out_of_sync;
@@ -1031,31 +1031,31 @@ typedef struct {
 
 /*! \brief subband bitmap confguration (for ALU icic algo purpose), in test phase */
 typedef struct {
-  uint8_t sbmap[13]; 
+  uint8_t sbmap[13];
   uint8_t periodicity;
   uint8_t first_subframe;
   uint8_t sb_size;
   uint8_t nb_active_sb;
 } SBMAP_CONF;
-/*! \brief UE list used by eNB to order UEs/CC for scheduling*/ 
+/*! \brief UE list used by eNB to order UEs/CC for scheduling*/
 typedef struct {
   /// Dedicated information for UEs
   struct PhysicalConfigDedicated  *physicalConfigDedicated[MAX_NUM_CCs][NUMBER_OF_UE_MAX];
-  /// DLSCH pdu 
+  /// DLSCH pdu
   DLSCH_PDU DLSCH_pdu[MAX_NUM_CCs][2][NUMBER_OF_UE_MAX];
   /// DCI template and MAC connection parameters for UEs
   UE_TEMPLATE UE_template[MAX_NUM_CCs][NUMBER_OF_UE_MAX];
   /// DCI template and MAC connection for RA processes
   int pCC_id[NUMBER_OF_UE_MAX];
-  /// sorted downlink component carrier for the scheduler 
+  /// sorted downlink component carrier for the scheduler
   int ordered_CCids[MAX_NUM_CCs][NUMBER_OF_UE_MAX];
-  /// number of downlink active component carrier 
+  /// number of downlink active component carrier
   int numactiveCCs[NUMBER_OF_UE_MAX];
-  /// sorted uplink component carrier for the scheduler 
+  /// sorted uplink component carrier for the scheduler
   int ordered_ULCCids[MAX_NUM_CCs][NUMBER_OF_UE_MAX];
-  /// number of uplink active component carrier 
+  /// number of uplink active component carrier
   int numactiveULCCs[NUMBER_OF_UE_MAX];
-  /// number of downlink active component carrier 
+  /// number of downlink active component carrier
   uint8_t dl_CC_bitmap[NUMBER_OF_UE_MAX];
   /// eNB to UE statistics
   eNB_UE_STATS eNB_UE_stats[MAX_NUM_CCs][NUMBER_OF_UE_MAX];
@@ -1070,7 +1070,7 @@ typedef struct {
   boolean_t active[NUMBER_OF_UE_MAX];
 } UE_list_t;
 
-/*! \brief eNB common channels */ 
+/*! \brief eNB common channels */
 typedef struct {
   int                              physCellId;
   int                              p_eNB;
@@ -1080,7 +1080,7 @@ typedef struct {
   BCCH_BCH_Message_t               *mib;
   RadioResourceConfigCommonSIB_t   *radioResourceConfigCommon;
 #ifdef Rel14
-  RadioResourceConfigCommonSIB_t   *radioResourceConfigCommon_BR;  
+  RadioResourceConfigCommonSIB_t   *radioResourceConfigCommon_BR;
 #endif
   TDD_Config_t                     *tdd_Config;
   SchedulingInfoList_t             *schedulingInfoList;
@@ -1137,7 +1137,7 @@ typedef struct {
   BCCH_PDU BCCH_BR_pdu[20];
 #endif
 } COMMON_channels_t;
-/*! \brief top level eNB MAC structure */ 
+/*! \brief top level eNB MAC structure */
 typedef struct eNB_MAC_INST_s {
   /// Ethernet parameters for northbound midhaul interface
   eth_params_t         eth_params_n;
@@ -1170,7 +1170,7 @@ typedef struct eNB_MAC_INST_s {
   nfapi_ul_config_request_t UL_req[MAX_NUM_CCs];
   /// NFAPI "Temporary" UL Config Request Structure, holds future UL_config requests
   nfapi_ul_config_request_t UL_req_tmp[MAX_NUM_CCs][10];
-  /// Preallocated HI_DCI0 pdu list 
+  /// Preallocated HI_DCI0 pdu list
   nfapi_hi_dci0_request_pdu_t hi_dci0_pdu_list[MAX_NUM_CCs][MAX_NUM_HI_DCI0_PDU];
   /// NFAPI HI/DCI0 Config Request Structure
   nfapi_hi_dci0_request_t HI_DCI0_req[MAX_NUM_CCs];
@@ -1191,29 +1191,29 @@ typedef struct eNB_MAC_INST_s {
   /// eNB stats
   eNB_STATS eNB_stats[MAX_NUM_CCs];
   // MAC function execution peformance profiler
-  /// processing time of eNB scheduler 
+  /// processing time of eNB scheduler
   time_stats_t eNB_scheduler;
-  /// processing time of eNB scheduler for SI 
+  /// processing time of eNB scheduler for SI
   time_stats_t schedule_si;
   /// processing time of eNB scheduler for Random access
   time_stats_t schedule_ra;
-  /// processing time of eNB ULSCH scheduler 
+  /// processing time of eNB ULSCH scheduler
   time_stats_t schedule_ulsch;
   /// processing time of eNB DCI generation
   time_stats_t fill_DLSCH_dci;
   /// processing time of eNB MAC preprocessor
   time_stats_t schedule_dlsch_preprocessor;
-  /// processing time of eNB DLSCH scheduler 
+  /// processing time of eNB DLSCH scheduler
   time_stats_t schedule_dlsch; // include rlc_data_req + MAC header + preprocessor
-  /// processing time of eNB MCH scheduler 
+  /// processing time of eNB MCH scheduler
   time_stats_t schedule_mch;
   /// processing time of eNB ULSCH reception
   time_stats_t rx_ulsch_sdu; // include rlc_data_ind
 } eNB_MAC_INST;
 
-/* 
- * UE part 
- */ 
+/*
+ * UE part
+ */
 
 typedef enum {
   TYPE0,
@@ -1378,7 +1378,6 @@ typedef struct {
   int sltx_active;
   SLSCH_t slsch;
   SLDCH_t sldch;
-  ULDCH_PDU sldch_pdu;
   ULSCH_PDU slsch_pdu;
   int slsch_lcid;
 #endif
@@ -1447,24 +1446,24 @@ typedef struct {
   uint8_t msi_status;// could be an array if there are >1 MCH in one MBSFN area
 #endif
   //#ifdef CBA
-  /// CBA RNTI for each group 
+  /// CBA RNTI for each group
   uint16_t cba_rnti[NUM_MAX_CBA_GROUP];
-  /// last SFN for CBA channel access 
+  /// last SFN for CBA channel access
   uint8_t cba_last_access[NUM_MAX_CBA_GROUP];
   //#endif
-  /// total UE scheduler processing time 
+  /// total UE scheduler processing time
   time_stats_t ue_scheduler; // total
-  /// UE ULSCH tx  processing time inlcuding RLC interface (rlc_data_req) and mac header generation 
-  time_stats_t tx_ulsch_sdu;  
+  /// UE ULSCH tx  processing time inlcuding RLC interface (rlc_data_req) and mac header generation
+  time_stats_t tx_ulsch_sdu;
   /// UE DLSCH rx  processing time inlcuding RLC interface (mac_rrc_data_ind or mac_rlc_status_ind+mac_rlc_data_ind) and mac header parser
-  time_stats_t rx_dlsch_sdu ; 
-  /// UE query for MCH subframe processing time 
+  time_stats_t rx_dlsch_sdu ;
+  /// UE query for MCH subframe processing time
   time_stats_t ue_query_mch;
-  /// UE MCH rx processing time 
+  /// UE MCH rx processing time
   time_stats_t rx_mch_sdu;
-  /// UE BCCH rx processing time including RLC interface (mac_rrc_data_ind) 
-  time_stats_t rx_si; 
-  /// UE PCCH rx processing time including RLC interface (mac_rrc_data_ind) 
+  /// UE BCCH rx processing time including RLC interface (mac_rrc_data_ind)
+  time_stats_t rx_si;
+  /// UE PCCH rx processing time including RLC interface (mac_rrc_data_ind)
   time_stats_t rx_p;
   /// Panos: Mutex for nfapi UL_INFO
   pthread_mutex_t      UL_INFO_mutex;
@@ -1498,6 +1497,3 @@ typedef struct {
 #include "proto.h"
 /*@}*/
 #endif /*__LAYER2_MAC_DEFS_H__ */
-
-
-
diff --git a/openair2/LAYER2/MAC/ue_procedures.c b/openair2/LAYER2/MAC/ue_procedures.c
index 4cd78baca785301e9a87e9ef9e319d5cd0d3cc04..7ebcb08f1b6b5543b561102c129f6ade1c6e770f 100644
--- a/openair2/LAYER2/MAC/ue_procedures.c
+++ b/openair2/LAYER2/MAC/ue_procedures.c
@@ -117,7 +117,7 @@ void ue_init_mac(module_id_t module_idP)
   UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF  =  MAC_UE_BSR_TIMER_NOT_RUNNING;
   UE_mac_inst[module_idP].scheduling_info.retxBSR_SF     =  MAC_UE_BSR_TIMER_NOT_RUNNING;
   UE_mac_inst[module_idP].BSR_reporting_active = BSR_TRIGGER_NONE;
-  
+
   UE_mac_inst[module_idP].scheduling_info.periodicPHR_SF =  get_sf_perioidicPHR_Timer(UE_mac_inst[module_idP].scheduling_info.periodicPHR_Timer);
   UE_mac_inst[module_idP].scheduling_info.prohibitPHR_SF =  get_sf_prohibitPHR_Timer(UE_mac_inst[module_idP].scheduling_info.prohibitPHR_Timer);
   UE_mac_inst[module_idP].scheduling_info.PathlossChange_db =  get_db_dl_PathlossChange(UE_mac_inst[module_idP].scheduling_info.PathlossChange);
@@ -463,7 +463,7 @@ ue_send_sdu(
 #ifdef DEBUG_HEADER_PARSING
     LOG_D(MAC,"[UE] SDU %d : LCID %d, length %d\n",i,rx_lcids[i],rx_lengths[i]);
 #endif
-    
+
     if (rx_lcids[i] == CCCH) {
 
       LOG_D(MAC,"[UE %d] rnti %x Frame %d : DLSCH -> DL-CCCH, RRC message (eNB %d, %d bytes)\n",
@@ -506,9 +506,9 @@ ue_send_sdu(
                        rx_lengths[i],
                        1,
                        NULL);
- 
+
     } else if ((rx_lcids[i]  < NB_RB_MAX) && (rx_lcids[i] > DCCH1 )) {
-      
+
       LOG_D(MAC,"[UE %d] Frame %d : DLSCH -> DL-DTCH%d (eNB %d, %d bytes)\n", module_idP, frameP,rx_lcids[i], eNB_index,rx_lengths[i]);
 
 #if defined(ENABLE_MAC_PAYLOAD_DEBUG)
@@ -534,7 +534,7 @@ ue_send_sdu(
     payload_ptr+= rx_lengths[i];
   }
   } // end if (payload_ptr != NULL)
-  
+
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SEND_SDU, VCD_FUNCTION_OUT);
 #if UE_TIMING_TRACE
   stop_meas(&UE_mac_inst[module_idP].rx_dlsch_sdu);
@@ -1416,7 +1416,7 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf
   int highest_priority = 16;
   int num_lcg_id_with_data = 0;
   rlc_buffer_occupancy_t lcid_buffer_occupancy_old=0, lcid_buffer_occupancy_new=0;
-  
+
   LOG_D(MAC,"[UE %d] MAC PROCESS UL TRANSPORT BLOCK at frame%d subframe %d TBS=%d\n",
                         module_idP, frameP, subframe, buflen);
 
@@ -1919,7 +1919,7 @@ for (lcid=DCCH; (lcid < MAX_NUM_LCID) && (is_all_lcid_processed == FALSE) ; lcid
 #if UE_TIMING_TRACE
   stop_meas(&UE_mac_inst[module_idP].tx_ulsch_sdu);
 #endif
-  
+
 
   if (opt_enabled) {
     trace_pdu(0, ulsch_buffer, buflen, module_idP, 3, UE_mac_inst[module_idP].crnti, UE_mac_inst[module_idP].txFrame, UE_mac_inst[module_idP].txSubframe, 0, 0);
@@ -2118,9 +2118,9 @@ ue_scheduler(
 
 
       /*
-      if (lcid == DCCH) {    
-        LOG_D(MAC,"[UE %d][SR] Frame %d subframe %d Pending data for SRB1=%d for LCGID %d \n",                  
-        module_idP, txFrameP,txSubframeP,UE_mac_inst[module_idP].scheduling_info.BSR[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]],                  
+      if (lcid == DCCH) {
+        LOG_D(MAC,"[UE %d][SR] Frame %d subframe %d Pending data for SRB1=%d for LCGID %d \n",
+        module_idP, txFrameP,txSubframeP,UE_mac_inst[module_idP].scheduling_info.BSR[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]],
 //         UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]);
       }
       */
@@ -2748,24 +2748,27 @@ SLSS_t *ue_get_slss(module_id_t Mod_id,int CC_id,frame_t frame_tx,sub_frame_t su
 }
 
 SLDCH_t *ue_get_sldch(module_id_t Mod_id,int CC_id,frame_t frame_tx,sub_frame_t subframe_tx) {
-/*  int sdu_length;
+
     UE_MAC_INST *ue = &UE_mac_inst[Mod_id];
     SLDCH_t *sldch = &UE_mac_inst[Mod_id].sldch;
-   LOG_I(MAC, "[ue_get_sldch]");
-   int sdu_length = mac_rrc_data_req(Mod_id,
+
+    sldch->payload_length = mac_rrc_data_req(Mod_id,
             CC_id,
             frame_tx,
             SL_DISCOVERY,
             1,
-            (char*)(ue->sldch_pdu.payload), //&UE_mac_inst[Mod_id].SL_Discovery[0].Tx_buffer.Payload[0],
+            (char*)(sldch->payload), //&UE_mac_inst[Mod_id].SL_Discovery[0].Tx_buffer.Payload[0],
             0,
             0, //eNB_indexP
             0);
 
 
-   if (sdu_length >0 ) return (&ue->sldch);
+   if (sldch->payload_length >0 ) {
+     LOG_I(MAC,"Got %d bytes from RRC for SLDCH @ %p\n",sldch->payload_length,sldch);
+     return (sldch);
+   }
    else
-   */
+
    return((SLDCH_t*)NULL);
 }
 
@@ -2807,7 +2810,7 @@ SLSCH_t *ue_get_slsch(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_
        ue->slsch_lcid = 3;
     }
   } // we're not in the SCCH period
-  else if (((absSF & 3) == 0 ) && 
+  else if (((absSF & 3) == 0 ) &&
 	   (ue->sltx_active == 1)) { // every 4th subframe, check for new data from RLC
     // 10 PRBs, mcs 19
     int TBS = 4584/8;
@@ -2833,7 +2836,7 @@ SLSCH_t *ue_get_slsch(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_
 				    ue->slsch_lcid,
 				    req,
 				    (char*)(ue->slsch_pdu.payload + sizeof(SLSCH_SUBHEADER_24_Bit_DST_LONG)));
-      
+
       // Notes: 1. hard-coded to 24-bit destination format for now
       //        2. LCID hard-coded to 3
       //        3. SRC/DST IDs with debug values
@@ -2844,7 +2847,7 @@ SLSCH_t *ue_get_slsch(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_
 	LOG_I(MAC,"groupL2Id/destinationL2Id: 0x%08x \n",destL2Id);
 
 	slsch->payload = (unsigned char*)ue->slsch_pdu.payload;
-	if (sdu_length < 128) { 
+	if (sdu_length < 128) {
 	  slsch->payload++;
 	  SLSCH_SUBHEADER_24_Bit_DST_SHORT *shorth= (SLSCH_SUBHEADER_24_Bit_DST_SHORT *)slsch->payload;
 	  shorth->F=0;
@@ -2890,6 +2893,6 @@ SLSCH_t *ue_get_slsch(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_
     return(&ue->slsch);
   }
 
-  
+
   return(NULL);
 }
diff --git a/openair2/RRC/LITE/L2_interface.c b/openair2/RRC/LITE/L2_interface.c
index 7b4ad57a2f9dcbdc60ad2afd8586c71a54d09dc1..2fbe6bec44aa378a987965157fc9a4667dda519a 100644
--- a/openair2/RRC/LITE/L2_interface.c
+++ b/openair2/RRC/LITE/L2_interface.c
@@ -102,7 +102,7 @@ mac_rrc_data_req(
       }
 
       // All even frames transmit SIB in SF 5
-      AssertFatal(RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB1 != 255, 
+      AssertFatal(RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB1 != 255,
 		  "[eNB %d] MAC Request for SIB1 and SIB1 not initialized\n",Mod_idP);
 
       if ((frameP%2) == 0) {
@@ -312,7 +312,7 @@ mac_rrc_data_req(
                RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB1_BR);
         return (RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB1_BR);
     }
- 
+
     if ((Srb_id & RAB_OFFSET) == BCCH_SI_BR){ // First SI message with SIB2/3
         memcpy(&buffer_pP[0],
                RC.rrc[Mod_idP]->carrier[CC_id].SIB23_BR,
@@ -329,10 +329,11 @@ mac_rrc_data_req(
      LOG_D(RRC,"[UE %d] Frame %d buffer_pP status %d,\n",Mod_idP,frameP, UE_rrc_inst[Mod_idP].SL_Discovery[eNB_index].Tx_buffer.payload_size);
 
    //TTN (for D2D)
-     if ((Srb_id & RAB_OFFSET) == SL_DISCOVERY){
+     if (Srb_id  == SL_DISCOVERY && UE_rrc_inst[Mod_idP].SL_Discovery[eNB_index].Tx_buffer.payload_size > 0){
         memcpy(&buffer_pP[0],&UE_rrc_inst[Mod_idP].SL_Discovery[eNB_index].Tx_buffer.Payload[0],UE_rrc_inst[Mod_idP].SL_Discovery[eNB_index].Tx_buffer.payload_size);
         uint8_t Ret_size=UE_rrc_inst[Mod_idP].SL_Discovery[eNB_index].Tx_buffer.payload_size;
-        //      msg("[RRC][UE %d] Sending SL_Discovery\n",Mod_id);
+        LOG_I(RRC,"[UE %d] Sending SL_Discovery, size %d bytes\n",Mod_idP,Ret_size);
+        UE_rrc_inst[Mod_idP].SL_Discovery[eNB_index].Tx_buffer.payload_size = 0;
         return(Ret_size);
      }
 #endif
@@ -513,7 +514,7 @@ mac_rrc_data_ind(
     }
 
     //TTN (for D2D)
-    if((srb_idP & RAB_OFFSET) == SL_DISCOVERY) {
+    if(srb_idP == SL_DISCOVERY) {
        decode_SL_Discovery_Message(&ctxt, eNB_indexP, sduP, sdu_lenP);
     }
 
@@ -522,7 +523,7 @@ mac_rrc_data_ind(
   } else { // This is an eNB
     Srb_info = &RC.rrc[module_idP]->carrier[CC_id].Srb0;
     LOG_D(RRC,"[eNB %d] Received SDU for CCCH on SRB %d\n",module_idP,Srb_info->Srb_id);
-    
+
 #if 0 //defined(ENABLE_ITTI)
     {
       MessageDef *message_p;
@@ -740,7 +741,7 @@ void rrc_out_of_sync_ind(module_id_t Mod_idP, frame_t frameP, uint16_t eNB_index
 	  UE_rrc_inst[Mod_idP].Info[eNB_index].T310_cnt,
 	  UE_rrc_inst[Mod_idP].Info[eNB_index].N310_cnt,
 	  UE_rrc_inst[Mod_idP].Info[eNB_index].N311_cnt);
-  
+
 #if defined(ENABLE_ITTI)
   {
     MessageDef *message_p;
@@ -797,8 +798,8 @@ void mac_eNB_rrc_ul_failure(const module_id_t Mod_instP,
   rrc_mac_remove_ue(Mod_instP,rntiP);
 }
 
-void mac_eNB_rrc_ul_in_sync(const module_id_t Mod_instP, 
-			    const int CC_idP, 
+void mac_eNB_rrc_ul_in_sync(const module_id_t Mod_instP,
+			    const int CC_idP,
 			    const frame_t frameP,
 			    const sub_frame_t subframeP,
 			    const rnti_t rntiP)
diff --git a/openair2/RRC/LITE/defs.h b/openair2/RRC/LITE/defs.h
index cda0815d3310cecc4619d2e29529f3b556860073..ac08000a7b78d0de6205859580cdc66101376369 100644
--- a/openair2/RRC/LITE/defs.h
+++ b/openair2/RRC/LITE/defs.h
@@ -134,11 +134,9 @@ struct PC5SEstablishRsp{
 
 //example of PC5_DSICOVERY ANNOUNCEMENT (for testing only)
 typedef struct  {
-   uint8_t msg_type;
-   uint32_t discoveryGroupId;
-   //AnnouncerInfo
-   uint32_t proSeUEId;
-}  __attribute__((__packed__)) PC5DiscoveryAnnouncement;
+   unsigned char bytes[29];
+}  __attribute__((__packed__)) PC5DiscoveryAnnouncement ;
+
 
 struct sidelink_ctrl_element {
    unsigned short type;
@@ -310,7 +308,7 @@ typedef struct uid_linear_allocator_s {
 
 #define PROTOCOL_RRC_CTXT_FMT           PROTOCOL_CTXT_FMT
 #define PROTOCOL_RRC_CTXT_ARGS(CTXT_Pp) PROTOCOL_CTXT_ARGS(CTXT_Pp)
-/** @defgroup _rrc RRC 
+/** @defgroup _rrc RRC
  * @ingroup _oai2
  * @{
  */
@@ -488,7 +486,7 @@ typedef struct SRB_INFO_TABLE_ENTRY_s {
   SRB_INFO Srb_info;
   uint8_t Active;
   uint8_t Status;
-  uint32_t Next_check_frame; 
+  uint32_t Next_check_frame;
 } SRB_INFO_TABLE_ENTRY;
 
 typedef struct MEAS_REPORT_LIST_s {
diff --git a/openair2/RRC/LITE/proto.h b/openair2/RRC/LITE/proto.h
index 98acfa7fbd750cd5970c2ba540be83a48e668df6..630b65fecd52b49446f8152bfe982582398f97af 100644
--- a/openair2/RRC/LITE/proto.h
+++ b/openair2/RRC/LITE/proto.h
@@ -25,7 +25,7 @@
  * \date 2010 - 2014
  * \email navid.nikaein@eurecom.fr
  * \version 1.0
- 
+
  */
 /** \addtogroup _rrc
  *  @{
@@ -90,7 +90,7 @@ rrc_ue_decode_dcch(
 );
 
 #ifdef Rel14
-int decode_SL_DISCOVERY_Message(
+int decode_SL_Discovery_Message(
   const protocol_ctxt_t* const ctxt_pP,
   const uint8_t                eNB_index,
   uint8_t*               const Sdu,
@@ -291,7 +291,7 @@ rrc_eNB_generate_dedeicatedRRCConnectionReconfiguration(
   const uint8_t                ho_state
 );
 
-void 
+void
 rrc_eNB_reconfigure_DRBs (const protocol_ctxt_t* const ctxt_pP,
 			  rrc_eNB_ue_context_t*  ue_context_pP);
 
@@ -396,14 +396,14 @@ mac_rrc_data_ind(
 
 void mac_sync_ind( module_id_t Mod_instP, uint8_t status);
 
-void mac_eNB_rrc_ul_failure(const module_id_t Mod_instP, 
-			    const int CC_id, 
+void mac_eNB_rrc_ul_failure(const module_id_t Mod_instP,
+			    const int CC_id,
 			    const frame_t frameP,
 			    const sub_frame_t subframeP,
 			    const rnti_t rnti);
 
-void mac_eNB_rrc_ul_in_sync(const module_id_t Mod_instP, 
-			    const int CC_id, 
+void mac_eNB_rrc_ul_in_sync(const module_id_t Mod_instP,
+			    const int CC_id,
 			    const frame_t frameP,
 			    const sub_frame_t subframeP,
 			    const rnti_t rnti);
diff --git a/openair2/RRC/LITE/rrc_UE.c b/openair2/RRC/LITE/rrc_UE.c
index a3c39fdc42a6c1e2431313eea7b680f14aa7e63b..68ded568ce065f9b47976c31b7d6253d65ec5bea 100644
--- a/openair2/RRC/LITE/rrc_UE.c
+++ b/openair2/RRC/LITE/rrc_UE.c
@@ -306,12 +306,12 @@ void init_SL_preconfig(UE_RRC_INST *UE, const uint8_t eNB_index )
   preconfigpool->sc_CP_Len_r12                                                    = SL_CP_Len_r12_normal;
   preconfigpool->sc_Period_r12                                                    = SL_PeriodComm_r12_sf40;
   // 20 PRBs for SL communications
-  preconfigpool->sc_TF_ResourceConfig_r12.prb_Num_r12                             = 20; 
-  preconfigpool->sc_TF_ResourceConfig_r12.prb_Start_r12                           = 5; 
+  preconfigpool->sc_TF_ResourceConfig_r12.prb_Num_r12                             = 20;
+  preconfigpool->sc_TF_ResourceConfig_r12.prb_Start_r12                           = 5;
   preconfigpool->sc_TF_ResourceConfig_r12.prb_End_r12                             = 44;
   // Offset set to 0 subframes
   preconfigpool->sc_TF_ResourceConfig_r12.offsetIndicator_r12.present             = SL_OffsetIndicator_r12_PR_small_r12;
-  preconfigpool->sc_TF_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12    = 0; 
+  preconfigpool->sc_TF_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12    = 0;
   // 40 ms SL Period
   preconfigpool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present              = SubframeBitmapSL_r12_PR_bs40_r12;
   preconfigpool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.buf         = CALLOC(1,5);
@@ -327,12 +327,12 @@ void init_SL_preconfig(UE_RRC_INST *UE, const uint8_t eNB_index )
 
   preconfigpool->data_CP_Len_r12                                                  = SL_CP_Len_r12_normal;
   // 20 PRBs for SL communications
-  preconfigpool->data_TF_ResourceConfig_r12.prb_Num_r12                             = 20; 
-  preconfigpool->data_TF_ResourceConfig_r12.prb_Start_r12                           = 5; 
+  preconfigpool->data_TF_ResourceConfig_r12.prb_Num_r12                             = 20;
+  preconfigpool->data_TF_ResourceConfig_r12.prb_Start_r12                           = 5;
   preconfigpool->data_TF_ResourceConfig_r12.prb_End_r12                             = 44;
   // Offset set to 0 subframes
   preconfigpool->data_TF_ResourceConfig_r12.offsetIndicator_r12.present             = SL_OffsetIndicator_r12_PR_small_r12;
-  preconfigpool->data_TF_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12    = 0; 
+  preconfigpool->data_TF_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12    = 0;
   // 40 ms SL Period
   preconfigpool->data_TF_ResourceConfig_r12.subframeBitmap_r12.present              = SubframeBitmapSL_r12_PR_bs40_r12;
   preconfigpool->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.buf         = CALLOC(1,5);
@@ -368,7 +368,7 @@ void init_SL_preconfig(UE_RRC_INST *UE, const uint8_t eNB_index )
   *(UE->DRB_config[0][0]->eps_BearerIdentity) = 3;
   UE->DRB_config[0][0]->logicalChannelIdentity = CALLOC(1, sizeof(long));
   *(UE->DRB_config[0][0]->logicalChannelIdentity) = UE->DRB_config[0][0]->drb_Identity; //(long) (ue_context_pP->ue_context.e_rab[i].param.e_rab_id + 2); // value : x+2
-  
+
   // TTN - Establish a new SLRB for PC5-S (using DRB 10 for now)
   UE->DRB_config[0][1] = CALLOC(1,sizeof(struct DRB_ToAddMod));
   UE->DRB_config[0][1]->eps_BearerIdentity = CALLOC(1, sizeof(long));
@@ -437,8 +437,8 @@ void init_SL_preconfig(UE_RRC_INST *UE, const uint8_t eNB_index )
 #if defined(Rel10) || defined(Rel14)
                            , (PMCH_InfoList_r9_t *) NULL
 #endif
-                           ,NULL);	   
-  
+                           ,NULL);
+
   rrc_rlc_config_asn1_req(&ctxt,
 			  (SRB_ToAddModList_t*)NULL,
 			  UE->DRB_configList,
@@ -1746,11 +1746,11 @@ rrc_ue_process_radioResourceConfigDedicated(
            NULL
 #endif
 			      );
-	
+
       }
     }
   }
-  
+
   UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].State = RRC_CONNECTED;
   LOG_I(RRC,"[UE %d] State = RRC_CONNECTED (eNB %d)\n",ctxt_pP->module_id,eNB_index);
 #if !defined(ENABLE_USE_MME) && defined(OAI_EMU)
@@ -2335,7 +2335,7 @@ rrc_ue_process_mobilityControlInfo(
            NULL
 #endif
 			);
-  
+
   // Re-establish PDCP for all RBs that are established
   // rrc_pdcp_config_req (ue_mod_idP+NB_eNB_INST, frameP, 0, CONFIG_ACTION_ADD, ue_mod_idP+DCCH);
   // rrc_pdcp_config_req (ue_mod_idP+NB_eNB_INST, frameP, 0, CONFIG_ACTION_ADD, ue_mod_idP+DCCH1);
@@ -3203,7 +3203,7 @@ int decode_SIB1( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_index,
            NULL
 #endif
 			);
-  
+
   UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus = 1;
   UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIB1systemInfoValueTag = sib1->systemInfoValueTag;
 
@@ -3597,7 +3597,7 @@ int Qoffsettab[31] = {-24,-22,-20,-18,-16,-14,-12,-10,-8,-6,-5,-4,-3,-2,-1,0,1,2
 int PhysCellIdRange[16] = {4,8,12,16,24,32,48,64,84,96,128,168,252,504,0,0};
 
 uint64_t arfcn_to_freq(long arfcn) {
-  
+
   if (arfcn < 600)  // Band 1
     return((uint64_t)2110000000 + (arfcn*100000));
   else if (arfcn <1200) // Band 2
@@ -3678,7 +3678,7 @@ uint64_t arfcn_to_freq(long arfcn) {
   InterFreqCarrierFreqInfo_t *ifcfInfo;
 
   LOG_I( RRC, "Dumping SIB5 (see TS36.331 V8.21.0)\n" );
-  
+
   for (i=0;i<interFreqCarrierFreqList.list.count;i++) {
     LOG_I(RRC, "SIB5 InterFreqCarrierFreq element %d/%d\n",i,interFreqCarrierFreqList.list.count);
     ifcfInfo = interFreqCarrierFreqList.list.array[i];
@@ -3732,16 +3732,16 @@ uint64_t arfcn_to_freq(long arfcn) {
     if (ifcfInfo->q_OffsetFreq)
       LOG_I(RRC,"   Q_OffsetFreq : %d\n",Qoffsettab[*ifcfInfo->q_OffsetFreq]);
     if (ifcfInfo->interFreqNeighCellList) {
-      
+
       for (j=0;j<ifcfInfo->interFreqNeighCellList->list.count;j++) {
 	LOG_I(RRC,"   Cell %d\n", j);
 	LOG_I(RRC,"      PhysCellId : %ld\n",ifcfInfo->interFreqNeighCellList->list.array[j]->physCellId);
 	LOG_I(RRC,"      Q_OffsetRange : %ld\n",ifcfInfo->interFreqNeighCellList->list.array[j]->q_OffsetCell);
-	
+
       }
     }
     if (ifcfInfo->interFreqBlackCellList) {
-      
+
       for (j=0;j<ifcfInfo->interFreqBlackCellList->list.count;j++) {
 	LOG_I(RRC,"   Cell %d\n", j);
 	LOG_I(RRC,"      PhysCellId start: %ld\n",ifcfInfo->interFreqBlackCellList->list.array[j]->start);
@@ -3753,16 +3753,16 @@ uint64_t arfcn_to_freq(long arfcn) {
 #if defined(Rel10) || defined(Rel14)
     if (ifcfInfo->ext1 && ifcfInfo->ext1->q_QualMin_r9)
       LOG_I(RRC,"   Q_QualMin_r9 : %ld\n",*ifcfInfo->ext1->q_QualMin_r9);
-    
+
     if (ifcfInfo->ext1 && ifcfInfo->ext1->threshX_Q_r9) {
       LOG_I(RRC,"   threshX_HighQ_r9 : %ld\n",ifcfInfo->ext1->threshX_Q_r9->threshX_HighQ_r9);
       LOG_I(RRC,"   threshX_LowQ_r9: %ld\n",ifcfInfo->ext1->threshX_Q_r9->threshX_LowQ_r9);
     }
 #endif
   }
-  
+
 }
-  
+
 #if defined(Rel10) || defined(Rel14)
  void dump_sib13( SystemInformationBlockType13_r9_t *sib13 )
 {
@@ -3895,9 +3895,9 @@ uint64_t arfcn_to_freq(long arfcn) {
 #endif
 #if !(defined(ENABLE_ITTI) && defined(ENABLE_USE_MME))
 	  rrc_ue_generate_RRCConnectionRequest( ctxt_pP, eNB_index );
-	
+
 #endif
-	
+
 	if (UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].State == RRC_IDLE) {
 	  LOG_I( RRC, "[UE %d] Received SIB1/SIB2/SIB3 Switching to RRC_SI_RECEIVED\n", ctxt_pP->module_id );
 	  UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].State = RRC_SI_RECEIVED;
@@ -3905,7 +3905,7 @@ uint64_t arfcn_to_freq(long arfcn) {
 	  {
 	    MessageDef                            *message_ral_p = NULL;
 	    rrc_ral_system_information_ind_t       ral_si_ind;
-	    
+
 	    message_ral_p = itti_alloc_new_message (TASK_RRC_UE, RRC_RAL_SYSTEM_INFORMATION_IND);
 	    memset(&ral_si_ind, 0, sizeof(rrc_ral_system_information_ind_t));
 	    ral_si_ind.plmn_id.MCCdigit2 = '0';
@@ -3957,7 +3957,7 @@ uint64_t arfcn_to_freq(long arfcn) {
       if ((UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus&16) == 0) {
 	UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus|=16;
 	new_sib=1;
-     
+
 	memcpy( UE_rrc_inst[ctxt_pP->module_id].sib5[eNB_index], &typeandinfo->choice.sib5, sizeof(SystemInformationBlockType5_t) );
 	LOG_I( RRC, "[UE %"PRIu8"] Frame %"PRIu32" Found SIB5 from eNB %"PRIu8"\n", ctxt_pP->module_id, ctxt_pP->frame, eNB_index );
 	dump_sib5(UE_rrc_inst[ctxt_pP->module_id].sib5[eNB_index]);
@@ -3968,7 +3968,7 @@ uint64_t arfcn_to_freq(long arfcn) {
       if ((UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus&32) == 0) {
 	UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus|=32;
 	new_sib=1;
-     
+
 	memcpy( UE_rrc_inst[ctxt_pP->module_id].sib6[eNB_index], &typeandinfo->choice.sib6, sizeof(SystemInformationBlockType6_t) );
 	LOG_I( RRC, "[UE %"PRIu8"] Frame %"PRIu32" Found SIB6 from eNB %"PRIu8"\n", ctxt_pP->module_id, ctxt_pP->frame, eNB_index );
       }
@@ -3996,7 +3996,7 @@ uint64_t arfcn_to_freq(long arfcn) {
       if ((UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus&256) == 0) {
 	UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus|=256;
 	new_sib=1;
-      
+
 	memcpy( UE_rrc_inst[ctxt_pP->module_id].sib9[eNB_index], &typeandinfo->choice.sib9, sizeof(SystemInformationBlockType9_t) );
 	LOG_I( RRC, "[UE %"PRIu8"] Frame %"PRIu32" Found SIB9 from eNB %"PRIu8"\n", ctxt_pP->module_id, ctxt_pP->frame, eNB_index );
       }
@@ -4031,12 +4031,12 @@ uint64_t arfcn_to_freq(long arfcn) {
 	LOG_I( RRC, "[UE %"PRIu8"] Frame %"PRIu32" Found SIB12 from eNB %"PRIu8"\n", ctxt_pP->module_id, ctxt_pP->frame, eNB_index );
       }
       break;
-	
+
     case SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib13_v920:
       if ((UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus&4096) == 0) {
 	UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus|=4096;
 	new_sib=1;
-	
+
 	memcpy( UE_rrc_inst[ctxt_pP->module_id].sib13[eNB_index], &typeandinfo->choice.sib13_v920, sizeof(SystemInformationBlockType13_r9_t) );
 	LOG_I( RRC, "[UE %"PRIu8"] Frame %"PRIu32" Found SIB13 from eNB %"PRIu8"\n", ctxt_pP->module_id, ctxt_pP->frame, eNB_index );
 	dump_sib13( UE_rrc_inst[ctxt_pP->module_id].sib13[eNB_index] );
@@ -4135,7 +4135,7 @@ uint64_t arfcn_to_freq(long arfcn) {
     if (UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIcnt == sib1->schedulingInfoList.list.count)
       rrc_set_sub_state( ctxt_pP->module_id, RRC_SUB_STATE_IDLE_SIB_COMPLETE );
 
-    LOG_I(RRC,"SIStatus %x, SIcnt %d/%d\n", 
+    LOG_I(RRC,"SIStatus %x, SIcnt %d/%d\n",
 	  UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus,
 	  UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIcnt,
 	  sib1->schedulingInfoList.list.count);
@@ -4576,7 +4576,7 @@ int decode_MCCH_Message( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB
            NULL
 #endif
 			);
-  
+
   UE_rrc_inst[ue_mod_idP].Info[eNB_index].MCCHStatus[mbsfn_sync_area] = 1;
 
   PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, ue_mod_idP, ENB_FLAG_NO, UE_rrc_inst[ue_mod_idP].Info[eNB_index].rnti, frameP, 0,eNB_index);
@@ -4909,7 +4909,7 @@ void *rrc_ue_task( void *args_p )
       /* Transfer data to PDCP */
       PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, ue_mod_id, ENB_FLAG_NO, UE_rrc_inst[ue_mod_id].Info[0].rnti, 0, 0,0);
 
-      // check if SRB2 is created, if yes request data_req on DCCH1 (SRB2) 
+      // check if SRB2 is created, if yes request data_req on DCCH1 (SRB2)
       if(UE_rrc_inst[ue_mod_id].SRB2_config[0] == NULL)
       {
           rrc_data_req (&ctxt,
@@ -4930,7 +4930,7 @@ void *rrc_ue_task( void *args_p )
       }
       break;
     }
-      
+
 # endif
 
 # if ENABLE_RAL
@@ -5166,7 +5166,7 @@ rrc_top_cleanup_ue(
 {
 
   if (NB_UE_INST > 0) free (UE_rrc_inst);
-  
+
 
 }
 
@@ -5806,14 +5806,16 @@ void *rrc_control_socket_thread_fct(void *arg)
 
  #ifdef DEBUG_CTRL_SOCKET
            LOG_I(RRC,"[PC5DiscoveryAnnouncement] Received on socket from ProSe App (msg type: %d)\n",sl_ctrl_msg_recv->type);
-           LOG_I(RRC,"[PC5DiscoveryAnnouncement] type: %d\n",sl_ctrl_msg_recv->sidelinkPrimitive.pc5_discovery_announcement.msg_type);
-           LOG_I(RRC,"[PC5DiscoveryAnnouncement] discoveryGroupId: 0x%08x\n",sl_ctrl_msg_recv->sidelinkPrimitive.pc5_discovery_announcement.discoveryGroupId);
-           LOG_I(RRC,"[PC5DiscoveryAnnouncement] proSeUEId: 0x%08x\n",sl_ctrl_msg_recv->sidelinkPrimitive.pc5_discovery_announcement.proSeUEId);
+        //   LOG_I(RRC,"[PC5DiscoveryAnnouncement] type: %d\n",sl_ctrl_msg_recv->sidelinkPrimitive.pc5_discovery_announcement.msg_type);
+        //   LOG_D(RRC,"[PC5DiscoveryAnnouncement] discoveryGroupId: 0x%08x\n",sl_ctrl_msg_recv->sidelinkPrimitive.pc5_discovery_announcement.discoveryGroupId);
+        //   LOG_D(RRC,"[PC5DiscoveryAnnouncement] proSeUEId: 0x%08x\n",sl_ctrl_msg_recv->sidelinkPrimitive.pc5_discovery_announcement.proSeUEId);
  #endif
         //prepare SL_Discovery buffer
-         memcpy((void*)&UE_rrc_inst[module_id].SL_Discovery[0].Tx_buffer.Payload[0], (void*)receive_buf, n);
-         UE_rrc_inst[module_id].SL_Discovery[0].Tx_buffer.payload_size = n;
-
+         if (UE_rrc_inst) {
+           memcpy((void*)&UE_rrc_inst[module_id].SL_Discovery[0].Tx_buffer.Payload[0], (void*)receive_buf, n);
+           UE_rrc_inst[module_id].SL_Discovery[0].Tx_buffer.payload_size = n;
+           LOG_I(RRC,"[PC5DiscoveryAnnouncement] Copied %d bytes\n",n);
+         }
          break;
       default:
          break;
@@ -5825,7 +5827,7 @@ void *rrc_control_socket_thread_fct(void *arg)
 
 
 //-----------------------------------------------------------------------------
-int decode_SL_DISCOVERY_Message(
+int decode_SL_Discovery_Message(
   const protocol_ctxt_t* const ctxt_pP,
   const uint8_t                eNB_index,
   uint8_t*               const Sdu,
diff --git a/targets/RT/USER/lte-ue.c b/targets/RT/USER/lte-ue.c
index af39b5bdb61554914de0d6ec0c107894bd11e0f1..2cfaac41604e39d6656215593e00667b0ccd7c69 100644
--- a/targets/RT/USER/lte-ue.c
+++ b/targets/RT/USER/lte-ue.c
@@ -162,7 +162,7 @@ PHY_VARS_UE* init_ue_vars(LTE_DL_FRAME_PARMS *frame_parms,
     ue = (PHY_VARS_UE *)malloc(sizeof(PHY_VARS_UE));
     memset(ue,0,sizeof(PHY_VARS_UE));
     memcpy(&(ue->frame_parms), frame_parms, sizeof(LTE_DL_FRAME_PARMS));
-  }					
+  }
   else ue = PHY_vars_UE_g[UE_id][0];
 
 
@@ -229,11 +229,11 @@ void init_UE(int nb_inst,int eMBMS_active, int uecap_xer_in) {
   int         ret;
 
   LOG_I(PHY,"UE : Calling Layer 2 for initialization\n");
-    
+
   l2_init_ue(eMBMS_active,(uecap_xer_in==1)?uecap_xer:NULL,
 	     0,// cba_group_active
 	     0); // HO flag
-  
+
   for (inst=0;inst<nb_inst;inst++) {
 
     LOG_I(PHY,"Initializing memory for UE instance %d (%p)\n",inst,PHY_vars_UE_g[inst]);
@@ -331,7 +331,7 @@ static void *UE_thread_synch(void *arg)
   // this thread priority must be lower that the main acquisition thread
   sprintf(threadname, "sync UE %d\n", UE->Mod_id);
   init_thread(100000, 500000, FIFO_PRIORITY-1, &cpuset, threadname);
-  
+
   printf("starting UE synch thread (IC %d)\n",UE->proc.instance_cnt_synch);
   ind = 0;
   found = 0;
@@ -352,7 +352,7 @@ static void *UE_thread_synch(void *arg)
 
       ind++;
     } while (ind < sizeof(eutra_bands) / sizeof(eutra_bands[0]));
-  
+
     if (found == 0) {
       exit_fun("Can't find EUTRA band for frequency");
       return &UE_thread_synch_retval;
@@ -365,7 +365,7 @@ static void *UE_thread_synch(void *arg)
       openair0_cfg[UE->rf_map.card].rx_freq[UE->rf_map.chain+i] = UE->frame_parms.dl_CarrierFreq;
       openair0_cfg[UE->rf_map.card].tx_freq[UE->rf_map.chain+i] = UE->frame_parms.ul_CarrierFreq;
       openair0_cfg[UE->rf_map.card].autocal[UE->rf_map.chain+i] = 1;
-      if (uplink_frequency_offset[CC_id][i] != 0) // 
+      if (uplink_frequency_offset[CC_id][i] != 0) //
 	openair0_cfg[UE->rf_map.card].duplex_mode = duplex_mode_FDD;
       else //FDD
 	openair0_cfg[UE->rf_map.card].duplex_mode = duplex_mode_TDD;
@@ -387,15 +387,15 @@ static void *UE_thread_synch(void *arg)
     }
   }
 
-  while (sync_var<0)     
-    pthread_cond_wait(&sync_cond, &sync_mutex);   
-  pthread_mutex_unlock(&sync_mutex);   
+  while (sync_var<0)
+    pthread_cond_wait(&sync_cond, &sync_mutex);
+  pthread_mutex_unlock(&sync_mutex);
 
-  printf("Started device, unlocked sync_mutex (UE_sync_thread)\n");   
+  printf("Started device, unlocked sync_mutex (UE_sync_thread)\n");
 
-  if (UE->rfdevice.trx_start_func(&UE->rfdevice) != 0 ) {     
-    LOG_E(HW,"Could not start the device\n");     
-    oai_exit=1;   
+  if (UE->rfdevice.trx_start_func(&UE->rfdevice) != 0 ) {
+    LOG_E(HW,"Could not start the device\n");
+    oai_exit=1;
   }
 
   while (oai_exit==0) {
@@ -404,13 +404,13 @@ static void *UE_thread_synch(void *arg)
       // the thread waits here most of the time
       pthread_cond_wait( &UE->proc.cond_synch, &UE->proc.mutex_synch );
     AssertFatal ( 0== pthread_mutex_unlock(&UE->proc.mutex_synch), "");
-    
+
     switch (sync_mode) {
     case pss:
       LOG_I(PHY,"[SCHED][UE] Scanning band %d (%d), freq %u\n",bands_to_scan.band_info[current_band].band, current_band,bands_to_scan.band_info[current_band].dl_min+current_offset);
       lte_sync_timefreq(UE,current_band,bands_to_scan.band_info[current_band].dl_min+current_offset);
       current_offset += 20000000; // increase by 20 MHz
-      
+
       if (current_offset > bands_to_scan.band_info[current_band].dl_max-bands_to_scan.band_info[current_band].dl_min) {
 	current_band++;
 	current_offset=0;
@@ -434,7 +434,7 @@ static void *UE_thread_synch(void *arg)
       }
 
       break;
- 
+
     case pbch:
 
 #if DISABLE_LOG_X
@@ -770,8 +770,8 @@ void ue_stub_rx_handler(unsigned int num_bytes, char *rx_buffer) {
     wakeup_thread(&UE->timer_mutex,&UE->timer_cond,&UE->instance_cnt_timer,"timer_thread");
     break;
   case SLSCH:
-    
-    
+
+
     LOG_I(PHY,"Emulator SFN.SF %d.%d, Got SLSCH packet\n",emulator_absSF/10,emulator_absSF%10);
     LOG_I(PHY,"Received %d bytes on UE-UE link for SFN.SF %d.%d, sending SLSCH payload (%d bytes) to MAC\n",num_bytes,
 	  pdu->header.absSF/10,pdu->header.absSF%10,
@@ -779,7 +779,7 @@ void ue_stub_rx_handler(unsigned int num_bytes, char *rx_buffer) {
     printf("SLSCH:");
     for (int i=0;i<sizeof(SLSCH_t);i++) printf("%x ",((uint8_t*)slsch)[i]);
     printf("\n");
-    
+
     ue_send_sl_sdu(0,
 		   0,
 		   pdu->header.absSF/10,
@@ -980,9 +980,9 @@ static void *UE_phy_stub_thread_rxn_txnp4(void *arg) {
     stop_meas(&UE->generic_stat);
 #endif
 
-	
+
     // Prepare the future Tx data
-	
+
     if ((subframe_select( &UE->frame_parms, proc->subframe_tx) == SF_UL) ||
 	(UE->frame_parms.frame_type == FDD) )
       if (UE->mode != loop_through_memory){
@@ -1473,14 +1473,14 @@ int setup_ue_buffers(PHY_VARS_UE **phy_vars_ue, openair0_config_t *openair0_cfg)
 
   for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
     rf_map = &phy_vars_ue[CC_id]->rf_map;
-      
+
     AssertFatal( phy_vars_ue[CC_id] !=0, "");
     frame_parms = &(phy_vars_ue[CC_id]->frame_parms);
-      
+
     // replace RX signal buffers with mmaped HW versions
     rxdata = (int32_t**)malloc16( frame_parms->nb_antennas_rx*sizeof(int32_t*) );
     txdata = (int32_t**)malloc16( frame_parms->nb_antennas_tx*sizeof(int32_t*) );
-      
+
     for (i=0; i<frame_parms->nb_antennas_rx; i++) {
       LOG_I(PHY, "Mapping UE CC_id %d, rx_ant %d, freq %u on card %d, chain %d\n",
 	    CC_id, i, downlink_frequency[CC_id][i], rf_map->card, rf_map->chain+i );
@@ -1488,7 +1488,7 @@ int setup_ue_buffers(PHY_VARS_UE **phy_vars_ue, openair0_config_t *openair0_cfg)
       rxdata[i] = (int32_t*)malloc16_clear( 307200*sizeof(int32_t) );
       phy_vars_ue[CC_id]->common_vars.rxdata[i] = rxdata[i]; // what about the "-N_TA_offset" ? // N_TA offset for TDD
     }
-		
+
     for (i=0; i<frame_parms->nb_antennas_tx; i++) {
       LOG_I(PHY, "Mapping UE CC_id %d, tx_ant %d, freq %u on card %d, chain %d\n",
 	    CC_id, i, downlink_frequency[CC_id][i], rf_map->card, rf_map->chain+i );
@@ -1496,7 +1496,7 @@ int setup_ue_buffers(PHY_VARS_UE **phy_vars_ue, openair0_config_t *openair0_cfg)
       txdata[i] = (int32_t*)malloc16_clear( 307200*sizeof(int32_t) );
       phy_vars_ue[CC_id]->common_vars.txdata[i] = txdata[i];
     }
-      
+
     // rxdata[x] points now to the same memory region as phy_vars_ue[CC_id]->common_vars.rxdata[x]
     // txdata[x] points now to the same memory region as phy_vars_ue[CC_id]->common_vars.txdata[x]
     // be careful when releasing memory!
@@ -1520,7 +1520,7 @@ static void* timer_thread( void* param ) {
   UE = PHY_vars_UE_g[0][0];
   double t_diff;
   int external_timer = 0;
-  
+
   wait_sync("timer_thread");
 
   //pthread_mutex_init(&phy_stub_ticking->mutex_ticking,NULL);
@@ -1582,10 +1582,10 @@ static void* timer_thread( void* param ) {
       UE_tport_t pdu;
       pdu.header.packet_type = TTI_SYNC;
       pdu.header.absSF = (timer_frame*10)+timer_subframe;
-      multicast_link_write_sock(0, 
-				&pdu, 
+      multicast_link_write_sock(0,
+				&pdu,
 				sizeof(UE_tport_header_t));
-    
+
     }
     else {
       wait_on_condition(&UE->timer_mutex,&UE->timer_cond,&UE->instance_cnt_timer,"timer_thread");
@@ -1640,11 +1640,3 @@ int init_timer_thread(void) {
   pthread_create(&phy_stub_ticking->pthread_timer, NULL, &timer_thread, NULL);
   return 0;
 }
-
-
-
-
-
-
-
-