diff --git a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c
index f875264967404c4a1e5e9fca7d7c61def84834a3..230917f673e33af455b864cd06d4cd50b56fd4b8 100644
--- a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c
+++ b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c
@@ -670,7 +670,7 @@ int flexran_agent_mac_destroy_stats_reply(Protocol__FlexranMessage *msg) {
 }
 
 int flexran_agent_mac_sr_info(mid_t mod_id, const void *params, Protocol__FlexranMessage **msg) {
-  Protocol__FlexHeader *header;
+  Protocol__FlexHeader *header = NULL;
   int i;
   const int xid = *((int *)params);
 
@@ -738,7 +738,7 @@ int flexran_agent_mac_destroy_sr_info(Protocol__FlexranMessage *msg) {
 }
 
 int flexran_agent_mac_sf_trigger(mid_t mod_id, const void *params, Protocol__FlexranMessage **msg) {
-  Protocol__FlexHeader *header;
+  Protocol__FlexHeader *header = NULL;
   int i, j, UE_id;
   
   int available_harq[NUMBER_OF_UE_MAX];
@@ -954,7 +954,7 @@ int flexran_agent_mac_destroy_sf_trigger(Protocol__FlexranMessage *msg) {
 int flexran_agent_mac_create_empty_dl_config(mid_t mod_id, Protocol__FlexranMessage **msg) {
 
   int xid = 0;
-  Protocol__FlexHeader *header;
+  Protocol__FlexHeader *header = NULL;
   if (flexran_create_header(xid, PROTOCOL__FLEX_TYPE__FLPT_DL_MAC_CONFIG, &header) != 0)
     goto error;
 
@@ -1049,7 +1049,7 @@ int flexran_agent_mac_destroy_dl_config(Protocol__FlexranMessage *msg) {
 int flexran_agent_mac_create_empty_ul_config(mid_t mod_id, Protocol__FlexranMessage **msg) {
 
   int xid = 0;
-  Protocol__FlexHeader *header;
+  Protocol__FlexHeader *header = NULL;
   if (flexran_create_header(xid, PROTOCOL__FLEX_TYPE__FLPT_UL_MAC_CONFIG, &header) != 0)
     goto error;
 
diff --git a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_internal.c b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_internal.c
index b7a93b849165cd39679b9c96fb7fbdaffe3755e3..2acee0686f62165881d256e96eb09500274d0a30 100644
--- a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_internal.c
+++ b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_internal.c
@@ -101,7 +101,7 @@ Protocol__FlexranMessage * flexran_agent_generate_diff_mac_stats_report(Protocol
   if (n_cell_report > 0 || n_ue_report > 0) {
     /*Create header*/
     int xid = old_report->header->xid;
-    Protocol__FlexHeader *header;
+    Protocol__FlexHeader *header = NULL;
     if (flexran_create_header(xid, PROTOCOL__FLEX_TYPE__FLPT_STATS_REPLY, &header) != 0) {
     goto error;
     }
diff --git a/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c b/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c
index 590e9c870f8b6c72915959e76631d892670398d6..e88c4eaccfaa773eb98fcc7f5a3e2bb466f15d46 100644
--- a/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c
+++ b/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c
@@ -45,8 +45,8 @@ AGENT_RRC_xface *agent_rrc_xface[NUM_MAX_ENB];
 
 void flexran_agent_ue_state_change(mid_t mod_id, uint32_t rnti, uint8_t state_change) {
   int size;
-  Protocol__FlexranMessage *msg;
-  Protocol__FlexHeader *header;
+  Protocol__FlexranMessage *msg = NULL;
+  Protocol__FlexHeader *header = NULL;
   void *data;
   int priority = 0;
   err_code_t err_code;
diff --git a/openair2/ENB_APP/flexran_agent_common.c b/openair2/ENB_APP/flexran_agent_common.c
index f837d575d5cac1da5bf77481db700c599f66da93..2df59598155162a2bbab309c014cbc7660229c3b 100644
--- a/openair2/ENB_APP/flexran_agent_common.c
+++ b/openair2/ENB_APP/flexran_agent_common.c
@@ -106,7 +106,7 @@ int flexran_create_header(xid_t xid, Protocol__FlexType type,  Protocol__FlexHea
 
 int flexran_agent_hello(mid_t mod_id, const void *params, Protocol__FlexranMessage **msg) {
  
-  Protocol__FlexHeader *header;
+  Protocol__FlexHeader *header = NULL;
   /*TODO: Need to set random xid or xid from received hello message*/
   xid_t xid = 1;
 
@@ -161,7 +161,7 @@ int flexran_agent_destroy_hello(Protocol__FlexranMessage *msg) {
 
 
 int flexran_agent_echo_request(mid_t mod_id, const void* params, Protocol__FlexranMessage **msg) {
-  Protocol__FlexHeader *header;
+  Protocol__FlexHeader *header = NULL;
   /*TODO: Need to set a random xid*/
   xid_t xid = 1;
 
@@ -216,6 +216,7 @@ int flexran_agent_destroy_echo_request(Protocol__FlexranMessage *msg) {
 int flexran_agent_echo_reply(mid_t mod_id, const void *params, Protocol__FlexranMessage **msg) {
   
   xid_t xid;
+  Protocol__FlexHeader *header = NULL;
   Protocol__FlexranMessage *input = (Protocol__FlexranMessage *)params;
   Protocol__FlexEchoRequest *echo_req = input->echo_request_msg;
   xid = (echo_req->header)->xid;
@@ -226,7 +227,6 @@ int flexran_agent_echo_reply(mid_t mod_id, const void *params, Protocol__Flexran
     goto error;
   protocol__flex_echo_reply__init(echo_reply_msg);
 
-  Protocol__FlexHeader *header;
   if (flexran_create_header(xid, PROTOCOL__FLEX_TYPE__FLPT_ECHO_REPLY, &header) != 0)
     goto error;
 
@@ -429,6 +429,7 @@ int flexran_agent_destroy_agent_reconfiguration(Protocol__FlexranMessage *msg) {
 int flexran_agent_lc_config_reply(mid_t mod_id, const void *params, Protocol__FlexranMessage **msg) {
 
   xid_t xid;
+  Protocol__FlexHeader *header = NULL;
   Protocol__FlexranMessage *input = (Protocol__FlexranMessage *)params;
   Protocol__FlexLcConfigRequest *lc_config_request_msg = input->lc_config_request_msg;
   xid = (lc_config_request_msg->header)->xid;
@@ -441,7 +442,6 @@ int flexran_agent_lc_config_reply(mid_t mod_id, const void *params, Protocol__Fl
     goto error;
   protocol__flex_lc_config_reply__init(lc_config_reply_msg);
 
-  Protocol__FlexHeader *header;
   if(flexran_create_header(xid, PROTOCOL__FLEX_TYPE__FLPT_GET_LC_CONFIG_REPLY, &header) != 0)
     goto error;
 
@@ -557,6 +557,7 @@ int flexran_agent_lc_config_reply(mid_t mod_id, const void *params, Protocol__Fl
 int flexran_agent_ue_config_reply(mid_t mod_id, const void *params, Protocol__FlexranMessage **msg) {
 
   xid_t xid;
+  Protocol__FlexHeader *header = NULL;
   Protocol__FlexranMessage *input = (Protocol__FlexranMessage *)params;
   Protocol__FlexUeConfigRequest *ue_config_request_msg = input->ue_config_request_msg;
   xid = (ue_config_request_msg->header)->xid;
@@ -569,7 +570,6 @@ int flexran_agent_ue_config_reply(mid_t mod_id, const void *params, Protocol__Fl
     goto error;
   protocol__flex_ue_config_reply__init(ue_config_reply_msg);
 
-  Protocol__FlexHeader *header;
   if(flexran_create_header(xid, PROTOCOL__FLEX_TYPE__FLPT_GET_UE_CONFIG_REPLY, &header) != 0)
     goto error;
 
@@ -762,7 +762,7 @@ int flexran_agent_ue_config_reply(mid_t mod_id, const void *params, Protocol__Fl
 
 int flexran_agent_enb_config_request(mid_t mod_id, const void* params, Protocol__FlexranMessage **msg) {
 
-	Protocol__FlexHeader *header;
+	Protocol__FlexHeader *header = NULL;
 	xid_t xid = 1;
 
 	Protocol__FlexEnbConfigRequest *enb_config_request_msg;
@@ -801,6 +801,7 @@ int flexran_agent_enb_config_request(mid_t mod_id, const void* params, Protocol_
 int flexran_agent_enb_config_reply(mid_t mod_id, const void *params, Protocol__FlexranMessage **msg) {
 
   xid_t xid;
+  Protocol__FlexHeader *header = NULL;
   Protocol__FlexranMessage *input = (Protocol__FlexranMessage *)params;
   Protocol__FlexEnbConfigRequest *enb_config_req_msg = input->enb_config_request_msg;
   xid = (enb_config_req_msg->header)->xid;
@@ -814,7 +815,6 @@ int flexran_agent_enb_config_reply(mid_t mod_id, const void *params, Protocol__F
     goto error;
   protocol__flex_enb_config_reply__init(enb_config_reply_msg);
 
-  Protocol__FlexHeader *header;
   if(flexran_create_header(xid, PROTOCOL__FLEX_TYPE__FLPT_GET_ENB_CONFIG_REPLY, &header) != 0)
     goto error;
   
diff --git a/openair2/ENB_APP/flexran_agent_handler.c b/openair2/ENB_APP/flexran_agent_handler.c
index 3597463ae369c2aee14d36e07a81b24dacd1ce92..6c20c635a19365df6e6541306c88b2ab0fbe57c2 100644
--- a/openair2/ENB_APP/flexran_agent_handler.c
+++ b/openair2/ENB_APP/flexran_agent_handler.c
@@ -393,7 +393,7 @@ int flexran_agent_handle_stats(mid_t mod_id, const void *params, Protocol__Flexr
 
 int flexran_agent_stats_reply(mid_t enb_id, xid_t xid, const report_config_t *report_config, Protocol__FlexranMessage **msg){
 
-  Protocol__FlexHeader *header;
+  Protocol__FlexHeader *header = NULL;
   err_code_t err_code;
   int i;
 
@@ -514,7 +514,7 @@ int flexran_agent_stats_request(mid_t mod_id,
             xid_t xid,
             const stats_request_config_t *report_config,
             Protocol__FlexranMessage **msg) {
-  Protocol__FlexHeader *header;
+  Protocol__FlexHeader *header = NULL;
   int i;
 
   Protocol__FlexStatsRequest *stats_request_msg;