diff --git a/openair-cn/NAS/EURECOM-NAS/src/emm/Attach.c b/openair-cn/NAS/EURECOM-NAS/src/emm/Attach.c
index 95f8c23f3d5661032b5ab168772345d2b5487695..d78308b91f08151029b584ccaeb073004d3f2021 100644
--- a/openair-cn/NAS/EURECOM-NAS/src/emm/Attach.c
+++ b/openair-cn/NAS/EURECOM-NAS/src/emm/Attach.c
@@ -1652,6 +1652,7 @@ static int _emm_attach_release(void *args)
         emm_sap_t emm_sap;
         emm_sap.primitive = EMMREG_PROC_ABORT;
         emm_sap.u.emm_reg.ueid = ueid;
+        emm_sap.u.emm_reg.ctx  = emm_ctx;
         rc = emm_sap_send(&emm_sap);
     }
 
diff --git a/openair-cn/S1AP/s1ap_mme_itti_messaging.c b/openair-cn/S1AP/s1ap_mme_itti_messaging.c
index e30d4afb99c7e064639a86cbece164891b79b4ed..f1d8d692a6a52c8a1d36afebac904c7e937905c2 100644
--- a/openair-cn/S1AP/s1ap_mme_itti_messaging.c
+++ b/openair-cn/S1AP/s1ap_mme_itti_messaging.c
@@ -59,13 +59,15 @@ int s1ap_mme_itti_nas_uplink_ind(const uint32_t ue_id, uint8_t * const buffer,
     return itti_send_msg_to_task(TASK_NAS, INSTANCE_DEFAULT, message_p);
 }
 
-int s1ap_mme_itti_nas_downlink_cnf(const uint32_t ue_id)
+int s1ap_mme_itti_nas_downlink_cnf(const uint32_t ue_id,
+                                   nas_error_code_t error_code)
 {
     MessageDef *message_p;
 
     message_p = itti_alloc_new_message(TASK_S1AP, NAS_DOWNLINK_DATA_CNF);
 
     NAS_DL_DATA_CNF(message_p).UEid = ue_id;
+    NAS_DL_DATA_CNF(message_p).errCode = error_code;
 
     return itti_send_msg_to_task(TASK_NAS, INSTANCE_DEFAULT, message_p);
 }
diff --git a/openair-cn/S1AP/s1ap_mme_itti_messaging.h b/openair-cn/S1AP/s1ap_mme_itti_messaging.h
index b099c3c7646d911b08e87d1f51ab5dc4236a5415..38e30f6a90cd1902246fccb24ae685cbf7962f0f 100644
--- a/openair-cn/S1AP/s1ap_mme_itti_messaging.h
+++ b/openair-cn/S1AP/s1ap_mme_itti_messaging.h
@@ -41,6 +41,7 @@ int s1ap_mme_itti_send_sctp_request(uint8_t *buffer, uint32_t length,
 int s1ap_mme_itti_nas_uplink_ind(const uint32_t ue_id, uint8_t * const buffer,
                                  const uint32_t length);
 
-int s1ap_mme_itti_nas_downlink_cnf(const uint32_t ue_id);
+int s1ap_mme_itti_nas_downlink_cnf(const uint32_t ue_id,
+                                   nas_error_code_t error_code);
 
 #endif /* S1AP_MME_ITTI_MESSAGING_H_ */
diff --git a/openair-cn/S1AP/s1ap_mme_nas_procedures.c b/openair-cn/S1AP/s1ap_mme_nas_procedures.c
index d68a6dd8ba0348c15a67cc798ee563a5388d559d..b849e98f11220a93b6cd27aa1a4a81b11f78d496 100644
--- a/openair-cn/S1AP/s1ap_mme_nas_procedures.c
+++ b/openair-cn/S1AP/s1ap_mme_nas_procedures.c
@@ -256,7 +256,7 @@ int s1ap_generate_downlink_nas_transport(const uint32_t ue_id, void * const data
         s1ap_mme_itti_send_sctp_request(buffer_p, length,
                                         ue_ref->eNB->sctp_assoc_id,
                                         ue_ref->sctp_stream_send);
-        s1ap_mme_itti_nas_downlink_cnf(ue_ref->mme_ue_s1ap_id);
+        s1ap_mme_itti_nas_downlink_cnf(ue_ref->mme_ue_s1ap_id, AS_SUCCESS);
     }
     return 0;
 }
