diff --git a/pkg/control/control.go b/pkg/control/control.go
index 9ce34a0..5a38656 100755
--- a/pkg/control/control.go
+++ b/pkg/control/control.go
@@ -157,40 +157,39 @@
 	xapp.Rmr.Free(params.Mbuf)
 	params.Mbuf = nil
 
+	srcAddr, srcPort, err := c.rtmgrClient.SplitSource(params.Src)
+	if err != nil {
+		xapp.Logger.Error("SubReq: Failed to update routing-manager. Dropping this msg. Err: %s, SubId: %v, Xid: %s", err, params.SubId, params.Xid)
+		return
+	}
+
 	/* Reserve a sequence number and set it in the payload */
-	subs := c.registry.ReserveSubscription()
+	subs := c.registry.ReserveSubscription(RmrEndpoint{*srcAddr, *srcPort}, params.Meid)
 	if subs == nil {
 		xapp.Logger.Error("SubReq: Failed to reserve sequence number. Dropping this msg. SubId: %v, Xid: %s", params.SubId, params.Xid)
 		return
 	}
 
 	params.SubId = int(subs.Seq)
-	err := c.e2ap.SetSubscriptionRequestSequenceNumber(params.Payload, subs.Seq)
+	err = c.e2ap.SetSubscriptionRequestSequenceNumber(params.Payload, subs.Seq)
 	if err != nil {
 		xapp.Logger.Error("SubReq: Unable to get Sequence Number from Payload. Dropping this msg. Err: %v, SubId: %v, Xid: %s, Payload %X", err, params.SubId, params.Xid, params.Payload)
 		c.registry.releaseSequenceNumber(subs.Seq)
 		return
 	}
 
-	srcAddr, srcPort, err := c.rtmgrClient.SplitSource(params.Src)
-	if err != nil {
-		xapp.Logger.Error("SubReq: Failed to update routing-manager. Dropping this msg. Err: %s, SubId: %v, Xid: %s", err, params.SubId, params.Xid)
-		c.registry.releaseSequenceNumber(subs.Seq)
-		return
-	}
-
 	// Create transatcion record for every subscription request
 	var forwardRespToXapp bool = true
 	var responseReceived bool = false
-	transaction, err := c.tracker.TrackTransaction(subs.Seq, CREATE, *srcAddr, *srcPort, params, responseReceived, forwardRespToXapp)
+	_, err = c.tracker.TrackTransaction(subs, RmrEndpoint{*srcAddr, *srcPort}, params, responseReceived, forwardRespToXapp)
 	if err != nil {
-		xapp.Logger.Error("SubReq: Failed to create transaction record. Dropping this msg. Err: %v SubId: %v, Xid: %s", err, params.SubId, params.Xid)
+		xapp.Logger.Error("SubReq: %s, Dropping this msg.", err.Error())
 		c.registry.releaseSequenceNumber(subs.Seq)
 		return
 	}
 
 	// Update routing manager about the new subscription
-	subRouteAction := transaction.SubRouteInfo()
+	subRouteAction := subs.SubRouteInfo(CREATE)
 	xapp.Logger.Info("SubReq: Starting routing manager update. SubId: %v, Xid: %s", params.SubId, params.Xid)
 
 	err = c.rtmgrClient.SubscriptionRequestUpdate(subRouteAction)
@@ -207,7 +206,7 @@
 		xapp.Logger.Error("SubReq: Failed to send request to E2T %v, SubId: %v, Xid: %s", err, params.SubId, params.Xid)
 	}
 	c.timerMap.StartTimer("RIC_SUB_REQ", int(subs.Seq), subReqTime, FirstTry, c.handleSubscriptionRequestTimer)
-	xapp.Logger.Debug("SubReq: Debugging transaction table = %v", c.tracker.transactionTable)
+	xapp.Logger.Debug("SubReq: Debugging transaction table = %v", c.tracker.transactionXappTable)
 	return
 }
 
@@ -223,26 +222,25 @@
 	}
 	xapp.Logger.Info("SubResp: Received payloadSeqNum: %v", payloadSeqNum)
 
-	if !c.registry.IsValidSequenceNumber(payloadSeqNum) {
+	subs := c.registry.GetSubscription(payloadSeqNum)
+	if subs == nil {
 		xapp.Logger.Error("SubResp: Unknown payloadSeqNum. Dropping this msg. PayloadSeqNum: %v, SubId: %v", payloadSeqNum, params.SubId)
 		return
 	}
 
+	transaction := subs.GetTransaction()
+
 	c.timerMap.StopTimer("RIC_SUB_REQ", int(payloadSeqNum))
 
-	transaction, responseReceived, err := c.tracker.CheckResponseReceived(payloadSeqNum, CREATE)
-	if err != nil {
-		xapp.Logger.Info("SubResp: Dropping this msg. Err: %v SubId: %v", err, payloadSeqNum)
-		return
-	}
-
+	responseReceived := transaction.CheckResponseReceived()
 	if responseReceived == true {
 		// Subscription timer already received
 		return
 	}
-	xapp.Logger.Info("SubResp: SubId: %v, from address: %v:%v.", payloadSeqNum, transaction.Xappkey.Addr, transaction.Xappkey.Port)
+	xapp.Logger.Info("SubResp: SubId: %v, from address: %s.", payloadSeqNum, transaction.RmrEndpoint)
 
-	c.registry.setSubscriptionToConfirmed(payloadSeqNum)
+	subs.Confirmed()
+	transaction.Release()
 
 	params.SubId = int(payloadSeqNum)
 	params.Xid = transaction.OrigParams.Xid
@@ -253,12 +251,7 @@
 		xapp.Logger.Error("SubResp: Failed to send response to xApp. Err: %v, SubId: %v, Xid: %s", err, params.SubId, params.Xid)
 	}
 
