[VOL-1707]
Run golang SCA tools on the golang openolt adapter and fix the errors.
Used golangci-lint tool.
Makefile integrated with new target for running golangci-lint tool.

Change-Id: I8458d75bf4a997d6f93740acf10a03bf43c554c7
diff --git a/.gitignore b/.gitignore
index 6850f66..ce10b34 100644
--- a/.gitignore
+++ b/.gitignore
@@ -39,3 +39,6 @@
 
 # test output
 tests/results
+
+# SCA reports from run golangci-lint tool
+sca-report/
diff --git a/.golangci.yml b/.golangci.yml
new file mode 100644
index 0000000..ed56321
--- /dev/null
+++ b/.golangci.yml
@@ -0,0 +1,87 @@
+#Copyright 2018-present Open Networking Foundation
+#
+#Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+#
+#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.
+
+linters-settings:
+  govet:
+    check-shadowing: true
+    settings:
+      printf:
+        funcs:
+          - (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
+          - (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
+          - (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
+          - (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
+  golint:
+    min-confidence: 0
+
+  gocyclo:
+    min-complexity: 15
+
+  misspell:
+    locale: US
+
+linters:
+  disable-all: true
+  enable:
+    - gofmt
+    - govet
+    - gocyclo
+    - golint
+    - ineffassign
+    - misspell
+
+run:
+  skip-dirs:
+    - vendor
+  modules-download-mode: vendor
+
+issues:
+  exclude-rules:
+    - text: "weak cryptographic primitive"
+      linters:
+        - gosec
+  exclude:
+    - "don't use underscores in Go names; method Adapter_descriptor"
+    - "don't use underscores in Go names; method Device_types"
+    - "don't use underscores in Go names; method Adopt_device"
+    - "don't use underscores in Go names; method Reconcile_device"
+    - "don't use underscores in Go names; method Abandon_device"
+    - "don't use underscores in Go names; method Disable_device"
+    - "don't use underscores in Go names; method Reenable_device"
+    - "don't use underscores in Go names; method Reboot_device"
+    - "don't use underscores in Go names; method Self_test_device"
+    - "don't use underscores in Go names; method Delete_device"
+    - "don't use underscores in Go names; method Get_device_details"
+    - "don't use underscores in Go names; method Update_flows_bulk"
+    - "don't use underscores in Go names; method Update_flows_incrementally"
+    - "don't use underscores in Go names; method Update_pm_config"
+    - "don't use underscores in Go names; method Receive_packet_out"
+    - "don't use underscores in Go names; method Suppress_alarm"
+    - "don't use underscores in Go names; method Unsuppress_alarm"
+    - "don't use underscores in Go names; method Get_ofp_device_info"
+    - "don't use underscores in Go names; method Get_ofp_port_info"
+    - "don't use underscores in Go names; method Process_inter_adapter_message"
+    - "don't use underscores in Go names; method Download_image"
+    - "don't use underscores in Go names; method Get_image_download_status"
+    - "don't use underscores in Go names; method Cancel_image_download"
+    - "don't use underscores in Go names; method Activate_image_update"
+    - "don't use underscores in Go names; method Revert_image_update"
+  exclude-use-default: false
+
+# golangci.com configuration
+# https://github.com/golangci/golangci/wiki/Configuration
+service:
+  golangci-lint-version: 1.17.1 # use the fixed version to not introduce new linters unexpectedly
+  prepare:
+    - echo "here I can run custom commands, but no preparation needed for this repo"
diff --git a/Makefile b/Makefile
index e97238c..9ccda96 100644
--- a/Makefile
+++ b/Makefile
@@ -53,6 +53,7 @@
 	@echo "help              : Print this help"
 	@echo "docker-push       : Push the docker images to an external repository"
 	@echo "lint              : Run lint verification, depenancy, gofmt and reference check"
+	@echo "sca               : Runs various SCA through golangci-lint tool"
 	@echo "test              : Run unit tests, if any"
 	@echo
 
@@ -188,8 +189,20 @@
 	$(GOCOVER_COBERTURA) < ./tests/results/go-test-coverage.out > ./tests/results/go-test-coverage.xml ;\
 	exit $$RETURN
 
+GOLANGCI_LINT_TOOL:=$(shell which golangci-lint)
+sca:
+ifeq (,$(GOLANGCI_LINT_TOOL))
+	@echo "Please install golangci-lint tool to run sca"
+	exit 1
+endif
+	@mkdir -p ./sca-report
+	GO111MODULE=on golangci-lint run --out-format junit-xml ./... 2>&1 | tee ./sca-report/sca-report.xml ;\
+	RETURN=$$? ;\
+	exit $$RETURN
+
 clean:
 	rm -rf python/local_imports
+	rm -rf sca-report
 	find python -name '*.pyc' | xargs rm -f
 
 distclean: clean
diff --git a/adaptercore/device_handler.go b/adaptercore/device_handler.go
index 5fddcf7..de23653 100644
--- a/adaptercore/device_handler.go
+++ b/adaptercore/device_handler.go
@@ -13,6 +13,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
+//Package adaptercore provides the utility for olt devices, flows and statistics
 package adaptercore
 
 import (
@@ -44,7 +46,7 @@
 
 //DeviceHandler will interact with the OLT device.
 type DeviceHandler struct {
-	deviceId      string
+	deviceID      string
 	deviceType    string
 	adminState    string
 	device        *voltha.Device
@@ -60,27 +62,28 @@
 	resourceMgr   *rsrcMgr.OpenOltResourceMgr
 	discOnus      map[string]bool
 	onus          map[string]*OnuDevice
-	nniIntfId     int
+	nniIntfID     int
 }
 
+//OnuDevice represents ONU related info
 type OnuDevice struct {
-	deviceId      string
+	deviceID      string
 	deviceType    string
 	serialNumber  string
-	onuId         uint32
-	intfId        uint32
-	proxyDeviceId string
+	onuID         uint32
+	intfID        uint32
+	proxyDeviceID string
 }
 
 //NewOnuDevice creates a new Onu Device
-func NewOnuDevice(devId string, deviceTp string, serialNum string, onuId uint32, intfId uint32, proxyDevId string) *OnuDevice {
+func NewOnuDevice(devID, deviceTp, serialNum string, onuID, intfID uint32, proxyDevID string) *OnuDevice {
 	var device OnuDevice
-	device.deviceId = devId
+	device.deviceID = devID
 	device.deviceType = deviceTp
 	device.serialNumber = serialNum
-	device.onuId = onuId
-	device.intfId = intfId
-	device.proxyDeviceId = proxyDevId
+	device.onuID = onuID
+	device.intfID = intfID
+	device.proxyDeviceID = proxyDevID
 	return &device
 }
 
@@ -90,7 +93,7 @@
 	dh.coreProxy = cp
 	dh.AdapterProxy = ap
 	cloned := (proto.Clone(device)).(*voltha.Device)
-	dh.deviceId = cloned.Id
+	dh.deviceID = cloned.Id
 	dh.deviceType = cloned.Type
 	dh.adminState = "up"
 	dh.device = cloned
@@ -99,10 +102,10 @@
 	dh.discOnus = make(map[string]bool)
 	dh.lockDevice = sync.RWMutex{}
 	dh.onus = make(map[string]*OnuDevice)
-	// The nniIntfId is initialized to -1 (invalid) and set to right value
+	// The nniIntfID is initialized to -1 (invalid) and set to right value
 	// when the first IntfOperInd with status as "up" is received for
 	// any one of the available NNI port on the OLT device.
-	dh.nniIntfId = -1
+	dh.nniIntfID = -1
 
 	//TODO initialize the support classes.
 	return &dh
@@ -140,6 +143,7 @@
 	return result
 }
 
+//GetportLabel returns the label for the NNI and the PON port based on port number and port type
 func GetportLabel(portNum uint32, portType voltha.Port_PortType) string {
 
 	if portType == voltha.Port_ETHERNET_NNI {
@@ -153,14 +157,14 @@
 	return ""
 }
 
-func (dh *DeviceHandler) addPort(intfId uint32, portType voltha.Port_PortType, state string) {
+func (dh *DeviceHandler) addPort(intfID uint32, portType voltha.Port_PortType, state string) {
 	var operStatus common.OperStatus_OperStatus
 	if state == "up" {
 		operStatus = voltha.OperStatus_ACTIVE
 	} else {
 		operStatus = voltha.OperStatus_DISCOVERED
 	}
-	portNum := IntfIdToPortNo(intfId, portType)
+	portNum := IntfIDToPortNo(intfID, portType)
 	label := GetportLabel(portNum, portType)
 	if len(label) == 0 {
 		log.Errorw("Invalid-port-label", log.Fields{"portNum": portNum, "portType": portType})
@@ -175,14 +179,14 @@
 	}
 	log.Debugw("Sending port update to core", log.Fields{"port": port})
 	// Synchronous call to update device - this method is run in its own go routine
-	if err := dh.coreProxy.PortCreated(nil, dh.device.Id, port); err != nil {
-		log.Errorw("error-creating-port", log.Fields{"deviceId": dh.device.Id, "portType": portType, "error": err})
-		return
+	if err := dh.coreProxy.PortCreated(context.TODO(), dh.device.Id, port); err != nil {
+		log.Errorw("error-creating-nni-port", log.Fields{"deviceID": dh.device.Id, "portType": portType, "error": err})
 	}
+
 	// Once we have successfully added the NNI port to the core, if the
-	// locally cached nniIntfId is set to invalid (-1), set it to the right value.
-	if portType == voltha.Port_ETHERNET_NNI && dh.nniIntfId == -1 {
-		dh.nniIntfId = int(intfId)
+	// locally cached nniIntfID is set to invalid (-1), set it to the right value.
+	if portType == voltha.Port_ETHERNET_NNI && dh.nniIntfID == -1 {
+		dh.nniIntfID = int(intfID)
 	}
 }
 
@@ -198,11 +202,11 @@
 		return
 	}
 	/* get device state */
-	device, err := dh.coreProxy.GetDevice(nil, dh.device.Id, dh.device.Id)
+	device, err := dh.coreProxy.GetDevice(context.TODO(), dh.device.Id, dh.device.Id)
 	if err != nil || device == nil {
 		/*TODO: needs to handle error scenarios */
 		log.Errorw("Failed to fetch device info", log.Fields{"err": err})
-
+		return
 	}
 	// When the device is in DISABLED and Adapter container restarts, we need to
 	// rebuild the locally maintained admin state.
@@ -236,66 +240,74 @@
 				continue
 			}
 		}
-		switch indication.Data.(type) {
-		case *oop.Indication_OltInd:
-			oltInd := indication.GetOltInd()
-			if oltInd.OperState == "up" {
-				dh.transitionMap.Handle(DeviceUpInd)
-			} else if oltInd.OperState == "down" {
-				dh.transitionMap.Handle(DeviceDownInd)
-			}
-		case *oop.Indication_IntfInd:
 
-			intfInd := indication.GetIntfInd()
-			go dh.addPort(intfInd.GetIntfId(), voltha.Port_PON_OLT, intfInd.GetOperState())
-			log.Infow("Received interface indication ", log.Fields{"InterfaceInd": intfInd})
-		case *oop.Indication_IntfOperInd:
-			intfOperInd := indication.GetIntfOperInd()
-			if intfOperInd.GetType() == "nni" {
-				go dh.addPort(intfOperInd.GetIntfId(), voltha.Port_ETHERNET_NNI, intfOperInd.GetOperState())
-			} else if intfOperInd.GetType() == "pon" {
-				// TODO: Check what needs to be handled here for When PON PORT down, ONU will be down
-				// Handle pon port update
-			}
-			log.Infow("Received interface oper indication ", log.Fields{"InterfaceOperInd": intfOperInd})
-		case *oop.Indication_OnuDiscInd:
-			onuDiscInd := indication.GetOnuDiscInd()
-			log.Infow("Received Onu discovery indication ", log.Fields{"OnuDiscInd": onuDiscInd})
-			//onuId,err := dh.resourceMgr.GetONUID(onuDiscInd.GetIntfId())
-			//onuId,err := dh.resourceMgr.GetONUID(onuDiscInd.GetIntfId())
-			// TODO Get onu ID from the resource manager
-			var onuId uint32 = 1
-			/*if err != nil{
-			    log.Errorw("onu-id-unavailable",log.Fields{"intfId":onuDiscInd.GetIntfId()})
-			    return
-			}*/
+		dh.handleIndication(indication)
 
-			sn := dh.stringifySerialNumber(onuDiscInd.SerialNumber)
-			go dh.onuDiscIndication(onuDiscInd, onuId, sn)
-		case *oop.Indication_OnuInd:
-			onuInd := indication.GetOnuInd()
-			log.Infow("Received Onu indication ", log.Fields{"OnuInd": onuInd})
-			go dh.onuIndication(onuInd)
-		case *oop.Indication_OmciInd:
-			omciInd := indication.GetOmciInd()
-			log.Infow("Received Omci indication ", log.Fields{"OmciInd": omciInd})
-			if err := dh.omciIndication(omciInd); err != nil {
-				log.Errorw("send-omci-indication-errr", log.Fields{"error": err, "omciInd": omciInd})
-			}
-		case *oop.Indication_PktInd:
-			pktInd := indication.GetPktInd()
-			log.Infow("Received pakcet indication ", log.Fields{"PktInd": pktInd})
-			go dh.handlePacketIndication(pktInd)
-		case *oop.Indication_PortStats:
-			portStats := indication.GetPortStats()
-			log.Infow("Received port stats indication", log.Fields{"PortStats": portStats})
-		case *oop.Indication_FlowStats:
-			flowStats := indication.GetFlowStats()
-			log.Infow("Received flow stats", log.Fields{"FlowStats": flowStats})
-		case *oop.Indication_AlarmInd:
-			alarmInd := indication.GetAlarmInd()
-			log.Infow("Received alarm indication ", log.Fields{"AlarmInd": alarmInd})
+	}
+}
+
+func (dh *DeviceHandler) handleOltIndication(oltIndication *oop.OltIndication) {
+	if oltIndication.OperState == "up" {
+		dh.transitionMap.Handle(DeviceUpInd)
+	} else if oltIndication.OperState == "down" {
+		dh.transitionMap.Handle(DeviceDownInd)
+	}
+}
+
+func (dh *DeviceHandler) handleIndication(indication *oop.Indication) {
+	switch indication.Data.(type) {
+	case *oop.Indication_OltInd:
+		dh.handleOltIndication(indication.GetOltInd())
+	case *oop.Indication_IntfInd:
+		intfInd := indication.GetIntfInd()
+		go dh.addPort(intfInd.GetIntfId(), voltha.Port_PON_OLT, intfInd.GetOperState())
+		log.Infow("Received interface indication ", log.Fields{"InterfaceInd": intfInd})
+	case *oop.Indication_IntfOperInd:
+		intfOperInd := indication.GetIntfOperInd()
+		if intfOperInd.GetType() == "nni" {
+			go dh.addPort(intfOperInd.GetIntfId(), voltha.Port_ETHERNET_NNI, intfOperInd.GetOperState())
+		} else if intfOperInd.GetType() == "pon" {
+			// TODO: Check what needs to be handled here for When PON PORT down, ONU will be down
+			// Handle pon port update
 		}
+		log.Infow("Received interface oper indication ", log.Fields{"InterfaceOperInd": intfOperInd})
+	case *oop.Indication_OnuDiscInd:
+		onuDiscInd := indication.GetOnuDiscInd()
+		log.Infow("Received Onu discovery indication ", log.Fields{"OnuDiscInd": onuDiscInd})
+		//onuID,err := dh.resourceMgr.GetONUID(onuDiscInd.GetIntfId())
+		//onuID,err := dh.resourceMgr.GetONUID(onuDiscInd.GetIntfId())
+		// TODO Get onu ID from the resource manager
+		var onuID uint32 = 1
+		/*if err != nil{
+		    log.Errorw("onu-id-unavailable",log.Fields{"intfID":onuDiscInd.GetIntfId()})
+		    return
+		}*/
+
+		sn := dh.stringifySerialNumber(onuDiscInd.SerialNumber)
+		go dh.onuDiscIndication(onuDiscInd, onuID, sn)
+	case *oop.Indication_OnuInd:
+		onuInd := indication.GetOnuInd()
+		log.Infow("Received Onu indication ", log.Fields{"OnuInd": onuInd})
+		go dh.onuIndication(onuInd)
+	case *oop.Indication_OmciInd:
+		omciInd := indication.GetOmciInd()
+		log.Infow("Received Omci indication ", log.Fields{"OmciInd": omciInd})
+		if err := dh.omciIndication(omciInd); err != nil {
+			log.Errorw("send-omci-indication-errr", log.Fields{"error": err, "omciInd": omciInd})
+		}
+	case *oop.Indication_PktInd:
+		pktInd := indication.GetPktInd()
+		log.Infow("Received pakcet indication ", log.Fields{"PktInd": pktInd})
+		go dh.handlePacketIndication(pktInd)
+	case *oop.Indication_PortStats:
+		portStats := indication.GetPortStats()
+		log.Infow("Received port stats indication", log.Fields{"PortStats": portStats})
+	case *oop.Indication_FlowStats:
+		flowStats := indication.GetFlowStats()
+		log.Infow("Received flow stats", log.Fields{"FlowStats": flowStats})
+	case *oop.Indication_AlarmInd:
+		alarmInd := indication.GetAlarmInd()
+		log.Infow("Received alarm indication ", log.Fields{"AlarmInd": alarmInd})
 	}
 }
 
@@ -304,7 +316,7 @@
 	// Synchronous call to update device state - this method is run in its own go routine
 	if err := dh.coreProxy.DeviceStateUpdate(context.Background(), dh.device.Id, voltha.ConnectStatus_REACHABLE,
 		voltha.OperStatus_ACTIVE); err != nil {
-		log.Errorw("Failed to update device with OLT UP indication", log.Fields{"deviceId": dh.device.Id, "error": err})
+		log.Errorw("Failed to update device with OLT UP indication", log.Fields{"deviceID": dh.device.Id, "error": err})
 		return err
 	}
 	return nil
@@ -314,17 +326,18 @@
 func (dh *DeviceHandler) doStateDown() error {
 	log.Debug("do-state-down-start")
 
-	device, err := dh.coreProxy.GetDevice(nil, dh.device.Id, dh.device.Id)
+	device, err := dh.coreProxy.GetDevice(context.TODO(), dh.device.Id, dh.device.Id)
 	if err != nil || device == nil {
 		/*TODO: needs to handle error scenarios */
 		log.Errorw("Failed to fetch device device", log.Fields{"err": err})
+		return errors.New("failed to fetch device device")
 	}
 
 	cloned := proto.Clone(device).(*voltha.Device)
 	// Update the all ports state on that device to disable
-	if err := dh.coreProxy.PortsStateUpdate(nil, cloned.Id, voltha.OperStatus_UNKNOWN); err != nil {
-		log.Errorw("updating-ports-failed", log.Fields{"deviceId": device.Id, "error": err})
-		return err
+	if er := dh.coreProxy.PortsStateUpdate(context.TODO(), cloned.Id, voltha.OperStatus_UNKNOWN); er != nil {
+		log.Errorw("updating-ports-failed", log.Fields{"deviceID": device.Id, "error": er})
+		return er
 	}
 
 	//Update the device oper state and connection status
@@ -332,15 +345,15 @@
 	cloned.ConnectStatus = common.ConnectStatus_UNREACHABLE
 	dh.device = cloned
 
-	if err := dh.coreProxy.DeviceStateUpdate(nil, cloned.Id, cloned.ConnectStatus, cloned.OperStatus); err != nil {
-		log.Errorw("error-updating-device-state", log.Fields{"deviceId": device.Id, "error": err})
-		return err
+	if er := dh.coreProxy.DeviceStateUpdate(context.TODO(), cloned.Id, cloned.ConnectStatus, cloned.OperStatus); er != nil {
+		log.Errorw("error-updating-device-state", log.Fields{"deviceID": device.Id, "error": er})
+		return er
 	}
 
 	//get the child device for the parent device
-	onuDevices, err := dh.coreProxy.GetChildDevices(nil, dh.device.Id)
+	onuDevices, err := dh.coreProxy.GetChildDevices(context.TODO(), dh.device.Id)
 	if err != nil {
-		log.Errorw("failed to get child devices information", log.Fields{"deviceId": dh.device.Id, "error": err})
+		log.Errorw("failed to get child devices information", log.Fields{"deviceID": dh.device.Id, "error": err})
 		return err
 	}
 	for _, onuDevice := range onuDevices.Items {
@@ -348,10 +361,15 @@
 		// Update onu state as down in onu adapter
 		onuInd := oop.OnuIndication{}
 		onuInd.OperState = "down"
-		dh.AdapterProxy.SendInterAdapterMessage(nil, &onuInd, ic.InterAdapterMessageType_ONU_IND_REQUEST, "openolt", onuDevice.Type, onuDevice.Id, onuDevice.ProxyAddress.DeviceId, "")
-
+		er := dh.AdapterProxy.SendInterAdapterMessage(context.TODO(), &onuInd, ic.InterAdapterMessageType_ONU_IND_REQUEST,
+			"openolt", onuDevice.Type, onuDevice.Id, onuDevice.ProxyAddress.DeviceId, "")
+		if er != nil {
+			log.Errorw("Failed to send inter-adapter-message", log.Fields{"OnuInd": onuInd,
+				"From Adapter": "openolt", "DevieType": onuDevice.Type, "DeviceID": onuDevice.Id})
+			return er
+		}
 	}
-	log.Debugw("do-state-down-end", log.Fields{"deviceId": device.Id})
+	log.Debugw("do-state-down-end", log.Fields{"deviceID": device.Id})
 	return nil
 }
 
@@ -360,7 +378,7 @@
 	var err error
 	dh.clientCon, err = grpc.Dial(dh.device.GetHostAndPort(), grpc.WithInsecure(), grpc.WithBlock())
 	if err != nil {
-		log.Errorw("Failed to dial device", log.Fields{"DeviceId": dh.deviceId, "HostAndPort": dh.device.GetHostAndPort(), "err": err})
+		log.Errorw("Failed to dial device", log.Fields{"DeviceId": dh.deviceID, "HostAndPort": dh.device.GetHostAndPort(), "err": err})
 		return err
 	}
 	return nil
@@ -380,7 +398,7 @@
 	// Case where OLT is disabled and then rebooted.
 	if dh.adminState == "down" {
 		log.Debugln("do-state-connected--device-admin-state-down")
-		device, err := dh.coreProxy.GetDevice(nil, dh.device.Id, dh.device.Id)
+		device, err := dh.coreProxy.GetDevice(context.TODO(), dh.device.Id, dh.device.Id)
 		if err != nil || device == nil {
 			/*TODO: needs to handle error scenarios */
 			log.Errorw("Failed to fetch device device", log.Fields{"err": err})
@@ -390,8 +408,8 @@
 		cloned.ConnectStatus = voltha.ConnectStatus_REACHABLE
 		cloned.OperStatus = voltha.OperStatus_UNKNOWN
 		dh.device = cloned
-		if err := dh.coreProxy.DeviceStateUpdate(nil, cloned.Id, cloned.ConnectStatus, cloned.OperStatus); err != nil {
-			log.Errorw("error-updating-device-state", log.Fields{"deviceId": dh.device.Id, "error": err})
+		if er := dh.coreProxy.DeviceStateUpdate(context.TODO(), cloned.Id, cloned.ConnectStatus, cloned.OperStatus); er != nil {
+			log.Errorw("error-updating-device-state", log.Fields{"deviceID": dh.device.Id, "error": er})
 		}
 
 		// Since the device was disabled before the OLT was rebooted, enfore the OLT to be Disabled after re-connection.
@@ -412,7 +430,7 @@
 	}
 	if deviceInfo == nil {
 		log.Errorw("Device info is nil", log.Fields{})
-		return errors.New("Failed to get device info from OLT")
+		return errors.New("failed to get device info from OLT")
 	}
 	log.Debugw("Fetched device info", log.Fields{"deviceInfo": deviceInfo})
 	dh.device.Root = true
@@ -425,33 +443,34 @@
 	dh.device.MacAddress = "0a:0b:0c:0d:0e:0f"
 
 	// Synchronous call to update device - this method is run in its own go routine
-	if err := dh.coreProxy.DeviceUpdate(nil, dh.device); err != nil {
-		log.Errorw("error-updating-device", log.Fields{"deviceId": dh.device.Id, "error": err})
+	if er := dh.coreProxy.DeviceUpdate(context.TODO(), dh.device); er != nil {
+		log.Errorw("error-updating-device", log.Fields{"deviceID": dh.device.Id, "error": er})
 	}
 
-	device, err := dh.coreProxy.GetDevice(nil, dh.device.Id, dh.device.Id)
+	device, err := dh.coreProxy.GetDevice(context.TODO(), dh.device.Id, dh.device.Id)
 	if err != nil || device == nil {
 		/*TODO: needs to handle error scenarios */
 		log.Errorw("Failed to fetch device device", log.Fields{"err": err})
+		return err
 	}
 	cloned := proto.Clone(device).(*voltha.Device)
 	// Update the all ports (if available) on that device to ACTIVE.
 	// The ports do not normally exist, unless the device is coming back from a reboot
-	if err := dh.coreProxy.PortsStateUpdate(nil, cloned.Id, voltha.OperStatus_ACTIVE); err != nil {
-		log.Errorw("updating-ports-failed", log.Fields{"deviceId": device.Id, "error": err})
+	if err := dh.coreProxy.PortsStateUpdate(context.TODO(), cloned.Id, voltha.OperStatus_ACTIVE); err != nil {
+		log.Errorw("updating-ports-failed", log.Fields{"deviceID": device.Id, "error": err})
 		return err
 	}
 
 	KVStoreHostPort := fmt.Sprintf("%s:%d", dh.openOLT.KVStoreHost, dh.openOLT.KVStorePort)
 	// Instantiate resource manager
-	if dh.resourceMgr = rsrcMgr.NewResourceMgr(dh.deviceId, KVStoreHostPort, dh.openOLT.KVStoreType, dh.deviceType, deviceInfo); dh.resourceMgr == nil {
+	if dh.resourceMgr = rsrcMgr.NewResourceMgr(dh.deviceID, KVStoreHostPort, dh.openOLT.KVStoreType, dh.deviceType, deviceInfo); dh.resourceMgr == nil {
 		log.Error("Error while instantiating resource manager")
-		return errors.New("Instantiating resource manager failed")
+		return errors.New("instantiating resource manager failed")
 	}
 	// Instantiate flow manager
 	if dh.flowMgr = NewFlowManager(dh, dh.resourceMgr); dh.flowMgr == nil {
 		log.Error("Error while instantiating flow manager")
-		return errors.New("Instantiating flow manager failed")
+		return errors.New("instantiating flow manager failed")
 	}
 	/* TODO: Instantiate Alarm , stats , BW managers */
 
@@ -460,14 +479,14 @@
 	return nil
 }
 
-// AdoptDevice adopts the OLT device
+//AdoptDevice adopts the OLT device
 func (dh *DeviceHandler) AdoptDevice(device *voltha.Device) {
 	dh.transitionMap = NewTransitionMap(dh)
-	log.Infow("AdoptDevice", log.Fields{"deviceId": device.Id, "Address": device.GetHostAndPort()})
+	log.Infow("Adopt_device", log.Fields{"deviceID": device.Id, "Address": device.GetHostAndPort()})
 	dh.transitionMap.Handle(DeviceInit)
 }
 
-// GetOfpDeviceInfo Get the Ofp device information
+//GetOfpDeviceInfo Gets the Ofp information of the given device
 func (dh *DeviceHandler) GetOfpDeviceInfo(device *voltha.Device) (*ic.SwitchCapability, error) {
 	return &ic.SwitchCapability{
 		Desc: &of.OfpDesc{
@@ -487,18 +506,18 @@
 	}, nil
 }
 
-// GetOfpPortInfo Get Ofp port information
+//GetOfpPortInfo Get Ofp port information
 func (dh *DeviceHandler) GetOfpPortInfo(device *voltha.Device, portNo int64) (*ic.PortCapability, error) {
-	cap := uint32(of.OfpPortFeatures_OFPPF_1GB_FD | of.OfpPortFeatures_OFPPF_FIBER)
+	capacity := uint32(of.OfpPortFeatures_OFPPF_1GB_FD | of.OfpPortFeatures_OFPPF_FIBER)
 	return &ic.PortCapability{
 		Port: &voltha.LogicalPort{
 			OfpPort: &of.OfpPort{
 				HwAddr:     macAddressToUint32Array(dh.device.MacAddress),
 				Config:     0,
 				State:      uint32(of.OfpPortState_OFPPS_LIVE),
-				Curr:       cap,
-				Advertised: cap,
-				Peer:       cap,
+				Curr:       capacity,
+				Advertised: capacity,
+				Peer:       capacity,
 				CurrSpeed:  uint32(of.OfpPortFeatures_OFPPF_1GB_FD),
 				MaxSpeed:   uint32(of.OfpPortFeatures_OFPPF_1GB_FD),
 			},
@@ -509,58 +528,60 @@
 }
 
 func (dh *DeviceHandler) omciIndication(omciInd *oop.OmciIndication) error {
-	log.Debugw("omci indication", log.Fields{"intfId": omciInd.IntfId, "onuId": omciInd.OnuId})
+	log.Debugw("omci indication", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId})
 	var deviceType string
-	var deviceId string
-	var proxyDeviceId string
+	var deviceID string
+	var proxyDeviceID string
 
 	onuKey := dh.formOnuKey(omciInd.IntfId, omciInd.OnuId)
 	if onuInCache, ok := dh.onus[onuKey]; !ok {
-		log.Debugw("omci indication for a device not in cache.", log.Fields{"intfId": omciInd.IntfId, "onuId": omciInd.OnuId})
-		ponPort := IntfIdToPortNo(omciInd.GetIntfId(), voltha.Port_PON_OLT)
+		log.Debugw("omci indication for a device not in cache.", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId})
+		ponPort := IntfIDToPortNo(omciInd.GetIntfId(), voltha.Port_PON_OLT)
 		kwargs := make(map[string]interface{})
 		kwargs["onu_id"] = omciInd.OnuId
 		kwargs["parent_port_no"] = ponPort
 
-		if onuDevice, err := dh.coreProxy.GetChildDevice(nil, dh.device.Id, kwargs); err != nil {
-			log.Errorw("onu not found", log.Fields{"intfId": omciInd.IntfId, "onuId": omciInd.OnuId})
+		onuDevice, err := dh.coreProxy.GetChildDevice(context.TODO(), dh.device.Id, kwargs)
+		if err != nil {
+			log.Errorw("onu not found", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId})
 			return err
-		} else {
-			deviceType = onuDevice.Type
-			deviceId = onuDevice.Id
-			proxyDeviceId = onuDevice.ProxyAddress.DeviceId
-			//if not exist in cache, then add to cache.
-			dh.onus[onuKey] = NewOnuDevice(deviceId, deviceType, onuDevice.SerialNumber, omciInd.OnuId, omciInd.IntfId, proxyDeviceId)
 		}
+		deviceType = onuDevice.Type
+		deviceID = onuDevice.Id
+		proxyDeviceID = onuDevice.ProxyAddress.DeviceId
+		//if not exist in cache, then add to cache.
+		dh.onus[onuKey] = NewOnuDevice(deviceID, deviceType, onuDevice.SerialNumber, omciInd.OnuId, omciInd.IntfId, proxyDeviceID)
 	} else {
 		//found in cache
-		log.Debugw("omci indication for a device in cache.", log.Fields{"intfId": omciInd.IntfId, "onuId": omciInd.OnuId})
+		log.Debugw("omci indication for a device in cache.", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId})
 		deviceType = onuInCache.deviceType
-		deviceId = onuInCache.deviceId
-		proxyDeviceId = onuInCache.proxyDeviceId
+		deviceID = onuInCache.deviceID
+		proxyDeviceID = onuInCache.proxyDeviceID
 	}
 
 	omciMsg := &ic.InterAdapterOmciMessage{Message: omciInd.Pkt}
 	if sendErr := dh.AdapterProxy.SendInterAdapterMessage(context.Background(), omciMsg,
 		ic.InterAdapterMessageType_OMCI_REQUEST, dh.deviceType, deviceType,
-		deviceId, proxyDeviceId, ""); sendErr != nil {
-		log.Errorw("send omci request error", log.Fields{"fromAdapter": dh.deviceType, "toAdapter": deviceType, "onuId": deviceId, "proxyDeviceId": proxyDeviceId})
+		deviceID, proxyDeviceID, ""); sendErr != nil {
+		log.Errorw("send omci request error", log.Fields{"fromAdapter": dh.deviceType, "toAdapter": deviceType, "onuID": deviceID, "proxyDeviceID": proxyDeviceID})
 		return sendErr
 	}
 	return nil
 }
 
-// Process_inter_adapter_message process inter adater message
-func (dh *DeviceHandler) Process_inter_adapter_message(msg *ic.InterAdapterMessage) error {
-	log.Debugw("Process_inter_adapter_message", log.Fields{"msgId": msg.Header.Id})
+//ProcessInterAdapterMessage sends the proxied messages to the target device
+// If the proxy address is not found in the unmarshalled message, it first fetches the onu device for which the message
+// is meant, and then send the unmarshalled omci message to this onu
+func (dh *DeviceHandler) ProcessInterAdapterMessage(msg *ic.InterAdapterMessage) error {
+	log.Debugw("Process_inter_adapter_message", log.Fields{"msgID": msg.Header.Id})
 	if msg.Header.Type == ic.InterAdapterMessageType_OMCI_REQUEST {
-		msgId := msg.Header.Id
+		msgID := msg.Header.Id
 		fromTopic := msg.Header.FromTopic
 		toTopic := msg.Header.ToTopic
-		toDeviceId := msg.Header.ToDeviceId
-		proxyDeviceId := msg.Header.ProxyDeviceId
+		toDeviceID := msg.Header.ToDeviceId
+		proxyDeviceID := msg.Header.ProxyDeviceId
 
-		log.Debugw("omci request message header", log.Fields{"msgId": msgId, "fromTopic": fromTopic, "toTopic": toTopic, "toDeviceId": toDeviceId, "proxyDeviceId": proxyDeviceId})
+		log.Debugw("omci request message header", log.Fields{"msgID": msgID, "fromTopic": fromTopic, "toTopic": toTopic, "toDeviceID": toDeviceID, "proxyDeviceID": proxyDeviceID})
 
 		msgBody := msg.GetBody()
 
@@ -571,15 +592,16 @@
 		}
 
 		if omciMsg.GetProxyAddress() == nil {
-			if onuDevice, err := dh.coreProxy.GetDevice(nil, dh.device.Id, toDeviceId); err != nil {
-				log.Errorw("onu not found", log.Fields{"onuDeviceId": toDeviceId, "error": err})
+			onuDevice, err := dh.coreProxy.GetDevice(context.TODO(), dh.device.Id, toDeviceID)
+			if err != nil {
+				log.Errorw("onu not found", log.Fields{"onuDeviceId": toDeviceID, "error": err})
 				return err
-			} else {
-				log.Debugw("device retrieved from core", log.Fields{"msgId": msgId, "fromTopic": fromTopic, "toTopic": toTopic, "toDeviceId": toDeviceId, "proxyDeviceId": proxyDeviceId})
-				dh.sendProxiedMessage(onuDevice, omciMsg)
 			}
+			log.Debugw("device retrieved from core", log.Fields{"msgID": msgID, "fromTopic": fromTopic, "toTopic": toTopic, "toDeviceID": toDeviceID, "proxyDeviceID": proxyDeviceID})
+			dh.sendProxiedMessage(onuDevice, omciMsg)
+
 		} else {
-			log.Debugw("Proxy Address found in omci message", log.Fields{"msgId": msgId, "fromTopic": fromTopic, "toTopic": toTopic, "toDeviceId": toDeviceId, "proxyDeviceId": proxyDeviceId})
+			log.Debugw("Proxy Address found in omci message", log.Fields{"msgID": msgID, "fromTopic": fromTopic, "toTopic": toTopic, "toDeviceID": toDeviceID, "proxyDeviceID": proxyDeviceID})
 			dh.sendProxiedMessage(nil, omciMsg)
 		}
 
@@ -590,35 +612,39 @@
 }
 
 func (dh *DeviceHandler) sendProxiedMessage(onuDevice *voltha.Device, omciMsg *ic.InterAdapterOmciMessage) {
-	var intfId uint32
-	var onuId uint32
-	var status common.ConnectStatus_ConnectStatus
+	var intfID uint32
+	var onuID uint32
+	var connectStatus common.ConnectStatus_ConnectStatus
 	if onuDevice != nil {
-		intfId = onuDevice.ProxyAddress.GetChannelId()
-		onuId = onuDevice.ProxyAddress.GetOnuId()
-		status = onuDevice.ConnectStatus
+		intfID = onuDevice.ProxyAddress.GetChannelId()
+		onuID = onuDevice.ProxyAddress.GetOnuId()
+		connectStatus = onuDevice.ConnectStatus
 	} else {
-		intfId = omciMsg.GetProxyAddress().GetChannelId()
-		onuId = omciMsg.GetProxyAddress().GetOnuId()
-		status = omciMsg.GetConnectStatus()
+		intfID = omciMsg.GetProxyAddress().GetChannelId()
+		onuID = omciMsg.GetProxyAddress().GetOnuId()
+		connectStatus = omciMsg.GetConnectStatus()
 	}
-	if status != voltha.ConnectStatus_REACHABLE {
-		log.Debugw("ONU is not reachable, cannot send OMCI", log.Fields{"intfId": intfId, "onuId": onuId})
+	if connectStatus != voltha.ConnectStatus_REACHABLE {
+		log.Debugw("ONU is not reachable, cannot send OMCI", log.Fields{"intfID": intfID, "onuID": onuID})
 		return
 	}
 
-	omciMessage := &oop.OmciMsg{IntfId: intfId, OnuId: onuId, Pkt: omciMsg.Message}
+	omciMessage := &oop.OmciMsg{IntfId: intfID, OnuId: onuID, Pkt: omciMsg.Message}
 
-	dh.Client.OmciMsgOut(context.Background(), omciMessage)
-	log.Debugw("omci-message-sent", log.Fields{"intfId": intfId, "onuId": onuId, "omciMsg": string(omciMsg.GetMessage())})
+	_, err := dh.Client.OmciMsgOut(context.Background(), omciMessage)
+	if err != nil {
+		log.Errorw("unable to send omci-msg-out", log.Fields{"IntfID": intfID, "OnuID": onuID, "Msg": omciMessage})
+		return
+	}
+	log.Debugw("omci-message-sent", log.Fields{"intfID": intfID, "onuID": onuID, "omciMsg": string(omciMsg.GetMessage())})
 }
 
-func (dh *DeviceHandler) activateONU(intfId uint32, onuId int64, serialNum *oop.SerialNumber, serialNumber string) {
-	log.Debugw("activate-onu", log.Fields{"intfId": intfId, "onuId": onuId, "serialNum": serialNum, "serialNumber": serialNumber})
-	dh.flowMgr.UpdateOnuInfo(intfId, uint32(onuId), serialNumber)
+func (dh *DeviceHandler) activateONU(intfID uint32, onuID int64, serialNum *oop.SerialNumber, serialNumber string) {
+	log.Debugw("activate-onu", log.Fields{"intfID": intfID, "onuID": onuID, "serialNum": serialNum, "serialNumber": serialNumber})
+	dh.flowMgr.UpdateOnuInfo(intfID, uint32(onuID), serialNumber)
 	// TODO: need resource manager
 	var pir uint32 = 1000000
-	Onu := oop.Onu{IntfId: intfId, OnuId: uint32(onuId), SerialNumber: serialNum, Pir: pir}
+	Onu := oop.Onu{IntfId: intfID, OnuId: uint32(onuID), SerialNumber: serialNum, Pir: pir}
 	if _, err := dh.Client.ActivateOnu(context.Background(), &Onu); err != nil {
 		st, _ := status.FromError(err)
 		if st.Code() == codes.AlreadyExists {
@@ -631,9 +657,9 @@
 	}
 }
 
-func (dh *DeviceHandler) onuDiscIndication(onuDiscInd *oop.OnuDiscIndication, onuId uint32, sn string) error {
-	channelId := onuDiscInd.GetIntfId()
-	parentPortNo := IntfIdToPortNo(onuDiscInd.GetIntfId(), voltha.Port_PON_OLT)
+func (dh *DeviceHandler) onuDiscIndication(onuDiscInd *oop.OnuDiscIndication, onuID uint32, sn string) error {
+	channelID := onuDiscInd.GetIntfId()
+	parentPortNo := IntfIDToPortNo(onuDiscInd.GetIntfId(), voltha.Port_PON_OLT)
 	if _, ok := dh.discOnus[sn]; ok {
 		log.Debugw("onu-sn-is-already-being-processed", log.Fields{"sn": sn})
 		return nil
@@ -651,41 +677,49 @@
 	if sn != "" {
 		kwargs["serial_number"] = sn
 	}
-	kwargs["onu_id"] = onuId
+	kwargs["onu_id"] = onuID
 	kwargs["parent_port_no"] = parentPortNo
-	onuDevice, err := dh.coreProxy.GetChildDevice(nil, dh.device.Id, kwargs)
-	if onuDevice == nil {
-		if err := dh.coreProxy.ChildDeviceDetected(nil, dh.device.Id, int(parentPortNo), "brcm_openomci_onu", int(channelId), string(onuDiscInd.SerialNumber.GetVendorId()), sn, int64(onuId)); err != nil {
-			log.Errorw("Create onu error", log.Fields{"parent_id": dh.device.Id, "ponPort": onuDiscInd.GetIntfId(), "onuId": onuId, "sn": sn, "error": err})
-			return err
+	onuDevice, err := dh.coreProxy.GetChildDevice(context.TODO(), dh.device.Id, kwargs)
+	if onuDevice == nil || err != nil {
+		if er := dh.coreProxy.ChildDeviceDetected(context.TODO(), dh.device.Id, int(parentPortNo),
+			"brcm_openomci_onu", int(channelID),
+			string(onuDiscInd.SerialNumber.GetVendorId()), sn, int64(onuID)); er != nil {
+			log.Errorw("Create onu error",
+				log.Fields{"parent_id": dh.device.Id, "ponPort": onuDiscInd.GetIntfId(),
+					"onuID": onuID, "sn": sn, "error": er})
+			return er
 		}
 	}
-	onuDevice, err = dh.coreProxy.GetChildDevice(nil, dh.device.Id, kwargs)
+	onuDevice, err = dh.coreProxy.GetChildDevice(context.TODO(), dh.device.Id, kwargs)
 	if err != nil {
 		log.Errorw("failed to get ONU device information", log.Fields{"err": err})
 		return err
 	}
-	dh.coreProxy.DeviceStateUpdate(nil, onuDevice.Id, common.ConnectStatus_REACHABLE, common.OperStatus_DISCOVERED)
-	log.Debugw("onu-discovered-reachable", log.Fields{"deviceId": onuDevice.Id})
+	er := dh.coreProxy.DeviceStateUpdate(context.TODO(), onuDevice.Id, common.ConnectStatus_REACHABLE, common.OperStatus_DISCOVERED)
+	if er != nil {
+		log.Errorw("Unable to update device state", log.Fields{"DeviceID": onuDevice.Id})
+		return er
+	}
+	log.Debugw("onu-discovered-reachable", log.Fields{"deviceID": onuDevice.Id})
 
 	for i := 0; i < 10; i++ {
-		if onuDevice, _ := dh.coreProxy.GetChildDevice(nil, dh.device.Id, kwargs); onuDevice != nil {
-			dh.activateONU(onuDiscInd.IntfId, int64(onuId), onuDiscInd.SerialNumber, sn)
+		onuDevice, _ := dh.coreProxy.GetChildDevice(context.TODO(), dh.device.Id, kwargs)
+		if onuDevice != nil {
+			dh.activateONU(onuDiscInd.IntfId, int64(onuID), onuDiscInd.SerialNumber, sn)
 			return nil
-		} else {
-			time.Sleep(1 * time.Second)
-			log.Debugln("Sleep 1 seconds to active onu, retry times ", i+1)
 		}
+		time.Sleep(1 * time.Second)
+		log.Debugln("Sleep 1 seconds to active onu, retry times ", i+1)
 	}
-	log.Errorw("Cannot query onu, dont activate it.", log.Fields{"parent_id": dh.device.Id, "ponPort": onuDiscInd.GetIntfId(), "onuId": onuId, "sn": sn})
-	return errors.New("Failed to activate onu")
+	log.Errorw("Cannot query onu, dont activate it.", log.Fields{"parent_id": dh.device.Id, "ponPort": onuDiscInd.GetIntfId(), "onuID": onuID, "sn": sn})
+	return errors.New("failed to activate onu")
 }
 
 func (dh *DeviceHandler) onuIndication(onuInd *oop.OnuIndication) {
 	serialNumber := dh.stringifySerialNumber(onuInd.SerialNumber)
 
 	kwargs := make(map[string]interface{})
-	ponPort := IntfIdToPortNo(onuInd.GetIntfId(), voltha.Port_PON_OLT)
+	ponPort := IntfIDToPortNo(onuInd.GetIntfId(), voltha.Port_PON_OLT)
 
 	if serialNumber != "" {
 		kwargs["serial_number"] = serialNumber
@@ -693,9 +727,9 @@
 		kwargs["onu_id"] = onuInd.OnuId
 		kwargs["parent_port_no"] = ponPort
 	}
-	if onuDevice, _ := dh.coreProxy.GetChildDevice(nil, dh.device.Id, kwargs); onuDevice != nil {
+	if onuDevice, _ := dh.coreProxy.GetChildDevice(context.TODO(), dh.device.Id, kwargs); onuDevice != nil {
 		if onuDevice.ParentPortNo != ponPort {
-			//log.Warnw("ONU-is-on-a-different-intf-id-now", log.Fields{"previousIntfId": intfIdFromPortNo(onuDevice.ParentPortNo), "currentIntfId": onuInd.GetIntfId()})
+			//log.Warnw("ONU-is-on-a-different-intf-id-now", log.Fields{"previousIntfId": intfIDFromPortNo(onuDevice.ParentPortNo), "currentIntfId": onuInd.GetIntfId()})
 			log.Warnw("ONU-is-on-a-different-intf-id-now", log.Fields{"previousIntfId": onuDevice.ParentPortNo, "currentIntfId": ponPort})
 		}
 
@@ -704,66 +738,98 @@
 		}
 		onuKey := dh.formOnuKey(onuInd.GetIntfId(), onuInd.GetOnuId())
 		dh.onus[onuKey] = NewOnuDevice(onuDevice.Id, onuDevice.Type, onuDevice.SerialNumber, onuInd.GetOnuId(), onuInd.GetIntfId(), onuDevice.ProxyAddress.DeviceId)
+		dh.updateOnuAdminState(onuInd)
+		dh.updateOnuStates(onuDevice, onuInd)
 
-		// adminState
-		if onuInd.AdminState == "down" {
-			if onuInd.OperState != "down" {
-				log.Errorw("ONU-admin-state-down-and-oper-status-not-down", log.Fields{"operState": onuInd.OperState})
-				// Forcing the oper state change code to execute
-				onuInd.OperState = "down"
-			}
-			// Port and logical port update is taken care of by oper state block
-		} else if onuInd.AdminState == "up" {
-			log.Debugln("received-onu-admin-state up")
-		} else {
-			log.Errorw("Invalid-or-not-implemented-admin-state", log.Fields{"received-admin-state": onuInd.AdminState})
-		}
-		log.Debugln("admin-state-dealt-with")
-
-		// operState
-		if onuInd.OperState == "down" {
-			if onuDevice.ConnectStatus != common.ConnectStatus_UNREACHABLE {
-				dh.coreProxy.DeviceStateUpdate(nil, onuDevice.Id, common.ConnectStatus_UNREACHABLE, onuDevice.OperStatus)
-				log.Debugln("onu-oper-state-is-down")
-			}
-			if onuDevice.OperStatus != common.OperStatus_DISCOVERED {
-				dh.coreProxy.DeviceStateUpdate(nil, onuDevice.Id, common.ConnectStatus_UNREACHABLE, common.OperStatus_DISCOVERED)
-			}
-			log.Debugw("inter-adapter-send-onu-ind", log.Fields{"onuIndication": onuInd})
-
-			// TODO NEW CORE do not hardcode adapter name. Handler needs Adapter reference
-			dh.AdapterProxy.SendInterAdapterMessage(nil, onuInd, ic.InterAdapterMessageType_ONU_IND_REQUEST, "openolt", onuDevice.Type, onuDevice.Id, onuDevice.ProxyAddress.DeviceId, "")
-		} else if onuInd.OperState == "up" {
-			if onuDevice.ConnectStatus != common.ConnectStatus_REACHABLE {
-				dh.coreProxy.DeviceStateUpdate(nil, onuDevice.Id, common.ConnectStatus_REACHABLE, onuDevice.OperStatus)
-
-			}
-			if onuDevice.OperStatus != common.OperStatus_DISCOVERED {
-				log.Warnw("ignore onu indication", log.Fields{"intfId": onuInd.IntfId, "onuId": onuInd.OnuId, "operStatus": onuDevice.OperStatus, "msgOperStatus": onuInd.OperState})
-				return
-			}
-			dh.AdapterProxy.SendInterAdapterMessage(nil, onuInd, ic.InterAdapterMessageType_ONU_IND_REQUEST, "openolt", onuDevice.Type, onuDevice.Id, onuDevice.ProxyAddress.DeviceId, "")
-		} else {
-			log.Warnw("Not-implemented-or-invalid-value-of-oper-state", log.Fields{"operState": onuInd.OperState})
-		}
 	} else {
-		log.Errorw("onu not found", log.Fields{"intfId": onuInd.IntfId, "onuId": onuInd.OnuId})
+		log.Errorw("onu not found", log.Fields{"intfID": onuInd.IntfId, "onuID": onuInd.OnuId})
 		return
 	}
 
 }
 
+func (dh *DeviceHandler) updateOnuStates(onuDevice *voltha.Device, onuInd *oop.OnuIndication) {
+	onuKey := dh.formOnuKey(onuInd.GetIntfId(), onuInd.GetOnuId())
+	dh.onus[onuKey] = NewOnuDevice(onuDevice.Id, onuDevice.Type, onuDevice.SerialNumber, onuInd.GetOnuId(), onuInd.GetIntfId(), onuDevice.ProxyAddress.DeviceId)
+	dh.updateOnuAdminState(onuInd)
+	// operState
+	if onuInd.OperState == "down" {
+		if onuDevice.ConnectStatus != common.ConnectStatus_UNREACHABLE {
+			err := dh.coreProxy.DeviceStateUpdate(context.TODO(), onuDevice.Id, common.ConnectStatus_UNREACHABLE,
+				onuDevice.OperStatus)
+			if err != nil {
+				log.Errorw("unable to update onu state", log.Fields{"DeviceID": onuDevice.Id})
+				return
+			}
+			log.Debugln("onu-oper-state-is-down")
+		}
+		if onuDevice.OperStatus != common.OperStatus_DISCOVERED {
+			err := dh.coreProxy.DeviceStateUpdate(context.TODO(), onuDevice.Id, common.ConnectStatus_UNREACHABLE,
+				common.OperStatus_DISCOVERED)
+			if err != nil {
+				log.Errorw("unable to update onu state", log.Fields{"DeviceID": onuDevice.Id})
+				return
+			}
+		}
+		log.Debugw("inter-adapter-send-onu-ind", log.Fields{"onuIndication": onuInd})
+
+		// TODO NEW CORE do not hardcode adapter name. Handler needs Adapter reference
+		err := dh.AdapterProxy.SendInterAdapterMessage(context.TODO(), onuInd, ic.InterAdapterMessageType_ONU_IND_REQUEST,
+			"openolt", onuDevice.Type, onuDevice.Id, onuDevice.ProxyAddress.DeviceId, "")
+		if err != nil {
+			log.Errorw("Failed to send inter-adapter-message", log.Fields{"OnuInd": onuInd,
+				"From Adapter": "openolt", "DevieType": onuDevice.Type, "DeviceID": onuDevice.Id})
+		}
+	} else if onuInd.OperState == "up" {
+		if onuDevice.ConnectStatus != common.ConnectStatus_REACHABLE {
+			err := dh.coreProxy.DeviceStateUpdate(context.TODO(), onuDevice.Id, common.ConnectStatus_REACHABLE, onuDevice.OperStatus)
+			if err != nil {
+				log.Errorw("unable to update onu state", log.Fields{"DeviceID": onuDevice.Id})
+				return
+			}
+		}
+		if onuDevice.OperStatus != common.OperStatus_DISCOVERED {
+			log.Warnw("ignore onu indication", log.Fields{"intfID": onuInd.IntfId, "onuID": onuInd.OnuId, "operStatus": onuDevice.OperStatus, "msgOperStatus": onuInd.OperState})
+			return
+		}
+		err := dh.AdapterProxy.SendInterAdapterMessage(context.TODO(), onuInd, ic.InterAdapterMessageType_ONU_IND_REQUEST,
+			"openolt", onuDevice.Type, onuDevice.Id, onuDevice.ProxyAddress.DeviceId, "")
+		if err != nil {
+			log.Errorw("Failed to send inter-adapter-message", log.Fields{"OnuInd": onuInd,
+				"From Adapter": "openolt", "DevieType": onuDevice.Type, "DeviceID": onuDevice.Id})
+			return
+		}
+	} else {
+		log.Warnw("Not-implemented-or-invalid-value-of-oper-state", log.Fields{"operState": onuInd.OperState})
+	}
+}
+
+func (dh *DeviceHandler) updateOnuAdminState(onuInd *oop.OnuIndication) {
+	if onuInd.AdminState == "down" {
+		if onuInd.OperState != "down" {
+			log.Errorw("ONU-admin-state-down-and-oper-status-not-down", log.Fields{"operState": onuInd.OperState})
+			// Forcing the oper state change code to execute
+			onuInd.OperState = "down"
+		}
+		// Port and logical port update is taken care of by oper state block
+	} else if onuInd.AdminState == "up" {
+		log.Debugln("received-onu-admin-state up")
+	} else {
+		log.Errorw("Invalid-or-not-implemented-admin-state", log.Fields{"received-admin-state": onuInd.AdminState})
+	}
+	log.Debugln("admin-state-dealt-with")
+}
+
 func (dh *DeviceHandler) stringifySerialNumber(serialNum *oop.SerialNumber) string {
 	if serialNum != nil {
 		return string(serialNum.VendorId) + dh.stringifyVendorSpecific(serialNum.VendorSpecific)
-	} else {
-		return ""
 	}
+	return ""
 }
 
 func (dh *DeviceHandler) stringifyVendorSpecific(vendorSpecific []byte) string {
 	tmp := fmt.Sprintf("%x", (uint32(vendorSpecific[0])>>4)&0x0f) +
-		fmt.Sprintf("%x", (uint32(vendorSpecific[0]&0x0f))) +
+		fmt.Sprintf("%x", uint32(vendorSpecific[0]&0x0f)) +
 		fmt.Sprintf("%x", (uint32(vendorSpecific[1])>>4)&0x0f) +
 		fmt.Sprintf("%x", (uint32(vendorSpecific[1]))&0x0f) +
 		fmt.Sprintf("%x", (uint32(vendorSpecific[2])>>4)&0x0f) +
@@ -773,35 +839,41 @@
 	return tmp
 }
 
-// flows
-func (dh *DeviceHandler) Update_flows_bulk() error {
-	return errors.New("UnImplemented")
+//UpdateFlowsBulk upates the bulk flow
+func (dh *DeviceHandler) UpdateFlowsBulk() error {
+	return errors.New("unimplemented")
 }
-func (dh *DeviceHandler) GetChildDevice(parentPort uint32, onuId uint32) *voltha.Device {
-	log.Debugw("GetChildDevice", log.Fields{"pon port": parentPort, "onuId": onuId})
+
+//GetChildDevice returns the child device for given parent port and onu id
+func (dh *DeviceHandler) GetChildDevice(parentPort, onuID uint32) *voltha.Device {
+	log.Debugw("GetChildDevice", log.Fields{"pon port": parentPort, "onuID": onuID})
 	kwargs := make(map[string]interface{})
-	kwargs["onu_id"] = onuId
+	kwargs["onu_id"] = onuID
 	kwargs["parent_port_no"] = parentPort
-	onuDevice, err := dh.coreProxy.GetChildDevice(nil, dh.device.Id, kwargs)
+	onuDevice, err := dh.coreProxy.GetChildDevice(context.TODO(), dh.device.Id, kwargs)
 	if err != nil {
-		log.Errorw("onu not found", log.Fields{"intfId": parentPort, "onuId": onuId})
+		log.Errorw("onu not found", log.Fields{"intfID": parentPort, "onuID": onuID})
 		return nil
 	}
 	log.Debugw("Successfully received child device from core", log.Fields{"child_device": *onuDevice})
 	return onuDevice
 }
 
+// SendPacketInToCore sends packet-in to core
+// For this, it calls SendPacketIn of the core-proxy which uses a device specific topic to send the request.
+// The adapter handling the device creates a device specific topic
 func (dh *DeviceHandler) SendPacketInToCore(logicalPort uint32, packetPayload []byte) {
 	log.Debugw("SendPacketInToCore", log.Fields{"port": logicalPort, "packetPayload": packetPayload})
-	if err := dh.coreProxy.SendPacketIn(nil, dh.device.Id, logicalPort, packetPayload); err != nil {
+	if err := dh.coreProxy.SendPacketIn(context.TODO(), dh.device.Id, logicalPort, packetPayload); err != nil {
 		log.Errorw("Error sending packetin to core", log.Fields{"error": err})
 		return
 	}
 	log.Debug("Sent packet-in to core successfully")
 }
 
+//UpdateFlowsIncrementally updates the device flow
 func (dh *DeviceHandler) UpdateFlowsIncrementally(device *voltha.Device, flows *of.FlowChanges, groups *of.FlowGroupChanges) error {
-	log.Debugw("In UpdateFlowsIncrementally", log.Fields{"deviceId": device.Id, "flows": flows, "groups": groups})
+	log.Debugw("In Update_flows_incrementally", log.Fields{"deviceID": device.Id, "flows": flows, "groups": groups})
 	if flows != nil {
 		for _, flow := range flows.ToAdd.Items {
 			log.Debug("Adding flow", log.Fields{"deviceId": device.Id, "flowToAdd": flow})
@@ -812,15 +884,20 @@
 			dh.flowMgr.RemoveFlow(flow)
 		}
 	}
-	if groups != nil {
+	if groups != nil && flows != nil {
 		for _, flow := range flows.ToRemove.Items {
-			log.Debug("Removing flow", log.Fields{"deviceId": device.Id, "flowToRemove": flow})
+			log.Debug("Removing flow", log.Fields{"deviceID": device.Id, "flowToRemove": flow})
 			//  dh.flowMgr.RemoveFlow(flow)
 		}
 	}
 	return nil
 }
 
+//DisableDevice disables the given device
+//It marks the following for the given device:
+//Device-Handler Admin-State : down
+//Device Port-State: UNKNOWN
+//Device Oper-State: UNKNOWN
 func (dh *DeviceHandler) DisableDevice(device *voltha.Device) error {
 	if _, err := dh.Client.DisableOlt(context.Background(), new(oop.Empty)); err != nil {
 		log.Errorw("Failed to disable olt ", log.Fields{"err": err})
@@ -833,8 +910,8 @@
 
 	cloned := proto.Clone(device).(*voltha.Device)
 	// Update the all ports state on that device to disable
-	if err := dh.coreProxy.PortsStateUpdate(nil, cloned.Id, voltha.OperStatus_UNKNOWN); err != nil {
-		log.Errorw("updating-ports-failed", log.Fields{"deviceId": device.Id, "error": err})
+	if err := dh.coreProxy.PortsStateUpdate(context.TODO(), cloned.Id, voltha.OperStatus_UNKNOWN); err != nil {
+		log.Errorw("updating-ports-failed", log.Fields{"deviceID": device.Id, "error": err})
 		return err
 	}
 
@@ -842,14 +919,19 @@
 	cloned.OperStatus = voltha.OperStatus_UNKNOWN
 	dh.device = cloned
 
-	if err := dh.coreProxy.DeviceStateUpdate(nil, cloned.Id, cloned.ConnectStatus, cloned.OperStatus); err != nil {
-		log.Errorw("error-updating-device-state", log.Fields{"deviceId": device.Id, "error": err})
+	if err := dh.coreProxy.DeviceStateUpdate(context.TODO(), cloned.Id, cloned.ConnectStatus, cloned.OperStatus); err != nil {
+		log.Errorw("error-updating-device-state", log.Fields{"deviceID": device.Id, "error": err})
 		return err
 	}
-	log.Debugw("DisableDevice-end", log.Fields{"deviceId": device.Id})
+	log.Debugw("Disable_device-end", log.Fields{"deviceID": device.Id})
 	return nil
 }
 
+//ReenableDevice re-enables the olt device after disable
+//It marks the following for the given device:
+//Device-Handler Admin-State : up
+//Device Port-State: ACTIVE
+//Device Oper-State: ACTIVE
 func (dh *DeviceHandler) ReenableDevice(device *voltha.Device) error {
 	if _, err := dh.Client.ReenableOlt(context.Background(), new(oop.Empty)); err != nil {
 		log.Errorw("Failed to reenable olt ", log.Fields{"err": err})
@@ -863,8 +945,8 @@
 
 	cloned := proto.Clone(device).(*voltha.Device)
 	// Update the all ports state on that device to enable
-	if err := dh.coreProxy.PortsStateUpdate(nil, cloned.Id, voltha.OperStatus_ACTIVE); err != nil {
-		log.Errorw("updating-ports-failed", log.Fields{"deviceId": device.Id, "error": err})
+	if err := dh.coreProxy.PortsStateUpdate(context.TODO(), cloned.Id, voltha.OperStatus_ACTIVE); err != nil {
+		log.Errorw("updating-ports-failed", log.Fields{"deviceID": device.Id, "error": err})
 		return err
 	}
 
@@ -872,22 +954,23 @@
 	cloned.OperStatus = voltha.OperStatus_ACTIVE
 	dh.device = cloned
 
-	if err := dh.coreProxy.DeviceStateUpdate(nil, cloned.Id, cloned.ConnectStatus, cloned.OperStatus); err != nil {
-		log.Errorw("error-updating-device-state", log.Fields{"deviceId": device.Id, "error": err})
+	if err := dh.coreProxy.DeviceStateUpdate(context.TODO(), cloned.Id, cloned.ConnectStatus, cloned.OperStatus); err != nil {
+		log.Errorw("error-updating-device-state", log.Fields{"deviceID": device.Id, "error": err})
 		return err
 	}
-	log.Debugw("ReEnableDevice-end", log.Fields{"deviceId": device.Id})
+	log.Debugw("ReEnableDevice-end", log.Fields{"deviceID": device.Id})
 
 	return nil
 }
 
+//RebootDevice reboots the given device
 func (dh *DeviceHandler) RebootDevice(device *voltha.Device) error {
 	if _, err := dh.Client.Reboot(context.Background(), new(oop.Empty)); err != nil {
 		log.Errorw("Failed to reboot olt ", log.Fields{"err": err})
 		return err
 	}
 
-	log.Debugw("rebooted-device-successfully", log.Fields{"deviceId": device.Id})
+	log.Debugw("rebooted-device-successfully", log.Fields{"deviceID": device.Id})
 
 	return nil
 }
@@ -900,15 +983,16 @@
 		return
 	}
 	log.Debugw("sending packet-in to core", log.Fields{"logicalPortNum": logicalPortNum, "packet": *packetIn})
-	if err := dh.coreProxy.SendPacketIn(nil, dh.device.Id, logicalPortNum, packetIn.Pkt); err != nil {
+	if err := dh.coreProxy.SendPacketIn(context.TODO(), dh.device.Id, logicalPortNum, packetIn.Pkt); err != nil {
 		log.Errorw("Error sending packet-in to core", log.Fields{"error": err})
 		return
 	}
 	log.Debug("Success sending packet-in to core!")
 }
 
-func (dh *DeviceHandler) PacketOut(egress_port_no int, packet *of.OfpPacketOut) error {
-	log.Debugw("PacketOut", log.Fields{"deviceId": dh.deviceId, "egress_port_no": egress_port_no, "pkt-length": len(packet.Data)})
+// PacketOut sends packet-out from VOLTHA to OLT on the egress port provided
+func (dh *DeviceHandler) PacketOut(egressPortNo int, packet *of.OfpPacketOut) error {
+	log.Debugw("PacketOut", log.Fields{"deviceID": dh.deviceID, "egress_port_no": egressPortNo, "pkt-length": len(packet.Data)})
 	var etherFrame ethernet.Frame
 	err := (&etherFrame).UnmarshalBinary(packet.Data)
 	if err != nil {
@@ -916,7 +1000,7 @@
 		return err
 	}
 	log.Debugw("Ethernet Frame", log.Fields{"Frame": etherFrame})
-	egressPortType := IntfIdToPortTypeName(uint32(egress_port_no))
+	egressPortType := IntfIDToPortTypeName(uint32(egressPortNo))
 	if egressPortType == voltha.Port_ETHERNET_UNI {
 		if etherFrame.VLAN != nil { // If double tag, remove the outer tag
 			nextEthType := (uint16(packet.Data[16]) << 8) | uint16(packet.Data[17])
@@ -934,35 +1018,34 @@
 				log.Debug("Double tagged packet , removed outer vlan", log.Fields{"New frame": etherFrame})
 			}
 		}
-		intfId := IntfIdFromUniPortNum(uint32(egress_port_no))
-		onuId := OnuIdFromPortNum(uint32(egress_port_no))
-		uniId := UniIdFromPortNum(uint32(egress_port_no))
-		/*gemPortId, err := dh.flowMgr.GetPacketOutGemPortId(intfId, onuId, uint32(egress_port_no))
+		intfID := IntfIDFromUniPortNum(uint32(egressPortNo))
+		onuID := OnuIDFromPortNum(uint32(egressPortNo))
+		uniID := UniIDFromPortNum(uint32(egressPortNo))
+		/*gemPortId, err := dh.flowMgr.GetPacketOutGemPortId(intfID, onuID, uint32(egress_port_no))
 		  if err != nil{
 		      log.Errorw("Error while getting gemport to packet-out",log.Fields{"error": err})
 		      return err
 		  }*/
-		onuPkt := oop.OnuPacket{IntfId: intfId, OnuId: onuId, PortNo: uint32(egress_port_no), Pkt: packet.Data}
-		log.Debug("sending-packet-to-ONU", log.Fields{"egress_port_no": egress_port_no, "IntfId": intfId, "onuId": onuId,
-			"uniId": uniId, "packet": packet.Data})
+		onuPkt := oop.OnuPacket{IntfId: intfID, OnuId: onuID, PortNo: uint32(egressPortNo), Pkt: packet.Data}
+		log.Debug("sending-packet-to-ONU", log.Fields{"egress_port_no": egressPortNo, "IntfId": intfID, "onuID": onuID,
+			"uniID": uniID, "packet": packet.Data})
 		if _, err := dh.Client.OnuPacketOut(context.Background(), &onuPkt); err != nil {
 			log.Errorw("Error while sending packet-out to ONU", log.Fields{"error": err})
 			return err
 		}
 	} else if egressPortType == voltha.Port_ETHERNET_NNI {
-		uplinkPkt := oop.UplinkPacket{IntfId: IntfIdFromNniPortNum(uint32(egress_port_no)), Pkt: packet.Data}
+		uplinkPkt := oop.UplinkPacket{IntfId: IntfIDFromNniPortNum(uint32(egressPortNo)), Pkt: packet.Data}
 		log.Debug("sending-packet-to-uplink", log.Fields{"uplink_pkt": uplinkPkt})
 		if _, err := dh.Client.UplinkPacketOut(context.Background(), &uplinkPkt); err != nil {
 			log.Errorw("Error while sending packet-out to uplink", log.Fields{"error": err})
 			return err
 		}
 	} else {
-		log.Warnw("Packet-out-to-this-interface-type-not-implemented", log.Fields{"egress_port_no": egress_port_no, "egressPortType": egressPortType})
+		log.Warnw("Packet-out-to-this-interface-type-not-implemented", log.Fields{"egress_port_no": egressPortNo, "egressPortType": egressPortType})
 	}
 	return nil
 }
 
-func (dh *DeviceHandler) formOnuKey(intfId uint32, onuId uint32) string {
-	return ("" + strconv.Itoa(int(intfId)) + "." + strconv.Itoa(int(onuId)))
-
+func (dh *DeviceHandler) formOnuKey(intfID, onuID uint32) string {
+	return "" + strconv.Itoa(int(intfID)) + "." + strconv.Itoa(int(onuID))
 }
diff --git a/adaptercore/olt_platform.go b/adaptercore/olt_platform.go
index 648db1d..7f457dc 100644
--- a/adaptercore/olt_platform.go
+++ b/adaptercore/olt_platform.go
@@ -13,13 +13,15 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
+//Package adaptercore provides the utility for olt devices, flows and statistics
 package adaptercore
 
 import (
 	"errors"
 	"github.com/opencord/voltha-go/rw_core/utils"
 	ofp "github.com/opencord/voltha-protos/go/openflow_13"
-	voltha "github.com/opencord/voltha-protos/go/voltha"
+	"github.com/opencord/voltha-protos/go/voltha"
 )
 
 /*=====================================================================
@@ -78,89 +80,84 @@
     +--------+------------------------~~~------+
 */
 
-var MAX_ONUS_PER_PON = 32
-var MIN_UPSTREAM_PORT_ID = 0xfffd
-var MAX_UPSTREAM_PORT_ID = 0xfffffffd
+//MaxOnusPerPon value
+var MaxOnusPerPon = 32
 
-var controllerPorts []uint32 = []uint32{0xfffd, 0x7ffffffd, 0xfffffffd}
+//MinUpstreamPortID value
+var MinUpstreamPortID = 0xfffd
 
-func MkUniPortNum(intfId uint32, onuId uint32, uniId uint32) uint32 {
+//MaxUpstreamPortID value
+var MaxUpstreamPortID = 0xfffffffd
+
+var controllerPorts = []uint32{0xfffd, 0x7ffffffd, 0xfffffffd}
+
+//MkUniPortNum returns new UNIportNum based on intfID, inuID and uniID
+func MkUniPortNum(intfID, onuID, uniID uint32) uint32 {
 	/* TODO: Add checks */
-	return ((intfId << 11) | (onuId << 4) | uniId)
+	return (intfID << 11) | (onuID << 4) | uniID
 }
 
-func MkFlowId(intfId uint32, onuId uint32, idx uint32) uint32 {
-	return (((intfId << 9) | (onuId << 4)) | idx)
+//OnuIDFromPortNum returns ONUID derived from portNumber
+func OnuIDFromPortNum(portNum uint32) uint32 {
+	return (portNum >> 4) & 127
 }
 
-func OnuIdFromPortNum(portNum uint32) uint32 {
-	return ((portNum >> 4) & 127)
+//IntfIDFromUniPortNum returns IntfID derived from portNum
+func IntfIDFromUniPortNum(portNum uint32) uint32 {
+	return (portNum >> 11) & 15
 }
 
-func IntfIdFromUniPortNum(portNum uint32) uint32 {
-	return ((portNum >> 11) & 15)
+//UniIDFromPortNum return UniID derived from portNum
+func UniIDFromPortNum(portNum uint32) uint32 {
+	return (portNum) & 0xF
 }
 
-func UniIdFromPortNum(portNum uint32) uint32 {
-	return ((portNum) & 0xF)
-}
-
-func IntfIdFromPonPortNo(portNo uint32) uint32 {
-	return (portNo & 15)
-}
-
-func IntfIdToPortNo(intfId uint32, intfType voltha.Port_PortType) uint32 {
+//IntfIDToPortNo returns portId derived from intftype, intfId and portType
+func IntfIDToPortNo(intfID uint32, intfType voltha.Port_PortType) uint32 {
 	if (intfType) == voltha.Port_ETHERNET_NNI {
-		return ((1 << 16) | intfId)
-	} else {
-		if (intfType) == voltha.Port_PON_OLT {
-			return ((2 << 28) | intfId)
-		} else {
-			return 0
-		}
+		return (1 << 16) | intfID
 	}
+	if (intfType) == voltha.Port_PON_OLT {
+		return (2 << 28) | intfID
+	}
+	return 0
 }
 
-func IntfIdFromNniPortNum(portNum uint32) uint32 {
-	return (portNum & 0xFFFF)
+//IntfIDFromNniPortNum returns Intf ID derived from portNum
+func IntfIDFromNniPortNum(portNum uint32) uint32 {
+	return portNum & 0xFFFF
 }
 
-func IntfIdToPortTypeName(intfId uint32) voltha.Port_PortType {
-	if ((2 << 28) ^ intfId) < 16 {
+//IntfIDToPortTypeName returns port type derived from the intfId
+func IntfIDToPortTypeName(intfID uint32) voltha.Port_PortType {
+	if ((2 << 28) ^ intfID) < 16 {
 		return voltha.Port_PON_OLT
-	} else {
-		if (intfId & (1 << 16)) == (1 << 16) {
-			return voltha.Port_ETHERNET_NNI
-		} else {
-			return voltha.Port_ETHERNET_UNI
-		}
 	}
+	if (intfID & (1 << 16)) == (1 << 16) {
+		return voltha.Port_ETHERNET_NNI
+	}
+	return voltha.Port_ETHERNET_UNI
 }
 
-func PortTypeNameByPortIndex(portIndex int32) string {
-	return voltha.Port_PortType_name[portIndex]
-}
-
-func ExtractAccessFromFlow(inPort uint32, outPort uint32) (uint32, uint32, uint32, uint32) {
+//ExtractAccessFromFlow returns AccessDevice information
+func ExtractAccessFromFlow(inPort, outPort uint32) (uint32, uint32, uint32, uint32) {
 	if IsUpstream(outPort) {
-		return inPort, IntfIdFromUniPortNum(inPort), OnuIdFromPortNum(inPort), UniIdFromPortNum(inPort)
-	} else {
-		return outPort, IntfIdFromUniPortNum(outPort), OnuIdFromPortNum(outPort), UniIdFromPortNum(outPort)
+		return inPort, IntfIDFromUniPortNum(inPort), OnuIDFromPortNum(inPort), UniIDFromPortNum(inPort)
 	}
+	return outPort, IntfIDFromUniPortNum(outPort), OnuIDFromPortNum(outPort), UniIDFromPortNum(outPort)
 }
 
+//IsUpstream returns true for Upstream and false for downstream
 func IsUpstream(outPort uint32) bool {
 	for _, port := range controllerPorts {
 		if port == outPort {
 			return true
 		}
 	}
-	if (outPort & (1 << 16)) == (1 << 16) {
-		return true
-	}
-	return false
+	return (outPort & (1 << 16)) == (1 << 16)
 }
 
+//IsControllerBoundFlow returns true/false
 func IsControllerBoundFlow(outPort uint32) bool {
 	for _, port := range controllerPorts {
 		if port == outPort {
@@ -170,15 +167,17 @@
 	return false
 }
 
-func OnuIdFromUniPortNum(portNum uint32) uint32 {
+//OnuIDFromUniPortNum returns onuId from give portNum information.
+func OnuIDFromUniPortNum(portNum uint32) uint32 {
 	return (portNum >> 4) & 0x7F
 }
 
+//FlowExtractInfo fetches uniport from the flow, based on which it gets and returns ponInf, onuID and uniID
 func FlowExtractInfo(flow *ofp.OfpFlowStats, flowDirection string) (uint32, uint32, uint32, error) {
-	var uniPortNo uint32 = 0
-	var ponIntf uint32 = 0
-	var onuId uint32 = 0
-	var uniId uint32 = 0
+	var uniPortNo uint32
+	var ponIntf uint32
+	var onuID uint32
+	var uniID uint32
 
 	if flowDirection == "upstream" {
 		if uniPortNo = utils.GetChildPortFromTunnelId(flow); uniPortNo == 0 {
@@ -203,12 +202,12 @@
 	}
 
 	if uniPortNo == 0 {
-		return 0, 0, 0, errors.New("Failed to extract Pon Interface, ONU Id and Uni Id from flow")
+		return 0, 0, 0, errors.New("failed to extract Pon Interface, ONU Id and Uni Id from flow")
 	}
 
-	ponIntf = IntfIdFromUniPortNum(uniPortNo)
-	onuId = OnuIdFromUniPortNum(uniPortNo)
-	uniId = UniIdFromPortNum(uniPortNo)
+	ponIntf = IntfIDFromUniPortNum(uniPortNo)
+	onuID = OnuIDFromUniPortNum(uniPortNo)
+	uniID = UniIDFromPortNum(uniPortNo)
 
-	return ponIntf, onuId, uniId, nil
+	return ponIntf, onuID, uniID, nil
 }
diff --git a/adaptercore/olt_state_transitions.go b/adaptercore/olt_state_transitions.go
index 1cd71f0..bd410d3 100644
--- a/adaptercore/olt_state_transitions.go
+++ b/adaptercore/olt_state_transitions.go
@@ -13,6 +13,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
+//Package adaptercore provides the utility for olt devices, flows and statistics
 package adaptercore
 
 import (
@@ -141,7 +143,7 @@
 }
 
 // Handle moves the state machine to next state based on the trigger and invokes the before and
-//         after handlers
+// after handlers if the transition is a valid transition
 func (tMap *TransitionMap) Handle(trigger Trigger) {
 
 	// Check whether the transtion is valid from current state
@@ -152,17 +154,17 @@
 
 	// Invoke the before handlers
 	beforeHandlers := tMap.transitions[trigger].before
-	if beforeHandlers != nil {
-		for _, handler := range beforeHandlers {
-			log.Debugw("running-before-handler", log.Fields{"handler": funcName(handler)})
-			if err := handler(); err != nil {
-				// TODO handle error
-				return
-			}
-		}
-	} else {
+	if beforeHandlers == nil {
 		log.Debugw("No handlers for before", log.Fields{"trigger": trigger})
 	}
+	for _, handler := range beforeHandlers {
+		log.Debugw("running-before-handler", log.Fields{"handler": funcName(handler)})
+		if err := handler(); err != nil {
+			// TODO handle error
+			log.Error(err)
+			return
+		}
+	}
 
 	// Update the state
 	tMap.currentDeviceState = tMap.transitions[trigger].currentState
@@ -170,15 +172,15 @@
 
 	// Invoke the after handlers
 	afterHandlers := tMap.transitions[trigger].after
-	if afterHandlers != nil {
-		for _, handler := range afterHandlers {
-			log.Debugw("running-after-handler", log.Fields{"handler": funcName(handler)})
-			if err := handler(); err != nil {
-				// TODO handle error
-				return
-			}
-		}
-	} else {
+	if afterHandlers == nil {
 		log.Debugw("No handlers for after", log.Fields{"trigger": trigger})
 	}
+	for _, handler := range afterHandlers {
+		log.Debugw("running-after-handler", log.Fields{"handler": funcName(handler)})
+		if err := handler(); err != nil {
+			// TODO handle error
+			log.Error(err)
+			return
+		}
+	}
 }
diff --git a/adaptercore/openolt.go b/adaptercore/openolt.go
index 81639be..ce501ef 100644
--- a/adaptercore/openolt.go
+++ b/adaptercore/openolt.go
@@ -13,6 +13,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
+//Package adaptercore provides the utility for olt devices, flows and statistics
 package adaptercore
 
 import (
@@ -29,6 +31,7 @@
 	"github.com/opencord/voltha-protos/go/voltha"
 )
 
+//OpenOLT structure holds the OLT information
 type OpenOLT struct {
 	deviceHandlers        map[string]*DeviceHandler
 	coreProxy             *com.CoreProxy
@@ -42,6 +45,7 @@
 	lockDeviceHandlersMap sync.RWMutex
 }
 
+//NewOpenOLT returns a new instance of OpenOLT
 func NewOpenOLT(ctx context.Context, kafkaICProxy *kafka.InterContainerProxy, coreProxy *com.CoreProxy, adapterProxy *com.AdapterProxy, onuNumber int, kvStoreHost string, kvStorePort int, KVStoreType string) *OpenOLT {
 	var openOLT OpenOLT
 	openOLT.exitChannel = make(chan int, 1)
@@ -57,12 +61,14 @@
 	return &openOLT
 }
 
+//Start starts (logs) the device manager
 func (oo *OpenOLT) Start(ctx context.Context) error {
 	log.Info("starting-device-manager")
 	log.Info("device-manager-started")
 	return nil
 }
 
+//Stop terminates the session
 func (oo *OpenOLT) Stop(ctx context.Context) error {
 	log.Info("stopping-device-manager")
 	oo.exitChannel <- 1
@@ -72,7 +78,7 @@
 
 func sendResponse(ctx context.Context, ch chan interface{}, result interface{}) {
 	if ctx.Err() == nil {
-		// Returned response only of the ctx has not been cancelled/timeout/etc
+		// Returned response only of the ctx has not been canceled/timeout/etc
 		// Channel is automatically closed when a context is Done
 		ch <- result
 		log.Debugw("sendResponse", log.Fields{"result": result})
@@ -85,26 +91,27 @@
 func (oo *OpenOLT) addDeviceHandlerToMap(agent *DeviceHandler) {
 	oo.lockDeviceHandlersMap.Lock()
 	defer oo.lockDeviceHandlersMap.Unlock()
-	if _, exist := oo.deviceHandlers[agent.deviceId]; !exist {
-		oo.deviceHandlers[agent.deviceId] = agent
+	if _, exist := oo.deviceHandlers[agent.deviceID]; !exist {
+		oo.deviceHandlers[agent.deviceID] = agent
 	}
 }
 
 func (oo *OpenOLT) deleteDeviceHandlerToMap(agent *DeviceHandler) {
 	oo.lockDeviceHandlersMap.Lock()
 	defer oo.lockDeviceHandlersMap.Unlock()
-	delete(oo.deviceHandlers, agent.deviceId)
+	delete(oo.deviceHandlers, agent.deviceID)
 }
 
-func (oo *OpenOLT) getDeviceHandler(deviceId string) *DeviceHandler {
+func (oo *OpenOLT) getDeviceHandler(deviceID string) *DeviceHandler {
 	oo.lockDeviceHandlersMap.Lock()
 	defer oo.lockDeviceHandlersMap.Unlock()
-	if agent, ok := oo.deviceHandlers[deviceId]; ok {
+	if agent, ok := oo.deviceHandlers[deviceID]; ok {
 		return agent
 	}
 	return nil
 }
 
+//createDeviceTopic returns
 func (oo *OpenOLT) createDeviceTopic(device *voltha.Device) error {
 	log.Infow("create-device-topic", log.Fields{"deviceId": device.Id})
 	deviceTopic := kafka.Topic{Name: oo.kafkaICProxy.DefaultTopic.Name + "_" + device.Id}
@@ -116,6 +123,7 @@
 	return nil
 }
 
+// Adopt_device creates a new device handler if not present already and then adopts the device
 func (oo *OpenOLT) Adopt_device(device *voltha.Device) error {
 	if device == nil {
 		log.Warn("device-is-nil")
@@ -133,6 +141,7 @@
 	return nil
 }
 
+//Get_ofp_device_info returns OFP information for the given device
 func (oo *OpenOLT) Get_ofp_device_info(device *voltha.Device) (*ic.SwitchCapability, error) {
 	log.Infow("Get_ofp_device_info", log.Fields{"deviceId": device.Id})
 	if handler := oo.getDeviceHandler(device.Id); handler != nil {
@@ -142,15 +151,17 @@
 	return nil, errors.New("device-handler-not-set")
 }
 
-func (oo *OpenOLT) Get_ofp_port_info(device *voltha.Device, port_no int64) (*ic.PortCapability, error) {
+//Get_ofp_port_info returns OFP port information for the given device
+func (oo *OpenOLT) Get_ofp_port_info(device *voltha.Device, portNo int64) (*ic.PortCapability, error) {
 	log.Infow("Get_ofp_port_info", log.Fields{"deviceId": device.Id})
 	if handler := oo.getDeviceHandler(device.Id); handler != nil {
-		return handler.GetOfpPortInfo(device, port_no)
+		return handler.GetOfpPortInfo(device, portNo)
 	}
 	log.Errorw("device-handler-not-set", log.Fields{"deviceId": device.Id})
 	return nil, errors.New("device-handler-not-set")
 }
 
+//Process_inter_adapter_message sends messages to a target device (between adapters)
 func (oo *OpenOLT) Process_inter_adapter_message(msg *ic.InterAdapterMessage) error {
 	log.Infow("Process_inter_adapter_message", log.Fields{"msgId": msg.Header.Id})
 	targetDevice := msg.Header.ProxyDeviceId // Request?
@@ -159,31 +170,37 @@
 		targetDevice = msg.Header.ToDeviceId
 	}
 	if handler := oo.getDeviceHandler(targetDevice); handler != nil {
-		return handler.Process_inter_adapter_message(msg)
+		return handler.ProcessInterAdapterMessage(msg)
 	}
-	return errors.New(fmt.Sprintf("handler-not-found-%s", targetDevice))
+	return fmt.Errorf(fmt.Sprintf("handler-not-found-%s", targetDevice))
 }
 
+//Adapter_descriptor not implemented
 func (oo *OpenOLT) Adapter_descriptor() error {
-	return errors.New("UnImplemented")
+	return errors.New("unImplemented")
 }
 
+//Device_types unimplemented
 func (oo *OpenOLT) Device_types() (*voltha.DeviceTypes, error) {
-	return nil, errors.New("UnImplemented")
+	return nil, errors.New("unImplemented")
 }
 
+//Health  returns unimplemented
 func (oo *OpenOLT) Health() (*voltha.HealthStatus, error) {
-	return nil, errors.New("UnImplemented")
+	return nil, errors.New("unImplemented")
 }
 
+//Reconcile_device unimplemented
 func (oo *OpenOLT) Reconcile_device(device *voltha.Device) error {
-	return errors.New("UnImplemented")
+	return errors.New("unImplemented")
 }
 
+//Abandon_device unimplemented
 func (oo *OpenOLT) Abandon_device(device *voltha.Device) error {
-	return errors.New("UnImplemented")
+	return errors.New("unImplemented")
 }
 
+//Disable_device disables the given device
 func (oo *OpenOLT) Disable_device(device *voltha.Device) error {
 	log.Infow("disable-device", log.Fields{"deviceId": device.Id})
 	if handler := oo.getDeviceHandler(device.Id); handler != nil {
@@ -193,6 +210,7 @@
 	return errors.New("device-handler-not-found")
 }
 
+//Reenable_device enables the olt device after disable
 func (oo *OpenOLT) Reenable_device(device *voltha.Device) error {
 	log.Infow("reenable-device", log.Fields{"deviceId": device.Id})
 	if handler := oo.getDeviceHandler(device.Id); handler != nil {
@@ -202,6 +220,7 @@
 	return errors.New("device-handler-not-found")
 }
 
+//Reboot_device reboots the given device
 func (oo *OpenOLT) Reboot_device(device *voltha.Device) error {
 	log.Infow("reboot-device", log.Fields{"deviceId": device.Id})
 	if handler := oo.getDeviceHandler(device.Id); handler != nil {
@@ -212,22 +231,27 @@
 
 }
 
+//Self_test_device unimplented
 func (oo *OpenOLT) Self_test_device(device *voltha.Device) error {
-	return errors.New("UnImplemented")
+	return errors.New("unImplemented")
 }
 
+//Delete_device unimplemented
 func (oo *OpenOLT) Delete_device(device *voltha.Device) error {
-	return errors.New("UnImplemented")
+	return errors.New("unImplemented")
 }
 
+//Get_device_details unimplemented
 func (oo *OpenOLT) Get_device_details(device *voltha.Device) error {
-	return errors.New("UnImplemented")
+	return errors.New("unImplemented")
 }
 
+//Update_flows_bulk returns
 func (oo *OpenOLT) Update_flows_bulk(device *voltha.Device, flows *voltha.Flows, groups *voltha.FlowGroups) error {
-	return errors.New("UnImplemented")
+	return errors.New("unImplemented")
 }
 
+//Update_flows_incrementally updates (add/remove) the flows on a given device
 func (oo *OpenOLT) Update_flows_incrementally(device *voltha.Device, flows *openflow_13.FlowChanges, groups *openflow_13.FlowGroupChanges) error {
 	log.Debugw("Update_flows_incrementally", log.Fields{"deviceId": device.Id, "flows": flows})
 	if handler := oo.getDeviceHandler(device.Id); handler != nil {
@@ -237,43 +261,52 @@
 	return errors.New("device-handler-not-set")
 }
 
-func (oo *OpenOLT) Update_pm_config(device *voltha.Device, pm_configs *voltha.PmConfigs) error {
-	return errors.New("UnImplemented")
+//Update_pm_config returns PmConfigs nil or error
+func (oo *OpenOLT) Update_pm_config(device *voltha.Device, pmConfigs *voltha.PmConfigs) error {
+	return errors.New("unImplemented")
 }
 
-func (oo *OpenOLT) Receive_packet_out(deviceId string, egress_port_no int, packet *openflow_13.OfpPacketOut) error {
-	log.Debugw("Receive_packet_out", log.Fields{"deviceId": deviceId, "egress_port_no": egress_port_no, "pkt": packet})
-	if handler := oo.getDeviceHandler(deviceId); handler != nil {
-		return handler.PacketOut(egress_port_no, packet)
+//Receive_packet_out sends packet out to the device
+func (oo *OpenOLT) Receive_packet_out(deviceID string, egressPortNo int, packet *openflow_13.OfpPacketOut) error {
+	log.Debugw("Receive_packet_out", log.Fields{"deviceId": deviceID, "egress_port_no": egressPortNo, "pkt": packet})
+	if handler := oo.getDeviceHandler(deviceID); handler != nil {
+		return handler.PacketOut(egressPortNo, packet)
 	}
-	log.Errorw("Receive_packet_out failed-device-handler-not-set", log.Fields{"deviceId": deviceId, "egressport": egress_port_no, "packet": packet})
+	log.Errorw("Receive_packet_out failed-device-handler-not-set", log.Fields{"deviceId": deviceID, "egressport": egressPortNo, "packet": packet})
 	return errors.New("device-handler-not-set")
 }
 
+//Suppress_alarm unimplemented
 func (oo *OpenOLT) Suppress_alarm(filter *voltha.AlarmFilter) error {
-	return errors.New("UnImplemented")
+	return errors.New("unImplemented")
 }
 
+//Unsuppress_alarm  unimplemented
 func (oo *OpenOLT) Unsuppress_alarm(filter *voltha.AlarmFilter) error {
-	return errors.New("UnImplemented")
+	return errors.New("unImplemented")
 }
 
+//Download_image unimplemented
 func (oo *OpenOLT) Download_image(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
-	return nil, errors.New("UnImplemented")
+	return nil, errors.New("unImplemented")
 }
 
+//Get_image_download_status unimplemented
 func (oo *OpenOLT) Get_image_download_status(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
-	return nil, errors.New("UnImplemented")
+	return nil, errors.New("unImplemented")
 }
 
+//Cancel_image_download unimplemented
 func (oo *OpenOLT) Cancel_image_download(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
-	return nil, errors.New("UnImplemented")
+	return nil, errors.New("unImplemented")
 }
 
+//Activate_image_update unimplemented
 func (oo *OpenOLT) Activate_image_update(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
-	return nil, errors.New("UnImplemented")
+	return nil, errors.New("unImplemented")
 }
 
+//Revert_image_update unimplemented
 func (oo *OpenOLT) Revert_image_update(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
-	return nil, errors.New("UnImplemented")
+	return nil, errors.New("unImplemented")
 }
diff --git a/adaptercore/openolt_flowmgr.go b/adaptercore/openolt_flowmgr.go
index 19abc26..1d96d2c 100644
--- a/adaptercore/openolt_flowmgr.go
+++ b/adaptercore/openolt_flowmgr.go
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 
+//Package adaptercore provides the utility for olt devices, flows and statistics
 package adaptercore
 
 import (
@@ -28,90 +29,129 @@
 	rsrcMgr "github.com/opencord/voltha-openolt-adapter/adaptercore/resourcemanager"
 	ic "github.com/opencord/voltha-protos/go/inter_container"
 	ofp "github.com/opencord/voltha-protos/go/openflow_13"
-	openolt_pb2 "github.com/opencord/voltha-protos/go/openolt"
-	voltha "github.com/opencord/voltha-protos/go/voltha"
+	openoltpb2 "github.com/opencord/voltha-protos/go/openolt"
+	"github.com/opencord/voltha-protos/go/voltha"
 	"math/big"
 	//deepcopy "github.com/getlantern/deepcopy"
 )
 
 const (
 	// Flow categories
-	HSIA_FLOW  = "HSIA_FLOW"
-	EAPOL_FLOW = "EAPOL_FLOW"
 
-	IP_PROTO_DHCP = 17
+	//HsiaFlow flow category
+	HsiaFlow = "HSIA_FLOW"
 
-	IP_PROTO_IGMP = 2
+	//EapolFlow flow category
+	EapolFlow = "EAPOL_FLOW"
 
-	EAP_ETH_TYPE  = 0x888e
-	LLDP_ETH_TYPE = 0x88cc
+	//IPProtoDhcp flow category
+	IPProtoDhcp = 17
 
-	IGMP_PROTO = 2
+	//IPProtoIgmp flow category
+	IPProtoIgmp = 2
+
+	//EapEthType eapethtype value
+	EapEthType = 0x888e
+	//LldpEthType lldp ethtype value
+	LldpEthType = 0x88cc
+
+	//IgmpProto proto value
+	IgmpProto = 2
 
 	//FIXME - see also BRDCM_DEFAULT_VLAN in broadcom_onu.py
-	DEFAULT_MGMT_VLAN = 4091
+
+	//DefaultMgmtVlan default vlan value
+	DefaultMgmtVlan = 4091
 
 	// Openolt Flow
-	UPSTREAM        = "upstream"
-	DOWNSTREAM      = "downstream"
-	PACKET_TAG_TYPE = "pkt_tag_type"
-	UNTAGGED        = "untagged"
-	SINGLE_TAG      = "single_tag"
-	DOUBLE_TAG      = "double_tag"
+
+	//UPSTREAM constant
+	UPSTREAM = "upstream"
+	//DOWNSTREAM constant
+	DOWNSTREAM = "downstream"
+	//PacketTagType constant
+	PacketTagType = "pkt_tag_type"
+	//UNTAGGED constant
+	UNTAGGED = "untagged"
+	//SingleTag constant
+	SingleTag = "single_tag"
+	//DoubleTag constant
+	DoubleTag = "double_tag"
 
 	// classifierInfo
-	ETH_TYPE  = "eth_type"
-	TPID      = "tpid"
-	IP_PROTO  = "ip_proto"
-	IN_PORT   = "in_port"
-	VLAN_VID  = "vlan_vid"
-	VLAN_PCP  = "vlan_pcp"
-	UDP_DST   = "udp_dst"
-	UDP_SRC   = "udp_src"
-	IPV4_DST  = "ipv4_dst"
-	IPV4_SRC  = "ipv4_src"
-	METADATA  = "metadata"
-	TUNNEL_ID = "tunnel_id"
-	OUTPUT    = "output"
-	// Action
-	POP_VLAN     = "pop_vlan"
-	PUSH_VLAN    = "push_vlan"
-	TRAP_TO_HOST = "trap_to_host"
+
+	//EthType constant
+	EthType = "eth_type"
+	//TPID constant
+	TPID = "tpid"
+	//IPProto constant
+	IPProto = "ip_proto"
+	//InPort constant
+	InPort = "in_port"
+	//VlanVid constant
+	VlanVid = "vlan_vid"
+	//VlanPcp constant
+	VlanPcp = "vlan_pcp"
+
+	//UDPDst constant
+	UDPDst = "udp_dst"
+	//UDPSrc constant
+	UDPSrc = "udp_src"
+	//Ipv4Dst constant
+	Ipv4Dst = "ipv4_dst"
+	//Ipv4Src constant
+	Ipv4Src = "ipv4_src"
+	//METADATA constant
+	METADATA = "metadata"
+	//TunnelID constant
+	TunnelID = "tunnel_id"
+	//OUTPUT constant
+	OUTPUT = "output"
+	// Actions
+
+	//PopVlan constant
+	PopVlan = "pop_vlan"
+	//PushVlan constant
+	PushVlan = "push_vlan"
+	//TrapToHost constant
+	TrapToHost = "trap_to_host"
 )
 
 type onuInfo struct {
-	intfId       uint32
-	onuId        uint32
+	intfID       uint32
+	onuID        uint32
 	serialNumber string
 }
 
-type onuIdKey struct {
-	intfId uint32
-	onuId  uint32
+type onuIDKey struct {
+	intfID uint32
+	onuID  uint32
 }
 
 type gemPortKey struct {
-	intfId  uint32
+	intfID  uint32
 	gemPort uint32
 }
 
 type packetInInfoKey struct {
-	intfId      uint32
-	onuId       uint32
+	intfID      uint32
+	onuID       uint32
 	logicalPort uint32
 }
 
+//OpenOltFlowMgr creates the Structure of OpenOltFlowMgr obj
 type OpenOltFlowMgr struct {
 	techprofile       []*tp.TechProfileMgr
 	deviceHandler     *DeviceHandler
 	resourceMgr       *rsrcMgr.OpenOltResourceMgr
-	onuIds            map[onuIdKey]onuInfo       //OnuId -> OnuInfo
+	onuIds            map[onuIDKey]onuInfo       //OnuId -> OnuInfo
 	onuSerialNumbers  map[string]onuInfo         //onu serial_number (string) -> OnuInfo
 	onuGemPortIds     map[gemPortKey]onuInfo     //GemPortId -> OnuInfo
 	packetInGemPort   map[packetInInfoKey]uint32 //packet in gem port
 	storedDeviceFlows []ofp.OfpFlowStats         /* Required during deletion to obtain device flows from logical flows */
 }
 
+//NewFlowManager creates OpenOltFlowMgr object and initializes the parameters
 func NewFlowManager(dh *DeviceHandler, rsrcMgr *rsrcMgr.OpenOltResourceMgr) *OpenOltFlowMgr {
 	log.Info("Initializing flow manager")
 	var flowMgr OpenOltFlowMgr
@@ -121,7 +161,7 @@
 		log.Error("Error while populating tech profile mgr\n")
 		return nil
 	}
-	flowMgr.onuIds = make(map[onuIdKey]onuInfo)
+	flowMgr.onuIds = make(map[onuIDKey]onuInfo)
 	flowMgr.onuSerialNumbers = make(map[string]onuInfo)
 	flowMgr.onuGemPortIds = make(map[gemPortKey]onuInfo)
 	flowMgr.packetInGemPort = make(map[packetInInfoKey]uint32)
@@ -129,25 +169,25 @@
 	return &flowMgr
 }
 
-func (f *OpenOltFlowMgr) generateStoredFlowId(flowId uint32, direction string) (uint64, error) {
+func (f *OpenOltFlowMgr) generateStoredFlowID(flowID uint32, direction string) (uint64, error) {
 	if direction == UPSTREAM {
 		log.Debug("upstream flow, shifting id")
-		return 0x1<<15 | uint64(flowId), nil
+		return 0x1<<15 | uint64(flowID), nil
 	} else if direction == DOWNSTREAM {
 		log.Debug("downstream flow, not shifting id")
-		return uint64(flowId), nil
+		return uint64(flowID), nil
 	} else {
 		log.Debug("Unrecognized direction")
-		return 0, errors.New(fmt.Sprintf("Unrecognized direction %s", direction))
+		return 0, fmt.Errorf("unrecognized direction %s", direction)
 	}
 }
 
-func (f *OpenOltFlowMgr) registerFlow(flowFromCore *ofp.OfpFlowStats, deviceFlow *openolt_pb2.Flow) {
+func (f *OpenOltFlowMgr) registerFlow(flowFromCore *ofp.OfpFlowStats, deviceFlow *openoltpb2.Flow) {
 	log.Debug("Registering Flow for Device ", log.Fields{"flow": flowFromCore},
-		log.Fields{"device": f.deviceHandler.deviceId})
+		log.Fields{"device": f.deviceHandler.deviceID})
 
 	var storedFlow ofp.OfpFlowStats
-	storedFlow.Id, _ = f.generateStoredFlowId(deviceFlow.FlowId, deviceFlow.FlowType)
+	storedFlow.Id, _ = f.generateStoredFlowID(deviceFlow.FlowId, deviceFlow.FlowType)
 	log.Debug(fmt.Sprintf("Generated stored device flow. id = %d, flowId = %d, direction = %s", storedFlow.Id,
 		deviceFlow.FlowId, deviceFlow.FlowType))
 	storedFlow.Cookie = flowFromCore.Id
@@ -155,19 +195,19 @@
 	log.Debugw("updated Stored flow info", log.Fields{"storedDeviceFlows": f.storedDeviceFlows})
 }
 
-func (f *OpenOltFlowMgr) divideAndAddFlow(intfId uint32, onuId uint32, uniId uint32, portNo uint32, classifierInfo map[string]interface{}, actionInfo map[string]interface{}, flow *ofp.OfpFlowStats) {
-	var allocId []uint32
+func (f *OpenOltFlowMgr) divideAndAddFlow(intfID uint32, onuID uint32, uniID uint32, portNo uint32, classifierInfo map[string]interface{}, actionInfo map[string]interface{}, flow *ofp.OfpFlowStats) {
+	var allocID []uint32
 	var gemPorts []uint32
 
-	log.Infow("Dividing flow", log.Fields{"intfId": intfId, "onuId": onuId, "uniId": uniId, "portNo": portNo, "classifier": classifierInfo, "action": actionInfo})
+	log.Infow("Dividing flow", log.Fields{"intfId": intfID, "onuId": onuID, "uniId": uniID, "portNo": portNo, "classifier": classifierInfo, "action": actionInfo})
 
-	log.Infow("sorting flow", log.Fields{"intfId": intfId, "onuId": onuId, "uniId": uniId, "portNo": portNo,
+	log.Infow("sorting flow", log.Fields{"intfId": intfID, "onuId": onuID, "uniId": uniID, "portNo": portNo,
 		"classifierInfo": classifierInfo, "actionInfo": actionInfo})
 
-	uni := getUniPortPath(intfId, onuId, uniId)
+	uni := getUniPortPath(intfID, onuID, uniID)
 	log.Debugw("Uni port name", log.Fields{"uni": uni})
-	allocId, gemPorts = f.createTcontGemports(intfId, onuId, uniId, uni, portNo, flow.GetTableId())
-	if allocId == nil || gemPorts == nil {
+	allocID, gemPorts = f.createTcontGemports(intfID, onuID, uniID, uni, portNo, flow.GetTableId())
+	if allocID == nil || gemPorts == nil {
 		log.Error("alloc-id-gem-ports-unavailable")
 		return
 	}
@@ -176,36 +216,36 @@
 	 * Hence adding flows for all gemports
 	 */
 	for _, gemPort := range gemPorts {
-		if ipProto, ok := classifierInfo[IP_PROTO]; ok {
-			if ipProto.(uint32) == IP_PROTO_DHCP {
+		if ipProto, ok := classifierInfo[IPProto]; ok {
+			if ipProto.(uint32) == IPProtoDhcp {
 				log.Info("Adding DHCP flow")
-				f.addDHCPTrapFlow(intfId, onuId, uniId, portNo, classifierInfo, actionInfo, flow, allocId[0], gemPort)
-			} else if ipProto == IP_PROTO_IGMP {
+				f.addDHCPTrapFlow(intfID, onuID, uniID, portNo, classifierInfo, actionInfo, flow, allocID[0], gemPort)
+			} else if ipProto == IPProtoIgmp {
 				log.Info("igmp flow add ignored, not implemented yet")
 			} else {
 				log.Errorw("Invalid-Classifier-to-handle", log.Fields{"classifier": classifierInfo, "action": actionInfo})
 				//return errors.New("Invalid-Classifier-to-handle")
 			}
-		} else if ethType, ok := classifierInfo[ETH_TYPE]; ok {
-			if ethType.(uint32) == EAP_ETH_TYPE {
+		} else if ethType, ok := classifierInfo[EthType]; ok {
+			if ethType.(uint32) == EapEthType {
 				log.Info("Adding EAPOL flow")
-				f.addEAPOLFlow(intfId, onuId, uniId, portNo, flow, allocId[0], gemPort, DEFAULT_MGMT_VLAN)
+				f.addEAPOLFlow(intfID, onuID, uniID, portNo, flow, allocID[0], gemPort, DefaultMgmtVlan)
 				if vlan := getSubscriberVlan(utils.GetInPort(flow)); vlan != 0 {
-					f.addEAPOLFlow(intfId, onuId, uniId, portNo, flow, allocId[0], gemPort, vlan)
+					f.addEAPOLFlow(intfID, onuID, uniID, portNo, flow, allocID[0], gemPort, vlan)
 				}
 				// Send Techprofile download event to child device in go routine as it takes time
-				go f.sendTPDownloadMsgToChild(intfId, onuId, uniId, uni)
+				go f.sendTPDownloadMsgToChild(intfID, onuID, uniID, uni)
 			}
-			if ethType == LLDP_ETH_TYPE {
+			if ethType == LldpEthType {
 				log.Info("Adding LLDP flow")
 				addLLDPFlow(flow, portNo)
 			}
-		} else if _, ok := actionInfo[PUSH_VLAN]; ok {
+		} else if _, ok := actionInfo[PushVlan]; ok {
 			log.Info("Adding upstream data rule")
-			f.addUpstreamDataFlow(intfId, onuId, uniId, portNo, classifierInfo, actionInfo, flow, allocId[0], gemPort)
-		} else if _, ok := actionInfo[POP_VLAN]; ok {
+			f.addUpstreamDataFlow(intfID, onuID, uniID, portNo, classifierInfo, actionInfo, flow, allocID[0], gemPort)
+		} else if _, ok := actionInfo[PopVlan]; ok {
 			log.Info("Adding Downstream data rule")
-			f.addDownstreamDataFlow(intfId, onuId, uniId, portNo, classifierInfo, actionInfo, flow, allocId[0], gemPort)
+			f.addDownstreamDataFlow(intfID, onuID, uniID, portNo, classifierInfo, actionInfo, flow, allocID[0], gemPort)
 		} else {
 			log.Errorw("Invalid-flow-type-to-handle", log.Fields{"classifier": classifierInfo, "action": actionInfo, "flow": flow})
 		}
@@ -213,36 +253,36 @@
 }
 
 // This function allocates tconts and GEM ports for an ONU, currently one TCONT is supported per ONU
-func (f *OpenOltFlowMgr) createTcontGemports(intfId uint32, onuId uint32, uniId uint32, uni string, uniPort uint32, tableID uint32) ([]uint32, []uint32) {
+func (f *OpenOltFlowMgr) createTcontGemports(intfID uint32, onuID uint32, uniID uint32, uni string, uniPort uint32, tableID uint32) ([]uint32, []uint32) {
 	var allocID []uint32
 	var gemPortIDs []uint32
 	//If we already have allocated earlier for this onu, render them
-	if tcontId := f.resourceMgr.GetCurrentAllocIDForOnu(intfId, onuId, uniId); tcontId != 0 {
-		allocID = append(allocID, tcontId)
+	if tcontID := f.resourceMgr.GetCurrentAllocIDForOnu(intfID, onuID, uniID); tcontID != 0 {
+		allocID = append(allocID, tcontID)
 	}
-	gemPortIDs = f.resourceMgr.GetCurrentGEMPortIDsForOnu(intfId, onuId, uniId)
+	gemPortIDs = f.resourceMgr.GetCurrentGEMPortIDsForOnu(intfID, onuID, uniID)
 	if len(allocID) != 0 && len(gemPortIDs) != 0 {
-		log.Debug("Rendered Tcont and GEM ports from resource manager", log.Fields{"intfId": intfId, "onuId": onuId, "uniPort": uniId,
+		log.Debug("Rendered Tcont and GEM ports from resource manager", log.Fields{"intfId": intfID, "onuId": onuID, "uniPort": uniID,
 			"allocID": allocID, "gemPortIDs": gemPortIDs})
 		return allocID, gemPortIDs
 	}
-	log.Debug("Creating New TConts and Gem ports", log.Fields{"pon": intfId, "onu": onuId, "uni": uniId})
+	log.Debug("Creating New TConts and Gem ports", log.Fields{"pon": intfID, "onu": onuID, "uni": uniID})
 
 	//FIXME: If table id is <= 63 using 64 as table id
 	if tableID < tp.DEFAULT_TECH_PROFILE_TABLE_ID {
 		tableID = tp.DEFAULT_TECH_PROFILE_TABLE_ID
 	}
-	tpPath := f.getTPpath(intfId, uni)
+	tpPath := f.getTPpath(intfID, uni)
 	// Check tech profile instance already exists for derived port name
-	tech_profile_instance, err := f.techprofile[intfId].GetTPInstanceFromKVStore(tableID, tpPath)
+	techProfileInstance, err := f.techprofile[intfID].GetTPInstanceFromKVStore(tableID, tpPath)
 	if err != nil { // This should not happen, something wrong in KV backend transaction
 		log.Errorw("Error in fetching tech profile instance from KV store", log.Fields{"tableID": tableID, "path": tpPath})
 		return nil, nil
 	}
-	if tech_profile_instance == nil {
+	if techProfileInstance == nil {
 		log.Info("Creating tech profile instance", log.Fields{"path": tpPath})
-		tech_profile_instance = f.techprofile[intfId].CreateTechProfInstance(tableID, uni, intfId)
-		if tech_profile_instance == nil {
+		techProfileInstance = f.techprofile[intfID].CreateTechProfInstance(tableID, uni, intfID)
+		if techProfileInstance == nil {
 			log.Error("Tech-profile-instance-creation-failed")
 			return nil, nil
 		}
@@ -250,107 +290,107 @@
 		log.Debugw("Tech-profile-instance-already-exist-for-given port-name", log.Fields{"uni": uni})
 	}
 	// Get upstream and downstream scheduler protos
-	us_scheduler := f.techprofile[intfId].GetUsScheduler(tech_profile_instance)
-	ds_scheduler := f.techprofile[intfId].GetDsScheduler(tech_profile_instance)
+	usScheduler := f.techprofile[intfID].GetUsScheduler(techProfileInstance)
+	dsScheduler := f.techprofile[intfID].GetDsScheduler(techProfileInstance)
 	// Get TCONTS protos
-	tconts := f.techprofile[intfId].GetTconts(tech_profile_instance, us_scheduler, ds_scheduler)
+	tconts := f.techprofile[intfID].GetTconts(techProfileInstance, usScheduler, dsScheduler)
 	if len(tconts) == 0 {
 		log.Error("TCONTS not found ")
 		return nil, nil
 	}
 	log.Debugw("Sending Create tcont to device",
-		log.Fields{"onu": onuId, "uni": uniId, "portNo": "", "tconts": tconts})
+		log.Fields{"onu": onuID, "uni": uniID, "portNo": "", "tconts": tconts})
 	if _, err := f.deviceHandler.Client.CreateTconts(context.Background(),
-		&openolt_pb2.Tconts{IntfId: intfId,
-			OnuId:  onuId,
-			UniId:  uniId,
+		&openoltpb2.Tconts{IntfId: intfID,
+			OnuId:  onuID,
+			UniId:  uniID,
 			PortNo: uniPort,
 			Tconts: tconts}); err != nil {
 		log.Errorw("Error while creating TCONT in device", log.Fields{"error": err})
 		return nil, nil
 	}
-	allocID = append(allocID, tech_profile_instance.UsScheduler.AllocID)
-	for _, gem := range tech_profile_instance.UpstreamGemPortAttributeList {
+	allocID = append(allocID, techProfileInstance.UsScheduler.AllocID)
+	for _, gem := range techProfileInstance.UpstreamGemPortAttributeList {
 		gemPortIDs = append(gemPortIDs, gem.GemportID)
 	}
 	log.Debugw("Allocated Tcont and GEM ports", log.Fields{"allocID": allocID, "gemports": gemPortIDs})
 	// Send Tconts and GEM ports to KV store
-	f.storeTcontsGEMPortsIntoKVStore(intfId, onuId, uniId, allocID, gemPortIDs)
+	f.storeTcontsGEMPortsIntoKVStore(intfID, onuID, uniID, allocID, gemPortIDs)
 	return allocID, gemPortIDs
 }
 
-func (f *OpenOltFlowMgr) storeTcontsGEMPortsIntoKVStore(intfId uint32, onuId uint32, uniId uint32, allocID []uint32, gemPortIDs []uint32) {
+func (f *OpenOltFlowMgr) storeTcontsGEMPortsIntoKVStore(intfID uint32, onuID uint32, uniID uint32, allocID []uint32, gemPortIDs []uint32) {
 
 	log.Debugw("Storing allocated Tconts and GEM ports into KV store",
-		log.Fields{"intfId": intfId, "onuId": onuId, "uniId": uniId, "allocID": allocID, "gemPortIDs": gemPortIDs})
+		log.Fields{"intfId": intfID, "onuId": onuID, "uniId": uniID, "allocID": allocID, "gemPortIDs": gemPortIDs})
 	/* Update the allocated alloc_id and gem_port_id for the ONU/UNI to KV store  */
-	if err := f.resourceMgr.UpdateAllocIdsForOnu(intfId, onuId, uniId, allocID); err != nil {
+	if err := f.resourceMgr.UpdateAllocIdsForOnu(intfID, onuID, uniID, allocID); err != nil {
 		log.Error("Errow while uploading allocID to KV store")
 	}
-	if err := f.resourceMgr.UpdateGEMPortIDsForOnu(intfId, onuId, uniId, gemPortIDs); err != nil {
+	if err := f.resourceMgr.UpdateGEMPortIDsForOnu(intfID, onuID, uniID, gemPortIDs); err != nil {
 		log.Error("Errow while uploading GEMports to KV store")
 	}
-	if err := f.resourceMgr.UpdateGEMportsPonportToOnuMapOnKVStore(gemPortIDs, intfId, onuId, uniId); err != nil {
+	if err := f.resourceMgr.UpdateGEMportsPonportToOnuMapOnKVStore(gemPortIDs, intfID, onuID, uniID); err != nil {
 		log.Error("Errow while uploading gemtopon map to KV store")
 	}
 	log.Debug("Stored tconts and GEM into KV store successfully")
 	for _, gemPort := range gemPortIDs {
-		f.addGemPortToOnuInfoMap(intfId, onuId, gemPort)
+		f.addGemPortToOnuInfoMap(intfID, onuID, gemPort)
 	}
 }
 
 func (f *OpenOltFlowMgr) populateTechProfilePerPonPort() error {
 	for _, techRange := range f.resourceMgr.DevInfo.Ranges {
-		for intfId := range techRange.IntfIds {
-			f.techprofile = append(f.techprofile, f.resourceMgr.ResourceMgrs[uint32(intfId)].TechProfileMgr)
+		for intfID := range techRange.IntfIds {
+			f.techprofile = append(f.techprofile, f.resourceMgr.ResourceMgrs[uint32(intfID)].TechProfileMgr)
 		}
 	}
 	//Make sure we have as many tech_profiles as there are pon ports on the device
 	if len(f.techprofile) != int(f.resourceMgr.DevInfo.GetPonPorts()) {
 		log.Errorw("Error while populating techprofile",
 			log.Fields{"numofTech": len(f.techprofile), "numPonPorts": f.resourceMgr.DevInfo.GetPonPorts()})
-		return errors.New("Error while populating techprofile mgrs")
+		return errors.New("error while populating techprofile mgrs")
 	}
 	log.Infow("Populated techprofile per ponport successfully",
 		log.Fields{"numofTech": len(f.techprofile), "numPonPorts": f.resourceMgr.DevInfo.GetPonPorts()})
 	return nil
 }
 
-func (f *OpenOltFlowMgr) addUpstreamDataFlow(intfId uint32, onuId uint32, uniId uint32,
+func (f *OpenOltFlowMgr) addUpstreamDataFlow(intfID uint32, onuID uint32, uniID uint32,
 	portNo uint32, uplinkClassifier map[string]interface{},
 	uplinkAction map[string]interface{}, logicalFlow *ofp.OfpFlowStats,
-	allocId uint32, gemportId uint32) {
-	uplinkClassifier[PACKET_TAG_TYPE] = SINGLE_TAG
+	allocID uint32, gemportID uint32) {
+	uplinkClassifier[PacketTagType] = SingleTag
 	log.Debugw("Adding upstream data flow", log.Fields{"uplinkClassifier": uplinkClassifier, "uplinkAction": uplinkAction})
-	f.addHSIAFlow(intfId, onuId, uniId, portNo, uplinkClassifier, uplinkAction,
-		UPSTREAM, logicalFlow, allocId, gemportId)
+	f.addHSIAFlow(intfID, onuID, uniID, portNo, uplinkClassifier, uplinkAction,
+		UPSTREAM, logicalFlow, allocID, gemportID)
 	/* TODO: Install Secondary EAP on the subscriber vlan */
 }
 
-func (f *OpenOltFlowMgr) addDownstreamDataFlow(intfId uint32, onuId uint32, uniId uint32,
+func (f *OpenOltFlowMgr) addDownstreamDataFlow(intfID uint32, onuID uint32, uniID uint32,
 	portNo uint32, downlinkClassifier map[string]interface{},
 	downlinkAction map[string]interface{}, logicalFlow *ofp.OfpFlowStats,
-	allocId uint32, gemportId uint32) {
-	downlinkClassifier[PACKET_TAG_TYPE] = DOUBLE_TAG
+	allocID uint32, gemportID uint32) {
+	downlinkClassifier[PacketTagType] = DoubleTag
 	log.Debugw("Adding downstream data flow", log.Fields{"downlinkClassifier": downlinkClassifier,
 		"downlinkAction": downlinkAction})
 	// Ignore private VLAN flow given by decomposer, cannot do anything with this flow
-	if uint32(downlinkClassifier[METADATA].(uint64)) == MkUniPortNum(intfId, onuId, uniId) &&
-		downlinkClassifier[VLAN_VID] == (uint32(ofp.OfpVlanId_OFPVID_PRESENT)|4000) {
+	if uint32(downlinkClassifier[METADATA].(uint64)) == MkUniPortNum(intfID, onuID, uniID) &&
+		downlinkClassifier[VlanVid] == (uint32(ofp.OfpVlanId_OFPVID_PRESENT)|4000) {
 		log.Infow("EAPOL DL flow , Already added ,ignoring it", log.Fields{"downlinkClassifier": downlinkClassifier,
 			"downlinkAction": downlinkAction})
 		return
 	}
 	/* Already this info available classifier? */
-	downlinkAction[POP_VLAN] = true
-	downlinkAction[VLAN_VID] = downlinkClassifier[VLAN_VID]
-	f.addHSIAFlow(intfId, onuId, uniId, portNo, downlinkClassifier, downlinkAction,
-		DOWNSTREAM, logicalFlow, allocId, gemportId)
+	downlinkAction[PopVlan] = true
+	downlinkAction[VlanVid] = downlinkClassifier[VlanVid]
+	f.addHSIAFlow(intfID, onuID, uniID, portNo, downlinkClassifier, downlinkAction,
+		DOWNSTREAM, logicalFlow, allocID, gemportID)
 }
 
-func (f *OpenOltFlowMgr) addHSIAFlow(intfId uint32, onuId uint32, uniId uint32, portNo uint32, classifier map[string]interface{},
+func (f *OpenOltFlowMgr) addHSIAFlow(intfID uint32, onuID uint32, uniID uint32, portNo uint32, classifier map[string]interface{},
 	action map[string]interface{}, direction string, logicalFlow *ofp.OfpFlowStats,
-	allocId uint32, gemPortId uint32) {
+	allocID uint32, gemPortID uint32) {
 	/* One of the OLT platform (Broadcom BAL) requires that symmetric
 	   flows require the same flow_id to be used across UL and DL.
 	   Since HSIA flow is the only symmetric flow currently, we need to
@@ -358,18 +398,18 @@
 	   takes priority over flow_cookie to find any available HSIA_FLOW
 	   id for the ONU.
 	*/
-	log.Debugw("Adding HSIA flow", log.Fields{"intfId": intfId, "onuId": onuId, "uniId": uniId, "classifier": classifier,
-		"action": action, "direction": direction, "allocId": allocId, "gemPortId": gemPortId,
+	log.Debugw("Adding HSIA flow", log.Fields{"intfId": intfID, "onuId": onuID, "uniId": uniID, "classifier": classifier,
+		"action": action, "direction": direction, "allocId": allocID, "gemPortId": gemPortID,
 		"logicalFlow": *logicalFlow})
 	flowCategory := "HSIA"
-	flowStoreCookie := getFlowStoreCookie(classifier, gemPortId)
-	flowId, err := f.resourceMgr.GetFlowID(intfId, onuId, uniId, flowStoreCookie, flowCategory)
+	flowStoreCookie := getFlowStoreCookie(classifier, gemPortID)
+	flowID, err := f.resourceMgr.GetFlowID(intfID, onuID, uniID, flowStoreCookie, flowCategory)
 	if err != nil {
 		log.Errorw("Flow id unavailable for HSIA flow", log.Fields{"direction": direction})
 		return
 	}
-	var classifierProto *openolt_pb2.Classifier
-	var actionProto *openolt_pb2.Action
+	var classifierProto *openoltpb2.Classifier
+	var actionProto *openoltpb2.Action
 	if classifierProto = makeOpenOltClassifierField(classifier); classifierProto == nil {
 		log.Error("Error in making classifier protobuf for hsia flow")
 		return
@@ -380,15 +420,15 @@
 		return
 	}
 	log.Debugw("Created action proto", log.Fields{"action": *actionProto})
-	networkIntfId := f.deviceHandler.nniIntfId
-	flow := openolt_pb2.Flow{AccessIntfId: int32(intfId),
-		OnuId:         int32(onuId),
-		UniId:         int32(uniId),
-		FlowId:        flowId,
+	networkIntfID := f.deviceHandler.nniIntfID
+	flow := openoltpb2.Flow{AccessIntfId: int32(intfID),
+		OnuId:         int32(onuID),
+		UniId:         int32(uniID),
+		FlowId:        flowID,
 		FlowType:      direction,
-		AllocId:       int32(allocId),
-		NetworkIntfId: int32(networkIntfId),
-		GemportId:     int32(gemPortId),
+		AllocId:       int32(allocID),
+		NetworkIntfId: int32(networkIntfID),
+		GemportId:     int32(gemPortID),
 		Classifier:    classifierProto,
 		Action:        actionProto,
 		Priority:      int32(logicalFlow.Priority),
@@ -396,7 +436,7 @@
 		PortNo:        portNo}
 	if ok := f.addFlowToDevice(logicalFlow, &flow); ok {
 		log.Debug("HSIA flow added to device successfully", log.Fields{"direction": direction})
-		flowsToKVStore := f.getUpdatedFlowInfo(&flow, flowStoreCookie, "HSIA", flowId)
+		flowsToKVStore := f.getUpdatedFlowInfo(&flow, flowStoreCookie, "HSIA", flowID)
 		if err := f.updateFlowInfoToKVStore(flow.AccessIntfId,
 			flow.OnuId,
 			flow.UniId,
@@ -406,29 +446,29 @@
 		}
 	}
 }
-func (f *OpenOltFlowMgr) addDHCPTrapFlow(intfId uint32, onuId uint32, uniId uint32, portNo uint32, classifier map[string]interface{}, action map[string]interface{}, logicalFlow *ofp.OfpFlowStats, allocId uint32, gemPortId uint32) {
+func (f *OpenOltFlowMgr) addDHCPTrapFlow(intfID uint32, onuID uint32, uniID uint32, portNo uint32, classifier map[string]interface{}, action map[string]interface{}, logicalFlow *ofp.OfpFlowStats, allocID uint32, gemPortID uint32) {
 
-	var dhcpFlow openolt_pb2.Flow
-	var actionProto *openolt_pb2.Action
-	var classifierProto *openolt_pb2.Classifier
+	var dhcpFlow openoltpb2.Flow
+	var actionProto *openoltpb2.Action
+	var classifierProto *openoltpb2.Classifier
 
 	// Clear the action map
 	for k := range action {
 		delete(action, k)
 	}
 
-	action[TRAP_TO_HOST] = true
-	classifier[UDP_SRC] = uint32(68)
-	classifier[UDP_DST] = uint32(67)
-	classifier[PACKET_TAG_TYPE] = SINGLE_TAG
-	delete(classifier, VLAN_VID)
+	action[TrapToHost] = true
+	classifier[UDPSrc] = uint32(68)
+	classifier[UDPDst] = uint32(67)
+	classifier[PacketTagType] = SingleTag
+	delete(classifier, VlanVid)
 
-	flowStoreCookie := getFlowStoreCookie(classifier, gemPortId)
+	flowStoreCookie := getFlowStoreCookie(classifier, gemPortID)
 
-	flowID, err := f.resourceMgr.GetFlowID(intfId, onuId, uniId, flowStoreCookie, "")
+	flowID, err := f.resourceMgr.GetFlowID(intfID, onuID, uniID, flowStoreCookie, "")
 
 	if err != nil {
-		log.Errorw("flowId unavailable for UL EAPOL", log.Fields{"intfId": intfId, "onuId": onuId, "flowStoreCookie": flowStoreCookie})
+		log.Errorw("flowId unavailable for UL EAPOL", log.Fields{"intfId": intfID, "onuId": onuID, "flowStoreCookie": flowStoreCookie})
 		return
 	}
 
@@ -443,16 +483,16 @@
 		log.Error("Error in making action protobuf for ul flow")
 		return
 	}
-	networkIntfId := f.deviceHandler.nniIntfId
+	networkIntfID := f.deviceHandler.nniIntfID
 
-	dhcpFlow = openolt_pb2.Flow{AccessIntfId: int32(intfId),
-		OnuId:         int32(onuId),
-		UniId:         int32(uniId),
+	dhcpFlow = openoltpb2.Flow{AccessIntfId: int32(intfID),
+		OnuId:         int32(onuID),
+		UniId:         int32(uniID),
 		FlowId:        flowID,
 		FlowType:      UPSTREAM,
-		AllocId:       int32(allocId),
-		NetworkIntfId: int32(networkIntfId),
-		GemportId:     int32(gemPortId),
+		AllocId:       int32(allocID),
+		NetworkIntfId: int32(networkIntfID),
+		GemportId:     int32(gemPortID),
 		Classifier:    classifierProto,
 		Action:        actionProto,
 		Priority:      int32(logicalFlow.Priority),
@@ -474,33 +514,33 @@
 	return
 }
 
-// Add EAPOL to  device
-func (f *OpenOltFlowMgr) addEAPOLFlow(intfId uint32, onuId uint32, uniId uint32, portNo uint32, logicalFlow *ofp.OfpFlowStats, allocId uint32, gemPortId uint32, vlanId uint32) {
-	log.Debugw("Adding EAPOL to device", log.Fields{"intfId": intfId, "onuId": onuId, "portNo": portNo, "allocId": allocId, "gemPortId": gemPortId, "vlanId": vlanId, "flow": logicalFlow})
+// Add EAPOL flow to  device with mac, vlanId as classifier for upstream and downstream
+func (f *OpenOltFlowMgr) addEAPOLFlow(intfID uint32, onuID uint32, uniID uint32, portNo uint32, logicalFlow *ofp.OfpFlowStats, allocID uint32, gemPortID uint32, vlanID uint32) {
+	log.Debugw("Adding EAPOL to device", log.Fields{"intfId": intfID, "onuId": onuID, "portNo": portNo, "allocId": allocID, "gemPortId": gemPortID, "vlanId": vlanID, "flow": logicalFlow})
 
 	uplinkClassifier := make(map[string]interface{})
 	uplinkAction := make(map[string]interface{})
 	downlinkClassifier := make(map[string]interface{})
 	downlinkAction := make(map[string]interface{})
-	var upstreamFlow openolt_pb2.Flow
-	var downstreamFlow openolt_pb2.Flow
+	var upstreamFlow openoltpb2.Flow
+	var downstreamFlow openoltpb2.Flow
 
 	// Fill Classfier
-	uplinkClassifier[ETH_TYPE] = uint32(EAP_ETH_TYPE)
-	uplinkClassifier[PACKET_TAG_TYPE] = SINGLE_TAG
-	uplinkClassifier[VLAN_VID] = vlanId
+	uplinkClassifier[EthType] = uint32(EapEthType)
+	uplinkClassifier[PacketTagType] = SingleTag
+	uplinkClassifier[VlanVid] = vlanID
 	// Fill action
-	uplinkAction[TRAP_TO_HOST] = true
-	flowStoreCookie := getFlowStoreCookie(uplinkClassifier, gemPortId)
+	uplinkAction[TrapToHost] = true
+	flowStoreCookie := getFlowStoreCookie(uplinkClassifier, gemPortID)
 	//Add Uplink EAPOL Flow
-	uplinkFlowId, err := f.resourceMgr.GetFlowID(intfId, onuId, uniId, flowStoreCookie, "")
+	uplinkFlowID, err := f.resourceMgr.GetFlowID(intfID, onuID, uniID, flowStoreCookie, "")
 	if err != nil {
-		log.Errorw("flowId unavailable for UL EAPOL", log.Fields{"intfId": intfId, "onuId": onuId, "flowStoreCookie": flowStoreCookie})
+		log.Errorw("flowId unavailable for UL EAPOL", log.Fields{"intfId": intfID, "onuId": onuID, "flowStoreCookie": flowStoreCookie})
 		return
 	}
-	var classifierProto *openolt_pb2.Classifier
-	var actionProto *openolt_pb2.Action
-	log.Debugw("Creating UL EAPOL flow", log.Fields{"ul_classifier": uplinkClassifier, "ul_action": uplinkAction, "uplinkFlowId": uplinkFlowId})
+	var classifierProto *openoltpb2.Classifier
+	var actionProto *openoltpb2.Action
+	log.Debugw("Creating UL EAPOL flow", log.Fields{"ul_classifier": uplinkClassifier, "ul_action": uplinkAction, "uplinkFlowId": uplinkFlowID})
 
 	if classifierProto = makeOpenOltClassifierField(uplinkClassifier); classifierProto == nil {
 		log.Error("Error in making classifier protobuf for ul flow")
@@ -512,15 +552,15 @@
 		return
 	}
 	log.Debugw("Created action proto", log.Fields{"action": *actionProto})
-	networkIntfId := f.deviceHandler.nniIntfId
-	upstreamFlow = openolt_pb2.Flow{AccessIntfId: int32(intfId),
-		OnuId:         int32(onuId),
-		UniId:         int32(uniId),
-		FlowId:        uplinkFlowId,
+	networkIntfID := f.deviceHandler.nniIntfID
+	upstreamFlow = openoltpb2.Flow{AccessIntfId: int32(intfID),
+		OnuId:         int32(onuID),
+		UniId:         int32(uniID),
+		FlowId:        uplinkFlowID,
 		FlowType:      UPSTREAM,
-		AllocId:       int32(allocId),
-		NetworkIntfId: int32(networkIntfId),
-		GemportId:     int32(gemPortId),
+		AllocId:       int32(allocID),
+		NetworkIntfId: int32(networkIntfID),
+		GemportId:     int32(gemPortID),
 		Classifier:    classifierProto,
 		Action:        actionProto,
 		Priority:      int32(logicalFlow.Priority),
@@ -529,7 +569,7 @@
 	if ok := f.addFlowToDevice(logicalFlow, &upstreamFlow); ok {
 		log.Debug("EAPOL UL flow added to device successfully")
 		flowCategory := "EAPOL"
-		flowsToKVStore := f.getUpdatedFlowInfo(&upstreamFlow, flowStoreCookie, flowCategory, uplinkFlowId)
+		flowsToKVStore := f.getUpdatedFlowInfo(&upstreamFlow, flowStoreCookie, flowCategory, uplinkFlowID)
 		if err := f.updateFlowInfoToKVStore(upstreamFlow.AccessIntfId,
 			upstreamFlow.OnuId,
 			upstreamFlow.UniId,
@@ -541,7 +581,7 @@
 		}
 	}
 
-	if vlanId == DEFAULT_MGMT_VLAN {
+	if vlanID == DefaultMgmtVlan {
 		/* Add Downstream EAPOL Flow, Only for first EAP flow (BAL
 		# requirement)
 		# On one of the platforms (Broadcom BAL), when same DL classifier
@@ -551,8 +591,8 @@
 		# onu_id and uniId is used.
 		# uniId defaults to 0, so add 1 to it.
 		*/
-		log.Debugw("Creating DL EAPOL flow with default vlan", log.Fields{"vlan": vlanId})
-		specialVlanDlFlow := 4090 - intfId*onuId*(uniId+1)
+		log.Debugw("Creating DL EAPOL flow with default vlan", log.Fields{"vlan": vlanID})
+		specialVlanDlFlow := 4090 - intfID*onuID*(uniID+1)
 		// Assert that we do not generate invalid vlans under no condition
 		if specialVlanDlFlow <= 2 {
 			log.Fatalw("invalid-vlan-generated", log.Fields{"vlan": specialVlanDlFlow})
@@ -560,20 +600,20 @@
 		}
 		log.Debugw("specialVlanEAPOLDlFlow:", log.Fields{"dl_vlan": specialVlanDlFlow})
 		// Fill Classfier
-		downlinkClassifier[PACKET_TAG_TYPE] = SINGLE_TAG
-		downlinkClassifier[VLAN_VID] = uint32(specialVlanDlFlow)
+		downlinkClassifier[PacketTagType] = SingleTag
+		downlinkClassifier[VlanVid] = uint32(specialVlanDlFlow)
 		// Fill action
-		downlinkAction[PUSH_VLAN] = true
-		downlinkAction[VLAN_VID] = vlanId
-		flowStoreCookie := getFlowStoreCookie(downlinkClassifier, gemPortId)
-		downlinkFlowId, err := f.resourceMgr.GetFlowID(intfId, onuId, uniId, flowStoreCookie, "")
+		downlinkAction[PushVlan] = true
+		downlinkAction[VlanVid] = vlanID
+		flowStoreCookie := getFlowStoreCookie(downlinkClassifier, gemPortID)
+		downlinkFlowID, err := f.resourceMgr.GetFlowID(intfID, onuID, uniID, flowStoreCookie, "")
 		if err != nil {
 			log.Errorw("flowId unavailable for DL EAPOL",
-				log.Fields{"intfId": intfId, "onuId": onuId, "flowStoreCookie": flowStoreCookie})
+				log.Fields{"intfId": intfID, "onuId": onuID, "flowStoreCookie": flowStoreCookie})
 			return
 		}
 		log.Debugw("Creating DL EAPOL flow",
-			log.Fields{"dl_classifier": downlinkClassifier, "dl_action": downlinkAction, "downlinkFlowId": downlinkFlowId})
+			log.Fields{"dl_classifier": downlinkClassifier, "dl_action": downlinkAction, "downlinkFlowId": downlinkFlowID})
 		if classifierProto = makeOpenOltClassifierField(downlinkClassifier); classifierProto == nil {
 			log.Error("Error in making classifier protobuf for downlink flow")
 			return
@@ -583,14 +623,14 @@
 			return
 		}
 		// Downstream flow in grpc protobuf
-		downstreamFlow = openolt_pb2.Flow{AccessIntfId: int32(intfId),
-			OnuId:         int32(onuId),
-			UniId:         int32(uniId),
-			FlowId:        downlinkFlowId,
+		downstreamFlow = openoltpb2.Flow{AccessIntfId: int32(intfID),
+			OnuId:         int32(onuID),
+			UniId:         int32(uniID),
+			FlowId:        downlinkFlowID,
 			FlowType:      DOWNSTREAM,
-			AllocId:       int32(allocId),
-			NetworkIntfId: int32(networkIntfId),
-			GemportId:     int32(gemPortId),
+			AllocId:       int32(allocID),
+			NetworkIntfId: int32(networkIntfID),
+			GemportId:     int32(gemPortID),
 			Classifier:    classifierProto,
 			Action:        actionProto,
 			Priority:      int32(logicalFlow.Priority),
@@ -599,7 +639,7 @@
 		if ok := f.addFlowToDevice(logicalFlow, &downstreamFlow); ok {
 			log.Debug("EAPOL DL flow added to device successfully")
 			flowCategory := ""
-			flowsToKVStore := f.getUpdatedFlowInfo(&downstreamFlow, flowStoreCookie, flowCategory, downlinkFlowId)
+			flowsToKVStore := f.getUpdatedFlowInfo(&downstreamFlow, flowStoreCookie, flowCategory, downlinkFlowID)
 			if err := f.updateFlowInfoToKVStore(downstreamFlow.AccessIntfId,
 				downstreamFlow.OnuId,
 				downstreamFlow.UniId,
@@ -611,46 +651,46 @@
 			}
 		}
 	} else {
-		log.Infow("EAPOL flow with non-default mgmt vlan is not supported", log.Fields{"vlanId": vlanId})
+		log.Infow("EAPOL flow with non-default mgmt vlan is not supported", log.Fields{"vlanId": vlanID})
 		return
 	}
 	log.Debugw("Added EAPOL flows to device successfully", log.Fields{"flow": logicalFlow})
 }
 
-func makeOpenOltClassifierField(classifierInfo map[string]interface{}) *openolt_pb2.Classifier {
-	var classifier openolt_pb2.Classifier
-	if etherType, ok := classifierInfo[ETH_TYPE]; ok {
+func makeOpenOltClassifierField(classifierInfo map[string]interface{}) *openoltpb2.Classifier {
+	var classifier openoltpb2.Classifier
+	if etherType, ok := classifierInfo[EthType]; ok {
 		classifier.EthType = etherType.(uint32)
 	}
-	if ipProto, ok := classifierInfo[IP_PROTO]; ok {
+	if ipProto, ok := classifierInfo[IPProto]; ok {
 		classifier.IpProto = ipProto.(uint32)
 	}
-	if vlanId, ok := classifierInfo[VLAN_VID]; ok {
-		classifier.OVid = (vlanId.(uint32)) & 0xFFF
+	if vlanID, ok := classifierInfo[VlanVid]; ok {
+		classifier.OVid = (vlanID.(uint32)) & 0xFFF
 	}
 	if metadata, ok := classifierInfo[METADATA]; ok { // TODO: Revisit
 		classifier.IVid = uint32(metadata.(uint64))
 	}
-	if vlanPcp, ok := classifierInfo[VLAN_PCP]; ok {
+	if vlanPcp, ok := classifierInfo[VlanPcp]; ok {
 		classifier.OPbits = vlanPcp.(uint32)
 	}
-	if udpSrc, ok := classifierInfo[UDP_SRC]; ok {
+	if udpSrc, ok := classifierInfo[UDPSrc]; ok {
 		classifier.SrcPort = udpSrc.(uint32)
 	}
-	if udpDst, ok := classifierInfo[UDP_DST]; ok {
+	if udpDst, ok := classifierInfo[UDPDst]; ok {
 		classifier.DstPort = udpDst.(uint32)
 	}
-	if ipv4Dst, ok := classifierInfo[IPV4_DST]; ok {
+	if ipv4Dst, ok := classifierInfo[Ipv4Dst]; ok {
 		classifier.DstIp = ipv4Dst.(uint32)
 	}
-	if ipv4Src, ok := classifierInfo[IPV4_SRC]; ok {
+	if ipv4Src, ok := classifierInfo[Ipv4Src]; ok {
 		classifier.SrcIp = ipv4Src.(uint32)
 	}
-	if pktTagType, ok := classifierInfo[PACKET_TAG_TYPE]; ok {
-		if pktTagType.(string) == SINGLE_TAG {
-			classifier.PktTagType = SINGLE_TAG
-		} else if pktTagType.(string) == DOUBLE_TAG {
-			classifier.PktTagType = DOUBLE_TAG
+	if pktTagType, ok := classifierInfo[PacketTagType]; ok {
+		if pktTagType.(string) == SingleTag {
+			classifier.PktTagType = SingleTag
+		} else if pktTagType.(string) == DoubleTag {
+			classifier.PktTagType = DoubleTag
 		} else if pktTagType.(string) == UNTAGGED {
 			classifier.PktTagType = UNTAGGED
 		} else {
@@ -661,18 +701,18 @@
 	return &classifier
 }
 
-func makeOpenOltActionField(actionInfo map[string]interface{}) *openolt_pb2.Action {
-	var actionCmd openolt_pb2.ActionCmd
-	var action openolt_pb2.Action
+func makeOpenOltActionField(actionInfo map[string]interface{}) *openoltpb2.Action {
+	var actionCmd openoltpb2.ActionCmd
+	var action openoltpb2.Action
 	action.Cmd = &actionCmd
-	if _, ok := actionInfo[POP_VLAN]; ok {
-		action.OVid = actionInfo[VLAN_VID].(uint32)
+	if _, ok := actionInfo[PopVlan]; ok {
+		action.OVid = actionInfo[VlanVid].(uint32)
 		action.Cmd.RemoveOuterTag = true
-	} else if _, ok := actionInfo[PUSH_VLAN]; ok {
-		action.OVid = actionInfo[VLAN_VID].(uint32)
+	} else if _, ok := actionInfo[PushVlan]; ok {
+		action.OVid = actionInfo[VlanVid].(uint32)
 		action.Cmd.AddOuterTag = true
-	} else if _, ok := actionInfo[TRAP_TO_HOST]; ok {
-		action.Cmd.TrapToHost = actionInfo[TRAP_TO_HOST].(bool)
+	} else if _, ok := actionInfo[TrapToHost]; ok {
+		action.Cmd.TrapToHost = actionInfo[TrapToHost].(bool)
 	} else {
 		log.Errorw("Invalid-action-field", log.Fields{"action": actionInfo})
 		return nil
@@ -680,17 +720,17 @@
 	return &action
 }
 
-func (f *OpenOltFlowMgr) getTPpath(intfId uint32, uni string) string {
+func (f *OpenOltFlowMgr) getTPpath(intfID uint32, uni string) string {
 	/*
 	   FIXME
 	   Should get Table id form the flow, as of now hardcoded to DEFAULT_TECH_PROFILE_TABLE_ID (64)
 	   'tp_path' contains the suffix part of the tech_profile_instance path. The prefix to the 'tp_path' should be set to
 	   TechProfile.KV_STORE_TECH_PROFILE_PATH_PREFIX by the ONU adapter.
 	*/
-	return f.techprofile[intfId].GetTechProfileInstanceKVPath(tp.DEFAULT_TECH_PROFILE_TABLE_ID, uni)
+	return f.techprofile[intfID].GetTechProfileInstanceKVPath(tp.DEFAULT_TECH_PROFILE_TABLE_ID, uni)
 }
 
-func getFlowStoreCookie(classifier map[string]interface{}, gemPortId uint32) uint64 {
+func getFlowStoreCookie(classifier map[string]interface{}, gemPortID uint32) uint64 {
 	if len(classifier) == 0 { // should never happen
 		log.Error("Invalid classfier object")
 		return 0
@@ -704,33 +744,35 @@
 		return 0
 	}
 	flowString = string(jsonData)
-	if gemPortId != 0 {
-		flowString = fmt.Sprintf("%s%s", string(jsonData), string(gemPortId))
+	if gemPortID != 0 {
+		flowString = fmt.Sprintf("%s%s", string(jsonData), string(gemPortID))
 	}
 	h := md5.New()
-	h.Write([]byte(flowString))
+	_, _ = h.Write([]byte(flowString))
 	hash := big.NewInt(0)
 	hash.SetBytes(h.Sum(nil))
 	return hash.Uint64()
 }
 
-func (f *OpenOltFlowMgr) getUpdatedFlowInfo(flow *openolt_pb2.Flow, flowStoreCookie uint64, flowCategory string, deviceFlowId uint32) *[]rsrcMgr.FlowInfo {
-	var flows []rsrcMgr.FlowInfo = []rsrcMgr.FlowInfo{rsrcMgr.FlowInfo{Flow: flow, FlowCategory: flowCategory, FlowStoreCookie: flowStoreCookie}}
-	var intfId uint32
+func (f *OpenOltFlowMgr) getUpdatedFlowInfo(flow *openoltpb2.Flow, flowStoreCookie uint64, flowCategory string, deviceFlowID uint32) *[]rsrcMgr.FlowInfo {
+	var flows = []rsrcMgr.FlowInfo{{Flow: flow, FlowCategory: flowCategory, FlowStoreCookie: flowStoreCookie}}
+	var intfID uint32
 	/* For flows which trap out of the NNI, the AccessIntfId is invalid
 	   (set to -1). In such cases, we need to refer to the NetworkIntfId .
 	*/
 	if flow.AccessIntfId != -1 {
-		intfId = uint32(flow.AccessIntfId)
+		intfID = uint32(flow.AccessIntfId)
 	} else {
-		intfId = uint32(flow.NetworkIntfId)
+		intfID = uint32(flow.NetworkIntfId)
 	}
-	existingFlows := f.resourceMgr.GetFlowIDInfo(intfId, uint32(flow.OnuId), uint32(flow.UniId), flow.FlowId)
+	// Get existing flows matching flowid for given subscriber from KV store
+	existingFlows := f.resourceMgr.GetFlowIDInfo(intfID, uint32(flow.OnuId), uint32(flow.UniId), flow.FlowId)
 	if existingFlows != nil {
 		log.Debugw("Flow exists for given flowID, appending it to current flow", log.Fields{"flowID": flow.FlowId})
-		for _, f := range *existingFlows {
-			flows = append(flows, f)
-		}
+		//for _, f := range *existingFlows {
+		//	flows = append(flows, f)
+		//}
+		flows = append(flows, *existingFlows...)
 	}
 	log.Debugw("Updated flows for given flowID and onuid", log.Fields{"updatedflow": flows, "flowid": flow.FlowId, "onu": flow.OnuId})
 	return &flows
@@ -759,9 +801,9 @@
 //	return &flows
 //}
 
-func (f *OpenOltFlowMgr) updateFlowInfoToKVStore(intfId int32, onuId int32, uniId int32, flowId uint32, flows *[]rsrcMgr.FlowInfo) error {
+func (f *OpenOltFlowMgr) updateFlowInfoToKVStore(intfID int32, onuID int32, uniID int32, flowID uint32, flows *[]rsrcMgr.FlowInfo) error {
 	log.Debugw("Storing flow(s) into KV store", log.Fields{"flows": *flows})
-	if err := f.resourceMgr.UpdateFlowIDInfo(intfId, onuId, uniId, flowId, flows); err != nil {
+	if err := f.resourceMgr.UpdateFlowIDInfo(intfID, onuID, uniID, flowID, flows); err != nil {
 		log.Debug("Error while Storing flow into KV store")
 		return err
 	}
@@ -769,26 +811,27 @@
 	return nil
 }
 
-func (f *OpenOltFlowMgr) addFlowToDevice(logicalFlow *ofp.OfpFlowStats, deviceFlow *openolt_pb2.Flow) bool {
+func (f *OpenOltFlowMgr) addFlowToDevice(logicalFlow *ofp.OfpFlowStats, deviceFlow *openoltpb2.Flow) bool {
 	log.Debugw("Sending flow to device via grpc", log.Fields{"flow": *deviceFlow})
 	_, err := f.deviceHandler.Client.FlowAdd(context.Background(), deviceFlow)
 	if err != nil {
 		log.Errorw("Failed to Add flow to device", log.Fields{"err": err, "deviceFlow": deviceFlow})
 		return false
 	}
-	log.Debugw("Flow added to device successfuly ", log.Fields{"flow": *deviceFlow})
+	log.Debugw("Flow added to device successfully ", log.Fields{"flow": *deviceFlow})
+	log.Debugw("Flow added to device successfully ", log.Fields{"flow": *deviceFlow})
 	f.registerFlow(logicalFlow, deviceFlow)
 	return true
 }
 
-func (f *OpenOltFlowMgr) removeFlowFromDevice(deviceFlow *openolt_pb2.Flow) bool {
+func (f *OpenOltFlowMgr) removeFlowFromDevice(deviceFlow *openoltpb2.Flow) bool {
 	log.Debugw("Sending flow to device via grpc", log.Fields{"flow": *deviceFlow})
 	_, err := f.deviceHandler.Client.FlowRemove(context.Background(), deviceFlow)
 	if err != nil {
 		log.Errorw("Failed to Remove flow from device", log.Fields{"err": err, "deviceFlow": deviceFlow})
 		return false
 	}
-	log.Debugw("Flow removed from device successfuly ", log.Fields{"flow": *deviceFlow})
+	log.Debugw("Flow removed from device successfully ", log.Fields{"flow": *deviceFlow})
 	return true
 }
 
@@ -813,18 +856,20 @@
 */
 
 func addLLDPFlow(flow *ofp.OfpFlowStats, portNo uint32) {
-	log.Info("Unimplemented")
-}
-func getUniPortPath(intfId uint32, onuId uint32, uniId uint32) string {
-	return fmt.Sprintf("pon-{%d}/onu-{%d}/uni-{%d}", intfId, onuId, uniId)
+	log.Info("unimplemented flow : %v, portNo : %v ", flow, portNo)
 }
 
-func (f *OpenOltFlowMgr) getOnuChildDevice(intfId uint32, onuId uint32) (*voltha.Device, error) {
-	log.Debugw("GetChildDevice", log.Fields{"pon port": intfId, "onuId": onuId})
-	parentPortNo := IntfIdToPortNo(intfId, voltha.Port_PON_OLT)
-	onuDevice := f.deviceHandler.GetChildDevice(parentPortNo, onuId)
+func getUniPortPath(intfID uint32, onuID uint32, uniID uint32) string {
+	return fmt.Sprintf("pon-{%d}/onu-{%d}/uni-{%d}", intfID, onuID, uniID)
+}
+
+//getOnuChildDevice to fetch onu
+func (f *OpenOltFlowMgr) getOnuChildDevice(intfID uint32, onuID uint32) (*voltha.Device, error) {
+	log.Debugw("GetChildDevice", log.Fields{"pon port": intfID, "onuId": onuID})
+	parentPortNo := IntfIDToPortNo(intfID, voltha.Port_PON_OLT)
+	onuDevice := f.deviceHandler.GetChildDevice(parentPortNo, onuID)
 	if onuDevice == nil {
-		log.Errorw("onu not found", log.Fields{"intfId": parentPortNo, "onuId": onuId})
+		log.Errorw("onu not found", log.Fields{"intfId": parentPortNo, "onuId": onuID})
 		return nil, errors.New("onu not found")
 	}
 	log.Debugw("Successfully received child device from core", log.Fields{"child_device": *onuDevice})
@@ -832,41 +877,41 @@
 }
 
 func findNextFlow(flow *ofp.OfpFlowStats) *ofp.OfpFlowStats {
-	log.Info("Unimplemented")
+	log.Info("unimplemented flow : %v", flow)
 	return nil
 }
 
 func getSubscriberVlan(inPort uint32) uint32 {
 	/* For EAPOL case we will use default VLAN , so will implement later if required */
-	log.Info("Unimplemented")
+	log.Info("unimplemented inport %v", inPort)
 	return 0
 }
 
-func (f *OpenOltFlowMgr) clear_flows_and_scheduler_for_logical_port(childDevice *voltha.Device, logicalPort *voltha.LogicalPort) {
-	log.Info("Unimplemented")
+func (f *OpenOltFlowMgr) clearFlowsAndSchedulerForLogicalPort(childDevice *voltha.Device, logicalPort *voltha.LogicalPort) {
+	log.Info("unimplemented device %v, logicalport %v", childDevice, logicalPort)
 }
 
-func (f *OpenOltFlowMgr) decodeStoredId(id uint64) (uint64, string) {
+func (f *OpenOltFlowMgr) decodeStoredID(id uint64) (uint64, string) {
 	if id>>15 == 0x1 {
 		return id & 0x7fff, UPSTREAM
 	}
 	return id, DOWNSTREAM
 }
 
-func (f *OpenOltFlowMgr) clearFlowFromResourceManager(flow *ofp.OfpFlowStats, flowId uint32, flowDirection string) {
-	log.Debugw("clearFlowFromResourceManager", log.Fields{"flowId": flowId, "flowDirection": flowDirection, "flow": *flow})
-	ponIntf, onuId, uniId, err := FlowExtractInfo(flow, flowDirection)
+func (f *OpenOltFlowMgr) clearFlowFromResourceManager(flow *ofp.OfpFlowStats, flowID uint32, flowDirection string) {
+	log.Debugw("clearFlowFromResourceManager", log.Fields{"flowID": flowID, "flowDirection": flowDirection, "flow": *flow})
+	ponIntf, onuID, uniID, err := FlowExtractInfo(flow, flowDirection)
 	if err != nil {
 		log.Error(err)
 		return
 	}
 	log.Debugw("Extracted access info from flow to be deleted",
-		log.Fields{"ponIntf": ponIntf, "onuId": onuId, "uniId": uniId, "flowId": flowId})
+		log.Fields{"ponIntf": ponIntf, "onuID": onuID, "uniID": uniID, "flowID": flowID})
 
-	flowsInfo := f.resourceMgr.GetFlowIDInfo(ponIntf, onuId, uniId, flowId)
+	flowsInfo := f.resourceMgr.GetFlowIDInfo(ponIntf, onuID, uniID, flowID)
 	if flowsInfo == nil {
 		log.Debugw("No FlowInfo found found in KV store",
-			log.Fields{"ponIntf": ponIntf, "onuId": onuId, "uniId": uniId, "flowId": flowId})
+			log.Fields{"ponIntf": ponIntf, "onuID": onuID, "uniID": uniID, "flowID": flowID})
 		return
 	}
 	var updatedFlows []rsrcMgr.FlowInfo
@@ -889,17 +934,18 @@
 		// So the flow should not be freed yet.
 		// For ex: Case of HSIA where same flow is shared
 		// between DS and US.
-		f.updateFlowInfoToKVStore(int32(ponIntf), int32(onuId), int32(uniId), flowId, &updatedFlows)
+		f.updateFlowInfoToKVStore(int32(ponIntf), int32(onuID), int32(uniID), flowID, &updatedFlows)
 		return
 	}
-	log.Debugw("Releasing flow Id to resource manager", log.Fields{"ponIntf": ponIntf, "onuId": onuId, "uniId": uniId, "flowId": flowId})
-	f.resourceMgr.FreeFlowID(ponIntf, onuId, uniId, flowId)
-	flowIds := f.resourceMgr.GetCurrentFlowIDsForOnu(ponIntf, onuId, uniId)
+	log.Debugw("Releasing flow Id to resource manager", log.Fields{"ponIntf": ponIntf, "onuID": onuID, "uniID": uniID, "flowID": flowID})
+	f.resourceMgr.FreeFlowID(ponIntf, onuID, uniID, flowID)
+	flowIds := f.resourceMgr.GetCurrentFlowIDsForOnu(ponIntf, onuID, uniID)
 	if len(flowIds) == 0 {
 		/* TODO: Remove Upstream and Downstream Schedulers */
 	}
 }
 
+//RemoveFlow removes the flow from the device
 func (f *OpenOltFlowMgr) RemoveFlow(flow *ofp.OfpFlowStats) {
 	log.Debugw("Removing Flow", log.Fields{"flow": flow})
 	var deviceFlowsToRemove []ofp.OfpFlowStats
@@ -912,8 +958,8 @@
 	}
 	log.Debugw("Flows to be deleted", log.Fields{"deviceFlowsToRemove": deviceFlowsToRemove})
 	for index, curFlow := range deviceFlowsToRemove {
-		id, direction := f.decodeStoredId(curFlow.GetId())
-		removeFlowMessage := openolt_pb2.Flow{FlowId: uint32(id), FlowType: direction}
+		id, direction := f.decodeStoredID(curFlow.GetId())
+		removeFlowMessage := openoltpb2.Flow{FlowId: uint32(id), FlowType: direction}
 		if ok := f.removeFlowFromDevice(&removeFlowMessage); ok {
 			log.Debug("Flow removed from device successfully")
 			deletedFlowsIdx = append(deletedFlowsIdx, index)
@@ -936,107 +982,25 @@
 	return
 }
 
+// AddFlow add flow to device
 func (f *OpenOltFlowMgr) AddFlow(flow *ofp.OfpFlowStats) {
-	classifierInfo := make(map[string]interface{}, 0)
-	actionInfo := make(map[string]interface{}, 0)
+	classifierInfo := make(map[string]interface{})
+	actionInfo := make(map[string]interface{})
 	log.Debug("Adding Flow", log.Fields{"flow": flow})
 	for _, field := range utils.GetOfbFields(flow) {
-		if field.Type == utils.ETH_TYPE {
-			classifierInfo[ETH_TYPE] = field.GetEthType()
-			log.Debug("field-type-eth-type", log.Fields{"classifierInfo[ETH_TYPE]": classifierInfo[ETH_TYPE].(uint32)})
-		} else if field.Type == utils.IP_PROTO {
-			classifierInfo[IP_PROTO] = field.GetIpProto()
-			log.Debug("field-type-ip-proto", log.Fields{"classifierInfo[IP_PROTO]": classifierInfo[IP_PROTO].(uint32)})
-		} else if field.Type == utils.IN_PORT {
-			classifierInfo[IN_PORT] = field.GetPort()
-			log.Debug("field-type-in-port", log.Fields{"classifierInfo[IN_PORT]": classifierInfo[IN_PORT].(uint32)})
-		} else if field.Type == utils.VLAN_VID {
-			classifierInfo[VLAN_VID] = field.GetVlanVid()
-			log.Debug("field-type-vlan-vid", log.Fields{"classifierInfo[VLAN_VID]": classifierInfo[VLAN_VID].(uint32)})
-		} else if field.Type == utils.VLAN_PCP {
-			classifierInfo[VLAN_PCP] = field.GetVlanPcp()
-			log.Debug("field-type-vlan-pcp", log.Fields{"classifierInfo[VLAN_PCP]": classifierInfo[VLAN_PCP].(uint32)})
-		} else if field.Type == utils.UDP_DST {
-			classifierInfo[UDP_DST] = field.GetUdpDst()
-			log.Debug("field-type-udp-dst", log.Fields{"classifierInfo[UDP_DST]": classifierInfo[UDP_DST].(uint32)})
-		} else if field.Type == utils.UDP_SRC {
-			classifierInfo[UDP_SRC] = field.GetUdpSrc()
-			log.Debug("field-type-udp-src", log.Fields{"classifierInfo[UDP_SRC]": classifierInfo[UDP_SRC].(uint32)})
-		} else if field.Type == utils.IPV4_DST {
-			classifierInfo[IPV4_DST] = field.GetIpv4Dst()
-			log.Debug("field-type-ipv4-dst", log.Fields{"classifierInfo[IPV4_DST]": classifierInfo[IPV4_DST].(uint32)})
-		} else if field.Type == utils.IPV4_SRC {
-			classifierInfo[IPV4_SRC] = field.GetIpv4Src()
-			log.Debug("field-type-ipv4-src", log.Fields{"classifierInfo[IPV4_SRC]": classifierInfo[IPV4_SRC].(uint32)})
-		} else if field.Type == utils.METADATA {
-			classifierInfo[METADATA] = field.GetTableMetadata()
-			log.Debug("field-type-metadata", log.Fields{"classifierInfo[METADATA]": classifierInfo[METADATA].(uint64)})
-		} else if field.Type == utils.TUNNEL_ID {
-			classifierInfo[TUNNEL_ID] = field.GetTunnelId()
-			log.Debug("field-type-tunnelId", log.Fields{"classifierInfo[TUNNEL_ID]": classifierInfo[TUNNEL_ID].(uint64)})
-		} else {
-			log.Errorw("Un supported field type", log.Fields{"type": field.Type})
-			return
-		}
+		f.updateClassifierInfo(field, classifierInfo)
 	}
 	for _, action := range utils.GetActions(flow) {
-		if action.Type == utils.OUTPUT {
-			if out := action.GetOutput(); out != nil {
-				actionInfo[OUTPUT] = out.GetPort()
-				log.Debugw("action-type-output", log.Fields{"out_port": actionInfo[OUTPUT].(uint32)})
-			} else {
-				log.Error("Invalid output port in action")
-				return
-			}
-		} else if action.Type == utils.POP_VLAN {
-			actionInfo[POP_VLAN] = true
-			log.Debugw("action-type-pop-vlan", log.Fields{"in_port": classifierInfo[IN_PORT].(uint32)})
-		} else if action.Type == utils.PUSH_VLAN {
-			if out := action.GetPush(); out != nil {
-				if tpid := out.GetEthertype(); tpid != 0x8100 {
-					log.Errorw("Invalid ethertype in push action", log.Fields{"ethertype": actionInfo[PUSH_VLAN].(int32)})
-				} else {
-					actionInfo[PUSH_VLAN] = true
-					actionInfo[TPID] = tpid
-					log.Debugw("action-type-push-vlan",
-						log.Fields{"push_tpid": actionInfo[TPID].(uint32), "in_port": classifierInfo[IN_PORT].(uint32)})
-				}
-			}
-		} else if action.Type == utils.SET_FIELD {
-			if out := action.GetSetField(); out != nil {
-				if field := out.GetField(); field != nil {
-					if ofClass := field.GetOxmClass(); ofClass != ofp.OfpOxmClass_OFPXMC_OPENFLOW_BASIC {
-						log.Errorw("Invalid openflow class", log.Fields{"class": ofClass})
-						return
-					}
-					/*log.Debugw("action-type-set-field",log.Fields{"field": field, "in_port": classifierInfo[IN_PORT].(uint32)})*/
-					if ofbField := field.GetOfbField(); ofbField != nil {
-						if fieldtype := ofbField.GetType(); fieldtype == ofp.OxmOfbFieldTypes_OFPXMT_OFB_VLAN_VID {
-							if vlan := ofbField.GetVlanVid(); vlan != 0 {
-								actionInfo[VLAN_VID] = vlan & 0xfff
-								log.Debugw("action-set-vlan-vid", log.Fields{"actionInfo[VLAN_VID]": actionInfo[VLAN_VID].(uint32)})
-							} else {
-								log.Error("No Invalid vlan id in set vlan-vid action")
-							}
-						} else {
-							log.Errorw("unsupported-action-set-field-type", log.Fields{"type": fieldtype})
-						}
-					}
-				}
-			}
-		} else {
-			log.Errorw("Un supported action type", log.Fields{"type": action.Type})
-			return
-		}
+		f.updateFlowActionInfo(action, actionInfo, classifierInfo)
 	}
 	/* Controller bound trap flows */
 	if isControllerFlow := IsControllerBoundFlow(actionInfo[OUTPUT].(uint32)); isControllerFlow {
 		log.Debug("Controller bound trap flows, getting inport from tunnelid")
 		/* Get UNI port/ IN Port from tunnel ID field for upstream controller bound flows  */
-		if portType := IntfIdToPortTypeName(classifierInfo[IN_PORT].(uint32)); portType == voltha.Port_PON_OLT {
+		if portType := IntfIDToPortTypeName(classifierInfo[InPort].(uint32)); portType == voltha.Port_PON_OLT {
 			if uniPort := utils.GetChildPortFromTunnelId(flow); uniPort != 0 {
-				classifierInfo[IN_PORT] = uniPort
-				log.Debugw("upstream pon-to-controller-flow,inport-in-tunnelid", log.Fields{"newInPort": classifierInfo[IN_PORT].(uint32), "outPort": actionInfo[OUTPUT].(uint32)})
+				classifierInfo[InPort] = uniPort
+				log.Debugw("upstream pon-to-controller-flow,inport-in-tunnelid", log.Fields{"newInPort": classifierInfo[InPort].(uint32), "outPort": actionInfo[OUTPUT].(uint32)})
 			} else {
 				log.Error("upstream pon-to-controller-flow, NO-inport-in-tunnelid")
 				return
@@ -1045,32 +1009,32 @@
 	} else {
 		log.Debug("Non-Controller flows, getting uniport from tunnelid")
 		// Downstream flow from NNI to PON port , Use tunnel ID as new OUT port / UNI port
-		if portType := IntfIdToPortTypeName(actionInfo[OUTPUT].(uint32)); portType == voltha.Port_PON_OLT {
+		if portType := IntfIDToPortTypeName(actionInfo[OUTPUT].(uint32)); portType == voltha.Port_PON_OLT {
 			if uniPort := utils.GetChildPortFromTunnelId(flow); uniPort != 0 {
 				actionInfo[OUTPUT] = uniPort
 				log.Debugw("downstream-nni-to-pon-port-flow, outport-in-tunnelid", log.Fields{"newOutPort": actionInfo[OUTPUT].(uint32), "outPort": actionInfo[OUTPUT].(uint32)})
 			} else {
-				log.Debug("downstream-nni-to-pon-port-flow, no-outport-in-tunnelid", log.Fields{"InPort": classifierInfo[IN_PORT].(uint32), "outPort": actionInfo[OUTPUT].(uint32)})
+				log.Debug("downstream-nni-to-pon-port-flow, no-outport-in-tunnelid", log.Fields{"InPort": classifierInfo[InPort].(uint32), "outPort": actionInfo[OUTPUT].(uint32)})
 				return
 			}
 			// Upstream flow from PON to NNI port , Use tunnel ID as new IN port / UNI port
-		} else if portType := IntfIdToPortTypeName(classifierInfo[IN_PORT].(uint32)); portType == voltha.Port_PON_OLT {
+		} else if portType := IntfIDToPortTypeName(classifierInfo[InPort].(uint32)); portType == voltha.Port_PON_OLT {
 			if uniPort := utils.GetChildPortFromTunnelId(flow); uniPort != 0 {
-				classifierInfo[IN_PORT] = uniPort
+				classifierInfo[InPort] = uniPort
 				log.Debugw("upstream-pon-to-nni-port-flow, inport-in-tunnelid", log.Fields{"newInPort": actionInfo[OUTPUT].(uint32),
 					"outport": actionInfo[OUTPUT].(uint32)})
 			} else {
-				log.Debug("upstream-pon-to-nni-port-flow, no-inport-in-tunnelid", log.Fields{"InPort": classifierInfo[IN_PORT].(uint32),
+				log.Debug("upstream-pon-to-nni-port-flow, no-inport-in-tunnelid", log.Fields{"InPort": classifierInfo[InPort].(uint32),
 					"outPort": actionInfo[OUTPUT].(uint32)})
 				return
 			}
 		}
 	}
-	log.Infow("Flow ports", log.Fields{"classifierInfo_inport": classifierInfo[IN_PORT], "action_output": actionInfo[OUTPUT]})
-	portNo, intfId, onuId, uniId := ExtractAccessFromFlow(classifierInfo[IN_PORT].(uint32), actionInfo[OUTPUT].(uint32))
-	if ipProto, ok := classifierInfo[IP_PROTO]; ok {
-		if ipProto.(uint32) == IP_PROTO_DHCP {
-			if udpSrc, ok := classifierInfo[UDP_SRC]; ok {
+	log.Infow("Flow ports", log.Fields{"classifierInfo_inport": classifierInfo[InPort], "action_output": actionInfo[OUTPUT]})
+	portNo, intfID, onuID, uniID := ExtractAccessFromFlow(classifierInfo[InPort].(uint32), actionInfo[OUTPUT].(uint32))
+	if ipProto, ok := classifierInfo[IPProto]; ok {
+		if ipProto.(uint32) == IPProtoDhcp {
+			if udpSrc, ok := classifierInfo[UDPSrc]; ok {
 				if udpSrc.(uint32) == uint32(67) {
 					log.Debug("trap-dhcp-from-nni-flow")
 					f.addDHCPTrapFlowOnNNI(flow, classifierInfo, portNo)
@@ -1079,20 +1043,112 @@
 			}
 		}
 	}
-	f.divideAndAddFlow(intfId, onuId, uniId, portNo, classifierInfo, actionInfo, flow)
+	f.divideAndAddFlow(intfID, onuID, uniID, portNo, classifierInfo, actionInfo, flow)
 }
 
-func (f *OpenOltFlowMgr) sendTPDownloadMsgToChild(intfId uint32, onuId uint32, uniId uint32, uni string) error {
+func (f *OpenOltFlowMgr) updateClassifierInfo(field *ofp.OfpOxmOfbField, classifierInfo map[string]interface{}) {
+	if field.Type == utils.ETH_TYPE {
+		classifierInfo[EthType] = field.GetEthType()
+		log.Debug("field-type-eth-type", log.Fields{"classifierInfo[ETH_TYPE]": classifierInfo[EthType].(uint32)})
+	} else if field.Type == utils.IP_PROTO {
+		classifierInfo[IPProto] = field.GetIpProto()
+		log.Debug("field-type-ip-proto", log.Fields{"classifierInfo[IP_PROTO]": classifierInfo[IPProto].(uint32)})
+	} else if field.Type == utils.IN_PORT {
+		classifierInfo[InPort] = field.GetPort()
+		log.Debug("field-type-in-port", log.Fields{"classifierInfo[IN_PORT]": classifierInfo[InPort].(uint32)})
+	} else if field.Type == utils.VLAN_VID {
+		classifierInfo[VlanVid] = field.GetVlanVid()
+		log.Debug("field-type-vlan-vid", log.Fields{"classifierInfo[VLAN_VID]": classifierInfo[VlanVid].(uint32)})
+	} else if field.Type == utils.VLAN_PCP {
+		classifierInfo[VlanPcp] = field.GetVlanPcp()
+		log.Debug("field-type-vlan-pcp", log.Fields{"classifierInfo[VLAN_PCP]": classifierInfo[VlanPcp].(uint32)})
+	} else if field.Type == utils.UDP_DST {
+		classifierInfo[UDPDst] = field.GetUdpDst()
+		log.Debug("field-type-udp-dst", log.Fields{"classifierInfo[UDP_DST]": classifierInfo[UDPDst].(uint32)})
+	} else if field.Type == utils.UDP_SRC {
+		classifierInfo[UDPSrc] = field.GetUdpSrc()
+		log.Debug("field-type-udp-src", log.Fields{"classifierInfo[UDP_SRC]": classifierInfo[UDPSrc].(uint32)})
+	} else if field.Type == utils.IPV4_DST {
+		classifierInfo[Ipv4Dst] = field.GetIpv4Dst()
+		log.Debug("field-type-ipv4-dst", log.Fields{"classifierInfo[IPV4_DST]": classifierInfo[Ipv4Dst].(uint32)})
+	} else if field.Type == utils.IPV4_SRC {
+		classifierInfo[Ipv4Src] = field.GetIpv4Src()
+		log.Debug("field-type-ipv4-src", log.Fields{"classifierInfo[IPV4_SRC]": classifierInfo[Ipv4Src].(uint32)})
+	} else if field.Type == utils.METADATA {
+		classifierInfo[METADATA] = field.GetTableMetadata()
+		log.Debug("field-type-metadata", log.Fields{"classifierInfo[METADATA]": classifierInfo[METADATA].(uint64)})
+	} else if field.Type == utils.TUNNEL_ID {
+		classifierInfo[TunnelID] = field.GetTunnelId()
+		log.Debug("field-type-tunnelId", log.Fields{"classifierInfo[TUNNEL_ID]": classifierInfo[TunnelID].(uint64)})
+	} else {
+		log.Errorw("Un supported field type", log.Fields{"type": field.Type})
+		return
+	}
+}
 
-	onuDevice, err := f.getOnuChildDevice(intfId, onuId)
+func (f *OpenOltFlowMgr) updateFlowActionInfo(action *ofp.OfpAction, actionInfo map[string]interface{}, classifierInfo map[string]interface{}) {
+	if action.Type == utils.OUTPUT {
+		if out := action.GetOutput(); out != nil {
+			actionInfo[OUTPUT] = out.GetPort()
+			log.Debugw("action-type-output", log.Fields{"out_port": actionInfo[OUTPUT].(uint32)})
+		} else {
+			log.Error("Invalid output port in action")
+			return
+		}
+	} else if action.Type == utils.POP_VLAN {
+		actionInfo[PopVlan] = true
+		log.Debugw("action-type-pop-vlan", log.Fields{"in_port": classifierInfo[InPort].(uint32)})
+	} else if action.Type == utils.PUSH_VLAN {
+		if out := action.GetPush(); out != nil {
+			if tpid := out.GetEthertype(); tpid != 0x8100 {
+				log.Errorw("Invalid ethertype in push action", log.Fields{"ethertype": actionInfo[PushVlan].(int32)})
+			} else {
+				actionInfo[PushVlan] = true
+				actionInfo[TPID] = tpid
+				log.Debugw("action-type-push-vlan",
+					log.Fields{"push_tpid": actionInfo[TPID].(uint32), "in_port": classifierInfo[InPort].(uint32)})
+			}
+		}
+	} else if action.Type == utils.SET_FIELD {
+		if out := action.GetSetField(); out != nil {
+			if field := out.GetField(); field != nil {
+				if ofClass := field.GetOxmClass(); ofClass != ofp.OfpOxmClass_OFPXMC_OPENFLOW_BASIC {
+					log.Errorw("Invalid openflow class", log.Fields{"class": ofClass})
+					return
+				}
+				/*log.Debugw("action-type-set-field",log.Fields{"field": field, "in_port": classifierInfo[IN_PORT].(uint32)})*/
+				if ofbField := field.GetOfbField(); ofbField != nil {
+					if fieldtype := ofbField.GetType(); fieldtype == ofp.OxmOfbFieldTypes_OFPXMT_OFB_VLAN_VID {
+						if vlan := ofbField.GetVlanVid(); vlan != 0 {
+							actionInfo[VlanVid] = vlan & 0xfff
+							log.Debugw("action-set-vlan-vid", log.Fields{"actionInfo[VLAN_VID]": actionInfo[VlanVid].(uint32)})
+						} else {
+							log.Error("No Invalid vlan id in set vlan-vid action")
+						}
+					} else {
+						log.Errorw("unsupported-action-set-field-type", log.Fields{"type": fieldtype})
+					}
+				}
+			}
+		}
+	} else {
+		log.Errorw("Un supported action type", log.Fields{"type": action.Type})
+		return
+	}
+}
+
+//sendTPDownloadMsgToChild send payload
+func (f *OpenOltFlowMgr) sendTPDownloadMsgToChild(intfID uint32, onuID uint32, uniID uint32, uni string) error {
+
+	onuDevice, err := f.getOnuChildDevice(intfID, onuID)
 	if err != nil {
-		log.Errorw("Error while fetching Child device from core", log.Fields{"onuId": onuId})
+		log.Errorw("Error while fetching Child device from core", log.Fields{"onuId": onuID})
 		return err
 	}
 	log.Debugw("Got child device from OLT device handler", log.Fields{"device": *onuDevice})
 
-	tpPath := f.getTPpath(intfId, uni)
-	tpDownloadMsg := &ic.InterAdapterTechProfileDownloadMessage{UniId: uniId, Path: tpPath}
+	tpPath := f.getTPpath(intfID, uni)
+	tpDownloadMsg := &ic.InterAdapterTechProfileDownloadMessage{UniId: uniID, Path: tpPath}
 	log.Infow("Sending Load-tech-profile-request-to-brcm-onu-adapter", log.Fields{"msg": *tpDownloadMsg})
 	sendErr := f.deviceHandler.AdapterProxy.SendInterAdapterMessage(context.Background(),
 		tpDownloadMsg,
@@ -1111,92 +1167,94 @@
 	return nil
 }
 
-// This function adds onu info to cache
+//UpdateOnuInfo function adds onu info to cache
 func (f *OpenOltFlowMgr) UpdateOnuInfo(intfID uint32, onuID uint32, serialNum string) {
-	onu := onuInfo{intfId: intfID, onuId: onuID, serialNumber: serialNum}
-	onuIDkey := onuIdKey{intfId: intfID, onuId: onuID}
+	onu := onuInfo{intfID: intfID, onuID: onuID, serialNumber: serialNum}
+	onuIDkey := onuIDKey{intfID: intfID, onuID: onuID}
 	f.onuIds[onuIDkey] = onu
 	log.Debugw("Updated onuinfo", log.Fields{"intfID": intfID, "onuID": onuID, "serialNum": serialNum})
 }
 
-// This function stores adds GEMport to ONU map
-func (f *OpenOltFlowMgr) addGemPortToOnuInfoMap(intfId uint32, onuId uint32, gemPort uint32) {
-	onuIDkey := onuIdKey{intfId: intfId, onuId: onuId}
+//addGemPortToOnuInfoMap function stores adds GEMport to ONU map
+func (f *OpenOltFlowMgr) addGemPortToOnuInfoMap(intfID uint32, onuID uint32, gemPort uint32) {
+	onuIDkey := onuIDKey{intfID: intfID, onuID: onuID}
 	if val, ok := f.onuIds[onuIDkey]; ok {
 		onuInfo := val
-		gemPortKey := gemPortKey{intfId: intfId, gemPort: gemPort}
-		f.onuGemPortIds[gemPortKey] = onuInfo
-		log.Debugw("Cached Gemport to Onuinfo map", log.Fields{"GemPort": gemPort, "intfId": onuInfo.intfId, "onuId": onuInfo.onuId})
+		gemportKey := gemPortKey{intfID: intfID, gemPort: gemPort}
+		f.onuGemPortIds[gemportKey] = onuInfo
+		log.Debugw("Cached Gemport to Onuinfo map", log.Fields{"GemPort": gemPort, "intfId": onuInfo.intfID, "onuId": onuInfo.onuID})
 		return
 	}
-	log.Errorw("OnuInfo not found", log.Fields{"intfId": intfId, "onuId": onuId, "gemPort": gemPort})
+	log.Errorw("OnuInfo not found", log.Fields{"intfId": intfID, "onuId": onuID, "gemPort": gemPort})
 }
 
 // This function Lookup maps  by serialNumber or (intfId, gemPort)
-// Returns OnuID,nil if found or set 0,error if no onuId is found for serialNumber or (intfId, gemPort)
-func (f *OpenOltFlowMgr) getOnuIdfromGemPortMap(serialNumber string, intfId uint32, gemPortId uint32) (uint32, error) {
-	log.Debugw("Getting ONU ID from GEM port and PON port", log.Fields{"serialNumber": serialNumber, "intfId": intfId, "gemPortId": gemPortId})
+
+//getOnuIDfromGemPortMap Returns OnuID,nil if found or set 0,error if no onuId is found for serialNumber or (intfId, gemPort)
+func (f *OpenOltFlowMgr) getOnuIDfromGemPortMap(serialNumber string, intfID uint32, gemPortID uint32) (uint32, error) {
+	log.Debugw("Getting ONU ID from GEM port and PON port", log.Fields{"serialNumber": serialNumber, "intfId": intfID, "gemPortId": gemPortID})
 	if serialNumber != "" {
 		if onuInfo, ok := f.onuSerialNumbers[serialNumber]; ok {
-			return onuInfo.onuId, nil
+			return onuInfo.onuID, nil
 		}
 	} else {
-		gemPortKey := gemPortKey{intfId: intfId, gemPort: gemPortId}
-		if onuInfo, ok := f.onuGemPortIds[gemPortKey]; ok {
-			log.Debugw("Retrived onu info from access", log.Fields{"intfId": intfId, "gemPortId": gemPortId, "onuId": onuInfo.onuId})
-			return onuInfo.onuId, nil
+		gemportKey := gemPortKey{intfID: intfID, gemPort: gemPortID}
+		if onuInfo, ok := f.onuGemPortIds[gemportKey]; ok {
+			log.Debugw("Retrieved onu info from access", log.Fields{"intfId": intfID, "gemPortId": gemPortID, "onuId": onuInfo.onuID})
+			return onuInfo.onuID, nil
 		}
 	}
-	log.Errorw("ONU ID  is not found", log.Fields{"serialNumber": serialNumber, "intfId": intfId, "gemPort": gemPortId})
-	return uint32(0), errors.New("Key Error ,ONU ID  is not found") // ONU ID 0 is not a valid one
+	log.Errorw("onuid is not found", log.Fields{"serialNumber": serialNumber, "intfId": intfID, "gemPort": gemPortID})
+	return uint32(0), errors.New("key error, onuid is not found") // ONU ID 0 is not a valid one
 }
 
-// This function computes logical port UNI/NNI port from packet-in indication and returns the same
-func (f *OpenOltFlowMgr) GetLogicalPortFromPacketIn(packetIn *openolt_pb2.PacketIndication) (uint32, error) {
+//GetLogicalPortFromPacketIn function computes logical port UNI/NNI port from packet-in indication and returns the same
+func (f *OpenOltFlowMgr) GetLogicalPortFromPacketIn(packetIn *openoltpb2.PacketIndication) (uint32, error) {
 	var logicalPortNum uint32
-	var onuId uint32
+	var onuID uint32
 	var err error
 
 	if packetIn.IntfType == "pon" {
 		// packet indication does not have serial number , so sending as nil
-		if onuId, err = f.getOnuIdfromGemPortMap("", packetIn.IntfId, packetIn.GemportId); err != nil {
+		if onuID, err = f.getOnuIDfromGemPortMap("", packetIn.IntfId, packetIn.GemportId); err != nil {
 			log.Errorw("Unable to get ONU ID from GEM/PON port", log.Fields{"pon port": packetIn.IntfId, "gemport": packetIn.GemportId})
 			return logicalPortNum, err
 		}
 		if packetIn.PortNo != 0 {
 			logicalPortNum = packetIn.PortNo
 		} else {
-			uniId := uint32(0) //  FIXME - multi-uni support
-			logicalPortNum = MkUniPortNum(packetIn.IntfId, onuId, uniId)
+			uniID := uint32(0) //  FIXME - multi-uni support
+			logicalPortNum = MkUniPortNum(packetIn.IntfId, onuID, uniID)
 		}
 		// Store the gem port through which the packet_in came. Use the same gem port for packet_out
-		pktInkey := packetInInfoKey{intfId: packetIn.IntfId, onuId: onuId, logicalPort: logicalPortNum}
+		pktInkey := packetInInfoKey{intfID: packetIn.IntfId, onuID: onuID, logicalPort: logicalPortNum}
 		f.packetInGemPort[pktInkey] = packetIn.GemportId
 	} else if packetIn.IntfType == "nni" {
-		logicalPortNum = IntfIdToPortNo(packetIn.IntfId, voltha.Port_ETHERNET_NNI)
+		logicalPortNum = IntfIDToPortNo(packetIn.IntfId, voltha.Port_ETHERNET_NNI)
 	}
 	log.Debugw("Retrieved logicalport from  packet-in", log.Fields{"logicalPortNum": logicalPortNum, "IntfType": packetIn.IntfType})
 	return logicalPortNum, nil
 }
 
-func (f *OpenOltFlowMgr) GetPacketOutGemPortId(intfId uint32, onuId uint32, portNum uint32) (uint32, error) {
-	var gemPortId uint32
+//GetPacketOutGemPortID returns gemPortId
+func (f *OpenOltFlowMgr) GetPacketOutGemPortID(intfID uint32, onuID uint32, portNum uint32) (uint32, error) {
+	var gemPortID uint32
 	var err error
-	key := packetInInfoKey{intfId: intfId, onuId: onuId, logicalPort: portNum}
+	key := packetInInfoKey{intfID: intfID, onuID: onuID, logicalPort: portNum}
 	if val, ok := f.packetInGemPort[key]; ok {
-		gemPortId = val
+		gemPortID = val
 	} else {
 		log.Errorw("Key-Error while fetching packet-out GEM port", log.Fields{"key": key})
-		err = errors.New("Key-Error while fetching packet-out GEM port")
+		err = errors.New("key-error while fetching packet-out GEM port")
 	}
-	return gemPortId, err
+	return gemPortID, err
 }
 
 func (f *OpenOltFlowMgr) addDHCPTrapFlowOnNNI(logicalFlow *ofp.OfpFlowStats, classifier map[string]interface{}, portNo uint32) {
 	log.Debug("Adding trap-dhcp-of-nni-flow")
 	action := make(map[string]interface{})
-	classifier[PACKET_TAG_TYPE] = DOUBLE_TAG
-	action[TRAP_TO_HOST] = true
+	classifier[PacketTagType] = DoubleTag
+	action[TrapToHost] = true
 	/* We manage flowId resource pool on per PON port basis.
 	   Since this situation is tricky, as a hack, we pass the NNI port
 	   index (network_intf_id) as PON port Index for the flowId resource
@@ -1208,23 +1266,23 @@
 	   we need to have a re-look at this.
 	   *********************************************
 	*/
-	onuId := -1
-	uniId := -1
-	gemPortId := -1
-	allocId := -1
-	networkInterfaceId := f.deviceHandler.nniIntfId
+	onuID := -1
+	uniID := -1
+	gemPortID := -1
+	allocID := -1
+	networkInterfaceID := f.deviceHandler.nniIntfID
 	flowStoreCookie := getFlowStoreCookie(classifier, uint32(0))
-	if present := f.resourceMgr.IsFlowCookieOnKVStore(uint32(networkInterfaceId), uint32(onuId), uint32(uniId), flowStoreCookie); present {
+	if present := f.resourceMgr.IsFlowCookieOnKVStore(uint32(networkInterfaceID), uint32(onuID), uint32(uniID), flowStoreCookie); present {
 		log.Debug("Flow-exists--not-re-adding")
 		return
 	}
-	flowId, err := f.resourceMgr.GetFlowID(uint32(networkInterfaceId), uint32(onuId), uint32(uniId), flowStoreCookie, "")
+	flowID, err := f.resourceMgr.GetFlowID(uint32(networkInterfaceID), uint32(onuID), uint32(uniID), flowStoreCookie, "")
 	if err != nil {
 		log.Errorw("Flow id unavailable for DHCP traponNNI flow", log.Fields{"error": err})
 		return
 	}
-	var classifierProto *openolt_pb2.Classifier
-	var actionProto *openolt_pb2.Action
+	var classifierProto *openoltpb2.Classifier
+	var actionProto *openoltpb2.Action
 	if classifierProto = makeOpenOltClassifierField(classifier); classifierProto == nil {
 		log.Error("Error in making classifier protobuf for  dhcp trap on nni flow")
 		return
@@ -1235,14 +1293,14 @@
 		return
 	}
 	log.Debugw("Created action proto", log.Fields{"action": *actionProto})
-	downstreamflow := openolt_pb2.Flow{AccessIntfId: int32(-1), // AccessIntfId not required
-		OnuId:         int32(onuId), // OnuId not required
-		UniId:         int32(uniId), // UniId not used
-		FlowId:        flowId,
+	downstreamflow := openoltpb2.Flow{AccessIntfId: int32(-1), // AccessIntfId not required
+		OnuId:         int32(onuID), // OnuId not required
+		UniId:         int32(uniID), // UniId not used
+		FlowId:        flowID,
 		FlowType:      DOWNSTREAM,
-		AllocId:       int32(allocId), // AllocId not used
-		NetworkIntfId: int32(networkInterfaceId),
-		GemportId:     int32(gemPortId), // GemportId not used
+		AllocId:       int32(allocID), // AllocId not used
+		NetworkIntfId: int32(networkInterfaceID),
+		GemportId:     int32(gemPortID), // GemportId not used
 		Classifier:    classifierProto,
 		Action:        actionProto,
 		Priority:      int32(logicalFlow.Priority),
@@ -1250,11 +1308,11 @@
 		PortNo:        portNo}
 	if ok := f.addFlowToDevice(logicalFlow, &downstreamflow); ok {
 		log.Debug("DHCP trap on NNI flow added to device successfully")
-		flowsToKVStore := f.getUpdatedFlowInfo(&downstreamflow, flowStoreCookie, "", flowId)
-		if err := f.updateFlowInfoToKVStore(int32(networkInterfaceId),
-			int32(onuId),
-			int32(uniId),
-			flowId, flowsToKVStore); err != nil {
+		flowsToKVStore := f.getUpdatedFlowInfo(&downstreamflow, flowStoreCookie, "", flowID)
+		if err := f.updateFlowInfoToKVStore(int32(networkInterfaceID),
+			int32(onuID),
+			int32(uniID),
+			flowID, flowsToKVStore); err != nil {
 			log.Errorw("Error uploading DHCP DL  flow into KV store", log.Fields{"flow": downstreamflow, "error": err})
 		}
 	}
diff --git a/adaptercore/resourcemanager/resourcemanager.go b/adaptercore/resourcemanager/resourcemanager.go
index 524997a..799a733 100755
--- a/adaptercore/resourcemanager/resourcemanager.go
+++ b/adaptercore/resourcemanager/resourcemanager.go
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 
+//Package resourcemanager provides the utility for managing resources
 package resourcemanager
 
 import (
@@ -30,16 +31,22 @@
 	"github.com/opencord/voltha-protos/go/openolt"
 )
 
-const KVSTORE_TIMEOUT = 5
-const BASE_PATH_KV_STORE = "service/voltha/openolt/{%s}" // service/voltha/openolt/<device_id>
+// KvstoreTimeout specifies the time out for KV Store Connection
+const KvstoreTimeout = 5
 
+// BasePathKvStore - service/voltha/openolt/<device_id>
+const BasePathKvStore = "service/voltha/openolt/{%s}"
+
+// FlowInfo holds the flow information
 type FlowInfo struct {
 	Flow            *openolt.Flow
 	FlowStoreCookie uint64
 	FlowCategory    string
 }
+
+// OpenOltResourceMgr holds resource related information as provided below for each field
 type OpenOltResourceMgr struct {
-	DeviceID    string         //OLT device id
+	DeviceID    string         // OLT device id
 	HostAndPort string         // Host and port of the kv store to connect to
 	Args        string         // args
 	KVStore     *model.Backend // backend kv store connection handle
@@ -51,7 +58,7 @@
 	ResourceMgrs map[uint32]*ponrmgr.PONResourceManager
 }
 
-func newKVClient(storeType string, address string, timeout uint32) (kvstore.Client, error) {
+func newKVClient(storeType, address string, timeout uint32) (kvstore.Client, error) {
 	log.Infow("kv-store-type", log.Fields{"store": storeType})
 	switch storeType {
 	case "consul":
@@ -62,44 +69,43 @@
 	return nil, errors.New("unsupported-kv-store")
 }
 
-func SetKVClient(Backend string, Host string, Port int, DeviceID string) *model.Backend {
+// SetKVClient sets the KV client and return a kv backend
+func SetKVClient(backend string, Host string, Port int, DeviceID string) *model.Backend {
 	addr := Host + ":" + strconv.Itoa(Port)
 	// TODO : Make sure direct call to NewBackend is working fine with backend , currently there is some
 	// issue between kv store and backend , core is not calling NewBackend directly
-	kvClient, err := newKVClient(Backend, addr, KVSTORE_TIMEOUT)
+	kvClient, err := newKVClient(backend, addr, KvstoreTimeout)
 	if err != nil {
 		log.Fatalw("Failed to init KV client\n", log.Fields{"err": err})
 		return nil
 	}
 	kvbackend := &model.Backend{
 		Client:     kvClient,
-		StoreType:  Backend,
+		StoreType:  backend,
 		Host:       Host,
 		Port:       Port,
-		Timeout:    KVSTORE_TIMEOUT,
-		PathPrefix: fmt.Sprintf(BASE_PATH_KV_STORE, DeviceID)}
+		Timeout:    KvstoreTimeout,
+		PathPrefix: fmt.Sprintf(BasePathKvStore, DeviceID)}
 
 	return kvbackend
 }
 
-func NewResourceMgr(DeviceID string, KVStoreHostPort string, KVStoreType string, DeviceType string, DevInfo *openolt.DeviceInfo) *OpenOltResourceMgr {
-
-	/* init a New resource maanger instance which in turn instantiates pon resource manager
-	   instances according to technology. Initializes the default resource ranges for all
-	   the reources.
-	*/
+// NewResourceMgr init a New resource maanger instance which in turn instantiates pon resource manager
+// instances according to technology. Initializes the default resource ranges for all
+// the resources.
+func NewResourceMgr(deviceID string, KVStoreHostPort string, kvStoreType string, deviceType string, devInfo *openolt.DeviceInfo) *OpenOltResourceMgr {
 	var ResourceMgr OpenOltResourceMgr
-	log.Debugf("Init new resource manager , host_port: %s, deviceid: %s", KVStoreHostPort, DeviceID)
+	log.Debugf("Init new resource manager , host_port: %s, deviceid: %s", KVStoreHostPort, deviceID)
 	ResourceMgr.HostAndPort = KVStoreHostPort
-	ResourceMgr.DeviceType = DeviceType
-	ResourceMgr.DevInfo = DevInfo
-	IpPort := strings.Split(KVStoreHostPort, ":")
-	ResourceMgr.Host = IpPort[0]
-	ResourceMgr.Port, _ = strconv.Atoi(IpPort[1])
+	ResourceMgr.DeviceType = deviceType
+	ResourceMgr.DevInfo = devInfo
+	IPPort := strings.Split(KVStoreHostPort, ":")
+	ResourceMgr.Host = IPPort[0]
+	ResourceMgr.Port, _ = strconv.Atoi(IPPort[1])
 
-	Backend := KVStoreType
+	Backend := kvStoreType
 	ResourceMgr.KVStore = SetKVClient(Backend, ResourceMgr.Host,
-		ResourceMgr.Port, DeviceID)
+		ResourceMgr.Port, deviceID)
 	if ResourceMgr.KVStore == nil {
 		log.Error("Failed to setup KV store")
 	}
@@ -114,11 +120,11 @@
 	   the legacy global per-device informaiton. This, in theory, is temporary until
 	   the legacy drivers are upgrade to support pool ranges.
 	*/
-	if DevInfo.Ranges == nil {
+	if devInfo.Ranges == nil {
 		var ranges openolt.DeviceInfo_DeviceResourceRanges
-		ranges.Technology = DevInfo.GetTechnology()
+		ranges.Technology = devInfo.GetTechnology()
 
-		NumPONPorts := DevInfo.GetPonPorts()
+		NumPONPorts := devInfo.GetPonPorts()
 		var index uint32
 		for index = 0; index < NumPONPorts; index++ {
 			ranges.IntfIds = append(ranges.IntfIds, index)
@@ -126,76 +132,80 @@
 
 		var Pool openolt.DeviceInfo_DeviceResourceRanges_Pool
 		Pool.Type = openolt.DeviceInfo_DeviceResourceRanges_Pool_ONU_ID
-		Pool.Start = DevInfo.OnuIdStart
-		Pool.End = DevInfo.OnuIdEnd
+		Pool.Start = devInfo.OnuIdStart
+		Pool.End = devInfo.OnuIdEnd
 		Pool.Sharing = openolt.DeviceInfo_DeviceResourceRanges_Pool_DEDICATED_PER_INTF
 		ranges.Pools = append(ranges.Pools, &Pool)
 
 		Pool.Type = openolt.DeviceInfo_DeviceResourceRanges_Pool_ALLOC_ID
-		Pool.Start = DevInfo.AllocIdStart
-		Pool.End = DevInfo.AllocIdEnd
+		Pool.Start = devInfo.AllocIdStart
+		Pool.End = devInfo.AllocIdEnd
 		Pool.Sharing = openolt.DeviceInfo_DeviceResourceRanges_Pool_SHARED_BY_ALL_INTF_ALL_TECH
 		ranges.Pools = append(ranges.Pools, &Pool)
 
 		Pool.Type = openolt.DeviceInfo_DeviceResourceRanges_Pool_GEMPORT_ID
-		Pool.Start = DevInfo.GemportIdStart
-		Pool.End = DevInfo.GemportIdEnd
+		Pool.Start = devInfo.GemportIdStart
+		Pool.End = devInfo.GemportIdEnd
 		Pool.Sharing = openolt.DeviceInfo_DeviceResourceRanges_Pool_SHARED_BY_ALL_INTF_ALL_TECH
 		ranges.Pools = append(ranges.Pools, &Pool)
 
 		Pool.Type = openolt.DeviceInfo_DeviceResourceRanges_Pool_FLOW_ID
-		Pool.Start = DevInfo.FlowIdStart
-		Pool.End = DevInfo.FlowIdEnd
+		Pool.Start = devInfo.FlowIdStart
+		Pool.End = devInfo.FlowIdEnd
 		Pool.Sharing = openolt.DeviceInfo_DeviceResourceRanges_Pool_SHARED_BY_ALL_INTF_ALL_TECH
 		ranges.Pools = append(ranges.Pools, &Pool)
 		// Add to device info
-		DevInfo.Ranges = append(DevInfo.Ranges, &ranges)
+		devInfo.Ranges = append(devInfo.Ranges, &ranges)
 	}
 
-	//Create a separate Resource Manager instance for each range. This assumes that
+	// Create a separate Resource Manager instance for each range. This assumes that
 	// each technology is represented by only a single range
 	var GlobalPONRsrcMgr *ponrmgr.PONResourceManager
 	var err error
-	for _, TechRange := range DevInfo.Ranges {
+	for _, TechRange := range devInfo.Ranges {
 		technology := TechRange.Technology
 		log.Debugf("Device info technology %s", technology)
 		Ranges[technology] = TechRange
-		RsrcMgrsByTech[technology], err = ponrmgr.NewPONResourceManager(technology, DeviceType, DeviceID,
+		RsrcMgrsByTech[technology], err = ponrmgr.NewPONResourceManager(technology, deviceType, deviceID,
 			Backend, ResourceMgr.Host, ResourceMgr.Port)
 		if err != nil {
 			log.Errorf("Failed to create pon resource manager instacnce for technology %s", technology)
 			return nil
 		}
-		//resource_mgrs_by_tech[technology] = resource_mgr
+		// resource_mgrs_by_tech[technology] = resource_mgr
 		if GlobalPONRsrcMgr == nil {
 			GlobalPONRsrcMgr = RsrcMgrsByTech[technology]
 		}
-		for _, IntfId := range TechRange.IntfIds {
-			ResourceMgr.ResourceMgrs[uint32(IntfId)] = RsrcMgrsByTech[technology]
+		for _, IntfID := range TechRange.IntfIds {
+			ResourceMgr.ResourceMgrs[uint32(IntfID)] = RsrcMgrsByTech[technology]
 		}
-		//self.initialize_device_resource_range_and_pool(resource_mgr, global_resource_mgr, arange)
+		// self.initialize_device_resource_range_and_pool(resource_mgr, global_resource_mgr, arange)
 		InitializeDeviceResourceRangeAndPool(RsrcMgrsByTech[technology], GlobalPONRsrcMgr,
-			TechRange, DevInfo)
+			TechRange, devInfo)
 	}
 	// After we have initialized resource ranges, initialize the
 	// resource pools accordingly.
 	for _, PONRMgr := range RsrcMgrsByTech {
-		PONRMgr.InitDeviceResourcePool()
+		_ = PONRMgr.InitDeviceResourcePool()
 	}
 	log.Info("Initialization of  resource manager success!")
 	return &ResourceMgr
 }
 
-func InitializeDeviceResourceRangeAndPool(PONRMgr *ponrmgr.PONResourceManager, GlobalPONRMgr *ponrmgr.PONResourceManager,
-	TechRange *openolt.DeviceInfo_DeviceResourceRanges, DevInfo *openolt.DeviceInfo) {
+// InitializeDeviceResourceRangeAndPool initializes the resource range pool according to the sharing type, then apply
+// device specific information. If KV doesn't exist
+// or is broader than the device, the device's information will
+// dictate the range limits
+func InitializeDeviceResourceRangeAndPool(ponRMgr *ponrmgr.PONResourceManager, globalPONRMgr *ponrmgr.PONResourceManager,
+	techRange *openolt.DeviceInfo_DeviceResourceRanges, devInfo *openolt.DeviceInfo) {
 
 	// init the resource range pool according to the sharing type
 
-	log.Debugf("Resource range pool init for technology %s", PONRMgr.Technology)
-	//first load from KV profiles
-	status := PONRMgr.InitResourceRangesFromKVStore()
-	if status == false {
-		log.Debugf("Failed to load resource ranges from KV store for tech %s", PONRMgr.Technology)
+	log.Debugf("Resource range pool init for technology %s", ponRMgr.Technology)
+	// first load from KV profiles
+	status := ponRMgr.InitResourceRangesFromKVStore()
+	if !status {
+		log.Debugf("Failed to load resource ranges from KV store for tech %s", ponRMgr.Technology)
 	}
 
 	/*
@@ -203,22 +213,22 @@
 	   or is broader than the device, the device's informationw ill
 	   dictate the range limits
 	*/
-	log.Debugf("Using device info to init pon resource ranges for tech", PONRMgr.Technology)
+	log.Debugf("Using device info to init pon resource ranges for tech", ponRMgr.Technology)
 
-	ONUIDStart := DevInfo.OnuIdStart
-	ONUIDEnd := DevInfo.OnuIdEnd
+	ONUIDStart := devInfo.OnuIdStart
+	ONUIDEnd := devInfo.OnuIdEnd
 	ONUIDShared := openolt.DeviceInfo_DeviceResourceRanges_Pool_DEDICATED_PER_INTF
 	ONUIDSharedPoolID := uint32(0)
-	AllocIDStart := DevInfo.AllocIdStart
-	AllocIDEnd := DevInfo.AllocIdEnd
+	AllocIDStart := devInfo.AllocIdStart
+	AllocIDEnd := devInfo.AllocIdEnd
 	AllocIDShared := openolt.DeviceInfo_DeviceResourceRanges_Pool_SHARED_BY_ALL_INTF_ALL_TECH // TODO EdgeCore/BAL limitation
 	AllocIDSharedPoolID := uint32(0)
-	GEMPortIDStart := DevInfo.GemportIdStart
-	GEMPortIDEnd := DevInfo.GemportIdEnd
+	GEMPortIDStart := devInfo.GemportIdStart
+	GEMPortIDEnd := devInfo.GemportIdEnd
 	GEMPortIDShared := openolt.DeviceInfo_DeviceResourceRanges_Pool_SHARED_BY_ALL_INTF_ALL_TECH // TODO EdgeCore/BAL limitation
 	GEMPortIDSharedPoolID := uint32(0)
-	FlowIDStart := DevInfo.FlowIdStart
-	FlowIDEnd := DevInfo.FlowIdEnd
+	FlowIDStart := devInfo.FlowIdStart
+	FlowIDEnd := devInfo.FlowIdEnd
 	FlowIDShared := openolt.DeviceInfo_DeviceResourceRanges_Pool_SHARED_BY_ALL_INTF_ALL_TECH // TODO EdgeCore/BAL limitation
 	FlowIDSharedPoolID := uint32(0)
 
@@ -227,9 +237,9 @@
 
 	/*
 	 * As a zero check is made against SharedPoolID to check whether the resources are shared across all intfs
-	 * if resources are shared accross interfaces then SharedPoolID is given a positive number.
+	 * if resources are shared across interfaces then SharedPoolID is given a positive number.
 	 */
-	for _, FirstIntfPoolID = range TechRange.IntfIds {
+	for _, FirstIntfPoolID = range techRange.IntfIds {
 		// skip the intf id 0
 		if FirstIntfPoolID == 0 {
 			continue
@@ -237,7 +247,7 @@
 		break
 	}
 
-	for _, RangePool := range TechRange.Pools {
+	for _, RangePool := range techRange.Pools {
 		if RangePool.Sharing == openolt.DeviceInfo_DeviceResourceRanges_Pool_SHARED_BY_ALL_INTF_ALL_TECH {
 			SharedPoolID = FirstIntfPoolID
 		} else if RangePool.Sharing == openolt.DeviceInfo_DeviceResourceRanges_Pool_SHARED_BY_ALL_INTF_SAME_TECH {
@@ -268,7 +278,7 @@
 		}
 	}
 
-	log.Debugw("Device info init", log.Fields{"technology": TechRange.Technology,
+	log.Debugw("Device info init", log.Fields{"technology": techRange.Technology,
 		"onu_id_start": ONUIDStart, "onu_id_end": ONUIDEnd, "onu_id_shared_pool_id": ONUIDSharedPoolID,
 		"alloc_id_start": AllocIDStart, "alloc_id_end": AllocIDEnd,
 		"alloc_id_shared_pool_id": AllocIDSharedPoolID,
@@ -277,46 +287,47 @@
 		"flow_id_start":             FlowIDStart,
 		"flow_id_end_idx":           FlowIDEnd,
 		"flow_id_shared_pool_id":    FlowIDSharedPoolID,
-		"intf_ids":                  TechRange.IntfIds,
+		"intf_ids":                  techRange.IntfIds,
 		"uni_id_start":              0,
-		"uni_id_end_idx":/*MaxUNIIDperONU()*/ 1})
+		"uni_id_end_idx":            1, /*MaxUNIIDperONU()*/
+	})
 
-	PONRMgr.InitDefaultPONResourceRanges(ONUIDStart, ONUIDEnd, ONUIDSharedPoolID,
+	ponRMgr.InitDefaultPONResourceRanges(ONUIDStart, ONUIDEnd, ONUIDSharedPoolID,
 		AllocIDStart, AllocIDEnd, AllocIDSharedPoolID,
 		GEMPortIDStart, GEMPortIDEnd, GEMPortIDSharedPoolID,
 		FlowIDStart, FlowIDEnd, FlowIDSharedPoolID, 0, 1,
-		DevInfo.PonPorts, TechRange.IntfIds)
+		devInfo.PonPorts, techRange.IntfIds)
 
 	// For global sharing, make sure to refresh both local and global resource manager instances' range
 
 	if ONUIDShared == openolt.DeviceInfo_DeviceResourceRanges_Pool_SHARED_BY_ALL_INTF_ALL_TECH {
-		GlobalPONRMgr.UpdateRanges(ponrmgr.ONU_ID_START_IDX, ONUIDStart, ponrmgr.ONU_ID_END_IDX, ONUIDEnd,
+		globalPONRMgr.UpdateRanges(ponrmgr.ONU_ID_START_IDX, ONUIDStart, ponrmgr.ONU_ID_END_IDX, ONUIDEnd,
 			"", 0, nil)
-		PONRMgr.UpdateRanges(ponrmgr.ONU_ID_START_IDX, ONUIDStart, ponrmgr.ONU_ID_END_IDX, ONUIDEnd,
-			"", 0, GlobalPONRMgr)
+		ponRMgr.UpdateRanges(ponrmgr.ONU_ID_START_IDX, ONUIDStart, ponrmgr.ONU_ID_END_IDX, ONUIDEnd,
+			"", 0, globalPONRMgr)
 	}
 	if AllocIDShared == openolt.DeviceInfo_DeviceResourceRanges_Pool_SHARED_BY_ALL_INTF_ALL_TECH {
-		GlobalPONRMgr.UpdateRanges(ponrmgr.ALLOC_ID_START_IDX, AllocIDStart, ponrmgr.ALLOC_ID_END_IDX, AllocIDEnd,
+		globalPONRMgr.UpdateRanges(ponrmgr.ALLOC_ID_START_IDX, AllocIDStart, ponrmgr.ALLOC_ID_END_IDX, AllocIDEnd,
 			"", 0, nil)
 
-		PONRMgr.UpdateRanges(ponrmgr.ALLOC_ID_START_IDX, AllocIDStart, ponrmgr.ALLOC_ID_END_IDX, AllocIDEnd,
-			"", 0, GlobalPONRMgr)
+		ponRMgr.UpdateRanges(ponrmgr.ALLOC_ID_START_IDX, AllocIDStart, ponrmgr.ALLOC_ID_END_IDX, AllocIDEnd,
+			"", 0, globalPONRMgr)
 	}
 	if GEMPortIDShared == openolt.DeviceInfo_DeviceResourceRanges_Pool_SHARED_BY_ALL_INTF_ALL_TECH {
-		GlobalPONRMgr.UpdateRanges(ponrmgr.GEMPORT_ID_START_IDX, GEMPortIDStart, ponrmgr.GEMPORT_ID_END_IDX, GEMPortIDEnd,
+		globalPONRMgr.UpdateRanges(ponrmgr.GEMPORT_ID_START_IDX, GEMPortIDStart, ponrmgr.GEMPORT_ID_END_IDX, GEMPortIDEnd,
 			"", 0, nil)
-		PONRMgr.UpdateRanges(ponrmgr.GEMPORT_ID_START_IDX, GEMPortIDStart, ponrmgr.GEMPORT_ID_END_IDX, GEMPortIDEnd,
-			"", 0, GlobalPONRMgr)
+		ponRMgr.UpdateRanges(ponrmgr.GEMPORT_ID_START_IDX, GEMPortIDStart, ponrmgr.GEMPORT_ID_END_IDX, GEMPortIDEnd,
+			"", 0, globalPONRMgr)
 	}
 	if FlowIDShared == openolt.DeviceInfo_DeviceResourceRanges_Pool_SHARED_BY_ALL_INTF_ALL_TECH {
-		GlobalPONRMgr.UpdateRanges(ponrmgr.FLOW_ID_START_IDX, FlowIDStart, ponrmgr.FLOW_ID_END_IDX, FlowIDEnd,
+		globalPONRMgr.UpdateRanges(ponrmgr.FLOW_ID_START_IDX, FlowIDStart, ponrmgr.FLOW_ID_END_IDX, FlowIDEnd,
 			"", 0, nil)
-		PONRMgr.UpdateRanges(ponrmgr.FLOW_ID_START_IDX, FlowIDStart, ponrmgr.FLOW_ID_END_IDX, FlowIDEnd,
-			"", 0, GlobalPONRMgr)
+		ponRMgr.UpdateRanges(ponrmgr.FLOW_ID_START_IDX, FlowIDStart, ponrmgr.FLOW_ID_END_IDX, FlowIDEnd,
+			"", 0, globalPONRMgr)
 	}
 
 	// Make sure loaded range fits the platform bit encoding ranges
-	PONRMgr.UpdateRanges(ponrmgr.UNI_ID_START_IDX, 0, ponrmgr.UNI_ID_END_IDX /* TODO =OpenOltPlatform.MAX_UNIS_PER_ONU-1*/, 1, "", 0, nil)
+	ponRMgr.UpdateRanges(ponrmgr.UNI_ID_START_IDX, 0, ponrmgr.UNI_ID_END_IDX /* TODO =OpenOltPlatform.MAX_UNIS_PER_ONU-1*/, 1, "", 0, nil)
 }
 
 /* TODO
@@ -341,35 +352,35 @@
         self.resource_mgrs[pon_intf_id].assert_resource_limits(uni_id, PONResourceManager.UNI_ID)
 */
 
-func (RsrcMgr *OpenOltResourceMgr) GetONUID(PONIntfID uint32) (uint32, error) {
+// GetONUID returns the available OnuID for the given pon-port
+func (RsrcMgr *OpenOltResourceMgr) GetONUID(ponIntfID uint32) (uint32, error) {
 
 	// Get ONU id for a provided pon interface ID.
 
-	ONUID, err := RsrcMgr.ResourceMgrs[PONIntfID].GetResourceID(PONIntfID,
+	ONUID, err := RsrcMgr.ResourceMgrs[ponIntfID].GetResourceID(ponIntfID,
 		ponrmgr.ONU_ID, 1)
 	if err != nil {
 		log.Errorf("Failed to get resource for interface %d for type %s",
-			PONIntfID, ponrmgr.ONU_ID)
+			ponIntfID, ponrmgr.ONU_ID)
 		return ONUID[0], err
 	}
 	if ONUID != nil {
-		RsrcMgr.ResourceMgrs[PONIntfID].InitResourceMap(fmt.Sprintf("%d,%d", PONIntfID, ONUID))
+		RsrcMgr.ResourceMgrs[ponIntfID].InitResourceMap(fmt.Sprintf("%d,%d", ponIntfID, ONUID))
+		return ONUID[0], err
 	}
 
-	return ONUID[0], err
+	return 0, err // return OnuID 0 on error
 }
 
-func (RsrcMgr *OpenOltResourceMgr) GetFlowIDInfo(PONIntfID uint32, ONUID uint32, UNIID uint32, FlowID uint32) *[]FlowInfo {
-
-	/*
-	   Note: For flows which trap from the NNI and not really associated with any particular
-	   ONU (like LLDP), the onu_id and uni_id is set as -1. The intf_id is the NNI intf_id.
-	*/
+// GetFlowIDInfo returns the slice of flow info of the given pon-port
+// Note: For flows which trap from the NNI and not really associated with any particular
+// ONU (like LLDP), the onu_id and uni_id is set as -1. The intf_id is the NNI intf_id.
+func (RsrcMgr *OpenOltResourceMgr) GetFlowIDInfo(ponIntfID uint32, onuID uint32, uniID uint32, flowID uint32) *[]FlowInfo {
 	var flows []FlowInfo
 
-	FlowPath := fmt.Sprintf("%d,%d,%d", PONIntfID, ONUID, UNIID)
-	if err := RsrcMgr.ResourceMgrs[PONIntfID].GetFlowIDInfo(FlowPath, FlowID, &flows); err != nil {
-		log.Errorw("Error while getting flows from KV store", log.Fields{"flowId": FlowID})
+	FlowPath := fmt.Sprintf("%d,%d,%d", ponIntfID, onuID, uniID)
+	if err := RsrcMgr.ResourceMgrs[ponIntfID].GetFlowIDInfo(FlowPath, flowID, &flows); err != nil {
+		log.Errorw("Error while getting flows from KV store", log.Fields{"flowId": flowID})
 		return nil
 	}
 	if len(flows) == 0 {
@@ -379,82 +390,82 @@
 	return &flows
 }
 
+// GetCurrentFlowIDsForOnu fetches flow ID from the resource manager
+// Note: For flows which trap from the NNI and not really associated with any particular
+// ONU (like LLDP), the onu_id and uni_id is set as -1. The intf_id is the NNI intf_id.
 func (RsrcMgr *OpenOltResourceMgr) GetCurrentFlowIDsForOnu(PONIntfID uint32, ONUID uint32, UNIID uint32) []uint32 {
-	/*
-	   Note: For flows which trap from the NNI and not really associated with any particular
-	   ONU (like LLDP), the onu_id and uni_id is set as -1. The intf_id is the NNI intf_id.
-	*/
+
 	FlowPath := fmt.Sprintf("%d,%d,%d", PONIntfID, ONUID, UNIID)
 	return RsrcMgr.ResourceMgrs[PONIntfID].GetCurrentFlowIDsForOnu(FlowPath)
 }
 
-func (RsrcMgr *OpenOltResourceMgr) UpdateFlowIDInfo(PONIntfID int32, ONUID int32, UNIID int32,
-	FlowID uint32, FlowData *[]FlowInfo) error {
-
-	/*
-	   Note: For flows which trap from the NNI and not really associated with any particular
-	   ONU (like LLDP), the onu_id and uni_id is set as -1. The intf_id is the NNI intf_id.
-	*/
-	FlowPath := fmt.Sprintf("%d,%d,%d", PONIntfID, ONUID, UNIID)
-	return RsrcMgr.ResourceMgrs[uint32(PONIntfID)].UpdateFlowIDInfoForOnu(FlowPath, FlowID, *FlowData)
+// UpdateFlowIDInfo updates flow info for the given pon interface, onu id, and uni id
+// Note: For flows which trap from the NNI and not really associated with any particular
+// ONU (like LLDP), the onu_id and uni_id is set as -1. The intf_id is the NNI intf_id.
+func (RsrcMgr *OpenOltResourceMgr) UpdateFlowIDInfo(ponIntfID int32, onuID int32, uniID int32,
+	flowID uint32, flowData *[]FlowInfo) error {
+	FlowPath := fmt.Sprintf("%d,%d,%d", ponIntfID, onuID, uniID)
+	return RsrcMgr.ResourceMgrs[uint32(ponIntfID)].UpdateFlowIDInfoForOnu(FlowPath, flowID, *flowData)
 }
 
-func (RsrcMgr *OpenOltResourceMgr) GetFlowID(PONIntfID uint32, ONUID uint32, UNIID uint32,
-	FlowStoreCookie uint64,
-	FlowCategory string) (uint32, error) {
-
-	// Get flow ID for a given pon interface id, onu id and uni id.
+// GetFlowID return flow ID for a given pon interface id, onu id and uni id
+func (RsrcMgr *OpenOltResourceMgr) GetFlowID(ponIntfID uint32, ONUID uint32, uniID uint32,
+	flowStoreCookie uint64,
+	flowCategory string) (uint32, error) {
 
 	var err error
-	FlowPath := fmt.Sprintf("%d,%d,%d", PONIntfID, ONUID, UNIID)
-	FlowIDs := RsrcMgr.ResourceMgrs[PONIntfID].GetCurrentFlowIDsForOnu(FlowPath)
+	FlowPath := fmt.Sprintf("%d,%d,%d", ponIntfID, ONUID, uniID)
+	FlowIDs := RsrcMgr.ResourceMgrs[ponIntfID].GetCurrentFlowIDsForOnu(FlowPath)
 	if FlowIDs != nil {
-		log.Debugw("Found flowId(s) for this ONU", log.Fields{"pon": PONIntfID, "ONUID": ONUID, "UNIID": UNIID, "KVpath": FlowPath})
-		for _, flowId := range FlowIDs {
-			FlowInfo := RsrcMgr.GetFlowIDInfo(PONIntfID, ONUID, UNIID, uint32(flowId))
+		log.Debugw("Found flowId(s) for this ONU", log.Fields{"pon": ponIntfID, "ONUID": ONUID, "uniID": uniID, "KVpath": FlowPath})
+		for _, flowID := range FlowIDs {
+			FlowInfo := RsrcMgr.GetFlowIDInfo(ponIntfID, ONUID, uniID, uint32(flowID))
 			if FlowInfo != nil {
 				for _, Info := range *FlowInfo {
-					if FlowCategory != "" && Info.FlowCategory == FlowCategory {
-						log.Debug("Found flow matching with flow catagory", log.Fields{"flowId": flowId, "FlowCategory": FlowCategory})
-						return flowId, nil
+					if flowCategory != "" && Info.FlowCategory == flowCategory {
+						log.Debug("Found flow matching with flow category", log.Fields{"flowId": flowID, "flowCategory": flowCategory})
+						return flowID, nil
 					}
-					if FlowStoreCookie != 0 && Info.FlowStoreCookie == FlowStoreCookie {
-						log.Debug("Found flow matching with flowStore cookie", log.Fields{"flowId": flowId, "FlowStoreCookie": FlowStoreCookie})
-						return flowId, nil
+					if flowStoreCookie != 0 && Info.FlowStoreCookie == flowStoreCookie {
+						log.Debug("Found flow matching with flowStore cookie", log.Fields{"flowId": flowID, "flowStoreCookie": flowStoreCookie})
+						return flowID, nil
 					}
 				}
 			}
 		}
 	}
 	log.Debug("No matching flows with flow cookie or flow category, allocating new flowid")
-	FlowIDs, err = RsrcMgr.ResourceMgrs[PONIntfID].GetResourceID(PONIntfID,
+	FlowIDs, err = RsrcMgr.ResourceMgrs[ponIntfID].GetResourceID(ponIntfID,
 		ponrmgr.FLOW_ID, 1)
 	if err != nil {
 		log.Errorf("Failed to get resource for interface %d for type %s",
-			PONIntfID, ponrmgr.FLOW_ID)
+			ponIntfID, ponrmgr.FLOW_ID)
 		return uint32(0), err
 	}
 	if FlowIDs != nil {
-		RsrcMgr.ResourceMgrs[PONIntfID].UpdateFlowIDForOnu(FlowPath, FlowIDs[0], true)
+		_ = RsrcMgr.ResourceMgrs[ponIntfID].UpdateFlowIDForOnu(FlowPath, FlowIDs[0], true)
+		return FlowIDs[0], err
 	}
 
-	return FlowIDs[0], err
+	return 0, err
 }
 
-func (RsrcMgr *OpenOltResourceMgr) GetAllocID(IntfID uint32, ONUID uint32, UNIID uint32) uint32 {
+// GetAllocID return the first Alloc ID for a given pon interface id and onu id and then update the resource map on
+// the KV store with the list of alloc_ids allocated for the pon_intf_onu_id tuple
+// Currently of all the alloc_ids available, it returns the first alloc_id in the list for tha given ONU
+func (RsrcMgr *OpenOltResourceMgr) GetAllocID(intfID uint32, onuID uint32, uniID uint32) uint32 {
 
-	// Get alloc id for a given pon interface id and onu id.
 	var err error
-	IntfOnuIDUniID := fmt.Sprintf("%d,%d,%d", IntfID, ONUID, UNIID)
-	AllocID := RsrcMgr.ResourceMgrs[IntfID].GetCurrentAllocIDForOnu(IntfOnuIDUniID)
+	IntfOnuIDUniID := fmt.Sprintf("%d,%d,%d", intfID, onuID, uniID)
+	AllocID := RsrcMgr.ResourceMgrs[intfID].GetCurrentAllocIDForOnu(IntfOnuIDUniID)
 	if AllocID != nil {
 		// Since we support only one alloc_id for the ONU at the moment,
 		// return the first alloc_id in the list, if available, for that
 		// ONU.
-		log.Debugw("Retrived alloc ID from pon resource mgr", log.Fields{"AllocID": AllocID})
+		log.Debugw("Retrieved alloc ID from pon resource mgr", log.Fields{"AllocID": AllocID})
 		return AllocID[0]
 	}
-	AllocID, err = RsrcMgr.ResourceMgrs[IntfID].GetResourceID(IntfID,
+	AllocID, err = RsrcMgr.ResourceMgrs[intfID].GetResourceID(intfID,
 		ponrmgr.ALLOC_ID, 1)
 
 	if AllocID == nil || err != nil {
@@ -463,7 +474,7 @@
 	}
 	// update the resource map on KV store with the list of alloc_id
 	// allocated for the pon_intf_onu_id tuple
-	err = RsrcMgr.ResourceMgrs[IntfID].UpdateAllocIdsForOnu(IntfOnuIDUniID, AllocID)
+	err = RsrcMgr.ResourceMgrs[intfID].UpdateAllocIdsForOnu(IntfOnuIDUniID, AllocID)
 	if err != nil {
 		log.Error("Failed to update Alloc ID")
 		return 0
@@ -472,30 +483,30 @@
 	return AllocID[0]
 }
 
-func (RsrcMgr *OpenOltResourceMgr) UpdateAllocIdsForOnu(PONPort uint32, ONUID uint32, UNIID uint32, AllocID []uint32) error {
+// UpdateAllocIdsForOnu updates alloc ids in kv store for a given pon interface id, onu id and uni id
+func (RsrcMgr *OpenOltResourceMgr) UpdateAllocIdsForOnu(ponPort uint32, onuID uint32, uniID uint32, allocID []uint32) error {
 
-	/* update alloc ids in kv store for a given pon interface id,
-	   onu id and uni id.
-	*/
-	IntfOnuIDUniID := fmt.Sprintf("%d,%d,%d", PONPort, ONUID, UNIID)
-	return RsrcMgr.ResourceMgrs[PONPort].UpdateAllocIdsForOnu(IntfOnuIDUniID,
-		AllocID)
+	IntfOnuIDUniID := fmt.Sprintf("%d,%d,%d", ponPort, onuID, uniID)
+	return RsrcMgr.ResourceMgrs[ponPort].UpdateAllocIdsForOnu(IntfOnuIDUniID,
+		allocID)
 }
-func (RsrcMgr *OpenOltResourceMgr) GetCurrentGEMPortIDsForOnu(IntfID uint32, ONUID uint32,
-	UNIID uint32) []uint32 {
+
+// GetCurrentGEMPortIDsForOnu returns gem ports for given pon interface , onu id and uni id
+func (RsrcMgr *OpenOltResourceMgr) GetCurrentGEMPortIDsForOnu(intfID uint32, onuID uint32,
+	uniID uint32) []uint32 {
 
 	/* Get gem ports for given pon interface , onu id and uni id. */
 
-	IntfOnuIDUniID := fmt.Sprintf("%d,%d,%d", IntfID, ONUID, UNIID)
-	return RsrcMgr.ResourceMgrs[IntfID].GetCurrentGEMPortIDsForOnu(IntfOnuIDUniID)
+	IntfOnuIDUniID := fmt.Sprintf("%d,%d,%d", intfID, onuID, uniID)
+	return RsrcMgr.ResourceMgrs[intfID].GetCurrentGEMPortIDsForOnu(IntfOnuIDUniID)
 }
 
-func (RsrcMgr *OpenOltResourceMgr) GetCurrentAllocIDForOnu(IntfID uint32, ONUID uint32, UNIID uint32) uint32 {
+// GetCurrentAllocIDForOnu returns alloc ids for given pon interface and onu id
+// Currently of all the alloc_ids available, it returns the first alloc_id in the list for tha given ONU
+func (RsrcMgr *OpenOltResourceMgr) GetCurrentAllocIDForOnu(intfID uint32, onuID uint32, uniID uint32) uint32 {
 
-	/* Get alloc ids for given pon interface and onu id. */
-
-	IntfOnuIDUniID := fmt.Sprintf("%d,%d,%d", IntfID, ONUID, UNIID)
-	AllocID := RsrcMgr.ResourceMgrs[IntfID].GetCurrentAllocIDForOnu(IntfOnuIDUniID)
+	IntfOnuIDUniID := fmt.Sprintf("%d,%d,%d", intfID, onuID, uniID)
+	AllocID := RsrcMgr.ResourceMgrs[intfID].GetCurrentAllocIDForOnu(IntfOnuIDUniID)
 	if AllocID != nil {
 		// Since we support only one alloc_id for the ONU at the moment,
 		// return the first alloc_id in the list, if available, for that
@@ -505,22 +516,23 @@
 	return 0
 }
 
-func (RsrcMgr *OpenOltResourceMgr) UpdateGEMportsPonportToOnuMapOnKVStore(GEMPorts []uint32, PonPort uint32,
-	ONUID uint32, UNIID uint32) error {
+// UpdateGEMportsPonportToOnuMapOnKVStore updates onu and uni id associated with the gem port to the kv store
+// This stored information is used when packet_indication is received and we need to derive the ONU Id for which
+// the packet arrived based on the pon_intf and gemport available in the packet_indication
+func (RsrcMgr *OpenOltResourceMgr) UpdateGEMportsPonportToOnuMapOnKVStore(gemPorts []uint32, PonPort uint32,
+	onuID uint32, uniID uint32) error {
 
 	/* Update onu and uni id associated with the gem port to the kv store. */
 	var IntfGEMPortPath string
-	Data := fmt.Sprintf("%d %d", ONUID, UNIID)
-	for _, GEM := range GEMPorts {
+	Data := fmt.Sprintf("%d %d", onuID, uniID)
+	for _, GEM := range gemPorts {
 		IntfGEMPortPath = fmt.Sprintf("%d,%d", PonPort, GEM)
 		Val, err := json.Marshal(Data)
 		if err != nil {
 			log.Error("failed to Marshal")
 			return err
 		}
-		// This information is used when packet_indication is received and
-		// we need to derive the ONU Id for which the packet arrived based
-		// on the pon_intf and gemport available in the packet_indication
+
 		if err = RsrcMgr.KVStore.Put(IntfGEMPortPath, Val); err != nil {
 			log.Errorf("Failed to update resource %s", IntfGEMPortPath)
 			return err
@@ -529,56 +541,24 @@
 	return nil
 }
 
-func (RsrcMgr *OpenOltResourceMgr) GetONUUNIfromPONPortGEMPort(PONPort uint32, GEMPort uint32) (err error, OnuID uint32, UniID uint32) {
-
-	var ONUID uint32
-	var UNIID uint32
-	var Data string
-
-	/* get the onu and uni id for a given gem port and pon port */
-	IntfGEMPortPath := fmt.Sprintf("%d,%d", PONPort, GEMPort)
-	Value, err := RsrcMgr.KVStore.Get(IntfGEMPortPath)
-	if err == nil {
-		if Value != nil {
-			Val, _ := kvstore.ToByte(Value.Value)
-			if err = json.Unmarshal(Val, &Data); err != nil {
-				log.Error("Failed to unmarshal")
-				return err, ONUID, UNIID
-			}
-			IDs := strings.Split(Data, " ")
-			for index, val := range IDs {
-				switch index {
-				case 0:
-					if intval, err := strconv.Atoi(val); err == nil {
-						ONUID = uint32(intval)
-					}
-				case 1:
-					if intval, err := strconv.Atoi(val); err == nil {
-						UNIID = uint32(intval)
-					}
-				}
-			}
-		}
-	}
-	return err, ONUID, UNIID
-}
-
-func (RsrcMgr *OpenOltResourceMgr) GetGEMPortID(PONPort uint32, ONUID uint32,
-	UNIID uint32, NumOfPorts uint32) ([]uint32, error) {
+// GetGEMPortID gets gem port id for a particular pon port, onu id and uni id and then update the resource map on
+// the KV store with the list of gemport_id allocated for the pon_intf_onu_id tuple
+func (RsrcMgr *OpenOltResourceMgr) GetGEMPortID(ponPort uint32, onuID uint32,
+	uniID uint32, NumOfPorts uint32) ([]uint32, error) {
 
 	/* Get gem port id for a particular pon port, onu id
 	   and uni id.
 	*/
 
 	var err error
-	IntfOnuIDUniID := fmt.Sprintf("%d,%d,%d", PONPort, ONUID, UNIID)
+	IntfOnuIDUniID := fmt.Sprintf("%d,%d,%d", ponPort, onuID, uniID)
 
-	GEMPortList := RsrcMgr.ResourceMgrs[PONPort].GetCurrentGEMPortIDsForOnu(IntfOnuIDUniID)
+	GEMPortList := RsrcMgr.ResourceMgrs[ponPort].GetCurrentGEMPortIDsForOnu(IntfOnuIDUniID)
 	if GEMPortList != nil {
 		return GEMPortList, nil
 	}
 
-	GEMPortList, err = RsrcMgr.ResourceMgrs[PONPort].GetResourceID(PONPort,
+	GEMPortList, err = RsrcMgr.ResourceMgrs[ponPort].GetResourceID(ponPort,
 		ponrmgr.GEMPORT_ID, NumOfPorts)
 	if err != nil && GEMPortList == nil {
 		log.Errorf("Failed to get gem port id for %s", IntfOnuIDUniID)
@@ -587,123 +567,122 @@
 
 	// update the resource map on KV store with the list of gemport_id
 	// allocated for the pon_intf_onu_id tuple
-	err = RsrcMgr.ResourceMgrs[PONPort].UpdateGEMPortIDsForOnu(IntfOnuIDUniID,
+	err = RsrcMgr.ResourceMgrs[ponPort].UpdateGEMPortIDsForOnu(IntfOnuIDUniID,
 		GEMPortList)
 	if err != nil {
 		log.Errorf("Failed to update GEM ports to kv store for %s", IntfOnuIDUniID)
 		return nil, err
 	}
-	RsrcMgr.UpdateGEMportsPonportToOnuMapOnKVStore(GEMPortList, PONPort,
-		ONUID, UNIID)
+	_ = RsrcMgr.UpdateGEMportsPonportToOnuMapOnKVStore(GEMPortList, ponPort,
+		onuID, uniID)
 	return GEMPortList, err
 }
 
-func (RsrcMgr *OpenOltResourceMgr) UpdateGEMPortIDsForOnu(PONPort uint32, ONUID uint32,
-	UNIID uint32, GEMPortList []uint32) error {
-
-	/* Update gemport ids on to kv store for a given pon port,
-	   onu id and uni id.
-	*/
-	IntfOnuIDUniID := fmt.Sprintf("%d,%d,%d", PONPort, ONUID, UNIID)
-	return RsrcMgr.ResourceMgrs[PONPort].UpdateGEMPortIDsForOnu(IntfOnuIDUniID,
+// UpdateGEMPortIDsForOnu updates gemport ids on to the kv store for a given pon port, onu id and uni id
+func (RsrcMgr *OpenOltResourceMgr) UpdateGEMPortIDsForOnu(ponPort uint32, onuID uint32,
+	uniID uint32, GEMPortList []uint32) error {
+	IntfOnuIDUniID := fmt.Sprintf("%d,%d,%d", ponPort, onuID, uniID)
+	return RsrcMgr.ResourceMgrs[ponPort].UpdateGEMPortIDsForOnu(IntfOnuIDUniID,
 		GEMPortList)
 
 }
-func (RsrcMgr *OpenOltResourceMgr) FreeONUID(IntfID uint32, ONUID []uint32) {
+
+// FreeonuID releases(make free) onu id for a particular pon-port
+func (RsrcMgr *OpenOltResourceMgr) FreeonuID(intfID uint32, onuID []uint32) {
+
+	RsrcMgr.ResourceMgrs[intfID].FreeResourceID(intfID, ponrmgr.ONU_ID, onuID)
 
 	/* Free onu id for a particular interface.*/
-	RsrcMgr.ResourceMgrs[IntfID].FreeResourceID(IntfID, ponrmgr.ONU_ID, ONUID)
-
-	var IntfONUID string
-	for _, onu := range ONUID {
-		IntfONUID = fmt.Sprintf("%d,%d", IntfID, onu)
-		RsrcMgr.ResourceMgrs[IntfID].RemoveResourceMap(IntfONUID)
+	var IntfonuID string
+	for _, onu := range onuID {
+		IntfonuID = fmt.Sprintf("%d,%d", intfID, onu)
+		RsrcMgr.ResourceMgrs[intfID].RemoveResourceMap(IntfonuID)
 	}
-	return
 }
 
-func (RsrcMgr *OpenOltResourceMgr) FreeFlowID(IntfID uint32, ONUID uint32,
-	UNIID uint32, FlowId uint32) {
+// FreeFlowID returns the free flow id for a given interface, onu id and uni id
+func (RsrcMgr *OpenOltResourceMgr) FreeFlowID(IntfID uint32, onuID uint32,
+	uniID uint32, FlowID uint32) {
 	var IntfONUID string
 	var err error
-	IntfONUID = fmt.Sprintf("%d,%d,%d", IntfID, ONUID, UNIID)
-	err = RsrcMgr.ResourceMgrs[IntfID].UpdateFlowIDForOnu(IntfONUID, FlowId, false)
+	IntfONUID = fmt.Sprintf("%d,%d,%d", IntfID, onuID, uniID)
+	err = RsrcMgr.ResourceMgrs[IntfID].UpdateFlowIDForOnu(IntfONUID, FlowID, false)
 	if err != nil {
 		log.Error("Failed to Update flow id infor for %s", IntfONUID)
 	}
-	RsrcMgr.ResourceMgrs[IntfID].RemoveFlowIDInfo(IntfONUID, FlowId)
+	RsrcMgr.ResourceMgrs[IntfID].RemoveFlowIDInfo(IntfONUID, FlowID)
 }
 
-func (RsrcMgr *OpenOltResourceMgr) FreeFlowIDs(IntfID uint32, ONUID uint32,
-	UNIID uint32, FlowID []uint32) {
-
-	/* Free flow id for a given interface, onu id and uni id.*/
+// FreeFlowIDs releases the flow Ids
+func (RsrcMgr *OpenOltResourceMgr) FreeFlowIDs(IntfID uint32, onuID uint32,
+	uniID uint32, FlowID []uint32) {
 
 	RsrcMgr.ResourceMgrs[IntfID].FreeResourceID(IntfID, ponrmgr.FLOW_ID, FlowID)
 
 	var IntfOnuIDUniID string
 	var err error
 	for _, flow := range FlowID {
-		IntfOnuIDUniID = fmt.Sprintf("%d,%d,%d", IntfID, ONUID, UNIID)
+		IntfOnuIDUniID = fmt.Sprintf("%d,%d,%d", IntfID, onuID, uniID)
 		err = RsrcMgr.ResourceMgrs[IntfID].UpdateFlowIDForOnu(IntfOnuIDUniID, flow, false)
 		if err != nil {
 			log.Error("Failed to Update flow id infor for %s", IntfOnuIDUniID)
 		}
 		RsrcMgr.ResourceMgrs[IntfID].RemoveFlowIDInfo(IntfOnuIDUniID, flow)
 	}
-	return
 }
 
-func (RsrcMgr *OpenOltResourceMgr) FreePONResourcesForONU(IntfID uint32, ONUID uint32, UNIID uint32) {
+// FreePONResourcesForONU make the pon resources free for a given pon interface and onu id, and the clears the
+// resource map and the onuID associated with (pon_intf_id, gemport_id) tuple,
+func (RsrcMgr *OpenOltResourceMgr) FreePONResourcesForONU(intfID uint32, onuID uint32, uniID uint32) {
 
-	/* Free pon resources for a given pon interface and onu id. */
+	var onuIDs []uint32
+	onuIDs = append(onuIDs, onuID)
+	IntfOnuIDUniID := fmt.Sprintf("%d,%d,%d", intfID, onuID, uniID)
 
-	var ONUIDs []uint32
-	ONUIDs = append(ONUIDs, ONUID)
-	IntfOnuIDUniID := fmt.Sprintf("%d,%d,%d", IntfID, ONUID, UNIID)
+	AllocIDs := RsrcMgr.ResourceMgrs[intfID].GetCurrentAllocIDForOnu(IntfOnuIDUniID)
 
-	AllocIDs := RsrcMgr.ResourceMgrs[IntfID].GetCurrentAllocIDForOnu(IntfOnuIDUniID)
-
-	RsrcMgr.ResourceMgrs[IntfID].FreeResourceID(IntfID,
+	RsrcMgr.ResourceMgrs[intfID].FreeResourceID(intfID,
 		ponrmgr.ALLOC_ID,
 		AllocIDs)
 
-	GEMPortIDs := RsrcMgr.ResourceMgrs[IntfID].GetCurrentGEMPortIDsForOnu(IntfOnuIDUniID)
-	RsrcMgr.ResourceMgrs[IntfID].FreeResourceID(IntfID,
+	GEMPortIDs := RsrcMgr.ResourceMgrs[intfID].GetCurrentGEMPortIDsForOnu(IntfOnuIDUniID)
+	RsrcMgr.ResourceMgrs[intfID].FreeResourceID(intfID,
 		ponrmgr.GEMPORT_ID,
 		GEMPortIDs)
 
-	FlowIDs := RsrcMgr.ResourceMgrs[IntfID].GetCurrentFlowIDsForOnu(IntfOnuIDUniID)
-	RsrcMgr.ResourceMgrs[IntfID].FreeResourceID(IntfID,
+	FlowIDs := RsrcMgr.ResourceMgrs[intfID].GetCurrentFlowIDsForOnu(IntfOnuIDUniID)
+	RsrcMgr.ResourceMgrs[intfID].FreeResourceID(intfID,
 		ponrmgr.FLOW_ID,
 		FlowIDs)
-	RsrcMgr.ResourceMgrs[IntfID].FreeResourceID(IntfID,
+	RsrcMgr.ResourceMgrs[intfID].FreeResourceID(intfID,
 		ponrmgr.ONU_ID,
-		ONUIDs)
+		onuIDs)
 
 	// Clear resource map associated with (pon_intf_id, gemport_id) tuple.
-	RsrcMgr.ResourceMgrs[IntfID].RemoveResourceMap(IntfOnuIDUniID)
+	RsrcMgr.ResourceMgrs[intfID].RemoveResourceMap(IntfOnuIDUniID)
 
 	// Clear the ONU Id associated with the (pon_intf_id, gemport_id) tuple.
 	for _, GEM := range GEMPortIDs {
-		RsrcMgr.KVStore.Delete(fmt.Sprintf("%d,%d", IntfID, GEM))
+		_ = RsrcMgr.KVStore.Delete(fmt.Sprintf("%d,%d", intfID, GEM))
 	}
 }
 
-func (RsrcMgr *OpenOltResourceMgr) IsFlowCookieOnKVStore(PONIntfID uint32, ONUID uint32, UNIID uint32,
-	FlowStoreCookie uint64) bool {
+// IsFlowCookieOnKVStore checks if the given flow cookie is present on the kv store
+// Returns true if the flow cookie is found, otherwise it returns false
+func (RsrcMgr *OpenOltResourceMgr) IsFlowCookieOnKVStore(ponIntfID uint32, onuID uint32, uniID uint32,
+	flowStoreCookie uint64) bool {
 
-	FlowPath := fmt.Sprintf("%d,%d,%d", PONIntfID, ONUID, UNIID)
-	FlowIDs := RsrcMgr.ResourceMgrs[PONIntfID].GetCurrentFlowIDsForOnu(FlowPath)
+	FlowPath := fmt.Sprintf("%d,%d,%d", ponIntfID, onuID, uniID)
+	FlowIDs := RsrcMgr.ResourceMgrs[ponIntfID].GetCurrentFlowIDsForOnu(FlowPath)
 	if FlowIDs != nil {
-		log.Debugw("Found flowId(s) for this ONU", log.Fields{"pon": PONIntfID, "ONUID": ONUID, "UNIID": UNIID, "KVpath": FlowPath})
-		for _, flowId := range FlowIDs {
-			FlowInfo := RsrcMgr.GetFlowIDInfo(PONIntfID, ONUID, UNIID, uint32(flowId))
+		log.Debugw("Found flowId(s) for this ONU", log.Fields{"pon": ponIntfID, "onuID": onuID, "uniID": uniID, "KVpath": FlowPath})
+		for _, flowID := range FlowIDs {
+			FlowInfo := RsrcMgr.GetFlowIDInfo(ponIntfID, onuID, uniID, uint32(flowID))
 			if FlowInfo != nil {
-				log.Debugw("Found flows", log.Fields{"flows": *FlowInfo, "flowId": flowId})
+				log.Debugw("Found flows", log.Fields{"flows": *FlowInfo, "flowId": flowID})
 				for _, Info := range *FlowInfo {
-					if Info.FlowStoreCookie == FlowStoreCookie {
-						log.Debug("Found flow matching with flowStore cookie", log.Fields{"flowId": flowId, "FlowStoreCookie": FlowStoreCookie})
+					if Info.FlowStoreCookie == flowStoreCookie {
+						log.Debug("Found flow matching with flowStore cookie", log.Fields{"flowId": flowID, "flowStoreCookie": flowStoreCookie})
 						return true
 					}
 				}
diff --git a/adaptercore/statsmanager.go b/adaptercore/statsmanager.go
index 8d7f467..6b2dfdc 100755
--- a/adaptercore/statsmanager.go
+++ b/adaptercore/statsmanager.go
@@ -13,6 +13,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
+//Package adaptercore provides the utility for olt devices, flows and statistics
 package adaptercore
 
 import (
@@ -20,10 +22,11 @@
 	"fmt"
 
 	"github.com/opencord/voltha-go/common/log"
-	openolt "github.com/opencord/voltha-protos/go/openolt"
+	"github.com/opencord/voltha-protos/go/openolt"
 	"github.com/opencord/voltha-protos/go/voltha"
 )
 
+// PonPort representation
 type PonPort struct {
 	/*
 	   This is a highly reduced version taken from the adtran pon_port.
@@ -61,6 +64,7 @@
 	TxErrorPackets uint64
 }
 
+// NewPONPort returns a new instance of PonPort initialized with given PONID, DeviceID, IntfID and PortNum
 func NewPONPort(PONID uint32, DeviceID string, IntfID uint32, PortNum uint32) *PonPort {
 
 	var PON PonPort
@@ -109,6 +113,7 @@
 	return &PON
 }
 
+// NniPort representation
 type NniPort struct {
 	/*
 	   Northbound network port, often Ethernet-based
@@ -134,6 +139,7 @@
 	TxErrorPackets uint64
 }
 
+// NewNniPort returns a new instance of NniPort initialized with the given PortNum and IntfID
 func NewNniPort(PortNum uint32, IntfID uint32) *NniPort {
 
 	var NNI NniPort
@@ -157,6 +163,7 @@
 	return &NNI
 }
 
+// OpenOltStatisticsMgr structure
 type OpenOltStatisticsMgr struct {
 	Device         *DeviceHandler
 	NorthBoundPort map[uint32]NniPort
@@ -164,6 +171,7 @@
 	// TODO  PMMetrics Metrics
 }
 
+// NewOpenOltStatsMgr returns a new instance of the OpenOltStatisticsMgr
 func NewOpenOltStatsMgr(Dev *DeviceHandler) *OpenOltStatisticsMgr {
 
 	var StatMgr OpenOltStatisticsMgr
@@ -173,14 +181,15 @@
 	// Northbound and Southbound ports
 	// added to initialize the pm_metrics
 	var Ports interface{}
-	Ports, _ = InitPorts("nni", Dev.deviceId)
+	Ports, _ = InitPorts("nni", Dev.deviceID)
 	StatMgr.NorthBoundPort, _ = Ports.(map[uint32]NniPort)
-	Ports, _ = InitPorts("pon", Dev.deviceId)
+	Ports, _ = InitPorts("pon", Dev.deviceID)
 	StatMgr.SouthBoundPort, _ = Ports.(map[uint32]PonPort)
 
 	return &StatMgr
 }
 
+// InitPorts collects the port objects:  nni and pon that are updated with the current data from the OLT
 func InitPorts(Intftype string, DeviceID string) (interface{}, error) {
 	/*
 	     This method collects the port objects:  nni and pon that are updated with the
@@ -210,13 +219,14 @@
 		return PONPorts, nil
 	} else {
 		log.Errorf("Invalid type of interface %s", Intftype)
-		return nil, errors.New("Invalid type of interface ")
+		return nil, errors.New("invalid type of interface ")
 	}
 }
 
+// BuildPortObject allows for updating north and southbound ports, newly discovered ports, and devices
 func BuildPortObject(PortNum uint32, IntfType string, DeviceID string) interface{} {
 	/*
-	   Seperate method to allow for updating north and southbound ports
+	   Separate method to allow for updating north and southbound ports
 	   newly discovered ports and devices
 
 	   :param port_num:
@@ -227,12 +237,12 @@
 	//This builds a port object which is added to the
 	//appropriate northbound or southbound values
 	if IntfType == "nni" {
-		IntfID := IntfIdToPortNo(PortNum, voltha.Port_ETHERNET_UNI)
+		IntfID := IntfIDToPortNo(PortNum, voltha.Port_ETHERNET_UNI)
 		return NewNniPort(PortNum, IntfID)
 	} else if IntfType == "pon" {
 		// PON ports require a different configuration
 		//  intf_id and pon_id are currently equal.
-		IntfID := IntfIdToPortNo(PortNum, voltha.Port_ETHERNET_NNI)
+		IntfID := IntfIDToPortNo(PortNum, voltha.Port_ETHERNET_NNI)
 		PONID := IntfID
 		return NewPONPort(PONID, DeviceID, IntfID, PortNum)
 	} else {
@@ -241,17 +251,20 @@
 	}
 }
 
+// PortStatisticsIndication handles the port statistics indication
 func (StatMgr *OpenOltStatisticsMgr) PortStatisticsIndication(PortStats *openolt.PortStatistics) {
 	log.Debugf("port-stats-collected %v", PortStats)
 	StatMgr.PortsStatisticsKpis(PortStats)
 	// TODO send stats to core topic to the voltha kafka or a different kafka ?
 }
 
+// FlowStatisticsIndication to be implemented
 func FlowStatisticsIndication(self, FlowStats *openolt.FlowStatistics) {
 	log.Debugf("flow-stats-collected %v", FlowStats)
 	//TODO send to kafka ?
 }
 
+// PortsStatisticsKpis map the port stats values into a dictionary, creates the kpiEvent and then publish to Kafka
 func (StatMgr *OpenOltStatisticsMgr) PortsStatisticsKpis(PortStats *openolt.PortStatistics) {
 
 	/*map the port stats values into a dictionary
@@ -263,55 +276,54 @@
 	//var err error
 	IntfID := PortStats.IntfId
 
-	if (IntfIdToPortNo(0, voltha.Port_ETHERNET_NNI) < IntfID) &&
-		(IntfID < IntfIdToPortNo(4, voltha.Port_ETHERNET_NNI)) {
+	if (IntfIDToPortNo(0, voltha.Port_ETHERNET_NNI) < IntfID) &&
+		(IntfID < IntfIDToPortNo(4, voltha.Port_ETHERNET_NNI)) {
 		/*
 		   for this release we are only interested in the first NNI for
 		   Northbound.
 		   we are not using the other 3
 		*/
 		return
-	} else {
-
-		PMData := make(map[string]uint64)
-		PMData["rx_bytes"] = PortStats.RxBytes
-		PMData["rx_packets"] = PortStats.RxPackets
-		PMData["rx_ucast_packets"] = PortStats.RxUcastPackets
-		PMData["rx_mcast_packets"] = PortStats.RxMcastPackets
-		PMData["rx_bcast_packets"] = PortStats.RxBcastPackets
-		PMData["rx_error_packets"] = PortStats.RxErrorPackets
-		PMData["tx_bytes"] = PortStats.TxBytes
-		PMData["tx_packets"] = PortStats.TxPackets
-		PMData["tx_ucast_packets"] = PortStats.TxUcastPackets
-		PMData["tx_mcast_packets"] = PortStats.TxMcastPackets
-		PMData["tx_bcast_packets"] = PortStats.TxBcastPackets
-		PMData["tx_error_packets"] = PortStats.TxErrorPackets
-		PMData["rx_crc_errors"] = PortStats.RxCrcErrors
-		PMData["bip_errors"] = PortStats.BipErrors
-
-		PMData["intf_id"] = uint64(PortStats.IntfId)
-
-		/*
-		   Based upon the intf_id map to an nni port or a pon port
-		   the intf_id is the key to the north or south bound collections
-
-		   Based upon the intf_id the port object (nni_port or pon_port) will
-		   have its data attr. updated by the current dataset collected.
-
-		   For prefixing the rule is currently to use the port number and not the intf_id
-		*/
-		//FIXME : Just use first NNI for now
-		/* TODO should the data be marshalled before sending it ?
-		   if IntfID == IntfIdToPortNo(0, voltha.Port_ETHERNET_NNI) {
-		       //NNI port (just the first one)
-		       err = UpdatePortObjectKpiData(StatMgr.NorthBoundPorts[PortStats.IntfID], PMData)
-		   } else {
-		       //PON ports
-		       err = UpdatePortObjectKpiData(SouthboundPorts[PortStats.IntfID], PMData)
-		   }
-		   if (err != nil) {
-		       log.Error("Error publishing statistics data")
-		   }
-		*/
 	}
+	PMData := make(map[string]uint64)
+	PMData["rx_bytes"] = PortStats.RxBytes
+	PMData["rx_packets"] = PortStats.RxPackets
+	PMData["rx_ucast_packets"] = PortStats.RxUcastPackets
+	PMData["rx_mcast_packets"] = PortStats.RxMcastPackets
+	PMData["rx_bcast_packets"] = PortStats.RxBcastPackets
+	PMData["rx_error_packets"] = PortStats.RxErrorPackets
+	PMData["tx_bytes"] = PortStats.TxBytes
+	PMData["tx_packets"] = PortStats.TxPackets
+	PMData["tx_ucast_packets"] = PortStats.TxUcastPackets
+	PMData["tx_mcast_packets"] = PortStats.TxMcastPackets
+	PMData["tx_bcast_packets"] = PortStats.TxBcastPackets
+	PMData["tx_error_packets"] = PortStats.TxErrorPackets
+	PMData["rx_crc_errors"] = PortStats.RxCrcErrors
+	PMData["bip_errors"] = PortStats.BipErrors
+
+	PMData["intf_id"] = uint64(PortStats.IntfId)
+
+	/*
+	   Based upon the intf_id map to an nni port or a pon port
+	   the intf_id is the key to the north or south bound collections
+
+	   Based upon the intf_id the port object (nni_port or pon_port) will
+	   have its data attr. updated by the current dataset collected.
+
+	   For prefixing the rule is currently to use the port number and not the intf_id
+	*/
+	//FIXME : Just use first NNI for now
+	/* TODO should the data be marshaled before sending it ?
+	   if IntfID == IntfIdToPortNo(0, voltha.Port_ETHERNET_NNI) {
+	       //NNI port (just the first one)
+	       err = UpdatePortObjectKpiData(StatMgr.NorthBoundPorts[PortStats.IntfID], PMData)
+	   } else {
+	       //PON ports
+	       err = UpdatePortObjectKpiData(SouthboundPorts[PortStats.IntfID], PMData)
+	   }
+	   if (err != nil) {
+	       log.Error("Error publishing statistics data")
+	   }
+	*/
+
 }
diff --git a/config/config.go b/config/config.go
index 7eaaeb6..0a47ef2 100644
--- a/config/config.go
+++ b/config/config.go
@@ -13,6 +13,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
+//Package config provides the Log, kvstore, Kafka configuration
 package config
 
 import (
@@ -24,21 +26,21 @@
 
 // Open OLT default constants
 const (
-	EtcdStoreName            = "etcd"
-	default_InstanceID       = "openOlt001"
-	default_KafkaAdapterHost = "127.0.0.1"
-	default_KafkaAdapterPort = 9092
-	default_KafkaClusterHost = "127.0.0.1"
-	default_KafkaClusterPort = 9094
-	default_KVStoreType      = EtcdStoreName
-	default_KVStoreTimeout   = 5 //in seconds
-	default_KVStoreHost      = "127.0.0.1"
-	default_KVStorePort      = 2379 // Consul = 8500; Etcd = 2379
-	default_LogLevel         = 0
-	default_Banner           = false
-	default_Topic            = "openolt"
-	default_CoreTopic        = "rwcore"
-	default_OnuNumber        = 1
+	EtcdStoreName           = "etcd"
+	defaultInstanceid       = "openOlt001"
+	defaultKafkaadapterhost = "127.0.0.1"
+	defaultKafkaadapterport = 9092
+	defaultKafkaclusterhost = "127.0.0.1"
+	defaultKafkaclusterport = 9094
+	defaultKvstoretype      = EtcdStoreName
+	defaultKvstoretimeout   = 5 //in seconds
+	defaultKvstorehost      = "127.0.0.1"
+	defaultKvstoreport      = 2379 // Consul = 8500; Etcd = 2379
+	defaultLoglevel         = 0
+	defaultBanner           = false
+	defaultTopic            = "openolt"
+	defaultCoretopic        = "rwcore"
+	defaultOnunumber        = 1
 )
 
 // AdapterFlags represents the set of configurations used by the read-write adaptercore service
@@ -61,26 +63,26 @@
 }
 
 func init() {
-	log.AddPackage(log.JSON, log.WarnLevel, nil)
+	_, _ = log.AddPackage(log.JSON, log.WarnLevel, nil)
 }
 
-// NewRWCoreFlags returns a new RWCore config
+// NewAdapterFlags returns a new RWCore config
 func NewAdapterFlags() *AdapterFlags {
 	var adapterFlags = AdapterFlags{ // Default values
-		InstanceID:       default_InstanceID,
-		KafkaAdapterHost: default_KafkaAdapterHost,
-		KafkaAdapterPort: default_KafkaAdapterPort,
-		KafkaClusterHost: default_KafkaClusterHost,
-		KafkaClusterPort: default_KafkaClusterPort,
-		KVStoreType:      default_KVStoreType,
-		KVStoreTimeout:   default_KVStoreTimeout,
-		KVStoreHost:      default_KVStoreHost,
-		KVStorePort:      default_KVStorePort,
-		Topic:            default_Topic,
-		CoreTopic:        default_CoreTopic,
-		LogLevel:         default_LogLevel,
-		OnuNumber:        default_OnuNumber,
-		Banner:           default_Banner,
+		InstanceID:       defaultInstanceid,
+		KafkaAdapterHost: defaultKafkaadapterhost,
+		KafkaAdapterPort: defaultKafkaadapterport,
+		KafkaClusterHost: defaultKafkaclusterhost,
+		KafkaClusterPort: defaultKafkaclusterport,
+		KVStoreType:      defaultKvstoretype,
+		KVStoreTimeout:   defaultKvstoretimeout,
+		KVStoreHost:      defaultKvstorehost,
+		KVStorePort:      defaultKvstoreport,
+		Topic:            defaultTopic,
+		CoreTopic:        defaultCoretopic,
+		LogLevel:         defaultLoglevel,
+		OnuNumber:        defaultOnunumber,
+		Banner:           defaultBanner,
 	}
 	return &adapterFlags
 }
@@ -88,46 +90,44 @@
 // ParseCommandArguments parses the arguments when running read-write adaptercore service
 func (so *AdapterFlags) ParseCommandArguments() {
 
-	var help string
-
-	help = fmt.Sprintf("Kafka - Adapter messaging host")
-	flag.StringVar(&(so.KafkaAdapterHost), "kafka_adapter_host", default_KafkaAdapterHost, help)
+	help := fmt.Sprintf("Kafka - Adapter messaging host")
+	flag.StringVar(&(so.KafkaAdapterHost), "kafka_adapter_host", defaultKafkaadapterhost, help)
 
 	help = fmt.Sprintf("Kafka - Adapter messaging port")
-	flag.IntVar(&(so.KafkaAdapterPort), "kafka_adapter_port", default_KafkaAdapterPort, help)
+	flag.IntVar(&(so.KafkaAdapterPort), "kafka_adapter_port", defaultKafkaadapterport, help)
 
 	help = fmt.Sprintf("Kafka - Cluster messaging host")
-	flag.StringVar(&(so.KafkaClusterHost), "kafka_cluster_host", default_KafkaClusterHost, help)
+	flag.StringVar(&(so.KafkaClusterHost), "kafka_cluster_host", defaultKafkaclusterhost, help)
 
 	help = fmt.Sprintf("Kafka - Cluster messaging port")
-	flag.IntVar(&(so.KafkaClusterPort), "kafka_cluster_port", default_KafkaClusterPort, help)
+	flag.IntVar(&(so.KafkaClusterPort), "kafka_cluster_port", defaultKafkaclusterport, help)
 
 	help = fmt.Sprintf("Open OLT topic")
-	flag.StringVar(&(so.Topic), "adapter_topic", default_Topic, help)
+	flag.StringVar(&(so.Topic), "adapter_topic", defaultTopic, help)
 
 	help = fmt.Sprintf("Core topic")
-	flag.StringVar(&(so.CoreTopic), "core_topic", default_CoreTopic, help)
+	flag.StringVar(&(so.CoreTopic), "core_topic", defaultCoretopic, help)
 
 	help = fmt.Sprintf("KV store type")
-	flag.StringVar(&(so.KVStoreType), "kv_store_type", default_KVStoreType, help)
+	flag.StringVar(&(so.KVStoreType), "kv_store_type", defaultKvstoretype, help)
 
 	help = fmt.Sprintf("The default timeout when making a kv store request")
-	flag.IntVar(&(so.KVStoreTimeout), "kv_store_request_timeout", default_KVStoreTimeout, help)
+	flag.IntVar(&(so.KVStoreTimeout), "kv_store_request_timeout", defaultKvstoretimeout, help)
 
 	help = fmt.Sprintf("KV store host")
-	flag.StringVar(&(so.KVStoreHost), "kv_store_host", default_KVStoreHost, help)
+	flag.StringVar(&(so.KVStoreHost), "kv_store_host", defaultKvstorehost, help)
 
 	help = fmt.Sprintf("KV store port")
-	flag.IntVar(&(so.KVStorePort), "kv_store_port", default_KVStorePort, help)
+	flag.IntVar(&(so.KVStorePort), "kv_store_port", defaultKvstoreport, help)
 
 	help = fmt.Sprintf("Log level")
-	flag.IntVar(&(so.LogLevel), "log_level", default_LogLevel, help)
+	flag.IntVar(&(so.LogLevel), "log_level", defaultLoglevel, help)
 
 	help = fmt.Sprintf("Number of ONUs")
-	flag.IntVar(&(so.OnuNumber), "onu_number", default_OnuNumber, help)
+	flag.IntVar(&(so.OnuNumber), "onu_number", defaultOnunumber, help)
 
 	help = fmt.Sprintf("Show startup banner log lines")
-	flag.BoolVar(&so.Banner, "banner", default_Banner, help)
+	flag.BoolVar(&so.Banner, "banner", defaultBanner, help)
 
 	flag.Parse()
 
diff --git a/main.go b/main.go
index 9c0bd8c..519aedb 100644
--- a/main.go
+++ b/main.go
@@ -13,6 +13,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
+//Package main invokes the application
 package main
 
 import (
@@ -36,7 +38,7 @@
 )
 
 type adapter struct {
-	instanceId       string
+	instanceID       string
 	config           *config.AdapterFlags
 	iAdapter         adapters.IAdapter
 	kafkaClient      kafka.Client
@@ -50,12 +52,12 @@
 }
 
 func init() {
-	log.AddPackage(log.JSON, log.DebugLevel, nil)
+	_, _ = log.AddPackage(log.JSON, log.DebugLevel, nil)
 }
 
 func newAdapter(cf *config.AdapterFlags) *adapter {
 	var a adapter
-	a.instanceId = cf.InstanceID
+	a.instanceID = cf.InstanceID
 	a.config = cf
 	a.halted = false
 	a.exitChannel = make(chan int, 1)
@@ -69,7 +71,7 @@
 
 	// Setup KV Client
 	log.Debugw("create-kv-client", log.Fields{"kvstore": a.config.KVStoreType})
-	if err := a.setKVClient(); err != nil {
+	if err = a.setKVClient(); err != nil {
 		log.Fatal("error-setting-kv-client")
 	}
 
@@ -90,42 +92,43 @@
 	a.adapterProxy = com.NewAdapterProxy(a.kip, "brcm_openomci_onu", a.config.CoreTopic)
 
 	// Create the open OLT adapter
-	if a.iAdapter, err = a.startOpenOLT(ctx, a.kip, a.coreProxy, a.adapterProxy, a.config.OnuNumber, a.config.KVStoreHost, a.config.KVStorePort, a.config.KVStoreType); err != nil {
+	if a.iAdapter, err = a.startOpenOLT(ctx, a.kip, a.coreProxy, a.adapterProxy, a.config.OnuNumber,
+		a.config.KVStoreHost, a.config.KVStorePort, a.config.KVStoreType); err != nil {
 		log.Fatal("error-starting-inter-container-proxy")
 	}
 
 	// Register the core request handler
-	if err = a.setupRequestHandler(a.instanceId, a.iAdapter); err != nil {
+	if err = a.setupRequestHandler(a.instanceID, a.iAdapter); err != nil {
 		log.Fatal("error-setting-core-request-handler")
 	}
 
-	//    Register this adapter to the Core - retries indefinitely
+	// Register this adapter to the Core - retries indefinitely
 	if err = a.registerWithCore(-1); err != nil {
 		log.Fatal("error-registering-with-core")
 	}
 }
 
-func (rw *adapter) stop() {
+func (a *adapter) stop() {
 	// Stop leadership tracking
-	rw.halted = true
+	a.halted = true
 
 	// send exit signal
-	rw.exitChannel <- 0
+	a.exitChannel <- 0
 
 	// Cleanup - applies only if we had a kvClient
-	if rw.kvClient != nil {
+	if a.kvClient != nil {
 		// Release all reservations
-		if err := rw.kvClient.ReleaseAllReservations(); err != nil {
+		if err := a.kvClient.ReleaseAllReservations(); err != nil {
 			log.Infow("fail-to-release-all-reservations", log.Fields{"error": err})
 		}
 		// Close the DB connection
-		rw.kvClient.Close()
+		a.kvClient.Close()
 	}
 
 	// TODO:  More cleanup
 }
 
-func newKVClient(storeType string, address string, timeout int) (kvstore.Client, error) {
+func newKVClient(storeType, address string, timeout int) (kvstore.Client, error) {
 
 	log.Infow("kv-store-type", log.Fields{"store": storeType})
 	switch storeType {
@@ -137,7 +140,7 @@
 	return nil, errors.New("unsupported-kv-store")
 }
 
-func newKafkaClient(clientType string, host string, port int) (kafka.Client, error) {
+func newKafkaClient(clientType, host string, port int) (kafka.Client, error) {
 
 	log.Infow("common-client-type", log.Fields{"client": clientType})
 	switch clientType {
@@ -150,6 +153,7 @@
 			kafka.ProducerMaxRetries(6),
 			kafka.ProducerRetryBackoff(time.Millisecond*30)), nil
 	}
+
 	return nil, errors.New("unsupported-client-type")
 }
 
@@ -165,17 +169,6 @@
 	return nil
 }
 
-func toString(value interface{}) (string, error) {
-	switch t := value.(type) {
-	case []byte:
-		return string(value.([]byte)), nil
-	case string:
-		return value.(string), nil
-	default:
-		return "", fmt.Errorf("unexpected-type-%T", t)
-	}
-}
-
 func (a *adapter) startInterContainerProxy(retries int) (*kafka.InterContainerProxy, error) {
 	log.Infow("starting-intercontainer-messaging-proxy", log.Fields{"host": a.config.KafkaAdapterHost,
 		"port": a.config.KafkaAdapterPort, "topic": a.config.Topic})
@@ -197,7 +190,7 @@
 				return nil, err
 			}
 			count = +1
-			//    Take a nap before retrying
+			// Take a nap before retrying
 			time.Sleep(2 * time.Second)
 		} else {
 			break
@@ -222,9 +215,9 @@
 	return sOLT, nil
 }
 
-func (a *adapter) setupRequestHandler(coreInstanceId string, iadapter adapters.IAdapter) error {
+func (a *adapter) setupRequestHandler(coreInstanceID string, iadapter adapters.IAdapter) error {
 	log.Info("setting-request-handler")
-	requestProxy := com.NewRequestHandlerProxy(coreInstanceId, iadapter, a.coreProxy)
+	requestProxy := com.NewRequestHandlerProxy(coreInstanceID, iadapter, a.coreProxy)
 	if err := a.kip.SubscribeWithRequestHandlerInterface(kafka.Topic{Name: a.config.Topic}, requestProxy); err != nil {
 		log.Errorw("request-handler-setup-failed", log.Fields{"error": err})
 		return err
@@ -239,19 +232,19 @@
 	adapterDescription := &voltha.Adapter{Id: "openolt", // Unique name for the device type
 		Vendor: "simulation Enterprise Inc"}
 	types := []*voltha.DeviceType{{Id: "openolt",
-		Adapter:                     "openolt", //Name of the adapter that handles device type
+		Adapter:                     "openolt", // Name of the adapter that handles device type
 		AcceptsBulkFlowUpdate:       false,     // Currently openolt adapter does not support bulk flow handling
 		AcceptsAddRemoveFlowUpdates: true}}
 	deviceTypes := &voltha.DeviceTypes{Items: types}
 	count := 0
 	for {
-		if err := a.coreProxy.RegisterAdapter(nil, adapterDescription, deviceTypes); err != nil {
+		if err := a.coreProxy.RegisterAdapter(context.TODO(), adapterDescription, deviceTypes); err != nil {
 			log.Warnw("registering-with-core-failed", log.Fields{"error": err})
 			if retries == count {
 				return err
 			}
-			count += 1
-			//    Take a nap before retrying
+			count++
+			// Take a nap before retrying
 			time.Sleep(2 * time.Second)
 		} else {
 			break
@@ -308,15 +301,15 @@
 	cf := config.NewAdapterFlags()
 	cf.ParseCommandArguments()
 
-	//// Setup logging
+	// Setup logging
 
-	//Setup default logger - applies for packages that do not have specific logger set
-	if _, err := log.SetDefaultLogger(log.JSON, cf.LogLevel, log.Fields{"instanceId": cf.InstanceID}); err != nil {
+	// Setup default logger - applies for packages that do not have specific logger set
+	if _, err := log.SetDefaultLogger(log.JSON, cf.LogLevel, log.Fields{"instanceID": cf.InstanceID}); err != nil {
 		log.With(log.Fields{"error": err}).Fatal("Cannot setup logging")
 	}
 
 	// Update all loggers (provisionned via init) with a common field
-	if err := log.UpdateAllLoggers(log.Fields{"instanceId": cf.InstanceID}); err != nil {
+	if err := log.UpdateAllLoggers(log.Fields{"instanceID": cf.InstanceID}); err != nil {
 		log.With(log.Fields{"error": err}).Fatal("Cannot setup logging")
 	}
 
@@ -344,5 +337,5 @@
 	ad.stop()
 
 	elapsed := time.Since(start)
-	log.Infow("run-time", log.Fields{"instanceId": ad.config.InstanceID, "time": elapsed / time.Second})
+	log.Infow("run-time", log.Fields{"instanceID": ad.config.InstanceID, "time": elapsed / time.Second})
 }