diff --git a/charts/physims/charts/dlsim/values.yaml b/charts/physims/charts/dlsim/values.yaml
index d78fbb74099a964a7d3ac65c919cdc7a15a6cf07..7f45b42f72bf374d04d81f03c43a4eb5ddcb8654 100644
--- a/charts/physims/charts/dlsim/values.yaml
+++ b/charts/physims/charts/dlsim/values.yaml
@@ -4,11 +4,11 @@
 
 replicaCount: 1
 
-namespace: "oaicicd-ran-tmp"
+namespace: "OAICICD_PROJECT"
 
 image:
   registry: local
-  repository: image-registry.openshift-image-registry.svc:5000/oaicicd-ran-tmp/oai-physim
+  repository: image-registry.openshift-image-registry.svc:5000/OAICICD_PROJECT/oai-physim
   version: temp
   # pullPolicy: IfNotPresent or Never or Always
   pullPolicy: Always
diff --git a/charts/physims/charts/ldpctest/values.yaml b/charts/physims/charts/ldpctest/values.yaml
index e2e6467923809ce3f8e3bd06e85b10c70e33ff1e..b3cc476cf86116a1616856d61d53b3a4307ed96f 100644
--- a/charts/physims/charts/ldpctest/values.yaml
+++ b/charts/physims/charts/ldpctest/values.yaml
@@ -4,11 +4,11 @@
 
 replicaCount: 1
 
-namespace: "oaicicd-ran-tmp"
+namespace: "OAICICD_PROJECT"
 
 image:
   registry: local
-  repository: image-registry.openshift-image-registry.svc:5000/oaicicd-ran-tmp/oai-physim
+  repository: image-registry.openshift-image-registry.svc:5000/OAICICD_PROJECT/oai-physim
   version: temp
   # pullPolicy: IfNotPresent or Never or Always
   pullPolicy: Always
diff --git a/charts/physims/charts/nr-dlschsim/values.yaml b/charts/physims/charts/nr-dlschsim/values.yaml
index 8944e7e7246b284d2d6a32bb74b37b305659bd02..b7ef28f47a7b8e7b969a9886cf28b4b5faf6bf1c 100644
--- a/charts/physims/charts/nr-dlschsim/values.yaml
+++ b/charts/physims/charts/nr-dlschsim/values.yaml
@@ -4,11 +4,11 @@
 
 replicaCount: 1
 
-namespace: "oaicicd-ran-tmp"
+namespace: "OAICICD_PROJECT"
 
 image:
   registry: local
-  repository: image-registry.openshift-image-registry.svc:5000/oaicicd-ran-tmp/oai-physim
+  repository: image-registry.openshift-image-registry.svc:5000/OAICICD_PROJECT/oai-physim
   version: temp
   # pullPolicy: IfNotPresent or Never or Always
   pullPolicy: Always
diff --git a/charts/physims/charts/nr-dlsim/values.yaml b/charts/physims/charts/nr-dlsim/values.yaml
index 573e8630de864cb20ea6e0f658727594668a476a..2a35912fee5ed100b80c4871b799bcc28d48f40d 100644
--- a/charts/physims/charts/nr-dlsim/values.yaml
+++ b/charts/physims/charts/nr-dlsim/values.yaml
@@ -4,11 +4,11 @@
 
 replicaCount: 1
 
-namespace: "oaicicd-ran-tmp"
+namespace: "OAICICD_PROJECT"
 
 image:
   registry: local
-  repository: image-registry.openshift-image-registry.svc:5000/oaicicd-ran-tmp/oai-physim
+  repository: image-registry.openshift-image-registry.svc:5000/OAICICD_PROJECT/oai-physim
   version: temp
   # pullPolicy: IfNotPresent or Never or Always
   pullPolicy: Always
diff --git a/charts/physims/charts/nr-pbchsim/values.yaml b/charts/physims/charts/nr-pbchsim/values.yaml
index 28c4678334ba2587fabc0d6f23eb38b06d705a7b..9a25d2810da87d0fc9f21506db974f72a4230c6c 100644
--- a/charts/physims/charts/nr-pbchsim/values.yaml
+++ b/charts/physims/charts/nr-pbchsim/values.yaml
@@ -4,11 +4,11 @@
 
 replicaCount: 1
 
-namespace: "oaicicd-ran-tmp"
+namespace: "OAICICD_PROJECT"
 
 image:
   registry: local
-  repository: image-registry.openshift-image-registry.svc:5000/oaicicd-ran-tmp/oai-physim
+  repository: image-registry.openshift-image-registry.svc:5000/OAICICD_PROJECT/oai-physim
   version: temp
   # pullPolicy: IfNotPresent or Never or Always
   pullPolicy: Always
diff --git a/charts/physims/charts/nr-prachsim/values.yaml b/charts/physims/charts/nr-prachsim/values.yaml
index 9e3c68b54d306899dbb4ba161a0b37afc3d0157d..dba6cc16c079ce9f65922e11a2082aa8ffec8baa 100644
--- a/charts/physims/charts/nr-prachsim/values.yaml
+++ b/charts/physims/charts/nr-prachsim/values.yaml
@@ -4,11 +4,11 @@
 
 replicaCount: 1
 
-namespace: "oaicicd-ran-tmp"
+namespace: "OAICICD_PROJECT"
 
 image:
   registry: local
-  repository: image-registry.openshift-image-registry.svc:5000/oaicicd-ran-tmp/oai-physim
+  repository: image-registry.openshift-image-registry.svc:5000/OAICICD_PROJECT/oai-physim
   version: temp
   # pullPolicy: IfNotPresent or Never or Always
   pullPolicy: Always
diff --git a/charts/physims/charts/nr-pucchsim/values.yaml b/charts/physims/charts/nr-pucchsim/values.yaml
index 449670f71328bf3d070f62abdabb75043ea2d2ec..77fe0963ac2dc5d939a042aceee96c46703f3232 100644
--- a/charts/physims/charts/nr-pucchsim/values.yaml
+++ b/charts/physims/charts/nr-pucchsim/values.yaml
@@ -4,11 +4,11 @@
 
 replicaCount: 1
 
-namespace: "oaicicd-ran-tmp"
+namespace: "OAICICD_PROJECT"
 
 image:
   registry: local
-  repository: image-registry.openshift-image-registry.svc:5000/oaicicd-ran-tmp/oai-physim
+  repository: image-registry.openshift-image-registry.svc:5000/OAICICD_PROJECT/oai-physim
   version: temp
   # pullPolicy: IfNotPresent or Never or Always
   pullPolicy: Always
diff --git a/charts/physims/charts/nr-ulschsim/values.yaml b/charts/physims/charts/nr-ulschsim/values.yaml
index a3afc090e84527a3471abbe80f231f95452e88db..efb011a7f6530d59c4713c2c51c3a8c776318e98 100644
--- a/charts/physims/charts/nr-ulschsim/values.yaml
+++ b/charts/physims/charts/nr-ulschsim/values.yaml
@@ -4,11 +4,11 @@
 
 replicaCount: 1
 
-namespace: "oaicicd-ran-tmp"
+namespace: "OAICICD_PROJECT"
 
 image:
   registry: local
-  repository: image-registry.openshift-image-registry.svc:5000/oaicicd-ran-tmp/oai-physim
+  repository: image-registry.openshift-image-registry.svc:5000/OAICICD_PROJECT/oai-physim
   version: temp
   # pullPolicy: IfNotPresent or Never or Always
   pullPolicy: Always
diff --git a/charts/physims/charts/nr-ulsim/values.yaml b/charts/physims/charts/nr-ulsim/values.yaml
index 2bf96498e880be7942dfa9e6bfc58e768b203208..71c455b69cc55849105891c6821681b3a72ebef1 100644
--- a/charts/physims/charts/nr-ulsim/values.yaml
+++ b/charts/physims/charts/nr-ulsim/values.yaml
@@ -4,11 +4,11 @@
 
 replicaCount: 1
 
-namespace: "oaicicd-ran-tmp"
+namespace: "OAICICD_PROJECT"
 
 image:
   registry: local
-  repository: image-registry.openshift-image-registry.svc:5000/oaicicd-ran-tmp/oai-physim
+  repository: image-registry.openshift-image-registry.svc:5000/OAICICD_PROJECT/oai-physim
   version: temp
   # pullPolicy: IfNotPresent or Never or Always
   pullPolicy: Always
diff --git a/charts/physims/charts/polartest/values.yaml b/charts/physims/charts/polartest/values.yaml
index e0a532fdd8f419fe0a6f732cd0c8ec000ccf250c..e0751e8ec48cc3798097989abb7abea4cb8f5de8 100644
--- a/charts/physims/charts/polartest/values.yaml
+++ b/charts/physims/charts/polartest/values.yaml
@@ -4,11 +4,11 @@
 
 replicaCount: 1
 
-namespace: "oaicicd-ran-tmp"
+namespace: "OAICICD_PROJECT"
 
 image:
   registry: local
-  repository: image-registry.openshift-image-registry.svc:5000/oaicicd-ran-tmp/oai-physim
+  repository: image-registry.openshift-image-registry.svc:5000/OAICICD_PROJECT/oai-physim
   version: temp
   # pullPolicy: IfNotPresent or Never or Always
   pullPolicy: Always
diff --git a/charts/physims/charts/smallblocktest/values.yaml b/charts/physims/charts/smallblocktest/values.yaml
index f2f113d9b6cc946957c44f9cc34a885992e37a87..f933a978fd20515f5226e4f1232b77cdce3cb7f0 100644
--- a/charts/physims/charts/smallblocktest/values.yaml
+++ b/charts/physims/charts/smallblocktest/values.yaml
@@ -4,11 +4,11 @@
 
 replicaCount: 1
 
-namespace: "oaicicd-ran-tmp"
+namespace: "OAICICD_PROJECT"
 
 image:
   registry: local
-  repository: image-registry.openshift-image-registry.svc:5000/oaicicd-ran-tmp/oai-physim
+  repository: image-registry.openshift-image-registry.svc:5000/OAICICD_PROJECT/oai-physim
   version: temp
   # pullPolicy: IfNotPresent or Never or Always
   pullPolicy: Always
diff --git a/charts/physims/charts/ulsim/values.yaml b/charts/physims/charts/ulsim/values.yaml
index 35dc14d596cf6cbb05b844b84710645e2743479a..d25b6fc2a5351e6208124d06532dd4377d0d913b 100644
--- a/charts/physims/charts/ulsim/values.yaml
+++ b/charts/physims/charts/ulsim/values.yaml
@@ -4,11 +4,11 @@
 
 replicaCount: 1
 
-namespace: "oaicicd-ran-tmp"
+namespace: "OAICICD_PROJECT"
 
 image:
   registry: local
-  repository: image-registry.openshift-image-registry.svc:5000/oaicicd-ran-tmp/oai-physim
+  repository: image-registry.openshift-image-registry.svc:5000/OAICICD_PROJECT/oai-physim
   version: temp
   # pullPolicy: IfNotPresent or Never or Always
   pullPolicy: Always
diff --git a/charts/physims/templates/rbac.yaml b/charts/physims/templates/rbac.yaml
index 35f956a203beaf004b75369e524147dc0afabf1b..b341744796100cc2d95fb580eac9ec60db1726df 100644
--- a/charts/physims/templates/rbac.yaml
+++ b/charts/physims/templates/rbac.yaml
@@ -1,12 +1,26 @@
-apiVersion: rbac.authorization.k8s.io/v1beta1
-kind: ClusterRoleBinding
+apiVersion: rbac.authorization.k8s.io/v1
+kind: Role
 metadata:
-  name: {{ .Chart.Name }}-{{ .Values.global.namespace }}-rbac
-roleRef:
-  apiGroup: rbac.authorization.k8s.io
-  kind: ClusterRole
-  name: cluster-admin
+  name: {{ .Chart.Name }}-{{ .Release.Namespace }}-role
+rules:
+- apiGroups:
+  - security.openshift.io
+  resourceNames:
+  - privileged
+  resources:
+  - securitycontextconstraints
+  verbs:
+  - use
+---
+apiVersion: rbac.authorization.k8s.io/v1
+kind: RoleBinding
+metadata:
+  name: {{ .Chart.Name }}-{{ .Release.Namespace }}-binding
 subjects:
 - kind: ServiceAccount
   name: {{ .Values.global.serviceAccountName }}
-  namespace: {{ .Values.global.namespace }}
+  namespace: {{ .Release.Namespace }}
+roleRef:
+  kind: Role
+  name: {{ .Chart.Name }}-{{ .Release.Namespace }}-role
+  apiGroup: rbac.authorization.k8s.io
diff --git a/charts/physims/values.yaml b/charts/physims/values.yaml
index b348e822bb0e2e64ed7ae2f2c1c6e737f0afd5ec..d5253c781226742bf7dc65bfa6e8b4f82cf5aa1f 100644
--- a/charts/physims/values.yaml
+++ b/charts/physims/values.yaml
@@ -4,9 +4,9 @@
 
 global:
   serviceAccountName: oai-physim-sa
-  namespace: "oaicicd-ran-tmp"
+  namespace: "OAICICD_PROJECT"
   image:
-    repository: image-registry.openshift-image-registry.svc:5000/oaicicd-ran-tmp/oai-physim
+    repository: image-registry.openshift-image-registry.svc:5000/OAICICD_PROJECT/oai-physim
     version: TAG
 
 ## Declaring values specific to coressponding physim to overwrite
diff --git a/ci-scripts/Jenkinsfile-push-registry b/ci-scripts/Jenkinsfile-push-registry
index f5847ff0aab2e45adee158f8f5d8fceda735f209..bc1a80ba614fc3554e4c9c1d00bd508acd06d551 100644
--- a/ci-scripts/Jenkinsfile-push-registry
+++ b/ci-scripts/Jenkinsfile-push-registry
@@ -26,6 +26,9 @@ def nodeExecutor = params.nodeExecutor
 // Name of the phone resource
 def ciServerResource = params.serverResource
 
+// Docker Hub account to push to
+def DH_Account = "oaisoftwarealliance"
+
 pipeline {
   agent {
     label nodeExecutor
@@ -66,11 +69,11 @@ pipeline {
             def listOfImages = ["oai-enb", "oai-gnb", "oai-lte-ue", "oai-nr-ue"]
             sh "docker login -u ${DH_Username} -p ${DH_Password} > /dev/null 2>&1"
             listOfImages.eachWithIndex { item, iindex ->
-              sh "docker image tag ${item}:develop ${DH_Username}/${item}:develop"
-              sh "docker image tag ${item}:develop ${DH_Username}/${item}:${WEEK_TAG}"
-              sh "docker push --quiet ${DH_Username}/${item}:${WEEK_TAG}"
-              sh "docker push --quiet ${DH_Username}/${item}:develop"
-              sh "docker rmi ${DH_Username}/${item}:${WEEK_TAG} ${DH_Username}/${item}:develop"
+              sh "docker image tag ${item}:develop ${DH_Account}/${item}:develop"
+              sh "docker image tag ${item}:develop ${DH_Account}/${item}:${WEEK_TAG}"
+              sh "docker push --quiet ${DH_Account}/${item}:${WEEK_TAG}"
+              sh "docker push --quiet ${DH_Account}/${item}:develop"
+              sh "docker rmi ${DH_Account}/${item}:${WEEK_TAG} ${DH_Account}/${item}:develop"
             }
             sh "docker logout > /dev/null 2>&1"
           }
diff --git a/ci-scripts/build_fr1_template.yaml b/ci-scripts/build_fr1_template.yaml
index 02e49bc4b59b303ee3a1cd36136a34d3796ce0ad..5c7b2fc6f4cf316e22515494c5532cc030853992 100755
--- a/ci-scripts/build_fr1_template.yaml
+++ b/ci-scripts/build_fr1_template.yaml
@@ -14,7 +14,7 @@ steps:
 
 
 ADB: #on Caracal
-  ADBIPAddress : 192.168.18.196
+  ADBIPAddress : 172.21.16.132
   ADBUserName : oaici
   ADBPassword : KkexF6CErOi1fNuebCPsuIVK
 
diff --git a/ci-scripts/ci_ueinfra.yaml b/ci-scripts/ci_ueinfra.yaml
index 89bda5fa920008349644726ab08146ceee7631d9..b888f6bb59fc0257c9d402e18a0e86178d4d2537 100644
--- a/ci-scripts/ci_ueinfra.yaml
+++ b/ci-scripts/ci_ueinfra.yaml
@@ -12,7 +12,7 @@ idefix:
   LogStore : /media/usb-drive/ci_qlogs
   PLMN : 22201
   UENetwork : wwan0 
-  HostIPAddress : 192.168.18.188
+  HostIPAddress : 172.21.16.135
   HostUsername : oaicicd
   HostPassword : oaicicd
   HostSourceCodePath : none
@@ -32,7 +32,7 @@ nrmodule2_quectel:
   LogStore : /media/ci_qlogs  
   PLMN : 20897
   UENetwork : wwan0
-  HostIPAddress : 192.168.18.189
+  HostIPAddress : 172.21.16.139
   HostUsername : nrmodule2 
   HostPassword : linux 
   HostSourceCodePath : none
@@ -40,6 +40,7 @@ nrmodule2_quectel:
     - sudo -S ip link set dev wwan1 mtu 1500
   MTU : 1500
 
+# CAUTION: 192.168.18.89 address has to be changed when the server is moved
 #single UE single ping
 amarisoft_ue_1:
   ID: amarisoft_ue_1
@@ -97,7 +98,7 @@ dummy:
   DetachScript : ''
   PLMN : 22201
   UENetwork : wwan0
-  HostIPAddress : 192.168.18.188
+  HostIPAddress : 172.21.16.135
   HostUsername : oaicicd
   HostPassword : oaicicd
   HostSourceCodePath : none
diff --git a/ci-scripts/cls_containerize.py b/ci-scripts/cls_containerize.py
index 8092febe39666ada6ac15a5c49a8e8af8e69708e..89a3ac586d43504345b6692099028bf7a13595f6 100644
--- a/ci-scripts/cls_containerize.py
+++ b/ci-scripts/cls_containerize.py
@@ -243,7 +243,7 @@ class Containerize():
 		# Build the base image only on Push Events (not on Merge Requests)
 		# On when the base image docker file is being modified.
 		if forceBaseImageBuild:
-			mySSH.command(self.cli + ' build ' + self.cliBuildOptions + ' --target ' + baseImage + ' --tag ' + baseImage + ':' + baseTag + ' --file docker/Dockerfile.base' + self.dockerfileprefix + ' --build-arg NEEDED_GIT_PROXY="http://proxy.eurecom.fr:8080" . > cmake_targets/log/ran-base.log 2>&1', '\$', 1600)
+			mySSH.command(self.cli + ' build ' + self.cliBuildOptions + ' --target ' + baseImage + ' --tag ' + baseImage + ':' + baseTag + ' --file docker/Dockerfile.base' + self.dockerfileprefix + ' . > cmake_targets/log/ran-base.log 2>&1', '\$', 1600)
 		# First verify if the base image was properly created.
 		status = True
 		mySSH.command(self.cli + ' image inspect --format=\'Size = {{.Size}} bytes\' ' + baseImage + ':' + baseTag, '\$', 5)
@@ -1146,19 +1146,19 @@ class Containerize():
 			mySSH.open(ipAddr, userName, password)
 			# Check if route to asterix gnb exists
 			mySSH.command('ip route | grep --colour=never "192.168.68.64/26"', '\$', 10)
-			result = re.search('192.168.18.194', mySSH.getBefore())
+			result = re.search('172.21.16.127', mySSH.getBefore())
 			if result is None:
-				mySSH.command('echo ' + password + ' | sudo -S ip route add 192.168.68.64/26 via 192.168.18.194 dev eno1', '\$', 10)
+				mySSH.command('echo ' + password + ' | sudo -S ip route add 192.168.68.64/26 via 172.21.16.127 dev eno1', '\$', 10)
 			# Check if route to obelix enb exists
 			mySSH.command('ip route | grep --colour=never "192.168.68.128/26"', '\$', 10)
-			result = re.search('192.168.18.193', mySSH.getBefore())
+			result = re.search('172.21.16.128', mySSH.getBefore())
 			if result is None:
-				mySSH.command('echo ' + password + ' | sudo -S ip route add 192.168.68.128/26 via 192.168.18.193 dev eno1', '\$', 10)
+				mySSH.command('echo ' + password + ' | sudo -S ip route add 192.168.68.128/26 via 172.21.16.128 dev eno1', '\$', 10)
 			# Check if route to nepes gnb exists
 			mySSH.command('ip route | grep --colour=never "192.168.68.192/26"', '\$', 10)
-			result = re.search('192.168.18.209', mySSH.getBefore())
+			result = re.search('172.21.16.137', mySSH.getBefore())
 			if result is None:
-				mySSH.command('echo ' + password + ' | sudo -S ip route add 192.168.68.192/26 via 192.168.18.209 dev eno1', '\$', 10)
+				mySSH.command('echo ' + password + ' | sudo -S ip route add 192.168.68.192/26 via 172.21.16.137 dev eno1', '\$', 10)
 			# Check if forwarding is enabled
 			mySSH.command('sysctl net.ipv4.conf.all.forwarding', '\$', 10)
 			result = re.search('net.ipv4.conf.all.forwarding = 1', mySSH.getBefore())
@@ -1174,19 +1174,19 @@ class Containerize():
 			mySSH.open(ipAddr, userName, password)
 			# Check if route to porcepix epc exists
 			mySSH.command('ip route | grep --colour=never "192.168.61.192/26"', '\$', 10)
-			result = re.search('192.168.18.210', mySSH.getBefore())
+			result = re.search('172.21.16.136', mySSH.getBefore())
 			if result is None:
-				mySSH.command('echo ' + password + ' | sudo -S ip route add 192.168.61.192/26 via 192.168.18.210 dev em1', '\$', 10)
+				mySSH.command('echo ' + password + ' | sudo -S ip route add 192.168.61.192/26 via 172.21.16.136 dev em1', '\$', 10)
 			# Check if route to porcepix cn5g exists
 			mySSH.command('ip route | grep --colour=never "192.168.70.128/26"', '\$', 10)
-			result = re.search('192.168.18.210', mySSH.getBefore())
+			result = re.search('172.21.16.136', mySSH.getBefore())
 			if result is None:
-				mySSH.command('echo ' + password + ' | sudo -S ip route add 192.168.70.128/26 via 192.168.18.210 dev em1', '\$', 10)
+				mySSH.command('echo ' + password + ' | sudo -S ip route add 192.168.70.128/26 via 172.21.16.136 dev em1', '\$', 10)
 			# Check if X2 route to obelix enb exists
 			mySSH.command('ip route | grep --colour=never "192.168.68.128/26"', '\$', 10)
-			result = re.search('192.168.18.193', mySSH.getBefore())
+			result = re.search('172.21.16.128', mySSH.getBefore())
 			if result is None:
-				mySSH.command('echo ' + password + ' | sudo -S ip route add 192.168.68.128/26 via 192.168.18.193 dev em1', '\$', 10)
+				mySSH.command('echo ' + password + ' | sudo -S ip route add 192.168.68.128/26 via 172.21.16.128 dev em1', '\$', 10)
 			# Check if forwarding is enabled
 			mySSH.command('sysctl net.ipv4.conf.all.forwarding', '\$', 10)
 			result = re.search('net.ipv4.conf.all.forwarding = 1', mySSH.getBefore())
@@ -1202,19 +1202,19 @@ class Containerize():
 			mySSH.open(ipAddr, userName, password)
 			# Check if route to porcepix epc exists
 			mySSH.command('ip route | grep --colour=never "192.168.61.192/26"', '\$', 10)
-			result = re.search('192.168.18.210', mySSH.getBefore())
+			result = re.search('172.21.16.136', mySSH.getBefore())
 			if result is None:
-				mySSH.command('echo ' + password + ' | sudo -S ip route add 192.168.61.192/26 via 192.168.18.210 dev eno1', '\$', 10)
+				mySSH.command('echo ' + password + ' | sudo -S ip route add 192.168.61.192/26 via 172.21.16.136 dev eno1', '\$', 10)
 			# Check if X2 route to asterix gnb exists
 			mySSH.command('ip route | grep --colour=never "192.168.68.64/26"', '\$', 10)
-			result = re.search('192.168.18.194', mySSH.getBefore())
+			result = re.search('172.21.16.127', mySSH.getBefore())
 			if result is None:
-				mySSH.command('echo ' + password + ' | sudo -S ip route add 192.168.68.64/26 via 192.168.18.194 dev eno1', '\$', 10)
+				mySSH.command('echo ' + password + ' | sudo -S ip route add 192.168.68.64/26 via 172.21.16.127 dev eno1', '\$', 10)
 			# Check if X2 route to nepes gnb exists
 			mySSH.command('ip route | grep --colour=never "192.168.68.192/26"', '\$', 10)
-			result = re.search('192.168.18.209', mySSH.getBefore())
+			result = re.search('172.21.16.137', mySSH.getBefore())
 			if result is None:
-				mySSH.command('echo ' + password + ' | sudo -S ip route add 192.168.68.192/26 via 192.168.18.209 dev eno1', '\$', 10)
+				mySSH.command('echo ' + password + ' | sudo -S ip route add 192.168.68.192/26 via 172.21.16.137 dev eno1', '\$', 10)
 			# Check if forwarding is enabled
 			mySSH.command('sysctl net.ipv4.conf.all.forwarding', '\$', 10)
 			result = re.search('net.ipv4.conf.all.forwarding = 1', mySSH.getBefore())
@@ -1230,14 +1230,14 @@ class Containerize():
 			mySSH.open(ipAddr, userName, password)
 			# Check if route to porcepix epc exists
 			mySSH.command('ip route | grep --colour=never "192.168.61.192/26"', '\$', 10)
-			result = re.search('192.168.18.210', mySSH.getBefore())
+			result = re.search('172.21.16.136', mySSH.getBefore())
 			if result is None:
-				mySSH.command('echo ' + password + ' | sudo -S ip route add 192.168.61.192/26 via 192.168.18.210 dev enp0s31f6', '\$', 10)
+				mySSH.command('echo ' + password + ' | sudo -S ip route add 192.168.61.192/26 via 172.21.16.136 dev enp0s31f6', '\$', 10)
 			# Check if X2 route to obelix enb exists
 			mySSH.command('ip route | grep --colour=never "192.168.68.128/26"', '\$', 10)
-			result = re.search('192.168.18.193', mySSH.getBefore())
+			result = re.search('172.21.16.128', mySSH.getBefore())
 			if result is None:
-				mySSH.command('echo ' + password + ' | sudo -S ip route add 192.168.68.128/26 via 192.168.18.193 dev enp0s31f6', '\$', 10)
+				mySSH.command('echo ' + password + ' | sudo -S ip route add 192.168.68.128/26 via 172.21.16.128 dev enp0s31f6', '\$', 10)
 			# Check if forwarding is enabled
 			mySSH.command('sysctl net.ipv4.conf.all.forwarding', '\$', 10)
 			result = re.search('net.ipv4.conf.all.forwarding = 1', mySSH.getBefore())
diff --git a/ci-scripts/cls_log_mgt.py b/ci-scripts/cls_log_mgt.py
index 905a105512213e0c8ad80e450931d2dd43de99c8..f1dbf6b8ec2a90bba38808f0f27e4aa54ec9383c 100644
--- a/ci-scripts/cls_log_mgt.py
+++ b/ci-scripts/cls_log_mgt.py
@@ -64,10 +64,10 @@ class Log_Mgt:
 		if m is not None:
 			return int(m.group(1))
 
-	def __RemoveOldest(self):
+	def __RemoveOldest(self, days):
 		mySSH = sshconnection.SSHConnection()
 		mySSH.open(self.IPAddress, self.Username, self.Password)
-		COMMAND='echo ' + self.Password + ' | sudo -S find ' + self.path + ' -type f -mtime +14 -delete'
+		COMMAND='echo ' + self.Password + ' | sudo -S find ' + self.path + ' -type f -mtime +' +  str(days) + ' -delete'
 		mySSH.command(COMMAND,'\$',20)
 		mySSH.close()
 
@@ -79,13 +79,18 @@ class Log_Mgt:
 
 
 	def LogRotation(self):
-		used_space = self.__CheckUsedSpace() #avail space in target folder
-		if used_space > 80 :
-			logging.debug('\u001B[1;37;41m  Used Disk > 80%, on '  + self.Username+'@'+self.IPAddress + '\u001B[0m')
-			logging.debug('\u001B[1;37;41m  Removing Artifacts older than 14 days \u001B[0m')
-			self.__RemoveOldest()
-		else:
-			logging.debug('Used Disk < 80%, on '  + self.Username+'@'+self.IPAddress +', no cleaning required')
+		doLoop = True
+		nbDays = 14
+		while doLoop and nbDays > 1:
+			used_space = self.__CheckUsedSpace() #avail space in target folder
+			if used_space > 80 :
+				logging.debug('\u001B[1;37;41m  Used Disk (' + str(used_space) + '%) > 80%, on '  + self.Username+'@'+self.IPAddress + '\u001B[0m')
+				logging.debug('\u001B[1;37;41m  Removing Artifacts older than ' + str(nbDays) + ' days \u001B[0m')
+				self.__RemoveOldest(nbDays)
+				nbDays -= 1
+			else:
+				logging.debug('Used Disk (' + str(used_space) + '%) < 80%, on '  + self.Username+'@'+self.IPAddress +', no cleaning required')
+				doLoop = False
 
 
 			
diff --git a/ci-scripts/cls_module_ue.py b/ci-scripts/cls_module_ue.py
index fb107007980d53059da297e06bcb396a80922480..dcf75a34fcd616a111cc3c98fc25f1e9281706dd 100644
--- a/ci-scripts/cls_module_ue.py
+++ b/ci-scripts/cls_module_ue.py
@@ -107,14 +107,15 @@ class Module_UE:
 	def GetModuleIPAddress(self):
 		HOST=self.HostUsername+'@'+self.HostIPAddress
 		response= []
-		tentative = 3 
+		tentative = 8
 		while (len(response)==0) and (tentative>0):
 			COMMAND="ip a show dev " + self.UENetwork + " | grep --colour=never inet | grep " + self.UENetwork
-			logging.debug(COMMAND)
+			if tentative == 8:
+				logging.debug(COMMAND)
 			ssh = subprocess.Popen(["ssh", "%s" % HOST, COMMAND],shell=False,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
 			response = ssh.stdout.readlines()
 			tentative-=1
-			time.sleep(10)
+			time.sleep(2)
 		if (tentative==0) and (len(response)==0):
 			logging.debug('\u001B[1;37;41m Module IP Address Not Found! Time expired \u001B[0m')
 			return -1
diff --git a/ci-scripts/html.py b/ci-scripts/cls_oai_html.py
similarity index 100%
rename from ci-scripts/html.py
rename to ci-scripts/cls_oai_html.py
diff --git a/ci-scripts/cls_oaicitest.py b/ci-scripts/cls_oaicitest.py
index 33910f1f9bd5dbe8ebe0e025d1745c9a3d61baba..9d5ae840387e4e9d12ba33352e913167fd1ce4c4 100644
--- a/ci-scripts/cls_oaicitest.py
+++ b/ci-scripts/cls_oaicitest.py
@@ -439,7 +439,7 @@ class OaiCiTest():
 					while cnt < 4:
 						Module_UE.Command("wup")
 						logging.debug("Waiting for IP address to be assigned")
-						time.sleep(20)
+						time.sleep(5)
 						logging.debug("Retrieve IP address")
 						status=Module_UE.GetModuleIPAddress()
 						if status==0:
@@ -1111,7 +1111,7 @@ class OaiCiTest():
 			while cnt < 4:
 				Module_UE.Command("wup")
 				logging.debug("Waiting for IP address to be assigned")
-				time.sleep(20)
+				time.sleep(5)
 				logging.debug("Retrieve IP address")
 				status=Module_UE.GetModuleIPAddress()
 				if status==0:
diff --git a/ci-scripts/cls_physim.py b/ci-scripts/cls_physim.py
index 33792f6ca4cb2c57f6179c1460ef43f3d2b0d183..ecd8f63af121561c3d004b2f2a0bef9443b71bf4 100644
--- a/ci-scripts/cls_physim.py
+++ b/ci-scripts/cls_physim.py
@@ -32,7 +32,7 @@ import logging
 #to create a SSH object locally in the methods
 import sshconnection
 #to update the HTML object
-import html
+import cls_oai_html
 from multiprocessing import SimpleQueue
 #for log folder maintenance
 import os
diff --git a/ci-scripts/cls_physim1.py b/ci-scripts/cls_physim1.py
index 83fb74b7cb0e030969dd82e654ad2eb4470d184c..3907fc2a34d3364225f0c9534b1350cb0dbcd4f4 100644
--- a/ci-scripts/cls_physim1.py
+++ b/ci-scripts/cls_physim1.py
@@ -33,7 +33,7 @@
 #-----------------------------------------------------------
 import logging
 import sshconnection as SSH
-import html
+import cls_oai_html
 import os
 import re
 import time
@@ -153,6 +153,7 @@ class PhySim:
 		mySSH.command(f'oc project {ocProjectName}', '\$', 30)
 		if mySSH.getBefore().count(f'Already on project "{ocProjectName}"') == 0 and mySSH.getBefore().count(f'Now using project "{self.OCProjectName}"') == 0:
 			logging.error(f'\u001B[1m Unable to access OC project {ocProjectName}\u001B[0m')
+			mySSH.command('oc logout', '\$', 30)
 			mySSH.close()
 			HTML.CreateHtmlTestRow('N/A', 'KO', CONST.OC_PROJECT_FAIL)
 			RAN.prematureExit = True
@@ -161,9 +162,10 @@ class PhySim:
 			logging.debug(f'\u001B[1m   Now using project {ocProjectName}\u001B[0m')
 
 		# Tag the image and push to the OC cluster
-		mySSH.command('oc whoami -t | sudo podman login -u ' + ocUserName + ' --password-stdin https://default-route-openshift-image-registry.apps.5glab.nsa.eurecom.fr/ --tls-verify=false', '\$', 30)
+		mySSH.command('oc whoami -t | sudo podman login -u ' + ocUserName + ' --password-stdin https://default-route-openshift-image-registry.apps.oai.cs.eurecom.fr/ --tls-verify=false', '\$', 30)
 		if mySSH.getBefore().count('Login Succeeded!') == 0:
 			logging.error('\u001B[1m Podman Login to OC Cluster Registry Failed\u001B[0m')
+			mySSH.command('oc logout', '\$', 30)
 			mySSH.close()
 			HTML.CreateHtmlTestRow('N/A', 'KO', CONST.OC_LOGIN_FAIL)
 			RAN.prematureExit = True
@@ -171,9 +173,11 @@ class PhySim:
 		else:
 			logging.debug('\u001B[1m Podman Login to OC Cluster Registry Successfully\u001B[0m')
 		time.sleep(2)
-		mySSH.command('oc create -f openshift/oai-physim-image-stream.yml', '\$', 30)
+		mySSH.command('oc create -f openshift/oai-physim-image-stream.yml || true', '\$', 30)
 		if mySSH.getBefore().count('(AlreadyExists):') == 0 and mySSH.getBefore().count('created') == 0:
 			logging.error(f'\u001B[1m Image Stream "oai-physim" Creation Failed on OC Cluster {ocProjectName}\u001B[0m')
+			mySSH.command('sudo podman logout https://default-route-openshift-image-registry.apps.oai.cs.eurecom.fr/', '\$', 6)
+			mySSH.command('oc logout', '\$', 30)
 			mySSH.close()
 			HTML.CreateHtmlTestRow('N/A', 'KO', CONST.OC_IS_FAIL)
 			RAN.prematureExit = True
@@ -181,11 +185,13 @@ class PhySim:
 		else:
 			logging.debug(f'\u001B[1m   Image Stream "oai-physim" created on OC project {ocProjectName}\u001B[0m')
 		time.sleep(2)
-		mySSH.command(f'sudo podman tag oai-physim:{imageTag} default-route-openshift-image-registry.apps.5glab.nsa.eurecom.fr/{self.OCProjectName}/oai-physim:{imageTag}', '\$', 30)
+		mySSH.command(f'sudo podman tag oai-physim:{imageTag} default-route-openshift-image-registry.apps.oai.cs.eurecom.fr/{self.OCProjectName}/oai-physim:{imageTag}', '\$', 30)
 		time.sleep(2)
-		mySSH.command(f'sudo podman push default-route-openshift-image-registry.apps.5glab.nsa.eurecom.fr/{self.OCProjectName}/oai-physim:{imageTag} --tls-verify=false', '\$', 180)
+		mySSH.command(f'sudo podman push default-route-openshift-image-registry.apps.oai.cs.eurecom.fr/{self.OCProjectName}/oai-physim:{imageTag} --tls-verify=false', '\$', 180)
 		if mySSH.getBefore().count('Storing signatures') == 0:
 			logging.error('\u001B[1m Image "oai-physim" push to OC Cluster Registry Failed\u001B[0m')
+			mySSH.command('sudo podman logout https://default-route-openshift-image-registry.apps.oai.cs.eurecom.fr/', '\$', 6)
+			mySSH.command('oc logout', '\$', 30)
 			mySSH.close()
 			HTML.CreateHtmlTestRow('N/A', 'KO', CONST.OC_IS_FAIL)
 			RAN.prematureExit = True
@@ -195,8 +201,9 @@ class PhySim:
 
 		# Using helm charts deployment
 		time.sleep(5)
+		mySSH.command(f'grep -rl OAICICD_PROJECT ./charts/ | xargs sed -i -e "s#OAICICD_PROJECT#{ocProjectName}#"', '\$', 30)
 		mySSH.command(f'sed -i -e "s#TAG#{imageTag}#g" ./charts/physims/values.yaml', '\$', 6)
-		mySSH.command('helm install physim ./charts/physims/ | tee -a cmake_targets/log/physim_helm_summary.txt 2>&1', '\$', 30)
+		mySSH.command('helm install physim ./charts/physims/ 2>&1 | tee -a cmake_targets/log/physim_helm_summary.txt', '\$', 30)
 		if mySSH.getBefore().count('STATUS: deployed') == 0:
 			logging.error('\u001B[1m Deploying PhySim Failed using helm chart on OC Cluster\u001B[0m')
 			mySSH.command('helm uninstall physim >> cmake_targets/log/physim_helm_summary.txt 2>&1', '\$', 30)
@@ -206,8 +213,10 @@ class PhySim:
 				mySSH.command('oc get pods -l app.kubernetes.io/instance=physim', '\$', 6, resync=True)
 				if re.search('No resources found', mySSH.getBefore()):
 					isFinished1 = True
-			mySSH.command(f'sudo podman rmi default-route-openshift-image-registry.apps.5glab.nsa.eurecom.fr/{self.OCProjectName}/oai-physim:{imageTag}', '\$', 30)
+			mySSH.command(f'sudo podman rmi default-route-openshift-image-registry.apps.oai.cs.eurecom.fr/{self.OCProjectName}/oai-physim:{imageTag}', '\$', 30)
 			mySSH.command('oc delete is oai-physim', '\$', 30)
+			mySSH.command('sudo podman logout https://default-route-openshift-image-registry.apps.oai.cs.eurecom.fr/', '\$', 6)
+			mySSH.command('oc logout', '\$', 30)
 			mySSH.close()
 			self.AnalyzeLogFile_phySim(HTML)
 			RAN.prematureExit = True
@@ -227,7 +236,7 @@ class PhySim:
 		if isRunning == False:
 			logging.error('\u001B[1m Some PODS Running FAILED \u001B[0m')
 			mySSH.command('oc get pods -l app.kubernetes.io/instance=physim 2>&1 | tee -a cmake_targets/log/physim_pods_summary.txt', '\$', 6)
-			mySSH.command('helm uninstall physim >> cmake_targets/log/physim_helm_summary.txt 2>&1', '\$', 6)
+			mySSH.command('helm uninstall physim 2>&1 >> cmake_targets/log/physim_helm_summary.txt', '\$', 6)
 			self.AnalyzeLogFile_phySim(HTML)
 			isFinished1 = False
 			while(isFinished1 == False):
@@ -235,8 +244,10 @@ class PhySim:
 				mySSH.command('oc get pods -l app.kubernetes.io/instance=physim', '\$', 6, resync=True)
 				if re.search('No resources found', mySSH.getBefore()):
 					isFinished1 = True
-			mySSH.command(f'sudo podman rmi default-route-openshift-image-registry.apps.5glab.nsa.eurecom.fr/{self.OCProjectName}/oai-physim:{imageTag}', '\$', 6)
+			mySSH.command(f'sudo podman rmi default-route-openshift-image-registry.apps.oai.cs.eurecom.fr/{self.OCProjectName}/oai-physim:{imageTag}', '\$', 6)
 			mySSH.command('oc delete is oai-physim', '\$', 6)
+			mySSH.command('sudo podman logout https://default-route-openshift-image-registry.apps.oai.cs.eurecom.fr/', '\$', 6)
+			mySSH.command('oc logout', '\$', 30)
 			HTML.CreateHtmlTestRow('N/A', 'KO', CONST.OC_PHYSIM_DEPLOY_FAIL)
 			HTML.CreateHtmlTestRowPhySimTestResult(self.testSummary,self.testResult)
 			RAN.prematureExit = True
@@ -293,9 +304,10 @@ class PhySim:
 				isFinished1 = True
 		if isFinished1 == True:
 			logging.debug('\u001B[1m UnDeployed PhySim Successfully on OC Cluster\u001B[0m')
-		mySSH.command(f'sudo podman rmi default-route-openshift-image-registry.apps.5glab.nsa.eurecom.fr/{self.OCProjectName}/oai-physim:{imageTag}', '\$', 6)
+		mySSH.command(f'sudo podman rmi default-route-openshift-image-registry.apps.oai.cs.eurecom.fr/{self.OCProjectName}/oai-physim:{imageTag}', '\$', 6)
 		mySSH.command('oc delete is oai-physim', '\$', 6)
 		logging.debug('\u001B[1m Deleted the Image and ImageStream\u001B[0m')
+		mySSH.command('sudo podman logout https://default-route-openshift-image-registry.apps.oai.cs.eurecom.fr/', '\$', 6)
 		mySSH.command('oc logout', '\$', 6)
 		mySSH.close()
 		self.AnalyzeLogFile_phySim(HTML)
diff --git a/ci-scripts/conf_files/enb.band38.lte_2x2.100PRB.usrpn310.conf b/ci-scripts/conf_files/enb.band38.lte_2x2.100PRB.usrpn310.conf
index fe2e031acb6d0a000b68a973ba54c89867f85783..a7100a97e3314417eaf15e621ef92228b6c762be 100644
--- a/ci-scripts/conf_files/enb.band38.lte_2x2.100PRB.usrpn310.conf
+++ b/ci-scripts/conf_files/enb.band38.lte_2x2.100PRB.usrpn310.conf
@@ -237,7 +237,7 @@ RUs = (
          max_pdschReferenceSignalPower = -27;
          max_rxgain                    = 75;
          eNB_instances  = [0];
-         sdr_addrs      = "mgmt_addr=192.168.18.241,addr=192.168.20.2,second_addr=192.168.10.2";
+         sdr_addrs      = "mgmt_addr=172.21.19.13,addr=192.168.20.2,second_addr=192.168.10.2";
 
     }
 );  
diff --git a/ci-scripts/conf_files/enb.band38.lte_2x2_tm2.100PRB.usrpn310.conf b/ci-scripts/conf_files/enb.band38.lte_2x2_tm2.100PRB.usrpn310.conf
index a0742c57a69022c74ec2e244ea320ea0ff0f83d7..1f358c15715e68f8f60df52c57f4bea37353054b 100644
--- a/ci-scripts/conf_files/enb.band38.lte_2x2_tm2.100PRB.usrpn310.conf
+++ b/ci-scripts/conf_files/enb.band38.lte_2x2_tm2.100PRB.usrpn310.conf
@@ -237,7 +237,7 @@ RUs = (
          max_pdschReferenceSignalPower = -27;
          max_rxgain                    = 75;
          eNB_instances  = [0];
-         sdr_addrs      = "mgmt_addr=192.168.18.241,addr=192.168.20.2,second_addr=192.168.10.2";
+         sdr_addrs      = "mgmt_addr=172.21.19.13,addr=192.168.20.2,second_addr=192.168.10.2";
 
     }
 );  
diff --git a/ci-scripts/conf_files/enb.band38.nsa_2x2.100PRB.usrpn310.conf b/ci-scripts/conf_files/enb.band38.nsa_2x2.100PRB.usrpn310.conf
index dfc9beda715c695b17672f780d7344af3f46572b..f7088aee5249884474f2bd395ee807b651ee6647 100644
--- a/ci-scripts/conf_files/enb.band38.nsa_2x2.100PRB.usrpn310.conf
+++ b/ci-scripts/conf_files/enb.band38.nsa_2x2.100PRB.usrpn310.conf
@@ -237,7 +237,7 @@ RUs = (
          max_pdschReferenceSignalPower = -27;
          max_rxgain                    = 75;
          eNB_instances  = [0];
-         sdr_addrs      = "mgmt_addr=192.168.18.241,addr=192.168.20.2,second_addr=192.168.10.2";
+         sdr_addrs      = "mgmt_addr=172.21.19.13,addr=192.168.20.2,second_addr=192.168.10.2";
 
     }
 );  
diff --git a/ci-scripts/conf_files/episci/episci_gnb.band78.sa.fr1.106PRB.usrpn310.conf b/ci-scripts/conf_files/episci/episci_gnb.band78.sa.fr1.106PRB.usrpn310.conf
index 40f6f911b16f017ef20b1f552ce449f35323f461..51ffb1d5cd2bb59f7818b390564b51278ec21ab7 100644
--- a/ci-scripts/conf_files/episci/episci_gnb.band78.sa.fr1.106PRB.usrpn310.conf
+++ b/ci-scripts/conf_files/episci/episci_gnb.band78.sa.fr1.106PRB.usrpn310.conf
@@ -239,7 +239,7 @@ RUs = (
          #beamforming 1x4 matrix:
          bf_weights = [0x00007fff, 0x0000, 0x0000, 0x0000];
          #clock_src = "external";
-         sdr_addrs = "mgmt_addr=192.168.18.240,addr=192.168.10.2,second_addr=192.168.20.2,clock_source=internal,time_source=internal"
+         sdr_addrs = "mgmt_addr=172.21.19.14,addr=192.168.10.2,second_addr=192.168.20.2,clock_source=internal,time_source=internal"
     }
 );
 
diff --git a/ci-scripts/conf_files/episci/proxy_gnb.band78.sa.fr1.106PRB.usrpn310.conf b/ci-scripts/conf_files/episci/proxy_gnb.band78.sa.fr1.106PRB.usrpn310.conf
index edcd4f06ffcf66f06868cf321fba144c6026bd94..f80ce3751a93ed88e88c9fe95f1083c02052a454 100644
--- a/ci-scripts/conf_files/episci/proxy_gnb.band78.sa.fr1.106PRB.usrpn310.conf
+++ b/ci-scripts/conf_files/episci/proxy_gnb.band78.sa.fr1.106PRB.usrpn310.conf
@@ -240,7 +240,7 @@ RUs = (
          #beamforming 1x4 matrix:
          bf_weights = [0x00007fff, 0x0000, 0x0000, 0x0000];
          #clock_src = "external";
-         sdr_addrs = "mgmt_addr=192.168.18.240,addr=192.168.10.2,second_addr=192.168.20.2,clock_source=internal,time_source=internal"
+         sdr_addrs = "mgmt_addr=172.21.19.14,addr=192.168.10.2,second_addr=192.168.20.2,clock_source=internal,time_source=internal"
     }
 );
 
diff --git a/ci-scripts/conf_files/gNB_SA_n78_106PRB.2x2_usrpn310.conf b/ci-scripts/conf_files/gNB_SA_n78_106PRB.2x2_usrpn310.conf
index 33ab30887f6a11df307cbaac8e61e8d288515309..d6edc092865e9247b94e09491d85a0d2f9af3a54 100644
--- a/ci-scripts/conf_files/gNB_SA_n78_106PRB.2x2_usrpn310.conf
+++ b/ci-scripts/conf_files/gNB_SA_n78_106PRB.2x2_usrpn310.conf
@@ -209,9 +209,9 @@ gNBs =
         {
 
            GNB_INTERFACE_NAME_FOR_NG_AMF            = "em1";
-           GNB_IPV4_ADDRESS_FOR_NG_AMF              = "192.168.18.194/24";
+           GNB_IPV4_ADDRESS_FOR_NG_AMF              = "172.21.16.127/24";
            GNB_INTERFACE_NAME_FOR_NGU               = "em1";
-           GNB_IPV4_ADDRESS_FOR_NGU                 = "192.168.18.194/24";
+           GNB_IPV4_ADDRESS_FOR_NGU                 = "172.21.16.127/24";
            GNB_PORT_FOR_S1U                         = 2152; # Spec 2152
         };
 
@@ -258,7 +258,7 @@ RUs = (
          ## beamforming 4x4 matrix:
          #bf_weights = [0x00007fff, 0x0000, 0x0000, 0x0000, 0x00000000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff];
 
-         sdr_addrs = "mgmt_addr=192.168.18.252,addr=192.168.10.2,second_addr=192.168.20.2,clock_source=internal,time_source=internal"
+         sdr_addrs = "mgmt_addr=172.21.19.14,addr=192.168.10.2,second_addr=192.168.20.2,clock_source=internal,time_source=internal"
     }
 );  
 
diff --git a/ci-scripts/conf_files/gNB_SA_n78_133PRB.2x2_usrpn310.conf b/ci-scripts/conf_files/gNB_SA_n78_133PRB.2x2_usrpn310.conf
index 4a5eaec89b5f2faa7518e5c3a8fd60473f40ecc6..7f4b11c35d8a598c8462050b8521ee3b611a32cf 100644
--- a/ci-scripts/conf_files/gNB_SA_n78_133PRB.2x2_usrpn310.conf
+++ b/ci-scripts/conf_files/gNB_SA_n78_133PRB.2x2_usrpn310.conf
@@ -206,9 +206,9 @@ gNBs =
         {
 
            GNB_INTERFACE_NAME_FOR_NG_AMF            = "em1";
-           GNB_IPV4_ADDRESS_FOR_NG_AMF              = "192.168.18.194/24";
+           GNB_IPV4_ADDRESS_FOR_NG_AMF              = "172.21.16.127/24";
            GNB_INTERFACE_NAME_FOR_NGU               = "em1";
-           GNB_IPV4_ADDRESS_FOR_NGU                 = "192.168.18.194/24";
+           GNB_IPV4_ADDRESS_FOR_NGU                 = "172.21.16.127/24";
            GNB_PORT_FOR_S1U                         = 2152; # Spec 2152
         };
 
@@ -254,7 +254,7 @@ RUs = (
          ## beamforming 4x4 matrix:
          #bf_weights = [0x00007fff, 0x0000, 0x0000, 0x0000, 0x00000000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff];
 
-         sdr_addrs = "mgmt_addr=192.168.18.252,addr=192.168.10.2,second_addr=192.168.20.2,clock_source=internal,time_source=internal"
+         sdr_addrs = "mgmt_addr=172.21.19.14,addr=192.168.10.2,second_addr=192.168.20.2,clock_source=internal,time_source=internal"
     }
 );  
 
diff --git a/ci-scripts/conf_files/gnb.band78.nsa_2x2.106PRB.usrpn310.conf b/ci-scripts/conf_files/gnb.band78.nsa_2x2.106PRB.usrpn310.conf
index 21863dcfc7bf99cbe6ba36501f36d192d8209f56..fa7c1905385be2d9420a39de8a2c02fc309aab36 100644
--- a/ci-scripts/conf_files/gnb.band78.nsa_2x2.106PRB.usrpn310.conf
+++ b/ci-scripts/conf_files/gnb.band78.nsa_2x2.106PRB.usrpn310.conf
@@ -199,12 +199,12 @@ gNBs =
 );
 
 MACRLCs = (
-	{
-	num_cc = 1;
-	tr_s_preference = "local_L1";
-	tr_n_preference = "local_RRC";
-	ulsch_max_frame_inactivity = 1;
-        }  
+{
+  num_cc                     = 1;
+  tr_s_preference            = "local_L1";
+  tr_n_preference            = "local_RRC";
+  ulsch_max_frame_inactivity = 0;
+}
 );
 
 L1s = (
@@ -213,6 +213,7 @@ L1s = (
   tr_n_preference = "local_mac";
   thread_pool_size = 8;
   prach_dtx_threshold = 120;
+  pucch0_dtx_threshold = 80;
 }
 );
 
@@ -230,7 +231,7 @@ RUs = (
          bf_weights = [0x00007fff, 0x00007fff];
          #clock_src = "external";
          sf_extension = 0 
-         sdr_addrs = "mgmt_addr=192.168.18.252,addr=192.168.10.2,second_addr=192.168.20.2,clock_source=internal,time_source=internal"
+         sdr_addrs = "mgmt_addr=172.21.19.14,addr=192.168.10.2,second_addr=192.168.20.2,clock_source=internal,time_source=internal"
     }
 );  
 
diff --git a/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.asue.conf b/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.asue.conf
index 60fb16318fc9011e69007a08364aae58b021c525..5e6b3fb217b52c512dc8e17e6ca6fb1acb81ec2f 100644
--- a/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.asue.conf
+++ b/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.asue.conf
@@ -264,7 +264,7 @@ RUs = (
          ## beamforming 4x4 matrix:
          #bf_weights = [0x00007fff, 0x0000, 0x0000, 0x0000, 0x00000000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff];
          sf_extension = 0
-         sdr_addrs = "mgmt_addr=192.168.18.252,addr=192.168.10.2,second_addr=192.168.20.2,clock_source=internal,time_source=internal"
+         sdr_addrs = "mgmt_addr=172.21.19.14,addr=192.168.10.2,second_addr=192.168.20.2,clock_source=internal,time_source=internal"
     }
 );
 
diff --git a/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.conf b/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.conf
index 1d7c4b57f08ec1a7b396097959cf1a9dac2aacf2..8489008300de5b4e7bff0a389f43be46a94b4ae8 100644
--- a/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.conf
+++ b/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.conf
@@ -261,7 +261,7 @@ RUs = (
          ## beamforming 4x4 matrix:
          #bf_weights = [0x00007fff, 0x0000, 0x0000, 0x0000, 0x00000000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff];
          sf_extension = 0
-         sdr_addrs = "mgmt_addr=192.168.18.252,addr=192.168.10.2,second_addr=192.168.20.2,clock_source=internal,time_source=internal"
+         sdr_addrs = "mgmt_addr=172.21.19.14,addr=192.168.10.2,second_addr=192.168.20.2,clock_source=internal,time_source=internal"
     }
 );
 
diff --git a/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.usrpn310.conf b/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.usrpn310.conf
index e2b331939b99082d2b90d2f7cb1b98688cf3061d..9e1f499f0342d00c41a66786e6a2e3763f689c28 100644
--- a/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.usrpn310.conf
+++ b/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.usrpn310.conf
@@ -263,7 +263,7 @@ RUs = (
          ## beamforming 4x4 matrix:
          #bf_weights = [0x00007fff, 0x0000, 0x0000, 0x0000, 0x00000000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff];
          sf_extension = 0
-         sdr_addrs = "mgmt_addr=192.168.18.252,addr=192.168.10.2,second_addr=192.168.20.2,clock_source=internal,time_source=internal"
+         sdr_addrs = "mgmt_addr=172.21.19.14,addr=192.168.10.2,second_addr=192.168.20.2,clock_source=internal,time_source=internal"
     }
 );
 
diff --git a/ci-scripts/conf_files/gnb.band78.sa.fr1.162PRB.2x2.usrpn310.conf b/ci-scripts/conf_files/gnb.band78.sa.fr1.162PRB.2x2.usrpn310.conf
index 324b3d2ce1c36556816d128fd7cfef0fbe92e39a..ce63578dd3740c2308550a1544ae2ea32701ca2f 100644
--- a/ci-scripts/conf_files/gnb.band78.sa.fr1.162PRB.2x2.usrpn310.conf
+++ b/ci-scripts/conf_files/gnb.band78.sa.fr1.162PRB.2x2.usrpn310.conf
@@ -262,7 +262,7 @@ RUs = (
          ## beamforming 4x4 matrix:
          #bf_weights = [0x00007fff, 0x0000, 0x0000, 0x0000, 0x00000000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff];
          sf_extension = 0
-         sdr_addrs = "mgmt_addr=192.168.18.252,addr=192.168.10.2,second_addr=192.168.20.2,clock_source=internal,time_source=internal"
+         sdr_addrs = "mgmt_addr=172.21.19.14,addr=192.168.10.2,second_addr=192.168.20.2,clock_source=internal,time_source=internal"
     }
 );
 
diff --git a/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf b/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf
index af581453229280fbb425992a4e5023c408f1f5b3..f3515d388248d851fe8bbcffbf2bec39883e42ce 100644
--- a/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf
+++ b/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf
@@ -203,7 +203,7 @@ MACRLCs = (
     tr_n_preference     = "local_RRC";
     pusch_TargetSNRx10  = 200;
     pucch_TargetSNRx10  = 200;
-    ulsch_max_frame_inactivity = 1;
+    ulsch_max_frame_inactivity = 0;
   }
 );
 
@@ -221,11 +221,11 @@ RUs = (
     local_rf       = "yes"
     nb_tx          = 1
     nb_rx          = 1
-    att_tx         = 3
-    att_rx         = 0;
+    att_tx         = 12
+    att_rx         = 12;
     bands          = [7];
     max_pdschReferenceSignalPower = -27;
-    max_rxgain     = 111;
+    max_rxgain     = 114;
     eNB_instances  = [0];
 #    sdr_addrs = "serial=30C51D4";
 #    clock_src      = "external";
diff --git a/ci-scripts/main.py b/ci-scripts/main.py
index c838c3740d9cb3482b8b2e19d9bc593f8242fbbd..03947bdfc968c83f83eed43a6f0ab05212b6c218 100644
--- a/ci-scripts/main.py
+++ b/ci-scripts/main.py
@@ -49,7 +49,7 @@ import cls_physim1          #class PhySim for physical simulators deploy and run
 import sshconnection 
 import epc
 import ran
-import html
+import cls_oai_html
 
 
 #-----------------------------------------------------------
@@ -518,7 +518,7 @@ CiTestObj = cls_oaicitest.OaiCiTest()
 SSH = sshconnection.SSHConnection()
 EPC = epc.EPCManagement()
 RAN = ran.RANManagement()
-HTML = html.HTMLManagement()
+HTML = cls_oai_html.HTMLManagement()
 CONTAINERS = cls_containerize.Containerize()
 SCA = cls_static_code_analysis.StaticCodeAnalysis()
 PHYSIM = cls_physim1.PhySim()
@@ -779,19 +779,19 @@ elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re
 	HTML.CreateHtmlTabHeader()
 
 	# On CI bench w/ containers, we need to validate if IP routes are set
-	if EPC.IPAddress == '192.168.18.210':
+	if EPC.IPAddress == '172.21.16.136':
 		CONTAINERS.CheckAndAddRoute('porcepix', EPC.IPAddress, EPC.UserName, EPC.Password)
-	if CONTAINERS.eNBIPAddress == '192.168.18.194':
+	if CONTAINERS.eNBIPAddress == '172.21.16.127':
 		CONTAINERS.CheckAndAddRoute('asterix', CONTAINERS.eNBIPAddress, CONTAINERS.eNBUserName, CONTAINERS.eNBPassword)
-	if CONTAINERS.eNB1IPAddress == '192.168.18.194':
+	if CONTAINERS.eNB1IPAddress == '172.21.16.127':
 		CONTAINERS.CheckAndAddRoute('asterix', CONTAINERS.eNB1IPAddress, CONTAINERS.eNB1UserName, CONTAINERS.eNB1Password)
-	if CONTAINERS.eNBIPAddress == '192.168.18.193':
+	if CONTAINERS.eNBIPAddress == '172.21.16.128':
 		CONTAINERS.CheckAndAddRoute('obelix', CONTAINERS.eNBIPAddress, CONTAINERS.eNBUserName, CONTAINERS.eNBPassword)
-	if CONTAINERS.eNB1IPAddress == '192.168.18.193':
+	if CONTAINERS.eNB1IPAddress == '172.21.16.128':
 		CONTAINERS.CheckAndAddRoute('obelix', CONTAINERS.eNB1IPAddress, CONTAINERS.eNB1UserName, CONTAINERS.eNB1Password)
-	if CONTAINERS.eNBIPAddress == '192.168.18.209':
+	if CONTAINERS.eNBIPAddress == '172.21.16.137':
 		CONTAINERS.CheckAndAddRoute('nepes', CONTAINERS.eNBIPAddress, CONTAINERS.eNBUserName, CONTAINERS.eNBPassword)
-	if CONTAINERS.eNB1IPAddress == '192.168.18.209':
+	if CONTAINERS.eNB1IPAddress == '172.21.16.137':
 		CONTAINERS.CheckAndAddRoute('nepes', CONTAINERS.eNB1IPAddress, CONTAINERS.eNB1UserName, CONTAINERS.eNB1Password)
 
 	CiTestObj.FailReportCnt = 0
diff --git a/ci-scripts/provideUniqueImageTag.py b/ci-scripts/provideUniqueImageTag.py
index ee8306402fb7bdac08977a9f392c1c6f04de1f85..88d51ca6f88903aa0c69d6057352ba11f52949ab 100644
--- a/ci-scripts/provideUniqueImageTag.py
+++ b/ci-scripts/provideUniqueImageTag.py
@@ -5,15 +5,15 @@ import subprocess
 import sys
 
 AUTH_SERVICE = 'registry.docker.io'
-AUTH_SCOPE   = 'repository:rdefosseoai/oai-enb:pull'
+AUTH_SCOPE   = 'repository:oaisoftwarealliance/oai-enb:pull'
 
 def main() -> None:
     args = _parse_args()
 
-    cmd = 'curl -fsSL "https://auth.docker.io/token?service=' + AUTH_SERVICE + '&scope=' + AUTH_SCOPE + '" | jq --raw-output ".token"'
+    cmd = 'curl -fsSL "https://auth.docker.io/token?service=' + AUTH_SERVICE + '&scope=' + AUTH_SCOPE + '" 2>/dev/null | jq --raw-output ".token"'
     token = subprocess.check_output(cmd, shell=True, universal_newlines=True)
     token = str(token).strip()
-    cmd = 'curl -fsSL -H "Authorization: Bearer ' + token + '" "https://index.docker.io/v2/rdefosseoai/oai-enb/tags/list" | jq .'
+    cmd = 'curl -fsSL -H "Authorization: Bearer ' + token + '" "https://index.docker.io/v2/oaisoftwarealliance/oai-enb/tags/list" 2>/dev/null | jq .'
     listOfTags = subprocess.check_output(cmd, shell=True, universal_newlines=True)
 
     foundTag = False
diff --git a/ci-scripts/xml_files/container_nsa_b200_quectel.xml b/ci-scripts/xml_files/container_nsa_b200_quectel.xml
index 610f0b019a447ff5e78e632cd9b016143c054f6b..47a939f63c51c18b395017a5ddb0411efff83beb 100644
--- a/ci-scripts/xml_files/container_nsa_b200_quectel.xml
+++ b/ci-scripts/xml_files/container_nsa_b200_quectel.xml
@@ -138,19 +138,19 @@
 
 	<testCase id="070000">
 		<class>Iperf</class>
-		<desc>iperf (DL/40Mbps/UDP)(60 sec)(single-ue profile)</desc>
-		<iperf_args>-u -b 40M -t 60 -i 1 -fm</iperf_args>
+		<desc>iperf (DL/125Mbps/UDP)(60 sec)(single-ue profile)</desc>
+		<iperf_args>-u -b 125M -t 60 -i 1 -fm</iperf_args>
 		<direction>DL</direction>
 		<id>idefix</id>
-		<iperf_packetloss_threshold>20</iperf_packetloss_threshold>
-		<iperf_bitrate_threshold>85</iperf_bitrate_threshold>
+		<iperf_packetloss_threshold>1</iperf_packetloss_threshold>
+		<iperf_bitrate_threshold>95</iperf_bitrate_threshold>
 		<iperf_profile>single-ue</iperf_profile>
 	</testCase>
 
 	<testCase id="070001">
 		<class>Iperf</class>
-		<desc>iperf (UL/3Mbps/UDP)(60 sec)(single-ue profile)</desc>
-		<iperf_args>-u -b 3M -t 60 -i 1 -fm</iperf_args>
+		<desc>iperf (UL/8Mbps/UDP)(60 sec)(single-ue profile)</desc>
+		<iperf_args>-u -b 8M -t 60 -i 1 -fm</iperf_args>
 		<direction>UL</direction>
 		<id>idefix</id>
 		<iperf_packetloss_threshold>1</iperf_packetloss_threshold>
diff --git a/ci-scripts/xml_files/fr1_nsa_2x2_quectel.xml b/ci-scripts/xml_files/fr1_nsa_2x2_quectel.xml
index 56694920ba593fbc6d048c7169e8df00c2940893..2ef2b7d7ce74f2ac6f7b5a4bce433fd35effbb9b 100644
--- a/ci-scripts/xml_files/fr1_nsa_2x2_quectel.xml
+++ b/ci-scripts/xml_files/fr1_nsa_2x2_quectel.xml
@@ -68,7 +68,7 @@
 		<air_interface>lte</air_interface>
 		<eNB_Trace>yes</eNB_Trace>
 		<eNB_Stats>yes</eNB_Stats>
-		<USRP_IPAddress>192.168.18.241</USRP_IPAddress>
+		<USRP_IPAddress>172.21.19.13</USRP_IPAddress>
 	</testCase>
 
 
@@ -81,7 +81,7 @@
 		<air_interface>nr</air_interface>
 		<eNB_Stats>yes</eNB_Stats>
 		<rt_stats_cfg>datalog_rt_stats.2x2.yaml</rt_stats_cfg>
-		<USRP_IPAddress>192.168.18.252</USRP_IPAddress>
+		<USRP_IPAddress>172.21.19.14</USRP_IPAddress>
 	</testCase>
 
 	<testCase id="000001">
@@ -115,11 +115,12 @@
 
 	<testCase id="070000">
 		<class>Iperf</class>
-		<desc>iperf (DL/60Mbps/UDP)(60 sec)(single-ue profile)</desc>
-		<iperf_args>-u -b 60M -t 60</iperf_args>
+		<desc>iperf (DL/125Mbps/UDP)(60 sec)(single-ue profile)</desc>
+		<iperf_args>-u -b 125M -t 60</iperf_args>
 		<direction>DL</direction>
 		<id>nrmodule2_quectel</id>
-		<iperf_packetloss_threshold>5</iperf_packetloss_threshold>
+		<iperf_packetloss_threshold>15</iperf_packetloss_threshold>
+		<iperf_bitrate_threshold>85</iperf_bitrate_threshold>
 		<iperf_profile>single-ue</iperf_profile>
 	</testCase>
 
diff --git a/ci-scripts/xml_files/fr1_nsa_2x2_quectel_attach_detach.xml b/ci-scripts/xml_files/fr1_nsa_2x2_quectel_attach_detach.xml
index 840521481e82fa69d058b59ed830eeec1dd77f93..335fe873a163afc0002ee94c663efcc1973b5e0d 100644
--- a/ci-scripts/xml_files/fr1_nsa_2x2_quectel_attach_detach.xml
+++ b/ci-scripts/xml_files/fr1_nsa_2x2_quectel_attach_detach.xml
@@ -87,7 +87,7 @@
 		<air_interface>lte</air_interface>
 		<eNB_Trace>yes</eNB_Trace>
 		<eNB_Stats>yes</eNB_Stats>
-		<USRP_IPAddress>192.168.18.241</USRP_IPAddress>
+		<USRP_IPAddress>172.21.19.13</USRP_IPAddress>
 	</testCase>
 
 
@@ -100,7 +100,7 @@
 		<air_interface>nr</air_interface>
 		<eNB_Stats>yes</eNB_Stats>
 		<rt_stats_cfg>datalog_rt_stats.2x2.yaml</rt_stats_cfg>
-		<USRP_IPAddress>192.168.18.252</USRP_IPAddress>
+		<USRP_IPAddress>172.21.19.14</USRP_IPAddress>
 	</testCase>
 
 	<testCase id="000001">
diff --git a/ci-scripts/xml_files/fr1_nsa_quectel.xml b/ci-scripts/xml_files/fr1_nsa_quectel.xml
index 55f6f4376ea275760a7c41aa5e7856a5c1860548..0f8c90abdf12b0e97e9c5fc1b343f45dfa311757 100644
--- a/ci-scripts/xml_files/fr1_nsa_quectel.xml
+++ b/ci-scripts/xml_files/fr1_nsa_quectel.xml
@@ -74,7 +74,7 @@
 	<testCase id="040000">
 		<class>Initialize_eNB</class>
 		<desc>Initialize gNB</desc>
-		<Initialize_eNB_args>-O ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf -E -q --RUs.[0].sdr_addrs "serial=30C51D4" --log_config.global_log_options level,nocolor,time,line_num,function</Initialize_eNB_args>
+		<Initialize_eNB_args>-O ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf -E -q --RUs.[0].sdr_addrs "serial=30C51D4" --continuous-tx --log_config.global_log_options level,nocolor,time,line_num,function</Initialize_eNB_args>
 		<eNB_instance>1</eNB_instance>
 		<eNB_serverId>1</eNB_serverId>
 		<air_interface>nr</air_interface>
@@ -117,37 +117,37 @@
 		<iperf_args>-u -b 30M -t 30</iperf_args>
 		<direction>DL</direction>
 		<id>idefix</id>
-		<iperf_packetloss_threshold>5</iperf_packetloss_threshold>
+		<iperf_packetloss_threshold>1</iperf_packetloss_threshold>
 		<iperf_bitrate_threshold>95</iperf_bitrate_threshold>
 		<iperf_profile>single-ue</iperf_profile>
 	</testCase>
 
 	<testCase id="070001">
 		<class>Iperf</class>
-		<desc>iperf (DL/40Mbps/UDP)(30 sec)(single-ue profile)</desc>
-		<iperf_args>-u -b 40M -t 30</iperf_args>
+		<desc>iperf (DL/90Mbps/UDP)(30 sec)(single-ue profile)</desc>
+		<iperf_args>-u -b 90M -t 30</iperf_args>
 		<direction>DL</direction>
 		<id>idefix</id>
-		<iperf_packetloss_threshold>5</iperf_packetloss_threshold>
+		<iperf_packetloss_threshold>1</iperf_packetloss_threshold>
 		<iperf_bitrate_threshold>95</iperf_bitrate_threshold>
 		<iperf_profile>single-ue</iperf_profile>
 	</testCase>
 
 	<testCase id="070002">
 		<class>Iperf</class>
-		<desc>iperf (DL/60Mbps/UDP)(60 sec)(single-ue profile)</desc>
-		<iperf_args>-u -b 60M -t 60</iperf_args>
+		<desc>iperf (DL/125Mbps/UDP)(60 sec)(single-ue profile)</desc>
+		<iperf_args>-u -b 125M -t 60</iperf_args>
 		<direction>DL</direction>
 		<id>idefix</id>
-		<iperf_packetloss_threshold>5</iperf_packetloss_threshold>
+		<iperf_packetloss_threshold>1</iperf_packetloss_threshold>
 		<iperf_bitrate_threshold>95</iperf_bitrate_threshold>
 		<iperf_profile>single-ue</iperf_profile>
 	</testCase>
 
 	<testCase id="070003">
 		<class>Iperf</class>
-		<desc>iperf (UL/3Mbps/UDP)(60 sec)(single-ue profile)</desc>
-		<iperf_args>-u -b 3M -t 60</iperf_args>
+		<desc>iperf (UL/8Mbps/UDP)(60 sec)(single-ue profile)</desc>
+		<iperf_args>-u -b 8M -t 60</iperf_args>
 		<direction>UL</direction>
 		<id>idefix</id>
 		<iperf_packetloss_threshold>1</iperf_packetloss_threshold>
diff --git a/ci-scripts/xml_files/fr1_sa_amarisoft_ue_1x.xml b/ci-scripts/xml_files/fr1_sa_amarisoft_ue_1x.xml
index 194ed4e453e072de6e1c66c258b1c0a64590cd86..ea031a0174ef631c6a063fc9b276b133ec9d3a9e 100644
--- a/ci-scripts/xml_files/fr1_sa_amarisoft_ue_1x.xml
+++ b/ci-scripts/xml_files/fr1_sa_amarisoft_ue_1x.xml
@@ -52,7 +52,7 @@
 		<eNB_Trace>yes</eNB_Trace>
 		<eNB_Stats>yes</eNB_Stats>
 		<rt_stats_cfg>datalog_rt_stats.2x2.yaml</rt_stats_cfg>
-		<USRP_IPAddress>192.168.18.252</USRP_IPAddress>
+		<USRP_IPAddress>172.21.19.14</USRP_IPAddress>
 	</testCase>
 
 	<testCase id="050000">
diff --git a/ci-scripts/xml_files/fr1_sa_oaiue_b200.xml b/ci-scripts/xml_files/fr1_sa_oaiue_b200.xml
index 55268b909d7451a55345acd44bbfbb157d86d5b0..5995f75a64460044866fea1db966b13f5e2b158b 100644
--- a/ci-scripts/xml_files/fr1_sa_oaiue_b200.xml
+++ b/ci-scripts/xml_files/fr1_sa_oaiue_b200.xml
@@ -60,7 +60,7 @@
 		<air_interface>nr</air_interface>
 		<eNB_Trace>yes</eNB_Trace>
 		<eNB_Stats>yes</eNB_Stats>
-		<USRP_IPAddress>192.168.18.252</USRP_IPAddress>
+		<USRP_IPAddress>172.21.19.14</USRP_IPAddress>
 	</testCase>
 
 	<testCase id="000001">
diff --git a/ci-scripts/xml_files/fr1_sa_oaiue_n310.xml b/ci-scripts/xml_files/fr1_sa_oaiue_n310.xml
index 53b696c6eb0fffbd8c198bfefedd445d12297bd8..468005f54f677f8208ded94f278a67a7088e746e 100644
--- a/ci-scripts/xml_files/fr1_sa_oaiue_n310.xml
+++ b/ci-scripts/xml_files/fr1_sa_oaiue_n310.xml
@@ -42,7 +42,7 @@
 		<class>Initialize_OAI_UE</class>
 		<desc>Initialize OAI UE (N310)</desc>
 		<air_interface>nr</air_interface>
-		<Initialize_OAI_UE_args>--sa -O ../../../ci-scripts/conf_files/ue.sa.conf --usrp-args "mgmt_addr=192.168.18.241,addr=192.168.10.2"  --numerology 1 -r 106 --band 78 -C 3319680000 --nokrnmod 1 --ue-txgain 0 --ue-rxgain 70 --ue-fo-compensation --log_config.global_log_options level,nocolor,time</Initialize_OAI_UE_args>
+		<Initialize_OAI_UE_args>--sa -O ../../../ci-scripts/conf_files/ue.sa.conf --usrp-args "mgmt_addr=172.21.19.13,addr=192.168.10.2"  --numerology 1 -r 106 --band 78 -C 3319680000 --nokrnmod 1 --ue-txgain 0 --ue-rxgain 70 --ue-fo-compensation --log_config.global_log_options level,nocolor,time</Initialize_OAI_UE_args>
 	</testCase>
 
 	<testCase id="010002">
@@ -60,7 +60,7 @@
 		<air_interface>nr</air_interface>
 		<eNB_Trace>yes</eNB_Trace>
 		<eNB_Stats>yes</eNB_Stats>
-		<USRP_IPAddress>192.168.18.252</USRP_IPAddress>
+		<USRP_IPAddress>172.21.19.14</USRP_IPAddress>
 	</testCase>
 
 	<testCase id="000001">
diff --git a/ci-scripts/xml_files/fr1_sa_oaiue_x300.xml b/ci-scripts/xml_files/fr1_sa_oaiue_x300.xml
index 8c2f7052e4eb52101575ba8646345d59f16f6f76..ef001a7518f2cc28392c28acff585cfdfa933712 100644
--- a/ci-scripts/xml_files/fr1_sa_oaiue_x300.xml
+++ b/ci-scripts/xml_files/fr1_sa_oaiue_x300.xml
@@ -60,7 +60,7 @@
 		<air_interface>nr</air_interface>
 		<eNB_Trace>yes</eNB_Trace>
 		<eNB_Stats>yes</eNB_Stats>
-		<USRP_IPAddress>192.168.18.252</USRP_IPAddress>
+		<USRP_IPAddress>172.21.19.14</USRP_IPAddress>
 	</testCase>
 
 	<testCase id="000001">
diff --git a/ci-scripts/xml_files/fr1_sa_quectel.xml b/ci-scripts/xml_files/fr1_sa_quectel.xml
index 576456ebc96959cd3e9e4284c84e02ecce1d1685..4d4edab56bd4be6c4e0b67836647dec1885269a3 100644
--- a/ci-scripts/xml_files/fr1_sa_quectel.xml
+++ b/ci-scripts/xml_files/fr1_sa_quectel.xml
@@ -70,7 +70,7 @@
 		<eNB_Trace>yes</eNB_Trace>
 		<eNB_Stats>yes</eNB_Stats>
 		<rt_stats_cfg>datalog_rt_stats.2x2.yaml</rt_stats_cfg>
-		<USRP_IPAddress>192.168.18.252</USRP_IPAddress>
+		<USRP_IPAddress>172.21.19.14</USRP_IPAddress>
 	</testCase>
 
 	<testCase id="000001">
diff --git a/ci-scripts/xml_files/fr1_sa_quectel_162prb.xml b/ci-scripts/xml_files/fr1_sa_quectel_162prb.xml
index c5f2ddad5f479a4691330392499fdb1d7226838d..23eaccfcfd2d5fe6f9b4d82685b3b11e4e6b2459 100644
--- a/ci-scripts/xml_files/fr1_sa_quectel_162prb.xml
+++ b/ci-scripts/xml_files/fr1_sa_quectel_162prb.xml
@@ -68,7 +68,7 @@
 		<eNB_Trace>yes</eNB_Trace>
 		<eNB_Stats>yes</eNB_Stats>
 		<rt_stats_cfg>datalog_rt_stats.2x2.yaml</rt_stats_cfg>
-		<USRP_IPAddress>192.168.18.252</USRP_IPAddress>
+		<USRP_IPAddress>172.21.19.14</USRP_IPAddress>
 	</testCase>
 
 	<testCase id="000001">
diff --git a/ci-scripts/xml_files/fr1_sa_quectel_stages.xml b/ci-scripts/xml_files/fr1_sa_quectel_stages.xml
index 2707fd4ebff998441de2c9a23d42458976fdcd05..603f3f919b47f0de104a4a5d0b7db8f8d117c84b 100644
--- a/ci-scripts/xml_files/fr1_sa_quectel_stages.xml
+++ b/ci-scripts/xml_files/fr1_sa_quectel_stages.xml
@@ -74,7 +74,7 @@
 		<eNB_Trace>yes</eNB_Trace>
 		<eNB_Stats>yes</eNB_Stats>
 		<rt_stats_cfg>datalog_rt_stats.2x2.yaml</rt_stats_cfg>
-		<USRP_IPAddress>192.168.18.252</USRP_IPAddress>
+		<USRP_IPAddress>172.21.19.14</USRP_IPAddress>
 	</testCase>
 
 	<testCase id="000001">
diff --git a/ci-scripts/xml_files/fr1_sa_quectel_stages_162prb.xml b/ci-scripts/xml_files/fr1_sa_quectel_stages_162prb.xml
index 661bcb32fe0c5112cb437921dce8c79b38ec6cc0..9371e46ec9f5835a4490e19bfc2b5c5ad644c9b4 100644
--- a/ci-scripts/xml_files/fr1_sa_quectel_stages_162prb.xml
+++ b/ci-scripts/xml_files/fr1_sa_quectel_stages_162prb.xml
@@ -74,7 +74,7 @@
 		<eNB_Trace>yes</eNB_Trace>
 		<eNB_Stats>yes</eNB_Stats>
 		<rt_stats_cfg>datalog_rt_stats.2x2.yaml</rt_stats_cfg>
-		<USRP_IPAddress>192.168.18.252</USRP_IPAddress>
+		<USRP_IPAddress>172.21.19.14</USRP_IPAddress>
 	</testCase>
 
 	<testCase id="000001">
diff --git a/ci-scripts/xml_files/lte_2x2_tm1_quectel.xml b/ci-scripts/xml_files/lte_2x2_tm1_quectel.xml
index 11c4abce1b2f0edcf7bac36f34154fe4f2c63d2f..6aa53200c85ec8e484da718b6ae1dc8a25f5514d 100644
--- a/ci-scripts/xml_files/lte_2x2_tm1_quectel.xml
+++ b/ci-scripts/xml_files/lte_2x2_tm1_quectel.xml
@@ -65,7 +65,7 @@
 		<air_interface>lte</air_interface>
 		<eNB_Trace>yes</eNB_Trace>
 		<eNB_Stats>yes</eNB_Stats>
-		<USRP_IPAddress>192.168.18.241</USRP_IPAddress>
+		<USRP_IPAddress>172.21.19.13</USRP_IPAddress>
 	</testCase>
 
 
diff --git a/ci-scripts/xml_files/lte_2x2_tm2_quectel.xml b/ci-scripts/xml_files/lte_2x2_tm2_quectel.xml
index 714cf51a9b5641ed7118fe57a0aa0eb5ca4d079b..84aa87aa235eaaa28d220111c8157b77616106e0 100644
--- a/ci-scripts/xml_files/lte_2x2_tm2_quectel.xml
+++ b/ci-scripts/xml_files/lte_2x2_tm2_quectel.xml
@@ -65,7 +65,7 @@
 		<air_interface>lte</air_interface>
 		<eNB_Trace>yes</eNB_Trace>
 		<eNB_Stats>yes</eNB_Stats>
-		<USRP_IPAddress>192.168.18.241</USRP_IPAddress>
+		<USRP_IPAddress>172.21.19.13</USRP_IPAddress>
 	</testCase>
 
 
diff --git a/ci-scripts/yaml_files/4g_rfsimulator_fdd_05MHz/README.md b/ci-scripts/yaml_files/4g_rfsimulator_fdd_05MHz/README.md
index 400559d26988ec1dd5d04aee886ad89e225ba493..1a947d0389019f611701fc62405c39251186b972 100644
--- a/ci-scripts/yaml_files/4g_rfsimulator_fdd_05MHz/README.md
+++ b/ci-scripts/yaml_files/4g_rfsimulator_fdd_05MHz/README.md
@@ -31,9 +31,7 @@ This page is only valid for an `Ubuntu18` host.
 
 # 1. Retrieving the images on Docker-Hub #
 
-Currently the images are hosted under the user account `rdefosseoai`.
-
-This may change in the future.
+Currently the images are hosted under the team account `oaisoftwarealliance`. They were previously hosted under the user account `rdefosseoai`.
 
 Once again you may need to log on [docker-hub](https://hub.docker.com/) if your organization has reached pulling limit as `anonymous`.
 
@@ -49,13 +47,13 @@ Now pull images.
 ```bash
 $ docker pull cassandra:2.1
 $ docker pull redis:6.0.5
-$ docker pull rdefosseoai/oai-hss:latest
-$ docker pull rdefosseoai/magma-mme:latest
-$ docker pull rdefosseoai/oai-spgwc:latest
-$ docker pull rdefosseoai/oai-spgwu-tiny:latest
+$ docker pull oaisoftwarealliance/oai-hss:latest
+$ docker pull oaisoftwarealliance/magma-mme:latest
+$ docker pull oaisoftwarealliance/oai-spgwc:latest
+$ docker pull oaisoftwarealliance/oai-spgwu-tiny:latest
 
-$ docker pull rdefosseoai/oai-enb:develop
-$ docker pull rdefosseoai/oai-lte-ue:develop
+$ docker pull oaisoftwarealliance/oai-enb:develop
+$ docker pull oaisoftwarealliance/oai-lte-ue:develop
 ```
 
 If the `redis` tag is not available, pick the newest available `6.0.x` tag at [Docker Hub Redis Tags](https://hub.docker.com/_/redis?tab=tags).
@@ -63,13 +61,13 @@ If the `redis` tag is not available, pick the newest available `6.0.x` tag at [D
 And **re-tag** them for tutorials' docker-compose file to work.
 
 ```bash
-$ docker image tag rdefosseoai/oai-spgwc:latest oai-spgwc:latest
-$ docker image tag rdefosseoai/oai-hss:latest oai-hss:latest
-$ docker image tag rdefosseoai/oai-spgwu-tiny:latest oai-spgwu-tiny:latest 
-$ docker image tag rdefosseoai/magma-mme:latest magma-mme:latest
+$ docker image tag oaisoftwarealliance/oai-spgwc:latest oai-spgwc:latest
+$ docker image tag oaisoftwarealliance/oai-hss:latest oai-hss:latest
+$ docker image tag oaisoftwarealliance/oai-spgwu-tiny:latest oai-spgwu-tiny:latest 
+$ docker image tag oaisoftwarealliance/magma-mme:latest magma-mme:latest
 
-$ docker image tag rdefosseoai/oai-enb:develop oai-enb:develop
-$ docker image tag rdefosseoai/oai-lte-ue:develop oai-lte-ue:develop
+$ docker image tag oaisoftwarealliance/oai-enb:develop oai-enb:develop
+$ docker image tag oaisoftwarealliance/oai-lte-ue:develop oai-lte-ue:develop
 ```
 
 ```bash
@@ -505,7 +503,7 @@ In my traffic test, I was able to ping outside of my local network.
 in SPGW-C config:
 
 ```yaml
-            DEFAULT_DNS_IPV4_ADDRESS: 192.168.18.129
+            DEFAULT_DNS_IPV4_ADDRESS: 172.21.3.100
             DEFAULT_DNS_SEC_IPV4_ADDRESS: 8.8.4.4
             PUSH_PROTOCOL_OPTION: 'true'
 ```
diff --git a/ci-scripts/yaml_files/4g_rfsimulator_fdd_05MHz/docker-compose.yml b/ci-scripts/yaml_files/4g_rfsimulator_fdd_05MHz/docker-compose.yml
index b15e794c1026a11657e4c1deaa9ef2b75aace8c6..a260857a34d7a607929cac21dc6ac04f9ba6ee19 100644
--- a/ci-scripts/yaml_files/4g_rfsimulator_fdd_05MHz/docker-compose.yml
+++ b/ci-scripts/yaml_files/4g_rfsimulator_fdd_05MHz/docker-compose.yml
@@ -115,7 +115,7 @@ services:
             TZ: Europe/Paris
             SGW_INTERFACE_NAME_FOR_S11: eth0
             PGW_INTERFACE_NAME_FOR_SX: eth0
-            DEFAULT_DNS_IPV4_ADDRESS: 192.168.18.129
+            DEFAULT_DNS_IPV4_ADDRESS: 172.21.3.100
             DEFAULT_DNS_SEC_IPV4_ADDRESS: 8.8.4.4
             PUSH_PROTOCOL_OPTION: 'true'
             APN_NI_1: oai.ipv4
diff --git a/ci-scripts/yaml_files/4g_rfsimulator_fdd_10MHz/docker-compose.yml b/ci-scripts/yaml_files/4g_rfsimulator_fdd_10MHz/docker-compose.yml
index e1e992c94c2a668cdd4f9fd2ab0c1449f25d753f..3f63953b0e6c0287f434a250236d15cbb563bc76 100644
--- a/ci-scripts/yaml_files/4g_rfsimulator_fdd_10MHz/docker-compose.yml
+++ b/ci-scripts/yaml_files/4g_rfsimulator_fdd_10MHz/docker-compose.yml
@@ -115,7 +115,7 @@ services:
             TZ: Europe/Paris
             SGW_INTERFACE_NAME_FOR_S11: eth0
             PGW_INTERFACE_NAME_FOR_SX: eth0
-            DEFAULT_DNS_IPV4_ADDRESS: 192.168.18.129
+            DEFAULT_DNS_IPV4_ADDRESS: 172.21.3.100
             DEFAULT_DNS_SEC_IPV4_ADDRESS: 8.8.4.4
             PUSH_PROTOCOL_OPTION: 'true'
             APN_NI_1: oai.ipv4
diff --git a/ci-scripts/yaml_files/4g_rfsimulator_fdd_20MHz/docker-compose.yml b/ci-scripts/yaml_files/4g_rfsimulator_fdd_20MHz/docker-compose.yml
index ad665813f2a5bb1a956e7f7056dadf63bc7c4d5b..1165400273e7f542dcec56d88572cbb6c0c387fb 100644
--- a/ci-scripts/yaml_files/4g_rfsimulator_fdd_20MHz/docker-compose.yml
+++ b/ci-scripts/yaml_files/4g_rfsimulator_fdd_20MHz/docker-compose.yml
@@ -115,7 +115,7 @@ services:
             TZ: Europe/Paris
             SGW_INTERFACE_NAME_FOR_S11: eth0
             PGW_INTERFACE_NAME_FOR_SX: eth0
-            DEFAULT_DNS_IPV4_ADDRESS: 192.168.18.129
+            DEFAULT_DNS_IPV4_ADDRESS: 172.21.3.100
             DEFAULT_DNS_SEC_IPV4_ADDRESS: 8.8.4.4
             PUSH_PROTOCOL_OPTION: 'true'
             APN_NI_1: oai.ipv4
diff --git a/ci-scripts/yaml_files/4g_rfsimulator_tdd_05MHz/docker-compose.yml b/ci-scripts/yaml_files/4g_rfsimulator_tdd_05MHz/docker-compose.yml
index ffa92bac4907046960d4f7a4bcaa4af6b488dafe..86f6c80b5982da70e61c07c8d712a29366fd4798 100644
--- a/ci-scripts/yaml_files/4g_rfsimulator_tdd_05MHz/docker-compose.yml
+++ b/ci-scripts/yaml_files/4g_rfsimulator_tdd_05MHz/docker-compose.yml
@@ -115,7 +115,7 @@ services:
             TZ: Europe/Paris
             SGW_INTERFACE_NAME_FOR_S11: eth0
             PGW_INTERFACE_NAME_FOR_SX: eth0
-            DEFAULT_DNS_IPV4_ADDRESS: 192.168.18.129
+            DEFAULT_DNS_IPV4_ADDRESS: 172.21.3.100
             DEFAULT_DNS_SEC_IPV4_ADDRESS: 8.8.4.4
             PUSH_PROTOCOL_OPTION: 'true'
             APN_NI_1: oai.ipv4
diff --git a/ci-scripts/yaml_files/5g_f1_rfsimulator/docker-compose.yaml b/ci-scripts/yaml_files/5g_f1_rfsimulator/docker-compose.yaml
index 74a23905f0abc4e5258e3837d88c1ae410696732..d52b228ec67cfa2520a0fea396927da60d4fde06 100644
--- a/ci-scripts/yaml_files/5g_f1_rfsimulator/docker-compose.yaml
+++ b/ci-scripts/yaml_files/5g_f1_rfsimulator/docker-compose.yaml
@@ -120,7 +120,7 @@ services:
             - SMF_INTERFACE_PORT_FOR_SBI=80
             - SMF_INTERFACE_HTTP2_PORT_FOR_SBI=9090
             - SMF_API_VERSION=v1
-            - DEFAULT_DNS_IPV4_ADDRESS=192.168.18.129
+            - DEFAULT_DNS_IPV4_ADDRESS=172.21.3.100
             - DEFAULT_DNS_SEC_IPV4_ADDRESS=4.4.4.4
             - AMF_IPV4_ADDRESS=0.0.0.0
             - AMF_PORT=80
diff --git a/ci-scripts/yaml_files/5g_fdd_rfsimulator/docker-compose.yaml b/ci-scripts/yaml_files/5g_fdd_rfsimulator/docker-compose.yaml
index 3e46adb9e7eac397a66fc33fe194bddd7ebe2608..7758c395927f5c71c24ff9e761544e5bac005143 100644
--- a/ci-scripts/yaml_files/5g_fdd_rfsimulator/docker-compose.yaml
+++ b/ci-scripts/yaml_files/5g_fdd_rfsimulator/docker-compose.yaml
@@ -120,7 +120,7 @@ services:
             - SMF_INTERFACE_PORT_FOR_SBI=80
             - SMF_INTERFACE_HTTP2_PORT_FOR_SBI=9090
             - SMF_API_VERSION=v1
-            - DEFAULT_DNS_IPV4_ADDRESS=192.168.18.129
+            - DEFAULT_DNS_IPV4_ADDRESS=172.21.3.100
             - DEFAULT_DNS_SEC_IPV4_ADDRESS=4.4.4.4
             - AMF_IPV4_ADDRESS=0.0.0.0
             - AMF_PORT=80
diff --git a/ci-scripts/yaml_files/5g_l2sim_tdd/README.md b/ci-scripts/yaml_files/5g_l2sim_tdd/README.md
index 531f2406ef8c622852fec4ef76108e5072ca3932..c3f631cf7682620a603ab2dba67ef0476bb43e5f 100644
--- a/ci-scripts/yaml_files/5g_l2sim_tdd/README.md
+++ b/ci-scripts/yaml_files/5g_l2sim_tdd/README.md
@@ -18,9 +18,7 @@ This tutorial is only valid once this file is merged into the `develop` branch.
 
 # 1. Retrieving the images on Docker-Hub #
 
-Currently the images are hosted under the user account `rdefosseoai`.
-
-This may change in the future.
+Currently the images are hosted under the team account `oaisoftwarealliance`. They were previously hosted under the user account `rdefosseoai`.
 
 Once again you may need to log on [docker-hub](https://hub.docker.com/) if your organization has reached pulling limit as `anonymous`.
 
@@ -35,27 +33,27 @@ Now pull images.
 
 ```bash
 $ docker pull mysql:5.7
-$ docker pull rdefosseoai/oai-amf:latest
-$ docker pull rdefosseoai/oai-nrf:latest
-$ docker pull rdefosseoai/oai-smf:latest
-$ docker pull rdefosseoai/oai-spgwu-tiny:latest
-
-$ docker pull rdefosseoai/oai-gnb:develop
-$ docker pull rdefosseoai/oai-nr-ue:develop
-$ docker pull rdefosseoai/proxy:latest
+$ docker pull oaisoftwarealliance/oai-amf:latest
+$ docker pull oaisoftwarealliance/oai-nrf:latest
+$ docker pull oaisoftwarealliance/oai-smf:latest
+$ docker pull oaisoftwarealliance/oai-spgwu-tiny:latest
+
+$ docker pull oaisoftwarealliance/oai-gnb:develop
+$ docker pull oaisoftwarealliance/oai-nr-ue:develop
+$ docker pull oaisoftwarealliance/proxy:latest
 ```
 
 And **re-tag** them for tutorials' docker-compose file to work.
 
 ```bash
-$ docker image tag rdefosseoai/oai-amf:latest oai-amf:latest
-$ docker image tag rdefosseoai/oai-nrf:latest oai-nrf:latest
-$ docker image tag rdefosseoai/oai-smf:latest oai-smf:latest
-$ docker image tag rdefosseoai/oai-spgwu-tiny:latest oai-spgwu-tiny:latest
-
-$ docker image tag rdefosseoai/oai-gnb:develop oai-gnb:develop
-$ docker image tag rdefosseoai/oai-nr-ue:develop oai-nr-ue:develop
-$ docker image tag rdefosseoai/proxy:latest oai-lte-multi-ue-proxy:latest
+$ docker image tag oaisoftwarealliance/oai-amf:latest oai-amf:latest
+$ docker image tag oaisoftwarealliance/oai-nrf:latest oai-nrf:latest
+$ docker image tag oaisoftwarealliance/oai-smf:latest oai-smf:latest
+$ docker image tag oaisoftwarealliance/oai-spgwu-tiny:latest oai-spgwu-tiny:latest
+
+$ docker image tag oaisoftwarealliance/oai-gnb:develop oai-gnb:develop
+$ docker image tag oaisoftwarealliance/oai-nr-ue:develop oai-nr-ue:develop
+$ docker image tag oaisoftwarealliance/proxy:latest oai-lte-multi-ue-proxy:latest
 ```
 
 ```bash
@@ -326,16 +324,16 @@ Removing network l2sim-oai-traffic-net
 In the `SMF` section, provide your own DNS IP address:
 
 ```yaml
-            DEFAULT_DNS_IPV4_ADDRESS=192.168.18.129
+            DEFAULT_DNS_IPV4_ADDRESS=172.21.3.100
 ```
 
-In the `gNB` section, provide your docker-host primary IP address and interface name: in our case `192.168.18.193` and `eno1`.
+In the `gNB` section, provide your docker-host primary IP address and interface name: in our case `172.21.16.128` and `eno1`.
 
 ```yaml
             GNB_NGA_IF_NAME: eno1
-            GNB_NGA_IP_ADDRESS: 192.168.18.193
+            GNB_NGA_IP_ADDRESS: 172.21.16.128
             GNB_NGU_IF_NAME: eno1
-            GNB_NGU_IP_ADDRESS: 192.168.18.193
+            GNB_NGU_IP_ADDRESS: 172.21.16.128
 ```
 
 Same thing in the `nr-ue` section:
diff --git a/ci-scripts/yaml_files/5g_l2sim_tdd/docker-compose.yaml b/ci-scripts/yaml_files/5g_l2sim_tdd/docker-compose.yaml
index c899f8cc7e2076593e8f848cf2d3dbd36bb75c53..a28b640e1a5d7a79bd6e226034726c1d2e6a7721 100644
--- a/ci-scripts/yaml_files/5g_l2sim_tdd/docker-compose.yaml
+++ b/ci-scripts/yaml_files/5g_l2sim_tdd/docker-compose.yaml
@@ -120,7 +120,7 @@ services:
             - SMF_INTERFACE_PORT_FOR_SBI=80
             - SMF_INTERFACE_HTTP2_PORT_FOR_SBI=9090
             - SMF_API_VERSION=v1
-            - DEFAULT_DNS_IPV4_ADDRESS=192.168.18.129
+            - DEFAULT_DNS_IPV4_ADDRESS=172.21.3.100
             - DEFAULT_DNS_SEC_IPV4_ADDRESS=4.4.4.4
             - AMF_IPV4_ADDRESS=0.0.0.0
             - AMF_PORT=80
@@ -241,9 +241,9 @@ services:
             NSSAI_SD1: 112233
             AMF_IP_ADDRESS: 192.168.71.132
             GNB_NGA_IF_NAME: eno1
-            GNB_NGA_IP_ADDRESS: 192.168.18.193
+            GNB_NGA_IP_ADDRESS: 172.21.16.128
             GNB_NGU_IF_NAME: eno1
-            GNB_NGU_IP_ADDRESS: 192.168.18.193
+            GNB_NGU_IP_ADDRESS: 172.21.16.128
             LOCAL_S_IF_NAME: 'lo:'
             REMOTE_S_ADDRESS: 127.0.0.1
             LOCAL_S_ADDRESS: 127.0.0.2
diff --git a/ci-scripts/yaml_files/5g_rfsimulator/README.md b/ci-scripts/yaml_files/5g_rfsimulator/README.md
index 64c9084500ce58c964875b8ad78313cb0506cab4..aa185717765e5f63b5b734ac24d864790e3c5351 100644
--- a/ci-scripts/yaml_files/5g_rfsimulator/README.md
+++ b/ci-scripts/yaml_files/5g_rfsimulator/README.md
@@ -35,9 +35,7 @@ This page is only valid for an `Ubuntu18` host.
 
 # 1. Retrieving the images on Docker-Hub #
 
-Currently the images are hosted under the user account `rdefosseoai`.
-
-This may change in the future.
+Currently the images are hosted under the team account `oaisoftwarealliance`. They were previously hosted under the user account `rdefosseoai`.
 
 Once again you may need to log on [docker-hub](https://hub.docker.com/) if your organization has reached pulling limit as `anonymous`.
 
@@ -52,25 +50,25 @@ Now pull images.
 
 ```bash
 $ docker pull mysql:5.7
-$ docker pull rdefosseoai/oai-amf:latest
-$ docker pull rdefosseoai/oai-nrf:latest
-$ docker pull rdefosseoai/oai-smf:latest
-$ docker pull rdefosseoai/oai-spgwu-tiny:latest
+$ docker pull oaisoftwarealliance/oai-amf:latest
+$ docker pull oaisoftwarealliance/oai-nrf:latest
+$ docker pull oaisoftwarealliance/oai-smf:latest
+$ docker pull oaisoftwarealliance/oai-spgwu-tiny:latest
 
-$ docker pull rdefosseoai/oai-gnb:develop
-$ docker pull rdefosseoai/oai-nr-ue:develop
+$ docker pull oaisoftwarealliance/oai-gnb:develop
+$ docker pull oaisoftwarealliance/oai-nr-ue:develop
 ```
 
 And **re-tag** them for tutorials' docker-compose file to work.
 
 ```bash
-$ docker image tag rdefosseoai/oai-amf:latest oai-amf:latest
-$ docker image tag rdefosseoai/oai-nrf:latest oai-nrf:latest
-$ docker image tag rdefosseoai/oai-smf:latest oai-smf:latest
-$ docker image tag rdefosseoai/oai-spgwu-tiny:latest oai-spgwu-tiny:latest
+$ docker image tag oaisoftwarealliance/oai-amf:latest oai-amf:latest
+$ docker image tag oaisoftwarealliance/oai-nrf:latest oai-nrf:latest
+$ docker image tag oaisoftwarealliance/oai-smf:latest oai-smf:latest
+$ docker image tag oaisoftwarealliance/oai-spgwu-tiny:latest oai-spgwu-tiny:latest
 
-$ docker image tag rdefosseoai/oai-gnb:develop oai-gnb:develop
-$ docker image tag rdefosseoai/oai-nr-ue:develop oai-nr-ue:develop
+$ docker image tag oaisoftwarealliance/oai-gnb:develop oai-gnb:develop
+$ docker image tag oaisoftwarealliance/oai-nr-ue:develop oai-nr-ue:develop
 ```
 
 ```bash
diff --git a/ci-scripts/yaml_files/5g_rfsimulator/docker-compose.yaml b/ci-scripts/yaml_files/5g_rfsimulator/docker-compose.yaml
index f27ec3050dc2116faf97f28d4e25f64abb8fcf02..696d8c66989da277c7ed3b3378f40978b1ef546c 100644
--- a/ci-scripts/yaml_files/5g_rfsimulator/docker-compose.yaml
+++ b/ci-scripts/yaml_files/5g_rfsimulator/docker-compose.yaml
@@ -120,7 +120,7 @@ services:
             - SMF_INTERFACE_PORT_FOR_SBI=80
             - SMF_INTERFACE_HTTP2_PORT_FOR_SBI=9090
             - SMF_API_VERSION=v1
-            - DEFAULT_DNS_IPV4_ADDRESS=192.168.18.129
+            - DEFAULT_DNS_IPV4_ADDRESS=172.21.3.100
             - DEFAULT_DNS_SEC_IPV4_ADDRESS=4.4.4.4
             - AMF_IPV4_ADDRESS=0.0.0.0
             - AMF_PORT=80
diff --git a/ci-scripts/yaml_files/fr1_epc_20897/docker-compose.yml b/ci-scripts/yaml_files/fr1_epc_20897/docker-compose.yml
index a3675dc78e10366cf72c794a7832e2701082f119..91d15b52514738d31e19fa5e280132cb6846fcfa 100644
--- a/ci-scripts/yaml_files/fr1_epc_20897/docker-compose.yml
+++ b/ci-scripts/yaml_files/fr1_epc_20897/docker-compose.yml
@@ -132,7 +132,7 @@ services:
             TZ: Europe/Paris
             SGW_INTERFACE_NAME_FOR_S11: eth0
             PGW_INTERFACE_NAME_FOR_SX: eth0
-            DEFAULT_DNS_IPV4_ADDRESS: 192.168.18.129
+            DEFAULT_DNS_IPV4_ADDRESS: 172.21.3.100
             DEFAULT_DNS_SEC_IPV4_ADDRESS: 8.8.4.4
             PUSH_PROTOCOL_OPTION: 'true'
             APN_NI_1: oai.ipv4
diff --git a/ci-scripts/yaml_files/magma_nsa_20897/docker-compose.yml b/ci-scripts/yaml_files/magma_nsa_20897/docker-compose.yml
index df14e900e75859a1f001719a5f207badb653101b..f320e7e3df792f4431e6f42dfeb2556f3dbc49f9 100644
--- a/ci-scripts/yaml_files/magma_nsa_20897/docker-compose.yml
+++ b/ci-scripts/yaml_files/magma_nsa_20897/docker-compose.yml
@@ -116,7 +116,7 @@ services:
             TZ: Europe/Paris
             SGW_INTERFACE_NAME_FOR_S11: eth0
             PGW_INTERFACE_NAME_FOR_SX: eth0
-            DEFAULT_DNS_IPV4_ADDRESS: 192.168.18.129
+            DEFAULT_DNS_IPV4_ADDRESS: 172.21.3.100
             DEFAULT_DNS_SEC_IPV4_ADDRESS: 8.8.4.4
             PUSH_PROTOCOL_OPTION: 'true'
             APN_NI_1: oai.ipv4
diff --git a/ci-scripts/yaml_files/nsa_b200_enb/docker-compose.yml b/ci-scripts/yaml_files/nsa_b200_enb/docker-compose.yml
index 92ccdf8a0ac3fe0e2251ad62e23177f2e060c533..2df5eac61bce953406b081cfe582f534136bfc2e 100644
--- a/ci-scripts/yaml_files/nsa_b200_enb/docker-compose.yml
+++ b/ci-scripts/yaml_files/nsa_b200_enb/docker-compose.yml
@@ -20,7 +20,7 @@ services:
             NB_PRB: 25
             ENABLE_MEASUREMENT_REPORTS: 'yes'
             ENABLE_X2: 'yes'
-            MME_S1C_IP_ADDRESS: 192.168.18.210
+            MME_S1C_IP_ADDRESS: 172.21.16.136
             ENB_S1C_IF_NAME: eth0
             ENB_S1C_IP_ADDRESS: 192.168.68.130
             ENB_S1U_IF_NAME: eth0
@@ -29,7 +29,7 @@ services:
             RRC_INACTIVITY_THRESHOLD: 0
             FLEXRAN_ENABLED: 'no'
             FLEXRAN_INTERFACE_NAME: eth0
-            FLEXRAN_IPV4_ADDRESS: 192.168.18.210
+            FLEXRAN_IPV4_ADDRESS: 172.21.16.136
             THREAD_PARALLEL_CONFIG: PARALLEL_SINGLE_THREAD
             USE_ADDITIONAL_OPTIONS: --log_config.global_log_options level,nocolor,time,line_num,function
         volumes:
diff --git a/ci-scripts/yaml_files/nsa_b200_gnb/docker-compose.yml b/ci-scripts/yaml_files/nsa_b200_gnb/docker-compose.yml
index c6096956a87ec2105ea7b341ae130fef0233d686..208e1564cd41189f52e677d4516a3a467a94b504 100644
--- a/ci-scripts/yaml_files/nsa_b200_gnb/docker-compose.yml
+++ b/ci-scripts/yaml_files/nsa_b200_gnb/docker-compose.yml
@@ -15,7 +15,7 @@ services:
             TAC: 1
             ENABLE_X2: 'yes'
             ENB_X2_IP_ADDRESS: 192.168.68.130
-            MME_S1C_IP_ADDRESS: 192.168.18.210
+            MME_S1C_IP_ADDRESS: 172.21.16.136
             GNB_S1C_IF_NAME: eth0
             GNB_S1C_IP_ADDRESS: 192.168.68.194
             GNB_S1U_IF_NAME: eth0
@@ -24,9 +24,9 @@ services:
             RRC_INACTIVITY_THRESHOLD: 0
             FLEXRAN_ENABLED: 'no'
             FLEXRAN_INTERFACE_NAME: eth0
-            FLEXRAN_IPV4_ADDRESS: 192.168.18.210
+            FLEXRAN_IPV4_ADDRESS: 172.21.16.136
             THREAD_PARALLEL_CONFIG: PARALLEL_RU_L1_TRX_SPLIT
-            USE_ADDITIONAL_OPTIONS: -E -q --RUs.[0].sdr_addrs serial=30C51D4 --log_config.global_log_options level,nocolor,time,line_num,function
+            USE_ADDITIONAL_OPTIONS: -E -q --RUs.[0].sdr_addrs serial=30C51D4 --continuous-tx --log_config.global_log_options level,nocolor,time,line_num,function
         volumes:
             - /dev:/dev
         networks:
diff --git a/cmake_targets/autotests/test_case_list.xml b/cmake_targets/autotests/test_case_list.xml
index ce1b9dcdf4981b968de86b36245fcfd47d5044f5..b55228bdc925b76486e8a8f689225b9c06e4754f 100755
--- a/cmake_targets/autotests/test_case_list.xml
+++ b/cmake_targets/autotests/test_case_list.xml
@@ -1093,7 +1093,7 @@
                                  (Test8: 217 PRB 100 PDSCH-PRBs 110 PDSCH-Offset),
                                  (Test9: 106 PRBs 50 PDSCH-PRBs MCS Index 27),
                                  (Test10: 106 PRBs 50 PDSCH-PRBs MCS Index 16),
-                                 (Test11: 106 MCS-TABLE 256 QAM MCS Index 27),
+                                 (Test11: 106 MCS-TABLE 256 QAM MCS Index 26),
                                  (Test12: HARQ test 25% TP 4 rounds),
                                  (Test13: HARQ test 33% TP 3 rounds),
                                  (Test14: HARQ test 50% TP 2 rounds),
@@ -1121,7 +1121,7 @@
                   -n100 -R217 -a110 -s5 -b100
                   -n100 -e27 -s30
                   -n100 -e16 -s10
-                  -n100 -q1 -e27 -s30
+                  -n100 -q1 -e26 -s30
                   -n100 -s1 -t25
                   -n100 -s1 -t33
                   -n100 -s1 -t50
diff --git a/cmake_targets/phy_simulators b/cmake_targets/phy_simulators
deleted file mode 120000
index 2a12e92f3e9e3938cd869184ab1b8d3f78aa1240..0000000000000000000000000000000000000000
--- a/cmake_targets/phy_simulators
+++ /dev/null
@@ -1 +0,0 @@
-ran_build/
\ No newline at end of file
diff --git a/common/utils/assertions.h b/common/utils/assertions.h
index 573036b1d949e23730cb15cc44d46e3023305d9f..c8959d0adb15b0bbc4478cde7a162851361432eb 100644
--- a/common/utils/assertions.h
+++ b/common/utils/assertions.h
@@ -44,9 +44,9 @@
 #define _Assert_(cOND, aCTION, fORMAT, aRGS...)             \
 do {                                                        \
     if (!(cOND)) {                                          \
-        fprintf(stderr, "\nAssertion ("#cOND") failed!\n"   \
+        fprintf(stderr, "\nAssertion (%s) failed!\n"   \
                 "In %s() %s:%d\n" fORMAT,                   \
-                __FUNCTION__, __FILE__, __LINE__, ##aRGS);  \
+                #cOND, __FUNCTION__, __FILE__, __LINE__, ##aRGS);  \
         aCTION;                                             \
     }						\
 } while(0)
diff --git a/common/utils/lte/ue_power.c b/common/utils/lte/ue_power.c
index b377abf2ff91719f1d4107902c4ce5ba6912fe8a..aaa2826275fb1643c4d513929e29260034d390de 100644
--- a/common/utils/lte/ue_power.c
+++ b/common/utils/lte/ue_power.c
@@ -33,10 +33,8 @@
 #include <stdint.h>
 #include <stdio.h>
 #include "PHY/defs_eNB.h"
-#include "PHY/TOOLS/dB_routines.h"
-
-extern int16_t hundred_times_delta_TF[100];
-extern uint16_t hundred_times_log10_NPRB[100];
+#include <openair1/PHY/TOOLS/tools_defs.h>
+#include <openair1/SCHED/sched_common_extern.h>
 
 int16_t estimate_ue_tx_power(int norm,uint32_t tbs, uint32_t nb_rb, uint8_t control_only, int ncp, uint8_t use_srs)
 {
diff --git a/common/utils/nr/nr_common.c b/common/utils/nr/nr_common.c
index 691d6e08240d73a5aa33df4f1bb1790310e4d9e2..1e76d2e949ea3d40da1d15a72aab1de7f5f065e6 100644
--- a/common/utils/nr/nr_common.c
+++ b/common/utils/nr/nr_common.c
@@ -275,9 +275,9 @@ int get_dmrs_port(int nl, uint16_t dmrs_ports) {
   return p;
 }
 
-lte_frame_type_t get_frame_type(uint16_t current_band, uint8_t scs_index)
+frame_type_t get_frame_type(uint16_t current_band, uint8_t scs_index)
 {
-  lte_frame_type_t current_type;
+  frame_type_t current_type;
   int32_t delta_duplex = get_delta_duplex(current_band, scs_index);
 
   if (delta_duplex == 0)
diff --git a/common/utils/nr/nr_common.h b/common/utils/nr/nr_common.h
index 9b55a48b0b15199a2c95b3714147bd44cd5bc93d..5258ce8809b66a45f737f032057a50ea88414db1 100644
--- a/common/utils/nr/nr_common.h
+++ b/common/utils/nr/nr_common.h
@@ -63,7 +63,7 @@ void get_coreset_rballoc(uint8_t *FreqDomainResource,int *n_rb,int *rb_offset);
 uint16_t config_bandwidth(int mu, int nb_rb, int nr_band);
 int get_nr_table_idx(int nr_bandP, uint8_t scs_index);
 int32_t get_delta_duplex(int nr_bandP, uint8_t scs_index);
-lte_frame_type_t get_frame_type(uint16_t nr_bandP, uint8_t scs_index);
+frame_type_t get_frame_type(uint16_t nr_bandP, uint8_t scs_index);
 uint16_t get_band(uint64_t downlink_frequency, int32_t delta_duplex);
 int NRRIV2BW(int locationAndBandwidth,int N_RB);
 int NRRIV2PRBOFFSET(int locationAndBandwidth,int N_RB);
diff --git a/doc/TESTING_5GSA_setup.md b/doc/TESTING_5GSA_setup.md
index f8c85bf2ca51f012ed578fd99cf145d12f6b649c..9b27549df438ffda963222e04c23435aecbba53c 100644
--- a/doc/TESTING_5GSA_setup.md
+++ b/doc/TESTING_5GSA_setup.md
@@ -36,6 +36,8 @@ At the moment of writing this document interoperability with the following COTS
  - [Quectel RM500Q-GL](https://www.quectel.com/product/5g-rm500q-gl/)
  - [Simcom SIMCOM8200EA](https://www.simcom.com/product/SIM8200EA_M2.html)
  - Huawei Mate 30 Pro
+ - Oneplus 8
+ - Google Pixel 5
 
  End-to-end control plane signaling to achieve a 5G SA connection, UE registration and PDU session establishment with the CN, as well as some basic user-plane traffic tests have been validated so far using SIMCOM/Quectel modules and Huawei Mate 30 pro. In terms of interoperability with different 5G Core Networks, so far this setup has been tested with:
  
diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c
index ff0d3c5a4786e6bef0a7016d7ab6ae1ad9e1aac7..576a4d92b03c614f0122b15182812701aeca65b8 100644
--- a/executables/nr-gnb.c
+++ b/executables/nr-gnb.c
@@ -457,6 +457,7 @@ void init_gNB_Tpool(int inst) {
   for (int i=0; i < 2; i++) {
     notifiedFIFO_elt_t *msgL1Tx = newNotifiedFIFO_elt(sizeof(processingData_L1tx_t),0,gNB->L1_tx_out,tx_func);
     processingData_L1tx_t *msgDataTx = (processingData_L1tx_t *)NotifiedFifoData(msgL1Tx);
+    memset(msgDataTx,0, sizeof(processingData_L1tx_t));
     init_DLSCH_struct(gNB, msgDataTx);
     memset(msgDataTx->ssb, 0, 64*sizeof(NR_gNB_SSB_t));
     pushNotifiedFIFO(gNB->L1_tx_free,msgL1Tx); // to unblock the process in the beginning
diff --git a/executables/nr-softmodem-common.h b/executables/nr-softmodem-common.h
index 47fd816db5a95f4ac5cd642f109f1af8904c8c5b..6e36dcf6c7f749d7f18400ab655a304c726bb315 100644
--- a/executables/nr-softmodem-common.h
+++ b/executables/nr-softmodem-common.h
@@ -51,7 +51,6 @@
 #define CONFIG_HLP_UEFO          "set UE to enable estimation and compensation of frequency offset\n"
 #define CONFIG_HLP_DUMPFRAME     "dump UE received frame to rxsig_frame0.dat and exit\n"
 #define CONFIG_HLP_DLSHIFT       "dynamic shift for LLR compuation for TM3/4 (default 0)\n"
-#define CONFIG_HLP_UELOOP        "get softmodem (UE) to loop through memory instead of acquiring from HW\n"
 #define CONFIG_HLP_PHYTST        "test UE phy layer, mac disabled\n"
 #define CONFIG_HLP_DORA          "test gNB  and UE with RA procedures\n"
 #define CONFIG_HLP_DMAMAP        "sets flag for improved EXMIMO UE performance\n"
diff --git a/executables/nr-ue.c b/executables/nr-ue.c
index 65b74a0218a539c504b83b506c6ea7c80e491fa1..f643344a2b69396509d86e5debdc1334c36cddf0 100644
--- a/executables/nr-ue.c
+++ b/executables/nr-ue.c
@@ -573,17 +573,7 @@ static void UE_synch(void *arg) {
               openair0_cfg[UE->rf_map.card].rx_freq[0],
               openair0_cfg[UE->rf_map.card].tx_freq[0]);
 
-        if (UE->mode != loop_through_memory) {
-          UE->rfdevice.trx_set_freq_func(&UE->rfdevice,&openair0_cfg[0],0);
-          //UE->rfdevice.trx_set_gains_func(&openair0,&openair0_cfg[0]);
-          //UE->rfdevice.trx_stop_func(&UE->rfdevice);
-          // sleep(1);
-          /*if (UE->rfdevice.trx_start_func(&UE->rfdevice) != 0 ) {
-            LOG_E(HW,"Could not start the device\n");
-            oai_exit=1;
-            }*/
-        }
-
+        UE->rfdevice.trx_set_freq_func(&UE->rfdevice,&openair0_cfg[0],0);
         if (UE->UE_scan_carrier == 1) {
           UE->UE_scan_carrier = 0;
         } else {
@@ -602,8 +592,7 @@ static void UE_synch(void *arg) {
 
           LOG_I(PHY, "Initial sync failed: trying carrier off %d Hz\n", freq_offset);
 
-          if (UE->mode != loop_through_memory)
-            UE->rfdevice.trx_set_freq_func(&UE->rfdevice,&openair0_cfg[0],0);
+          UE->rfdevice.trx_set_freq_func(&UE->rfdevice,&openair0_cfg[0],0);
         }
 
         break;
@@ -648,7 +637,7 @@ void processSlotTX(void *arg) {
       stop_meas(&UE->ue_ul_indication_stats);
     }
 
-    if ((UE->mode != loop_through_memory) && (rxtxD->ue_sched_mode != NOT_PUSCH)) {
+    if (rxtxD->ue_sched_mode != NOT_PUSCH) {
       phy_procedures_nrUE_TX(UE,proc,0);
     }
   }
@@ -663,6 +652,7 @@ void processSlotRX(void *arg) {
   int rx_slot_type = nr_ue_slot_select(cfg, proc->frame_rx, proc->nr_slot_rx);
   int tx_slot_type = nr_ue_slot_select(cfg, proc->frame_tx, proc->nr_slot_tx);
   uint8_t gNB_id = 0;
+  NR_UE_PDCCH_CONFIG phy_pdcch_config={0};
 
   if (IS_SOFTMODEM_NOS1 || get_softmodem_params()->sa) {
     /* send tick to RLC and PDCP every ms */
@@ -678,7 +668,7 @@ void processSlotRX(void *arg) {
 
     if(UE->if_inst != NULL && UE->if_inst->dl_indication != NULL) {
       nr_downlink_indication_t dl_indication;
-      nr_fill_dl_indication(&dl_indication, NULL, NULL, proc, UE, gNB_id);
+      nr_fill_dl_indication(&dl_indication, NULL, NULL, proc, UE, gNB_id, &phy_pdcch_config);
       UE->if_inst->dl_indication(&dl_indication, NULL);
     }
 
@@ -687,7 +677,7 @@ void processSlotRX(void *arg) {
     phy_procedures_slot_parallelization_nrUE_RX( UE, proc, 0, 0, 1, no_relay, NULL );
 #else
     uint64_t a=rdtsc_oai();
-    phy_procedures_nrUE_RX(UE, proc, gNB_id, get_nrUE_params()->nr_dlsch_parallel, &rxtxD->txFifo);
+    phy_procedures_nrUE_RX(UE, proc, gNB_id, get_nrUE_params()->nr_dlsch_parallel, &phy_pdcch_config, &rxtxD->txFifo);
     LOG_D(PHY, "In %s: slot %d, time %llu\n", __FUNCTION__, proc->nr_slot_rx, (rdtsc_oai()-a)/3500);
 #endif
 
@@ -737,9 +727,10 @@ void processSlotRX(void *arg) {
 
 void dummyWrite(PHY_VARS_NR_UE *UE,openair0_timestamp timestamp, int writeBlockSize) {
   void *dummy_tx[UE->frame_parms.nb_antennas_tx];
-
+  int16_t dummy_tx_data[UE->frame_parms.nb_antennas_tx][2*writeBlockSize]; // 2 because the function we call use pairs of int16_t implicitly as complex numbers
+  memset(dummy_tx_data, 0, sizeof(dummy_tx_data));
   for (int i=0; i<UE->frame_parms.nb_antennas_tx; i++)
-    dummy_tx[i]=malloc16_clear(writeBlockSize*4);
+    dummy_tx[i]=dummy_tx_data[i];
 
   AssertFatal( writeBlockSize ==
                UE->rfdevice.trx_write_func(&UE->rfdevice,
@@ -749,8 +740,6 @@ void dummyWrite(PHY_VARS_NR_UE *UE,openair0_timestamp timestamp, int writeBlockS
                UE->frame_parms.nb_antennas_tx,
                4),"");
 
-  for (int i=0; i<UE->frame_parms.nb_antennas_tx; i++)
-    free(dummy_tx[i]);
 }
 
 void readFrame(PHY_VARS_NR_UE *UE,  openair0_timestamp *timestamp, bool toTrash) {
@@ -792,7 +781,7 @@ void syncInFrame(PHY_VARS_NR_UE *UE, openair0_timestamp *timestamp) {
     *timestamp += UE->frame_parms.get_samples_per_slot(1,&UE->frame_parms);
     for ( int size=UE->rx_offset ; size > 0 ; size -= UE->frame_parms.samples_per_subframe ) {
       int unitTransfer=size>UE->frame_parms.samples_per_subframe ? UE->frame_parms.samples_per_subframe : size ;
-      // we write before read becasue gNB waits for UE to write and both executions halt
+      // we write before read because gNB waits for UE to write and both executions halt
       // this happens here as the read size is samples_per_subframe which is very much larger than samp_per_slot
       if (IS_SOFTMODEM_RFSIM) dummyWrite(UE,*timestamp, unitTransfer);
       AssertFatal(unitTransfer ==
diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c
index 46fa515e0d2d050d1ccd4679c0beab3afd3b8de8..b1960faf7d555057cba80704529d2f71ccd9eef0 100644
--- a/executables/nr-uesoftmodem.c
+++ b/executables/nr-uesoftmodem.c
@@ -245,14 +245,17 @@ nrUE_params_t *get_nrUE_params(void) {
 }
 /* initialie thread pools used for NRUE processing paralleliation */ 
 void init_tpools(uint8_t nun_dlsch_threads) {
-  char *params = NULL;
-  params = calloc(1,(NR_RX_NB_TH*NR_NB_TH_SLOT*3)+1);
+  char params[NR_RX_NB_TH*NR_NB_TH_SLOT*3+1]={0};
   for (int i=0; i<NR_RX_NB_TH*NR_NB_TH_SLOT; i++) {
     memcpy(params+(i*3),"-1,",3);
   }
-  initTpool(params, &(nrUE_params.Tpool), false);
-  free(params);
-  init_dlsch_tpool( nun_dlsch_threads);
+  if (getenv("noThreads")) {
+     initTpool("n", &(nrUE_params.Tpool), false);
+     init_dlsch_tpool(0);
+   } else {
+     initTpool(params, &(nrUE_params.Tpool), false);
+     init_dlsch_tpool( nun_dlsch_threads);
+   }
 }
 static void get_options(void) {
 
diff --git a/executables/softmodem-common.h b/executables/softmodem-common.h
index 48ce73149f1612e04412ace6737abda0f0b40a6c..eb0c1a54f74025e5c3cb31d159790883c4e59ea7 100644
--- a/executables/softmodem-common.h
+++ b/executables/softmodem-common.h
@@ -53,7 +53,6 @@ extern "C"
 
 
 #define CONFIG_HLP_DUMPFRAME     "dump UE received frame to rxsig_frame0.dat and exit\n"
-#define CONFIG_HLP_UELOOP        "get softmodem (UE) to loop through memory instead of acquiring from HW\n"
 #define CONFIG_HLP_PHYTST        "test UE phy layer, mac disabled\n"
 #define CONFIG_HLP_DORA          "test gNB  and UE with RA procedures\n"
 #define CONFIG_HLP_SA            "run gNB in standalone mode\n"
diff --git a/openair1/PHY/CODING/nr_rate_matching.c b/openair1/PHY/CODING/nr_rate_matching.c
index 29cba0a55729b2b7347a4a8b8324afeeb9a10f43..8c105c37e69cb0706006b83a789eba29c981fca2 100644
--- a/openair1/PHY/CODING/nr_rate_matching.c
+++ b/openair1/PHY/CODING/nr_rate_matching.c
@@ -307,62 +307,76 @@ void nr_interleaving_ldpc(uint32_t E, uint8_t Qm, uint8_t *e,uint8_t *f)
 
 
 void nr_deinterleaving_ldpc(uint32_t E, uint8_t Qm, int16_t *e,int16_t *f)
-{
+{ 
 
-  int16_t *e1,*e2,*e3,*e4,*e5,*e6,*e7;
+  
   switch(Qm) {
   case 2:
-    e1=e+(E/2);
-    for (int j = 0,j2=0; j< E/2; j+=2,j2+=4){
-      e[j]  = f[j2];
-      e1[j] = f[j2+1];
-      e[j+1]  = f[j2+2];
-      e1[j+1] = f[j2+3];
+    {
+      AssertFatal(E%2==0,"");
+      int16_t *e1=e+(E/2);
+      int16_t *end=f+E-1;
+      while( f<end ){
+        *e++  = *f++;
+        *e1++ = *f++;
+      }
     }
     break;
   case 4:
-    e1=e+(E/4);
-    e2=e1+(E/4);
-    e3=e2+(E/4);
-    for (int j = 0,j2=0; j< E/4; j++,j2+=4){
-      e[j]  = f[j2];
-      e1[j] = f[j2+1];
-      e2[j] = f[j2+2];
-      e3[j] = f[j2+3];
+    {
+      AssertFatal(E%4==0,"");
+      int16_t *e1=e+(E/4);
+      int16_t *e2=e1+(E/4);
+      int16_t *e3=e2+(E/4);
+      int16_t *end=f+E-3;
+      while( f<end ){ 
+        *e++  = *f++;
+        *e1++ = *f++;
+        *e2++ = *f++;
+        *e3++ = *f++;
+      }
     }
     break;
   case 6:
-    e1=e+(E/6);
-    e2=e1+(E/6);
-    e3=e2+(E/6);
-    e4=e3+(E/6);
-    e5=e4+(E/6);
-    for (int j = 0,j2=0; j< E/6; j++,j2+=6){
-      e[j]  = f[j2];
-      e1[j] = f[j2+1];
-      e2[j] = f[j2+2];
-      e3[j] = f[j2+3];
-      e4[j] = f[j2+4];
-      e5[j] = f[j2+5];
+    {
+      AssertFatal(E%6==0,"");
+      int16_t *e1=e+(E/6);
+      int16_t *e2=e1+(E/6);
+      int16_t *e3=e2+(E/6);
+      int16_t *e4=e3+(E/6);
+      int16_t *e5=e4+(E/6);
+      int16_t *end=f+E-5;
+     while( f<end ){ 
+        *e++  = *f++;
+        *e1++ = *f++;
+        *e2++ = *f++;
+        *e3++ = *f++;
+        *e4++ = *f++;
+        *e5++ = *f++;
+      }
     }
     break;
   case 8:
-    e1=e+(E/8);
-    e2=e1+(E/8);
-    e3=e2+(E/8);
-    e4=e3+(E/8);
-    e5=e4+(E/8);
-    e6=e5+(E/8);
-    e7=e6+(E/8);
-    for (int j = 0,j2=0; j< E/8; j++,j2+=8){
-      e[j]  = f[j2];
-      e1[j] = f[j2+1];
-      e2[j] = f[j2+2];
-      e3[j] = f[j2+3];
-      e4[j] = f[j2+4];
-      e5[j] = f[j2+5];
-      e6[j] = f[j2+6];
-      e7[j] = f[j2+7];
+    {
+      AssertFatal(E%8==0,"");
+      int16_t *e1=e+(E/8);
+      int16_t *e2=e1+(E/8);
+      int16_t *e3=e2+(E/8);
+      int16_t *e4=e3+(E/8);
+      int16_t *e5=e4+(E/8);
+      int16_t *e6=e5+(E/8);
+      int16_t *e7=e6+(E/8);
+      int16_t *end=f+E-7;
+      while( f<end ){
+        *e++  = *f++;
+        *e1++ = *f++;
+        *e2++ = *f++;
+        *e3++ = *f++;
+        *e4++ = *f++;
+        *e5++ = *f++;
+        *e6++ = *f++;
+        *e7++ = *f++;
+      }
     }
     break;
   default:
diff --git a/openair1/PHY/CODING/nr_segmentation.c b/openair1/PHY/CODING/nr_segmentation.c
index 281e61cda523fc3c9621f81c4d2f1ab183f0c5a5..f43813a6ca1f7b0f872308c6d8263dd91f4a1291 100644
--- a/openair1/PHY/CODING/nr_segmentation.c
+++ b/openair1/PHY/CODING/nr_segmentation.c
@@ -87,7 +87,7 @@ if ((Kprime%Kb) > 0)
 else
   Z = (Kprime/Kb);
 
- LOG_D(PHY,"nr segmetation B %u Bprime %u Kprime %u z %u \n", B, Bprime, Kprime, Z);
+ LOG_D(PHY,"nr segmentation B %u Bprime %u Kprime %u z %u \n", B, Bprime, Kprime, Z);
 	  
   if (Z <= 2) {
     *K = 2;
diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c
index e5bf08abf6faca2d12827fc8cee91b468dcb39d1..9927085a921d8919d11049cd37a3874a375ad8de 100644
--- a/openair1/PHY/INIT/nr_init_ue.c
+++ b/openair1/PHY/INIT/nr_init_ue.c
@@ -159,7 +159,7 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB)
   NR_UE_COMMON *const common_vars        = &ue->common_vars;
   NR_UE_PBCH  **const pbch_vars          = ue->pbch_vars;
   NR_UE_PRACH **const prach_vars         = ue->prach_vars;
-  int i,j,slot,symb, gNB_id, th_id;
+  int i,slot,symb, gNB_id, th_id;
 
   NR_UE_SRS **const srs_vars             = ue->srs_vars;
 
@@ -359,35 +359,6 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB)
       ue->nr_srs_info->srs_estimated_channel_time_shifted[i] = (int32_t *) malloc16_clear(fp->ofdm_symbol_size*MAX_NUM_NR_SRS_SYMBOLS*sizeof(int32_t));
     }
 
-    // 100 PRBs * 12 REs/PRB * 4 PDCCH SYMBOLS * 2 LLRs/RE
-    for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
-      ue->pdcch_vars[th_id][gNB_id]->llr                 = (int16_t *)malloc16_clear( 2*4*100*12*sizeof(uint16_t) );
-      ue->pdcch_vars[th_id][gNB_id]->llr16               = (int16_t *)malloc16_clear( 2*4*100*12*sizeof(uint16_t) );
-      ue->pdcch_vars[th_id][gNB_id]->wbar                = (int16_t *)malloc16_clear( 2*4*100*12*sizeof(uint16_t) );
-      ue->pdcch_vars[th_id][gNB_id]->e_rx                = (int16_t *)malloc16_clear( 4*2*100*12 );
-      ue->pdcch_vars[th_id][gNB_id]->rxdataF_comp        = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
-      ue->pdcch_vars[th_id][gNB_id]->rho                 = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) );
-      ue->pdcch_vars[th_id][gNB_id]->rxdataF_ext         = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
-      ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates_ext = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
-      // Channel estimates
-      ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates      = (int32_t **)malloc16_clear(4*fp->nb_antennas_rx*sizeof(int32_t *));
-      ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates_time = (int32_t **)malloc16_clear(4*fp->nb_antennas_rx*sizeof(int32_t *));
-
-      for (i=0; i<fp->nb_antennas_rx; i++) {
-        ue->pdcch_vars[th_id][gNB_id]->rho[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*(100*12*4));
-
-        for (j=0; j<4; j++) {
-          int idx = (j*fp->nb_antennas_rx)+i;
-          ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates[idx] = (int32_t *)malloc16_clear( sizeof(int32_t)*fp->symbols_per_slot*(fp->ofdm_symbol_size+LTE_CE_FILTER_LENGTH) );
-          ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates_time[idx] = (int32_t *)malloc16_clear( sizeof(int32_t)*fp->ofdm_symbol_size*2 );
-          //  size_t num = 7*2*fp->N_RB_DL*12;
-          size_t num = 4*273*12;  // 4 symbols, 100 PRBs, 12 REs per PRB
-          ue->pdcch_vars[th_id][gNB_id]->rxdataF_comp[idx]        = (int32_t *)malloc16_clear(sizeof(int32_t) * num);
-          ue->pdcch_vars[th_id][gNB_id]->rxdataF_ext[idx]         = (int32_t *)malloc16_clear(sizeof(int32_t) * num);
-          ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates_ext[idx] = (int32_t *)malloc16_clear(sizeof(int32_t) * num);
-        }
-      }
-    }
 
     // RACH
     prach_vars[gNB_id]->prachF             = (int16_t *)malloc16_clear( sizeof(int)*(7*2*sizeof(int)*(fp->ofdm_symbol_size*12)) );
@@ -485,27 +456,6 @@ void term_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB)
   for (int gNB_id = 0; gNB_id < ue->n_connected_gNB; gNB_id++) {
 
     for (int th_id = 0; th_id < RX_NB_TH_MAX; th_id++) {
-      for (int i = 0; i < fp->nb_antennas_rx; i++) {
-        for (int j = 0; j < 4; j++) {
-          int idx = j * fp->nb_antennas_rx + i;
-          free_and_zero(ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates[idx]);
-          free_and_zero(ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates_time[idx]);
-          free_and_zero(ue->pdcch_vars[th_id][gNB_id]->rxdataF_comp[idx]);
-          free_and_zero(ue->pdcch_vars[th_id][gNB_id]->rxdataF_ext[idx]);
-          free_and_zero(ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates_ext[idx]);
-        }
-        free_and_zero(ue->pdcch_vars[th_id][gNB_id]->rho[i]);
-      }
-      free_and_zero(ue->pdcch_vars[th_id][gNB_id]->llr);
-      free_and_zero(ue->pdcch_vars[th_id][gNB_id]->llr16);
-      free_and_zero(ue->pdcch_vars[th_id][gNB_id]->wbar);
-      free_and_zero(ue->pdcch_vars[th_id][gNB_id]->e_rx);
-      free_and_zero(ue->pdcch_vars[th_id][gNB_id]->rxdataF_comp);
-      free_and_zero(ue->pdcch_vars[th_id][gNB_id]->rho);
-      free_and_zero(ue->pdcch_vars[th_id][gNB_id]->rxdataF_ext);
-      free_and_zero(ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates_ext);
-      free_and_zero(ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates);
-      free_and_zero(ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates_time);
 
       free_and_zero(ue->pdcch_vars[th_id][gNB_id]);
     }
diff --git a/openair1/PHY/LTE_ESTIMATION/lte_est_freq_offset.c b/openair1/PHY/LTE_ESTIMATION/lte_est_freq_offset.c
index ed82aeb09e36c602ee2b8d71d2db425176b19b60..80d9fc9cc3144576420b87459bb53185a5bd1498 100644
--- a/openair1/PHY/LTE_ESTIMATION/lte_est_freq_offset.c
+++ b/openair1/PHY/LTE_ESTIMATION/lte_est_freq_offset.c
@@ -102,7 +102,7 @@ int lte_est_freq_offset(int **dl_ch_estimates,
 {
 
   int ch_offset, omega, dl_ch_shift;
-  struct complex16 omega_cpx;
+  c16_t omega_cpx;
   double phase_offset;
   int freq_offset_est;
   unsigned char aa;
@@ -142,8 +142,8 @@ int lte_est_freq_offset(int **dl_ch_estimates,
     //    printf("Computing freq_offset\n");
     omega = dot_product(dl_ch,dl_ch_prev,(frame_parms->N_RB_DL/2 - 1)*12,dl_ch_shift);
     //omega = dot_product(dl_ch,dl_ch_prev,frame_parms->ofdm_symbol_size,15);
-    omega_cpx.r = ((struct complex16*) &omega)->r;
-    omega_cpx.i = ((struct complex16*) &omega)->i;
+    omega_cpx.r = ((c16_t*) &omega)->r;
+    omega_cpx.i = ((c16_t*) &omega)->i;
 
     dl_ch = (int16_t *)&dl_ch_estimates[aa][(((frame_parms->N_RB_DL/2) + 1)*12) + ch_offset];
 
@@ -155,8 +155,8 @@ int lte_est_freq_offset(int **dl_ch_estimates,
     // calculate omega = angle(conj(dl_ch)*dl_ch_prev))
     omega = dot_product(dl_ch,dl_ch_prev,((frame_parms->N_RB_DL/2) - 1)*12,dl_ch_shift);
 
-    omega_cpx.r += ((struct complex16*) &omega)->r;
-    omega_cpx.i += ((struct complex16*) &omega)->i;
+    omega_cpx.r += ((c16_t*) &omega)->r;
+    omega_cpx.i += ((c16_t*) &omega)->i;
 
     //    phase_offset += atan2((double)omega_cpx->i,(double)omega_cpx->r);
     phase_offset += atan2((double)omega_cpx.i,(double)omega_cpx.r);
@@ -195,7 +195,7 @@ int lte_mbsfn_est_freq_offset(int **dl_ch_estimates,
 {
 
   int ch_offset, omega, dl_ch_shift;
-  struct complex16 *omega_cpx;
+  c16_t *omega_cpx;
   double phase_offset;
   int freq_offset_est;
   unsigned char aa;
@@ -234,7 +234,7 @@ int lte_mbsfn_est_freq_offset(int **dl_ch_estimates,
     //    printf("Computing freq_offset\n");
     omega = dot_product(dl_ch,dl_ch_prev,(frame_parms->N_RB_DL/2 - 1)*12,dl_ch_shift);
     //omega = dot_product(dl_ch,dl_ch_prev,frame_parms->ofdm_symbol_size,15);
-    omega_cpx = (struct complex16*) &omega;
+    omega_cpx = (c16_t*) &omega;
 
     //    printf("omega (%d,%d)\n",omega_cpx->r,omega_cpx->i);
 
@@ -247,8 +247,8 @@ int lte_mbsfn_est_freq_offset(int **dl_ch_estimates,
 
     // calculate omega = angle(conj(dl_ch)*dl_ch_prev))
     omega = dot_product(dl_ch,dl_ch_prev,((frame_parms->N_RB_DL/2) - 1)*12,dl_ch_shift);
-    omega_cpx->r += ((struct complex16*) &omega)->r;
-    omega_cpx->i += ((struct complex16*) &omega)->i;
+    omega_cpx->r += ((c16_t*) &omega)->r;
+    omega_cpx->i += ((c16_t*) &omega)->i;
     //    phase_offset += atan2((double)omega_cpx->i,(double)omega_cpx->r);
     phase_offset += atan2((double)omega_cpx->i,(double)omega_cpx->r);
     //    printf("omega (%d,%d) -> %f\n",omega_cpx->r,omega_cpx->i,phase_offset);
diff --git a/openair1/PHY/LTE_ESTIMATION/lte_sync_time.c b/openair1/PHY/LTE_ESTIMATION/lte_sync_time.c
index 1fbc8b7ef2bcd643a718245a9d3873edc3efeb0b..b21f526fcc05851a0253edf585983aafb395e52f 100644
--- a/openair1/PHY/LTE_ESTIMATION/lte_sync_time.c
+++ b/openair1/PHY/LTE_ESTIMATION/lte_sync_time.c
@@ -34,9 +34,9 @@
 // Note: this is for prototype of generate_drs_pusch (OTA synchronization of RRUs)
 #include "PHY/LTE_UE_TRANSPORT/transport_proto_ue.h"
 
-static struct complex16 *primary_synch0_time __attribute__((aligned(32)));
-static struct complex16 *primary_synch1_time __attribute__((aligned(32)));
-static struct complex16 *primary_synch2_time __attribute__((aligned(32)));
+static c16_t *primary_synch0_time __attribute__((aligned(32)));
+static c16_t *primary_synch1_time __attribute__((aligned(32)));
+static c16_t *primary_synch2_time __attribute__((aligned(32)));
 
 static void doIdft(int size, short *in, short *out) {
   switch (size) {
@@ -67,7 +67,7 @@ static void doIdft(int size, short *in, short *out) {
     }
   }
 
-static void copyPrimary( struct complex16 *out, struct complex16 *in, int ofdmSize) {
+static void copyPrimary( c16_t *out, struct complex16 *in, int ofdmSize) {
   int k=ofdmSize-36;
     
   for (int i=0; i<72; i++) {
@@ -83,20 +83,20 @@ static void copyPrimary( struct complex16 *out, struct complex16 *in, int ofdmSi
   }
 
 int lte_sync_time_init(LTE_DL_FRAME_PARMS *frame_parms ) { // LTE_UE_COMMON *common_vars
-  struct complex16 syncF_tmp[2048]__attribute__((aligned(32)))= {{0}};
+  c16_t syncF_tmp[2048]__attribute__((aligned(32)))= {{0}};
   int sz=frame_parms->ofdm_symbol_size*sizeof(*primary_synch0_time);
-  AssertFatal( NULL != (primary_synch0_time = (struct complex16 *)malloc16(sz)),"");
+  AssertFatal( NULL != (primary_synch0_time = (c16_t *)malloc16(sz)),"");
   bzero(primary_synch0_time,sz);
-  AssertFatal( NULL != (primary_synch1_time = (struct complex16 *)malloc16(sz)),"");
+  AssertFatal( NULL != (primary_synch1_time = (c16_t *)malloc16(sz)),"");
   bzero(primary_synch1_time,sz);
-  AssertFatal( NULL != (primary_synch2_time = (struct complex16 *)malloc16(sz)),"");
+  AssertFatal( NULL != (primary_synch2_time = (c16_t *)malloc16(sz)),"");
   bzero(primary_synch2_time,sz);
   // generate oversampled sync_time sequences
-  copyPrimary( syncF_tmp, (struct complex16 *) primary_synch0, frame_parms->ofdm_symbol_size);
+  copyPrimary( syncF_tmp, (c16_t *) primary_synch0, frame_parms->ofdm_symbol_size);
   doIdft(frame_parms->N_RB_DL, (short *)syncF_tmp,(short *)primary_synch0_time);
-  copyPrimary( syncF_tmp, (struct complex16 *) primary_synch1, frame_parms->ofdm_symbol_size);
+  copyPrimary( syncF_tmp, (c16_t *) primary_synch1, frame_parms->ofdm_symbol_size);
   doIdft(frame_parms->N_RB_DL, (short *)syncF_tmp,(short *)primary_synch1_time);
-  copyPrimary( syncF_tmp, (struct complex16 *) primary_synch2, frame_parms->ofdm_symbol_size);
+  copyPrimary( syncF_tmp, (c16_t *) primary_synch2, frame_parms->ofdm_symbol_size);
   doIdft(frame_parms->N_RB_DL, (short *)syncF_tmp,(short *)primary_synch2_time);
 
   if ( LOG_DUMPFLAG(DEBUG_LTEESTIM)){
diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c b/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c
index c6b312cc61a1ffd34e38e6573b9aeae8f16a6825..de21b7f4e2e08a52cbe36a32e062dc63d390286c 100644
--- a/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c
+++ b/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c
@@ -2237,7 +2237,7 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB,
   int P1_SHIFT[13],P2_SHIFT[13];
   int offset,nushiftmod3;
 
-  uint8_t get_pmi_temp;
+  int get_pmi_temp;
 
   MIMO_mode_t mimo_mode = -1;
   uint8_t mprime=0,Ns;
diff --git a/openair1/PHY/LTE_TRANSPORT/prach.c b/openair1/PHY/LTE_TRANSPORT/prach.c
index eb46a8d663df1d670857d0ad247945467024dcc8..91c419ebe39495931098001711d00ef45af97b28 100644
--- a/openair1/PHY/LTE_TRANSPORT/prach.c
+++ b/openair1/PHY/LTE_TRANSPORT/prach.c
@@ -56,7 +56,7 @@ void rx_prach0(PHY_VARS_eNB *eNB,
                uint8_t ce_level
               ) {
   int i;
-  lte_frame_type_t   frame_type;
+  frame_type_t   frame_type;
   uint16_t           rootSequenceIndex;
   uint8_t            prach_ConfigIndex;
   uint8_t            Ncs_config;
diff --git a/openair1/PHY/LTE_TRANSPORT/prach_common.c b/openair1/PHY/LTE_TRANSPORT/prach_common.c
index e366e8edbc9008c1e5435fcdb4fb18405d6d4729..f3409a90e3a7bcace50d889ab85e082489c48465 100644
--- a/openair1/PHY/LTE_TRANSPORT/prach_common.c
+++ b/openair1/PHY/LTE_TRANSPORT/prach_common.c
@@ -399,7 +399,7 @@ void compute_prach_seq(uint16_t rootSequenceIndex,
                        uint8_t prach_ConfigIndex,
                        uint8_t zeroCorrelationZoneConfig,
                        uint8_t highSpeedFlag,
-                       lte_frame_type_t frame_type,
+                       frame_type_t frame_type,
                        uint32_t X_u[64][839]) {
   // Compute DFT of x_u => X_u[k] = x_u(inv(u)*k)^* X_u[k] = exp(j\pi u*inv(u)*k*(inv(u)*k+1)/N_ZC)
   unsigned int k,inv_u,i,NCS=0,num_preambles;
diff --git a/openair1/PHY/LTE_TRANSPORT/prach_extern.h b/openair1/PHY/LTE_TRANSPORT/prach_extern.h
index 3404646923adc9175b78a018f099f9ff2058a748..340386101120f00ac9a65268a41278db0fa5bc6e 100644
--- a/openair1/PHY/LTE_TRANSPORT/prach_extern.h
+++ b/openair1/PHY/LTE_TRANSPORT/prach_extern.h
@@ -81,7 +81,7 @@ void compute_prach_seq(uint16_t rootSequenceIndex,
 		       uint8_t prach_ConfigIndex,
 		       uint8_t zeroCorrelationZoneConfig,
 		       uint8_t highSpeedFlag,
-		       lte_frame_type_t frame_type,
+		       frame_type_t frame_type,
 		       uint32_t X_u[64][839]);
 
 #endif
diff --git a/openair1/PHY/LTE_TRANSPORT/transport_common_proto.h b/openair1/PHY/LTE_TRANSPORT/transport_common_proto.h
index af8e63c3edc02823e0b9a7ad45f674d579de7dc2..57a7b2ec915eabc2e8458abfb3a8810fbf0d2369 100644
--- a/openair1/PHY/LTE_TRANSPORT/transport_common_proto.h
+++ b/openair1/PHY/LTE_TRANSPORT/transport_common_proto.h
@@ -224,7 +224,7 @@ uint8_t get_num_prach_tdd(module_id_t Mod_id);
   @returns 0-1 accordingly
 */
 /*
-uint8_t get_prach_fmt(uint8_t prach_ConfigIndex,lte_frame_type_t frame_type);
+uint8_t get_prach_fmt(uint8_t prach_ConfigIndex,frame_type_t frame_type);
 */
 
 /*!
@@ -247,7 +247,7 @@ void compute_prach_seq(uint16_t rootSequenceIndex,
                        uint8_t prach_ConfigIndex,
                        uint8_t zeroCorrelationZoneConfig,
                        uint8_t highSpeedFlag,
-                       lte_frame_type_t frame_type,
+                       frame_type_t frame_type,
                        uint32_t X_u[64][839]);
 
 
@@ -299,7 +299,7 @@ uint64_t pmi2hex_2Ar1(uint32_t pmi);
 
 uint64_t pmi2hex_2Ar2(uint32_t pmi);
 
-uint8_t get_pmi(uint8_t N_RB_DL,MIMO_mode_t mode, uint32_t pmi_alloc,uint16_t rb);
+uint8_t get_pmi(int N_RB_DL,MIMO_mode_t mode, uint32_t pmi_alloc,uint16_t rb);
 
 // DL power control functions
 double get_pa_dB(uint8_t pa);
diff --git a/openair1/PHY/LTE_UE_TRANSPORT/dci_tools_ue.c b/openair1/PHY/LTE_UE_TRANSPORT/dci_tools_ue.c
index efde277203d2a93a9c953fd49945105c82090e4f..088e2c0a5e29665d2d64ba86e7a374906af00c52 100644
--- a/openair1/PHY/LTE_UE_TRANSPORT/dci_tools_ue.c
+++ b/openair1/PHY/LTE_UE_TRANSPORT/dci_tools_ue.c
@@ -64,7 +64,7 @@ extern uint16_t beta_cqi[16];
 extern uint16_t beta_ri[16];
 extern uint16_t beta_ack[16];
 
-void extract_dci1A_info(uint8_t N_RB_DL, lte_frame_type_t frame_type, void *dci_pdu, DCI_INFO_EXTRACTED_t *pdci_info_extarcted)
+void extract_dci1A_info(uint8_t N_RB_DL, frame_type_t frame_type, void *dci_pdu, DCI_INFO_EXTRACTED_t *pdci_info_extarcted)
 {
     uint8_t harq_pid=0;
     uint32_t rballoc=0;
@@ -182,7 +182,7 @@ void extract_dci1A_info(uint8_t N_RB_DL, lte_frame_type_t frame_type, void *dci_
     pdci_info_extarcted->dai      = dai;
 }
 
-void extract_dci1C_info(uint8_t N_RB_DL, lte_frame_type_t frame_type, void *dci_pdu, DCI_INFO_EXTRACTED_t *pdci_info_extarcted)
+void extract_dci1C_info(uint8_t N_RB_DL, frame_type_t frame_type, void *dci_pdu, DCI_INFO_EXTRACTED_t *pdci_info_extarcted)
 {
 
     uint32_t rballoc=0;
@@ -222,7 +222,7 @@ void extract_dci1C_info(uint8_t N_RB_DL, lte_frame_type_t frame_type, void *dci_
     pdci_info_extarcted->Ngap     = Ngap;
 }
 
-void extract_dci1_info(uint8_t N_RB_DL, lte_frame_type_t frame_type, void *dci_pdu, DCI_INFO_EXTRACTED_t *pdci_info_extarcted)
+void extract_dci1_info(uint8_t N_RB_DL, frame_type_t frame_type, void *dci_pdu, DCI_INFO_EXTRACTED_t *pdci_info_extarcted)
 {
 
     uint32_t rballoc=0;
@@ -329,7 +329,7 @@ void extract_dci1_info(uint8_t N_RB_DL, lte_frame_type_t frame_type, void *dci_p
 
 }
 
-void extract_dci2_info(uint8_t N_RB_DL, lte_frame_type_t frame_type, uint8_t nb_antenna_ports_eNB, void *dci_pdu, DCI_INFO_EXTRACTED_t *pdci_info_extarcted)
+void extract_dci2_info(uint8_t N_RB_DL, frame_type_t frame_type, uint8_t nb_antenna_ports_eNB, void *dci_pdu, DCI_INFO_EXTRACTED_t *pdci_info_extarcted)
 {
 
     uint32_t rballoc=0;
@@ -615,7 +615,7 @@ void extract_dci2_info(uint8_t N_RB_DL, lte_frame_type_t frame_type, uint8_t nb_
 
 }
 
-void extract_dci2A_info(uint8_t N_RB_DL, lte_frame_type_t frame_type, uint8_t nb_antenna_ports_eNB, void *dci_pdu, DCI_INFO_EXTRACTED_t *pdci_info_extarcted)
+void extract_dci2A_info(uint8_t N_RB_DL, frame_type_t frame_type, uint8_t nb_antenna_ports_eNB, void *dci_pdu, DCI_INFO_EXTRACTED_t *pdci_info_extarcted)
 {
 
     uint32_t rballoc=0;
diff --git a/openair1/PHY/LTE_UE_TRANSPORT/get_pmi.c b/openair1/PHY/LTE_UE_TRANSPORT/get_pmi.c
index 7bbe8e894257d772ae1edc96795df9e84119a0d7..6ab2ad9fddef3926df62b39e3c15d60cce9de9aa 100644
--- a/openair1/PHY/LTE_UE_TRANSPORT/get_pmi.c
+++ b/openair1/PHY/LTE_UE_TRANSPORT/get_pmi.c
@@ -21,7 +21,7 @@
 
 #include "PHY/LTE_UE_TRANSPORT/transport_proto_ue.h"
 
-uint8_t get_pmi(uint8_t N_RB_DL, MIMO_mode_t mode, uint32_t pmi_alloc,uint16_t rb)
+uint8_t get_pmi(int N_RB_DL, MIMO_mode_t mode, uint32_t pmi_alloc,uint16_t rb)
 {
   /*
   MIMO_mode_t mode   = dlsch_harq->mimo_mode;
diff --git a/openair1/PHY/LTE_UE_TRANSPORT/prach_ue.c b/openair1/PHY/LTE_UE_TRANSPORT/prach_ue.c
index 82120dc3c333833eb338083596b2758a422a8b17..4faa8367c3ac87a112a9c7348789f2763f66eb15 100644
--- a/openair1/PHY/LTE_UE_TRANSPORT/prach_ue.c
+++ b/openair1/PHY/LTE_UE_TRANSPORT/prach_ue.c
@@ -46,7 +46,7 @@
 //#define PRACH_DEBUG 1
 
 int32_t generate_prach( PHY_VARS_UE *ue, uint8_t eNB_id, uint8_t subframe, uint16_t Nf ) {
-  lte_frame_type_t frame_type         = ue->frame_parms.frame_type;
+  frame_type_t frame_type         = ue->frame_parms.frame_type;
   //uint8_t tdd_config         = ue->frame_parms.tdd_config;
   uint16_t rootSequenceIndex = ue->frame_parms.prach_config_common.rootSequenceIndex;
   uint8_t prach_ConfigIndex  = ue->frame_parms.prach_config_common.prach_ConfigInfo.prach_ConfigIndex;
diff --git a/openair1/PHY/LTE_UE_TRANSPORT/transport_proto_ue.h b/openair1/PHY/LTE_UE_TRANSPORT/transport_proto_ue.h
index c5d096ceb789573d70aea15784f4aff9e1c8f374..f5b8c6b64a0e287f90078bfbb407171ae6836705 100644
--- a/openair1/PHY/LTE_UE_TRANSPORT/transport_proto_ue.h
+++ b/openair1/PHY/LTE_UE_TRANSPORT/transport_proto_ue.h
@@ -1550,16 +1550,6 @@ uint64_t cqi2hex(uint32_t cqi);
 
 uint16_t computeRIV(uint16_t N_RB_DL,uint16_t RBstart,uint16_t Lcrbs);
 
-
-/** \brief  This routine extracts a single subband PMI from a bitmap coming from UCI or the pmi_extend function
-    @param N_RB_DL number of resource blocks
-    @param mimo_mode
-    @param pmi_alloc subband PMI bitmap
-    @param rb resource block for which to extract PMI
-    @returns subband PMI
-*/
-uint8_t get_pmi(uint8_t N_RB_DL,MIMO_mode_t mode, uint32_t pmi_alloc,uint16_t rb);
-
 int get_nCCE_offset_l1(int *CCE_table,
                        const unsigned char L,
                        const int nCCE,
@@ -1669,7 +1659,7 @@ uint8_t get_num_prach_tdd(module_id_t Mod_id);
   @param frame_type 0-FDD, 1-TDD
   @returns 0-1 accordingly
 */
-uint8_t get_prach_fmt(uint8_t prach_ConfigIndex,lte_frame_type_t frame_type);
+uint8_t get_prach_fmt(uint8_t prach_ConfigIndex,frame_type_t frame_type);
 
 /*!
   \brief Helper for MAC, returns frequency index of PRACH resource in TDD for a particular configuration index
@@ -1691,7 +1681,7 @@ void compute_prach_seq(uint16_t rootSequenceIndex,
                        uint8_t prach_ConfigIndex,
                        uint8_t zeroCorrelationZoneConfig,
                        uint8_t highSpeedFlag,
-                       lte_frame_type_t frame_type,
+                       frame_type_t frame_type,
                        uint32_t X_u[64][839]);
 
 
diff --git a/openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c b/openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c
index f4761489f578f7828c89ea0405b9eb78cfd680a8..aec5e1b12bffdc77dde439a201d7596a5577ad28 100644
--- a/openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c
+++ b/openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c
@@ -107,25 +107,20 @@ void gNB_I0_measurements(PHY_VARS_gNB *gNB,int slot, int first_symb,int num_symb
   NR_DL_FRAME_PARMS *frame_parms = &gNB->frame_parms;
   NR_gNB_COMMON *common_vars = &gNB->common_vars;
   PHY_MEASUREMENTS_gNB *measurements = &gNB->measurements;
-  int rb, offset, offset0, nb_symb[275], len;
-  int32_t *ul_ch;
-
-  LOG_D(PHY,"slot %d Doing I0 for first_symb %d, num_symb %d\n",slot,first_symb,num_symb);
+  int rb, nb_symb[275]={0};
+   
+  memset(measurements->n0_subband_power, 0, sizeof(measurements->n0_subband_power));
+    
   for (int s=first_symb;s<(first_symb+num_symb);s++) {
     for (rb=0; rb<frame_parms->N_RB_UL; rb++) {
-
-      if (s==first_symb) {
-        nb_symb[rb]=0;
-        for (int aarx=0; aarx<frame_parms->nb_antennas_rx;aarx++) 
-           measurements->n0_subband_power[aarx][rb]=0;   
-      }
-      offset0 = (slot&3)*(frame_parms->symbols_per_slot * frame_parms->ofdm_symbol_size) + (frame_parms->first_carrier_offset + (rb*12))%frame_parms->ofdm_symbol_size;
+      int offset0 = (slot&3)*(frame_parms->symbols_per_slot * frame_parms->ofdm_symbol_size) +
+	(frame_parms->first_carrier_offset + (rb*12))%frame_parms->ofdm_symbol_size;
       if ((gNB->rb_mask_ul[s][rb>>5]&(1<<(rb&31))) == 0) {  // check that rb was not used in this subframe
         nb_symb[rb]++;          
         for (int aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
-          offset = offset0 + (s*frame_parms->ofdm_symbol_size);
-          ul_ch  = &common_vars->rxdataF[aarx][offset];
-          len = 12;
+          int offset = offset0 + (s*frame_parms->ofdm_symbol_size);
+          int32_t *ul_ch  = &common_vars->rxdataF[aarx][offset];
+          int len = 12;
           if (((frame_parms->N_RB_UL&1) == 1) && 
               (rb==(frame_parms->N_RB_UL>>1))) {
             len=6;
diff --git a/openair1/PHY/NR_REFSIG/pss_nr.h b/openair1/PHY/NR_REFSIG/pss_nr.h
index b32d48a2e9f95e126e6dd3d77b2b8c9517a7fd76..c65ca3799d6348c81c39fae8a9a2d627f6fcedfa 100644
--- a/openair1/PHY/NR_REFSIG/pss_nr.h
+++ b/openair1/PHY/NR_REFSIG/pss_nr.h
@@ -113,12 +113,6 @@ EXTERN int16_t *primary_synchro_time_nr[NUMBER_PSS_SEQUENCE]
 #endif
 ;
 
-EXTERN int64_t *pss_corr_ue[NUMBER_PSS_SEQUENCE]
-#ifdef INIT_VARIABLES_PSS_NR_H
-= { NULL, NULL, NULL}
-#endif
-;
-
 /* profiling structure */
 EXTERN time_stats_t generic_time[TIME_LAST];
 
diff --git a/openair1/PHY/NR_REFSIG/ptrs_nr.c b/openair1/PHY/NR_REFSIG/ptrs_nr.c
index 40a6a56611ebbf0db6bbb2f2e2f8a6f4d2859f0b..68134eb02ddb61b2dd7d63b54180cebc05bd64e1 100644
--- a/openair1/PHY/NR_REFSIG/ptrs_nr.c
+++ b/openair1/PHY/NR_REFSIG/ptrs_nr.c
@@ -268,8 +268,8 @@ void nr_ptrs_cpe_estimation(uint8_t K_ptrs,
     return;
   }
   uint16_t              sc_per_symbol    = (nb_rb + K_ptrs - 1)/K_ptrs;
-  struct complex16      ptrs_p[(1 + sc_per_symbol/4)*4];
-  struct complex16      dmrs_comp_p[(1 + sc_per_symbol/4)*4];
+  c16_t      ptrs_p[(1 + sc_per_symbol/4)*4];
+  c16_t      dmrs_comp_p[(1 + sc_per_symbol/4)*4];
   double                abs              = 0.0;
   double                real             = 0.0;
   double                imag             = 0.0;
@@ -422,7 +422,7 @@ void get_slope_from_estimates(uint8_t start, uint8_t end, int16_t *est_p, double
 /* estimate from slope */
 void ptrs_estimate_from_slope(int16_t *error_est, double *slope_p, uint8_t start, uint8_t end)
 {
-  struct complex16 *error=(struct complex16 *) error_est;
+  c16_t *error=(struct complex16 *) error_est;
   for(uint8_t i = 1; i< (end -start);i++) {
     error[start+i].r = error[start].r + (int16_t)(i * slope_p[0]);// real
     error[start+i].i = error[start].i + (int16_t)(i * slope_p[1]); //imag
diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c
index ba7e539429d87717d687009560681bfca0112b8f..47961640369f80d19d5f0a74f6d7e8bb8f479c71 100644
--- a/openair1/PHY/NR_TRANSPORT/nr_dci.c
+++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c
@@ -141,6 +141,7 @@ void nr_generate_dci(PHY_VARS_gNB *gNB,
     polar_encoder_fast((uint64_t*)dci_pdu->Payload, (void*)encoder_output, n_RNTI, 1, 
                        NR_POLAR_DCI_MESSAGE_TYPE, dci_pdu->PayloadSizeBits, dci_pdu->AggregationLevel);
 #ifdef DEBUG_CHANNEL_CODING
+//debug dump dci
     printf("polar rnti %x,length %d, L %d\n",n_RNTI, dci_pdu->PayloadSizeBits,pdcch_pdu_rel15->dci_pdu->AggregationLevel);
     printf("DCI PDU: [0]->0x%lx \t [1]->0x%lx\n",
 	   ((uint64_t*)dci_pdu->Payload)[0], ((uint64_t*)dci_pdu->Payload)[1]);
diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch.c b/openair1/PHY/NR_TRANSPORT/nr_dlsch.c
index 19b56f6dbab327b194f8febba8a003bbd825e310..2c4fb26c5adab7508063f45ab6f18da919d82254 100644
--- a/openair1/PHY/NR_TRANSPORT/nr_dlsch.c
+++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch.c
@@ -129,7 +129,7 @@ void nr_generate_pdsch(processingData_L1tx_t *msgTx,
     start_meas(dlsch_encoding_stats);
 
     if (nr_dlsch_encoding(gNB,
-                          harq->pdu, frame, slot, dlsch, frame_parms,output,tinput,tprep,tparity,toutput,
+                          frame, slot, harq, frame_parms,output,tinput,tprep,tparity,toutput,
                           dlsch_rate_matching_stats,
                           dlsch_interleaving_stats,
                           dlsch_segmentation_stats) == -1)
@@ -163,6 +163,7 @@ void nr_generate_pdsch(processingData_L1tx_t *msgTx,
                                    rel15->dataScramblingId,
                                    rel15->rnti,
                                    scrambled_output);
+
 #ifdef DEBUG_DLSCH
       printf("PDSCH scrambling:\n");
       for (int i=0; i<encoded_length>>8; i++) {
@@ -171,6 +172,7 @@ void nr_generate_pdsch(processingData_L1tx_t *msgTx,
         printf("\n");
       }
 #endif
+
       stop_meas(dlsch_scrambling_stats);
       /// Modulation
       start_meas(dlsch_modulation_stats);
diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch.h b/openair1/PHY/NR_TRANSPORT/nr_dlsch.h
index fe503709644c665e351c9638eb180dc1ddb5b548..bdf681c21d3dbb480dca1a4f16acb754bb62f8b3 100644
--- a/openair1/PHY/NR_TRANSPORT/nr_dlsch.h
+++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch.h
@@ -73,9 +73,9 @@ int16_t find_nr_dlsch(uint16_t rnti, PHY_VARS_gNB *gNB,find_type_t type);
 NR_gNB_SCH_STATS_t *find_nr_dlsch_stats(uint16_t rnti, PHY_VARS_gNB *gNB,find_type_t type);
 
 int nr_dlsch_encoding(PHY_VARS_gNB *gNB,
-		      unsigned char *a,int frame,
+		      int frame,
 		      uint8_t slot,
-		      NR_gNB_DLSCH_t *dlsch,
+		      NR_DL_gNB_HARQ_t *harq,
 		      NR_DL_FRAME_PARMS* frame_parms,
 		      unsigned char * output,
 		      time_stats_t *tinput,
diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c
index 5447c2bd73f2521f64491b7597ca9a8fc0467682..23101756bf715bef8d31872a93f973f491332d1e 100644
--- a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c
+++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c
@@ -286,10 +286,9 @@ void ldpc8blocks( void *p) {
 }
 
 int nr_dlsch_encoding(PHY_VARS_gNB *gNB,
-                      unsigned char *a,
                       int frame,
                       uint8_t slot,
-                      NR_gNB_DLSCH_t *dlsch,
+                      NR_DL_gNB_HARQ_t *harq,
                       NR_DL_FRAME_PARMS *frame_parms,
 		      unsigned char * output,
                       time_stats_t *tinput,time_stats_t *tprep,time_stats_t *tparity,time_stats_t *toutput,
@@ -298,12 +297,11 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB,
   encoder_implemparams_t impp;
   impp.output=output;
   unsigned int crc=1;
-  NR_DL_gNB_HARQ_t *harq = &dlsch->harq_process;
   nfapi_nr_dl_tti_pdsch_pdu_rel15_t *rel15 = &harq->pdsch_pdu.pdsch_pdu_rel15;
-  impp.Zc = &dlsch->harq_process.Z;
+  impp.Zc = &harq->Z;
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_gNB_DLSCH_ENCODING, VCD_FUNCTION_IN);
   uint32_t A = rel15->TBSize[0]<<3;
-
+  unsigned char *a=harq->pdu;
   if ( rel15->rnti != SI_RNTI)
     trace_NRpdu(DIRECTION_DOWNLINK, a, rel15->TBSize[0], 0, WS_C_RNTI, rel15->rnti, frame, slot,0, 0);
 
@@ -316,14 +314,14 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB,
       stats=&gNB->dlsch_stats[i];
     }
 
-    if (gNB->dlsch_stats[i].rnti == dlsch->rnti) {
+    if (gNB->dlsch_stats[i].rnti == rel15->rnti) {
       stats=&gNB->dlsch_stats[i];
       break;
     }
   }
 
   if (stats) {
-    stats->rnti = dlsch->rnti;
+    stats->rnti = rel15->rnti;
     stats->total_bytes_tx += rel15->TBSize[0];
     stats->current_RI   = rel15->nrOfLayers;
     stats->current_Qm   = rel15->qamModOrder[0];
diff --git a/openair1/PHY/NR_TRANSPORT/pucch_rx.c b/openair1/PHY/NR_TRANSPORT/pucch_rx.c
index 50c3b62f5023931ad28924a9f96d96bfcf9c80e7..cd368a68cc31ec33092d19089f22e07d0b492739 100644
--- a/openair1/PHY/NR_TRANSPORT/pucch_rx.c
+++ b/openair1/PHY/NR_TRANSPORT/pucch_rx.c
@@ -243,7 +243,7 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB,
    * x(l*12+n) = r_u_v_alpha_delta(n)
    */
   // the value of u,v (delta always 0 for PUCCH) has to be calculated according to TS 38.211 Subclause 6.3.2.2.1
-  uint8_t u[2]={0,0},v[2]={0,0};
+  uint8_t u[2]={0},v[2]={0};
 
   // x_n contains the sequence r_u_v_alpha_delta(n)
 
@@ -262,7 +262,7 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB,
 
 
   AssertFatal(pucch_pdu->nr_of_symbols < 3,"nr_of_symbols %d not allowed\n",pucch_pdu->nr_of_symbols);
-  uint32_t re_offset[2]={0,0};
+  uint32_t re_offset[2]={0};
   uint8_t l2;
 
   const int16_t *x_re[2],*x_im[2];
@@ -271,16 +271,10 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB,
   x_re[1] = table_5_2_2_2_2_Re[u[1]];
   x_im[1] = table_5_2_2_2_2_Im[u[1]];
 
-  int16_t xr[1+frame_parms->nb_antennas_rx][1+pucch_pdu->nr_of_symbols][24]  __attribute__((aligned(32)));
+  c64_t xr[frame_parms->nb_antennas_rx][pucch_pdu->nr_of_symbols][12]  __attribute__((aligned(32)));
   int64_t xrtmag=0,xrtmag_next=0;
   uint8_t maxpos=0;
   uint8_t index=0;
-  for (int l=0; l<pucch_pdu->nr_of_symbols; l++) {
-    for (int aarx=0;aarx<frame_parms->nb_antennas_rx;aarx++) {
-      memset((void*)xr[aarx][l],0,24*sizeof(int16_t));
-    }
-  }
-  int n2;
 
   for (int l=0; l<pucch_pdu->nr_of_symbols; l++) {
     l2 = l+pucch_pdu->start_symbol_index;
@@ -289,75 +283,68 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB,
       re_offset[l]-=frame_parms->ofdm_symbol_size;
   
     AssertFatal(re_offset[l]+12 < frame_parms->ofdm_symbol_size,"pucch straddles DC carrier, handle this!\n");
-    int16_t *r;
     for (int aa=0;aa<frame_parms->nb_antennas_rx;aa++) {
-      r=(int16_t*)&rxdataF[aa][soffset+(l2*frame_parms->ofdm_symbol_size)+re_offset[l]];
-      n2=0;
-      for (n=0;n<12;n++,n2+=2) {
-        xr[aa][l][n2]  +=(int16_t)(((int32_t)x_re[l][n]*r[n2]+(int32_t)x_im[l][n]*r[n2+1])>>15);
-        xr[aa][l][n2+1]+=(int16_t)(((int32_t)x_re[l][n]*r[n2+1]-(int32_t)x_im[l][n]*r[n2])>>15);
+      c16_t *r=(c16_t*)&rxdataF[aa][soffset+(l2*frame_parms->ofdm_symbol_size)+re_offset[l]];
+      for (n=0;n<12;n++) {
+        xr[aa][l][n].r = (int32_t)x_re[l][n] * r[n].r + (int32_t)x_im[l][n] * r[n].i;
+        xr[aa][l][n].i = (int32_t)x_re[l][n] * r[n].i - (int32_t)x_im[l][n] * r[n].r;
 #ifdef DEBUG_NR_PUCCH_RX
-        printf("x (%d,%d), r%d.%d (%d,%d), xr (%d,%d)\n",
-	               x_re[l][n],x_im[l][n],l2,re_offset[l],r[n2],r[n2+1],xr[aa][l][n2],xr[aa][l][n2+1]);
+        printf("x (%d,%d), r%d.%d (%d,%d), xr (%lld,%lld)\n",
+	             x_re[l][n],x_im[l][n],l2,re_offset[l],r[n].r,r[n].i,xr[aa][l][n].r,xr[aa][l][n].i);
 #endif
       }
     }
   }
 
-  int32_t corr_re[1+frame_parms->nb_antennas_rx][2];
-  int32_t corr_im[1+frame_parms->nb_antennas_rx][2];
   //int32_t no_corr = 0;
   int seq_index = 0;
   int64_t temp;
 
   for(i=0;i<nr_sequences;i++){
-
-    for (int l=0;l<pucch_pdu->nr_of_symbols;l++) {
-      seq_index = (pucch_pdu->initial_cyclic_shift+
-		   mcs[i]+
-		   gNB->pucch0_lut.lut[cs_ind][slot][l+pucch_pdu->start_symbol_index])%12;
+    c64_t corr[frame_parms->nb_antennas_rx][2];
+    for (int aa=0;aa<frame_parms->nb_antennas_rx;aa++) {
+      for (int l=0;l<pucch_pdu->nr_of_symbols;l++) {
+        seq_index = (pucch_pdu->initial_cyclic_shift+
+                     mcs[i]+
+                     gNB->pucch0_lut.lut[cs_ind][slot][l+pucch_pdu->start_symbol_index])%12;
 #ifdef DEBUG_NR_PUCCH_RX
-      printf("PUCCH symbol %d seq %d, seq_index %d, mcs %d\n",l,i,seq_index,mcs[i]);
+        printf("PUCCH symbol %d seq %d, seq_index %d, mcs %d\n",l,i,seq_index,mcs[i]);
 #endif
-      for (int aa=0;aa<frame_parms->nb_antennas_rx;aa++) {
-        corr_re[aa][l]=0;
-        corr_im[aa][l]=0;
-
-        n2=0;
-        for (n=0;n<12;n++,n2+=2) {
-          corr_re[aa][l]+=(xr[aa][l][n2]*idft12_re[seq_index][n]+xr[aa][l][n2+1]*idft12_im[seq_index][n])>>15;
-          corr_im[aa][l]+=(xr[aa][l][n2]*idft12_im[seq_index][n]-xr[aa][l][n2+1]*idft12_re[seq_index][n])>>15;
+        corr[aa][l]=(c64_t){0};
+        for (n = 0; n < 12; n++) {
+          corr[aa][l].r += xr[aa][l][n].r * idft12_re[seq_index][n] + xr[aa][l][n].i * idft12_im[seq_index][n];
+          corr[aa][l].i += xr[aa][l][n].r * idft12_im[seq_index][n] - xr[aa][l][n].i * idft12_re[seq_index][n];
         }
+	corr[aa][l].r >>= 31;
+	corr[aa][l].i >>= 31;
       }
     }
-    LOG_D(PHY,"PUCCH IDFT[%d/%d] = (%d,%d)=>%f\n",
-          mcs[i],seq_index,corr_re[0][0],corr_im[0][0],
-          10*log10((double)corr_re[0][0]*corr_re[0][0] + (double)corr_im[0][0]*corr_im[0][0]));
+    LOG_D(PHY,"PUCCH IDFT[%d/%d] = (%ld,%ld)=>%f\n",
+          mcs[i],seq_index,corr[0][0].r,corr[0][0].i,
+          10*log10((double)squaredMod(corr[0][0])));
     if (pucch_pdu->nr_of_symbols==2)
-       LOG_D(PHY,"PUCCH 2nd symbol IDFT[%d/%d] = (%d,%d)=>%f\n",
-             mcs[i],seq_index,corr_re[0][1],corr_im[0][1],
-             10*log10((double)corr_re[0][1]*corr_re[0][1] + (double)corr_im[0][1]*corr_im[0][1]));
+       LOG_D(PHY,"PUCCH 2nd symbol IDFT[%d/%d] = (%ld,%ld)=>%f\n",
+             mcs[i],seq_index,corr[0][1].r,corr[0][1].i,
+             10*log10((double)squaredMod(corr[0][1])));
     if (pucch_pdu->freq_hop_flag == 0) {
        if (pucch_pdu->nr_of_symbols==1) {// non-coherent correlation
           temp=0;
           for (int aa=0;aa<frame_parms->nb_antennas_rx;aa++)
-             temp+=(int64_t)corr_re[aa][0]*corr_re[aa][0] + (int64_t)corr_im[aa][0]*corr_im[aa][0];
+            temp+=squaredMod(corr[aa][0]);
         } else {
-          int64_t corr_re2=0;
-          int64_t corr_im2=0;
           temp=0;
           for (int aa=0;aa<frame_parms->nb_antennas_rx;aa++) {
-             corr_re2 = (int64_t)corr_re[aa][0]+corr_re[aa][1];
-             corr_im2 = (int64_t)corr_im[aa][0]+corr_im[aa][1];
-             // coherent combining of 2 symbols and then complex modulus for single-frequency case
-             temp+=corr_re2*corr_re2 + corr_im2*corr_im2;
+            c64_t corr2;
+            csum(corr2, corr[aa][0], corr[aa][1]);
+            // coherent combining of 2 symbols and then complex modulus for single-frequency case
+            temp+=corr2.r*corr2.r + corr2.i*corr2.i;
           }
         }
     } else if (pucch_pdu->freq_hop_flag == 1) {
       // full non-coherent combining of 2 symbols for frequency-hopping case
       temp=0;
       for (int aa=0;aa<frame_parms->nb_antennas_rx;aa++)
-        temp += (int64_t)corr_re[aa][0]*corr_re[aa][0] + (int64_t)corr_im[aa][0]*corr_im[aa][0] + (int64_t)corr_re[aa][1]*corr_re[aa][1] + (int64_t)corr_im[aa][1]*corr_im[aa][1];
+        temp += squaredMod(corr[aa][0]) + squaredMod(corr[aa][1]);
     }
     else AssertFatal(1==0,"shouldn't happen\n");
 
@@ -369,9 +356,9 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB,
       uci_stats->current_pucch0_stat0 = 0;
       int64_t temp2=0,temp3=0;;
       for (int aa=0;aa<frame_parms->nb_antennas_rx;aa++) {
-        temp2 += ((int64_t)corr_re[aa][0]*corr_re[aa][0] + (int64_t)corr_im[aa][0]*corr_im[aa][0]);
+        temp2 += squaredMod(corr[aa][0]);
         if (pucch_pdu->nr_of_symbols==2)
-	  temp3 += ((int64_t)corr_re[aa][1]*corr_re[aa][1] + (int64_t)corr_im[aa][1]*corr_im[aa][1]);
+	  temp3 += squaredMod(corr[aa][1]);
       }
       uci_stats->current_pucch0_stat0= dB_fixed64(temp2);
       if ( pucch_pdu->nr_of_symbols==2)
@@ -392,7 +379,8 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB,
   uci_stats->pucch0_n01 = gNB->measurements.n0_subband_power_tot_dB[prb_offset[1]];
   LOG_D(PHY,"n00[%d] = %d, n01[%d] = %d\n",prb_offset[0],uci_stats->pucch0_n00,prb_offset[1],uci_stats->pucch0_n01);
   // estimate CQI for MAC (from antenna port 0 only)
-  int max_n0 = uci_stats->pucch0_n00>uci_stats->pucch0_n01 ? uci_stats->pucch0_n00:uci_stats->pucch0_n01;
+  int max_n0 = max(gNB->measurements.n0_subband_power_tot_dB[prb_offset[0]],
+		   gNB->measurements.n0_subband_power_tot_dB[prb_offset[1]]);
   int SNRtimes10,sigenergy=0;
   for (int aa=0;aa<frame_parms->nb_antennas_rx;aa++)
     sigenergy += signal_energy_nodc(&rxdataF[aa][soffset+
@@ -407,8 +395,15 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB,
   uci_stats->pucch0_thres = gNB->pucch0_thres; /* + (10*max_n0);*/
   bool no_conf=false;
   if (nr_sequences>1) {
-    if (xrtmag_dBtimes10 < (50+xrtmag_next_dBtimes10) || SNRtimes10 < uci_stats->pucch0_thres)
+    if (xrtmag_dBtimes10 < (50+xrtmag_next_dBtimes10) || SNRtimes10 < gNB->pucch0_thres) {
       no_conf=true;
+      LOG_D(PHY,"%d.%d PUCCH bad confidence: %d threshold, %d, %d, %d\n",
+	  frame, slot,
+	  uci_stats->pucch0_thres,
+	  SNRtimes10,
+	  xrtmag_dBtimes10,
+	  xrtmag_next_dBtimes10);
+    }
   }
   gNB->bad_pucch += no_conf;
   // first bit of bitmap for sr presence and second bit for acknack presence
@@ -422,11 +417,12 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB,
   if (pucch_pdu->bit_len_harq==0) {
     uci_pdu->harq = NULL;
     uci_pdu->sr = calloc(1,sizeof(*uci_pdu->sr));
-    uci_pdu->sr->sr_confidence_level = no_conf ? 1 : 0;
+    uci_pdu->sr->sr_confidence_level = SNRtimes10 < uci_stats->pucch0_thres;
     uci_stats->pucch0_sr_trials++;
-    if (xrtmag_dBtimes10>(10*gNB->measurements.n0_power_tot_dB)) {
+    if (xrtmag_dBtimes10>(10*max_n0+100)) {
       uci_pdu->sr->sr_indication = 1;
       uci_stats->pucch0_positive_SR++;
+      LOG_D(PHY,"PUCCH0 got positive SR. Cumulative number of positive SR %d\n", uci_stats->pucch0_positive_SR);
     } else {
       uci_pdu->sr->sr_indication = 0;
     }
@@ -434,35 +430,50 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB,
   else if (pucch_pdu->bit_len_harq==1) {
     uci_pdu->harq = calloc(1,sizeof(*uci_pdu->harq));
     uci_pdu->harq->num_harq = 1;
-    uci_pdu->harq->harq_confidence_level = no_conf ? 1 : 0;
-    uci_pdu->harq->harq_list = (nfapi_nr_harq_t*)malloc(1);
+    uci_pdu->harq->harq_confidence_level = no_conf;
+    uci_pdu->harq->harq_list = (nfapi_nr_harq_t*)malloc(sizeof *uci_pdu->harq->harq_list);
 
     uci_pdu->harq->harq_list[0].harq_value = !(index&0x01);
-    LOG_D(PHY, "[DLSCH/PDSCH/PUCCH] %d.%d HARQ value %d (0 pass, 1 fail) with confidence level %d (0 is good, 1 is bad) xrt_mag %d xrt_mag_next %d n0 %d (%d,%d) pucch0_thres %d, cqi %d, SNRtimes10 %d, energy %f, sync_pos %d\n",
-          frame,slot,uci_pdu->harq->harq_list[0].harq_value,uci_pdu->harq->harq_confidence_level,xrtmag_dBtimes10,xrtmag_next_dBtimes10,max_n0,uci_stats->pucch0_n00,uci_stats->pucch0_n01,uci_stats->pucch0_thres,cqi,SNRtimes10,10*log10((double)sigenergy),gNB->ulsch_stats[0].sync_pos);
+    LOG_D(PHY, "[DLSCH/PDSCH/PUCCH] %d.%d HARQ %s with confidence level %s xrt_mag %d xrt_mag_next %d n0 %d (%d,%d) pucch0_thres %d, cqi %d, SNRtimes10 %d, energy %f, sync_pos %d\n",
+          frame,slot,uci_pdu->harq->harq_list[0].harq_value==0?"ACK":"NACK",
+	  uci_pdu->harq->harq_confidence_level==0?"good":"bad",
+	  xrtmag_dBtimes10,xrtmag_next_dBtimes10,max_n0,uci_stats->pucch0_n00,uci_stats->pucch0_n01,uci_stats->pucch0_thres,cqi,SNRtimes10,10*log10((double)sigenergy),gNB->ulsch_stats[0].sync_pos);
 
     if (pucch_pdu->sr_flag == 1) {
       uci_pdu->sr = calloc(1,sizeof(*uci_pdu->sr));
-      uci_pdu->sr->sr_indication = (index>1) ? 1 : 0;
-      uci_pdu->sr->sr_confidence_level = no_conf ? 1 : 0;
-      uci_stats->pucch0_positive_SR++;
+      uci_pdu->sr->sr_indication = (index>1);
+      uci_pdu->sr->sr_confidence_level = no_conf;
+      if(uci_pdu->sr->sr_indication == 1 && uci_pdu->sr->sr_confidence_level == 0) {
+        uci_stats->pucch0_positive_SR++;
+        LOG_D(PHY,"PUCCH0 got positive SR. Cumulative number of positive SR %d\n", uci_stats->pucch0_positive_SR);
+      }
     }
     uci_stats->pucch01_trials++;
   }
   else {
     uci_pdu->harq = calloc(1,sizeof(*uci_pdu->harq));
     uci_pdu->harq->num_harq = 2;
-    uci_pdu->harq->harq_confidence_level = (no_conf) ? 1 : 0;
-    uci_pdu->harq->harq_list = (nfapi_nr_harq_t*)malloc(2);
+    uci_pdu->harq->harq_confidence_level = no_conf;
+    uci_pdu->harq->harq_list = (nfapi_nr_harq_t*)malloc(2 * sizeof( *uci_pdu->harq->harq_list));
 
     uci_pdu->harq->harq_list[1].harq_value = !(index&0x01);
     uci_pdu->harq->harq_list[0].harq_value = !((index>>1)&0x01);
-    LOG_D(PHY, "[DLSCH/PDSCH/PUCCH] %d.%d HARQ values %d and %d (0 pass, 1 fail) with confidence level %d (0 is good, 1 is bad), xrt_mag %d xrt_mag_next %d n0 %d (%d,%d) pucch0_thres %d, cqi %d, SNRtimes10 %d,sync_pos %d\n",
-          frame,slot,uci_pdu->harq->harq_list[1].harq_value,uci_pdu->harq->harq_list[0].harq_value,uci_pdu->harq->harq_confidence_level,xrtmag_dBtimes10,xrtmag_next_dBtimes10,max_n0,uci_stats->pucch0_n00,uci_stats->pucch0_n01,uci_stats->pucch0_thres,cqi,SNRtimes10,gNB->ulsch_stats[0].sync_pos);
+    LOG_D(PHY, "[DLSCH/PDSCH/PUCCH] %d.%d HARQ values (%s, %s) with confidence level %s, xrt_mag %d xrt_mag_next %d n0 %d (%d,%d) pucch0_thres %d, cqi %d, SNRtimes10 %d,sync_pos %d\n",
+          frame,slot,
+          uci_pdu->harq->harq_list[1].harq_value == 0 ? "ACK" : "NACK",
+          uci_pdu->harq->harq_list[0].harq_value == 0 ? "ACK" : "NACK",
+          uci_pdu->harq->harq_confidence_level == 0 ? "good" : "bad",
+          xrtmag_dBtimes10,xrtmag_next_dBtimes10,max_n0,
+          uci_stats->pucch0_n00,uci_stats->pucch0_n01,uci_stats->pucch0_thres,cqi,
+          SNRtimes10,gNB->ulsch_stats[0].sync_pos);
     if (pucch_pdu->sr_flag == 1) {
       uci_pdu->sr = calloc(1,sizeof(*uci_pdu->sr));
       uci_pdu->sr->sr_indication = (index>3) ? 1 : 0;
-      uci_pdu->sr->sr_confidence_level = (no_conf) ? 1 : 0;
+      uci_pdu->sr->sr_confidence_level = no_conf;
+      if(uci_pdu->sr->sr_indication == 1 && uci_pdu->sr->sr_confidence_level == 0) {
+        uci_stats->pucch0_positive_SR++;
+        LOG_D(PHY,"PUCCH0 got positive SR. Cumulative number of positive SR %d\n", uci_stats->pucch0_positive_SR);
+      }
     }
   }
 }
@@ -1671,7 +1682,8 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB,
     LOG_D(PHY,"metric %d dB\n",corr_dB);
   }
 
-    // estimate CQI for MAC (from antenna port 0 only)
+  // estimate CQI for MAC (from antenna port 0 only)
+  // TODO this computation is wrong -> to be ignored at MAC for now
   int SNRtimes10 = dB_fixed_times10(signal_energy_nodc(&rxdataF[0][soffset+(l2*frame_parms->ofdm_symbol_size)+re_offset[0]],
                                                        12*pucch_pdu->prb_size)) -
                                                        (10*gNB->measurements.n0_power_tot_dB);
diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c
index 5c415e7d4054bbb8411c56993dc683abc2dcbfcd..3b4ce9a42354c76b127bc338bbc822c3974f95f3 100644
--- a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c
+++ b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c
@@ -468,7 +468,9 @@ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue,
                                 unsigned char symbol,
                                 unsigned short scrambling_id,
                                 unsigned short coreset_start_subcarrier,
-                                unsigned short nb_rb_coreset)
+                                unsigned short nb_rb_coreset,
+                                int32_t pdcch_est_size,
+                                int32_t pdcch_dl_ch_estimates[][pdcch_est_size])
 {
 
   unsigned char aarx;
@@ -477,7 +479,6 @@ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue,
   int16_t ch[2],*pil,*rxF,*dl_ch,*fl,*fm,*fr;
   int ch_offset,symbol_offset;
 
-  int **dl_ch_estimates  =ue->pdcch_vars[proc->thread_id][gNB_id]->dl_ch_estimates;
   int **rxdataF=ue->common_vars.common_vars_rx_data_per_thread[proc->thread_id].rxdataF;
 
   ch_offset     = ue->frame_parms.ofdm_symbol_size*symbol;
@@ -510,7 +511,7 @@ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue,
     k = coreset_start_subcarrier;
     pil   = (int16_t *)&pilot[0];
     rxF   = (int16_t *)&rxdataF[aarx][(symbol_offset+k+1)];
-    dl_ch = (int16_t *)&dl_ch_estimates[aarx][ch_offset];
+    dl_ch = (int16_t *)&pdcch_dl_ch_estimates[aarx][ch_offset];
 
     memset(dl_ch,0,4*(ue->frame_parms.ofdm_symbol_size));
 
diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h b/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h
index 963a845876d1211fc8c5515bc71df5f9f1c3e07a..ce99f0f9c96a770b4f9d1261475328b1879225bf 100644
--- a/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h
+++ b/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h
@@ -46,7 +46,9 @@ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue,
                                 unsigned char symbol,
                                 unsigned short scrambling_id,
                                 unsigned short coreset_start_subcarrier,
-                                unsigned short nb_rb_coreset);
+                                unsigned short nb_rb_coreset,
+                                int32_t pdcch_est_size,
+                                int32_t pdcch_dl_ch_estimates[][pdcch_est_size]);
 
 int nr_pbch_dmrs_correlation(PHY_VARS_NR_UE *ue,
                              UE_nr_rxtx_proc_t *proc,
diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c
index b5cc765be4443a8086bfbb58aa1016b8d7dfd786..336d388d40d794644f9774418bcbfe92399abd78 100644
--- a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c
+++ b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c
@@ -42,6 +42,7 @@
 #include "PHY/CODING/coding_extern.h"
 #include "PHY/sse_intrin.h"
 #include "common/utils/nr/nr_common.h"
+#include <openair1/PHY/TOOLS/phy_scope_interface.h>
 
 #include "assertions.h"
 #include "T.h"
@@ -79,8 +80,8 @@ char nr_dci_format_string[8][30] = {
 //static const int16_t conjugate[8]__attribute__((aligned(32))) = {-1,1,-1,1,-1,1,-1,1};
 
 
-void nr_pdcch_demapping_deinterleaving(uint32_t *llr,
-                                       uint32_t *z,
+static void nr_pdcch_demapping_deinterleaving(uint32_t *llr,
+                                       uint32_t *e_rx,
                                        uint8_t coreset_time_dur,
                                        uint8_t start_symbol,
                                        uint32_t coreset_nbr_rb,
@@ -186,10 +187,10 @@ void nr_pdcch_demapping_deinterleaving(uint32_t *llr,
             index_z = data_sc * rb_count;
             index_llr = (uint16_t) (f*B_rb + rb + symbol_idx * coreset_nbr_rb) * data_sc;
             for (int i = 0; i < data_sc; i++) {
-              z[index_z + i] = llr[index_llr + i];
+              e_rx[index_z + i] = llr[index_llr + i];
 #ifdef NR_PDCCH_DCI_DEBUG
               LOG_I(PHY,"[candidate=%d,symbol_idx=%d,cce=%d,REG bundle=%d,PRB=%d] z[%d]=(%d,%d) <-> \t llr[%d]=(%d,%d) \n",
-                    c_id,symbol_idx,cce_count,k,f*B_rb + rb,(index_z + i),*(int16_t *) &z[index_z + i],*(1 + (int16_t *) &z[index_z + i]),
+                    c_id,symbol_idx,cce_count,k,f*B_rb + rb,(index_z + i),*(int16_t *) &e_rx[index_z + i],*(1 + (int16_t *) &e_rx[index_z + i]),
                     (index_llr + i),*(int16_t *) &llr[index_llr + i], *(1 + (int16_t *) &llr[index_llr + i]));
 #endif
             }
@@ -201,7 +202,7 @@ void nr_pdcch_demapping_deinterleaving(uint32_t *llr,
   }
 }
 
-int32_t nr_pdcch_llr(NR_DL_FRAME_PARMS *frame_parms, int32_t **rxdataF_comp,
+int32_t nr_pdcch_llr(NR_DL_FRAME_PARMS *frame_parms, int32_t rx_size, int32_t rxdataF_comp[][rx_size],
                      int16_t *pdcch_llr, uint8_t symbol,uint32_t coreset_nbr_rb) {
   int16_t *rxF = (int16_t *) &rxdataF_comp[0][(symbol * coreset_nbr_rb * 12)];
   int32_t i;
@@ -270,7 +271,8 @@ int32_t pdcch_llr(NR_DL_FRAME_PARMS *frame_parms,
 //__m128i avg128P;
 
 //compute average channel_level on each (TX,RX) antenna pair
-void nr_pdcch_channel_level(int32_t **dl_ch_estimates_ext,
+void nr_pdcch_channel_level(int32_t rx_size,
+                            int32_t dl_ch_estimates_ext[][rx_size],
                             NR_DL_FRAME_PARMS *frame_parms,
                             int32_t *avg,
                             int symbol,
@@ -337,9 +339,11 @@ void nr_pdcch_channel_level(int32_t **dl_ch_estimates_ext,
 
 // This function will extract the mapped DM-RS PDCCH REs as per 38.211 Section 7.4.1.3.2 (Mapping to physical resources)
 void nr_pdcch_extract_rbs_single(int32_t **rxdataF,
-                                 int32_t **dl_ch_estimates,
-                                 int32_t **rxdataF_ext,
-                                 int32_t **dl_ch_estimates_ext,
+                                 int32_t est_size,
+                                 int32_t dl_ch_estimates[][est_size],
+                                 int32_t rx_size,
+                                 int32_t rxdataF_ext[][rx_size],
+                                 int32_t dl_ch_estimates_ext[][rx_size],
                                  uint8_t symbol,
                                  NR_DL_FRAME_PARMS *frame_parms,
                                  uint8_t *coreset_freq_dom,
@@ -515,9 +519,9 @@ void nr_pdcch_extract_rbs_single(int32_t **rxdataF,
 
 #define print_shorts(s,x) printf("%s %d,%d,%d,%d,%d,%d,%d,%d\n",s,(x)[0],(x)[1],(x)[2],(x)[3],(x)[4],(x)[5],(x)[6],(x)[7])
 
-void nr_pdcch_channel_compensation(int32_t **rxdataF_ext,
-                                   int32_t **dl_ch_estimates_ext,
-                                   int32_t **rxdataF_comp,
+void nr_pdcch_channel_compensation(int32_t rx_size, int32_t rxdataF_ext[][rx_size],
+                                   int32_t dl_ch_estimates_ext[][rx_size],
+                                   int32_t rxdataF_comp[][rx_size],
                                    int32_t **rho,
                                    NR_DL_FRAME_PARMS *frame_parms,
                                    uint8_t symbol,
@@ -628,7 +632,8 @@ void nr_pdcch_channel_compensation(int32_t **rxdataF_ext,
 
 
 void nr_pdcch_detection_mrc(NR_DL_FRAME_PARMS *frame_parms,
-                         int32_t **rxdataF_comp,
+                         int32_t rx_size,
+                         int32_t rxdataF_comp[][rx_size],
                          uint8_t symbol) {
 #if defined(__x86_64__) || defined(__i386__)
   __m128i *rxdataF_comp128_0,*rxdataF_comp128_1;
@@ -664,18 +669,31 @@ void nr_pdcch_detection_mrc(NR_DL_FRAME_PARMS *frame_parms,
 
 int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue,
                     UE_nr_rxtx_proc_t *proc,
+                    int32_t pdcch_est_size,
+                    int32_t pdcch_dl_ch_estimates[][pdcch_est_size],
+                    int16_t *pdcch_e_rx,
                     fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15) {
 
   uint32_t frame = proc->frame_rx;
   uint32_t slot  = proc->nr_slot_rx;
   NR_UE_COMMON *common_vars      = &ue->common_vars;
   NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms;
-  NR_UE_PDCCH *pdcch_vars        = ue->pdcch_vars[proc->thread_id][0];
 
   uint8_t log2_maxh, aarx;
   int32_t avgs;
   int32_t avgP[4];
   int n_rb,rb_offset;
+
+  // Pointers to extracted PDCCH symbols in frequency-domain.
+  int32_t rx_size = 4*273*12;
+  int32_t rxdataF_ext[4*frame_parms->nb_antennas_rx][rx_size];
+  int32_t rxdataF_comp[4*frame_parms->nb_antennas_rx][rx_size];
+  int32_t pdcch_dl_ch_estimates_ext[4*frame_parms->nb_antennas_rx][rx_size];
+
+  // Pointer to llrs, 4-bit resolution.
+  int32_t llr_size = 2*4*100*12;
+  int16_t llr[llr_size];
+
   get_coreset_rballoc(rel15->coreset.frequency_domain_resource,&n_rb,&rb_offset);
   LOG_D(PHY,"pdcch coreset: freq %x, n_rb %d, rb_offset %d\n",
         rel15->coreset.frequency_domain_resource[0],n_rb,rb_offset);
@@ -683,9 +701,11 @@ int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue,
     LOG_D(PHY,"in nr_pdcch_extract_rbs_single(rxdataF -> rxdataF_ext || dl_ch_estimates -> dl_ch_estimates_ext)\n");
 
     nr_pdcch_extract_rbs_single(common_vars->common_vars_rx_data_per_thread[proc->thread_id].rxdataF,
-                                pdcch_vars->dl_ch_estimates,
-                                pdcch_vars->rxdataF_ext,
-                                pdcch_vars->dl_ch_estimates_ext,
+                                pdcch_est_size,
+                                pdcch_dl_ch_estimates,
+                                rx_size,
+                                rxdataF_ext,
+                                pdcch_dl_ch_estimates_ext,
                                 s,
                                 frame_parms,
                                 rel15->coreset.frequency_domain_resource,
@@ -695,7 +715,8 @@ int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue,
     LOG_D(PHY,"we enter nr_pdcch_channel_level(avgP=%d) => compute channel level based on ofdm symbol 0, pdcch_vars[eNB_id]->dl_ch_estimates_ext\n",*avgP);
     LOG_D(PHY,"in nr_pdcch_channel_level(dl_ch_estimates_ext -> dl_ch_estimates_ext)\n");
     // compute channel level based on ofdm symbol 0
-    nr_pdcch_channel_level(pdcch_vars->dl_ch_estimates_ext,
+    nr_pdcch_channel_level(rx_size,
+                           pdcch_dl_ch_estimates_ext,
                            frame_parms,
                            avgP,
                            s,
@@ -717,26 +738,33 @@ int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue,
     LOG_D(PHY,"we enter nr_pdcch_channel_compensation(log2_maxh=%d)\n",log2_maxh);
     LOG_D(PHY,"in nr_pdcch_channel_compensation(rxdataF_ext x dl_ch_estimates_ext -> rxdataF_comp)\n");
     // compute LLRs for ofdm symbol 0 only
-    nr_pdcch_channel_compensation(pdcch_vars->rxdataF_ext,
-                                  pdcch_vars->dl_ch_estimates_ext,
-                                  pdcch_vars->rxdataF_comp,
+    nr_pdcch_channel_compensation(rx_size, rxdataF_ext,
+                                  pdcch_dl_ch_estimates_ext,
+                                  rxdataF_comp,
                                   NULL,
                                   frame_parms,
                                   s,
                                   log2_maxh,
                                   n_rb); // log2_maxh+I0_shift
+
+    UEscopeCopy(ue, pdcchRxdataF_comp, rxdataF_comp, sizeof(struct complex16), frame_parms->nb_antennas_rx, rx_size);
+
     if (frame_parms->nb_antennas_rx > 1) {
       LOG_D(PHY,"we enter nr_pdcch_detection_mrc(frame_parms->nb_antennas_rx=%d)\n", frame_parms->nb_antennas_rx);
-      nr_pdcch_detection_mrc(frame_parms, pdcch_vars->rxdataF_comp,s);
+      nr_pdcch_detection_mrc(frame_parms, rx_size, rxdataF_comp,s);
     }
 
     LOG_D(PHY,"we enter nr_pdcch_llr(for symbol %d), pdcch_vars[eNB_id]->rxdataF_comp ---> pdcch_vars[eNB_id]->llr \n",s);
     LOG_D(PHY,"in nr_pdcch_llr(rxdataF_comp -> llr)\n");
     nr_pdcch_llr(frame_parms,
-                 pdcch_vars->rxdataF_comp,
-                 pdcch_vars->llr,
+                 rx_size,
+                 rxdataF_comp,
+                 llr,
                  s,
                  n_rb);
+
+    UEscopeCopy(ue, pdcchLlr, llr, sizeof(int16_t), 1, llr_size);
+
 #if T_TRACER
     
     //  T(T_UE_PHY_PDCCH_IQ, T_INT(frame_parms->N_RB_DL), T_INT(frame_parms->N_RB_DL),
@@ -750,8 +778,8 @@ int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue,
   }
 
   LOG_D(PHY,"we enter nr_pdcch_demapping_deinterleaving(), number of candidates %d\n",rel15->number_of_candidates);
-  nr_pdcch_demapping_deinterleaving((uint32_t *) pdcch_vars->llr,
-                                    (uint32_t *) pdcch_vars->e_rx,
+  nr_pdcch_demapping_deinterleaving((uint32_t *) llr,
+                                    (uint32_t *) pdcch_e_rx,
                                     rel15->coreset.duration,
                                     rel15->coreset.StartSymbolIndex,
                                     n_rb,
@@ -770,7 +798,7 @@ int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue,
 
 
 
-void nr_pdcch_unscrambling(int16_t *z,
+void nr_pdcch_unscrambling(int16_t *e_rx,
                            uint16_t scrambling_RNTI,
                            uint32_t length,
                            uint16_t pdcch_DMRS_scrambling_id,
@@ -793,8 +821,10 @@ void nr_pdcch_unscrambling(int16_t *z,
       reset = 0;
     }
 
-    if (((s >> (i % 32)) & 1) == 1) z2[i] = -z[i];
-    else z2[i]=z[i];
+    if (((s >> (i % 32)) & 1) == 1)
+      z2[i] = -e_rx[i];
+    else
+      z2[i]=e_rx[i];
   }
 }
 
@@ -832,10 +862,10 @@ static uint16_t nr_dci_false_detection(uint64_t *dci,
 
 uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue,
                                   UE_nr_rxtx_proc_t *proc,
+                                  int16_t *pdcch_e_rx,
                                   fapi_nr_dci_indication_t *dci_ind,
-                                  fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15) {
-
-  NR_UE_PDCCH *pdcch_vars = ue->pdcch_vars[proc->thread_id][0];
+                                  fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15,
+                                  NR_UE_PDCCH_CONFIG *phy_pdcch_config) {
 
   //int gNB_id = 0;
   int16_t tmp_e[16*108];
@@ -847,6 +877,7 @@ uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue,
     int L = rel15->L[j];
 
     // Loop over possible DCI lengths
+    
     for (int k = 0; k < rel15->num_dci_options; k++) {
       // skip this candidate if we've already found one with the
       // same rnti and format at a different aggregation level
@@ -865,10 +896,11 @@ uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue,
       LOG_D(PHY, "(%i.%i) Trying DCI candidate %d of %d number of candidates, CCE %d (%d), L %d, length %d, format %s\n",
             proc->frame_rx, proc->nr_slot_rx, j, rel15->number_of_candidates, CCEind, e_rx_cand_idx, L, dci_length, nr_dci_format_string[rel15->dci_format_options[k]]);
 
-      nr_pdcch_unscrambling(&pdcch_vars->e_rx[e_rx_cand_idx], rel15->coreset.scrambling_rnti, L*108, rel15->coreset.pdcch_dmrs_scrambling_id, tmp_e);
+
+      nr_pdcch_unscrambling(&pdcch_e_rx[e_rx_cand_idx], rel15->coreset.scrambling_rnti, L*108, rel15->coreset.pdcch_dmrs_scrambling_id, tmp_e);
 
 #ifdef DEBUG_DCI_DECODING
-      uint32_t *z = (uint32_t *) &pdcch_vars->e_rx[e_rx_cand_idx];
+      uint32_t *z = (uint32_t *) &e_rx[e_rx_cand_idx];
       for (int index_z = 0; index_z < L*6; index_z++){
         for (int i=0; i<9; i++) {
           LOG_I(PHY,"z[%d]=(%d,%d) \n", (9*index_z + i), *(int16_t *) &z[9*index_z + i],*(1 + (int16_t *) &z[9*index_z + i]));
@@ -881,8 +913,8 @@ uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue,
                                          NR_POLAR_DCI_MESSAGE_TYPE, dci_length, L);
 
       n_rnti = rel15->rnti;
-      LOG_D(PHY, "(%i.%i) dci indication (rnti %x,dci format %s,n_CCE %d,payloadSize %d)\n",
-            proc->frame_rx, proc->nr_slot_rx,n_rnti,nr_dci_format_string[rel15->dci_format_options[k]],CCEind,dci_length);
+      LOG_D(PHY, "(%i.%i) dci indication (rnti %x,dci format %s,n_CCE %d,payloadSize %d,payload %llx )\n",
+            proc->frame_rx, proc->nr_slot_rx,n_rnti,nr_dci_format_string[rel15->dci_format_options[k]],CCEind,dci_length, *(unsigned long long*)dci_estimation);
       if (crc == n_rnti) {
         LOG_D(PHY, "(%i.%i) Received dci indication (rnti %x,dci format %s,n_CCE %d,payloadSize %d,payload %llx)\n",
               proc->frame_rx, proc->nr_slot_rx,n_rnti,nr_dci_format_string[rel15->dci_format_options[k]],CCEind,dci_length,*(unsigned long long*)dci_estimation);
@@ -910,7 +942,7 @@ uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue,
     }
     e_rx_cand_idx += 9*L*6*2; //e_rx index for next candidate (L CCEs, 6 REGs per CCE and 9 REs per REG and 2 uint16_t per RE)
   }
-  pdcch_vars->nb_search_space = 0;
+  phy_pdcch_config->nb_search_space = 0;
   return(dci_ind->number_of_dcis);
 }
 
diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c
index 92a8d13c21374a76886f046ed0c9c8dd148b47ae..beacc0ce904c047be52e924ffbc319cd63210302 100644
--- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c
+++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c
@@ -168,6 +168,7 @@ NR_UE_DLSCH_t *new_nr_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint
             memset(dlsch->harq_processes[i]->d[r],0,5*8448);
           else
             exit_flag=2;
+
         }
       } else {
         exit_flag=1;
@@ -221,7 +222,7 @@ bool nr_ue_postDecode(PHY_VARS_NR_UE *phy_vars_ue, notifiedFIFO_elt_t *req, bool
       //LOG_D(PHY,"[UE %d] DLSCH: Setting ACK for nr_slot_rx %d TBS %d mcs %d nb_rb %d harq_process->round %d\n",
       //      phy_vars_ue->Mod_id,nr_slot_rx,harq_process->TBS,harq_process->mcs,harq_process->nb_rb, harq_process->round);
       harq_process->status = SCH_IDLE;
-      harq_process->round  = 0;
+      harq_process->DLround  = 0;
       harq_process->ack = 1;
 
       //LOG_D(PHY,"[UE %d] DLSCH: Setting ACK for SFN/SF %d/%d (pid %d, status %d, round %d, TBS %d, mcs %d)\n",
@@ -236,9 +237,9 @@ bool nr_ue_postDecode(PHY_VARS_NR_UE *phy_vars_ue, notifiedFIFO_elt_t *req, bool
       //LOG_D(PHY,"[UE %d] DLSCH: Setting NAK for SFN/SF %d/%d (pid %d, status %d, round %d, TBS %d, mcs %d) Kr %d r %d harq_process->round %d\n",
       //      phy_vars_ue->Mod_id, frame, nr_slot_rx, harq_pid,harq_process->status, harq_process->round,harq_process->TBS,harq_process->mcs,Kr,r,harq_process->round);
       harq_process->ack = 0;
-      if (harq_process->round >= dlsch->Mlimit) {
+      if (harq_process->DLround >= dlsch->Mlimit) {
         harq_process->status = SCH_IDLE;
-        harq_process->round  = 0;
+        harq_process->DLround  = 0;
         phy_vars_ue->dl_stats[4]++;
       }
 
@@ -295,14 +296,14 @@ void nr_processDLSegment(void* arg) {
   K_bits_F = Kr-harq_process->F;
 
   t_nrLDPC_time_stats procTime = {0};
-  t_nrLDPC_time_stats* p_procTime     = &procTime ;
 
-  int16_t w[5*8448];
-  memset(w,0,(5*8448)*sizeof(short));
+
 
   start_meas(&rdata->ts_deinterleave);
 
   //VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_DEINTERLEAVING, VCD_FUNCTION_IN);
+    int16_t w[E];
+    memset(w, 0, sizeof(w));
   nr_deinterleaving_ldpc(E,
                          Qm,
                          w, // [hna] w is e
@@ -389,12 +390,12 @@ void nr_processDLSegment(void* arg) {
     no_iteration_ldpc = nrLDPC_decoder(p_decoderParms,
                                        (int8_t *)&pl[0],
                                        llrProcBuf,
-                                       p_procTime);
+                                       &procTime);
     //VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_LDPC, VCD_FUNCTION_OUT);
 
     // Fixme: correct type is unsigned, but nrLDPC_decoder and all called behind use signed int
     if (check_crc((uint8_t *)llrProcBuf,length_dec,harq_process->F,crc_type)) {
-      LOG_D(PHY,"Segment %u CRC OK\n\033[0m",r);
+      LOG_D(PHY,"Segment %u CRC OK\n",r);
 
       if (r==0) {
         for (int i=0; i<10; i++) LOG_D(PHY,"byte %d : %x\n",i,((uint8_t *)llrProcBuf)[i]);
@@ -404,7 +405,7 @@ void nr_processDLSegment(void* arg) {
       no_iteration_ldpc = dlsch->max_ldpc_iterations;
       rdata->decodeIterations = no_iteration_ldpc;
     } else {
-      LOG_D(PHY,"CRC NOT OK\n\033[0m");
+      LOG_D(PHY,"CRC NOT OK\n");
     }
 
     nb_total_decod++;
@@ -446,8 +447,8 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue,
   }
 
   // HARQ stats
-  phy_vars_ue->dl_stats[harq_process->round]++;
-  LOG_D(PHY,"Round %d RV idx %d\n",harq_process->round,harq_process->rvidx);
+  phy_vars_ue->dl_stats[harq_process->DLround]++;
+  LOG_D(PHY,"Round %d RV idx %d\n",harq_process->DLround,harq_process->rvidx);
   uint8_t kc;
   uint32_t Tbslbrm;// = 950984;
   uint16_t nb_rb;// = 30;
@@ -499,7 +500,8 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue,
   }
   */
   nb_rb = harq_process->nb_rb;
-  harq_process->trials[harq_process->round]++;
+  harq_process->trials[harq_process->DLround]++;
+
   A = harq_process->TBS;
   ret = dlsch->max_ldpc_iterations + 1;
   dlsch->last_iteration_cnt = ret;
diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c
index db39bfddc9e5a27ca221c0b73fe0c175e8c8a147..cd1bc9d3b2eea6ee05fb8221fa0f2f43cf78abfd 100644
--- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c
+++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c
@@ -117,7 +117,6 @@ static int nr_dlsch_llr(NR_UE_PDSCH **pdsch_vars,
                         unsigned char first_symbol_flag,
                         unsigned char symbol,
                         unsigned short nb_rb,
-                        unsigned short round,
                         int32_t codeword_TB0,
                         int32_t codeword_TB1,
                         uint32_t len,
@@ -154,7 +153,6 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue,
 
   unsigned char aatx=0,aarx=0;
 
-  unsigned short round;
   int avgs = 0;// rb;
   NR_DL_UE_HARQ_t *dlsch0_harq, *dlsch1_harq = NULL;
 
@@ -271,8 +269,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue,
   nb_rb_pdsch =  dlsch0_harq->nb_rb;
 
   DevAssert(dlsch0_harq);
-  round = dlsch0_harq->round;
-  //printf("round = %d\n", round);
+
 
   if (gNB_id > 2) {
     LOG_W(PHY, "In %s: Illegal gNB_id %d\n", __FUNCTION__, gNB_id);
@@ -515,7 +512,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue,
                      rx_type, harq_pid,
                      gNB_id, gNB_id_i,
                      first_symbol_flag,
-                     i, nb_rb_pdsch, round,
+                     i, nb_rb_pdsch,
                      codeword_TB0, codeword_TB1,
                      pdsch_vars[gNB_id]->dl_valid_re[i-1],
                      nr_slot_rx, beamforming_mode);
@@ -2472,7 +2469,6 @@ static int nr_dlsch_llr(NR_UE_PDSCH **pdsch_vars,
                         unsigned char first_symbol_flag,
                         unsigned char symbol,
                         unsigned short nb_rb,
-                        unsigned short round,
                         int32_t codeword_TB0,
                         int32_t codeword_TB1,
                         uint32_t len,
diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c
index b806e4c381cba26624b278a3d1b45fefabae7dba..e248ce87cb23ca88ddcf34a506be282e61d46b32 100644
--- a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c
+++ b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c
@@ -101,7 +101,7 @@ void free_list(NR_UE_SSB *node) {
 }
 
 
-int nr_pbch_detection(UE_nr_rxtx_proc_t * proc, PHY_VARS_NR_UE *ue, int pbch_initial_symbol)
+int nr_pbch_detection(UE_nr_rxtx_proc_t * proc, PHY_VARS_NR_UE *ue, int pbch_initial_symbol, NR_UE_PDCCH_CONFIG *phy_pdcch_config)
 {
   NR_DL_FRAME_PARMS *frame_parms=&ue->frame_parms;
   int ret =-1;
@@ -165,6 +165,7 @@ int nr_pbch_detection(UE_nr_rxtx_proc_t * proc, PHY_VARS_NR_UE *ue, int pbch_ini
                      0,
                      temp_ptr->i_ssb,
                      SISO,
+                     phy_pdcch_config,
                      &result);
 
     temp_ptr=temp_ptr->next_ssb;
@@ -215,6 +216,8 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc,
   NR_DL_FRAME_PARMS *fp = &ue->frame_parms;
   int ret=-1;
   int rx_power=0; //aarx,
+
+  NR_UE_PDCCH_CONFIG phy_pdcch_config={0};
   
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_NR_INITIAL_UE_SYNC, VCD_FUNCTION_IN);
 
@@ -305,7 +308,7 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc,
 #endif
 
       int freq_offset_sss = 0;
-      rx_sss_nr(ue, proc, &metric_tdd_ncp, &phase_tdd_ncp, &freq_offset_sss);
+      ret = rx_sss_nr(ue, proc, &metric_tdd_ncp, &phase_tdd_ncp, &freq_offset_sss);
 
       accumulated_freq_offset += freq_offset_sss;
 
@@ -333,8 +336,10 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc,
         }
       }
 
-      nr_gold_pbch(ue);
-      ret = nr_pbch_detection(proc, ue, 1);  // start pbch detection at first symbol after pss
+      if (ret==0) { //we got sss channel
+        nr_gold_pbch(ue);
+        ret = nr_pbch_detection(proc, ue, 1, &phy_pdcch_config);  // start pbch detection at first symbol after pss
+      }
 
       if (ret == 0) {
         // sync at symbol ue->symbol_offset
@@ -531,34 +536,40 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc,
   // if stand alone and sync on ssb do sib1 detection as part of initial sync
   if (sa==1 && ret==0) {
     bool dec = false;
-    NR_UE_PDCCH *pdcch_vars  = ue->pdcch_vars[proc->thread_id][0];
     int gnb_id = 0; //FIXME
     int coreset_nb_rb=0;
     int coreset_start_rb=0;
 
-    for(int n_ss = 0; n_ss<pdcch_vars->nb_search_space; n_ss++) {
-      uint8_t nb_symb_pdcch = pdcch_vars->pdcch_config[n_ss].coreset.duration;
-      int start_symb = pdcch_vars->pdcch_config[n_ss].coreset.StartSymbolIndex;
-      get_coreset_rballoc(pdcch_vars->pdcch_config[n_ss].coreset.frequency_domain_resource,&coreset_nb_rb,&coreset_start_rb);
+    // Hold the channel estimates in frequency domain.
+    int32_t pdcch_est_size = ((((fp->symbols_per_slot*(fp->ofdm_symbol_size+LTE_CE_FILTER_LENGTH))+15)/16)*16);
+    __attribute__ ((aligned(16))) int32_t pdcch_dl_ch_estimates[4*fp->nb_antennas_rx][pdcch_est_size];
+
+
+    for(int n_ss = 0; n_ss<phy_pdcch_config.nb_search_space; n_ss++) {
+      uint8_t nb_symb_pdcch = phy_pdcch_config.pdcch_config[n_ss].coreset.duration;
+      int start_symb = phy_pdcch_config.pdcch_config[n_ss].coreset.StartSymbolIndex;
+      get_coreset_rballoc(phy_pdcch_config.pdcch_config[n_ss].coreset.frequency_domain_resource,&coreset_nb_rb,&coreset_start_rb);
       for (uint16_t l=start_symb; l<start_symb+nb_symb_pdcch; l++) {
         nr_slot_fep_init_sync(ue,
                               proc,
                               l, // the UE PHY has no notion of the symbols to be monitored in the search space
-                              pdcch_vars->slot,
-                              is*fp->samples_per_frame+pdcch_vars->sfn*fp->samples_per_frame+ue->rx_offset);
+                              phy_pdcch_config.slot,
+                              is*fp->samples_per_frame+phy_pdcch_config.sfn*fp->samples_per_frame+ue->rx_offset);
 
         if (coreset_nb_rb > 0)
           nr_pdcch_channel_estimation(ue,
                                       proc,
                                       0,
-                                      pdcch_vars->slot,
+                                      phy_pdcch_config.slot,
                                       l,
                                       fp->Nid_cell,
-                                      fp->first_carrier_offset+(pdcch_vars->pdcch_config[n_ss].BWPStart + coreset_start_rb)*12,
-                                      coreset_nb_rb);
+                                      fp->first_carrier_offset+(phy_pdcch_config.pdcch_config[n_ss].BWPStart + coreset_start_rb)*12,
+                                      coreset_nb_rb,
+                                      pdcch_est_size,
+                                      pdcch_dl_ch_estimates);
 
       }
-      int  dci_cnt = nr_ue_pdcch_procedures(gnb_id, ue, proc, n_ss);
+      int  dci_cnt = nr_ue_pdcch_procedures(gnb_id, ue, proc, pdcch_est_size, pdcch_dl_ch_estimates, &phy_pdcch_config, n_ss);
       if (dci_cnt>0){
         NR_UE_DLSCH_t *dlsch = ue->dlsch_SI[gnb_id];
         if (dlsch && (dlsch->active == 1)) {
@@ -571,8 +582,8 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc,
             nr_slot_fep_init_sync(ue,
                                   proc,
                                   m,
-                                  pdcch_vars->slot,  // same slot and offset as pdcch
-                                  is*fp->samples_per_frame+pdcch_vars->sfn*fp->samples_per_frame+ue->rx_offset);
+                                  phy_pdcch_config.slot,  // same slot and offset as pdcch
+                                  is*fp->samples_per_frame+phy_pdcch_config.sfn*fp->samples_per_frame+ue->rx_offset);
           }
 
           int ret = nr_ue_pdsch_procedures(ue,
diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c
index 2705132bc6adccc1aa917766c1ef5c9232d429e0..48b08d761ece8f76e29eb3f1e737f8a686ac4393 100644
--- a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c
+++ b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c
@@ -391,6 +391,7 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue,
                 uint8_t gNB_id,
                 uint8_t i_ssb,
                 MIMO_mode_t mimo_mode,
+                NR_UE_PDCCH_CONFIG *phy_pdcch_config,
                 fapiPbch_t *result) {
   NR_UE_COMMON *nr_ue_common_vars = &ue->common_vars;
   int max_h=0;
@@ -577,7 +578,8 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue,
   nr_downlink_indication_t dl_indication;
   fapi_nr_rx_indication_t *rx_ind=calloc(sizeof(*rx_ind),1);
   uint16_t number_pdus = 1;
-  nr_fill_dl_indication(&dl_indication, NULL, rx_ind, proc, ue, gNB_id);
+
+  nr_fill_dl_indication(&dl_indication, NULL, rx_ind, proc, ue, gNB_id, phy_pdcch_config);
   nr_fill_rx_indication(rx_ind, FAPI_NR_RX_PDU_TYPE_SSB, gNB_id, ue, NULL, NULL, number_pdus, proc,(void *)result);
 
   if (ue->if_inst && ue->if_inst->dl_indication)
diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h
index 6897cbd69c03ab087dfd6c2d0c57ccefe944b6a1..c9d1b091be8994dd98fb466d706c77dc67dec1fc 100644
--- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h
+++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h
@@ -1075,6 +1075,9 @@ uint32_t dlsch_decoding_emul(PHY_VARS_NR_UE *phy_vars_ue,
 
 int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue,
                     UE_nr_rxtx_proc_t *proc,
+                    int32_t pdcch_est_size,
+                    int32_t pdcch_dl_ch_estimates[][pdcch_est_size],
+                    int16_t *pdcch_e_rx,
                     fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15);
 
 
@@ -1129,11 +1132,13 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue,
                 uint8_t eNB_id,
                 uint8_t i_ssb,
                 MIMO_mode_t mimo_mode,
-		fapiPbch_t* result);
+                NR_UE_PDCCH_CONFIG *phy_pdcch_config,
+                fapiPbch_t* result);
 
 int nr_pbch_detection(UE_nr_rxtx_proc_t *proc,
-		      PHY_VARS_NR_UE *ue,
-                      int pbch_initial_symbol);
+		              PHY_VARS_NR_UE *ue,
+                      int pbch_initial_symbol,
+                      NR_UE_PDCCH_CONFIG *phy_pdcch_config);
 
 uint16_t rx_pbch_emul(PHY_VARS_NR_UE *phy_vars_ue,
                       uint8_t eNB_id,
@@ -1450,16 +1455,6 @@ uint64_t cqi2hex(uint32_t cqi);
 
 uint16_t computeRIV(uint16_t N_RB_DL,uint16_t RBstart,uint16_t Lcrbs);
 
-
-/** \brief  This routine extracts a single subband PMI from a bitmap coming from UCI or the pmi_extend function
-    @param N_RB_DL number of resource blocks
-    @param mimo_mode
-    @param pmi_alloc subband PMI bitmap
-    @param rb resource block for which to extract PMI
-    @returns subband PMI
-*/
-uint8_t get_pmi(uint8_t N_RB_DL,MIMO_mode_t mode, uint32_t pmi_alloc,uint16_t rb);
-
 int get_nCCE_offset_l1(int *CCE_table,
                        const unsigned char L,
                        const int nCCE,
@@ -1561,7 +1556,7 @@ uint8_t get_num_prach_tdd(module_id_t Mod_id);
   @param frame_type 0-FDD, 1-TDD
   @returns 0-1 accordingly
 */
-uint8_t get_prach_fmt(uint8_t prach_ConfigIndex,lte_frame_type_t frame_type);
+uint8_t get_prach_fmt(uint8_t prach_ConfigIndex,frame_type_t frame_type);
 
 /*!
   \brief Helper for MAC, returns frequency index of PRACH resource in TDD for a particular configuration index
@@ -1583,7 +1578,7 @@ void compute_prach_seq(uint16_t rootSequenceIndex,
 		       uint8_t prach_ConfigIndex,
 		       uint8_t zeroCorrelationZoneConfig,
 		       uint8_t highSpeedFlag,
-		       lte_frame_type_t frame_type,
+		       frame_type_t frame_type,
 		       uint32_t X_u[64][839]);
 
 
@@ -1639,8 +1634,10 @@ uint8_t get_prach_prb_offset(NR_DL_FRAME_PARMS *frame_parms,
 
 uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue,
                                   UE_nr_rxtx_proc_t *proc,
+                                  int16_t *pdcch_e_rx,
                                   fapi_nr_dci_indication_t *dci_ind,
-                                  fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15);
+                                  fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15,
+                                  NR_UE_PDCCH_CONFIG *phy_pdcch_config);
 
 
 /** \brief This function is the top-level entry point to PDSCH demodulation, after frequency-domain transformation and channel estimation.  It performs
diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h
index 7b5019edfe8518f64c26d18e5788dd88083726f0..4086f60f02e956f5f2fe4c10bea0f5f9a7cbbf8b 100644
--- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h
+++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h
@@ -181,9 +181,10 @@ typedef struct {
   /// Pointers to transport block segments
   uint8_t **c;
   /// soft bits for each received segment ("d"-sequence)(for definition see 36-212 V8.6 2009-03, p.15)
+  /// Accumulates the soft bits for each round to increase decoding success (HARQ)
   int16_t **d;
   /// Index of current HARQ round for this DLSCH
-  uint8_t round;
+  uint8_t DLround;
   /// MCS table for this DLSCH
   uint8_t mcs_table;
   /// MCS format for this DLSCH
diff --git a/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c b/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c
index 54712cb64e5b72cec804638c1592d6edfa4f6b99..13ed436273ee9d0f79ee8b308b6596873c559dd8 100644
--- a/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c
+++ b/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c
@@ -381,7 +381,6 @@ void init_context_pss_nr(NR_DL_FRAME_PARMS *frame_parms_ue)
   int sizePss = LENGTH_PSS_NR * IQ_SIZE;  /* complex value i & q signed 16 bits */
   int size = ofdm_symbol_size * IQ_SIZE; /* i and q samples signed 16 bits */
   int16_t *p = NULL;
-  int64_t *q = NULL;
 
   AssertFatal(ofdm_symbol_size > 127, "illegal ofdm_symbol_size %d\n",ofdm_symbol_size);
   for (int i = 0; i < NUMBER_PSS_SEQUENCE; i++) {
@@ -410,17 +409,6 @@ void init_context_pss_nr(NR_DL_FRAME_PARMS *frame_parms_ue)
      assert(0);
     }
 
-    size = sizeof(int64_t)*(frame_parms_ue->samples_per_frame + (2*ofdm_symbol_size));
-    q = (int64_t*)malloc16(size);
-    if (q != NULL) {
-      pss_corr_ue[i] = q;
-      bzero( pss_corr_ue[i], size);
-    }
-    else {
-      LOG_E(PHY,"Fatal memory allocation problem \n");
-      assert(0);
-    }
-
     generate_pss_nr(frame_parms_ue,i);
   }
 }
@@ -443,7 +431,6 @@ void free_context_pss_nr(void)
     free_and_zero(primary_synchro_nr[i]);
     free_and_zero(primary_synchro_nr2[i]);
     free_and_zero(primary_synchro_time_nr[i]);
-    free_and_zero(pss_corr_ue[i]);
   }
 }
 
@@ -801,7 +788,6 @@ static inline double angle64(int64_t x)
 *********************************************************************/
 
 #define DOT_PRODUCT_SCALING_SHIFT    (17)
-
 int pss_search_time_nr(int **rxdata, ///rx data in time domain
                        NR_DL_FRAME_PARMS *frame_parms,
 		       int fo_flag,
@@ -812,7 +798,7 @@ int pss_search_time_nr(int **rxdata, ///rx data in time domain
   unsigned int n, ar, peak_position, pss_source;
   int64_t peak_value;
   int64_t result;
-  int64_t avg[NUMBER_PSS_SEQUENCE];
+  int64_t avg[NUMBER_PSS_SEQUENCE]={0};
   double ffo_est=0;
 
   // performing the correlation on a frame length plus one symbol for the first of the two frame
@@ -823,9 +809,8 @@ int pss_search_time_nr(int **rxdata, ///rx data in time domain
   else
     length = frame_parms->samples_per_frame;
 
-  AssertFatal(length>0,"illegal length %d\n",length);
-  for (int i = 0; i < NUMBER_PSS_SEQUENCE; i++) AssertFatal(pss_corr_ue[i] != NULL,"pss_corr_ue[%d] not yet allocated! Exiting.\n", i);
 
+  AssertFatal(length>0,"illegal length %d\n",length);
   peak_value = 0;
   peak_position = 0;
   pss_source = 0;
@@ -846,47 +831,41 @@ int pss_search_time_nr(int **rxdata, ///rx data in time domain
   /* Correlation computation is based on a a dot product which is realized thank to SIMS extensions */
 
   for (int pss_index = 0; pss_index < NUMBER_PSS_SEQUENCE; pss_index++) {
-    avg[pss_index]=0;
-    memset(pss_corr_ue[pss_index],0,length*sizeof(int64_t)); 
-  }
-
-  for (n=0; n < length; n+=4) { //
 
-    for (int pss_index = 0; pss_index < NUMBER_PSS_SEQUENCE; pss_index++) {
+    for (n=0; n < length; n+=4) { //
 
-      if ( n < (length - frame_parms->ofdm_symbol_size)) {
+      int64_t pss_corr_ue=0;
+      /* calculate dot product of primary_synchro_time_nr and rxdata[ar][n]
+       * (ar=0..nb_ant_rx) and store the sum in temp[n]; */
+      for (ar=0; ar<frame_parms->nb_antennas_rx; ar++) {
 
-        /* calculate dot product of primary_synchro_time_nr and rxdata[ar][n] (ar=0..nb_ant_rx) and store the sum in temp[n]; */
-        for (ar=0; ar<frame_parms->nb_antennas_rx; ar++) {
-
-          /* perform correlation of rx data and pss sequence ie it is a dot product */
-          result  = dot_product64((short*)primary_synchro_time_nr[pss_index], 
-				  (short*)&(rxdata[ar][n+is*frame_parms->samples_per_frame]), 
-				  frame_parms->ofdm_symbol_size, 
-				  shift);
-	  pss_corr_ue[pss_index][n] += abs64(result);
-          //((short*)pss_corr_ue[pss_index])[2*n] += ((short*) &result)[0];   /* real part */
-          //((short*)pss_corr_ue[pss_index])[2*n+1] += ((short*) &result)[1]; /* imaginary part */
-          //((short*)&synchro_out)[0] += ((int*) &result)[0];               /* real part */
-          //((short*)&synchro_out)[1] += ((int*) &result)[1];               /* imaginary part */
+        /* perform correlation of rx data and pss sequence ie it is a dot product */
+        result  = dot_product64((short*)primary_synchro_time_nr[pss_index],
+                                (short*)&(rxdata[ar][n+is*frame_parms->samples_per_frame]),
+                                frame_parms->ofdm_symbol_size,
+                                shift);
+        pss_corr_ue += abs64(result);
+        //((short*)pss_corr_ue[pss_index])[2*n] += ((short*) &result)[0];   /* real part */
+        //((short*)pss_corr_ue[pss_index])[2*n+1] += ((short*) &result)[1]; /* imaginary part */
+        //((short*)&synchro_out)[0] += ((int*) &result)[0];               /* real part */
+        //((short*)&synchro_out)[1] += ((int*) &result)[1];               /* imaginary part */
 
-        }
       }
- 
+      
       /* calculate the absolute value of sync_corr[n] */
-      avg[pss_index]+=pss_corr_ue[pss_index][n];
-      if (pss_corr_ue[pss_index][n] > peak_value) {
-        peak_value = pss_corr_ue[pss_index][n];
+      avg[pss_index]+=pss_corr_ue;
+      if (pss_corr_ue > peak_value) {
+        peak_value = pss_corr_ue;
         peak_position = n;
         pss_source = pss_index;
-
+        
 #ifdef DEBUG_PSS_NR
-        printf("pss_index %d: n %6u peak_value %15llu\n", pss_index, n, (unsigned long long)pss_corr_ue[pss_index][n]);
+        printf("pss_index %d: n %6u peak_value %15llu\n", pss_index, n, (unsigned long long)pss_corr_ue[n]);
 #endif
       }
     }
   }
-
+  
   if (fo_flag){
 
 	  // fractional frequency offset computation according to Cross-correlation Synchronization Algorithm Using PSS
@@ -922,7 +901,8 @@ int pss_search_time_nr(int **rxdata, ///rx data in time domain
   // computing absolute value of frequency offset
   *f_off = ffo_est*frame_parms->subcarrier_spacing;  
 
-  for (int pss_index = 0; pss_index < NUMBER_PSS_SEQUENCE; pss_index++) avg[pss_index]/=(length/4);
+  for (int pss_index = 0; pss_index < NUMBER_PSS_SEQUENCE; pss_index++)
+    avg[pss_index]/=(length/4);
 
   *eNB_id = pss_source;
 
@@ -937,9 +917,6 @@ int pss_search_time_nr(int **rxdata, ///rx data in time domain
   static int debug_cnt = 0;
 
   if (debug_cnt == 0) {
-    LOG_M("pss_corr_ue0.m","pss_corr_ue0",pss_corr_ue[0],length,1,6);
-    LOG_M("pss_corr_ue1.m","pss_corr_ue1",pss_corr_ue[1],length,1,6);
-    LOG_M("pss_corr_ue2.m","pss_corr_ue2",pss_corr_ue[2],length,1,6);
     if (is)
       LOG_M("rxdata1.m","rxd0",rxdata[frame_parms->samples_per_frame],length,1,1); 
     else
diff --git a/openair1/PHY/NR_UE_TRANSPORT/sss_nr.c b/openair1/PHY/NR_UE_TRANSPORT/sss_nr.c
index 88585e6094f92bb6817c80586c06f677990ac80c..ff8d5d42ff803118d1b2650d2044bd1647e3af73 100644
--- a/openair1/PHY/NR_UE_TRANSPORT/sss_nr.c
+++ b/openair1/PHY/NR_UE_TRANSPORT/sss_nr.c
@@ -563,6 +563,10 @@ int rx_sss_nr(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int32_t *tot_metric,
   
   int re = 0;
   int im = 0;
+  if (Nid1 == N_ID_1_NUMBER) {
+    LOG_I(PHY,"Failled to detect SSS after PSS\n");
+    return -1;
+  }
   d = (int16_t *)&d_sss[Nid2][Nid1];
   for(i = 0; i<LENGTH_SSS_NR; i++) {
     re += d[i]*sss[2*i];
diff --git a/openair1/PHY/TOOLS/angle.c b/openair1/PHY/TOOLS/angle.c
index a06640d1cf4a8762121b515c4b78bd9db0c0a42d..89ffc3cb608d1172b324401b21a146d586c2d3b7 100644
--- a/openair1/PHY/TOOLS/angle.c
+++ b/openair1/PHY/TOOLS/angle.c
@@ -29,7 +29,7 @@
 #include "costable.h"
 #include "defs.h"
 
-unsigned int angle(struct complex16 perror)
+unsigned int angle(c16_t perror)
 {
   int a;
 
diff --git a/openair1/PHY/TOOLS/cadd_sv.c b/openair1/PHY/TOOLS/cadd_sv.c
index caa8d1cc04197480ee30483bf544dc03baeb75bf..56dcb718478c25ad843bee62eabfa535e6c11d72 100644
--- a/openair1/PHY/TOOLS/cadd_sv.c
+++ b/openair1/PHY/TOOLS/cadd_sv.c
@@ -129,7 +129,7 @@ main ()
   short output[256] __attribute__((aligned(16)));
 
   int i;
-  struct complex16 alpha;
+  c16_t alpha;
 
   Zero_Buffer(output,256*2);
 
diff --git a/openair1/PHY/TOOLS/cadd_vv.c b/openair1/PHY/TOOLS/cadd_vv.c
index 77346a97f7facdcf1e68a78b7397a709d9af6b12..08bf514cb357b2f032b3922810b0440f2d29cfb0 100644
--- a/openair1/PHY/TOOLS/cadd_vv.c
+++ b/openair1/PHY/TOOLS/cadd_vv.c
@@ -278,7 +278,7 @@ main ()
   short output[256] __attribute__((aligned(16)));
 
   int i;
-  struct complex16 alpha;
+  c16_t alpha;
 
   Zero_Buffer(output,256*2);
 
diff --git a/openair1/PHY/TOOLS/calibration_test.c b/openair1/PHY/TOOLS/calibration_test.c
index 5dced270604cfa0ec5f8b6a40a4886d2758d9021..650d5e420cacfe5d361f947922a6f2dc0b3de098 100644
--- a/openair1/PHY/TOOLS/calibration_test.c
+++ b/openair1/PHY/TOOLS/calibration_test.c
@@ -305,15 +305,15 @@ int main(int argc, char **argv) {
   
   openair0_device_load(&rfdevice,&openair0_cfg);
 
-  void ** samplesRx = (void **)malloc16(antennas* sizeof(struct complex16 *) );
-  void ** samplesTx = (void **)malloc16(antennas* sizeof(struct complex16 *) );
+  void ** samplesRx = (void **)malloc16(antennas* sizeof(c16_t *) );
+  void ** samplesTx = (void **)malloc16(antennas* sizeof(c16_t *) );
 
   int fd=open(getenv("rftestInputFile"),O_RDONLY);
   AssertFatal(fd>=0,"%s",strerror(errno));
   
   for (int i=0; i<antennas; i++) {
-    samplesRx[i] = (int32_t *)malloc16_clear( DFT*sizeof(struct complex16) );
-    samplesTx[i] = (int32_t *)malloc16_clear( DFT*sizeof(struct complex16) );
+    samplesRx[i] = (int32_t *)malloc16_clear( DFT*sizeof(c16_t) );
+    samplesTx[i] = (int32_t *)malloc16_clear( DFT*sizeof(c16_t) );
   }
 
   CalibrationInitScope(samplesRx, &rfdevice);
@@ -322,7 +322,7 @@ int main(int argc, char **argv) {
   
   while(!oai_exit) {
     for (int i=0; i<antennas; i++)
-      read(fd, samplesTx[i], DFT*sizeof(struct complex16));
+      read(fd, samplesTx[i], DFT*sizeof(c16_t));
     int readBlockSize = rfdevice.trx_read_func(&rfdevice,
 					       &timestamp,
 					       samplesRx,
diff --git a/openair1/PHY/TOOLS/dB_routines.h b/openair1/PHY/TOOLS/dB_routines.h
deleted file mode 100644
index 185913cf5b052e0a607a9bdd3abebc7a166a0579..0000000000000000000000000000000000000000
--- a/openair1/PHY/TOOLS/dB_routines.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The OpenAirInterface Software Alliance licenses this file to You under
- * the OAI Public License, Version 1.1  (the "License"); you may not use this file
- * except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.openairinterface.org/?page_id=698
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *-------------------------------------------------------------------------------
- * For more information about the OpenAirInterface (OAI) Software Alliance:
- *      contact@openairinterface.org
- */
-
-/*
- * dB_routines.h
- *
- *  Created on: Nov 12, 2013
- *      Author: winckel
- */
-
-#ifndef DB_ROUTINES_H_
-#define DB_ROUTINES_H_
-
-int16_t dB_fixed_times10(uint32_t x);
-int16_t dB_fixed_x10(uint32_t x);
-
-#endif /* DB_ROUTINES_H_ */
diff --git a/openair1/PHY/TOOLS/nr_phy_scope.c b/openair1/PHY/TOOLS/nr_phy_scope.c
index fe0f785ef4ce44a07ef85f7472329fb2e995f6f0..723813fbb62632ba31b8f82e609a5dc74685174a 100644
--- a/openair1/PHY/TOOLS/nr_phy_scope.c
+++ b/openair1/PHY/TOOLS/nr_phy_scope.c
@@ -37,7 +37,7 @@
 const FL_COLOR rx_antenna_colors[4] = {FL_RED,FL_BLUE,FL_GREEN,FL_YELLOW};
 const FL_COLOR water_colors[4] = {FL_BLUE,FL_GREEN,FL_YELLOW,FL_RED};
 
-typedef struct complex16 scopeSample_t;
+typedef c16_t scopeSample_t;
 #define SquaredNorm(VaR) ((VaR).r*(VaR).r+(VaR).i*(VaR).i)
 
 typedef struct {
@@ -678,52 +678,42 @@ static void uePbchIQ  (scopeGraphData_t **data, OAIgraph_t *graph, PHY_VARS_NR_U
 
 static void uePcchLLR  (scopeGraphData_t **data, OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id) {
   // PDCCH LLRs
-  if (!phy_vars_ue->pdcch_vars[0][eNB_id]->llr)
+  if (!data[pdcchLlr])
     return;
 
   //int num_re = 4*273*12; // 12*frame_parms->N_RB_DL*num_pdcch_symbols
   //int Qm = 2;
-  int coded_bits_per_codeword = 2*4*100*12; //num_re*Qm;
+  const int sz=data[pdcchLlr]->lineSz;
   float *llr, *bit;
-  oai_xygraph_getbuff(graph, &bit, &llr, coded_bits_per_codeword*RX_NB_TH_MAX, 0);
-  int base=0;
+  oai_xygraph_getbuff(graph, &bit, &llr, sz, 0);
 
-  for (int thr=0 ; thr < RX_NB_TH_MAX ; thr ++ ) {
-    int16_t *pdcch_llr = (int16_t *) phy_vars_ue->pdcch_vars[thr][eNB_id]->llr;
-
-    for (int i=0; i<coded_bits_per_codeword; i++) {
-      llr[base+i] = (float) pdcch_llr[i];
-    }
+  int16_t *pdcch_llr = (int16_t *)(data[pdcchLlr]+1);
 
-    base+=coded_bits_per_codeword;
+  for (int i=0; i<sz; i++) {
+    llr[i] = (float) pdcch_llr[i];
   }
 
-  AssertFatal(base <= coded_bits_per_codeword*RX_NB_TH_MAX, "");
-  oai_xygraph(graph,bit,llr,base,0,10);
+  oai_xygraph(graph,bit,llr,sz,0,10);
 }
 static void uePcchIQ  (scopeGraphData_t **data, OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id) {
   // PDCCH I/Q of MF Output
-  if (!phy_vars_ue->pdcch_vars[0][eNB_id]->rxdataF_comp[0])
+  if (!data[pdcchRxdataF_comp])
     return;
 
-  int nb=4*273*12; // 12*frame_parms->N_RB_DL*num_pdcch_symbols
+  const int sz=data[pdcchRxdataF_comp]->lineSz;
+  //const int antennas=data[pdcchRxdataF_comp]->colSz;
+  // We take the first antenna only for now
   float *I, *Q;
-  oai_xygraph_getbuff(graph, &I, &Q, nb*RX_NB_TH_MAX, 0);
-  int base=0;
-
-  for (int thr=0 ; thr < RX_NB_TH_MAX ; thr ++ ) {
-    scopeSample_t *pdcch_comp = (scopeSample_t *) phy_vars_ue->pdcch_vars[thr][eNB_id]->rxdataF_comp[0];
+  oai_xygraph_getbuff(graph, &I, &Q, sz, 0);
 
-    for (int i=0; i< nb; i++) {
-      I[base+i] = pdcch_comp[i].r;
-      Q[base+i] = pdcch_comp[i].i;
-    }
+  scopeSample_t *pdcch_comp = (scopeSample_t *) (data[pdcchRxdataF_comp]+1);
 
-    base+=nb;
+  for (int i=0; i<sz; i++) {
+    I[i] = pdcch_comp[i].r;
+    Q[i] = pdcch_comp[i].i;
   }
 
-  AssertFatal(base <= nb*RX_NB_TH_MAX, "");
-  oai_xygraph(graph,I,Q,base,0,10);
+  oai_xygraph(graph,I,Q,sz,0,10);
 }
 static void uePdschLLR  (scopeGraphData_t **data, OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id) {
   // PDSCH LLRs
@@ -908,7 +898,6 @@ static void *nrUEscopeThread(void *arg) {
   char *name="5G-UE-scope";
   fl_initialize (&fl_argc, &name, NULL, 0, 0);
   OAI_phy_scope_t  *form_nrue=create_phy_scope_nrue(0);
-  (( scopeData_t *)ue->scopeData)->liveData=calloc(sizeof(scopeGraphData_t *), UEdataTypeNumberOfItems);
 
   while (!oai_exit) {
     fl_freeze_form(form_nrue->phy_scope);
@@ -925,28 +914,43 @@ static void *nrUEscopeThread(void *arg) {
 }
 
 void UEcopyData(PHY_VARS_NR_UE *ue, enum UEdataType type, void *dataIn, int elementSz, int colSz, int lineSz) {
+  // Local static copy of the scope data bufs
+  // The active data buf is alterned to avoid interference between the Scope thread (display) and the Rx thread (data input)
+  // Index of "2" could be set to the number of Rx threads + 1
+  static scopeGraphData_t *copyDataBufs[UEdataTypeNumberOfItems][2] = {0};
+  static int  copyDataBufsIdx[UEdataTypeNumberOfItems] = {0};
+
   scopeData_t *tmp=(scopeData_t *)ue->scopeData;
 
   if (tmp) {
-    scopeGraphData_t *live= ((scopeGraphData_t **)tmp->liveData)[type];
+    // Begin of critical zone between UE Rx threads that might copy new data at the same time: might require a mutex
+    int newCopyDataIdx = (copyDataBufsIdx[type]==0)?1:0;
+    copyDataBufsIdx[type] = newCopyDataIdx;
+    // End of critical zone between UE Rx threads
 
-    if (live == NULL || live->dataSize < elementSz*colSz*lineSz) {
-      scopeGraphData_t *ptr=realloc(live, sizeof(scopeGraphData_t) + elementSz*colSz*lineSz);
+    // New data will be copied in a different buffer than the live one
+    scopeGraphData_t *copyData= copyDataBufs[type][newCopyDataIdx];
+
+    if (copyData == NULL || copyData->dataSize < elementSz*colSz*lineSz) {
+      scopeGraphData_t *ptr=realloc(copyData, sizeof(scopeGraphData_t) + elementSz*colSz*lineSz);
 
       if (!ptr) {
         LOG_E(PHY,"can't realloc\n");
         return;
       } else {
-        live=ptr;
+        copyData=ptr;
       }
     }
 
-    live->dataSize=elementSz*colSz*lineSz;
-    live->elementSz=elementSz;
-    live->colSz=colSz;
-    live->lineSz=lineSz;
-    memcpy(live+1, dataIn,  elementSz*colSz*lineSz);
-    ((scopeGraphData_t **)tmp->liveData)[type]=live;
+    copyData->dataSize=elementSz*colSz*lineSz;
+    copyData->elementSz=elementSz;
+    copyData->colSz=colSz;
+    copyData->lineSz=lineSz;
+    memcpy(copyData+1, dataIn,  elementSz*colSz*lineSz);
+    copyDataBufs[type][newCopyDataIdx] = copyData;
+
+    // The new data just copied in the local static buffer becomes live now
+    ((scopeGraphData_t **)tmp->liveData)[type]=copyData;
   }
 }
 
@@ -954,6 +958,7 @@ void nrUEinitScope(PHY_VARS_NR_UE *ue) {
   AssertFatal(ue->scopeData=malloc(sizeof(scopeData_t)),"");
   scopeData_t *scope=(scopeData_t *) ue->scopeData;
   scope->copyData=UEcopyData;
+  AssertFatal(scope->liveData=calloc(sizeof(scopeGraphData_t *), UEdataTypeNumberOfItems),"");
   pthread_t forms_thread;
   threadCreate(&forms_thread, nrUEscopeThread, ue, "scope", -1, OAI_PRIORITY_RT_LOW);
 }
diff --git a/openair1/PHY/TOOLS/phy_scope_interface.h b/openair1/PHY/TOOLS/phy_scope_interface.h
index 9cd8e1dc40c0924d3b01f1ef7561bd46b46f1561..6162e1eee58023622c0aaccc5e2de962aa62bb67 100644
--- a/openair1/PHY/TOOLS/phy_scope_interface.h
+++ b/openair1/PHY/TOOLS/phy_scope_interface.h
@@ -45,6 +45,8 @@ enum UEdataType {
   pbchDlChEstimateTime,
   pbchLlr,
   pbchRxdataF_comp,
+  pdcchLlr,
+  pdcchRxdataF_comp,
   UEdataTypeNumberOfItems
 };
 
diff --git a/openair1/PHY/TOOLS/tools_defs.h b/openair1/PHY/TOOLS/tools_defs.h
index 86bce9614fd442ef47ad3670901c477c17d21378..145fbe4a31a2867e21f1ba645ea0ebef125a0a55 100644
--- a/openair1/PHY/TOOLS/tools_defs.h
+++ b/openair1/PHY/TOOLS/tools_defs.h
@@ -39,26 +39,33 @@ extern "C" {
 #define CEILIDIV(a,b) ((a+b-1)/b)
 #define ROUNDIDIV(a,b) (((a<<1)+b)/(b<<1))
 
-struct complexd {
+typedef struct complexd {
   double r;
   double i;
-};
+} cd_t;
 
-struct complexf {
+typedef struct complexf {
   float r;
   float i;
-};
+} cf_t;
 
-struct complex16 {
+typedef struct complex16 {
   int16_t r;
   int16_t i;
-};
+} c16_t;
 
-struct complex32 {
+typedef struct complex32 {
   int32_t r;
   int32_t i;
-};
-
+} c32_t;
+  
+typedef struct complex64 {
+  int64_t r;
+  int64_t i;
+} c64_t;
+
+#define squaredMod(a) ((a).r*(a).r+(a).i*(a).i)
+#define csum(res, i1, i2) (res).r=(i1).r+(i2).r ; (res).i=(i1).i+(i2).i  
 //cmult_sv.h
 
 /*!\fn void multadd_real_vector_complex_scalar(int16_t *x,int16_t *alpha,int16_t *y,uint32_t N)
diff --git a/openair1/PHY/defs_RU.h b/openair1/PHY/defs_RU.h
index 0b20aa409ba69edc3f49b734f91248dc73c43e44..243e76f851823a384c0fe676f0ccc32016fde48d 100644
--- a/openair1/PHY/defs_RU.h
+++ b/openair1/PHY/defs_RU.h
@@ -54,7 +54,6 @@ typedef enum {
   no_L2_connect=5,
   calib_prach_tx=6,
   rx_dump_frame=7,
-  loop_through_memory=8
 } runmode_t;
 
 /*! \brief Extension Type */
diff --git a/openair1/PHY/defs_UE.h b/openair1/PHY/defs_UE.h
index 7f4d07ddae8c5b58251ca3a50ae0ae4ba913105d..4f9bc076ffd004b7371a46fbfc6326e7b77089f6 100644
--- a/openair1/PHY/defs_UE.h
+++ b/openair1/PHY/defs_UE.h
@@ -833,7 +833,6 @@ typedef struct {
   pthread_mutex_t timer_mutex;
   pthread_cond_t timer_cond;
   int instance_cnt_timer;
-
   /// RF and Interface devices per CC
 
   openair0_device rfdevice;
diff --git a/openair1/PHY/defs_common.h b/openair1/PHY/defs_common.h
index 86df85db5c5ed1c076444ec5c07e2930b202ad22..d13fe260deba559e3b0dcbf3077192289cfa16a5 100644
--- a/openair1/PHY/defs_common.h
+++ b/openair1/PHY/defs_common.h
@@ -99,7 +99,7 @@
 #define NB_RX_ANTENNAS_MAX 64
 
 
-typedef enum {TDD=1,FDD=0} lte_frame_type_t;
+typedef enum {TDD=1,FDD=0} frame_type_t;
 
 typedef enum {EXTENDED=1,NORMAL=0} lte_prefix_type_t;
 
@@ -597,7 +597,7 @@ typedef struct LTE_DL_FRAME_PARMS {
   /// shift of pilot position in one RB
   uint8_t nushift;
   /// Frame type (0 FDD, 1 TDD)
-  lte_frame_type_t frame_type;
+  frame_type_t frame_type;
   /// TDD subframe assignment (0-7) (default = 3) (254=RX only, 255=TX only)
   uint8_t tdd_config;
   /// TDD S-subframe configuration (0-9)
diff --git a/openair1/PHY/defs_gNB.h b/openair1/PHY/defs_gNB.h
index 7b655c023a9bbd27db6c315528f38eef6c66bf50..1ff17f9a39458fcfe651168fc27451919e475bb1 100644
--- a/openair1/PHY/defs_gNB.h
+++ b/openair1/PHY/defs_gNB.h
@@ -587,9 +587,6 @@ typedef struct gNB_L1_proc_t_s {
   int instance_cnt_te;
   /// \internal This variable is protected by \ref mutex_prach.
   int instance_cnt_prach;
-
-  // instance count for over-the-air gNB synchronization
-  int instance_cnt_synch;
   /// \internal This variable is protected by \ref mutex_asynch_rxtx.
   int instance_cnt_asynch_rxtx;
   /// pthread structure for eNB single processing thread
@@ -661,8 +658,6 @@ typedef struct {
   unsigned int   n0_power_tot;
   //! estimated avg noise power (dB)
   unsigned int n0_power_tot_dB;
-  //! estimated avg noise power (dB)
-  int n0_power_tot_dBm;
   //! estimated avg noise power per RB per RX ant (lin)
   unsigned int n0_subband_power[MAX_NUM_RU_PER_gNB][275];
   //! estimated avg noise power per RB per RX ant (dB)
diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h
index ddd84fbc41ce049a1dc3f2db838ba3c890ed88a6..82de7ed96ea014d117fc68f37d2c0129f575775a 100644
--- a/openair1/PHY/defs_nr_UE.h
+++ b/openair1/PHY/defs_nr_UE.h
@@ -550,60 +550,20 @@ typedef struct {
 } NR_UE_PDCCH_SEARCHSPACE;
 #endif
 typedef struct {
-  /// \brief Pointers to extracted PDCCH symbols in frequency-domain.
-  /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx
-  /// - second index: ? [0..168*N_RB_DL[
-  int32_t **rxdataF_ext;
-  /// \brief Pointers to extracted and compensated PDCCH symbols in frequency-domain.
-  /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx
-  /// - second index: ? [0..168*N_RB_DL[
-  int32_t **rxdataF_comp;
-  /// \brief Hold the channel estimates in frequency domain.
-  /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx
-  /// - second index: samples? [0..symbols_per_tti*(ofdm_symbol_size+LTE_CE_FILTER_LENGTH)[
-  int32_t **dl_ch_estimates;
-  /// \brief Hold the channel estimates in time domain (used for tracking).
-  /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx
-  /// - second index: samples? [0..2*ofdm_symbol_size[
-  int32_t **dl_ch_estimates_time;
-  /// \brief Pointers to extracted channel estimates of PDCCH symbols.
-  /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx
-  /// - second index: ? [0..168*N_RB_DL[
-  int32_t **dl_ch_estimates_ext;
-  /// \brief Pointers to channel cross-correlation vectors for multi-gNB detection.
-  /// - first index: rx antenna [0..nb_antennas_rx[
-  /// - second index: ? [0..]
-  int32_t **rho;
-  /// \brief Pointer to llrs, 4-bit resolution.
-  /// - first index: ? [0..48*N_RB_DL[
-  int16_t *llr;
-  /// \brief Pointer to llrs, 16-bit resolution.
-  /// - first index: ? [0..96*N_RB_DL[
-  int16_t *llr16;
-  /// \brief \f$\overline{w}\f$ from 36-211.
-  /// - first index: ? [0..48*N_RB_DL[
-  int16_t *wbar;
-  /// \brief PDCCH/DCI e-sequence (input to rate matching).
-  /// - first index: ? [0..96*N_RB_DL[
-  int16_t *e_rx;
-  /// Total number of PDU errors (diagnostic mode)
-  uint32_t dci_errors;
+  int nb_search_space;
+  uint16_t sfn;
+  uint16_t slot;
+  fapi_nr_dl_config_dci_dl_pdu_rel15_t pdcch_config[FAPI_NR_MAX_SS];
+} NR_UE_PDCCH_CONFIG;
+
+typedef struct {
   /// Total number of PDU received
   uint32_t dci_received;
   /// Total number of DCI False detection (diagnostic mode)
   uint32_t dci_false;
   /// Total number of DCI missed (diagnostic mode)
   uint32_t dci_missed;
-  /// nCCE for PDCCH per subframe
-  uint8_t nCCE[10];
-  //Check for specific DCIFormat and AgregationLevel
-  uint8_t dciFormat;
-  uint8_t agregationLevel;
-  int nb_search_space;
-  fapi_nr_dl_config_dci_dl_pdu_rel15_t pdcch_config[FAPI_NR_MAX_SS];
-  // frame and slot for sib1 in initial sync
-  uint16_t sfn;
-  uint16_t slot;
+
   /*
 #ifdef NR_PDCCH_DEFS_NR_UE
   int nb_searchSpaces;
diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h
index 7c78d20ae50bf7c73fadb3b1f9eb22efadcabad4..b24abd7de39e20bfdf9c626619b0946e218c4321 100644
--- a/openair1/PHY/defs_nr_common.h
+++ b/openair1/PHY/defs_nr_common.h
@@ -67,6 +67,7 @@
 
 /*used for the resource mapping*/
 #define NR_MAX_PDCCH_DMRS_LENGTH 576 // 16(L)*2(QPSK)*3(3 DMRS symbs per REG)*6(REG per CCE)
+#define  NR_MAX_PDCCH_SIZE 8192 // It seems it is the max polar coded block size
 
 #define NR_MAX_DCI_PAYLOAD_SIZE 64
 #define NR_MAX_DCI_SIZE 1728 //16(L)*2(QPSK)*9(12 RE per REG - 3(DMRS))*6(REG per CCE)
@@ -280,7 +281,7 @@ struct NR_DL_FRAME_PARMS {
   uint32_t att_rx;
   ///  total Number of Resource Block Groups: this is ceil(N_PRB/P)
   /// Frame type (0 FDD, 1 TDD)
-  lte_frame_type_t frame_type;
+  frame_type_t frame_type;
   uint8_t tdd_config;
   /// Cell ID
   uint16_t Nid_cell;
diff --git a/openair1/SCHED/phy_procedures_lte_common.c b/openair1/SCHED/phy_procedures_lte_common.c
index 7033c5270138ee50f5527987b59c185d37e0738b..9de453da948e7594356319d2d6cc8dad94171ac0 100644
--- a/openair1/SCHED/phy_procedures_lte_common.c
+++ b/openair1/SCHED/phy_procedures_lte_common.c
@@ -994,7 +994,7 @@ int is_srs_occasion_common(LTE_DL_FRAME_PARMS *frame_parms,int frame_tx,int subf
   return(isSubframeSRS);
 }
 
-void compute_srs_pos(lte_frame_type_t frameType,uint16_t isrs,uint16_t *psrsPeriodicity,uint16_t *psrsOffset)
+void compute_srs_pos(frame_type_t frameType,uint16_t isrs,uint16_t *psrsPeriodicity,uint16_t *psrsOffset)
 {
     if(TDD == frameType)
     {
diff --git a/openair1/SCHED/sched_common.h b/openair1/SCHED/sched_common.h
index c9fc3386865b6931fc7fdbb98f694f61d078806f..9f3e6695b6ccf650dde15eaba9f178bca176874d 100644
--- a/openair1/SCHED/sched_common.h
+++ b/openair1/SCHED/sched_common.h
@@ -339,7 +339,7 @@ void dump_dlsch2(PHY_VARS_UE *phy_vars_ue,uint8_t eNB_id,uint8_t subframe, unsig
 
 int is_srs_occasion_common(LTE_DL_FRAME_PARMS *frame_parms,int frame_tx,int subframe_tx);
 
-void compute_srs_pos(lte_frame_type_t frameType,uint16_t isrs,uint16_t *psrsPeriodicity,uint16_t *psrsOffset);
+void compute_srs_pos(frame_type_t frameType,uint16_t isrs,uint16_t *psrsPeriodicity,uint16_t *psrsOffset);
 
 
 /* from here: prototype added to remove compilation warnings, doc to be written by the author of the function */
diff --git a/openair1/SCHED/sched_common_vars.h b/openair1/SCHED/sched_common_vars.h
index 2cae2aa96f21bc49bc32dc156ac688b8c22f72eb..8886e0d576bae75c8e088e9131d9dea4b00e2d19 100644
--- a/openair1/SCHED/sched_common_vars.h
+++ b/openair1/SCHED/sched_common_vars.h
@@ -20,6 +20,7 @@
  */
 
 #include <stdint.h>
+#include <openair1/SCHED/sched_common_extern.h>
 
 
 // This is the formula from Section 5.1.1.1 in 36.213 100*10*log10((2^(MPR*Ks)-1)), where MPR is in the range [0,6] and Ks=1.25
diff --git a/openair1/SCHED/sched_eNB.h b/openair1/SCHED/sched_eNB.h
index de987b0ac7eece4820e24f208798954a658d7572..efdb1bd199ffb544a8df92b1ed424564b1a91e42 100644
--- a/openair1/SCHED/sched_eNB.h
+++ b/openair1/SCHED/sched_eNB.h
@@ -215,7 +215,7 @@ int16_t get_target_pucch_rx_power(module_id_t module_idP, uint8_t CC_id);
 
 int is_srs_occasion_common(LTE_DL_FRAME_PARMS *frame_parms,int frame_tx,int subframe_tx);
 
-void compute_srs_pos(lte_frame_type_t frameType,uint16_t isrs,uint16_t *psrsPeriodicity,uint16_t *psrsOffset);
+void compute_srs_pos(frame_type_t frameType,uint16_t isrs,uint16_t *psrsPeriodicity,uint16_t *psrsOffset);
 
 void release_rnti_of_phy(module_id_t mod_id);
 /*@}*/
diff --git a/openair1/SCHED_NR_UE/defs.h b/openair1/SCHED_NR_UE/defs.h
index eeea57ffc6125ddfd9af36ba9cb83a770f041d31..9bcf659eac83b4a279521acdc6cbeece4e980109 100644
--- a/openair1/SCHED_NR_UE/defs.h
+++ b/openair1/SCHED_NR_UE/defs.h
@@ -116,16 +116,18 @@ int phy_procedures_RN_UE_RX(unsigned char last_slot, unsigned char next_slot, re
 void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t eNB_id);
 
 /*! \brief Scheduling for UE RX procedures in normal subframes.
-  @param ue             Pointer to UE variables on which to act
-  @param proc           Pointer to proc information
-  @param gNB_id         Local id of eNB on which to act
-  @param dlsch_parallel use multithreaded dlsch processing
-  @param txFifo         Result fifo if PDSCH is run in parallel
+  @param ue                     Pointer to UE variables on which to act
+  @param proc                   Pointer to proc information
+  @param gNB_id                 Local id of eNB on which to act
+  @param dlsch_parallel         use multithreaded dlsch processing
+  @param phy_pdcch_config       PDCCH Config for this slot
+  @param txFifo                 Result fifo if PDSCH is run in parallel
 */
 int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,
                            UE_nr_rxtx_proc_t *proc,
                            uint8_t gNB_id,
                            uint8_t dlsch_parallel,
+                           NR_UE_PDCCH_CONFIG *phy_pdcch_config,
                            notifiedFIFO_t *txFifo);
 
 int phy_procedures_slot_parallelization_nrUE_RX(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t eNB_id, uint8_t abstraction_flag, uint8_t do_pdcch_flag, relaying_type_t r_type);
@@ -383,7 +385,8 @@ void nr_fill_dl_indication(nr_downlink_indication_t *dl_ind,
                            fapi_nr_rx_indication_t *rx_ind,
                            UE_nr_rxtx_proc_t *proc,
                            PHY_VARS_NR_UE *ue,
-                           uint8_t gNB_id);
+                           uint8_t gNB_id,
+                           void *phy_data);
 
 /*@}*/
 
@@ -417,8 +420,11 @@ int nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue,
                            NR_UE_DLSCH_t *dlsch0, NR_UE_DLSCH_t *dlsch1);
 
 int nr_ue_pdcch_procedures(uint8_t gNB_id,
-			   PHY_VARS_NR_UE *ue,
-			   UE_nr_rxtx_proc_t *proc,
+                           PHY_VARS_NR_UE *ue,
+                           UE_nr_rxtx_proc_t *proc,
+                           int32_t pdcch_est_size,
+                           int32_t pdcch_dl_ch_estimates[][pdcch_est_size],
+                           NR_UE_PDCCH_CONFIG *phy_pdcch_config,
                            int n_ss);
 
 
diff --git a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c
index 8a1def31e25578b0f44849211541adc4b82e5afb..740d04f922ed1e3dbb01476d2b6c8b5fd9a42986 100644
--- a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c
+++ b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c
@@ -356,15 +356,14 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){
     // Note: we have to handle the thread IDs for this. To be revisited completely.
     thread_id = scheduled_response->thread_id;
     NR_UE_DLSCH_t *dlsch0 = NULL;
-    NR_UE_PDCCH *pdcch_vars = PHY_vars_UE_g[module_id][cc_id]->pdcch_vars[thread_id][0];
     NR_UE_ULSCH_t *ulsch = PHY_vars_UE_g[module_id][cc_id]->ulsch[thread_id][0];
     NR_UE_PUCCH *pucch_vars = PHY_vars_UE_g[module_id][cc_id]->pucch_vars[thread_id][0];
+    NR_UE_PDCCH_CONFIG *phy_pdcch_config = NULL;
 
     if(scheduled_response->dl_config != NULL){
       fapi_nr_dl_config_request_t *dl_config = scheduled_response->dl_config;
       fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config_pdu;
       fapi_nr_dl_config_dci_dl_pdu_rel15_t *pdcch_config;
-      pdcch_vars->nb_search_space = 0;
 
       for (int i = 0; i < dl_config->number_pdus; ++i){
         AssertFatal(dl_config->number_pdus < FAPI_NR_DL_CONFIG_LIST_NUM,"dl_config->number_pdus %d out of bounds\n",dl_config->number_pdus);
@@ -374,12 +373,16 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){
 
         switch(dl_config->dl_config_list[i].pdu_type) {
           case FAPI_NR_DL_CONFIG_TYPE_DCI:
+            if (NULL == phy_pdcch_config) {
+              phy_pdcch_config = (NR_UE_PDCCH_CONFIG *)scheduled_response->phy_data;
+              phy_pdcch_config->nb_search_space = 0;
+            }
             pdcch_config = &dl_config->dl_config_list[i].dci_config_pdu.dci_config_rel15;
-            memcpy(&pdcch_vars->pdcch_config[pdcch_vars->nb_search_space],pdcch_config,sizeof(*pdcch_config));
-            pdcch_vars->nb_search_space = pdcch_vars->nb_search_space + 1;
-            pdcch_vars->sfn = scheduled_response->frame;
-            pdcch_vars->slot = slot;
-            LOG_D(PHY,"Number of DCI SearchSpaces %d\n",pdcch_vars->nb_search_space);
+            memcpy((void*)&phy_pdcch_config->pdcch_config[phy_pdcch_config->nb_search_space],(void*)pdcch_config,sizeof(*pdcch_config));
+            phy_pdcch_config->nb_search_space = phy_pdcch_config->nb_search_space + 1;
+            phy_pdcch_config->sfn = scheduled_response->frame;
+            phy_pdcch_config->slot = slot;
+            LOG_D(PHY,"Number of DCI SearchSpaces %d\n",phy_pdcch_config->nb_search_space);
             break;
           case FAPI_NR_DL_CONFIG_TYPE_CSI_IM:
             LOG_I(PHY,"Received CSI-IM PDU at FAPI\n");
diff --git a/openair1/SCHED_NR_UE/harq_nr.c b/openair1/SCHED_NR_UE/harq_nr.c
index 4afe5f41d3b50a9611c2ffb9246ba59a39377038..a9ff01d78a471cb5dc51016a3cbfd04f476c575e 100644
--- a/openair1/SCHED_NR_UE/harq_nr.c
+++ b/openair1/SCHED_NR_UE/harq_nr.c
@@ -307,7 +307,7 @@ void init_downlink_harq_status(NR_DL_UE_HARQ_t *dl_harq)
 {
   dl_harq->status = SCH_IDLE;
   dl_harq->first_rx = 1;
-  dl_harq->round  = 0;
+  dl_harq->DLround  = 0;
   dl_harq->DCINdi = 1;
   dl_harq->ack = DL_ACKNACK_NO_SET;
 }
@@ -334,60 +334,38 @@ void downlink_harq_process(NR_DL_UE_HARQ_t *dl_harq, int harq_pid, int ndi, int
   if (rnti_type == _SI_RNTI_ ||
       rnti_type == _P_RNTI_ ||
       rnti_type == _RA_RNTI_) {
-    dl_harq->round = 0;
+    dl_harq->DLround = 0;
     dl_harq->status = ACTIVE;
     dl_harq->first_rx = 1;
-  }
-  else{
-    switch(rv){
-      case 0:
-        dl_harq->round = 0;
-        dl_harq->status = ACTIVE;
-        dl_harq->first_rx = 1;
-        if (dl_harq->DCINdi == ndi)
-          LOG_E(PHY,"Warning! rv %d indicates new transmission but new ndi %d is the same as old ndi %d\n",rv,ndi,dl_harq->DCINdi);
-        dl_harq->DCINdi = ndi;
-        break;
-      case 1:
-        dl_harq->round = 3;
-        dl_harq->status = ACTIVE;
-        dl_harq->first_rx = 0;
-        if (dl_harq->DCINdi != ndi) {
-          LOG_E(PHY,"Missed previous DCI detections. NDI toggled but rv %d does not correspond to first reception\n",rv);
-          dl_harq->first_rx = 1;
-          dl_harq->DCINdi = ndi;
-        }
-        else if (dl_harq->ack == 1)
-          dl_harq->status = SCH_IDLE;
-        break;
-      case 2:
-        dl_harq->round = 1;
-        dl_harq->status = ACTIVE;
-        dl_harq->first_rx = 0;
-        if (dl_harq->DCINdi != ndi) {
-          LOG_E(PHY,"Missed previous DCI detections. NDI toggled but rv %d does not correspond to first reception\n",rv);
-          dl_harq->first_rx = 1;
-          dl_harq->DCINdi = ndi;
-        }
-        else if (dl_harq->ack == 1)
-          dl_harq->status = SCH_IDLE;
-        break;
-      case 3:
-        dl_harq->round = 2;
-        dl_harq->status = ACTIVE;
-        dl_harq->first_rx = 0;
-        if (dl_harq->DCINdi != ndi) {
-          LOG_E(PHY,"Missed previous DCI detections. NDI toggled but rv %d does not correspond to first reception\n",rv);
-          dl_harq->first_rx = 1;
-          dl_harq->DCINdi = ndi;
-        }
-        else if (dl_harq->ack == 1)
-          dl_harq->status = SCH_IDLE;
-        break;
-      default:
-        AssertFatal(1==0,"Invalid value for rv %d\n",rv);
+  }  else {
+    LOG_D(PHY,"receive harq process: %p harqPid=%d, rv=%d, ndi=%d, rntiType=%d new transmission= %s\n",
+	  dl_harq, harq_pid, rv, ndi, rnti_type, dl_harq->DCINdi != ndi ? "yes":"no");
+    AssertFatal(rv<4 && rv>=0, "invalid redondancy version %d\n", rv);
+    
+    if (ndi!=dl_harq->DCINdi) {
+      if (dl_harq->ack == DL_NACK)
+        LOG_D(PHY,"New transmission on a harq pid (%d) never acknowledged\n", harq_pid);
+      else
+         LOG_D(PHY,"Starting new transmission on a harq pid (%d)\n", harq_pid);
+    } else {
+      if (dl_harq->ack != DL_NACK)
+        LOG_D(PHY,"gNB asked for retransmission even if we sent ACK\n");
+      else
+        LOG_D(PHY,"Starting retransmission on a harq pid (%d), rv (%d)\n", harq_pid, rv);
     }
-  }
 
+    if (ndi!=dl_harq->DCINdi) {
+      dl_harq->first_rx = true;
+      dl_harq->DLround = 0;
+    } else {
+      dl_harq->first_rx = false;
+      dl_harq->DLround++;
+    }
+    
+    dl_harq->status = ACTIVE;
+
+    dl_harq->DCINdi = ndi;
+    //dl_harq->status = SCH_IDLE;
+   }
 }
 
diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c
index 35674da2e28d9e467d8c5fde4d917133c44cd1df..82ff310479d8c841786e33a25198bb5d2ff34b5f 100644
--- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c
+++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c
@@ -87,7 +87,8 @@ void nr_fill_dl_indication(nr_downlink_indication_t *dl_ind,
                            fapi_nr_rx_indication_t *rx_ind,
                            UE_nr_rxtx_proc_t *proc,
                            PHY_VARS_NR_UE *ue,
-                           uint8_t gNB_id){
+                           uint8_t gNB_id,
+                           void *phy_data){
 
   memset((void*)dl_ind, 0, sizeof(nr_downlink_indication_t));
 
@@ -97,6 +98,7 @@ void nr_fill_dl_indication(nr_downlink_indication_t *dl_ind,
   dl_ind->frame     = proc->frame_rx;
   dl_ind->slot      = proc->nr_slot_rx;
   dl_ind->thread_id = proc->thread_id;
+  dl_ind->phy_data  = phy_data;
 
   if (dci_ind) {
 
@@ -360,7 +362,7 @@ void nr_ue_measurement_procedures(uint16_t l,
 
 static void nr_ue_pbch_procedures(uint8_t gNB_id,
 			   PHY_VARS_NR_UE *ue,
-				  UE_nr_rxtx_proc_t *proc,int estimateSz, struct complex16 dl_ch_estimates[][estimateSz])
+				  UE_nr_rxtx_proc_t *proc,int estimateSz, struct complex16 dl_ch_estimates[][estimateSz], NR_UE_PDCCH_CONFIG *phy_pdcch_config)
 {
   int ret = 0;
 
@@ -380,7 +382,8 @@ static void nr_ue_pbch_procedures(uint8_t gNB_id,
                    gNB_id,
                    (ue->frame_parms.ssb_index)&7,
                    SISO,
-		   &result);
+                   phy_pdcch_config,
+                   &result);
 
   if (ret==0) {
 
@@ -486,6 +489,9 @@ unsigned int nr_get_tx_amp(int power_dBm, int power_max_dBm, int N_RB_UL, int nb
 int nr_ue_pdcch_procedures(uint8_t gNB_id,
                            PHY_VARS_NR_UE *ue,
                            UE_nr_rxtx_proc_t *proc,
+                           int32_t pdcch_est_size,
+                           int32_t pdcch_dl_ch_estimates[][pdcch_est_size],
+                           NR_UE_PDCCH_CONFIG *phy_pdcch_config,
                            int n_ss)
 {
   int frame_rx = proc->frame_rx;
@@ -494,13 +500,16 @@ int nr_ue_pdcch_procedures(uint8_t gNB_id,
   fapi_nr_dci_indication_t *dci_ind = calloc(1, sizeof(*dci_ind));
   nr_downlink_indication_t dl_indication;
 
-  NR_UE_PDCCH *pdcch_vars = ue->pdcch_vars[proc->thread_id][gNB_id];
-  fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15 = &pdcch_vars->pdcch_config[n_ss];
+  fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15 = &phy_pdcch_config->pdcch_config[n_ss];
 
   start_meas(&ue->dlsch_rx_pdcch_stats);
 
+  /// PDCCH/DCI e-sequence (input to rate matching).
+  int32_t pdcch_e_rx_size = NR_MAX_PDCCH_SIZE;
+  int16_t pdcch_e_rx[pdcch_e_rx_size];
+
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RX_PDCCH, VCD_FUNCTION_IN);
-  nr_rx_pdcch(ue, proc, rel15);
+  nr_rx_pdcch(ue, proc, pdcch_est_size, pdcch_dl_ch_estimates, pdcch_e_rx, rel15);
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RX_PDCCH, VCD_FUNCTION_OUT);
   
 
@@ -511,7 +520,7 @@ int nr_ue_pdcch_procedures(uint8_t gNB_id,
 	 n_ss);
 #endif
 
-  dci_cnt = nr_dci_decoding_procedure(ue, proc, dci_ind, rel15);
+  dci_cnt = nr_dci_decoding_procedure(ue, proc, pdcch_e_rx, dci_ind, rel15, phy_pdcch_config);
 
 #ifdef NR_PDCCH_SCHED_DEBUG
   LOG_I(PHY,"<-NR_PDCCH_PHY_PROCEDURES_LTE_UE (nr_ue_pdcch_procedures)-> Ending function nr_dci_decoding_procedure() -> dci_cnt=%u\n",dci_cnt);
@@ -531,11 +540,13 @@ int nr_ue_pdcch_procedures(uint8_t gNB_id,
   ue->pdcch_vars[proc->thread_id][gNB_id]->dci_received += dci_cnt;
 
   dci_ind->number_of_dcis = dci_cnt;
+
   // fill dl_indication message
-  nr_fill_dl_indication(&dl_indication, dci_ind, NULL, proc, ue, gNB_id);
+  nr_fill_dl_indication(&dl_indication, dci_ind, NULL, proc, ue, gNB_id, phy_pdcch_config);
   //  send to mac
   ue->if_inst->dl_indication(&dl_indication, NULL);
 
+
   stop_meas(&ue->dlsch_rx_pdcch_stats);
     
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_PDCCH_PROCEDURES, VCD_FUNCTION_OUT);
@@ -800,16 +811,16 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue,
 
     switch (pdsch) {
       case RA_PDSCH:
-        nr_fill_dl_indication(&dl_indication, NULL, rx_ind, proc, ue, gNB_id);
+        nr_fill_dl_indication(&dl_indication, NULL, rx_ind, proc, ue, gNB_id, NULL);
         nr_fill_rx_indication(rx_ind, FAPI_NR_RX_PDU_TYPE_RAR, gNB_id, ue, dlsch0, NULL, number_pdus, proc, NULL);
         ue->UE_mode[gNB_id] = RA_RESPONSE;
         break;
       case PDSCH:
-        nr_fill_dl_indication(&dl_indication, NULL, rx_ind, proc, ue, gNB_id);
+        nr_fill_dl_indication(&dl_indication, NULL, rx_ind, proc, ue, gNB_id, NULL);
         nr_fill_rx_indication(rx_ind, FAPI_NR_RX_PDU_TYPE_DLSCH, gNB_id, ue, dlsch0, NULL, number_pdus, proc, NULL);
         break;
       case SI_PDSCH:
-        nr_fill_dl_indication(&dl_indication, NULL, rx_ind, proc, ue, gNB_id);
+        nr_fill_dl_indication(&dl_indication, NULL, rx_ind, proc, ue, gNB_id, NULL);
         nr_fill_rx_indication(rx_ind, FAPI_NR_RX_PDU_TYPE_SIB, gNB_id, ue, dlsch0, NULL, number_pdus, proc, NULL);
         break;
       default:
@@ -1366,6 +1377,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,
                            UE_nr_rxtx_proc_t *proc,
                            uint8_t gNB_id,
                            uint8_t dlsch_parallel,
+                           NR_UE_PDCCH_CONFIG *phy_pdcch_config,
                            notifiedFIFO_t *txFifo
                            )
 {                                         
@@ -1373,10 +1385,9 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,
   int nr_slot_rx = proc->nr_slot_rx;
   int slot_pbch;
   int slot_ssb;
-  NR_UE_PDCCH *pdcch_vars  = ue->pdcch_vars[proc->thread_id][0];
   fapi_nr_config_request_t *cfg = &ue->nrUE_config;
 
-  uint8_t nb_symb_pdcch = pdcch_vars->nb_search_space > 0 ? pdcch_vars->pdcch_config[0].coreset.duration : 0;
+  uint8_t nb_symb_pdcch = phy_pdcch_config->nb_search_space > 0 ? phy_pdcch_config->pdcch_config[0].coreset.duration : 0;
   uint8_t dci_cnt = 0;
   NR_DL_FRAME_PARMS *fp = &ue->frame_parms;
   
@@ -1395,8 +1406,8 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,
   int coreset_nb_rb=0;
   int coreset_start_rb=0;
 
-  if (pdcch_vars->nb_search_space > 0)
-    get_coreset_rballoc(pdcch_vars->pdcch_config[0].coreset.frequency_domain_resource,&coreset_nb_rb,&coreset_start_rb);
+  if (phy_pdcch_config->nb_search_space > 0)
+    get_coreset_rballoc(phy_pdcch_config->pdcch_config[0].coreset.frequency_domain_resource,&coreset_nb_rb,&coreset_start_rb);
 
   slot_pbch = is_pbch_in_slot(cfg, frame_rx, nr_slot_rx, fp);
   slot_ssb  = is_ssb_in_slot(cfg, frame_rx, nr_slot_rx, fp);
@@ -1427,7 +1438,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,
     if ((ue->decode_MIB == 1) && slot_pbch) {
 
       LOG_D(PHY," ------  Decode MIB: frame.slot %d.%d ------  \n", frame_rx%1024, nr_slot_rx);
-      nr_ue_pbch_procedures(gNB_id, ue, proc, estimateSz, dl_ch_estimates);
+      nr_ue_pbch_procedures(gNB_id, ue, proc, estimateSz, dl_ch_estimates, phy_pdcch_config);
 
       if (ue->no_timing_correction==0) {
         LOG_D(PHY,"start adjust sync slot = %d no timing %d\n", nr_slot_rx, ue->no_timing_correction);
@@ -1468,13 +1479,17 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,
                 nr_slot_rx);
   }
 
+    // Hold the channel estimates in frequency domain.
+  int32_t pdcch_est_size = ((((fp->symbols_per_slot*(fp->ofdm_symbol_size+LTE_CE_FILTER_LENGTH))+15)/16)*16);
+  __attribute__ ((aligned(16))) int32_t pdcch_dl_ch_estimates[4*fp->nb_antennas_rx][pdcch_est_size];
+
   dci_cnt = 0;
-  for(int n_ss = 0; n_ss<pdcch_vars->nb_search_space; n_ss++) {
+  for(int n_ss = 0; n_ss<phy_pdcch_config->nb_search_space; n_ss++) {
     for (uint16_t l=0; l<nb_symb_pdcch; l++) {
 
       // note: this only works if RBs for PDCCH are contigous!
       LOG_D(PHY, "pdcch_channel_estimation: first_carrier_offset %d, BWPStart %d, coreset_start_rb %d, coreset_nb_rb %d\n",
-            fp->first_carrier_offset, pdcch_vars->pdcch_config[n_ss].BWPStart, coreset_start_rb, coreset_nb_rb);
+            fp->first_carrier_offset, phy_pdcch_config->pdcch_config[n_ss].BWPStart, coreset_start_rb, coreset_nb_rb);
 
       if (coreset_nb_rb > 0)
         nr_pdcch_channel_estimation(ue,
@@ -1482,14 +1497,16 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,
                                     gNB_id,
                                     nr_slot_rx,
                                     l,
-                                    pdcch_vars->pdcch_config[n_ss].coreset.pdcch_dmrs_scrambling_id,
-                                    fp->first_carrier_offset+(pdcch_vars->pdcch_config[n_ss].BWPStart + coreset_start_rb)*12,
-                                    coreset_nb_rb);
+                                    phy_pdcch_config->pdcch_config[n_ss].coreset.pdcch_dmrs_scrambling_id,
+                                    fp->first_carrier_offset+(phy_pdcch_config->pdcch_config[n_ss].BWPStart + coreset_start_rb)*12,
+                                    coreset_nb_rb,
+                                    pdcch_est_size,
+                                    pdcch_dl_ch_estimates);
 
       stop_meas(&ue->ofdm_demod_stats);
 
     }
-    dci_cnt = dci_cnt + nr_ue_pdcch_procedures(gNB_id, ue, proc, n_ss);
+    dci_cnt = dci_cnt + nr_ue_pdcch_procedures(gNB_id, ue, proc, pdcch_est_size, pdcch_dl_ch_estimates, phy_pdcch_config, n_ss);
   }
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP_PDCCH, VCD_FUNCTION_OUT);
 
diff --git a/openair1/SCHED_UE/phy_procedures_lte_ue.c b/openair1/SCHED_UE/phy_procedures_lte_ue.c
index b02f24e04eafcd5e77e64fd3e38f1433dfc060cf..aa0ff0db80fe9506d796f9f927464e11add22a38 100644
--- a/openair1/SCHED_UE/phy_procedures_lte_ue.c
+++ b/openair1/SCHED_UE/phy_procedures_lte_ue.c
@@ -574,7 +574,7 @@ void get_cqipmiri_params(PHY_VARS_UE *ue,
   }
 }
 
-PUCCH_FMT_t get_pucch_format(lte_frame_type_t frame_type,
+PUCCH_FMT_t get_pucch_format(frame_type_t frame_type,
                              lte_prefix_type_t cyclic_prefix_type,
                              uint8_t SR_payload,
                              uint8_t nb_cw,
@@ -4870,109 +4870,3 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,
   LOG_D(PHY," ****** end RX-Chain  for AbsSubframe %d.%d ******  \n", frame_rx%1024, subframe_rx);
   return (0);
 }
-
-
-void phy_procedures_UE_lte(PHY_VARS_UE *ue,
-                           UE_rxtx_proc_t *proc,
-                           uint8_t eNB_id,
-                           uint8_t abstraction_flag,
-                           uint8_t do_pdcch_flag,
-                           runmode_t mode) {
-  MessageDef   *msg_p;
-  int           result;
-  int           frame_rx = proc->frame_rx;
-  int           frame_tx = proc->frame_tx;
-  int           subframe_rx = proc->subframe_rx;
-  int           subframe_tx = proc->subframe_tx;
-  UE_L2_STATE_t ret;
-  int slot;
-
-  if (ue->mac_enabled == 0) {
-    ue->UE_mode[eNB_id]=PUSCH;
-  }
-
-  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_LTE,1);
-
-  if ( LOG_DEBUGFLAG(UE_TIMING)) {
-    start_meas(&ue->phy_proc[ue->current_thread_id[subframe_rx]]);
-  }
-  do {
-    // Checks if a message has been sent to PHY sub-task
-    itti_poll_msg (TASK_PHY_UE, &msg_p);
-
-    if (msg_p != NULL) {
-      switch (ITTI_MSG_ID(msg_p)) {
-        case PHY_FIND_CELL_REQ:
-          LOG_I(PHY, "[UE ] Received %s\n", ITTI_MSG_NAME (msg_p));
-          /* TODO process the message */
-          break;
-
-        default:
-          LOG_E(PHY, "[UE %ld] Received unexpected message %s\n", ITTI_MSG_DESTINATION_INSTANCE (msg_p), ITTI_MSG_NAME (msg_p));
-          break;
-      }
-
-      result = itti_free (ITTI_MSG_ORIGIN_ID(msg_p), msg_p);
-      AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result);
-    }
-  } while(msg_p != NULL);
-
-  for (slot=0; slot<2; slot++) {
-    if ((subframe_select(&ue->frame_parms,subframe_tx)==SF_UL)||
-        (ue->frame_parms.frame_type == FDD)) {
-      phy_procedures_UE_TX(ue,proc,eNB_id,abstraction_flag,mode);
-    }
-
-    if ((subframe_select(&ue->frame_parms,subframe_rx)==SF_DL) ||
-        (ue->frame_parms.frame_type == FDD)) {
-      phy_procedures_UE_RX(ue,proc,eNB_id,abstraction_flag,do_pdcch_flag,mode);
-    }
-
-    if ((subframe_select(&ue->frame_parms,subframe_tx)==SF_S) &&
-        (slot==1)) {
-      phy_procedures_UE_S_TX(ue,eNB_id,abstraction_flag);
-    }
-
-    if ((subframe_select(&ue->frame_parms,subframe_rx)==SF_S) &&
-        (slot==0)) {
-      phy_procedures_UE_RX(ue,proc,eNB_id,abstraction_flag,do_pdcch_flag,mode);
-    }
-
-    if (ue->mac_enabled==1) {
-      if (slot==0) {
-        //LOG_I(PHY,"[UE %d] Frame %d, subframe %d, star ue_scheduler\n", ue->Mod_id,frame_rx,subframe_tx);
-        ret = ue_scheduler(ue->Mod_id,
-                           frame_rx,
-                           subframe_rx,
-                           frame_tx,
-                           subframe_tx,
-                           subframe_select(&ue->frame_parms,subframe_tx),
-                           eNB_id,
-                           0/*FIXME CC_id*/);
-
-        if (ret == CONNECTION_LOST) {
-          LOG_E(PHY,"[UE %d] Frame %d, subframe %d RRC Connection lost, returning to PRACH\n",ue->Mod_id,
-                frame_rx,subframe_tx);
-          ue->UE_mode[eNB_id] = PRACH;
-          //      mac_xface->macphy_exit("Connection lost");
-        } else if (ret == PHY_RESYNCH) {
-          LOG_E(PHY,"[UE %d] Frame %d, subframe %d RRC Connection lost, trying to resynch\n",
-                ue->Mod_id,
-                frame_rx,subframe_tx);
-          ue->UE_mode[eNB_id] = RESYNCH;
-          //     mac_xface->macphy_exit("Connection lost");
-        } else if (ret == PHY_HO_PRACH) {
-          LOG_I(PHY,"[UE %d] Frame %d, subframe %d, return to PRACH and perform a contention-free access\n",
-                ue->Mod_id,frame_rx,subframe_tx);
-          ue->UE_mode[eNB_id] = PRACH;
-        }
-      }
-    }
-
-    VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_LTE,0);
-
-    if (LOG_DEBUGFLAG(UE_TIMING)) {
-      stop_meas(&ue->phy_proc[ue->current_thread_id[subframe_rx]]);
-    }
-  } // slot
-}
diff --git a/openair1/SCHED_UE/sched_UE.h b/openair1/SCHED_UE/sched_UE.h
index 32702b114893329bf0db88291e2df50be8661a34..0dbb77963026ed905922d2568b4dfbc448ca05c0 100644
--- a/openair1/SCHED_UE/sched_UE.h
+++ b/openair1/SCHED_UE/sched_UE.h
@@ -278,7 +278,7 @@ void dump_dlsch2(PHY_VARS_UE *phy_vars_ue,uint8_t eNB_id,uint8_t subframe, unsig
 
 int is_srs_occasion_common(LTE_DL_FRAME_PARMS *frame_parms,int frame_tx,int subframe_tx);
 
-void compute_srs_pos(lte_frame_type_t frameType,uint16_t isrs,uint16_t *psrsPeriodicity,uint16_t *psrsOffset);
+void compute_srs_pos(frame_type_t frameType,uint16_t isrs,uint16_t *psrsPeriodicity,uint16_t *psrsOffset);
 
 /*@}*/
 
diff --git a/openair1/SIMULATION/LTE_PHY/pdcchsim.c b/openair1/SIMULATION/LTE_PHY/pdcchsim.c
index bd2c2d66b9653f7daa9f71985df875c5f7cd0dc4..50910290c391fb979c193d3989dc95240331fa67 100644
--- a/openair1/SIMULATION/LTE_PHY/pdcchsim.c
+++ b/openair1/SIMULATION/LTE_PHY/pdcchsim.c
@@ -415,7 +415,7 @@ int main(int argc, char **argv) {
   uint8_t harq_pid;
   uint8_t phich_ACK;
   uint8_t num_phich_interf = 0;
-  lte_frame_type_t frame_type=TDD;
+  frame_type_t frame_type=TDD;
   //  int re_offset;
   //  uint32_t *txptr;
   int aarx;
diff --git a/openair1/SIMULATION/NR_PHY/dlschsim.c b/openair1/SIMULATION/NR_PHY/dlschsim.c
index 520c2deebd072bb7ab866b34c9924083361a095c..5e134bab6c82c8653c907375772d6e19851de45b 100644
--- a/openair1/SIMULATION/NR_PHY/dlschsim.c
+++ b/openair1/SIMULATION/NR_PHY/dlschsim.c
@@ -477,14 +477,11 @@ int main(int argc, char **argv)
 	harq_process->n_dmrs_cdm_groups = 1;
 	printf("harq process ue mcs = %d Qm = %d, symb %d\n", harq_process->mcs, harq_process->Qm, nb_symb_sch);
 
-	unsigned char *test_input;
-	test_input = (unsigned char *) malloc16(sizeof(unsigned char) * TBS / 8);
+	unsigned char *test_input=dlsch->harq_process.pdu;
 	//unsigned char test_input[TBS / 8]  __attribute__ ((aligned(16)));
 	for (i = 0; i < TBS / 8; i++)
 		test_input[i] = (unsigned char) rand();
 
-	//estimated_output = harq_process->b;
-
 #ifdef DEBUG_NR_DLSCHSIM
 	for (i = 0; i < TBS / 8; i++) printf("test_input[i]=%hhu \n",test_input[i]);
 #endif
@@ -497,7 +494,7 @@ int main(int argc, char **argv)
         unsigned char output[rel15->rbSize * NR_SYMBOLS_PER_SLOT * NR_NB_SC_PER_RB * 8 * NR_MAX_NB_LAYERS] __attribute__((aligned(32)));
         bzero(output,rel15->rbSize * NR_SYMBOLS_PER_SLOT * NR_NB_SC_PER_RB * 8 * NR_MAX_NB_LAYERS);
 	if (input_fd == NULL) {
-	  nr_dlsch_encoding(gNB, test_input, frame, slot, dlsch, frame_parms,output,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
+	  nr_dlsch_encoding(gNB, frame, slot, &dlsch->harq_process, frame_parms,output,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
 	}
 
 	for (SNR = snr0; SNR < snr1; SNR += snr_step) {
@@ -617,8 +614,6 @@ int main(int argc, char **argv)
 	 }
 	 }*/
 
-  free(test_input);
-
   free_channel_desc_scm(gNB2UE);
 
   reset_DLSCH_struct(gNB, &msgDataTx);
diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c
index 412ab1a6eaec23b245ac8de7fc6f6b23307f5523..00262149c9e8486f1dc606c4a1fc9ba905a45dd4 100644
--- a/openair1/SIMULATION/NR_PHY/dlsim.c
+++ b/openair1/SIMULATION/NR_PHY/dlsim.c
@@ -1003,6 +1003,8 @@ int main(int argc, char **argv)
 
   nr_dcireq_t dcireq;
   nr_scheduled_response_t scheduled_response;
+  NR_UE_PDCCH_CONFIG phy_pdcch_config={0};
+
   memset((void*)&dcireq,0,sizeof(dcireq));
   memset((void*)&scheduled_response,0,sizeof(scheduled_response));
   dcireq.module_id = 0;
@@ -1017,6 +1019,7 @@ int main(int argc, char **argv)
   scheduled_response.frame = frame;
   scheduled_response.slot  = slot;
   scheduled_response.thread_id = 0;
+  scheduled_response.phy_data = &phy_pdcch_config;
 
   nr_ue_phy_config_request(&UE_mac->phy_config);
   //NR_COMMON_channels_t *cc = RC.nrmac[0]->common_channels;
@@ -1086,7 +1089,7 @@ int main(int argc, char **argv)
       
       UE_harq_process->ack = 0;
       round = 0;
-      UE_harq_process->round = round;
+      UE_harq_process->DLround = round;
       UE_harq_process->first_rx = 1;
         
       while ((round<num_rounds) && (UE_harq_process->ack==0)) {
@@ -1259,6 +1262,7 @@ int main(int argc, char **argv)
                                &UE_proc,
                                0,
                                dlsch_threads,
+                               &phy_pdcch_config,
                                NULL);
         
         //printf("dlsim round %d ends\n",round);
@@ -1407,8 +1411,6 @@ int main(int argc, char **argv)
       LOG_M("chestF0.m","chF0",&UE->pdsch_vars[0][0]->dl_ch_estimates_ext[0][0],g_rbSize*12*14,1,1);
       write_output("rxF_comp.m","rxFc",&UE->pdsch_vars[0][0]->rxdataF_comp0[0][0],N_RB_DL*12*14,1,1);
       LOG_M("rxF_llr.m","rxFllr",UE->pdsch_vars[UE_proc.thread_id][0]->llr[0],available_bits,1,0);
-      LOG_M("pdcch_rxFcomp.m","pdcch_rxFcomp",&UE->pdcch_vars[0][0]->rxdataF_comp[0][0],96*12,1,1);
-      LOG_M("pdcch_rxFllr.m","pdcch_rxFllr",UE->pdcch_vars[0][0]->llr,96*12,1,1);
       break;
     }
 
diff --git a/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c b/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c
index 351c2f33c47a74a94e8276201289767a47b67973..2d1fc597557518e993d84c2d83636c37457b01c1 100644
--- a/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c
+++ b/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c
@@ -28,7 +28,8 @@ void nr_fill_dl_indication(nr_downlink_indication_t *dl_ind,
                            fapi_nr_rx_indication_t *rx_ind,
                            UE_nr_rxtx_proc_t *proc,
                            PHY_VARS_NR_UE *ue,
-                           uint8_t gNB_id) {}
+                           uint8_t gNB_id,
+                           void *phy_data) {}
 void nr_fill_rx_indication(fapi_nr_rx_indication_t *rx_ind,
                            uint8_t pdu_type,
                            uint8_t gNB_id,
diff --git a/openair1/SIMULATION/NR_PHY/pbchsim.c b/openair1/SIMULATION/NR_PHY/pbchsim.c
index 8fc6410538a25f57c55fc6b70cb60dc1c065fd13..62f6b21528e81082024a49f68e718cad646c7057 100644
--- a/openair1/SIMULATION/NR_PHY/pbchsim.c
+++ b/openair1/SIMULATION/NR_PHY/pbchsim.c
@@ -74,7 +74,10 @@ void init_downlink_harq_status(NR_DL_UE_HARQ_t *dl_harq) {}
 int nr_ue_pdcch_procedures(uint8_t gNB_id,
 			   PHY_VARS_NR_UE *ue,
 			   UE_nr_rxtx_proc_t *proc,
-                           int n_ss) {
+         int32_t pdcch_est_size,
+         int32_t pdcch_dl_ch_estimates[][pdcch_est_size],
+         NR_UE_PDCCH_CONFIG *phy_pdcch_config,
+         int n_ss) {
   return 0;
 }
 
@@ -722,6 +725,8 @@ int main(int argc, char **argv)
       }
       else {
 	UE_nr_rxtx_proc_t proc={0};
+  NR_UE_PDCCH_CONFIG phy_pdcch_config={0};
+
 	UE->rx_offset=0;
 	uint8_t ssb_index = 0;
 	const int estimateSz=7*2*sizeof(int)*frame_parms->ofdm_symbol_size;
@@ -750,7 +755,8 @@ int main(int argc, char **argv)
                          0,
                          ssb_index%8,
                          SISO,
-			 &result);
+                         &phy_pdcch_config,
+                         &result);
 
 	if (ret==0) {
 	  //UE->rx_ind.rx_indication_body->mib_pdu.ssb_index;  //not yet detected automatically
diff --git a/openair1/SIMULATION/NR_PHY/pucchsim.c b/openair1/SIMULATION/NR_PHY/pucchsim.c
index 151d51d7267c77a944f7f3bc1c00a9051130fa51..b6dc3d8f11e8e804d4094e6d7074f511d1af9278 100644
--- a/openair1/SIMULATION/NR_PHY/pucchsim.c
+++ b/openair1/SIMULATION/NR_PHY/pucchsim.c
@@ -551,7 +551,7 @@ int main(int argc, char **argv)
 
       if (n_trials==1) printf("txlev %d (%f dB), offset %d, sigma2 %f ( %f dB)\n",txlev,10*log10(txlev),startingSymbolIndex*frame_parms->ofdm_symbol_size,sigma2,sigma2_dB);
 
-      struct complex16 **rxdataF =  (struct complex16 **)gNB->common_vars.rxdataF;
+      c16_t **rxdataF =  (struct complex16 **)gNB->common_vars.rxdataF;
       for (int symb=0; symb<gNB->frame_parms.symbols_per_slot;symb++) {
         if (symb<startingSymbolIndex || symb >= startingSymbolIndex+nrofSymbols) {
           int i0 = symb*gNB->frame_parms.ofdm_symbol_size;
diff --git a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/frame_config_test.c b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/frame_config_test.c
index c88c261667de88bf56aebb288a4090029e42d84d..093bb2d0006c6a7bd5f1d0a41adafe9e63a210a9 100644
--- a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/frame_config_test.c
+++ b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/frame_config_test.c
@@ -285,7 +285,7 @@ int main(int argc, char *argv[])
   uint8_t nb_antennas_tx = 1;
   uint8_t nb_antennas_rx = 1;
   uint8_t frame_type = FDD;
-  uint8_t N_RB_DL=100;
+  int N_RB_DL=100;
   lte_prefix_type_t extended_prefix_flag = NORMAL;
   int Nid_cell[] = {(3*0+0)};
   VOID_PARAMETER argc;
diff --git a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/harq_test.c b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/harq_test.c
index 05170e0bc96feca3a5f67753d97b478988f1dd6a..96d7382f2b86cd08a4bd7b7fa48dcd608740d5fa 100644
--- a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/harq_test.c
+++ b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/harq_test.c
@@ -200,7 +200,7 @@ int main(int argc, char *argv[])
   uint8_t nb_antennas_tx = 1;
   uint8_t nb_antennas_rx = 1;
   uint8_t frame_type = FDD;
-  uint8_t N_RB_DL=100;
+  int N_RB_DL=100;
   lte_prefix_type_t extended_prefix_flag = NORMAL;
   int Nid_cell[] = {(3*0+0)};
   VOID_PARAMETER argc;
diff --git a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pbch_test.c b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pbch_test.c
index 7600dfb08f0d1987c17014df8c702da973320db2..5c7f3157e7e408ad10656e87e17eb9d62cc920e8 100644
--- a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pbch_test.c
+++ b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pbch_test.c
@@ -379,7 +379,7 @@ int main(int argc, char *argv[])
   uint8_t nb_antennas_tx = 1;
   uint8_t nb_antennas_rx = 1;
   uint8_t frame_type = FDD;
-  uint8_t N_RB_DL=100;
+  int N_RB_DL=100;
   lte_prefix_type_t extended_prefix_flag = NORMAL;
   int decoded_pbch = -1;
   int Nid1, Nid2;
diff --git a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pss_test.c b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pss_test.c
index 2088d558cb24ea60b63363b79c6762bc0d0909ff..de1249457fb2d023c88a209656bbeba671a61d83 100644
--- a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pss_test.c
+++ b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pss_test.c
@@ -184,7 +184,7 @@ int main(int argc, char *argv[])
   uint8_t nb_antennas_rx = 1;
   uint16_t Nid_cell=123;
   uint8_t frame_type=FDD;
-  uint8_t N_RB_DL=100;
+  int N_RB_DL=100;
   lte_prefix_type_t extended_prefix_flag=NORMAL;
   const char *name_test = "PSS NR";
   test_t test = { name_test, 0, 0, 0, 0};
diff --git a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pss_util_test.c b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pss_util_test.c
index 4334bd12f9d9f7adbfaa8a3fa0fa8c6f829848f6..2302c50ab190149c16be4ea5d0ff8452a8941086 100644
--- a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pss_util_test.c
+++ b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pss_util_test.c
@@ -206,7 +206,7 @@ void undefined_function(const char *function) {
 *********************************************************************/
 
 int init_test(unsigned char N_tx, unsigned char N_rx, unsigned char transmission_mode,
-              unsigned char extended_prefix_flag, uint8_t frame_type, uint16_t Nid_cell, uint8_t N_RB_DL) {
+              unsigned char extended_prefix_flag, uint8_t frame_type, uint16_t Nid_cell, int N_RB_DL) {
   (void) transmission_mode;
   NR_DL_FRAME_PARMS *frame_parms;
   int log_level = OAILOG_TRACE;
diff --git a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pss_util_test.h b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pss_util_test.h
index f0929e88c088dc12b77d99bbdf82d417c94c2779..78efc2234b6bba1ac48210b1e7838024ade28a8e 100644
--- a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pss_util_test.h
+++ b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pss_util_test.h
@@ -90,7 +90,7 @@ int set_pss_in_rx_buffer(PHY_VARS_NR_UE *PHY_vars_UE, int position_symbol, int p
 
 int init_test(unsigned char N_tx, unsigned char N_rx, unsigned char transmission_mode,
                       unsigned char extended_prefix_flag, uint8_t frame_type, uint16_t Nid_cell,
-                      uint8_t N_RB_DL);
+                      int N_RB_DL);
 
 void display_test_configuration_pss(int position, int pss_sequence_number);
 
diff --git a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pucch_uci_generator_test.c b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pucch_uci_generator_test.c
index 68acea6d9801d2b9446c8c5312c5be824f97533d..4948d0a876edc3bf2f8dd57df9251aca083bef49 100644
--- a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pucch_uci_generator_test.c
+++ b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pucch_uci_generator_test.c
@@ -142,7 +142,7 @@ int main(int argc, char *argv[]) {
   uint8_t nb_antennas_tx = 1;
   uint8_t nb_antennas_rx = 1;
   uint8_t frame_type = FDD;
-  uint8_t N_RB_DL=106;
+  int N_RB_DL=106;
   lte_prefix_type_t extended_prefix_flag = NORMAL;
   int Nid_cell[] = {(3*1+3)};
   VOID_PARAMETER argc;
diff --git a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pucch_uci_test.c b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pucch_uci_test.c
index f731edc20acab668fd873b0bcef8356306b578db..31fe15a6de8ed377a4da95aaa50b82d7d8fa2f8a 100644
--- a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pucch_uci_test.c
+++ b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pucch_uci_test.c
@@ -1239,7 +1239,7 @@ int main(int argc, char *argv[])
   uint8_t nb_antennas_tx = 1;
   uint8_t nb_antennas_rx = 1;
   uint8_t frame_type = FDD;
-  uint8_t N_RB_DL=100;
+  int N_RB_DL=100;
   lte_prefix_type_t extended_prefix_flag = NORMAL;
   int Nid_cell[] = {(3*1+3)};
   VOID_PARAMETER argc;
diff --git a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/srs_test.c b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/srs_test.c
index 34ea68bc61f1ddb6d353a02a665254dbc5d7f292..235387acf7eeb043fcc8ea74de566224b9eb27fd 100644
--- a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/srs_test.c
+++ b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/srs_test.c
@@ -442,7 +442,7 @@ int main(int argc, char *argv[])
   uint8_t nb_antennas_tx = 1;
   uint8_t nb_antennas_rx = 1;
   uint8_t frame_type = FDD;
-  uint8_t N_RB_DL=100;
+  int N_RB_DL=100;
   lte_prefix_type_t extended_prefix_flag = NORMAL;
   int Nid_cell[] = {(3*0+0)};
   VOID_PARAMETER argc;
diff --git a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/sss_test.c b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/sss_test.c
index 34127b604f8488b0f0e9da4b8b1c528de6df59cc..6f6594861a768da70325e9caf1f0622d24039838 100644
--- a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/sss_test.c
+++ b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/sss_test.c
@@ -181,7 +181,7 @@ int main(int argc, char *argv[])
   uint8_t nb_antennas_tx = 1;
   uint8_t nb_antennas_rx = 1;
   uint8_t frame_type = FDD;
-  uint8_t N_RB_DL=100;
+  int N_RB_DL=100;
   lte_prefix_type_t extended_prefix_flag = NORMAL;
   int phase;
   int Nid1, Nid2;
diff --git a/openair2/COMMON/m2ap_messages_types.h b/openair2/COMMON/m2ap_messages_types.h
index c70c50fc642517e5e7f7bf095d41f5c6a1256744..460dbfc4bb1b7d360b1bdfc856209528e2092944 100644
--- a/openair2/COMMON/m2ap_messages_types.h
+++ b/openair2/COMMON/m2ap_messages_types.h
@@ -354,7 +354,7 @@ typedef struct m2ap_register_mce_req_s {
   int32_t                 uplink_frequency_offset[MAX_NUM_CCs];
   uint32_t                Nid_cell[MAX_NUM_CCs];
   int16_t                 N_RB_DL[MAX_NUM_CCs];
-  lte_frame_type_t        frame_type[MAX_NUM_CCs];
+  frame_type_t        frame_type[MAX_NUM_CCs];
   uint32_t                fdd_earfcn_DL[MAX_NUM_CCs];
   uint32_t                fdd_earfcn_UL[MAX_NUM_CCs];
   int                     num_cc;
@@ -427,7 +427,7 @@ typedef struct m2ap_register_enb_req_s {
   int32_t                 uplink_frequency_offset[MAX_NUM_CCs];
   uint32_t                Nid_cell[MAX_NUM_CCs];
   int16_t                 N_RB_DL[MAX_NUM_CCs];
-  lte_frame_type_t        frame_type[MAX_NUM_CCs];
+  frame_type_t            frame_type[MAX_NUM_CCs];
   uint32_t                fdd_earfcn_DL[MAX_NUM_CCs];
   uint32_t                fdd_earfcn_UL[MAX_NUM_CCs];
   int                     num_cc;
diff --git a/openair2/COMMON/m3ap_messages_types.h b/openair2/COMMON/m3ap_messages_types.h
index 21e24dd449c1403386c9af38b93f8e763c875d50..36ac8fcc9ae6970e2303f8cf8b6de2964d415ccd 100644
--- a/openair2/COMMON/m3ap_messages_types.h
+++ b/openair2/COMMON/m3ap_messages_types.h
@@ -123,7 +123,7 @@ typedef struct m3ap_register_mce_req_s {
   int32_t                 uplink_frequency_offset[MAX_NUM_CCs];
   uint32_t                Nid_cell[MAX_NUM_CCs];
   int16_t                 N_RB_DL[MAX_NUM_CCs];
-  lte_frame_type_t        frame_type[MAX_NUM_CCs];
+  frame_type_t            frame_type[MAX_NUM_CCs];
   uint32_t                fdd_earfcn_DL[MAX_NUM_CCs];
   uint32_t                fdd_earfcn_UL[MAX_NUM_CCs];
   int                     num_cc;
diff --git a/openair2/COMMON/phy_messages_types.h b/openair2/COMMON/phy_messages_types.h
index 1f040a0a773e00163df53a660af70c799629f5d2..40e467822866291524343e68e6a616183604b7ec 100644
--- a/openair2/COMMON/phy_messages_types.h
+++ b/openair2/COMMON/phy_messages_types.h
@@ -70,7 +70,7 @@ typedef struct CellInfo_s {
 //-------------------------------------------------------------------------------------------//
 // eNB: ENB_APP -> PHY messages
 typedef struct PhyConfigurationReq_s {
-  lte_frame_type_t        frame_type[MAX_NUM_CCs];
+  frame_type_t            frame_type[MAX_NUM_CCs];
   lte_prefix_type_t       prefix_type[MAX_NUM_CCs];
   uint32_t                downlink_frequency[MAX_NUM_CCs];
   int32_t                 uplink_frequency_offset[MAX_NUM_CCs];
diff --git a/openair2/COMMON/rrc_messages_types.h b/openair2/COMMON/rrc_messages_types.h
index ac70dee0928f4d9586495938d6f50d375adf6cf5..5b214cf95a9ce515f04da6ec91e235be43b3711a 100644
--- a/openair2/COMMON/rrc_messages_types.h
+++ b/openair2/COMMON/rrc_messages_types.h
@@ -188,7 +188,7 @@ typedef struct RrcConfigurationReq_s {
   uint32_t                rrc_inactivity_timer_thres; // for testing, maybe change later
   paging_drx_t            default_drx;
   int16_t                 nb_cc;
-  lte_frame_type_t        frame_type[MAX_NUM_CCs];
+  frame_type_t            frame_type[MAX_NUM_CCs];
   uint8_t                 tdd_config[MAX_NUM_CCs];
   uint8_t                 tdd_config_s[MAX_NUM_CCs];
   lte_prefix_type_t       prefix_type[MAX_NUM_CCs];
@@ -339,7 +339,7 @@ typedef struct NbIoTRrcConfigurationReq_s {
   uint16_t                mcc;
   uint16_t                mnc;
   uint8_t                 mnc_digit_length;
-  lte_frame_type_t        frame_type;
+  frame_type_t            frame_type;
   uint8_t                 tdd_config;
   uint8_t                 tdd_config_s;
   lte_prefix_type_t       prefix_type;
diff --git a/openair2/COMMON/x2ap_messages_types.h b/openair2/COMMON/x2ap_messages_types.h
index 9339ab12f38fd4b842cc0e0aad8b9c6e9afdeefb..cd092b6ca8987652aa2d31f0bcc95fda44a6488d 100644
--- a/openair2/COMMON/x2ap_messages_types.h
+++ b/openair2/COMMON/x2ap_messages_types.h
@@ -138,7 +138,7 @@ typedef struct x2ap_register_enb_req_s {
   int32_t                 uplink_frequency_offset[MAX_NUM_CCs];
   uint32_t                Nid_cell[MAX_NUM_CCs];
   int16_t                 N_RB_DL[MAX_NUM_CCs];
-  lte_frame_type_t        frame_type[MAX_NUM_CCs];
+  frame_type_t            frame_type[MAX_NUM_CCs];
   uint32_t                fdd_earfcn_DL[MAX_NUM_CCs];
   uint32_t                fdd_earfcn_UL[MAX_NUM_CCs];
   uint32_t                subframeAssignment[MAX_NUM_CCs];
diff --git a/openair2/ENB_APP/RRC_config_tools.h b/openair2/ENB_APP/RRC_config_tools.h
index 488441ff59f8cd68c258645cb5a9cddc3eeec9bd..89cefeaa1fd1201172f950a47200d0388f639e15 100644
--- a/openair2/ENB_APP/RRC_config_tools.h
+++ b/openair2/ENB_APP/RRC_config_tools.h
@@ -38,7 +38,7 @@ typedef struct eutra_band_s {
   uint32_t            ul_max;
   uint32_t            dl_min;
   uint32_t            dl_max;
-  lte_frame_type_t    frame_type;
+  frame_type_t        frame_type;
 } eutra_band_t;
 
 
diff --git a/openair2/ENB_APP/flexran_agent_ran_api.c b/openair2/ENB_APP/flexran_agent_ran_api.c
index 68d1f3311f261ab38f45250c35371b5f53d8cd39..9926ec9e20639d356b5e1ccdc6cf13b0a5cf83a4 100644
--- a/openair2/ENB_APP/flexran_agent_ran_api.c
+++ b/openair2/ENB_APP/flexran_agent_ran_api.c
@@ -1352,7 +1352,7 @@ void flexran_agent_set_operating_bandwidth(mid_t mod_id, uint8_t cc_id, uint8_t
   }
 }
 
-void flexran_agent_set_operating_frame_type(mid_t mod_id, uint8_t cc_id, lte_frame_type_t frame_type) {
+void flexran_agent_set_operating_frame_type(mid_t mod_id, uint8_t cc_id, frame_type_t frame_type) {
   if (phy_is_present(mod_id, cc_id)) {
     RC.eNB[mod_id][cc_id]->frame_parms.frame_type = frame_type;
   } else {
diff --git a/openair2/ENB_APP/flexran_agent_ran_api.h b/openair2/ENB_APP/flexran_agent_ran_api.h
index 79115b0a168b0030af938b6291d34a0a2c8ac1bc..c15865ccfd081d7ca4eb9262abc7163b4cd096f9 100644
--- a/openair2/ENB_APP/flexran_agent_ran_api.h
+++ b/openair2/ENB_APP/flexran_agent_ran_api.h
@@ -433,7 +433,7 @@ void flexran_agent_set_operating_eutra_band(mid_t mod_id, uint8_t cc_id, uint8_t
 void flexran_agent_set_operating_bandwidth(mid_t mod_id, uint8_t cc_id, uint8_t N_RB);
 
 /*set frame type*/
-void flexran_agent_set_operating_frame_type(mid_t mod_id, uint8_t cc_id, lte_frame_type_t frame_type);
+void flexran_agent_set_operating_frame_type(mid_t mod_id, uint8_t cc_id, frame_type_t frame_type);
 
 /*RRC status flexRAN*/
 uint8_t flexran_get_rrc_status(mid_t mod_id, rnti_t rnti);
diff --git a/openair2/GNB_APP/gnb_config.c b/openair2/GNB_APP/gnb_config.c
index 434a2896de95e72071931f50d422bdedce49513b..2c486ec83244b86021550429553063d149e604a8 100644
--- a/openair2/GNB_APP/gnb_config.c
+++ b/openair2/GNB_APP/gnb_config.c
@@ -346,7 +346,7 @@ void fix_scc(NR_ServingCellConfigCommon_t *scc,uint64_t ssbmap) {
   // prepare DL Allocation lists
   nr_rrc_config_dl_tda(scc);
 
-  lte_frame_type_t frame_type = get_frame_type((int)*scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0], *scc->ssbSubcarrierSpacing);
+  frame_type_t frame_type = get_frame_type((int)*scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0], *scc->ssbSubcarrierSpacing);
   if (frame_type == FDD) {
     ASN_STRUCT_FREE(asn_DEF_NR_TDD_UL_DL_ConfigCommon, scc->tdd_UL_DL_ConfigurationCommon);
     scc->tdd_UL_DL_ConfigurationCommon = NULL;
diff --git a/openair2/LAYER2/MAC/config.c b/openair2/LAYER2/MAC/config.c
index 209275acb38c69c6351fce0f87ed7fda56589662..d22485d23f261823d8b028c90a46b056273eb9eb 100644
--- a/openair2/LAYER2/MAC/config.c
+++ b/openair2/LAYER2/MAC/config.c
@@ -58,11 +58,6 @@ extern int l2_init_eNB(void);
 extern void mac_top_init_eNB(void);
 extern void mac_init_cell_params(int Mod_idP,int CC_idP);
 
-
-int32_t **rxdata;
-int32_t **txdata;
-
-
 typedef struct eutra_bandentry_s {
   int16_t band;
   uint32_t ul_min;
diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h
index 9dd03ddcf6bdbf708874298260b4c8aae8a55164..9123afd3248bb6f750f2c43ffd66a00f9bab113b 100644
--- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h
+++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h
@@ -107,11 +107,10 @@ typedef struct {
 } __attribute__ ((__packed__)) NR_MAC_SUBHEADER_SHORT;
 
 typedef struct {
-  uint8_t LCID: 6;    // octet 1 [5:0]
-  uint8_t F: 1;       // octet 1 [6]
-  uint8_t R: 1;       // octet 1 [7]
-  uint8_t L1: 8;      // octet 2 [7:0]
-  uint8_t L2: 8;      // octet 3 [7:0]
+  uint8_t LCID: 6;
+  uint8_t F: 1;
+  uint8_t R: 1;
+  uint16_t L: 16;
 } __attribute__ ((__packed__)) NR_MAC_SUBHEADER_LONG;
 
 typedef struct {
@@ -119,6 +118,23 @@ typedef struct {
   uint8_t R: 2;       // octet 1 [7:6]
 } __attribute__ ((__packed__)) NR_MAC_SUBHEADER_FIXED;
 
+static inline int get_mac_len(uint8_t* pdu, int pdu_len, uint16_t *mac_ce_len, uint16_t *mac_subheader_len) {
+  if ( pdu_len < sizeof(NR_MAC_SUBHEADER_SHORT))
+    return false;
+  NR_MAC_SUBHEADER_SHORT *s = (NR_MAC_SUBHEADER_SHORT*) pdu;
+  NR_MAC_SUBHEADER_LONG *l = (NR_MAC_SUBHEADER_LONG*) pdu;
+  if (s->F && pdu_len < sizeof(NR_MAC_SUBHEADER_LONG))
+    return false;
+  if (s->F) {
+    *mac_subheader_len = sizeof(*l);
+    *mac_ce_len = ntohs(l->L);
+  } else {
+    *mac_subheader_len = sizeof(*s);
+    *mac_ce_len = s->L;
+  }
+  return true;
+}
+    
 // BSR MAC CEs
 // TS 38.321 ch. 6.1.3.1
 // Short BSR for a specific logical channel group ID
diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c
index ad0f9c2c38d41357f862e82f473c286dffb89911..5c3138f61f968dd0701a91f2bfbe1d4c26552e39 100644
--- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c
+++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c
@@ -3090,7 +3090,7 @@ int is_nr_DL_slot(NR_TDD_UL_DL_ConfigCommon_t *tdd_UL_DL_ConfigurationCommon,slo
   else return(slot_in_period <= slots1+tdd_UL_DL_ConfigurationCommon->pattern2->nrofDownlinkSlots ? 1 : 0);    
 }
 
-int is_nr_UL_slot(NR_TDD_UL_DL_ConfigCommon_t	*tdd_UL_DL_ConfigurationCommon, slot_t slot, lte_frame_type_t frame_type) {
+int is_nr_UL_slot(NR_TDD_UL_DL_ConfigCommon_t	*tdd_UL_DL_ConfigurationCommon, slot_t slot, frame_type_t frame_type) {
 
   int period,period1,period2=0;
 
diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h
index 56e24792ccf5b8ed4ea59d083b7bc9a71808c3cd..de49f8e71c16ffc615834ae2c46413e85c6af6d8 100644
--- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h
+++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h
@@ -45,7 +45,7 @@ int16_t fill_dmrs_mask(NR_PDSCH_Config_t *pdsch_Config,int dmrs_TypeA_Position,i
 
 int is_nr_DL_slot(NR_TDD_UL_DL_ConfigCommon_t *tdd_UL_DL_ConfigurationCommon,slot_t slotP);
 
-int is_nr_UL_slot(NR_TDD_UL_DL_ConfigCommon_t *tdd_UL_DL_ConfigurationCommon, slot_t slotP, lte_frame_type_t frame_type);
+int is_nr_UL_slot(NR_TDD_UL_DL_ConfigCommon_t *tdd_UL_DL_ConfigurationCommon, slot_t slotP, frame_type_t frame_type);
 
 uint16_t nr_dci_size(const NR_BWP_DownlinkCommon_t *initialDLBWP,
                      const NR_BWP_UplinkCommon_t *initialULBWP,
diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c
index 3b10167e03c33d2f46c070130e91fb204dade024..bd693e4d888d15be8b1ae42d91b76efea1f123b4 100644
--- a/openair2/LAYER2/NR_MAC_UE/config_ue.c
+++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c
@@ -323,7 +323,7 @@ void config_common_ue(NR_UE_MAC_INST_t *mac,
     uint32_t band = *scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0];
     mac->frequency_range = band<100?FR1:FR2;
     
-    lte_frame_type_t frame_type = get_frame_type(*scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0], *scc->ssbSubcarrierSpacing);
+    frame_type_t frame_type = get_frame_type(*scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0], *scc->ssbSubcarrierSpacing);
     
     // cell config
     
diff --git a/openair2/LAYER2/NR_MAC_UE/mac_defs.h b/openair2/LAYER2/NR_MAC_UE/mac_defs.h
index fc2c2d2c8b7d6e4c08da99577f8bf748c0039d0a..99cbdf32927e44e5d2211370296454d4bca87fd0 100644
--- a/openair2/LAYER2/NR_MAC_UE/mac_defs.h
+++ b/openair2/LAYER2/NR_MAC_UE/mac_defs.h
@@ -369,7 +369,7 @@ typedef struct {
   NR_ControlResourceSet_t         *coreset[MAX_NUM_BWP][FAPI_NR_MAX_CORESET_PER_BWP];
   NR_SearchSpace_t                *SSpace[MAX_NUM_BWP][FAPI_NR_MAX_SS];
 
-  lte_frame_type_t frame_type;
+  frame_type_t frame_type;
 
   /*BWP*/
   // dedicated active DL BWP
diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h
index 3e4d53b985be0ae4270287fed9ef0e5d7ec2e4e4..7ed99b92b5131d76740fb7b61b714a4759e05422 100644
--- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h
+++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h
@@ -48,6 +48,7 @@ void nr_ue_init_mac(module_id_t module_idP);
    \param module_id      module id
    \param cc_id          component carrier id
    \param gNB_index      gNB index
+   \param phy_data       PHY structure to be filled in by the callee in the FAPI call (L1 caller -> indication to L2 -> FAPI call to L1 callee)
    \param extra_bits     extra bits for frame calculation
    \param l_ssb_equal_64 check if ssb number of candicate is equal 64, 1=equal; 0=non equal. Reference 38.212 7.1.1
    \param pduP           pointer to pdu
@@ -56,7 +57,8 @@ void nr_ue_init_mac(module_id_t module_idP);
 int8_t nr_ue_decode_mib(
     module_id_t module_id, 
     int cc_id, 
-    uint8_t gNB_index, 
+    uint8_t gNB_index,
+    void *phy_data, 
     uint8_t extra_bits, 
     uint32_t ssb_length, 
     uint32_t ssb_index,
@@ -132,7 +134,7 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in
    @param int cc_id                    CC ID
    @param frame_t frame                frame number
    @param int slot                     reference number
-   @param UE_nr_rxtx_proc_t *proc      pointer to process context */
+   @param void *phy_pata               pointer to a PHY specific structure to be filled in the scheduler response (can be null) */
 void fill_scheduled_response(nr_scheduled_response_t *scheduled_response,
                              fapi_nr_dl_config_request_t *dl_config,
                              fapi_nr_ul_config_request_t *ul_config,
@@ -141,7 +143,8 @@ void fill_scheduled_response(nr_scheduled_response_t *scheduled_response,
                              int cc_id,
                              frame_t frame,
                              int slot,
-                             int thread_id);
+                             int thread_id,
+                             void *phy_data);
 
 /*! \fn int8_t nr_ue_get_SR(module_id_t module_idP, frame_t frameP, slot_t slotP);
    \brief Called by PHY to get sdu for PUSCH transmission.  It performs the following operations: Checks BSR for DCCH, DCCH1 and DTCH corresponding to previous values computed either in SR or BSR procedures.  It gets rlc status indications on DCCH,DCCH1 and DTCH and forms BSR elements and PHR in MAC header.  CRNTI element is not supported yet.  It computes transport block for up to 3 SDUs and generates header and forms the complete MAC SDU.
@@ -373,7 +376,8 @@ void nr_ue_sib1_scheduler(module_id_t module_idP,
                           uint8_t ssb_subcarrier_offset,
                           uint32_t ssb_index,
                           uint16_t ssb_start_subcarrier,
-                          frequency_range_t frequency_range);
+                          frequency_range_t frequency_range,
+                          void *phy_data);
 
 /* \brief Function called by PHY to process the received RAR and check that the preamble matches what was sent by the gNB. It provides the timing advance and t-CRNTI.
 @param Mod_id Index of UE instance
diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c
index eac1cca54b4e351be2d5075ecc4587d08834e154..3f21f03f6fa42aa775072610d778f0ce6af1e66e 100644
--- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c
+++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c
@@ -287,6 +287,7 @@ int get_rnti_type(NR_UE_MAC_INST_t *mac, uint16_t rnti){
 int8_t nr_ue_decode_mib(module_id_t module_id,
                         int cc_id,
                         uint8_t gNB_index,
+                        void *phy_data,
                         uint8_t extra_bits,	//	8bits 38.212 c7.1.1
                         uint32_t ssb_length,
                         uint32_t ssb_index,
@@ -362,7 +363,8 @@ int8_t nr_ue_decode_mib(module_id_t module_id,
                            ssb_subcarrier_offset,
                            ssb_index,
                            ssb_start_subcarrier,
-                           mac->frequency_range);
+                           mac->frequency_range,
+                           phy_data);
   }
   else {
     NR_ServingCellConfigCommon_t *scc = mac->scc;
@@ -2171,6 +2173,7 @@ uint8_t get_downlink_ack(NR_UE_MAC_INST_t *mac,
               pucch->is_common = current_harq->is_common;
               current_harq->active = false;
               current_harq->ack_received = false;
+	      LOG_D(PHY,"%4d.%2d Sent %d ack on harq pid %d\n", frame, slot, current_harq->ack, dl_harq_pid);
             }
           }
         }
@@ -3404,10 +3407,6 @@ void nr_ue_process_mac_pdu(nr_downlink_indication_t *dl_info,
                            NR_UL_TIME_ALIGNMENT_t *ul_time_alignment,
                            int pdu_id){
 
-  uint8_t rx_lcid;
-  uint16_t mac_ce_len;
-  uint16_t mac_subheader_len;
-  uint16_t mac_sdu_len;
   module_id_t module_idP = dl_info->module_id;
   frame_t frameP         = dl_info->frame;
   int slot               = dl_info->slot;
@@ -3426,139 +3425,100 @@ void nr_ue_process_mac_pdu(nr_downlink_indication_t *dl_info,
   LOG_D(MAC, "In %s [%d.%d]: processing PDU %d (with length %d) of %d total number of PDUs...\n", __FUNCTION__, frameP, slot, pdu_id, pdu_len, dl_info->rx_ind->number_pdus);
 
   while (!done && pdu_len > 0){
-    mac_ce_len = 0x0000;
-    mac_subheader_len = 0x0001; //  default to fixed-length subheader = 1-oct
-    mac_sdu_len = 0x0000;
-    rx_lcid = ((NR_MAC_SUBHEADER_FIXED *)pduP)->LCID;
+    uint16_t mac_len = 0x0000;
+    uint16_t mac_subheader_len = 0x0001; //  default to fixed-length subheader = 1-oct
+    uint8_t rx_lcid = ((NR_MAC_SUBHEADER_FIXED *)pduP)->LCID;
 
     LOG_D(MAC, "[UE] LCID %d, PDU length %d\n", rx_lcid, pdu_len);
+    bool ret;
     switch(rx_lcid){
       //  MAC CE
       case DL_SCH_LCID_CCCH:
         //  MSG4 RRC Setup 38.331
         //  variable length
-        if(((NR_MAC_SUBHEADER_SHORT *)pduP)->F){
-          mac_sdu_len = ((uint16_t)(((NR_MAC_SUBHEADER_LONG *) pduP)->L1 & 0x7f) << 8)
-                        | ((uint16_t)((NR_MAC_SUBHEADER_LONG *) pduP)->L2 & 0xff);
-          mac_subheader_len = 3;
-        } else {
-          mac_sdu_len = ((NR_MAC_SUBHEADER_SHORT *) pduP)->L;
-          mac_subheader_len = 2;
-        }
-
-        AssertFatal(pdu_len > mac_sdu_len, "The mac_sdu_len (%d) has an invalid size. PDU len = %d! \n",
-                    mac_sdu_len, pdu_len);
+        ret=get_mac_len(pduP, pdu_len, &mac_len, &mac_subheader_len);
+        AssertFatal(ret, "The mac_len (%d) has an invalid size. PDU len = %d! \n",
+                    mac_len, pdu_len);
 
         // Check if it is a valid CCCH message, we get all 00's messages very often
         int i = 0;
-        for(i=0; i<(mac_subheader_len+mac_sdu_len); i++) {
+        for(i=0; i<(mac_subheader_len+mac_len); i++) {
           if(pduP[i] != 0) {
             break;
           }
         }
-        if (i == (mac_subheader_len+mac_sdu_len)) {
+        if (i == (mac_subheader_len+mac_len)) {
           LOG_D(NR_MAC, "%s() Invalid CCCH message!, pdu_len: %d\n", __func__, pdu_len);
           done = 1;
           break;
         }
 
-        if ( mac_sdu_len > 0 ) {
-          LOG_D(NR_MAC,"DL_SCH_LCID_CCCH (e.g. RRCSetup) with payload len %d\n", mac_sdu_len);
+        if ( mac_len > 0 ) {
+          LOG_D(NR_MAC,"DL_SCH_LCID_CCCH (e.g. RRCSetup) with payload len %d\n", mac_len);
           for (int i = 0; i < mac_subheader_len; i++) {
             LOG_D(NR_MAC, "MAC header %d: 0x%x\n", i, pduP[i]);
           }
-          for (int i = 0; i < mac_sdu_len; i++) {
+          for (int i = 0; i < mac_len; i++) {
             LOG_D(NR_MAC, "%d: 0x%x\n", i, pduP[mac_subheader_len + i]);
           }
-          nr_mac_rrc_data_ind_ue(module_idP, CC_id, gNB_index, frameP, 0, mac->crnti, CCCH, pduP+mac_subheader_len, mac_sdu_len);
+          nr_mac_rrc_data_ind_ue(module_idP, CC_id, gNB_index, frameP, 0, mac->crnti, CCCH, pduP+mac_subheader_len, mac_len);
         }
         break;
       case DL_SCH_LCID_TCI_STATE_ACT_UE_SPEC_PDSCH:
-
-        //  38.321 Ch6.1.3.14
-        //  varialbe length
-        mac_ce_len |= (uint16_t)((NR_MAC_SUBHEADER_SHORT *)pduP)->L;
-        mac_subheader_len = 2;
-        if(((NR_MAC_SUBHEADER_SHORT *)pduP)->F){
-          mac_ce_len |= (uint16_t)(((NR_MAC_SUBHEADER_LONG *)pduP)->L2)<<8;
-          mac_subheader_len = 3;
-        }
-        break;
       case DL_SCH_LCID_APERIODIC_CSI_TRI_STATE_SUBSEL:
-        //  38.321 Ch6.1.3.13
-        //  varialbe length
-        mac_ce_len |= (uint16_t)((NR_MAC_SUBHEADER_SHORT *)pduP)->L;
-        mac_subheader_len = 2;
-        if(((NR_MAC_SUBHEADER_SHORT *)pduP)->F){
-          mac_ce_len |= (uint16_t)(((NR_MAC_SUBHEADER_LONG *)pduP)->L2)<<8;
-          mac_subheader_len = 3;
-        }
-        break;
       case DL_SCH_LCID_SP_CSI_RS_CSI_IM_RES_SET_ACT:
-        //  38.321 Ch6.1.3.12
-        //  varialbe length
-        mac_ce_len |= (uint16_t)((NR_MAC_SUBHEADER_SHORT *)pduP)->L;
-        mac_subheader_len = 2;
-        if(((NR_MAC_SUBHEADER_SHORT *)pduP)->F){
-          mac_ce_len |= (uint16_t)(((NR_MAC_SUBHEADER_LONG *)pduP)->L2)<<8;
-          mac_subheader_len = 3;
-        }
-        break;
       case DL_SCH_LCID_SP_SRS_ACTIVATION:
-        //  38.321 Ch6.1.3.17
+
+        //  38.321 Ch6.1.3.14
         //  varialbe length
-        mac_ce_len |= (uint16_t)((NR_MAC_SUBHEADER_SHORT *)pduP)->L;
-        mac_subheader_len = 2;
-        if(((NR_MAC_SUBHEADER_SHORT *)pduP)->F){
-          mac_ce_len |= (uint16_t)(((NR_MAC_SUBHEADER_LONG *)pduP)->L2)<<8;
-          mac_subheader_len = 3;
-        }
+        get_mac_len(pduP, pdu_len, &mac_len, &mac_subheader_len);
         break;
+
       case DL_SCH_LCID_RECOMMENDED_BITRATE:
         //  38.321 Ch6.1.3.20
-        mac_ce_len = 2;
+        mac_len = 2;
         break;
       case DL_SCH_LCID_SP_ZP_CSI_RS_RES_SET_ACT:
         //  38.321 Ch6.1.3.19
-        mac_ce_len = 2;
+        mac_len = 2;
         break;
       case DL_SCH_LCID_PUCCH_SPATIAL_RELATION_ACT:
         //  38.321 Ch6.1.3.18
-        mac_ce_len = 3;
+        mac_len = 3;
         break;
       case DL_SCH_LCID_SP_CSI_REP_PUCCH_ACT:
         //  38.321 Ch6.1.3.16
-        mac_ce_len = 2;
+        mac_len = 2;
         break;
       case DL_SCH_LCID_TCI_STATE_IND_UE_SPEC_PDCCH:
         //  38.321 Ch6.1.3.15
-        mac_ce_len = 2;
+        mac_len = 2;
         break;
       case DL_SCH_LCID_DUPLICATION_ACT:
         //  38.321 Ch6.1.3.11
-        mac_ce_len = 1;
+        mac_len = 1;
         break;
       case DL_SCH_LCID_SCell_ACT_4_OCT:
         //  38.321 Ch6.1.3.10
-        mac_ce_len = 4;
+        mac_len = 4;
         break;
       case DL_SCH_LCID_SCell_ACT_1_OCT:
         //  38.321 Ch6.1.3.10
-        mac_ce_len = 1;
+        mac_len = 1;
         break;
       case DL_SCH_LCID_L_DRX:
         //  38.321 Ch6.1.3.6
         //  fixed length but not yet specify.
-        mac_ce_len = 0;
+        mac_len = 0;
         break;
       case DL_SCH_LCID_DRX:
         //  38.321 Ch6.1.3.5
         //  fixed length but not yet specify.
-        mac_ce_len = 0;
+        mac_len = 0;
         break;
       case DL_SCH_LCID_TA_COMMAND:
         //  38.321 Ch6.1.3.4
-        mac_ce_len = 1;
+        mac_len = 1;
 
         /*uint8_t ta_command = ((NR_MAC_CE_TA *)pduP)[1].TA_COMMAND;
           uint8_t tag_id = ((NR_MAC_CE_TA *)pduP)[1].TAGID;*/
@@ -3580,14 +3540,14 @@ void nr_ue_process_mac_pdu(nr_downlink_indication_t *dl_info,
         //  Clause 5.1.5 and 6.1.3.3 of 3GPP TS 38.321 version 16.2.1 Release 16
         // MAC Header: 1 byte (R/R/LCID)
         // MAC SDU: 6 bytes (UE Contention Resolution Identity)
-        mac_ce_len = 6;
+        mac_len = 6;
 
         if(ra->ra_state == WAIT_CONTENTION_RESOLUTION) {
           LOG_I(MAC, "[UE %d][RAPROC] Frame %d : received contention resolution identity: 0x%02x%02x%02x%02x%02x%02x Terminating RA procedure\n",
                 module_idP, frameP, pduP[1], pduP[2], pduP[3], pduP[4], pduP[5], pduP[6]);
 
           bool ra_success = true;
-          for(int i = 0; i<mac_ce_len; i++) {
+          for(int i = 0; i<mac_len; i++) {
             if(ra->cont_res_id[i] != pduP[i+1]) {
               ra_success = false;
               break;
@@ -3615,25 +3575,9 @@ void nr_ue_process_mac_pdu(nr_downlink_indication_t *dl_info,
         //  check if LCID is valid at current time.
       default:
             {
-                //  check if LCID is valid at current time.
-                if (pdu_len < sizeof(NR_MAC_SUBHEADER_SHORT))
-                  return;
-                NR_MAC_SUBHEADER_SHORT *shs = (NR_MAC_SUBHEADER_SHORT *)pduP;
-                if (shs->F) {
-                    //mac_sdu_len |= (uint16_t)(((NR_MAC_SUBHEADER_LONG *)pduP)->L2)<<8;
-                    mac_subheader_len = 3;
-                    if (pdu_len < sizeof(NR_MAC_SUBHEADER_LONG))
-                      return;
-                    NR_MAC_SUBHEADER_LONG *shl = (NR_MAC_SUBHEADER_LONG *)pduP;
-                    mac_sdu_len = ((uint16_t)(shl->L1 & 0x7f) << 8) | (uint16_t)(shl->L2 & 0xff);
-                } else {
-                  if (pdu_len < sizeof(NR_MAC_SUBHEADER_SHORT))
-                    return;
-                  mac_sdu_len = (uint16_t)((NR_MAC_SUBHEADER_SHORT *)pduP)->L;
-                  mac_subheader_len = 2;
-                }
-
-                LOG_D(NR_MAC, "[UE %d] Frame %d : DLSCH -> DL-DTCH %d (gNB %d, %d bytes)\n", module_idP, frameP, rx_lcid, gNB_index, mac_sdu_len);
+	      if (!get_mac_len(pduP, pdu_len, &mac_len, &mac_subheader_len))
+		    return;
+                LOG_D(NR_MAC, "[UE %d] %4d.%2d : DLSCH -> DL-DTCH %d (gNB %d, %d bytes)\n", module_idP, frameP, slot, rx_lcid, gNB_index, mac_len);
 
                 #if defined(ENABLE_MAC_PAYLOAD_DEBUG)
                     LOG_T(MAC, "[UE %d] First 32 bytes of DLSCH : \n", module_idP);
@@ -3654,7 +3598,7 @@ void nr_ue_process_mac_pdu(nr_downlink_indication_t *dl_info,
                                 MBMS_FLAG_NO,
                                 rx_lcid,
                                 (char *) (pduP + mac_subheader_len),
-                                mac_sdu_len,
+                                mac_len,
                                 1,
                                 NULL);
                 } else {
@@ -3665,8 +3609,8 @@ void nr_ue_process_mac_pdu(nr_downlink_indication_t *dl_info,
             break;
             }
       }
-      pduP += ( mac_subheader_len + mac_ce_len + mac_sdu_len );
-      pdu_len -= ( mac_subheader_len + mac_ce_len + mac_sdu_len );
+      pduP += ( mac_subheader_len + mac_len );
+      pdu_len -= ( mac_subheader_len + mac_len );
       if (pdu_len < 0)
         LOG_E(MAC, "[UE %d][%d.%d] nr_ue_process_mac_pdu, residual mac pdu length %d < 0!\n", module_idP, frameP, slot, pdu_len);
     }
diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c
index c62b2d34a6983288a57863d1e081f15af64ffc10..54284045ad6c5ae9c4148b39a5c7e83196e2c687 100644
--- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c
+++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c
@@ -93,7 +93,8 @@ void fill_scheduled_response(nr_scheduled_response_t *scheduled_response,
                              int cc_id,
                              frame_t frame,
                              int slot,
-                             int thread_id){
+                             int thread_id,
+                             void *phy_data){
 
   scheduled_response->dl_config  = dl_config;
   scheduled_response->ul_config  = ul_config;
@@ -103,6 +104,7 @@ void fill_scheduled_response(nr_scheduled_response_t *scheduled_response,
   scheduled_response->frame      = frame;
   scheduled_response->slot       = slot;
   scheduled_response->thread_id  = thread_id;
+  scheduled_response->phy_data   = phy_data;
 
 }
 
@@ -1072,7 +1074,7 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in
       nr_ue_dcireq(&dcireq); //to be replaced with function pointer later
       mac->dl_config_request = dcireq.dl_config_req;
 
-      fill_scheduled_response(&scheduled_response, &dcireq.dl_config_req, NULL, NULL, mod_id, cc_id, rx_frame, rx_slot, dl_info->thread_id);
+      fill_scheduled_response(&scheduled_response, &dcireq.dl_config_req, NULL, NULL, mod_id, cc_id, rx_frame, rx_slot, dl_info->thread_id, dl_info->phy_data);
       if(mac->if_module != NULL && mac->if_module->scheduled_response != NULL)
         mac->if_module->scheduled_response(&scheduled_response);
     }
@@ -1088,7 +1090,7 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in
         fill_dci_search_candidates(mac->ra.ss, rel15);
         dl_config->number_pdus = 1;
         LOG_D(MAC,"mac->cg %p: Calling fill_scheduled_response rnti %x, type0_pdcch, num_pdus %d\n",mac->cg,rel15->rnti,dl_config->number_pdus);
-        fill_scheduled_response(&scheduled_response, dl_config, NULL, NULL, mod_id, cc_id, rx_frame, rx_slot, dl_info->thread_id);
+        fill_scheduled_response(&scheduled_response, dl_config, NULL, NULL, mod_id, cc_id, rx_frame, rx_slot, dl_info->thread_id, dl_info->phy_data);
         if(mac->if_module != NULL && mac->if_module->scheduled_response != NULL)
           mac->if_module->scheduled_response(&scheduled_response);
       }
@@ -1197,7 +1199,7 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in
         }
         pthread_mutex_unlock(&ul_config->mutex_ul_config); // avoid double lock
 
-        fill_scheduled_response(&scheduled_response, NULL, ul_config, &tx_req, mod_id, cc_id, frame_tx, slot_tx, ul_info->thread_id);
+        fill_scheduled_response(&scheduled_response, NULL, ul_config, &tx_req, mod_id, cc_id, frame_tx, slot_tx, ul_info->thread_id, NULL);
         if(mac->if_module != NULL && mac->if_module->scheduled_response != NULL){
           mac->if_module->scheduled_response(&scheduled_response);
         }
@@ -2352,7 +2354,7 @@ void nr_ue_pucch_scheduler(module_id_t module_idP, frame_t frameP, int slotP, in
                           O_SR, O_ACK, O_CSI);
     LOG_D(NR_MAC, "Configuring pucch, is_common = %d\n", pucch.is_common);
     nr_scheduled_response_t scheduled_response;
-    fill_scheduled_response(&scheduled_response, NULL, ul_config, NULL, module_idP, 0 /*TBR fix*/, frameP, slotP, thread_id);
+    fill_scheduled_response(&scheduled_response, NULL, ul_config, NULL, module_idP, 0 /*TBR fix*/, frameP, slotP, thread_id, NULL);
     if(mac->if_module != NULL && mac->if_module->scheduled_response != NULL)
       mac->if_module->scheduled_response(&scheduled_response);
   }
@@ -2699,7 +2701,7 @@ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t s
         }
       } // if format1
 
-      fill_scheduled_response(&scheduled_response, NULL, ul_config, NULL, module_idP, 0 /*TBR fix*/, frameP, slotP, thread_id);
+      fill_scheduled_response(&scheduled_response, NULL, ul_config, NULL, module_idP, 0 /*TBR fix*/, frameP, slotP, thread_id, NULL);
       if(mac->if_module != NULL && mac->if_module->scheduled_response != NULL)
         mac->if_module->scheduled_response(&scheduled_response);
     } // is_nr_prach_slot
@@ -2714,7 +2716,8 @@ void nr_ue_sib1_scheduler(module_id_t module_idP,
                           uint8_t ssb_subcarrier_offset,
                           uint32_t ssb_index,
                           uint16_t ssb_start_subcarrier,
-                          frequency_range_t frequency_range) {
+                          frequency_range_t frequency_range,
+                          void *phy_data) {
 
   NR_UE_MAC_INST_t *mac = get_mac_inst(module_idP);
   nr_scheduled_response_t scheduled_response;
@@ -2762,7 +2765,7 @@ void nr_ue_sib1_scheduler(module_id_t module_idP,
     slot_s = mac->type0_PDCCH_CSS_config.n_c;
   }
   LOG_D(MAC,"Calling fill_scheduled_response, type0_pdcch, num_pdus %d\n",dl_config->number_pdus);
-  fill_scheduled_response(&scheduled_response, dl_config, NULL, NULL, module_idP, cc_id, frame_s, slot_s, 0); // TODO fix thread_id, for now assumed 0
+  fill_scheduled_response(&scheduled_response, dl_config, NULL, NULL, module_idP, cc_id, frame_s, slot_s, 0, phy_data); // TODO fix thread_id, for now assumed 0
 
   if (dl_config->number_pdus) {
     if(mac->if_module != NULL && mac->if_module->scheduled_response != NULL)
@@ -3140,8 +3143,7 @@ uint8_t nr_ue_get_sdu(module_id_t module_idP,
         header->R = 0;
         header->F = 1;
         header->LCID = lcid;
-        header->L1 = ((unsigned short) sdu_length >> 8) & 0x7f;
-        header->L2 = (unsigned short) sdu_length & 0xff;
+        header->L = htons(sdu_length);
 
         #ifdef ENABLE_MAC_PAYLOAD_DEBUG
         LOG_I(NR_MAC, "In %s: dumping MAC sub-header with length %d: \n", __FUNCTION__, sh_size);
diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c
index 6ba8629718a2ba134c5ff8805307f8c1b5766a26..a2cbd4807fedc1d0565343604620fb8d79f46e26 100644
--- a/openair2/LAYER2/NR_MAC_gNB/config.c
+++ b/openair2/LAYER2/NR_MAC_gNB/config.c
@@ -233,7 +233,7 @@ void config_common(int Mod_idP, int ssb_SubcarrierOffset, rrc_pdsch_AntennaPorts
   uint32_t band = *scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0];
   frequency_range_t frequency_range = band<100?FR1:FR2;
 
-  lte_frame_type_t frame_type = get_frame_type(*scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0], *scc->ssbSubcarrierSpacing);
+  frame_type_t frame_type = get_frame_type(*scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0], *scc->ssbSubcarrierSpacing);
   RC.nrmac[Mod_idP]->common_channels[0].frame_type = frame_type;
 
   // Cell configuration
diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c
index 59f0367090342b1f523da96c619f3c07e9a7a747..88a08688edf7134d01babd143626c157cc55fa3b 100644
--- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c
+++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c
@@ -399,7 +399,7 @@ void schedule_nr_prach(module_id_t module_idP, frame_t frameP, sub_frame_t slotP
 void nr_schedule_msg2(uint16_t rach_frame, uint16_t rach_slot,
                       uint16_t *msg2_frame, uint16_t *msg2_slot,
                       NR_ServingCellConfigCommon_t *scc,
-                      lte_frame_type_t frame_type,
+                      frame_type_t frame_type,
                       uint16_t monitoring_slot_period,
                       uint16_t monitoring_offset,uint8_t beam_index,
                       uint8_t num_active_ssb,
@@ -525,7 +525,7 @@ void nr_initiate_ra_proc(module_id_t module_idP,
   gNB_MAC_INST *nr_mac = RC.nrmac[module_idP];
   NR_COMMON_channels_t *cc = &nr_mac->common_channels[CC_id];
   NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon;
-  lte_frame_type_t frame_type = cc->frame_type;
+  frame_type_t frame_type = cc->frame_type;
 
   uint8_t total_RApreambles = MAX_NUM_NR_PRACH_PREAMBLES;
   uint8_t  num_ssb_per_RO = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->present;
@@ -933,7 +933,7 @@ void nr_get_Msg3alloc(module_id_t module_id,
 
   uint16_t msg3_nb_rb = 8; // sdu has 6 or 8 bytes
 
-  lte_frame_type_t frame_type = RC.nrmac[module_id]->common_channels->frame_type;
+  frame_type_t frame_type = RC.nrmac[module_id]->common_channels->frame_type;
 
   int mu = ubwp ?
     ubwp->bwp_Common->genericParameters.subcarrierSpacing :
@@ -1623,7 +1623,7 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra
     harq->feedback_slot = pucch->ul_slot;
     harq->feedback_frame = pucch->frame;
 
-    uint8_t *buf = (uint8_t *) harq->tb;
+    uint8_t *buf = (uint8_t *) harq->transportBlock;
     // Bytes to be transmitted
     if (harq->round == 0) {
       if (ra->msg3_dcch_dtch) {
@@ -1872,11 +1872,11 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra
     }
 
     T(T_GNB_MAC_DL_PDU_WITH_DATA, T_INT(module_idP), T_INT(CC_id), T_INT(ra->rnti),
-      T_INT(frameP), T_INT(slotP), T_INT(current_harq_pid), T_BUFFER(harq->tb, harq->tb_size));
+      T_INT(frameP), T_INT(slotP), T_INT(current_harq_pid), T_BUFFER(harq->transportBlock, harq->tb_size));
 
     // DL TX request
     nfapi_nr_pdu_t *tx_req = &nr_mac->TX_req[CC_id].pdu_list[nr_mac->TX_req[CC_id].Number_of_PDUs];
-    memcpy(tx_req->TLVs[0].value.direct, harq->tb, sizeof(uint8_t) * harq->tb_size);
+    memcpy(tx_req->TLVs[0].value.direct, harq->transportBlock, sizeof(uint8_t) * harq->tb_size);
     tx_req->PDU_length =  harq->tb_size;
     tx_req->PDU_index = pduindex;
     tx_req->num_TLV = 1;
diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c
index 00dec1bd4d1be0ef8935d60434e6aa370d1f4f9a..08ef923fa9eee0e4af7a7572e6c30d9595064b80 100644
--- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c
+++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c
@@ -53,39 +53,39 @@
 #define WORD 32
 //#define SIZE_OF_POINTER sizeof (void *)
 
-void calculate_preferred_dl_tda(module_id_t module_id, const NR_BWP_Downlink_t *bwp)
-{
+void calculate_preferred_dl_tda(module_id_t module_id, const NR_BWP_Downlink_t *bwp) {
   gNB_MAC_INST *nrmac = RC.nrmac[module_id];
   const int bwp_id = bwp ? bwp->bwp_Id : 0;
+
   if (nrmac->preferred_dl_tda[bwp_id])
     return;
 
   /* there is a mixed slot only when in TDD */
   NR_ServingCellConfigCommon_t *scc = nrmac->common_channels->ServingCellConfigCommon;
-  lte_frame_type_t frame_type = nrmac->common_channels->frame_type;
+  frame_type_t frame_type = nrmac->common_channels->frame_type;
   const int n = nr_slots_per_frame[*scc->ssbSubcarrierSpacing];
   const NR_TDD_UL_DL_Pattern_t *tdd =
-      scc->tdd_UL_DL_ConfigurationCommon ? &scc->tdd_UL_DL_ConfigurationCommon->pattern1 : NULL;
-
+    scc->tdd_UL_DL_ConfigurationCommon ? &scc->tdd_UL_DL_ConfigurationCommon->pattern1 : NULL;
   int symb_dlMixed = 0;
   int nr_mix_slots = 0;
   int nr_slots_period = n;
+
   if (tdd) {
     symb_dlMixed = (1 << tdd->nrofDownlinkSymbols) - 1;
     nr_mix_slots = tdd->nrofDownlinkSymbols != 0 || tdd->nrofUplinkSymbols != 0;
     nr_slots_period /= get_nb_periods_per_frame(tdd->dl_UL_TransmissionPeriodicity);
-  }
-  else
+  } else
     // if TDD configuration is not present and the band is not FDD, it means it is a dynamic TDD configuration
     AssertFatal(nrmac->common_channels->frame_type == FDD,"Dynamic TDD not handled yet\n");
 
   int target_ss;
+
   if (bwp) {
     target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific;
-  }
-  else {
+  } else {
     target_ss = NR_SearchSpace__searchSpaceType_PR_common;
   }
+
   const NR_SIB1_t *sib1 = nrmac->common_channels[0].sib1 ? nrmac->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL;
   NR_SearchSpace_t *search_space = get_searchspace(sib1,
                                                    scc,
@@ -113,9 +113,9 @@ void calculate_preferred_dl_tda(module_id_t module_id, const NR_BWP_Downlink_t *
   // here we assume that the coreset is scheduled every slot (which it
   // currently is) and starting at symbol 0
   AssertFatal((symb_coreset & symb_tda) == 0, "TDA index 0 for DL overlaps with CORESET\n");
-
   /* check that TDA index 1 fits into DL part of mixed slot, if it exists */
   int tdaMi = -1;
+
   if (frame_type == TDD && tdaList->list.count > 1) {
     const NR_PDSCH_TimeDomainResourceAllocation_t *tdaP_Mi = tdaList->list.array[1];
     AssertFatal(!tdaP_Mi->k0 || *tdaP_Mi->k0 == 0,
@@ -124,6 +124,7 @@ void calculate_preferred_dl_tda(module_id_t module_id, const NR_BWP_Downlink_t *
     int start, len;
     SLIV2SL(tdaP_Mi->startSymbolAndLength, &start, &len);
     const uint16_t symb_tda = ((1 << len) - 1) << start;
+
     // check whether coreset and TDA overlap: then, we cannot use it. Also,
     // check whether TDA is entirely within mixed slot DL. Note that
     // here we assume that the coreset is scheduled every slot (which it
@@ -143,10 +144,12 @@ void calculate_preferred_dl_tda(module_id_t module_id, const NR_BWP_Downlink_t *
 
   for (int i = 0; i < n; ++i) {
     nrmac->preferred_dl_tda[bwp_id][i] = -1;
+
     if (frame_type == FDD || i % nr_slots_period < tdd->nrofDownlinkSlots)
       nrmac->preferred_dl_tda[bwp_id][i] = 0;
     else if (nr_mix_slots && i % nr_slots_period == tdd->nrofDownlinkSlots)
       nrmac->preferred_dl_tda[bwp_id][i] = tdaMi;
+
     LOG_D(MAC, "slot %d preferred_dl_tda %d\n", i, nrmac->preferred_dl_tda[bwp_id][i]);
   }
 }
@@ -157,8 +160,7 @@ int nr_write_ce_dlsch_pdu(module_id_t module_idP,
                           const NR_UE_sched_ctrl_t *ue_sched_ctl,
                           unsigned char *mac_pdu,
                           unsigned char drx_cmd,
-                          unsigned char *ue_cont_res_id)
-{
+                          unsigned char *ue_cont_res_id) {
   gNB_MAC_INST *gNB = RC.nrmac[module_idP];
   NR_MAC_SUBHEADER_FIXED *mac_pdu_ptr = (NR_MAC_SUBHEADER_FIXED *) mac_pdu;
   uint8_t last_size = 0;
@@ -201,8 +203,6 @@ int nr_write_ce_dlsch_pdu(module_id_t module_idP,
     memcpy((void *) mac_pdu_ptr, (void *) ce_ptr, mac_ce_size);
     ce_ptr += mac_ce_size;
     mac_pdu_ptr += (unsigned char) mac_ce_size;
-
-
   }
 
   // Contention resolution fixed subheader and MAC CE
@@ -399,18 +399,18 @@ int nr_write_ce_dlsch_pdu(module_id_t module_idP,
 
 #define BLER_UPDATE_FRAME 10
 #define BLER_FILTER 0.9f
-int get_mcs_from_bler(module_id_t mod_id, int CC_id, frame_t frame, sub_frame_t slot, int UE_id, int mcs_table)
-{
+int get_mcs_from_bler(module_id_t mod_id, int CC_id, frame_t frame, sub_frame_t slot, int UE_id, int mcs_table) {
   gNB_MAC_INST *nrmac = RC.nrmac[mod_id];
   const NR_ServingCellConfigCommon_t *scc = nrmac->common_channels[CC_id].ServingCellConfigCommon;
   const int n = nr_slots_per_frame[*scc->ssbSubcarrierSpacing];
-
   int max_allowed_mcs = (mcs_table == 1) ? 27 : 28;
   int max_mcs = nrmac->dl_max_mcs;
+
   if (nrmac->dl_max_mcs>max_allowed_mcs)
     max_mcs = max_allowed_mcs;
 
   NR_DL_bler_stats_t *bler_stats = &nrmac->UE_info.UE_sched_ctrl[UE_id].dl_bler_stats;
+
   /* first call: everything is zero. Initialize to sensible default */
   if (bler_stats->last_frame_slot == 0 && bler_stats->mcs == 0) {
     bler_stats->last_frame_slot = frame * n + slot;
@@ -418,13 +418,16 @@ int get_mcs_from_bler(module_id_t mod_id, int CC_id, frame_t frame, sub_frame_t
     bler_stats->bler = (nrmac->dl_bler_target_lower + nrmac->dl_bler_target_upper) / 2;
     bler_stats->rd2_bler = nrmac->dl_rd2_bler_threshold;
   }
+
   const int now = frame * n + slot;
   int diff = now - bler_stats->last_frame_slot;
+
   if (diff < 0) // wrap around
     diff += 1024 * n;
 
   const uint8_t old_mcs = bler_stats->mcs;
   const NR_mac_stats_t *stats = &nrmac->UE_info.mac_stats[UE_id];
+
   // TODO put back this condition when relevant
   /*const int dret3x = stats->dlsch_rounds[3] - bler_stats->dlsch_rounds[3];
   if (dret3x > 0) {
@@ -447,8 +450,8 @@ int get_mcs_from_bler(module_id_t mod_id, int CC_id, frame_t frame, sub_frame_t
   const float rd2_bler_wnd = dtx > 0 ? (float) dretx2 / dtx : bler_stats->rd2_bler;
   bler_stats->bler = BLER_FILTER * bler_stats->bler + (1 - BLER_FILTER) * bler_window;
   bler_stats->rd2_bler = BLER_FILTER / 4 * bler_stats->rd2_bler + (1 - BLER_FILTER / 4) * rd2_bler_wnd;
-
   int new_mcs = old_mcs;
+
   // TODO put back this condition when relevant
   /* first ensure that number of 2nd retx is below threshold. If this is the
    * case, use 1st retx to adjust faster
@@ -459,9 +462,8 @@ int get_mcs_from_bler(module_id_t mod_id, int CC_id, frame_t frame, sub_frame_t
     new_mcs += 1;
   else if (bler_stats->bler > nrmac->dl_bler_target_upper && old_mcs > 6)
     new_mcs -= 1;
-  // else we are within threshold boundaries
-
 
+  // else we are within threshold boundaries
   bler_stats->last_frame_slot = now;
   bler_stats->mcs = new_mcs;
   memcpy(bler_stats->dlsch_rounds, stats->dlsch_rounds, sizeof(stats->dlsch_rounds));
@@ -473,11 +475,9 @@ int get_mcs_from_bler(module_id_t mod_id, int CC_id, frame_t frame, sub_frame_t
 void nr_store_dlsch_buffer(module_id_t module_id,
                            frame_t frame,
                            sub_frame_t slot) {
-
   NR_UE_info_t *UE_info = &RC.nrmac[module_id]->UE_info;
 
   for (int UE_id = UE_info->list.head; UE_id >= 0; UE_id = UE_info->list.next[UE_id]) {
-
     NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id];
     sched_ctrl->num_total_bytes = 0;
     sched_ctrl->dl_pdus_total = 0;
@@ -485,21 +485,20 @@ void nr_store_dlsch_buffer(module_id_t module_id,
     /* loop over all activated logical channels */
     // Note: DL_SCH_LCID_DCCH, DL_SCH_LCID_DCCH1, DL_SCH_LCID_DTCH
     for (int i = 0; i < sched_ctrl->dl_lc_num; ++i) {
-
       const int lcid = sched_ctrl->dl_lc_ids[i];
       const uint16_t rnti = UE_info->rnti[UE_id];
       LOG_D(NR_MAC, "In %s: UE %d/%x: LCID %d\n", __FUNCTION__, UE_id, rnti, lcid);
       start_meas(&RC.nrmac[module_id]->rlc_status_ind);
       sched_ctrl->rlc_status[lcid] = mac_rlc_status_ind(module_id,
-                                                        rnti,
-                                                        module_id,
-                                                          frame,
-                                                        slot,
-                                                        ENB_FLAG_YES,
-                                                        MBMS_FLAG_NO,
-                                                        lcid,
-                                                        0,
-                                                        0);
+                                     rnti,
+                                     module_id,
+                                     frame,
+                                     slot,
+                                     ENB_FLAG_YES,
+                                     MBMS_FLAG_NO,
+                                     lcid,
+                                     0,
+                                     0);
       stop_meas(&RC.nrmac[module_id]->rlc_status_ind);
 
       if (sched_ctrl->rlc_status[lcid].bytes_in_buffer == 0)
@@ -531,6 +530,7 @@ bool allocate_dl_retransmission(module_id_t module_id,
                                 int UE_id,
                                 int current_harq_pid) {
 
+
   gNB_MAC_INST *nr_mac = RC.nrmac[module_id];
   const NR_ServingCellConfigCommon_t *scc = nr_mac->common_channels->ServingCellConfigCommon;
   NR_UE_info_t *UE_info = &nr_mac->UE_info;
@@ -558,30 +558,34 @@ bool allocate_dl_retransmission(module_id_t module_id,
 
   const int coresetid = (sched_ctrl->active_bwp||bwpd) ? sched_ctrl->coreset->controlResourceSetId : RC.nrmac[module_id]->sched_ctrlCommon->coreset->controlResourceSetId;
   const uint16_t bwpSize = coresetid == 0 ? RC.nrmac[module_id]->cset0_bwp_size : NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE);
-  int rbStart = 0; // start wrt BWPstart
 
+  int rbStart = 0; // start wrt BWPstart
   NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static;
-
   int rbSize = 0;
   const int tda = RC.nrmac[module_id]->preferred_dl_tda[sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Id : 0][slot];
   AssertFatal(tda>=0,"Unable to find PDSCH time domain allocation in list\n");
+
   if (tda == retInfo->time_domain_allocation) {
     /* Check that there are enough resources for retransmission */
     while (rbSize < retInfo->rbSize) {
       rbStart += rbSize; /* last iteration rbSize was not enough, skip it */
       rbSize = 0;
+
       while (rbStart < bwpSize &&
              !(rballoc_mask[rbStart]&SL_to_bitmap(ps->startSymbolIndex, ps->nrOfSymbols)))
         rbStart++;
+
       if (rbStart >= bwpSize) {
         LOG_D(NR_MAC, "cannot allocate retransmission for UE %d/RNTI %04x: no resources\n", UE_id, UE_info->rnti[UE_id]);
         return false;
       }
+
       while (rbStart + rbSize < bwpSize &&
              (rballoc_mask[rbStart + rbSize]&SL_to_bitmap(ps->startSymbolIndex, ps->nrOfSymbols)) &&
              rbSize < retInfo->rbSize)
         rbSize++;
     }
+
     /* check whether we need to switch the TDA allocation since the last
      * (re-)transmission */
     if (ps->time_domain_allocation != tda || sched_ctrl->update_pdsch_ps) {
@@ -599,8 +603,8 @@ bool allocate_dl_retransmission(module_id_t module_id,
   } else {
     /* the retransmission will use a different time domain allocation, check
      * that we have enough resources */
-
     NR_pdsch_semi_static_t temp_ps = *ps;
+
     nr_set_pdsch_semi_static(sib1,
                              scc,
                              UE_info->CellGroup[UE_id],
@@ -613,6 +617,7 @@ bool allocate_dl_retransmission(module_id_t module_id,
     while (rbStart < bwpSize &&
            !(rballoc_mask[rbStart]&SL_to_bitmap(temp_ps.startSymbolIndex, temp_ps.nrOfSymbols)))
       rbStart++;
+
     while (rbStart + rbSize < bwpSize &&
            (rballoc_mask[rbStart + rbSize]&SL_to_bitmap(temp_ps.startSymbolIndex, temp_ps.nrOfSymbols)))
       rbSize++;
@@ -629,10 +634,12 @@ bool allocate_dl_retransmission(module_id_t module_id,
                                  rbSize,
                                  &new_tbs,
                                  &new_rbSize);
+
     if (!success || new_tbs != retInfo->tb_size) {
-      LOG_D(MAC, "%s(): new TBsize %d of new TDA does not match old TBS %d\n", __func__, new_tbs, retInfo->tb_size);
+      LOG_D(MAC, "new TBsize %d of new TDA does not match old TBS %d\n", new_tbs, retInfo->tb_size);
       return false; /* the maximum TBsize we might have is smaller than what we need */
     }
+
     /* we can allocate it. Overwrite the time_domain_allocation, the number
      * of RBs, and the new TB size. The rest is done below */
     retInfo->tb_size = new_tbs;
@@ -645,12 +652,14 @@ bool allocate_dl_retransmission(module_id_t module_id,
   const int cid = sched_ctrl->coreset->controlResourceSetId;
   const uint16_t Y = get_Y(cid%3, slot, UE_info->rnti[UE_id]);
   uint8_t nr_of_candidates;
+
   for (int i=0; i<5; i++) {
     // for now taking the lowest value among the available aggregation levels
     find_aggregation_candidates(&sched_ctrl->aggregation_level,
                                 &nr_of_candidates,
                                 sched_ctrl->search_space,
                                 1<<i);
+
     if(nr_of_candidates>0) break;
   }
 
@@ -670,12 +679,12 @@ bool allocate_dl_retransmission(module_id_t module_id,
 
   /* Find PUCCH occasion: if it fails, undo CCE allocation (undoing PUCCH
    * allocation after CCE alloc fail would be more complex) */
+
   int r_pucch = nr_get_pucch_resource(sched_ctrl->coreset, sched_ctrl->active_ubwp, ubwpd, CCEIndex);
   const int alloc = nr_acknack_scheduling(module_id, UE_id, frame, slot, r_pucch, 0);
   if (alloc<0) {
     LOG_D(MAC,
-          "%s(): could not find PUCCH for UE %d/%04x@%d.%d\n",
-          __func__,
+          "could not find PUCCH for UE %d/%04x@%d.%d\n",
           UE_id,
           UE_info->rnti[UE_id],
           frame,
@@ -685,23 +694,21 @@ bool allocate_dl_retransmission(module_id_t module_id,
   }
 
   sched_ctrl->cce_index = CCEIndex;
-
   fill_pdcch_vrb_map(RC.nrmac[module_id],
                      /* CC_id = */ 0,
                      &sched_ctrl->sched_pdcch,
                      CCEIndex,
                      sched_ctrl->aggregation_level);
-
   /* just reuse from previous scheduling opportunity, set new start RB */
   sched_ctrl->sched_pdsch = *retInfo;
   sched_ctrl->sched_pdsch.rbStart = rbStart;
-
   sched_ctrl->sched_pdsch.pucch_allocation = alloc;
-
   /* retransmissions: directly allocate */
   *n_rb_sched -= sched_ctrl->sched_pdsch.rbSize;
+
   for (int rb = 0; rb < sched_ctrl->sched_pdsch.rbSize; rb++)
     rballoc_mask[rb + sched_ctrl->sched_pdsch.rbStart] ^= SL_to_bitmap(ps->startSymbolIndex, ps->nrOfSymbols);
+
   return true;
 }
 
@@ -715,7 +722,6 @@ void pf_dl(module_id_t module_id,
            int max_num_ue,
            int n_rb_sched,
            uint16_t *rballoc_mask) {
-
   gNB_MAC_INST *mac = RC.nrmac[module_id];
   NR_UE_info_t *UE_info = &mac->UE_info;
   NR_ServingCellConfigCommon_t *scc=mac->common_channels[0].ServingCellConfigCommon;
@@ -728,15 +734,16 @@ void pf_dl(module_id_t module_id,
   /* Loop UE_info->list to check retransmission */
   for (int UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id]) {
     if (UE_info->Msg4_ACKed[UE_id] != true) continue;
+
     NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id];
+
     if (sched_ctrl->ul_failure==1 && get_softmodem_params()->phy_test==0) continue;
+
     NR_sched_pdsch_t *sched_pdsch = &sched_ctrl->sched_pdsch;
     NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static;
     /* get the PID of a HARQ process awaiting retrnasmission, or -1 otherwise */
     sched_pdsch->dl_harq_pid = sched_ctrl->retrans_dl_harq.head;
-
     layers[UE_id] = ps->nrOfLayers; // initialization of layers to the previous value in the strcuture
-
     /* Calculate Throughput */
     const float a = 0.0005f; // corresponds to 200ms window
     const uint32_t b = UE_info->mac_stats[UE_id].dlsch_current_bytes;
@@ -746,13 +753,16 @@ void pf_dl(module_id_t module_id,
     if (sched_pdsch->dl_harq_pid >= 0) {
       /* Allocate retransmission */
       bool r = allocate_dl_retransmission(
-          module_id, frame, slot, rballoc_mask, &n_rb_sched, UE_id, sched_pdsch->dl_harq_pid);
+                 module_id, frame, slot, rballoc_mask, &n_rb_sched, UE_id, sched_pdsch->dl_harq_pid);
+
       if (!r) {
         LOG_D(NR_MAC, "%4d.%2d retransmission can NOT be allocated\n", frame, slot);
         continue;
       }
+
       /* reduce max_num_ue once we are sure UE can be allocated, i.e., has CCE */
       max_num_ue--;
+
       if (max_num_ue < 0) return;
     } else {
       /* Check DL buffer and skip this UE if no bytes and no TA necessary */
@@ -782,18 +792,21 @@ void pf_dl(module_id_t module_id,
   }
 
   const int min_rbSize = 5;
+
   /* Loop UE_sched to find max coeff and allocate transmission */
   while (max_num_ue > 0 && n_rb_sched >= min_rbSize && UE_sched.head >= 0) {
-
     /* Find max coeff from UE_sched*/
     int *max = &UE_sched.head; /* assume head is max */
     int *p = &UE_sched.next[*max];
+
     while (*p >= 0) {
       /* if the current one has larger coeff, save for later */
       if (coeff_ue[*p] > coeff_ue[*max])
         max = p;
+
       p = &UE_sched.next[*p];
     }
+
     /* remove the max one: do not use remove_nr_list() it goes through the
      * whole list every time. Note that UE_sched.tail might not be set
      * correctly anymore */
@@ -803,6 +816,7 @@ void pf_dl(module_id_t module_id,
     *p = -1;
     NR_CellGroupConfig_t *cg = UE_info->CellGroup[UE_id];
 
+
     NR_BWP_DownlinkDedicated_t *bwpd =
         cg &&
         cg->spCellConfig &&
@@ -837,12 +851,14 @@ void pf_dl(module_id_t module_id,
     const int cid = sched_ctrl->coreset->controlResourceSetId;
     const uint16_t Y = get_Y(cid%3, slot, UE_info->rnti[UE_id]);
     uint8_t nr_of_candidates;
+
     for (int i=0; i<5; i++) {
       // for now taking the lowest value among the available aggregation levels
       find_aggregation_candidates(&sched_ctrl->aggregation_level,
                                   &nr_of_candidates,
                                   sched_ctrl->search_space,
                                   1<<i);
+
       if(nr_of_candidates>0) break;
     }
 
@@ -861,12 +877,13 @@ void pf_dl(module_id_t module_id,
 
     /* Find PUCCH occasion: if it fails, undo CCE allocation (undoing PUCCH
     * allocation after CCE alloc fail would be more complex) */
+
     int r_pucch = nr_get_pucch_resource(sched_ctrl->coreset, sched_ctrl->active_ubwp, ubwpd, CCEIndex);
     const int alloc = nr_acknack_scheduling(module_id, UE_id, frame, slot, r_pucch, 0);
+
     if (alloc<0) {
       LOG_D(NR_MAC,
-            "%s(): could not find PUCCH for UE %d/%04x@%d.%d\n",
-            __func__,
+            "could not find PUCCH for UE %d/%04x@%d.%d\n",
             UE_id,
             rnti,
             frame,
@@ -879,21 +896,18 @@ void pf_dl(module_id_t module_id,
      * and PUCCH */
     max_num_ue--;
     AssertFatal(max_num_ue >= 0, "Illegal max_num_ue %d\n", max_num_ue);
-
     sched_ctrl->cce_index = CCEIndex;
-
     fill_pdcch_vrb_map(mac,
                        /* CC_id = */ 0,
                        &sched_ctrl->sched_pdcch,
                        CCEIndex,
                        sched_ctrl->aggregation_level);
-
     /* reduce max_num_ue once we are sure UE can be allocated, i.e., has CCE */
     max_num_ue--;
+
     if (max_num_ue < 0) return;
 
     /* MCS has been set above */
-
     const int tda = RC.nrmac[module_id]->preferred_dl_tda[sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Id : 0][slot];
     AssertFatal(tda>=0,"Unable to find PDSCH time domain allocation in list\n");
     NR_sched_pdsch_t *sched_pdsch = &sched_ctrl->sched_pdsch;
@@ -913,12 +927,14 @@ void pf_dl(module_id_t module_id,
     }
 
     const uint16_t slbitmap = SL_to_bitmap(ps->startSymbolIndex, ps->nrOfSymbols);
+
     // Freq-demain allocation
     while (rbStart < bwpSize &&
            !(rballoc_mask[rbStart]&slbitmap))
       rbStart++;
 
     uint16_t max_rbSize = 1;
+
     while (rbStart + max_rbSize < bwpSize &&
            (rballoc_mask[rbStart + max_rbSize]&slbitmap))
       max_rbSize++;
@@ -947,39 +963,41 @@ void pf_dl(module_id_t module_id,
     sched_pdsch->rbSize = rbSize;
     sched_pdsch->rbStart = rbStart;
     sched_pdsch->tb_size = TBS;
-
     /* transmissions: directly allocate */
     n_rb_sched -= sched_pdsch->rbSize;
+
     for (int rb = 0; rb < sched_pdsch->rbSize; rb++)
       rballoc_mask[rb + sched_pdsch->rbStart] ^= slbitmap;
   }
 }
 
-void nr_fr1_dlsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t slot)
-{
+void nr_fr1_dlsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t slot) {
   NR_UE_info_t *UE_info = &RC.nrmac[module_id]->UE_info;
+
   if (UE_info->num_UEs == 0)
     return;
 
   NR_ServingCellConfigCommon_t *scc = RC.nrmac[module_id]->common_channels[0].ServingCellConfigCommon;
   const int CC_id = 0;
-
   /* Get bwpSize and TDAfrom the first UE */
   /* This is temporary and it assumes all UEs have the same BWP and TDA*/
   int UE_id = UE_info->list.head;
   NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id];
   const int bwp_id = sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Id : 0;
+
   if (!RC.nrmac[module_id]->preferred_dl_tda[bwp_id])
     return;
+
   const int tda = RC.nrmac[module_id]->preferred_dl_tda[bwp_id][slot];
   int startSymbolIndex, nrOfSymbols;
   const struct NR_PDSCH_TimeDomainResourceAllocationList *tdaList = sched_ctrl->active_bwp ?
-      sched_ctrl->active_bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList :
-      scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList;
+        sched_ctrl->active_bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList :
+        scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList;
   AssertFatal(tda < tdaList->list.count, "time_domain_allocation %d>=%d\n", tda, tdaList->list.count);
   const int startSymbolAndLength = tdaList->list.array[tda]->startSymbolAndLength;
   SLIV2SL(startSymbolAndLength, &startSymbolIndex, &nrOfSymbols);
 
+
   const NR_SIB1_t *sib1 = RC.nrmac[module_id]->common_channels[0].sib1 ? RC.nrmac[module_id]->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL;
   NR_BWP_t *genericParameters = get_dl_bwp_genericParameters(sched_ctrl->active_bwp,
                                                              RC.nrmac[module_id]->common_channels[0].ServingCellConfigCommon,
@@ -1000,19 +1018,20 @@ void nr_fr1_dlsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t
   uint16_t *vrb_map = RC.nrmac[module_id]->common_channels[CC_id].vrb_map;
   uint16_t rballoc_mask[bwpSize];
   int n_rb_sched = 0;
+
   for (int i = 0; i < bwpSize; i++) {
     // calculate mask: init with "NOT" vrb_map:
     // if any RB in vrb_map is blocked (1), the current RBG will be 0
     rballoc_mask[i] = (~vrb_map[i+BWPStart])&0x3fff; //bitwise not and 14 symbols
+
     // if all the pdsch symbols are free
     if((rballoc_mask[i]&slbitmap) ==
-       slbitmap)
+        slbitmap)
       n_rb_sched++;
   }
 
   /* Retrieve amount of data to send for this UE */
   nr_store_dlsch_buffer(module_id, frame, slot);
-
   /* proportional fair scheduling algorithm */
   pf_dl(module_id,
         frame,
@@ -1023,8 +1042,7 @@ void nr_fr1_dlsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t
         rballoc_mask);
 }
 
-nr_pp_impl_dl nr_init_fr1_dlsch_preprocessor(module_id_t module_id, int CC_id)
-{
+nr_pp_impl_dl nr_init_fr1_dlsch_preprocessor(module_id_t module_id, int CC_id) {
   /* in the PF algorithm, we have to use the TBsize to compute the coefficient.
    * This would include the number of DMRS symbols, which in turn depends on
    * the time domain allocation. In case we are in a mixed slot, we do not want
@@ -1034,16 +1052,17 @@ nr_pp_impl_dl nr_init_fr1_dlsch_preprocessor(module_id_t module_id, int CC_id)
     for (int mcs = 0; mcs < 29; ++mcs) {
       if (mcs > 27 && mcsTableIdx == 1)
         continue;
+
       const uint8_t Qm = nr_get_Qm_dl(mcs, mcsTableIdx);
       const uint16_t R = nr_get_code_rate_dl(mcs, mcsTableIdx);
       pf_tbs[mcsTableIdx][mcs] = nr_compute_tbs(Qm,
-                                                R,
-                                                1, /* rbSize */
-                                                10, /* hypothetical number of slots */
-                                                0, /* N_PRB_DMRS * N_DMRS_SLOT */
-                                                0 /* N_PRB_oh, 0 for initialBWP */,
-                                                0 /* tb_scaling */,
-                                                1 /* nrOfLayers */)
+                                 R,
+                                 1, /* rbSize */
+                                 10, /* hypothetical number of slots */
+                                 0, /* N_PRB_DMRS * N_DMRS_SLOT */
+                                 0 /* N_PRB_oh, 0 for initialBWP */,
+                                 0 /* tb_scaling */,
+                                 1 /* nrOfLayers */)
                                  >> 3;
     }
   }
@@ -1055,22 +1074,23 @@ void nr_schedule_ue_spec(module_id_t module_id,
                          frame_t frame,
                          sub_frame_t slot) {
   gNB_MAC_INST *gNB_mac = RC.nrmac[module_id];
+
   if (!is_xlsch_in_slot(gNB_mac->dlsch_slot_bitmap[slot / 64], slot))
     return;
 
   /* PREPROCESSOR */
   gNB_mac->pre_processor_dl(module_id, frame, slot);
-
   const int CC_id = 0;
   NR_ServingCellConfigCommon_t *scc = gNB_mac->common_channels[CC_id].ServingCellConfigCommon;
   NR_UE_info_t *UE_info = &gNB_mac->UE_info;
-
   nfapi_nr_dl_tti_request_body_t *dl_req = &gNB_mac->DL_req[CC_id].dl_tti_request_body;
-
   NR_list_t *UE_list = &UE_info->list;
+
   for (int UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id]) {
     NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id];
+
     if (sched_ctrl->ul_failure==1 && get_softmodem_params()->phy_test==0) continue;
+
     NR_sched_pdsch_t *sched_pdsch = &sched_ctrl->sched_pdsch;
     UE_info->mac_stats[UE_id].dlsch_current_bytes = 0;
     NR_CellGroupConfig_t *cg = UE_info->CellGroup[UE_id];
@@ -1085,7 +1105,7 @@ void nr_schedule_ue_spec(module_id_t module_id,
      * Possible improvement: take the periodicity from input file.
      * If such UE is not scheduled now, it will be by the preprocessor later.
      * If we add the CE, ta_apply will be reset */
-    if (frame == (sched_ctrl->ta_frame + 10) % 1024){
+    if (frame == (sched_ctrl->ta_frame + 10) % 1024) {
       sched_ctrl->ta_apply = true; /* the timer is reset once TA CE is scheduled */
       LOG_D(NR_MAC, "[UE %d][%d.%d] UL timing alignment procedures: setting flag for Timing Advance command\n", UE_id, frame, slot);
     }
@@ -1094,19 +1114,17 @@ void nr_schedule_ue_spec(module_id_t module_id,
       continue;
 
     const rnti_t rnti = UE_info->rnti[UE_id];
-
     /* pre-computed PDSCH values that only change if time domain
      * allocation/DMRS parameters change. Updated in the preprocessor through
      * nr_set_pdsch_semi_static() */
     NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static;
-
     /* POST processing */
     const uint8_t nrOfLayers = ps->nrOfLayers;
     const uint16_t R = sched_pdsch->R;
     const uint8_t Qm = sched_pdsch->Qm;
     const uint32_t TBS = sched_pdsch->tb_size;
-
     int8_t current_harq_pid = sched_pdsch->dl_harq_pid;
+
     if (current_harq_pid < 0) {
       /* PP has not selected a specific HARQ Process, get a new one */
       current_harq_pid = sched_ctrl->available_dl_harq.head;
@@ -1124,6 +1142,7 @@ void nr_schedule_ue_spec(module_id_t module_id,
       else
         remove_nr_list(&sched_ctrl->retrans_dl_harq, current_harq_pid);
     }
+
     NR_UE_harq_t *harq = &sched_ctrl->harq_processes[current_harq_pid];
     DevAssert(!harq->is_waiting);
     add_tail_nr_list(&sched_ctrl->feedback_dl_harq, current_harq_pid);
@@ -1132,8 +1151,8 @@ void nr_schedule_ue_spec(module_id_t module_id,
     harq->feedback_slot = pucch->ul_slot;
     harq->is_waiting = true;
     UE_info->mac_stats[UE_id].dlsch_rounds[harq->round]++;
-
-    LOG_D(NR_MAC,"%4d.%2d [DLSCH/PDSCH/PUCCH] UE %d RNTI %04x DCI L %d start %3d RBs %3d startSymbol %2d nb_symbol %2d dmrspos %x MCS %2d nrOfLayers %d TBS %4d HARQ PID %2d round %d RV %d NDI %d dl_data_to_ULACK %d (%d.%d) PUCCH allocation %d TPC %d\n",
+    LOG_D(NR_MAC,
+          "%4d.%2d [DLSCH/PDSCH/PUCCH] UE %d RNTI %04x DCI L %d start %3d RBs %3d startSymbol %2d nb_symbol %2d dmrspos %x MCS %2d nrOfLayers %d TBS %4d HARQ PID %2d round %d RV %d NDI %d dl_data_to_ULACK %d (%d.%d) PUCCH allocation %d TPC %d\n",
           frame,
           slot,
           UE_id,
@@ -1156,8 +1175,8 @@ void nr_schedule_ue_spec(module_id_t module_id,
           pucch->ul_slot,
           sched_pdsch->pucch_allocation,
           sched_ctrl->tpc1);
-
     NR_BWP_Downlink_t *bwp = sched_ctrl->active_bwp;
+
     const NR_SIB1_t *sib1 = RC.nrmac[module_id]->common_channels[0].sib1 ? RC.nrmac[module_id]->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL;
     NR_BWP_t *genericParameters = get_dl_bwp_genericParameters(bwp,
                                                                RC.nrmac[module_id]->common_channels[0].ServingCellConfigCommon,
@@ -1170,6 +1189,7 @@ void nr_schedule_ue_spec(module_id_t module_id,
 
     /* look up the PDCCH PDU for this CC, BWP, and CORESET. If it does not exist, create it */
     nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu = gNB_mac->pdcch_pdu_idx[CC_id][coresetid];
+
     if (!pdcch_pdu) {
       LOG_D(NR_MAC, "creating pdcch pdu, pdcch_pdu = NULL. \n");
       nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdcch_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs];
@@ -1190,7 +1210,6 @@ void nr_schedule_ue_spec(module_id_t module_id,
     dl_tti_pdsch_pdu->PDUSize = (uint8_t)(2+sizeof(nfapi_nr_dl_tti_pdsch_pdu));
     dl_req->nPDUs += 1;
     nfapi_nr_dl_tti_pdsch_pdu_rel15_t *pdsch_pdu = &dl_tti_pdsch_pdu->pdsch_pdu.pdsch_pdu_rel15;
-
     pdsch_pdu->pduBitmap = 0;
     pdsch_pdu->rnti = rnti;
     /* SCF222: PDU index incremented for each PDSCH PDU sent in TX control
@@ -1208,9 +1227,7 @@ void nr_schedule_ue_spec(module_id_t module_id,
     }
 
     pdsch_pdu->SubcarrierSpacing = genericParameters->subcarrierSpacing;
-
     pdsch_pdu->CyclicPrefix = genericParameters->cyclicPrefix ? *genericParameters->cyclicPrefix : 0;
-
     // Codeword information
     pdsch_pdu->NrOfCodewords = 1;
     //number of information bits per 1024 coded bits expressed in 0.1 bit units
@@ -1222,12 +1239,10 @@ void nr_schedule_ue_spec(module_id_t module_id,
     AssertFatal(harq->round<4,"%d",harq->round);
     pdsch_pdu->rvIndex[0] = nr_rv_round_map[harq->round];
     pdsch_pdu->TBSize[0] = TBS;
-
     pdsch_pdu->dataScramblingId = *scc->physCellId;
     pdsch_pdu->nrOfLayers = nrOfLayers;
     pdsch_pdu->transmissionScheme = 0;
     pdsch_pdu->refPoint = 0; // Point A
-
     // DMRS
     pdsch_pdu->dlDmrsSymbPos = ps->dl_dmrs_symb_pos;
     pdsch_pdu->dmrsConfigType = ps->dmrsConfigType;
@@ -1235,18 +1250,16 @@ void nr_schedule_ue_spec(module_id_t module_id,
     pdsch_pdu->SCID = 0;
     pdsch_pdu->numDmrsCdmGrpsNoData = ps->numDmrsCdmGrpsNoData;
     pdsch_pdu->dmrsPorts = (1<<nrOfLayers)-1;  // FIXME with a better implementation
-
     // Pdsch Allocation in frequency domain
     pdsch_pdu->resourceAlloc = 1;
     pdsch_pdu->rbStart = sched_pdsch->rbStart;
     pdsch_pdu->rbSize = sched_pdsch->rbSize;
     pdsch_pdu->VRBtoPRBMapping = 1; // non-interleaved, check if this is ok for initialBWP
-
     // Resource Allocation in time domain
     pdsch_pdu->StartSymbolIndex = ps->startSymbolIndex;
     pdsch_pdu->NrOfSymbols = ps->nrOfSymbols;
-
     NR_PDSCH_Config_t *pdsch_Config=NULL;
+
     if (bwp &&
         bwp->bwp_Dedicated &&
         bwp->bwp_Dedicated->pdsch_Config &&
@@ -1255,18 +1268,20 @@ void nr_schedule_ue_spec(module_id_t module_id,
 
     /* Check and validate PTRS values */
     struct NR_SetupRelease_PTRS_DownlinkConfig *phaseTrackingRS =
-      pdsch_Config ? pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS : NULL;
+        pdsch_Config ? pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS : NULL;
+
     if (phaseTrackingRS) {
       bool valid_ptrs_setup = set_dl_ptrs_values(phaseTrackingRS->choice.setup,
-                                                 pdsch_pdu->rbSize,
-                                                 pdsch_pdu->mcsIndex[0],
-                                                 pdsch_pdu->mcsTable[0],
-                                                 &pdsch_pdu->PTRSFreqDensity,
-                                                 &pdsch_pdu->PTRSTimeDensity,
-                                                 &pdsch_pdu->PTRSPortIndex,
-                                                 &pdsch_pdu->nEpreRatioOfPDSCHToPTRS,
-                                                 &pdsch_pdu->PTRSReOffset,
-                                                 pdsch_pdu->NrOfSymbols);
+                              pdsch_pdu->rbSize,
+                              pdsch_pdu->mcsIndex[0],
+                              pdsch_pdu->mcsTable[0],
+                              &pdsch_pdu->PTRSFreqDensity,
+                              &pdsch_pdu->PTRSTimeDensity,
+                              &pdsch_pdu->PTRSPortIndex,
+                              &pdsch_pdu->nEpreRatioOfPDSCHToPTRS,
+                              &pdsch_pdu->PTRSReOffset,
+                              pdsch_pdu->NrOfSymbols);
+
       if (valid_ptrs_setup)
         pdsch_pdu->pduBitmap |= 0x1; // Bit 0: pdschPtrs - Indicates PTRS included (FR2)
     }
@@ -1276,6 +1291,7 @@ void nr_schedule_ue_spec(module_id_t module_id,
     nfapi_nr_dl_dci_pdu_t *dci_pdu = &pdcch_pdu->dci_pdu[pdcch_pdu->numDlDci];
     pdcch_pdu->numDlDci++;
     dci_pdu->RNTI = rnti;
+
     if (sched_ctrl->coreset &&
         sched_ctrl->search_space &&
         sched_ctrl->coreset->pdcch_DMRS_ScramblingID &&
@@ -1286,27 +1302,28 @@ void nr_schedule_ue_spec(module_id_t module_id,
       dci_pdu->ScramblingId = *scc->physCellId;
       dci_pdu->ScramblingRNTI = 0;
     }
+
     dci_pdu->AggregationLevel = sched_ctrl->aggregation_level;
     dci_pdu->CceIndex = sched_ctrl->cce_index;
     dci_pdu->beta_PDCCH_1_0 = 0;
     dci_pdu->powerControlOffsetSS = 1;
-
     /* DCI payload */
     dci_pdu_rel15_t dci_payload;
     memset(&dci_payload, 0, sizeof(dci_pdu_rel15_t));
     // bwp indicator
     const int n_dl_bwp = bwp ? UE_info->CellGroup[UE_id]->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count : 0;
     AssertFatal(n_dl_bwp <= 1, "downlinkBWP_ToAddModList has %d BWP!\n", n_dl_bwp);
-
     // as per table 7.3.1.1.2-1 in 38.212
     dci_payload.bwp_indicator.val = bwp ? (n_dl_bwp < 4 ? bwp->bwp_Id : bwp->bwp_Id - 1) : 0;
+
     if (bwp) AssertFatal(bwp->bwp_Dedicated->pdsch_Config->choice.setup->resourceAllocation == NR_PDSCH_Config__resourceAllocation_resourceAllocationType1,
-			 "Only frequency resource allocation type 1 is currently supported\n");
+                           "Only frequency resource allocation type 1 is currently supported\n");
+
     dci_payload.frequency_domain_assignment.val =
-        PRBalloc_to_locationandbandwidth0(
-            pdsch_pdu->rbSize,
-            pdsch_pdu->rbStart,
-            pdsch_pdu->BWPSize);
+      PRBalloc_to_locationandbandwidth0(
+        pdsch_pdu->rbSize,
+        pdsch_pdu->rbStart,
+        pdsch_pdu->BWPSize);
     dci_payload.format_indicator = 1;
     dci_payload.time_domain_assignment.val = ps->time_domain_allocation;
     dci_payload.mcs = sched_pdsch->mcs;
@@ -1337,11 +1354,11 @@ void nr_schedule_ue_spec(module_id_t module_id,
           dci_payload.tpc,
           pucch->timing_indicator);
 
+
     int dci_format = ss && ss->searchSpaceType && ss->searchSpaceType->present == NR_SearchSpace__searchSpaceType_PR_ue_Specific ?
                      NR_DL_DCI_FORMAT_1_1 : NR_DL_DCI_FORMAT_1_0;
 
     const int rnti_type = NR_RNTI_C;
-
     fill_dci_pdu_rel15(scc,
                        UE_info->CellGroup[UE_id],
                        dci_pdu,
@@ -1360,7 +1377,7 @@ void nr_schedule_ue_spec(module_id_t module_id,
 
     if (harq->round != 0) { /* retransmission */
       /* we do not have to do anything, since we do not require to get data
-       * from RLC or encode MAC CEs. The TX_req structure is filled below 
+       * from RLC or encode MAC CEs. The TX_req structure is filled below
        * or copy data to FAPI structures */
       LOG_D(NR_MAC,
             "%d.%2d DL retransmission UE %d/RNTI %04x HARQ PID %d round %d NDI %d\n",
@@ -1371,20 +1388,15 @@ void nr_schedule_ue_spec(module_id_t module_id,
             current_harq_pid,
             harq->round,
             harq->ndi);
-
       AssertFatal(harq->sched_pdsch.tb_size == TBS,
                   "UE %d mismatch between scheduled TBS and buffered TB for HARQ PID %d\n",
                   UE_id,
                   current_harq_pid);
-
       T(T_GNB_MAC_RETRANSMISSION_DL_PDU_WITH_DATA, T_INT(module_id), T_INT(CC_id), T_INT(rnti),
-        T_INT(frame), T_INT(slot), T_INT(current_harq_pid), T_INT(harq->round), T_BUFFER(harq->tb, TBS));
+        T_INT(frame), T_INT(slot), T_INT(current_harq_pid), T_INT(harq->round), T_BUFFER(harq->transportBlock, TBS));
     } else { /* initial transmission */
-
       LOG_D(NR_MAC, "[%s] Initial HARQ transmission in %d.%d\n", __FUNCTION__, frame, slot);
-
-      uint8_t *buf = (uint8_t *) harq->tb;
-
+      uint8_t *buf = (uint8_t *) harq->transportBlock;
       /* first, write all CEs that might be there */
       int written = nr_write_ce_dlsch_pdu(module_id,
                                           sched_ctrl,
@@ -1392,32 +1404,30 @@ void nr_schedule_ue_spec(module_id_t module_id,
                                           255, // no drx
                                           NULL); // contention res id
       buf += written;
-      int size = TBS - written;
-      DevAssert(size >= 0);
+      uint8_t *bufEnd = buf + TBS - written;
+      DevAssert(TBS > written);
+      int dlsch_total_bytes = 0;
       /* next, get RLC data */
-
       start_meas(&gNB_mac->rlc_data_req);
-      if (sched_ctrl->num_total_bytes > 0) {
 
+      if (sched_ctrl->num_total_bytes > 0) {
         /* loop over all activated logical channels */
         for (int i = 0; i < sched_ctrl->dl_lc_num; ++i) {
-
           const int lcid = sched_ctrl->dl_lc_ids[i];
+
           if (sched_ctrl->rlc_status[lcid].bytes_in_buffer == 0)
-            continue; // no data for this LC
+            continue; // no data for this LC        tbs_size_t len = 0;
 
-          int dlsch_total_bytes = 0;
-          while (size > 3) {
+          int lcid_bytes=0;
+          while (bufEnd-buf > sizeof(NR_MAC_SUBHEADER_LONG) + 1 ) {
             // we do not know how much data we will get from RLC, i.e., whether it
             // will be longer than 256B or not. Therefore, reserve space for long header, then
             // fetch data, then fill real length
             NR_MAC_SUBHEADER_LONG *header = (NR_MAC_SUBHEADER_LONG *) buf;
-            buf += 3;
-            size -= 3;
-
             /* limit requested number of bytes to what preprocessor specified, or
              * such that TBS is full */
-            const rlc_buffer_occupancy_t ndata = min(sched_ctrl->rlc_status[lcid].bytes_in_buffer, size);
+            const rlc_buffer_occupancy_t ndata = min(sched_ctrl->rlc_status[lcid].bytes_in_buffer,
+                                                 bufEnd-buf-sizeof(NR_MAC_SUBHEADER_LONG));
             tbs_size_t len = mac_rlc_data_req(module_id,
                                               rnti,
                                               module_id,
@@ -1426,12 +1436,11 @@ void nr_schedule_ue_spec(module_id_t module_id,
                                               MBMS_FLAG_NO,
                                               lcid,
                                               ndata,
-                                              (char *)buf,
+                                              (char *)buf+sizeof(NR_MAC_SUBHEADER_LONG),
                                               0,
                                               0);
-
             LOG_D(NR_MAC,
-                  "%4d.%2d RNTI %04x: %d bytes from %s %d (ndata %d, remaining size %d)\n",
+                  "%4d.%2d RNTI %04x: %d bytes from %s %d (ndata %d, remaining size %ld)\n",
                   frame,
                   slot,
                   rnti,
@@ -1439,64 +1448,56 @@ void nr_schedule_ue_spec(module_id_t module_id,
                   lcid < 4 ? "DCCH" : "DTCH",
                   lcid,
                   ndata,
-                  size);
-            if (len == 0) {
-              /* RLC did not have data anymore, mark buffer as unused */
-              buf -= 3;
-              size += 3;
+                  bufEnd-buf-+sizeof(NR_MAC_SUBHEADER_LONG));
+
+            if (len == 0)
               break;
-            }
 
             header->R = 0;
             header->F = 1;
             header->LCID = lcid;
-            header->L1 = (len >> 8) & 0xff;
-            header->L2 = len & 0xff;
-            size -= len;
-            buf += len;
+            header->L = htons(len);
+            buf += len+sizeof(NR_MAC_SUBHEADER_LONG);
             dlsch_total_bytes += len;
+            lcid_bytes += len;
           }
 
-          UE_info->mac_stats[UE_id].lc_bytes_tx[lcid] += dlsch_total_bytes;
+          UE_info->mac_stats[UE_id].lc_bytes_tx[lcid] += lcid_bytes;
         }
       } else if (get_softmodem_params()->phy_test || get_softmodem_params()->do_ra) {
         /* we will need the large header, phy-test typically allocates all
          * resources and fills to the last byte below */
-        NR_MAC_SUBHEADER_LONG *header = (NR_MAC_SUBHEADER_LONG *) buf;
-        buf += 3;
-        size -= 3;
-        DevAssert(size > 0);
-        LOG_D(NR_MAC, "Configuring DL_TX in %d.%d: TBS %d with %d B of random data\n", frame, slot, TBS, size);
-        // fill dlsch_buffer with random data
-        for (int i = 0; i < size; i++)
-          buf[i] = lrand48() & 0xff;
-        header->R = 0;
-        header->F = 1;
-        header->LCID = DL_SCH_LCID_PADDING;
-        header->L1 = (size >> 8) & 0xff;
-        header->L2 = size & 0xff;
-        size -= size;
-        buf += size;
+        LOG_D(NR_MAC, "Configuring DL_TX in %d.%d: TBS %d of random data\n", frame, slot, TBS);
+
+        if (bufEnd-buf > sizeof(NR_MAC_SUBHEADER_LONG) ) {
+          NR_MAC_SUBHEADER_LONG *header = (NR_MAC_SUBHEADER_LONG *) buf;
+          // fill dlsch_buffer with random data
+          header->R = 0;
+          header->F = 1;
+          header->LCID = DL_SCH_LCID_PADDING;
+          buf += sizeof(NR_MAC_SUBHEADER_LONG);
+          header->L = htons(bufEnd-buf);
+          dlsch_total_bytes += bufEnd-buf;
+
+          for (; buf < bufEnd; buf++)
+            *buf = lrand48() & 0xff;
+        }
       }
+
       stop_meas(&gNB_mac->rlc_data_req);
 
       // Add padding header and zero rest out if there is space left
-      if (size > 0) {
+      if (bufEnd-buf > 0) {
         NR_MAC_SUBHEADER_FIXED *padding = (NR_MAC_SUBHEADER_FIXED *) buf;
         padding->R = 0;
         padding->LCID = DL_SCH_LCID_PADDING;
-        size -= 1;
         buf += 1;
-        while (size > 0) {
-          *buf = 0;
-          buf += 1;
-          size -= 1;
-        }
+        memset(buf,0,bufEnd-buf);
+        buf=bufEnd;
       }
 
       UE_info->mac_stats[UE_id].dlsch_total_bytes += TBS;
       UE_info->mac_stats[UE_id].dlsch_current_bytes = TBS;
-
       /* save retransmission information */
       harq->sched_pdsch = *sched_pdsch;
       /* save which time allocation has been used, to be used on
@@ -1515,7 +1516,7 @@ void nr_schedule_ue_spec(module_id_t module_id,
       }
 
       T(T_GNB_MAC_DL_PDU_WITH_DATA, T_INT(module_id), T_INT(CC_id), T_INT(rnti),
-        T_INT(frame), T_INT(slot), T_INT(current_harq_pid), T_BUFFER(harq->tb, TBS));
+        T_INT(frame), T_INT(slot), T_INT(current_harq_pid), T_BUFFER(harq->transportBlock, TBS));
     }
 
     const int ntx_req = gNB_mac->TX_req[CC_id].Number_of_PDUs;
@@ -1524,11 +1525,10 @@ void nr_schedule_ue_spec(module_id_t module_id,
     tx_req->PDU_index  = pduindex;
     tx_req->num_TLV = 1;
     tx_req->TLVs[0].length = TBS + 2;
-    memcpy(tx_req->TLVs[0].value.direct, harq->tb, TBS);
+    memcpy(tx_req->TLVs[0].value.direct, harq->transportBlock, TBS);
     gNB_mac->TX_req[CC_id].Number_of_PDUs++;
     gNB_mac->TX_req[CC_id].SFN = frame;
     gNB_mac->TX_req[CC_id].Slot = slot;
-
     /* mark UE as scheduled */
     sched_pdsch->rbSize = 0;
   }
diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c
index e21d1e50f7ccd15823068bf15470ca9cbe781ad8..43822d0cd04b7d2f058caba73b667bb4ecb0e690 100644
--- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c
+++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c
@@ -51,7 +51,7 @@ void nr_fill_nfapi_pucch(module_id_t mod_id,
       &RC.nrmac[mod_id]->UL_tti_req_ahead[0][pucch->ul_slot];
   AssertFatal(future_ul_tti_req->SFN == pucch->frame
               && future_ul_tti_req->Slot == pucch->ul_slot,
-              "future UL_tti_req's frame.slot %d.%d does not match PUCCH %d.%d\n",
+              "future UL_tti_req's frame.slot %4d.%2d does not match PUCCH %4d.%2d\n",
               future_ul_tti_req->SFN,
               future_ul_tti_req->Slot,
               pucch->frame,
@@ -84,7 +84,7 @@ void nr_fill_nfapi_pucch(module_id_t mod_id,
                                     cg->spCellConfig->spCellConfigDedicated->uplinkConfig ?
                                     cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP : NULL;
 
-  LOG_D(NR_MAC,"%d.%d Calling nr_configure_pucch (ubwpd %p,r_pucch %d) pucch to be scheduled in %d.%d\n",
+  LOG_D(NR_MAC,"%4d.%2d Calling nr_configure_pucch (ubwpd %p,r_pucch %d) pucch to be scheduled in %4d.%2d\n",
         frame,slot,ubwpd,pucch->r_pucch,pucch->frame,pucch->ul_slot);
 
   const NR_SIB1_t *sib1 = nr_mac->common_channels[0].sib1 ? nr_mac->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL;
@@ -161,7 +161,7 @@ void nr_schedule_pucch(int Mod_idP,
           || frameP != curr_pucch->frame
           || slotP != curr_pucch->ul_slot)
         continue;
-      LOG_D(NR_MAC,"Scheduling PUCCH[%d] RX for UE %d in %d.%d O_ack %d\n",i,UE_id,curr_pucch->frame,curr_pucch->ul_slot,O_ack);
+      LOG_D(NR_MAC,"Scheduling PUCCH[%d] RX for UE %d in %4d.%2d O_ack %d\n",i,UE_id,curr_pucch->frame,curr_pucch->ul_slot,O_ack);
       nr_fill_nfapi_pucch(Mod_idP, frameP, slotP, curr_pucch, UE_id);
       memset(curr_pucch, 0, sizeof(*curr_pucch));
     }
@@ -820,6 +820,7 @@ static void handle_dl_harq(module_id_t mod_id,
     stats->dlsch_errors++;
     LOG_D(NR_MAC, "retransmission error for UE %d (total %"PRIu64")\n", UE_id, stats->dlsch_errors);
   } else {
+    LOG_D(PHY,"NACK for: pid %d, ue %x\n",harq_pid, UE_id);
     add_tail_nr_list(&UE_info->UE_sched_ctrl[UE_id].retrans_dl_harq, harq_pid);
     harq->round++;
   }
@@ -1398,7 +1399,7 @@ static NR_UE_harq_t *find_harq(module_id_t mod_id, frame_t frame, sub_frame_t sl
   while (harq->feedback_frame != frame
          || (harq->feedback_frame == frame && harq->feedback_slot < slot)) {
     LOG_W(NR_MAC,
-          "expected HARQ pid %d feedback at %d.%d, but is at %d.%d instead (HARQ feedback is in the past)\n",
+          "expected HARQ pid %d feedback at %4d.%2d, but is at %4d.%2d instead (HARQ feedback is in the past)\n",
           pid,
           harq->feedback_frame,
           harq->feedback_slot,
@@ -1414,7 +1415,7 @@ static NR_UE_harq_t *find_harq(module_id_t mod_id, frame_t frame, sub_frame_t sl
   /* feedbacks that we wait for in the future: don't do anything */
   if (harq->feedback_slot > slot) {
     LOG_W(NR_MAC,
-          "expected HARQ pid %d feedback at %d.%d, but is at %d.%d instead (HARQ feedback is in the future)\n",
+          "expected HARQ pid %d feedback at %4d.%2d, but is at %4d.%2d instead (HARQ feedback is in the future)\n",
           pid,
           harq->feedback_frame,
           harq->feedback_slot,
@@ -1451,7 +1452,7 @@ void handle_nr_uci_pucch_0_1(module_id_t mod_id,
       DevAssert(harq->is_waiting);
       const int8_t pid = sched_ctrl->feedback_dl_harq.head;
       remove_front_nr_list(&sched_ctrl->feedback_dl_harq);
-      LOG_D(NR_MAC,"bit %d pid %d ack/nack %d\n",harq_bit,pid,harq_value);
+      LOG_D(NR_MAC,"%4d.%2d bit %d pid %d ack/nack %d\n",frame, slot, harq_bit,pid,harq_value);
       handle_dl_harq(mod_id, UE_id, pid, harq_value == 0 && harq_confidence == 0);
       if (harq_confidence == 1)  UE_info->mac_stats[UE_id].pucch0_DTX++;
     }
@@ -1493,10 +1494,11 @@ void handle_nr_uci_pucch_2_3_4(module_id_t mod_id,
   NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id];
 
   // tpc (power control)
-  sched_ctrl->tpc1 = nr_get_tpc(RC.nrmac[mod_id]->pucch_target_snrx10,
-                                uci_234->ul_cqi,
-                                30);
-  sched_ctrl->pucch_snrx10 = uci_234->ul_cqi * 5 - 640;
+  // TODO PUCCH2 SNR computation is not correct -> ignore the following
+  //sched_ctrl->tpc1 = nr_get_tpc(RC.nrmac[mod_id]->pucch_target_snrx10,
+  //                              uci_234->ul_cqi,
+  //                              30);
+  //sched_ctrl->pucch_snrx10 = uci_234->ul_cqi * 5 - 640;
 
   if ((uci_234->pduBitmap >> 1) & 0x01) {
     // iterate over received harq bits
@@ -1635,7 +1637,7 @@ int nr_acknack_scheduling(int mod_id,
   int bwp_size = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE);
 
   NR_sched_pucch_t *pucch = &sched_ctrl->sched_pucch[0];
-  LOG_D(NR_MAC, "In %s: %d.%d Trying to allocate pucch, current DAI %d\n", __FUNCTION__, frame, slot, pucch->dai_c);
+  LOG_D(NR_MAC, "In %s: %4d.%2d Trying to allocate pucch, current DAI %d\n", __FUNCTION__, frame, slot, pucch->dai_c);
 
   pucch->r_pucch=r_pucch;
   AssertFatal(pucch->csi_bits == 0,
@@ -1649,7 +1651,7 @@ int nr_acknack_scheduling(int mod_id,
      * the same slot again */
     const int f = pucch->frame;
     const int s = pucch->ul_slot;
-    LOG_D(NR_MAC, "In %s: %d.%d DAI = 2 pucch currently in %d.%d, advancing by 1 slot\n", __FUNCTION__, frame, slot, f, s);
+    LOG_D(NR_MAC, "In %s: %4d.%2d DAI = 2 pucch currently in %4d.%2d, advancing by 1 slot\n", __FUNCTION__, frame, slot, f, s);
     nr_fill_nfapi_pucch(mod_id, frame, slot, pucch, UE_id);
     memset(pucch, 0, sizeof(*pucch));
     pucch->frame = s == n_slots_frame - 1 ? (f + 1) % 1024 : f;
@@ -1676,7 +1678,7 @@ int nr_acknack_scheduling(int mod_id,
     }
   }
 
-  LOG_D(NR_MAC, "In %s: pucch_acknak 1. DL %d.%d, UL_ACK %d.%d, DAI_C %d\n", __FUNCTION__, frame, slot, pucch->frame, pucch->ul_slot, pucch->dai_c);
+  LOG_D(NR_MAC, "In %s: pucch_acknak 1. DL %4d.%2d, UL_ACK %4d.%2d, DAI_C %d\n", __FUNCTION__, frame, slot, pucch->frame, pucch->ul_slot, pucch->dai_c);
 
   // this is hardcoded for now as ue specific only if we are not on the initialBWP (to be fixed to allow ue_Specific also on initialBWP
   NR_BWP_UplinkDedicated_t *ubwpd=NULL;
@@ -1696,7 +1698,7 @@ int nr_acknack_scheduling(int mod_id,
   int max_fb_time = 0;
   get_pdsch_to_harq_feedback(mod_id, UE_id, bwp_Id, ss_type, &max_fb_time, pdsch_to_harq_feedback);
 
-  LOG_D(NR_MAC, "In %s: 1b. DL %d.%d, UL_ACK %d.%d, DAI_C %d\n", __FUNCTION__, frame,slot,pucch->frame,pucch->ul_slot,pucch->dai_c);
+  LOG_D(NR_MAC, "In %s: 1b. DL %4d.%2d, UL_ACK %4d.%2d, DAI_C %d\n", __FUNCTION__, frame,slot,pucch->frame,pucch->ul_slot,pucch->dai_c);
   /* there is a HARQ. Check whether we can use it for this ACKNACK */
   if (pucch->dai_c > 0) {
     /* this UE already has a PUCCH occasion */
@@ -1716,7 +1718,7 @@ int nr_acknack_scheduling(int mod_id,
       const int f = pucch->frame;
       const int s = pucch->ul_slot;
       const int n_slots_frame = nr_slots_per_frame[*scc->ssbSubcarrierSpacing];
-      LOG_D(NR_MAC, "In %s: %d.%d DAI > 0, cannot reach timing for pucch in %d.%d, advancing slot by 1 and trying again\n", __FUNCTION__, frame, slot, f, s);
+      LOG_D(NR_MAC, "In %s: %4d.%2d DAI > 0, cannot reach timing for pucch in %4d.%2d, advancing slot by 1 and trying again\n", __FUNCTION__, frame, slot, f, s);
       nr_fill_nfapi_pucch(mod_id, frame, slot, pucch, UE_id);
       memset(pucch, 0, sizeof(*pucch));
       pucch->frame = s == n_slots_frame - 1 ? (f + 1) % 1024 : f;
@@ -1730,11 +1732,11 @@ int nr_acknack_scheduling(int mod_id,
     pucch->timing_indicator = i;
     pucch->dai_c++;
     // retain old resource indicator, and we are good
-    LOG_D(NR_MAC, "In %s: %d.%d. DAI > 0, pucch allocated for %d.%d (index %d)\n", __FUNCTION__, frame,slot,pucch->frame,pucch->ul_slot,pucch->timing_indicator);
+    LOG_D(NR_MAC, "In %s: %4d.%2d. DAI > 0, pucch allocated for %4d.%2d (index %d)\n", __FUNCTION__, frame,slot,pucch->frame,pucch->ul_slot,pucch->timing_indicator);
     return 0;
   }
 
-  LOG_D(NR_MAC, "In %s: %d.%d DAI = 0, looking for new pucch occasion\n", __FUNCTION__, frame, slot);
+  LOG_D(NR_MAC, "In %s: %4d.%2d DAI = 0, looking for new pucch occasion\n", __FUNCTION__, frame, slot);
   /* we need to find a new PUCCH occasion */
 
   /*(Re)Inizialization of timing information*/
@@ -1837,7 +1839,7 @@ int nr_acknack_scheduling(int mod_id,
 
   pucch->timing_indicator = ind_found; // index in the list of timing indicators
 
-  LOG_D(NR_MAC, "In %s: 2. DAI 0 DL %d.%d, UL_ACK %d.%d (index %d)\n", __FUNCTION__, frame,slot,pucch->frame,pucch->ul_slot,pucch->timing_indicator);
+  LOG_D(NR_MAC, "In %s: 2. DAI 0 DL %4d.%2d, UL_ACK %4d.%2d (index %d)\n", __FUNCTION__, frame,slot,pucch->frame,pucch->ul_slot,pucch->timing_indicator);
 
   pucch->dai_c++;
   pucch->resource_indicator = 0; // each UE has dedicated PUCCH resources
diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c
index 5d1ddcb8ef3b894486bad3d9898d15a1f166101f..5cdca04bce57e86305efc1ac876339d188533dc1 100644
--- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c
+++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c
@@ -55,7 +55,7 @@ void calculate_preferred_ul_tda(module_id_t module_id, const NR_BWP_Uplink_t *ub
 
   /* there is a mixed slot only when in TDD */
   NR_ServingCellConfigCommon_t *scc = nrmac->common_channels->ServingCellConfigCommon;
-  lte_frame_type_t frame_type = nrmac->common_channels->frame_type;
+  frame_type_t frame_type = nrmac->common_channels->frame_type;
   const int n = nr_slots_per_frame[*scc->ssbSubcarrierSpacing];
 
   NR_ServingCellConfigCommonSIB_t *scc_sib1 = get_softmodem_params()->sa ?
@@ -213,11 +213,8 @@ int nr_process_mac_pdu(module_id_t module_idP,
                         int pdu_len)
 {
 
-    uint8_t rx_lcid;
+
     uint8_t done = 0;
-    uint16_t mac_ce_len;
-    uint16_t mac_subheader_len;
-    uint16_t mac_sdu_len;
 
     NR_UE_info_t *UE_info = &RC.nrmac[module_idP]->UE_info;
     NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id];
@@ -231,10 +228,9 @@ int nr_process_mac_pdu(module_id_t module_idP,
     #endif
 
     while (!done && pdu_len > 0){
-        mac_ce_len = 0;
-        mac_subheader_len = sizeof(NR_MAC_SUBHEADER_FIXED);
-        mac_sdu_len = 0;
-        rx_lcid = ((NR_MAC_SUBHEADER_FIXED *)pduP)->LCID;
+      uint16_t mac_len=0;
+      uint16_t mac_subheader_len=sizeof(NR_MAC_SUBHEADER_FIXED);
+      uint8_t rx_lcid = ((NR_MAC_SUBHEADER_FIXED *)pduP)->LCID;
 
         LOG_D(NR_MAC, "In %s: received UL-SCH sub-PDU with LCID 0x%x in %d.%d (remaining PDU length %d)\n", __func__, rx_lcid, frameP, slot, pdu_len);
 
@@ -249,7 +245,7 @@ int nr_process_mac_pdu(module_id_t module_idP,
             #endif*/
         case UL_SCH_LCID_RECOMMENDED_BITRATE_QUERY:
               // 38.321 Ch6.1.3.20
-              mac_ce_len = 2;
+              mac_len = 2;
               break;
         case UL_SCH_LCID_CONFIGURED_GRANT_CONFIRMATION:
                 // 38.321 Ch6.1.3.7
@@ -259,7 +255,7 @@ int nr_process_mac_pdu(module_id_t module_idP,
         case UL_SCH_LCID_S_TRUNCATED_BSR:
                //38.321 section 6.1.3.1
                //fixed length
-               mac_ce_len =1;
+               mac_len =1;
                /* Extract short BSR value */
                ce_ptr = &pduP[mac_subheader_len];
                NR_BSR_SHORT *bsr_s = (NR_BSR_SHORT *) ce_ptr;
@@ -284,16 +280,8 @@ int nr_process_mac_pdu(module_id_t module_idP,
                    to be a partial PDU at the end of this buffer, so here
                    we gracefully ignore that by returning 0. See:
                    https://gitlab.eurecom.fr/oai/openairinterface5g/-/issues/534 */
-                if (pdu_len < sizeof(NR_MAC_SUBHEADER_SHORT))
-                        return 0;
-        	mac_ce_len |= (uint16_t)((NR_MAC_SUBHEADER_SHORT *)pduP)->L;
-        	mac_subheader_len = 2;
-        	if(((NR_MAC_SUBHEADER_SHORT *)pduP)->F){
-                        if (pdu_len < sizeof(NR_MAC_SUBHEADER_LONG))
-                                return 0;
-        		mac_ce_len |= (uint16_t)(((NR_MAC_SUBHEADER_LONG *)pduP)->L2)<<8;
-        		mac_subheader_len = 3;
-        	}
+	  if (!get_mac_len(pduP, pdu_len, &mac_len, &mac_subheader_len))
+		  return 0;
         	/* Extract long BSR value */
                ce_ptr = &pduP[mac_subheader_len];
                NR_BSR_LONG *bsr_l = (NR_BSR_LONG *) ce_ptr;
@@ -339,14 +327,14 @@ int nr_process_mac_pdu(module_id_t module_idP,
 
         	//38.321 section 6.1.3.2
         	//fixed length
-        	mac_ce_len = 2;
+        	mac_len = 2;
         	/* Extract CRNTI value */
         	break;
 
         case UL_SCH_LCID_SINGLE_ENTRY_PHR:
         	//38.321 section 6.1.3.8
         	//fixed length
-        	mac_ce_len = 2;
+        	mac_len = 2;
         	/* Extract SINGLE ENTRY PHR elements for PHR calculation */
         	ce_ptr = &pduP[mac_subheader_len];
         	NR_SINGLE_ENTRY_PHR_MAC_CE *phr = (NR_SINGLE_ENTRY_PHR_MAC_CE *) ce_ptr;
@@ -367,32 +355,16 @@ int nr_process_mac_pdu(module_id_t module_idP,
         case UL_SCH_LCID_MULTI_ENTRY_PHR_1_OCT:
         	//38.321 section 6.1.3.9
         	//  varialbe length
-                if (pdu_len < sizeof(NR_MAC_SUBHEADER_SHORT))
-                        return 0;
-        	mac_ce_len |= (uint16_t)((NR_MAC_SUBHEADER_SHORT *)pduP)->L;
-        	mac_subheader_len = 2;
-        	if(((NR_MAC_SUBHEADER_SHORT *)pduP)->F){
-                        if (pdu_len < sizeof(NR_MAC_SUBHEADER_LONG))
-                                return 0;
-        		mac_ce_len |= (uint16_t)(((NR_MAC_SUBHEADER_LONG *)pduP)->L2)<<8;
-        		mac_subheader_len = 3;
-        	}
+	  if (!get_mac_len(pduP, pdu_len, &mac_len, &mac_subheader_len))
+	    return 0;
         	/* Extract MULTI ENTRY PHR elements from single octet bitmap for PHR calculation */
         	break;
 
         case UL_SCH_LCID_MULTI_ENTRY_PHR_4_OCT:
         	//38.321 section 6.1.3.9
         	//  varialbe length
-                if (pdu_len < sizeof(NR_MAC_SUBHEADER_SHORT))
-                        return 0;
-        	mac_ce_len |= (uint16_t)((NR_MAC_SUBHEADER_SHORT *)pduP)->L;
-        	mac_subheader_len = 2;
-        	if(((NR_MAC_SUBHEADER_SHORT *)pduP)->F){
-                        if (pdu_len < sizeof(NR_MAC_SUBHEADER_LONG))
-                                return 0;
-        		mac_ce_len |= (uint16_t)(((NR_MAC_SUBHEADER_LONG *)pduP)->L2)<<8;
-        		mac_subheader_len = 3;
-        	}
+	  if (!get_mac_len(pduP, pdu_len, &mac_len, &mac_subheader_len))
+	    return 0;
         	/* Extract MULTI ENTRY PHR elements from four octets bitmap for PHR calculation */
         	break;
 
@@ -403,27 +375,16 @@ int nr_process_mac_pdu(module_id_t module_idP,
 
         case UL_SCH_LCID_SRB1:
         case UL_SCH_LCID_SRB2:
-          if (pdu_len < sizeof(NR_MAC_SUBHEADER_SHORT))
-                return 0;
-          if(((NR_MAC_SUBHEADER_SHORT *)pduP)->F){
-            //mac_sdu_len |= (uint16_t)(((NR_MAC_SUBHEADER_LONG *)pduP)->L2)<<8;
-            if (pdu_len < sizeof(NR_MAC_SUBHEADER_LONG))
-                  return 0;
-            mac_subheader_len = 3;
-            mac_sdu_len = ((uint16_t)(((NR_MAC_SUBHEADER_LONG *) pduP)->L1 & 0x7f) << 8)
-                | ((uint16_t)((NR_MAC_SUBHEADER_LONG *) pduP)->L2 & 0xff);
-          } else {
-            mac_sdu_len = (uint16_t)((NR_MAC_SUBHEADER_SHORT *)pduP)->L;
-            mac_subheader_len = 2;
-          }
+	  if (!get_mac_len(pduP, pdu_len, &mac_len, &mac_subheader_len))
+	    return 0;
 
           rnti_t crnti = UE_info->rnti[UE_id];
           int UE_idx = UE_id;
           for (int i = 0; i < NR_NB_RA_PROC_MAX; i++) {
             NR_RA_t *ra = &RC.nrmac[module_idP]->common_channels[CC_id].ra[i];
             if (ra->state >= WAIT_Msg3 && ra->rnti == UE_info->rnti[UE_id]) {
-              uint8_t *next_subpduP = pduP + mac_subheader_len + mac_sdu_len;
-              if ((pduP[mac_subheader_len+mac_sdu_len] & 0x3F) == UL_SCH_LCID_C_RNTI) {
+              uint8_t *next_subpduP = pduP + mac_subheader_len + mac_len;
+              if ((pduP[mac_subheader_len+mac_len] & 0x3F) == UL_SCH_LCID_C_RNTI) {
                 crnti = ((next_subpduP[1]&0xFF)<<8)|(next_subpduP[2]&0xFF);
                 UE_idx = find_nr_UE_id(module_idP, crnti);
                 break;
@@ -432,7 +393,7 @@ int nr_process_mac_pdu(module_id_t module_idP,
           }
 
           if (UE_info->CellGroup[UE_idx]) {
-            LOG_D(NR_MAC, "[UE %d] Frame %d : ULSCH -> UL-DCCH %d (gNB %d, %d bytes), rnti: 0x%04x \n", module_idP, frameP, rx_lcid, module_idP, mac_sdu_len, crnti);
+            LOG_D(NR_MAC, "[UE %d] Frame %d : ULSCH -> UL-DCCH %d (gNB %d, %d bytes), rnti: 0x%04x \n", module_idP, frameP, rx_lcid, module_idP, mac_len, crnti);
             mac_rlc_data_ind(module_idP,
                              crnti,
                              module_idP,
@@ -441,7 +402,7 @@ int nr_process_mac_pdu(module_id_t module_idP,
                              MBMS_FLAG_NO,
                              rx_lcid,
                              (char *) (pduP + mac_subheader_len),
-                             mac_sdu_len,
+                             mac_len,
                              1,
                              NULL);
           } else {
@@ -459,23 +420,23 @@ int nr_process_mac_pdu(module_id_t module_idP,
 
           if ( rx_lcid == UL_SCH_LCID_CCCH1 ) {
             // RRCResumeRequest1 message includes the full I-RNTI and has a size of 8 bytes
-            mac_sdu_len = 8;
+            mac_len = 8;
 
             // Check if it is a valid CCCH1 message, we get all 00's messages very often
             int i = 0;
-            for(i=0; i<(mac_subheader_len+mac_sdu_len); i++) {
+            for(i=0; i<(mac_subheader_len+mac_len); i++) {
               if(pduP[i] != 0) {
                 break;
               }
             }
-            if (i == (mac_subheader_len+mac_sdu_len)) {
+            if (i == (mac_subheader_len+mac_len)) {
               LOG_D(NR_MAC, "%s() Invalid CCCH1 message!, pdu_len: %d\n", __func__, pdu_len);
               done = 1;
               break;
             }
           } else {
             // fixed length of 6 bytes
-            mac_sdu_len = 6;
+            mac_len = 6;
           }
 
           nr_mac_rrc_data_ind(module_idP,
@@ -486,26 +447,14 @@ int nr_process_mac_pdu(module_id_t module_idP,
                               UE_info->rnti[UE_id],
                               CCCH,
                               pduP + mac_subheader_len,
-                              mac_sdu_len,
+                              mac_len,
                               0);
           break;
 
         case UL_SCH_LCID_DTCH:
           //  check if LCID is valid at current time.
-          if (pdu_len < sizeof(NR_MAC_SUBHEADER_SHORT))
-                return 0;
-          if (((NR_MAC_SUBHEADER_SHORT *)pduP)->F) {
-            // mac_sdu_len |= (uint16_t)(((NR_MAC_SUBHEADER_LONG *)pduP)->L2)<<8;
-            if (pdu_len < sizeof(NR_MAC_SUBHEADER_LONG))
-                  return 0;
-            mac_subheader_len = 3;
-            mac_sdu_len = ((uint16_t)(((NR_MAC_SUBHEADER_LONG *)pduP)->L1 & 0x7f) << 8)
-                          | ((uint16_t)((NR_MAC_SUBHEADER_LONG *)pduP)->L2 & 0xff);
-
-          } else {
-            mac_sdu_len = (uint16_t)((NR_MAC_SUBHEADER_SHORT *)pduP)->L;
-            mac_subheader_len = 2;
-          }
+	  if (!get_mac_len(pduP, pdu_len, &mac_len, &mac_subheader_len))
+	    return 0;
 
           LOG_D(NR_MAC, "In %s: [UE %d] %d.%d : ULSCH -> UL-%s %d (gNB %d, %d bytes)\n",
                 __func__,
@@ -515,8 +464,8 @@ int nr_process_mac_pdu(module_id_t module_idP,
                 rx_lcid<4?"DCCH":"DTCH",
                 rx_lcid,
                 module_idP,
-                mac_sdu_len);
-          UE_info->mac_stats[UE_id].lc_bytes_rx[rx_lcid] += mac_sdu_len;
+                mac_len);
+          UE_info->mac_stats[UE_id].lc_bytes_rx[rx_lcid] += mac_len;
 
           mac_rlc_data_ind(module_idP,
                            UE_info->rnti[UE_id],
@@ -526,13 +475,13 @@ int nr_process_mac_pdu(module_id_t module_idP,
                            MBMS_FLAG_NO,
                            rx_lcid,
                            (char *)(pduP + mac_subheader_len),
-                           mac_sdu_len,
+                           mac_len,
                            1,
                            NULL);
 
           /* Updated estimated buffer when receiving data */
-          if (sched_ctrl->estimated_ul_buffer >= mac_sdu_len)
-            sched_ctrl->estimated_ul_buffer -= mac_sdu_len;
+          if (sched_ctrl->estimated_ul_buffer >= mac_len)
+            sched_ctrl->estimated_ul_buffer -= mac_len;
           else
             sched_ctrl->estimated_ul_buffer = 0;
           break;
@@ -547,16 +496,16 @@ int nr_process_mac_pdu(module_id_t module_idP,
         if (rx_lcid < 45 || rx_lcid == 52 || rx_lcid == 63) {
           LOG_I(NR_MAC, "In %s: dumping UL MAC SDU sub-header with length %d (LCID = 0x%02x):\n", __func__, mac_subheader_len, rx_lcid);
           log_dump(NR_MAC, pduP, mac_subheader_len, LOG_DUMP_CHAR, "\n");
-          LOG_I(NR_MAC, "In %s: dumping UL MAC SDU with length %d (LCID = 0x%02x):\n", __func__, mac_sdu_len, rx_lcid);
-          log_dump(NR_MAC, pduP + mac_subheader_len, mac_sdu_len, LOG_DUMP_CHAR, "\n");
+          LOG_I(NR_MAC, "In %s: dumping UL MAC SDU with length %d (LCID = 0x%02x):\n", __func__, mac_len, rx_lcid);
+          log_dump(NR_MAC, pduP + mac_subheader_len, mac_len, LOG_DUMP_CHAR, "\n");
         } else {
-          LOG_I(NR_MAC, "In %s: dumping UL MAC CE with length %d (LCID = 0x%02x):\n", __func__, mac_ce_len, rx_lcid);
-          log_dump(NR_MAC, pduP + mac_subheader_len + mac_sdu_len, mac_ce_len, LOG_DUMP_CHAR, "\n");
+          LOG_I(NR_MAC, "In %s: dumping UL MAC CE with length %d (LCID = 0x%02x):\n", __func__, mac_len, rx_lcid);
+          log_dump(NR_MAC, pduP + mac_subheader_len + mac_len, mac_len, LOG_DUMP_CHAR, "\n");
         }
         #endif
 
-        pduP += ( mac_subheader_len + mac_ce_len + mac_sdu_len );
-        pdu_len -= ( mac_subheader_len + mac_ce_len + mac_sdu_len );
+        pduP += ( mac_subheader_len + mac_len );
+        pdu_len -= ( mac_subheader_len + mac_len );
 
         if (pdu_len < 0) {
           LOG_E(NR_MAC, "In %s: residual UL MAC PDU in %d.%d with length < 0!, pdu_len %d \n", __func__, frameP, slot, pdu_len);
diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h
index 0f538131dddb0b4c6071ef46d17c28cfd9a72a15..e32e63a778cd9ea1be584291ffc15d5186c5717c 100644
--- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h
+++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h
@@ -202,7 +202,7 @@ typedef struct {
   int p_gNB;
   int Ncp;
   int nr_band;
-  lte_frame_type_t frame_type;
+  frame_type_t frame_type;
   uint64_t dl_CarrierFreq;
   NR_BCCH_BCH_Message_t *mib;
   NR_BCCH_DL_SCH_Message_t *sib1;
@@ -445,7 +445,7 @@ typedef struct NR_UE_harq {
 
   /* Transport block to be sent using this HARQ process, its size is in
    * sched_pdsch */
-  uint32_t tb[16384];
+  uint32_t transportBlock[16384];
   uint32_t tb_size;
 
   /// sched_pdsch keeps information on MCS etc used for the initial transmission
diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_entity_am.c b/openair2/LAYER2/nr_rlc/nr_rlc_entity_am.c
index af8cb5715adbb67ab2ca37d47bf4e5d46853ad64..2382db267fe68283e8ba2c251ec7d49966246daa 100644
--- a/openair2/LAYER2/nr_rlc/nr_rlc_entity_am.c
+++ b/openair2/LAYER2/nr_rlc/nr_rlc_entity_am.c
@@ -103,36 +103,6 @@ static int segment_already_received(nr_rlc_entity_am_t *entity,
   return size <= 0;
 }
 
-static void consider_retransmission(nr_rlc_entity_am_t *entity,
-    nr_rlc_sdu_segment_t *cur, int update_retx)
-{
-  if (update_retx)
-    cur->sdu->retx_count++;
-
-  /* let's report max RETX reached for all retx_count >= max_retx_threshold
-   * (specs say to report if retx_count == max_retx_threshold).
-   * Upper layers should react (radio link failure), so no big deal actually.
-   */
-  if (update_retx && cur->sdu->retx_count >= entity->max_retx_threshold) {
-    entity->common.max_retx_reached(entity->common.max_retx_reached_data,
-                                    (nr_rlc_entity_t *)entity);
-  }
-
-  /* let's put in retransmit list even if we are over max_retx_threshold.
-   * upper layers should deal with this condition, internally it's better
-   * for the RLC code to keep going with this segment (we only remove
-   * a segment that was ACKed)
-   */ 
-  LOG_D(RLC, "RLC segment to be added at the ReTx list \n"); 
-  nr_rlc_sdu_segment_list_append(&entity->retransmit_list,
-                                 &entity->retransmit_end,
-                                 cur);
-
-  /* update buffer status */
-  entity->common.bstatus.retx_size += compute_pdu_header_size(entity, cur)
-                                      + cur->size;
-}
-
 /* checks that all the bytes of the SDU sn have been received (but SDU
  * has not been already processed)
  */
@@ -315,81 +285,6 @@ static void reception_actions(nr_rlc_entity_am_t *entity, nr_rlc_pdu_t *pdu)
   }
 }
 
-static void process_received_ack(nr_rlc_entity_am_t *entity, int ack_sn)
-{
-  nr_rlc_sdu_segment_t head;
-  nr_rlc_sdu_segment_t *cur;
-  nr_rlc_sdu_segment_t *prev;
-  unsigned char sn_set[32768];  /* used to dec retx_count only once per sdu */
-
-  memset(sn_set, 0, 32768);
-
-#define IS_SN_SET(b) (sn_set[(b)/8] & (1 << ((b) % 8)))
-#define SET_SN(b) do { sn_set[(b)/8] |= (1 << ((b) % 8)); } while (0)
-
-  /* put SDUs from wait and retransmit lists with SN < 'ack_sn' to ack_list */
-
-  /* process wait list */
-  head.next = entity->wait_list;
-  prev = &head;
-  cur = entity->wait_list;
-  while (cur != NULL) {
-    if (sn_compare_tx(entity, cur->sdu->sn, ack_sn) < 0) {
-      /* remove from wait list */
-      prev->next = cur->next;
-      /* put the PDU in the ack list */
-      entity->ack_list = nr_rlc_sdu_segment_list_add(sn_compare_tx, entity,
-                                                     entity->ack_list, cur);
-      entity->wait_end = prev;
-      cur = prev->next;
-    } else {
-      entity->wait_end = cur;
-      prev = cur;
-      cur = cur->next;
-    }
-  }
-  entity->wait_list = head.next;
-  if (entity->wait_list == NULL)
-    entity->wait_end = NULL;
-
-  /* process retransmit list */
-  head.next = entity->retransmit_list;
-  prev = &head;
-  cur = entity->retransmit_list;
-  while (cur != NULL) {
-    if (sn_compare_tx(entity, cur->sdu->sn, ack_sn) < 0) {
-      /* dec. retx_count in case we put this segment back in retransmit list
-       * in 'process_received_nack'
-       * do it only once per SDU
-       */
-      if (!IS_SN_SET(cur->sdu->sn)) {
-        cur->sdu->retx_count--;
-        SET_SN(cur->sdu->sn);
-      }
-      /* remove from retransmit list */
-      prev->next = cur->next;
-      /* update buffer status */
-      entity->common.bstatus.retx_size -= compute_pdu_header_size(entity, cur)
-                                          + cur->size;
-      /* put the PDU in the ack list */
-      entity->ack_list = nr_rlc_sdu_segment_list_add(sn_compare_tx, entity,
-                                                     entity->ack_list, cur);
-      entity->retransmit_end = prev;
-      cur = prev->next;
-    } else {
-      entity->retransmit_end = cur;
-      prev = cur;
-      cur = cur->next;
-    }
-  }
-  entity->retransmit_list = head.next;
-  if (entity->retransmit_list == NULL)
-    entity->retransmit_end = NULL;
-
-#undef IS_BIT_SET
-#undef SET_BIT
-}
-
 static int so_overlap(int s1, int e1, int s2, int e2)
 {
   if (s1 < s2) {
@@ -402,136 +297,375 @@ static int so_overlap(int s1, int e1, int s2, int e2)
   return 0;
 }
 
-static void process_nack_sn(nr_rlc_entity_am_t *entity, int nack_sn,
-                            int so_start, int so_end, unsigned char *sn_set)
+static void process_control_pdu(nr_rlc_entity_am_t *entity,
+                                char *buffer, int size)
 {
-  /* put all SDU segments with SN == 'sn' and with an overlapping so start/end
-   * to the retransmit list
-   * source lists are ack list and wait list.
-   * Not sure if we should consider wait list, isn't the other end supposed
-   * to only NACK SNs lower than the ACK SN sent in the status PDU, in which
-   * case all potential SDU segments should all be in ack list when calling
-   * the current function? in doubt let's accept anything and thus process
-   * also wait list.
-   */
-  nr_rlc_sdu_segment_t head;
-  nr_rlc_sdu_segment_t *cur;
-  nr_rlc_sdu_segment_t *prev;
+#define R(d) do { if (nr_rlc_pdu_decoder_in_error(&d)) goto err; } while (0)
+  nr_rlc_pdu_decoder_t decoder;
+  int i;
+  int cpt;
+  int ack_sn;
+  int nack_sn;
+  int e1;
+  int e2;
+  int e3;
+  int so_start;
+  int so_end;
+  int range;
+  int prev_nack_sn = -1;
+  int prev_so_start;
+  int prev_so_end;
+  int tx_next_ack;
+  nr_rlc_sdu_segment_t *cur_wait_list;
+  nr_rlc_sdu_segment_t *prev_wait_list;
+  nr_rlc_sdu_segment_t *end_wait_list = NULL;
+  nr_rlc_sdu_segment_t head_wait_list;
+  nr_rlc_sdu_segment_t *cur_retransmit_list;
+  nr_rlc_sdu_segment_t *new_retransmit_list;
+  nr_rlc_sdu_segment_t head_retransmit_list;
+
+  head_wait_list.next = entity->wait_list;
+  cur_wait_list       = entity->wait_list;
+  prev_wait_list      = &head_wait_list;
+
+  head_retransmit_list.next = NULL;
+  cur_retransmit_list = entity->retransmit_list;
+  new_retransmit_list = &head_retransmit_list;
 
-#define IS_SN_SET(b) (sn_set[(b)/8] & (1 << ((b) % 8)))
-#define SET_SN(b) do { sn_set[(b)/8] |= (1 << ((b) % 8)); } while (0)
+  nr_rlc_pdu_decoder_init(&decoder, buffer, size);
+  nr_rlc_pdu_decoder_get_bits(&decoder, 1); R(decoder); /* dc */
 
-  /* check that tx_next_ack <= sn < tx_next */
-  if (!(sn_compare_tx(entity, entity->tx_next_ack, nack_sn) <= 0 &&
-        sn_compare_tx(entity, nack_sn, entity->tx_next) < 0))
-    return;
+  cpt = nr_rlc_pdu_decoder_get_bits(&decoder, 3); R(decoder);
+  if (cpt != 0) {
+    LOG_E(RLC, "%s:%d:%s: warning: discard PDU, CPT not 0 (%d)\n",
+          __FILE__, __LINE__, __FUNCTION__, cpt);
+    goto err;
+  }
+  ack_sn = nr_rlc_pdu_decoder_get_bits(&decoder, entity->sn_field_length); R(decoder);
+  e1 = nr_rlc_pdu_decoder_get_bits(&decoder, 1); R(decoder);
+  /* r bits */
+  if (entity->sn_field_length == 18) {
+    nr_rlc_pdu_decoder_get_bits(&decoder, 1); R(decoder);
+  } else {
+    nr_rlc_pdu_decoder_get_bits(&decoder, 7); R(decoder);
+  }
 
-  /* process wait list */
-  head.next = entity->wait_list;
-  prev = &head;
-  cur = entity->wait_list;
-  while (cur != NULL) {
-    if (cur->sdu->sn == nack_sn &&
-        so_overlap(so_start, so_end, cur->so, cur->so + cur->size - 1)) {
-      /* remove from wait list */
-      prev->next = cur->next;
-      cur->next = NULL;
-      /* consider the SDU segment for retransmission */
-      consider_retransmission(entity, cur, !IS_SN_SET(cur->sdu->sn));
-      SET_SN(cur->sdu->sn);
-      entity->wait_end = prev;
-      cur = prev->next;
+  /* 38.322 5.3.3.3 says to stop t_poll_retransmit if a ACK or NACK is
+   * received for the SN 'poll_sn' - check ACK case (NACK done below)
+   */
+  if (sn_compare_tx(entity, entity->poll_sn, ack_sn) < 0)
+    entity->t_poll_retransmit_start = 0;
+
+  while (e1) {
+    nack_sn = nr_rlc_pdu_decoder_get_bits(&decoder, entity->sn_field_length); R(decoder);
+    e1 = nr_rlc_pdu_decoder_get_bits(&decoder, 1); R(decoder);
+    e2 = nr_rlc_pdu_decoder_get_bits(&decoder, 1); R(decoder);
+    e3 = nr_rlc_pdu_decoder_get_bits(&decoder, 1); R(decoder);
+    /* r bits */
+    if (entity->sn_field_length == 18) {
+      nr_rlc_pdu_decoder_get_bits(&decoder, 3); R(decoder);
     } else {
-      entity->wait_end = cur;
-      prev = cur;
-      cur = cur->next;
+      nr_rlc_pdu_decoder_get_bits(&decoder, 1); R(decoder);
     }
-  }
-  entity->wait_list = head.next;
-  if (entity->wait_list == NULL)
-    entity->wait_end = NULL;
-
-  /* process ack list */
-  head.next = entity->ack_list;
-  prev = &head;
-  cur = entity->ack_list;
-  while (cur != NULL) {
-    if (cur->sdu->sn == nack_sn &&
-        so_overlap(so_start, so_end, cur->so, cur->so + cur->size - 1)) {
-      /* remove from ack list */
-      prev->next = cur->next;
-      cur->next = NULL;
-      /* consider the SDU segment for retransmission */
-      consider_retransmission(entity, cur, !IS_SN_SET(cur->sdu->sn));
-      SET_SN(cur->sdu->sn);
-      cur = prev->next;
+    if (e2) {
+      so_start = nr_rlc_pdu_decoder_get_bits(&decoder, 16); R(decoder);
+      so_end = nr_rlc_pdu_decoder_get_bits(&decoder, 16); R(decoder);
     } else {
-      prev = cur;
-      cur = cur->next;
+      so_start = 0;
+      so_end = 0xffff;
     }
-  }
-  entity->ack_list = head.next;
+    if (e3) {
+      range = nr_rlc_pdu_decoder_get_bits(&decoder, 8); R(decoder);
+    } else {
+      range = 1;
+    }
+    /* special value 0xffff indicates 'all bytes to the end' */
+    if (so_end == 0xffff)
+      so_end = -1;
 
-#undef IS_BIT_SET
-#undef SET_BIT
-}
+    /* process nacks */
+    for (i = 0; i < range; i++) {
+      int cur_nack_sn  = (nack_sn + i) % entity->sn_modulus;
+      int cur_so_start = i == 0 ?         so_start : 0;
+      int cur_so_end   = i == range - 1 ? so_end : -1;
 
-static void process_received_nack(nr_rlc_entity_am_t *entity, int nack_sn,
-                                  int so_start, int so_end, int range,
-                                  unsigned char *sn_set)
-{
-  int i;
+      /* check that current nack is > previous nack and <= ack
+       * if not then skip it and all following nacks, and
+       * do not touch t_poll_retransmit
+       */
+      if (prev_nack_sn != -1) {
+        int cmp = sn_compare_tx(entity, cur_nack_sn, prev_nack_sn);
+        if (cmp < 0
+            || (cmp == 0
+                && (prev_so_end == -1
+                    || cur_so_start <= prev_so_end))) {
+          LOG_E(RLC, "%s:%d:%s: bad NACK (nack sn %d so start/end %d/%d, previous nack sn %d so start/end %d/%d), skip it and all following NACKs\n",
+                __FILE__, __LINE__, __FUNCTION__,
+                cur_nack_sn, cur_so_start, cur_so_end,
+                prev_nack_sn, prev_so_start, prev_so_end);
+          goto nacks_done;
+        }
+      }
+      if (sn_compare_tx(entity, cur_nack_sn, ack_sn) > 0) {
+        LOG_E(RLC, "%s:%d:%s: bad NACK (nack %d ack %d), skip it and all following NACKs\n",
+              __FILE__, __LINE__, __FUNCTION__,
+              cur_nack_sn, ack_sn);
+        goto nacks_done;
+      }
 
-  for (i = 0; i < range; i++)
-    process_nack_sn(entity, (nack_sn + i) % entity->sn_modulus,
-                    i == 0 ?         so_start : 0,
-                    i == range - 1 ? so_end : -1,
-                    sn_set);
-}
+process_next_pdu:
+      /* process smallest SN either from wait_list or retransmit list */
+      if (cur_wait_list == NULL && cur_retransmit_list == NULL)
+        goto lists_over;
+      if (cur_wait_list == NULL)
+        goto process_retransmit_list_head;
+      if (cur_retransmit_list == NULL)
+        goto process_wait_list_head;
+      if (cur_wait_list->sdu->sn < cur_retransmit_list->sdu->sn
+          || (cur_wait_list->sdu->sn == cur_retransmit_list->sdu->sn &&
+              cur_wait_list->so < cur_retransmit_list->so))
+        goto process_wait_list_head;
+      goto process_retransmit_list_head;
+
+process_wait_list_head:
+      /* if nack overlaps with current segment, put it in retransmit list */
+      if (cur_wait_list->sdu->sn == cur_nack_sn
+          && so_overlap(cur_so_start, cur_so_end,
+                        cur_wait_list->so,
+                        cur_wait_list->so + cur_wait_list->size - 1)) {
+        prev_wait_list->next = cur_wait_list->next;
+        if (cur_wait_list == entity->wait_end)
+          end_wait_list = prev_wait_list;
+        cur_wait_list->next = NULL;
+        new_retransmit_list->next = cur_wait_list;
+        new_retransmit_list = cur_wait_list;
+        /* increase retx count. Don't care about segmentation, so maybe we
+         * increase too much.
+         */
+        cur_wait_list->sdu->retx_count++;
+        /* report max RETX reached for all retx_count >= max_retx_threshold
+         * (specs say to report if retx_count == max_retx_threshold).
+         * Upper layers should react (radio link failure), so no big deal.
+         * We deal with segmentation by requiring
+         * retx_count >= max_retx_threshold * number of segments.
+         * We may report max RETX reached too late/early. To be refined if
+         * this is a problem.
+         */
+        if (cur_wait_list->sdu->retx_count
+              >= entity->max_retx_threshold * cur_wait_list->sdu->ref_count)
+          entity->common.max_retx_reached(entity->common.max_retx_reached_data,
+                                          (nr_rlc_entity_t *)entity);
+        /* update buffer status */
+        entity->common.bstatus.retx_size += compute_pdu_header_size(entity, cur_wait_list)
+                                            + cur_wait_list->size;
+        /* and go process the next pdu, still for the current nack */
+        cur_wait_list = prev_wait_list->next;
+        goto process_next_pdu;
+      }
 
-static int sdu_segment_in_ack_list_full(nr_rlc_sdu_segment_t *sdu)
-{
-  int target_count = sdu->sdu->ref_count;
-  int actual_count = 0;
-  int sn = sdu->sdu->sn;
+      /* if current segment SN > current NACK, we can't classify it yet */
+      if (sn_compare_tx(entity, cur_wait_list->sdu->sn, cur_nack_sn) > 0
+          || (cur_wait_list->sdu->sn == cur_nack_sn
+              && cur_wait_list->so > cur_so_start))
+        goto done_nack;
 
-  while (sdu != NULL && sdu->sdu->sn == sn) {
-    actual_count++;
-    sdu = sdu->next;
-  }
+      /* if current segment is acked, free it, indicate successful delivery
+       * if fully acked
+       */
+      if (sn_compare_tx(entity, cur_wait_list->sdu->sn, ack_sn) < 0) {
+        nr_rlc_sdu_segment_t *cur = cur_wait_list;
+        int upper_layer_id = cur->sdu->upper_layer_id;
+        int sdu_size = cur->sdu->size;
+        cur_wait_list = cur_wait_list->next;
+        prev_wait_list->next = cur_wait_list;
+        if (cur_wait_list == entity->wait_end)
+          end_wait_list = prev_wait_list;
+        if (nr_rlc_free_sdu_segment(cur)) {
+          entity->tx_size -= sdu_size;
+          entity->common.sdu_successful_delivery(
+              entity->common.sdu_successful_delivery_data,
+              (nr_rlc_entity_t *)entity, upper_layer_id);
+        }
+        goto process_next_pdu;
+      }
 
-  return actual_count == target_count;
-}
+      /* if current segment SN > ack_sn, we're done with this list */
+      if (sn_compare_tx(entity, cur_wait_list->sdu->sn, ack_sn) > 0) {
+        cur_wait_list = NULL;
+        goto process_next_pdu;
+      }
 
-static void finalize_ack_nack_processing(nr_rlc_entity_am_t *entity)
-{
-  nr_rlc_sdu_segment_t *cur = entity->ack_list;
-  int sn;
+      /* current segment SN == ack_sn, skip this segment and move to the next.
+       * Not sure if correct, can we get a nack_sn == ack_sn? 38.322 5.3.4 says
+       * "set the ACK_SN to the SN of the next not received RLC SDU which is
+       * not indicated as missing in the resulting STATUS PDU." Is it okay to
+       * receive some NACK for a given SN and an ACK == this SN? I can see a
+       * case where it's possible (only parts of an SN were received and the
+       * TB is too small to report the several NACKs for this SN, then we
+       * can't set ACK = SN+1 but in this case, shouldn't we skip sending
+       * NACKs for this SN and only send ACK = SN? our current implementation
+       * does send both NACKs and ACK, see function generate_status()).
+       */
+      prev_wait_list = cur_wait_list;
+      cur_wait_list = cur_wait_list->next;
+      goto process_next_pdu;
+
+process_retransmit_list_head:
+      /* if nack overlaps with current segment, leave it in retransmit list */
+      if (cur_retransmit_list->sdu->sn == cur_nack_sn
+          && so_overlap(cur_so_start, cur_so_end,
+                        cur_retransmit_list->so,
+                        cur_retransmit_list->so + cur_retransmit_list->size - 1)) {
+        new_retransmit_list->next = cur_retransmit_list;
+        cur_retransmit_list = cur_retransmit_list->next;
+        new_retransmit_list = new_retransmit_list->next;
+        new_retransmit_list->next = NULL;
+        /* go process the next pdu, still for the current nack */
+        goto process_next_pdu;
+      }
 
-  /* - send indication of successful delivery for all consecutive acked SDUs
-   *   starting from tx_next_ack. Also free them.
-   * - update tx_next_ack to the next SN not acked yet
-   */
-  /* todo: send indication of successful delivery as soon as possible as
-   *       the specs say (38.322 5.2.3.1.1). As the code is, if we receive
-   *       ack for SN+2 we won't indicate successful delivery before
-   *       SN+1 has been indicated.
+      /* if current segment SN > current NACK, we can't classify it yet */
+      if (sn_compare_tx(entity, cur_retransmit_list->sdu->sn, cur_nack_sn) > 0
+          || (cur_retransmit_list->sdu->sn == cur_nack_sn
+              && cur_retransmit_list->so > cur_so_start))
+        goto done_nack;
+
+      /* if current segment is acked, free it, indicate successful delivery
+       * if fully acked
+       */
+      if (sn_compare_tx(entity, cur_retransmit_list->sdu->sn, ack_sn) < 0) {
+        nr_rlc_sdu_segment_t *cur = cur_retransmit_list;
+        int upper_layer_id = cur->sdu->upper_layer_id;
+        int sdu_size = cur->sdu->size;
+        cur_retransmit_list = cur_retransmit_list->next;
+        /* update buffer status */
+        entity->common.bstatus.retx_size -= compute_pdu_header_size(entity, cur)
+                                            + cur->size;
+        if (nr_rlc_free_sdu_segment(cur)) {
+          entity->tx_size -= sdu_size;
+          entity->common.sdu_successful_delivery(
+              entity->common.sdu_successful_delivery_data,
+              (nr_rlc_entity_t *)entity, upper_layer_id);
+        }
+        goto process_next_pdu;
+      }
+
+      /* current segment SN >= ack_sn
+       * if the wait list is empty, then put the remaining retransmit list at
+       * the end of the new retransmit list (just a speedup)
+       * if not, put only this segment
+       */
+      if (cur_wait_list == NULL) {
+        new_retransmit_list->next = cur_retransmit_list;
+        cur_retransmit_list = NULL;
+        goto lists_over;
+      }
+      new_retransmit_list->next = cur_retransmit_list;
+      cur_retransmit_list = cur_retransmit_list->next;
+      new_retransmit_list = new_retransmit_list->next;
+      new_retransmit_list->next = NULL;
+      goto process_next_pdu;
+
+done_nack:
+      prev_nack_sn  = cur_nack_sn;
+      prev_so_start = cur_so_start;
+      prev_so_end   = cur_so_end;
+    } /* for (i = 0; i < range; i++) */
+
+lists_over:
+    /* 38.322 5.3.3.3 says to stop t_poll_retransmit if a ACK or NACK is
+     * received for the SN 'poll_sn' - check NACK case (ACK done above)
+     */
+    if (sn_compare_tx(entity, nack_sn, entity->poll_sn) <= 0 &&
+        sn_compare_tx(entity, entity->poll_sn, (nack_sn + range) % entity->sn_modulus) < 0)
+      entity->t_poll_retransmit_start = 0;
+  } /* while (e1) */
+
+nacks_done:
+  /* nacks done, finish with ack */
+  /* we may report successful delivery out of order, if it's a problem
+   * then we can have a single loop and deal with the smallest sn of
+   * the current head of wait list and the current head of retransmit list.
+   * (It's simpler to process those two lists the one after the other.)
    */
-  while (cur != NULL && cur->sdu->sn == entity->tx_next_ack &&
-         sdu_segment_in_ack_list_full(cur)) {
-    entity->tx_size -= cur->sdu->size;
-    sn = cur->sdu->sn;
-    entity->common.sdu_successful_delivery(
-        entity->common.sdu_successful_delivery_data,
-        (nr_rlc_entity_t *)entity, cur->sdu->upper_layer_id);
-    while (cur != NULL && cur->sdu->sn == sn) {
-      nr_rlc_sdu_segment_t *s = cur;
-      cur = cur->next;
-      nr_rlc_free_sdu_segment(s);
+  /* deal with wait list */
+  while (cur_wait_list != NULL
+         && sn_compare_tx(entity, cur_wait_list->sdu->sn, ack_sn) < 0) {
+    /* current segment is acked, free it, indicate successful delivery
+     * if fully acked
+     */
+    nr_rlc_sdu_segment_t *cur = cur_wait_list;
+    int upper_layer_id = cur->sdu->upper_layer_id;
+    int sdu_size = cur->sdu->size;
+    prev_wait_list->next = cur_wait_list->next;
+    if (cur_wait_list == entity->wait_end)
+      end_wait_list = prev_wait_list;
+    cur_wait_list = cur_wait_list->next;
+    if (nr_rlc_free_sdu_segment(cur)) {
+      entity->tx_size -= sdu_size;
+      entity->common.sdu_successful_delivery(
+          entity->common.sdu_successful_delivery_data,
+          (nr_rlc_entity_t *)entity, upper_layer_id);
+    }
+  }
+  /* deal with retransmit list */
+  while (cur_retransmit_list != NULL
+         && sn_compare_tx(entity, cur_retransmit_list->sdu->sn, ack_sn) < 0) {
+    /* current segment is acked, free it, indicate successful delivery
+     * if fully acked
+     */
+    nr_rlc_sdu_segment_t *cur = cur_retransmit_list;
+    int upper_layer_id = cur->sdu->upper_layer_id;
+    int sdu_size = cur->sdu->size;
+    cur_retransmit_list = cur_retransmit_list->next;
+    /* update buffer status */
+    entity->common.bstatus.retx_size -= compute_pdu_header_size(entity, cur)
+                                        + cur->size;
+    if (nr_rlc_free_sdu_segment(cur)) {
+      entity->tx_size -= sdu_size;
+      entity->common.sdu_successful_delivery(
+          entity->common.sdu_successful_delivery_data,
+          (nr_rlc_entity_t *)entity, upper_layer_id);
     }
-    entity->ack_list = cur;
-    entity->tx_next_ack = (entity->tx_next_ack + 1) % entity->sn_modulus;
   }
+
+  new_retransmit_list->next = cur_retransmit_list;
+
+  entity->wait_list       = head_wait_list.next;
+  entity->retransmit_list = head_retransmit_list.next;
+
+  if (end_wait_list != NULL) {
+    if (end_wait_list == &head_wait_list)
+      entity->wait_end = NULL;
+    else
+      entity->wait_end = end_wait_list;
+  }
+
+  /* update tx_next_ack */
+  /* 38.322 5.2.3.1.1 says "set TX_Next_Ack equal to the SN of the RLC SDU
+   * with the smallest SN, whose SN falls within the range
+   * TX_Next_Ack <= SN <= TX_Next and for which a positive acknowledgment
+   * has not been received yet.
+   */
+  /* let's start from highest possible value and go down as needed */
+  tx_next_ack = entity->tx_next;
+  if (entity->wait_list != NULL
+      && sn_compare_tx(entity, entity->wait_list->sdu->sn, tx_next_ack) < 0)
+    tx_next_ack = entity->wait_list->sdu->sn;
+  if (entity->retransmit_list != NULL
+      && sn_compare_tx(entity, entity->retransmit_list->sdu->sn, tx_next_ack) < 0)
+    tx_next_ack = entity->retransmit_list->sdu->sn;
+  if (sn_compare_tx(entity, ack_sn, tx_next_ack) < 0)
+    tx_next_ack = ack_sn;
+  entity->tx_next_ack = tx_next_ack;
+
+  return;
+
+err:
+  LOG_E(RLC, "%s:%d:%s: error decoding PDU, NR RLC entity in inconsistent state\n",
+        __FILE__, __LINE__, __FUNCTION__);
+
+#undef R
 }
 
 void nr_rlc_entity_am_recv_pdu(nr_rlc_entity_t *_entity,
@@ -540,7 +674,6 @@ void nr_rlc_entity_am_recv_pdu(nr_rlc_entity_t *_entity,
 #define R(d) do { if (nr_rlc_pdu_decoder_in_error(&d)) goto err; } while (0)
   nr_rlc_entity_am_t *entity = (nr_rlc_entity_am_t *)_entity;
   nr_rlc_pdu_decoder_t decoder;
-  nr_rlc_pdu_decoder_t control_decoder;
   nr_rlc_pdu_t *pdu;
   int dc;
   int p = 0;
@@ -551,23 +684,11 @@ void nr_rlc_entity_am_recv_pdu(nr_rlc_entity_t *_entity,
   int is_first;
   int is_last;
 
-  int cpt;
-  int e1;
-  int e2;
-  int e3;
-  int ack_sn;
-  int nack_sn;
-  int so_start;
-  int so_end;
-  int range;
-  int control_e1;
-  int control_e2;
-  int control_e3;
-  unsigned char sn_set[32768];  /* used to dec retx_count only once per sdu */
-
   nr_rlc_pdu_decoder_init(&decoder, buffer, size);
   dc = nr_rlc_pdu_decoder_get_bits(&decoder, 1); R(decoder);
-  if (dc == 0) goto control;
+
+  if (dc == 0)
+    return process_control_pdu(entity, buffer, size);
 
   /* data PDU */
   p  = nr_rlc_pdu_decoder_get_bits(&decoder, 1); R(decoder);
@@ -596,20 +717,20 @@ void nr_rlc_entity_am_recv_pdu(nr_rlc_entity_t *_entity,
 
   /* dicard PDU if no data */
   if (data_size <= 0) {
-    LOG_W(RLC, "%s:%d:%s: warning: discard PDU, no data\n",
+    LOG_D(RLC, "%s:%d:%s: warning: discard PDU, no data\n",
           __FILE__, __LINE__, __FUNCTION__);
     goto discard;
   }
 
   /* dicard PDU if rx buffer is full */
   if (entity->rx_size + data_size > entity->rx_maxsize) {
-    LOG_W(RLC, "%s:%d:%s: warning: discard PDU, RX buffer full\n",
+    LOG_D(RLC, "%s:%d:%s: warning: discard PDU, RX buffer full\n",
           __FILE__, __LINE__, __FUNCTION__);
     goto discard;
   }
 
   if (!sn_in_recv_window(entity, sn)) {
-    LOG_W(RLC, "%s:%d:%s: warning: discard PDU, sn out of window (sn %d rx_next %d)\n",
+    LOG_D(RLC, "%s:%d:%s: warning: discard PDU, sn out of window (sn %d rx_next %d)\n",
           __FILE__, __LINE__, __FUNCTION__,
            sn, entity->rx_next);
     goto discard;
@@ -617,7 +738,7 @@ void nr_rlc_entity_am_recv_pdu(nr_rlc_entity_t *_entity,
 
   /* discard segment if all the bytes of the segment are already there */
   if (segment_already_received(entity, sn, so, data_size)) {
-    LOG_W(RLC, "%s:%d:%s: warning: discard PDU, already received\n",
+    LOG_D(RLC, "%s:%d:%s: warning: discard PDU, already received\n",
           __FILE__, __LINE__, __FUNCTION__);
     goto discard;
   }
@@ -650,118 +771,6 @@ void nr_rlc_entity_am_recv_pdu(nr_rlc_entity_t *_entity,
 
   return;
 
-control:
-  cpt = nr_rlc_pdu_decoder_get_bits(&decoder, 3); R(decoder);
-  if (cpt != 0) {
-    LOG_W(RLC, "%s:%d:%s: warning: discard PDU, CPT not 0 (%d)\n",
-          __FILE__, __LINE__, __FUNCTION__, cpt);
-    goto discard;
-  }
-  ack_sn = nr_rlc_pdu_decoder_get_bits(&decoder, entity->sn_field_length); R(decoder);
-  e1 = nr_rlc_pdu_decoder_get_bits(&decoder, 1); R(decoder);
-  /* r bits */
-  if (entity->sn_field_length == 18) {
-    nr_rlc_pdu_decoder_get_bits(&decoder, 1); R(decoder);
-  } else {
-    nr_rlc_pdu_decoder_get_bits(&decoder, 7); R(decoder);
-  }
-
-  /* let's try to parse the control PDU once to check consistency */
-  control_decoder = decoder;
-  control_e1 = e1;
-  while (control_e1) {
-    nack_sn = nr_rlc_pdu_decoder_get_bits(&control_decoder, entity->sn_field_length); R(control_decoder);
-    control_e1 = nr_rlc_pdu_decoder_get_bits(&control_decoder, 1); R(control_decoder);
-    control_e2 = nr_rlc_pdu_decoder_get_bits(&control_decoder, 1); R(control_decoder);
-    control_e3 = nr_rlc_pdu_decoder_get_bits(&control_decoder, 1); R(control_decoder);
-    /* r bits */
-    if (entity->sn_field_length == 18) {
-      nr_rlc_pdu_decoder_get_bits(&control_decoder, 3); R(control_decoder);
-    } else {
-      nr_rlc_pdu_decoder_get_bits(&control_decoder, 1); R(control_decoder);
-    }
-    /* check range and so_start/so_end consistency */
-    if (control_e2) {
-      so_start = nr_rlc_pdu_decoder_get_bits(&control_decoder, 16); R(control_decoder);
-      so_end = nr_rlc_pdu_decoder_get_bits(&control_decoder, 16); R(control_decoder);
-    } else {
-      so_start = 0;
-      so_end = 0xffff;
-    }
-    if (control_e3) {
-      range = nr_rlc_pdu_decoder_get_bits(&control_decoder, 8); R(control_decoder);
-    } else {
-      range = 1;
-    }
-    if (range < 1) {
-      LOG_E(RLC, "%s:%d:%s: error, bad 'range' in RLC NACK (sn %d)\n",
-            __FILE__, __LINE__, __FUNCTION__, nack_sn);
-      goto err;
-    }
-    /* so_start can be > so_end if more than one range; they don't refer
-     * to the same PDU then
-     */
-    if (range == 1 && so_end < so_start) {
-      LOG_E(RLC, "%s:%d:%s: error, bad so start/end (sn %d)\n",
-            __FILE__, __LINE__, __FUNCTION__, nack_sn);
-      goto err;
-    }
-  }
-
-  /* 38.322 5.3.3.3 says to stop t_poll_retransmit if a ACK or NACK is
-   * received for the SN 'poll_sn' - check ACK case (NACK done below)
-   */
-  if (sn_compare_tx(entity, entity->poll_sn, ack_sn) < 0)
-    entity->t_poll_retransmit_start = 0;
-
-  /* at this point, accept the PDU even if the actual values
-   * may be incorrect (eg. if so_start > so_end)
-   */
-  process_received_ack(entity, ack_sn);
-
-  if (e1)
-    memset(sn_set, 0, 32768);
-
-  while (e1) {
-    nack_sn = nr_rlc_pdu_decoder_get_bits(&decoder, entity->sn_field_length); R(decoder);
-    e1 = nr_rlc_pdu_decoder_get_bits(&decoder, 1); R(decoder);
-    e2 = nr_rlc_pdu_decoder_get_bits(&decoder, 1); R(decoder);
-    e3 = nr_rlc_pdu_decoder_get_bits(&decoder, 1); R(decoder);
-    /* r bits */
-    if (entity->sn_field_length == 18) {
-      nr_rlc_pdu_decoder_get_bits(&decoder, 3); R(decoder);
-    } else {
-      nr_rlc_pdu_decoder_get_bits(&decoder, 1); R(decoder);
-    }
-    if (e2) {
-      so_start = nr_rlc_pdu_decoder_get_bits(&decoder, 16); R(decoder);
-      so_end = nr_rlc_pdu_decoder_get_bits(&decoder, 16); R(decoder);
-    } else {
-      so_start = 0;
-      so_end = 0xffff;
-    }
-    if (e3) {
-      range = nr_rlc_pdu_decoder_get_bits(&decoder, 8); R(decoder);
-    } else {
-      range = 1;
-    }
-    /* special value 0xffff indicates 'all bytes to the end' */
-    if (so_end == 0xffff)
-      so_end = -1;
-    process_received_nack(entity, nack_sn, so_start, so_end, range, sn_set);
-
-    /* 38.322 5.3.3.3 says to stop t_poll_retransmit if a ACK or NACK is
-     * received for the SN 'poll_sn' - check NACK case (ACK done above)
-     */
-    if (sn_compare_tx(entity, nack_sn, entity->poll_sn) <= 0 &&
-        sn_compare_tx(entity, entity->poll_sn, (nack_sn + range) % entity->sn_modulus) < 0)
-      entity->t_poll_retransmit_start = 0;
-  }
-
-  finalize_ack_nack_processing(entity);
-
-  return;
-
 err:
   LOG_W(RLC, "%s:%d:%s: error decoding PDU, discarding\n", __FILE__, __LINE__, __FUNCTION__);
   goto discard;
@@ -908,8 +917,6 @@ typedef struct {
   int so_start;
   int sn_end;
   int so_end;
-  /* data for maximum ack */
-  int ack_sn;                               /* -1 if not to be used */
   /* pdu to use for next call to 'next_missing' */
   nr_rlc_pdu_t *next;
 } missing_data_t;
@@ -924,13 +931,12 @@ static missing_data_t next_missing(nr_rlc_entity_am_t *entity,
   int max_so       = 0;
   int last_reached = 0;
 
-  ret.ack_sn = -1;
-
   /* special case: missing part before the head of RX list */
   if (check_head) {
     if (cur->sn != entity->rx_next || !cur->is_first) {
       /* don't report if out of reporting window */
-      if (sn_compare_rx(entity, entity->rx_highest_status, cur->sn) <= 0) {
+      if (sn_compare_rx(entity, entity->rx_highest_status,
+                        entity->rx_next) <= 0) {
         ret.sn_start = -1;
         return ret;
       }
@@ -954,10 +960,6 @@ next_pdu:
     max_so = cur_max_so;
   last_reached = last_reached | cur->is_last;
 
-  /* if cur already processed, it can be the acked SDU */
-  if (cur->data == NULL)
-    ret.ack_sn = (cur->sn + 1) % entity->sn_modulus;
-
   /* no next? */
   if (cur->next == NULL) {
     /* inform the caller that work is over */
@@ -1033,32 +1035,36 @@ next_pdu:
   }
 
   /* discontinuity between different SDUs */
-  ret.sn_start = sn;
+  if (last_reached) {
+    ret.sn_start = (sn + 1) % entity->sn_modulus;
+    ret.so_start = 0;
+  } else {
+    ret.sn_start = sn;
+    ret.so_start = max_so + 1;
+  }
   /* don't report if out of reporting window */
   if (sn_compare_rx(entity, entity->rx_highest_status, ret.sn_start) <= 0) {
     ret.sn_start = -1;
     return ret;
   }
-  ret.so_start = max_so + 1;
 
 set_end_different_sdu:
-  /* don't go more than rx_highest_status - 1 */
-  if (sn_compare_rx(entity, entity->rx_highest_status, cur->sn) <= 0) {
-    ret.sn_end = (entity->rx_highest_status - 1 + entity->sn_modulus) %
-                      entity->sn_modulus;
-    ret.so_end   = 0xffff;
-    return ret;
-  }
-
   /* if cur is the head of a SDU, then use cur-1 */
   if (cur->is_first) {
     ret.sn_end = (cur->sn - 1 + entity->sn_modulus) % entity->sn_modulus;
     ret.so_end = 0xffff;
-    return ret;
+  } else {
+    ret.sn_end = cur->sn;
+    ret.so_end = cur->so - 1;
+  }
+  /* don't go more than rx_highest_status - 1 */
+  if (sn_compare_rx(entity, entity->rx_highest_status, ret.sn_end) <= 0) {
+    ret.sn_end = (entity->rx_highest_status - 1 + entity->sn_modulus) %
+                      entity->sn_modulus;
+    ret.so_end   = 0xffff;
+    ret.next = NULL;
   }
 
-  ret.sn_end = cur->sn;
-  ret.so_end = cur->so - 1;
   return ret;
 }
 
@@ -1098,21 +1104,20 @@ static void get_e1_position(nr_rlc_entity_am_t *entity,
   }
 }
 
-/* returns the number of nacks serialized.
- * In most cases it is 1, it can be more if the
- * missing data consists of a range that is more
- * than 255 SNs in which case it has to be cut in
- * smaller ranges.
+/* returns the last nack SN generated, -1 if nothing generated.
  * If there is no more room in the status buffer,
  * will set m->next = NULL (and may serialize
- * less nacks than required by 'm').
+ * less nacks than required by 'm'), also
+ * sets *generation_truncated to 1.
  */
 static int generate_missing(nr_rlc_entity_am_t *entity,
                             nr_rlc_pdu_encoder_t *encoder,
-                            missing_data_t *m, int *e1_byte, int *e1_bit)
+                            missing_data_t *m, int *e1_byte, int *e1_bit,
+                            int *generation_truncated,
+                            unsigned char **so_end_address)
 {
   int r_bits = entity->sn_field_length == 18 ? 3 : 1;
-  int range_count = 0;
+  int last_nack_generated = -1;
   int sn_start;
   int so_start;
   int sn_end;
@@ -1164,6 +1169,7 @@ static int generate_missing(nr_rlc_entity_am_t *entity,
     m_nack.so_end = so_end;
     if (encoder->byte + nack_size(entity, &m_nack) > encoder->size) {
       m->next = NULL;
+      *generation_truncated = 1;
       break;
     }
 
@@ -1197,6 +1203,7 @@ static int generate_missing(nr_rlc_entity_am_t *entity,
     /* nack_sn */
     nr_rlc_pdu_encoder_put_bits(encoder, sn_start,
                                 entity->sn_field_length);
+    last_nack_generated = sn_start;
     /* e1 = 0 (set later if needed) */
     nr_rlc_pdu_encoder_put_bits(encoder, 0, 1);
     /* e2 */
@@ -1208,34 +1215,44 @@ static int generate_missing(nr_rlc_entity_am_t *entity,
     /* so_start/so_end */
     if (e2) {
       nr_rlc_pdu_encoder_put_bits(encoder, so_start, 16);
+      *so_end_address = (unsigned char *)encoder->buffer + encoder->byte;
       nr_rlc_pdu_encoder_put_bits(encoder, so_end, 16);
-    }
+    } else
+      *so_end_address = NULL;
     /* nack range */
-    if (e3)
+    if (e3) {
       nr_rlc_pdu_encoder_put_bits(encoder, cur_sn_count, 8);
+      last_nack_generated += cur_sn_count - 1;
+    }
 
     sn_count -= cur_sn_count;
     sn_start = (sn_start + cur_sn_count) % entity->sn_modulus;
-    range_count++;
   }
 
-  return range_count;
+  return last_nack_generated;
 }
 
 static int generate_status(nr_rlc_entity_am_t *entity, char *buffer, int size)
 {
-  int                  ack_sn = entity->rx_next;
-  missing_data_t  m;
+  int                  last_nack;
+  int                  ack_sn;
+  missing_data_t       m;
   nr_rlc_pdu_t         *cur;
-  int                  nack_count = 0;
+  int                  check_head = 1;
   nr_rlc_pdu_encoder_t encoder;
   int                  e1_byte;
   int                  e1_bit;
+  int                  generation_truncated;
+  int                  ln;
+  unsigned char        *so_end_address = NULL;
 
   /* if not enough room, do nothing */
   if (size < 3)
     return 0;
 
+  /* initial last_nack is rx_next - 1 */
+  last_nack = (entity->rx_next - 1 + entity->sn_modulus) % entity->sn_modulus;
+
   nr_rlc_pdu_encoder_init(&encoder, buffer, size);
 
   /* first 3 bytes, ack_sn and e1 will be set later */
@@ -1250,22 +1267,33 @@ static int generate_status(nr_rlc_entity_am_t *entity, char *buffer, int size)
   e1_bit = entity->sn_field_length == 18 ? 1 : 7;
 
   while (cur != NULL) {
-    m = next_missing(entity, cur, nack_count == 0);
-
-    /* update ack_sn if the returned value is valid */
-    if (m.ack_sn != -1)
-      ack_sn = m.ack_sn;
+    m = next_missing(entity, cur, check_head);
+    check_head = 0;
 
     /* stop here if no more nack to report */
     if (m.sn_start == -1)
       break;
 
-    nack_count += generate_missing(entity, &encoder, &m, &e1_byte, &e1_bit);
+    generation_truncated = 0;
+    ln = generate_missing(entity, &encoder, &m, &e1_byte, &e1_bit,
+                          &generation_truncated, &so_end_address);
+    /* remember the last nack put, if any */
+    if (ln != -1)
+      last_nack = ln;
+    /* if generation was truncated and so_end was put, we force its value to
+     * 0xffff (end of SDU) because we don't know what missing nack information
+     * was supposed to be put, so we nack until the end of the PDU to be sure
+     */
+    if (generation_truncated && so_end_address != NULL) {
+      so_end_address[0] = 0xff;
+      so_end_address[1] = 0xff;
+    }
 
     cur = m.next;
   }
 
-  /* put ack_sn */
+  /* put ack_sn, which is last_nack + 1 */
+  ack_sn = (last_nack + 1) % entity->sn_modulus;
   if (entity->sn_field_length == 12) {
     buffer[0] = ack_sn >> 8;
     buffer[1] = ack_sn & 255;
@@ -1427,8 +1455,6 @@ static int generate_retx_pdu(nr_rlc_entity_am_t *entity, char *buffer,
     return 0;
 
   entity->retransmit_list = entity->retransmit_list->next;
-  if (entity->retransmit_list == NULL)
-    entity->retransmit_end = NULL;
 
   sdu->next = NULL;
 
@@ -1444,15 +1470,24 @@ static int generate_retx_pdu(nr_rlc_entity_am_t *entity, char *buffer,
     /* put the second SDU back at the head of the retransmit list */
     next_sdu->next = entity->retransmit_list;
     entity->retransmit_list = next_sdu;
-    if (entity->retransmit_end == NULL)
-      entity->retransmit_end = entity->retransmit_list;
     /* update buffer status */
     entity->common.bstatus.retx_size += compute_pdu_header_size(entity, next_sdu)
                                         + next_sdu->size;
   }
 
   /* put SDU/SDU segment in the wait list */
-  nr_rlc_sdu_segment_list_append(&entity->wait_list, &entity->wait_end, sdu);
+  /* speedup: check end of wait list, maybe the new sdu comes after */
+  if (entity->wait_end == NULL
+      || sn_compare_tx(entity, sdu->sdu->sn, entity->wait_end->sdu->sn) > 0
+      || (sn_compare_tx(entity, sdu->sdu->sn, entity->wait_end->sdu->sn) == 0
+          && sdu->so > entity->wait_end->so))
+    nr_rlc_sdu_segment_list_append(&entity->wait_list, &entity->wait_end, sdu);
+  else {
+    entity->wait_list = nr_rlc_sdu_segment_list_add(sn_compare_tx, entity,
+                            entity->wait_list, sdu);
+    if (entity->wait_list->next == NULL)
+      entity->wait_end = entity->wait_list;
+  }
 
   p = check_poll_after_pdu_assembly(entity);
 
@@ -1519,7 +1554,18 @@ static int generate_tx_pdu(nr_rlc_entity_am_t *entity, char *buffer, int size)
     entity->tx_next = (entity->tx_next + 1) % entity->sn_modulus;
 
   /* put SDU/SDU segment in the wait list */
-  nr_rlc_sdu_segment_list_append(&entity->wait_list, &entity->wait_end, sdu);
+  /* speedup: check end of wait list, probably the new sdu comes after */
+  if (entity->wait_end == NULL
+      || sn_compare_tx(entity, sdu->sdu->sn, entity->wait_end->sdu->sn) > 0
+      || (sn_compare_tx(entity, sdu->sdu->sn, entity->wait_end->sdu->sn) == 0
+          && sdu->so > entity->wait_end->so))
+    nr_rlc_sdu_segment_list_append(&entity->wait_list, &entity->wait_end, sdu);
+  else {
+    entity->wait_list = nr_rlc_sdu_segment_list_add(sn_compare_tx, entity,
+                            entity->wait_list, sdu);
+    if (entity->wait_list->next == NULL)
+      entity->wait_end = entity->wait_list;
+  }
 
   /* polling actions for a new PDU */
   entity->pdu_without_poll++;
@@ -1629,11 +1675,7 @@ void nr_rlc_entity_am_recv_sdu(nr_rlc_entity_t *_entity,
 
 static void check_t_poll_retransmit(nr_rlc_entity_am_t *entity)
 {
-  nr_rlc_sdu_segment_t head;
   nr_rlc_sdu_segment_t *cur;
-  nr_rlc_sdu_segment_t *prev;
-  int sn;
-  int old_retx_count;
 
   /* 38.322 5.3.3.4 */
   /* did t_poll_retransmit expire? */
@@ -1659,74 +1701,58 @@ static void check_t_poll_retransmit(nr_rlc_entity_am_t *entity)
    */
   entity->force_poll = 1;
 
-  LOG_W(RLC, "%s:%d:%s: warning: t_poll_retransmit expired\n",
+  LOG_D(RLC, "%s:%d:%s: warning: t_poll_retransmit expired\n",
         __FILE__, __LINE__, __FUNCTION__);
 
   /* do we meet conditions of 38.322 5.3.3.4? */
   if (!check_poll_after_pdu_assembly(entity))
     return;
 
-  /* search wait list for SDU with highest SN */
-  /* this code may be incorrect: in LTE we had to look for PDU
-   * with SN = VT(S) - 1, but for NR the specs say "highest SN among the
-   * ones submitted to lower layers" not 'tx_next - 1'. So we should look
-   * for the highest SN in the wait list. But that's no big deal. If the
-   * program runs this code, then the connection is in a bad state and we
-   * can retransmit whatever we want. At some point we will receive a status
-   * report and retransmit what we really have to. Actually we could just
-   * retransmit the head of wait list (the specs have this 'or').
-   * (Actually, maybe this interpretation is not correct and what the code
-   * does is correct. The specs are confusing.)
+  /* retransmit the head of wait list, this is the case
+   * "consider any RLC SDU which has not been positively acknowledged for
+   * retransmission" of 36.322 5.3.3.4.
+   * We don't search for the highest SN, it's simpler to just take the head
+   * of wait list. This can be changed if needed.
    */
-  sn = (entity->tx_next - 1 + entity->sn_modulus) % entity->sn_modulus;
-
-  head.next = entity->wait_list;
   cur = entity->wait_list;
-  prev = &head;
-
-  while (cur != NULL) {
-    if (cur->sdu->sn == sn)
-      break;
-    prev = cur;
-    cur = cur->next;
-  }
-
-  /* SDU with highest SN not found? take the head of wait list */
-  if (cur == NULL) {
-    cur = entity->wait_list;
-    prev = &head;
-    sn = cur->sdu->sn;
-  }
 
   /* todo: do we need to for check cur == NULL?
    * It seems that no, the wait list should not be empty here, but not sure.
    */
 
-  old_retx_count = cur->sdu->retx_count;
+  entity->wait_list = cur->next;
+  if (entity->wait_list == NULL)
+     entity->wait_end = NULL;
 
-  /* 38.322 says "SDU", not "SDU segment", so let's retransmit all
-   * SDU segments with this SN
+  /* 38.322 says "SDU", not "SDU segment", but let's retransmit only
+   * the 'cur' SDU segment. To be changed if needed. (Maybe we have
+   * to retransmit all SDU segments with the same SN that are in the
+   * wait list.)
    */
-  /* todo: maybe we could simply retransmit the current SDU segment,
-   * so that we don't have to run through the full wait list.
+
+  /* increase retx count. Don't care about segmentation, so maybe we
+   * increase too much.
    */
-  while (cur != NULL) {
-    if (cur->sdu->sn == sn) {
-      prev->next = cur->next;
-      cur->next = NULL;
-      /* put in retransmit list */
-      consider_retransmission(entity, cur,
-                              old_retx_count == cur->sdu->retx_count);
-    } else {
-      prev = cur;
-    }
-    cur = prev->next;
-  }
-  entity->wait_list = head.next;
-  /* reset wait_end (todo: optimize?) */
-  entity->wait_end = entity->wait_list;
-  while (entity->wait_end != NULL && entity->wait_end->next != NULL)
-    entity->wait_end = entity->wait_end->next;
+  cur->sdu->retx_count++;
+  /* report max RETX reached for all retx_count >= max_retx_threshold
+   * (specs say to report if retx_count == max_retx_threshold).
+   * Upper layers should react (radio link failure), so no big deal.
+   * We deal with segmentation by requiring
+   * retx_count >= max_retx_threshold * number of segments.
+   * We may report max RETX reached too late/early. To be refined if
+   * this is a problem.
+   */
+  if (cur->sdu->retx_count
+        >= entity->max_retx_threshold * cur->sdu->ref_count)
+    entity->common.max_retx_reached(entity->common.max_retx_reached_data,
+                                    (nr_rlc_entity_t *)entity);
+  /* update buffer status */
+  entity->common.bstatus.retx_size += compute_pdu_header_size(entity, cur)
+                                      + cur->size;
+
+  /* put in retransmit list */
+  entity->retransmit_list = nr_rlc_sdu_segment_list_add(sn_compare_tx, entity,
+                                entity->retransmit_list, cur);
 }
 
 static void check_t_reassembly(nr_rlc_entity_am_t *entity)
@@ -1815,6 +1841,7 @@ void nr_rlc_entity_am_discard_sdu(nr_rlc_entity_t *_entity, int sdu_id)
   entity->common.bstatus.tx_size -= compute_pdu_header_size(entity, cur)
                                     + cur->size;
 
+  entity->tx_size -= cur->sdu->size;
   nr_rlc_free_sdu_segment(cur);
 }
 
@@ -1857,7 +1884,6 @@ static void clear_entity(nr_rlc_entity_am_t *entity)
   nr_rlc_free_sdu_segment_list(entity->tx_list);
   nr_rlc_free_sdu_segment_list(entity->wait_list);
   nr_rlc_free_sdu_segment_list(entity->retransmit_list);
-  nr_rlc_free_sdu_segment_list(entity->ack_list);
 
   entity->tx_list         = NULL;
   entity->tx_end          = NULL;
@@ -1867,9 +1893,6 @@ static void clear_entity(nr_rlc_entity_am_t *entity)
   entity->wait_end        = NULL;
 
   entity->retransmit_list = NULL;
-  entity->retransmit_end  = NULL;
-
-  entity->ack_list        = NULL;
 
   entity->common.bstatus.tx_size   = 0;
   entity->common.bstatus.retx_size = 0;
diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_entity_am.h b/openair2/LAYER2/nr_rlc/nr_rlc_entity_am.h
index 453fe870265ac8e8fce2d104672d6ef213e11471..57ae1a3485698dd7056e87d97b01b51f35ac001d 100644
--- a/openair2/LAYER2/nr_rlc/nr_rlc_entity_am.h
+++ b/openair2/LAYER2/nr_rlc/nr_rlc_entity_am.h
@@ -84,9 +84,6 @@ typedef struct {
   nr_rlc_sdu_segment_t *wait_end;
 
   nr_rlc_sdu_segment_t *retransmit_list;
-  nr_rlc_sdu_segment_t *retransmit_end;
-
-  nr_rlc_sdu_segment_t *ack_list;
 } nr_rlc_entity_am_t;
 
 void nr_rlc_entity_am_recv_sdu(nr_rlc_entity_t *entity,
diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_sdu.c b/openair2/LAYER2/nr_rlc/nr_rlc_sdu.c
index ef0d52558aa402c3701d72ab9f8e0d2a492a6d57..ef64389ac559c8554fcc21a0c6c042b9c7067a86 100644
--- a/openair2/LAYER2/nr_rlc/nr_rlc_sdu.c
+++ b/openair2/LAYER2/nr_rlc/nr_rlc_sdu.c
@@ -58,14 +58,19 @@ oom:
   exit(1);
 }
 
-void nr_rlc_free_sdu_segment(nr_rlc_sdu_segment_t *sdu)
+int nr_rlc_free_sdu_segment(nr_rlc_sdu_segment_t *sdu)
 {
-  sdu->sdu->ref_count--;
-  if (sdu->sdu->ref_count == 0) {
+  int ret = 0;
+
+  sdu->sdu->free_count++;
+  if (sdu->sdu->free_count == sdu->sdu->ref_count) {
     free(sdu->sdu->data);
     free(sdu->sdu);
+    ret = 1;
   }
   free(sdu);
+
+  return ret;
 }
 
 void nr_rlc_sdu_segment_list_append(nr_rlc_sdu_segment_t **list,
diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_sdu.h b/openair2/LAYER2/nr_rlc/nr_rlc_sdu.h
index f4585fb7d62342f4b5a5065c1c778d05c27ff063..20cc90f185aadc9f3993c85aaa24eaef87bf3359 100644
--- a/openair2/LAYER2/nr_rlc/nr_rlc_sdu.h
+++ b/openair2/LAYER2/nr_rlc/nr_rlc_sdu.h
@@ -30,6 +30,10 @@ typedef struct nr_rlc_sdu_t {
   int retx_count;
 
   int ref_count;      /* incremented each time the SDU is segmented */
+  int free_count;     /* incremented each time a segment is freed
+                       * when it equals ref_count we can free the SDU
+                       * completely
+                       */
 } nr_rlc_sdu_t;
 
 typedef struct nr_rlc_sdu_segment_t {
@@ -44,7 +48,8 @@ typedef struct nr_rlc_sdu_segment_t {
 nr_rlc_sdu_segment_t *nr_rlc_new_sdu(
     char *buffer, int size,
     int upper_layer_id);
-void nr_rlc_free_sdu_segment(nr_rlc_sdu_segment_t *sdu);
+/* return 1 if the SDU has been freed too, 0 if not (more segments to free) */
+int nr_rlc_free_sdu_segment(nr_rlc_sdu_segment_t *sdu);
 void nr_rlc_sdu_segment_list_append(nr_rlc_sdu_segment_t **list,
                                     nr_rlc_sdu_segment_t **end,
                                     nr_rlc_sdu_segment_t *sdu);
diff --git a/openair2/LAYER2/nr_rlc/tests/test14.txt.gz b/openair2/LAYER2/nr_rlc/tests/test14.txt.gz
index 53616dae3d10b71375cea41ca9061d4304f64dcf..45e54651eb317c3b7695cfcab7428fe43172227b 100644
Binary files a/openair2/LAYER2/nr_rlc/tests/test14.txt.gz and b/openair2/LAYER2/nr_rlc/tests/test14.txt.gz differ
diff --git a/openair2/LAYER2/nr_rlc/tests/test15.txt.gz b/openair2/LAYER2/nr_rlc/tests/test15.txt.gz
index 2619436c2d4740017eb6b620d8fd0c7b919d3d84..ddb895d56f0fe88f0ceffb9a100359413292f2b7 100644
Binary files a/openair2/LAYER2/nr_rlc/tests/test15.txt.gz and b/openair2/LAYER2/nr_rlc/tests/test15.txt.gz differ
diff --git a/openair2/M2AP/m2ap_MCE_defs.h b/openair2/M2AP/m2ap_MCE_defs.h
index 5267232d69f5482ae6cab17371d0629aadbdc0e4..73183e89c2a9e3e8fdc38351d52d79d81328db09 100644
--- a/openair2/M2AP/m2ap_MCE_defs.h
+++ b/openair2/M2AP/m2ap_MCE_defs.h
@@ -170,7 +170,7 @@ typedef struct m2ap_MCE_instance_s {
   int32_t                 uplink_frequency_offset[MAX_NUM_CCs];
   uint32_t                Nid_cell[MAX_NUM_CCs];
   int16_t                 N_RB_DL[MAX_NUM_CCs];
-  lte_frame_type_t        frame_type[MAX_NUM_CCs];
+  frame_type_t            frame_type[MAX_NUM_CCs];
   uint32_t                fdd_earfcn_DL[MAX_NUM_CCs];
   uint32_t                fdd_earfcn_UL[MAX_NUM_CCs];
   int                     num_cc;
diff --git a/openair2/M2AP/m2ap_eNB_defs.h b/openair2/M2AP/m2ap_eNB_defs.h
index b8f7e4b3c61600651e2b2f0ceeb520d23b8357a7..0b30c33d80253381b56e62658bc32a38f5e46776 100644
--- a/openair2/M2AP/m2ap_eNB_defs.h
+++ b/openair2/M2AP/m2ap_eNB_defs.h
@@ -181,7 +181,7 @@ typedef struct m2ap_eNB_instance_s {
   int32_t                 uplink_frequency_offset[MAX_NUM_CCs];
   uint32_t                Nid_cell[MAX_NUM_CCs];
   int16_t                 N_RB_DL[MAX_NUM_CCs];
-  lte_frame_type_t        frame_type[MAX_NUM_CCs];
+  frame_type_t            frame_type[MAX_NUM_CCs];
   uint32_t                fdd_earfcn_DL[MAX_NUM_CCs];
   uint32_t                fdd_earfcn_UL[MAX_NUM_CCs];
   int                     num_cc;
diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c
index 26c60fbb9bba5eaf90e25c0b72193272efab38c3..b8b79f8399f10a5908f5b558aeea52e300a0c7ac 100644
--- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c
+++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c
@@ -89,13 +89,13 @@ void nrue_init_standalone_socket(int tx_port, int rx_port)
     int sd = socket(server_address.sin_family, SOCK_DGRAM, 0);
     if (sd < 0)
     {
-      LOG_E(MAC, "Socket creation error standalone PNF\n");
+      LOG_E(NR_MAC, "Socket creation error standalone PNF\n");
       return;
     }
 
     if (inet_pton(server_address.sin_family, stub_eth_params.remote_addr, &server_address.sin_addr) <= 0)
     {
-      LOG_E(MAC, "Invalid standalone PNF Address\n");
+      LOG_E(NR_MAC, "Invalid standalone PNF Address\n");
       close(sd);
       return;
     }
@@ -103,7 +103,7 @@ void nrue_init_standalone_socket(int tx_port, int rx_port)
     // Using connect to use send() instead of sendto()
     if (connect(sd, (struct sockaddr *)&server_address, addr_len) < 0)
     {
-      LOG_E(MAC, "Connection to standalone PNF failed: %s\n", strerror(errno));
+      LOG_E(NR_MAC, "Connection to standalone PNF failed: %s\n", strerror(errno));
       close(sd);
       return;
     }
@@ -129,7 +129,7 @@ void nrue_init_standalone_socket(int tx_port, int rx_port)
 
     if (bind(sd, (struct sockaddr *)&server_address, addr_len) < 0)
     {
-      LOG_E(MAC, "Connection to standalone PNF failed: %s\n", strerror(errno));
+      LOG_E(NR_MAC, "Connection to standalone PNF failed: %s\n", strerror(errno));
       close(sd);
       return;
     }
@@ -634,6 +634,7 @@ static void copy_ul_tti_data_req_to_dl_info(nr_downlink_indication_t *dl_info, n
     AssertFatal(num_pdus >= 0, "Invalid ul_tti_request number of PDUS\n");
     AssertFatal(num_pdus <= sizeof(ul_tti_req->pdus_list) / sizeof(ul_tti_req->pdus_list[0]),
                 "Too many pdus %d in ul_tti_req\n", num_pdus);
+
     if (!send_crc_ind_and_rx_ind(sfn_slot))
     {
         LOG_T(NR_MAC, "CRC_RX ind not sent\n");
@@ -1045,7 +1046,7 @@ void *nrue_standalone_pnf_task(void *context)
 
       if (sem_post(&sfn_slot_semaphore) != 0)
       {
-        LOG_E(MAC, "sem_post() error\n");
+        LOG_E(NR_MAC, "sem_post() error\n");
         abort();
       }
     }
@@ -1064,7 +1065,7 @@ void *nrue_standalone_pnf_task(void *context)
 
 //  L2 Abstraction Layer
 int handle_bcch_bch(module_id_t module_id, int cc_id,
-                    unsigned int gNB_index, uint8_t *pduP,
+                    unsigned int gNB_index, void *phy_data, uint8_t *pduP,
                     unsigned int additional_bits,
                     uint32_t ssb_index, uint32_t ssb_length,
                     uint16_t ssb_start_subcarrier, uint16_t cell_id){
@@ -1072,6 +1073,7 @@ int handle_bcch_bch(module_id_t module_id, int cc_id,
   return nr_ue_decode_mib(module_id,
 			  cc_id,
 			  gNB_index,
+			  phy_data,
 			  additional_bits,
 			  ssb_length,  //  Lssb = 64 is not support    
 			  ssb_index,
@@ -1124,13 +1126,13 @@ void update_harq_status(module_id_t module_id, uint8_t harq_pid, uint8_t ack_nac
   }
   else {
     //shouldn't get here
-    LOG_E(MAC, "Trying to process acknack for an inactive harq process (%d)\n", harq_pid);
+    LOG_E(NR_MAC, "Trying to process acknack for an inactive harq process (%d)\n", harq_pid);
   }
 }
 
 int nr_ue_ul_indication(nr_uplink_indication_t *ul_info){
 
-  NR_UE_L2_STATE_t ret;
+  NR_UE_L2_STATE_t ret=0;
   module_id_t module_id = ul_info->module_id;
   NR_UE_MAC_INST_t *mac = get_mac_inst(module_id);
 
@@ -1182,6 +1184,7 @@ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_
   } else {
     // UL indication after reception of DCI or DL PDU
     if (dl_info && dl_info->dci_ind && dl_info->dci_ind->number_of_dcis) {
+
       LOG_T(MAC,"[L2][IF MODULE][DL INDICATION][DCI_IND]\n");
       for (int i = 0; i < dl_info->dci_ind->number_of_dcis; i++) {
         LOG_T(MAC,">>>NR_IF_Module i=%d, dl_info->dci_ind->number_of_dcis=%d\n",i,dl_info->dci_ind->number_of_dcis);
@@ -1197,8 +1200,8 @@ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_
 
         /* The check below filters out UL_DCIs (format 7) which are being processed as DL_DCIs. */
         if (dci_index->dci_format == 7 && mac->ra.ra_state == RA_SUCCEEDED) {
-          LOG_T(NR_MAC, "We are filtering a UL_DCI to prevent it from being treated like a DL_DCI\n");
-          break;
+          LOG_D(NR_MAC, "We are filtering a UL_DCI to prevent it from being treated like a DL_DCI\n");
+          continue;
         }
         dci_pdu_rel15_t *def_dci_pdu_rel15 = &mac->def_dci_pdu_rel15[dci_index->dci_format];
         g_harq_pid = def_dci_pdu_rel15->harq_pid;
@@ -1208,7 +1211,7 @@ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_
         if (ret >= 0) {
           AssertFatal( nr_ue_if_module_inst[module_id] != NULL, "IF module is NULL!\n" );
           AssertFatal( nr_ue_if_module_inst[module_id]->scheduled_response != NULL, "scheduled_response is NULL!\n" );
-          fill_scheduled_response(&scheduled_response, dl_config, NULL, NULL, dl_info->module_id, dl_info->cc_id, dl_info->frame, dl_info->slot, dl_info->thread_id);
+          fill_scheduled_response(&scheduled_response, dl_config, NULL, NULL, dl_info->module_id, dl_info->cc_id, dl_info->frame, dl_info->slot, dl_info->thread_id, dl_info->phy_data);
           nr_ue_if_module_inst[module_id]->scheduled_response(&scheduled_response);
         }
         memset(def_dci_pdu_rel15, 0, sizeof(*def_dci_pdu_rel15));
@@ -1221,7 +1224,7 @@ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_
 
       for (int i=0; i<dl_info->rx_ind->number_pdus; ++i) {
 
-        LOG_T(MAC, "In %s sending DL indication to MAC. 1 PDU type %d of %d total number of PDUs \n",
+        LOG_D(NR_MAC, "In %s sending DL indication to MAC. 1 PDU type %d of %d total number of PDUs \n",
           __FUNCTION__,
           dl_info->rx_ind->rx_indication_body[i].pdu_type,
           dl_info->rx_ind->number_pdus);
@@ -1229,7 +1232,7 @@ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_
         switch(dl_info->rx_ind->rx_indication_body[i].pdu_type){
           case FAPI_NR_RX_PDU_TYPE_SSB:
             mac->ssb_rsrp_dBm = (dl_info->rx_ind->rx_indication_body+i)->ssb_pdu.rsrp_dBm;
-            ret_mask |= (handle_bcch_bch(dl_info->module_id, dl_info->cc_id, dl_info->gNB_index,
+            ret_mask |= (handle_bcch_bch(dl_info->module_id, dl_info->cc_id, dl_info->gNB_index, dl_info->phy_data,
                                          (dl_info->rx_ind->rx_indication_body+i)->ssb_pdu.pdu,
                                          (dl_info->rx_ind->rx_indication_body+i)->ssb_pdu.additional_bits,
                                          (dl_info->rx_ind->rx_indication_body+i)->ssb_pdu.ssb_index,
diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h
index 034c1c6b48b2ec4dac7046c9c4a03c486ac67380..45d1a071ca96323c353dcf5d0b5754c773fedae2 100755
--- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h
+++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h
@@ -123,6 +123,9 @@ typedef struct {
     /// dci reception indication structure
     fapi_nr_dci_indication_t *dci_ind;
 
+    /// PHY specific data structure that can be passed on to L2 via nr_downlink_indication_t and
+    /// back to L1 via the nr_scheduled_response_t 
+    void *phy_data;
 } nr_downlink_indication_t;
 
 
@@ -176,6 +179,9 @@ typedef struct {
     /// data transmission request structure
     fapi_nr_tx_request_t *tx_request;
 
+    /// PHY data structure initially passed on to L2 via the nr_downlink_indication_t and
+    /// returned to L1 via nr_scheduled_response_t
+    void *phy_data;
 } nr_scheduled_response_t;
 
 typedef struct {
@@ -286,6 +292,7 @@ int nr_ue_dcireq(nr_dcireq_t *dcireq);
 
 //  TODO check
 /**\brief handle BCCH-BCH message from dl_indication
+   \param phy_data        PHY structure to be filled in by the callee in the FAPI call (L1 caller -> indication to L2 -> FAPI call to L1 callee)
    \param pduP            pointer to bch pdu
    \param additional_bits corresponding to 38.212 ch.7
    \param ssb_index       SSB index within 0 - (L_ssb-1) corresponding to 38.331 ch.13 parameter i
@@ -294,6 +301,7 @@ int nr_ue_dcireq(nr_dcireq_t *dcireq);
 int handle_bcch_bch(module_id_t module_id,
                     int cc_id,
                     unsigned int gNB_index,
+                    void *phy_data,
                     uint8_t *pduP,
                     unsigned int additional_bits,
                     uint32_t ssb_index,
diff --git a/openair2/RRC/LTE/rrc_UE.c b/openair2/RRC/LTE/rrc_UE.c
index b46bba249268ff8466f195a3afb7a972f3eedebe..9b37853ed2b2ac5503f29632e66e9f88cf3bbf99 100644
--- a/openair2/RRC/LTE/rrc_UE.c
+++ b/openair2/RRC/LTE/rrc_UE.c
@@ -3175,7 +3175,8 @@ int decode_SIB1( const protocol_ctxt_t *const ctxt_pP, const uint8_t eNB_index,
     const size_t num_plmn_data = sizeof(plmn_data) / sizeof(plmn_data[0]);
     for (size_t plmn_ind = 0;; ++plmn_ind) {
       if (plmn_ind == num_plmn_data) {
-        LOG_E( RRC, "Did not find name from internal table for %u %u\n", mcc, mnc);
+        LOG_W( RRC, "Did not find operator name from internal table for MCC %0*d, MNC %0*d\n",
+               mccdigits, mcc, mncdigits, mnc);
         break;
       }
       if ((plmn_data[plmn_ind].mcc == mcc) && (plmn_data[plmn_ind].mnc == mnc)) {
diff --git a/openair2/RRC/LTE/rrc_eNB_S1AP.c b/openair2/RRC/LTE/rrc_eNB_S1AP.c
index 9b9e267828552335e0754e90f097435b51c13cc4..f24c9ab1b616df1c3cf5d781c4feb515c435ffbf 100644
--- a/openair2/RRC/LTE/rrc_eNB_S1AP.c
+++ b/openair2/RRC/LTE/rrc_eNB_S1AP.c
@@ -1757,7 +1757,7 @@ int rrc_eNB_process_PAGING_IND(MessageDef *msg_p, const char *msg_name, instance
           && RC.rrc[instance]->configuration.mnc[j] == S1AP_PAGING_IND(msg_p).plmn_identity[tai_size].mnc
           && RC.rrc[instance]->configuration.tac == S1AP_PAGING_IND(msg_p).tac[tai_size]) {
         for (uint8_t CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
-          lte_frame_type_t frame_type = RC.eNB[instance][CC_id]->frame_parms.frame_type;
+          frame_type_t frame_type = RC.eNB[instance][CC_id]->frame_parms.frame_type;
           /* get nB from configuration */
           /* get default DRX cycle from configuration */
           Tc = (uint8_t)RC.rrc[instance]->configuration.radioresourceconfig[CC_id].pcch_defaultPagingCycle;
diff --git a/openair2/RRC/NR/nr_rrc_config.c b/openair2/RRC/NR/nr_rrc_config.c
index bb2a180146c12bc92e65ba768e57289dada83075..54fb5a168b1e30d9bf9b56f9aa7ef5813c074287 100644
--- a/openair2/RRC/NR/nr_rrc_config.c
+++ b/openair2/RRC/NR/nr_rrc_config.c
@@ -216,7 +216,7 @@ void prepare_sim_uecap(NR_UE_NR_Capability_t *cap,
 
 void nr_rrc_config_dl_tda(NR_ServingCellConfigCommon_t *scc){
 
-  lte_frame_type_t frame_type = get_frame_type(*scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0], *scc->ssbSubcarrierSpacing);
+  frame_type_t frame_type = get_frame_type(*scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0], *scc->ssbSubcarrierSpacing);
   int curr_bwp = scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth;
   // coreset duration setting to be improved in the framework of RRC harmonization, potentially using a common function
   int len_coreset = 1;
@@ -253,7 +253,7 @@ void nr_rrc_config_ul_tda(NR_ServingCellConfigCommon_t *scc, int min_fb_delay){
 
   uint8_t DELTA[4]= {2,3,4,6}; // Delta parameter for Msg3
   int mu = scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing;
-  lte_frame_type_t frame_type = get_frame_type(*scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0], *scc->ssbSubcarrierSpacing);
+  frame_type_t frame_type = get_frame_type(*scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0], *scc->ssbSubcarrierSpacing);
 
   struct NR_PUSCH_TimeDomainResourceAllocation *pusch_timedomainresourceallocation = CALLOC(1,sizeof(struct NR_PUSCH_TimeDomainResourceAllocation));
   pusch_timedomainresourceallocation->k2  = CALLOC(1,sizeof(long));
diff --git a/openair2/RRC/NR/rrc_gNB_NGAP.c b/openair2/RRC/NR/rrc_gNB_NGAP.c
index 4492380d7f86460d3b7827670b646fdb1e3b70cf..c73c3d9649df3bdd81b2eda5e497db748662adb7 100644
--- a/openair2/RRC/NR/rrc_gNB_NGAP.c
+++ b/openair2/RRC/NR/rrc_gNB_NGAP.c
@@ -969,9 +969,9 @@ rrc_gNB_process_NGAP_PDUSESSION_SETUP_REQ(
   uint16_t                        ue_initial_id;
   uint32_t                        gNB_ue_ngap_id;
   rrc_gNB_ue_context_t            *ue_context_p = NULL;
-  protocol_ctxt_t                 ctxt;
-  gtpv1u_gnb_create_tunnel_req_t  create_tunnel_req;
-  gtpv1u_gnb_create_tunnel_resp_t create_tunnel_resp;
+  protocol_ctxt_t                 ctxt={0};
+  gtpv1u_gnb_create_tunnel_req_t  create_tunnel_req={0};
+  gtpv1u_gnb_create_tunnel_resp_t create_tunnel_resp={0};
   uint8_t                         pdu_sessions_done;
   uint8_t                         inde_list[NR_NB_RB_MAX - 3]= {0};
   int                             ret = 0;
diff --git a/openair2/RRC/NR/rrc_gNB_reconfig.c b/openair2/RRC/NR/rrc_gNB_reconfig.c
index 36113fb7eea025f70d09e5cf5c70916450f15a5e..4e9245cf46126fd7eb2576176cec0fb4e87c2c81 100644
--- a/openair2/RRC/NR/rrc_gNB_reconfig.c
+++ b/openair2/RRC/NR/rrc_gNB_reconfig.c
@@ -223,7 +223,7 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco
  secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS=NULL;
 
  secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition));
- *secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition = NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos0;
+ *secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition = NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos1;
 
 
  secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList=calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList));
@@ -572,7 +572,7 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco
    bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS=NULL;
  }
  bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition));
- *bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition = NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos0;
+ *bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition = NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos1;
 
  bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList=calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList));
 
diff --git a/openair2/UTIL/OCG/OCG.h b/openair2/UTIL/OCG/OCG.h
index 58cc7184e7d05ef0f449f15aafa44a2b1ca9c7c4..452581bb1783cc03e3cf6ce768e1b4b440041566 100644
--- a/openair2/UTIL/OCG/OCG.h
+++ b/openair2/UTIL/OCG/OCG.h
@@ -700,7 +700,7 @@ typedef struct {
   unsigned int n_frames_flag; // if set, then let the emulation goes to infinity
   node_function_t node_function[MAX_NUM_CCs];
   node_timing_t node_timing[MAX_NUM_CCs];
-  unsigned char frame_type[MAX_NUM_CCs]; //! LTE frame type (TDD=1, FDD=0). \note this should be converted to \ref lte_frame_type_t (header file reorganization needed)
+  unsigned char frame_type[MAX_NUM_CCs]; //! LTE frame type (TDD=1, FDD=0). \note this should be converted to \ref frame_type_t (header file reorganization needed)
   char *frame_type_name[MAX_NUM_CCs];
   unsigned char tdd_config[MAX_NUM_CCs];
   unsigned char tdd_config_S[MAX_NUM_CCs];
diff --git a/openair2/X2AP/x2ap_eNB_defs.h b/openair2/X2AP/x2ap_eNB_defs.h
index 063302d03abf7fce76f4307a272ba2def99afc10..bd6092e0cba75f72171d8f118789a3f9638296a2 100644
--- a/openair2/X2AP/x2ap_eNB_defs.h
+++ b/openair2/X2AP/x2ap_eNB_defs.h
@@ -172,7 +172,7 @@ typedef struct x2ap_eNB_instance_s {
   int32_t                 uplink_frequency_offset[MAX_NUM_CCs];
   uint32_t                Nid_cell[MAX_NUM_CCs];
   int16_t                 N_RB_DL[MAX_NUM_CCs];
-  lte_frame_type_t        frame_type[MAX_NUM_CCs];
+  frame_type_t            frame_type[MAX_NUM_CCs];
   uint32_t                fdd_earfcn_DL[MAX_NUM_CCs];
   uint32_t                fdd_earfcn_UL[MAX_NUM_CCs];
   uint32_t                subframeAssignment[MAX_NUM_CCs];
diff --git a/openair3/M3AP/m3ap_MCE_defs.h b/openair3/M3AP/m3ap_MCE_defs.h
index 18ad70a408b50739aedae4fa13ffee03711b2238..4dcb2b4db021559ce3304996210ffabf96aa7a15 100644
--- a/openair3/M3AP/m3ap_MCE_defs.h
+++ b/openair3/M3AP/m3ap_MCE_defs.h
@@ -170,7 +170,7 @@ typedef struct m3ap_MCE_instance_s {
   int32_t                 uplink_frequency_offset[MAX_NUM_CCs];
   uint32_t                Nid_cell[MAX_NUM_CCs];
   int16_t                 N_RB_DL[MAX_NUM_CCs];
-  lte_frame_type_t        frame_type[MAX_NUM_CCs];
+  frame_type_t            frame_type[MAX_NUM_CCs];
   uint32_t                fdd_earfcn_DL[MAX_NUM_CCs];
   uint32_t                fdd_earfcn_UL[MAX_NUM_CCs];
   int                     num_cc;
diff --git a/openair3/M3AP/m3ap_MME_defs.h b/openair3/M3AP/m3ap_MME_defs.h
index 3b5725655de153cd605793838ce27aa9df2b31af..6608587cc3be76e79ba04b525a64c3a44e4cf331 100644
--- a/openair3/M3AP/m3ap_MME_defs.h
+++ b/openair3/M3AP/m3ap_MME_defs.h
@@ -170,7 +170,7 @@ typedef struct m3ap_MME_instance_s {
   int32_t                 uplink_frequency_offset[MAX_NUM_CCs];
   uint32_t                Nid_cell[MAX_NUM_CCs];
   int16_t                 N_RB_DL[MAX_NUM_CCs];
-  lte_frame_type_t        frame_type[MAX_NUM_CCs];
+  frame_type_t            frame_type[MAX_NUM_CCs];
   uint32_t                fdd_earfcn_DL[MAX_NUM_CCs];
   uint32_t                fdd_earfcn_UL[MAX_NUM_CCs];
   int                     num_cc;
diff --git a/openair3/NAS/NR_UE/nr_nas_msg_sim.c b/openair3/NAS/NR_UE/nr_nas_msg_sim.c
index 283f3b7311d123d13bd18a3c02222574f8a07b85..e151fec9b43f63fa9b8d8fcb3e04faba2112a206 100644
--- a/openair3/NAS/NR_UE/nr_nas_msg_sim.c
+++ b/openair3/NAS/NR_UE/nr_nas_msg_sim.c
@@ -428,7 +428,7 @@ void generateRegistrationRequest(as_nas_info_t *initialNasMsg, int Mod_id) {
   size += 10;
 
   // encode the message
-  initialNasMsg->data = (Byte_t *)malloc(size * sizeof(Byte_t));
+  initialNasMsg->data = malloc16_clear(size * sizeof(Byte_t));
   registration_request_buf = initialNasMsg->data;
 
   initialNasMsg->length = mm_msg_encode(mm_msg, (uint8_t*)(initialNasMsg->data), size);
diff --git a/targets/ARCH/rfsimulator/apply_channelmod.c b/targets/ARCH/rfsimulator/apply_channelmod.c
index d7d3a68965717280276ec9d839ab6e576e98d390..4ff5321e4d973572ce25026fc908ad35e4c8fc5b 100644
--- a/targets/ARCH/rfsimulator/apply_channelmod.c
+++ b/targets/ARCH/rfsimulator/apply_channelmod.c
@@ -52,7 +52,8 @@
   either we regenerate the channel (call again random_channel(desc,0)), or we keep it over subframes
   legacy: we regenerate each sub frame in UL, and each frame only in DL
 */
-void rxAddInput( struct complex16 *input_sig, struct complex16 *after_channel_sig,
+void rxAddInput( const c16_t *input_sig,
+		 c16_t *after_channel_sig,
                  int rxAnt,
                  channel_desc_t *channelDesc,
                  int nbSamples,
@@ -73,7 +74,7 @@ void rxAddInput( struct complex16 *input_sig, struct complex16 *after_channel_si
   const int nbTx=channelDesc->nb_tx;
 
   for (int i=0; i<((int)nbSamples-dd); i++) {
-    struct complex16 *out_ptr=after_channel_sig+dd+i;
+    c16_t *out_ptr=after_channel_sig+dd+i;
     struct complexd rx_tmp= {0};
 
     for (int txAnt=0; txAnt < nbTx; txAnt++) {
@@ -87,7 +88,7 @@ void rxAddInput( struct complex16 *input_sig, struct complex16 *after_channel_si
         // but it is not very usefull
         // it would be better to split out each antenna in a separate flow
         // that will allow to mix ru antennas freely
-        struct complex16 tx16=input_sig[((TS+i-l)*nbTx+txAnt)%CirSize];
+        c16_t tx16=input_sig[((TS+i-l)*nbTx+txAnt)%CirSize];
         rx_tmp.r += tx16.r * channelModel[l].r - tx16.i * channelModel[l].i;
         rx_tmp.i += tx16.i * channelModel[l].r + tx16.r * channelModel[l].i;
       } //l
diff --git a/targets/ARCH/rfsimulator/rfsimulator.h b/targets/ARCH/rfsimulator/rfsimulator.h
index 292873032e010d7d1443f5e5424fe4c087962f39..e69d41fa6cea830df0f5d55ba2022c26ea70b988 100644
--- a/targets/ARCH/rfsimulator/rfsimulator.h
+++ b/targets/ARCH/rfsimulator/rfsimulator.h
@@ -25,8 +25,8 @@
 #define  __RFSIMULATOR_H
 double gaussZiggurat(double mean, double variance);
 void tableNor(unsigned long seed);
-void rxAddInput( struct complex16 *input_sig,
-                 struct complex16 *after_channel_sig,
+void rxAddInput( const c16_t *input_sig,
+                 c16_t *after_channel_sig,
                  int rxAnt,
                  channel_desc_t *channelDesc,
                  int nbSamples,
diff --git a/targets/ARCH/rfsimulator/simulator.c b/targets/ARCH/rfsimulator/simulator.c
index 24a0348d35d6857f13bdfda34dc0f175de3aab96..bc9882b4bd2342ffecb3e47dcd89888ea208f1e7 100644
--- a/targets/ARCH/rfsimulator/simulator.c
+++ b/targets/ARCH/rfsimulator/simulator.c
@@ -100,7 +100,7 @@ static telnetshell_vardef_t rfsimu_vardef[] = {
 };
 pthread_mutex_t Sockmutex;
 
-typedef struct complex16 sample_t; // 2*16 bits complex number
+typedef c16_t sample_t; // 2*16 bits complex number
 
 typedef struct buffer_s {
   int conn_sock;
@@ -117,7 +117,7 @@ typedef struct buffer_s {
 
 typedef struct {
   int listen_sock, epollfd;
-  openair0_timestamp nextTimestamp;
+  openair0_timestamp nextRxTstamp;
   openair0_timestamp lastWroteTS;
   uint64_t typeStamp;
   char *ip;
@@ -196,7 +196,7 @@ static void removeCirBuf(rfsimulator_state_t *bridge, int sock) {
   free(bridge->buf[sock].circularBuf);
   // Fixme: no free_channel_desc_scm(bridge->buf[sock].channel_model) implemented
   // a lot of mem leaks
-  free(bridge->buf[sock].channel_model);
+  //free(bridge->buf[sock].channel_model);
   memset(&bridge->buf[sock], 0, sizeof(buffer_t));
   bridge->buf[sock].conn_sock=-1;
 }
@@ -429,8 +429,6 @@ static int rfsimulator_write_internal(rfsimulator_state_t *t, openair0_timestamp
   if (!alreadyLocked)
     pthread_mutex_lock(&Sockmutex);
 
-  LOG_D(HW,"sending %d samples at time: %ld\n", nsamps, timestamp);
-
   for (int i=0; i<FD_SETSIZE; i++) {
     buffer_t *b=&t->buf[i];
 
@@ -495,7 +493,7 @@ static bool flushInput(rfsimulator_state_t *t, int timeout, int nsamps_for_initi
       setblocking(conn_sock, notBlocking);
       allocCirBuf(t, conn_sock);
       LOG_I(HW,"A client connected, sending the current time\n");
-      struct complex16 v= {0};
+      c16_t v= {0};
       void *samplesVoid[t->tx_num_channels];
 
       for ( int i=0; i < t->tx_num_channels; i++)
@@ -549,14 +547,14 @@ static bool flushInput(rfsimulator_state_t *t, int timeout, int nsamps_for_initi
                      (t->typeStamp == ENB_MAGICDL && b->th.magic==UE_MAGICDL), "Socket Error in protocol");
         b->headerMode=false;
 
-        if ( t->nextTimestamp == 0 ) { // First block in UE, resync with the eNB current TS
-          t->nextTimestamp=b->th.timestamp> nsamps_for_initial ?
+        if ( t->nextRxTstamp == 0 ) { // First block in UE, resync with the eNB current TS
+          t->nextRxTstamp=b->th.timestamp> nsamps_for_initial ?
                            b->th.timestamp -  nsamps_for_initial :
                            0;
           b->lastReceivedTS=b->th.timestamp> nsamps_for_initial ?
                             b->th.timestamp :
                             nsamps_for_initial;
-          LOG_W(HW,"UE got first timestamp: starting at %lu\n",  t->nextTimestamp);
+          LOG_W(HW,"UE got first timestamp: starting at %lu\n",  t->nextRxTstamp);
           b->trashingPacket=true;
         } else if ( b->lastReceivedTS < b->th.timestamp) {
           int nbAnt= b->th.nbAnt;
@@ -623,7 +621,7 @@ static int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimest
   }
 
   rfsimulator_state_t *t = device->priv;
-  LOG_D(HW, "Enter rfsimulator_read, expect %d samples, will release at TS: %ld\n", nsamps, t->nextTimestamp+nsamps);
+  LOG_D(HW, "Enter rfsimulator_read, expect %d samples, will release at TS: %ld\n", nsamps, t->nextRxTstamp+nsamps);
   // deliver data from received data
   // check if a UE is connected
   int first_sock;
@@ -634,54 +632,22 @@ static int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimest
 
   if ( first_sock ==  FD_SETSIZE ) {
     // no connected device (we are eNB, no UE is connected)
-    if ( t->nextTimestamp == 0)
+    if ( t->nextRxTstamp == 0)
       LOG_W(HW,"No connected device, generating void samples...\n");
 
     if (!flushInput(t, 10,  nsamps)) {
       for (int x=0; x < nbAnt; x++)
         memset(samplesVoid[x],0,sampleToByte(nsamps,1));
 
-      t->nextTimestamp+=nsamps;
+      t->nextRxTstamp+=nsamps;
 
-      if ( ((t->nextTimestamp/nsamps)%100) == 0)
-        LOG_D(HW,"No UE, Generated void samples for Rx: %ld\n", t->nextTimestamp);
+      if ( ((t->nextRxTstamp/nsamps)%100) == 0)
+        LOG_D(HW,"No UE, Generated void samples for Rx: %ld\n", t->nextRxTstamp);
 
-      *ptimestamp = t->nextTimestamp-nsamps;
+      *ptimestamp = t->nextRxTstamp-nsamps;
       return nsamps;
     }
   } else {
-    pthread_mutex_lock(&Sockmutex);
-
-    if ( t->nextTimestamp > 0 && t->lastWroteTS < t->nextTimestamp) {
-      pthread_mutex_unlock(&Sockmutex);
-      usleep(10000);
-      pthread_mutex_lock(&Sockmutex);
-
-      if ( t->lastWroteTS < t->nextTimestamp ) {
-        // Assuming Tx is not done fully in another thread
-        // We can never write is the past from the received time
-        // So, the node perform receive but will never write these symbols
-        // let's tell this to the opposite node
-        // We send timestamp for nb samples required
-        // assuming this should have been done earlier if a Tx would exist
-        pthread_mutex_unlock(&Sockmutex);
-        struct complex16 v= {0};
-        void *dummyS[t->tx_num_channels];
-
-        for ( int i=0; i < t->tx_num_channels; i++)
-          dummyS[i]=(void *)&v;
-
-        LOG_I(HW, "No samples Tx occured, so we send 1 sample to notify it: Tx:%lu, Rx:%lu\n",
-              t->lastWroteTS, t->nextTimestamp);
-        rfsimulator_write_internal(t, t->nextTimestamp,
-                                   dummyS, 1,
-                                   t->tx_num_channels, 1, true);
-      } else {
-        pthread_mutex_unlock(&Sockmutex);
-        LOG_W(HW, "trx_write came from another thread\n");
-      }
-    } else
-      pthread_mutex_unlock(&Sockmutex);
 
     bool have_to_wait;
 
@@ -692,7 +658,7 @@ static int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimest
         buffer_t *b=&t->buf[sock];
 
         if ( b->circularBuf )
-          if ( t->nextTimestamp+nsamps > b->lastReceivedTS ) {
+          if ( t->nextRxTstamp+nsamps > b->lastReceivedTS ) {
             have_to_wait=true;
             break;
           }
@@ -701,7 +667,7 @@ static int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimest
       if (have_to_wait)
         /*printf("Waiting on socket, current last ts: %ld, expected at least : %ld\n",
           ptr->lastReceivedTS,
-          t->nextTimestamp+nsamps);
+          t->nextRxTstamp+nsamps);
         */
         flushInput(t, 3, nsamps);
     } while (have_to_wait);
@@ -728,11 +694,11 @@ static int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimest
 
       for (int a=0; a<nbAnt; a++) {//loop over number of Rx antennas
         if ( ptr->channel_model != NULL ) // apply a channel model
-          rxAddInput( ptr->circularBuf, (struct complex16 *) samplesVoid[a],
+          rxAddInput( ptr->circularBuf, (c16_t *) samplesVoid[a],
                       a,
                       ptr->channel_model,
                       nsamps,
-                      t->nextTimestamp,
+                      t->nextRxTstamp,
                       CirSize
                     );
         else { // no channel modeling
@@ -747,8 +713,8 @@ static int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimest
           //LOG_I(HW, "nbAnt_tx %d\n",nbAnt_tx);
           for (int i=0; i < nsamps; i++) {//loop over nsamps
             for (int a_tx=0; a_tx<nbAnt_tx; a_tx++) { //sum up signals from nbAnt_tx antennas
-              out[i].r += (short)(ptr->circularBuf[((t->nextTimestamp+i)*nbAnt_tx+a_tx)%CirSize].r*H_awgn_mimo[a][a_tx]);
-              out[i].i += (short)(ptr->circularBuf[((t->nextTimestamp+i)*nbAnt_tx+a_tx)%CirSize].i*H_awgn_mimo[a][a_tx]);
+              out[i].r += (short)(ptr->circularBuf[((t->nextRxTstamp+i)*nbAnt_tx+a_tx)%CirSize].r*H_awgn_mimo[a][a_tx]);
+              out[i].i += (short)(ptr->circularBuf[((t->nextRxTstamp+i)*nbAnt_tx+a_tx)%CirSize].i*H_awgn_mimo[a][a_tx]);
             } // end for a_tx
           } // end for i (number of samps)
         } // end of no channel modeling
@@ -756,11 +722,11 @@ static int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimest
     }
   }
 
-  *ptimestamp = t->nextTimestamp; // return the time of the first sample
-  t->nextTimestamp+=nsamps;
+  *ptimestamp = t->nextRxTstamp; // return the time of the first sample
+  t->nextRxTstamp+=nsamps;
   LOG_D(HW,"Rx to upper layer: %d from %ld to %ld, energy in first antenna %d\n",
         nsamps,
-        *ptimestamp, t->nextTimestamp,
+        *ptimestamp, t->nextRxTstamp,
         signal_energy(samplesVoid[0], nsamps));
   return nsamps;
 }
diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c
index 66ce6ef2474acaa36da14769254d8664e1e37d2d..cee15ef48b1f269d2b4c779acf01f37b049aac5b 100644
--- a/targets/RT/USER/lte-ru.c
+++ b/targets/RT/USER/lte-ru.c
@@ -733,7 +733,7 @@ void tx_rf(RU_t *ru,
   int sf_extension = 0;
 
   if ((SF_type == SF_DL) ||
-      (SF_type == SF_S)) {
+      (SF_type == SF_S) ) {
     int siglen=fp->samples_per_tti,flags=1;
 
     if (SF_type == SF_S) {
@@ -831,6 +831,23 @@ void tx_rf(RU_t *ru,
       late_control=STATE_BURST_TERMINATE;
       LOG_E(PHY,"TX : Timeout (sent %d/%d) state =%d\n",txs, siglen,late_control);
     }
+  } else if (IS_SOFTMODEM_RFSIM ) {
+    // in case of rfsim, we always enable tx because we need to feed rx of the opposite side
+    // we write 1 single I/Q sample to trigger Rx (rfsim will fill gaps with 0 I/Q)
+    void *dummy_tx[ru->frame_parms->nb_antennas_tx];
+    int16_t dummy_tx_data[ru->frame_parms->nb_antennas_tx][2]; // 2 because the function we call use pairs of int16_t implicitly as complex numbers
+    memset(dummy_tx_data,0,sizeof(dummy_tx_data));
+    for (int i=0; i<ru->frame_parms->nb_antennas_tx; i++)
+      dummy_tx[i]= dummy_tx_data[i];
+    
+    AssertFatal( 1 ==
+                 ru->rfdevice.trx_write_func(&ru->rfdevice,
+                                             timestamp+ru->ts_offset-ru->openair0_cfg.tx_sample_advance-sf_extension,
+                                             dummy_tx,
+                                             1,
+                                             ru->frame_parms->nb_antennas_tx,
+                                             4),"");
+    
   }
 }
 
diff --git a/targets/RT/USER/lte-softmodem.h b/targets/RT/USER/lte-softmodem.h
index 0267ad8ce0ab32d0a15c9304a1025b5437dd74bb..1c887dd3c8ee4652fa9ac7d7335ce2557bf67e7f 100644
--- a/targets/RT/USER/lte-softmodem.h
+++ b/targets/RT/USER/lte-softmodem.h
@@ -49,7 +49,6 @@
     {"debug-ue-prach",           CONFIG_HLP_DBGUEPR,    PARAMFLAG_BOOL,   uptr:NULL,                  defuintval:1,       TYPE_INT,   0},    \
     {"no-L2-connect",            CONFIG_HLP_NOL2CN,     PARAMFLAG_BOOL,   uptr:NULL,                  defuintval:1,       TYPE_INT,   0},    \
     {"calib-prach-tx",           CONFIG_HLP_CALPRACH,   PARAMFLAG_BOOL,   uptr:NULL,                  defuintval:1,       TYPE_INT,   0},    \
-    {"loop-memory",              CONFIG_HLP_UELOOP,     0,                strptr:&loopfile,           defstrval:"iqs.in", TYPE_STRING,0},    \
     {"ue-dump-frame",            CONFIG_HLP_DUMPFRAME,  PARAMFLAG_BOOL,   iptr:&dumpframe,            defintval:0,        TYPE_INT,   0},    \
   }
 #define CMDLINE_CALIBUERX_IDX                   0
diff --git a/targets/RT/USER/lte-ue.c b/targets/RT/USER/lte-ue.c
index 9010a40bf951feb6008f4a4acdb0d394f376aaa7..0658b8b9d0ba17f47b932ae9cff05ff5e9e56e77 100644
--- a/targets/RT/USER/lte-ue.c
+++ b/targets/RT/USER/lte-ue.c
@@ -87,15 +87,12 @@ extern void multicast_link_start(void (*rx_handlerP) (unsigned int, char *),
 extern int multicast_link_write_sock(int groupP, char *dataP, uint32_t sizeP);
 
 
-int	tx_req_num_elems;
+int tx_req_num_elems;
 extern uint16_t sf_ahead;
 //extern int tx_req_UE_MAC1();
 
 void ue_stub_rx_handler(unsigned int, char *);
 
-int32_t **rxdata;
-int32_t **txdata;
-
 int timer_subframe = 0;
 int timer_frame = 0;
 SF_ticking *phy_stub_ticking = NULL;
@@ -111,7 +108,7 @@ typedef struct eutra_band_s {
   uint32_t ul_max;
   uint32_t dl_min;
   uint32_t dl_max;
-  lte_frame_type_t frame_type;
+  frame_type_t frame_type;
 } eutra_band_t;
 
 typedef struct band_info_s {
@@ -176,6 +173,7 @@ PHY_VARS_UE *init_ue_vars(LTE_DL_FRAME_PARMS *frame_parms,
 {
   PHY_VARS_UE *ue = (PHY_VARS_UE *)calloc(1,sizeof(PHY_VARS_UE));
   AssertFatal(ue,"");
+
   if (frame_parms!=(LTE_DL_FRAME_PARMS *)NULL) { // if we want to give initial frame parms, allocate the PHY_VARS_UE structure and put them in
     memcpy(&(ue->frame_parms), frame_parms, sizeof(LTE_DL_FRAME_PARMS));
   }
@@ -204,8 +202,7 @@ void init_thread(int sched_runtime,
                  int sched_deadline,
                  int sched_fifo,
                  cpu_set_t *cpuset,
-                 char *name)
-{
+                 char *name) {
 #ifdef DEADLINE_SCHEDULER
 
   if (sched_runtime!=0) {
@@ -266,8 +263,7 @@ void init_UE(int nb_inst,
              runmode_t mode,
              int rxgain,
              int txpowermax,
-             LTE_DL_FRAME_PARMS *fp0)
-{
+             LTE_DL_FRAME_PARMS *fp0) {
   PHY_VARS_UE *UE;
   int         inst;
   int         ret;
@@ -283,9 +279,7 @@ void init_UE(int nb_inst,
     if (PHY_vars_UE_g[inst]==NULL) PHY_vars_UE_g[inst] = (PHY_VARS_UE **)calloc(1+MAX_NUM_CCs,sizeof(PHY_VARS_UE *));
 
     LOG_I(PHY,"Allocating UE context %d\n",inst);
-
     PHY_vars_UE_g[inst][0] = init_ue_vars(fp0,inst,0);
-
     // turn off timing control loop in UE
     PHY_vars_UE_g[inst][0]->no_timing_correction = timing_correction;
     UE = PHY_vars_UE_g[inst][0];
@@ -362,7 +356,6 @@ void init_UE(int nb_inst,
 
     LOG_I(PHY,"Intializing UE Threads for instance %d (%p,%p)...\n",inst,PHY_vars_UE_g[inst],PHY_vars_UE_g[inst][0]);
     init_UE_threads(inst);
-
     ret = openair0_device_load(&(UE->rfdevice), &openair0_cfg[0]);
 
     if (ret !=0) {
@@ -385,8 +378,7 @@ void init_UE(int nb_inst,
 void init_UE_stub_single_thread(int nb_inst,
                                 int eMBMS_active,
                                 int uecap_xer_in,
-                                char *emul_iface)
-{
+                                char *emul_iface) {
   int         inst;
   LOG_I(PHY,"UE : Calling Layer 2 for initialization, nb_inst: %d \n", nb_inst);
   l2_init_ue(eMBMS_active,(uecap_xer_in==1)?uecap_xer:NULL,
@@ -411,24 +403,23 @@ void init_UE_stub_single_thread(int nb_inst,
   }
 }
 
-void init_UE_standalone_thread(int ue_idx)
-{
+void init_UE_standalone_thread(int ue_idx) {
   int standalone_tx_port = 3211 + ue_idx * 2;
   int standalone_rx_port = 3212 + ue_idx * 2;
   ue_init_standalone_socket(standalone_tx_port, standalone_rx_port);
-
   pthread_t thread;
+
   if (pthread_create(&thread, NULL, ue_standalone_pnf_task, NULL) != 0) {
     LOG_E(MAC, "pthread_create failed for calling ue_standalone_pnf_task");
   }
+
   pthread_setname_np(thread, "oai:ue-stand");
 }
 
 void init_UE_stub(int nb_inst,
                   int eMBMS_active,
                   int uecap_xer_in,
-                  char *emul_iface)
-{
+                  char *emul_iface) {
   int         inst;
   LOG_I(PHY,"UE : Calling Layer 2 for initialization\n");
   l2_init_ue(eMBMS_active,(uecap_xer_in==1)?uecap_xer:NULL,
@@ -462,8 +453,7 @@ void init_UE_stub(int nb_inst,
  * \returns a pointer to an int. The storage is not on the heap and must not be freed.
  */
 
-static void *UE_thread_synch(void *arg)
-{
+static void *UE_thread_synch(void *arg) {
   static int UE_thread_synch_retval;
   int i ;
   PHY_VARS_UE *UE = (PHY_VARS_UE *) arg;
@@ -478,6 +468,7 @@ static void *UE_thread_synch(void *arg)
   printf("UE_thread_sync in with PHY_vars_UE %p\n",arg);
   cpu_set_t cpuset;
   CPU_ZERO(&cpuset);
+
   if ( threads.sync != -1 )
     CPU_SET(threads.sync, &cpuset);
 
@@ -757,8 +748,7 @@ static void *UE_thread_synch(void *arg)
  * \param arg is a pointer to a \ref PHY_VARS_UE structure.
  * \returns a pointer to an int. The storage is not on the heap and must not be freed.
  */
-const char *get_connectionloss_errstr(int errcode)
-{
+const char *get_connectionloss_errstr(int errcode) {
   switch (errcode) {
     case CONNECTION_LOST:
       return "RRC Connection lost, returning to PRACH";
@@ -773,8 +763,7 @@ const char *get_connectionloss_errstr(int errcode)
   return "UNKNOWN RETURN CODE";
 }
 
-static void *UE_thread_rxn_txnp4(void *arg)
-{
+static void *UE_thread_rxn_txnp4(void *arg) {
   static __thread int UE_thread_rxtx_retval;
   struct rx_tx_thread_data *rtd = arg;
   UE_rxtx_proc_t *proc = rtd->proc;
@@ -867,13 +856,11 @@ static void *UE_thread_rxn_txnp4(void *arg)
 
     if ((subframe_select( &UE->frame_parms, proc->subframe_tx) == SF_UL) ||
         (UE->frame_parms.frame_type == FDD) )
-      if (UE->mode != loop_through_memory)
-        phy_procedures_UE_TX(UE,proc,0,0,UE->mode);
+      phy_procedures_UE_TX(UE,proc,0,0,UE->mode);
 
     if ((subframe_select( &UE->frame_parms, proc->subframe_tx) == SF_S) &&
         (UE->frame_parms.frame_type == TDD))
-      if (UE->mode != loop_through_memory)
-        phy_procedures_UE_S_TX(UE,0,0);
+      phy_procedures_UE_S_TX(UE,0,0);
 
     proc->instance_cnt_rxtx--;
 
@@ -895,8 +882,7 @@ static void *UE_thread_rxn_txnp4(void *arg)
 unsigned int emulator_absSF;
 
 void ue_stub_rx_handler(unsigned int num_bytes,
-                        char *rx_buffer)
-{
+                        char *rx_buffer) {
   PHY_VARS_UE *UE;
   UE = PHY_vars_UE_g[0][0];
   UE_tport_t *pdu = (UE_tport_t *)rx_buffer;
@@ -951,14 +937,14 @@ void ue_stub_rx_handler(unsigned int num_bytes,
   }
 }
 
-uint64_t clock_usec(void)
-{
-    struct timespec t;
-    if (clock_gettime(CLOCK_MONOTONIC, &t) == -1)
-    {
-        abort();
-    }
-    return (uint64_t)t.tv_sec * 1000000 + (t.tv_nsec / 1000);
+uint64_t clock_usec(void) {
+  struct timespec t;
+
+  if (clock_gettime(CLOCK_MONOTONIC, &t) == -1) {
+    abort();
+  }
+
+  return (uint64_t)t.tv_sec * 1000000 + (t.tv_nsec / 1000);
 }
 /*!
  * \brief This is the UE thread for RX subframe n and TX subframe n+4.
@@ -968,23 +954,21 @@ uint64_t clock_usec(void)
  * \returns a pointer to an int. The storage is not on the heap and must not be freed.
  */
 
-static void *UE_phy_stub_standalone_pnf_task(void *arg)
-{
+static void *UE_phy_stub_standalone_pnf_task(void *arg) {
 #if 1
   {
     struct sched_param sparam =
     {
       .sched_priority = 79,
     };
-    if (pthread_setschedparam(pthread_self(), SCHED_RR, &sparam) != 0)
-    {
+
+    if (pthread_setschedparam(pthread_self(), SCHED_RR, &sparam) != 0) {
       LOG_E(PHY,"pthread_setschedparam: %s\n", strerror(errno));
     }
   }
 #else
   thread_top_init("UE_phy_stub_thread_rxn_txnp4", 1, 870000L, 1000000L, 1000000L);
 #endif
-
   // for multipule UE's L2-emulator
   //module_id_t Mod_id = 0;
   //int init_ra_UE = -1; // This counter is used to initiate the RA of each UE in different SFrames
@@ -1004,9 +988,7 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg)
   PHY_VARS_UE *UE = NULL;
   int ret;
   proc = &PHY_vars_UE_g[0][0]->proc.proc_rxtx[0];
-
   UE = rtd->UE;
-
   UL_INFO = (UL_IND_t *)calloc(1, sizeof(UL_IND_t));
   UL_INFO->rx_ind.rx_indication_body.rx_pdu_list = calloc(NFAPI_RX_IND_MAX_PDU, sizeof(nfapi_rx_indication_pdu_t));
   UL_INFO->rx_ind.rx_indication_body.number_of_pdus = 0;
@@ -1019,19 +1001,15 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg)
   UL_INFO->cqi_ind.cqi_indication_body.cqi_pdu_list = calloc(NFAPI_CQI_IND_MAX_PDU, sizeof(nfapi_cqi_indication_pdu_t));
   UL_INFO->cqi_ind.cqi_indication_body.cqi_raw_pdu_list = calloc(NFAPI_CQI_IND_MAX_PDU, sizeof(nfapi_cqi_indication_raw_pdu_t));
   UL_INFO->cqi_ind.cqi_indication_body.number_of_cqis = 0;
-
   proc->subframe_rx = proc->sub_frame_start;
   proc->subframe_tx = -1;
   proc->frame_rx = -1;
   proc->frame_tx = -1;
   // Initializations for nfapi-L2-emulator mode
   sync_var = 0;
-
   //PANOS: CAREFUL HERE!
   wait_sync("UE_phy_stub_standalone_pnf_task");
-
   int last_sfn_sf = -1;
-
   LOG_I(MAC, "Clearing Queues\n");
   reset_queue(&dl_config_req_tx_req_queue);
   reset_queue(&ul_config_req_queue);
@@ -1039,72 +1017,77 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg)
 
   while (!oai_exit) {
     bool sent_any = false;
+
     if (sem_wait(&sfn_semaphore) != 0) {
       LOG_E(MAC, "sem_wait() error\n");
       abort();
     }
 
     int sfn_sf = current_sfn_sf;
-    if (sfn_sf == last_sfn_sf)
-    {
+
+    if (sfn_sf == last_sfn_sf) {
       LOG_W(MAC, "repeated sfn_sf = %d.%d\n",
             sfn_sf >> 4, sfn_sf & 15);
       continue;
     }
-    last_sfn_sf = sfn_sf;
 
+    last_sfn_sf = sfn_sf;
     nfapi_dl_config_req_tx_req_t *dl_config_req_tx_req = get_queue(&dl_config_req_tx_req_queue);
     nfapi_ul_config_request_t *ul_config_req = get_queue(&ul_config_req_queue);
     nfapi_hi_dci0_request_t *hi_dci0_req = get_queue(&hi_dci0_req_queue);
-
     LOG_I(MAC, "received from proxy frame %d subframe %d\n",
           NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf));
 
     if (ul_config_req != NULL) {
       uint8_t ul_num_pdus = ul_config_req->ul_config_request_body.number_of_pdus;
+
       if (ul_num_pdus > 0) {
         char *ul_str = nfapi_ul_config_req_to_string(ul_config_req);
         LOG_I(MAC, "ul_config_req: %s\n", ul_str);
         free(ul_str);
       }
     }
+
     if (hi_dci0_req != NULL) {
       LOG_D(MAC, "hi_dci0_req pdus: %u Frame: %d Subframe: %d\n",
-      hi_dci0_req->hi_dci0_request_body.number_of_dci,
-      NFAPI_SFNSF2SFN(hi_dci0_req->sfn_sf), NFAPI_SFNSF2SF(hi_dci0_req->sfn_sf));
+            hi_dci0_req->hi_dci0_request_body.number_of_dci,
+            NFAPI_SFNSF2SFN(hi_dci0_req->sfn_sf), NFAPI_SFNSF2SF(hi_dci0_req->sfn_sf));
     }
 
     if (dl_config_req_tx_req != NULL) {
-
       nfapi_tx_req_pdu_list_t *tx_req_pdu_list = dl_config_req_tx_req->tx_req_pdu_list;
       nfapi_dl_config_request_t *dl_config_req = dl_config_req_tx_req->dl_config_req;
-
       uint16_t dl_num_pdus = dl_config_req->dl_config_request_body.number_pdu;
       LOG_I(MAC, "(OAI UE) Received dl_config_req from proxy at Frame: %d, Subframe: %d,"
             " with number of PDUs: %u\n",
             NFAPI_SFNSF2SFN(dl_config_req->sfn_sf), NFAPI_SFNSF2SF(dl_config_req->sfn_sf),
             dl_num_pdus);
+
       if (dl_num_pdus > 0) {
         char *dl_str = nfapi_dl_config_req_to_string(dl_config_req);
         LOG_I(MAC, "dl_config_req: %s\n", dl_str);
         free(dl_str);
       }
-      LOG_D(MAC, "tx_req pdus: %d\n", tx_req_pdu_list->num_pdus);
 
+      LOG_D(MAC, "tx_req pdus: %d\n", tx_req_pdu_list->num_pdus);
       // Handling dl_config_req and tx_req:
       nfapi_dl_config_request_body_t *dl_config_req_body = &dl_config_req->dl_config_request_body;
+
       for (int i = 0; i < dl_config_req_body->number_pdu; ++i) {
         nfapi_dl_config_request_pdu_t *pdu = &dl_config_req_body->dl_config_pdu_list[i];
+
         if (pdu->pdu_type == NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE) {
           i += 1;
           AssertFatal(i < dl_config_req->dl_config_request_body.number_pdu,
                       "Need PDU following DCI at index %d, but not found\n",
                       i);
           nfapi_dl_config_request_pdu_t *dlsch = &dl_config_req_body->dl_config_pdu_list[i];
+
           if (dlsch->pdu_type != NFAPI_DL_CONFIG_DLSCH_PDU_TYPE) {
             LOG_E(MAC, "expected DLSCH PDU at index %d\n", i);
             continue;
           }
+
           dl_config_req_UE_MAC_dci(NFAPI_SFNSF2SFN(dl_config_req->sfn_sf),
                                    NFAPI_SFNSF2SF(dl_config_req->sfn_sf),
                                    pdu,
@@ -1125,8 +1108,10 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg)
         }
       }
     }
+
     if (hi_dci0_req) {
       nfapi_hi_dci0_request_body_t *hi_dci0_body = &hi_dci0_req->hi_dci0_request_body;
+
       for (int i = 0; i < hi_dci0_body->number_of_dci + hi_dci0_body->number_of_hi; i++) {
         nfapi_hi_dci0_request_pdu_t *pdu = &hi_dci0_body->hi_dci0_pdu_list[i];
         hi_dci0_req_UE_MAC(NFAPI_SFNSF2SFN(hi_dci0_req->sfn_sf),
@@ -1139,13 +1124,13 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg)
     for (ue_index = 0; ue_index < ue_num; ue_index++) {
       ue_Mod_id = ue_thread_id + NB_THREAD_INST * ue_index; // Always 0 in standalone pnf mode
       UE = PHY_vars_UE_g[ue_Mod_id][0];
-
 #if UE_TIMING_TRACE
       start_meas(&UE->generic_stat);
 #endif
       int rx_frame = NFAPI_SFNSF2SF(sfn_sf) < 4 ? (NFAPI_SFNSF2SFN(sfn_sf) + 1023) % 1024 : NFAPI_SFNSF2SFN(sfn_sf); // subtracting 4 from subframe_tx
       int rx_subframe = NFAPI_SFNSF2SF(sfn_sf) < 4 ? NFAPI_SFNSF2SF(sfn_sf) + 6 : NFAPI_SFNSF2SF(sfn_sf) - 4;
       LOG_D(MAC, "rx_frame %d rx_subframe %d\n", rx_frame, rx_subframe);
+
       if (UE->mac_enabled == 1) {
         ret = ue_scheduler(ue_Mod_id,
                            rx_frame,
@@ -1168,67 +1153,60 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg)
 
       // Prepare the future Tx data
       if ((subframe_select(&UE->frame_parms, NFAPI_SFNSF2SF(sfn_sf)) == SF_UL) ||
-          (UE->frame_parms.frame_type == FDD))
-      {
-        if (UE->mode != loop_through_memory)
-        {
-          // We make the start of RA between consecutive UEs differ by 20 frames
-          //if ((UE_mac_inst[Mod_id].UE_mode[0] == PRACH  && Mod_id == 0) || (UE_mac_inst[Mod_id].UE_mode[0] == PRACH && Mod_id>0 && rx_frame >= UE_mac_inst[Mod_id-1].ra_frame + 20) ) {
-          if (UE_mac_inst[ue_Mod_id].UE_mode[0] == RA_RESPONSE &&
-              is_prach_subframe(&UE->frame_parms, NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf)))
-          {
-            UE_mac_inst[ue_Mod_id].UE_mode[0] = PRACH;
-          }
-          LOG_D(MAC, "UE_mode: %d\n", UE_mac_inst[ue_Mod_id].UE_mode[0]);
-          if (UE_mac_inst[ue_Mod_id].UE_mode[0] == PRACH)
-          { //&& ue_Mod_id == next_Mod_id) {
-            next_ra_frame++;
-            if (next_ra_frame > 500)
-            {
-              // check if we have PRACH opportunity
-              if (is_prach_subframe(&UE->frame_parms, NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf)) && UE_mac_inst[ue_Mod_id].SI_Decoded == 1)
-              {
-                // The one working strangely...
-                //if (is_prach_subframe(&UE->frame_parms,NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf) && Mod_id == (module_id_t) init_ra_UE) ) {
-                PRACH_RESOURCES_t *prach_resources = ue_get_rach(ue_Mod_id, 0, NFAPI_SFNSF2SFN(sfn_sf), 0, NFAPI_SFNSF2SF(sfn_sf));
-                if (prach_resources != NULL)
-                {
-                  LOG_I(MAC, "preamble_received_tar_power: %d\n",
-                        prach_resources->ra_PREAMBLE_RECEIVED_TARGET_POWER);
-                  UE_mac_inst[ue_Mod_id].ra_frame = NFAPI_SFNSF2SFN(sfn_sf);
-                  LOG_D(MAC, "UE_phy_stub_thread_rxn_txnp4 before RACH, Mod_id: %d frame %d subframe %d\n", ue_Mod_id, NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf));
-                  fill_rach_indication_UE_MAC(ue_Mod_id, NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf), UL_INFO, prach_resources->ra_PreambleIndex, prach_resources->ra_RNTI);
-                  sent_any = true;
-                  Msg1_transmitted(ue_Mod_id, 0, NFAPI_SFNSF2SFN(sfn_sf), 0);
-                  UE_mac_inst[ue_Mod_id].UE_mode[0] = RA_RESPONSE;
-                  next_Mod_id = ue_Mod_id + 1;
-                  //next_ra_frame = (rx_frame + 20)%1000;
-                  next_ra_frame = 0;
-                }
-                //ue_prach_procedures(ue,proc,eNB_id,abstraction_flag,mode);
+          (UE->frame_parms.frame_type == FDD)) {
+        // We make the start of RA between consecutive UEs differ by 20 frames
+        //if ((UE_mac_inst[Mod_id].UE_mode[0] == PRACH  && Mod_id == 0) || (UE_mac_inst[Mod_id].UE_mode[0] == PRACH && Mod_id>0 && rx_frame >= UE_mac_inst[Mod_id-1].ra_frame + 20) ) {
+        if (UE_mac_inst[ue_Mod_id].UE_mode[0] == RA_RESPONSE &&
+            is_prach_subframe(&UE->frame_parms, NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf))) {
+          UE_mac_inst[ue_Mod_id].UE_mode[0] = PRACH;
+        }
+
+        LOG_D(MAC, "UE_mode: %d\n", UE_mac_inst[ue_Mod_id].UE_mode[0]);
+
+        if (UE_mac_inst[ue_Mod_id].UE_mode[0] == PRACH) {
+          //&& ue_Mod_id == next_Mod_id) {
+          next_ra_frame++;
+
+          if (next_ra_frame > 500) {
+            // check if we have PRACH opportunity
+            if (is_prach_subframe(&UE->frame_parms, NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf)) && UE_mac_inst[ue_Mod_id].SI_Decoded == 1) {
+              // The one working strangely...
+              //if (is_prach_subframe(&UE->frame_parms,NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf) && Mod_id == (module_id_t) init_ra_UE) ) {
+              PRACH_RESOURCES_t *prach_resources = ue_get_rach(ue_Mod_id, 0, NFAPI_SFNSF2SFN(sfn_sf), 0, NFAPI_SFNSF2SF(sfn_sf));
+
+              if (prach_resources != NULL) {
+                LOG_I(MAC, "preamble_received_tar_power: %d\n",
+                      prach_resources->ra_PREAMBLE_RECEIVED_TARGET_POWER);
+                UE_mac_inst[ue_Mod_id].ra_frame = NFAPI_SFNSF2SFN(sfn_sf);
+                LOG_D(MAC, "UE_phy_stub_thread_rxn_txnp4 before RACH, Mod_id: %d frame %d subframe %d\n", ue_Mod_id, NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf));
+                fill_rach_indication_UE_MAC(ue_Mod_id, NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf), UL_INFO, prach_resources->ra_PreambleIndex, prach_resources->ra_RNTI);
+                sent_any = true;
+                Msg1_transmitted(ue_Mod_id, 0, NFAPI_SFNSF2SFN(sfn_sf), 0);
+                UE_mac_inst[ue_Mod_id].UE_mode[0] = RA_RESPONSE;
+                next_Mod_id = ue_Mod_id + 1;
+                //next_ra_frame = (rx_frame + 20)%1000;
+                next_ra_frame = 0;
               }
+
+              //ue_prach_procedures(ue,proc,eNB_id,abstraction_flag,mode);
             }
-          } // mode is PRACH
-
-          // Substitute call to phy_procedures Tx with call to phy_stub functions in order to trigger
-          // UE Tx procedures directly at the MAC layer, based on the received ul_config requests from the vnf (eNB).
-          // Generate UL_indications which correspond to UL traffic.
-          if (ul_config_req != NULL)
-          { //&& UE_mac_inst[Mod_id].ul_config_req->ul_config_request_body.ul_config_pdu_list != NULL){
-            ul_config_req_UE_MAC(ul_config_req, NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf), ue_Mod_id);
           }
-        }
+        } // mode is PRACH
 
-        phy_procedures_UE_SL_RX(UE, proc);
-      }
-      else
-      {
+        // Substitute call to phy_procedures Tx with call to phy_stub functions in order to trigger
+        // UE Tx procedures directly at the MAC layer, based on the received ul_config requests from the vnf (eNB).
+        // Generate UL_indications which correspond to UL traffic.
+        if (ul_config_req != NULL) {
+          //&& UE_mac_inst[Mod_id].ul_config_req->ul_config_request_body.ul_config_pdu_list != NULL){
+          ul_config_req_UE_MAC(ul_config_req, NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf), ue_Mod_id);
+        }
+      } else {
         LOG_I(MAC, "Skipping subframe select statement proxy SFN.SF: %d.%d\n",
-        NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf));
-        if (ul_config_req != NULL)
-        {
+              NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf));
+
+        if (ul_config_req != NULL) {
           LOG_I(MAC, "Skipping subframe select statement ul_config_req SFN.SF: %d.%d\n",
-          NFAPI_SFNSF2SFN(ul_config_req->sfn_sf), NFAPI_SFNSF2SF(ul_config_req->sfn_sf));
+                NFAPI_SFNSF2SFN(ul_config_req->sfn_sf), NFAPI_SFNSF2SF(ul_config_req->sfn_sf));
         }
       }
     } //for (Mod_id=0; Mod_id<NB_UE_INST; Mod_id++)
@@ -1243,12 +1221,10 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg)
     }
 
     if (UL_INFO->rx_ind.rx_indication_body.number_of_pdus > 0) {
-
       //LOG_D(PHY,"UL_info->rx_ind.number_of_pdus:%d RX_IND:SFN/SF:%d\n", UL_info->rx_ind.rx_indication_body.number_of_pdus, NFAPI_SFNSF2DEC(UL_info->rx_ind.sfn_sf));
       //LOG_I(MAC, "ul_config_req_UE_MAC 2.3, SFN/SF of PNF counter:%d.%d, number_of_pdus: %d \n", timer_frame, timer_subframe, UL_INFO->rx_ind.rx_indication_body.number_of_pdus);
       send_standalone_msg(UL_INFO, UL_INFO->rx_ind.header.message_id);
       sent_any = true;
-
       //LOG_I(MAC, "ul_config_req_UE_MAC 2.31 \n");
       UL_INFO->rx_ind.rx_indication_body.number_of_pdus = 0;
     }
@@ -1261,16 +1237,16 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg)
 
     if (UL_INFO->harq_ind.harq_indication_body.number_of_harqs > 0) {
       //LOG_D(MAC, "ul_config_req_UE_MAC 2.4, SFN/SF of PNF counter:%d.%d, number_of_harqs: %d \n", timer_frame, timer_subframe, UL_INFO->harq_ind.harq_indication_body.number_of_harqs);
-        send_standalone_msg(UL_INFO, UL_INFO->harq_ind.header.message_id);
-        sent_any = true;
+      send_standalone_msg(UL_INFO, UL_INFO->harq_ind.header.message_id);
+      sent_any = true;
       //LOG_I(MAC, "ul_config_req_UE_MAC 2.41 \n");
       UL_INFO->harq_ind.harq_indication_body.number_of_harqs = 0;
     }
 
     if (UL_INFO->sr_ind.sr_indication_body.number_of_srs > 0) {
       //LOG_I(MAC, "ul_config_req_UE_MAC 2.5, SFN/SF of PNF counter:%d.%d, number_of_srs: %d \n", timer_frame, timer_subframe, UL_INFO->sr_ind.sr_indication_body.number_of_srs);
-        send_standalone_msg(UL_INFO, UL_INFO->sr_ind.header.message_id);
-        sent_any = true;
+      send_standalone_msg(UL_INFO, UL_INFO->sr_ind.header.message_id);
+      sent_any = true;
       //LOG_I(MAC, "ul_config_req_UE_MAC 2.51 \n");
       UL_INFO->sr_ind.sr_indication_body.number_of_srs = 0;
     }
@@ -1286,12 +1262,11 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg)
         free(dl_config_req_tx_req->dl_config_req->dl_config_request_body.dl_config_pdu_list);
         dl_config_req_tx_req->dl_config_req->dl_config_request_body.dl_config_pdu_list = NULL;
       }
+
       nfapi_free_tx_req_pdu_list(dl_config_req_tx_req->tx_req_pdu_list);
       dl_config_req_tx_req->tx_req_pdu_list = NULL;
-
       free(dl_config_req_tx_req->dl_config_req);
       dl_config_req_tx_req->dl_config_req = NULL;
-
       free(dl_config_req_tx_req);
       dl_config_req_tx_req = NULL;
     }
@@ -1315,9 +1290,9 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg)
       free(hi_dci0_req);
       hi_dci0_req = NULL;
     }
-    if (!sent_any)
-    {
-     send_standalone_dummy();
+
+    if (!sent_any) {
+      send_standalone_dummy();
     }
   }
 
@@ -1336,7 +1311,6 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg)
   UL_INFO->rx_ind.rx_indication_body.rx_pdu_list = NULL;
   free(UL_INFO);
   UL_INFO = NULL;
-
   // thread finished
   free(arg);
   return NULL;
@@ -1350,8 +1324,7 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg)
  * \returns a pointer to an int. The storage is not on the heap and must not be freed.
  */
 
-static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg)
-{
+static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg) {
 #if 0 // TODO: doesn't currently compile, obviated by multi-ue proxy
   thread_top_init("UE_phy_stub_thread_rxn_txnp4",1,870000L,1000000L,1000000L);
   // for multipule UE's L2-emulator
@@ -1377,7 +1350,6 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg)
   proc = &PHY_vars_UE_g[0][0]->proc.proc_rxtx[0];
   phy_stub_ticking->num_single_thread[ue_thread_id] = -1;
   UE = rtd->UE;
-
   UL_INFO = (UL_IND_t *)malloc(sizeof(UL_IND_t));
   UL_INFO->rx_ind.rx_indication_body.rx_pdu_list = calloc(NB_UE_INST, sizeof(nfapi_rx_indication_pdu_t));
   UL_INFO->rx_ind.rx_indication_body.number_of_pdus = 0;
@@ -1489,19 +1461,23 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg)
     }
 
     if (dl_config_req && tx_req_pdu_list) {
-      nfapi_dl_config_request_body_t* dl_config_req_body = &dl_config_req->dl_config_request_body;
+      nfapi_dl_config_request_body_t *dl_config_req_body = &dl_config_req->dl_config_request_body;
+
       for (int i = 0; i < dl_config_req_body->number_pdu; ++i) {
-        nfapi_dl_config_request_pdu_t* pdu = &dl_config_req_body->dl_config_pdu_list[i];
+        nfapi_dl_config_request_pdu_t *pdu = &dl_config_req_body->dl_config_pdu_list[i];
+
         if (pdu->pdu_type ==  NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE) {
           i += 1;
           AssertFatal(i < dl_config_req->dl_config_request_body.number_pdu,
                       "Need PDU following DCI at index %d, but not found\n",
                       i);
           nfapi_dl_config_request_pdu_t *dlsch = &dl_config_req_body->dl_config_pdu_list[i];
+
           if (dlsch->pdu_type != NFAPI_DL_CONFIG_DLSCH_PDU_TYPE) {
             LOG_E(MAC, "expected DLSCH PDU at index %d\n", i);
             continue;
           }
+
           dl_config_req_UE_MAC_dci(NFAPI_SFNSF2SFN(dl_config_req->sfn_sf),
                                    NFAPI_SFNSF2SF(dl_config_req->sfn_sf),
                                    pdu,
@@ -1523,8 +1499,9 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg)
 
     if (hi_dci0_req) {
       nfapi_hi_dci0_request_body_t *hi_dci0_body = &hi_dci0_req->hi_dci0_request_body;
+
       for (int i = 0; i < hi_dci0_body->number_of_dci + hi_dci0_body->number_of_hi; i++) {
-        nfapi_hi_dci0_request_pdu_t* pdu = &hi_dci0_body->hi_dci0_pdu_list[i];
+        nfapi_hi_dci0_request_pdu_t *pdu = &hi_dci0_body->hi_dci0_pdu_list[i];
         hi_dci0_req_UE_MAC(NFAPI_SFNSF2SFN(hi_dci0_req->sfn_sf),
                            NFAPI_SFNSF2SF(hi_dci0_req->sfn_sf),
                            pdu,
@@ -1592,44 +1569,41 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg)
 
       if ((subframe_select( &UE->frame_parms, proc->subframe_tx) == SF_UL) ||
           (UE->frame_parms.frame_type == FDD) )
-        if (UE->mode != loop_through_memory) {
-          // We make the start of RA between consecutive UEs differ by 20 frames
-          //if ((UE_mac_inst[Mod_id].UE_mode[0] == PRACH  && Mod_id == 0) || (UE_mac_inst[Mod_id].UE_mode[0] == PRACH && Mod_id>0 && proc->frame_rx >= UE_mac_inst[Mod_id-1].ra_frame + 20) ) {
-          if (UE_mac_inst[ue_Mod_id].UE_mode[0] == PRACH  && ue_Mod_id == next_Mod_id) {
-            next_ra_frame++;
-
-            if(next_ra_frame > 500) {
-              // check if we have PRACH opportunity
-              if (is_prach_subframe(&UE->frame_parms,proc->frame_tx, proc->subframe_tx) &&  UE_mac_inst[ue_Mod_id].SI_Decoded == 1) {
-                // The one working strangely...
-                //if (is_prach_subframe(&UE->frame_parms,proc->frame_tx, proc->subframe_tx && Mod_id == (module_id_t) init_ra_UE) ) {
-                PRACH_RESOURCES_t *prach_resources = ue_get_rach(ue_Mod_id, 0, proc->frame_tx, 0, proc->subframe_tx);
-
-                if(prach_resources!=NULL ) {
-                  UE_mac_inst[ue_Mod_id].ra_frame = proc->frame_rx;
-                  LOG_D(MAC, "UE_phy_stub_thread_rxn_txnp4 before RACH, Mod_id: %d frame %d subframe %d\n", ue_Mod_id,proc->frame_tx, proc->subframe_tx);
-                  fill_rach_indication_UE_MAC(ue_Mod_id, proc->frame_tx,proc->subframe_tx, UL_INFO, prach_resources->ra_PreambleIndex, prach_resources->ra_RNTI);
-                  Msg1_transmitted(ue_Mod_id, 0, proc->frame_tx, 0);
-                  UE_mac_inst[ue_Mod_id].UE_mode[0] = RA_RESPONSE;
-                  next_Mod_id = ue_Mod_id + 1;
-                  //next_ra_frame = (proc->frame_rx + 20)%1000;
-                  next_ra_frame = 0;
-                }
 
-                //ue_prach_procedures(ue,proc,eNB_id,abstraction_flag,mode);
+        // We make the start of RA between consecutive UEs differ by 20 frames
+        //if ((UE_mac_inst[Mod_id].UE_mode[0] == PRACH  && Mod_id == 0) || (UE_mac_inst[Mod_id].UE_mode[0] == PRACH && Mod_id>0 && proc->frame_rx >= UE_mac_inst[Mod_id-1].ra_frame + 20) ) {
+        if (UE_mac_inst[ue_Mod_id].UE_mode[0] == PRACH  && ue_Mod_id == next_Mod_id) {
+          next_ra_frame++;
+
+          if(next_ra_frame > 500) {
+            // check if we have PRACH opportunity
+            if (is_prach_subframe(&UE->frame_parms,proc->frame_tx, proc->subframe_tx) &&  UE_mac_inst[ue_Mod_id].SI_Decoded == 1) {
+              // The one working strangely...
+              //if (is_prach_subframe(&UE->frame_parms,proc->frame_tx, proc->subframe_tx && Mod_id == (module_id_t) init_ra_UE) ) {
+              PRACH_RESOURCES_t *prach_resources = ue_get_rach(ue_Mod_id, 0, proc->frame_tx, 0, proc->subframe_tx);
+
+              if(prach_resources!=NULL ) {
+                UE_mac_inst[ue_Mod_id].ra_frame = proc->frame_rx;
+                LOG_D(MAC, "UE_phy_stub_thread_rxn_txnp4 before RACH, Mod_id: %d frame %d subframe %d\n", ue_Mod_id,proc->frame_tx, proc->subframe_tx);
+                fill_rach_indication_UE_MAC(ue_Mod_id, proc->frame_tx,proc->subframe_tx, UL_INFO, prach_resources->ra_PreambleIndex, prach_resources->ra_RNTI);
+                Msg1_transmitted(ue_Mod_id, 0, proc->frame_tx, 0);
+                UE_mac_inst[ue_Mod_id].UE_mode[0] = RA_RESPONSE;
+                next_Mod_id = ue_Mod_id + 1;
+                //next_ra_frame = (proc->frame_rx + 20)%1000;
+                next_ra_frame = 0;
               }
-            }
-          } // mode is PRACH
 
-          // Substitute call to phy_procedures Tx with call to phy_stub functions in order to trigger
-          // UE Tx procedures directly at the MAC layer, based on the received ul_config requests from the vnf (eNB).
-          // Generate UL_indications which correspond to UL traffic.
-          if(ul_config_req!=NULL) { //&& UE_mac_inst[Mod_id].ul_config_req->ul_config_request_body.ul_config_pdu_list != NULL){
-            ul_config_req_UE_MAC(ul_config_req, timer_frame, timer_subframe, ue_Mod_id);
+              //ue_prach_procedures(ue,proc,eNB_id,abstraction_flag,mode);
+            }
           }
-        }
+        } // mode is PRACH
 
-      phy_procedures_UE_SL_RX(UE,proc);
+      // Substitute call to phy_procedures Tx with call to phy_stub functions in order to trigger
+      // UE Tx procedures directly at the MAC layer, based on the received ul_config requests from the vnf (eNB).
+      // Generate UL_indications which correspond to UL traffic.
+      if(ul_config_req!=NULL) { //&& UE_mac_inst[Mod_id].ul_config_req->ul_config_request_body.ul_config_pdu_list != NULL){
+        ul_config_req_UE_MAC(ul_config_req, timer_frame, timer_subframe, ue_Mod_id);
+      }
     } //for (Mod_id=0; Mod_id<NB_UE_INST; Mod_id++)
 
     phy_stub_ticking->num_single_thread[ue_thread_id] = -1;
@@ -1709,6 +1683,7 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg)
             tx_req_pdu_list[i].segments[j].segment_data = NULL;
           }
         }
+
         tx_req_num_elems = 0;
         free(tx_req_pdu_list);
         tx_req_pdu_list = NULL;
@@ -1752,7 +1727,6 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg)
   free(UL_INFO);
   UL_INFO = NULL;
 #endif // disabled UE_phy_stub_single_thread_rxn_txnp4
-
   // thread finished
   free(arg);
   return NULL;
@@ -1767,9 +1741,8 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg)
  * \returns a pointer to an int. The storage is not on the heap and must not be freed.
  */
 
-static void *UE_phy_stub_thread_rxn_txnp4(void *arg)
-{
-  #if 0
+static void *UE_phy_stub_thread_rxn_txnp4(void *arg) {
+#if 0
   thread_top_init("UE_phy_stub_thread_rxn_txnp4",1,870000L,1000000L,1000000L);
   module_id_t Mod_id = 0;
   static __thread int UE_thread_rxtx_retval;
@@ -1880,45 +1853,42 @@ static void *UE_phy_stub_thread_rxn_txnp4(void *arg)
 
     if ((subframe_select( &UE->frame_parms, proc->subframe_tx) == SF_UL) ||
         (UE->frame_parms.frame_type == FDD) )
-      if (UE->mode != loop_through_memory) {
-        if ((UE_mac_inst[Mod_id].UE_mode[0] == PRACH) ) {
-          // check if we have PRACH opportunity
-          if (is_prach_subframe(&UE->frame_parms,proc->frame_tx, proc->subframe_tx)) {
-            PRACH_RESOURCES_t *prach_resources = ue_get_rach(Mod_id, 0, proc->frame_tx, 0, proc->subframe_tx);
-
-            if(prach_resources!=NULL) {
-              fill_rach_indication_UE_MAC(Mod_id, proc->frame_tx,proc->subframe_tx, UL_INFO, prach_resources->ra_PreambleIndex, prach_resources->ra_RNTI);
-              Msg1_transmitted(Mod_id, 0, proc->frame_tx, 0);
-              UE_mac_inst[Mod_id].UE_mode[0] = RA_RESPONSE;
-            }
-
-            //ue_prach_procedures(ue,proc,eNB_id,abstraction_flag,mode);
+      if ((UE_mac_inst[Mod_id].UE_mode[0] == PRACH) ) {
+        // check if we have PRACH opportunity
+        if (is_prach_subframe(&UE->frame_parms,proc->frame_tx, proc->subframe_tx)) {
+          PRACH_RESOURCES_t *prach_resources = ue_get_rach(Mod_id, 0, proc->frame_tx, 0, proc->subframe_tx);
+
+          if(prach_resources!=NULL) {
+            fill_rach_indication_UE_MAC(Mod_id, proc->frame_tx,proc->subframe_tx, UL_INFO, prach_resources->ra_PreambleIndex, prach_resources->ra_RNTI);
+            Msg1_transmitted(Mod_id, 0, proc->frame_tx, 0);
+            UE_mac_inst[Mod_id].UE_mode[0] = RA_RESPONSE;
           }
-        } // mode is PRACH
 
-        // Substitute call to phy_procedures Tx with call to phy_stub functions in order to trigger
-        // UE Tx procedures directly at the MAC layer, based on the received ul_config requests from the vnf (eNB).
-        // Generate UL_indications which correspond to UL traffic.
-        if(ul_config_req!= NULL && ul_config_req->ul_config_request_body.ul_config_pdu_list != NULL) {
-          //LOG_I(MAC, "UE_phy_stub_thread_rxn_txnp4 ul_config_req is not NULL \n");
-          ul_config_req_UE_MAC(ul_config_req, timer_frame, timer_subframe, Mod_id);
+          //ue_prach_procedures(ue,proc,eNB_id,abstraction_flag,mode);
+        }
+      } // mode is PRACH
 
-          if(ul_config_req->ul_config_request_body.ul_config_pdu_list != NULL) {
-            free(ul_config_req->ul_config_request_body.ul_config_pdu_list);
-            ul_config_req->ul_config_request_body.ul_config_pdu_list = NULL;
-          }
+    // Substitute call to phy_procedures Tx with call to phy_stub functions in order to trigger
+    // UE Tx procedures directly at the MAC layer, based on the received ul_config requests from the vnf (eNB).
+    // Generate UL_indications which correspond to UL traffic.
+    if(ul_config_req!= NULL && ul_config_req->ul_config_request_body.ul_config_pdu_list != NULL) {
+      //LOG_I(MAC, "UE_phy_stub_thread_rxn_txnp4 ul_config_req is not NULL \n");
+      ul_config_req_UE_MAC(ul_config_req, timer_frame, timer_subframe, Mod_id);
 
-          free(ul_config_req);
-          ul_config_req = NULL;
-        } else if(ul_config_req!=NULL) {
-          free(ul_config_req);
-          ul_config_req = NULL;
-        }
+      if(ul_config_req->ul_config_request_body.ul_config_pdu_list != NULL) {
+        free(ul_config_req->ul_config_request_body.ul_config_pdu_list);
+        ul_config_req->ul_config_request_body.ul_config_pdu_list = NULL;
       }
 
-    phy_procedures_UE_SL_RX(UE,proc);
+      free(ul_config_req);
+      ul_config_req = NULL;
+    } else if(ul_config_req!=NULL) {
+      free(ul_config_req);
+      ul_config_req = NULL;
+    }
   }
-  #endif // disabled
+
+#endif // disabled
   // thread finished
   free(arg);
   return NULL; //return &UE_thread_rxtx_retval;
@@ -1938,22 +1908,21 @@ void write_dummy(PHY_VARS_UE *UE,  openair0_timestamp timestamp) {
   // we have to write to tell explicitly to the eNB, else it will wait for us forever
   // we write the next subframe (always write in future of what we received)
   //
-  struct complex16 v= {0};
+  c16_t v= {0};
   void *samplesVoid[UE->frame_parms.nb_antennas_tx];
-  
+
   for ( int i=0; i < UE->frame_parms.nb_antennas_tx; i++)
     samplesVoid[i]=(void *)&v;
-  
+
   AssertFatal( 1 == UE->rfdevice.trx_write_func(&UE->rfdevice,
-						timestamp+2*UE->frame_parms.samples_per_tti,
-						samplesVoid, 
-						1,
-						UE->frame_parms.nb_antennas_tx,
-						1),"");
+               timestamp+2*UE->frame_parms.samples_per_tti,
+               samplesVoid,
+               1,
+               UE->frame_parms.nb_antennas_tx,
+               1),"");
 }
 
-void *UE_thread(void *arg)
-{
+void *UE_thread(void *arg) {
   PHY_VARS_UE *UE = (PHY_VARS_UE *) arg;
   //  int tx_enabled = 0;
   int dummy_rx[UE->frame_parms.nb_antennas_rx][UE->frame_parms.samples_per_tti] __attribute__((aligned(32)));
@@ -1966,10 +1935,11 @@ void *UE_thread(void *arg)
   int ret;
   cpu_set_t cpuset;
   CPU_ZERO(&cpuset);
+
   if ( threads.main != -1 )
     CPU_SET(threads.main, &cpuset);
-  init_thread(100000, 500000, FIFO_PRIORITY, &cpuset, "UHD Threads");
 
+  init_thread(100000, 500000, FIFO_PRIORITY, &cpuset, "UHD Threads");
   /*
   while (sync_var<0)
     pthread_cond_wait(&sync_cond, &sync_mutex);
@@ -1996,46 +1966,45 @@ void *UE_thread(void *arg)
     int instance_cnt_synch = UE->proc.instance_cnt_synch;
     int is_synchronized    = UE->is_synchronized;
     AssertFatal ( 0== pthread_mutex_unlock(&UE->proc.mutex_synch), "");
-    
+
     if (is_synchronized == 0) {
       if (instance_cnt_synch < 0) {  // we can invoke the synch
 
-	// we shift in time flow because the UE doesn't detect sync when frame alignment is not easy
-	for (int i=0; i<UE->frame_parms.nb_antennas_rx; i++)
-            rxp[i] = (void *)&dummy_rx[i][0];
-	UE->rfdevice.trx_read_func(&UE->rfdevice,
-				   &timestamp,
-				   rxp,
-				   UE->frame_parms.samples_per_tti/2,
-				   UE->frame_parms.nb_antennas_rx);
-	
+        // we shift in time flow because the UE doesn't detect sync when frame alignment is not easy
+        for (int i=0; i<UE->frame_parms.nb_antennas_rx; i++)
+          rxp[i] = (void *)&dummy_rx[i][0];
+
+        UE->rfdevice.trx_read_func(&UE->rfdevice,
+                                   &timestamp,
+                                   rxp,
+                                   UE->frame_parms.samples_per_tti/2,
+                                   UE->frame_parms.nb_antennas_rx);
+
         // grab 10 ms of signal and wakeup synch thread
-	
-        if (UE->mode != loop_through_memory) {
-          if (IS_SOFTMODEM_RFSIM ) {
-	    for(int sf=0; sf<10; sf++) {
-	      for (int i=0; i<UE->frame_parms.nb_antennas_rx; i++)
-		rxp[i] = (void *)&UE->common_vars.rxdata[i][UE->frame_parms.samples_per_tti*sf];
-	      
-              AssertFatal(UE->frame_parms.samples_per_tti == UE->rfdevice.trx_read_func(&UE->rfdevice,
-						      &timestamp,
-						      rxp,
-						      UE->frame_parms.samples_per_tti,
-						      UE->frame_parms.nb_antennas_rx), "");
-	      write_dummy(UE, timestamp);
-	    }
-	  } else {
-	    for (int i=0; i<UE->frame_parms.nb_antennas_rx; i++)
-	      rxp[i] = (void *)&UE->common_vars.rxdata[i][0];
-	    
-	    AssertFatal( UE->frame_parms.samples_per_tti*10 ==
-                         UE->rfdevice.trx_read_func(&UE->rfdevice,
-                                                    &timestamp,
-                                                    rxp,
-                                                    UE->frame_parms.samples_per_tti*10,
-                                                    UE->frame_parms.nb_antennas_rx), "");
-	      }
-	}
+
+        if (IS_SOFTMODEM_RFSIM ) {
+          for(int sf=0; sf<10; sf++) {
+            for (int i=0; i<UE->frame_parms.nb_antennas_rx; i++)
+              rxp[i] = (void *)&UE->common_vars.rxdata[i][UE->frame_parms.samples_per_tti*sf];
+
+            AssertFatal(UE->frame_parms.samples_per_tti == UE->rfdevice.trx_read_func(&UE->rfdevice,
+                        &timestamp,
+                        rxp,
+                        UE->frame_parms.samples_per_tti,
+                        UE->frame_parms.nb_antennas_rx), "");
+            write_dummy(UE, timestamp);
+          }
+        } else {
+          for (int i=0; i<UE->frame_parms.nb_antennas_rx; i++)
+            rxp[i] = (void *)&UE->common_vars.rxdata[i][0];
+
+          AssertFatal( UE->frame_parms.samples_per_tti*10 ==
+                       UE->rfdevice.trx_read_func(&UE->rfdevice,
+                                                  &timestamp,
+                                                  rxp,
+                                                  UE->frame_parms.samples_per_tti*10,
+                                                  UE->frame_parms.nb_antennas_rx), "");
+        }
 
         AssertFatal ( 0== pthread_mutex_lock(&UE->proc.mutex_synch), "");
         instance_cnt_synch = ++UE->proc.instance_cnt_synch;
@@ -2049,69 +2018,62 @@ void *UE_thread(void *arg)
 
         AssertFatal ( 0== pthread_mutex_unlock(&UE->proc.mutex_synch), "");
       } else {
-#if OAISIM
-        (void)dummy_rx; /* avoid gcc warnings */
-        usleep(500);
-#else
         // grab 10 ms of signal into dummy buffer
-        if (UE->mode != loop_through_memory) {
-          for (int i=0; i<UE->frame_parms.nb_antennas_rx; i++)
-            rxp[i] = (void *)&dummy_rx[i][0];
-
-          for (int sf=0; sf<10; sf++) {
-            //      printf("Reading dummy sf %d\n",sf);
-            UE->rfdevice.trx_read_func(&UE->rfdevice,
-                                       &timestamp,
-                                       rxp,
-                                       UE->frame_parms.samples_per_tti,
-                                       UE->frame_parms.nb_antennas_rx);
-	    if (IS_SOFTMODEM_RFSIM )
-	      write_dummy(UE, timestamp);
-	  }
-	  }
-#endif
+        for (int i=0; i<UE->frame_parms.nb_antennas_rx; i++)
+          rxp[i] = (void *)&dummy_rx[i][0];
+
+        for (int sf=0; sf<10; sf++) {
+          //      printf("Reading dummy sf %d\n",sf);
+          UE->rfdevice.trx_read_func(&UE->rfdevice,
+                                     &timestamp,
+                                     rxp,
+                                     UE->frame_parms.samples_per_tti,
+                                     UE->frame_parms.nb_antennas_rx);
+
+          if (IS_SOFTMODEM_RFSIM )
+            write_dummy(UE, timestamp);
+        }
       }
     } // UE->is_synchronized==0
     else {
       if (start_rx_stream==0) {
         start_rx_stream=1;
 
-        if (UE->mode != loop_through_memory) {
-          if (UE->no_timing_correction==0) {
-            LOG_I(PHY,"Resynchronizing RX by %d samples (mode = %d)\n",UE->rx_offset,UE->mode);
-	    while ( UE->rx_offset ) {
-	      size_t s=min(UE->rx_offset,UE->frame_parms.samples_per_tti);
-              AssertFatal(s == UE->rfdevice.trx_read_func(&UE->rfdevice,
-						     &timestamp,
-						     (void **)UE->common_vars.rxdata,
-						     s,
-						     UE->frame_parms.nb_antennas_rx),"");
-	      if (IS_SOFTMODEM_RFSIM )
-		write_dummy(UE, timestamp);
-	      UE->rx_offset-=s;
-	    }
-          }
+        if (UE->no_timing_correction==0) {
+          LOG_I(PHY,"Resynchronizing RX by %d samples (mode = %d)\n",UE->rx_offset,UE->mode);
 
-          UE->rx_offset=0;
-          UE->time_sync_cell=0;
+          while ( UE->rx_offset ) {
+            size_t s=min(UE->rx_offset,UE->frame_parms.samples_per_tti);
+            AssertFatal(s == UE->rfdevice.trx_read_func(&UE->rfdevice,
+                        &timestamp,
+                        (void **)UE->common_vars.rxdata,
+                        s,
+                        UE->frame_parms.nb_antennas_rx),"");
 
-          //UE->proc.proc_rxtx[0].frame_rx++;
-          //UE->proc.proc_rxtx[1].frame_rx++;
-          for (th_id=0; th_id < RX_NB_TH; th_id++) {
-            UE->proc.proc_rxtx[th_id].frame_rx++;
+            if (IS_SOFTMODEM_RFSIM )
+              write_dummy(UE, timestamp);
+
+            UE->rx_offset-=s;
           }
+        }
 
-          // read in first symbol
-          AssertFatal (UE->frame_parms.ofdm_symbol_size+UE->frame_parms.nb_prefix_samples0 ==
-                       UE->rfdevice.trx_read_func(&UE->rfdevice,
-                                                  &timestamp,
-                                                  (void **)UE->common_vars.rxdata,
-                                                  UE->frame_parms.ofdm_symbol_size+UE->frame_parms.nb_prefix_samples0,
-                                                  UE->frame_parms.nb_antennas_rx),"");
-          slot_fep(UE,0, 0, 0, 0, 0);
-        } //UE->mode != loop_through_memory
-        else
-          rt_sleep_ns(1000*1000);
+        UE->rx_offset=0;
+        UE->time_sync_cell=0;
+
+        //UE->proc.proc_rxtx[0].frame_rx++;
+        //UE->proc.proc_rxtx[1].frame_rx++;
+        for (th_id=0; th_id < RX_NB_TH; th_id++) {
+          UE->proc.proc_rxtx[th_id].frame_rx++;
+        }
+
+        // read in first symbol
+        AssertFatal (UE->frame_parms.ofdm_symbol_size+UE->frame_parms.nb_prefix_samples0 ==
+                     UE->rfdevice.trx_read_func(&UE->rfdevice,
+                                                &timestamp,
+                                                (void **)UE->common_vars.rxdata,
+                                                UE->frame_parms.ofdm_symbol_size+UE->frame_parms.nb_prefix_samples0,
+                                                UE->frame_parms.nb_antennas_rx),"");
+        slot_fep(UE,0, 0, 0, 0, 0);
       } else {
         sub_frame++;
         sub_frame%=10;
@@ -2130,7 +2092,8 @@ void *UE_thread(void *arg)
 
             pthread_mutex_unlock(&proc->mutex_rxtx);
           }
-	  usleep(300);
+
+          usleep(300);
         }
 
         LOG_D(PHY,"Process Subframe %d thread Idx %d \n", sub_frame, UE->current_thread_id[sub_frame]);
@@ -2139,130 +2102,129 @@ void *UE_thread(void *arg)
         if(thread_idx>=RX_NB_TH)
           thread_idx = 0;
 
-        if (UE->mode != loop_through_memory) {
-          for (i=0; i<UE->frame_parms.nb_antennas_rx; i++)
-            rxp[i] = (void *)&UE->common_vars.rxdata[i][UE->frame_parms.ofdm_symbol_size+
-                     UE->frame_parms.nb_prefix_samples0+
-                     sub_frame*UE->frame_parms.samples_per_tti];
-
-          for (i=0; i<UE->frame_parms.nb_antennas_tx; i++)
-            txp[i] = (void *)&UE->common_vars.txdata[i][((sub_frame+2)%10)*UE->frame_parms.samples_per_tti];
+        for (i=0; i<UE->frame_parms.nb_antennas_rx; i++)
+          rxp[i] = (void *)&UE->common_vars.rxdata[i][UE->frame_parms.ofdm_symbol_size+
+                   UE->frame_parms.nb_prefix_samples0+
+                   sub_frame*UE->frame_parms.samples_per_tti];
 
-          int readBlockSize, writeBlockSize;
+        for (i=0; i<UE->frame_parms.nb_antennas_tx; i++)
+          txp[i] = (void *)&UE->common_vars.txdata[i][((sub_frame+2)%10)*UE->frame_parms.samples_per_tti];
 
-          if (sub_frame<9) {
-            readBlockSize=UE->frame_parms.samples_per_tti;
-            writeBlockSize=UE->frame_parms.samples_per_tti;
-          } else {
-            // set TO compensation to zero
-            UE->rx_offset_diff = 0;
+        int readBlockSize, writeBlockSize;
 
-            // compute TO compensation that should be applied for this frame
+        if (sub_frame<9) {
+          readBlockSize=UE->frame_parms.samples_per_tti;
+          writeBlockSize=UE->frame_parms.samples_per_tti;
+        } else {
+          // set TO compensation to zero
+          UE->rx_offset_diff = 0;
 
-            if (UE->no_timing_correction == 0) {
-              if ( UE->rx_offset < 5*UE->frame_parms.samples_per_tti  &&
-                   UE->rx_offset > 0 )
-                UE->rx_offset_diff = -1 ;
+          // compute TO compensation that should be applied for this frame
 
-              if ( UE->rx_offset > 5*UE->frame_parms.samples_per_tti &&
-                   UE->rx_offset < 10*UE->frame_parms.samples_per_tti )
-                UE->rx_offset_diff = 1;
-            }
+          if (UE->no_timing_correction == 0) {
+            if ( UE->rx_offset < 5*UE->frame_parms.samples_per_tti  &&
+                 UE->rx_offset > 0 )
+              UE->rx_offset_diff = -1 ;
 
-            LOG_D(PHY,"AbsSubframe %d.%d SET rx_off_diff to %d rx_offset %d \n",proc->frame_rx,sub_frame,UE->rx_offset_diff,UE->rx_offset);
-            readBlockSize=UE->frame_parms.samples_per_tti -
-                          UE->frame_parms.ofdm_symbol_size -
-                          UE->frame_parms.nb_prefix_samples0 -
-                          UE->rx_offset_diff;
-            writeBlockSize=UE->frame_parms.samples_per_tti -
-                           UE->rx_offset_diff;
+            if ( UE->rx_offset > 5*UE->frame_parms.samples_per_tti &&
+                 UE->rx_offset < 10*UE->frame_parms.samples_per_tti )
+              UE->rx_offset_diff = 1;
           }
 
-          AssertFatal(readBlockSize ==
-                      UE->rfdevice.trx_read_func(&UE->rfdevice,
-                                                 &timestamp,
-                                                 rxp,
-                                                 readBlockSize,
-                                                 UE->frame_parms.nb_antennas_rx),"");
-          AssertFatal( writeBlockSize ==
-                       UE->rfdevice.trx_write_func(&UE->rfdevice,
-                           timestamp+
-                           (2*UE->frame_parms.samples_per_tti) -
-                           UE->frame_parms.ofdm_symbol_size-UE->frame_parms.nb_prefix_samples0 -
-                           openair0_cfg[0].tx_sample_advance,
-                           txp,
-                           writeBlockSize,
-                           UE->frame_parms.nb_antennas_tx,
-                           1),"");
-
-          if( sub_frame==9) {
-            // read in first symbol of next frame and adjust for timing drift
-            int first_symbols=writeBlockSize-readBlockSize;
-
-            if ( first_symbols > 0 )
-              AssertFatal(first_symbols ==
-                          UE->rfdevice.trx_read_func(&UE->rfdevice,
-                                                     &timestamp1,
-                                                     (void **)UE->common_vars.rxdata,
-                                                     first_symbols,
-                                                     UE->frame_parms.nb_antennas_rx),"");
-
-            if ( first_symbols <0 )
-              LOG_E(PHY,"can't compensate: diff =%d\n", first_symbols);
-          }
+          LOG_D(PHY,"AbsSubframe %d.%d SET rx_off_diff to %d rx_offset %d \n",proc->frame_rx,sub_frame,UE->rx_offset_diff,UE->rx_offset);
+          readBlockSize=UE->frame_parms.samples_per_tti -
+                        UE->frame_parms.ofdm_symbol_size -
+                        UE->frame_parms.nb_prefix_samples0 -
+                        UE->rx_offset_diff;
+          writeBlockSize=UE->frame_parms.samples_per_tti -
+                         UE->rx_offset_diff;
+        }
 
-          /* no timeout in IS_SOFTMODEM_RFSIM mode */
-          if (IS_SOFTMODEM_RFSIM) {
-            ret = pthread_mutex_lock(&proc->mutex_rxtx);
-          } else {
-            struct timespec tv;
-            if (clock_gettime(CLOCK_REALTIME, &tv) != 0) {
-              perror("clock_gettime");
-              exit(1);
-            }
-            tv.tv_nsec += 10*1000;
-            if (tv.tv_nsec >= 1000 * 1000 * 1000) {
-              tv.tv_sec++;
-              tv.tv_nsec -= 1000 * 1000 * 1000;
-            }
-            ret = pthread_mutex_timedlock(&proc->mutex_rxtx, &tv);
+        AssertFatal(readBlockSize ==
+                    UE->rfdevice.trx_read_func(&UE->rfdevice,
+                                               &timestamp,
+                                               rxp,
+                                               readBlockSize,
+                                               UE->frame_parms.nb_antennas_rx),"");
+        AssertFatal( writeBlockSize ==
+                     UE->rfdevice.trx_write_func(&UE->rfdevice,
+                         timestamp+
+                         (2*UE->frame_parms.samples_per_tti) -
+                         UE->frame_parms.ofdm_symbol_size-UE->frame_parms.nb_prefix_samples0 -
+                         openair0_cfg[0].tx_sample_advance,
+                         txp,
+                         writeBlockSize,
+                         UE->frame_parms.nb_antennas_tx,
+                         1),"");
+
+        if( sub_frame==9) {
+          // read in first symbol of next frame and adjust for timing drift
+          int first_symbols=writeBlockSize-readBlockSize;
+
+          if ( first_symbols > 0 )
+            AssertFatal(first_symbols ==
+                        UE->rfdevice.trx_read_func(&UE->rfdevice,
+                                                   &timestamp1,
+                                                   (void **)UE->common_vars.rxdata,
+                                                   first_symbols,
+                                                   UE->frame_parms.nb_antennas_rx),"");
+
+          if ( first_symbols <0 )
+            LOG_E(PHY,"can't compensate: diff =%d\n", first_symbols);
+        }
+
+        /* no timeout in IS_SOFTMODEM_RFSIM mode */
+        if (IS_SOFTMODEM_RFSIM) {
+          ret = pthread_mutex_lock(&proc->mutex_rxtx);
+        } else {
+          struct timespec tv;
+
+          if (clock_gettime(CLOCK_REALTIME, &tv) != 0) {
+            perror("clock_gettime");
+            exit(1);
           }
 
-          // operate on thread sf mod 2
-          if (ret != 0) {
-            if (ret == ETIMEDOUT) {
-              LOG_E(PHY,"Missed real time\n");
-              continue;
-            } else {
-              LOG_E(PHY,"System error %s (%d)\n",strerror(errno),errno);
-              abort();
-            }
+          tv.tv_nsec += 10*1000;
+
+          if (tv.tv_nsec >= 1000 * 1000 * 1000) {
+            tv.tv_sec++;
+            tv.tv_nsec -= 1000 * 1000 * 1000;
           }
 
-          //          usleep(3000);
-          if(sub_frame == 0) {
-            //UE->proc.proc_rxtx[0].frame_rx++;
-            //UE->proc.proc_rxtx[1].frame_rx++;
-            for (th_id=0; th_id < RX_NB_TH; th_id++) {
-              UE->proc.proc_rxtx[th_id].frame_rx++;
-            }
+          ret = pthread_mutex_timedlock(&proc->mutex_rxtx, &tv);
+        }
+
+        // operate on thread sf mod 2
+        if (ret != 0) {
+          if (ret == ETIMEDOUT) {
+            LOG_E(PHY,"Missed real time\n");
+            continue;
+          } else {
+            LOG_E(PHY,"System error %s (%d)\n",strerror(errno),errno);
+            abort();
           }
+        }
 
-          proc->subframe_rx=sub_frame;
-          proc->subframe_tx=(sub_frame+4)%10;
-          proc->frame_tx = proc->frame_rx + (proc->subframe_rx>5?1:0);
-          proc->timestamp_tx = timestamp+
-                               (4*UE->frame_parms.samples_per_tti)-
-                               UE->frame_parms.ofdm_symbol_size-UE->frame_parms.nb_prefix_samples0;
-          proc->instance_cnt_rxtx++;
-          LOG_D( PHY, "[SCHED][UE %d] UE RX instance_cnt_rxtx %d subframe %d !!\n", UE->Mod_id, proc->instance_cnt_rxtx,proc->subframe_rx);
-          T(T_UE_MASTER_TICK, T_INT(0), T_INT(proc->frame_rx%1024), T_INT(proc->subframe_rx));
-          AssertFatal (pthread_cond_signal(&proc->cond_rxtx) ==0,"");
-          AssertFatal(pthread_mutex_unlock(&proc->mutex_rxtx) ==0,"");
-        } else {
-          printf("Processing subframe %d",proc->subframe_rx);
-          getchar();
+        //          usleep(3000);
+        if(sub_frame == 0) {
+          //UE->proc.proc_rxtx[0].frame_rx++;
+          //UE->proc.proc_rxtx[1].frame_rx++;
+          for (th_id=0; th_id < RX_NB_TH; th_id++) {
+            UE->proc.proc_rxtx[th_id].frame_rx++;
+          }
         }
+
+        proc->subframe_rx=sub_frame;
+        proc->subframe_tx=(sub_frame+4)%10;
+        proc->frame_tx = proc->frame_rx + (proc->subframe_rx>5?1:0);
+        proc->timestamp_tx = timestamp+
+                             (4*UE->frame_parms.samples_per_tti)-
+                             UE->frame_parms.ofdm_symbol_size-UE->frame_parms.nb_prefix_samples0;
+        proc->instance_cnt_rxtx++;
+        LOG_D( PHY, "[SCHED][UE %d] UE RX instance_cnt_rxtx %d subframe %d !!\n", UE->Mod_id, proc->instance_cnt_rxtx,proc->subframe_rx);
+        T(T_UE_MASTER_TICK, T_INT(0), T_INT(proc->frame_rx%1024), T_INT(proc->subframe_rx));
+        AssertFatal (pthread_cond_signal(&proc->cond_rxtx) ==0,"");
+        AssertFatal(pthread_mutex_unlock(&proc->mutex_rxtx) ==0,"");
       } // start_rx_stream==1
     } // UE->is_synchronized==1
   } // while !oai_exit
@@ -2283,8 +2245,7 @@ void *UE_thread(void *arg)
  * - UE_thread_dlsch_proc_slot1
  * and the locking between them.
  */
-void init_UE_threads(int inst)
-{
+void init_UE_threads(int inst) {
   struct rx_tx_thread_data *rtd;
   PHY_VARS_UE *UE;
   AssertFatal(PHY_vars_UE_g!=NULL,"PHY_vars_UE_g is NULL\n");
@@ -2339,8 +2300,7 @@ void init_UE_threads(int inst)
  * - UE_thread_dlsch_proc_slot1
  * and the locking between them.
  */
-void init_UE_single_thread_stub(int nb_inst)
-{
+void init_UE_single_thread_stub(int nb_inst) {
   struct rx_tx_thread_data *rtd;
   PHY_VARS_UE *UE;
 
@@ -2368,8 +2328,8 @@ void init_UE_single_thread_stub(int nb_inst)
   // In phy_stub_UE mode due to less heavy processing operations we don't need two threads
   //int nb_threads=RX_NB_TH;
   int nb_threads=1;
+  void *(*task_func)(void *);
 
-  void* (*task_func)(void*);
   if (NFAPI_MODE == NFAPI_MODE_STANDALONE_PNF) {
     task_func = UE_phy_stub_standalone_pnf_task;
   } else {
@@ -2413,8 +2373,7 @@ void init_UE_single_thread_stub(int nb_inst)
  * - UE_thread_dlsch_proc_slot1
  * and the locking between them.
  */
-void init_UE_threads_stub(int inst)
-{
+void init_UE_threads_stub(int inst) {
   struct rx_tx_thread_data *rtd;
   PHY_VARS_UE *UE;
   AssertFatal(PHY_vars_UE_g!=NULL,"PHY_vars_UE_g is NULL\n");
@@ -2451,8 +2410,7 @@ void init_UE_threads_stub(int inst)
 }
 
 
-void fill_ue_band_info(void)
-{
+void fill_ue_band_info(void) {
   LTE_UE_EUTRA_Capability_t *UE_EUTRA_Capability = UE_rrc_inst[0].UECap->UE_EUTRA_Capability;
   int i,j;
   bands_to_scan.nbands = UE_EUTRA_Capability->rf_Parameters.supportedBandListEUTRA.list.count;
@@ -2477,8 +2435,7 @@ void fill_ue_band_info(void)
 }
 
 int setup_ue_buffers(PHY_VARS_UE **phy_vars_ue,
-                     openair0_config_t *openair0_cfg)
-{
+                     openair0_config_t *openair0_cfg) {
   int i, CC_id;
   LTE_DL_FRAME_PARMS *frame_parms;
 
@@ -2486,23 +2443,18 @@ int setup_ue_buffers(PHY_VARS_UE **phy_vars_ue,
     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 %lu on card %d, chain %d\n",
             CC_id, i, downlink_frequency[CC_id][i], phy_vars_ue[CC_id]->rf_map.card, (phy_vars_ue[CC_id]->rf_map.chain)+i );
       free( phy_vars_ue[CC_id]->common_vars.rxdata[i] );
-      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
+      phy_vars_ue[CC_id]->common_vars.rxdata[i] = malloc16_clear( 307200*sizeof(int32_t) ); // 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 %lu on card %d, chain %d\n",
             CC_id, i, downlink_frequency[CC_id][i], phy_vars_ue[CC_id]->rf_map.card, (phy_vars_ue[CC_id]->rf_map.chain)+i );
       free( phy_vars_ue[CC_id]->common_vars.txdata[i] );
-      txdata[i] = (int32_t *)malloc16_clear( 307200*sizeof(int32_t) );
-      phy_vars_ue[CC_id]->common_vars.txdata[i] = txdata[i];
+      phy_vars_ue[CC_id]->common_vars.txdata[i] = malloc16_clear( 307200*sizeof(int32_t) );
     }
 
     // rxdata[x] points now to the same memory region as phy_vars_ue[CC_id]->common_vars.rxdata[x]
@@ -2520,8 +2472,7 @@ int setup_ue_buffers(PHY_VARS_UE **phy_vars_ue,
 // playing the role of nfapi-pnf.
 
 //02/02/2018
-static void *timer_thread( void *param )
-{
+static void *timer_thread( void *param ) {
   thread_top_init("timer_thread",1,870000L,1000000L,1000000L);
   timer_subframe =9;
   timer_frame    =1023;
@@ -2647,8 +2598,7 @@ static void *timer_thread( void *param )
 }
 
 
-int init_timer_thread(void)
-{
+int init_timer_thread(void) {
   //PHY_VARS_UE *UE=PHY_vars_UE_g[0];
   PHY_VARS_UE *UE=PHY_vars_UE_g[0][0];
   phy_stub_ticking = (SF_ticking *)malloc(sizeof(SF_ticking));
@@ -2670,8 +2620,7 @@ int init_timer_thread(void)
  */
 int8_t find_dlsch(uint16_t rnti,
                   PHY_VARS_eNB *eNB,
-                  find_type_t type)
-{
+                  find_type_t type) {
   printf("you cannot read this\n");
   abort();
 }
diff --git a/targets/RT/USER/lte-uesoftmodem.c b/targets/RT/USER/lte-uesoftmodem.c
index 8cdef647cab5063722aaccf0d3ccbe938677e6ef..089941c7dfc0de799960b9206bf2f771e5564e11 100644
--- a/targets/RT/USER/lte-uesoftmodem.c
+++ b/targets/RT/USER/lte-uesoftmodem.c
@@ -276,7 +276,6 @@ uint16_t node_number;
 static void get_options(void) {
   int CC_id=0;
   int tddflag=0;
-  char *loopfile=NULL;
   int dumpframe=0;
   int timingadv=0;
   uint8_t nfapi_mode = NFAPI_MONOLITHIC;
@@ -293,14 +292,6 @@ static void get_options(void) {
   config_process_cmdline( cmdline_ueparams,sizeof(cmdline_ueparams)/sizeof(paramdef_t),NULL);
   nfapi_setmode(nfapi_mode);
 
-
-  if (loopfile != NULL) {
-    printf("Input file for hardware emulation: %s",loopfile);
-    mode=loop_through_memory;
-    input_fd = fopen(loopfile,"r");
-    AssertFatal(input_fd != NULL,"Please provide a valid input file\n");
-  }
-
   get_softmodem_params()->hw_timing_advance = timingadv;
 
   if ( (cmdline_uemodeparams[CMDLINE_CALIBUERX_IDX].paramflags &  PARAMFLAG_PARAMSET) != 0) mode = rx_calib_ue;