-	xapp.Logger.Info("SubResp: SubId: %v, from address: %v:%v. Deleting transaction record", payloadSeqNum, transaction.Xappkey.Addr, transaction.Xappkey.Port)
-	_, err = c.tracker.completeTransaction(payloadSeqNum, CREATE)
-	if err != nil {
-		xapp.Logger.Error("SubResp: Failed to delete transaction record. Err: %v, SubId: %v, Xid: %s", err, params.SubId, params.Xid)
-		return
-	}
+	xapp.Logger.Info("SubResp: SubId: %v, from address: %s. Deleting transaction record", payloadSeqNum, transaction.RmrEndpoint)
 	return
 }
 
@@ -274,9 +267,21 @@
 	}
 	xapp.Logger.Info("SubFail: Received payloadSeqNum: %v", payloadSeqNum)
 
+	subs := c.registry.GetSubscription(payloadSeqNum)
+	if subs == nil {
+		xapp.Logger.Error("SubFail: Unknown payloadSeqNum. Dropping this msg. PayloadSeqNum: %v, SubId: %v", payloadSeqNum, params.SubId)
+		return
+	}
+
+	transaction := subs.GetTransaction()
+	if transaction == nil {
+		xapp.Logger.Error("SubFail: Unknown transaction. Dropping this msg. PayloadSeqNum: %v, SubId: %v", payloadSeqNum, params.SubId)
+		return
+	}
+
 	c.timerMap.StopTimer("RIC_SUB_REQ", int(payloadSeqNum))
 
-	transaction, responseReceived, err := c.tracker.CheckResponseReceived(payloadSeqNum, CREATE)
+	responseReceived := transaction.CheckResponseReceived()
 	if err != nil {
 		xapp.Logger.Info("SubFail: Dropping this msg. Err: %v SubId: %v", err, payloadSeqNum)
 		return
@@ -286,27 +291,21 @@
 		// Subscription timer already received
 		return
 	}
-	xapp.Logger.Info("SubFail: SubId: %v, from address: %v:%v. Forwarding response to xApp", payloadSeqNum, transaction.Xappkey.Addr, transaction.Xappkey.Port)
+	xapp.Logger.Info("SubFail: SubId: %v, from address: %s. Forwarding response to xApp", payloadSeqNum, transaction.RmrEndpoint)
 
 	time.Sleep(3 * time.Second)
 
 	xapp.Logger.Info("SubFail: Starting routing manager update. SubId: %v, Xid: %s", params.SubId, params.Xid)
-	subRouteAction := transaction.SubRouteInfo()
+	subRouteAction := subs.SubRouteInfo(DELETE)
 	err = c.rtmgrClient.SubscriptionRequestUpdate(subRouteAction)
 	if err != nil {
 		xapp.Logger.Error("SubFail: Failed to update routing manager. Err: %v, SubId: %v, Xid: %s", err, params.SubId, params.Xid)
 	}
 
 	xapp.Logger.Info("SubFail: Deleting transaction record. SubId: %v, Xid: %s", params.SubId, params.Xid)
-	if c.registry.releaseSequenceNumber(payloadSeqNum) {
-		_, err = c.tracker.completeTransaction(payloadSeqNum, CREATE)
-		if err != nil {
-			xapp.Logger.Error("SubFail: Failed to delete transaction record. Err: %v, SubId: %v, Xid: %s", err, params.SubId, params.Xid)
-			return
-		}
-	} else {
+	transaction.Release()
+	if !c.registry.releaseSequenceNumber(payloadSeqNum) {
 		xapp.Logger.Error("SubFail: Failed to release sequency number. SubId: %v, Xid: %s", params.SubId, params.Xid)
-		return
 	}
 	return
 }
@@ -315,12 +314,20 @@
 	subId := uint16(nbrId)
 	xapp.Logger.Info("handleSubTimer: SubReq timer expired. subId: %v,  tryCount: %v", subId, tryCount)
 