diff --git a/openair2/COMMON/as_message.h b/openair2/COMMON/as_message.h
index 7158f1b0334f94d14dcc62783fefd8ed35e25712..7c8c715dd7b2bd4f513279c38c1383d1c08b3798 100644
--- a/openair2/COMMON/as_message.h
+++ b/openair2/COMMON/as_message.h
@@ -196,7 +196,7 @@ typedef struct cell_info_req_s {
  * is selected to camp on.
  */
 typedef struct cell_info_cnf_s {
-    UInt8_t errCode;	/* Error code					  */
+    UInt8_t errCode;    /* Error code                     */
     ci_t cellID;    /* Identity of the cell serving the selected PLMN */
     tac_t tac;      /* Code of the tracking area the cell belongs to  */
     AcT_t rat;      /* Radio access technology supported by the cell  */
@@ -242,7 +242,7 @@ typedef struct paging_req_s {
  * AS reports to the NAS that appropriate procedure has to be initiated.
  */
 typedef struct paging_ind_s {
-    UInt8_t cause;  /* Paging cause                 */
+    paging_cause_t cause;  /* Paging cause                 */
 } paging_ind_t;
 
 /*
@@ -252,20 +252,23 @@ typedef struct paging_ind_s {
  */
 
 /* Cause of RRC connection establishment */
-#define AS_CAUSE_EMERGENCY      (NET_ESTABLISH_CAUSE_EMERGENCY)
-#define AS_CAUSE_HIGH_PRIO      (NET_ESTABLISH_CAUSE_HIGH_PRIO)
-#define AS_CAUSE_MT_ACCESS      (NET_ESTABLISH_CAUSE_MT_ACCESS)
-#define AS_CAUSE_MO_SIGNAL      (NET_ESTABLISH_CAUSE_MO_SIGNAL)
-#define AS_CAUSE_MO_DATA        (NET_ESTABLISH_CAUSE_MO_DATA)
-#define AS_CAUSE_V1020          (NET_ESTABLISH_CAUSE_V1020)
+typedef enum as_cause_s {
+    AS_CAUSE_EMERGENCY  = NET_ESTABLISH_CAUSE_EMERGENCY,
+    AS_CAUSE_HIGH_PRIO  = NET_ESTABLISH_CAUSE_HIGH_PRIO,
+    AS_CAUSE_MT_ACCESS  = NET_ESTABLISH_CAUSE_MT_ACCESS,
+    AS_CAUSE_MO_SIGNAL  = NET_ESTABLISH_CAUSE_MO_SIGNAL,
+    AS_CAUSE_MO_DATA    = NET_ESTABLISH_CAUSE_MO_DATA,
+    AS_CAUSE_V1020      = NET_ESTABLISH_CAUSE_V1020
+} as_cause_t;
 
 /* Type of the call associated to the RRC connection establishment */
-#define AS_TYPE_ORIGINATING_SIGNAL  (NET_ESTABLISH_TYPE_ORIGINATING_SIGNAL)
-#define AS_TYPE_EMERGENCY_CALLS     (NET_ESTABLISH_TYPE_EMERGENCY_CALLS)
-#define AS_TYPE_ORIGINATING_CALLS   (NET_ESTABLISH_TYPE_ORIGINATING_CALLS)
-#define AS_TYPE_TERMINATING_CALLS   (NET_ESTABLISH_TYPE_TERMINATING_CALLS)
-#define AS_TYPE_MO_CS_FALLBACK      (NET_ESTABLISH_TYPE_MO_CS_FALLBACK)
-
+typedef enum as_call_type_s {
+    AS_TYPE_ORIGINATING_SIGNAL  = NET_ESTABLISH_TYPE_ORIGINATING_SIGNAL,
+    AS_TYPE_EMERGENCY_CALLS     = NET_ESTABLISH_TYPE_EMERGENCY_CALLS,
+    AS_TYPE_ORIGINATING_CALLS   = NET_ESTABLISH_TYPE_ORIGINATING_CALLS,
+    AS_TYPE_TERMINATING_CALLS   = NET_ESTABLISH_TYPE_TERMINATING_CALLS,
+    AS_TYPE_MO_CS_FALLBACK      = NET_ESTABLISH_TYPE_MO_CS_FALLBACK
+} as_call_type_t;
 
 /*
  * NAS->AS - NAS signalling connection establishment request
@@ -273,11 +276,11 @@ typedef struct paging_ind_s {
  * to transfer initial NAS message to the network while UE is in IDLE mode.
  */
 typedef struct nas_establish_req_s {
-    UInt8_t cause;       /* RRC connection establishment cause  */
-    UInt8_t type;        /* RRC associated call type        */
-    as_stmsi_t s_tmsi;   /* UE identity             */
-    plmn_t plmnID;       /* Selected PLMN identity      */
-    as_nas_info_t initialNasMsg; /* Initial NAS message to transfer */
+    as_cause_t      cause;          /* RRC connection establishment cause   */
+    as_call_type_t  type;           /* RRC associated call type             */
+    as_stmsi_t      s_tmsi;         /* UE identity                          */
+    plmn_t          plmnID;         /* Selected PLMN identity               */
+    as_nas_info_t   initialNasMsg;  /* Initial NAS message to transfer      */
 } nas_establish_req_t;
 
 /*
@@ -287,7 +290,7 @@ typedef struct nas_establish_req_s {
 typedef struct nas_establish_ind_s {
     UInt32_t UEid;       /* UE lower layer identifier       */
     tac_t tac;           /* Code of the tracking area the initiating
-                  * UE belongs to           */
+                          * UE belongs to           */
     as_nas_info_t initialNasMsg; /* Initial NAS message to transfer */
 } nas_establish_ind_t;
 
@@ -297,10 +300,10 @@ typedef struct nas_establish_ind_s {
  * the UE.
  */
 typedef struct nas_establish_rsp_s {
-    UInt32_t UEid;           /* UE lower layer identifier   */
-    as_stmsi_t s_tmsi;       /* UE identity                 */
-    UInt8_t errCode;		 /* Transaction status			*/
-    as_nas_info_t nasMsg;    /* NAS message to transfer     */
+    UInt32_t         UEid;         /* UE lower layer identifier   */
+    as_stmsi_t       s_tmsi;       /* UE identity                 */
+    nas_error_code_t errCode;      /* Transaction status          */
+    as_nas_info_t    nasMsg;       /* NAS message to transfer     */
 } nas_establish_rsp_t;
 
 /*
@@ -308,8 +311,8 @@ typedef struct nas_establish_rsp_s {
  * AS transfers the initial answer message to the NAS.
  */
 typedef struct nas_establish_cnf_s {
-    UInt8_t errCode;		 /* Transaction status			*/
-    as_nas_info_t    nasMsg;     /* NAS message to transfer     */
+    nas_error_code_t errCode;         /* Transaction status          */
+    as_nas_info_t    nasMsg;          /* NAS message to transfer     */
 } nas_establish_cnf_t;
 
 /*
@@ -320,8 +323,8 @@ typedef struct nas_establish_cnf_s {
 
 /* Release cause */
 typedef enum release_cause_s {
-    AS_AUTHENTICATION_FAILURE = 1, /* Authentication procedure failed   */
-    AS_DETACH              /* Detach requested          */
+    AS_AUTHENTICATION_FAILURE = 1,  /* Authentication procedure failed   */
+    AS_DETACH                       /* Detach requested                  */
 } release_cause_t;
 
 /*
@@ -329,9 +332,9 @@ typedef enum release_cause_s {
  * NAS requests the termination of the connection with the UE.
  */
 typedef struct nas_release_req_s {
-    UInt32_t UEid;      /* UE lower layer identifier        */
-    as_stmsi_t s_tmsi;      /* UE identity              */
-    UInt8_t cause;      /* Release cause            */
+    UInt32_t UEid;          /* UE lower layer identifier    */
+    as_stmsi_t s_tmsi;      /* UE identity                  */
+    release_cause_t cause;  /* Release cause                */
 } nas_release_req_t;
 
 /*
@@ -339,7 +342,7 @@ typedef struct nas_release_req_s {
  * AS reports that connection has been terminated by the network.
  */
 typedef struct nas_release_ind_s {
-    UInt8_t cause;      /* Release cause            */
+    release_cause_t cause;      /* Release cause            */
 } nas_release_ind_t;
 
 /*
@@ -366,7 +369,7 @@ typedef struct ul_info_transfer_req_s {
  */
 typedef struct ul_info_transfer_cnf_s {
     UInt32_t         UEid;      /* UE lower layer identifier        */
-    UInt8_t errCode;		/* Transaction status			*/
+    nas_error_code_t errCode;   /* Transaction status               */
 } ul_info_transfer_cnf_t;
 
 /*
@@ -375,7 +378,7 @@ typedef struct ul_info_transfer_cnf_s {
  * at the network side.
  */
 typedef struct ul_info_transfer_ind_s {
-    UInt32_t UEid;      /* UE lower layer identifier        */
+    UInt32_t UEid;          /* UE lower layer identifier        */
     as_nas_info_t nasMsg;   /* Uplink NAS message           */
 } ul_info_transfer_ind_t;
 
@@ -415,9 +418,9 @@ typedef struct {} as_qos_t;
  * bearer initialized at the network side.
  */
 typedef struct rab_establish_req_s {
-    as_stmsi_t s_tmsi;      /* UE identity              */
+    as_stmsi_t s_tmsi;      /* UE identity                      */
     as_rab_id_t rabID;      /* Radio access bearer identity     */
-    as_qos_t QoS;       /* Requested Quality of Service     */
+    as_qos_t QoS;           /* Requested Quality of Service     */
 } rab_establish_req_t;
 
 /*
@@ -434,9 +437,9 @@ typedef struct rab_establish_ind_s {
  * successfully setup or not.
  */
 typedef struct rab_establish_rsp_s {
-    as_stmsi_t s_tmsi;      /* UE identity              */
-    as_rab_id_t rabID;      /* Radio access bearer identity     */
-    UInt8_t errCode;		/* Transaction status			*/
+    as_stmsi_t       s_tmsi;        /* UE identity                      */
+    as_rab_id_t      rabID;         /* Radio access bearer identity     */
+    nas_error_code_t errCode;       /* Transaction status               */
 } rab_establish_rsp_t;
 
 /*
@@ -445,8 +448,8 @@ typedef struct rab_establish_rsp_s {
  * successfully setup at the UE side or not.
  */
 typedef struct rab_establish_cnf_s {
-    as_rab_id_t rabID;      /* Radio access bearer identity     */
-    UInt8_t errCode;		/* Transaction status			*/
+    as_rab_id_t rabID;          /* Radio access bearer identity     */
+    nas_error_code_t errCode;   /* Transaction status               */
 } rab_establish_cnf_t;
 
 /*
@@ -461,7 +464,7 @@ typedef struct rab_establish_cnf_s {
  * to specific radio access bearer at the network side.
  */
 typedef struct rab_release_req_s {
-    as_stmsi_t s_tmsi;      /* UE identity              */
+    as_stmsi_t s_tmsi;      /* UE identity                      */
     as_rab_id_t rabID;      /* Radio access bearer identity     */
 } rab_release_req_t;