-	transaction, responseReceived, err := c.tracker.CheckResponseReceived(subId, CREATE)
-	if err != nil {
-		xapp.Logger.Info("handleSubTimer: Dropping this timer action. Err: %v SubId: %v", err, subId)
+	subs := c.registry.GetSubscription(subId)
+	if subs == nil {
+		xapp.Logger.Error("SubFail: Unknown payloadSeqNum. Dropping this msg. SubId: %v", subId)
 		return
 	}
 
+	transaction := subs.GetTransaction()
+	if transaction == nil {
+		xapp.Logger.Error("SubFail: Unknown transaction. Dropping this msg. SubId: %v", subId)
+		return
+	}
+
+	responseReceived := transaction.CheckResponseReceived()
+
 	if responseReceived == true {
 		// Subscription Response or Failure already received
 		return
@@ -328,14 +335,10 @@
 
 	if tryCount < maxSubReqTryCount {
 		xapp.Logger.Info("handleSubTimer: Resending SubReq to E2T: Mtype: %v, SubId: %v, Xid %s, Meid %v", transaction.OrigParams.Mtype, transaction.OrigParams.SubId, transaction.OrigParams.Xid, transaction.OrigParams.Meid)
-		// Set possible to handle new response for the subId
-		err = c.tracker.RetryTransaction(subId, CREATE)
-		if err != nil {
-			xapp.Logger.Error("handleSubDelTimer: Failed to retry transaction record. Dropping timer action. Err %v, SubId: %v", err, transaction.OrigParams.SubId)
-			return
-		}
 
-		err = c.rmrSend(transaction.OrigParams)
+		transaction.RetryTransaction()
+
+		err := c.rmrSend(transaction.OrigParams)
 		if err != nil {
 			xapp.Logger.Error("handleSubTimer: Failed to send request to E2T %v, SubId: %v, Xid: %s", err, transaction.OrigParams.SubId, transaction.OrigParams.Xid)
 		}
@@ -346,7 +349,7 @@
 	}
 
 	var subDelReqPayload []byte
-	subDelReqPayload, err = c.e2ap.PackSubscriptionDeleteRequest(transaction.OrigParams.Payload, subId)
+	subDelReqPayload, err := c.e2ap.PackSubscriptionDeleteRequest(transaction.OrigParams.Payload, subId)
 	if err != nil {
 		xapp.Logger.Error("handleSubTimer: Packing SubDelReq failed. Err: %v", err)
 		return
@@ -364,17 +367,12 @@
 	params.Mbuf = nil
 
 	// Delete CREATE transaction
-	_, err = c.tracker.completeTransaction(subId, CREATE)
-	if err != nil {
-		xapp.Logger.Error("handleSubTimer: Failed to delete create transaction record. Dropping this timer action. Err: %v, SubId: %v, Xid: %s", err, subId, params.Xid)
-		return
-	}
+	transaction.Release()
 
 	// Create DELETE transaction
-	var forwardRespToXapp bool = false
-	_, err = c.trackDeleteTransaction(&params, subId, forwardRespToXapp)
+	_, err = c.trackDeleteTransaction(subs, &params, subId, false)
 	if err != nil {
-		xapp.Logger.Error("handleSubTimer: Failed to create delete transaction record. Dropping this timer action. Err: %v, SubId: %v, Xid: %s", err, subId, params.Xid)
+		xapp.Logger.Error("handleSubTimer: %s, Dropping this msg.", err.Error())
 		return
 	}
 
@@ -422,14 +420,15 @@
 	}
 	xapp.Logger.Info("SubDelReq: Received payloadSeqNum: %v", payloadSeqNum)
 
-	if c.registry.IsValidSequenceNumber(payloadSeqNum) {
+	subs := c.registry.GetSubscription(payloadSeqNum)
+	if subs != nil {
 		var forwardRespToXapp bool = true
-		_, err = c.trackDeleteTransaction(params, payloadSeqNum, forwardRespToXapp)
+		_, err = c.trackDeleteTransaction(subs, params, payloadSeqNum, forwardRespToXapp)
 		if err != nil {
-			xapp.Logger.Error("SubDelReq: Failed to create transaction record. Dropping this msg. Err: %v, SubId: %v, Xid: %s", err, params.SubId, params.Xid)
+			xapp.Logger.Error("SubDelReq: %s, Dropping this msg.", err.Error())
 			return
 		}
-		c.registry.setSubscriptionToUnConfirmed(payloadSeqNum)
+		subs.UnConfirmed()
 	} else {
 		xapp.Logger.Error("SubDelReq: Not valid sequence number. Dropping this msg. SubId: %v, Xid: %s", params.SubId, params.Xid)
 		return
@@ -444,13 +443,13 @@
 	return
 }
 
-func (c *Control) trackDeleteTransaction(params *xapp.RMRParams, payloadSeqNum uint16, forwardRespToXapp bool) (transaction *Transaction, err error) {
+func (c *Control) trackDeleteTransaction(subs *Subscription, params *xapp.RMRParams, payloadSeqNum uint16, forwardRespToXapp bool) (transaction *Transaction, err error) {
 	srcAddr, srcPort, err := c.rtmgrClient.SplitSource(params.Src)
 	if err != nil {
 		xapp.Logger.Error("Failed to split source address. Err: %s, SubId: %v, Xid: %s", err, payloadSeqNum, params.Xid)
 	}
 	var respReceived bool = false
-	transaction, err = c.tracker.TrackTransaction(payloadSeqNum, DELETE, *srcAddr, *srcPort, params, respReceived, forwardRespToXapp)
+	transaction, err = c.tracker.TrackTransaction(subs, RmrEndpoint{*srcAddr, *srcPort}, params, respReceived, forwardRespToXapp)
 	return
 }
 
@@ -466,20 +465,29 @@
 	}
 	xapp.Logger.Info("SubDelResp: Received payloadSeqNum: %v", payloadSeqNum)
 
-	c.timerMap.StopTimer("RIC_SUB_DEL_REQ", int(payloadSeqNum))
-
-	transaction, responseReceived, err := c.tracker.CheckResponseReceived(payloadSeqNum, DELETE)
-	if err != nil {
-		xapp.Logger.Info("SubDelResp: Dropping this msg. Err: %v SubId: %v", err, payloadSeqNum)
+	subs := c.registry.GetSubscription(payloadSeqNum)
+	if subs == nil {
+		xapp.Logger.Error("SubDelResp: Unknown payloadSeqNum. Dropping this msg. PayloadSeqNum: %v, SubId: %v", payloadSeqNum, params.SubId)
 		return
 	}
 
+	transaction := subs.GetTransaction()
+	if transaction == nil {
+		xapp.Logger.Error("SubDelResp: Unknown transaction. Dropping this msg. PayloadSeqNum: %v, SubId: %v", payloadSeqNum, params.SubId)
+		return
+	}
+
+	c.timerMap.StopTimer("RIC_SUB_DEL_REQ", int(payloadSeqNum))
+
+	responseReceived := transaction.CheckResponseReceived()
 	if responseReceived == true {
 		// Subscription Delete timer already received
 		return
 	}
-	xapp.Logger.Info("SubDelResp: SubId: %v, from address: %v:%v. Forwarding response to xApp", payloadSeqNum, transaction.Xappkey.Addr, transaction.Xappkey.Port)
 
+	transaction.Release()
+
+	xapp.Logger.Info("SubDelResp: SubId: %v, from address: %s. Forwarding response to xApp", payloadSeqNum, transaction.RmrEndpoint)
 	if transaction.ForwardRespToXapp == true {
 		params.SubId = int(payloadSeqNum)
 		params.Xid = transaction.OrigParams.Xid
@@ -493,7 +501,7 @@
 	}
 
 	xapp.Logger.Info("SubDelResp: Starting routing manager update. SubId: %v, Xid: %s", params.SubId, params.Xid)
-	subRouteAction := SubRouteInfo{DELETE, transaction.Xappkey.Addr, transaction.Xappkey.Port, payloadSeqNum}
+	subRouteAction := subs.SubRouteInfo(DELETE)
 	err = c.rtmgrClient.SubscriptionRequestUpdate(subRouteAction)
 	if err != nil {
 		xapp.Logger.Error("SubDelResp: Failed to update routing manager. Err: %v, SubId: %v, Xid: %s", err, params.SubId, params.Xid)
@@ -501,13 +509,7 @@
 	}
 
 	xapp.Logger.Info("SubDelResp: Deleting transaction record. SubId: %v, Xid: %s", params.SubId, params.Xid)
-	if c.registry.releaseSequenceNumber(payloadSeqNum) {
-		_, err = c.tracker.completeTransaction(payloadSeqNum, DELETE)
-		if err != nil {
-			xapp.Logger.Error("SubDelResp: Failed to delete transaction record. Err: %v, SubId: %v, Xid: %s", err, params.SubId, params.Xid)
-			return
-		}
-	} else {
+	if !c.registry.releaseSequenceNumber(payloadSeqNum) {
 		xapp.Logger.Error("SubDelResp: Failed to release sequency number. SubId: %v, Xid: %s", params.SubId, params.Xid)
 		return
 	}
@@ -526,19 +528,26 @@
 	}
 	xapp.Logger.Info("SubDelFail: Received payloadSeqNum: %v", payloadSeqNum)
 
-	c.timerMap.StopTimer("RIC_SUB_DEL_REQ", int(payloadSeqNum))
-
-	transaction, responseReceived, err := c.tracker.CheckResponseReceived(payloadSeqNum, DELETE)
-	if err != nil {
-		xapp.Logger.Info("SubDelFail: Dropping this msg. Err: %v SubId: %v", err, payloadSeqNum)
+	subs := c.registry.GetSubscription(payloadSeqNum)
+	if subs == nil {
+		xapp.Logger.Error("SubDelFail: Unknown payloadSeqNum. Dropping this msg. PayloadSeqNum: %v, SubId: %v", payloadSeqNum, params.SubId)
 		return
 	}
 
+	transaction := subs.GetTransaction()
+	if transaction == nil {
+		xapp.Logger.Error("SubDelFail: Unknown transaction. Dropping this msg. PayloadSeqNum: %v, SubId: %v", payloadSeqNum, params.SubId)
+		return
+	}
+
+	c.timerMap.StopTimer("RIC_SUB_DEL_REQ", int(payloadSeqNum))
+
+	responseReceived := transaction.CheckResponseReceived()
 	if responseReceived == true {
 		// Subscription Delete timer already received
 		return
 	}
-	xapp.Logger.Info("SubDelFail: SubId: %v, from address: %v:%v. Forwarding response to xApp", payloadSeqNum, transaction.Xappkey.Addr, transaction.Xappkey.Port)
+	xapp.Logger.Info("SubDelFail: SubId: %v, from address: %s. Forwarding response to xApp", payloadSeqNum, transaction.RmrEndpoint)
 
 	if transaction.ForwardRespToXapp == true {
 		var subDelRespPayload []byte
@@ -566,7 +575,7 @@
 	}
 
 	xapp.Logger.Info("SubDelFail: Starting routing manager update. SubId: %v, Xid: %s", params.SubId, params.Xid)
-	subRouteAction := SubRouteInfo{DELETE, transaction.Xappkey.Addr, transaction.Xappkey.Port, payloadSeqNum}
+	subRouteAction := subs.SubRouteInfo(DELETE)
 	err = c.rtmgrClient.SubscriptionRequestUpdate(subRouteAction)
 	if err != nil {
 		xapp.Logger.Error("SubDelFail: Failed to update routing manager. Err: %v, SubId: %v, Xid: %s", err, params.SubId, params.Xid)
@@ -574,13 +583,8 @@
 	}
 
 	xapp.Logger.Info("SubDelFail: Deleting transaction record. SubId: %v, Xid: %s", params.SubId, params.Xid)
-	if c.registry.releaseSequenceNumber(payloadSeqNum) {
-		_, err = c.tracker.completeTransaction(payloadSeqNum, DELETE)
-		if err != nil {
-			xapp.Logger.Error("SubDelFail: Failed to delete transaction record. Err: %v, SubId: %v, Xid: %s", err, params.SubId, params.Xid)
-			return
-		}
-	} else {
+	transaction.Release()
+	if !c.registry.releaseSequenceNumber(payloadSeqNum) {
 		xapp.Logger.Error("SubDelFail: Failed to release sequency number. Err: %v, SubId: %v, Xid: %s", err, params.SubId, params.Xid)
 		return
 	}
@@ -591,12 +595,19 @@
 	subId := uint16(nbrId)
 	xapp.Logger.Info("handleSubDelTimer: SubDelReq timer expired. subId: %v, tryCount: %v", subId, tryCount)
 
-	transaction, responseReceived, err := c.tracker.CheckResponseReceived(subId, DELETE)
-	if err != nil {
-		xapp.Logger.Info("handleSubTimer: Dropping this timer action. Err: %v SubId: %v", err, subId)
+	subs := c.registry.GetSubscription(subId)
+	if subs == nil {
+		xapp.Logger.Error("handleSubDelTimer: Unknown payloadSeqNum. Dropping this msg. SubId: %v", subId)
 		return
 	}
 
+	transaction := subs.GetTransaction()
+	if transaction == nil {
+		xapp.Logger.Error("handleSubDelTimer: Unknown transaction. Dropping this msg. SubId: %v", subId)
+		return
+	}
+
+	responseReceived := transaction.CheckResponseReceived()
 	if responseReceived == true {
 		// Subscription Delete Response or Failure already received
 		return
@@ -605,13 +616,10 @@
 	if tryCount < maxSubDelReqTryCount {
 		xapp.Logger.Info("handleSubDelTimer: Resending SubDelReq to E2T: Mtype: %v, SubId: %v, Xid %s, Meid %v", transaction.OrigParams.Mtype, transaction.OrigParams.SubId, transaction.OrigParams.Xid, transaction.OrigParams.Meid)
 		// Set possible to handle new response for the subId
-		err = c.tracker.RetryTransaction(subId, DELETE)
-		if err != nil {
-			xapp.Logger.Error("handleSubDelTimer: Failed to retry transaction record. Dropping  timer action. Err %v, SubId: %v", err, transaction.OrigParams.SubId)
-			return
-		}
 
-		err = c.rmrSend(transaction.OrigParams)
+		transaction.RetryTransaction()
+
+		err := c.rmrSend(transaction.OrigParams)
 		if err != nil {
 			xapp.Logger.Error("handleSubDelTimer: Failed to send request to E2T %v, SubId: %v, Xid: %s", err, transaction.OrigParams.SubId, transaction.OrigParams.Xid)
 		}
@@ -624,7 +632,7 @@
 	var params xapp.RMRParams
 	if transaction.ForwardRespToXapp == true {
 		var subDelRespPayload []byte
-		subDelRespPayload, err = c.e2ap.PackSubscriptionDeleteResponse(transaction.OrigParams.Payload, subId)
+		subDelRespPayload, err := c.e2ap.PackSubscriptionDeleteResponse(transaction.OrigParams.Payload, subId)
 		if err != nil {
 			xapp.Logger.Error("handleSubDelTimer: Unable to pack payload. Dropping this timer action. Err: %v, SubId: %v, Xid: %s, Payload %x", err, subId, transaction.OrigParams.Xid, transaction.OrigParams.Payload)
 			return
@@ -649,21 +657,16 @@
 	}
 
 	xapp.Logger.Info("handleSubDelTimer: Starting routing manager update. SubId: %v, Xid: %s", subId, params.Xid)
-	subRouteAction := SubRouteInfo{DELETE, transaction.Xappkey.Addr, transaction.Xappkey.Port, subId}
-	err = c.rtmgrClient.SubscriptionRequestUpdate(subRouteAction)
+	subRouteAction := subs.SubRouteInfo(DELETE)
+	err := c.rtmgrClient.SubscriptionRequestUpdate(subRouteAction)
 	if err != nil {
 		xapp.Logger.Error("handleSubDelTimer: Failed to update routing manager. Err: %v, SubId: %v, Xid: %s", err, subId, params.Xid)
 		return
 	}
 
 	xapp.Logger.Info("handleSubDelTimer: Deleting transaction record. SubId: %v, Xid: %s", subId, params.Xid)
-	if c.registry.releaseSequenceNumber(subId) {
-		_, err = c.tracker.completeTransaction(subId, DELETE)
-		if err != nil {
-			xapp.Logger.Error("handleSubDelTimer: Failed to delete transaction record. Err: %v, SubId: %v, Xid: %s", err, subId, params.Xid)
-			return
-		}
-	} else {
+	transaction.Release()
+	if !c.registry.releaseSequenceNumber(subId) {
 		xapp.Logger.Error("handleSubDelTimer: Failed to release sequency number. SubId: %v, Xid: %s", subId, params.Xid)
 	}
 	return
diff --git a/pkg/control/main_test.go b/pkg/control/main_test.go
index dc62225..69dadff 100644
--- a/pkg/control/main_test.go
+++ b/pkg/control/main_test.go
@@ -129,7 +129,6 @@
 type testingXappControl struct {
 	testingRmrControl
 	testingMessageChannel
-	meid    *xapp.RMRMeid
 	xid_seq uint64
 }
 
@@ -163,11 +162,10 @@
 	return
 }
 
-func createNewXappControl(desc string, rtfile string, port string, stat string, ranname string) *testingXappControl {
+func createNewXappControl(desc string, rtfile string, port string, stat string) *testingXappControl {
 	xappCtrl := &testingXappControl{}
 	xappCtrl.testingRmrControl = initTestingRmrControl(desc, rtfile, port, stat, xappCtrl)
 	xappCtrl.testingMessageChannel = initTestingMessageChannel()
-	xappCtrl.meid = &xapp.RMRMeid{RanName: ranname}
 	xappCtrl.xid_seq = 1
 	return xappCtrl
 }
@@ -330,7 +328,7 @@
 
 	xapprtfilename1, _ := testCreateTmpFile(xapprt1)
 	defer os.Remove(xapprtfilename1)
-	xappConn1 = createNewXappControl("xappConn1", xapprtfilename1, "13560", "RMRXAPP1STUB", "RAN_NAME_1")
+	xappConn1 = createNewXappControl("xappstub1", xapprtfilename1, "13560", "RMRXAPP1STUB")
 
 	//---------------------------------
 	//
@@ -350,7 +348,7 @@
 
 	xapprtfilename2, _ := testCreateTmpFile(xapprt2)
 	defer os.Remove(xapprtfilename2)
-	xappConn2 = createNewXappControl("xappConn2", xapprtfilename2, "13660", "RMRXAPP2STUB", "RAN_NAME_1")
+	xappConn2 = createNewXappControl("xappstub2", xapprtfilename2, "13660", "RMRXAPP2STUB")
 
 	//---------------------------------
 	//
@@ -369,7 +367,7 @@
 
 	e2termrtfilename, _ := testCreateTmpFile(e2termrt)
 	defer os.Remove(e2termrtfilename)
-	e2termConn = createNewE2termControl("e2termConn", e2termrtfilename, "15560", "RMRE2TERMSTUB")
+	e2termConn = createNewE2termControl("e2termstub", e2termrtfilename, "15560", "RMRE2TERMSTUB")
 
 	//---------------------------------
 	//
diff --git a/pkg/control/messaging_test.go b/pkg/control/messaging_test.go
index 3edf7a5..acd1544 100644
--- a/pkg/control/messaging_test.go
+++ b/pkg/control/messaging_test.go
@@ -395,7 +395,24 @@
 func (mc *testingMainControl) wait_subs_clean(t *testing.T, e2SubsId int, secs int) bool {
 	i := 1
 	for ; i <= secs*2; i++ {
-		if mc.c.registry.IsValidSequenceNumber(uint16(e2SubsId)) == false {
+		if mc.c.registry.GetSubscription(uint16(e2SubsId)) == nil {
+			return true
+		}
+		time.Sleep(500 * time.Millisecond)
+	}
+	testError(t, "(general) no clean within %d secs", secs)
+	return false
+}
+
+func (mc *testingMainControl) wait_subs_trans_clean(t *testing.T, e2SubsId int, secs int) bool {
+	i := 1
+	for ; i <= secs*2; i++ {
+		subs := mc.c.registry.GetSubscription(uint16(e2SubsId))
+		if subs == nil {
+			return true
+		}
+		trans := subs.GetTransaction()
+		if trans == nil {
 			return true
 		}
 		time.Sleep(500 * time.Millisecond)
@@ -563,6 +580,8 @@
 //     |              |------------->|
 //     |              |              |
 //     | SubDelReq    |              |
+//     | (same sub)   |              |
+//     | (same xid)   |              |
 //     |------------->|              |
 //     |              |              |
 //     |              |   SubDelResp |
@@ -597,6 +616,60 @@
 }
 
 //-----------------------------------------------------------------------------
+// TestSubDelReqCollision
+//
+//   stub                          stub
+// +-------+     +---------+    +---------+
+// | xapp  |     | submgr  |    | e2term  |
+// +-------+     +---------+    +---------+
+//     |              |              |
+//     |         [SUBS CREATE]       |
+//     |              |              |
+//     |              |              |
+//     | SubDelReq    |              |
+//     |------------->|              |
+//     |              |              |
+//     |              | SubDelReq    |
+//     |              |------------->|
+//     |              |              |
+//     | SubDelReq    |              |
+//     | (same sub)   |              |
+//     | (diff xid)   |              |
+//     |------------->|              |
+//     |              |              |
+//     |              |   SubDelResp |
+//     |              |<-------------|
+//     |              |              |
+//     |   SubDelResp |              |
+//     |<-------------|              |
+//
+//-----------------------------------------------------------------------------
+func TestSubDelReqCollision(t *testing.T) {
+	xapp.Logger.Info("TestSubDelReqCollision")
+
+	//Subs Create
+	cretrans := xappConn1.handle_xapp_subs_req(t, nil)
+	crereq, cremsg := e2termConn.handle_e2term_subs_req(t)
+	e2termConn.handle_e2term_subs_resp(t, crereq, cremsg)
+	e2SubsId := xappConn1.handle_xapp_subs_resp(t, cretrans)
+
+	//Subs Delete
+	deltrans := xappConn1.handle_xapp_subs_del_req(t, nil, e2SubsId)
+	delreq, delmsg := e2termConn.handle_e2term_subs_del_req(t)
+
+	seqBef := mainCtrl.get_msgcounter(t)
+	deltranscol := xappConn1.newXappTransaction(nil, "RAN_NAME_1")
+	xappConn1.handle_xapp_subs_del_req(t, deltranscol, e2SubsId) //Colliding SubDelReq
+	mainCtrl.wait_msgcounter_change(t, seqBef, 10)
+
+	e2termConn.handle_e2term_subs_del_resp(t, delreq, delmsg)
+	xappConn1.handle_xapp_subs_del_resp(t, deltrans)
+
+	//Wait that subs is cleaned
+	mainCtrl.wait_subs_clean(t, e2SubsId, 10)
+}
+
+//-----------------------------------------------------------------------------
 // TestSubReqAndSubDelOkTwoParallel
 //
 //   stub                          stub
diff --git a/pkg/control/registry.go b/pkg/control/registry.go
index 3d70d63..1adb4f7 100644
--- a/pkg/control/registry.go
+++ b/pkg/control/registry.go
@@ -21,26 +21,82 @@
 
 import (
 	"gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
+	"strconv"
 	"sync"
 )
 
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
 type Subscription struct {
+	mutex  sync.Mutex
 	Seq    uint16
 	Active bool
+	//
+	Meid        *xapp.RMRMeid
+	RmrEndpoint // xapp endpoint
+	Trans       *Transaction
+}
+
+func (s *Subscription) String() string {
+	s.mutex.Lock()
+	defer s.mutex.Unlock()
+	return strconv.FormatUint(uint64(s.Seq), 10) + "/" + s.RmrEndpoint.String() + "/" + s.Meid.RanName
 }
 
 func (s *Subscription) Confirmed() {
+	s.mutex.Lock()
+	defer s.mutex.Unlock()
 	s.Active = true
 }
 
 func (s *Subscription) UnConfirmed() {
+	s.mutex.Lock()
+	defer s.mutex.Unlock()
 	s.Active = false
 }
 
 func (s *Subscription) IsConfirmed() bool {
+	s.mutex.Lock()
+	defer s.mutex.Unlock()
 	return s.Active
 }
 
+func (s *Subscription) SetTransaction(trans *Transaction) bool {
+	s.mutex.Lock()
+	defer s.mutex.Unlock()
+	if s.Trans == nil {
+		s.Trans = trans
+		return true
+	}
+	return false
+}
+
+func (s *Subscription) UnSetTransaction(trans *Transaction) bool {
+	s.mutex.Lock()
+	defer s.mutex.Unlock()
+	if trans == nil || trans == s.Trans {
+		s.Trans = nil
+		return true
+	}
+	return false
+}
+
+func (s *Subscription) GetTransaction() *Transaction {
+	s.mutex.Lock()
+	defer s.mutex.Unlock()
+	return s.Trans
+}
+
+func (s *Subscription) SubRouteInfo(act Action) SubRouteInfo {
+	s.mutex.Lock()
+	defer s.mutex.Unlock()
+	return SubRouteInfo{act, s.RmrEndpoint.Addr, s.RmrEndpoint.Port, s.Seq}
+}
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
 type Registry struct {
 	register map[uint16]*Subscription
 	counter  uint16
@@ -54,7 +110,7 @@
 }
 
 // Reserves and returns the next free sequence number
-func (r *Registry) ReserveSubscription() *Subscription {
+func (r *Registry) ReserveSubscription(endPoint RmrEndpoint, meid *xapp.RMRMeid) *Subscription {
 	// Check is current SequenceNumber valid
 	// Allocate next SequenceNumber value and retry N times
 	r.mutex.Lock()
@@ -69,14 +125,19 @@
 			r.counter++
 		}
 		if _, ok := r.register[sequenceNumber]; ok == false {
-			r.register[sequenceNumber] = &Subscription{sequenceNumber, false}
+			r.register[sequenceNumber] = &Subscription{
+				Seq:         sequenceNumber,
+				Active:      false,
+				RmrEndpoint: endPoint,
+				Meid:        meid,
+				Trans:       nil,
+			}
 			return r.register[sequenceNumber]
 		}
 	}
 	return nil
 }
 
-// This function checks the validity of the given subscription id
 func (r *Registry) GetSubscription(sn uint16) *Subscription {
 	r.mutex.Lock()
 	defer r.mutex.Unlock()
@@ -87,31 +148,6 @@
 	return nil
 }
 
-// This function checks the validity of the given subscription id
-func (r *Registry) IsValidSequenceNumber(sn uint16) bool {
-	r.mutex.Lock()
-	defer r.mutex.Unlock()
-	xapp.Logger.Debug("Registry map: %v", r.register)
-	if _, ok := r.register[sn]; ok {
-		return true
-	}
-	return false
-}
-
-// This function sets the give id as confirmed in the register
-func (r *Registry) setSubscriptionToConfirmed(sn uint16) {
-	r.mutex.Lock()
-	defer r.mutex.Unlock()
-	r.register[sn].Confirmed()
-}
-
-//This function sets the given id as unused in the register
-func (r *Registry) setSubscriptionToUnConfirmed(sn uint16) {
-	r.mutex.Lock()
-	defer r.mutex.Unlock()
-	r.register[sn].UnConfirmed()
-}
-
 //This function releases the given id as unused in the register
 func (r *Registry) releaseSequenceNumber(sn uint16) bool {
 	r.mutex.Lock()
diff --git a/pkg/control/tracker.go b/pkg/control/tracker.go
index 9287ea8..0e6941d 100644
--- a/pkg/control/tracker.go
+++ b/pkg/control/tracker.go
@@ -22,138 +22,132 @@
 import (
 	"fmt"
 	"gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
+	"strconv"
 	"sync"
 )
 
-type TransactionKey struct {
-	SubID     uint16 // subscription id / sequence number
-	TransType Action // action ongoing (CREATE/DELETE etc)
-}
-
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
 type TransactionXappKey struct {
 	RmrEndpoint
 	Xid string // xapp xid in req
 }
 
+func (key *TransactionXappKey) String() string {
+	return key.RmrEndpoint.String() + "/" + key.Xid
+}
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
 type Transaction struct {
-	tracker           *Tracker           // tracker instance
-	Key               TransactionKey     // action key
-	Xappkey           TransactionXappKey // transaction key
-	OrigParams        *xapp.RMRParams    // request orginal params
+	tracker           *Tracker // tracker instance
+	Subs              *Subscription
+	RmrEndpoint       RmrEndpoint
+	Xid               string          // xapp xid in req
+	OrigParams        *xapp.RMRParams // request orginal params
 	RespReceived      bool
 	ForwardRespToXapp bool
+	mutex             sync.Mutex
 }
 
-func (t *Transaction) SubRouteInfo() SubRouteInfo {
-	return SubRouteInfo{t.Key.TransType, t.Xappkey.RmrEndpoint.Addr, t.Xappkey.RmrEndpoint.Port, t.Key.SubID}
+func (t *Transaction) String() string {
+	t.mutex.Lock()
+	defer t.mutex.Unlock()
+	var subId string = "?"
+	if t.Subs != nil {
+		subId = strconv.FormatUint(uint64(t.Subs.Seq), 10)
+	}
+	return subId + "/" + t.RmrEndpoint.String() + "/" + t.Xid
 }
 
-/*
-Implements a record of ongoing transactions and helper functions to CRUD the records.
-*/
+func (t *Transaction) CheckResponseReceived() bool {
+	t.mutex.Lock()
+	defer t.mutex.Unlock()
+	if t.RespReceived == false {
+		t.RespReceived = true
+		return false
+	}
+	return true
+}
+
+func (t *Transaction) RetryTransaction() {
+	t.mutex.Lock()
+	defer t.mutex.Unlock()
+	t.RespReceived = false
+}
+
+func (t *Transaction) Release() {
+	t.mutex.Lock()
+	defer t.mutex.Unlock()
+	if t.Subs != nil {
+		t.Subs.UnSetTransaction(t)
+	}
+	if t.tracker != nil {
+		xappkey := TransactionXappKey{t.RmrEndpoint, t.Xid}
+		t.tracker.UnTrackTransaction(xappkey)
+	}
+	t.Subs = nil
+	t.tracker = nil
+}
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
 type Tracker struct {
-	transactionTable     map[TransactionKey]*Transaction
 	transactionXappTable map[TransactionXappKey]*Transaction
 	mutex                sync.Mutex
 }
 
 func (t *Tracker) Init() {
-	t.transactionTable = make(map[TransactionKey]*Transaction)
 	t.transactionXappTable = make(map[TransactionXappKey]*Transaction)
 }
 
-/*
-Checks if a tranascation with similar type has been ongoing. If not then creates one.
-Returns error if there is similar transatcion ongoing.
-*/
-func (t *Tracker) TrackTransaction(subID uint16, act Action, addr string, port uint16, params *xapp.RMRParams, respReceived bool, forwardRespToXapp bool) (*Transaction, error) {
-	key := TransactionKey{subID, act}
-	endpoint := RmrEndpoint{addr, port}
-	xappkey := TransactionXappKey{endpoint, params.Xid}
-	trans := &Transaction{t, key, xappkey, params, respReceived, forwardRespToXapp}
+func (t *Tracker) TrackTransaction(subs *Subscription, endpoint RmrEndpoint, params *xapp.RMRParams, respReceived bool, forwardRespToXapp bool) (*Transaction, error) {
+
+	trans := &Transaction{
+		tracker:           nil,
+		Subs:              nil,
+		RmrEndpoint:       endpoint,
+		Xid:               params.Xid,
+		OrigParams:        params,
+		RespReceived:      respReceived,
+		ForwardRespToXapp: forwardRespToXapp,
+	}
+
 	t.mutex.Lock()
 	defer t.mutex.Unlock()
-	if _, ok := t.transactionTable[key]; ok {
-		// TODO: Implement merge related check here. If the key is same but the value is different.
-		err := fmt.Errorf("transaction tracker: Similar transaction with sub id %d and type %s is ongoing", key.SubID, key.TransType)
-		return nil, err
-	}
+
+	xappkey := TransactionXappKey{endpoint, params.Xid}
 	if _, ok := t.transactionXappTable[xappkey]; ok {
-		// TODO: Implement merge related check here. If the key is same but the value is different.
-		err := fmt.Errorf("transaction tracker: Similar transaction with xapp key %v is ongoing", xappkey)
+		err := fmt.Errorf("Tracker: Similar transaction with xappkey %s is ongoing, transaction %s not created ", xappkey, trans)
 		return nil, err
 	}
-	t.transactionTable[key] = trans
+
+	if subs.SetTransaction(trans) == false {
+		othTrans := subs.GetTransaction()
+		err := fmt.Errorf("Tracker: Subscription %s got already transaction ongoing: %s, transaction %s not created", subs, othTrans, trans)
+		return nil, err
+	}
+	trans.Subs = subs
+	if (trans.Subs.RmrEndpoint.Addr != trans.RmrEndpoint.Addr) || (trans.Subs.RmrEndpoint.Port != trans.RmrEndpoint.Port) {
+		err := fmt.Errorf("Tracker: Subscription endpoint %s mismatch with trans: %s", subs, trans)
+		trans.Subs.UnSetTransaction(nil)
+		return nil, err
+	}
+
+	trans.tracker = t
 	t.transactionXappTable[xappkey] = trans
 	return trans, nil
 }
 
-/*
-Retreives the transaction table entry for the given request. Controls that only one response is sent to xapp.
-Returns error in case the transaction cannot be found.
-*/
-func (t *Tracker) RetriveTransaction(subID uint16, act Action) (*Transaction, error) {
-	key := TransactionKey{subID, act}
+func (t *Tracker) UnTrackTransaction(xappKey TransactionXappKey) (*Transaction, error) {
 	t.mutex.Lock()
 	defer t.mutex.Unlock()
-	if trans, ok := t.transactionTable[key]; ok {
+	if trans, ok2 := t.transactionXappTable[xappKey]; ok2 {
+		delete(t.transactionXappTable, xappKey)
 		return trans, nil
 	}
-	err := fmt.Errorf("transaction record for Subscription ID %d and action %s does not exist", subID, act)
-	return nil, err
-}
-
-/*
-Deletes the transaction table entry for the given request and returns the deleted xapp's address and port for reference.
-Returns error in case the transaction cannot be found.
-*/
-func (t *Tracker) completeTransaction(subID uint16, act Action) (*Transaction, error) {
-	key := TransactionKey{subID, act}
-	t.mutex.Lock()
-	defer t.mutex.Unlock()
-	if trans, ok1 := t.transactionTable[key]; ok1 {
-		if _, ok2 := t.transactionXappTable[trans.Xappkey]; ok2 {
-			delete(t.transactionXappTable, trans.Xappkey)
-		}
-		delete(t.transactionTable, key)
-		return trans, nil
-	}
-	err := fmt.Errorf("transaction record for Subscription ID %d and action %s does not exist", subID, act)
-	return nil, err
-}
-
-/*
-Makes possible to to detect has response already received from BTS
-Returns error in case the transaction cannot be found.
-*/
-func (t *Tracker) CheckResponseReceived(subID uint16, act Action) (*Transaction, bool, error) {
-	key := TransactionKey{subID, act}
-	t.mutex.Lock()
-	defer t.mutex.Unlock()
-	if trans, ok := t.transactionTable[key]; ok {
-		if trans.RespReceived == false {
-			trans.RespReceived = true
-			// This is used to control that only one response action (success response, failure or timer) is excecuted for the transaction
-			return trans, false, nil
-		}
-		return trans, true, nil
-	}
-	err := fmt.Errorf("transaction record for Subscription ID %d and action %s does not exist", subID, act)
-	return nil, false, err
-}
-
-/*
-Makes possible to receive response to retransmitted request to BTS
-Returns error in case the transaction cannot be found.
-*/
-func (t *Tracker) RetryTransaction(subID uint16, act Action) error {
-	key := TransactionKey{subID, act}
-	t.mutex.Lock()
-	defer t.mutex.Unlock()
-	if trans, ok := t.transactionTable[key]; ok {
-		trans.RespReceived = false
-		return nil
-	}
-	err := fmt.Errorf("transaction record for Subscription ID %d and action %s does not exist", subID, act)
-	return err
+	return nil, fmt.Errorf("Tracker: No record for xappkey %s", xappKey)
 }
diff --git a/pkg/control/types.go b/pkg/control/types.go
index febd41a..64fd15f 100644
--- a/pkg/control/types.go
+++ b/pkg/control/types.go
@@ -19,6 +19,10 @@
 
 package control
 
+import (
+	"strconv"
+)
+
 type RmrDatagram struct {
 	MessageType    int
 	SubscriptionId uint16
@@ -36,4 +40,9 @@
 	Addr string // xapp addr
 	Port uint16 // xapp port
 }
+
+func (endpoint RmrEndpoint) String() string {
+	return endpoint.Addr + ":" + strconv.FormatUint(uint64(endpoint.Port), 10)
+}
+
 type Action int
