diff --git a/rw_core/config/config.go b/rw_core/config/config.go
index 68dca2c..5ba2f3c 100644
--- a/rw_core/config/config.go
+++ b/rw_core/config/config.go
@@ -13,52 +13,55 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package config
 
 import (
 	"flag"
 	"fmt"
-	"github.com/opencord/voltha-lib-go/v2/pkg/log"
+
 	"time"
+
+	"github.com/opencord/voltha-lib-go/v2/pkg/log"
 )
 
 // RW Core service default constants
 const (
-	ConsulStoreName                   = "consul"
-	EtcdStoreName                     = "etcd"
-	default_GrpcPort                  = 50057
-	default_GrpcHost                  = ""
-	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_KVTxnKeyDelTime           = 60
-	default_KVStoreDataPrefix         = "service/voltha"
-	default_LogLevel                  = 0
-	default_Banner                    = false
-	default_DisplayVersionOnly        = false
-	default_CoreTopic                 = "rwcore"
-	default_RWCoreEndpoint            = "rwcore"
-	default_RWCoreKey                 = "pki/voltha.key"
-	default_RWCoreCert                = "pki/voltha.crt"
-	default_RWCoreCA                  = "pki/voltha-CA.pem"
-	default_AffinityRouterTopic       = "affinityRouter"
-	default_InCompetingMode           = true
-	default_LongRunningRequestTimeout = int64(2000)
-	default_DefaultRequestTimeout     = int64(500)
-	default_CoreTimeout               = int64(500)
-	default_CoreBindingKey            = "voltha_backend_name"
-	default_CorePairTopic             = "rwcore_1"
-	default_MaxConnectionRetries      = -1 // retries forever
-	default_ConnectionRetryInterval   = 2 * time.Second
-	default_LiveProbeInterval         = 60 * time.Second
-	default_NotLiveProbeInterval      = 5 * time.Second // Probe more frequently when not alive
-	default_ProbeHost                 = ""
-	default_ProbePort                 = 8080
+	ConsulStoreName                  = "consul"
+	EtcdStoreName                    = "etcd"
+	defaultGrpcPort                  = 50057
+	defaultGrpcHost                  = ""
+	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
+	defaultKVTxnKeyDelTime           = 60
+	defaultKVStoreDataPrefix         = "service/voltha"
+	defaultLogLevel                  = 0
+	defaultBanner                    = false
+	defaultDisplayVersionOnly        = false
+	defaultCoreTopic                 = "rwcore"
+	defaultRWCoreEndpoint            = "rwcore"
+	defaultRWCoreKey                 = "pki/voltha.key"
+	defaultRWCoreCert                = "pki/voltha.crt"
+	defaultRWCoreCA                  = "pki/voltha-CA.pem"
+	defaultAffinityRouterTopic       = "affinityRouter"
+	defaultInCompetingMode           = true
+	defaultLongRunningRequestTimeout = int64(2000)
+	defaultDefaultRequestTimeout     = int64(500)
+	defaultCoreTimeout               = int64(500)
+	defaultCoreBindingKey            = "voltha_backend_name"
+	defaultCorePairTopic             = "rwcore_1"
+	defaultMaxConnectionRetries      = -1 // retries forever
+	defaultConnectionRetryInterval   = 2 * time.Second
+	defaultLiveProbeInterval         = 60 * time.Second
+	defaultNotLiveProbeInterval      = 5 * time.Second // Probe more frequently when not alive
+	defaultProbeHost                 = ""
+	defaultProbePort                 = 8080
 )
 
 // RWCoreFlags represents the set of configurations used by the read-write core service
@@ -100,45 +103,48 @@
 }
 
 func init() {
-	log.AddPackage(log.JSON, log.WarnLevel, nil)
+	_, err := log.AddPackage(log.JSON, log.WarnLevel, nil)
+	if err != nil {
+		log.Errorw("unable-to-register-a-package-to-the-log-map", log.Fields{"error": err})
+	}
 }
 
 // NewRWCoreFlags returns a new RWCore config
 func NewRWCoreFlags() *RWCoreFlags {
 	var rwCoreFlag = RWCoreFlags{ // Default values
-		RWCoreEndpoint:            default_RWCoreEndpoint,
-		GrpcHost:                  default_GrpcHost,
-		GrpcPort:                  default_GrpcPort,
-		KafkaAdapterHost:          default_KafkaAdapterHost,
-		KafkaAdapterPort:          default_KafkaAdapterPort,
-		KafkaClusterHost:          default_KafkaClusterHost,
-		KafkaClusterPort:          default_KafkaClusterPort,
-		KVStoreType:               default_KVStoreType,
-		KVStoreTimeout:            default_KVStoreTimeout,
-		KVStoreHost:               default_KVStoreHost,
-		KVStorePort:               default_KVStorePort,
-		KVStoreDataPrefix:         default_KVStoreDataPrefix,
-		KVTxnKeyDelTime:           default_KVTxnKeyDelTime,
-		CoreTopic:                 default_CoreTopic,
-		LogLevel:                  default_LogLevel,
-		Banner:                    default_Banner,
-		DisplayVersionOnly:        default_DisplayVersionOnly,
-		RWCoreKey:                 default_RWCoreKey,
-		RWCoreCert:                default_RWCoreCert,
-		RWCoreCA:                  default_RWCoreCA,
-		AffinityRouterTopic:       default_AffinityRouterTopic,
-		InCompetingMode:           default_InCompetingMode,
-		DefaultRequestTimeout:     default_DefaultRequestTimeout,
-		LongRunningRequestTimeout: default_LongRunningRequestTimeout,
-		DefaultCoreTimeout:        default_CoreTimeout,
-		CoreBindingKey:            default_CoreBindingKey,
-		CorePairTopic:             default_CorePairTopic,
-		MaxConnectionRetries:      default_MaxConnectionRetries,
-		ConnectionRetryInterval:   default_ConnectionRetryInterval,
-		LiveProbeInterval:         default_LiveProbeInterval,
-		NotLiveProbeInterval:      default_NotLiveProbeInterval,
-		ProbeHost:                 default_ProbeHost,
-		ProbePort:                 default_ProbePort,
+		RWCoreEndpoint:            defaultRWCoreEndpoint,
+		GrpcHost:                  defaultGrpcHost,
+		GrpcPort:                  defaultGrpcPort,
+		KafkaAdapterHost:          defaultKafkaAdapterHost,
+		KafkaAdapterPort:          defaultKafkaAdapterPort,
+		KafkaClusterHost:          defaultKafkaClusterHost,
+		KafkaClusterPort:          defaultKafkaClusterPort,
+		KVStoreType:               defaultKVStoreType,
+		KVStoreTimeout:            defaultKVStoreTimeout,
+		KVStoreHost:               defaultKVStoreHost,
+		KVStorePort:               defaultKVStorePort,
+		KVStoreDataPrefix:         defaultKVStoreDataPrefix,
+		KVTxnKeyDelTime:           defaultKVTxnKeyDelTime,
+		CoreTopic:                 defaultCoreTopic,
+		LogLevel:                  defaultLogLevel,
+		Banner:                    defaultBanner,
+		DisplayVersionOnly:        defaultDisplayVersionOnly,
+		RWCoreKey:                 defaultRWCoreKey,
+		RWCoreCert:                defaultRWCoreCert,
+		RWCoreCA:                  defaultRWCoreCA,
+		AffinityRouterTopic:       defaultAffinityRouterTopic,
+		InCompetingMode:           defaultInCompetingMode,
+		DefaultRequestTimeout:     defaultDefaultRequestTimeout,
+		LongRunningRequestTimeout: defaultLongRunningRequestTimeout,
+		DefaultCoreTimeout:        defaultCoreTimeout,
+		CoreBindingKey:            defaultCoreBindingKey,
+		CorePairTopic:             defaultCorePairTopic,
+		MaxConnectionRetries:      defaultMaxConnectionRetries,
+		ConnectionRetryInterval:   defaultConnectionRetryInterval,
+		LiveProbeInterval:         defaultLiveProbeInterval,
+		NotLiveProbeInterval:      defaultNotLiveProbeInterval,
+		ProbeHost:                 defaultProbeHost,
+		ProbePort:                 defaultProbePort,
 	}
 	return &rwCoreFlag
 }
@@ -146,97 +152,95 @@
 // ParseCommandArguments parses the arguments when running read-write core service
 func (cf *RWCoreFlags) ParseCommandArguments() {
 
-	var help string
-
-	help = fmt.Sprintf("RW core endpoint address")
-	flag.StringVar(&(cf.RWCoreEndpoint), "vcore-endpoint", default_RWCoreEndpoint, help)
+	help := fmt.Sprintf("RW core endpoint address")
+	flag.StringVar(&(cf.RWCoreEndpoint), "vcore-endpoint", defaultRWCoreEndpoint, help)
 
 	help = fmt.Sprintf("GRPC server - host")
-	flag.StringVar(&(cf.GrpcHost), "grpc_host", default_GrpcHost, help)
+	flag.StringVar(&(cf.GrpcHost), "grpc_host", defaultGrpcHost, help)
 
 	help = fmt.Sprintf("GRPC server - port")
-	flag.IntVar(&(cf.GrpcPort), "grpc_port", default_GrpcPort, help)
+	flag.IntVar(&(cf.GrpcPort), "grpc_port", defaultGrpcPort, help)
 
 	help = fmt.Sprintf("Kafka - Adapter messaging host")
-	flag.StringVar(&(cf.KafkaAdapterHost), "kafka_adapter_host", default_KafkaAdapterHost, help)
+	flag.StringVar(&(cf.KafkaAdapterHost), "kafka_adapter_host", defaultKafkaAdapterHost, help)
 
 	help = fmt.Sprintf("Kafka - Adapter messaging port")
-	flag.IntVar(&(cf.KafkaAdapterPort), "kafka_adapter_port", default_KafkaAdapterPort, help)
+	flag.IntVar(&(cf.KafkaAdapterPort), "kafka_adapter_port", defaultKafkaAdapterPort, help)
 
 	help = fmt.Sprintf("Kafka - Cluster messaging host")
-	flag.StringVar(&(cf.KafkaClusterHost), "kafka_cluster_host", default_KafkaClusterHost, help)
+	flag.StringVar(&(cf.KafkaClusterHost), "kafka_cluster_host", defaultKafkaClusterHost, help)
 
 	help = fmt.Sprintf("Kafka - Cluster messaging port")
-	flag.IntVar(&(cf.KafkaClusterPort), "kafka_cluster_port", default_KafkaClusterPort, help)
+	flag.IntVar(&(cf.KafkaClusterPort), "kafka_cluster_port", defaultKafkaClusterPort, help)
 
 	help = fmt.Sprintf("RW Core topic")
-	flag.StringVar(&(cf.CoreTopic), "rw_core_topic", default_CoreTopic, help)
+	flag.StringVar(&(cf.CoreTopic), "rw_core_topic", defaultCoreTopic, help)
 
 	help = fmt.Sprintf("Affinity Router topic")
-	flag.StringVar(&(cf.AffinityRouterTopic), "affinity_router_topic", default_AffinityRouterTopic, help)
+	flag.StringVar(&(cf.AffinityRouterTopic), "affinity_router_topic", defaultAffinityRouterTopic, help)
 
 	help = fmt.Sprintf("In competing Mode - two cores competing to handle a transaction ")
-	flag.BoolVar(&cf.InCompetingMode, "in_competing_mode", default_InCompetingMode, help)
+	flag.BoolVar(&cf.InCompetingMode, "in_competing_mode", defaultInCompetingMode, help)
 
 	help = fmt.Sprintf("KV store type")
-	flag.StringVar(&(cf.KVStoreType), "kv_store_type", default_KVStoreType, help)
+	flag.StringVar(&(cf.KVStoreType), "kv_store_type", defaultKVStoreType, help)
 
 	help = fmt.Sprintf("The default timeout when making a kv store request")
-	flag.IntVar(&(cf.KVStoreTimeout), "kv_store_request_timeout", default_KVStoreTimeout, help)
+	flag.IntVar(&(cf.KVStoreTimeout), "kv_store_request_timeout", defaultKVStoreTimeout, help)
 
 	help = fmt.Sprintf("KV store host")
-	flag.StringVar(&(cf.KVStoreHost), "kv_store_host", default_KVStoreHost, help)
+	flag.StringVar(&(cf.KVStoreHost), "kv_store_host", defaultKVStoreHost, help)
 
 	help = fmt.Sprintf("KV store port")
-	flag.IntVar(&(cf.KVStorePort), "kv_store_port", default_KVStorePort, help)
+	flag.IntVar(&(cf.KVStorePort), "kv_store_port", defaultKVStorePort, help)
 
 	help = fmt.Sprintf("The time to wait before deleting a completed transaction key")
-	flag.IntVar(&(cf.KVTxnKeyDelTime), "kv_txn_delete_time", default_KVTxnKeyDelTime, help)
+	flag.IntVar(&(cf.KVTxnKeyDelTime), "kv_txn_delete_time", defaultKVTxnKeyDelTime, help)
 
 	help = fmt.Sprintf("KV store data prefix")
-	flag.StringVar(&(cf.KVStoreDataPrefix), "kv_store_data_prefix", default_KVStoreDataPrefix, help)
+	flag.StringVar(&(cf.KVStoreDataPrefix), "kv_store_data_prefix", defaultKVStoreDataPrefix, help)
 
 	help = fmt.Sprintf("Log level")
-	flag.IntVar(&(cf.LogLevel), "log_level", default_LogLevel, help)
+	flag.IntVar(&(cf.LogLevel), "log_level", defaultLogLevel, help)
 
 	help = fmt.Sprintf("Timeout for long running request")
-	flag.Int64Var(&(cf.LongRunningRequestTimeout), "timeout_long_request", default_LongRunningRequestTimeout, help)
+	flag.Int64Var(&(cf.LongRunningRequestTimeout), "timeout_long_request", defaultLongRunningRequestTimeout, help)
 
 	help = fmt.Sprintf("Default timeout for regular request")
-	flag.Int64Var(&(cf.DefaultRequestTimeout), "timeout_request", default_DefaultRequestTimeout, help)
+	flag.Int64Var(&(cf.DefaultRequestTimeout), "timeout_request", defaultDefaultRequestTimeout, help)
 
 	help = fmt.Sprintf("Default Core timeout")
-	flag.Int64Var(&(cf.DefaultCoreTimeout), "core_timeout", default_CoreTimeout, help)
+	flag.Int64Var(&(cf.DefaultCoreTimeout), "core_timeout", defaultCoreTimeout, help)
 
 	help = fmt.Sprintf("Show startup banner log lines")
-	flag.BoolVar(&cf.Banner, "banner", default_Banner, help)
+	flag.BoolVar(&cf.Banner, "banner", defaultBanner, help)
 
 	help = fmt.Sprintf("Show version information and exit")
-	flag.BoolVar(&cf.DisplayVersionOnly, "version", default_DisplayVersionOnly, help)
+	flag.BoolVar(&cf.DisplayVersionOnly, "version", defaultDisplayVersionOnly, help)
 
 	help = fmt.Sprintf("The name of the meta-key whose value is the rw-core group to which the ofagent is bound")
-	flag.StringVar(&(cf.CoreBindingKey), "core_binding_key", default_CoreBindingKey, help)
+	flag.StringVar(&(cf.CoreBindingKey), "core_binding_key", defaultCoreBindingKey, help)
 
 	help = fmt.Sprintf("Core pairing group topic")
-	flag.StringVar(&cf.CorePairTopic, "core_pair_topic", default_CorePairTopic, help)
+	flag.StringVar(&cf.CorePairTopic, "core_pair_topic", defaultCorePairTopic, help)
 
 	help = fmt.Sprintf("The number of retries to connect to a dependent component")
-	flag.IntVar(&(cf.MaxConnectionRetries), "max_connection_retries", default_MaxConnectionRetries, help)
+	flag.IntVar(&(cf.MaxConnectionRetries), "max_connection_retries", defaultMaxConnectionRetries, help)
 
 	help = fmt.Sprintf("The number of seconds between each connection retry attempt")
-	flag.DurationVar(&(cf.ConnectionRetryInterval), "connection_retry_interval", default_ConnectionRetryInterval, help)
+	flag.DurationVar(&(cf.ConnectionRetryInterval), "connection_retry_interval", defaultConnectionRetryInterval, help)
 
 	help = fmt.Sprintf("The number of seconds between liveness probes while in a live state")
-	flag.DurationVar(&(cf.LiveProbeInterval), "live_probe_interval", default_LiveProbeInterval, help)
+	flag.DurationVar(&(cf.LiveProbeInterval), "live_probe_interval", defaultLiveProbeInterval, help)
 
 	help = fmt.Sprintf("The number of seconds between liveness probes while in a not live state")
-	flag.DurationVar(&(cf.NotLiveProbeInterval), "not_live_probe_interval", default_NotLiveProbeInterval, help)
+	flag.DurationVar(&(cf.NotLiveProbeInterval), "not_live_probe_interval", defaultNotLiveProbeInterval, help)
 
 	help = fmt.Sprintf("The host on which to listen to answer liveness and readiness probe queries over HTTP.")
-	flag.StringVar(&(cf.ProbeHost), "probe_host", default_ProbeHost, help)
+	flag.StringVar(&(cf.ProbeHost), "probe_host", defaultProbeHost, help)
 
 	help = fmt.Sprintf("The port on which to listen to answer liveness and readiness probe queries over HTTP.")
-	flag.IntVar(&(cf.ProbePort), "probe_port", default_ProbePort, help)
+	flag.IntVar(&(cf.ProbePort), "probe_port", defaultProbePort, help)
 
 	flag.Parse()
 }
diff --git a/rw_core/core/adapter_manager.go b/rw_core/core/adapter_manager.go
index aa83b53..493b391 100644
--- a/rw_core/core/adapter_manager.go
+++ b/rw_core/core/adapter_manager.go
@@ -13,26 +13,29 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package core
 
 import (
 	"context"
-	"errors"
 	"fmt"
+	"reflect"
+	"sync"
+
 	"github.com/gogo/protobuf/proto"
 	"github.com/opencord/voltha-go/db/model"
 	"github.com/opencord/voltha-lib-go/v2/pkg/log"
 	"github.com/opencord/voltha-lib-go/v2/pkg/probe"
 	"github.com/opencord/voltha-protos/v2/go/voltha"
-	"reflect"
-	"sync"
 )
 
+// sentinel constants
 const (
-	SENTINEL_ADAPTER_ID    = "adapter_sentinel"
-	SENTINEL_DEVICETYPE_ID = "device_type_sentinel"
+	SentinelAdapterID    = "adapter_sentinel"
+	SentinelDevicetypeID = "device_type_sentinel"
 )
 
+// AdapterAgent represents adapter agent
 type AdapterAgent struct {
 	adapter     *voltha.Adapter
 	deviceTypes map[string]*voltha.DeviceType
@@ -52,14 +55,6 @@
 	return &adapterAgent
 }
 
-// Returns true if this device agent can handle this device Type
-func (aa *AdapterAgent) handlesDeviceType(deviceType string) bool {
-	aa.lock.RLock()
-	defer aa.lock.RUnlock()
-	_, exist := aa.deviceTypes[deviceType]
-	return exist
-}
-
 func (aa *AdapterAgent) getDeviceType(deviceType string) *voltha.DeviceType {
 	aa.lock.RLock()
 	defer aa.lock.RUnlock()
@@ -88,6 +83,7 @@
 	aa.deviceTypes[deviceType.Id] = deviceType
 }
 
+// AdapterManager represents adapter manager attributes
 type AdapterManager struct {
 	adapterAgents               map[string]*AdapterAgent
 	deviceTypeToAdapterMap      map[string]string
@@ -95,16 +91,16 @@
 	adapterProxy                *model.Proxy
 	deviceTypeProxy             *model.Proxy
 	deviceMgr                   *DeviceManager
-	coreInstanceId              string
+	coreInstanceID              string
 	exitChannel                 chan int
 	lockAdaptersMap             sync.RWMutex
 	lockdDeviceTypeToAdapterMap sync.RWMutex
 }
 
-func newAdapterManager(cdProxy *model.Proxy, coreInstanceId string, deviceMgr *DeviceManager) *AdapterManager {
+func newAdapterManager(cdProxy *model.Proxy, coreInstanceID string, deviceMgr *DeviceManager) *AdapterManager {
 	var adapterMgr AdapterManager
 	adapterMgr.exitChannel = make(chan int, 1)
-	adapterMgr.coreInstanceId = coreInstanceId
+	adapterMgr.coreInstanceID = coreInstanceID
 	adapterMgr.clusterDataProxy = cdProxy
 	adapterMgr.adapterAgents = make(map[string]*AdapterAgent)
 	adapterMgr.deviceTypeToAdapterMap = make(map[string]string)
@@ -132,13 +128,6 @@
 	log.Info("adapter-manager-started")
 }
 
-func (aMgr *AdapterManager) stop(ctx context.Context) {
-	log.Info("stopping-device-manager")
-	aMgr.exitChannel <- 1
-	probe.UpdateStatusFromContext(ctx, "adapter-manager", probe.ServiceStatusStopped)
-	log.Info("device-manager-stopped")
-}
-
 //loadAdaptersAndDevicetypesInMemory loads the existing set of adapters and device types in memory
 func (aMgr *AdapterManager) loadAdaptersAndDevicetypesInMemory() {
 	// Load the adapters
@@ -152,7 +141,7 @@
 	} else {
 		log.Debug("no-existing-adapter-found")
 		//	No adapter data.   In order to have a proxy setup for that path let's create a fake adapter
-		aMgr.addAdapter(&voltha.Adapter{Id: SENTINEL_ADAPTER_ID}, true)
+		aMgr.addAdapter(&voltha.Adapter{Id: SentinelAdapterID}, true)
 	}
 
 	// Load the device types
@@ -168,7 +157,7 @@
 	} else {
 		log.Debug("no-existing-device-type-found")
 		//	No device types data.   In order to have a proxy setup for that path let's create a fake device type
-		aMgr.addDeviceTypes(&voltha.DeviceTypes{Items: []*voltha.DeviceType{{Id: SENTINEL_DEVICETYPE_ID, Adapter: SENTINEL_ADAPTER_ID}}}, true)
+		aMgr.addDeviceTypes(&voltha.DeviceTypes{Items: []*voltha.DeviceType{{Id: SentinelDevicetypeID, Adapter: SentinelAdapterID}}}, true)
 	}
 }
 
@@ -180,7 +169,12 @@
 	if adapterAgent, ok := aMgr.adapterAgents[adapter.Id]; ok {
 		if adapterAgent.getAdapter() != nil {
 			// Already registered - Adapter may have restarted.  Trigger the reconcile process for that adapter
-			go aMgr.deviceMgr.adapterRestarted(adapter)
+			go func() {
+				err := aMgr.deviceMgr.adapterRestarted(adapter)
+				if err != nil {
+					log.Errorw("unable-to-restart-adapter", log.Fields{"error": err})
+				}
+			}()
 			return
 		}
 	}
@@ -270,7 +264,7 @@
 	defer aMgr.lockAdaptersMap.RUnlock()
 	for _, adapterAgent := range aMgr.adapterAgents {
 		if a := adapterAgent.getAdapter(); a != nil {
-			if a.Id != SENTINEL_ADAPTER_ID { // don't report the sentinel
+			if a.Id != SentinelAdapterID { // don't report the sentinel
 				result.Items = append(result.Items, (proto.Clone(a)).(*voltha.Adapter))
 			}
 		}
@@ -278,16 +272,10 @@
 	return result, nil
 }
 
-func (aMgr *AdapterManager) deleteAdapter(adapterId string) {
-	aMgr.lockAdaptersMap.Lock()
-	defer aMgr.lockAdaptersMap.Unlock()
-	delete(aMgr.adapterAgents, adapterId)
-}
-
-func (aMgr *AdapterManager) getAdapter(adapterId string) *voltha.Adapter {
+func (aMgr *AdapterManager) getAdapter(adapterID string) *voltha.Adapter {
 	aMgr.lockAdaptersMap.RLock()
 	defer aMgr.lockAdaptersMap.RUnlock()
-	if adapterAgent, ok := aMgr.adapterAgents[adapterId]; ok {
+	if adapterAgent, ok := aMgr.adapterAgents[adapterID]; ok {
 		return adapterAgent.getAdapter()
 	}
 	return nil
@@ -332,8 +320,13 @@
 
 	if aMgr.getAdapter(adapter.Id) != nil {
 		//	Already registered - Adapter may have restarted.  Trigger the reconcile process for that adapter
-		go aMgr.deviceMgr.adapterRestarted(adapter)
-		return &voltha.CoreInstance{InstanceId: aMgr.coreInstanceId}
+		go func() {
+			err := aMgr.deviceMgr.adapterRestarted(adapter)
+			if err != nil {
+				log.Errorw("unable-to-restart-adapter", log.Fields{"error": err})
+			}
+		}()
+		return &voltha.CoreInstance{InstanceId: aMgr.coreInstanceID}
 	}
 	// Save the adapter and the device types
 	aMgr.addAdapter(adapter, true)
@@ -341,17 +334,17 @@
 
 	log.Debugw("adapter-registered", log.Fields{"adapter": adapter.Id})
 
-	return &voltha.CoreInstance{InstanceId: aMgr.coreInstanceId}
+	return &voltha.CoreInstance{InstanceId: aMgr.coreInstanceID}
 }
 
 //getAdapterName returns the name of the device adapter that service this device type
 func (aMgr *AdapterManager) getAdapterName(deviceType string) (string, error) {
 	aMgr.lockdDeviceTypeToAdapterMap.Lock()
 	defer aMgr.lockdDeviceTypeToAdapterMap.Unlock()
-	if adapterId, exist := aMgr.deviceTypeToAdapterMap[deviceType]; exist {
-		return adapterId, nil
+	if adapterID, exist := aMgr.deviceTypeToAdapterMap[deviceType]; exist {
+		return adapterID, nil
 	}
-	return "", errors.New(fmt.Sprintf("Adapter-not-registered-for-device-type %s", deviceType))
+	return "", fmt.Errorf("Adapter-not-registered-for-device-type %s", deviceType)
 }
 
 func (aMgr *AdapterManager) listDeviceTypes() []*voltha.DeviceType {
@@ -359,9 +352,9 @@
 	defer aMgr.lockdDeviceTypeToAdapterMap.Unlock()
 
 	deviceTypes := make([]*voltha.DeviceType, 0, len(aMgr.deviceTypeToAdapterMap))
-	for deviceTypeId, adapterId := range aMgr.deviceTypeToAdapterMap {
-		if adapterAgent, have := aMgr.adapterAgents[adapterId]; have {
-			if deviceType := adapterAgent.getDeviceType(deviceTypeId); deviceType != nil {
+	for deviceTypeID, adapterID := range aMgr.deviceTypeToAdapterMap {
+		if adapterAgent, have := aMgr.adapterAgents[adapterID]; have {
+			if deviceType := adapterAgent.getDeviceType(deviceTypeID); deviceType != nil {
 				deviceTypes = append(deviceTypes, deviceType)
 			}
 		}
@@ -374,8 +367,8 @@
 	aMgr.lockdDeviceTypeToAdapterMap.Lock()
 	defer aMgr.lockdDeviceTypeToAdapterMap.Unlock()
 
-	if adapterId, exist := aMgr.deviceTypeToAdapterMap[deviceType]; exist {
-		if adapterAgent, _ := aMgr.adapterAgents[adapterId]; adapterAgent != nil {
+	if adapterID, exist := aMgr.deviceTypeToAdapterMap[deviceType]; exist {
+		if adapterAgent := aMgr.adapterAgents[adapterID]; adapterAgent != nil {
 			return adapterAgent.getDeviceType(deviceType)
 		}
 	}
diff --git a/rw_core/core/adapter_proxy.go b/rw_core/core/adapter_proxy.go
index b986a0e..c8b28aa 100755
--- a/rw_core/core/adapter_proxy.go
+++ b/rw_core/core/adapter_proxy.go
@@ -13,10 +13,12 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package core
 
 import (
 	"context"
+
 	"github.com/golang/protobuf/ptypes"
 	a "github.com/golang/protobuf/ptypes/any"
 	"github.com/opencord/voltha-lib-go/v2/pkg/kafka"
@@ -28,6 +30,7 @@
 	"google.golang.org/grpc/status"
 )
 
+// AdapterProxy represents adapter proxy attributes
 type AdapterProxy struct {
 	TestMode              bool
 	deviceTopicRegistered bool
@@ -35,6 +38,7 @@
 	kafkaICProxy          *kafka.InterContainerProxy
 }
 
+// NewAdapterProxy will return adapter proxy instance
 func NewAdapterProxy(kafkaProxy *kafka.InterContainerProxy, corePairTopic string) *AdapterProxy {
 	return &AdapterProxy{
 		kafkaICProxy:          kafkaProxy,
@@ -43,20 +47,19 @@
 	}
 }
 
-func unPackResponse(rpc string, deviceId string, success bool, response *a.Any) error {
+func unPackResponse(rpc string, deviceID string, success bool, response *a.Any) error {
 	if success {
 		return nil
-	} else {
-		unpackResult := &ic.Error{}
-		var err error
-		if err = ptypes.UnmarshalAny(response, unpackResult); err != nil {
-			log.Warnw("cannot-unmarshal-response", log.Fields{"error": err})
-			return err
-		}
-		log.Debugw("response", log.Fields{"rpc": rpc, "deviceId": deviceId, "success": success, "error": err})
-		// TODO:  Need to get the real error code
-		return status.Errorf(codes.Canceled, "%s", unpackResult.Reason)
 	}
+	unpackResult := &ic.Error{}
+	var err error
+	if err = ptypes.UnmarshalAny(response, unpackResult); err != nil {
+		log.Warnw("cannot-unmarshal-response", log.Fields{"error": err})
+		return err
+	}
+	log.Debugw("response", log.Fields{"rpc": rpc, "deviceId": deviceID, "success": success, "error": err})
+	// TODO:  Need to get the real error code
+	return status.Errorf(codes.Canceled, "%s", unpackResult.Reason)
 }
 
 func (ap *AdapterProxy) getCoreTopic() kafka.Topic {
@@ -67,6 +70,7 @@
 	return kafka.Topic{Name: adapterName}
 }
 
+// AdoptDevice invokes adopt device rpc
 func (ap *AdapterProxy) AdoptDevice(ctx context.Context, device *voltha.Device) error {
 	log.Debugw("AdoptDevice", log.Fields{"device": device})
 	rpc := "adopt_device"
@@ -85,6 +89,7 @@
 	return unPackResponse(rpc, device.Id, success, result)
 }
 
+// DisableDevice invokes disable device rpc
 func (ap *AdapterProxy) DisableDevice(ctx context.Context, device *voltha.Device) error {
 	log.Debugw("DisableDevice", log.Fields{"deviceId": device.Id})
 	rpc := "disable_device"
@@ -106,6 +111,7 @@
 	return unPackResponse(rpc, device.Id, success, result)
 }
 
+// ReEnableDevice invokes reenable device rpc
 func (ap *AdapterProxy) ReEnableDevice(ctx context.Context, device *voltha.Device) error {
 	log.Debugw("ReEnableDevice", log.Fields{"deviceId": device.Id})
 	rpc := "reenable_device"
@@ -122,6 +128,7 @@
 	return unPackResponse(rpc, device.Id, success, result)
 }
 
+// RebootDevice invokes reboot device rpc
 func (ap *AdapterProxy) RebootDevice(ctx context.Context, device *voltha.Device) error {
 	log.Debugw("RebootDevice", log.Fields{"deviceId": device.Id})
 	rpc := "reboot_device"
@@ -138,6 +145,7 @@
 	return unPackResponse(rpc, device.Id, success, result)
 }
 
+// DeleteDevice invokes delete device rpc
 func (ap *AdapterProxy) DeleteDevice(ctx context.Context, device *voltha.Device) error {
 	log.Debugw("DeleteDevice", log.Fields{"deviceId": device.Id})
 	rpc := "delete_device"
@@ -155,6 +163,7 @@
 	return unPackResponse(rpc, device.Id, success, result)
 }
 
+// GetOfpDeviceInfo invokes get ofp device info rpc
 func (ap *AdapterProxy) GetOfpDeviceInfo(ctx context.Context, device *voltha.Device) (*ic.SwitchCapability, error) {
 	log.Debugw("GetOfpDeviceInfo", log.Fields{"deviceId": device.Id})
 	toTopic := ap.getAdapterTopic(device.Adapter)
@@ -174,18 +183,18 @@
 			return nil, status.Errorf(codes.InvalidArgument, "%s", err.Error())
 		}
 		return unpackResult, nil
-	} else {
-		unpackResult := &ic.Error{}
-		var err error
-		if err = ptypes.UnmarshalAny(result, unpackResult); err != nil {
-			log.Warnw("cannot-unmarshal-response", log.Fields{"error": err})
-		}
-		log.Debugw("GetOfpDeviceInfo-return", log.Fields{"deviceid": device.Id, "success": success, "error": err})
-		// TODO:  Need to get the real error code
-		return nil, status.Errorf(codes.Internal, "%s", unpackResult.Reason)
 	}
+	unpackResult := &ic.Error{}
+	var err error
+	if err = ptypes.UnmarshalAny(result, unpackResult); err != nil {
+		log.Warnw("cannot-unmarshal-response", log.Fields{"error": err})
+	}
+	log.Debugw("GetOfpDeviceInfo-return", log.Fields{"deviceid": device.Id, "success": success, "error": err})
+	// TODO:  Need to get the real error code
+	return nil, status.Errorf(codes.Internal, "%s", unpackResult.Reason)
 }
 
+// GetOfpPortInfo invokes get ofp port info rpc
 func (ap *AdapterProxy) GetOfpPortInfo(ctx context.Context, device *voltha.Device, portNo uint32) (*ic.PortCapability, error) {
 	log.Debugw("GetOfpPortInfo", log.Fields{"deviceId": device.Id})
 	toTopic := ap.getAdapterTopic(device.Adapter)
@@ -210,35 +219,38 @@
 			return nil, status.Errorf(codes.InvalidArgument, "%s", err.Error())
 		}
 		return unpackResult, nil
-	} else {
-		unpackResult := &ic.Error{}
-		var err error
-		if err = ptypes.UnmarshalAny(result, unpackResult); err != nil {
-			log.Warnw("cannot-unmarshal-response", log.Fields{"error": err})
-		}
-		log.Debugw("GetOfpPortInfo-return", log.Fields{"deviceid": device.Id, "success": success, "error": err})
-		// TODO:  Need to get the real error code
-		return nil, status.Errorf(codes.Internal, "%s", unpackResult.Reason)
 	}
+	unpackResult := &ic.Error{}
+	var err error
+	if err = ptypes.UnmarshalAny(result, unpackResult); err != nil {
+		log.Warnw("cannot-unmarshal-response", log.Fields{"error": err})
+	}
+	log.Debugw("GetOfpPortInfo-return", log.Fields{"deviceid": device.Id, "success": success, "error": err})
+	// TODO:  Need to get the real error code
+	return nil, status.Errorf(codes.Internal, "%s", unpackResult.Reason)
 }
 
 //TODO: Implement the functions below
 
+// AdapterDescriptor - TODO
 func (ap *AdapterProxy) AdapterDescriptor() (*voltha.Adapter, error) {
 	log.Debug("AdapterDescriptor")
 	return nil, nil
 }
 
+// DeviceTypes - TODO
 func (ap *AdapterProxy) DeviceTypes() (*voltha.DeviceType, error) {
 	log.Debug("DeviceTypes")
 	return nil, nil
 }
 
+// Health - TODO
 func (ap *AdapterProxy) Health() (*voltha.HealthStatus, error) {
 	log.Debug("Health")
 	return nil, nil
 }
 
+// ReconcileDevice invokes reconcile device rpc
 func (ap *AdapterProxy) ReconcileDevice(ctx context.Context, device *voltha.Device) error {
 	log.Debugw("ReconcileDevice", log.Fields{"deviceId": device.Id})
 	rpc := "Reconcile_device"
@@ -254,16 +266,19 @@
 	return unPackResponse(rpc, device.Id, success, result)
 }
 
+// AbandonDevice - TODO
 func (ap *AdapterProxy) AbandonDevice(device voltha.Device) error {
 	log.Debug("AbandonDevice")
 	return nil
 }
 
+// GetDeviceDetails - TODO
 func (ap *AdapterProxy) GetDeviceDetails(device voltha.Device) (*voltha.Device, error) {
 	log.Debug("GetDeviceDetails")
 	return nil, nil
 }
 
+// DownloadImage invokes download image rpc
 func (ap *AdapterProxy) DownloadImage(ctx context.Context, device *voltha.Device, download *voltha.ImageDownload) error {
 	log.Debugw("DownloadImage", log.Fields{"deviceId": device.Id, "image": download.Name})
 	rpc := "download_image"
@@ -285,6 +300,7 @@
 	return unPackResponse(rpc, device.Id, success, result)
 }
 
+// GetImageDownloadStatus invokes get image download status rpc
 func (ap *AdapterProxy) GetImageDownloadStatus(ctx context.Context, device *voltha.Device, download *voltha.ImageDownload) (*voltha.ImageDownload, error) {
 	log.Debugw("GetImageDownloadStatus", log.Fields{"deviceId": device.Id, "image": download.Name})
 	rpc := "get_image_download_status"
@@ -310,18 +326,18 @@
 			return nil, status.Errorf(codes.InvalidArgument, "%s", err.Error())
 		}
 		return unpackResult, nil
-	} else {
-		unpackResult := &ic.Error{}
-		var err error
-		if err = ptypes.UnmarshalAny(result, unpackResult); err != nil {
-			log.Warnw("cannot-unmarshal-response", log.Fields{"error": err})
-			return nil, err
-		}
-		log.Debugw("GetImageDownloadStatus-return", log.Fields{"deviceid": device.Id, "success": success, "error": err})
-		return nil, status.Errorf(codes.Internal, "%s", unpackResult.Reason)
 	}
+	unpackResult := &ic.Error{}
+	var err error
+	if err = ptypes.UnmarshalAny(result, unpackResult); err != nil {
+		log.Warnw("cannot-unmarshal-response", log.Fields{"error": err})
+		return nil, err
+	}
+	log.Debugw("GetImageDownloadStatus-return", log.Fields{"deviceid": device.Id, "success": success, "error": err})
+	return nil, status.Errorf(codes.Internal, "%s", unpackResult.Reason)
 }
 
+// CancelImageDownload invokes cancel image download rpc
 func (ap *AdapterProxy) CancelImageDownload(ctx context.Context, device *voltha.Device, download *voltha.ImageDownload) error {
 	log.Debugw("CancelImageDownload", log.Fields{"deviceId": device.Id, "image": download.Name})
 	rpc := "cancel_image_download"
@@ -343,6 +359,7 @@
 	return unPackResponse(rpc, device.Id, success, result)
 }
 
+// ActivateImageUpdate invokes activate image update rpc
 func (ap *AdapterProxy) ActivateImageUpdate(ctx context.Context, device *voltha.Device, download *voltha.ImageDownload) error {
 	log.Debugw("ActivateImageUpdate", log.Fields{"deviceId": device.Id, "image": download.Name})
 	rpc := "activate_image_update"
@@ -364,6 +381,7 @@
 	return unPackResponse(rpc, device.Id, success, result)
 }
 
+// RevertImageUpdate invokes revert image update rpc
 func (ap *AdapterProxy) RevertImageUpdate(ctx context.Context, device *voltha.Device, download *voltha.ImageDownload) error {
 	log.Debugw("RevertImageUpdate", log.Fields{"deviceId": device.Id, "image": download.Name})
 	rpc := "revert_image_update"
@@ -385,20 +403,21 @@
 	return unPackResponse(rpc, device.Id, success, result)
 }
 
+// SelfTestDevice - TODO
 func (ap *AdapterProxy) SelfTestDevice(device voltha.Device) (*voltha.SelfTestResponse, error) {
 	log.Debug("SelfTestDevice")
 	return nil, nil
 }
 
-func (ap *AdapterProxy) packetOut(deviceType string, deviceId string, outPort uint32, packet *openflow_13.OfpPacketOut) error {
-	log.Debugw("packetOut", log.Fields{"deviceId": deviceId})
+func (ap *AdapterProxy) packetOut(deviceType string, deviceID string, outPort uint32, packet *openflow_13.OfpPacketOut) error {
+	log.Debugw("packetOut", log.Fields{"deviceId": deviceID})
 	toTopic := ap.getAdapterTopic(deviceType)
 	rpc := "receive_packet_out"
-	dId := &ic.StrType{Val: deviceId}
+	dID := &ic.StrType{Val: deviceID}
 	args := make([]*kafka.KVArg, 3)
 	args[0] = &kafka.KVArg{
 		Key:   "deviceId",
-		Value: dId,
+		Value: dID,
 	}
 	op := &ic.IntType{Val: int64(outPort)}
 	args[1] = &kafka.KVArg{
@@ -413,11 +432,12 @@
 	// TODO:  Do we need to wait for an ACK on a packet Out?
 	// Use a device specific topic as we are the only core handling requests for this device
 	replyToTopic := ap.getCoreTopic()
-	success, result := ap.kafkaICProxy.InvokeRPC(nil, rpc, &toTopic, &replyToTopic, true, deviceId, args...)
-	log.Debugw("packetOut", log.Fields{"deviceid": deviceId, "success": success})
-	return unPackResponse(rpc, deviceId, success, result)
+	success, result := ap.kafkaICProxy.InvokeRPC(context.TODO(), rpc, &toTopic, &replyToTopic, true, deviceID, args...)
+	log.Debugw("packetOut", log.Fields{"deviceid": deviceID, "success": success})
+	return unPackResponse(rpc, deviceID, success, result)
 }
 
+// UpdateFlowsBulk invokes update flows bulk rpc
 func (ap *AdapterProxy) UpdateFlowsBulk(device *voltha.Device, flows *voltha.Flows, groups *voltha.FlowGroups, flowMetadata *voltha.FlowMetadata) error {
 	log.Debugw("UpdateFlowsBulk", log.Fields{"deviceId": device.Id, "flowsInUpdate": len(flows.Items), "groupsToUpdate": len(groups.Items)})
 	toTopic := ap.getAdapterTopic(device.Adapter)
@@ -442,11 +462,12 @@
 
 	// Use a device specific topic as we are the only core handling requests for this device
 	replyToTopic := ap.getCoreTopic()
-	success, result := ap.kafkaICProxy.InvokeRPC(nil, rpc, &toTopic, &replyToTopic, true, device.Id, args...)
+	success, result := ap.kafkaICProxy.InvokeRPC(context.TODO(), rpc, &toTopic, &replyToTopic, true, device.Id, args...)
 	log.Debugw("UpdateFlowsBulk-response", log.Fields{"deviceid": device.Id, "success": success})
 	return unPackResponse(rpc, device.Id, success, result)
 }
 
+// UpdateFlowsIncremental invokes update flows incremental rpc
 func (ap *AdapterProxy) UpdateFlowsIncremental(device *voltha.Device, flowChanges *openflow_13.FlowChanges, groupChanges *openflow_13.FlowGroupChanges, flowMetadata *voltha.FlowMetadata) error {
 	log.Debugw("UpdateFlowsIncremental",
 		log.Fields{
@@ -479,11 +500,12 @@
 	}
 	// Use a device specific topic as we are the only core handling requests for this device
 	replyToTopic := ap.getCoreTopic()
-	success, result := ap.kafkaICProxy.InvokeRPC(nil, rpc, &toTopic, &replyToTopic, true, device.Id, args...)
+	success, result := ap.kafkaICProxy.InvokeRPC(context.TODO(), rpc, &toTopic, &replyToTopic, true, device.Id, args...)
 	log.Debugw("UpdateFlowsIncremental-response", log.Fields{"deviceid": device.Id, "success": success})
 	return unPackResponse(rpc, device.Id, success, result)
 }
 
+// UpdatePmConfigs invokes update pm configs rpc
 func (ap *AdapterProxy) UpdatePmConfigs(ctx context.Context, device *voltha.Device, pmConfigs *voltha.PmConfigs) error {
 	log.Debugw("UpdatePmConfigs", log.Fields{"deviceId": device.Id})
 	toTopic := ap.getAdapterTopic(device.Adapter)
@@ -499,26 +521,30 @@
 	}
 
 	replyToTopic := ap.getCoreTopic()
-	success, result := ap.kafkaICProxy.InvokeRPC(nil, rpc, &toTopic, &replyToTopic, true, device.Id, args...)
+	success, result := ap.kafkaICProxy.InvokeRPC(context.TODO(), rpc, &toTopic, &replyToTopic, true, device.Id, args...)
 	log.Debugw("UpdatePmConfigs-response", log.Fields{"deviceid": device.Id, "success": success})
 	return unPackResponse(rpc, device.Id, success, result)
 }
 
-func (ap *AdapterProxy) ReceivePacketOut(deviceId voltha.ID, egressPortNo int, msg interface{}) error {
+// ReceivePacketOut - TODO
+func (ap *AdapterProxy) ReceivePacketOut(deviceID voltha.ID, egressPortNo int, msg interface{}) error {
 	log.Debug("ReceivePacketOut")
 	return nil
 }
 
+// SuppressAlarm - TODO
 func (ap *AdapterProxy) SuppressAlarm(filter voltha.AlarmFilter) error {
 	log.Debug("SuppressAlarm")
 	return nil
 }
 
+// UnSuppressAlarm - TODO
 func (ap *AdapterProxy) UnSuppressAlarm(filter voltha.AlarmFilter) error {
 	log.Debug("UnSuppressAlarm")
 	return nil
 }
 
+// SimulateAlarm invokes simulate alarm rpc
 func (ap *AdapterProxy) SimulateAlarm(ctx context.Context, device *voltha.Device, simulatereq *voltha.SimulateAlarmRequest) error {
 	log.Debugw("SimulateAlarm", log.Fields{"id": simulatereq.Id})
 	rpc := "simulate_alarm"
diff --git a/rw_core/core/adapter_proxy_test.go b/rw_core/core/adapter_proxy_test.go
index e6e0ecb..c281f03 100755
--- a/rw_core/core/adapter_proxy_test.go
+++ b/rw_core/core/adapter_proxy_test.go
@@ -18,6 +18,9 @@
 import (
 	"context"
 	"crypto/rand"
+	"testing"
+	"time"
+
 	cm "github.com/opencord/voltha-go/rw_core/mocks"
 	com "github.com/opencord/voltha-lib-go/v2/pkg/adapters/common"
 	"github.com/opencord/voltha-lib-go/v2/pkg/kafka"
@@ -28,14 +31,12 @@
 	"github.com/stretchr/testify/assert"
 	"google.golang.org/grpc/codes"
 	"google.golang.org/grpc/status"
-	"testing"
-	"time"
 )
 
 const (
 	coreName       = "rw_core"
 	adapterName    = "adapter_mock"
-	coreInstanceId = "1000"
+	coreInstanceID = "1000"
 )
 
 var (
@@ -47,7 +48,7 @@
 )
 
 func init() {
-	if _, err := log.SetDefaultLogger(log.JSON, 0, log.Fields{"instanceId": coreInstanceId}); err != nil {
+	if _, err := log.SetDefaultLogger(log.JSON, 0, log.Fields{"instanceId": coreInstanceID}); err != nil {
 		log.With(log.Fields{"error": err}).Fatal("Cannot setup logging")
 	}
 	// Set the log level to Warning
@@ -65,17 +66,17 @@
 		log.Fatalw("Failure-creating-core-intercontainerProxy", log.Fields{"error": err})
 
 	}
-	if err := coreKafkaICProxy.Start(); err != nil {
+	if err = coreKafkaICProxy.Start(); err != nil {
 		log.Fatalw("Failure-starting-core-kafka-intercontainerProxy", log.Fields{"error": err})
 	}
-	if err := coreKafkaICProxy.SubscribeWithDefaultRequestHandler(kafka.Topic{Name: coreName}, 0); err != nil {
+	if err = coreKafkaICProxy.SubscribeWithDefaultRequestHandler(kafka.Topic{Name: coreName}, 0); err != nil {
 		log.Fatalw("Failure-subscribing-core-request-handler", log.Fields{"error": err})
 	}
 
 	// Setup adapter inter-container proxy and adapter request handler
 	adapterCoreProxy := com.NewCoreProxy(nil, adapterName, coreName)
 	adapter = cm.NewAdapter(adapterCoreProxy)
-	adapterReqHandler = com.NewRequestHandlerProxy(coreInstanceId, adapter, adapterCoreProxy)
+	adapterReqHandler = com.NewRequestHandlerProxy(coreInstanceID, adapter, adapterCoreProxy)
 	if adapterKafkaICProxy, err = kafka.NewInterContainerProxy(
 		kafka.MsgClient(kc),
 		kafka.DefaultTopic(&kafka.Topic{Name: adapterName}),
diff --git a/rw_core/core/adapter_request_handler.go b/rw_core/core/adapter_request_handler.go
index f1f17c8..8f43643 100644
--- a/rw_core/core/adapter_request_handler.go
+++ b/rw_core/core/adapter_request_handler.go
@@ -13,10 +13,13 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package core
 
 import (
+	"context"
 	"errors"
+
 	"github.com/golang/protobuf/ptypes"
 	"github.com/golang/protobuf/ptypes/empty"
 	"github.com/opencord/voltha-go/db/model"
@@ -29,9 +32,10 @@
 	"google.golang.org/grpc/status"
 )
 
+// AdapterRequestHandlerProxy represent adapter request handler proxy attributes
 type AdapterRequestHandlerProxy struct {
 	TestMode                  bool
-	coreInstanceId            string
+	coreInstanceID            string
 	deviceMgr                 *DeviceManager
 	lDeviceMgr                *LogicalDeviceManager
 	adapterMgr                *AdapterManager
@@ -43,12 +47,13 @@
 	core                      *Core
 }
 
-func NewAdapterRequestHandlerProxy(core *Core, coreInstanceId string, dMgr *DeviceManager, ldMgr *LogicalDeviceManager,
+// NewAdapterRequestHandlerProxy assigns values for adapter request handler proxy attributes and returns the new instance
+func NewAdapterRequestHandlerProxy(core *Core, coreInstanceID string, dMgr *DeviceManager, ldMgr *LogicalDeviceManager,
 	aMgr *AdapterManager, cdProxy *model.Proxy, ldProxy *model.Proxy, incompetingMode bool, longRunningRequestTimeout int64,
 	defaultRequestTimeout int64) *AdapterRequestHandlerProxy {
 	var proxy AdapterRequestHandlerProxy
 	proxy.core = core
-	proxy.coreInstanceId = coreInstanceId
+	proxy.coreInstanceID = coreInstanceID
 	proxy.deviceMgr = dMgr
 	proxy.lDeviceMgr = ldMgr
 	proxy.clusterDataProxy = cdProxy
@@ -61,22 +66,22 @@
 }
 
 // This is a helper function that attempts to acquire the request by using the device ownership model
-func (rhp *AdapterRequestHandlerProxy) takeRequestOwnership(transactionId string, devId string, maxTimeout ...int64) (*KVTransaction, error) {
+func (rhp *AdapterRequestHandlerProxy) takeRequestOwnership(transactionID string, devID string, maxTimeout ...int64) (*KVTransaction, error) {
 	timeout := rhp.defaultRequestTimeout
 	if len(maxTimeout) > 0 {
 		timeout = maxTimeout[0]
 	}
-	txn := NewKVTransaction(transactionId)
+	txn := NewKVTransaction(transactionID)
 	if txn == nil {
 		return nil, errors.New("fail-to-create-transaction")
 	}
 
 	var acquired bool
 	var err error
-	if devId != "" {
+	if devID != "" {
 		var ownedByMe bool
-		if ownedByMe, err = rhp.core.deviceOwnership.OwnedByMe(&utils.DeviceID{Id: devId}); err != nil {
-			log.Warnw("getting-ownership-failed", log.Fields{"deviceId": devId, "error": err})
+		if ownedByMe, err = rhp.core.deviceOwnership.OwnedByMe(&utils.DeviceID{ID: devID}); err != nil {
+			log.Warnw("getting-ownership-failed", log.Fields{"deviceId": devID, "error": err})
 			return nil, kafka.ErrorTransactionInvalidId
 		}
 		acquired, err = txn.Acquired(timeout, ownedByMe)
@@ -84,12 +89,11 @@
 		acquired, err = txn.Acquired(timeout)
 	}
 	if err == nil && acquired {
-		log.Debugw("transaction-acquired", log.Fields{"transactionId": txn.txnId})
+		log.Debugw("transaction-acquired", log.Fields{"transactionId": txn.txnID})
 		return txn, nil
-	} else {
-		log.Debugw("transaction-not-acquired", log.Fields{"transactionId": txn.txnId, "error": err})
-		return nil, kafka.ErrorTransactionNotAcquired
 	}
+	log.Debugw("transaction-not-acquired", log.Fields{"transactionId": txn.txnID, "error": err})
+	return nil, kafka.ErrorTransactionNotAcquired
 }
 
 // competeForTransaction is a helper function to determine whether every request needs to compete with another
@@ -98,6 +102,7 @@
 	return rhp.coreInCompetingMode
 }
 
+// Register registers the adapter
 func (rhp *AdapterRequestHandlerProxy) Register(args []*ic.Argument) (*voltha.CoreInstance, error) {
 	if len(args) < 3 {
 		log.Warn("invalid-number-of-args", log.Fields{"args": args})
@@ -106,7 +111,7 @@
 	}
 	adapter := &voltha.Adapter{}
 	deviceTypes := &voltha.DeviceTypes{}
-	transactionId := &ic.StrType{}
+	transactionID := &ic.StrType{}
 	for _, arg := range args {
 		switch arg.Key {
 		case "adapter":
@@ -120,26 +125,26 @@
 				return nil, err
 			}
 		case kafka.TransactionKey:
-			if err := ptypes.UnmarshalAny(arg.Value, transactionId); err != nil {
+			if err := ptypes.UnmarshalAny(arg.Value, transactionID); err != nil {
 				log.Warnw("cannot-unmarshal-transaction-ID", log.Fields{"error": err})
 				return nil, err
 			}
 		}
 	}
-	log.Debugw("Register", log.Fields{"Adapter": *adapter, "DeviceTypes": deviceTypes, "transactionId": transactionId.Val, "coreId": rhp.coreInstanceId})
+	log.Debugw("Register", log.Fields{"Adapter": *adapter, "DeviceTypes": deviceTypes, "transactionID": transactionID.Val, "coreID": rhp.coreInstanceID})
 
 	// Try to grab the transaction as this core may be competing with another Core
 	if rhp.competeForTransaction() {
-		if txn, err := rhp.takeRequestOwnership(transactionId.Val, ""); err != nil {
+		txn, err := rhp.takeRequestOwnership(transactionID.Val, "")
+		if err != nil {
 			if err.Error() == kafka.ErrorTransactionNotAcquired.Error() {
-				log.Debugw("Another core handled the request", log.Fields{"transactionId": transactionId})
+				log.Debugw("Another core handled the request", log.Fields{"transactionId": transactionID})
 				// Update our adapters in memory
 				go rhp.adapterMgr.updateAdaptersAndDevicetypesInMemory(adapter)
 			}
 			return nil, err
-		} else {
-			defer txn.Close()
 		}
+		defer txn.Close()
 	}
 
 	if rhp.TestMode { // Execute only for test cases
@@ -148,6 +153,7 @@
 	return rhp.adapterMgr.registerAdapter(adapter, deviceTypes), nil
 }
 
+// GetDevice returns device info
 func (rhp *AdapterRequestHandlerProxy) GetDevice(args []*ic.Argument) (*voltha.Device, error) {
 	if len(args) < 2 {
 		log.Warn("invalid-number-of-args", log.Fields{"args": args})
@@ -171,16 +177,16 @@
 			}
 		}
 	}
-	log.Debugw("GetDevice", log.Fields{"deviceId": pID.Id, "transactionID": transactionID.Val})
+	log.Debugw("GetDevice", log.Fields{"deviceID": pID.Id, "transactionID": transactionID.Val})
 
 	// Try to grab the transaction as this core may be competing with another Core
 	if rhp.competeForTransaction() {
-		if txn, err := rhp.takeRequestOwnership(transactionID.Val, pID.Id); err != nil {
+		txn, err := rhp.takeRequestOwnership(transactionID.Val, pID.Id)
+		if err != nil {
 			log.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
 			return nil, err
-		} else {
-			defer txn.Close()
 		}
+		defer txn.Close()
 	}
 
 	if rhp.TestMode { // Execute only for test cases
@@ -188,14 +194,15 @@
 	}
 
 	// Get the device via the device manager
-	if device, err := rhp.deviceMgr.GetDevice(pID.Id); err != nil {
+	device, err := rhp.deviceMgr.GetDevice(pID.Id)
+	if err != nil {
 		return nil, status.Errorf(codes.NotFound, "%s", err.Error())
-	} else {
-		log.Debugw("GetDevice-response", log.Fields{"deviceId": pID.Id})
-		return device, nil
 	}
+	log.Debugw("GetDevice-response", log.Fields{"deviceID": pID.Id})
+	return device, nil
 }
 
+// DeviceUpdate updates device using adapter data
 func (rhp *AdapterRequestHandlerProxy) DeviceUpdate(args []*ic.Argument) (*empty.Empty, error) {
 	if len(args) < 2 {
 		log.Warn("invalid-number-of-args", log.Fields{"args": args})
@@ -219,26 +226,32 @@
 			}
 		}
 	}
-	log.Debugw("DeviceUpdate", log.Fields{"deviceId": device.Id, "transactionID": transactionID.Val})
+	log.Debugw("DeviceUpdate", log.Fields{"deviceID": device.Id, "transactionID": transactionID.Val})
 
 	// Try to grab the transaction as this core may be competing with another Core
 	if rhp.competeForTransaction() {
-		if txn, err := rhp.takeRequestOwnership(transactionID.Val, device.Id); err != nil {
+		txn, err := rhp.takeRequestOwnership(transactionID.Val, device.Id)
+		if err != nil {
 			log.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
 			return nil, err
-		} else {
-			defer txn.Close()
 		}
+		defer txn.Close()
 	}
 
-	log.Debugw("DeviceUpdate got txn", log.Fields{"deviceId": device.Id, "transactionID": transactionID.Val})
+	log.Debugw("DeviceUpdate got txn", log.Fields{"deviceID": device.Id, "transactionID": transactionID.Val})
 	if rhp.TestMode { // Execute only for test cases
 		return new(empty.Empty), nil
 	}
-	go rhp.deviceMgr.updateDeviceUsingAdapterData(device)
+	go func() {
+		err := rhp.deviceMgr.updateDeviceUsingAdapterData(device)
+		if err != nil {
+			log.Errorw("unable-to-update-device-using-adapter-data", log.Fields{"error": err})
+		}
+	}()
 	return new(empty.Empty), nil
 }
 
+// GetChildDevice returns details of child device
 func (rhp *AdapterRequestHandlerProxy) GetChildDevice(args []*ic.Argument) (*voltha.Device, error) {
 	if len(args) < 3 {
 		log.Warn("invalid-number-of-args", log.Fields{"args": args})
@@ -249,7 +262,7 @@
 	pID := &voltha.ID{}
 	transactionID := &ic.StrType{}
 	serialNumber := &ic.StrType{}
-	onuId := &ic.IntType{}
+	onuID := &ic.IntType{}
 	parentPortNo := &ic.IntType{}
 	for _, arg := range args {
 		switch arg.Key {
@@ -264,7 +277,7 @@
 				return nil, err
 			}
 		case "onu_id":
-			if err := ptypes.UnmarshalAny(arg.Value, onuId); err != nil {
+			if err := ptypes.UnmarshalAny(arg.Value, onuID); err != nil {
 				log.Warnw("cannot-unmarshal-ID", log.Fields{"error": err})
 				return nil, err
 			}
@@ -280,24 +293,25 @@
 			}
 		}
 	}
-	log.Debugw("GetChildDevice", log.Fields{"parentDeviceId": pID.Id, "args": args, "transactionID": transactionID.Val})
+	log.Debugw("GetChildDevice", log.Fields{"parentDeviceID": pID.Id, "args": args, "transactionID": transactionID.Val})
 
 	// Try to grab the transaction as this core may be competing with another Core
 	if rhp.competeForTransaction() {
-		if txn, err := rhp.takeRequestOwnership(transactionID.Val, pID.Id); err != nil {
+		txn, err := rhp.takeRequestOwnership(transactionID.Val, pID.Id)
+		if err != nil {
 			log.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
 			return nil, err
-		} else {
-			defer txn.Close()
 		}
+		defer txn.Close()
 	}
 
 	if rhp.TestMode { // Execute only for test cases
 		return &voltha.Device{Id: pID.Id}, nil
 	}
-	return rhp.deviceMgr.GetChildDevice(pID.Id, serialNumber.Val, onuId.Val, parentPortNo.Val)
+	return rhp.deviceMgr.GetChildDevice(pID.Id, serialNumber.Val, onuID.Val, parentPortNo.Val)
 }
 
+// GetChildDeviceWithProxyAddress returns details of child device with proxy address
 func (rhp *AdapterRequestHandlerProxy) GetChildDeviceWithProxyAddress(args []*ic.Argument) (*voltha.Device, error) {
 	if len(args) < 2 {
 		log.Warn("invalid-number-of-args", log.Fields{"args": args})
@@ -325,12 +339,12 @@
 
 	// Try to grab the transaction as this core may be competing with another Core
 	if rhp.competeForTransaction() {
-		if txn, err := rhp.takeRequestOwnership(transactionID.Val, proxyAddress.DeviceId); err != nil {
+		txn, err := rhp.takeRequestOwnership(transactionID.Val, proxyAddress.DeviceId)
+		if err != nil {
 			log.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
 			return nil, err
-		} else {
-			defer txn.Close()
 		}
+		defer txn.Close()
 	}
 
 	if rhp.TestMode { // Execute only for test cases
@@ -339,19 +353,20 @@
 	return rhp.deviceMgr.GetChildDeviceWithProxyAddress(proxyAddress)
 }
 
+// GetPorts returns the ports information of the device based on the port type.
 func (rhp *AdapterRequestHandlerProxy) GetPorts(args []*ic.Argument) (*voltha.Ports, error) {
 	if len(args) < 3 {
 		log.Warn("invalid-number-of-args", log.Fields{"args": args})
 		err := errors.New("invalid-number-of-args")
 		return nil, err
 	}
-	deviceId := &voltha.ID{}
+	deviceID := &voltha.ID{}
 	pt := &ic.IntType{}
 	transactionID := &ic.StrType{}
 	for _, arg := range args {
 		switch arg.Key {
 		case "device_id":
-			if err := ptypes.UnmarshalAny(arg.Value, deviceId); err != nil {
+			if err := ptypes.UnmarshalAny(arg.Value, deviceID); err != nil {
 				log.Warnw("cannot-unmarshal-device-id", log.Fields{"error": err})
 				return nil, err
 			}
@@ -367,7 +382,7 @@
 			}
 		}
 	}
-	log.Debugw("GetPorts", log.Fields{"deviceID": deviceId.Id, "portype": pt.Val, "transactionID": transactionID.Val})
+	log.Debugw("GetPorts", log.Fields{"deviceID": deviceID.Id, "portype": pt.Val, "transactionID": transactionID.Val})
 	if rhp.TestMode { // Execute only for test cases
 		aPort := &voltha.Port{Label: "test_port"}
 		allPorts := &voltha.Ports{}
@@ -376,17 +391,18 @@
 	}
 	// Try to grab the transaction as this core may be competing with another Core
 	if rhp.competeForTransaction() {
-		if txn, err := rhp.takeRequestOwnership(transactionID.Val, deviceId.Id); err != nil {
+		txn, err := rhp.takeRequestOwnership(transactionID.Val, deviceID.Id)
+		if err != nil {
 			log.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
 			return nil, err
-		} else {
-			defer txn.Close()
 		}
+		defer txn.Close()
 	}
 
-	return rhp.deviceMgr.getPorts(nil, deviceId.Id, voltha.Port_PortType(pt.Val))
+	return rhp.deviceMgr.getPorts(context.TODO(), deviceID.Id, voltha.Port_PortType(pt.Val))
 }
 
+// GetChildDevices gets all the child device IDs from the device passed as parameter
 func (rhp *AdapterRequestHandlerProxy) GetChildDevices(args []*ic.Argument) (*voltha.Devices, error) {
 	if len(args) < 2 {
 		log.Warn("invalid-number-of-args", log.Fields{"args": args})
@@ -410,16 +426,16 @@
 			}
 		}
 	}
-	log.Debugw("GetChildDevices", log.Fields{"deviceId": pID.Id, "transactionID": transactionID.Val})
+	log.Debugw("GetChildDevices", log.Fields{"deviceID": pID.Id, "transactionID": transactionID.Val})
 
 	// Try to grab the transaction as this core may be competing with another Core
 	if rhp.competeForTransaction() {
-		if txn, err := rhp.takeRequestOwnership(transactionID.Val, pID.Id); err != nil {
+		txn, err := rhp.takeRequestOwnership(transactionID.Val, pID.Id)
+		if err != nil {
 			log.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
 			return nil, err
-		} else {
-			defer txn.Close()
 		}
+		defer txn.Close()
 	}
 
 	if rhp.TestMode { // Execute only for test cases
@@ -442,11 +458,11 @@
 	pID := &voltha.ID{}
 	portNo := &ic.IntType{}
 	dt := &ic.StrType{}
-	chnlId := &ic.IntType{}
+	chnlID := &ic.IntType{}
 	transactionID := &ic.StrType{}
 	serialNumber := &ic.StrType{}
-	vendorId := &ic.StrType{}
-	onuId := &ic.IntType{}
+	vendorID := &ic.StrType{}
+	onuID := &ic.IntType{}
 	for _, arg := range args {
 		switch arg.Key {
 		case "parent_device_id":
@@ -465,12 +481,12 @@
 				return nil, err
 			}
 		case "channel_id":
-			if err := ptypes.UnmarshalAny(arg.Value, chnlId); err != nil {
+			if err := ptypes.UnmarshalAny(arg.Value, chnlID); err != nil {
 				log.Warnw("cannot-unmarshal-channel-id", log.Fields{"error": err})
 				return nil, err
 			}
 		case "vendor_id":
-			if err := ptypes.UnmarshalAny(arg.Value, vendorId); err != nil {
+			if err := ptypes.UnmarshalAny(arg.Value, vendorID); err != nil {
 				log.Warnw("cannot-unmarshal-vendor-id", log.Fields{"error": err})
 				return nil, err
 			}
@@ -480,7 +496,7 @@
 				return nil, err
 			}
 		case "onu_id":
-			if err := ptypes.UnmarshalAny(arg.Value, onuId); err != nil {
+			if err := ptypes.UnmarshalAny(arg.Value, onuID); err != nil {
 				log.Warnw("cannot-unmarshal-onu-id", log.Fields{"error": err})
 				return nil, err
 			}
@@ -491,46 +507,47 @@
 			}
 		}
 	}
-	log.Debugw("ChildDeviceDetected", log.Fields{"parentDeviceId": pID.Id, "parentPortNo": portNo.Val,
-		"deviceType": dt.Val, "channelId": chnlId.Val, "serialNumber": serialNumber.Val,
-		"vendorId": vendorId.Val, "onuId": onuId.Val, "transactionID": transactionID.Val})
+	log.Debugw("ChildDeviceDetected", log.Fields{"parentDeviceID": pID.Id, "parentPortNo": portNo.Val,
+		"deviceType": dt.Val, "channelID": chnlID.Val, "serialNumber": serialNumber.Val,
+		"vendorID": vendorID.Val, "onuID": onuID.Val, "transactionID": transactionID.Val})
 
 	// Try to grab the transaction as this core may be competing with another Core
 	if rhp.competeForTransaction() {
-		if txn, err := rhp.takeRequestOwnership(transactionID.Val, pID.Id); err != nil {
+		txn, err := rhp.takeRequestOwnership(transactionID.Val, pID.Id)
+		if err != nil {
 			log.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
 			return nil, err
-		} else {
-			defer txn.Close()
 		}
+		defer txn.Close()
 	}
 
 	if rhp.TestMode { // Execute only for test cases
 		return nil, nil
 	}
-	device, err := rhp.deviceMgr.childDeviceDetected(pID.Id, portNo.Val, dt.Val, chnlId.Val, vendorId.Val, serialNumber.Val, onuId.Val)
+	device, err := rhp.deviceMgr.childDeviceDetected(pID.Id, portNo.Val, dt.Val, chnlID.Val, vendorID.Val, serialNumber.Val, onuID.Val)
 	if err != nil {
-		log.Errorw("child-detection-failed", log.Fields{"parentId": pID.Id, "onuId": onuId.Val, "error": err})
+		log.Errorw("child-detection-failed", log.Fields{"parentID": pID.Id, "onuID": onuID.Val, "error": err})
 		return nil, err
 	}
 
 	return device, nil
 }
 
+// DeviceStateUpdate updates device status
 func (rhp *AdapterRequestHandlerProxy) DeviceStateUpdate(args []*ic.Argument) (*empty.Empty, error) {
 	if len(args) < 3 {
 		log.Warn("invalid-number-of-args", log.Fields{"args": args})
 		err := errors.New("invalid-number-of-args")
 		return nil, err
 	}
-	deviceId := &voltha.ID{}
+	deviceID := &voltha.ID{}
 	operStatus := &ic.IntType{}
 	connStatus := &ic.IntType{}
 	transactionID := &ic.StrType{}
 	for _, arg := range args {
 		switch arg.Key {
 		case "device_id":
-			if err := ptypes.UnmarshalAny(arg.Value, deviceId); err != nil {
+			if err := ptypes.UnmarshalAny(arg.Value, deviceID); err != nil {
 				log.Warnw("cannot-unmarshal-device-id", log.Fields{"error": err})
 				return nil, err
 			}
@@ -551,43 +568,49 @@
 			}
 		}
 	}
-	log.Debugw("DeviceStateUpdate", log.Fields{"deviceId": deviceId.Id, "oper-status": operStatus,
+	log.Debugw("DeviceStateUpdate", log.Fields{"deviceID": deviceID.Id, "oper-status": operStatus,
 		"conn-status": connStatus, "transactionID": transactionID.Val})
 
 	// Try to grab the transaction as this core may be competing with another Core
 	if rhp.competeForTransaction() {
-		if txn, err := rhp.takeRequestOwnership(transactionID.Val, deviceId.Id); err != nil {
+		txn, err := rhp.takeRequestOwnership(transactionID.Val, deviceID.Id)
+		if err != nil {
 			log.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
 			return nil, err
-		} else {
-			defer txn.Close()
 		}
+		defer txn.Close()
 	}
 
 	if rhp.TestMode { // Execute only for test cases
 		return nil, nil
 	}
 	// When the enum is not set (i.e. -1), Go still convert to the Enum type with the value being -1
-	go rhp.deviceMgr.updateDeviceStatus(deviceId.Id, voltha.OperStatus_OperStatus(operStatus.Val),
-		voltha.ConnectStatus_ConnectStatus(connStatus.Val))
+	go func() {
+		err := rhp.deviceMgr.updateDeviceStatus(deviceID.Id, voltha.OperStatus_OperStatus(operStatus.Val),
+			voltha.ConnectStatus_ConnectStatus(connStatus.Val))
+		if err != nil {
+			log.Errorw("unable-to-update-device-status", log.Fields{"error": err})
+		}
+	}()
 
 	return new(empty.Empty), nil
 }
 
+// ChildrenStateUpdate updates child device status
 func (rhp *AdapterRequestHandlerProxy) ChildrenStateUpdate(args []*ic.Argument) (*empty.Empty, error) {
 	if len(args) < 3 {
 		log.Warn("invalid-number-of-args", log.Fields{"args": args})
 		err := errors.New("invalid-number-of-args")
 		return nil, err
 	}
-	deviceId := &voltha.ID{}
+	deviceID := &voltha.ID{}
 	operStatus := &ic.IntType{}
 	connStatus := &ic.IntType{}
 	transactionID := &ic.StrType{}
 	for _, arg := range args {
 		switch arg.Key {
 		case "device_id":
-			if err := ptypes.UnmarshalAny(arg.Value, deviceId); err != nil {
+			if err := ptypes.UnmarshalAny(arg.Value, deviceID); err != nil {
 				log.Warnw("cannot-unmarshal-device-id", log.Fields{"error": err})
 				return nil, err
 			}
@@ -608,17 +631,17 @@
 			}
 		}
 	}
-	log.Debugw("ChildrenStateUpdate", log.Fields{"deviceId": deviceId.Id, "oper-status": operStatus,
+	log.Debugw("ChildrenStateUpdate", log.Fields{"deviceID": deviceID.Id, "oper-status": operStatus,
 		"conn-status": connStatus, "transactionID": transactionID.Val})
 
 	// Try to grab the transaction as this core may be competing with another Core
 	if rhp.competeForTransaction() {
-		if txn, err := rhp.takeRequestOwnership(transactionID.Val, deviceId.Id); err != nil {
+		txn, err := rhp.takeRequestOwnership(transactionID.Val, deviceID.Id)
+		if err != nil {
 			log.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
 			return nil, err
-		} else {
-			defer txn.Close()
 		}
+		defer txn.Close()
 	}
 
 	if rhp.TestMode { // Execute only for test cases
@@ -626,29 +649,35 @@
 	}
 
 	// When the enum is not set (i.e. -1), Go still convert to the Enum type with the value being -1
-	go rhp.deviceMgr.updateChildrenStatus(deviceId.Id, voltha.OperStatus_OperStatus(operStatus.Val),
-		voltha.ConnectStatus_ConnectStatus(connStatus.Val))
+	go func() {
+		err := rhp.deviceMgr.updateChildrenStatus(deviceID.Id, voltha.OperStatus_OperStatus(operStatus.Val),
+			voltha.ConnectStatus_ConnectStatus(connStatus.Val))
+		if err != nil {
+			log.Errorw("unable-to-update-children-status", log.Fields{"error": err})
+		}
+	}()
 
-	//if err := rhp.deviceMgr.updateChildrenStatus(deviceId.Id, voltha.OperStatus_OperStatus(operStatus.Val),
+	//if err := rhp.deviceMgr.updateChildrenStatus(deviceID.ID, voltha.OperStatus_OperStatus(operStatus.Val),
 	//	voltha.ConnectStatus_ConnectStatus(connStatus.Val)); err != nil {
 	//	return nil, err
 	//}
 	return new(empty.Empty), nil
 }
 
+// PortsStateUpdate updates the ports state related to the device
 func (rhp *AdapterRequestHandlerProxy) PortsStateUpdate(args []*ic.Argument) (*empty.Empty, error) {
 	if len(args) < 2 {
 		log.Warn("invalid-number-of-args", log.Fields{"args": args})
 		err := errors.New("invalid-number-of-args")
 		return nil, err
 	}
-	deviceId := &voltha.ID{}
+	deviceID := &voltha.ID{}
 	operStatus := &ic.IntType{}
 	transactionID := &ic.StrType{}
 	for _, arg := range args {
 		switch arg.Key {
 		case "device_id":
-			if err := ptypes.UnmarshalAny(arg.Value, deviceId); err != nil {
+			if err := ptypes.UnmarshalAny(arg.Value, deviceID); err != nil {
 				log.Warnw("cannot-unmarshal-device-id", log.Fields{"error": err})
 				return nil, err
 			}
@@ -664,34 +693,40 @@
 			}
 		}
 	}
-	log.Debugw("PortsStateUpdate", log.Fields{"deviceId": deviceId.Id, "operStatus": operStatus, "transactionID": transactionID.Val})
+	log.Debugw("PortsStateUpdate", log.Fields{"deviceID": deviceID.Id, "operStatus": operStatus, "transactionID": transactionID.Val})
 
 	// Try to grab the transaction as this core may be competing with another Core
 	if rhp.competeForTransaction() {
-		if txn, err := rhp.takeRequestOwnership(transactionID.Val, deviceId.Id); err != nil {
+		txn, err := rhp.takeRequestOwnership(transactionID.Val, deviceID.Id)
+		if err != nil {
 			log.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
 			return nil, err
-		} else {
-			defer txn.Close()
 		}
+		defer txn.Close()
 	}
 
 	if rhp.TestMode { // Execute only for test cases
 		return nil, nil
 	}
 
-	go rhp.deviceMgr.updatePortsState(deviceId.Id, voltha.OperStatus_OperStatus(operStatus.Val))
+	go func() {
+		err := rhp.deviceMgr.updatePortsState(deviceID.Id, voltha.OperStatus_OperStatus(operStatus.Val))
+		if err != nil {
+			log.Errorw("unable-to-update-ports-state", log.Fields{"error": err})
+		}
+	}()
 
 	return new(empty.Empty), nil
 }
 
+// PortStateUpdate updates the port state of the device
 func (rhp *AdapterRequestHandlerProxy) PortStateUpdate(args []*ic.Argument) (*empty.Empty, error) {
 	if len(args) < 3 {
 		log.Warn("invalid-number-of-args", log.Fields{"args": args})
 		err := errors.New("invalid-number-of-args")
 		return nil, err
 	}
-	deviceId := &voltha.ID{}
+	deviceID := &voltha.ID{}
 	portType := &ic.IntType{}
 	portNo := &ic.IntType{}
 	operStatus := &ic.IntType{}
@@ -699,7 +734,7 @@
 	for _, arg := range args {
 		switch arg.Key {
 		case "device_id":
-			if err := ptypes.UnmarshalAny(arg.Value, deviceId); err != nil {
+			if err := ptypes.UnmarshalAny(arg.Value, deviceID); err != nil {
 				log.Warnw("cannot-unmarshal-device-id", log.Fields{"error": err})
 				return nil, err
 			}
@@ -725,45 +760,51 @@
 			}
 		}
 	}
-	log.Debugw("PortStateUpdate", log.Fields{"deviceId": deviceId.Id, "operStatus": operStatus,
+	log.Debugw("PortStateUpdate", log.Fields{"deviceID": deviceID.Id, "operStatus": operStatus,
 		"portType": portType, "portNo": portNo, "transactionID": transactionID.Val})
 
 	// Try to grab the transaction as this core may be competing with another Core
 	if rhp.competeForTransaction() {
-		if txn, err := rhp.takeRequestOwnership(transactionID.Val, deviceId.Id); err != nil {
+		txn, err := rhp.takeRequestOwnership(transactionID.Val, deviceID.Id)
+		if err != nil {
 			log.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
 			return nil, err
-		} else {
-			defer txn.Close()
 		}
+		defer txn.Close()
 	}
 
 	if rhp.TestMode { // Execute only for test cases
 		return nil, nil
 	}
 
-	go rhp.deviceMgr.updatePortState(deviceId.Id, voltha.Port_PortType(portType.Val), uint32(portNo.Val),
-		voltha.OperStatus_OperStatus(operStatus.Val))
+	go func() {
+		err := rhp.deviceMgr.updatePortState(deviceID.Id, voltha.Port_PortType(portType.Val), uint32(portNo.Val),
+			voltha.OperStatus_OperStatus(operStatus.Val))
+		if err != nil {
+			log.Errorw("unable-to-update-port-state", log.Fields{"error": err})
+		}
+	}()
 
-	//if err := rhp.deviceMgr.updatePortState(deviceId.Id, voltha.Port_PortType(portType.Val), uint32(portNo.Val),
+	//if err := rhp.deviceMgr.updatePortState(deviceID.ID, voltha.Port_PortType(portType.Val), uint32(portNo.Val),
 	//	voltha.OperStatus_OperStatus(operStatus.Val)); err != nil {
 	//	return nil, err
 	//}
 	return new(empty.Empty), nil
 }
 
+// DeleteAllPorts deletes all ports of device
 func (rhp *AdapterRequestHandlerProxy) DeleteAllPorts(args []*ic.Argument) (*empty.Empty, error) {
 	if len(args) < 3 {
 		log.Warn("invalid-number-of-args", log.Fields{"args": args})
 		err := errors.New("invalid-number-of-args")
 		return nil, err
 	}
-	deviceId := &voltha.ID{}
+	deviceID := &voltha.ID{}
 	transactionID := &ic.StrType{}
 	for _, arg := range args {
 		switch arg.Key {
 		case "device_id":
-			if err := ptypes.UnmarshalAny(arg.Value, deviceId); err != nil {
+			if err := ptypes.UnmarshalAny(arg.Value, deviceID); err != nil {
 				log.Warnw("cannot-unmarshal-device-id", log.Fields{"error": err})
 				return nil, err
 			}
@@ -774,39 +815,46 @@
 			}
 		}
 	}
-	log.Debugw("DeleteAllPorts", log.Fields{"deviceId": deviceId.Id, "transactionID": transactionID.Val})
+	log.Debugw("DeleteAllPorts", log.Fields{"deviceID": deviceID.Id, "transactionID": transactionID.Val})
 
 	// Try to grab the transaction as this core may be competing with another Core
 	if rhp.competeForTransaction() {
-		if txn, err := rhp.takeRequestOwnership(transactionID.Val, deviceId.Id); err != nil {
+		txn, err := rhp.takeRequestOwnership(transactionID.Val, deviceID.Id)
+		if err != nil {
 			log.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
 			return nil, err
-		} else {
-			defer txn.Close()
 		}
+		defer txn.Close()
 	}
 
 	if rhp.TestMode { // Execute only for test cases
 		return nil, nil
 	}
 
-	go rhp.deviceMgr.deleteAllPorts(deviceId.Id)
+	go func() {
+		err := rhp.deviceMgr.deleteAllPorts(deviceID.Id)
+		if err != nil {
+			log.Errorw("unable-to-delete-ports", log.Fields{"error": err})
+		}
+	}()
 
 	return new(empty.Empty), nil
 }
 
+// ChildDevicesLost indicates that a parent device is in a state (Disabled) where it cannot manage the child devices.
+// This will trigger the Core to disable all the child devices.
 func (rhp *AdapterRequestHandlerProxy) ChildDevicesLost(args []*ic.Argument) (*empty.Empty, error) {
 	if len(args) < 2 {
 		log.Warn("invalid-number-of-args", log.Fields{"args": args})
 		err := errors.New("invalid-number-of-args")
 		return nil, err
 	}
-	parentDeviceId := &voltha.ID{}
+	parentDeviceID := &voltha.ID{}
 	transactionID := &ic.StrType{}
 	for _, arg := range args {
 		switch arg.Key {
 		case "parent_device_id":
-			if err := ptypes.UnmarshalAny(arg.Value, parentDeviceId); err != nil {
+			if err := ptypes.UnmarshalAny(arg.Value, parentDeviceID); err != nil {
 				log.Warnw("cannot-unmarshal-device-id", log.Fields{"error": err})
 				return nil, err
 			}
@@ -817,39 +865,46 @@
 			}
 		}
 	}
-	log.Debugw("ChildDevicesLost", log.Fields{"deviceId": parentDeviceId.Id, "transactionID": transactionID.Val})
+	log.Debugw("ChildDevicesLost", log.Fields{"deviceID": parentDeviceID.Id, "transactionID": transactionID.Val})
 
 	// Try to grab the transaction as this core may be competing with another Core
 	if rhp.competeForTransaction() {
-		if txn, err := rhp.takeRequestOwnership(transactionID.Val, parentDeviceId.Id); err != nil {
+		txn, err := rhp.takeRequestOwnership(transactionID.Val, parentDeviceID.Id)
+		if err != nil {
 			log.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
 			return nil, err
-		} else {
-			defer txn.Close()
 		}
+		defer txn.Close()
 	}
 
 	if rhp.TestMode { // Execute only for test cases
 		return nil, nil
 	}
 
-	go rhp.deviceMgr.childDevicesLost(parentDeviceId.Id)
+	go func() {
+		err := rhp.deviceMgr.childDevicesLost(parentDeviceID.Id)
+		if err != nil {
+			log.Errorw("unable-to-disable-child-devices", log.Fields{"error": err})
+		}
+	}()
 
 	return new(empty.Empty), nil
 }
 
+// ChildDevicesDetected invoked by an adapter when child devices are found, typically after after a disable/enable sequence.
+// This will trigger the Core to Enable all the child devices of that parent.
 func (rhp *AdapterRequestHandlerProxy) ChildDevicesDetected(args []*ic.Argument) (*empty.Empty, error) {
 	if len(args) < 2 {
 		log.Warn("invalid-number-of-args", log.Fields{"args": args})
 		err := errors.New("invalid-number-of-args")
 		return nil, err
 	}
-	parentDeviceId := &voltha.ID{}
+	parentDeviceID := &voltha.ID{}
 	transactionID := &ic.StrType{}
 	for _, arg := range args {
 		switch arg.Key {
 		case "parent_device_id":
-			if err := ptypes.UnmarshalAny(arg.Value, parentDeviceId); err != nil {
+			if err := ptypes.UnmarshalAny(arg.Value, parentDeviceID); err != nil {
 				log.Warnw("cannot-unmarshal-device-id", log.Fields{"error": err})
 				return nil, err
 			}
@@ -860,43 +915,44 @@
 			}
 		}
 	}
-	log.Debugw("ChildDevicesDetected", log.Fields{"deviceId": parentDeviceId.Id, "transactionID": transactionID.Val})
+	log.Debugw("ChildDevicesDetected", log.Fields{"deviceID": parentDeviceID.Id, "transactionID": transactionID.Val})
 
 	// Try to grab the transaction as this core may be competing with another Core
 	if rhp.competeForTransaction() {
-		if txn, err := rhp.takeRequestOwnership(transactionID.Val, parentDeviceId.Id); err != nil {
+		txn, err := rhp.takeRequestOwnership(transactionID.Val, parentDeviceID.Id)
+		if err != nil {
 			log.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
 			return nil, err
-		} else {
-			defer txn.Close()
 		}
+		defer txn.Close()
 	}
 
 	if rhp.TestMode { // Execute only for test cases
 		return nil, nil
 	}
 
-	if err := rhp.deviceMgr.childDevicesDetected(parentDeviceId.Id); err != nil {
-		log.Errorw("child-devices-dection-failed", log.Fields{"parentId": parentDeviceId.Id, "error": err})
+	if err := rhp.deviceMgr.childDevicesDetected(parentDeviceID.Id); err != nil {
+		log.Errorw("child-devices-dection-failed", log.Fields{"parentID": parentDeviceID.Id, "error": err})
 		return nil, err
 	}
 
 	return new(empty.Empty), nil
 }
 
+// PortCreated adds port to device
 func (rhp *AdapterRequestHandlerProxy) PortCreated(args []*ic.Argument) (*empty.Empty, error) {
 	if len(args) < 3 {
 		log.Warn("invalid-number-of-args", log.Fields{"args": args})
 		err := errors.New("invalid-number-of-args")
 		return nil, err
 	}
-	deviceId := &voltha.ID{}
+	deviceID := &voltha.ID{}
 	port := &voltha.Port{}
 	transactionID := &ic.StrType{}
 	for _, arg := range args {
 		switch arg.Key {
 		case "device_id":
-			if err := ptypes.UnmarshalAny(arg.Value, deviceId); err != nil {
+			if err := ptypes.UnmarshalAny(arg.Value, deviceID); err != nil {
 				log.Warnw("cannot-unmarshal-device-id", log.Fields{"error": err})
 				return nil, err
 			}
@@ -912,26 +968,32 @@
 			}
 		}
 	}
-	log.Debugw("PortCreated", log.Fields{"deviceId": deviceId.Id, "port": port, "transactionID": transactionID.Val})
+	log.Debugw("PortCreated", log.Fields{"deviceID": deviceID.Id, "port": port, "transactionID": transactionID.Val})
 
 	// Try to grab the transaction as this core may be competing with another Core
 	if rhp.competeForTransaction() {
-		if txn, err := rhp.takeRequestOwnership(transactionID.Val, deviceId.Id); err != nil {
+		txn, err := rhp.takeRequestOwnership(transactionID.Val, deviceID.Id)
+		if err != nil {
 			log.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
 			return nil, err
-		} else {
-			defer txn.Close()
 		}
+		defer txn.Close()
 	}
 
 	if rhp.TestMode { // Execute only for test cases
 		return nil, nil
 	}
-	go rhp.deviceMgr.addPort(deviceId.Id, port)
+	go func() {
+		err := rhp.deviceMgr.addPort(deviceID.Id, port)
+		if err != nil {
+			log.Errorw("unable-to-add-port", log.Fields{"error": err})
+		}
+	}()
 
 	return new(empty.Empty), nil
 }
 
+// DevicePMConfigUpdate initializes the pm configs as defined by the adapter.
 func (rhp *AdapterRequestHandlerProxy) DevicePMConfigUpdate(args []*ic.Argument) (*empty.Empty, error) {
 	if len(args) < 2 {
 		log.Warn("invalid-number-of-args", log.Fields{"args": args})
@@ -954,42 +1016,48 @@
 			}
 		}
 	}
-	log.Debugw("DevicePMConfigUpdate", log.Fields{"deviceId": pmConfigs.Id, "configs": pmConfigs,
+	log.Debugw("DevicePMConfigUpdate", log.Fields{"deviceID": pmConfigs.Id, "configs": pmConfigs,
 		"transactionID": transactionID.Val})
 
 	// Try to grab the transaction as this core may be competing with another Core
 	if rhp.competeForTransaction() {
-		if txn, err := rhp.takeRequestOwnership(transactionID.Val, pmConfigs.Id); err != nil {
+		txn, err := rhp.takeRequestOwnership(transactionID.Val, pmConfigs.Id)
+		if err != nil {
 			log.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
 			return nil, err
-		} else {
-			defer txn.Close()
 		}
+		defer txn.Close()
 	}
 
 	if rhp.TestMode { // Execute only for test cases
 		return nil, nil
 	}
 
-	go rhp.deviceMgr.initPmConfigs(pmConfigs.Id, pmConfigs)
+	go func() {
+		err := rhp.deviceMgr.initPmConfigs(pmConfigs.Id, pmConfigs)
+		if err != nil {
+			log.Errorw("unable-to-initialize-pm-configs", log.Fields{"error": err})
+		}
+	}()
 
 	return new(empty.Empty), nil
 }
 
+// PacketIn sends the incoming packet of device
 func (rhp *AdapterRequestHandlerProxy) PacketIn(args []*ic.Argument) (*empty.Empty, error) {
 	if len(args) < 4 {
 		log.Warn("invalid-number-of-args", log.Fields{"args": args})
 		err := errors.New("invalid-number-of-args")
 		return nil, err
 	}
-	deviceId := &voltha.ID{}
+	deviceID := &voltha.ID{}
 	portNo := &ic.IntType{}
 	packet := &ic.Packet{}
 	transactionID := &ic.StrType{}
 	for _, arg := range args {
 		switch arg.Key {
 		case "device_id":
-			if err := ptypes.UnmarshalAny(arg.Value, deviceId); err != nil {
+			if err := ptypes.UnmarshalAny(arg.Value, deviceID); err != nil {
 				log.Warnw("cannot-unmarshal-device-id", log.Fields{"error": err})
 				return nil, err
 			}
@@ -1010,41 +1078,47 @@
 			}
 		}
 	}
-	log.Debugw("PacketIn", log.Fields{"deviceId": deviceId.Id, "port": portNo.Val, "packet": packet,
+	log.Debugw("PacketIn", log.Fields{"deviceID": deviceID.Id, "port": portNo.Val, "packet": packet,
 		"transactionID": transactionID.Val})
 
 	// Try to grab the transaction as this core may be competing with another Core
 	// TODO: If this adds too much latencies then needs to remove transaction and let OFAgent filter out
 	// duplicates.
 	if rhp.competeForTransaction() {
-		if txn, err := rhp.takeRequestOwnership(transactionID.Val, deviceId.Id); err != nil {
+		txn, err := rhp.takeRequestOwnership(transactionID.Val, deviceID.Id)
+		if err != nil {
 			log.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
 			return nil, err
-		} else {
-			defer txn.Close()
 		}
+		defer txn.Close()
 	}
 	if rhp.TestMode { // Execute only for test cases
 		return nil, nil
 	}
-	go rhp.deviceMgr.PacketIn(deviceId.Id, uint32(portNo.Val), transactionID.Val, packet.Payload)
+	go func() {
+		err := rhp.deviceMgr.PacketIn(deviceID.Id, uint32(portNo.Val), transactionID.Val, packet.Payload)
+		if err != nil {
+			log.Errorw("unable-to-receive-packet-from-adapter", log.Fields{"error": err})
+		}
+	}()
 
 	return new(empty.Empty), nil
 }
 
+// UpdateImageDownload updates image download
 func (rhp *AdapterRequestHandlerProxy) UpdateImageDownload(args []*ic.Argument) (*empty.Empty, error) {
 	if len(args) < 2 {
 		log.Warn("invalid-number-of-args", log.Fields{"args": args})
 		err := errors.New("invalid-number-of-args")
 		return nil, err
 	}
-	deviceId := &voltha.ID{}
+	deviceID := &voltha.ID{}
 	img := &voltha.ImageDownload{}
 	transactionID := &ic.StrType{}
 	for _, arg := range args {
 		switch arg.Key {
 		case "device_id":
-			if err := ptypes.UnmarshalAny(arg.Value, deviceId); err != nil {
+			if err := ptypes.UnmarshalAny(arg.Value, deviceID); err != nil {
 				log.Warnw("cannot-unmarshal-device-id", log.Fields{"error": err})
 				return nil, err
 			}
@@ -1060,41 +1134,47 @@
 			}
 		}
 	}
-	log.Debugw("UpdateImageDownload", log.Fields{"deviceId": deviceId.Id, "image-download": img,
+	log.Debugw("UpdateImageDownload", log.Fields{"deviceID": deviceID.Id, "image-download": img,
 		"transactionID": transactionID.Val})
 
 	// Try to grab the transaction as this core may be competing with another Core
 	if rhp.competeForTransaction() {
-		if txn, err := rhp.takeRequestOwnership(transactionID.Val, deviceId.Id); err != nil {
+		txn, err := rhp.takeRequestOwnership(transactionID.Val, deviceID.Id)
+		if err != nil {
 			log.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
 			return nil, err
-		} else {
-			defer txn.Close()
 		}
+		defer txn.Close()
 	}
 
 	if rhp.TestMode { // Execute only for test cases
 		return nil, nil
 	}
-	go rhp.deviceMgr.updateImageDownload(deviceId.Id, img)
-	//if err := rhp.deviceMgr.updateImageDownload(deviceId.Id, img); err != nil {
+	go func() {
+		err := rhp.deviceMgr.updateImageDownload(deviceID.Id, img)
+		if err != nil {
+			log.Errorw("unable-to-update-image-download", log.Fields{"error": err})
+		}
+	}()
+	//if err := rhp.deviceMgr.updateImageDownload(deviceID.ID, img); err != nil {
 	//	return nil, err
 	//}
 	return new(empty.Empty), nil
 }
 
+// ReconcileChildDevices reconciles child devices
 func (rhp *AdapterRequestHandlerProxy) ReconcileChildDevices(args []*ic.Argument) (*empty.Empty, error) {
 	if len(args) < 2 {
 		log.Warn("invalid-number-of-args", log.Fields{"args": args})
 		err := errors.New("invalid-number-of-args")
 		return nil, err
 	}
-	parentDeviceId := &voltha.ID{}
+	parentDeviceID := &voltha.ID{}
 	transactionID := &ic.StrType{}
 	for _, arg := range args {
 		switch arg.Key {
 		case "parent_device_id":
-			if err := ptypes.UnmarshalAny(arg.Value, parentDeviceId); err != nil {
+			if err := ptypes.UnmarshalAny(arg.Value, parentDeviceID); err != nil {
 				log.Warnw("cannot-unmarshal-device-id", log.Fields{"error": err})
 				return nil, err
 			}
@@ -1105,16 +1185,16 @@
 			}
 		}
 	}
-	log.Debugw("ReconcileChildDevices", log.Fields{"deviceId": parentDeviceId.Id, "transactionID": transactionID.Val})
+	log.Debugw("ReconcileChildDevices", log.Fields{"deviceID": parentDeviceID.Id, "transactionID": transactionID.Val})
 
 	// Try to grab the transaction as this core may be competing with another Core
 	if rhp.competeForTransaction() {
-		if txn, err := rhp.takeRequestOwnership(transactionID.Val, parentDeviceId.Id); err != nil {
+		txn, err := rhp.takeRequestOwnership(transactionID.Val, parentDeviceID.Id)
+		if err != nil {
 			log.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
 			return nil, err
-		} else {
-			defer txn.Close()
 		}
+		defer txn.Close()
 	}
 
 	if rhp.TestMode { // Execute only for test cases
@@ -1122,24 +1202,30 @@
 	}
 
 	// Run it in its own routine
-	go rhp.deviceMgr.reconcileChildDevices(parentDeviceId.Id)
+	go func() {
+		err := rhp.deviceMgr.reconcileChildDevices(parentDeviceID.Id)
+		if err != nil {
+			log.Errorw("unable-to-reconcile-child-devices", log.Fields{"error": err})
+		}
+	}()
 
 	return new(empty.Empty), nil
 }
 
+// DeviceReasonUpdate updates device reason
 func (rhp *AdapterRequestHandlerProxy) DeviceReasonUpdate(args []*ic.Argument) (*empty.Empty, error) {
 	if len(args) < 2 {
 		log.Warn("DeviceReasonUpdate: invalid-number-of-args", log.Fields{"args": args})
 		err := errors.New("DeviceReasonUpdate: invalid-number-of-args")
 		return nil, err
 	}
-	deviceId := &voltha.ID{}
+	deviceID := &voltha.ID{}
 	reason := &ic.StrType{}
 	transactionID := &ic.StrType{}
 	for _, arg := range args {
 		switch arg.Key {
 		case "device_id":
-			if err := ptypes.UnmarshalAny(arg.Value, deviceId); err != nil {
+			if err := ptypes.UnmarshalAny(arg.Value, deviceID); err != nil {
 				log.Warnw("cannot-unmarshal-device-id", log.Fields{"error": err})
 				return nil, err
 			}
@@ -1155,17 +1241,17 @@
 			}
 		}
 	}
-	log.Debugw("DeviceReasonUpdate", log.Fields{"deviceId": deviceId.Id, "reason": reason.Val,
+	log.Debugw("DeviceReasonUpdate", log.Fields{"deviceId": deviceID.Id, "reason": reason.Val,
 		"transactionID": transactionID.Val})
 
 	// Try to grab the transaction as this core may be competing with another Core
 	if rhp.competeForTransaction() {
-		if txn, err := rhp.takeRequestOwnership(transactionID.Val, deviceId.Id); err != nil {
+		txn, err := rhp.takeRequestOwnership(transactionID.Val, deviceID.Id)
+		if err != nil {
 			log.Debugw("DeviceReasonUpdate: Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
 			return nil, err
-		} else {
-			defer txn.Close()
 		}
+		defer txn.Close()
 	}
 
 	if rhp.TestMode { // Execute only for test cases
@@ -1173,7 +1259,12 @@
 	}
 
 	// Run it in its own routine
-	go rhp.deviceMgr.updateDeviceReason(deviceId.Id, reason.Val)
+	go func() {
+		err := rhp.deviceMgr.updateDeviceReason(deviceID.Id, reason.Val)
+		if err != nil {
+			log.Errorw("unable-to-update-device-reason", log.Fields{"error": err})
+		}
+	}()
 
 	return new(empty.Empty), nil
 }
diff --git a/rw_core/core/core.go b/rw_core/core/core.go
index 047ef4a..ef08402 100644
--- a/rw_core/core/core.go
+++ b/rw_core/core/core.go
@@ -13,10 +13,13 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package core
 
 import (
 	"context"
+	"time"
+
 	"github.com/opencord/voltha-go/db/model"
 	"github.com/opencord/voltha-go/rw_core/config"
 	"github.com/opencord/voltha-lib-go/v2/pkg/db"
@@ -29,11 +32,11 @@
 	"google.golang.org/grpc"
 	"google.golang.org/grpc/codes"
 	"google.golang.org/grpc/status"
-	"time"
 )
 
+// Core represent read,write core attributes
 type Core struct {
-	instanceId        string
+	instanceID        string
 	deviceMgr         *DeviceManager
 	logicalDeviceMgr  *LogicalDeviceManager
 	grpcServer        *grpcserver.GrpcServer
@@ -53,12 +56,16 @@
 }
 
 func init() {
-	log.AddPackage(log.JSON, log.WarnLevel, nil)
+	_, err := log.AddPackage(log.JSON, log.WarnLevel, nil)
+	if err != nil {
+		log.Errorw("unable-to-register-package-to-the-log-map", log.Fields{"error": err})
+	}
 }
 
+// NewCore creates instance of rw core
 func NewCore(id string, cf *config.RWCoreFlags, kvClient kvstore.Client, kafkaClient kafka.Client) *Core {
 	var core Core
-	core.instanceId = id
+	core.instanceID = id
 	core.exitChannel = make(chan int, 1)
 	core.config = cf
 	core.kvClient = kvClient
@@ -84,6 +91,7 @@
 	return &core
 }
 
+// Start brings up core services
 func (core *Core) Start(ctx context.Context) {
 
 	// If the context has a probe then fetch it and register our services
@@ -102,7 +110,7 @@
 		}
 	}
 
-	log.Info("starting-core-services", log.Fields{"coreId": core.instanceId})
+	log.Info("starting-core-services", log.Fields{"coreId": core.instanceID})
 
 	// Wait until connection to KV Store is up
 	if err := core.waitUntilKVStoreReachableOrMaxTries(ctx, core.config.MaxConnectionRetries, core.config.ConnectionRetryInterval); err != nil {
@@ -120,7 +128,7 @@
 
 	log.Debugw("values", log.Fields{"kmp": core.kmp})
 	core.deviceMgr = newDeviceManager(core)
-	core.adapterMgr = newAdapterManager(core.clusterDataProxy, core.instanceId, core.deviceMgr)
+	core.adapterMgr = newAdapterManager(core.clusterDataProxy, core.instanceID, core.deviceMgr)
 	core.deviceMgr.adapterMgr = core.adapterMgr
 	core.logicalDeviceMgr = newLogicalDeviceManager(core, core.deviceMgr, core.kmp, core.clusterDataProxy, core.config.DefaultCoreTimeout)
 
@@ -140,12 +148,13 @@
 	go core.monitorKvstoreLiveness(ctx)
 
 	// Setup device ownership context
-	core.deviceOwnership = NewDeviceOwnership(core.instanceId, core.kvClient, core.deviceMgr, core.logicalDeviceMgr,
+	core.deviceOwnership = NewDeviceOwnership(core.instanceID, core.kvClient, core.deviceMgr, core.logicalDeviceMgr,
 		"service/voltha/owns_device", 10)
 
 	log.Info("core-services-started")
 }
 
+// Stop brings down core services
 func (core *Core) Stop(ctx context.Context) {
 	log.Info("stopping-adaptercore")
 	if core.exitChannel != nil {
@@ -231,13 +240,13 @@
 /*
  * KafkaMonitorThread
  *
- * Repsonsible for starting the Kafka Interadapter Proxy and monitoring its liveness
+ * Responsible for starting the Kafka Interadapter Proxy and monitoring its liveness
  * state.
  *
  * Any producer that fails to send will cause KafkaInterContainerProxy to
  * post a false event on its liveness channel. Any producer that succeeds in sending
  * will cause KafkaInterContainerProxy to post a true event on its liveness
- * channel. Group recievers also update liveness state, and a receiver will typically
+ * channel. Group receivers also update liveness state, and a receiver will typically
  * indicate a loss of liveness within 3-5 seconds of Kafka going down. Receivers
  * only indicate restoration of liveness if a message is received. During normal
  * operation, messages will be routinely produced and received, automatically
@@ -281,7 +290,7 @@
 			log.Infow("started-kafka-proxy", log.Fields{})
 
 			// cannot do this until after the kmp is started
-			if err := core.registerAdapterRequestHandlers(ctx, core.instanceId, core.deviceMgr, core.logicalDeviceMgr, core.adapterMgr, core.clusterDataProxy, core.localDataProxy); err != nil {
+			if err := core.registerAdapterRequestHandlers(ctx, core.instanceID, core.deviceMgr, core.logicalDeviceMgr, core.adapterMgr, core.clusterDataProxy, core.localDataProxy); err != nil {
 				log.Fatal("Failure-registering-adapterRequestHandler")
 			}
 
@@ -357,7 +366,7 @@
 					return status.Error(codes.Unavailable, "kv store unreachable")
 				}
 			}
-			count += 1
+			count++
 			//	Take a nap before retrying
 			time.Sleep(retryInterval)
 			log.Infow("retry-KV-store-connectivity", log.Fields{"retryCount": count, "maxRetries": maxRetries, "retryInterval": retryInterval})
@@ -370,10 +379,10 @@
 	return nil
 }
 
-func (core *Core) registerAdapterRequestHandlers(ctx context.Context, coreInstanceId string, dMgr *DeviceManager,
+func (core *Core) registerAdapterRequestHandlers(ctx context.Context, coreInstanceID string, dMgr *DeviceManager,
 	ldMgr *LogicalDeviceManager, aMgr *AdapterManager, cdProxy *model.Proxy, ldProxy *model.Proxy,
 ) error {
-	requestProxy := NewAdapterRequestHandlerProxy(core, coreInstanceId, dMgr, ldMgr, aMgr, cdProxy, ldProxy,
+	requestProxy := NewAdapterRequestHandlerProxy(core, coreInstanceID, dMgr, ldMgr, aMgr, cdProxy, ldProxy,
 		core.config.InCompetingMode, core.config.LongRunningRequestTimeout, core.config.DefaultRequestTimeout)
 
 	// Register the broadcast topic to handle any core-bound broadcast requests
diff --git a/rw_core/core/device_agent.go b/rw_core/core/device_agent.go
index 9dd41fb..0f4c177 100755
--- a/rw_core/core/device_agent.go
+++ b/rw_core/core/device_agent.go
@@ -13,6 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package core
 
 import (
@@ -35,9 +36,10 @@
 	"google.golang.org/grpc/status"
 )
 
+// DeviceAgent represents device agent attributes
 type DeviceAgent struct {
-	deviceId         string
-	parentId         string
+	deviceID         string
+	parentID         string
 	deviceType       string
 	isRootdevice     bool
 	adapterProxy     *AdapterProxy
@@ -55,13 +57,13 @@
 	var agent DeviceAgent
 	agent.adapterProxy = ap
 	if device.Id == "" {
-		agent.deviceId = CreateDeviceId()
+		agent.deviceID = CreateDeviceID()
 	} else {
-		agent.deviceId = device.Id
+		agent.deviceID = device.Id
 	}
 
 	agent.isRootdevice = device.Root
-	agent.parentId = device.ParentId
+	agent.parentID = device.ParentId
 	agent.deviceType = device.Type
 	agent.deviceMgr = deviceMgr
 	agent.adapterMgr = deviceMgr.adapterMgr
@@ -74,36 +76,36 @@
 
 // start()
 // save the device to the data model and registers for callbacks on that device if deviceToCreate!=nil.  Otherwise,
-// it will load the data from the dB and setup teh necessary callbacks and proxies. Returns the device that
+// it will load the data from the dB and setup the necessary callbacks and proxies. Returns the device that
 // was started.
 func (agent *DeviceAgent) start(ctx context.Context, deviceToCreate *voltha.Device) (*voltha.Device, error) {
 	var device *voltha.Device
 
 	agent.lockDevice.Lock()
 	defer agent.lockDevice.Unlock()
-	log.Debugw("starting-device-agent", log.Fields{"deviceId": agent.deviceId})
+	log.Debugw("starting-device-agent", log.Fields{"deviceId": agent.deviceID})
 	if deviceToCreate == nil {
 		// Load the existing device
-		if loadedDevice := agent.clusterDataProxy.Get(ctx, "/devices/"+agent.deviceId, 1, true, ""); loadedDevice != nil {
+		if loadedDevice := agent.clusterDataProxy.Get(ctx, "/devices/"+agent.deviceID, 1, true, ""); loadedDevice != nil {
 			var ok bool
 			if device, ok = loadedDevice.(*voltha.Device); ok {
 				agent.deviceType = device.Adapter
 			} else {
-				log.Errorw("failed-to-convert-device", log.Fields{"deviceId": agent.deviceId})
-				return nil, status.Errorf(codes.NotFound, "device-%s", agent.deviceId)
+				log.Errorw("failed-to-convert-device", log.Fields{"deviceId": agent.deviceID})
+				return nil, status.Errorf(codes.NotFound, "device-%s", agent.deviceID)
 			}
 		} else {
-			log.Errorw("failed-to-load-device", log.Fields{"deviceId": agent.deviceId})
-			return nil, status.Errorf(codes.NotFound, "device-%s", agent.deviceId)
+			log.Errorw("failed-to-load-device", log.Fields{"deviceId": agent.deviceID})
+			return nil, status.Errorf(codes.NotFound, "device-%s", agent.deviceID)
 		}
-		log.Debugw("device-loaded-from-dB", log.Fields{"deviceId": agent.deviceId})
+		log.Debugw("device-loaded-from-dB", log.Fields{"deviceId": agent.deviceID})
 	} else {
 		// Create a new device
 		// Assumption is that AdminState, FlowGroups, and Flows are unitialized since this
 		// is a new device, so populate them here before passing the device to clusterDataProxy.AddWithId.
 		// agent.deviceId will also have been set during newDeviceAgent().
 		device = (proto.Clone(deviceToCreate)).(*voltha.Device)
-		device.Id = agent.deviceId
+		device.Id = agent.deviceID
 		device.AdminState = voltha.AdminState_PREPROVISIONED
 		device.FlowGroups = &ofp.FlowGroups{Items: nil}
 		device.Flows = &ofp.Flows{Items: nil}
@@ -114,16 +116,16 @@
 		}
 
 		// Add the initial device to the local model
-		if added := agent.clusterDataProxy.AddWithID(ctx, "/devices", agent.deviceId, device, ""); added == nil {
-			log.Errorw("failed-to-add-device", log.Fields{"deviceId": agent.deviceId})
-			return nil, status.Errorf(codes.Aborted, "failed-adding-device-%s", agent.deviceId)
+		if added := agent.clusterDataProxy.AddWithID(ctx, "/devices", agent.deviceID, device, ""); added == nil {
+			log.Errorw("failed-to-add-device", log.Fields{"deviceId": agent.deviceID})
+			return nil, status.Errorf(codes.Aborted, "failed-adding-device-%s", agent.deviceID)
 		}
 	}
 
-	agent.deviceProxy = agent.clusterDataProxy.CreateProxy(ctx, "/devices/"+agent.deviceId, false)
+	agent.deviceProxy = agent.clusterDataProxy.CreateProxy(ctx, "/devices/"+agent.deviceID, false)
 	agent.deviceProxy.RegisterCallback(model.POST_UPDATE, agent.processUpdate)
 
-	log.Debugw("device-agent-started", log.Fields{"deviceId": agent.deviceId})
+	log.Debugw("device-agent-started", log.Fields{"deviceId": agent.deviceID})
 	return device, nil
 }
 
@@ -133,8 +135,8 @@
 	defer agent.lockDevice.Unlock()
 	log.Debug("stopping-device-agent")
 	//	Remove the device from the KV store
-	if removed := agent.clusterDataProxy.Remove(ctx, "/devices/"+agent.deviceId, ""); removed == nil {
-		log.Debugw("device-already-removed", log.Fields{"id": agent.deviceId})
+	if removed := agent.clusterDataProxy.Remove(ctx, "/devices/"+agent.deviceID, ""); removed == nil {
+		log.Debugw("device-already-removed", log.Fields{"id": agent.deviceID})
 	}
 	agent.exitChannel <- 1
 	log.Debug("device-agent-stopped")
@@ -147,10 +149,10 @@
 	defer agent.lockDevice.Unlock()
 	log.Debug("reconciling-device-agent-devicetype")
 	// TODO: context timeout
-	if device := agent.clusterDataProxy.Get(context.Background(), "/devices/"+agent.deviceId, 1, true, ""); device != nil {
+	if device := agent.clusterDataProxy.Get(context.Background(), "/devices/"+agent.deviceID, 1, true, ""); device != nil {
 		if d, ok := device.(*voltha.Device); ok {
 			agent.deviceType = d.Adapter
-			log.Debugw("reconciled-device-agent-devicetype", log.Fields{"Id": agent.deviceId, "type": agent.deviceType})
+			log.Debugw("reconciled-device-agent-devicetype", log.Fields{"Id": agent.deviceID, "type": agent.deviceType})
 		}
 	}
 }
@@ -159,81 +161,81 @@
 func (agent *DeviceAgent) getDevice() (*voltha.Device, error) {
 	agent.lockDevice.RLock()
 	defer agent.lockDevice.RUnlock()
-	if device := agent.clusterDataProxy.Get(context.Background(), "/devices/"+agent.deviceId, 0, false, ""); device != nil {
+	if device := agent.clusterDataProxy.Get(context.Background(), "/devices/"+agent.deviceID, 0, false, ""); device != nil {
 		if d, ok := device.(*voltha.Device); ok {
 			cloned := proto.Clone(d).(*voltha.Device)
 			return cloned, nil
 		}
 	}
-	return nil, status.Errorf(codes.NotFound, "device-%s", agent.deviceId)
+	return nil, status.Errorf(codes.NotFound, "device-%s", agent.deviceID)
 }
 
 // getDeviceWithoutLock is a helper function to be used ONLY by any device agent function AFTER it has acquired the device lock.
 // This function is meant so that we do not have duplicate code all over the device agent functions
 func (agent *DeviceAgent) getDeviceWithoutLock() (*voltha.Device, error) {
-	if device := agent.clusterDataProxy.Get(context.Background(), "/devices/"+agent.deviceId, 0, false, ""); device != nil {
+	if device := agent.clusterDataProxy.Get(context.Background(), "/devices/"+agent.deviceID, 0, false, ""); device != nil {
 		if d, ok := device.(*voltha.Device); ok {
 			cloned := proto.Clone(d).(*voltha.Device)
 			return cloned, nil
 		}
 	}
-	return nil, status.Errorf(codes.NotFound, "device-%s", agent.deviceId)
+	return nil, status.Errorf(codes.NotFound, "device-%s", agent.deviceID)
 }
 
 // enableDevice activates a preprovisioned or a disable device
 func (agent *DeviceAgent) enableDevice(ctx context.Context) error {
 	agent.lockDevice.Lock()
 	defer agent.lockDevice.Unlock()
-	log.Debugw("enableDevice", log.Fields{"id": agent.deviceId})
+	log.Debugw("enableDevice", log.Fields{"id": agent.deviceID})
 
-	if device, err := agent.getDeviceWithoutLock(); err != nil {
-		return status.Errorf(codes.NotFound, "%s", agent.deviceId)
+	device, err := agent.getDeviceWithoutLock()
+	if err != nil {
+		return status.Errorf(codes.NotFound, "%s", agent.deviceID)
+	}
+	// First figure out which adapter will handle this device type.  We do it at this stage as allow devices to be
+	// pre-provisionned with the required adapter not registered.   At this stage, since we need to communicate
+	// with the adapter then we need to know the adapter that will handle this request
+	adapterName, err := agent.adapterMgr.getAdapterName(device.Type)
+	if err != nil {
+		log.Warnw("no-adapter-registered-for-device-type", log.Fields{"deviceType": device.Type, "deviceAdapter": device.Adapter})
+		return err
+	}
+	device.Adapter = adapterName
+
+	if device.AdminState == voltha.AdminState_ENABLED {
+		log.Debugw("device-already-enabled", log.Fields{"id": agent.deviceID})
+		return nil
+	}
+
+	if device.AdminState == voltha.AdminState_DELETED {
+		// This is a temporary state when a device is deleted before it gets removed from the model.
+		err = status.Error(codes.FailedPrecondition, fmt.Sprintf("cannot-enable-a-deleted-device: %s ", device.Id))
+		log.Warnw("invalid-state", log.Fields{"id": agent.deviceID, "state": device.AdminState, "error": err})
+		return err
+	}
+
+	previousAdminState := device.AdminState
+
+	// Update the Admin State and set the operational state to activating before sending the request to the
+	// Adapters
+	cloned := proto.Clone(device).(*voltha.Device)
+	cloned.AdminState = voltha.AdminState_ENABLED
+	cloned.OperStatus = voltha.OperStatus_ACTIVATING
+
+	if err := agent.updateDeviceInStoreWithoutLock(cloned, false, ""); err != nil {
+		return err
+	}
+
+	// Adopt the device if it was in preprovision state.  In all other cases, try to reenable it.
+	if previousAdminState == voltha.AdminState_PREPROVISIONED {
+		if err := agent.adapterProxy.AdoptDevice(ctx, device); err != nil {
+			log.Debugw("adoptDevice-error", log.Fields{"id": agent.deviceID, "error": err})
+			return err
+		}
 	} else {
-		// First figure out which adapter will handle this device type.  We do it at this stage as allow devices to be
-		// pre-provisionned with the required adapter not registered.   At this stage, since we need to communicate
-		// with the adapter then we need to know the adapter that will handle this request
-		if adapterName, err := agent.adapterMgr.getAdapterName(device.Type); err != nil {
-			log.Warnw("no-adapter-registered-for-device-type", log.Fields{"deviceType": device.Type, "deviceAdapter": device.Adapter})
+		if err := agent.adapterProxy.ReEnableDevice(ctx, device); err != nil {
+			log.Debugw("renableDevice-error", log.Fields{"id": agent.deviceID, "error": err})
 			return err
-		} else {
-			device.Adapter = adapterName
-		}
-
-		if device.AdminState == voltha.AdminState_ENABLED {
-			log.Debugw("device-already-enabled", log.Fields{"id": agent.deviceId})
-			return nil
-		}
-
-		if device.AdminState == voltha.AdminState_DELETED {
-			// This is a temporary state when a device is deleted before it gets removed from the model.
-			err = status.Error(codes.FailedPrecondition, fmt.Sprintf("cannot-enable-a-deleted-device: %s ", device.Id))
-			log.Warnw("invalid-state", log.Fields{"id": agent.deviceId, "state": device.AdminState, "error": err})
-			return err
-		}
-
-		previousAdminState := device.AdminState
-
-		// Update the Admin State and set the operational state to activating before sending the request to the
-		// Adapters
-		cloned := proto.Clone(device).(*voltha.Device)
-		cloned.AdminState = voltha.AdminState_ENABLED
-		cloned.OperStatus = voltha.OperStatus_ACTIVATING
-
-		if err := agent.updateDeviceInStoreWithoutLock(cloned, false, ""); err != nil {
-			return err
-		}
-
-		// Adopt the device if it was in preprovision state.  In all other cases, try to reenable it.
-		if previousAdminState == voltha.AdminState_PREPROVISIONED {
-			if err := agent.adapterProxy.AdoptDevice(ctx, device); err != nil {
-				log.Debugw("adoptDevice-error", log.Fields{"id": agent.deviceId, "error": err})
-				return err
-			}
-		} else {
-			if err := agent.adapterProxy.ReEnableDevice(ctx, device); err != nil {
-				log.Debugw("renableDevice-error", log.Fields{"id": agent.deviceId, "error": err})
-				return err
-			}
 		}
 	}
 	return nil
@@ -241,7 +243,7 @@
 
 func (agent *DeviceAgent) sendBulkFlowsToAdapters(device *voltha.Device, flows *voltha.Flows, groups *voltha.FlowGroups, flowMetadata *voltha.FlowMetadata, response coreutils.Response) {
 	if err := agent.adapterProxy.UpdateFlowsBulk(device, flows, groups, flowMetadata); err != nil {
-		log.Debugw("update-flow-bulk-error", log.Fields{"id": agent.deviceId, "error": err})
+		log.Debugw("update-flow-bulk-error", log.Fields{"id": agent.deviceID, "error": err})
 		response.Error(err)
 	}
 	response.Done()
@@ -249,7 +251,7 @@
 
 func (agent *DeviceAgent) sendIncrementalFlowsToAdapters(device *voltha.Device, flows *ofp.FlowChanges, groups *ofp.FlowGroupChanges, flowMetadata *voltha.FlowMetadata, response coreutils.Response) {
 	if err := agent.adapterProxy.UpdateFlowsIncremental(device, flows, groups, flowMetadata); err != nil {
-		log.Debugw("update-flow-incremental-error", log.Fields{"id": agent.deviceId, "error": err})
+		log.Debugw("update-flow-incremental-error", log.Fields{"id": agent.deviceID, "error": err})
 		response.Error(err)
 	}
 	response.Done()
@@ -258,10 +260,10 @@
 //addFlowsAndGroups adds the "newFlows" and "newGroups" from the existing flows/groups and sends the update to the
 //adapters
 func (agent *DeviceAgent) addFlowsAndGroups(newFlows []*ofp.OfpFlowStats, newGroups []*ofp.OfpGroupEntry, flowMetadata *voltha.FlowMetadata) error {
-	log.Debugw("addFlowsAndGroups", log.Fields{"deviceId": agent.deviceId, "flows": newFlows, "groups": newGroups, "flowMetadata": flowMetadata})
+	log.Debugw("addFlowsAndGroups", log.Fields{"deviceId": agent.deviceID, "flows": newFlows, "groups": newGroups, "flowMetadata": flowMetadata})
 
 	if (len(newFlows) | len(newGroups)) == 0 {
-		log.Debugw("nothing-to-update", log.Fields{"deviceId": agent.deviceId, "flows": newFlows, "groups": newGroups})
+		log.Debugw("nothing-to-update", log.Fields{"deviceId": agent.deviceID, "flows": newFlows, "groups": newGroups})
 		return nil
 	}
 
@@ -271,7 +273,7 @@
 	var device *voltha.Device
 	var err error
 	if device, err = agent.getDeviceWithoutLock(); err != nil {
-		return status.Errorf(codes.NotFound, "%s", agent.deviceId)
+		return status.Errorf(codes.NotFound, "%s", agent.deviceID)
 	}
 
 	existingFlows := proto.Clone(device.Flows).(*voltha.Flows)
@@ -283,9 +285,7 @@
 	var updatedGroups []*ofp.OfpGroupEntry
 
 	// Process flows
-	for _, flow := range newFlows {
-		updatedFlows = append(updatedFlows, flow)
-	}
+	updatedFlows = append(updatedFlows, newFlows...)
 	for _, flow := range existingFlows.Items {
 		if idx := fu.FindFlows(newFlows, flow); idx == -1 {
 			updatedFlows = append(updatedFlows, flow)
@@ -295,9 +295,7 @@
 	}
 
 	// Process groups
-	for _, g := range newGroups {
-		updatedGroups = append(updatedGroups, g)
-	}
+	updatedGroups = append(updatedGroups, newGroups...)
 	for _, group := range existingGroups.Items {
 		if fu.FindGroup(newGroups, group.Desc.GroupId) == -1 { // does not exist now
 			updatedGroups = append(updatedGroups, group)
@@ -308,7 +306,7 @@
 
 	// Sanity check
 	if (len(updatedFlows) | len(flowsToDelete) | len(updatedGroups) | len(groupsToDelete)) == 0 {
-		log.Debugw("nothing-to-update", log.Fields{"deviceId": agent.deviceId, "flows": newFlows, "groups": newGroups})
+		log.Debugw("nothing-to-update", log.Fields{"deviceId": agent.deviceID, "flows": newFlows, "groups": newGroups})
 		return nil
 	}
 
@@ -322,7 +320,7 @@
 	if !dType.AcceptsAddRemoveFlowUpdates {
 
 		if len(updatedGroups) != 0 && reflect.DeepEqual(existingGroups.Items, updatedGroups) && len(updatedFlows) != 0 && reflect.DeepEqual(existingFlows.Items, updatedFlows) {
-			log.Debugw("nothing-to-update", log.Fields{"deviceId": agent.deviceId, "flows": newFlows, "groups": newGroups})
+			log.Debugw("nothing-to-update", log.Fields{"deviceId": agent.deviceID, "flows": newFlows, "groups": newGroups})
 			return nil
 		}
 		go agent.sendBulkFlowsToAdapters(device, &voltha.Flows{Items: updatedFlows}, &voltha.FlowGroups{Items: updatedGroups}, flowMetadata, response)
@@ -344,7 +342,7 @@
 	device.Flows = &voltha.Flows{Items: updatedFlows}
 	device.FlowGroups = &voltha.FlowGroups{Items: updatedGroups}
 	if err := agent.updateDeviceWithoutLock(device); err != nil {
-		return status.Errorf(codes.Internal, "failure-updating-%s", agent.deviceId)
+		return status.Errorf(codes.Internal, "failure-updating-%s", agent.deviceID)
 	}
 
 	if res := coreutils.WaitForNilOrErrorResponses(agent.defaultTimeout, response); res != nil {
@@ -358,10 +356,10 @@
 //deleteFlowsAndGroups removes the "flowsToDel" and "groupsToDel" from the existing flows/groups and sends the update to the
 //adapters
 func (agent *DeviceAgent) deleteFlowsAndGroups(flowsToDel []*ofp.OfpFlowStats, groupsToDel []*ofp.OfpGroupEntry, flowMetadata *voltha.FlowMetadata) error {
-	log.Debugw("deleteFlowsAndGroups", log.Fields{"deviceId": agent.deviceId, "flows": flowsToDel, "groups": groupsToDel})
+	log.Debugw("deleteFlowsAndGroups", log.Fields{"deviceId": agent.deviceID, "flows": flowsToDel, "groups": groupsToDel})
 
 	if (len(flowsToDel) | len(groupsToDel)) == 0 {
-		log.Debugw("nothing-to-update", log.Fields{"deviceId": agent.deviceId, "flows": flowsToDel, "groups": groupsToDel})
+		log.Debugw("nothing-to-update", log.Fields{"deviceId": agent.deviceID, "flows": flowsToDel, "groups": groupsToDel})
 		return nil
 	}
 
@@ -372,7 +370,7 @@
 	var err error
 
 	if device, err = agent.getDeviceWithoutLock(); err != nil {
-		return status.Errorf(codes.NotFound, "%s", agent.deviceId)
+		return status.Errorf(codes.NotFound, "%s", agent.deviceID)
 	}
 
 	existingFlows := proto.Clone(device.Flows).(*voltha.Flows)
@@ -397,7 +395,7 @@
 
 	log.Debugw("deleteFlowsAndGroups",
 		log.Fields{
-			"deviceId":     agent.deviceId,
+			"deviceId":     agent.deviceID,
 			"flowsToDel":   len(flowsToDel),
 			"flowsToKeep":  len(flowsToKeep),
 			"groupsToDel":  len(groupsToDel),
@@ -406,7 +404,7 @@
 
 	// Sanity check
 	if (len(flowsToKeep) | len(flowsToDel) | len(groupsToKeep) | len(groupsToDel)) == 0 {
-		log.Debugw("nothing-to-update", log.Fields{"deviceId": agent.deviceId, "flowsToDel": flowsToDel, "groupsToDel": groupsToDel})
+		log.Debugw("nothing-to-update", log.Fields{"deviceId": agent.deviceID, "flowsToDel": flowsToDel, "groupsToDel": groupsToDel})
 		return nil
 	}
 
@@ -415,7 +413,7 @@
 	dType := agent.adapterMgr.getDeviceType(device.Type)
 	if !dType.AcceptsAddRemoveFlowUpdates {
 		if len(groupsToKeep) != 0 && reflect.DeepEqual(existingGroups.Items, groupsToKeep) && len(flowsToKeep) != 0 && reflect.DeepEqual(existingFlows.Items, flowsToKeep) {
-			log.Debugw("nothing-to-update", log.Fields{"deviceId": agent.deviceId, "flowsToDel": flowsToDel, "groupsToDel": groupsToDel})
+			log.Debugw("nothing-to-update", log.Fields{"deviceId": agent.deviceID, "flowsToDel": flowsToDel, "groupsToDel": groupsToDel})
 			return nil
 		}
 		go agent.sendBulkFlowsToAdapters(device, &voltha.Flows{Items: flowsToKeep}, &voltha.FlowGroups{Items: groupsToKeep}, flowMetadata, response)
@@ -436,7 +434,7 @@
 	device.Flows = &voltha.Flows{Items: flowsToKeep}
 	device.FlowGroups = &voltha.FlowGroups{Items: groupsToKeep}
 	if err := agent.updateDeviceWithoutLock(device); err != nil {
-		return status.Errorf(codes.Internal, "failure-updating-%s", agent.deviceId)
+		return status.Errorf(codes.Internal, "failure-updating-%s", agent.deviceID)
 	}
 
 	if res := coreutils.WaitForNilOrErrorResponses(agent.defaultTimeout, response); res != nil {
@@ -449,10 +447,10 @@
 //updateFlowsAndGroups replaces the existing flows and groups with "updatedFlows" and "updatedGroups" respectively. It
 //also sends the updates to the adapters
 func (agent *DeviceAgent) updateFlowsAndGroups(updatedFlows []*ofp.OfpFlowStats, updatedGroups []*ofp.OfpGroupEntry, flowMetadata *voltha.FlowMetadata) error {
-	log.Debugw("updateFlowsAndGroups", log.Fields{"deviceId": agent.deviceId, "flows": updatedFlows, "groups": updatedGroups})
+	log.Debugw("updateFlowsAndGroups", log.Fields{"deviceId": agent.deviceID, "flows": updatedFlows, "groups": updatedGroups})
 
 	if (len(updatedFlows) | len(updatedGroups)) == 0 {
-		log.Debugw("nothing-to-update", log.Fields{"deviceId": agent.deviceId, "flows": updatedFlows, "groups": updatedGroups})
+		log.Debugw("nothing-to-update", log.Fields{"deviceId": agent.deviceID, "flows": updatedFlows, "groups": updatedGroups})
 		return nil
 	}
 
@@ -461,19 +459,19 @@
 	var device *voltha.Device
 	var err error
 	if device, err = agent.getDeviceWithoutLock(); err != nil {
-		return status.Errorf(codes.NotFound, "%s", agent.deviceId)
+		return status.Errorf(codes.NotFound, "%s", agent.deviceID)
 	}
 	existingFlows := proto.Clone(device.Flows).(*voltha.Flows)
 	existingGroups := proto.Clone(device.FlowGroups).(*ofp.FlowGroups)
 
 	if len(updatedGroups) != 0 && reflect.DeepEqual(existingGroups.Items, updatedGroups) && len(updatedFlows) != 0 && reflect.DeepEqual(existingFlows.Items, updatedFlows) {
-		log.Debugw("nothing-to-update", log.Fields{"deviceId": agent.deviceId, "flows": updatedFlows, "groups": updatedGroups})
+		log.Debugw("nothing-to-update", log.Fields{"deviceId": agent.deviceID, "flows": updatedFlows, "groups": updatedGroups})
 		return nil
 	}
 
 	log.Debugw("updating-flows-and-groups",
 		log.Fields{
-			"deviceId":      agent.deviceId,
+			"deviceId":      agent.deviceID,
 			"updatedFlows":  updatedFlows,
 			"updatedGroups": updatedGroups,
 		})
@@ -516,7 +514,7 @@
 
 		log.Debugw("updating-flows-and-groups",
 			log.Fields{
-				"deviceId":       agent.deviceId,
+				"deviceId":       agent.deviceID,
 				"flowsToAdd":     flowsToAdd,
 				"flowsToDelete":  flowsToDelete,
 				"groupsToAdd":    groupsToAdd,
@@ -525,7 +523,7 @@
 
 		// Sanity check
 		if (len(flowsToAdd) | len(flowsToDelete) | len(groupsToAdd) | len(groupsToDelete) | len(updatedGroups)) == 0 {
-			log.Debugw("nothing-to-update", log.Fields{"deviceId": agent.deviceId, "flows": updatedFlows, "groups": updatedGroups})
+			log.Debugw("nothing-to-update", log.Fields{"deviceId": agent.deviceID, "flows": updatedFlows, "groups": updatedGroups})
 			return nil
 		}
 
@@ -545,7 +543,7 @@
 	device.Flows = &voltha.Flows{Items: updatedFlows}
 	device.FlowGroups = &voltha.FlowGroups{Items: updatedGroups}
 	if err := agent.updateDeviceWithoutLock(device); err != nil {
-		return status.Errorf(codes.Internal, "failure-updating-%s", agent.deviceId)
+		return status.Errorf(codes.Internal, "failure-updating-%s", agent.deviceID)
 	}
 
 	if res := coreutils.WaitForNilOrErrorResponses(agent.defaultTimeout, response); res != nil {
@@ -558,33 +556,33 @@
 func (agent *DeviceAgent) disableDevice(ctx context.Context) error {
 	agent.lockDevice.Lock()
 	defer agent.lockDevice.Unlock()
-	log.Debugw("disableDevice", log.Fields{"id": agent.deviceId})
+	log.Debugw("disableDevice", log.Fields{"id": agent.deviceID})
 	// Get the most up to date the device info
-	if device, err := agent.getDeviceWithoutLock(); err != nil {
-		return status.Errorf(codes.NotFound, "%s", agent.deviceId)
-	} else {
-		if device.AdminState == voltha.AdminState_DISABLED {
-			log.Debugw("device-already-disabled", log.Fields{"id": agent.deviceId})
-			return nil
-		}
-		if device.AdminState == voltha.AdminState_PREPROVISIONED ||
-			device.AdminState == voltha.AdminState_DELETED {
-			log.Debugw("device-not-enabled", log.Fields{"id": agent.deviceId})
-			return status.Errorf(codes.FailedPrecondition, "deviceId:%s, invalid-admin-state:%s", agent.deviceId, device.AdminState)
-		}
+	device, err := agent.getDeviceWithoutLock()
+	if err != nil {
+		return status.Errorf(codes.NotFound, "%s", agent.deviceID)
+	}
+	if device.AdminState == voltha.AdminState_DISABLED {
+		log.Debugw("device-already-disabled", log.Fields{"id": agent.deviceID})
+		return nil
+	}
+	if device.AdminState == voltha.AdminState_PREPROVISIONED ||
+		device.AdminState == voltha.AdminState_DELETED {
+		log.Debugw("device-not-enabled", log.Fields{"id": agent.deviceID})
+		return status.Errorf(codes.FailedPrecondition, "deviceId:%s, invalid-admin-state:%s", agent.deviceID, device.AdminState)
+	}
 
-		// Update the Admin State and operational state before sending the request out
-		cloned := proto.Clone(device).(*voltha.Device)
-		cloned.AdminState = voltha.AdminState_DISABLED
-		cloned.OperStatus = voltha.OperStatus_UNKNOWN
-		if err := agent.updateDeviceInStoreWithoutLock(cloned, false, ""); err != nil {
-			return err
-		}
+	// Update the Admin State and operational state before sending the request out
+	cloned := proto.Clone(device).(*voltha.Device)
+	cloned.AdminState = voltha.AdminState_DISABLED
+	cloned.OperStatus = voltha.OperStatus_UNKNOWN
+	if err := agent.updateDeviceInStoreWithoutLock(cloned, false, ""); err != nil {
+		return err
+	}
 
-		if err := agent.adapterProxy.DisableDevice(ctx, device); err != nil {
-			log.Debugw("disableDevice-error", log.Fields{"id": agent.deviceId, "error": err})
-			return err
-		}
+	if err := agent.adapterProxy.DisableDevice(ctx, device); err != nil {
+		log.Debugw("disableDevice-error", log.Fields{"id": agent.deviceID, "error": err})
+		return err
 	}
 	return nil
 }
@@ -592,21 +590,21 @@
 func (agent *DeviceAgent) updateAdminState(adminState voltha.AdminState_AdminState) error {
 	agent.lockDevice.Lock()
 	defer agent.lockDevice.Unlock()
-	log.Debugw("updateAdminState", log.Fields{"id": agent.deviceId})
+	log.Debugw("updateAdminState", log.Fields{"id": agent.deviceID})
 	// Get the most up to date the device info
-	if device, err := agent.getDeviceWithoutLock(); err != nil {
-		return status.Errorf(codes.NotFound, "%s", agent.deviceId)
-	} else {
-		if device.AdminState == adminState {
-			log.Debugw("no-change-needed", log.Fields{"id": agent.deviceId, "state": adminState})
-			return nil
-		}
-		// Received an Ack (no error found above).  Now update the device in the model to the expected state
-		cloned := proto.Clone(device).(*voltha.Device)
-		cloned.AdminState = adminState
-		if err := agent.updateDeviceInStoreWithoutLock(cloned, false, ""); err != nil {
-			return err
-		}
+	device, err := agent.getDeviceWithoutLock()
+	if err != nil {
+		return status.Errorf(codes.NotFound, "%s", agent.deviceID)
+	}
+	if device.AdminState == adminState {
+		log.Debugw("no-change-needed", log.Fields{"id": agent.deviceID, "state": adminState})
+		return nil
+	}
+	// Received an Ack (no error found above).  Now update the device in the model to the expected state
+	cloned := proto.Clone(device).(*voltha.Device)
+	cloned.AdminState = adminState
+	if err := agent.updateDeviceInStoreWithoutLock(cloned, false, ""); err != nil {
+		return err
 	}
 	return nil
 }
@@ -614,15 +612,15 @@
 func (agent *DeviceAgent) rebootDevice(ctx context.Context) error {
 	agent.lockDevice.Lock()
 	defer agent.lockDevice.Unlock()
-	log.Debugw("rebootDevice", log.Fields{"id": agent.deviceId})
+	log.Debugw("rebootDevice", log.Fields{"id": agent.deviceID})
 	// Get the most up to date the device info
-	if device, err := agent.getDeviceWithoutLock(); err != nil {
-		return status.Errorf(codes.NotFound, "%s", agent.deviceId)
-	} else {
-		if err := agent.adapterProxy.RebootDevice(ctx, device); err != nil {
-			log.Debugw("rebootDevice-error", log.Fields{"id": agent.deviceId, "error": err})
-			return err
-		}
+	device, err := agent.getDeviceWithoutLock()
+	if err != nil {
+		return status.Errorf(codes.NotFound, "%s", agent.deviceID)
+	}
+	if err := agent.adapterProxy.RebootDevice(ctx, device); err != nil {
+		log.Debugw("rebootDevice-error", log.Fields{"id": agent.deviceID, "error": err})
+		return err
 	}
 	return nil
 }
@@ -630,59 +628,64 @@
 func (agent *DeviceAgent) deleteDevice(ctx context.Context) error {
 	agent.lockDevice.Lock()
 	defer agent.lockDevice.Unlock()
-	log.Debugw("deleteDevice", log.Fields{"id": agent.deviceId})
+	log.Debugw("deleteDevice", log.Fields{"id": agent.deviceID})
 	// Get the most up to date the device info
-	if device, err := agent.getDeviceWithoutLock(); err != nil {
-		return status.Errorf(codes.NotFound, "%s", agent.deviceId)
-	} else {
-		if device.AdminState == voltha.AdminState_DELETED {
-			log.Debugw("device-already-in-deleted-state", log.Fields{"id": agent.deviceId})
-			return nil
-		}
-		if (device.AdminState != voltha.AdminState_DISABLED) &&
-			(device.AdminState != voltha.AdminState_PREPROVISIONED) {
-			log.Debugw("device-not-disabled", log.Fields{"id": agent.deviceId})
-			//TODO:  Needs customized error message
-			return status.Errorf(codes.FailedPrecondition, "deviceId:%s, expected-admin-state:%s", agent.deviceId, voltha.AdminState_DISABLED)
-		}
-		if device.AdminState != voltha.AdminState_PREPROVISIONED {
-			// Send the request to an Adapter only if the device is not in poreporovision state and wait for a response
-			if err := agent.adapterProxy.DeleteDevice(ctx, device); err != nil {
-				log.Debugw("deleteDevice-error", log.Fields{"id": agent.deviceId, "error": err})
-				return err
-			}
-		}
-		//	Set the state to deleted after we recieve an Ack - this will trigger some background process to clean up
-		//	the device as well as its association with the logical device
-		cloned := proto.Clone(device).(*voltha.Device)
-		cloned.AdminState = voltha.AdminState_DELETED
-		if err := agent.updateDeviceInStoreWithoutLock(cloned, false, ""); err != nil {
+	device, err := agent.getDeviceWithoutLock()
+	if err != nil {
+		return status.Errorf(codes.NotFound, "%s", agent.deviceID)
+	}
+	if device.AdminState == voltha.AdminState_DELETED {
+		log.Debugw("device-already-in-deleted-state", log.Fields{"id": agent.deviceID})
+		return nil
+	}
+	if (device.AdminState != voltha.AdminState_DISABLED) &&
+		(device.AdminState != voltha.AdminState_PREPROVISIONED) {
+		log.Debugw("device-not-disabled", log.Fields{"id": agent.deviceID})
+		//TODO:  Needs customized error message
+		return status.Errorf(codes.FailedPrecondition, "deviceId:%s, expected-admin-state:%s", agent.deviceID, voltha.AdminState_DISABLED)
+	}
+	if device.AdminState != voltha.AdminState_PREPROVISIONED {
+		// Send the request to an Adapter only if the device is not in poreporovision state and wait for a response
+		if err := agent.adapterProxy.DeleteDevice(ctx, device); err != nil {
+			log.Debugw("deleteDevice-error", log.Fields{"id": agent.deviceID, "error": err})
 			return err
 		}
-		//	If this is a child device then remove the associated peer ports on the parent device
-		if !device.Root {
-			go agent.deviceMgr.deletePeerPorts(device.ParentId, device.Id)
-		}
+	}
+	//	Set the state to deleted after we receive an Ack - this will trigger some background process to clean up
+	//	the device as well as its association with the logical device
+	cloned := proto.Clone(device).(*voltha.Device)
+	cloned.AdminState = voltha.AdminState_DELETED
+	if err := agent.updateDeviceInStoreWithoutLock(cloned, false, ""); err != nil {
+		return err
+	}
+	//	If this is a child device then remove the associated peer ports on the parent device
+	if !device.Root {
+		go func() {
+			err := agent.deviceMgr.deletePeerPorts(device.ParentId, device.Id)
+			if err != nil {
+				log.Errorw("unable-to-delete-peer-ports", log.Fields{"error": err})
+			}
+		}()
 	}
 	return nil
 }
 
-func (agent *DeviceAgent) setParentId(device *voltha.Device, parentId string) error {
+func (agent *DeviceAgent) setParentID(device *voltha.Device, parentID string) error {
 	agent.lockDevice.Lock()
 	defer agent.lockDevice.Unlock()
-	log.Debugw("setParentId", log.Fields{"deviceId": device.Id, "parentId": parentId})
-	if storeDevice, err := agent.getDeviceWithoutLock(); err != nil {
-		return status.Errorf(codes.NotFound, "%s", agent.deviceId)
-	} else {
-		// clone the device
-		cloned := proto.Clone(storeDevice).(*voltha.Device)
-		cloned.ParentId = parentId
-		// Store the device
-		if err := agent.updateDeviceInStoreWithoutLock(cloned, false, ""); err != nil {
-			return err
-		}
-		return nil
+	log.Debugw("setParentId", log.Fields{"deviceId": device.Id, "parentId": parentID})
+	storeDevice, err := agent.getDeviceWithoutLock()
+	if err != nil {
+		return status.Errorf(codes.NotFound, "%s", agent.deviceID)
 	}
+	// clone the device
+	cloned := proto.Clone(storeDevice).(*voltha.Device)
+	cloned.ParentId = parentID
+	// Store the device
+	if err := agent.updateDeviceInStoreWithoutLock(cloned, false, ""); err != nil {
+		return err
+	}
+	return nil
 }
 
 func (agent *DeviceAgent) updatePmConfigs(ctx context.Context, pmConfigs *voltha.PmConfigs) error {
@@ -690,23 +693,23 @@
 	defer agent.lockDevice.Unlock()
 	log.Debugw("updatePmConfigs", log.Fields{"id": pmConfigs.Id})
 	// Work only on latest data
-	if storeDevice, err := agent.getDeviceWithoutLock(); err != nil {
-		return status.Errorf(codes.NotFound, "%s", agent.deviceId)
-	} else {
-		// clone the device
-		cloned := proto.Clone(storeDevice).(*voltha.Device)
-		cloned.PmConfigs = proto.Clone(pmConfigs).(*voltha.PmConfigs)
-		// Store the device
-		if err := agent.updateDeviceInStoreWithoutLock(cloned, false, ""); err != nil {
-			return err
-		}
-		// Send the request to the adapter
-		if err := agent.adapterProxy.UpdatePmConfigs(ctx, cloned, pmConfigs); err != nil {
-			log.Errorw("update-pm-configs-error", log.Fields{"id": agent.deviceId, "error": err})
-			return err
-		}
-		return nil
+	storeDevice, err := agent.getDeviceWithoutLock()
+	if err != nil {
+		return status.Errorf(codes.NotFound, "%s", agent.deviceID)
 	}
+	// clone the device
+	cloned := proto.Clone(storeDevice).(*voltha.Device)
+	cloned.PmConfigs = proto.Clone(pmConfigs).(*voltha.PmConfigs)
+	// Store the device
+	if err := agent.updateDeviceInStoreWithoutLock(cloned, false, ""); err != nil {
+		return err
+	}
+	// Send the request to the adapter
+	if err := agent.adapterProxy.UpdatePmConfigs(ctx, cloned, pmConfigs); err != nil {
+		log.Errorw("update-pm-configs-error", log.Fields{"id": agent.deviceID, "error": err})
+		return err
+	}
+	return nil
 }
 
 func (agent *DeviceAgent) initPmConfigs(pmConfigs *voltha.PmConfigs) error {
@@ -714,46 +717,58 @@
 	defer agent.lockDevice.Unlock()
 	log.Debugw("initPmConfigs", log.Fields{"id": pmConfigs.Id})
 	// Work only on latest data
-	if storeDevice, err := agent.getDeviceWithoutLock(); err != nil {
-		return status.Errorf(codes.NotFound, "%s", agent.deviceId)
-	} else {
-		// clone the device
-		cloned := proto.Clone(storeDevice).(*voltha.Device)
-		cloned.PmConfigs = proto.Clone(pmConfigs).(*voltha.PmConfigs)
-		// Store the device
-		updateCtx := context.WithValue(context.Background(), model.RequestTimestamp, time.Now().UnixNano())
-		afterUpdate := agent.clusterDataProxy.Update(updateCtx, "/devices/"+agent.deviceId, cloned, false, "")
-		if afterUpdate == nil {
-			return status.Errorf(codes.Internal, "%s", agent.deviceId)
-		}
-		return nil
+	storeDevice, err := agent.getDeviceWithoutLock()
+	if err != nil {
+		return status.Errorf(codes.NotFound, "%s", agent.deviceID)
 	}
+	// clone the device
+	cloned := proto.Clone(storeDevice).(*voltha.Device)
+	cloned.PmConfigs = proto.Clone(pmConfigs).(*voltha.PmConfigs)
+	// Store the device
+	updateCtx := context.WithValue(context.Background(), model.RequestTimestamp, time.Now().UnixNano())
+	afterUpdate := agent.clusterDataProxy.Update(updateCtx, "/devices/"+agent.deviceID, cloned, false, "")
+	if afterUpdate == nil {
+		return status.Errorf(codes.Internal, "%s", agent.deviceID)
+	}
+	return nil
 }
 
 func (agent *DeviceAgent) listPmConfigs(ctx context.Context) (*voltha.PmConfigs, error) {
 	agent.lockDevice.RLock()
 	defer agent.lockDevice.RUnlock()
-	log.Debugw("listPmConfigs", log.Fields{"id": agent.deviceId})
+	log.Debugw("listPmConfigs", log.Fields{"id": agent.deviceID})
 	// Get the most up to date the device info
-	if device, err := agent.getDeviceWithoutLock(); err != nil {
-		return nil, status.Errorf(codes.NotFound, "%s", agent.deviceId)
-	} else {
-		cloned := proto.Clone(device).(*voltha.Device)
-		return cloned.PmConfigs, nil
+	device, err := agent.getDeviceWithoutLock()
+	if err != nil {
+		return nil, status.Errorf(codes.NotFound, "%s", agent.deviceID)
 	}
+	cloned := proto.Clone(device).(*voltha.Device)
+	return cloned.PmConfigs, nil
 }
 
 func (agent *DeviceAgent) downloadImage(ctx context.Context, img *voltha.ImageDownload) (*voltha.OperationResp, error) {
 	agent.lockDevice.Lock()
 	defer agent.lockDevice.Unlock()
-	log.Debugw("downloadImage", log.Fields{"id": agent.deviceId})
+	log.Debugw("downloadImage", log.Fields{"id": agent.deviceID})
 	// Get the most up to date the device info
-	if device, err := agent.getDeviceWithoutLock(); err != nil {
-		return nil, status.Errorf(codes.NotFound, "%s", agent.deviceId)
+	device, err := agent.getDeviceWithoutLock()
+	if err != nil {
+		return nil, status.Errorf(codes.NotFound, "%s", agent.deviceID)
+	}
+	if device.AdminState != voltha.AdminState_ENABLED {
+		log.Debugw("device-not-enabled", log.Fields{"id": agent.deviceID})
+		return nil, status.Errorf(codes.FailedPrecondition, "deviceId:%s, expected-admin-state:%s", agent.deviceID, voltha.AdminState_ENABLED)
+	}
+	// Save the image
+	clonedImg := proto.Clone(img).(*voltha.ImageDownload)
+	clonedImg.DownloadState = voltha.ImageDownload_DOWNLOAD_REQUESTED
+	cloned := proto.Clone(device).(*voltha.Device)
+	if cloned.ImageDownloads == nil {
+		cloned.ImageDownloads = []*voltha.ImageDownload{clonedImg}
 	} else {
 		if device.AdminState != voltha.AdminState_ENABLED {
-			log.Debugw("device-not-enabled", log.Fields{"id": agent.deviceId})
-			return nil, status.Errorf(codes.FailedPrecondition, "deviceId:%s, expected-admin-state:%s", agent.deviceId, voltha.AdminState_ENABLED)
+			log.Debugw("device-not-enabled", log.Fields{"id": agent.deviceID})
+			return nil, status.Errorf(codes.FailedPrecondition, "deviceId:%s, expected-admin-state:%s", agent.deviceID, voltha.AdminState_ENABLED)
 		}
 		// Save the image
 		clonedImg := proto.Clone(img).(*voltha.ImageDownload)
@@ -770,7 +785,7 @@
 		}
 		// Send the request to the adapter
 		if err := agent.adapterProxy.DownloadImage(ctx, cloned, clonedImg); err != nil {
-			log.Debugw("downloadImage-error", log.Fields{"id": agent.deviceId, "error": err, "image": img.Name})
+			log.Debugw("downloadImage-error", log.Fields{"id": agent.deviceID, "error": err, "image": img.Name})
 			return nil, err
 		}
 	}
@@ -790,35 +805,35 @@
 func (agent *DeviceAgent) cancelImageDownload(ctx context.Context, img *voltha.ImageDownload) (*voltha.OperationResp, error) {
 	agent.lockDevice.Lock()
 	defer agent.lockDevice.Unlock()
-	log.Debugw("cancelImageDownload", log.Fields{"id": agent.deviceId})
+	log.Debugw("cancelImageDownload", log.Fields{"id": agent.deviceID})
 	// Get the most up to date the device info
-	if device, err := agent.getDeviceWithoutLock(); err != nil {
-		return nil, status.Errorf(codes.NotFound, "%s", agent.deviceId)
-	} else {
-		// Verify whether the Image is in the list of image being downloaded
-		if !isImageRegistered(img, device) {
-			return nil, status.Errorf(codes.FailedPrecondition, "deviceId:%s, image-not-registered:%s", agent.deviceId, img.Name)
-		}
+	device, err := agent.getDeviceWithoutLock()
+	if err != nil {
+		return nil, status.Errorf(codes.NotFound, "%s", agent.deviceID)
+	}
+	// Verify whether the Image is in the list of image being downloaded
+	if !isImageRegistered(img, device) {
+		return nil, status.Errorf(codes.FailedPrecondition, "deviceId:%s, image-not-registered:%s", agent.deviceID, img.Name)
+	}
 
-		// Update image download state
-		cloned := proto.Clone(device).(*voltha.Device)
-		for _, image := range cloned.ImageDownloads {
-			if image.Id == img.Id && image.Name == img.Name {
-				image.DownloadState = voltha.ImageDownload_DOWNLOAD_CANCELLED
-			}
+	// Update image download state
+	cloned := proto.Clone(device).(*voltha.Device)
+	for _, image := range cloned.ImageDownloads {
+		if image.Id == img.Id && image.Name == img.Name {
+			image.DownloadState = voltha.ImageDownload_DOWNLOAD_CANCELLED
 		}
+	}
 
-		if device.AdminState == voltha.AdminState_DOWNLOADING_IMAGE {
-			// Set the device to Enabled
-			cloned.AdminState = voltha.AdminState_ENABLED
-			if err := agent.updateDeviceInStoreWithoutLock(cloned, false, ""); err != nil {
-				return nil, err
-			}
-			// Send the request to teh adapter
-			if err := agent.adapterProxy.CancelImageDownload(ctx, device, img); err != nil {
-				log.Debugw("cancelImageDownload-error", log.Fields{"id": agent.deviceId, "error": err, "image": img.Name})
-				return nil, err
-			}
+	if device.AdminState == voltha.AdminState_DOWNLOADING_IMAGE {
+		// Set the device to Enabled
+		cloned.AdminState = voltha.AdminState_ENABLED
+		if err := agent.updateDeviceInStoreWithoutLock(cloned, false, ""); err != nil {
+			return nil, err
+		}
+		// Send the request to the adapter
+		if err := agent.adapterProxy.CancelImageDownload(ctx, device, img); err != nil {
+			log.Debugw("cancelImageDownload-error", log.Fields{"id": agent.deviceID, "error": err, "image": img.Name})
+			return nil, err
 		}
 	}
 	return &voltha.OperationResp{Code: voltha.OperationResp_OPERATION_SUCCESS}, nil
@@ -827,74 +842,74 @@
 func (agent *DeviceAgent) activateImage(ctx context.Context, img *voltha.ImageDownload) (*voltha.OperationResp, error) {
 	agent.lockDevice.Lock()
 	defer agent.lockDevice.Unlock()
-	log.Debugw("activateImage", log.Fields{"id": agent.deviceId})
+	log.Debugw("activateImage", log.Fields{"id": agent.deviceID})
 	// Get the most up to date the device info
-	if device, err := agent.getDeviceWithoutLock(); err != nil {
-		return nil, status.Errorf(codes.NotFound, "%s", agent.deviceId)
-	} else {
-		// Verify whether the Image is in the list of image being downloaded
-		if !isImageRegistered(img, device) {
-			return nil, status.Errorf(codes.FailedPrecondition, "deviceId:%s, image-not-registered:%s", agent.deviceId, img.Name)
-		}
-
-		if device.AdminState == voltha.AdminState_DOWNLOADING_IMAGE {
-			return nil, status.Errorf(codes.FailedPrecondition, "deviceId:%s, device-in-downloading-state:%s", agent.deviceId, img.Name)
-		}
-		// Update image download state
-		cloned := proto.Clone(device).(*voltha.Device)
-		for _, image := range cloned.ImageDownloads {
-			if image.Id == img.Id && image.Name == img.Name {
-				image.ImageState = voltha.ImageDownload_IMAGE_ACTIVATING
-			}
-		}
-		// Set the device to downloading_image
-		cloned.AdminState = voltha.AdminState_DOWNLOADING_IMAGE
-		if err := agent.updateDeviceInStoreWithoutLock(cloned, false, ""); err != nil {
-			return nil, err
-		}
-
-		if err := agent.adapterProxy.ActivateImageUpdate(ctx, device, img); err != nil {
-			log.Debugw("activateImage-error", log.Fields{"id": agent.deviceId, "error": err, "image": img.Name})
-			return nil, err
-		}
-		// The status of the AdminState will be changed following the update_download_status response from the adapter
-		// The image name will also be removed from the device list
+	device, err := agent.getDeviceWithoutLock()
+	if err != nil {
+		return nil, status.Errorf(codes.NotFound, "%s", agent.deviceID)
 	}
+	// Verify whether the Image is in the list of image being downloaded
+	if !isImageRegistered(img, device) {
+		return nil, status.Errorf(codes.FailedPrecondition, "deviceId:%s, image-not-registered:%s", agent.deviceID, img.Name)
+	}
+
+	if device.AdminState == voltha.AdminState_DOWNLOADING_IMAGE {
+		return nil, status.Errorf(codes.FailedPrecondition, "deviceId:%s, device-in-downloading-state:%s", agent.deviceID, img.Name)
+	}
+	// Update image download state
+	cloned := proto.Clone(device).(*voltha.Device)
+	for _, image := range cloned.ImageDownloads {
+		if image.Id == img.Id && image.Name == img.Name {
+			image.ImageState = voltha.ImageDownload_IMAGE_ACTIVATING
+		}
+	}
+	// Set the device to downloading_image
+	cloned.AdminState = voltha.AdminState_DOWNLOADING_IMAGE
+	if err := agent.updateDeviceInStoreWithoutLock(cloned, false, ""); err != nil {
+		return nil, err
+	}
+
+	if err := agent.adapterProxy.ActivateImageUpdate(ctx, device, img); err != nil {
+		log.Debugw("activateImage-error", log.Fields{"id": agent.deviceID, "error": err, "image": img.Name})
+		return nil, err
+	}
+	// The status of the AdminState will be changed following the update_download_status response from the adapter
+	// The image name will also be removed from the device list
 	return &voltha.OperationResp{Code: voltha.OperationResp_OPERATION_SUCCESS}, nil
 }
 
 func (agent *DeviceAgent) revertImage(ctx context.Context, img *voltha.ImageDownload) (*voltha.OperationResp, error) {
 	agent.lockDevice.Lock()
 	defer agent.lockDevice.Unlock()
-	log.Debugw("revertImage", log.Fields{"id": agent.deviceId})
+	log.Debugw("revertImage", log.Fields{"id": agent.deviceID})
 	// Get the most up to date the device info
-	if device, err := agent.getDeviceWithoutLock(); err != nil {
-		return nil, status.Errorf(codes.NotFound, "%s", agent.deviceId)
-	} else {
-		// Verify whether the Image is in the list of image being downloaded
-		if !isImageRegistered(img, device) {
-			return nil, status.Errorf(codes.FailedPrecondition, "deviceId:%s, image-not-registered:%s", agent.deviceId, img.Name)
-		}
+	device, err := agent.getDeviceWithoutLock()
+	if err != nil {
+		return nil, status.Errorf(codes.NotFound, "%s", agent.deviceID)
+	}
+	// Verify whether the Image is in the list of image being downloaded
+	if !isImageRegistered(img, device) {
+		return nil, status.Errorf(codes.FailedPrecondition, "deviceId:%s, image-not-registered:%s", agent.deviceID, img.Name)
+	}
 
-		if device.AdminState != voltha.AdminState_ENABLED {
-			return nil, status.Errorf(codes.FailedPrecondition, "deviceId:%s, device-not-enabled-state:%s", agent.deviceId, img.Name)
+	if device.AdminState != voltha.AdminState_ENABLED {
+		return nil, status.Errorf(codes.FailedPrecondition, "deviceId:%s, device-not-enabled-state:%s", agent.deviceID, img.Name)
+	}
+	// Update image download state
+	cloned := proto.Clone(device).(*voltha.Device)
+	for _, image := range cloned.ImageDownloads {
+		if image.Id == img.Id && image.Name == img.Name {
+			image.ImageState = voltha.ImageDownload_IMAGE_REVERTING
 		}
-		// Update image download state
-		cloned := proto.Clone(device).(*voltha.Device)
-		for _, image := range cloned.ImageDownloads {
-			if image.Id == img.Id && image.Name == img.Name {
-				image.ImageState = voltha.ImageDownload_IMAGE_REVERTING
-			}
-		}
+	}
 
-		if err := agent.updateDeviceInStoreWithoutLock(cloned, false, ""); err != nil {
-			return nil, err
-		}
+	if err := agent.updateDeviceInStoreWithoutLock(cloned, false, ""); err != nil {
+		return nil, err
+	}
 
-		if err := agent.adapterProxy.RevertImageUpdate(ctx, device, img); err != nil {
-			log.Debugw("revertImage-error", log.Fields{"id": agent.deviceId, "error": err, "image": img.Name})
-			return nil, err
-		}
+	if err := agent.adapterProxy.RevertImageUpdate(ctx, device, img); err != nil {
+		log.Debugw("revertImage-error", log.Fields{"id": agent.deviceID, "error": err, "image": img.Name})
+		return nil, err
 	}
 	return &voltha.OperationResp{Code: voltha.OperationResp_OPERATION_SUCCESS}, nil
 }
@@ -902,49 +917,49 @@
 func (agent *DeviceAgent) getImageDownloadStatus(ctx context.Context, img *voltha.ImageDownload) (*voltha.ImageDownload, error) {
 	agent.lockDevice.Lock()
 	defer agent.lockDevice.Unlock()
-	log.Debugw("getImageDownloadStatus", log.Fields{"id": agent.deviceId})
+	log.Debugw("getImageDownloadStatus", log.Fields{"id": agent.deviceID})
 	// Get the most up to date the device info
-	if device, err := agent.getDeviceWithoutLock(); err != nil {
-		return nil, status.Errorf(codes.NotFound, "%s", agent.deviceId)
-	} else {
-		if resp, err := agent.adapterProxy.GetImageDownloadStatus(ctx, device, img); err != nil {
-			log.Debugw("getImageDownloadStatus-error", log.Fields{"id": agent.deviceId, "error": err, "image": img.Name})
-			return nil, err
-		} else {
-			return resp, nil
-		}
+	device, err := agent.getDeviceWithoutLock()
+	if err != nil {
+		return nil, status.Errorf(codes.NotFound, "%s", agent.deviceID)
 	}
+	resp, err := agent.adapterProxy.GetImageDownloadStatus(ctx, device, img)
+	if err != nil {
+		log.Debugw("getImageDownloadStatus-error", log.Fields{"id": agent.deviceID, "error": err, "image": img.Name})
+		return nil, err
+	}
+	return resp, nil
 }
 
 func (agent *DeviceAgent) updateImageDownload(img *voltha.ImageDownload) error {
 	agent.lockDevice.Lock()
 	defer agent.lockDevice.Unlock()
-	log.Debugw("updateImageDownload", log.Fields{"id": agent.deviceId})
+	log.Debugw("updateImageDownload", log.Fields{"id": agent.deviceID})
 	// Get the most up to date the device info
-	if device, err := agent.getDeviceWithoutLock(); err != nil {
-		return status.Errorf(codes.NotFound, "%s", agent.deviceId)
-	} else {
-		// Update the image as well as remove it if the download was cancelled
-		cloned := proto.Clone(device).(*voltha.Device)
-		clonedImages := make([]*voltha.ImageDownload, len(cloned.ImageDownloads))
-		for _, image := range cloned.ImageDownloads {
-			if image.Id == img.Id && image.Name == img.Name {
-				if image.DownloadState != voltha.ImageDownload_DOWNLOAD_CANCELLED {
-					clonedImages = append(clonedImages, img)
-				}
+	device, err := agent.getDeviceWithoutLock()
+	if err != nil {
+		return status.Errorf(codes.NotFound, "%s", agent.deviceID)
+	}
+	// Update the image as well as remove it if the download was cancelled
+	cloned := proto.Clone(device).(*voltha.Device)
+	clonedImages := make([]*voltha.ImageDownload, len(cloned.ImageDownloads))
+	for _, image := range cloned.ImageDownloads {
+		if image.Id == img.Id && image.Name == img.Name {
+			if image.DownloadState != voltha.ImageDownload_DOWNLOAD_CANCELLED {
+				clonedImages = append(clonedImages, img)
 			}
 		}
-		cloned.ImageDownloads = clonedImages
-		// Set the Admin state to enabled if required
-		if (img.DownloadState != voltha.ImageDownload_DOWNLOAD_REQUESTED &&
-			img.DownloadState != voltha.ImageDownload_DOWNLOAD_STARTED) ||
-			(img.ImageState != voltha.ImageDownload_IMAGE_ACTIVATING) {
-			cloned.AdminState = voltha.AdminState_ENABLED
-		}
+	}
+	cloned.ImageDownloads = clonedImages
+	// Set the Admin state to enabled if required
+	if (img.DownloadState != voltha.ImageDownload_DOWNLOAD_REQUESTED &&
+		img.DownloadState != voltha.ImageDownload_DOWNLOAD_STARTED) ||
+		(img.ImageState != voltha.ImageDownload_IMAGE_ACTIVATING) {
+		cloned.AdminState = voltha.AdminState_ENABLED
+	}
 
-		if err := agent.updateDeviceInStoreWithoutLock(cloned, false, ""); err != nil {
-			return err
-		}
+	if err := agent.updateDeviceInStoreWithoutLock(cloned, false, ""); err != nil {
+		return err
 	}
 	return nil
 }
@@ -952,37 +967,37 @@
 func (agent *DeviceAgent) getImageDownload(ctx context.Context, img *voltha.ImageDownload) (*voltha.ImageDownload, error) {
 	agent.lockDevice.RLock()
 	defer agent.lockDevice.RUnlock()
-	log.Debugw("getImageDownload", log.Fields{"id": agent.deviceId})
+	log.Debugw("getImageDownload", log.Fields{"id": agent.deviceID})
 	// Get the most up to date the device info
-	if device, err := agent.getDeviceWithoutLock(); err != nil {
-		return nil, status.Errorf(codes.NotFound, "%s", agent.deviceId)
-	} else {
-		for _, image := range device.ImageDownloads {
-			if image.Id == img.Id && image.Name == img.Name {
-				return image, nil
-			}
-		}
-		return nil, status.Errorf(codes.NotFound, "image-not-found:%s", img.Name)
+	device, err := agent.getDeviceWithoutLock()
+	if err != nil {
+		return nil, status.Errorf(codes.NotFound, "%s", agent.deviceID)
 	}
+	for _, image := range device.ImageDownloads {
+		if image.Id == img.Id && image.Name == img.Name {
+			return image, nil
+		}
+	}
+	return nil, status.Errorf(codes.NotFound, "image-not-found:%s", img.Name)
 }
 
-func (agent *DeviceAgent) listImageDownloads(ctx context.Context, deviceId string) (*voltha.ImageDownloads, error) {
+func (agent *DeviceAgent) listImageDownloads(ctx context.Context, deviceID string) (*voltha.ImageDownloads, error) {
 	agent.lockDevice.RLock()
 	defer agent.lockDevice.RUnlock()
-	log.Debugw("listImageDownloads", log.Fields{"id": agent.deviceId})
+	log.Debugw("listImageDownloads", log.Fields{"id": agent.deviceID})
 	// Get the most up to date the device info
-	if device, err := agent.getDeviceWithoutLock(); err != nil {
-		return nil, status.Errorf(codes.NotFound, "%s", agent.deviceId)
-	} else {
-		return &voltha.ImageDownloads{Items: device.ImageDownloads}, nil
+	device, err := agent.getDeviceWithoutLock()
+	if err != nil {
+		return nil, status.Errorf(codes.NotFound, "%s", agent.deviceID)
 	}
+	return &voltha.ImageDownloads{Items: device.ImageDownloads}, nil
 }
 
 // getPorts retrieves the ports information of the device based on the port type.
 func (agent *DeviceAgent) getPorts(ctx context.Context, portType voltha.Port_PortType) *voltha.Ports {
-	log.Debugw("getPorts", log.Fields{"id": agent.deviceId, "portType": portType})
+	log.Debugw("getPorts", log.Fields{"id": agent.deviceID, "portType": portType})
 	ports := &voltha.Ports{}
-	if device, _ := agent.deviceMgr.GetDevice(agent.deviceId); device != nil {
+	if device, _ := agent.deviceMgr.GetDevice(agent.deviceID); device != nil {
 		for _, port := range device.Ports {
 			if port.Type == portType {
 				ports.Items = append(ports.Items, port)
@@ -995,35 +1010,33 @@
 // getSwitchCapability is a helper method that a logical device agent uses to retrieve the switch capability of a
 // parent device
 func (agent *DeviceAgent) getSwitchCapability(ctx context.Context) (*ic.SwitchCapability, error) {
-	log.Debugw("getSwitchCapability", log.Fields{"deviceId": agent.deviceId})
-	if device, err := agent.deviceMgr.GetDevice(agent.deviceId); device == nil {
+	log.Debugw("getSwitchCapability", log.Fields{"deviceId": agent.deviceID})
+	device, err := agent.deviceMgr.GetDevice(agent.deviceID)
+	if device == nil {
 		return nil, err
-	} else {
-		var switchCap *ic.SwitchCapability
-		var err error
-		if switchCap, err = agent.adapterProxy.GetOfpDeviceInfo(ctx, device); err != nil {
-			log.Debugw("getSwitchCapability-error", log.Fields{"id": device.Id, "error": err})
-			return nil, err
-		}
-		return switchCap, nil
 	}
+	var switchCap *ic.SwitchCapability
+	if switchCap, err = agent.adapterProxy.GetOfpDeviceInfo(ctx, device); err != nil {
+		log.Debugw("getSwitchCapability-error", log.Fields{"id": device.Id, "error": err})
+		return nil, err
+	}
+	return switchCap, nil
 }
 
 // getPortCapability is a helper method that a logical device agent uses to retrieve the port capability of a
 // device
 func (agent *DeviceAgent) getPortCapability(ctx context.Context, portNo uint32) (*ic.PortCapability, error) {
-	log.Debugw("getPortCapability", log.Fields{"deviceId": agent.deviceId})
-	if device, err := agent.deviceMgr.GetDevice(agent.deviceId); device == nil {
+	log.Debugw("getPortCapability", log.Fields{"deviceId": agent.deviceID})
+	device, err := agent.deviceMgr.GetDevice(agent.deviceID)
+	if device == nil {
 		return nil, err
-	} else {
-		var portCap *ic.PortCapability
-		var err error
-		if portCap, err = agent.adapterProxy.GetOfpPortInfo(ctx, device, portNo); err != nil {
-			log.Debugw("getPortCapability-error", log.Fields{"id": device.Id, "error": err})
-			return nil, err
-		}
-		return portCap, nil
 	}
+	var portCap *ic.PortCapability
+	if portCap, err = agent.adapterProxy.GetOfpPortInfo(ctx, device, portNo); err != nil {
+		log.Debugw("getPortCapability-error", log.Fields{"id": device.Id, "error": err})
+		return nil, err
+	}
+	return portCap, nil
 }
 
 func (agent *DeviceAgent) packetOut(outPort uint32, packet *ofp.OfpPacketOut) error {
@@ -1033,9 +1046,9 @@
 		agent.reconcileWithKVStore()
 	}
 	//	Send packet to adapter
-	if err := agent.adapterProxy.packetOut(agent.deviceType, agent.deviceId, outPort, packet); err != nil {
+	if err := agent.adapterProxy.packetOut(agent.deviceType, agent.deviceID, outPort, packet); err != nil {
 		log.Debugw("packet-out-error", log.Fields{
-			"id":     agent.deviceId,
+			"id":     agent.deviceID,
 			"error":  err,
 			"packet": hex.EncodeToString(packet.Data),
 		})
@@ -1098,13 +1111,13 @@
 	agent.lockDevice.Lock()
 	defer agent.lockDevice.Unlock()
 	log.Debugw("updateDeviceUsingAdapterData", log.Fields{"deviceId": device.Id})
-	if updatedDevice, err := agent.mergeDeviceInfoFromAdapter(device); err != nil {
+	updatedDevice, err := agent.mergeDeviceInfoFromAdapter(device)
+	if err != nil {
 		log.Errorw("failed to update device ", log.Fields{"deviceId": device.Id})
 		return status.Errorf(codes.Internal, "%s", err.Error())
-	} else {
-		cloned := proto.Clone(updatedDevice).(*voltha.Device)
-		return agent.updateDeviceInStoreWithoutLock(cloned, false, "")
 	}
+	cloned := proto.Clone(updatedDevice).(*voltha.Device)
+	return agent.updateDeviceInStoreWithoutLock(cloned, false, "")
 }
 
 func (agent *DeviceAgent) updateDeviceWithoutLock(device *voltha.Device) error {
@@ -1117,59 +1130,59 @@
 	agent.lockDevice.Lock()
 	defer agent.lockDevice.Unlock()
 	// Work only on latest data
-	if storeDevice, err := agent.getDeviceWithoutLock(); err != nil {
-		return status.Errorf(codes.NotFound, "%s", agent.deviceId)
-	} else {
-		// clone the device
-		cloned := proto.Clone(storeDevice).(*voltha.Device)
-		// Ensure the enums passed in are valid - they will be invalid if they are not set when this function is invoked
-		if s, ok := voltha.ConnectStatus_ConnectStatus_value[connStatus.String()]; ok {
-			log.Debugw("updateDeviceStatus-conn", log.Fields{"ok": ok, "val": s})
-			cloned.ConnectStatus = connStatus
-		}
-		if s, ok := voltha.OperStatus_OperStatus_value[operStatus.String()]; ok {
-			log.Debugw("updateDeviceStatus-oper", log.Fields{"ok": ok, "val": s})
-			cloned.OperStatus = operStatus
-		}
-		log.Debugw("updateDeviceStatus", log.Fields{"deviceId": cloned.Id, "operStatus": cloned.OperStatus, "connectStatus": cloned.ConnectStatus})
-		// Store the device
-		return agent.updateDeviceInStoreWithoutLock(cloned, false, "")
+	storeDevice, err := agent.getDeviceWithoutLock()
+	if err != nil {
+		return status.Errorf(codes.NotFound, "%s", agent.deviceID)
 	}
+	// clone the device
+	cloned := proto.Clone(storeDevice).(*voltha.Device)
+	// Ensure the enums passed in are valid - they will be invalid if they are not set when this function is invoked
+	if s, ok := voltha.ConnectStatus_ConnectStatus_value[connStatus.String()]; ok {
+		log.Debugw("updateDeviceStatus-conn", log.Fields{"ok": ok, "val": s})
+		cloned.ConnectStatus = connStatus
+	}
+	if s, ok := voltha.OperStatus_OperStatus_value[operStatus.String()]; ok {
+		log.Debugw("updateDeviceStatus-oper", log.Fields{"ok": ok, "val": s})
+		cloned.OperStatus = operStatus
+	}
+	log.Debugw("updateDeviceStatus", log.Fields{"deviceId": cloned.Id, "operStatus": cloned.OperStatus, "connectStatus": cloned.ConnectStatus})
+	// Store the device
+	return agent.updateDeviceInStoreWithoutLock(cloned, false, "")
 }
 
 func (agent *DeviceAgent) enablePorts() error {
 	agent.lockDevice.Lock()
 	defer agent.lockDevice.Unlock()
-	if storeDevice, err := agent.getDeviceWithoutLock(); err != nil {
-		return status.Errorf(codes.NotFound, "%s", agent.deviceId)
-	} else {
-		// clone the device
-		cloned := proto.Clone(storeDevice).(*voltha.Device)
-		for _, port := range cloned.Ports {
-			port.AdminState = voltha.AdminState_ENABLED
-			port.OperStatus = voltha.OperStatus_ACTIVE
-		}
-		// Store the device
-		return agent.updateDeviceInStoreWithoutLock(cloned, false, "")
+	storeDevice, err := agent.getDeviceWithoutLock()
+	if err != nil {
+		return status.Errorf(codes.NotFound, "%s", agent.deviceID)
 	}
+	// clone the device
+	cloned := proto.Clone(storeDevice).(*voltha.Device)
+	for _, port := range cloned.Ports {
+		port.AdminState = voltha.AdminState_ENABLED
+		port.OperStatus = voltha.OperStatus_ACTIVE
+	}
+	// Store the device
+	return agent.updateDeviceInStoreWithoutLock(cloned, false, "")
 }
 
 func (agent *DeviceAgent) disablePorts() error {
-	log.Debugw("disablePorts", log.Fields{"deviceid": agent.deviceId})
+	log.Debugw("disablePorts", log.Fields{"deviceid": agent.deviceID})
 	agent.lockDevice.Lock()
 	defer agent.lockDevice.Unlock()
-	if storeDevice, err := agent.getDeviceWithoutLock(); err != nil {
-		return status.Errorf(codes.NotFound, "%s", agent.deviceId)
-	} else {
-		// clone the device
-		cloned := proto.Clone(storeDevice).(*voltha.Device)
-		for _, port := range cloned.Ports {
-			port.AdminState = voltha.AdminState_DISABLED
-			port.OperStatus = voltha.OperStatus_UNKNOWN
-		}
-		// Store the device
-		return agent.updateDeviceInStoreWithoutLock(cloned, false, "")
+	storeDevice, err := agent.getDeviceWithoutLock()
+	if err != nil {
+		return status.Errorf(codes.NotFound, "%s", agent.deviceID)
 	}
+	// clone the device
+	cloned := proto.Clone(storeDevice).(*voltha.Device)
+	for _, port := range cloned.Ports {
+		port.AdminState = voltha.AdminState_DISABLED
+		port.OperStatus = voltha.OperStatus_UNKNOWN
+	}
+	// Store the device
+	return agent.updateDeviceInStoreWithoutLock(cloned, false, "")
 }
 
 func (agent *DeviceAgent) updatePortState(portType voltha.Port_PortType, portNo uint32, operStatus voltha.OperStatus_OperStatus) error {
@@ -1177,90 +1190,90 @@
 	defer agent.lockDevice.Unlock()
 	// Work only on latest data
 	// TODO: Get list of ports from device directly instead of the entire device
-	if storeDevice, err := agent.getDeviceWithoutLock(); err != nil {
-		return status.Errorf(codes.NotFound, "%s", agent.deviceId)
-	} else {
-		// clone the device
-		cloned := proto.Clone(storeDevice).(*voltha.Device)
-		// Ensure the enums passed in are valid - they will be invalid if they are not set when this function is invoked
-		if _, ok := voltha.Port_PortType_value[portType.String()]; !ok {
-			return status.Errorf(codes.InvalidArgument, "%s", portType)
-		}
-		for _, port := range cloned.Ports {
-			if port.Type == portType && port.PortNo == portNo {
-				port.OperStatus = operStatus
-				// Set the admin status to ENABLED if the operational status is ACTIVE
-				// TODO: Set by northbound system?
-				if operStatus == voltha.OperStatus_ACTIVE {
-					port.AdminState = voltha.AdminState_ENABLED
-				}
-				break
-			}
-		}
-		log.Debugw("portStatusUpdate", log.Fields{"deviceId": cloned.Id})
-		// Store the device
-		return agent.updateDeviceInStoreWithoutLock(cloned, false, "")
+	storeDevice, err := agent.getDeviceWithoutLock()
+	if err != nil {
+		return status.Errorf(codes.NotFound, "%s", agent.deviceID)
 	}
+	// clone the device
+	cloned := proto.Clone(storeDevice).(*voltha.Device)
+	// Ensure the enums passed in are valid - they will be invalid if they are not set when this function is invoked
+	if _, ok := voltha.Port_PortType_value[portType.String()]; !ok {
+		return status.Errorf(codes.InvalidArgument, "%s", portType)
+	}
+	for _, port := range cloned.Ports {
+		if port.Type == portType && port.PortNo == portNo {
+			port.OperStatus = operStatus
+			// Set the admin status to ENABLED if the operational status is ACTIVE
+			// TODO: Set by northbound system?
+			if operStatus == voltha.OperStatus_ACTIVE {
+				port.AdminState = voltha.AdminState_ENABLED
+			}
+			break
+		}
+	}
+	log.Debugw("portStatusUpdate", log.Fields{"deviceId": cloned.Id})
+	// Store the device
+	return agent.updateDeviceInStoreWithoutLock(cloned, false, "")
 }
 
 func (agent *DeviceAgent) deleteAllPorts() error {
-	log.Debugw("deleteAllPorts", log.Fields{"deviceId": agent.deviceId})
+	log.Debugw("deleteAllPorts", log.Fields{"deviceId": agent.deviceID})
 	agent.lockDevice.Lock()
 	defer agent.lockDevice.Unlock()
 	// Work only on latest data
-	if storeDevice, err := agent.getDeviceWithoutLock(); err != nil {
-		return status.Errorf(codes.NotFound, "%s", agent.deviceId)
-	} else {
-		if storeDevice.AdminState != voltha.AdminState_DISABLED && storeDevice.AdminState != voltha.AdminState_DELETED {
-			err = status.Error(codes.FailedPrecondition, fmt.Sprintf("invalid-state-%v", storeDevice.AdminState))
-			log.Warnw("invalid-state-removing-ports", log.Fields{"state": storeDevice.AdminState, "error": err})
-			return err
-		}
-		if len(storeDevice.Ports) == 0 {
-			log.Debugw("no-ports-present", log.Fields{"deviceId": agent.deviceId})
-			return nil
-		}
-		// clone the device & set the fields to empty
-		cloned := proto.Clone(storeDevice).(*voltha.Device)
-		cloned.Ports = []*voltha.Port{}
-		log.Debugw("portStatusUpdate", log.Fields{"deviceId": cloned.Id})
-		// Store the device
-		return agent.updateDeviceInStoreWithoutLock(cloned, false, "")
+	storeDevice, err := agent.getDeviceWithoutLock()
+	if err != nil {
+		return status.Errorf(codes.NotFound, "%s", agent.deviceID)
 	}
+	if storeDevice.AdminState != voltha.AdminState_DISABLED && storeDevice.AdminState != voltha.AdminState_DELETED {
+		err = status.Error(codes.FailedPrecondition, fmt.Sprintf("invalid-state-%v", storeDevice.AdminState))
+		log.Warnw("invalid-state-removing-ports", log.Fields{"state": storeDevice.AdminState, "error": err})
+		return err
+	}
+	if len(storeDevice.Ports) == 0 {
+		log.Debugw("no-ports-present", log.Fields{"deviceId": agent.deviceID})
+		return nil
+	}
+	// clone the device & set the fields to empty
+	cloned := proto.Clone(storeDevice).(*voltha.Device)
+	cloned.Ports = []*voltha.Port{}
+	log.Debugw("portStatusUpdate", log.Fields{"deviceId": cloned.Id})
+	// Store the device
+	return agent.updateDeviceInStoreWithoutLock(cloned, false, "")
 }
 
 func (agent *DeviceAgent) addPort(port *voltha.Port) error {
 	agent.lockDevice.Lock()
 	defer agent.lockDevice.Unlock()
-	log.Debugw("addPort", log.Fields{"deviceId": agent.deviceId})
+	log.Debugw("addPort", log.Fields{"deviceId": agent.deviceID})
 	// Work only on latest data
-	if storeDevice, err := agent.getDeviceWithoutLock(); err != nil {
-		return status.Errorf(codes.NotFound, "%s", agent.deviceId)
+	storeDevice, err := agent.getDeviceWithoutLock()
+	if err != nil {
+		return status.Errorf(codes.NotFound, "%s", agent.deviceID)
+	}
+	// clone the device
+	cloned := proto.Clone(storeDevice).(*voltha.Device)
+	if cloned.Ports == nil {
+		//	First port
+		log.Debugw("addPort-first-port-to-add", log.Fields{"deviceId": agent.deviceID})
+		cloned.Ports = make([]*voltha.Port, 0)
 	} else {
-		// clone the device
-		cloned := proto.Clone(storeDevice).(*voltha.Device)
-		if cloned.Ports == nil {
-			//	First port
-			log.Debugw("addPort-first-port-to-add", log.Fields{"deviceId": agent.deviceId})
-			cloned.Ports = make([]*voltha.Port, 0)
-		} else {
-			for _, p := range cloned.Ports {
-				if p.Type == port.Type && p.PortNo == port.PortNo {
-					log.Debugw("port already exists", log.Fields{"port": *port})
-					return nil
-				}
+		for _, p := range cloned.Ports {
+			if p.Type == port.Type && p.PortNo == port.PortNo {
+				log.Debugw("port already exists", log.Fields{"port": *port})
+				return nil
 			}
 		}
-		cp := proto.Clone(port).(*voltha.Port)
-		// Set the admin state of the port to ENABLE if the operational state is ACTIVE
-		// TODO: Set by northbound system?
-		if cp.OperStatus == voltha.OperStatus_ACTIVE {
-			cp.AdminState = voltha.AdminState_ENABLED
-		}
-		cloned.Ports = append(cloned.Ports, cp)
-		// Store the device
-		return agent.updateDeviceInStoreWithoutLock(cloned, false, "")
 	}
+	cp := proto.Clone(port).(*voltha.Port)
+	// Set the admin state of the port to ENABLE if the operational state is ACTIVE
+	// TODO: Set by northbound system?
+	if cp.OperStatus == voltha.OperStatus_ACTIVE {
+		cp.AdminState = voltha.AdminState_ENABLED
+	}
+	cloned.Ports = append(cloned.Ports, cp)
+	// Store the device
+	return agent.updateDeviceInStoreWithoutLock(cloned, false, "")
 }
 
 func (agent *DeviceAgent) addPeerPort(port *voltha.Port_PeerPort) error {
@@ -1268,49 +1281,49 @@
 	defer agent.lockDevice.Unlock()
 	log.Debug("addPeerPort")
 	// Work only on latest data
-	if storeDevice, err := agent.getDeviceWithoutLock(); err != nil {
-		return status.Errorf(codes.NotFound, "%s", agent.deviceId)
-	} else {
-		// clone the device
-		cloned := proto.Clone(storeDevice).(*voltha.Device)
-		// Get the peer port on the device based on the port no
-		for _, peerPort := range cloned.Ports {
-			if peerPort.PortNo == port.PortNo { // found port
-				cp := proto.Clone(port).(*voltha.Port_PeerPort)
-				peerPort.Peers = append(peerPort.Peers, cp)
-				log.Debugw("found-peer", log.Fields{"portNo": port.PortNo, "deviceId": agent.deviceId})
-				break
-			}
-		}
-		// Store the device
-		return agent.updateDeviceInStoreWithoutLock(cloned, false, "")
+	storeDevice, err := agent.getDeviceWithoutLock()
+	if err != nil {
+		return status.Errorf(codes.NotFound, "%s", agent.deviceID)
 	}
+	// clone the device
+	cloned := proto.Clone(storeDevice).(*voltha.Device)
+	// Get the peer port on the device based on the port no
+	for _, peerPort := range cloned.Ports {
+		if peerPort.PortNo == port.PortNo { // found port
+			cp := proto.Clone(port).(*voltha.Port_PeerPort)
+			peerPort.Peers = append(peerPort.Peers, cp)
+			log.Debugw("found-peer", log.Fields{"portNo": port.PortNo, "deviceId": agent.deviceID})
+			break
+		}
+	}
+	// Store the device
+	return agent.updateDeviceInStoreWithoutLock(cloned, false, "")
 }
 
-func (agent *DeviceAgent) deletePeerPorts(deviceId string) error {
+func (agent *DeviceAgent) deletePeerPorts(deviceID string) error {
 	agent.lockDevice.Lock()
 	defer agent.lockDevice.Unlock()
 	log.Debug("deletePeerPorts")
 	// Work only on latest data
-	if storeDevice, err := agent.getDeviceWithoutLock(); err != nil {
-		return status.Errorf(codes.NotFound, "%s", agent.deviceId)
-	} else {
-		// clone the device
-		cloned := proto.Clone(storeDevice).(*voltha.Device)
-		var updatedPeers []*voltha.Port_PeerPort
-		for _, port := range cloned.Ports {
-			updatedPeers = make([]*voltha.Port_PeerPort, 0)
-			for _, peerPort := range port.Peers {
-				if peerPort.DeviceId != deviceId {
-					updatedPeers = append(updatedPeers, peerPort)
-				}
-			}
-			port.Peers = updatedPeers
-		}
-
-		// Store the device with updated peer ports
-		return agent.updateDeviceInStoreWithoutLock(cloned, false, "")
+	storeDevice, err := agent.getDeviceWithoutLock()
+	if err != nil {
+		return status.Errorf(codes.NotFound, "%s", agent.deviceID)
 	}
+	// clone the device
+	cloned := proto.Clone(storeDevice).(*voltha.Device)
+	var updatedPeers []*voltha.Port_PeerPort
+	for _, port := range cloned.Ports {
+		updatedPeers = make([]*voltha.Port_PeerPort, 0)
+		for _, peerPort := range port.Peers {
+			if peerPort.DeviceId != deviceID {
+				updatedPeers = append(updatedPeers, peerPort)
+			}
+		}
+		port.Peers = updatedPeers
+	}
+
+	// Store the device with updated peer ports
+	return agent.updateDeviceInStoreWithoutLock(cloned, false, "")
 }
 
 // TODO: A generic device update by attribute
@@ -1350,22 +1363,21 @@
 	if err = agent.updateDeviceInStoreWithoutLock(cloned, false, ""); err != nil {
 		log.Warnw("attribute-update-failed", log.Fields{"attribute": name, "value": value})
 	}
-	return
 }
 
 func (agent *DeviceAgent) simulateAlarm(ctx context.Context, simulatereq *voltha.SimulateAlarmRequest) error {
 	agent.lockDevice.Lock()
 	defer agent.lockDevice.Unlock()
-	log.Debugw("simulateAlarm", log.Fields{"id": agent.deviceId})
+	log.Debugw("simulateAlarm", log.Fields{"id": agent.deviceID})
 	// Get the most up to date the device info
-	if device, err := agent.getDeviceWithoutLock(); err != nil {
-		return status.Errorf(codes.NotFound, "%s", agent.deviceId)
-	} else {
-		// First send the request to an Adapter and wait for a response
-		if err := agent.adapterProxy.SimulateAlarm(ctx, device, simulatereq); err != nil {
-			log.Debugw("simulateAlarm-error", log.Fields{"id": agent.deviceId, "error": err})
-			return err
-		}
+	device, err := agent.getDeviceWithoutLock()
+	if err != nil {
+		return status.Errorf(codes.NotFound, "%s", agent.deviceID)
+	}
+	// First send the request to an Adapter and wait for a response
+	if err := agent.adapterProxy.SimulateAlarm(ctx, device, simulatereq); err != nil {
+		log.Debugw("simulateAlarm-error", log.Fields{"id": agent.deviceID, "error": err})
+		return err
 	}
 	return nil
 }
@@ -1374,10 +1386,10 @@
 // It is an internal helper function.
 func (agent *DeviceAgent) updateDeviceInStoreWithoutLock(device *voltha.Device, strict bool, txid string) error {
 	updateCtx := context.WithValue(context.Background(), model.RequestTimestamp, time.Now().UnixNano())
-	if afterUpdate := agent.clusterDataProxy.Update(updateCtx, "/devices/"+agent.deviceId, device, strict, txid); afterUpdate == nil {
-		return status.Errorf(codes.Internal, "failed-update-device:%s", agent.deviceId)
+	if afterUpdate := agent.clusterDataProxy.Update(updateCtx, "/devices/"+agent.deviceID, device, strict, txid); afterUpdate == nil {
+		return status.Errorf(codes.Internal, "failed-update-device:%s", agent.deviceID)
 	}
-	log.Debugw("updated-device-in-store", log.Fields{"deviceId: ": agent.deviceId})
+	log.Debugw("updated-device-in-store", log.Fields{"deviceId: ": agent.deviceID})
 
 	return nil
 }
@@ -1386,14 +1398,14 @@
 	agent.lockDevice.Lock()
 	defer agent.lockDevice.Unlock()
 	// Work only on latest data
-	if storeDevice, err := agent.getDeviceWithoutLock(); err != nil {
-		return status.Errorf(codes.NotFound, "%s", agent.deviceId)
-	} else {
-		// clone the device
-		cloned := proto.Clone(storeDevice).(*voltha.Device)
-		cloned.Reason = reason
-		log.Debugw("updateDeviceReason", log.Fields{"deviceId": cloned.Id, "reason": cloned.Reason})
-		// Store the device
-		return agent.updateDeviceInStoreWithoutLock(cloned, false, "")
+	storeDevice, err := agent.getDeviceWithoutLock()
+	if err != nil {
+		return status.Errorf(codes.NotFound, "%s", agent.deviceID)
 	}
+	// clone the device
+	cloned := proto.Clone(storeDevice).(*voltha.Device)
+	cloned.Reason = reason
+	log.Debugw("updateDeviceReason", log.Fields{"deviceId": cloned.Id, "reason": cloned.Reason})
+	// Store the device
+	return agent.updateDeviceInStoreWithoutLock(cloned, false, "")
 }
diff --git a/rw_core/core/device_manager.go b/rw_core/core/device_manager.go
index ce7ecd9..9e4956e 100755
--- a/rw_core/core/device_manager.go
+++ b/rw_core/core/device_manager.go
@@ -13,11 +13,16 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package core
 
 import (
 	"context"
 	"errors"
+	"reflect"
+	"runtime"
+	"sync"
+
 	"github.com/opencord/voltha-go/db/model"
 	"github.com/opencord/voltha-go/rw_core/utils"
 	"github.com/opencord/voltha-lib-go/v2/pkg/kafka"
@@ -28,11 +33,9 @@
 	"github.com/opencord/voltha-protos/v2/go/voltha"
 	"google.golang.org/grpc/codes"
 	"google.golang.org/grpc/status"
-	"reflect"
-	"runtime"
-	"sync"
 )
 
+// DeviceManager represent device manager attributes
 type DeviceManager struct {
 	deviceAgents            sync.Map
 	rootDevices             map[string]bool
@@ -44,7 +47,7 @@
 	kafkaICProxy            *kafka.InterContainerProxy
 	stateTransitions        *TransitionMap
 	clusterDataProxy        *model.Proxy
-	coreInstanceId          string
+	coreInstanceID          string
 	exitChannel             chan int
 	defaultTimeout          int64
 	devicesLoadingLock      sync.RWMutex
@@ -58,7 +61,7 @@
 	deviceMgr.rootDevices = make(map[string]bool)
 	deviceMgr.kafkaICProxy = core.kmp
 	deviceMgr.adapterProxy = NewAdapterProxy(core.kmp, core.config.CorePairTopic)
-	deviceMgr.coreInstanceId = core.instanceId
+	deviceMgr.coreInstanceID = core.instanceID
 	deviceMgr.clusterDataProxy = core.clusterDataProxy
 	deviceMgr.adapterMgr = core.adapterMgr
 	deviceMgr.lockRootDeviceMap = sync.RWMutex{}
@@ -96,41 +99,46 @@
 }
 
 func (dMgr *DeviceManager) addDeviceAgentToMap(agent *DeviceAgent) {
-	if _, exist := dMgr.deviceAgents.Load(agent.deviceId); !exist {
-		dMgr.deviceAgents.Store(agent.deviceId, agent)
+	if _, exist := dMgr.deviceAgents.Load(agent.deviceID); !exist {
+		dMgr.deviceAgents.Store(agent.deviceID, agent)
 	}
 	dMgr.lockRootDeviceMap.Lock()
 	defer dMgr.lockRootDeviceMap.Unlock()
-	dMgr.rootDevices[agent.deviceId] = agent.isRootdevice
+	dMgr.rootDevices[agent.deviceID] = agent.isRootdevice
 
 }
 
 func (dMgr *DeviceManager) deleteDeviceAgentFromMap(agent *DeviceAgent) {
-	dMgr.deviceAgents.Delete(agent.deviceId)
+	dMgr.deviceAgents.Delete(agent.deviceID)
 	dMgr.lockRootDeviceMap.Lock()
 	defer dMgr.lockRootDeviceMap.Unlock()
-	delete(dMgr.rootDevices, agent.deviceId)
+	delete(dMgr.rootDevices, agent.deviceID)
 }
 
 // getDeviceAgent returns the agent managing the device.  If the device is not in memory, it will loads it, if it exists
-func (dMgr *DeviceManager) getDeviceAgent(deviceId string) *DeviceAgent {
-	if agent, ok := dMgr.deviceAgents.Load(deviceId); ok {
+func (dMgr *DeviceManager) getDeviceAgent(deviceID string) *DeviceAgent {
+	agent, ok := dMgr.deviceAgents.Load(deviceID)
+	if ok {
 		return agent.(*DeviceAgent)
-	} else {
-		//	Try to load into memory - loading will also create the device agent and set the device ownership
-		if err := dMgr.load(deviceId); err == nil {
-			if agent, ok = dMgr.deviceAgents.Load(deviceId); !ok {
-				return nil
-			} else {
-				// Register this device for ownership tracking
-				go dMgr.core.deviceOwnership.OwnedByMe(&utils.DeviceID{Id: deviceId})
-				return agent.(*DeviceAgent)
-			}
-		} else {
-			//TODO: Change the return params to return an error as well
-			log.Errorw("loading-device-failed", log.Fields{"deviceId": deviceId, "error": err})
-		}
 	}
+	//	Try to load into memory - loading will also create the device agent and set the device ownership
+	err := dMgr.load(deviceID)
+	if err == nil {
+		agent, ok = dMgr.deviceAgents.Load(deviceID)
+		if !ok {
+			return nil
+		}
+		// Register this device for ownership tracking
+		go func() {
+			_, err = dMgr.core.deviceOwnership.OwnedByMe(&utils.DeviceID{ID: deviceID})
+			if err != nil {
+				log.Errorw("unable-to-find-core-instance-active-owns-this-device", log.Fields{"error": err})
+			}
+		}()
+		return agent.(*DeviceAgent)
+	}
+	//TODO: Change the return params to return an error as well
+	log.Errorw("loading-device-failed", log.Fields{"deviceId": deviceID, "error": err})
 	return nil
 }
 
@@ -223,27 +231,34 @@
 func (dMgr *DeviceManager) stopManagingDevice(id string) {
 	log.Infow("stopManagingDevice", log.Fields{"deviceId": id})
 	if dMgr.IsDeviceInCache(id) { // Proceed only if an agent is present for this device
-		if root, _ := dMgr.IsRootDevice(id); root == true {
+		if root, _ := dMgr.IsRootDevice(id); root {
 			// stop managing the logical device
-			ldeviceId := dMgr.logicalDeviceMgr.stopManagingLogicalDeviceWithDeviceId(id)
-			if ldeviceId != "" { // Can happen if logical device agent was already stopped
-				dMgr.core.deviceOwnership.AbandonDevice(ldeviceId)
+			ldeviceID := dMgr.logicalDeviceMgr.stopManagingLogicalDeviceWithDeviceID(id)
+			if ldeviceID != "" { // Can happen if logical device agent was already stopped
+				err := dMgr.core.deviceOwnership.AbandonDevice(ldeviceID)
+				if err != nil {
+					log.Errorw("unable-to-abandon-the-device", log.Fields{"error": err})
+				}
 			}
 			// stop managing the child devices
-			childDeviceIds := dMgr.getAllDeviceIdsWithDeviceParentId(id)
-			for _, cId := range childDeviceIds {
-				dMgr.stopManagingDevice(cId)
+			childDeviceIds := dMgr.getAllDeviceIdsWithDeviceParentID(id)
+			for _, cID := range childDeviceIds {
+				dMgr.stopManagingDevice(cID)
 			}
 		}
 		if agent := dMgr.getDeviceAgent(id); agent != nil {
-			agent.stop(nil)
+			agent.stop(context.TODO())
 			dMgr.deleteDeviceAgentFromMap(agent)
 			// Abandon the device ownership
-			dMgr.core.deviceOwnership.AbandonDevice(id)
+			err := dMgr.core.deviceOwnership.AbandonDevice(id)
+			if err != nil {
+				log.Errorw("unable-to-abandon-device", log.Fields{"error": err})
+			}
 		}
 	}
 }
 
+// RunPostDeviceDelete removes any reference of this device
 func (dMgr *DeviceManager) RunPostDeviceDelete(cDevice *voltha.Device) error {
 	log.Infow("RunPostDeviceDelete", log.Fields{"deviceId": cDevice.Id})
 	dMgr.stopManagingDevice(cDevice.Id)
@@ -259,13 +274,14 @@
 	return nil, status.Errorf(codes.NotFound, "%s", id)
 }
 
-func (dMgr *DeviceManager) GetChildDevice(parentDeviceId string, serialNumber string, onuId int64, parentPortNo int64) (*voltha.Device, error) {
-	log.Debugw("GetChildDevice", log.Fields{"parentDeviceid": parentDeviceId, "serialNumber": serialNumber,
-		"parentPortNo": parentPortNo, "onuId": onuId})
+// GetChildDevice will return a device, either from memory or from the dB, if present
+func (dMgr *DeviceManager) GetChildDevice(parentDeviceID string, serialNumber string, onuID int64, parentPortNo int64) (*voltha.Device, error) {
+	log.Debugw("GetChildDevice", log.Fields{"parentDeviceid": parentDeviceID, "serialNumber": serialNumber,
+		"parentPortNo": parentPortNo, "onuId": onuID})
 
 	var parentDevice *voltha.Device
 	var err error
-	if parentDevice, err = dMgr.GetDevice(parentDeviceId); err != nil {
+	if parentDevice, err = dMgr.GetDevice(parentDeviceID); err != nil {
 		return nil, status.Errorf(codes.Aborted, "%s", err.Error())
 	}
 	var childDeviceIds []string
@@ -273,20 +289,20 @@
 		return nil, status.Errorf(codes.Aborted, "%s", err.Error())
 	}
 	if len(childDeviceIds) == 0 {
-		log.Debugw("no-child-devices", log.Fields{"parentDeviceId": parentDevice.Id, "serialNumber": serialNumber, "onuId": onuId})
-		return nil, status.Errorf(codes.NotFound, "%s", parentDeviceId)
+		log.Debugw("no-child-devices", log.Fields{"parentDeviceId": parentDevice.Id, "serialNumber": serialNumber, "onuId": onuID})
+		return nil, status.Errorf(codes.NotFound, "%s", parentDeviceID)
 	}
 
 	var foundChildDevice *voltha.Device
-	for _, childDeviceId := range childDeviceIds {
-		found := false
-		if searchDevice, err := dMgr.GetDevice(childDeviceId); err == nil {
+	for _, childDeviceID := range childDeviceIds {
+		var found bool
+		if searchDevice, err := dMgr.GetDevice(childDeviceID); err == nil {
 
-			foundOnuId := false
-			if searchDevice.ProxyAddress.OnuId == uint32(onuId) {
+			foundOnuID := false
+			if searchDevice.ProxyAddress.OnuId == uint32(onuID) {
 				if searchDevice.ParentPortNo == uint32(parentPortNo) {
-					log.Debugw("found-child-by-onuid", log.Fields{"parentDeviceId": parentDevice.Id, "onuId": onuId})
-					foundOnuId = true
+					log.Debugw("found-child-by-onuid", log.Fields{"parentDeviceId": parentDevice.Id, "onuId": onuID})
+					foundOnuID = true
 				}
 			}
 
@@ -298,13 +314,13 @@
 
 			// if both onuId and serialNumber are provided both must be true for the device to be found
 			// otherwise whichever one found a match is good enough
-			if onuId > 0 && serialNumber != "" {
-				found = foundOnuId && foundSerialNumber
+			if onuID > 0 && serialNumber != "" {
+				found = foundOnuID && foundSerialNumber
 			} else {
-				found = foundOnuId || foundSerialNumber
+				found = foundOnuID || foundSerialNumber
 			}
 
-			if found == true {
+			if found {
 				foundChildDevice = searchDevice
 				break
 			}
@@ -317,10 +333,11 @@
 	}
 
 	log.Warnw("child-device-not-found", log.Fields{"parentDeviceId": parentDevice.Id,
-		"serialNumber": serialNumber, "onuId": onuId, "parentPortNo": parentPortNo})
-	return nil, status.Errorf(codes.NotFound, "%s", parentDeviceId)
+		"serialNumber": serialNumber, "onuId": onuID, "parentPortNo": parentPortNo})
+	return nil, status.Errorf(codes.NotFound, "%s", parentDeviceID)
 }
 
+// GetChildDeviceWithProxyAddress will return a device based on proxy address
 func (dMgr *DeviceManager) GetChildDeviceWithProxyAddress(proxyAddress *voltha.Device_ProxyAddress) (*voltha.Device, error) {
 	log.Debugw("GetChildDeviceWithProxyAddress", log.Fields{"proxyAddress": proxyAddress})
 
@@ -339,8 +356,8 @@
 	}
 
 	var foundChildDevice *voltha.Device
-	for _, childDeviceId := range childDeviceIds {
-		if searchDevice, err := dMgr.GetDevice(childDeviceId); err == nil {
+	for _, childDeviceID := range childDeviceIds {
+		if searchDevice, err := dMgr.GetDevice(childDeviceID); err == nil {
 			if searchDevice.ProxyAddress == proxyAddress {
 				foundChildDevice = searchDevice
 				break
@@ -357,11 +374,13 @@
 	return nil, status.Errorf(codes.NotFound, "%s", proxyAddress)
 }
 
+// IsDeviceInCache returns true if device is found in the map
 func (dMgr *DeviceManager) IsDeviceInCache(id string) bool {
 	_, exist := dMgr.deviceAgents.Load(id)
 	return exist
 }
 
+// IsRootDevice returns true if root device is found in the map
 func (dMgr *DeviceManager) IsRootDevice(id string) (bool, error) {
 	dMgr.lockRootDeviceMap.RLock()
 	defer dMgr.lockRootDeviceMap.RUnlock()
@@ -381,9 +400,9 @@
 			if !dMgr.IsDeviceInCache(device.(*voltha.Device).Id) {
 				log.Debugw("loading-device-from-Model", log.Fields{"id": device.(*voltha.Device).Id})
 				agent := newDeviceAgent(dMgr.adapterProxy, device.(*voltha.Device), dMgr, dMgr.clusterDataProxy, dMgr.defaultTimeout)
-				if _, err := agent.start(nil, nil); err != nil {
+				if _, err := agent.start(context.TODO(), nil); err != nil {
 					log.Warnw("failure-starting-agent", log.Fields{"deviceId": device.(*voltha.Device).Id})
-					agent.stop(nil)
+					agent.stop(context.TODO())
 				} else {
 					dMgr.addDeviceAgentToMap(agent)
 				}
@@ -415,47 +434,47 @@
 }
 
 //getDeviceFromModelretrieves the device data from the model.
-func (dMgr *DeviceManager) getDeviceFromModel(deviceId string) (*voltha.Device, error) {
-	if device := dMgr.clusterDataProxy.Get(context.Background(), "/devices/"+deviceId, 0, false, ""); device != nil {
+func (dMgr *DeviceManager) getDeviceFromModel(deviceID string) (*voltha.Device, error) {
+	if device := dMgr.clusterDataProxy.Get(context.Background(), "/devices/"+deviceID, 0, false, ""); device != nil {
 		if d, ok := device.(*voltha.Device); ok {
 			return d, nil
 		}
 	}
-	return nil, status.Error(codes.NotFound, deviceId)
+	return nil, status.Error(codes.NotFound, deviceID)
 }
 
-// loadDevice loads the deviceId in memory, if not present
-func (dMgr *DeviceManager) loadDevice(deviceId string) (*DeviceAgent, error) {
-	if deviceId == "" {
+// loadDevice loads the deviceID in memory, if not present
+func (dMgr *DeviceManager) loadDevice(deviceID string) (*DeviceAgent, error) {
+	if deviceID == "" {
 		return nil, status.Error(codes.InvalidArgument, "deviceId empty")
 	}
 	var err error
 	var device *voltha.Device
 	dMgr.devicesLoadingLock.Lock()
-	if _, exist := dMgr.deviceLoadingInProgress[deviceId]; !exist {
-		if !dMgr.IsDeviceInCache(deviceId) {
-			dMgr.deviceLoadingInProgress[deviceId] = []chan int{make(chan int, 1)}
+	if _, exist := dMgr.deviceLoadingInProgress[deviceID]; !exist {
+		if !dMgr.IsDeviceInCache(deviceID) {
+			dMgr.deviceLoadingInProgress[deviceID] = []chan int{make(chan int, 1)}
 			dMgr.devicesLoadingLock.Unlock()
 			// Proceed with the loading only if the device exist in the Model (could have been deleted)
-			if device, err = dMgr.getDeviceFromModel(deviceId); err == nil {
-				log.Debugw("loading-device", log.Fields{"deviceId": deviceId})
+			if device, err = dMgr.getDeviceFromModel(deviceID); err == nil {
+				log.Debugw("loading-device", log.Fields{"deviceId": deviceID})
 				agent := newDeviceAgent(dMgr.adapterProxy, device, dMgr, dMgr.clusterDataProxy, dMgr.defaultTimeout)
-				if _, err = agent.start(nil, nil); err != nil {
-					log.Warnw("Failure loading device", log.Fields{"deviceId": deviceId, "error": err})
-					agent.stop(nil)
+				if _, err = agent.start(context.TODO(), nil); err != nil {
+					log.Warnw("Failure loading device", log.Fields{"deviceId": deviceID, "error": err})
+					agent.stop(context.TODO())
 				} else {
 					dMgr.addDeviceAgentToMap(agent)
 				}
 			} else {
-				log.Debugw("Device not in model", log.Fields{"deviceId": deviceId})
+				log.Debugw("Device not in model", log.Fields{"deviceId": deviceID})
 			}
 			// announce completion of task to any number of waiting channels
 			dMgr.devicesLoadingLock.Lock()
-			if v, ok := dMgr.deviceLoadingInProgress[deviceId]; ok {
+			if v, ok := dMgr.deviceLoadingInProgress[deviceID]; ok {
 				for _, ch := range v {
 					close(ch)
 				}
-				delete(dMgr.deviceLoadingInProgress, deviceId)
+				delete(dMgr.deviceLoadingInProgress, deviceID)
 			}
 			dMgr.devicesLoadingLock.Unlock()
 		} else {
@@ -463,15 +482,15 @@
 		}
 	} else {
 		ch := make(chan int, 1)
-		dMgr.deviceLoadingInProgress[deviceId] = append(dMgr.deviceLoadingInProgress[deviceId], ch)
+		dMgr.deviceLoadingInProgress[deviceID] = append(dMgr.deviceLoadingInProgress[deviceID], ch)
 		dMgr.devicesLoadingLock.Unlock()
 		//	Wait for the channel to be closed, implying the process loading this device is done.
 		<-ch
 	}
-	if agent, ok := dMgr.deviceAgents.Load(deviceId); ok {
+	if agent, ok := dMgr.deviceAgents.Load(deviceID); ok {
 		return agent.(*DeviceAgent), nil
 	}
-	return nil, status.Errorf(codes.Aborted, "Error loading device %s", deviceId)
+	return nil, status.Errorf(codes.Aborted, "Error loading device %s", deviceID)
 }
 
 // loadRootDeviceParentAndChildren loads the children and parents of a root device in memory
@@ -489,9 +508,9 @@
 		}
 		//	Load all child devices, if needed
 		if childDeviceIds, err := dMgr.getAllChildDeviceIds(device); err == nil {
-			for _, childDeviceId := range childDeviceIds {
-				if _, err := dMgr.loadDevice(childDeviceId); err != nil {
-					log.Warnw("failure-loading-device", log.Fields{"deviceId": childDeviceId, "error": err})
+			for _, childDeviceID := range childDeviceIds {
+				if _, err := dMgr.loadDevice(childDeviceID); err != nil {
+					log.Warnw("failure-loading-device", log.Fields{"deviceId": childDeviceID, "error": err})
 					return err
 				}
 			}
@@ -507,12 +526,12 @@
 // in memory is for improved performance.  It is not imperative that a device needs to be in memory when a request
 // acting on the device is received by the core. In such a scenario, the Core will load the device in memory first
 // and the proceed with the request.
-func (dMgr *DeviceManager) load(deviceId string) error {
+func (dMgr *DeviceManager) load(deviceID string) error {
 	log.Debug("load...")
 	// First load the device - this may fail in case the device was deleted intentionally by the other core
 	var dAgent *DeviceAgent
 	var err error
-	if dAgent, err = dMgr.loadDevice(deviceId); err != nil {
+	if dAgent, err = dMgr.loadDevice(deviceID); err != nil {
 		return err
 	}
 	// Get the loaded device details
@@ -530,10 +549,10 @@
 	if device.Root {
 		// Load all children as well as the parent of this device (logical_device)
 		if err := dMgr.loadRootDeviceParentAndChildren(device); err != nil {
-			log.Warnw("failure-loading-device-parent-and-children", log.Fields{"deviceId": deviceId})
+			log.Warnw("failure-loading-device-parent-and-children", log.Fields{"deviceId": deviceID})
 			return err
 		}
-		log.Debugw("successfully-loaded-parent-and-children", log.Fields{"deviceId": deviceId})
+		log.Debugw("successfully-loaded-parent-and-children", log.Fields{"deviceId": deviceID})
 	} else {
 		//	Scenario B - use the parentId of that device (root device) to trigger the loading
 		if device.ParentId != "" {
@@ -563,7 +582,7 @@
 			if err = dMgr.load(id.Id); err != nil {
 				log.Warnw("failure-reconciling-device", log.Fields{"deviceId": id.Id, "error": err})
 			} else {
-				reconciled += 1
+				reconciled++
 			}
 		}
 		if toReconcile != reconciled {
@@ -595,8 +614,8 @@
 	}
 
 	responses := make([]utils.Response, 0)
-	for _, rootDeviceId := range rootDeviceIds {
-		if rootDevice, _ := dMgr.getDeviceFromModel(rootDeviceId); rootDevice != nil {
+	for _, rootDeviceID := range rootDeviceIds {
+		if rootDevice, _ := dMgr.getDeviceFromModel(rootDeviceID); rootDevice != nil {
 			if rootDevice.Adapter == adapter.Id {
 				if isOkToReconcile(rootDevice) {
 					log.Debugw("reconciling-root-device", log.Fields{"rootId": rootDevice.Id})
@@ -641,7 +660,7 @@
 func (dMgr *DeviceManager) sendReconcileDeviceRequest(device *voltha.Device) utils.Response {
 	// Send a reconcile request to the adapter. Since this Core may not be managing this device then there is no
 	// point of creating a device agent (if the device is not being managed by this Core) before sending the request
-	// to the adapter.   We will therefore bypass the adapter adapter and send the request directly to teh adapter via
+	// to the adapter.   We will therefore bypass the adapter adapter and send the request directly to the adapter via
 	// the adapter_proxy.
 	response := utils.NewResponse()
 	go func(device *voltha.Device) {
@@ -655,8 +674,8 @@
 	return response
 }
 
-func (dMgr *DeviceManager) reconcileChildDevices(parentDeviceId string) error {
-	if parentDevice, _ := dMgr.getDeviceFromModel(parentDeviceId); parentDevice != nil {
+func (dMgr *DeviceManager) reconcileChildDevices(parentDeviceID string) error {
+	if parentDevice, _ := dMgr.getDeviceFromModel(parentDeviceID); parentDevice != nil {
 		responses := make([]utils.Response, 0)
 		for _, port := range parentDevice.Ports {
 			for _, peer := range port.Peers {
@@ -681,13 +700,14 @@
 	return status.Errorf(codes.NotFound, "%s", device.Id)
 }
 
-func (dMgr *DeviceManager) addPort(deviceId string, port *voltha.Port) error {
-	if agent := dMgr.getDeviceAgent(deviceId); agent != nil {
+func (dMgr *DeviceManager) addPort(deviceID string, port *voltha.Port) error {
+	agent := dMgr.getDeviceAgent(deviceID)
+	if agent != nil {
 		if err := agent.addPort(port); err != nil {
 			return err
 		}
 		//	Setup peer ports
-		meAsPeer := &voltha.Port_PeerPort{DeviceId: deviceId, PortNo: port.PortNo}
+		meAsPeer := &voltha.Port_PeerPort{DeviceId: deviceID, PortNo: port.PortNo}
 		for _, peerPort := range port.Peers {
 			if agent := dMgr.getDeviceAgent(peerPort.DeviceId); agent != nil {
 				if err := agent.addPeerPort(meAsPeer); err != nil {
@@ -699,48 +719,52 @@
 		// Notify the logical device manager to setup a logical port, if needed.  If the added port is an NNI or UNI
 		// then a logical port will be added to the logical device and the device graph generated.  If the port is a
 		// PON port then only the device graph will be generated.
-		if device, err := dMgr.GetDevice(deviceId); err == nil {
-			go dMgr.logicalDeviceMgr.updateLogicalPort(device, port)
+		if device, err := dMgr.GetDevice(deviceID); err == nil {
+			go func() {
+				err = dMgr.logicalDeviceMgr.updateLogicalPort(device, port)
+				if err != nil {
+					log.Errorw("unable-to-update-logical-port", log.Fields{"error": err})
+				}
+			}()
 		} else {
-			log.Errorw("failed-to-retrieve-device", log.Fields{"deviceId": deviceId})
+			log.Errorw("failed-to-retrieve-device", log.Fields{"deviceId": deviceID})
 			return err
 		}
 		return nil
-	} else {
-		return status.Errorf(codes.NotFound, "%s", deviceId)
 	}
+	return status.Errorf(codes.NotFound, "%s", deviceID)
 }
 
-func (dMgr *DeviceManager) deletePeerPorts(fromDeviceId string, deviceId string) error {
-	log.Debugw("deletePeerPorts", log.Fields{"fromDeviceId": fromDeviceId, "deviceid": deviceId})
-	if agent := dMgr.getDeviceAgent(fromDeviceId); agent != nil {
-		return agent.deletePeerPorts(deviceId)
+func (dMgr *DeviceManager) deletePeerPorts(fromDeviceID string, deviceID string) error {
+	log.Debugw("deletePeerPorts", log.Fields{"fromDeviceId": fromDeviceID, "deviceid": deviceID})
+	if agent := dMgr.getDeviceAgent(fromDeviceID); agent != nil {
+		return agent.deletePeerPorts(deviceID)
 	}
-	return status.Errorf(codes.NotFound, "%s", deviceId)
+	return status.Errorf(codes.NotFound, "%s", deviceID)
 }
 
-func (dMgr *DeviceManager) addFlowsAndGroups(deviceId string, flows []*ofp.OfpFlowStats, groups []*ofp.OfpGroupEntry, flowMetadata *voltha.FlowMetadata) error {
-	log.Debugw("addFlowsAndGroups", log.Fields{"deviceid": deviceId, "flowMetadata": flowMetadata})
-	if agent := dMgr.getDeviceAgent(deviceId); agent != nil {
+func (dMgr *DeviceManager) addFlowsAndGroups(deviceID string, flows []*ofp.OfpFlowStats, groups []*ofp.OfpGroupEntry, flowMetadata *voltha.FlowMetadata) error {
+	log.Debugw("addFlowsAndGroups", log.Fields{"deviceid": deviceID, "flowMetadata": flowMetadata})
+	if agent := dMgr.getDeviceAgent(deviceID); agent != nil {
 		return agent.addFlowsAndGroups(flows, groups, flowMetadata)
 	}
-	return status.Errorf(codes.NotFound, "%s", deviceId)
+	return status.Errorf(codes.NotFound, "%s", deviceID)
 }
 
-func (dMgr *DeviceManager) deleteFlowsAndGroups(deviceId string, flows []*ofp.OfpFlowStats, groups []*ofp.OfpGroupEntry, flowMetadata *voltha.FlowMetadata) error {
-	log.Debugw("deleteFlowsAndGroups", log.Fields{"deviceid": deviceId})
-	if agent := dMgr.getDeviceAgent(deviceId); agent != nil {
+func (dMgr *DeviceManager) deleteFlowsAndGroups(deviceID string, flows []*ofp.OfpFlowStats, groups []*ofp.OfpGroupEntry, flowMetadata *voltha.FlowMetadata) error {
+	log.Debugw("deleteFlowsAndGroups", log.Fields{"deviceid": deviceID})
+	if agent := dMgr.getDeviceAgent(deviceID); agent != nil {
 		return agent.deleteFlowsAndGroups(flows, groups, flowMetadata)
 	}
-	return status.Errorf(codes.NotFound, "%s", deviceId)
+	return status.Errorf(codes.NotFound, "%s", deviceID)
 }
 
-func (dMgr *DeviceManager) updateFlowsAndGroups(deviceId string, flows []*ofp.OfpFlowStats, groups []*ofp.OfpGroupEntry, flowMetadata *voltha.FlowMetadata) error {
-	log.Debugw("updateFlowsAndGroups", log.Fields{"deviceid": deviceId})
-	if agent := dMgr.getDeviceAgent(deviceId); agent != nil {
+func (dMgr *DeviceManager) updateFlowsAndGroups(deviceID string, flows []*ofp.OfpFlowStats, groups []*ofp.OfpGroupEntry, flowMetadata *voltha.FlowMetadata) error {
+	log.Debugw("updateFlowsAndGroups", log.Fields{"deviceid": deviceID})
+	if agent := dMgr.getDeviceAgent(deviceID); agent != nil {
 		return agent.updateFlowsAndGroups(flows, groups, flowMetadata)
 	}
-	return status.Errorf(codes.NotFound, "%s", deviceId)
+	return status.Errorf(codes.NotFound, "%s", deviceID)
 }
 
 // updatePmConfigs updates the PM configs.  This is executed when the northbound gRPC API is invoked, typically
@@ -758,60 +782,60 @@
 }
 
 // initPmConfigs initialize the pm configs as defined by the adapter.
-func (dMgr *DeviceManager) initPmConfigs(deviceId string, pmConfigs *voltha.PmConfigs) error {
+func (dMgr *DeviceManager) initPmConfigs(deviceID string, pmConfigs *voltha.PmConfigs) error {
 	if pmConfigs.Id == "" {
 		return status.Errorf(codes.FailedPrecondition, "invalid-device-Id")
 	}
-	if agent := dMgr.getDeviceAgent(deviceId); agent != nil {
+	if agent := dMgr.getDeviceAgent(deviceID); agent != nil {
 		return agent.initPmConfigs(pmConfigs)
 	}
-	return status.Errorf(codes.NotFound, "%s", deviceId)
+	return status.Errorf(codes.NotFound, "%s", deviceID)
 }
 
-func (dMgr *DeviceManager) listPmConfigs(ctx context.Context, deviceId string) (*voltha.PmConfigs, error) {
-	if agent := dMgr.getDeviceAgent(deviceId); agent != nil {
+func (dMgr *DeviceManager) listPmConfigs(ctx context.Context, deviceID string) (*voltha.PmConfigs, error) {
+	if agent := dMgr.getDeviceAgent(deviceID); agent != nil {
 		return agent.listPmConfigs(ctx)
 	}
-	return nil, status.Errorf(codes.NotFound, "%s", deviceId)
+	return nil, status.Errorf(codes.NotFound, "%s", deviceID)
 }
 
-func (dMgr *DeviceManager) getSwitchCapability(ctx context.Context, deviceId string) (*ic.SwitchCapability, error) {
-	log.Debugw("getSwitchCapability", log.Fields{"deviceid": deviceId})
-	if agent := dMgr.getDeviceAgent(deviceId); agent != nil {
+func (dMgr *DeviceManager) getSwitchCapability(ctx context.Context, deviceID string) (*ic.SwitchCapability, error) {
+	log.Debugw("getSwitchCapability", log.Fields{"deviceid": deviceID})
+	if agent := dMgr.getDeviceAgent(deviceID); agent != nil {
 		return agent.getSwitchCapability(ctx)
 	}
-	return nil, status.Errorf(codes.NotFound, "%s", deviceId)
+	return nil, status.Errorf(codes.NotFound, "%s", deviceID)
 }
 
-func (dMgr *DeviceManager) getPorts(ctx context.Context, deviceId string, portType voltha.Port_PortType) (*voltha.Ports, error) {
-	log.Debugw("getPorts", log.Fields{"deviceid": deviceId, "portType": portType})
-	if agent := dMgr.getDeviceAgent(deviceId); agent != nil {
+func (dMgr *DeviceManager) getPorts(ctx context.Context, deviceID string, portType voltha.Port_PortType) (*voltha.Ports, error) {
+	log.Debugw("getPorts", log.Fields{"deviceid": deviceID, "portType": portType})
+	if agent := dMgr.getDeviceAgent(deviceID); agent != nil {
 		return agent.getPorts(ctx, portType), nil
 	}
-	return nil, status.Errorf(codes.NotFound, "%s", deviceId)
+	return nil, status.Errorf(codes.NotFound, "%s", deviceID)
 }
 
-func (dMgr *DeviceManager) getPortCapability(ctx context.Context, deviceId string, portNo uint32) (*ic.PortCapability, error) {
-	log.Debugw("getPortCapability", log.Fields{"deviceid": deviceId})
-	if agent := dMgr.getDeviceAgent(deviceId); agent != nil {
+func (dMgr *DeviceManager) getPortCapability(ctx context.Context, deviceID string, portNo uint32) (*ic.PortCapability, error) {
+	log.Debugw("getPortCapability", log.Fields{"deviceid": deviceID})
+	if agent := dMgr.getDeviceAgent(deviceID); agent != nil {
 		return agent.getPortCapability(ctx, portNo)
 	}
-	return nil, status.Errorf(codes.NotFound, "%s", deviceId)
+	return nil, status.Errorf(codes.NotFound, "%s", deviceID)
 }
 
-func (dMgr *DeviceManager) updateDeviceStatus(deviceId string, operStatus voltha.OperStatus_OperStatus, connStatus voltha.ConnectStatus_ConnectStatus) error {
-	log.Debugw("updateDeviceStatus", log.Fields{"deviceid": deviceId, "operStatus": operStatus, "connStatus": connStatus})
-	if agent := dMgr.getDeviceAgent(deviceId); agent != nil {
+func (dMgr *DeviceManager) updateDeviceStatus(deviceID string, operStatus voltha.OperStatus_OperStatus, connStatus voltha.ConnectStatus_ConnectStatus) error {
+	log.Debugw("updateDeviceStatus", log.Fields{"deviceid": deviceID, "operStatus": operStatus, "connStatus": connStatus})
+	if agent := dMgr.getDeviceAgent(deviceID); agent != nil {
 		return agent.updateDeviceStatus(operStatus, connStatus)
 	}
-	return status.Errorf(codes.NotFound, "%s", deviceId)
+	return status.Errorf(codes.NotFound, "%s", deviceID)
 }
 
-func (dMgr *DeviceManager) updateChildrenStatus(deviceId string, operStatus voltha.OperStatus_OperStatus, connStatus voltha.ConnectStatus_ConnectStatus) error {
-	log.Debugw("updateChildrenStatus", log.Fields{"parentDeviceid": deviceId, "operStatus": operStatus, "connStatus": connStatus})
+func (dMgr *DeviceManager) updateChildrenStatus(deviceID string, operStatus voltha.OperStatus_OperStatus, connStatus voltha.ConnectStatus_ConnectStatus) error {
+	log.Debugw("updateChildrenStatus", log.Fields{"parentDeviceid": deviceID, "operStatus": operStatus, "connStatus": connStatus})
 	var parentDevice *voltha.Device
 	var err error
-	if parentDevice, err = dMgr.GetDevice(deviceId); err != nil {
+	if parentDevice, err = dMgr.GetDevice(deviceID); err != nil {
 		return status.Errorf(codes.Aborted, "%s", err.Error())
 	}
 	var childDeviceIds []string
@@ -821,98 +845,108 @@
 	if len(childDeviceIds) == 0 {
 		log.Debugw("no-child-device", log.Fields{"parentDeviceId": parentDevice.Id})
 	}
-	for _, childDeviceId := range childDeviceIds {
-		if agent := dMgr.getDeviceAgent(childDeviceId); agent != nil {
+	for _, childDeviceID := range childDeviceIds {
+		if agent := dMgr.getDeviceAgent(childDeviceID); agent != nil {
 			if err = agent.updateDeviceStatus(operStatus, connStatus); err != nil {
-				return status.Errorf(codes.Aborted, "childDevice:%s, error:%s", childDeviceId, err.Error())
+				return status.Errorf(codes.Aborted, "childDevice:%s, error:%s", childDeviceID, err.Error())
 			}
 		}
 	}
 	return nil
 }
 
-func (dMgr *DeviceManager) updatePortState(deviceId string, portType voltha.Port_PortType, portNo uint32, operStatus voltha.OperStatus_OperStatus) error {
-	log.Debugw("updatePortState", log.Fields{"deviceid": deviceId, "portType": portType, "portNo": portNo, "operStatus": operStatus})
-	if agent := dMgr.getDeviceAgent(deviceId); agent != nil {
+func (dMgr *DeviceManager) updatePortState(deviceID string, portType voltha.Port_PortType, portNo uint32, operStatus voltha.OperStatus_OperStatus) error {
+	log.Debugw("updatePortState", log.Fields{"deviceid": deviceID, "portType": portType, "portNo": portNo, "operStatus": operStatus})
+	if agent := dMgr.getDeviceAgent(deviceID); agent != nil {
 		if err := agent.updatePortState(portType, portNo, operStatus); err != nil {
-			log.Errorw("updating-port-state-failed", log.Fields{"deviceid": deviceId, "portNo": portNo, "error": err})
+			log.Errorw("updating-port-state-failed", log.Fields{"deviceid": deviceID, "portNo": portNo, "error": err})
 			return err
 		}
 		// Notify the logical device manager to change the port state
-		go dMgr.logicalDeviceMgr.updatePortState(deviceId, portNo, operStatus)
+		go func() {
+			err := dMgr.logicalDeviceMgr.updatePortState(deviceID, portNo, operStatus)
+			if err != nil {
+				log.Errorw("unable-to-update-port-state", log.Fields{"error": err})
+			}
+		}()
 	}
-	return status.Errorf(codes.NotFound, "%s", deviceId)
+	return status.Errorf(codes.NotFound, "%s", deviceID)
 }
 
-func (dMgr *DeviceManager) deleteAllPorts(deviceId string) error {
-	log.Debugw("DeleteAllPorts", log.Fields{"deviceid": deviceId})
-	if agent := dMgr.getDeviceAgent(deviceId); agent != nil {
+func (dMgr *DeviceManager) deleteAllPorts(deviceID string) error {
+	log.Debugw("DeleteAllPorts", log.Fields{"deviceid": deviceID})
+	if agent := dMgr.getDeviceAgent(deviceID); agent != nil {
 		if err := agent.deleteAllPorts(); err != nil {
 			return err
 		}
 		// Notify the logical device manager to remove all logical ports, if needed.
 		// At this stage the device itself may gave been deleted already at a deleteAllPorts
 		// typically is part of a device deletion phase.
-		if device, err := dMgr.GetDevice(deviceId); err == nil {
-			go dMgr.logicalDeviceMgr.deleteAllLogicalPorts(device)
+		if device, err := dMgr.GetDevice(deviceID); err == nil {
+			go func() {
+				err = dMgr.logicalDeviceMgr.deleteAllLogicalPorts(device)
+				if err != nil {
+					log.Errorw("unable-to-delete-logical-ports", log.Fields{"error": err})
+				}
+			}()
 		} else {
-			log.Warnw("failed-to-retrieve-device", log.Fields{"deviceId": deviceId})
+			log.Warnw("failed-to-retrieve-device", log.Fields{"deviceId": deviceID})
 			return err
 		}
 		return nil
 	}
-	return status.Errorf(codes.NotFound, "%s", deviceId)
+	return status.Errorf(codes.NotFound, "%s", deviceID)
 }
 
 //updatePortsState updates all ports on the device
-func (dMgr *DeviceManager) updatePortsState(deviceId string, state voltha.OperStatus_OperStatus) error {
-	log.Debugw("updatePortsState", log.Fields{"deviceid": deviceId})
+func (dMgr *DeviceManager) updatePortsState(deviceID string, state voltha.OperStatus_OperStatus) error {
+	log.Debugw("updatePortsState", log.Fields{"deviceid": deviceID})
 
 	var adminState voltha.AdminState_AdminState
-	if agent := dMgr.getDeviceAgent(deviceId); agent != nil {
+	if agent := dMgr.getDeviceAgent(deviceID); agent != nil {
 		switch state {
 		case voltha.OperStatus_ACTIVE:
 			adminState = voltha.AdminState_ENABLED
 			if err := agent.enablePorts(); err != nil {
-				log.Warnw("enable-all-ports-failed", log.Fields{"deviceId": deviceId, "error": err})
+				log.Warnw("enable-all-ports-failed", log.Fields{"deviceId": deviceID, "error": err})
 				return err
 			}
 		case voltha.OperStatus_UNKNOWN:
 			adminState = voltha.AdminState_DISABLED
 			if err := agent.disablePorts(); err != nil {
-				log.Warnw("disable-all-ports-failed", log.Fields{"deviceId": deviceId, "error": err})
+				log.Warnw("disable-all-ports-failed", log.Fields{"deviceId": deviceID, "error": err})
 				return err
 			}
 		default:
 			return status.Error(codes.Unimplemented, "state-change-not-implemented")
 		}
 		// Notify the logical device about the state change
-		if device, err := dMgr.GetDevice(deviceId); err != nil {
-			log.Warnw("non-existent-device", log.Fields{"deviceId": deviceId, "error": err})
+		device, err := dMgr.GetDevice(deviceID)
+		if err != nil {
+			log.Warnw("non-existent-device", log.Fields{"deviceId": deviceID, "error": err})
 			return err
-		} else {
-			if err := dMgr.logicalDeviceMgr.updatePortsState(device, adminState); err != nil {
-				log.Warnw("failed-updating-ports-state", log.Fields{"deviceId": deviceId, "error": err})
-				return err
-			}
-			return nil
 		}
+		if err := dMgr.logicalDeviceMgr.updatePortsState(device, adminState); err != nil {
+			log.Warnw("failed-updating-ports-state", log.Fields{"deviceId": deviceID, "error": err})
+			return err
+		}
+		return nil
 	}
-	return status.Errorf(codes.NotFound, "%s", deviceId)
+	return status.Errorf(codes.NotFound, "%s", deviceID)
 }
 
-func (dMgr *DeviceManager) childDeviceDetected(parentDeviceId string, parentPortNo int64, deviceType string,
-	channelId int64, vendorId string, serialNumber string, onuId int64) (*voltha.Device, error) {
-	log.Debugw("childDeviceDetected", log.Fields{"parentDeviceId": parentDeviceId, "parentPortNo": parentPortNo, "deviceType": deviceType, "channelId": channelId, "vendorId": vendorId, "serialNumber": serialNumber, "onuId": onuId})
+func (dMgr *DeviceManager) childDeviceDetected(parentDeviceID string, parentPortNo int64, deviceType string,
+	channelID int64, vendorID string, serialNumber string, onuID int64) (*voltha.Device, error) {
+	log.Debugw("childDeviceDetected", log.Fields{"parentDeviceId": parentDeviceID, "parentPortNo": parentPortNo, "deviceType": deviceType, "channelId": channelID, "vendorId": vendorID, "serialNumber": serialNumber, "onuId": onuID})
 
-	if deviceType == "" && vendorId != "" {
+	if deviceType == "" && vendorID != "" {
 		log.Debug("device-type-is-nil-fetching-device-type")
 		if deviceTypesIf := dMgr.adapterMgr.clusterDataProxy.List(context.Background(), "/device_types", 0, false, ""); deviceTypesIf != nil {
 		OLoop:
 			for _, deviceTypeIf := range deviceTypesIf.([]interface{}) {
 				if dType, ok := deviceTypeIf.(*voltha.DeviceType); ok {
 					for _, v := range dType.VendorIds {
-						if v == vendorId {
+						if v == vendorID {
 							deviceType = dType.Adapter
 							break OLoop
 						}
@@ -923,37 +957,37 @@
 	}
 	//if no match found for the vendorid,report adapter with the custom error message
 	if deviceType == "" {
-		log.Errorw("failed-to-fetch-adapter-name ", log.Fields{"vendorId": vendorId})
-		return nil, status.Errorf(codes.NotFound, "%s", vendorId)
+		log.Errorw("failed-to-fetch-adapter-name ", log.Fields{"vendorId": vendorID})
+		return nil, status.Errorf(codes.NotFound, "%s", vendorID)
 	}
 
 	// Create the ONU device
 	childDevice := &voltha.Device{}
 	childDevice.Type = deviceType
-	childDevice.ParentId = parentDeviceId
+	childDevice.ParentId = parentDeviceID
 	childDevice.ParentPortNo = uint32(parentPortNo)
-	childDevice.VendorId = vendorId
+	childDevice.VendorId = vendorID
 	childDevice.SerialNumber = serialNumber
 	childDevice.Root = false
 
 	//Get parent device type
-	parent, err := dMgr.GetDevice(parentDeviceId)
+	parent, err := dMgr.GetDevice(parentDeviceID)
 	if err != nil {
-		log.Error("no-parent-found", log.Fields{"parentId": parentDeviceId})
-		return nil, status.Errorf(codes.NotFound, "%s", parentDeviceId)
+		log.Error("no-parent-found", log.Fields{"parentId": parentDeviceID})
+		return nil, status.Errorf(codes.NotFound, "%s", parentDeviceID)
 	}
 
-	if device, err := dMgr.GetChildDevice(parentDeviceId, serialNumber, onuId, parentPortNo); err == nil {
-		log.Warnw("child-device-exists", log.Fields{"parentId": parentDeviceId, "serialNumber": serialNumber})
+	if device, err := dMgr.GetChildDevice(parentDeviceID, serialNumber, onuID, parentPortNo); err == nil {
+		log.Warnw("child-device-exists", log.Fields{"parentId": parentDeviceID, "serialNumber": serialNumber})
 		return device, status.Errorf(codes.AlreadyExists, "%s", serialNumber)
 	}
 
-	childDevice.ProxyAddress = &voltha.Device_ProxyAddress{DeviceId: parentDeviceId, DeviceType: parent.Type, ChannelId: uint32(channelId), OnuId: uint32(onuId)}
+	childDevice.ProxyAddress = &voltha.Device_ProxyAddress{DeviceId: parentDeviceID, DeviceType: parent.Type, ChannelId: uint32(channelID), OnuId: uint32(onuID)}
 
 	// Create and start a device agent for that device
 	agent := newDeviceAgent(dMgr.adapterProxy, childDevice, dMgr, dMgr.clusterDataProxy, dMgr.defaultTimeout)
 	dMgr.addDeviceAgentToMap(agent)
-	childDevice, err = agent.start(nil, childDevice)
+	childDevice, err = agent.start(context.TODO(), childDevice)
 	if err != nil {
 		log.Error("error-starting-child")
 		return nil, err
@@ -961,15 +995,28 @@
 
 	// Since this Core has handled this request then it therefore owns this child device.  Set the
 	// ownership of this device to this Core
-	dMgr.core.deviceOwnership.OwnedByMe(&utils.DeviceID{Id: agent.deviceId})
+	_, err = dMgr.core.deviceOwnership.OwnedByMe(&utils.DeviceID{ID: agent.deviceID})
+	if err != nil {
+		log.Errorw("unable-to-find-core-instance-active-owns-this-device", log.Fields{"error": err})
+	}
 
 	// Activate the child device
-	if agent := dMgr.getDeviceAgent(agent.deviceId); agent != nil {
-		go agent.enableDevice(nil)
+	if agent = dMgr.getDeviceAgent(agent.deviceID); agent != nil {
+		go func() {
+			err := agent.enableDevice(context.TODO())
+			if err != nil {
+				log.Errorw("unable-to-enable-device", log.Fields{"error": err})
+			}
+		}()
 	}
 
 	// Publish on the messaging bus that we have discovered new devices
-	go dMgr.kafkaICProxy.DeviceDiscovered(agent.deviceId, deviceType, parentDeviceId, dMgr.coreInstanceId)
+	go func() {
+		err := dMgr.kafkaICProxy.DeviceDiscovered(agent.deviceID, deviceType, parentDeviceID, dMgr.coreInstanceID)
+		if err != nil {
+			log.Errorw("unable-to-discover-the-device", log.Fields{"error": err})
+		}
+	}()
 
 	return childDevice, nil
 }
@@ -992,42 +1039,44 @@
 	return nil
 }
 
-func (dMgr *DeviceManager) packetOut(deviceId string, outPort uint32, packet *ofp.OfpPacketOut) error {
-	log.Debugw("packetOut", log.Fields{"deviceId": deviceId, "outPort": outPort})
-	if agent := dMgr.getDeviceAgent(deviceId); agent != nil {
+func (dMgr *DeviceManager) packetOut(deviceID string, outPort uint32, packet *ofp.OfpPacketOut) error {
+	log.Debugw("packetOut", log.Fields{"deviceId": deviceID, "outPort": outPort})
+	if agent := dMgr.getDeviceAgent(deviceID); agent != nil {
 		return agent.packetOut(outPort, packet)
 	}
-	return status.Errorf(codes.NotFound, "%s", deviceId)
+	return status.Errorf(codes.NotFound, "%s", deviceID)
 }
 
-func (dMgr *DeviceManager) PacketIn(deviceId string, port uint32, transactionId string, packet []byte) error {
-	log.Debugw("PacketIn", log.Fields{"deviceId": deviceId, "port": port})
+// PacketIn receives packet from adapter
+func (dMgr *DeviceManager) PacketIn(deviceID string, port uint32, transactionID string, packet []byte) error {
+	log.Debugw("PacketIn", log.Fields{"deviceId": deviceID, "port": port})
 	// Get the logical device Id based on the deviceId
 	var device *voltha.Device
 	var err error
-	if device, err = dMgr.GetDevice(deviceId); err != nil {
-		log.Errorw("device-not-found", log.Fields{"deviceId": deviceId})
+	if device, err = dMgr.GetDevice(deviceID); err != nil {
+		log.Errorw("device-not-found", log.Fields{"deviceId": deviceID})
 		return err
 	}
 	if !device.Root {
-		log.Errorw("device-not-root", log.Fields{"deviceId": deviceId})
-		return status.Errorf(codes.FailedPrecondition, "%s", deviceId)
+		log.Errorw("device-not-root", log.Fields{"deviceId": deviceID})
+		return status.Errorf(codes.FailedPrecondition, "%s", deviceID)
 	}
 
-	if err := dMgr.logicalDeviceMgr.packetIn(device.ParentId, port, transactionId, packet); err != nil {
+	if err := dMgr.logicalDeviceMgr.packetIn(device.ParentId, port, transactionID, packet); err != nil {
 		return err
 	}
 	return nil
 }
 
-func (dMgr *DeviceManager) setParentId(device *voltha.Device, parentId string) error {
-	log.Debugw("setParentId", log.Fields{"deviceId": device.Id, "parentId": parentId})
+func (dMgr *DeviceManager) setParentID(device *voltha.Device, parentID string) error {
+	log.Debugw("setParentId", log.Fields{"deviceId": device.Id, "parentId": parentID})
 	if agent := dMgr.getDeviceAgent(device.Id); agent != nil {
-		return agent.setParentId(device, parentId)
+		return agent.setParentID(device, parentID)
 	}
 	return status.Errorf(codes.NotFound, "%s", device.Id)
 }
 
+// CreateLogicalDevice creates logical device in core
 func (dMgr *DeviceManager) CreateLogicalDevice(cDevice *voltha.Device) error {
 	log.Info("CreateLogicalDevice")
 	// Verify whether the logical device has already been created
@@ -1036,42 +1085,45 @@
 		return nil
 	}
 	var err error
-	if _, err = dMgr.logicalDeviceMgr.createLogicalDevice(nil, cDevice); err != nil {
+	if _, err = dMgr.logicalDeviceMgr.createLogicalDevice(context.TODO(), cDevice); err != nil {
 		log.Warnw("createlogical-device-error", log.Fields{"device": cDevice})
 		return err
 	}
 	return nil
 }
 
+// DeleteLogicalDevice deletes logical device from core
 func (dMgr *DeviceManager) DeleteLogicalDevice(cDevice *voltha.Device) error {
 	log.Info("DeleteLogicalDevice")
 	var err error
-	if err = dMgr.logicalDeviceMgr.deleteLogicalDevice(nil, cDevice); err != nil {
+	if err = dMgr.logicalDeviceMgr.deleteLogicalDevice(context.TODO(), cDevice); err != nil {
 		log.Warnw("deleteLogical-device-error", log.Fields{"deviceId": cDevice.Id})
 		return err
 	}
 	// Remove the logical device Id from the parent device
-	logicalId := ""
-	dMgr.UpdateDeviceAttribute(cDevice.Id, "ParentId", logicalId)
+	logicalID := ""
+	dMgr.UpdateDeviceAttribute(cDevice.Id, "ParentId", logicalID)
 	return nil
 }
 
+// DeleteLogicalPort removes the logical port associated with a device
 func (dMgr *DeviceManager) DeleteLogicalPort(device *voltha.Device) error {
 	log.Info("deleteLogicalPort")
 	var err error
 	// Get the logical port associated with this device
-	var lPortId *voltha.LogicalPortId
-	if lPortId, err = dMgr.logicalDeviceMgr.getLogicalPortId(device); err != nil {
+	var lPortID *voltha.LogicalPortId
+	if lPortID, err = dMgr.logicalDeviceMgr.getLogicalPortID(device); err != nil {
 		log.Warnw("getLogical-port-error", log.Fields{"deviceId": device.Id, "error": err})
 		return err
 	}
-	if err = dMgr.logicalDeviceMgr.deleteLogicalPort(nil, lPortId); err != nil {
+	if err = dMgr.logicalDeviceMgr.deleteLogicalPort(context.TODO(), lPortID); err != nil {
 		log.Warnw("deleteLogical-port-error", log.Fields{"deviceId": device.Id})
 		return err
 	}
 	return nil
 }
 
+// DeleteLogicalPorts removes the logical ports associated with that deviceId
 func (dMgr *DeviceManager) DeleteLogicalPorts(device *voltha.Device) error {
 	log.Info("deleteLogicalPorts")
 	if err := dMgr.logicalDeviceMgr.deleteLogicalPorts(device.Id); err != nil {
@@ -1093,12 +1145,12 @@
 
 //childDevicesLost is invoked by an adapter to indicate that a parent device is in a state (Disabled) where it
 //cannot manage the child devices.  This will trigger the Core to disable all the child devices.
-func (dMgr *DeviceManager) childDevicesLost(parentDeviceId string) error {
+func (dMgr *DeviceManager) childDevicesLost(parentDeviceID string) error {
 	log.Debug("childDevicesLost")
 	var err error
 	var parentDevice *voltha.Device
-	if parentDevice, err = dMgr.GetDevice(parentDeviceId); err != nil {
-		log.Warnw("failed-getting-device", log.Fields{"deviceId": parentDeviceId, "error": err})
+	if parentDevice, err = dMgr.GetDevice(parentDeviceID); err != nil {
+		log.Warnw("failed-getting-device", log.Fields{"deviceId": parentDeviceID, "error": err})
 		return err
 	}
 	return dMgr.DisableAllChildDevices(parentDevice)
@@ -1106,14 +1158,14 @@
 
 //childDevicesDetected is invoked by an adapter when child devices are found, typically after after a
 // disable/enable sequence.  This will trigger the Core to Enable all the child devices of that parent.
-func (dMgr *DeviceManager) childDevicesDetected(parentDeviceId string) error {
+func (dMgr *DeviceManager) childDevicesDetected(parentDeviceID string) error {
 	log.Debug("childDevicesDetected")
 	var err error
 	var parentDevice *voltha.Device
 	var childDeviceIds []string
 
-	if parentDevice, err = dMgr.GetDevice(parentDeviceId); err != nil {
-		log.Warnw("failed-getting-device", log.Fields{"deviceId": parentDeviceId, "error": err})
+	if parentDevice, err = dMgr.GetDevice(parentDeviceID); err != nil {
+		log.Warnw("failed-getting-device", log.Fields{"deviceId": parentDeviceID, "error": err})
 		return err
 	}
 
@@ -1124,13 +1176,18 @@
 		log.Debugw("no-child-device", log.Fields{"parentDeviceId": parentDevice.Id})
 	}
 	allChildEnableRequestSent := true
-	for _, childDeviceId := range childDeviceIds {
-		if agent := dMgr.getDeviceAgent(childDeviceId); agent != nil {
+	for _, childDeviceID := range childDeviceIds {
+		if agent := dMgr.getDeviceAgent(childDeviceID); agent != nil {
 			// Run the children re-registration in its own routine
-			go agent.enableDevice(nil)
+			go func() {
+				err = agent.enableDevice(context.TODO())
+				if err != nil {
+					log.Errorw("unable-to-enable-device", log.Fields{"error": err})
+				}
+			}()
 		} else {
-			err = status.Errorf(codes.Unavailable, "no agent for child device %s", childDeviceId)
-			log.Errorw("no-child-device-agent", log.Fields{"parentDeviceId": parentDevice.Id, "childId": childDeviceId})
+			err = status.Errorf(codes.Unavailable, "no agent for child device %s", childDeviceID)
+			log.Errorw("no-child-device-agent", log.Fields{"parentDeviceId": parentDevice.Id, "childId": childDeviceID})
 			allChildEnableRequestSent = false
 		}
 	}
@@ -1157,10 +1214,10 @@
 		log.Debugw("no-child-device", log.Fields{"parentDeviceId": parentDevice.Id})
 	}
 	allChildDisable := true
-	for _, childDeviceId := range childDeviceIds {
-		if agent := dMgr.getDeviceAgent(childDeviceId); agent != nil {
-			if err = agent.disableDevice(nil); err != nil {
-				log.Errorw("failure-disable-device", log.Fields{"deviceId": childDeviceId, "error": err.Error()})
+	for _, childDeviceID := range childDeviceIds {
+		if agent := dMgr.getDeviceAgent(childDeviceID); agent != nil {
+			if err = agent.disableDevice(context.TODO()); err != nil {
+				log.Errorw("failure-disable-device", log.Fields{"deviceId": childDeviceID, "error": err.Error()})
 				allChildDisable = false
 			}
 		}
@@ -1183,13 +1240,13 @@
 		log.Debugw("no-child-device", log.Fields{"parentDeviceId": parentDevice.Id})
 	}
 	allChildDeleted := true
-	for _, childDeviceId := range childDeviceIds {
-		if agent := dMgr.getDeviceAgent(childDeviceId); agent != nil {
-			if err = agent.deleteDevice(nil); err != nil {
-				log.Errorw("failure-delete-device", log.Fields{"deviceId": childDeviceId, "error": err.Error()})
+	for _, childDeviceID := range childDeviceIds {
+		if agent := dMgr.getDeviceAgent(childDeviceID); agent != nil {
+			if err = agent.deleteDevice(context.TODO()); err != nil {
+				log.Errorw("failure-delete-device", log.Fields{"deviceId": childDeviceID, "error": err.Error()})
 				allChildDeleted = false
 			} else {
-				agent.stop(nil)
+				agent.stop(context.TODO())
 				dMgr.deleteDeviceAgentFromMap(agent)
 			}
 		}
@@ -1203,12 +1260,12 @@
 //getAllDeviceIdsWithDeviceParentId returns the list of device Ids which has id as parent Id.  This function uses the
 // data from the agent instead of using the data from the parent device as that data would disappear from a parent
 // device during a delete device operation.
-func (dMgr *DeviceManager) getAllDeviceIdsWithDeviceParentId(id string) []string {
+func (dMgr *DeviceManager) getAllDeviceIdsWithDeviceParentID(id string) []string {
 	log.Debugw("getAllAgentsWithDeviceParentId", log.Fields{"parentDeviceId": id})
 	deviceIds := make([]string, 0)
 	dMgr.deviceAgents.Range(func(key, value interface{}) bool {
 		agent := value.(*DeviceAgent)
-		if agent.parentId == id {
+		if agent.parentID == id {
 			deviceIds = append(deviceIds, key.(string))
 		}
 		return true
@@ -1232,25 +1289,26 @@
 }
 
 //getAllChildDevices is a helper method to get all the child device IDs from the device passed as parameter
-func (dMgr *DeviceManager) getAllChildDevices(parentDeviceId string) (*voltha.Devices, error) {
-	log.Debugw("getAllChildDevices", log.Fields{"parentDeviceId": parentDeviceId})
-	if parentDevice, err := dMgr.GetDevice(parentDeviceId); err == nil {
+func (dMgr *DeviceManager) getAllChildDevices(parentDeviceID string) (*voltha.Devices, error) {
+	log.Debugw("getAllChildDevices", log.Fields{"parentDeviceId": parentDeviceID})
+	if parentDevice, err := dMgr.GetDevice(parentDeviceID); err == nil {
 		childDevices := make([]*voltha.Device, 0)
 		if childDeviceIds, er := dMgr.getAllChildDeviceIds(parentDevice); er == nil {
-			for _, deviceId := range childDeviceIds {
-				if d, e := dMgr.GetDevice(deviceId); e == nil && d != nil {
+			for _, deviceID := range childDeviceIds {
+				if d, e := dMgr.GetDevice(deviceID); e == nil && d != nil {
 					childDevices = append(childDevices, d)
 				}
 			}
 		}
 		return &voltha.Devices{Items: childDevices}, nil
 	}
-	return nil, status.Errorf(codes.NotFound, "%s", parentDeviceId)
+	return nil, status.Errorf(codes.NotFound, "%s", parentDeviceID)
 }
 
+// SetupUNILogicalPorts creates UNI ports on the logical device that represents a child UNI interface
 func (dMgr *DeviceManager) SetupUNILogicalPorts(cDevice *voltha.Device) error {
 	log.Info("addUNILogicalPort")
-	if err := dMgr.logicalDeviceMgr.setupUNILogicalPorts(nil, cDevice); err != nil {
+	if err := dMgr.logicalDeviceMgr.setupUNILogicalPorts(context.TODO(), cDevice); err != nil {
 		log.Warnw("addUNILogicalPort-error", log.Fields{"device": cDevice, "err": err})
 		return err
 	}
@@ -1332,9 +1390,9 @@
 	sendResponse(ctx, ch, res)
 }
 
-func (dMgr *DeviceManager) updateImageDownload(deviceId string, img *voltha.ImageDownload) error {
+func (dMgr *DeviceManager) updateImageDownload(deviceID string, img *voltha.ImageDownload) error {
 	log.Debugw("updateImageDownload", log.Fields{"deviceid": img.Id, "imageName": img.Name})
-	if agent := dMgr.getDeviceAgent(deviceId); agent != nil {
+	if agent := dMgr.getDeviceAgent(deviceID); agent != nil {
 		if err := agent.updateImageDownload(img); err != nil {
 			log.Debugw("updateImageDownload-failed", log.Fields{"err": err, "imageName": img.Name})
 			return err
@@ -1353,14 +1411,15 @@
 	return nil, status.Errorf(codes.NotFound, "%s", img.Id)
 }
 
-func (dMgr *DeviceManager) listImageDownloads(ctx context.Context, deviceId string) (*voltha.ImageDownloads, error) {
-	log.Debugw("listImageDownloads", log.Fields{"deviceId": deviceId})
-	if agent := dMgr.getDeviceAgent(deviceId); agent != nil {
-		return agent.listImageDownloads(ctx, deviceId)
+func (dMgr *DeviceManager) listImageDownloads(ctx context.Context, deviceID string) (*voltha.ImageDownloads, error) {
+	log.Debugw("listImageDownloads", log.Fields{"deviceID": deviceID})
+	if agent := dMgr.getDeviceAgent(deviceID); agent != nil {
+		return agent.listImageDownloads(ctx, deviceID)
 	}
-	return nil, status.Errorf(codes.NotFound, "%s", deviceId)
+	return nil, status.Errorf(codes.NotFound, "%s", deviceID)
 }
 
+// SetAdminStateToEnable sets admin state of device to enabled
 func (dMgr *DeviceManager) SetAdminStateToEnable(cDevice *voltha.Device) error {
 	log.Info("SetAdminStateToEnable")
 	if agent := dMgr.getDeviceAgent(cDevice.Id); agent != nil {
@@ -1369,36 +1428,7 @@
 	return status.Errorf(codes.NotFound, "%s", cDevice.Id)
 }
 
-func (dMgr *DeviceManager) activateDevice(cDevice *voltha.Device) error {
-	log.Info("activateDevice")
-	return nil
-}
-
-func (dMgr *DeviceManager) disableDeviceHandler(cDevice *voltha.Device) error {
-	log.Info("disableDevice-donothing")
-	return nil
-}
-
-func (dMgr *DeviceManager) abandonDevice(cDevice *voltha.Device) error {
-	log.Info("abandonDevice")
-	return nil
-}
-
-func (dMgr *DeviceManager) reEnableDevice(cDevice *voltha.Device) error {
-	log.Info("reEnableDevice")
-	return nil
-}
-
-func (dMgr *DeviceManager) noOp(cDevice *voltha.Device) error {
-	log.Info("noOp")
-	return nil
-}
-
-func (dMgr *DeviceManager) notAllowed(pcDevice *voltha.Device) error {
-	log.Info("notAllowed")
-	return errors.New("transition-not-allowed")
-}
-
+// NotifyInvalidTransition notifies about invalid transition
 func (dMgr *DeviceManager) NotifyInvalidTransition(pcDevice *voltha.Device) error {
 	log.Errorw("NotifyInvalidTransition", log.Fields{
 		"device":     pcDevice.Id,
@@ -1416,14 +1446,16 @@
 	return rf.Name()
 }
 
-func (dMgr *DeviceManager) UpdateDeviceAttribute(deviceId string, attribute string, value interface{}) {
-	if agent, ok := dMgr.deviceAgents.Load(deviceId); ok {
+// UpdateDeviceAttribute updates value of particular device attribute
+func (dMgr *DeviceManager) UpdateDeviceAttribute(deviceID string, attribute string, value interface{}) {
+	if agent, ok := dMgr.deviceAgents.Load(deviceID); ok {
 		agent.(*DeviceAgent).updateDeviceAttribute(attribute, value)
 	}
 }
 
-func (dMgr *DeviceManager) GetParentDeviceId(deviceId string) string {
-	if device, _ := dMgr.GetDevice(deviceId); device != nil {
+// GetParentDeviceID returns parent device id, either from memory or from the dB, if present
+func (dMgr *DeviceManager) GetParentDeviceID(deviceID string) string {
+	if device, _ := dMgr.GetDevice(deviceID); device != nil {
 		log.Infow("GetParentDeviceId", log.Fields{"deviceId": device.Id, "parentId": device.ParentId})
 		return device.ParentId
 	}
@@ -1443,10 +1475,10 @@
 	sendResponse(ctx, ch, res)
 }
 
-func (dMgr *DeviceManager) updateDeviceReason(deviceId string, reason string) error {
-	log.Debugw("updateDeviceReason", log.Fields{"deviceid": deviceId, "reason": reason})
-	if agent := dMgr.getDeviceAgent(deviceId); agent != nil {
+func (dMgr *DeviceManager) updateDeviceReason(deviceID string, reason string) error {
+	log.Debugw("updateDeviceReason", log.Fields{"deviceid": deviceID, "reason": reason})
+	if agent := dMgr.getDeviceAgent(deviceID); agent != nil {
 		return agent.updateDeviceReason(reason)
 	}
-	return status.Errorf(codes.NotFound, "%s", deviceId)
+	return status.Errorf(codes.NotFound, "%s", deviceID)
 }
diff --git a/rw_core/core/device_ownership.go b/rw_core/core/device_ownership.go
index b44e5c0..5f4d0d5 100644
--- a/rw_core/core/device_ownership.go
+++ b/rw_core/core/device_ownership.go
@@ -13,23 +13,28 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package core
 
 import (
 	"context"
 	"fmt"
+	"sync"
+	"time"
+
 	"github.com/opencord/voltha-go/rw_core/utils"
 	"github.com/opencord/voltha-lib-go/v2/pkg/db/kvstore"
 	"github.com/opencord/voltha-lib-go/v2/pkg/log"
 	"github.com/opencord/voltha-protos/v2/go/voltha"
 	"google.golang.org/grpc/codes"
 	"google.golang.org/grpc/status"
-	"sync"
-	"time"
 )
 
 func init() {
-	log.AddPackage(log.JSON, log.WarnLevel, nil)
+	_, err := log.AddPackage(log.JSON, log.WarnLevel, nil)
+	if err != nil {
+		log.Errorw("unable-to-register-package-to-the-log-map", log.Fields{"error": err})
+	}
 }
 
 type ownership struct {
@@ -38,8 +43,9 @@
 	chnl  chan int
 }
 
+// DeviceOwnership represent device ownership attributes
 type DeviceOwnership struct {
-	instanceId         string
+	instanceID         string
 	exitChannel        chan int
 	kvClient           kvstore.Client
 	reservationTimeout int64 // Duration in seconds
@@ -53,9 +59,10 @@
 	ownershipLock      sync.RWMutex
 }
 
+// NewDeviceOwnership creates device ownership instance
 func NewDeviceOwnership(id string, kvClient kvstore.Client, deviceMgr *DeviceManager, logicalDeviceMgr *LogicalDeviceManager, ownershipPrefix string, reservationTimeout int64) *DeviceOwnership {
 	var deviceOwnership DeviceOwnership
-	deviceOwnership.instanceId = id
+	deviceOwnership.instanceID = id
 	deviceOwnership.exitChannel = make(chan int, 1)
 	deviceOwnership.kvClient = kvClient
 	deviceOwnership.deviceMgr = deviceMgr
@@ -70,11 +77,13 @@
 	return &deviceOwnership
 }
 
+// Start starts device device ownership
 func (da *DeviceOwnership) Start(ctx context.Context) {
-	log.Info("starting-deviceOwnership", log.Fields{"instanceId": da.instanceId})
+	log.Info("starting-deviceOwnership", log.Fields{"instanceId": da.instanceID})
 	log.Info("deviceOwnership-started")
 }
 
+// Stop stops device ownership
 func (da *DeviceOwnership) Stop(ctx context.Context) {
 	log.Info("stopping-deviceOwnership")
 	da.exitChannel <- 1
@@ -87,15 +96,15 @@
 	var currOwner string
 	//Try to reserve the key
 	kvKey := fmt.Sprintf("%s_%s", da.ownershipPrefix, id)
-	value, err := da.kvClient.Reserve(kvKey, da.instanceId, da.reservationTimeout)
+	value, err := da.kvClient.Reserve(kvKey, da.instanceID, da.reservationTimeout)
 	if err != nil {
-		log.Errorw("error", log.Fields{"error": err, "id": id, "instanceId": da.instanceId})
+		log.Errorw("error", log.Fields{"error": err, "id": id, "instanceId": da.instanceID})
 	}
 	if value != nil {
 		if currOwner, err = kvstore.ToString(value); err != nil {
 			log.Error("unexpected-owner-type")
 		}
-		return currOwner == da.instanceId
+		return currOwner == da.instanceID
 	}
 	return false
 }
@@ -104,7 +113,7 @@
 	// Try to reserve the key
 	kvKey := fmt.Sprintf("%s_%s", da.ownershipPrefix, id)
 	if err := da.kvClient.RenewReservation(kvKey); err != nil {
-		log.Errorw("reservation-renewal-error", log.Fields{"error": err, "instance": da.instanceId})
+		log.Errorw("reservation-renewal-error", log.Fields{"error": err, "instance": da.instanceID})
 		return false
 	}
 	return true
@@ -136,9 +145,9 @@
 			// Device owned; renew reservation
 			op = "renew"
 			if da.renewReservation(id) {
-				log.Debugw("reservation-renewed", log.Fields{"id": id, "instanceId": da.instanceId})
+				log.Debugw("reservation-renewed", log.Fields{"id": id, "instanceId": da.instanceID})
 			} else {
-				log.Debugw("reservation-not-renewed", log.Fields{"id": id, "instanceId": da.instanceId})
+				log.Debugw("reservation-not-renewed", log.Fields{"id": id, "instanceId": da.instanceID})
 			}
 		} else {
 			// Device not owned or not owned by me; try to seize ownership
@@ -173,7 +182,7 @@
 	return status.Error(codes.NotFound, fmt.Sprintf("id-inexistent-%s", id))
 }
 
-// getAllDeviceIdsOwnedByMe returns all the deviceIds (root device Ids) that is managed by this Core
+// GetAllDeviceIdsOwnedByMe returns all the deviceIds (root device Ids) that is managed by this Core
 func (da *DeviceOwnership) GetAllDeviceIdsOwnedByMe() []string {
 	deviceIds := []string{}
 	da.deviceMapLock.Lock()
@@ -240,7 +249,8 @@
 	}
 	da.deviceMapLock.Lock()
 	defer da.deviceMapLock.Unlock()
-	if o, exist := da.deviceMap[id]; exist { // id is ownership key
+	o, exist := da.deviceMap[id]
+	if exist { // id is ownership key
 		// Need to clean up all deviceToKeyMap entries using this device as key
 		da.deviceToKeyMapLock.Lock()
 		defer da.deviceToKeyMapLock.Unlock()
@@ -257,9 +267,9 @@
 		delete(da.deviceMap, id)
 		log.Debugw("abandoning-device", log.Fields{"Id": id})
 		return nil
-	} else { // id is not ownership key
-		da.deleteDeviceKey(id)
 	}
+	// id is not ownership key
+	da.deleteDeviceKey(id)
 	return nil
 }
 
@@ -269,7 +279,7 @@
 	defer da.deviceMapLock.Unlock()
 	da.deviceToKeyMapLock.Lock()
 	defer da.deviceToKeyMapLock.Unlock()
-	for k, _ := range da.deviceToKeyMap {
+	for k := range da.deviceToKeyMap {
 		delete(da.deviceToKeyMap, k)
 	}
 	for _, val := range da.deviceMap {
@@ -277,25 +287,6 @@
 	}
 }
 
-func (da *DeviceOwnership) getDeviceKey(id string) (string, error) {
-	da.deviceToKeyMapLock.RLock()
-	defer da.deviceToKeyMapLock.RUnlock()
-	if val, exist := da.deviceToKeyMap[id]; exist {
-		return val, nil
-	}
-	return "", status.Error(codes.NotFound, fmt.Sprintf("not-present-%s", id))
-}
-
-func (da *DeviceOwnership) updateDeviceKey(id string, key string) error {
-	da.deviceToKeyMapLock.Lock()
-	defer da.deviceToKeyMapLock.Unlock()
-	if _, exist := da.deviceToKeyMap[id]; exist {
-		return status.Error(codes.AlreadyExists, fmt.Sprintf("already-present-%s", id))
-	}
-	da.deviceToKeyMap[id] = key
-	return nil
-}
-
 func (da *DeviceOwnership) deleteDeviceKey(id string) {
 	da.deviceToKeyMapLock.Lock()
 	defer da.deviceToKeyMapLock.Unlock()
@@ -317,28 +308,27 @@
 	var device *voltha.Device
 	var lDevice *voltha.LogicalDevice
 	// The id can either be a device Id or a logical device id.
-	if dId, ok := id.(*utils.DeviceID); ok {
+	if dID, ok := id.(*utils.DeviceID); ok {
 		// Use cache if present
-		if val, exist := da.deviceToKeyMap[dId.Id]; exist {
-			return val, dId.Id, true, nil
+		if val, exist := da.deviceToKeyMap[dID.ID]; exist {
+			return val, dID.ID, true, nil
 		}
-		if device, _ = da.deviceMgr.GetDevice(dId.Id); device == nil {
-			return "", dId.Id, false, status.Errorf(codes.NotFound, "id-absent-%s", dId)
+		if device, _ = da.deviceMgr.GetDevice(dID.ID); device == nil {
+			return "", dID.ID, false, status.Errorf(codes.NotFound, "id-absent-%s", dID)
 		}
 		if device.Root {
-			return device.Id, dId.Id, false, nil
-		} else {
-			return device.ParentId, dId.Id, false, nil
+			return device.Id, dID.ID, false, nil
 		}
-	} else if ldId, ok := id.(*utils.LogicalDeviceID); ok {
+		return device.ParentId, dID.ID, false, nil
+	} else if ldID, ok := id.(*utils.LogicalDeviceID); ok {
 		// Use cache if present
-		if val, exist := da.deviceToKeyMap[ldId.Id]; exist {
-			return val, ldId.Id, true, nil
+		if val, exist := da.deviceToKeyMap[ldID.ID]; exist {
+			return val, ldID.ID, true, nil
 		}
-		if lDevice, _ = da.logicalDeviceMgr.getLogicalDevice(ldId.Id); lDevice == nil {
-			return "", ldId.Id, false, status.Errorf(codes.NotFound, "id-absent-%s", dId)
+		if lDevice, _ = da.logicalDeviceMgr.getLogicalDevice(ldID.ID); lDevice == nil {
+			return "", ldID.ID, false, status.Errorf(codes.NotFound, "id-absent-%s", dID)
 		}
-		return lDevice.RootDeviceId, ldId.Id, false, nil
+		return lDevice.RootDeviceId, ldID.ID, false, nil
 	}
 	return "", "", false, status.Error(codes.NotFound, fmt.Sprintf("id-%v", id))
 }
diff --git a/rw_core/core/device_state_transitions.go b/rw_core/core/device_state_transitions.go
index a48346a..5188e56 100644
--- a/rw_core/core/device_state_transitions.go
+++ b/rw_core/core/device_state_transitions.go
@@ -13,14 +13,16 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package core
 
 import (
-	"github.com/opencord/voltha-go/rw_core/coreIf"
+	"github.com/opencord/voltha-go/rw_core/coreif"
 	"github.com/opencord/voltha-lib-go/v2/pkg/log"
 	"github.com/opencord/voltha-protos/v2/go/voltha"
 )
 
+// DeviceType mentions type of device like parent, child
 type DeviceType int32
 
 const (
@@ -29,14 +31,17 @@
 	any    DeviceType = 2
 )
 
+// DeviceState has admin, operational and connection status of device
 type DeviceState struct {
 	Admin       voltha.AdminState_AdminState
 	Connection  voltha.ConnectStatus_ConnectStatus
 	Operational voltha.OperStatus_OperStatus
 }
 
+// TransitionHandler function type which takes device as input parameter
 type TransitionHandler func(*voltha.Device) error
 
+// Transition represent transition related attributes
 type Transition struct {
 	deviceType    DeviceType
 	previousState DeviceState
@@ -44,12 +49,14 @@
 	handlers      []TransitionHandler
 }
 
+// TransitionMap represent map of transitions and device manager
 type TransitionMap struct {
 	transitions []Transition
-	dMgr        coreIf.DeviceManager
+	dMgr        coreif.DeviceManager
 }
 
-func NewTransitionMap(dMgr coreIf.DeviceManager) *TransitionMap {
+// NewTransitionMap creates transition map
+func NewTransitionMap(dMgr coreif.DeviceManager) *TransitionMap {
 	var transitionMap TransitionMap
 	transitionMap.dMgr = dMgr
 	transitionMap.transitions = make([]Transition, 0)
@@ -197,6 +204,7 @@
 	return nil, false
 }
 
+// GetTransitionHandler returns transition handler
 func (tMap *TransitionMap) GetTransitionHandler(pDevice *voltha.Device, cDevice *voltha.Device) []TransitionHandler {
 	//1. Get the previous and current set of states
 	pState := getDeviceStates(pDevice)
diff --git a/rw_core/core/device_state_transitions_test.go b/rw_core/core/device_state_transitions_test.go
index 0e7b4b3..fdd58ca 100644
--- a/rw_core/core/device_state_transitions_test.go
+++ b/rw_core/core/device_state_transitions_test.go
@@ -16,17 +16,18 @@
 package core
 
 import (
-	"github.com/opencord/voltha-go/rw_core/coreIf"
+	"reflect"
+	"testing"
+
+	"github.com/opencord/voltha-go/rw_core/coreif"
 	"github.com/opencord/voltha-go/rw_core/mocks"
 	"github.com/opencord/voltha-lib-go/v2/pkg/log"
 	"github.com/opencord/voltha-protos/v2/go/voltha"
 	"github.com/stretchr/testify/assert"
-	"reflect"
-	"testing"
 )
 
 var transitionMap *TransitionMap
-var tdm coreIf.DeviceManager
+var tdm coreif.DeviceManager
 
 type testDeviceManager struct {
 	mocks.DeviceManager
diff --git a/rw_core/core/grpc_nbi_api_handler.go b/rw_core/core/grpc_nbi_api_handler.go
index 725fb3e..7bbf5ee 100755
--- a/rw_core/core/grpc_nbi_api_handler.go
+++ b/rw_core/core/grpc_nbi_api_handler.go
@@ -13,6 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package core
 
 import (
@@ -20,6 +21,9 @@
 	"encoding/hex"
 	"encoding/json"
 	"errors"
+	"io"
+	"sync"
+
 	"github.com/golang/protobuf/ptypes/empty"
 	da "github.com/opencord/voltha-go/common/core/northbound/grpc"
 	"github.com/opencord/voltha-go/rw_core/utils"
@@ -32,19 +36,19 @@
 	"google.golang.org/grpc/codes"
 	"google.golang.org/grpc/metadata"
 	"google.golang.org/grpc/status"
-	"io"
-	"sync"
 )
 
-var errorIdNotFound = status.Error(codes.NotFound, "id-not-found")
+var errorIDNotFound = status.Error(codes.NotFound, "id-not-found")
 
+// Image related constants
 const (
-	IMAGE_DOWNLOAD        = iota
-	CANCEL_IMAGE_DOWNLOAD = iota
-	ACTIVATE_IMAGE        = iota
-	REVERT_IMAGE          = iota
+	ImageDownload       = iota
+	CancelImageDownload = iota
+	ActivateImage       = iota
+	RevertImage         = iota
 )
 
+// APIHandler represent attributes of API handler
 type APIHandler struct {
 	deviceMgr                 *DeviceManager
 	logicalDeviceMgr          *LogicalDeviceManager
@@ -60,6 +64,7 @@
 	core *Core
 }
 
+// NewAPIHandler creates API handler instance
 func NewAPIHandler(core *Core) *APIHandler {
 	handler := &APIHandler{
 		deviceMgr:                 core.deviceMgr,
@@ -147,19 +152,18 @@
 		var ownedByMe bool
 		if ownedByMe, err = handler.core.deviceOwnership.OwnedByMe(id); err != nil {
 			log.Warnw("getting-ownership-failed", log.Fields{"deviceId": id, "error": err})
-			return nil, errorIdNotFound
+			return nil, errorIDNotFound
 		}
 		acquired, err = txn.Acquired(timeout, ownedByMe)
 	} else {
 		acquired, err = txn.Acquired(timeout)
 	}
 	if err == nil && acquired {
-		log.Debugw("transaction-acquired", log.Fields{"transactionId": txn.txnId})
+		log.Debugw("transaction-acquired", log.Fields{"transactionId": txn.txnID})
 		return txn, nil
-	} else {
-		log.Debugw("transaction-not-acquired", log.Fields{"transactionId": txn.txnId, "error": err})
-		return nil, errorTransactionNotAcquired
 	}
+	log.Debugw("transaction-not-acquired", log.Fields{"transactionId": txn.txnID, "error": err})
+	return nil, errorTransactionNotAcquired
 }
 
 // waitForNilResponseOnSuccess is a helper function to wait for a response on channel monitorCh where an nil
@@ -182,6 +186,7 @@
 	}
 }
 
+// UpdateLogLevel dynamically sets the log level of a given package to level
 func (handler *APIHandler) UpdateLogLevel(ctx context.Context, logging *voltha.Logging) (*empty.Empty, error) {
 	log.Debugw("UpdateLogLevel-request", log.Fields{"package": logging.PackageName, "intval": int(logging.Level)})
 
@@ -197,7 +202,8 @@
 	return &empty.Empty{}, nil
 }
 
-func (_ APIHandler) GetLogLevels(ctx context.Context, in *voltha.LoggingComponent) (*voltha.Loggings, error) {
+// GetLogLevels returns log levels of packages
+func (APIHandler) GetLogLevels(ctx context.Context, in *voltha.LoggingComponent) (*voltha.Loggings, error) {
 	logLevels := &voltha.Loggings{}
 
 	// do the per-package log levels
@@ -237,19 +243,21 @@
 	return &voltha.CoreInstance{}, status.Errorf(codes.NotFound, "core-instance-%s", id.Id)
 }
 
+// GetLogicalDevicePort returns logical device port details
 func (handler *APIHandler) GetLogicalDevicePort(ctx context.Context, id *voltha.LogicalPortId) (*voltha.LogicalPort, error) {
 	log.Debugw("GetLogicalDevicePort-request", log.Fields{"id": *id})
 
 	if handler.competeForTransaction() {
-		if txn, err := handler.takeRequestOwnership(ctx, &utils.LogicalDeviceID{Id: id.Id}); err != nil {
+		txn, err := handler.takeRequestOwnership(ctx, &utils.LogicalDeviceID{ID: id.Id})
+		if err != nil {
 			return &voltha.LogicalPort{}, err
-		} else {
-			defer txn.Close()
 		}
+		defer txn.Close()
 	}
 	return handler.logicalDeviceMgr.getLogicalPort(id)
 }
 
+// EnableLogicalDevicePort enables logical device port
 func (handler *APIHandler) EnableLogicalDevicePort(ctx context.Context, id *voltha.LogicalPortId) (*empty.Empty, error) {
 	log.Debugw("EnableLogicalDevicePort-request", log.Fields{"id": id, "test": common.TestModeKeys_api_test.String()})
 	if isTestMode(ctx) {
@@ -257,11 +265,11 @@
 	}
 
 	if handler.competeForTransaction() {
-		if txn, err := handler.takeRequestOwnership(ctx, &utils.LogicalDeviceID{Id: id.Id}); err != nil {
+		txn, err := handler.takeRequestOwnership(ctx, &utils.LogicalDeviceID{ID: id.Id})
+		if err != nil {
 			return &empty.Empty{}, err
-		} else {
-			defer txn.Close()
 		}
+		defer txn.Close()
 	}
 
 	ch := make(chan interface{})
@@ -270,6 +278,7 @@
 	return waitForNilResponseOnSuccess(ctx, ch)
 }
 
+// DisableLogicalDevicePort disables logical device port
 func (handler *APIHandler) DisableLogicalDevicePort(ctx context.Context, id *voltha.LogicalPortId) (*empty.Empty, error) {
 	log.Debugw("DisableLogicalDevicePort-request", log.Fields{"id": id, "test": common.TestModeKeys_api_test.String()})
 	if isTestMode(ctx) {
@@ -277,11 +286,11 @@
 	}
 
 	if handler.competeForTransaction() {
-		if txn, err := handler.takeRequestOwnership(ctx, &utils.LogicalDeviceID{Id: id.Id}); err != nil {
+		txn, err := handler.takeRequestOwnership(ctx, &utils.LogicalDeviceID{ID: id.Id})
+		if err != nil {
 			return &empty.Empty{}, err
-		} else {
-			defer txn.Close()
 		}
+		defer txn.Close()
 	}
 
 	ch := make(chan interface{})
@@ -290,6 +299,7 @@
 	return waitForNilResponseOnSuccess(ctx, ch)
 }
 
+// UpdateLogicalDeviceFlowTable updates logical device flow table
 func (handler *APIHandler) UpdateLogicalDeviceFlowTable(ctx context.Context, flow *openflow_13.FlowTableUpdate) (*empty.Empty, error) {
 	log.Debugw("UpdateLogicalDeviceFlowTable-request", log.Fields{"flow": flow, "test": common.TestModeKeys_api_test.String()})
 	if isTestMode(ctx) {
@@ -297,11 +307,11 @@
 	}
 
 	if handler.competeForTransaction() {
-		if txn, err := handler.takeRequestOwnership(ctx, &utils.LogicalDeviceID{Id: flow.Id}); err != nil {
+		txn, err := handler.takeRequestOwnership(ctx, &utils.LogicalDeviceID{ID: flow.Id})
+		if err != nil {
 			return &empty.Empty{}, err
-		} else {
-			defer txn.Close()
 		}
+		defer txn.Close()
 	}
 
 	ch := make(chan interface{})
@@ -310,6 +320,7 @@
 	return waitForNilResponseOnSuccess(ctx, ch)
 }
 
+// UpdateLogicalDeviceFlowGroupTable updates logical device flow group table
 func (handler *APIHandler) UpdateLogicalDeviceFlowGroupTable(ctx context.Context, flow *openflow_13.FlowGroupTableUpdate) (*empty.Empty, error) {
 	log.Debugw("UpdateLogicalDeviceFlowGroupTable-request", log.Fields{"flow": flow, "test": common.TestModeKeys_api_test.String()})
 	if isTestMode(ctx) {
@@ -317,11 +328,11 @@
 	}
 
 	if handler.competeForTransaction() {
-		if txn, err := handler.takeRequestOwnership(ctx, &utils.LogicalDeviceID{Id: flow.Id}); err != nil {
+		txn, err := handler.takeRequestOwnership(ctx, &utils.LogicalDeviceID{ID: flow.Id})
+		if err != nil {
 			return &empty.Empty{}, err
-		} else {
-			defer txn.Close()
 		}
+		defer txn.Close()
 	}
 
 	ch := make(chan interface{})
@@ -337,6 +348,8 @@
 }
 
 // GetDevice must be implemented in the read-only containers - should it also be implemented here?
+
+// ListDevices retrieves the latest devices from the data model
 func (handler *APIHandler) ListDevices(ctx context.Context, empty *empty.Empty) (*voltha.Devices, error) {
 	log.Debug("ListDevices")
 	return handler.deviceMgr.ListDevices()
@@ -366,26 +379,28 @@
 	return waitForNilResponseOnSuccess(ctx, ch)
 }
 
+// GetLogicalDevice provides a cloned most up to date logical device
 func (handler *APIHandler) GetLogicalDevice(ctx context.Context, id *voltha.ID) (*voltha.LogicalDevice, error) {
 	log.Debugw("GetLogicalDevice-request", log.Fields{"id": id})
 	if handler.competeForTransaction() {
-		if txn, err := handler.takeRequestOwnership(ctx, &utils.LogicalDeviceID{Id: id.Id}); err != nil {
+		txn, err := handler.takeRequestOwnership(ctx, &utils.LogicalDeviceID{ID: id.Id})
+		if err != nil {
 			return &voltha.LogicalDevice{}, err
-		} else {
-			defer txn.Close()
 		}
+		defer txn.Close()
 	}
 	return handler.logicalDeviceMgr.getLogicalDevice(id.Id)
 }
 
+// ListLogicalDevices returns the list of all logical devices
 func (handler *APIHandler) ListLogicalDevices(ctx context.Context, empty *empty.Empty) (*voltha.LogicalDevices, error) {
 	log.Debug("ListLogicalDevices-request")
 	if handler.competeForTransaction() {
-		if txn, err := handler.takeRequestOwnership(ctx, nil); err != nil {
+		txn, err := handler.takeRequestOwnership(ctx, nil)
+		if err != nil {
 			return &voltha.LogicalDevices{}, err
-		} else {
-			defer txn.Close()
 		}
+		defer txn.Close()
 		if handler.isOFControllerRequest(ctx) {
 			//	Since an OF controller is only interested in the set of logical devices managed by thgis Core then return
 			//	only logical devices managed/monitored by this Core.
@@ -401,38 +416,41 @@
 	return handler.adapterMgr.listAdapters(ctx)
 }
 
+// ListLogicalDeviceFlows returns the flows of logical device
 func (handler *APIHandler) ListLogicalDeviceFlows(ctx context.Context, id *voltha.ID) (*openflow_13.Flows, error) {
 	log.Debugw("ListLogicalDeviceFlows", log.Fields{"id": *id})
 	if handler.competeForTransaction() {
-		if txn, err := handler.takeRequestOwnership(ctx, &utils.LogicalDeviceID{Id: id.Id}); err != nil {
+		txn, err := handler.takeRequestOwnership(ctx, &utils.LogicalDeviceID{ID: id.Id})
+		if err != nil {
 			return &openflow_13.Flows{}, err
-		} else {
-			defer txn.Close()
 		}
+		defer txn.Close()
 	}
 	return handler.logicalDeviceMgr.ListLogicalDeviceFlows(ctx, id.Id)
 }
 
+// ListLogicalDeviceFlowGroups returns logical device flow groups
 func (handler *APIHandler) ListLogicalDeviceFlowGroups(ctx context.Context, id *voltha.ID) (*openflow_13.FlowGroups, error) {
 	log.Debugw("ListLogicalDeviceFlowGroups", log.Fields{"id": *id})
 	if handler.competeForTransaction() {
-		if txn, err := handler.takeRequestOwnership(ctx, &utils.LogicalDeviceID{Id: id.Id}); err != nil {
+		txn, err := handler.takeRequestOwnership(ctx, &utils.LogicalDeviceID{ID: id.Id})
+		if err != nil {
 			return &openflow_13.FlowGroups{}, err
-		} else {
-			defer txn.Close()
 		}
+		defer txn.Close()
 	}
 	return handler.logicalDeviceMgr.ListLogicalDeviceFlowGroups(ctx, id.Id)
 }
 
+// ListLogicalDevicePorts returns ports of logical device
 func (handler *APIHandler) ListLogicalDevicePorts(ctx context.Context, id *voltha.ID) (*voltha.LogicalPorts, error) {
 	log.Debugw("ListLogicalDevicePorts", log.Fields{"logicaldeviceid": id})
 	if handler.competeForTransaction() {
-		if txn, err := handler.takeRequestOwnership(ctx, &utils.LogicalDeviceID{Id: id.Id}); err != nil {
+		txn, err := handler.takeRequestOwnership(ctx, &utils.LogicalDeviceID{ID: id.Id})
+		if err != nil {
 			return &voltha.LogicalPorts{}, err
-		} else {
-			defer txn.Close()
 		}
+		defer txn.Close()
 	}
 	return handler.logicalDeviceMgr.ListLogicalDevicePorts(ctx, id.Id)
 }
@@ -450,11 +468,11 @@
 
 	if handler.competeForTransaction() {
 		// There are no device Id present in this function.
-		if txn, err := handler.takeRequestOwnership(ctx, nil); err != nil {
+		txn, err := handler.takeRequestOwnership(ctx, nil)
+		if err != nil {
 			return &voltha.Device{}, err
-		} else {
-			defer txn.Close()
 		}
+		defer txn.Close()
 	}
 
 	ch := make(chan interface{})
@@ -467,7 +485,10 @@
 				return &voltha.Device{}, err
 			}
 			if d, ok := res.(*voltha.Device); ok {
-				handler.core.deviceOwnership.OwnedByMe(&utils.DeviceID{Id: d.Id})
+				_, err := handler.core.deviceOwnership.OwnedByMe(&utils.DeviceID{ID: d.Id})
+				if err != nil {
+					log.Errorw("unable-to-find-core-instance-active-owns-this-device", log.Fields{"error": err})
+				}
 				return d, nil
 			}
 		}
@@ -488,11 +509,11 @@
 	}
 
 	if handler.competeForTransaction() {
-		if txn, err := handler.takeRequestOwnership(ctx, &utils.DeviceID{Id: id.Id}, handler.longRunningRequestTimeout); err != nil {
+		txn, err := handler.takeRequestOwnership(ctx, &utils.DeviceID{ID: id.Id}, handler.longRunningRequestTimeout)
+		if err != nil {
 			return &empty.Empty{}, err
-		} else {
-			defer txn.Close()
 		}
+		defer txn.Close()
 	}
 
 	ch := make(chan interface{})
@@ -509,11 +530,11 @@
 	}
 
 	if handler.competeForTransaction() {
-		if txn, err := handler.takeRequestOwnership(ctx, &utils.DeviceID{Id: id.Id}); err != nil {
+		txn, err := handler.takeRequestOwnership(ctx, &utils.DeviceID{ID: id.Id})
+		if err != nil {
 			return &empty.Empty{}, err
-		} else {
-			defer txn.Close()
 		}
+		defer txn.Close()
 	}
 
 	ch := make(chan interface{})
@@ -530,11 +551,11 @@
 	}
 
 	if handler.competeForTransaction() {
-		if txn, err := handler.takeRequestOwnership(ctx, &utils.DeviceID{Id: id.Id}); err != nil {
+		txn, err := handler.takeRequestOwnership(ctx, &utils.DeviceID{ID: id.Id})
+		if err != nil {
 			return &empty.Empty{}, err
-		} else {
-			defer txn.Close()
 		}
+		defer txn.Close()
 	}
 
 	ch := make(chan interface{})
@@ -551,17 +572,17 @@
 	}
 
 	if handler.competeForTransaction() {
-		if txn, err := handler.takeRequestOwnership(ctx, &utils.DeviceID{Id: id.Id}); err != nil {
+		txn, err := handler.takeRequestOwnership(ctx, &utils.DeviceID{ID: id.Id})
+		if err != nil {
 			if err == errorTransactionNotAcquired {
-				if ownedByMe, err := handler.core.deviceOwnership.OwnedByMe(&utils.DeviceID{Id: id.Id}); !ownedByMe && err == nil {
+				if ownedByMe, err := handler.core.deviceOwnership.OwnedByMe(&utils.DeviceID{ID: id.Id}); !ownedByMe && err == nil {
 					// Remove the device in memory
 					handler.deviceMgr.stopManagingDevice(id.Id)
 				}
 			}
 			return &empty.Empty{}, err
-		} else {
-			defer txn.Close()
 		}
+		defer txn.Close()
 	}
 
 	ch := make(chan interface{})
@@ -574,11 +595,11 @@
 func (handler *APIHandler) ListDevicePorts(ctx context.Context, id *voltha.ID) (*voltha.Ports, error) {
 	log.Debugw("listdeviceports-request", log.Fields{"id": id})
 	if handler.competeForTransaction() {
-		if txn, err := handler.takeRequestOwnership(ctx, &utils.DeviceID{Id: id.Id}); err != nil {
+		txn, err := handler.takeRequestOwnership(ctx, &utils.DeviceID{ID: id.Id})
+		if err != nil {
 			return &voltha.Ports{}, err
-		} else {
-			defer txn.Close()
 		}
+		defer txn.Close()
 	}
 
 	device, err := handler.deviceMgr.GetDevice(id.Id)
@@ -586,9 +607,7 @@
 		return &voltha.Ports{}, err
 	}
 	ports := &voltha.Ports{}
-	for _, port := range device.Ports {
-		ports.Items = append(ports.Items, port)
-	}
+	ports.Items = append(ports.Items, device.Ports...)
 	return ports, nil
 }
 
@@ -596,11 +615,11 @@
 func (handler *APIHandler) ListDeviceFlows(ctx context.Context, id *voltha.ID) (*openflow_13.Flows, error) {
 	log.Debugw("listdeviceflows-request", log.Fields{"id": id})
 	if handler.competeForTransaction() {
-		if txn, err := handler.takeRequestOwnership(ctx, &utils.DeviceID{Id: id.Id}); err != nil {
+		txn, err := handler.takeRequestOwnership(ctx, &utils.DeviceID{ID: id.Id})
+		if err != nil {
 			return &openflow_13.Flows{}, err
-		} else {
-			defer txn.Close()
 		}
+		defer txn.Close()
 	}
 
 	device, err := handler.deviceMgr.GetDevice(id.Id)
@@ -608,9 +627,7 @@
 		return &openflow_13.Flows{}, err
 	}
 	flows := &openflow_13.Flows{}
-	for _, flow := range device.Flows.Items {
-		flows.Items = append(flows.Items, flow)
-	}
+	flows.Items = append(flows.Items, device.Flows.Items...)
 	return flows, nil
 }
 
@@ -685,11 +702,11 @@
 	}
 
 	if handler.competeForTransaction() {
-		if txn, err := handler.takeRequestOwnership(ctx, &utils.DeviceID{Id: img.Id}); err != nil {
+		txn, err := handler.takeRequestOwnership(ctx, &utils.DeviceID{ID: img.Id})
+		if err != nil {
 			return &common.OperationResp{}, err
-		} else {
-			defer txn.Close()
 		}
+		defer txn.Close()
 	}
 
 	failedresponse := &common.OperationResp{Code: voltha.OperationResp_OPERATION_FAILURE}
@@ -697,13 +714,13 @@
 	ch := make(chan interface{})
 	defer close(ch)
 	switch requestType {
-	case IMAGE_DOWNLOAD:
+	case ImageDownload:
 		go handler.deviceMgr.downloadImage(ctx, img, ch)
-	case CANCEL_IMAGE_DOWNLOAD:
+	case CancelImageDownload:
 		go handler.deviceMgr.cancelImageDownload(ctx, img, ch)
-	case ACTIVATE_IMAGE:
+	case ActivateImage:
 		go handler.deviceMgr.activateImage(ctx, img, ch)
-	case REVERT_IMAGE:
+	case RevertImage:
 		go handler.deviceMgr.revertImage(ctx, img, ch)
 	default:
 		log.Warn("invalid-request-type", log.Fields{"requestType": requestType})
@@ -727,6 +744,7 @@
 	}
 }
 
+// DownloadImage execute an image download request
 func (handler *APIHandler) DownloadImage(ctx context.Context, img *voltha.ImageDownload) (*common.OperationResp, error) {
 	log.Debugw("DownloadImage-request", log.Fields{"img": *img})
 	if isTestMode(ctx) {
@@ -734,18 +752,20 @@
 		return resp, nil
 	}
 
-	return handler.processImageRequest(ctx, img, IMAGE_DOWNLOAD)
+	return handler.processImageRequest(ctx, img, ImageDownload)
 }
 
+// CancelImageDownload cancels image download request
 func (handler *APIHandler) CancelImageDownload(ctx context.Context, img *voltha.ImageDownload) (*common.OperationResp, error) {
 	log.Debugw("cancelImageDownload-request", log.Fields{"img": *img})
 	if isTestMode(ctx) {
 		resp := &common.OperationResp{Code: common.OperationResp_OPERATION_SUCCESS}
 		return resp, nil
 	}
-	return handler.processImageRequest(ctx, img, CANCEL_IMAGE_DOWNLOAD)
+	return handler.processImageRequest(ctx, img, CancelImageDownload)
 }
 
+// ActivateImageUpdate activates image update request
 func (handler *APIHandler) ActivateImageUpdate(ctx context.Context, img *voltha.ImageDownload) (*common.OperationResp, error) {
 	log.Debugw("activateImageUpdate-request", log.Fields{"img": *img})
 	if isTestMode(ctx) {
@@ -753,9 +773,10 @@
 		return resp, nil
 	}
 
-	return handler.processImageRequest(ctx, img, ACTIVATE_IMAGE)
+	return handler.processImageRequest(ctx, img, ActivateImage)
 }
 
+// RevertImageUpdate reverts image update
 func (handler *APIHandler) RevertImageUpdate(ctx context.Context, img *voltha.ImageDownload) (*common.OperationResp, error) {
 	log.Debugw("revertImageUpdate-request", log.Fields{"img": *img})
 	if isTestMode(ctx) {
@@ -763,9 +784,10 @@
 		return resp, nil
 	}
 
-	return handler.processImageRequest(ctx, img, REVERT_IMAGE)
+	return handler.processImageRequest(ctx, img, RevertImage)
 }
 
+// GetImageDownloadStatus returns status of image download
 func (handler *APIHandler) GetImageDownloadStatus(ctx context.Context, img *voltha.ImageDownload) (*voltha.ImageDownload, error) {
 	log.Debugw("getImageDownloadStatus-request", log.Fields{"img": *img})
 	if isTestMode(ctx) {
@@ -776,11 +798,11 @@
 	failedresponse := &voltha.ImageDownload{DownloadState: voltha.ImageDownload_DOWNLOAD_UNKNOWN}
 
 	if handler.competeForTransaction() {
-		if txn, err := handler.takeRequestOwnership(ctx, &utils.DeviceID{Id: img.Id}); err != nil {
+		txn, err := handler.takeRequestOwnership(ctx, &utils.DeviceID{ID: img.Id})
+		if err != nil {
 			return failedresponse, err
-		} else {
-			defer txn.Close()
 		}
+		defer txn.Close()
 	}
 
 	ch := make(chan interface{})
@@ -805,6 +827,7 @@
 	}
 }
 
+// GetImageDownload returns image download
 func (handler *APIHandler) GetImageDownload(ctx context.Context, img *voltha.ImageDownload) (*voltha.ImageDownload, error) {
 	log.Debugw("GetImageDownload-request", log.Fields{"img": *img})
 	if isTestMode(ctx) {
@@ -812,13 +835,14 @@
 		return resp, nil
 	}
 
-	if download, err := handler.deviceMgr.getImageDownload(ctx, img); err != nil {
+	download, err := handler.deviceMgr.getImageDownload(ctx, img)
+	if err != nil {
 		return &voltha.ImageDownload{DownloadState: voltha.ImageDownload_DOWNLOAD_UNKNOWN}, err
-	} else {
-		return download, nil
 	}
+	return download, nil
 }
 
+// ListImageDownloads returns image downloads
 func (handler *APIHandler) ListImageDownloads(ctx context.Context, id *voltha.ID) (*voltha.ImageDownloads, error) {
 	log.Debugw("ListImageDownloads-request", log.Fields{"deviceId": id.Id})
 	if isTestMode(ctx) {
@@ -826,16 +850,16 @@
 		return resp, nil
 	}
 
-	if downloads, err := handler.deviceMgr.listImageDownloads(ctx, id.Id); err != nil {
+	downloads, err := handler.deviceMgr.listImageDownloads(ctx, id.Id)
+	if err != nil {
 		failedResp := &voltha.ImageDownloads{
 			Items: []*voltha.ImageDownload{
 				{DownloadState: voltha.ImageDownload_DOWNLOAD_UNKNOWN},
 			},
 		}
 		return failedResp, err
-	} else {
-		return downloads, nil
 	}
+	return downloads, nil
 }
 
 // GetImages returns all images for a specific device entry
@@ -848,17 +872,18 @@
 	return device.GetImages(), nil
 }
 
+// UpdateDevicePmConfigs updates the PM configs
 func (handler *APIHandler) UpdateDevicePmConfigs(ctx context.Context, configs *voltha.PmConfigs) (*empty.Empty, error) {
 	log.Debugw("UpdateDevicePmConfigs-request", log.Fields{"configs": *configs})
 	if isTestMode(ctx) {
 		return &empty.Empty{}, nil
 	}
 	if handler.competeForTransaction() {
-		if txn, err := handler.takeRequestOwnership(ctx, &utils.DeviceID{Id: configs.Id}); err != nil {
+		txn, err := handler.takeRequestOwnership(ctx, &utils.DeviceID{ID: configs.Id})
+		if err != nil {
 			return &empty.Empty{}, err
-		} else {
-			defer txn.Close()
 		}
+		defer txn.Close()
 	}
 
 	ch := make(chan interface{})
@@ -867,18 +892,20 @@
 	return waitForNilResponseOnSuccess(ctx, ch)
 }
 
+// ListDevicePmConfigs returns pm configs of device
 func (handler *APIHandler) ListDevicePmConfigs(ctx context.Context, id *voltha.ID) (*voltha.PmConfigs, error) {
 	log.Debugw("ListDevicePmConfigs-request", log.Fields{"deviceId": *id})
 	if handler.competeForTransaction() {
-		if txn, err := handler.takeRequestOwnership(ctx, &utils.LogicalDeviceID{Id: id.Id}); err != nil {
+		txn, err := handler.takeRequestOwnership(ctx, &utils.LogicalDeviceID{ID: id.Id})
+		if err != nil {
 			return &voltha.PmConfigs{}, err
-		} else {
-			defer txn.Close()
 		}
+		defer txn.Close()
 	}
 	return handler.deviceMgr.listPmConfigs(ctx, id.Id)
 }
 
+// CreateAlarmFilter creates alarm filter
 func (handler *APIHandler) CreateAlarmFilter(ctx context.Context, filter *voltha.AlarmFilter) (*voltha.AlarmFilter, error) {
 	log.Debugw("CreateAlarmFilter-request", log.Fields{"filter": *filter})
 	if isTestMode(ctx) {
@@ -888,6 +915,7 @@
 	return &voltha.AlarmFilter{}, errors.New("UnImplemented")
 }
 
+// UpdateAlarmFilter updates alarm filter
 func (handler *APIHandler) UpdateAlarmFilter(ctx context.Context, filter *voltha.AlarmFilter) (*voltha.AlarmFilter, error) {
 	log.Debugw("UpdateAlarmFilter-request", log.Fields{"filter": *filter})
 	if isTestMode(ctx) {
@@ -897,6 +925,7 @@
 	return &voltha.AlarmFilter{}, errors.New("UnImplemented")
 }
 
+// DeleteAlarmFilter deletes alarm filter
 func (handler *APIHandler) DeleteAlarmFilter(ctx context.Context, id *voltha.ID) (*empty.Empty, error) {
 	log.Debugw("DeleteAlarmFilter-request", log.Fields{"id": *id})
 	if isTestMode(ctx) {
@@ -905,16 +934,19 @@
 	return &empty.Empty{}, errors.New("UnImplemented")
 }
 
+// ListAlarmFilters returns alarm filters
 func (handler *APIHandler) ListAlarmFilters(ctx context.Context, empty *empty.Empty) (*voltha.AlarmFilters, error) {
 	log.Debug("ListAlarmFilters")
 	return &voltha.AlarmFilters{}, errors.New("UnImplemented")
 }
 
+// GetAlarmFilter returns alarm filter
 func (handler *APIHandler) GetAlarmFilter(ctx context.Context, id *voltha.ID) (*voltha.AlarmFilter, error) {
 	log.Debug("GetAlarmFilter")
 	return &voltha.AlarmFilter{}, errors.New("UnImplemented")
 }
 
+// SelfTest executes self test
 func (handler *APIHandler) SelfTest(ctx context.Context, id *voltha.ID) (*voltha.SelfTestResponse, error) {
 	log.Debugw("SelfTest-request", log.Fields{"id": id})
 	if isTestMode(ctx) {
@@ -929,12 +961,13 @@
 	//TODO: Update this logic once the OF Controller (OFAgent in this case) can include a transaction Id in its
 	// request.  For performance reason we can let both Cores in a Core-Pair forward the Packet to the adapters and
 	// let once of the shim layer (kafka proxy or adapter request handler filters out the duplicate packet)
-	if ownedByMe, err := handler.core.deviceOwnership.OwnedByMe(&utils.LogicalDeviceID{Id: packet.Id}); ownedByMe && err == nil {
+	if ownedByMe, err := handler.core.deviceOwnership.OwnedByMe(&utils.LogicalDeviceID{ID: packet.Id}); ownedByMe && err == nil {
 		agent := handler.logicalDeviceMgr.getLogicalDeviceAgent(packet.Id)
 		agent.packetOut(packet.PacketOut)
 	}
 }
 
+// StreamPacketsOut sends packets to adapter
 func (handler *APIHandler) StreamPacketsOut(packets voltha.VolthaService_StreamPacketsOutServer) error {
 	log.Debugw("StreamPacketsOut-request", log.Fields{"packets": packets})
 loop:
@@ -965,9 +998,9 @@
 	return nil
 }
 
-func (handler *APIHandler) sendPacketIn(deviceId string, transationId string, packet *openflow_13.OfpPacketIn) {
+func (handler *APIHandler) sendPacketIn(deviceID string, transationID string, packet *openflow_13.OfpPacketIn) {
 	// TODO: Augment the OF PacketIn to include the transactionId
-	packetIn := openflow_13.PacketIn{Id: deviceId, PacketIn: packet}
+	packetIn := openflow_13.PacketIn{Id: deviceID, PacketIn: packet}
 	log.Debugw("sendPacketIn", log.Fields{"packetIn": packetIn})
 	handler.packetInQueue <- packetIn
 }
@@ -1010,11 +1043,15 @@
 	return nil
 }
 
+// ReceivePacketsIn receives packets from adapter
 func (handler *APIHandler) ReceivePacketsIn(empty *empty.Empty, packetsIn voltha.VolthaService_ReceivePacketsInServer) error {
 	var streamingTracker = handler.getStreamingTracker("ReceivePacketsIn", handler.packetInQueueDone)
 	log.Debugw("ReceivePacketsIn-request", log.Fields{"packetsIn": packetsIn})
 
-	handler.flushFailedPackets(streamingTracker)
+	err := handler.flushFailedPackets(streamingTracker)
+	if err != nil {
+		log.Errorw("unable-to-flush-failed-packets", log.Fields{"error": err})
+	}
 
 loop:
 	for {
@@ -1043,20 +1080,24 @@
 	return nil
 }
 
-func (handler *APIHandler) sendChangeEvent(deviceId string, portStatus *openflow_13.OfpPortStatus) {
+func (handler *APIHandler) sendChangeEvent(deviceID string, portStatus *openflow_13.OfpPortStatus) {
 	// TODO: validate the type of portStatus parameter
 	//if _, ok := portStatus.(*openflow_13.OfpPortStatus); ok {
 	//}
-	event := openflow_13.ChangeEvent{Id: deviceId, Event: &openflow_13.ChangeEvent_PortStatus{PortStatus: portStatus}}
+	event := openflow_13.ChangeEvent{Id: deviceID, Event: &openflow_13.ChangeEvent_PortStatus{PortStatus: portStatus}}
 	log.Debugw("sendChangeEvent", log.Fields{"event": event})
 	handler.changeEventQueue <- event
 }
 
+// ReceiveChangeEvents receives change in events
 func (handler *APIHandler) ReceiveChangeEvents(empty *empty.Empty, changeEvents voltha.VolthaService_ReceiveChangeEventsServer) error {
 	var streamingTracker = handler.getStreamingTracker("ReceiveChangeEvents", handler.changeEventQueueDone)
 	log.Debugw("ReceiveChangeEvents-request", log.Fields{"changeEvents": changeEvents})
 
-	handler.flushFailedPackets(streamingTracker)
+	err := handler.flushFailedPackets(streamingTracker)
+	if err != nil {
+		log.Errorw("unable-to-flush-failed-packets", log.Fields{"error": err})
+	}
 
 loop:
 	for {
@@ -1083,6 +1124,7 @@
 	return nil
 }
 
+// Subscribe subscribing request of ofagent
 func (handler *APIHandler) Subscribe(
 	ctx context.Context,
 	ofAgent *voltha.OfAgentSubscriber,
@@ -1091,37 +1133,39 @@
 	return &voltha.OfAgentSubscriber{OfagentId: ofAgent.OfagentId, VolthaId: ofAgent.VolthaId}, nil
 }
 
-//@TODO useless stub, what should this actually do?
+// GetAlarmDeviceData @TODO useless stub, what should this actually do?
 func (handler *APIHandler) GetAlarmDeviceData(ctx context.Context, in *common.ID) (*omci.AlarmDeviceData, error) {
 	log.Debug("GetAlarmDeviceData-stub")
 	return &omci.AlarmDeviceData{}, errors.New("UnImplemented")
 }
 
+// ListLogicalDeviceMeters returns logical device meters
 func (handler *APIHandler) ListLogicalDeviceMeters(ctx context.Context, id *voltha.ID) (*openflow_13.Meters, error) {
 
 	log.Debugw("ListLogicalDeviceMeters", log.Fields{"id": *id})
 	if handler.competeForTransaction() {
-		if txn, err := handler.takeRequestOwnership(ctx, &utils.LogicalDeviceID{Id: id.Id}); err != nil {
+		txn, err := handler.takeRequestOwnership(ctx, &utils.LogicalDeviceID{ID: id.Id})
+		if err != nil {
 			return &openflow_13.Meters{}, err // TODO: Return empty meter entry
-		} else {
-			defer txn.Close()
 		}
+		defer txn.Close()
 	}
 	return handler.logicalDeviceMgr.ListLogicalDeviceMeters(ctx, id.Id)
 }
 
-//@TODO useless stub, what should this actually do?
+// GetMeterStatsOfLogicalDevice @TODO useless stub, what should this actually do?
 func (handler *APIHandler) GetMeterStatsOfLogicalDevice(ctx context.Context, in *common.ID) (*openflow_13.MeterStatsReply, error) {
 	log.Debug("GetMeterStatsOfLogicalDevice")
 	return &openflow_13.MeterStatsReply{}, errors.New("UnImplemented")
 }
 
-//@TODO useless stub, what should this actually do?
+// GetMibDeviceData @TODO useless stub, what should this actually do?
 func (handler *APIHandler) GetMibDeviceData(ctx context.Context, in *common.ID) (*omci.MibDeviceData, error) {
 	log.Debug("GetMibDeviceData")
 	return &omci.MibDeviceData{}, errors.New("UnImplemented")
 }
 
+// SimulateAlarm sends simulate alarm request
 func (handler *APIHandler) SimulateAlarm(
 	ctx context.Context,
 	in *voltha.SimulateAlarmRequest,
@@ -1133,12 +1177,12 @@
 	}
 
 	if handler.competeForTransaction() {
-		if txn, err := handler.takeRequestOwnership(ctx, &utils.DeviceID{Id: in.Id}, handler.longRunningRequestTimeout); err != nil {
+		txn, err := handler.takeRequestOwnership(ctx, &utils.DeviceID{ID: in.Id}, handler.longRunningRequestTimeout)
+		if err != nil {
 			failedresponse := &common.OperationResp{Code: voltha.OperationResp_OPERATION_FAILURE}
 			return failedresponse, err
-		} else {
-			defer txn.Close()
 		}
+		defer txn.Close()
 	}
 
 	ch := make(chan interface{})
@@ -1147,7 +1191,7 @@
 	return successResp, nil
 }
 
-// This function sends meter mod request to logical device manager and waits for response
+// UpdateLogicalDeviceMeterTable - This function sends meter mod request to logical device manager and waits for response
 func (handler *APIHandler) UpdateLogicalDeviceMeterTable(ctx context.Context, meter *openflow_13.MeterModUpdate) (*empty.Empty, error) {
 	log.Debugw("UpdateLogicalDeviceMeterTable-request",
 		log.Fields{"meter": meter, "test": common.TestModeKeys_api_test.String()})
@@ -1156,11 +1200,11 @@
 	}
 
 	if handler.competeForTransaction() {
-		if txn, err := handler.takeRequestOwnership(ctx, &utils.LogicalDeviceID{Id: meter.Id}); err != nil {
+		txn, err := handler.takeRequestOwnership(ctx, &utils.LogicalDeviceID{ID: meter.Id})
+		if err != nil {
 			return &empty.Empty{}, err
-		} else {
-			defer txn.Close()
 		}
+		defer txn.Close()
 	}
 
 	ch := make(chan interface{})
@@ -1169,10 +1213,12 @@
 	return waitForNilResponseOnSuccess(ctx, ch)
 }
 
+// GetMembership returns membership
 func (handler *APIHandler) GetMembership(context.Context, *empty.Empty) (*voltha.Membership, error) {
 	return &voltha.Membership{}, errors.New("UnImplemented")
 }
 
+// UpdateMembership updates membership
 func (handler *APIHandler) UpdateMembership(context.Context, *voltha.Membership) (*empty.Empty, error) {
 	return &empty.Empty{}, errors.New("UnImplemented")
 }
diff --git a/rw_core/core/id.go b/rw_core/core/id.go
index 369b4f1..399bf1d 100644
--- a/rw_core/core/id.go
+++ b/rw_core/core/id.go
@@ -13,6 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package core
 
 import (
@@ -32,36 +33,37 @@
 	return hex.EncodeToString(bytes), nil
 }
 
-// CreateDeviceId produces a device ID. DeviceId is 16 hex long - lower 12 hex is the device id.
+// CreateDeviceID produces a device ID. DeviceId is 16 hex long - lower 12 hex is the device id.
 // TODO:  A cluster unique ID may be required
-func CreateDeviceId() string {
+func CreateDeviceID() string {
 	val, _ := randomHex(12)
 	return val
 }
 
-// CreateLogicalDeviceId is not used for now as the logical device ID is derived from the
+// CreateLogicalDeviceID is not used for now as the logical device ID is derived from the
 // OLT MAC address
-func CreateLogicalDeviceId() string {
+func CreateLogicalDeviceID() string {
 	// logical device id is 16 hex long - lower 12 hex is the logical device id.  For now just generate the 12 hex
 	val, _ := randomHex(12)
 	return val
 }
 
-// CreateLogicalPortId produces a random port ID for a logical device.
-func CreateLogicalPortId() uint32 {
+// CreateLogicalPortID produces a random port ID for a logical device.
+func CreateLogicalPortID() uint32 {
 	//	A logical port is a uint32
 	return m.Uint32()
 }
 
-func CreateDataPathId(idInHexString string) (uint64, error) {
+// CreateDataPathID creates uint64 pathid from string pathid
+func CreateDataPathID(idInHexString string) (uint64, error) {
 	if idInHexString == "" {
 		return 0, errors.New("id-empty")
 	}
 	// First prepend 0x to the string
-	newId := fmt.Sprintf("0x%s", idInHexString)
-	if d, err := strconv.ParseUint(newId, 0, 64); err != nil {
+	newID := fmt.Sprintf("0x%s", idInHexString)
+	d, err := strconv.ParseUint(newID, 0, 64)
+	if err != nil {
 		return 0, err
-	} else {
-		return d, nil
 	}
+	return d, nil
 }
diff --git a/rw_core/core/logical_device_agent.go b/rw_core/core/logical_device_agent.go
index 3dbc2df..ca07454 100644
--- a/rw_core/core/logical_device_agent.go
+++ b/rw_core/core/logical_device_agent.go
@@ -13,6 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package core
 
 import (
@@ -20,9 +21,13 @@
 	"encoding/hex"
 	"errors"
 	"fmt"
+	"reflect"
+	"sync"
+	"time"
+
 	"github.com/gogo/protobuf/proto"
 	"github.com/opencord/voltha-go/db/model"
-	fd "github.com/opencord/voltha-go/rw_core/flow_decomposition"
+	fd "github.com/opencord/voltha-go/rw_core/flowdecomposition"
 	"github.com/opencord/voltha-go/rw_core/graph"
 	coreutils "github.com/opencord/voltha-go/rw_core/utils"
 	fu "github.com/opencord/voltha-lib-go/v2/pkg/flows"
@@ -32,14 +37,12 @@
 	"github.com/opencord/voltha-protos/v2/go/voltha"
 	"google.golang.org/grpc/codes"
 	"google.golang.org/grpc/status"
-	"reflect"
-	"sync"
-	"time"
 )
 
+// LogicalDeviceAgent represent attributes of logical device agent
 type LogicalDeviceAgent struct {
-	logicalDeviceId    string
-	rootDeviceId       string
+	logicalDeviceID    string
+	rootDeviceID       string
 	deviceMgr          *DeviceManager
 	ldeviceMgr         *LogicalDeviceManager
 	clusterDataProxy   *model.Proxy
@@ -59,13 +62,13 @@
 	defaultTimeout     int64
 }
 
-func newLogicalDeviceAgent(id string, deviceId string, ldeviceMgr *LogicalDeviceManager,
+func newLogicalDeviceAgent(id string, deviceID string, ldeviceMgr *LogicalDeviceManager,
 	deviceMgr *DeviceManager,
 	cdProxy *model.Proxy, timeout int64) *LogicalDeviceAgent {
 	var agent LogicalDeviceAgent
 	agent.exitChannel = make(chan int, 1)
-	agent.logicalDeviceId = id
-	agent.rootDeviceId = deviceId
+	agent.logicalDeviceID = id
+	agent.rootDeviceID = deviceID
 	agent.deviceMgr = deviceMgr
 	agent.clusterDataProxy = cdProxy
 	agent.ldeviceMgr = ldeviceMgr
@@ -82,21 +85,21 @@
 
 // start creates the logical device and add it to the data model
 func (agent *LogicalDeviceAgent) start(ctx context.Context, loadFromdB bool) error {
-	log.Infow("starting-logical_device-agent", log.Fields{"logicaldeviceId": agent.logicalDeviceId, "loadFromdB": loadFromdB})
+	log.Infow("starting-logical_device-agent", log.Fields{"logicaldeviceId": agent.logicalDeviceID, "loadFromdB": loadFromdB})
 	var ld *voltha.LogicalDevice
 	if !loadFromdB {
 		//Build the logical device based on information retrieved from the device adapter
 		var switchCap *ic.SwitchCapability
 		var err error
-		if switchCap, err = agent.deviceMgr.getSwitchCapability(ctx, agent.rootDeviceId); err != nil {
+		if switchCap, err = agent.deviceMgr.getSwitchCapability(ctx, agent.rootDeviceID); err != nil {
 			log.Errorw("error-creating-logical-device", log.Fields{"error": err})
 			return err
 		}
-		ld = &voltha.LogicalDevice{Id: agent.logicalDeviceId, RootDeviceId: agent.rootDeviceId}
+		ld = &voltha.LogicalDevice{Id: agent.logicalDeviceID, RootDeviceId: agent.rootDeviceID}
 
 		// Create the datapath ID (uint64) using the logical device ID (based on the MAC Address)
 		var datapathID uint64
-		if datapathID, err = CreateDataPathId(agent.logicalDeviceId); err != nil {
+		if datapathID, err = CreateDataPathID(agent.logicalDeviceID); err != nil {
 			log.Errorw("error-creating-datapath-id", log.Fields{"error": err})
 			return err
 		}
@@ -110,26 +113,31 @@
 		agent.lockLogicalDevice.Lock()
 		// Save the logical device
 		if added := agent.clusterDataProxy.AddWithID(ctx, "/logical_devices", ld.Id, ld, ""); added == nil {
-			log.Errorw("failed-to-add-logical-device", log.Fields{"logicaldeviceId": agent.logicalDeviceId})
+			log.Errorw("failed-to-add-logical-device", log.Fields{"logicaldeviceId": agent.logicalDeviceID})
 		} else {
-			log.Debugw("logicaldevice-created", log.Fields{"logicaldeviceId": agent.logicalDeviceId})
+			log.Debugw("logicaldevice-created", log.Fields{"logicaldeviceId": agent.logicalDeviceID})
 		}
 		agent.lockLogicalDevice.Unlock()
 
 		// TODO:  Set the logical ports in a separate call once the port update issue is fixed.
-		go agent.setupLogicalPorts(ctx)
+		go func() {
+			err := agent.setupLogicalPorts(ctx)
+			if err != nil {
+				log.Errorw("unable-to-setup-logical-ports", log.Fields{"error": err})
+			}
+		}()
 
 	} else {
 		//	load from dB - the logical may not exist at this time.  On error, just return and the calling function
 		// will destroy this agent.
 		var err error
 		if ld, err = agent.GetLogicalDevice(); err != nil {
-			log.Warnw("failed-to-load-logical-device", log.Fields{"logicaldeviceId": agent.logicalDeviceId})
+			log.Warnw("failed-to-load-logical-device", log.Fields{"logicaldeviceId": agent.logicalDeviceID})
 			return err
 		}
 
 		// Update the root device Id
-		agent.rootDeviceId = ld.RootDeviceId
+		agent.rootDeviceID = ld.RootDeviceId
 
 		// Setup the local list of logical ports
 		agent.addLogicalPortsToMap(ld.Ports)
@@ -140,26 +148,26 @@
 
 	agent.flowProxy = agent.clusterDataProxy.CreateProxy(
 		ctx,
-		fmt.Sprintf("/logical_devices/%s/flows", agent.logicalDeviceId),
+		fmt.Sprintf("/logical_devices/%s/flows", agent.logicalDeviceID),
 		false)
 	agent.meterProxy = agent.clusterDataProxy.CreateProxy(
 		ctx,
-		fmt.Sprintf("/logical_devices/%s/meters", agent.logicalDeviceId),
+		fmt.Sprintf("/logical_devices/%s/meters", agent.logicalDeviceID),
 		false)
 	agent.groupProxy = agent.clusterDataProxy.CreateProxy(
 		ctx,
-		fmt.Sprintf("/logical_devices/%s/flow_groups", agent.logicalDeviceId),
+		fmt.Sprintf("/logical_devices/%s/flow_groups", agent.logicalDeviceID),
 		false)
 	agent.ldProxy = agent.clusterDataProxy.CreateProxy(
 		ctx,
-		fmt.Sprintf("/logical_devices/%s", agent.logicalDeviceId),
+		fmt.Sprintf("/logical_devices/%s", agent.logicalDeviceID),
 		false)
 
 	// TODO:  Use a port proxy once the POST_ADD is fixed
 	if agent.ldProxy != nil {
 		agent.ldProxy.RegisterCallback(model.POST_UPDATE, agent.portUpdated)
 	} else {
-		log.Errorw("logical-device-proxy-null", log.Fields{"logicalDeviceId": agent.logicalDeviceId})
+		log.Errorw("logical-device-proxy-null", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
 		return status.Error(codes.Internal, "logical-device-proxy-null")
 	}
 
@@ -177,10 +185,10 @@
 	defer agent.lockLogicalDevice.Unlock()
 
 	//Remove the logical device from the model
-	if removed := agent.clusterDataProxy.Remove(ctx, "/logical_devices/"+agent.logicalDeviceId, ""); removed == nil {
-		log.Errorw("failed-to-remove-logical-device", log.Fields{"logicaldeviceId": agent.logicalDeviceId})
+	if removed := agent.clusterDataProxy.Remove(ctx, "/logical_devices/"+agent.logicalDeviceID, ""); removed == nil {
+		log.Errorw("failed-to-remove-logical-device", log.Fields{"logicaldeviceId": agent.logicalDeviceID})
 	} else {
-		log.Debugw("logicaldevice-removed", log.Fields{"logicaldeviceId": agent.logicalDeviceId})
+		log.Debugw("logicaldevice-removed", log.Fields{"logicaldeviceId": agent.logicalDeviceID})
 	}
 	agent.exitChannel <- 1
 	log.Info("logical_device-agent-stopped")
@@ -191,30 +199,32 @@
 	log.Debug("GetLogicalDevice")
 	agent.lockLogicalDevice.RLock()
 	defer agent.lockLogicalDevice.RUnlock()
-	logicalDevice := agent.clusterDataProxy.Get(context.Background(), "/logical_devices/"+agent.logicalDeviceId, 0, false, "")
+	logicalDevice := agent.clusterDataProxy.Get(context.Background(), "/logical_devices/"+agent.logicalDeviceID, 0, false, "")
 	if lDevice, ok := logicalDevice.(*voltha.LogicalDevice); ok {
 		return lDevice, nil
 	}
-	return nil, status.Errorf(codes.NotFound, "logical_device-%s", agent.logicalDeviceId)
+	return nil, status.Errorf(codes.NotFound, "logical_device-%s", agent.logicalDeviceID)
 }
 
+// ListLogicalDeviceFlows returns logical device flows
 func (agent *LogicalDeviceAgent) ListLogicalDeviceFlows() (*ofp.Flows, error) {
 	log.Debug("ListLogicalDeviceFlows")
 	agent.lockLogicalDevice.RLock()
 	defer agent.lockLogicalDevice.RUnlock()
-	logicalDevice := agent.clusterDataProxy.Get(context.Background(), "/logical_devices/"+agent.logicalDeviceId, 0, false, "")
+	logicalDevice := agent.clusterDataProxy.Get(context.Background(), "/logical_devices/"+agent.logicalDeviceID, 0, false, "")
 	if lDevice, ok := logicalDevice.(*voltha.LogicalDevice); ok {
 		cFlows := (proto.Clone(lDevice.Flows)).(*ofp.Flows)
 		return cFlows, nil
 	}
-	return nil, status.Errorf(codes.NotFound, "logical_device-%s", agent.logicalDeviceId)
+	return nil, status.Errorf(codes.NotFound, "logical_device-%s", agent.logicalDeviceID)
 }
 
+// ListLogicalDeviceMeters returns logical device meters
 func (agent *LogicalDeviceAgent) ListLogicalDeviceMeters() (*ofp.Meters, error) {
 	log.Debug("ListLogicalDeviceMeters")
 	agent.lockLogicalDevice.RLock()
 	defer agent.lockLogicalDevice.RUnlock()
-	logicalDevice := agent.clusterDataProxy.Get(context.Background(), "/logical_devices/"+agent.logicalDeviceId, 0, false, "")
+	logicalDevice := agent.clusterDataProxy.Get(context.Background(), "/logical_devices/"+agent.logicalDeviceID, 0, false, "")
 	if lDevice, ok := logicalDevice.(*voltha.LogicalDevice); ok {
 		if lDevice.Meters == nil {
 			return &ofp.Meters{}, nil
@@ -222,65 +232,41 @@
 		cMeters := (proto.Clone(lDevice.Meters)).(*ofp.Meters)
 		return cMeters, nil
 	}
-	return nil, status.Errorf(codes.NotFound, "logical_device-%s", agent.logicalDeviceId)
+	return nil, status.Errorf(codes.NotFound, "logical_device-%s", agent.logicalDeviceID)
 }
 
+// ListLogicalDeviceFlowGroups returns logical device flow groups
 func (agent *LogicalDeviceAgent) ListLogicalDeviceFlowGroups() (*ofp.FlowGroups, error) {
 	log.Debug("ListLogicalDeviceFlowGroups")
 	agent.lockLogicalDevice.RLock()
 	defer agent.lockLogicalDevice.RUnlock()
-	logicalDevice := agent.clusterDataProxy.Get(context.Background(), "/logical_devices/"+agent.logicalDeviceId, 0, false, "")
+	logicalDevice := agent.clusterDataProxy.Get(context.Background(), "/logical_devices/"+agent.logicalDeviceID, 0, false, "")
 	if lDevice, ok := logicalDevice.(*voltha.LogicalDevice); ok {
 		cFlowGroups := (proto.Clone(lDevice.FlowGroups)).(*ofp.FlowGroups)
 		return cFlowGroups, nil
 	}
-	return nil, status.Errorf(codes.NotFound, "logical_device-%s", agent.logicalDeviceId)
+	return nil, status.Errorf(codes.NotFound, "logical_device-%s", agent.logicalDeviceID)
 }
 
+// ListLogicalDevicePorts returns logical device ports
 func (agent *LogicalDeviceAgent) ListLogicalDevicePorts() (*voltha.LogicalPorts, error) {
 	log.Debug("ListLogicalDevicePorts")
 	agent.lockLogicalDevice.RLock()
 	defer agent.lockLogicalDevice.RUnlock()
-	logicalDevice := agent.clusterDataProxy.Get(context.Background(), "/logical_devices/"+agent.logicalDeviceId, 0, false, "")
+	logicalDevice := agent.clusterDataProxy.Get(context.Background(), "/logical_devices/"+agent.logicalDeviceID, 0, false, "")
 	if lDevice, ok := logicalDevice.(*voltha.LogicalDevice); ok {
 		lPorts := make([]*voltha.LogicalPort, 0)
-		for _, port := range lDevice.Ports {
-			lPorts = append(lPorts, port)
-		}
+		lPorts = append(lPorts, lDevice.Ports...)
 		return &voltha.LogicalPorts{Items: lPorts}, nil
 	}
-	return nil, status.Errorf(codes.NotFound, "logical_device-%s", agent.logicalDeviceId)
-}
-
-// listFlows locks the logical device model and then retrieves the latest flow information
-func (agent *LogicalDeviceAgent) listFlows() []*ofp.OfpFlowStats {
-	log.Debug("listFlows")
-	agent.lockLogicalDevice.RLock()
-	defer agent.lockLogicalDevice.RUnlock()
-	logicalDevice := agent.clusterDataProxy.Get(context.Background(), "/logical_devices/"+agent.logicalDeviceId, 0, false, "")
-	if lDevice, ok := logicalDevice.(*voltha.LogicalDevice); ok {
-		return lDevice.Flows.Items
-	}
-	return nil
-}
-
-// listFlowGroups locks the logical device model and then retrieves the latest flow groups information
-func (agent *LogicalDeviceAgent) listFlowGroups() []*ofp.OfpGroupEntry {
-	log.Debug("listFlowGroups")
-	agent.lockLogicalDevice.RLock()
-	defer agent.lockLogicalDevice.RUnlock()
-	logicalDevice := agent.clusterDataProxy.Get(context.Background(), "/logical_devices/"+agent.logicalDeviceId, 0, false, "")
-	if lDevice, ok := logicalDevice.(*voltha.LogicalDevice); ok {
-		return lDevice.FlowGroups.Items
-	}
-	return nil
+	return nil, status.Errorf(codes.NotFound, "logical_device-%s", agent.logicalDeviceID)
 }
 
 //updateLogicalDeviceFlowsWithoutLock updates the logical device with the latest flows in the model.
 func (agent *LogicalDeviceAgent) updateLogicalDeviceFlowsWithoutLock(flows *ofp.Flows) error {
 	ld, err := agent.getLogicalDeviceWithoutLock()
 	if err != nil {
-		return status.Errorf(codes.Internal, "logical-device-absent:%s", agent.logicalDeviceId)
+		return status.Errorf(codes.Internal, "logical-device-absent:%s", agent.logicalDeviceID)
 	}
 	log.Debugw("logical-device-before", log.Fields{"lports": len(ld.Ports)})
 	cloned := (proto.Clone(ld)).(*voltha.LogicalDevice)
@@ -297,7 +283,7 @@
 func (agent *LogicalDeviceAgent) updateLogicalDeviceMetersWithoutLock(meters *ofp.Meters) error {
 	ld, err := agent.getLogicalDeviceWithoutLock()
 	if err != nil {
-		return status.Errorf(codes.Internal, "logical-device-absent:%s", agent.logicalDeviceId)
+		return status.Errorf(codes.Internal, "logical-device-absent:%s", agent.logicalDeviceID)
 	}
 	log.Debugw("logical-device-before", log.Fields{"lports": len(ld.Ports)})
 	cloned := (proto.Clone(ld)).(*voltha.LogicalDevice)
@@ -314,7 +300,7 @@
 func (agent *LogicalDeviceAgent) updateLogicalDeviceFlowGroupsWithoutLock(flowGroups *ofp.FlowGroups) error {
 	ld, err := agent.getLogicalDeviceWithoutLock()
 	if err != nil {
-		return status.Errorf(codes.Internal, "logical-device-absent:%s", agent.logicalDeviceId)
+		return status.Errorf(codes.Internal, "logical-device-absent:%s", agent.logicalDeviceID)
 	}
 	log.Debugw("logical-device-before", log.Fields{"lports": len(ld.Ports)})
 	cloned := (proto.Clone(ld)).(*voltha.LogicalDevice)
@@ -331,12 +317,12 @@
 // functions that have already acquired the logical device lock to the model
 func (agent *LogicalDeviceAgent) getLogicalDeviceWithoutLock() (*voltha.LogicalDevice, error) {
 	log.Debug("getLogicalDeviceWithoutLock")
-	logicalDevice := agent.clusterDataProxy.Get(context.Background(), "/logical_devices/"+agent.logicalDeviceId, 0, false, "")
+	logicalDevice := agent.clusterDataProxy.Get(context.Background(), "/logical_devices/"+agent.logicalDeviceID, 0, false, "")
 	if lDevice, ok := logicalDevice.(*voltha.LogicalDevice); ok {
 		//log.Debug("getLogicalDeviceWithoutLock", log.Fields{"ldevice": lDevice})
 		return lDevice, nil
 	}
-	return nil, status.Errorf(codes.NotFound, "logical_device-%s", agent.logicalDeviceId)
+	return nil, status.Errorf(codes.NotFound, "logical_device-%s", agent.logicalDeviceID)
 }
 
 func (agent *LogicalDeviceAgent) updateLogicalPort(device *voltha.Device, port *voltha.Port) error {
@@ -362,71 +348,51 @@
 	return nil
 }
 
-func (agent *LogicalDeviceAgent) addLogicalPort(device *voltha.Device, port *voltha.Port) error {
-	log.Debugw("addLogicalPort", log.Fields{"deviceId": device.Id, "port": port})
-	var err error
-	if port.Type == voltha.Port_ETHERNET_NNI {
-		if _, err = agent.addNNILogicalPort(device, port); err != nil {
-			return err
-		}
-		agent.addLogicalPortToMap(port.PortNo, true)
-	} else if port.Type == voltha.Port_ETHERNET_UNI {
-		if _, err = agent.addUNILogicalPort(device, port); err != nil {
-			return err
-		}
-		agent.addLogicalPortToMap(port.PortNo, false)
-	} else {
-		log.Debugw("invalid-port-type", log.Fields{"deviceId": device.Id, "port": port})
-		return nil
-	}
-	return nil
-}
-
 // setupLogicalPorts is invoked once the logical device has been created and is ready to get ports
 // added to it.  While the logical device was being created we could have received requests to add
 // NNI and UNI ports which were discarded.  Now is the time to add them if needed
 func (agent *LogicalDeviceAgent) setupLogicalPorts(ctx context.Context) error {
-	log.Infow("setupLogicalPorts", log.Fields{"logicalDeviceId": agent.logicalDeviceId})
+	log.Infow("setupLogicalPorts", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
 	// First add any NNI ports which could have been missing
-	if err := agent.setupNNILogicalPorts(nil, agent.rootDeviceId); err != nil {
-		log.Errorw("error-setting-up-NNI-ports", log.Fields{"error": err, "deviceId": agent.rootDeviceId})
+	if err := agent.setupNNILogicalPorts(context.TODO(), agent.rootDeviceID); err != nil {
+		log.Errorw("error-setting-up-NNI-ports", log.Fields{"error": err, "deviceId": agent.rootDeviceID})
 		return err
 	}
 
 	// Now, set up the UNI ports if needed.
-	if children, err := agent.deviceMgr.getAllChildDevices(agent.rootDeviceId); err != nil {
-		log.Errorw("error-getting-child-devices", log.Fields{"error": err, "deviceId": agent.rootDeviceId})
+	children, err := agent.deviceMgr.getAllChildDevices(agent.rootDeviceID)
+	if err != nil {
+		log.Errorw("error-getting-child-devices", log.Fields{"error": err, "deviceId": agent.rootDeviceID})
 		return err
-	} else {
-		responses := make([]coreutils.Response, 0)
-		for _, child := range children.Items {
-			response := coreutils.NewResponse()
-			responses = append(responses, response)
-			go func(child *voltha.Device) {
-				if err = agent.setupUNILogicalPorts(nil, child); err != nil {
-					log.Error("setting-up-UNI-ports-failed", log.Fields{"deviceID": child.Id})
-					response.Error(status.Errorf(codes.Internal, "UNI-ports-setup-failed: %s", child.Id))
-				}
-				response.Done()
-			}(child)
-		}
-		// Wait for completion
-		if res := coreutils.WaitForNilOrErrorResponses(agent.defaultTimeout, responses...); res != nil {
-			return status.Errorf(codes.Aborted, "errors-%s", res)
-		}
+	}
+	responses := make([]coreutils.Response, 0)
+	for _, child := range children.Items {
+		response := coreutils.NewResponse()
+		responses = append(responses, response)
+		go func(child *voltha.Device) {
+			if err = agent.setupUNILogicalPorts(context.TODO(), child); err != nil {
+				log.Error("setting-up-UNI-ports-failed", log.Fields{"deviceID": child.Id})
+				response.Error(status.Errorf(codes.Internal, "UNI-ports-setup-failed: %s", child.Id))
+			}
+			response.Done()
+		}(child)
+	}
+	// Wait for completion
+	if res := coreutils.WaitForNilOrErrorResponses(agent.defaultTimeout, responses...); res != nil {
+		return status.Errorf(codes.Aborted, "errors-%s", res)
 	}
 	return nil
 }
 
 // setupNNILogicalPorts creates an NNI port on the logical device that represents an NNI interface on a root device
-func (agent *LogicalDeviceAgent) setupNNILogicalPorts(ctx context.Context, deviceId string) error {
-	log.Infow("setupNNILogicalPorts-start", log.Fields{"logicalDeviceId": agent.logicalDeviceId})
+func (agent *LogicalDeviceAgent) setupNNILogicalPorts(ctx context.Context, deviceID string) error {
+	log.Infow("setupNNILogicalPorts-start", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
 	// Build the logical device based on information retrieved from the device adapter
 	var err error
 
 	var device *voltha.Device
-	if device, err = agent.deviceMgr.GetDevice(deviceId); err != nil {
-		log.Errorw("error-retrieving-device", log.Fields{"error": err, "deviceId": deviceId})
+	if device, err = agent.deviceMgr.GetDevice(deviceID); err != nil {
+		log.Errorw("error-retrieving-device", log.Fields{"error": err, "deviceId": deviceID})
 		return err
 	}
 
@@ -443,74 +409,74 @@
 }
 
 // updatePortState updates the port state of the device
-func (agent *LogicalDeviceAgent) updatePortState(deviceId string, portNo uint32, operStatus voltha.OperStatus_OperStatus) error {
-	log.Infow("updatePortState-start", log.Fields{"logicalDeviceId": agent.logicalDeviceId, "portNo": portNo, "state": operStatus})
+func (agent *LogicalDeviceAgent) updatePortState(deviceID string, portNo uint32, operStatus voltha.OperStatus_OperStatus) error {
+	log.Infow("updatePortState-start", log.Fields{"logicalDeviceId": agent.logicalDeviceID, "portNo": portNo, "state": operStatus})
 	agent.lockLogicalDevice.Lock()
 	defer agent.lockLogicalDevice.Unlock()
 	// Get the latest logical device info
-	if ld, err := agent.getLogicalDeviceWithoutLock(); err != nil {
-		log.Warnw("logical-device-unknown", log.Fields{"logicalDeviceId": agent.logicalDeviceId, "error": err})
+	ld, err := agent.getLogicalDeviceWithoutLock()
+	if err != nil {
+		log.Warnw("logical-device-unknown", log.Fields{"logicalDeviceId": agent.logicalDeviceID, "error": err})
 		return err
-	} else {
-		for idx, lPort := range ld.Ports {
-			if lPort.DeviceId == deviceId && lPort.DevicePortNo == portNo {
-				cloned := (proto.Clone(ld)).(*voltha.LogicalDevice)
-				if operStatus == voltha.OperStatus_ACTIVE {
-					cloned.Ports[idx].OfpPort.Config = cloned.Ports[idx].OfpPort.Config & ^uint32(ofp.OfpPortConfig_OFPPC_PORT_DOWN)
-					cloned.Ports[idx].OfpPort.State = uint32(ofp.OfpPortState_OFPPS_LIVE)
-				} else {
-					cloned.Ports[idx].OfpPort.Config = cloned.Ports[idx].OfpPort.Config | uint32(ofp.OfpPortConfig_OFPPC_PORT_DOWN)
-					cloned.Ports[idx].OfpPort.State = uint32(ofp.OfpPortState_OFPPS_LINK_DOWN)
-				}
-				// Update the logical device
-				if err := agent.updateLogicalDeviceWithoutLock(cloned); err != nil {
-					log.Errorw("error-updating-logical-device", log.Fields{"error": err})
-					return err
-				}
-				return nil
-			}
-		}
-		return status.Errorf(codes.NotFound, "port-%d-not-exist", portNo)
 	}
+	for idx, lPort := range ld.Ports {
+		if lPort.DeviceId == deviceID && lPort.DevicePortNo == portNo {
+			cloned := (proto.Clone(ld)).(*voltha.LogicalDevice)
+			if operStatus == voltha.OperStatus_ACTIVE {
+				cloned.Ports[idx].OfpPort.Config = cloned.Ports[idx].OfpPort.Config & ^uint32(ofp.OfpPortConfig_OFPPC_PORT_DOWN)
+				cloned.Ports[idx].OfpPort.State = uint32(ofp.OfpPortState_OFPPS_LIVE)
+			} else {
+				cloned.Ports[idx].OfpPort.Config = cloned.Ports[idx].OfpPort.Config | uint32(ofp.OfpPortConfig_OFPPC_PORT_DOWN)
+				cloned.Ports[idx].OfpPort.State = uint32(ofp.OfpPortState_OFPPS_LINK_DOWN)
+			}
+			// Update the logical device
+			if err := agent.updateLogicalDeviceWithoutLock(cloned); err != nil {
+				log.Errorw("error-updating-logical-device", log.Fields{"error": err})
+				return err
+			}
+			return nil
+		}
+	}
+	return status.Errorf(codes.NotFound, "port-%d-not-exist", portNo)
 }
 
 // updatePortsState updates the ports state related to the device
 func (agent *LogicalDeviceAgent) updatePortsState(device *voltha.Device, state voltha.AdminState_AdminState) error {
-	log.Infow("updatePortsState-start", log.Fields{"logicalDeviceId": agent.logicalDeviceId})
+	log.Infow("updatePortsState-start", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
 	agent.lockLogicalDevice.Lock()
 	defer agent.lockLogicalDevice.Unlock()
 	// Get the latest logical device info
-	if ld, err := agent.getLogicalDeviceWithoutLock(); err != nil {
-		log.Warnw("logical-device-unknown", log.Fields{"ldeviceId": agent.logicalDeviceId, "error": err})
+	ld, err := agent.getLogicalDeviceWithoutLock()
+	if err != nil {
+		log.Warnw("logical-device-unknown", log.Fields{"ldeviceId": agent.logicalDeviceID, "error": err})
 		return err
-	} else {
-		cloned := (proto.Clone(ld)).(*voltha.LogicalDevice)
-		for _, lport := range cloned.Ports {
-			if lport.DeviceId == device.Id {
-				switch state {
-				case voltha.AdminState_ENABLED:
-					lport.OfpPort.Config = lport.OfpPort.Config & ^uint32(ofp.OfpPortConfig_OFPPC_PORT_DOWN)
-					lport.OfpPort.State = uint32(ofp.OfpPortState_OFPPS_LIVE)
-				case voltha.AdminState_DISABLED:
-					lport.OfpPort.Config = lport.OfpPort.Config | uint32(ofp.OfpPortConfig_OFPPC_PORT_DOWN)
-					lport.OfpPort.State = uint32(ofp.OfpPortState_OFPPS_LINK_DOWN)
-				default:
-					log.Warnw("unsupported-state-change", log.Fields{"deviceId": device.Id, "state": state})
-				}
+	}
+	cloned := (proto.Clone(ld)).(*voltha.LogicalDevice)
+	for _, lport := range cloned.Ports {
+		if lport.DeviceId == device.Id {
+			switch state {
+			case voltha.AdminState_ENABLED:
+				lport.OfpPort.Config = lport.OfpPort.Config & ^uint32(ofp.OfpPortConfig_OFPPC_PORT_DOWN)
+				lport.OfpPort.State = uint32(ofp.OfpPortState_OFPPS_LIVE)
+			case voltha.AdminState_DISABLED:
+				lport.OfpPort.Config = lport.OfpPort.Config | uint32(ofp.OfpPortConfig_OFPPC_PORT_DOWN)
+				lport.OfpPort.State = uint32(ofp.OfpPortState_OFPPS_LINK_DOWN)
+			default:
+				log.Warnw("unsupported-state-change", log.Fields{"deviceId": device.Id, "state": state})
 			}
 		}
-		// Updating the logical device will trigger the poprt change events to be populated to the controller
-		if err := agent.updateLogicalDeviceWithoutLock(cloned); err != nil {
-			log.Warnw("logical-device-update-failed", log.Fields{"ldeviceId": agent.logicalDeviceId, "error": err})
-			return err
-		}
+	}
+	// Updating the logical device will trigger the poprt change events to be populated to the controller
+	if err := agent.updateLogicalDeviceWithoutLock(cloned); err != nil {
+		log.Warnw("logical-device-update-failed", log.Fields{"ldeviceId": agent.logicalDeviceID, "error": err})
+		return err
 	}
 	return nil
 }
 
 // setupUNILogicalPorts creates a UNI port on the logical device that represents a child UNI interface
 func (agent *LogicalDeviceAgent) setupUNILogicalPorts(ctx context.Context, childDevice *voltha.Device) error {
-	log.Infow("setupUNILogicalPort", log.Fields{"logicalDeviceId": agent.logicalDeviceId})
+	log.Infow("setupUNILogicalPort", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
 	// Build the logical device based on information retrieved from the device adapter
 	var err error
 	var added bool
@@ -530,31 +496,31 @@
 
 // deleteAllLogicalPorts deletes all logical ports associated with this device
 func (agent *LogicalDeviceAgent) deleteAllLogicalPorts(device *voltha.Device) error {
-	log.Infow("updatePortsState-start", log.Fields{"logicalDeviceId": agent.logicalDeviceId})
+	log.Infow("updatePortsState-start", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
 	agent.lockLogicalDevice.Lock()
 	defer agent.lockLogicalDevice.Unlock()
 	// Get the latest logical device info
-	if ld, err := agent.getLogicalDeviceWithoutLock(); err != nil {
-		log.Warnw("logical-device-unknown", log.Fields{"ldeviceId": agent.logicalDeviceId, "error": err})
+	ld, err := agent.getLogicalDeviceWithoutLock()
+	if err != nil {
+		log.Warnw("logical-device-unknown", log.Fields{"ldeviceId": agent.logicalDeviceID, "error": err})
 		return err
+	}
+	cloned := (proto.Clone(ld)).(*voltha.LogicalDevice)
+	updateLogicalPorts := []*voltha.LogicalPort{}
+	for _, lport := range cloned.Ports {
+		if lport.DeviceId != device.Id {
+			updateLogicalPorts = append(updateLogicalPorts, lport)
+		}
+	}
+	if len(updateLogicalPorts) < len(cloned.Ports) {
+		cloned.Ports = updateLogicalPorts
+		// Updating the logical device will trigger the poprt change events to be populated to the controller
+		if err := agent.updateLogicalDeviceWithoutLock(cloned); err != nil {
+			log.Warnw("logical-device-update-failed", log.Fields{"ldeviceId": agent.logicalDeviceID, "error": err})
+			return err
+		}
 	} else {
-		cloned := (proto.Clone(ld)).(*voltha.LogicalDevice)
-		updateLogicalPorts := []*voltha.LogicalPort{}
-		for _, lport := range cloned.Ports {
-			if lport.DeviceId != device.Id {
-				updateLogicalPorts = append(updateLogicalPorts, lport)
-			}
-		}
-		if len(updateLogicalPorts) < len(cloned.Ports) {
-			cloned.Ports = updateLogicalPorts
-			// Updating the logical device will trigger the poprt change events to be populated to the controller
-			if err := agent.updateLogicalDeviceWithoutLock(cloned); err != nil {
-				log.Warnw("logical-device-update-failed", log.Fields{"ldeviceId": agent.logicalDeviceId, "error": err})
-				return err
-			}
-		} else {
-			log.Debugw("no-change-required", log.Fields{"logicalDeviceId": agent.logicalDeviceId})
-		}
+		log.Debugw("no-change-required", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
 	}
 	return nil
 }
@@ -562,9 +528,9 @@
 //updateLogicalDeviceWithoutLock updates the model with the logical device.  It clones the logicaldevice before saving it
 func (agent *LogicalDeviceAgent) updateLogicalDeviceWithoutLock(logicalDevice *voltha.LogicalDevice) error {
 	updateCtx := context.WithValue(context.Background(), model.RequestTimestamp, time.Now().UnixNano())
-	afterUpdate := agent.clusterDataProxy.Update(updateCtx, "/logical_devices/"+agent.logicalDeviceId, logicalDevice, false, "")
+	afterUpdate := agent.clusterDataProxy.Update(updateCtx, "/logical_devices/"+agent.logicalDeviceID, logicalDevice, false, "")
 	if afterUpdate == nil {
-		return status.Errorf(codes.Internal, "failed-updating-logical-device:%s", agent.logicalDeviceId)
+		return status.Errorf(codes.Internal, "failed-updating-logical-device:%s", agent.logicalDeviceID)
 	}
 	return nil
 }
@@ -572,18 +538,18 @@
 //generateDeviceGraphIfNeeded generates the device graph if the logical device has been updated since the last time
 //that device graph was generated.
 func (agent *LogicalDeviceAgent) generateDeviceGraphIfNeeded() error {
-	if ld, err := agent.GetLogicalDevice(); err != nil {
+	ld, err := agent.GetLogicalDevice()
+	if err != nil {
 		log.Errorw("get-logical-device-error", log.Fields{"error": err})
 		return err
-	} else {
-		agent.lockDeviceGraph.Lock()
-		defer agent.lockDeviceGraph.Unlock()
-		if agent.deviceGraph != nil && agent.deviceGraph.IsUpToDate(ld) {
-			return nil
-		}
-		log.Debug("Generation of device graph required")
-		agent.generateDeviceGraph()
 	}
+	agent.lockDeviceGraph.Lock()
+	defer agent.lockDeviceGraph.Unlock()
+	if agent.deviceGraph != nil && agent.deviceGraph.IsUpToDate(ld) {
+		return nil
+	}
+	log.Debug("Generation of device graph required")
+	agent.generateDeviceGraph()
 	return nil
 }
 
@@ -609,7 +575,7 @@
 		return agent.flowModifyStrict(flow)
 	}
 	return status.Errorf(codes.Internal,
-		"unhandled-command: lDeviceId:%s, command:%s", agent.logicalDeviceId, flow.GetCommand())
+		"unhandled-command: lDeviceId:%s, command:%s", agent.logicalDeviceID, flow.GetCommand())
 }
 
 //updateGroupTable updates the group table of that logical device
@@ -630,7 +596,7 @@
 		return agent.groupModify(groupMod)
 	}
 	return status.Errorf(codes.Internal,
-		"unhandled-command: lDeviceId:%s, command:%s", agent.logicalDeviceId, groupMod.GetCommand())
+		"unhandled-command: lDeviceId:%s, command:%s", agent.logicalDeviceID, groupMod.GetCommand())
 }
 
 // updateMeterTable updates the meter table of that logical device
@@ -651,7 +617,7 @@
 		return agent.meterModify(meterMod)
 	}
 	return status.Errorf(codes.Internal,
-		"unhandled-command: lDeviceId:%s, command:%s", agent.logicalDeviceId, meterMod.GetCommand())
+		"unhandled-command: lDeviceId:%s, command:%s", agent.logicalDeviceID, meterMod.GetCommand())
 
 }
 
@@ -667,8 +633,8 @@
 	var lDevice *voltha.LogicalDevice
 	var err error
 	if lDevice, err = agent.getLogicalDeviceWithoutLock(); err != nil {
-		log.Errorw("no-logical-device-present", log.Fields{"logicalDeviceId": agent.logicalDeviceId})
-		return errors.New(fmt.Sprintf("no-logical-device-present:%s", agent.logicalDeviceId))
+		log.Errorw("no-logical-device-present", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
+		return fmt.Errorf("no-logical-device-present:%s", agent.logicalDeviceID)
 	}
 
 	var meters []*ofp.OfpMeterEntry
@@ -688,7 +654,7 @@
 	meters = append(meters, meterEntry)
 	//Update model
 	if err := agent.updateLogicalDeviceMetersWithoutLock(&ofp.Meters{Items: meters}); err != nil {
-		log.Errorw("db-meter-update-failed", log.Fields{"logicalDeviceId": agent.logicalDeviceId})
+		log.Errorw("db-meter-update-failed", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
 		return err
 	}
 	log.Debugw("Meter-added-successfully", log.Fields{"Added-meter": meterEntry, "updated-meters": lDevice.Meters})
@@ -706,8 +672,8 @@
 	var lDevice *voltha.LogicalDevice
 	var err error
 	if lDevice, err = agent.getLogicalDeviceWithoutLock(); err != nil {
-		log.Errorw("no-logical-device-present", log.Fields{"logicalDeviceId": agent.logicalDeviceId})
-		return errors.New(fmt.Sprintf("no-logical-device-present:%s", agent.logicalDeviceId))
+		log.Errorw("no-logical-device-present", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
+		return fmt.Errorf("no-logical-device-present:%s", agent.logicalDeviceID)
 	}
 
 	var meters []*ofp.OfpMeterEntry
@@ -716,9 +682,6 @@
 	if lDevice.Meters != nil && lDevice.Meters.Items != nil {
 		meters = lDevice.Meters.Items
 	}
-	if lDevice.Flows != nil && lDevice.Flows.Items != nil {
-		flows = lDevice.Flows.Items
-	}
 
 	changedMeter := false
 	changedFow := false
@@ -726,7 +689,7 @@
 	for index, meter := range meters {
 		if meterMod.MeterId == meter.Config.MeterId {
 			flows = lDevice.Flows.Items
-			changedFow, updatedFlows = agent.getUpdatedFlowsAfterDeletebyMeterId(flows, meterMod.MeterId)
+			changedFow, updatedFlows = agent.getUpdatedFlowsAfterDeletebyMeterID(flows, meterMod.MeterId)
 			meters = append(meters[:index], meters[index+1:]...)
 			log.Debugw("Meter has been deleted", log.Fields{"meter": meter, "index": index})
 			changedMeter = true
@@ -740,7 +703,7 @@
 			metersToUpdate = &ofp.Meters{Items: meters}
 		}
 		if err := agent.updateLogicalDeviceMetersWithoutLock(metersToUpdate); err != nil {
-			log.Errorw("db-meter-update-failed", log.Fields{"logicalDeviceId": agent.logicalDeviceId})
+			log.Errorw("db-meter-update-failed", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
 			return err
 		}
 		log.Debug("Meter-deleted-from-DB-successfully", log.Fields{"updatedMeters": metersToUpdate, "no-of-meter": len(metersToUpdate.Items)})
@@ -749,7 +712,7 @@
 	if changedFow {
 		//Update model
 		if err := agent.updateLogicalDeviceFlowsWithoutLock(&ofp.Flows{Items: updatedFlows}); err != nil {
-			log.Errorw("db-flow-update-failed", log.Fields{"logicalDeviceId": agent.logicalDeviceId})
+			log.Errorw("db-flow-update-failed", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
 			return err
 		}
 		log.Debug("Flows-associated-with-meter-deleted-from-DB-successfully",
@@ -770,8 +733,8 @@
 	var lDevice *voltha.LogicalDevice
 	var err error
 	if lDevice, err = agent.getLogicalDeviceWithoutLock(); err != nil {
-		log.Errorw("no-logical-device-present", log.Fields{"logicalDeviceId": agent.logicalDeviceId})
-		return errors.New(fmt.Sprintf("no-logical-device-present:%s", agent.logicalDeviceId))
+		log.Errorw("no-logical-device-present", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
+		return fmt.Errorf("no-logical-device-present:%s", agent.logicalDeviceID)
 	}
 
 	var meters []*ofp.OfpMeterEntry
@@ -796,7 +759,7 @@
 			metersToUpdate = &ofp.Meters{Items: meters}
 		}
 		if err := agent.updateLogicalDeviceMetersWithoutLock(metersToUpdate); err != nil {
-			log.Errorw("db-meter-update-failed", log.Fields{"logicalDeviceId": agent.logicalDeviceId})
+			log.Errorw("db-meter-update-failed", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
 			return err
 		}
 		log.Debugw("meter-updated-in-DB-successfully", log.Fields{"updated_meters": meters})
@@ -804,16 +767,16 @@
 	}
 
 	log.Errorw("Meter not found ", log.Fields{"meter": meterMod})
-	return errors.New(fmt.Sprintf("no-logical-device-present:%d", meterMod.MeterId))
+	return fmt.Errorf("no-logical-device-present:%d", meterMod.MeterId)
 
 }
 
-func (agent *LogicalDeviceAgent) getUpdatedFlowsAfterDeletebyMeterId(flows []*ofp.OfpFlowStats, meterId uint32) (bool, []*ofp.OfpFlowStats) {
-	log.Infow("Delete flows matching meter", log.Fields{"meter": meterId})
+func (agent *LogicalDeviceAgent) getUpdatedFlowsAfterDeletebyMeterID(flows []*ofp.OfpFlowStats, meterID uint32) (bool, []*ofp.OfpFlowStats) {
+	log.Infow("Delete flows matching meter", log.Fields{"meter": meterID})
 	changed := false
 	//updatedFlows := make([]*ofp.OfpFlowStats, 0)
 	for index := len(flows) - 1; index >= 0; index-- {
-		if mId := fu.GetMeterIdFromFlow(flows[index]); mId != 0 && mId == meterId {
+		if mID := fu.GetMeterIdFromFlow(flows[index]); mID != 0 && mID == meterID {
 			log.Debugw("Flow to be deleted", log.Fields{"flow": flows[index], "index": index})
 			flows = append(flows[:index], flows[index+1:]...)
 			changed = true
@@ -825,9 +788,9 @@
 func (agent *LogicalDeviceAgent) updateFlowCountOfMeterStats(modCommand *ofp.OfpFlowMod, meters []*ofp.OfpMeterEntry, flow *ofp.OfpFlowStats) bool {
 
 	flowCommand := modCommand.GetCommand()
-	meterId := fu.GetMeterIdFromFlow(flow)
-	log.Debugw("Meter-id-in-flow-mod", log.Fields{"meterId": meterId})
-	if meterId == 0 {
+	meterID := fu.GetMeterIdFromFlow(flow)
+	log.Debugw("Meter-id-in-flow-mod", log.Fields{"meterId": meterID})
+	if meterID == 0 {
 		log.Debugw("No meter present in the flow", log.Fields{"flow": *flow})
 		return false
 	}
@@ -837,15 +800,15 @@
 	}
 	changedMeter := false
 	for _, meter := range meters {
-		if meterId == meter.Config.MeterId { // Found meter in Logicaldevice
+		if meterID == meter.Config.MeterId { // Found meter in Logicaldevice
 			if flowCommand == ofp.OfpFlowModCommand_OFPFC_ADD {
-				meter.Stats.FlowCount += 1
+				meter.Stats.FlowCount++
 				changedMeter = true
 			} else if flowCommand == ofp.OfpFlowModCommand_OFPFC_DELETE_STRICT {
-				meter.Stats.FlowCount -= 1
+				meter.Stats.FlowCount--
 				changedMeter = true
 			}
-			log.Debugw("Found meter, updated meter flow stats", log.Fields{" meterId": meterId})
+			log.Debugw("Found meter, updated meter flow stats", log.Fields{" meterId": meterID})
 			break
 		}
 	}
@@ -864,8 +827,8 @@
 	var lDevice *voltha.LogicalDevice
 	var err error
 	if lDevice, err = agent.getLogicalDeviceWithoutLock(); err != nil {
-		log.Errorw("no-logical-device-present", log.Fields{"logicalDeviceId": agent.logicalDeviceId})
-		return errors.New(fmt.Sprintf("no-logical-device-present:%s", agent.logicalDeviceId))
+		log.Errorw("no-logical-device-present", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
+		return fmt.Errorf("no-logical-device-present:%s", agent.logicalDeviceID)
 	}
 
 	var flows []*ofp.OfpFlowStats
@@ -886,7 +849,7 @@
 	if checkOverlap {
 		if overlapped := fu.FindOverlappingFlows(flows, mod); len(overlapped) != 0 {
 			//	TODO:  should this error be notified other than being logged?
-			log.Warnw("overlapped-flows", log.Fields{"logicaldeviceId": agent.logicalDeviceId})
+			log.Warnw("overlapped-flows", log.Fields{"logicaldeviceId": agent.logicalDeviceID})
 		} else {
 			//	Add flow
 			flow = fu.FlowStatsEntryFromFlowModMessage(mod)
@@ -927,13 +890,13 @@
 		log.Debugw("rules", log.Fields{"rules": deviceRules.String()})
 
 		if err := agent.addDeviceFlowsAndGroups(deviceRules, &flowMetadata); err != nil {
-			log.Errorw("failure-updating-device-flows", log.Fields{"logicalDeviceId": agent.logicalDeviceId, "error": err})
+			log.Errorw("failure-updating-device-flows", log.Fields{"logicalDeviceId": agent.logicalDeviceID, "error": err})
 			return err
 		}
 
 		//	Update model
 		if err := agent.updateLogicalDeviceFlowsWithoutLock(&ofp.Flows{Items: flows}); err != nil {
-			log.Errorw("db-flow-update-failed", log.Fields{"logicalDeviceId": agent.logicalDeviceId})
+			log.Errorw("db-flow-update-failed", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
 			return err
 		}
 		if !updated {
@@ -945,7 +908,7 @@
 			if changedMeterStats {
 				//Update model
 				if err := agent.updateLogicalDeviceMetersWithoutLock(metersToUpdate); err != nil {
-					log.Errorw("db-meter-update-failed", log.Fields{"logicalDeviceId": agent.logicalDeviceId})
+					log.Errorw("db-meter-update-failed", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
 					return err
 				}
 				log.Debugw("meter-stats-updated-in-DB-successfully", log.Fields{"updated_meters": meters})
@@ -957,10 +920,11 @@
 	return nil
 }
 
+// GetMeterConfig returns meter config
 func (agent *LogicalDeviceAgent) GetMeterConfig(flows []*ofp.OfpFlowStats, meters []*ofp.OfpMeterEntry, metadata *voltha.FlowMetadata) error {
 	m := make(map[uint32]bool)
 	for _, flow := range flows {
-		if flowMeterID := fu.GetMeterIdFromFlow(flow); flowMeterID != 0 && m[flowMeterID] == false {
+		if flowMeterID := fu.GetMeterIdFromFlow(flow); flowMeterID != 0 && !m[flowMeterID] {
 			foundMeter := false
 			// Meter is present in the flow , Get from logical device
 			for _, meter := range meters {
@@ -975,7 +939,7 @@
 			}
 			if !foundMeter {
 				log.Errorw("Meter-referred-by-flow-is-not-found-in-logicaldevice",
-					log.Fields{"meterID": flowMeterID, "Avaliable-meters": meters, "flow": *flow})
+					log.Fields{"meterID": flowMeterID, "Available-meters": meters, "flow": *flow})
 				return errors.New("Meter-referred-by-flow-is-not-found-in-logicaldevice")
 			}
 		}
@@ -997,8 +961,8 @@
 	var lDevice *voltha.LogicalDevice
 	var err error
 	if lDevice, err = agent.getLogicalDeviceWithoutLock(); err != nil {
-		log.Errorw("no-logical-device-present", log.Fields{"logicalDeviceId": agent.logicalDeviceId})
-		return errors.New(fmt.Sprintf("no-logical-device-present:%s", agent.logicalDeviceId))
+		log.Errorw("no-logical-device-present", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
+		return fmt.Errorf("no-logical-device-present:%s", agent.logicalDeviceID)
 	}
 
 	var meters []*ofp.OfpMeterEntry
@@ -1028,7 +992,7 @@
 		}
 	}
 
-	log.Debugw("flowDelete", log.Fields{"logicalDeviceId": agent.logicalDeviceId, "toKeep": len(toKeep), "toDelete": toDelete})
+	log.Debugw("flowDelete", log.Fields{"logicalDeviceId": agent.logicalDeviceID, "toKeep": len(toKeep), "toDelete": toDelete})
 
 	//Update flows
 	if len(toDelete) > 0 {
@@ -1041,12 +1005,12 @@
 		log.Debugw("rules", log.Fields{"rules": deviceRules.String()})
 
 		if err := agent.deleteDeviceFlowsAndGroups(deviceRules, &flowMetadata); err != nil {
-			log.Errorw("failure-updating-device-flows", log.Fields{"logicalDeviceId": agent.logicalDeviceId, "error": err})
+			log.Errorw("failure-updating-device-flows", log.Fields{"logicalDeviceId": agent.logicalDeviceID, "error": err})
 			return err
 		}
 
 		if err := agent.updateLogicalDeviceFlowsWithoutLock(&ofp.Flows{Items: toKeep}); err != nil {
-			log.Errorw("Cannot-update-flows", log.Fields{"logicalDeviceId": agent.logicalDeviceId})
+			log.Errorw("Cannot-update-flows", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
 			return err
 		}
 	}
@@ -1056,10 +1020,10 @@
 }
 
 func (agent *LogicalDeviceAgent) addDeviceFlowsAndGroups(deviceRules *fu.DeviceRules, flowMetadata *voltha.FlowMetadata) error {
-	log.Debugw("addDeviceFlowsAndGroups", log.Fields{"logicalDeviceID": agent.logicalDeviceId, "deviceRules": deviceRules, "flowMetadata": flowMetadata})
+	log.Debugw("addDeviceFlowsAndGroups", log.Fields{"logicalDeviceID": agent.logicalDeviceID, "deviceRules": deviceRules, "flowMetadata": flowMetadata})
 
 	responses := make([]coreutils.Response, 0)
-	for deviceId, value := range deviceRules.GetRules() {
+	for deviceID, value := range deviceRules.GetRules() {
 		response := coreutils.NewResponse()
 		responses = append(responses, response)
 		go func(deviceId string, value *fu.FlowsAndGroups) {
@@ -1068,7 +1032,7 @@
 				response.Error(status.Errorf(codes.Internal, "flow-add-failed: %s", deviceId))
 			}
 			response.Done()
-		}(deviceId, value)
+		}(deviceID, value)
 	}
 	// Wait for completion
 	if res := coreutils.WaitForNilOrErrorResponses(agent.defaultTimeout, responses...); res != nil {
@@ -1078,10 +1042,10 @@
 }
 
 func (agent *LogicalDeviceAgent) deleteDeviceFlowsAndGroups(deviceRules *fu.DeviceRules, flowMetadata *voltha.FlowMetadata) error {
-	log.Debugw("deleteDeviceFlowsAndGroups", log.Fields{"logicalDeviceID": agent.logicalDeviceId})
+	log.Debugw("deleteDeviceFlowsAndGroups", log.Fields{"logicalDeviceID": agent.logicalDeviceID})
 
 	responses := make([]coreutils.Response, 0)
-	for deviceId, value := range deviceRules.GetRules() {
+	for deviceID, value := range deviceRules.GetRules() {
 		response := coreutils.NewResponse()
 		responses = append(responses, response)
 		go func(deviceId string, value *fu.FlowsAndGroups) {
@@ -1090,7 +1054,7 @@
 				response.Error(status.Errorf(codes.Internal, "flow-delete-failed: %s", deviceId))
 			}
 			response.Done()
-		}(deviceId, value)
+		}(deviceID, value)
 	}
 	// Wait for completion
 	if res := coreutils.WaitForNilOrErrorResponses(agent.defaultTimeout, responses...); res != nil {
@@ -1100,10 +1064,10 @@
 }
 
 func (agent *LogicalDeviceAgent) updateDeviceFlowsAndGroups(deviceRules *fu.DeviceRules, flowMetadata *voltha.FlowMetadata) error {
-	log.Debugw("updateDeviceFlowsAndGroups", log.Fields{"logicalDeviceID": agent.logicalDeviceId})
+	log.Debugw("updateDeviceFlowsAndGroups", log.Fields{"logicalDeviceID": agent.logicalDeviceID})
 
 	responses := make([]coreutils.Response, 0)
-	for deviceId, value := range deviceRules.GetRules() {
+	for deviceID, value := range deviceRules.GetRules() {
 		response := coreutils.NewResponse()
 		responses = append(responses, response)
 		go func(deviceId string, value *fu.FlowsAndGroups) {
@@ -1112,7 +1076,7 @@
 				response.Error(status.Errorf(codes.Internal, "flow-update-failed: %s", deviceId))
 			}
 			response.Done()
-		}(deviceId, value)
+		}(deviceID, value)
 	}
 	// Wait for completion
 	if res := coreutils.WaitForNilOrErrorResponses(agent.defaultTimeout, responses...); res != nil {
@@ -1133,8 +1097,8 @@
 	var lDevice *voltha.LogicalDevice
 	var err error
 	if lDevice, err = agent.getLogicalDeviceWithoutLock(); err != nil {
-		log.Errorw("no-logical-device-present", log.Fields{"logicalDeviceId": agent.logicalDeviceId})
-		return errors.New(fmt.Sprintf("no-logical-device-present:%s", agent.logicalDeviceId))
+		log.Errorw("no-logical-device-present", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
+		return fmt.Errorf("no-logical-device-present:%s", agent.logicalDeviceID)
 	}
 	var meters []*ofp.OfpMeterEntry
 	var flows []*ofp.OfpFlowStats
@@ -1156,7 +1120,7 @@
 		flows = append(flows[:idx], flows[idx+1:]...)
 		changedFlow = true
 	} else {
-		return errors.New(fmt.Sprintf("Cannot delete flow - %s", flow))
+		return fmt.Errorf("Cannot delete flow - %s", flow)
 	}
 	if changedMeter {
 		//Update model
@@ -1165,7 +1129,7 @@
 			metersToUpdate = &ofp.Meters{Items: meters}
 		}
 		if err := agent.updateLogicalDeviceMetersWithoutLock(metersToUpdate); err != nil {
-			log.Errorw("db-meter-update-failed", log.Fields{"logicalDeviceId": agent.logicalDeviceId})
+			log.Errorw("db-meter-update-failed", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
 			return err
 		}
 
@@ -1180,12 +1144,12 @@
 		log.Debugw("rules", log.Fields{"rules": deviceRules.String()})
 
 		if err := agent.deleteDeviceFlowsAndGroups(deviceRules, &flowMetadata); err != nil {
-			log.Errorw("failure-deleting-device-flows", log.Fields{"logicalDeviceId": agent.logicalDeviceId, "error": err})
+			log.Errorw("failure-deleting-device-flows", log.Fields{"logicalDeviceId": agent.logicalDeviceID, "error": err})
 			return err
 		}
 
 		if err := agent.updateLogicalDeviceFlowsWithoutLock(&ofp.Flows{Items: flows}); err != nil {
-			log.Errorw("Cannot-update-flows", log.Fields{"logicalDeviceId": agent.logicalDeviceId})
+			log.Errorw("Cannot-update-flows", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
 			return err
 		}
 	}
@@ -1213,8 +1177,8 @@
 	var lDevice *voltha.LogicalDevice
 	var err error
 	if lDevice, err = agent.getLogicalDeviceWithoutLock(); err != nil {
-		log.Errorw("no-logical-device-present", log.Fields{"logicalDeviceId": agent.logicalDeviceId})
-		return errors.New(fmt.Sprintf("no-logical-device-present:%s", agent.logicalDeviceId))
+		log.Errorw("no-logical-device-present", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
+		return fmt.Errorf("no-logical-device-present:%s", agent.logicalDeviceID)
 	}
 	groups := lDevice.FlowGroups.Items
 	if fu.FindGroup(groups, groupMod.GroupId) == -1 {
@@ -1223,16 +1187,16 @@
 		deviceRules := agent.flowDecomposer.DecomposeRules(agent, *lDevice.Flows, ofp.FlowGroups{Items: groups})
 		log.Debugw("rules", log.Fields{"rules": deviceRules.String()})
 		if err := agent.addDeviceFlowsAndGroups(deviceRules, nil); err != nil {
-			log.Errorw("failure-updating-device-flows", log.Fields{"logicalDeviceId": agent.logicalDeviceId, "error": err})
+			log.Errorw("failure-updating-device-flows", log.Fields{"logicalDeviceId": agent.logicalDeviceID, "error": err})
 			return err
 		}
 
 		if err := agent.updateLogicalDeviceFlowGroupsWithoutLock(&ofp.FlowGroups{Items: groups}); err != nil {
-			log.Errorw("Cannot-update-group", log.Fields{"logicalDeviceId": agent.logicalDeviceId})
+			log.Errorw("Cannot-update-group", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
 			return err
 		}
 	} else {
-		return errors.New(fmt.Sprintf("Groups %d already present", groupMod.GroupId))
+		return fmt.Errorf("Groups %d already present", groupMod.GroupId)
 	}
 	return nil
 }
@@ -1248,47 +1212,47 @@
 	var lDevice *voltha.LogicalDevice
 	var err error
 	if lDevice, err = agent.getLogicalDeviceWithoutLock(); err != nil {
-		log.Errorw("no-logical-device-present", log.Fields{"logicalDeviceId": agent.logicalDeviceId})
-		return errors.New(fmt.Sprintf("no-logical-device-present:%s", agent.logicalDeviceId))
+		log.Errorw("no-logical-device-present", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
+		return fmt.Errorf("no-logical-device-present:%s", agent.logicalDeviceID)
 	}
 	groups := lDevice.FlowGroups.Items
 	flows := lDevice.Flows.Items
-	groupsChanged := false
+	var groupsChanged bool
 	flowsChanged := false
-	groupId := groupMod.GroupId
-	if groupId == uint32(ofp.OfpGroup_OFPG_ALL) {
+	groupID := groupMod.GroupId
+	if groupID == uint32(ofp.OfpGroup_OFPG_ALL) {
 		//TODO we must delete all flows that point to this group and
 		//signal controller as requested by flow's flag
 		groups = []*ofp.OfpGroupEntry{}
 		groupsChanged = true
 	} else {
-		if idx := fu.FindGroup(groups, groupId); idx == -1 {
+		idx := fu.FindGroup(groups, groupID)
+		if idx == -1 {
 			return nil // Valid case
-		} else {
-			flowsChanged, flows = fu.FlowsDeleteByGroupId(flows, groupId)
-			groups = append(groups[:idx], groups[idx+1:]...)
-			groupsChanged = true
 		}
+		flowsChanged, flows = fu.FlowsDeleteByGroupId(flows, groupID)
+		groups = append(groups[:idx], groups[idx+1:]...)
+		groupsChanged = true
 	}
 	if flowsChanged || groupsChanged {
 		deviceRules := agent.flowDecomposer.DecomposeRules(agent, ofp.Flows{Items: flows}, ofp.FlowGroups{Items: groups})
 		log.Debugw("rules", log.Fields{"rules": deviceRules.String()})
 
 		if err := agent.updateDeviceFlowsAndGroups(deviceRules, nil); err != nil {
-			log.Errorw("failure-updating-device-flows-groups", log.Fields{"logicalDeviceId": agent.logicalDeviceId, "error": err})
+			log.Errorw("failure-updating-device-flows-groups", log.Fields{"logicalDeviceId": agent.logicalDeviceID, "error": err})
 			return err
 		}
 	}
 
 	if groupsChanged {
 		if err := agent.updateLogicalDeviceFlowGroupsWithoutLock(&ofp.FlowGroups{Items: groups}); err != nil {
-			log.Errorw("Cannot-update-group", log.Fields{"logicalDeviceId": agent.logicalDeviceId})
+			log.Errorw("Cannot-update-group", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
 			return err
 		}
 	}
 	if flowsChanged {
 		if err := agent.updateLogicalDeviceFlowsWithoutLock(&ofp.Flows{Items: flows}); err != nil {
-			log.Errorw("Cannot-update-flow", log.Fields{"logicalDeviceId": agent.logicalDeviceId})
+			log.Errorw("Cannot-update-flow", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
 			return err
 		}
 	}
@@ -1306,32 +1270,32 @@
 	var lDevice *voltha.LogicalDevice
 	var err error
 	if lDevice, err = agent.getLogicalDeviceWithoutLock(); err != nil {
-		log.Errorw("no-logical-device-present", log.Fields{"logicalDeviceId": agent.logicalDeviceId})
-		return errors.New(fmt.Sprintf("no-logical-device-present:%s", agent.logicalDeviceId))
+		log.Errorw("no-logical-device-present", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
+		return fmt.Errorf("no-logical-device-present:%s", agent.logicalDeviceID)
 	}
 	groups := lDevice.FlowGroups.Items
-	groupsChanged := false
-	groupId := groupMod.GroupId
-	if idx := fu.FindGroup(groups, groupId); idx == -1 {
-		return errors.New(fmt.Sprintf("group-absent:%d", groupId))
-	} else {
-		//replace existing group entry with new group definition
-		groupEntry := fu.GroupEntryFromGroupMod(groupMod)
-		groups[idx] = groupEntry
-		groupsChanged = true
+	var groupsChanged bool
+	groupID := groupMod.GroupId
+	idx := fu.FindGroup(groups, groupID)
+	if idx == -1 {
+		return fmt.Errorf("group-absent:%d", groupID)
 	}
+	//replace existing group entry with new group definition
+	groupEntry := fu.GroupEntryFromGroupMod(groupMod)
+	groups[idx] = groupEntry
+	groupsChanged = true
 	if groupsChanged {
 		deviceRules := agent.flowDecomposer.DecomposeRules(agent, ofp.Flows{Items: lDevice.Flows.Items}, ofp.FlowGroups{Items: groups})
 		log.Debugw("rules", log.Fields{"rules": deviceRules.String()})
 
 		if err := agent.updateDeviceFlowsAndGroups(deviceRules, nil); err != nil {
-			log.Errorw("failure-updating-device-flows-groups", log.Fields{"logicalDeviceId": agent.logicalDeviceId, "error": err})
+			log.Errorw("failure-updating-device-flows-groups", log.Fields{"logicalDeviceId": agent.logicalDeviceID, "error": err})
 			return err
 		}
 
 		//lDevice.FlowGroups.Items = groups
 		if err := agent.updateLogicalDeviceFlowGroupsWithoutLock(&ofp.FlowGroups{Items: groups}); err != nil {
-			log.Errorw("Cannot-update-logical-group", log.Fields{"logicalDeviceId": agent.logicalDeviceId})
+			log.Errorw("Cannot-update-logical-group", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
 			return err
 		}
 	}
@@ -1346,7 +1310,7 @@
 	// Get the most up to date logical device
 	var logicaldevice *voltha.LogicalDevice
 	if logicaldevice, _ = agent.getLogicalDeviceWithoutLock(); logicaldevice == nil {
-		log.Debugw("no-logical-device", log.Fields{"logicalDeviceId": agent.logicalDeviceId, "logicalPortId": lPort.Id})
+		log.Debugw("no-logical-device", log.Fields{"logicalDeviceId": agent.logicalDeviceID, "logicalPortId": lPort.Id})
 		return nil
 	}
 	index := -1
@@ -1360,9 +1324,9 @@
 		copy(logicaldevice.Ports[index:], logicaldevice.Ports[index+1:])
 		logicaldevice.Ports[len(logicaldevice.Ports)-1] = nil
 		logicaldevice.Ports = logicaldevice.Ports[:len(logicaldevice.Ports)-1]
-		log.Debugw("logical-port-deleted", log.Fields{"logicalDeviceId": agent.logicalDeviceId})
+		log.Debugw("logical-port-deleted", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
 		if err := agent.updateLogicalDeviceWithoutLock(logicaldevice); err != nil {
-			log.Errorw("logical-device-update-failed", log.Fields{"logicalDeviceId": agent.logicalDeviceId})
+			log.Errorw("logical-device-update-failed", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
 			return err
 		}
 		// Reset the logical device graph
@@ -1372,26 +1336,26 @@
 }
 
 // deleteLogicalPorts removes the logical ports associated with that deviceId
-func (agent *LogicalDeviceAgent) deleteLogicalPorts(deviceId string) error {
+func (agent *LogicalDeviceAgent) deleteLogicalPorts(deviceID string) error {
 	agent.lockLogicalDevice.Lock()
 	defer agent.lockLogicalDevice.Unlock()
 
 	// Get the most up to date logical device
 	var logicaldevice *voltha.LogicalDevice
 	if logicaldevice, _ = agent.getLogicalDeviceWithoutLock(); logicaldevice == nil {
-		log.Debugw("no-logical-device", log.Fields{"logicalDeviceId": agent.logicalDeviceId})
+		log.Debugw("no-logical-device", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
 		return nil
 	}
 	updatedLPorts := []*voltha.LogicalPort{}
 	for _, logicalPort := range logicaldevice.Ports {
-		if logicalPort.DeviceId != deviceId {
+		if logicalPort.DeviceId != deviceID {
 			updatedLPorts = append(updatedLPorts, logicalPort)
 		}
 	}
 	logicaldevice.Ports = updatedLPorts
 	log.Debugw("updated-logical-ports", log.Fields{"ports": updatedLPorts})
 	if err := agent.updateLogicalDeviceWithoutLock(logicaldevice); err != nil {
-		log.Errorw("logical-device-update-failed", log.Fields{"logicalDeviceId": agent.logicalDeviceId})
+		log.Errorw("logical-device-update-failed", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
 		return err
 	}
 	// Reset the logical device graph
@@ -1401,19 +1365,19 @@
 }
 
 // enableLogicalPort enables the logical port
-func (agent *LogicalDeviceAgent) enableLogicalPort(lPortId string) error {
+func (agent *LogicalDeviceAgent) enableLogicalPort(lPortID string) error {
 	agent.lockLogicalDevice.Lock()
 	defer agent.lockLogicalDevice.Unlock()
 
 	// Get the most up to date logical device
 	var logicaldevice *voltha.LogicalDevice
 	if logicaldevice, _ = agent.getLogicalDeviceWithoutLock(); logicaldevice == nil {
-		log.Debugw("no-logical-device", log.Fields{"logicalDeviceId": agent.logicalDeviceId, "logicalPortId": lPortId})
+		log.Debugw("no-logical-device", log.Fields{"logicalDeviceId": agent.logicalDeviceID, "logicalPortId": lPortID})
 		return nil
 	}
 	index := -1
 	for i, logicalPort := range logicaldevice.Ports {
-		if logicalPort.Id == lPortId {
+		if logicalPort.Id == lPortID {
 			index = i
 			break
 		}
@@ -1421,25 +1385,24 @@
 	if index >= 0 {
 		logicaldevice.Ports[index].OfpPort.Config = logicaldevice.Ports[index].OfpPort.Config & ^uint32(ofp.OfpPortConfig_OFPPC_PORT_DOWN)
 		return agent.updateLogicalDeviceWithoutLock(logicaldevice)
-	} else {
-		return status.Errorf(codes.NotFound, "Port %s on Logical Device %s", lPortId, agent.logicalDeviceId)
 	}
+	return status.Errorf(codes.NotFound, "Port %s on Logical Device %s", lPortID, agent.logicalDeviceID)
 }
 
 // disableLogicalPort disabled the logical port
-func (agent *LogicalDeviceAgent) disableLogicalPort(lPortId string) error {
+func (agent *LogicalDeviceAgent) disableLogicalPort(lPortID string) error {
 	agent.lockLogicalDevice.Lock()
 	defer agent.lockLogicalDevice.Unlock()
 
 	// Get the most up to date logical device
 	var logicaldevice *voltha.LogicalDevice
 	if logicaldevice, _ = agent.getLogicalDeviceWithoutLock(); logicaldevice == nil {
-		log.Debugw("no-logical-device", log.Fields{"logicalDeviceId": agent.logicalDeviceId, "logicalPortId": lPortId})
+		log.Debugw("no-logical-device", log.Fields{"logicalDeviceId": agent.logicalDeviceID, "logicalPortId": lPortID})
 		return nil
 	}
 	index := -1
 	for i, logicalPort := range logicaldevice.Ports {
-		if logicalPort.Id == lPortId {
+		if logicalPort.Id == lPortID {
 			index = i
 			break
 		}
@@ -1447,9 +1410,8 @@
 	if index >= 0 {
 		logicaldevice.Ports[index].OfpPort.Config = (logicaldevice.Ports[index].OfpPort.Config & ^uint32(ofp.OfpPortConfig_OFPPC_PORT_DOWN)) | uint32(ofp.OfpPortConfig_OFPPC_PORT_DOWN)
 		return agent.updateLogicalDeviceWithoutLock(logicaldevice)
-	} else {
-		return status.Errorf(codes.NotFound, "Port %s on Logical Device %s", lPortId, agent.logicalDeviceId)
 	}
+	return status.Errorf(codes.NotFound, "Port %s on Logical Device %s", lPortID, agent.logicalDeviceID)
 }
 
 func (agent *LogicalDeviceAgent) getPreCalculatedRoute(ingress, egress uint32) []graph.RouteHop {
@@ -1460,10 +1422,11 @@
 			return route
 		}
 	}
-	log.Warnw("no-route", log.Fields{"logicalDeviceId": agent.logicalDeviceId, "ingress": ingress, "egress": egress})
+	log.Warnw("no-route", log.Fields{"logicalDeviceId": agent.logicalDeviceID, "ingress": ingress, "egress": egress})
 	return nil
 }
 
+// GetRoute returns route
 func (agent *LogicalDeviceAgent) GetRoute(ingressPortNo uint32, egressPortNo uint32) []graph.RouteHop {
 	log.Debugw("getting-route", log.Fields{"ingress-port": ingressPortNo, "egress-port": egressPortNo})
 	routes := make([]graph.RouteHop, 0)
@@ -1478,7 +1441,7 @@
 			if len(agent.deviceGraph.Routes) == 0 {
 				// If there are no routes set (usually when the logical device has only NNI port(s), then just return an
 				// route with same IngressHop and EgressHop
-				hop := graph.RouteHop{DeviceID: agent.rootDeviceId, Ingress: ingressPortNo, Egress: ingressPortNo}
+				hop := graph.RouteHop{DeviceID: agent.rootDeviceID, Ingress: ingressPortNo, Egress: ingressPortNo}
 				routes = append(routes, hop)
 				routes = append(routes, hop)
 				return routes
@@ -1552,37 +1515,38 @@
 	return lPorts
 }
 
+// GetDeviceGraph returns device graph
 func (agent *LogicalDeviceAgent) GetDeviceGraph() *graph.DeviceGraph {
 	return agent.deviceGraph
 }
 
 //updateRoutes rebuilds the device graph if not done already
 func (agent *LogicalDeviceAgent) updateRoutes(device *voltha.Device, port *voltha.Port) error {
-	log.Debugf("updateRoutes", log.Fields{"logicalDeviceId": agent.logicalDeviceId, "device": device.Id, "port": port})
+	log.Debugf("updateRoutes", log.Fields{"logicalDeviceId": agent.logicalDeviceID, "device": device.Id, "port": port})
 	agent.lockLogicalDevice.Lock()
 	defer agent.lockLogicalDevice.Unlock()
 	if agent.deviceGraph == nil {
-		agent.deviceGraph = graph.NewDeviceGraph(agent.logicalDeviceId, agent.deviceMgr.GetDevice)
+		agent.deviceGraph = graph.NewDeviceGraph(agent.logicalDeviceID, agent.deviceMgr.GetDevice)
 	}
 	// Get all the logical ports on that logical device
-	if lDevice, err := agent.getLogicalDeviceWithoutLock(); err != nil {
-		log.Errorw("unknown-logical-device", log.Fields{"error": err, "logicalDeviceId": agent.logicalDeviceId})
+	lDevice, err := agent.getLogicalDeviceWithoutLock()
+	if err != nil {
+		log.Errorw("unknown-logical-device", log.Fields{"error": err, "logicalDeviceId": agent.logicalDeviceID})
 		return err
-	} else {
-		//TODO:  Find a better way to refresh only missing routes
-		agent.deviceGraph.ComputeRoutes(lDevice.Ports)
 	}
+	//TODO:  Find a better way to refresh only missing routes
+	agent.deviceGraph.ComputeRoutes(lDevice.Ports)
 	agent.deviceGraph.Print()
 	return nil
 }
 
 //updateDeviceGraph updates the device graph if not done already and setup the default rules as well
 func (agent *LogicalDeviceAgent) updateDeviceGraph(lp *voltha.LogicalPort) {
-	log.Debugf("updateDeviceGraph", log.Fields{"logicalDeviceId": agent.logicalDeviceId})
+	log.Debugf("updateDeviceGraph", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
 	agent.lockLogicalDevice.Lock()
 	defer agent.lockLogicalDevice.Unlock()
 	if agent.deviceGraph == nil {
-		agent.deviceGraph = graph.NewDeviceGraph(agent.logicalDeviceId, agent.deviceMgr.GetDevice)
+		agent.deviceGraph = graph.NewDeviceGraph(agent.logicalDeviceID, agent.deviceMgr.GetDevice)
 	}
 	agent.deviceGraph.AddPort(lp)
 	agent.deviceGraph.Print()
@@ -1590,85 +1554,22 @@
 
 //generateDeviceGraph regenerates the device graph
 func (agent *LogicalDeviceAgent) generateDeviceGraph() {
-	log.Debugw("generateDeviceGraph", log.Fields{"logicalDeviceId": agent.logicalDeviceId})
+	log.Debugw("generateDeviceGraph", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
 	agent.lockLogicalDevice.Lock()
 	defer agent.lockLogicalDevice.Unlock()
 	// Get the latest logical device
 	if ld, err := agent.getLogicalDeviceWithoutLock(); err != nil {
-		log.Errorw("logical-device-not-present", log.Fields{"logicalDeviceId": agent.logicalDeviceId, "error": err})
+		log.Errorw("logical-device-not-present", log.Fields{"logicalDeviceId": agent.logicalDeviceID, "error": err})
 	} else {
-		log.Debugw("generating-graph", log.Fields{"lDeviceId": agent.logicalDeviceId, "lPorts": len(ld.Ports)})
+		log.Debugw("generating-graph", log.Fields{"lDeviceId": agent.logicalDeviceID, "lPorts": len(ld.Ports)})
 		if agent.deviceGraph == nil {
-			agent.deviceGraph = graph.NewDeviceGraph(agent.logicalDeviceId, agent.deviceMgr.GetDevice)
+			agent.deviceGraph = graph.NewDeviceGraph(agent.logicalDeviceID, agent.deviceMgr.GetDevice)
 		}
 		agent.deviceGraph.ComputeRoutes(ld.Ports)
 		agent.deviceGraph.Print()
 	}
 }
 
-// portAdded is a callback invoked when a port is added to the logical device.
-// TODO: To use when POST_ADD is fixed.
-func (agent *LogicalDeviceAgent) portAdded(args ...interface{}) interface{} {
-	log.Debugw("portAdded-callback", log.Fields{"argsLen": len(args)})
-
-	var port *voltha.LogicalPort
-
-	// Sanity check
-	if args[0] != nil {
-		log.Warnw("previous-data-not-nil", log.Fields{"args0": args[0]})
-	}
-	var ok bool
-	if port, ok = args[1].(*voltha.LogicalPort); !ok {
-		log.Errorw("invalid-args", log.Fields{"args1": args[1]})
-		return nil
-	}
-
-	// Set the proxy and callback for that port
-	agent.portProxiesLock.Lock()
-	agent.portProxies[port.Id] = agent.clusterDataProxy.CreateProxy(
-		context.Background(),
-		fmt.Sprintf("/logical_devices/%s/ports/%s", agent.logicalDeviceId, port.Id),
-		false)
-	agent.portProxies[port.Id].RegisterCallback(model.POST_UPDATE, agent.portUpdated)
-	agent.portProxiesLock.Unlock()
-
-	// Send the port change event to the OF controller
-	agent.ldeviceMgr.grpcNbiHdlr.sendChangeEvent(agent.logicalDeviceId,
-		&ofp.OfpPortStatus{Reason: ofp.OfpPortReason_OFPPR_ADD, Desc: port.OfpPort})
-
-	return nil
-}
-
-// portRemoved is a callback invoked when a port is removed from the logical device.
-// TODO: To use when POST_ADD is fixed.
-func (agent *LogicalDeviceAgent) portRemoved(args ...interface{}) interface{} {
-	log.Debugw("portRemoved-callback", log.Fields{"argsLen": len(args)})
-
-	var port *voltha.LogicalPort
-
-	// Sanity check
-	if args[1] != nil {
-		log.Warnw("data-not-nil", log.Fields{"args1": args[1]})
-	}
-	var ok bool
-	if port, ok = args[0].(*voltha.LogicalPort); !ok {
-		log.Errorw("invalid-args", log.Fields{"args0": args[0]})
-		return nil
-	}
-
-	// Remove the proxy and callback for that port
-	agent.portProxiesLock.Lock()
-	agent.portProxies[port.Id].UnregisterCallback(model.POST_UPDATE, agent.portUpdated)
-	delete(agent.portProxies, port.Id)
-	agent.portProxiesLock.Unlock()
-
-	// Send the port change event to the OF controller
-	agent.ldeviceMgr.grpcNbiHdlr.sendChangeEvent(agent.logicalDeviceId,
-		&ofp.OfpPortStatus{Reason: ofp.OfpPortReason_OFPPR_DELETE, Desc: port.OfpPort})
-
-	return nil
-}
-
 // diff go over two lists of logical ports and return what's new, what's changed and what's removed.
 func diff(oldList, newList []*voltha.LogicalPort) (newPorts, changedPorts, deletedPorts []*voltha.LogicalPort) {
 	newPorts = make([]*voltha.LogicalPort, 0)
@@ -1735,15 +1636,15 @@
 
 	// Send the port change events to the OF controller
 	for _, newP := range newPorts {
-		go agent.ldeviceMgr.grpcNbiHdlr.sendChangeEvent(agent.logicalDeviceId,
+		go agent.ldeviceMgr.grpcNbiHdlr.sendChangeEvent(agent.logicalDeviceID,
 			&ofp.OfpPortStatus{Reason: ofp.OfpPortReason_OFPPR_ADD, Desc: newP.OfpPort})
 	}
 	for _, change := range changedPorts {
-		go agent.ldeviceMgr.grpcNbiHdlr.sendChangeEvent(agent.logicalDeviceId,
+		go agent.ldeviceMgr.grpcNbiHdlr.sendChangeEvent(agent.logicalDeviceID,
 			&ofp.OfpPortStatus{Reason: ofp.OfpPortReason_OFPPR_MODIFY, Desc: change.OfpPort})
 	}
 	for _, del := range deletedPorts {
-		go agent.ldeviceMgr.grpcNbiHdlr.sendChangeEvent(agent.logicalDeviceId,
+		go agent.ldeviceMgr.grpcNbiHdlr.sendChangeEvent(agent.logicalDeviceID,
 			&ofp.OfpPortStatus{Reason: ofp.OfpPortReason_OFPPR_DELETE, Desc: del.OfpPort})
 	}
 
@@ -1771,7 +1672,7 @@
 	var portCap *ic.PortCapability
 	var err error
 	// First get the port capability
-	if portCap, err = agent.deviceMgr.getPortCapability(nil, device.Id, port.PortNo); err != nil {
+	if portCap, err = agent.deviceMgr.getPortCapability(context.TODO(), device.Id, port.PortNo); err != nil {
 		log.Errorw("error-retrieving-port-capabilities", log.Fields{"error": err})
 		return false, err
 	}
@@ -1846,7 +1747,7 @@
 	var portCap *ic.PortCapability
 	var err error
 	// First get the port capability
-	if portCap, err = agent.deviceMgr.getPortCapability(nil, childDevice.Id, port.PortNo); err != nil {
+	if portCap, err = agent.deviceMgr.getPortCapability(context.TODO(), childDevice.Id, port.PortNo); err != nil {
 		log.Errorw("error-retrieving-port-capabilities", log.Fields{"error": err})
 		return false, err
 	}
@@ -1858,28 +1759,28 @@
 		return false, nil
 	}
 	// Get stored logical device
-	if ldevice, err := agent.getLogicalDeviceWithoutLock(); err != nil {
-		return false, status.Error(codes.NotFound, agent.logicalDeviceId)
-	} else {
-		log.Debugw("adding-uni", log.Fields{"deviceId": childDevice.Id})
-		portCap.Port.RootPort = false
-		portCap.Port.Id = port.Label
-		portCap.Port.OfpPort.PortNo = port.PortNo
-		portCap.Port.DeviceId = childDevice.Id
-		portCap.Port.DevicePortNo = port.PortNo
-		cloned := (proto.Clone(ldevice)).(*voltha.LogicalDevice)
-		if cloned.Ports == nil {
-			cloned.Ports = make([]*voltha.LogicalPort, 0)
-		}
-		cloned.Ports = append(cloned.Ports, portCap.Port)
-		if err := agent.updateLogicalDeviceWithoutLock(cloned); err != nil {
-			return false, err
-		}
-		// Update the device graph with this new logical port
-		clonedLP := (proto.Clone(portCap.Port)).(*voltha.LogicalPort)
-		go agent.updateDeviceGraph(clonedLP)
-		return true, nil
+	ldevice, err := agent.getLogicalDeviceWithoutLock()
+	if err != nil {
+		return false, status.Error(codes.NotFound, agent.logicalDeviceID)
 	}
+	log.Debugw("adding-uni", log.Fields{"deviceId": childDevice.Id})
+	portCap.Port.RootPort = false
+	portCap.Port.Id = port.Label
+	portCap.Port.OfpPort.PortNo = port.PortNo
+	portCap.Port.DeviceId = childDevice.Id
+	portCap.Port.DevicePortNo = port.PortNo
+	cloned := (proto.Clone(ldevice)).(*voltha.LogicalDevice)
+	if cloned.Ports == nil {
+		cloned.Ports = make([]*voltha.LogicalPort, 0)
+	}
+	cloned.Ports = append(cloned.Ports, portCap.Port)
+	if err := agent.updateLogicalDeviceWithoutLock(cloned); err != nil {
+		return false, err
+	}
+	// Update the device graph with this new logical port
+	clonedLP := (proto.Clone(portCap.Port)).(*voltha.LogicalPort)
+	go agent.updateDeviceGraph(clonedLP)
+	return true, nil
 }
 
 func (agent *LogicalDeviceAgent) packetOut(packet *ofp.OfpPacketOut) {
@@ -1890,19 +1791,19 @@
 	outPort := fu.GetPacketOutPort(packet)
 	//frame := packet.GetData()
 	//TODO: Use a channel between the logical agent and the device agent
-	if err := agent.deviceMgr.packetOut(agent.rootDeviceId, outPort, packet); err != nil {
-		log.Error("packetout-failed", log.Fields{"logicalDeviceID": agent.rootDeviceId})
+	if err := agent.deviceMgr.packetOut(agent.rootDeviceID, outPort, packet); err != nil {
+		log.Error("packetout-failed", log.Fields{"logicalDeviceID": agent.rootDeviceID})
 	}
 }
 
-func (agent *LogicalDeviceAgent) packetIn(port uint32, transactionId string, packet []byte) {
+func (agent *LogicalDeviceAgent) packetIn(port uint32, transactionID string, packet []byte) {
 	log.Debugw("packet-in", log.Fields{
 		"port":          port,
 		"packet":        hex.EncodeToString(packet),
-		"transactionId": transactionId,
+		"transactionId": transactionID,
 	})
 	packetIn := fu.MkPacketIn(port, packet)
-	agent.ldeviceMgr.grpcNbiHdlr.sendPacketIn(agent.logicalDeviceId, transactionId, packetIn)
+	agent.ldeviceMgr.grpcNbiHdlr.sendPacketIn(agent.logicalDeviceID, transactionID, packetIn)
 	log.Debugw("sending-packet-in", log.Fields{"packet": hex.EncodeToString(packetIn.Data)})
 }
 
@@ -1924,14 +1825,6 @@
 	}
 }
 
-func (agent *LogicalDeviceAgent) deleteLogicalPortFromMap(portNo uint32) {
-	agent.lockLogicalPortsNo.Lock()
-	defer agent.lockLogicalPortsNo.Unlock()
-	if exist := agent.logicalPortsNo[portNo]; exist {
-		delete(agent.logicalPortsNo, portNo)
-	}
-}
-
 func (agent *LogicalDeviceAgent) isNNIPort(portNo uint32) bool {
 	agent.lockLogicalPortsNo.RLock()
 	defer agent.lockLogicalPortsNo.RUnlock()
diff --git a/rw_core/core/logical_device_manager.go b/rw_core/core/logical_device_manager.go
index ebe72b3..8c326a8 100644
--- a/rw_core/core/logical_device_manager.go
+++ b/rw_core/core/logical_device_manager.go
@@ -13,11 +13,15 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package core
 
 import (
 	"context"
 	"errors"
+	"strings"
+	"sync"
+
 	"github.com/opencord/voltha-go/db/model"
 	"github.com/opencord/voltha-lib-go/v2/pkg/kafka"
 	"github.com/opencord/voltha-lib-go/v2/pkg/log"
@@ -26,16 +30,14 @@
 	"github.com/opencord/voltha-protos/v2/go/voltha"
 	"google.golang.org/grpc/codes"
 	"google.golang.org/grpc/status"
-	"strings"
-	"sync"
 )
 
+// LogicalDeviceManager represent logical device manager attributes
 type LogicalDeviceManager struct {
 	logicalDeviceAgents            sync.Map
 	core                           *Core
 	deviceMgr                      *DeviceManager
 	grpcNbiHdlr                    *APIHandler
-	adapterProxy                   *AdapterProxy
 	kafkaICProxy                   *kafka.InterContainerProxy
 	clusterDataProxy               *model.Proxy
 	exitChannel                    chan int
@@ -87,34 +89,29 @@
 }
 
 func (ldMgr *LogicalDeviceManager) addLogicalDeviceAgentToMap(agent *LogicalDeviceAgent) {
-	if _, exist := ldMgr.logicalDeviceAgents.Load(agent.logicalDeviceId); !exist {
-		ldMgr.logicalDeviceAgents.Store(agent.logicalDeviceId, agent)
+	if _, exist := ldMgr.logicalDeviceAgents.Load(agent.logicalDeviceID); !exist {
+		ldMgr.logicalDeviceAgents.Store(agent.logicalDeviceID, agent)
 	}
 }
 
-func (ldMgr *LogicalDeviceManager) isLogicalDeviceInCache(logicalDeviceId string) bool {
-	_, inCache := ldMgr.logicalDeviceAgents.Load(logicalDeviceId)
-	return inCache
-}
-
 // getLogicalDeviceAgent returns the logical device agent.  If the device is not in memory then the device will
 // be loaded from dB and a logical device agent created to managed it.
-func (ldMgr *LogicalDeviceManager) getLogicalDeviceAgent(logicalDeviceId string) *LogicalDeviceAgent {
-	if agent, ok := ldMgr.logicalDeviceAgents.Load(logicalDeviceId); ok {
+func (ldMgr *LogicalDeviceManager) getLogicalDeviceAgent(logicalDeviceID string) *LogicalDeviceAgent {
+	agent, ok := ldMgr.logicalDeviceAgents.Load(logicalDeviceID)
+	if ok {
 		return agent.(*LogicalDeviceAgent)
-	} else {
-		//	Try to load into memory - loading will also create the logical device agent
-		if err := ldMgr.load(logicalDeviceId); err == nil {
-			if agent, ok = ldMgr.logicalDeviceAgents.Load(logicalDeviceId); ok {
-				return agent.(*LogicalDeviceAgent)
-			}
+	}
+	//	Try to load into memory - loading will also create the logical device agent
+	if err := ldMgr.load(logicalDeviceID); err == nil {
+		if agent, ok = ldMgr.logicalDeviceAgents.Load(logicalDeviceID); ok {
+			return agent.(*LogicalDeviceAgent)
 		}
 	}
 	return nil
 }
 
-func (ldMgr *LogicalDeviceManager) deleteLogicalDeviceAgent(logicalDeviceId string) {
-	ldMgr.logicalDeviceAgents.Delete(logicalDeviceId)
+func (ldMgr *LogicalDeviceManager) deleteLogicalDeviceAgent(logicalDeviceID string) {
+	ldMgr.logicalDeviceAgents.Delete(logicalDeviceID)
 }
 
 // GetLogicalDevice provides a cloned most up to date logical device.  If device is not in memory
@@ -176,12 +173,17 @@
 	ldMgr.addLogicalDeviceAgentToMap(agent)
 
 	// Update the root device with the logical device Id reference
-	if err := ldMgr.deviceMgr.setParentId(device, id); err != nil {
+	if err := ldMgr.deviceMgr.setParentID(device, id); err != nil {
 		log.Errorw("failed-setting-parent-id", log.Fields{"logicalDeviceId": id, "deviceId": device.Id})
 		return nil, err
 	}
 
-	go agent.start(ctx, false)
+	go func() {
+		err := agent.start(ctx, false)
+		if err != nil {
+			log.Errorw("unable-to-create-the-logical-device", log.Fields{"error": err})
+		}
+	}()
 
 	log.Debug("creating-logical-device-ends")
 	return &id, nil
@@ -190,62 +192,62 @@
 // stopManagingLogicalDeviceWithDeviceId stops the management of the logical device.  This implies removal of any
 // reference of this logical device in cache.  The device Id is passed as param because the logical device may already
 // have been removed from the model.  This function returns the logical device Id if found
-func (ldMgr *LogicalDeviceManager) stopManagingLogicalDeviceWithDeviceId(id string) string {
+func (ldMgr *LogicalDeviceManager) stopManagingLogicalDeviceWithDeviceID(id string) string {
 	log.Infow("stop-managing-logical-device", log.Fields{"deviceId": id})
 	// Go over the list of logical device agents to find the one which has rootDeviceId as id
-	var ldId = ""
+	var ldID = ""
 	ldMgr.logicalDeviceAgents.Range(func(key, value interface{}) bool {
 		ldAgent := value.(*LogicalDeviceAgent)
-		if ldAgent.rootDeviceId == id {
+		if ldAgent.rootDeviceID == id {
 			log.Infow("stopping-logical-device-agent", log.Fields{"lDeviceId": key})
-			ldAgent.stop(nil)
-			ldId = key.(string)
-			ldMgr.logicalDeviceAgents.Delete(ldId)
+			ldAgent.stop(context.TODO())
+			ldID = key.(string)
+			ldMgr.logicalDeviceAgents.Delete(ldID)
 		}
 		return true
 	})
-	return ldId
+	return ldID
 }
 
 //getLogicalDeviceFromModel retrieves the logical device data from the model.
-func (ldMgr *LogicalDeviceManager) getLogicalDeviceFromModel(lDeviceId string) (*voltha.LogicalDevice, error) {
-	if logicalDevice := ldMgr.clusterDataProxy.Get(context.Background(), "/logical_devices/"+lDeviceId, 0, false, ""); logicalDevice != nil {
+func (ldMgr *LogicalDeviceManager) getLogicalDeviceFromModel(lDeviceID string) (*voltha.LogicalDevice, error) {
+	if logicalDevice := ldMgr.clusterDataProxy.Get(context.Background(), "/logical_devices/"+lDeviceID, 0, false, ""); logicalDevice != nil {
 		if lDevice, ok := logicalDevice.(*voltha.LogicalDevice); ok {
 			return lDevice, nil
 		}
 	}
-	return nil, status.Error(codes.NotFound, lDeviceId)
+	return nil, status.Error(codes.NotFound, lDeviceID)
 }
 
 // load loads a logical device manager in memory
-func (ldMgr *LogicalDeviceManager) load(lDeviceId string) error {
-	if lDeviceId == "" {
+func (ldMgr *LogicalDeviceManager) load(lDeviceID string) error {
+	if lDeviceID == "" {
 		return nil
 	}
 	// Add a lock to prevent two concurrent calls from loading the same device twice
 	ldMgr.logicalDevicesLoadingLock.Lock()
-	if _, exist := ldMgr.logicalDeviceLoadingInProgress[lDeviceId]; !exist {
-		if ldAgent, _ := ldMgr.logicalDeviceAgents.Load(lDeviceId); ldAgent == nil {
-			ldMgr.logicalDeviceLoadingInProgress[lDeviceId] = []chan int{make(chan int, 1)}
+	if _, exist := ldMgr.logicalDeviceLoadingInProgress[lDeviceID]; !exist {
+		if ldAgent, _ := ldMgr.logicalDeviceAgents.Load(lDeviceID); ldAgent == nil {
+			ldMgr.logicalDeviceLoadingInProgress[lDeviceID] = []chan int{make(chan int, 1)}
 			ldMgr.logicalDevicesLoadingLock.Unlock()
-			if _, err := ldMgr.getLogicalDeviceFromModel(lDeviceId); err == nil {
-				log.Debugw("loading-logical-device", log.Fields{"lDeviceId": lDeviceId})
-				agent := newLogicalDeviceAgent(lDeviceId, "", ldMgr, ldMgr.deviceMgr, ldMgr.clusterDataProxy, ldMgr.defaultTimeout)
-				if err := agent.start(nil, true); err != nil {
-					agent.stop(nil)
+			if _, err := ldMgr.getLogicalDeviceFromModel(lDeviceID); err == nil {
+				log.Debugw("loading-logical-device", log.Fields{"lDeviceId": lDeviceID})
+				agent := newLogicalDeviceAgent(lDeviceID, "", ldMgr, ldMgr.deviceMgr, ldMgr.clusterDataProxy, ldMgr.defaultTimeout)
+				if err := agent.start(context.TODO(), true); err != nil {
+					agent.stop(context.TODO())
 				} else {
-					ldMgr.logicalDeviceAgents.Store(agent.logicalDeviceId, agent)
+					ldMgr.logicalDeviceAgents.Store(agent.logicalDeviceID, agent)
 				}
 			} else {
-				log.Debugw("logicalDevice not in model", log.Fields{"lDeviceId": lDeviceId})
+				log.Debugw("logicalDevice not in model", log.Fields{"lDeviceId": lDeviceID})
 			}
 			// announce completion of task to any number of waiting channels
 			ldMgr.logicalDevicesLoadingLock.Lock()
-			if v, ok := ldMgr.logicalDeviceLoadingInProgress[lDeviceId]; ok {
+			if v, ok := ldMgr.logicalDeviceLoadingInProgress[lDeviceID]; ok {
 				for _, ch := range v {
 					close(ch)
 				}
-				delete(ldMgr.logicalDeviceLoadingInProgress, lDeviceId)
+				delete(ldMgr.logicalDeviceLoadingInProgress, lDeviceID)
 			}
 			ldMgr.logicalDevicesLoadingLock.Unlock()
 		} else {
@@ -253,15 +255,15 @@
 		}
 	} else {
 		ch := make(chan int, 1)
-		ldMgr.logicalDeviceLoadingInProgress[lDeviceId] = append(ldMgr.logicalDeviceLoadingInProgress[lDeviceId], ch)
+		ldMgr.logicalDeviceLoadingInProgress[lDeviceID] = append(ldMgr.logicalDeviceLoadingInProgress[lDeviceID], ch)
 		ldMgr.logicalDevicesLoadingLock.Unlock()
 		//	Wait for the channel to be closed, implying the process loading this device is done.
 		<-ch
 	}
-	if _, exist := ldMgr.logicalDeviceAgents.Load(lDeviceId); exist {
+	if _, exist := ldMgr.logicalDeviceAgents.Load(lDeviceID); exist {
 		return nil
 	}
-	return status.Errorf(codes.Aborted, "Error loading logical device %s", lDeviceId)
+	return status.Errorf(codes.Aborted, "Error loading logical device %s", lDeviceID)
 }
 
 func (ldMgr *LogicalDeviceManager) deleteLogicalDevice(ctx context.Context, device *voltha.Device) error {
@@ -270,20 +272,23 @@
 	if !device.Root {
 		return errors.New("device-not-root")
 	}
-	logDeviceId := device.ParentId
-	if agent := ldMgr.getLogicalDeviceAgent(logDeviceId); agent != nil {
+	logDeviceID := device.ParentId
+	if agent := ldMgr.getLogicalDeviceAgent(logDeviceID); agent != nil {
 		// Stop the logical device agent
 		agent.stop(ctx)
 		//Remove the logical device agent from the Map
-		ldMgr.deleteLogicalDeviceAgent(logDeviceId)
-		ldMgr.core.deviceOwnership.AbandonDevice(logDeviceId)
+		ldMgr.deleteLogicalDeviceAgent(logDeviceID)
+		err := ldMgr.core.deviceOwnership.AbandonDevice(logDeviceID)
+		if err != nil {
+			log.Errorw("unable-to-abandon-the-device", log.Fields{"error": err})
+		}
 	}
 
 	log.Debug("deleting-logical-device-ends")
 	return nil
 }
 
-func (ldMgr *LogicalDeviceManager) getLogicalDeviceId(device *voltha.Device) (*string, error) {
+func (ldMgr *LogicalDeviceManager) getLogicalDeviceID(device *voltha.Device) (*string, error) {
 	// Device can either be a parent or a child device
 	if device.Root {
 		// Parent device.  The ID of a parent device is the logical device ID
@@ -297,36 +302,37 @@
 	return nil, status.Errorf(codes.NotFound, "%s", device.Id)
 }
 
-func (ldMgr *LogicalDeviceManager) getLogicalDeviceIdFromDeviceId(deviceId string) (*string, error) {
+func (ldMgr *LogicalDeviceManager) getLogicalDeviceIDFromDeviceID(deviceID string) (*string, error) {
 	// Get the device
 	var device *voltha.Device
 	var err error
-	if device, err = ldMgr.deviceMgr.GetDevice(deviceId); err != nil {
+	if device, err = ldMgr.deviceMgr.GetDevice(deviceID); err != nil {
 		return nil, err
 	}
-	return ldMgr.getLogicalDeviceId(device)
+	return ldMgr.getLogicalDeviceID(device)
 }
 
-func (ldMgr *LogicalDeviceManager) getLogicalPortId(device *voltha.Device) (*voltha.LogicalPortId, error) {
+func (ldMgr *LogicalDeviceManager) getLogicalPortID(device *voltha.Device) (*voltha.LogicalPortId, error) {
 	// Get the logical device where this device is attached
-	var lDeviceId *string
+	var lDeviceID *string
 	var err error
-	if lDeviceId, err = ldMgr.getLogicalDeviceId(device); err != nil {
+	if lDeviceID, err = ldMgr.getLogicalDeviceID(device); err != nil {
 		return nil, err
 	}
 	var lDevice *voltha.LogicalDevice
-	if lDevice, err = ldMgr.getLogicalDevice(*lDeviceId); err != nil {
+	if lDevice, err = ldMgr.getLogicalDevice(*lDeviceID); err != nil {
 		return nil, err
 	}
 	// Go over list of ports
 	for _, port := range lDevice.Ports {
 		if port.DeviceId == device.Id {
-			return &voltha.LogicalPortId{Id: *lDeviceId, PortId: port.Id}, nil
+			return &voltha.LogicalPortId{Id: *lDeviceID, PortId: port.Id}, nil
 		}
 	}
 	return nil, status.Errorf(codes.NotFound, "%s", device.Id)
 }
 
+// ListLogicalDeviceFlows returns the flows of logical device
 func (ldMgr *LogicalDeviceManager) ListLogicalDeviceFlows(ctx context.Context, id string) (*openflow_13.Flows, error) {
 	log.Debugw("ListLogicalDeviceFlows", log.Fields{"logicaldeviceid": id})
 	if agent := ldMgr.getLogicalDeviceAgent(id); agent != nil {
@@ -335,6 +341,7 @@
 	return nil, status.Errorf(codes.NotFound, "%s", id)
 }
 
+// ListLogicalDeviceFlowGroups returns logical device flow groups
 func (ldMgr *LogicalDeviceManager) ListLogicalDeviceFlowGroups(ctx context.Context, id string) (*openflow_13.FlowGroups, error) {
 	log.Debugw("ListLogicalDeviceFlowGroups", log.Fields{"logicaldeviceid": id})
 	if agent := ldMgr.getLogicalDeviceAgent(id); agent != nil {
@@ -343,6 +350,7 @@
 	return nil, status.Errorf(codes.NotFound, "%s", id)
 }
 
+// ListLogicalDevicePorts returns logical device ports
 func (ldMgr *LogicalDeviceManager) ListLogicalDevicePorts(ctx context.Context, id string) (*voltha.LogicalPorts, error) {
 	log.Debugw("ListLogicalDevicePorts", log.Fields{"logicaldeviceid": id})
 	if agent := ldMgr.getLogicalDeviceAgent(id); agent != nil {
@@ -351,73 +359,56 @@
 	return nil, status.Errorf(codes.NotFound, "%s", id)
 }
 
-func (ldMgr *LogicalDeviceManager) getLogicalPort(lPortId *voltha.LogicalPortId) (*voltha.LogicalPort, error) {
+func (ldMgr *LogicalDeviceManager) getLogicalPort(lPortID *voltha.LogicalPortId) (*voltha.LogicalPort, error) {
 	// Get the logical device where this device is attached
 	var err error
 	var lDevice *voltha.LogicalDevice
-	if lDevice, err = ldMgr.getLogicalDevice(lPortId.Id); err != nil {
+	if lDevice, err = ldMgr.getLogicalDevice(lPortID.Id); err != nil {
 		return nil, err
 	}
 	// Go over list of ports
 	for _, port := range lDevice.Ports {
-		if port.Id == lPortId.PortId {
+		if port.Id == lPortID.PortId {
 			return port, nil
 		}
 	}
-	return nil, status.Errorf(codes.NotFound, "%s-%s", lPortId.Id, lPortId.PortId)
+	return nil, status.Errorf(codes.NotFound, "%s-%s", lPortID.Id, lPortID.PortId)
 }
 
 // updateLogicalPort sets up a logical port on the logical device based on the device port
 // information, if needed
 func (ldMgr *LogicalDeviceManager) updateLogicalPort(device *voltha.Device, port *voltha.Port) error {
-	if ldID, err := ldMgr.getLogicalDeviceId(device); err != nil || *ldID == "" {
+	ldID, err := ldMgr.getLogicalDeviceID(device)
+	if err != nil || *ldID == "" {
 		// This is not an error as the logical device may not have been created at this time.  In such a case,
 		// the ports will be created when the logical device is ready.
 		return nil
-	} else {
-		if agent := ldMgr.getLogicalDeviceAgent(*ldID); agent != nil {
-			if err := agent.updateLogicalPort(device, port); err != nil {
-				return err
-			}
-		}
 	}
-	return nil
-}
-
-// addLogicalPort sets up a logical port on the logical device based on the device port
-// information.
-func (ldMgr *LogicalDeviceManager) addLogicalPort(device *voltha.Device, port *voltha.Port) error {
-	if ldID, err := ldMgr.getLogicalDeviceId(device); err != nil || *ldID == "" {
-		// This is not an error as the logical device may not have been created at this time.  In such a case,
-		// the ports will be created when the logical device is ready.
-		return nil
-	} else {
-		if agent := ldMgr.getLogicalDeviceAgent(*ldID); agent != nil {
-			if err := agent.addLogicalPort(device, port); err != nil {
-				return err
-			}
+	if agent := ldMgr.getLogicalDeviceAgent(*ldID); agent != nil {
+		if err := agent.updateLogicalPort(device, port); err != nil {
+			return err
 		}
 	}
 	return nil
 }
 
 // deleteLogicalPort removes the logical port associated with a device
-func (ldMgr *LogicalDeviceManager) deleteLogicalPort(ctx context.Context, lPortId *voltha.LogicalPortId) error {
-	log.Debugw("deleting-logical-port", log.Fields{"LDeviceId": lPortId.Id})
+func (ldMgr *LogicalDeviceManager) deleteLogicalPort(ctx context.Context, lPortID *voltha.LogicalPortId) error {
+	log.Debugw("deleting-logical-port", log.Fields{"LDeviceId": lPortID.Id})
 	// Get logical port
 	var logicalPort *voltha.LogicalPort
 	var err error
-	if logicalPort, err = ldMgr.getLogicalPort(lPortId); err != nil {
-		log.Debugw("no-logical-device-port-present", log.Fields{"logicalPortId": lPortId.PortId})
+	if logicalPort, err = ldMgr.getLogicalPort(lPortID); err != nil {
+		log.Debugw("no-logical-device-port-present", log.Fields{"logicalPortId": lPortID.PortId})
 		return err
 	}
 	// Sanity check
 	if logicalPort.RootPort {
 		return errors.New("device-root")
 	}
-	if agent := ldMgr.getLogicalDeviceAgent(lPortId.Id); agent != nil {
+	if agent := ldMgr.getLogicalDeviceAgent(lPortID.Id); agent != nil {
 		if err := agent.deleteLogicalPort(logicalPort); err != nil {
-			log.Warnw("deleting-logicalport-failed", log.Fields{"LDeviceId": lPortId.Id, "error": err})
+			log.Warnw("deleting-logicalport-failed", log.Fields{"LDeviceId": lPortID.Id, "error": err})
 		}
 	}
 
@@ -426,17 +417,17 @@
 }
 
 // deleteLogicalPort removes the logical port associated with a child device
-func (ldMgr *LogicalDeviceManager) deleteLogicalPorts(deviceId string) error {
-	log.Debugw("deleting-logical-ports", log.Fields{"deviceId": deviceId})
+func (ldMgr *LogicalDeviceManager) deleteLogicalPorts(deviceID string) error {
+	log.Debugw("deleting-logical-ports", log.Fields{"deviceId": deviceID})
 	// Get logical port
-	if ldId, err := ldMgr.getLogicalDeviceIdFromDeviceId(deviceId); err != nil {
+	ldID, err := ldMgr.getLogicalDeviceIDFromDeviceID(deviceID)
+	if err != nil {
 		return err
-	} else {
-		if agent := ldMgr.getLogicalDeviceAgent(*ldId); agent != nil {
-			if err = agent.deleteLogicalPorts(deviceId); err != nil {
-				log.Warnw("deleteLogicalPorts-failed", log.Fields{"ldeviceId": *ldId})
-				return err
-			}
+	}
+	if agent := ldMgr.getLogicalDeviceAgent(*ldID); agent != nil {
+		if err = agent.deleteLogicalPorts(deviceID); err != nil {
+			log.Warnw("deleteLogicalPorts-failed", log.Fields{"ldeviceId": *ldID})
+			return err
 		}
 	}
 	log.Debug("deleting-logical-port-ends")
@@ -451,16 +442,16 @@
 	}
 
 	// Get the logical device id parent device
-	parentId := childDevice.ParentId
-	logDeviceId := ldMgr.deviceMgr.GetParentDeviceId(parentId)
+	parentID := childDevice.ParentId
+	logDeviceID := ldMgr.deviceMgr.GetParentDeviceID(parentID)
 
-	log.Debugw("setupUNILogicalPorts", log.Fields{"logDeviceId": logDeviceId, "parentId": parentId})
+	log.Debugw("setupUNILogicalPorts", log.Fields{"logDeviceId": logDeviceID, "parentId": parentID})
 
-	if parentId == "" || logDeviceId == "" {
+	if parentID == "" || logDeviceID == "" {
 		return errors.New("device-in-invalid-state")
 	}
 
-	if agent := ldMgr.getLogicalDeviceAgent(logDeviceId); agent != nil {
+	if agent := ldMgr.getLogicalDeviceAgent(logDeviceID); agent != nil {
 		if err := agent.setupUNILogicalPorts(ctx, childDevice); err != nil {
 			return err
 		}
@@ -471,32 +462,32 @@
 func (ldMgr *LogicalDeviceManager) deleteAllLogicalPorts(device *voltha.Device) error {
 	log.Debugw("deleteAllLogicalPorts", log.Fields{"deviceId": device.Id})
 
-	var ldId *string
+	var ldID *string
 	var err error
 	//Get the logical device Id for this device
-	if ldId, err = ldMgr.getLogicalDeviceId(device); err != nil {
+	if ldID, err = ldMgr.getLogicalDeviceID(device); err != nil {
 		log.Warnw("no-logical-device-found", log.Fields{"deviceId": device.Id, "error": err})
 		return err
 	}
-	if agent := ldMgr.getLogicalDeviceAgent(*ldId); agent != nil {
+	if agent := ldMgr.getLogicalDeviceAgent(*ldID); agent != nil {
 		if err := agent.deleteAllLogicalPorts(device); err != nil {
 			return err
 		}
 	}
 	return nil
 }
-func (ldMgr *LogicalDeviceManager) updatePortState(deviceId string, portNo uint32, state voltha.OperStatus_OperStatus) error {
-	log.Debugw("updatePortState", log.Fields{"deviceId": deviceId, "state": state, "portNo": portNo})
+func (ldMgr *LogicalDeviceManager) updatePortState(deviceID string, portNo uint32, state voltha.OperStatus_OperStatus) error {
+	log.Debugw("updatePortState", log.Fields{"deviceId": deviceID, "state": state, "portNo": portNo})
 
-	var ldId *string
+	var ldID *string
 	var err error
 	//Get the logical device Id for this device
-	if ldId, err = ldMgr.getLogicalDeviceIdFromDeviceId(deviceId); err != nil {
-		log.Warnw("no-logical-device-found", log.Fields{"deviceId": deviceId, "error": err})
+	if ldID, err = ldMgr.getLogicalDeviceIDFromDeviceID(deviceID); err != nil {
+		log.Warnw("no-logical-device-found", log.Fields{"deviceId": deviceID, "error": err})
 		return err
 	}
-	if agent := ldMgr.getLogicalDeviceAgent(*ldId); agent != nil {
-		if err := agent.updatePortState(deviceId, portNo, state); err != nil {
+	if agent := ldMgr.getLogicalDeviceAgent(*ldID); agent != nil {
+		if err := agent.updatePortState(deviceID, portNo, state); err != nil {
 			return err
 		}
 	}
@@ -506,14 +497,14 @@
 func (ldMgr *LogicalDeviceManager) updatePortsState(device *voltha.Device, state voltha.AdminState_AdminState) error {
 	log.Debugw("updatePortsState", log.Fields{"deviceId": device.Id, "state": state, "current-data": device})
 
-	var ldId *string
+	var ldID *string
 	var err error
 	//Get the logical device Id for this device
-	if ldId, err = ldMgr.getLogicalDeviceId(device); err != nil {
+	if ldID, err = ldMgr.getLogicalDeviceID(device); err != nil {
 		log.Warnw("no-logical-device-found", log.Fields{"deviceId": device.Id, "error": err})
 		return err
 	}
-	if agent := ldMgr.getLogicalDeviceAgent(*ldId); agent != nil {
+	if agent := ldMgr.getLogicalDeviceAgent(*ldID); agent != nil {
 		if err := agent.updatePortsState(device, state); err != nil {
 			return err
 		}
@@ -545,6 +536,7 @@
 	sendAPIResponse(ctx, ch, res)
 }
 
+// ListLogicalDeviceMeters returns logical device meters
 func (ldMgr *LogicalDeviceManager) ListLogicalDeviceMeters(ctx context.Context, id string) (*openflow_13.Meters, error) {
 	log.Debugw("ListLogicalDeviceMeters", log.Fields{"logicalDeviceId": id})
 	if agent := ldMgr.getLogicalDeviceAgent(id); agent != nil {
@@ -567,7 +559,6 @@
 func (ldMgr *LogicalDeviceManager) enableLogicalPort(ctx context.Context, id *voltha.LogicalPortId, ch chan interface{}) {
 	log.Debugw("enableLogicalPort", log.Fields{"logicalDeviceId": id})
 	var res interface{}
-
 	if agent := ldMgr.getLogicalDeviceAgent(id.Id); agent != nil {
 		res = agent.enableLogicalPort(id.PortId)
 		log.Debugw("enableLogicalPort-result", log.Fields{"result": res})
@@ -580,7 +571,6 @@
 func (ldMgr *LogicalDeviceManager) disableLogicalPort(ctx context.Context, id *voltha.LogicalPortId, ch chan interface{}) {
 	log.Debugw("disableLogicalPort", log.Fields{"logicalDeviceId": id})
 	var res interface{}
-
 	if agent := ldMgr.getLogicalDeviceAgent(id.Id); agent != nil {
 		res = agent.disableLogicalPort(id.PortId)
 		log.Debugw("disableLogicalPort-result", log.Fields{"result": res})
@@ -590,21 +580,12 @@
 	sendAPIResponse(ctx, ch, res)
 }
 
-func (ldMgr *LogicalDeviceManager) packetOut(packetOut *openflow_13.PacketOut) {
-	log.Debugw("packetOut", log.Fields{"logicalDeviceId": packetOut.Id})
-	if agent := ldMgr.getLogicalDeviceAgent(packetOut.Id); agent != nil {
-		agent.packetOut(packetOut.PacketOut)
+func (ldMgr *LogicalDeviceManager) packetIn(logicalDeviceID string, port uint32, transactionID string, packet []byte) error {
+	log.Debugw("packetIn", log.Fields{"logicalDeviceId": logicalDeviceID, "port": port})
+	if agent := ldMgr.getLogicalDeviceAgent(logicalDeviceID); agent != nil {
+		agent.packetIn(port, transactionID, packet)
 	} else {
-		log.Error("logical-device-not-exist", log.Fields{"logicalDeviceId": packetOut.Id})
-	}
-}
-
-func (ldMgr *LogicalDeviceManager) packetIn(logicalDeviceId string, port uint32, transactionId string, packet []byte) error {
-	log.Debugw("packetIn", log.Fields{"logicalDeviceId": logicalDeviceId, "port": port})
-	if agent := ldMgr.getLogicalDeviceAgent(logicalDeviceId); agent != nil {
-		agent.packetIn(port, transactionId, packet)
-	} else {
-		log.Error("logical-device-not-exist", log.Fields{"logicalDeviceId": logicalDeviceId})
+		log.Error("logical-device-not-exist", log.Fields{"logicalDeviceId": logicalDeviceID})
 	}
 	return nil
 }
diff --git a/rw_core/core/transaction.go b/rw_core/core/transaction.go
index 4ce00f9..1f63deb 100644
--- a/rw_core/core/transaction.go
+++ b/rw_core/core/transaction.go
@@ -26,29 +26,32 @@
  * and then deletes the transaction key.
  *
  */
+
 package core
 
 import (
+	"time"
+
 	"github.com/opencord/voltha-lib-go/v2/pkg/db/kvstore"
 	"github.com/opencord/voltha-lib-go/v2/pkg/log"
 	"google.golang.org/grpc/codes"
 	"google.golang.org/grpc/status"
-	"time"
 )
 
 // Transaction acquisition results
 const (
 	UNKNOWN = iota
-	SEIZED_BY_SELF
-	COMPLETED_BY_OTHER
-	ABANDONED_BY_OTHER
-	ABANDONED_WATCH_BY_SELF
+	SeizedBySelf
+	CompletedByOther
+	AbandonedByOther
+	AbandonedWatchBySelf
 )
 
 var errorTransactionNotAcquired = status.Error(codes.Canceled, "transaction-not-acquired")
 
+// Transaction constant
 const (
-	TRANSACTION_COMPLETE = "TRANSACTION-COMPLETE"
+	TransactionComplete = "TRANSACTION-COMPLETE"
 )
 
 // Transaction constants used to guarantee the Core processing a request hold on to the transaction until
@@ -62,11 +65,12 @@
 // Since the MIN_TXN_RENEWAL_INTERVAL_IN_SEC is 3 seconds then for any transaction that completes within 3 seconds
 // there won't be a transaction renewal done.
 const (
-	NUM_TXN_RENEWAL_PER_REQUEST         = 2
-	MIN_TXN_RENEWAL_INTERVAL_IN_SEC     = 3
-	MIN_TXN_RESERVATION_DURATION_IN_SEC = 5
+	NumTxnRenewalPerRequest        = 2
+	MinTxnRenewalIntervalInSec     = 3
+	MinTxnReservationDurationInSec = 5
 )
 
+// TransactionContext represent transaction context attributes
 type TransactionContext struct {
 	kvClient           kvstore.Client
 	kvOperationTimeout int
@@ -84,9 +88,13 @@
 	"ABANDONED_WATCH_BY_SELF"}
 
 func init() {
-	log.AddPackage(log.JSON, log.DebugLevel, nil)
+	_, err := log.AddPackage(log.JSON, log.DebugLevel, nil)
+	if err != nil {
+		log.Errorw("unable-to-register-package-to-the-log-map", log.Fields{"error": err})
+	}
 }
 
+// NewTransactionContext creates transaction context instance
 func NewTransactionContext(
 	owner string,
 	txnPrefix string,
@@ -102,7 +110,7 @@
 
 /*
  * Before instantiating a KVTransaction, a TransactionContext must be created.
- * The parameters stored in the context govern the behaviour of all KVTransaction
+ * The parameters stored in the context govern the behavior of all KVTransaction
  * instances.
  *
  * :param owner: The owner (i.e. voltha core name) of a transaction
@@ -113,6 +121,8 @@
  * :param: kvOpTimeout: The maximum time, in seconds, to be taken by any KV operation
  *                      used by this package
  */
+
+// SetTransactionContext creates new transaction context
 func SetTransactionContext(owner string,
 	txnPrefix string,
 	kvClient kvstore.Client,
@@ -122,9 +132,10 @@
 	return nil
 }
 
+// KVTransaction represent KV transaction attributes
 type KVTransaction struct {
 	monitorCh chan int
-	txnId     string
+	txnID     string
 	txnKey    string
 }
 
@@ -134,10 +145,12 @@
  * :param txnId: The serial number of a voltha request.
  * :return: A KVTransaction instance
  */
-func NewKVTransaction(txnId string) *KVTransaction {
+
+// NewKVTransaction creates KV transaction instance
+func NewKVTransaction(txnID string) *KVTransaction {
 	return &KVTransaction{
-		txnId:  txnId,
-		txnKey: ctx.txnPrefix + txnId}
+		txnID:  txnID,
+		txnKey: ctx.txnPrefix + txnID}
 }
 
 /*
@@ -158,9 +171,11 @@
  * :return: A boolean specifying whether the resource was acquired. An error is return in case this function is invoked
  * for a resource that is nonexistent.
  */
+
+// Acquired aquires transaction status
 func (c *KVTransaction) Acquired(minDuration int64, ownedByMe ...bool) (bool, error) {
 	var acquired bool
-	var currOwner string = ""
+	var currOwner string
 	var res int
 
 	// Convert milliseconds to seconds, rounding up
@@ -169,8 +184,8 @@
 	if remainder := minDuration % 1000; remainder > 0 {
 		durationInSecs++
 	}
-	if durationInSecs < int64(MIN_TXN_RESERVATION_DURATION_IN_SEC) {
-		durationInSecs = int64(MIN_TXN_RESERVATION_DURATION_IN_SEC)
+	if durationInSecs < int64(MinTxnReservationDurationInSec) {
+		durationInSecs = int64(MinTxnReservationDurationInSec)
 	}
 	genericRequest := true
 	resourceOwned := false
@@ -183,36 +198,37 @@
 		// transaction key stays in the KV store until after the Core finalize a request timeout condition (which is
 		// a success from a request completion perspective).
 		if err := c.tryToReserveTxn(durationInSecs * 2); err == nil {
-			res = SEIZED_BY_SELF
+			res = SeizedBySelf
 		} else {
 			log.Debugw("watch-other-server",
-				log.Fields{"transactionId": c.txnId, "owner": currOwner, "timeout": durationInSecs})
+				log.Fields{"transactionId": c.txnID, "owner": currOwner, "timeout": durationInSecs})
 			res = c.Watch(durationInSecs)
 		}
 	} else {
 		res = c.Watch(durationInSecs)
 	}
 	switch res {
-	case SEIZED_BY_SELF, ABANDONED_BY_OTHER:
+	case SeizedBySelf, AbandonedByOther:
 		acquired = true
 	default:
 		acquired = false
 	}
-	log.Debugw("acquire-transaction-status", log.Fields{"transactionId": c.txnId, "acquired": acquired, "result": txnState[res]})
+	log.Debugw("acquire-transaction-status", log.Fields{"transactionId": c.txnID, "acquired": acquired, "result": txnState[res]})
 	return acquired, nil
 }
 
 func (c *KVTransaction) tryToReserveTxn(durationInSecs int64) error {
-	var currOwner string = ""
+	var currOwner string
 	var res int
-	value, err := ctx.kvClient.Reserve(c.txnKey, ctx.owner, durationInSecs)
+	var err error
+	value, _ := ctx.kvClient.Reserve(c.txnKey, ctx.owner, durationInSecs)
 	if value != nil {
 		if currOwner, err = kvstore.ToString(value); err != nil { // This should never happen
-			log.Errorw("unexpected-owner-type", log.Fields{"transactionId": c.txnId, "error": err})
+			log.Errorw("unexpected-owner-type", log.Fields{"transactionId": c.txnID, "error": err})
 			return err
 		}
 		if currOwner == ctx.owner {
-			log.Debugw("acquired-transaction", log.Fields{"transactionId": c.txnId, "result": txnState[res]})
+			log.Debugw("acquired-transaction", log.Fields{"transactionId": c.txnID, "result": txnState[res]})
 			// Setup the monitoring channel
 			c.monitorCh = make(chan int)
 			go c.holdOnToTxnUntilProcessingCompleted(c.txnKey, ctx.owner, durationInSecs)
@@ -222,6 +238,7 @@
 	return status.Error(codes.PermissionDenied, "reservation-denied")
 }
 
+// Watch watches transaction
 func (c *KVTransaction) Watch(durationInSecs int64) int {
 	var res int
 
@@ -234,16 +251,19 @@
 	if kvp, _ := ctx.kvClient.Get(c.txnKey, ctx.kvOperationTimeout); kvp != nil {
 		transactionWasAcquiredByOther = true
 		if val, err := kvstore.ToString(kvp.Value); err == nil {
-			if val == TRANSACTION_COMPLETE {
-				res = COMPLETED_BY_OTHER
+			if val == TransactionComplete {
+				res = CompletedByOther
 				// Do an immediate delete of the transaction in the KV Store to free up KV Storage faster
-				c.Delete()
+				err = c.Delete()
+				if err != nil {
+					log.Errorw("unable-to-delete-the-transaction", log.Fields{"error": err})
+				}
 				return res
 			}
 		} else {
 			// An unexpected value - let's get out of here as something did not go according to plan
-			res = ABANDONED_WATCH_BY_SELF
-			log.Debugw("cannot-read-transaction-value", log.Fields{"txn": c.txnId, "error": err})
+			res = AbandonedWatchBySelf
+			log.Debugw("cannot-read-transaction-value", log.Fields{"txn": c.txnID, "error": err})
 			return res
 		}
 	}
@@ -252,24 +272,27 @@
 		select {
 		case event := <-events:
 			transactionWasAcquiredByOther = true
-			log.Debugw("received-event", log.Fields{"txn": c.txnId, "type": event.EventType})
+			log.Debugw("received-event", log.Fields{"txn": c.txnID, "type": event.EventType})
 			if event.EventType == kvstore.DELETE {
 				// The other core failed to process the request
-				res = ABANDONED_BY_OTHER
+				res = AbandonedByOther
 			} else if event.EventType == kvstore.PUT {
 				key, e1 := kvstore.ToString(event.Key)
 				val, e2 := kvstore.ToString(event.Value)
 				if e1 == nil && e2 == nil && key == c.txnKey {
-					if val == TRANSACTION_COMPLETE {
-						res = COMPLETED_BY_OTHER
+					if val == TransactionComplete {
+						res = CompletedByOther
 						// Successful request completion has been detected. Remove the transaction key
-						c.Delete()
+						err := c.Delete()
+						if err != nil {
+							log.Errorw("unable-to-delete-the-transaction", log.Fields{"error": err})
+						}
 					} else {
 						log.Debugw("Ignoring-PUT-event", log.Fields{"val": val, "key": key})
 						continue
 					}
 				} else {
-					log.Warnw("received-unexpected-PUT-event", log.Fields{"txn": c.txnId, "key": key, "ctxKey": c.txnKey})
+					log.Warnw("received-unexpected-PUT-event", log.Fields{"txn": c.txnID, "key": key, "ctxKey": c.txnKey})
 				}
 			}
 		case <-time.After(time.Duration(durationInSecs) * time.Second):
@@ -280,8 +303,8 @@
 			// guarantee that the peer is actually gone instead of limiting the time the peer can get hold of a
 			// request.
 			if !transactionWasAcquiredByOther {
-				log.Debugw("timeout-no-peer", log.Fields{"txId": c.txnId})
-				res = ABANDONED_BY_OTHER
+				log.Debugw("timeout-no-peer", log.Fields{"txId": c.txnID})
+				res = AbandonedByOther
 			} else {
 				continue
 			}
@@ -291,18 +314,24 @@
 	return res
 }
 
+// Close closes transaction
 func (c *KVTransaction) Close() error {
-	log.Debugw("close", log.Fields{"txn": c.txnId})
+	log.Debugw("close", log.Fields{"txn": c.txnID})
 	// Stop monitoring the key (applies only when there has been no transaction switch over)
 	if c.monitorCh != nil {
 		close(c.monitorCh)
-		ctx.kvClient.Put(c.txnKey, TRANSACTION_COMPLETE, ctx.kvOperationTimeout)
+		err := ctx.kvClient.Put(c.txnKey, TransactionComplete, ctx.kvOperationTimeout)
+
+		if err != nil {
+			log.Errorw("unable-to-write-a-key-value-pair-to-the-KV-store", log.Fields{"error": err})
+		}
 	}
 	return nil
 }
 
+// Delete deletes transaction
 func (c *KVTransaction) Delete() error {
-	log.Debugw("delete", log.Fields{"txn": c.txnId})
+	log.Debugw("delete", log.Fields{"txn": c.txnID})
 	return ctx.kvClient.Delete(c.txnKey, ctx.kvOperationTimeout)
 }
 
@@ -310,16 +339,16 @@
 // is used to calculate the frequency at which the Core processing the transaction renews the lease.  This function
 // exits only when the transaction is Closed, i.e completed.
 func (c *KVTransaction) holdOnToTxnUntilProcessingCompleted(key string, owner string, durationInSecs int64) {
-	log.Debugw("holdOnToTxnUntilProcessingCompleted", log.Fields{"txn": c.txnId})
-	renewInterval := durationInSecs / NUM_TXN_RENEWAL_PER_REQUEST
-	if renewInterval < MIN_TXN_RENEWAL_INTERVAL_IN_SEC {
-		renewInterval = MIN_TXN_RENEWAL_INTERVAL_IN_SEC
+	log.Debugw("holdOnToTxnUntilProcessingCompleted", log.Fields{"txn": c.txnID})
+	renewInterval := durationInSecs / NumTxnRenewalPerRequest
+	if renewInterval < MinTxnRenewalIntervalInSec {
+		renewInterval = MinTxnRenewalIntervalInSec
 	}
 forLoop:
 	for {
 		select {
 		case <-c.monitorCh:
-			log.Debugw("transaction-renewal-exits", log.Fields{"txn": c.txnId})
+			log.Debugw("transaction-renewal-exits", log.Fields{"txn": c.txnID})
 			break forLoop
 		case <-time.After(time.Duration(renewInterval) * time.Second):
 			if err := ctx.kvClient.RenewReservation(c.txnKey); err != nil {
diff --git a/rw_core/coreIf/adapter_manager_if.go b/rw_core/coreif/adapter_manager_if.go
similarity index 92%
rename from rw_core/coreIf/adapter_manager_if.go
rename to rw_core/coreif/adapter_manager_if.go
index b48852c..a4b0b63 100644
--- a/rw_core/coreIf/adapter_manager_if.go
+++ b/rw_core/coreif/adapter_manager_if.go
@@ -13,13 +13,16 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package coreIf
+
+package coreif
 
 import (
 	"context"
+
 	"github.com/opencord/voltha-protos/v2/go/voltha"
 )
 
+// AdapterManager represent adapter manager related methods
 type AdapterManager interface {
 	ListAdapters(ctx context.Context) (*voltha.Adapters, error)
 	GetAdapterName(deviceType string) (string, error)
diff --git a/rw_core/coreIf/core_if.go b/rw_core/coreif/core_if.go
similarity index 96%
rename from rw_core/coreIf/core_if.go
rename to rw_core/coreif/core_if.go
index bf9a661..c63a738 100644
--- a/rw_core/coreIf/core_if.go
+++ b/rw_core/coreif/core_if.go
@@ -17,15 +17,18 @@
 Defines a DeviceManager Interface - Used for unit testing of the flow decomposer only at this
 time.
 */
-package coreIf
+
+package coreif
 
 import (
 	"context"
+
 	"github.com/opencord/voltha-go/db/model"
 	"github.com/opencord/voltha-go/rw_core/config"
 	"github.com/opencord/voltha-lib-go/v2/pkg/kafka"
 )
 
+// Core represent core methods
 type Core interface {
 	Start(ctx context.Context)
 	Stop(ctx context.Context)
diff --git a/rw_core/coreIf/device_manager_if.go b/rw_core/coreif/device_manager_if.go
similarity index 98%
rename from rw_core/coreIf/device_manager_if.go
rename to rw_core/coreif/device_manager_if.go
index 04a3d72..292a7b9 100644
--- a/rw_core/coreIf/device_manager_if.go
+++ b/rw_core/coreif/device_manager_if.go
@@ -17,7 +17,8 @@
 Defines a DeviceManager Interface - Used for unit testing of the flow decomposer only at this
 time.
 */
-package coreIf
+
+package coreif
 
 import "github.com/opencord/voltha-protos/v2/go/voltha"
 
diff --git a/rw_core/coreIf/device_ownership_if.go b/rw_core/coreif/device_ownership_if.go
similarity index 91%
rename from rw_core/coreIf/device_ownership_if.go
rename to rw_core/coreif/device_ownership_if.go
index fb19097..fc6fe78 100644
--- a/rw_core/coreIf/device_ownership_if.go
+++ b/rw_core/coreif/device_ownership_if.go
@@ -13,12 +13,14 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package coreIf
+
+package coreif
 
 import (
 	"context"
 )
 
+// DeviceOwnership represent device ownership related methods
 type DeviceOwnership interface {
 	Start(ctx context.Context)
 	Stop(ctx context.Context)
diff --git a/rw_core/coreIf/logical_device_agent_if.go b/rw_core/coreif/logical_device_agent_if.go
similarity index 94%
rename from rw_core/coreIf/logical_device_agent_if.go
rename to rw_core/coreif/logical_device_agent_if.go
index bcde284..34a71e5 100644
--- a/rw_core/coreIf/logical_device_agent_if.go
+++ b/rw_core/coreif/logical_device_agent_if.go
@@ -17,14 +17,15 @@
   Defines a logicalDeviceAgent Interface - Used for unit testing of the flow decomposer only at this
  time.
 */
-package coreIf
+
+package coreif
 
 import (
 	"github.com/opencord/voltha-go/rw_core/graph"
 	"github.com/opencord/voltha-protos/v2/go/voltha"
 )
 
-// LogicalAgent represents a generic agent
+// LogicalDeviceAgent represents a generic agent
 type LogicalDeviceAgent interface {
 	GetLogicalDevice() (*voltha.LogicalDevice, error)
 	GetDeviceGraph() *graph.DeviceGraph
diff --git a/rw_core/coreIf/logical_device_manager_if.go b/rw_core/coreif/logical_device_manager_if.go
similarity index 92%
rename from rw_core/coreIf/logical_device_manager_if.go
rename to rw_core/coreif/logical_device_manager_if.go
index a10a3c8..2beaea5 100644
--- a/rw_core/coreIf/logical_device_manager_if.go
+++ b/rw_core/coreif/logical_device_manager_if.go
@@ -17,16 +17,19 @@
 Defines a DeviceManager Interface - Used for unit testing of the flow decomposer only at this
 time.
 */
-package coreIf
+
+package coreif
 
 import (
 	"context"
+
 	"github.com/opencord/voltha-protos/v2/go/openflow_13"
 	"github.com/opencord/voltha-protos/v2/go/voltha"
 )
 
+// LogicalDeviceManager represent logical device manager related methods
 type LogicalDeviceManager interface {
-	GetLogicalPort(lPortId *voltha.LogicalPortId) (*voltha.LogicalPort, error)
+	GetLogicalPort(lPortID *voltha.LogicalPortId) (*voltha.LogicalPort, error)
 	EnableLogicalPort(ctx context.Context, id *voltha.LogicalPortId, ch chan interface{})
 	DisableLogicalPort(ctx context.Context, id *voltha.LogicalPortId, ch chan interface{})
 	UpdateFlowTable(ctx context.Context, id string, flow *openflow_13.OfpFlowMod, ch chan interface{})
diff --git a/rw_core/flow_decomposition/flow_decomposer.go b/rw_core/flowdecomposition/flow_decomposer.go
similarity index 88%
rename from rw_core/flow_decomposition/flow_decomposer.go
rename to rw_core/flowdecomposition/flow_decomposer.go
index 4ced06e..330a4af 100644
--- a/rw_core/flow_decomposition/flow_decomposer.go
+++ b/rw_core/flowdecomposition/flow_decomposer.go
@@ -14,11 +14,11 @@
  * limitations under the License.
  */
 
-package flow_decomposition
+package flowdecomposition
 
 import (
 	"github.com/gogo/protobuf/proto"
-	"github.com/opencord/voltha-go/rw_core/coreIf"
+	"github.com/opencord/voltha-go/rw_core/coreif"
 	"github.com/opencord/voltha-go/rw_core/graph"
 	fu "github.com/opencord/voltha-lib-go/v2/pkg/flows"
 	"github.com/opencord/voltha-lib-go/v2/pkg/log"
@@ -27,21 +27,26 @@
 )
 
 func init() {
-	log.AddPackage(log.JSON, log.DebugLevel, nil)
+	_, err := log.AddPackage(log.JSON, log.DebugLevel, nil)
+	if err != nil {
+		log.Errorw("unable-to-register-package-to-the-log-map", log.Fields{"error": err})
+	}
 }
 
+// FlowDecomposer represent flow decomposer attribute
 type FlowDecomposer struct {
-	deviceMgr coreIf.DeviceManager
+	deviceMgr coreif.DeviceManager
 }
 
-func NewFlowDecomposer(deviceMgr coreIf.DeviceManager) *FlowDecomposer {
+// NewFlowDecomposer creates flow decomposer instance
+func NewFlowDecomposer(deviceMgr coreif.DeviceManager) *FlowDecomposer {
 	var decomposer FlowDecomposer
 	decomposer.deviceMgr = deviceMgr
 	return &decomposer
 }
 
 //DecomposeRules decomposes per-device flows and flow-groups from the flows and groups defined on a logical device
-func (fd *FlowDecomposer) DecomposeRules(agent coreIf.LogicalDeviceAgent, flows ofp.Flows, groups ofp.FlowGroups) *fu.DeviceRules {
+func (fd *FlowDecomposer) DecomposeRules(agent coreif.LogicalDeviceAgent, flows ofp.Flows, groups ofp.FlowGroups) *fu.DeviceRules {
 	deviceRules := *fu.NewDeviceRules()
 	devicesToUpdate := make(map[string]string)
 
@@ -53,10 +58,10 @@
 	var decomposedRules *fu.DeviceRules
 	for _, flow := range flows.Items {
 		decomposedRules = fd.decomposeFlow(agent, flow, groupMap)
-		for deviceId, flowAndGroups := range decomposedRules.Rules {
-			deviceRules.CreateEntryIfNotExist(deviceId)
-			deviceRules.Rules[deviceId].AddFrom(flowAndGroups)
-			devicesToUpdate[deviceId] = deviceId
+		for deviceID, flowAndGroups := range decomposedRules.Rules {
+			deviceRules.CreateEntryIfNotExist(deviceID)
+			deviceRules.Rules[deviceID].AddFrom(flowAndGroups)
+			devicesToUpdate[deviceID] = deviceID
 		}
 	}
 	return deviceRules.FilterRules(devicesToUpdate)
@@ -71,9 +76,9 @@
 
 	newDeviceRules := dr.Copy()
 	//	Check whether we are dealing with a parent device
-	for deviceId, fg := range dr.GetRules() {
-		if root, _ := fd.deviceMgr.IsRootDevice(deviceId); root {
-			newDeviceRules.ClearFlows(deviceId)
+	for deviceID, fg := range dr.GetRules() {
+		if root, _ := fd.deviceMgr.IsRootDevice(deviceID); root {
+			newDeviceRules.ClearFlows(deviceID)
 			for i := 0; i < fg.Flows.Len(); i++ {
 				f := fg.GetFlow(i)
 				UpdateOutPortNo := false
@@ -91,7 +96,7 @@
 				}
 				// Update flow Id as a change in the instruction field will result in a new flow ID
 				f.Id = fu.HashFlowStats(f)
-				newDeviceRules.AddFlow(deviceId, (proto.Clone(f)).(*ofp.OfpFlowStats))
+				newDeviceRules.AddFlow(deviceID, (proto.Clone(f)).(*ofp.OfpFlowStats))
 			}
 		}
 	}
@@ -100,12 +105,12 @@
 }
 
 //processControllerBoundFlow decomposes trap flows
-func (fd *FlowDecomposer) processControllerBoundFlow(agent coreIf.LogicalDeviceAgent, route []graph.RouteHop,
+func (fd *FlowDecomposer) processControllerBoundFlow(agent coreif.LogicalDeviceAgent, route []graph.RouteHop,
 	inPortNo uint32, outPortNo uint32, flow *ofp.OfpFlowStats) *fu.DeviceRules {
 
 	log.Debugw("trap-flow", log.Fields{"inPortNo": inPortNo, "outPortNo": outPortNo, "flow": flow})
 	deviceRules := fu.NewDeviceRules()
-	meterId := fu.GetMeterIdFromFlow(flow)
+	meterID := fu.GetMeterIdFromFlow(flow)
 	metadataFromwriteMetadata := fu.GetMetadataFromWriteMetadataAction(flow)
 
 	ingressHop := route[0]
@@ -116,8 +121,7 @@
 		// Trap flow for NNI port
 		log.Debug("trap-nni")
 
-		var fa *fu.FlowArgs
-		fa = &fu.FlowArgs{
+		fa := &fu.FlowArgs{
 			KV: fu.OfpFlowModArgs{"priority": uint64(flow.Priority), "cookie": flow.Cookie},
 			MatchFields: []*ofp.OfpOxmOfbField{
 				fu.InPort(egressHop.Egress),
@@ -142,9 +146,8 @@
 		}
 		for _, inputPort := range inPorts {
 			// Upstream flow on parent (olt) device
-			var faParent *fu.FlowArgs
-			faParent = &fu.FlowArgs{
-				KV: fu.OfpFlowModArgs{"priority": uint64(flow.Priority), "cookie": flow.Cookie, "meter_id": uint64(meterId), "write_metadata": metadataFromwriteMetadata},
+			faParent := &fu.FlowArgs{
+				KV: fu.OfpFlowModArgs{"priority": uint64(flow.Priority), "cookie": flow.Cookie, "meter_id": uint64(meterID), "write_metadata": metadataFromwriteMetadata},
 				MatchFields: []*ofp.OfpOxmOfbField{
 					fu.InPort(egressHop.Ingress),
 					fu.TunnelId(uint64(inputPort)),
@@ -178,9 +181,8 @@
 					fu.Output(ingressHop.Egress),
 				}
 			}
-			var faChild *fu.FlowArgs
-			faChild = &fu.FlowArgs{
-				KV: fu.OfpFlowModArgs{"priority": uint64(flow.Priority), "cookie": flow.Cookie, "meter_id": uint64(meterId), "write_metadata": metadataFromwriteMetadata},
+			faChild := &fu.FlowArgs{
+				KV: fu.OfpFlowModArgs{"priority": uint64(flow.Priority), "cookie": flow.Cookie, "meter_id": uint64(meterID), "write_metadata": metadataFromwriteMetadata},
 				MatchFields: []*ofp.OfpOxmOfbField{
 					fu.InPort(ingressHop.Ingress),
 					fu.TunnelId(uint64(inputPort)),
@@ -209,13 +211,13 @@
 // upstream needs to get Q-in-Q treatment and that this is expressed via two flow rules, the first using the
 // goto-statement. We also assume that the inner tag is applied at the ONU, while the outer tag is
 // applied at the OLT
-func (fd *FlowDecomposer) processUpstreamNonControllerBoundFlow(agent coreIf.LogicalDeviceAgent,
+func (fd *FlowDecomposer) processUpstreamNonControllerBoundFlow(agent coreif.LogicalDeviceAgent,
 	route []graph.RouteHop, inPortNo uint32, outPortNo uint32, flow *ofp.OfpFlowStats) *fu.DeviceRules {
 
 	log.Debugw("upstream-non-controller-bound-flow", log.Fields{"inPortNo": inPortNo, "outPortNo": outPortNo})
 	deviceRules := fu.NewDeviceRules()
 
-	meterId := fu.GetMeterIdFromFlow(flow)
+	meterID := fu.GetMeterIdFromFlow(flow)
 	metadataFromwriteMetadata := fu.GetMetadataFromWriteMetadataAction(flow)
 
 	ingressHop := route[0]
@@ -227,9 +229,8 @@
 			log.Warnw("outPort-should-not-be-specified", log.Fields{"outPortNo": outPortNo})
 			return deviceRules
 		}
-		var fa *fu.FlowArgs
-		fa = &fu.FlowArgs{
-			KV: fu.OfpFlowModArgs{"priority": uint64(flow.Priority), "cookie": flow.Cookie, "meter_id": uint64(meterId), "write_metadata": metadataFromwriteMetadata},
+		fa := &fu.FlowArgs{
+			KV: fu.OfpFlowModArgs{"priority": uint64(flow.Priority), "cookie": flow.Cookie, "meter_id": uint64(meterID), "write_metadata": metadataFromwriteMetadata},
 			MatchFields: []*ofp.OfpOxmOfbField{
 				fu.InPort(ingressHop.Ingress),
 				fu.TunnelId(uint64(inPortNo)),
@@ -247,9 +248,8 @@
 		deviceRules.AddFlowsAndGroup(ingressHop.DeviceID, fg)
 	} else if flow.TableId == 1 && outPortNo != 0 {
 		log.Debugw("decomposing-olt-flow-in-upstream-has-next-table", log.Fields{"table_id": flow.TableId})
-		var fa *fu.FlowArgs
-		fa = &fu.FlowArgs{
-			KV: fu.OfpFlowModArgs{"priority": uint64(flow.Priority), "cookie": flow.Cookie, "meter_id": uint64(meterId), "write_metadata": metadataFromwriteMetadata},
+		fa := &fu.FlowArgs{
+			KV: fu.OfpFlowModArgs{"priority": uint64(flow.Priority), "cookie": flow.Cookie, "meter_id": uint64(meterID), "write_metadata": metadataFromwriteMetadata},
 			MatchFields: []*ofp.OfpOxmOfbField{
 				fu.InPort(egressHop.Ingress),
 				fu.TunnelId(uint64(inPortNo)),
@@ -271,11 +271,11 @@
 }
 
 // processDownstreamFlowWithNextTable decomposes downstream flows containing next table ID instructions
-func (fd *FlowDecomposer) processDownstreamFlowWithNextTable(agent coreIf.LogicalDeviceAgent, route []graph.RouteHop,
+func (fd *FlowDecomposer) processDownstreamFlowWithNextTable(agent coreif.LogicalDeviceAgent, route []graph.RouteHop,
 	inPortNo uint32, outPortNo uint32, flow *ofp.OfpFlowStats) *fu.DeviceRules {
 	log.Debugw("decomposing-olt-flow-in-downstream-flow-with-next-table", log.Fields{"inPortNo": inPortNo, "outPortNo": outPortNo})
 	deviceRules := fu.NewDeviceRules()
-	meterId := fu.GetMeterIdFromFlow(flow)
+	meterID := fu.GetMeterIdFromFlow(flow)
 	metadataFromwriteMetadata := fu.GetMetadataFromWriteMetadataAction(flow)
 
 	if outPortNo != 0 {
@@ -302,7 +302,6 @@
 				return deviceRules
 			case 2:
 				log.Debugw("route-found", log.Fields{"ingressHop": ingressHop, "egressHop": egressHop})
-				break
 			default:
 				log.Errorw("invalid-route-length", log.Fields{"routeLen": len(route)})
 				return deviceRules
@@ -315,9 +314,8 @@
 			//TODO: Delete flow
 			return deviceRules
 		}
-		var fa *fu.FlowArgs
-		fa = &fu.FlowArgs{
-			KV: fu.OfpFlowModArgs{"priority": uint64(flow.Priority), "cookie": flow.Cookie, "meter_id": uint64(meterId), "write_metadata": metadataFromwriteMetadata},
+		fa := &fu.FlowArgs{
+			KV: fu.OfpFlowModArgs{"priority": uint64(flow.Priority), "cookie": flow.Cookie, "meter_id": uint64(meterID), "write_metadata": metadataFromwriteMetadata},
 			MatchFields: []*ofp.OfpOxmOfbField{
 				fu.InPort(ingressHop.Ingress),
 				fu.Metadata_ofp(uint64(innerTag)),
@@ -336,9 +334,8 @@
 		deviceRules.AddFlowsAndGroup(ingressHop.DeviceID, fg)
 	} else { // Create standard flow
 		log.Debugw("creating-standard-flow", log.Fields{"flow": flow})
-		var fa *fu.FlowArgs
-		fa = &fu.FlowArgs{
-			KV: fu.OfpFlowModArgs{"priority": uint64(flow.Priority), "cookie": flow.Cookie, "meter_id": uint64(meterId), "write_metadata": metadataFromwriteMetadata},
+		fa := &fu.FlowArgs{
+			KV: fu.OfpFlowModArgs{"priority": uint64(flow.Priority), "cookie": flow.Cookie, "meter_id": uint64(meterID), "write_metadata": metadataFromwriteMetadata},
 			MatchFields: []*ofp.OfpOxmOfbField{
 				fu.InPort(ingressHop.Ingress),
 				fu.TunnelId(uint64(inPortNo)),
@@ -360,7 +357,7 @@
 }
 
 // processUnicastFlow decomposes unicast flows
-func (fd *FlowDecomposer) processUnicastFlow(agent coreIf.LogicalDeviceAgent, route []graph.RouteHop,
+func (fd *FlowDecomposer) processUnicastFlow(agent coreif.LogicalDeviceAgent, route []graph.RouteHop,
 	inPortNo uint32, outPortNo uint32, flow *ofp.OfpFlowStats) *fu.DeviceRules {
 
 	log.Debugw("decomposing-onu-flow-in-downstream-unicast-flow", log.Fields{"inPortNo": inPortNo, "outPortNo": outPortNo})
@@ -368,11 +365,10 @@
 
 	egressHop := route[1]
 
-	meterId := fu.GetMeterIdFromFlow(flow)
+	meterID := fu.GetMeterIdFromFlow(flow)
 	metadataFromwriteMetadata := fu.GetMetadataFromWriteMetadataAction(flow)
-	var fa *fu.FlowArgs
-	fa = &fu.FlowArgs{
-		KV: fu.OfpFlowModArgs{"priority": uint64(flow.Priority), "cookie": flow.Cookie, "meter_id": uint64(meterId), "write_metadata": metadataFromwriteMetadata},
+	fa := &fu.FlowArgs{
+		KV: fu.OfpFlowModArgs{"priority": uint64(flow.Priority), "cookie": flow.Cookie, "meter_id": uint64(meterID), "write_metadata": metadataFromwriteMetadata},
 		MatchFields: []*ofp.OfpOxmOfbField{
 			fu.InPort(egressHop.Ingress),
 		},
@@ -392,8 +388,8 @@
 }
 
 // processMulticastFlow decompose multicast flows
-func (fd *FlowDecomposer) processMulticastFlow(agent coreIf.LogicalDeviceAgent, route []graph.RouteHop,
-	inPortNo uint32, outPortNo uint32, flow *ofp.OfpFlowStats, grpId uint32,
+func (fd *FlowDecomposer) processMulticastFlow(agent coreif.LogicalDeviceAgent, route []graph.RouteHop,
+	inPortNo uint32, outPortNo uint32, flow *ofp.OfpFlowStats, grpID uint32,
 	groupMap map[uint32]*ofp.OfpGroupEntry) *fu.DeviceRules {
 
 	log.Debugw("multicast-flow", log.Fields{"inPortNo": inPortNo, "outPortNo": outPortNo})
@@ -402,12 +398,12 @@
 	//having no Group yet is the same as having a Group with no buckets
 	var grp *ofp.OfpGroupEntry
 	var ok bool
-	if grp, ok = groupMap[grpId]; !ok {
-		log.Warnw("Group-id-not-present-in-map", log.Fields{"grpId": grpId, "groupMap": groupMap})
+	if grp, ok = groupMap[grpID]; !ok {
+		log.Warnw("Group-id-not-present-in-map", log.Fields{"grpId": grpID, "groupMap": groupMap})
 		return deviceRules
 	}
 	if grp == nil || grp.Desc == nil {
-		log.Warnw("Group-or-desc-nil", log.Fields{"grpId": grpId, "grp": grp})
+		log.Warnw("Group-or-desc-nil", log.Fields{"grpId": grpID, "grp": grp})
 		return deviceRules
 	}
 	for _, bucket := range grp.Desc.Buckets {
@@ -428,7 +424,6 @@
 			return deviceRules
 		case 2:
 			log.Debugw("route-found", log.Fields{"ingressHop": route2[0], "egressHop": route2[1]})
-			break
 		default:
 			log.Errorw("invalid-route-length", log.Fields{"routeLen": len(route)})
 			return deviceRules
@@ -443,8 +438,7 @@
 			return deviceRules
 		}
 		// Set the parent device flow
-		var fa *fu.FlowArgs
-		fa = &fu.FlowArgs{
+		fa := &fu.FlowArgs{
 			KV: fu.OfpFlowModArgs{"priority": uint64(flow.Priority), "cookie": flow.Cookie},
 			MatchFields: []*ofp.OfpOxmOfbField{
 				fu.InPort(ingressHop.Ingress),
@@ -485,7 +479,7 @@
 }
 
 // decomposeFlow decomposes a flow for a logical device into flows for each physical device
-func (fd *FlowDecomposer) decomposeFlow(agent coreIf.LogicalDeviceAgent, flow *ofp.OfpFlowStats,
+func (fd *FlowDecomposer) decomposeFlow(agent coreif.LogicalDeviceAgent, flow *ofp.OfpFlowStats,
 	groupMap map[uint32]*ofp.OfpGroupEntry) *fu.DeviceRules {
 
 	inPortNo := fu.GetInPort(flow)
@@ -500,7 +494,6 @@
 		return deviceRules
 	case 2:
 		log.Debugw("route-found", log.Fields{"ingressHop": route[0], "egressHop": route[1]})
-		break
 	default:
 		log.Errorw("invalid-route-length", log.Fields{"routeLen": len(route)})
 		return deviceRules
@@ -526,9 +519,9 @@
 		} else if flow.TableId == 1 && outPortNo != 0 { // Unicast ONU flow DL
 			log.Debugw("processOnuDownstreamUnicastFlow", log.Fields{"flows": flow})
 			deviceRules = fd.processUnicastFlow(agent, route, inPortNo, outPortNo, flow)
-		} else if grpId := fu.GetGroup(flow); grpId != 0 && flow.TableId == 0 { //Multicast
+		} else if grpID := fu.GetGroup(flow); grpID != 0 && flow.TableId == 0 { //Multicast
 			log.Debugw("processMulticastFlow", log.Fields{"flows": flow})
-			deviceRules = fd.processMulticastFlow(agent, route, inPortNo, outPortNo, flow, grpId, groupMap)
+			deviceRules = fd.processMulticastFlow(agent, route, inPortNo, outPortNo, flow, grpID, groupMap)
 		} else {
 			log.Errorw("unknown-downstream-flow", log.Fields{"flow": *flow})
 		}
diff --git a/rw_core/flow_decomposition/flow_decomposer_test.go b/rw_core/flowdecomposition/flow_decomposer_test.go
similarity index 95%
rename from rw_core/flow_decomposition/flow_decomposer_test.go
rename to rw_core/flowdecomposition/flow_decomposer_test.go
index a24765e..cc89331 100644
--- a/rw_core/flow_decomposition/flow_decomposer_test.go
+++ b/rw_core/flowdecomposition/flow_decomposer_test.go
@@ -13,10 +13,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package flow_decomposition
+package flowdecomposition
 
 import (
 	"errors"
+
 	"github.com/opencord/voltha-go/rw_core/graph"
 	"github.com/opencord/voltha-go/rw_core/mocks"
 	fu "github.com/opencord/voltha-lib-go/v2/pkg/flows"
@@ -99,17 +100,17 @@
 	return &tdm
 }
 
-func (tdm *testDeviceManager) GetDevice(deviceId string) (*voltha.Device, error) {
-	if d, ok := tdm.devices[deviceId]; ok {
+func (tdm *testDeviceManager) GetDevice(deviceID string) (*voltha.Device, error) {
+	if d, ok := tdm.devices[deviceID]; ok {
 		return d, nil
 	}
-	return nil, errors.New("ABSENT.")
+	return nil, errors.New("ABSENT")
 }
-func (tdm *testDeviceManager) IsRootDevice(deviceId string) (bool, error) {
-	if d, ok := tdm.devices[deviceId]; ok {
+func (tdm *testDeviceManager) IsRootDevice(deviceID string) (bool, error) {
+	if d, ok := tdm.devices[deviceID]; ok {
 		return d.Root, nil
 	}
-	return false, errors.New("ABSENT.")
+	return false, errors.New("ABSENT")
 }
 
 type testFlowDecomposer struct {
@@ -327,8 +328,7 @@
 
 	tfd.defaultRules = fu.NewDeviceRules()
 	fg := fu.NewFlowsAndGroups()
-	var fa *fu.FlowArgs
-	fa = &fu.FlowArgs{
+	fa := &fu.FlowArgs{
 		MatchFields: []*ofp.OfpOxmOfbField{
 			fu.InPort(2),
 			fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0),
@@ -393,11 +393,11 @@
 	return &tfd
 }
 
-func (tfd *testFlowDecomposer) getDeviceHelper(deviceId string) (*voltha.Device, error) {
-	return tfd.dMgr.GetDevice(deviceId)
+func (tfd *testFlowDecomposer) getDeviceHelper(deviceID string) (*voltha.Device, error) {
+	return tfd.dMgr.GetDevice(deviceID)
 }
 
-func (tfd *testFlowDecomposer) GetDeviceLogicalId() string {
+func (tfd *testFlowDecomposer) GetDeviceLogicalID() string {
 	return ""
 }
 
@@ -451,8 +451,7 @@
 
 func TestEapolReRouteRuleVlanDecomposition(t *testing.T) {
 
-	var fa *fu.FlowArgs
-	fa = &fu.FlowArgs{
+	fa := &fu.FlowArgs{
 		KV: fu.OfpFlowModArgs{"priority": 1000},
 		MatchFields: []*ofp.OfpOxmOfbField{
 			fu.InPort(1),
@@ -476,8 +475,7 @@
 	assert.Equal(t, 1, oltFlowAndGroup.Flows.Len())
 	assert.Equal(t, 0, oltFlowAndGroup.Groups.Len())
 
-	var faParent *fu.FlowArgs
-	faParent = &fu.FlowArgs{
+	faParent := &fu.FlowArgs{
 		KV: fu.OfpFlowModArgs{"priority": 1000},
 		MatchFields: []*ofp.OfpOxmOfbField{
 			fu.InPort(1),
@@ -495,8 +493,7 @@
 	derivedFlow := oltFlowAndGroup.GetFlow(0)
 	assert.Equal(t, expectedOltFlow.String(), derivedFlow.String())
 
-	var faChild *fu.FlowArgs
-	faChild = &fu.FlowArgs{
+	faChild := &fu.FlowArgs{
 		KV: fu.OfpFlowModArgs{"priority": 1000},
 		MatchFields: []*ofp.OfpOxmOfbField{
 			fu.InPort(2),
@@ -516,8 +513,7 @@
 
 func TestEapolReRouteRuleZeroVlanDecomposition(t *testing.T) {
 
-	var fa *fu.FlowArgs
-	fa = &fu.FlowArgs{
+	fa := &fu.FlowArgs{
 		KV: fu.OfpFlowModArgs{"priority": 1000},
 		MatchFields: []*ofp.OfpOxmOfbField{
 			fu.InPort(1),
@@ -541,8 +537,7 @@
 	assert.Equal(t, 1, oltFlowAndGroup.Flows.Len())
 	assert.Equal(t, 0, oltFlowAndGroup.Groups.Len())
 
-	var faParent *fu.FlowArgs
-	faParent = &fu.FlowArgs{
+	faParent := &fu.FlowArgs{
 		KV: fu.OfpFlowModArgs{"priority": 1000},
 		MatchFields: []*ofp.OfpOxmOfbField{
 			fu.InPort(1),
@@ -560,8 +555,7 @@
 	derivedFlow := oltFlowAndGroup.GetFlow(0)
 	assert.Equal(t, expectedOltFlow.String(), derivedFlow.String())
 
-	var faChild *fu.FlowArgs
-	faChild = &fu.FlowArgs{
+	faChild := &fu.FlowArgs{
 		KV: fu.OfpFlowModArgs{"priority": 1000},
 		MatchFields: []*ofp.OfpOxmOfbField{
 			fu.InPort(2),
@@ -581,8 +575,7 @@
 
 func TestEapolReRouteRuleNoVlanDecomposition(t *testing.T) {
 
-	var fa *fu.FlowArgs
-	fa = &fu.FlowArgs{
+	fa := &fu.FlowArgs{
 		KV: fu.OfpFlowModArgs{"priority": 1000},
 		MatchFields: []*ofp.OfpOxmOfbField{
 			fu.InPort(1),
@@ -605,8 +598,7 @@
 	assert.Equal(t, 1, oltFlowAndGroup.Flows.Len())
 	assert.Equal(t, 0, oltFlowAndGroup.Groups.Len())
 
-	var faParent *fu.FlowArgs
-	faParent = &fu.FlowArgs{
+	faParent := &fu.FlowArgs{
 		KV: fu.OfpFlowModArgs{"priority": 1000},
 		MatchFields: []*ofp.OfpOxmOfbField{
 			fu.InPort(1),
@@ -623,8 +615,7 @@
 	derivedFlow := oltFlowAndGroup.GetFlow(0)
 	assert.Equal(t, expectedOltFlow.String(), derivedFlow.String())
 
-	var faChild *fu.FlowArgs
-	faChild = &fu.FlowArgs{
+	faChild := &fu.FlowArgs{
 		KV: fu.OfpFlowModArgs{"priority": 1000},
 		MatchFields: []*ofp.OfpOxmOfbField{
 			fu.InPort(2),
@@ -642,8 +633,7 @@
 
 func TestDhcpReRouteRuleDecomposition(t *testing.T) {
 
-	var fa *fu.FlowArgs
-	fa = &fu.FlowArgs{
+	fa := &fu.FlowArgs{
 		KV: fu.OfpFlowModArgs{"priority": 1000},
 		MatchFields: []*ofp.OfpOxmOfbField{
 			fu.InPort(1),
@@ -670,8 +660,7 @@
 	assert.Equal(t, 1, oltFlowAndGroup.Flows.Len())
 	assert.Equal(t, 0, oltFlowAndGroup.Groups.Len())
 
-	var faParent *fu.FlowArgs
-	faParent = &fu.FlowArgs{
+	faParent := &fu.FlowArgs{
 		KV: fu.OfpFlowModArgs{"priority": 1000},
 		MatchFields: []*ofp.OfpOxmOfbField{
 			fu.InPort(1),
@@ -692,8 +681,7 @@
 	derivedFlow := oltFlowAndGroup.GetFlow(0)
 	assert.Equal(t, expectedOltFlow.String(), derivedFlow.String())
 
-	var faChild *fu.FlowArgs
-	faChild = &fu.FlowArgs{
+	faChild := &fu.FlowArgs{
 		KV: fu.OfpFlowModArgs{"priority": 1000},
 		MatchFields: []*ofp.OfpOxmOfbField{
 			fu.InPort(2),
@@ -714,8 +702,7 @@
 }
 
 func TestLldpReRouteRuleDecomposition(t *testing.T) {
-	var fa *fu.FlowArgs
-	fa = &fu.FlowArgs{
+	fa := &fu.FlowArgs{
 		KV: fu.OfpFlowModArgs{"priority": 1000},
 		MatchFields: []*ofp.OfpOxmOfbField{
 			fu.InPort(10),
@@ -752,8 +739,7 @@
 }
 
 func TestUnicastUpstreamRuleDecomposition(t *testing.T) {
-	var fa *fu.FlowArgs
-	fa = &fu.FlowArgs{
+	fa := &fu.FlowArgs{
 		KV: fu.OfpFlowModArgs{"priority": 5000, "table_id": 0},
 		MatchFields: []*ofp.OfpOxmOfbField{
 			fu.InPort(1),
@@ -765,8 +751,7 @@
 		},
 	}
 
-	var fa2 *fu.FlowArgs
-	fa2 = &fu.FlowArgs{
+	fa2 := &fu.FlowArgs{
 		KV: fu.OfpFlowModArgs{"priority": 500, "table_id": 1},
 		MatchFields: []*ofp.OfpOxmOfbField{
 			fu.InPort(1),
@@ -858,8 +843,7 @@
 
 func TestUnicastDownstreamRuleDecomposition(t *testing.T) {
 	log.Debugf("Starting Test Unicast Downstream")
-	var fa1 *fu.FlowArgs
-	fa1 = &fu.FlowArgs{
+	fa1 := &fu.FlowArgs{
 		KV: fu.OfpFlowModArgs{"priority": 500, "table_id": 0},
 		MatchFields: []*ofp.OfpOxmOfbField{
 			fu.InPort(10),
@@ -871,8 +855,7 @@
 		},
 	}
 
-	var fa2 *fu.FlowArgs
-	fa2 = &fu.FlowArgs{
+	fa2 := &fu.FlowArgs{
 		KV: fu.OfpFlowModArgs{"priority": 500, "table_id": 1},
 		MatchFields: []*ofp.OfpOxmOfbField{
 			fu.InPort(10),
@@ -955,8 +938,7 @@
 }
 
 func TestMulticastDownstreamRuleDecomposition(t *testing.T) {
-	var fa *fu.FlowArgs
-	fa = &fu.FlowArgs{
+	fa := &fu.FlowArgs{
 		KV: fu.OfpFlowModArgs{"priority": 500},
 		MatchFields: []*ofp.OfpOxmOfbField{
 			fu.InPort(10),
@@ -970,8 +952,7 @@
 		},
 	}
 
-	var ga *fu.GroupArgs
-	ga = &fu.GroupArgs{
+	ga := &fu.GroupArgs{
 		GroupId: 10,
 		Buckets: []*ofp.OfpBucket{
 			{Actions: []*ofp.OfpAction{
diff --git a/rw_core/graph/device_graph.go b/rw_core/graph/device_graph.go
index 229a3a4..4c89134 100644
--- a/rw_core/graph/device_graph.go
+++ b/rw_core/graph/device_graph.go
@@ -17,26 +17,31 @@
 package graph
 
 import (
-	"errors"
 	"fmt"
-	"github.com/gyuho/goraph"
-	"github.com/opencord/voltha-lib-go/v2/pkg/log"
-	"github.com/opencord/voltha-protos/v2/go/voltha"
 	"strconv"
 	"strings"
 	"sync"
+
+	"github.com/gyuho/goraph"
+	"github.com/opencord/voltha-lib-go/v2/pkg/log"
+	"github.com/opencord/voltha-protos/v2/go/voltha"
 )
 
 func init() {
-	log.AddPackage(log.JSON, log.WarnLevel, nil)
+	_, err := log.AddPackage(log.JSON, log.WarnLevel, nil)
+	if err != nil {
+		log.Errorw("unable-to-register-package-to-the-log-map", log.Fields{"error": err})
+	}
 }
 
+// RouteHop represent route hop attributes
 type RouteHop struct {
 	DeviceID string
 	Ingress  uint32
 	Egress   uint32
 }
 
+// OFPortLink represent of port link attributes
 type OFPortLink struct {
 	Ingress uint32
 	Egress  uint32
@@ -47,10 +52,12 @@
 	path []RouteHop
 }
 
+// GetDeviceFunc returns device function
 type GetDeviceFunc func(id string) (*voltha.Device, error)
 
+// DeviceGraph represent device graph attributes
 type DeviceGraph struct {
-	logicalDeviceId    string
+	logicalDeviceID    string
 	GGraph             goraph.Graph
 	getDeviceFromModel GetDeviceFunc
 	logicalPorts       []*voltha.LogicalPort
@@ -68,9 +75,10 @@
 	portsAdded         map[string]string
 }
 
-func NewDeviceGraph(logicalDeviceId string, getDevice GetDeviceFunc) *DeviceGraph {
+// NewDeviceGraph creates device graph instance
+func NewDeviceGraph(logicalDeviceID string, getDevice GetDeviceFunc) *DeviceGraph {
 	var dg DeviceGraph
-	dg.logicalDeviceId = logicalDeviceId
+	dg.logicalDeviceID = logicalDeviceID
 	dg.GGraph = goraph.NewGraph()
 	dg.getDeviceFromModel = getDevice
 	dg.graphBuildLock = sync.RWMutex{}
@@ -126,14 +134,14 @@
 
 	// Set the root, non-root ports and boundary ports
 	for _, lp := range lps {
-		portId := concatDeviceIdPortId(lp.DeviceId, lp.DevicePortNo)
+		portID := concatDeviceIDPortID(lp.DeviceId, lp.DevicePortNo)
 		if lp.RootPort {
-			dg.rootPortsString[portId] = lp.OfpPort.PortNo
+			dg.rootPortsString[portID] = lp.OfpPort.PortNo
 			dg.RootPorts[lp.OfpPort.PortNo] = lp.OfpPort.PortNo
 		} else {
-			dg.nonRootPortsString[portId] = lp.OfpPort.PortNo
+			dg.nonRootPortsString[portID] = lp.OfpPort.PortNo
 		}
-		dg.boundaryPorts[portId] = lp.OfpPort.PortNo
+		dg.boundaryPorts[portID] = lp.OfpPort.PortNo
 	}
 
 	// Build the graph
@@ -158,14 +166,14 @@
 	dg.graphBuildLock.Lock()
 	defer dg.graphBuildLock.Unlock()
 
-	portId := concatDeviceIdPortId(lp.DeviceId, lp.DevicePortNo)
+	portID := concatDeviceIDPortID(lp.DeviceId, lp.DevicePortNo)
 
 	//	If the port is already part of the boundary ports, do nothing
-	if dg.portExist(portId) {
+	if dg.portExist(portID) {
 		return
 	}
 	// Add the port to the set of boundary ports
-	dg.boundaryPorts[portId] = lp.OfpPort.PortNo
+	dg.boundaryPorts[portID] = lp.OfpPort.PortNo
 
 	// Add the device where this port is located to the device graph. If the device is already added then
 	// only the missing port will be added
@@ -174,20 +182,21 @@
 
 	if lp.RootPort {
 		// Compute the route from this root port to all non-root ports
-		dg.rootPortsString[portId] = lp.OfpPort.PortNo
+		dg.rootPortsString[portID] = lp.OfpPort.PortNo
 		dg.RootPorts[lp.OfpPort.PortNo] = lp.OfpPort.PortNo
 		dg.Routes = dg.buildPathsToAllNonRootPorts(lp)
 	} else {
 		// Compute the route from this port to all root ports
-		dg.nonRootPortsString[portId] = lp.OfpPort.PortNo
+		dg.nonRootPortsString[portID] = lp.OfpPort.PortNo
 		dg.Routes = dg.buildPathsToAllRootPorts(lp)
 	}
 
 	dg.Print()
 }
 
+// Print prints routes
 func (dg *DeviceGraph) Print() error {
-	log.Debugw("Print", log.Fields{"graph": dg.logicalDeviceId, "boundaryPorts": dg.boundaryPorts})
+	log.Debugw("Print", log.Fields{"graph": dg.logicalDeviceID, "boundaryPorts": dg.boundaryPorts})
 	if level, err := log.GetPackageLogLevel(); err == nil && level == log.DebugLevel {
 		output := ""
 		routeNumber := 1
@@ -199,28 +208,29 @@
 			}
 			val = val[:len(val)-1]
 			output += fmt.Sprintf("%d:{%s=>%s}   ", routeNumber, key, fmt.Sprintf("[%s]", val))
-			routeNumber += 1
+			routeNumber++
 		}
 		if len(dg.Routes) == 0 {
-			log.Debugw("no-routes-found", log.Fields{"lDeviceId": dg.logicalDeviceId, "Graph": dg.GGraph.String()})
+			log.Debugw("no-routes-found", log.Fields{"lDeviceId": dg.logicalDeviceID, "Graph": dg.GGraph.String()})
 		} else {
-			log.Debugw("graph_routes", log.Fields{"lDeviceId": dg.logicalDeviceId, "Routes": output})
+			log.Debugw("graph_routes", log.Fields{"lDeviceId": dg.logicalDeviceID, "Routes": output})
 		}
 	}
 	return nil
 }
 
+// IsUpToDate returns true if device is up to date
 func (dg *DeviceGraph) IsUpToDate(ld *voltha.LogicalDevice) bool {
 	if ld != nil {
 		if len(dg.boundaryPorts) != len(ld.Ports) {
 			return false
 		}
-		var portId string
+		var portID string
 		var val uint32
 		var exist bool
 		for _, lp := range ld.Ports {
-			portId = concatDeviceIdPortId(lp.DeviceId, lp.DevicePortNo)
-			if val, exist = dg.boundaryPorts[portId]; !exist || val != lp.OfpPort.PortNo {
+			portID = concatDeviceIDPortID(lp.DeviceId, lp.DevicePortNo)
+			if val, exist = dg.boundaryPorts[portID]; !exist || val != lp.OfpPort.PortNo {
 				return false
 			}
 		}
@@ -243,16 +253,17 @@
 		dg.cachedDevicesLock.RUnlock()
 	}
 	//	Not cached
-	if d, err := dg.getDeviceFromModel(id); err != nil {
+	d, err := dg.getDeviceFromModel(id)
+	if err != nil {
 		log.Errorw("device-not-found", log.Fields{"deviceId": id, "error": err})
 		return nil, err
-	} else { // cache it
-		dg.cachedDevicesLock.Lock()
-		dg.cachedDevices[id] = d
-		dg.cachedDevicesLock.Unlock()
-		//log.Debugw("getDevice - returned from model", log.Fields{"deviceId": id})
-		return d, nil
 	}
+	// cache it
+	dg.cachedDevicesLock.Lock()
+	dg.cachedDevices[id] = d
+	dg.cachedDevicesLock.Unlock()
+	//log.Debugw("getDevice - returned from model", log.Fields{"deviceId": id})
+	return d, nil
 }
 
 // addDevice adds a device to a device graph and setup edges that represent the device connections to its peers
@@ -270,25 +281,36 @@
 		(*devicesAdded)[device.Id] = device.Id
 	}
 
-	var portId string
-	var peerPortId string
+	var portID string
+	var peerPortID string
 	for _, port := range device.Ports {
-		portId = concatDeviceIdPortId(device.Id, port.PortNo)
-		if _, exist := (*portsAdded)[portId]; !exist {
-			(*portsAdded)[portId] = portId
-			g.AddNode(goraph.NewNode(portId))
-			g.AddEdge(goraph.StringID(device.Id), goraph.StringID(portId), 1)
-			g.AddEdge(goraph.StringID(portId), goraph.StringID(device.Id), 1)
+		portID = concatDeviceIDPortID(device.Id, port.PortNo)
+		if _, exist := (*portsAdded)[portID]; !exist {
+			(*portsAdded)[portID] = portID
+			g.AddNode(goraph.NewNode(portID))
+			err := g.AddEdge(goraph.StringID(device.Id), goraph.StringID(portID), 1)
+			if err != nil {
+				log.Errorw("unable-to-add-edge", log.Fields{"error": err})
+			}
+			err = g.AddEdge(goraph.StringID(portID), goraph.StringID(device.Id), 1)
+			if err != nil {
+				log.Errorw("unable-to-add-edge", log.Fields{"error": err})
+			}
 		}
 		for _, peer := range port.Peers {
 			if _, exist := (*devicesAdded)[peer.DeviceId]; !exist {
 				d, _ := dg.getDevice(peer.DeviceId, true)
 				g = dg.addDevice(d, g, devicesAdded, portsAdded, boundaryPorts)
 			}
-			peerPortId = concatDeviceIdPortId(peer.DeviceId, peer.PortNo)
-			g.AddEdge(goraph.StringID(portId), goraph.StringID(peerPortId), 1)
-			g.AddEdge(goraph.StringID(peerPortId), goraph.StringID(portId), 1)
-
+			peerPortID = concatDeviceIDPortID(peer.DeviceId, peer.PortNo)
+			err := g.AddEdge(goraph.StringID(portID), goraph.StringID(peerPortID), 1)
+			if err != nil {
+				log.Errorw("unable-to-add-edge", log.Fields{"error": err})
+			}
+			err = g.AddEdge(goraph.StringID(peerPortID), goraph.StringID(portID), 1)
+			if err != nil {
+				log.Errorw("unable-to-add-edge", log.Fields{"error": err})
+			}
 		}
 	}
 	return g
@@ -306,13 +328,13 @@
 // on the logical device
 func (dg *DeviceGraph) buildPathsToAllRootPorts(lp *voltha.LogicalPort) map[OFPortLink][]RouteHop {
 	paths := dg.Routes
-	source := concatDeviceIdPortId(lp.DeviceId, lp.DevicePortNo)
+	source := concatDeviceIDPortID(lp.DeviceId, lp.DevicePortNo)
 	sourcePort := lp.OfpPort.PortNo
 	ch := make(chan *ofPortLinkToPath)
 	numBuildRequest := 0
 	for target, targetPort := range dg.rootPortsString {
 		go dg.buildRoute(source, target, sourcePort, targetPort, ch)
-		numBuildRequest += 1
+		numBuildRequest++
 	}
 	responseReceived := 0
 forloop:
@@ -320,18 +342,16 @@
 		if responseReceived == numBuildRequest {
 			break
 		}
-		select {
-		case res, ok := <-ch:
-			if !ok {
-				log.Debug("channel closed")
-				break forloop
-			}
-			if res != nil && len(res.path) > 0 {
-				paths[res.link] = res.path
-				paths[OFPortLink{Ingress: res.link.Egress, Egress: res.link.Ingress}] = getReverseRoute(res.path)
-			}
+		res, ok := <-ch
+		if !ok {
+			log.Debug("channel closed")
+			break forloop
 		}
-		responseReceived += 1
+		if res != nil && len(res.path) > 0 {
+			paths[res.link] = res.path
+			paths[OFPortLink{Ingress: res.link.Egress, Egress: res.link.Ingress}] = getReverseRoute(res.path)
+		}
+		responseReceived++
 	}
 	return paths
 }
@@ -340,13 +360,13 @@
 // on the logical device
 func (dg *DeviceGraph) buildPathsToAllNonRootPorts(lp *voltha.LogicalPort) map[OFPortLink][]RouteHop {
 	paths := dg.Routes
-	source := concatDeviceIdPortId(lp.DeviceId, lp.DevicePortNo)
+	source := concatDeviceIDPortID(lp.DeviceId, lp.DevicePortNo)
 	sourcePort := lp.OfpPort.PortNo
 	ch := make(chan *ofPortLinkToPath)
 	numBuildRequest := 0
 	for target, targetPort := range dg.nonRootPortsString {
 		go dg.buildRoute(source, target, sourcePort, targetPort, ch)
-		numBuildRequest += 1
+		numBuildRequest++
 	}
 	responseReceived := 0
 forloop:
@@ -354,31 +374,29 @@
 		if responseReceived == numBuildRequest {
 			break
 		}
-		select {
-		case res, ok := <-ch:
-			if !ok {
-				log.Debug("channel closed")
-				break forloop
-			}
-			if res != nil && len(res.path) > 0 {
-				paths[res.link] = res.path
-				paths[OFPortLink{Ingress: res.link.Egress, Egress: res.link.Ingress}] = getReverseRoute(res.path)
-			}
+		res, ok := <-ch
+		if !ok {
+			log.Debug("channel closed")
+			break forloop
 		}
-		responseReceived += 1
+		if res != nil && len(res.path) > 0 {
+			paths[res.link] = res.path
+			paths[OFPortLink{Ingress: res.link.Egress, Egress: res.link.Ingress}] = getReverseRoute(res.path)
+		}
+		responseReceived++
 	}
 	return paths
 }
 
 //buildRoute builds a route between a source and a target logical port
-func (dg *DeviceGraph) buildRoute(sourceId, targetId string, sourcePort, targetPort uint32, ch chan *ofPortLinkToPath) {
+func (dg *DeviceGraph) buildRoute(sourceID, targetID string, sourcePort, targetPort uint32, ch chan *ofPortLinkToPath) {
 	var pathIds []goraph.ID
 	path := make([]RouteHop, 0)
 	var err error
 	var hop RouteHop
 	var result *ofPortLinkToPath
 
-	if sourceId == targetId {
+	if sourceID == targetID {
 		ch <- result
 		return
 	}
@@ -394,8 +412,8 @@
 		return
 	}
 
-	if pathIds, _, err = goraph.Dijkstra(dg.GGraph, goraph.StringID(sourceId), goraph.StringID(targetId)); err != nil {
-		log.Errorw("no-path", log.Fields{"sourceId": sourceId, "targetId": targetId, "error": err})
+	if pathIds, _, err = goraph.Dijkstra(dg.GGraph, goraph.StringID(sourceID), goraph.StringID(targetID)); err != nil {
+		log.Errorw("no-path", log.Fields{"sourceId": sourceID, "targetId": targetID, "error": err})
 		ch <- result
 		return
 	}
@@ -403,19 +421,19 @@
 		ch <- result
 		return
 	}
-	var deviceId string
+	var deviceID string
 	var ingressPort uint32
 	var egressPort uint32
 	for i := 0; i < len(pathIds); i = i + 3 {
-		if deviceId, ingressPort, err = splitIntoDeviceIdPortId(pathIds[i].String()); err != nil {
-			log.Errorw("id-error", log.Fields{"sourceId": sourceId, "targetId": targetId, "error": err})
+		if deviceID, ingressPort, err = splitIntoDeviceIDPortID(pathIds[i].String()); err != nil {
+			log.Errorw("id-error", log.Fields{"sourceId": sourceID, "targetId": targetID, "error": err})
 			break
 		}
-		if _, egressPort, err = splitIntoDeviceIdPortId(pathIds[i+2].String()); err != nil {
-			log.Errorw("id-error", log.Fields{"sourceId": sourceId, "targetId": targetId, "error": err})
+		if _, egressPort, err = splitIntoDeviceIDPortID(pathIds[i+2].String()); err != nil {
+			log.Errorw("id-error", log.Fields{"sourceId": sourceID, "targetId": targetID, "error": err})
 			break
 		}
-		hop = RouteHop{Ingress: ingressPort, DeviceID: deviceId, Egress: egressPort}
+		hop = RouteHop{Ingress: ingressPort, DeviceID: deviceID, Egress: egressPort}
 		path = append(path, hop)
 	}
 	result = &ofPortLinkToPath{link: OFPortLink{Ingress: sourcePort, Egress: targetPort}, path: path}
@@ -430,7 +448,7 @@
 	for source, sourcePort := range dg.boundaryPorts {
 		for target, targetPort := range dg.boundaryPorts {
 			go dg.buildRoute(source, target, sourcePort, targetPort, ch)
-			numBuildRequest += 1
+			numBuildRequest++
 		}
 	}
 	responseReceived := 0
@@ -439,17 +457,15 @@
 		if responseReceived == numBuildRequest {
 			break
 		}
-		select {
-		case res, ok := <-ch:
-			if !ok {
-				log.Debug("channel closed")
-				break forloop
-			}
-			if res != nil && len(res.path) > 0 {
-				paths[res.link] = res.path
-			}
+		res, ok := <-ch
+		if !ok {
+			log.Debug("channel closed")
+			break forloop
 		}
-		responseReceived += 1
+		if res != nil && len(res.path) > 0 {
+			paths[res.link] = res.path
+		}
+		responseReceived++
 	}
 	return paths
 }
@@ -467,21 +483,21 @@
 }
 
 //concatDeviceIdPortId formats a portid using the device id and the port number
-func concatDeviceIdPortId(deviceId string, portNo uint32) string {
-	return fmt.Sprintf("%s:%d", deviceId, portNo)
+func concatDeviceIDPortID(deviceID string, portNo uint32) string {
+	return fmt.Sprintf("%s:%d", deviceID, portNo)
 }
 
 // splitIntoDeviceIdPortId extracts the device id and port number from the portId
-func splitIntoDeviceIdPortId(id string) (string, uint32, error) {
+func splitIntoDeviceIDPortID(id string) (string, uint32, error) {
 	result := strings.Split(id, ":")
 	if len(result) != 2 {
-		return "", 0, errors.New(fmt.Sprintf("invalid-id-%s", id))
+		return "", 0, fmt.Errorf("invalid-id-%s", id)
 	}
-	if temp, err := strconv.ParseInt(result[1], 10, 32); err != nil {
-		return "", 0, errors.New(fmt.Sprintf("invalid-id-%s-%s", id, err.Error()))
-	} else {
-		return result[0], uint32(temp), nil
+	temp, err := strconv.ParseInt(result[1], 10, 32)
+	if err != nil {
+		return "", 0, fmt.Errorf("invalid-id-%s-%s", id, err.Error())
 	}
+	return result[0], uint32(temp), nil
 }
 
 //getReverseRoute returns the reverse of the route
diff --git a/rw_core/graph/device_graph_test.go b/rw_core/graph/device_graph_test.go
index cb777fb..a4214e9 100644
--- a/rw_core/graph/device_graph_test.go
+++ b/rw_core/graph/device_graph_test.go
@@ -33,24 +33,24 @@
 	ld              voltha.LogicalDevice
 	olt             voltha.Device
 	onus            map[int][]voltha.Device
-	logicalDeviceId string
-	oltDeviceId     string
+	logicalDeviceID string
+	oltDeviceID     string
 	numCalled       int
 	lock            sync.RWMutex
 )
 
 func init() {
-	logicalDeviceId = "ld"
-	oltDeviceId = "olt"
+	logicalDeviceID = "ld"
+	oltDeviceID = "olt"
 	lock = sync.RWMutex{}
 }
 
 func setupDevices(numNNIPort, numPonPortOnOlt, numOnuPerOltPonPort, numUniPerOnu int) {
 	// Create the OLT and add the NNI ports
-	olt = voltha.Device{Id: oltDeviceId, ParentId: logicalDeviceId}
+	olt = voltha.Device{Id: oltDeviceID, ParentId: logicalDeviceID}
 	olt.Ports = make([]*voltha.Port, 0)
 	for nniPort := 1; nniPort < numNNIPort+1; nniPort++ {
-		p := voltha.Port{PortNo: uint32(nniPort), DeviceId: oltDeviceId, Type: voltha.Port_ETHERNET_NNI}
+		p := voltha.Port{PortNo: uint32(nniPort), DeviceId: oltDeviceID, Type: voltha.Port_ETHERNET_NNI}
 		olt.Ports = append(olt.Ports, &p)
 	}
 
@@ -60,14 +60,14 @@
 		onusOnPon := make([]voltha.Device, 0)
 		var onu voltha.Device
 		oltPeerPort := uint32(pPortNo)
-		oltPonPort := voltha.Port{PortNo: uint32(pPortNo), DeviceId: oltDeviceId, Type: voltha.Port_PON_OLT}
+		oltPonPort := voltha.Port{PortNo: uint32(pPortNo), DeviceId: oltDeviceID, Type: voltha.Port_PON_OLT}
 		oltPonPort.Peers = make([]*voltha.Port_PeerPort, 0)
 		for i := 0; i < numOnuPerOltPonPort; i++ {
 			id := fmt.Sprintf("%d-onu-%d", pPortNo, i)
-			onu = voltha.Device{Id: id, ParentId: oltDeviceId, ParentPortNo: uint32(pPortNo)}
+			onu = voltha.Device{Id: id, ParentId: oltDeviceID, ParentPortNo: uint32(pPortNo)}
 			ponPort := voltha.Port{PortNo: 1, DeviceId: onu.Id, Type: voltha.Port_PON_ONU}
 			ponPort.Peers = make([]*voltha.Port_PeerPort, 0)
-			peerPort := voltha.Port_PeerPort{DeviceId: oltDeviceId, PortNo: oltPeerPort}
+			peerPort := voltha.Port_PeerPort{DeviceId: oltDeviceID, PortNo: oltPeerPort}
 			ponPort.Peers = append(ponPort.Peers, &peerPort)
 			onu.Ports = make([]*voltha.Port, 0)
 			onu.Ports = append(onu.Ports, &ponPort)
@@ -84,7 +84,7 @@
 	}
 
 	// Create the logical device
-	ld = voltha.LogicalDevice{Id: logicalDeviceId}
+	ld = voltha.LogicalDevice{Id: logicalDeviceID}
 	ld.Ports = make([]*voltha.LogicalPort, 0)
 	ofpPortNo := 1
 	var id string
@@ -114,7 +114,7 @@
 
 func GetDeviceHelper(id string) (*voltha.Device, error) {
 	lock.Lock()
-	numCalled += 1
+	numCalled++
 	lock.Unlock()
 	if id == "olt" {
 		return &olt, nil
@@ -146,7 +146,7 @@
 	fmt.Println(fmt.Sprintf("Test: Computing all routes. LogicalPorts:%d,  NNI:%d, Pon/OLT:%d, ONU/Pon:%d, Uni/Onu:%d", len(ld.Ports), numNNIPort, numPonPortOnOlt, numOnuPerOltPonPort, numUniPerOnu))
 	// Create a device graph and computes Routes
 	start := time.Now()
-	dg := NewDeviceGraph(logicalDeviceId, getDevice)
+	dg := NewDeviceGraph(logicalDeviceID, getDevice)
 	dg.ComputeRoutes(ld.Ports)
 	assert.NotNil(t, dg.GGraph)
 	fmt.Println(fmt.Sprintf("Total Time:%dms  Total Routes:%d", time.Since(start)/time.Millisecond, len(dg.Routes)))
@@ -167,7 +167,7 @@
 	// Create a device graph and computes Routes
 	start := time.Now()
 	var pt time.Time
-	dg := NewDeviceGraph(logicalDeviceId, getDevice)
+	dg := NewDeviceGraph(logicalDeviceID, getDevice)
 	for k, lp := range ld.Ports {
 		if k == len(ld.Ports)-1 {
 			pt = time.Now()
@@ -193,7 +193,7 @@
 	// Create a device graph and computes Routes
 	start := time.Now()
 	var pt time.Time
-	dg := NewDeviceGraph(logicalDeviceId, getDevice)
+	dg := NewDeviceGraph(logicalDeviceID, getDevice)
 	for k, lp := range ld.Ports {
 		if k == len(ld.Ports)-1 {
 			pt = time.Now()
@@ -220,7 +220,7 @@
 	// Create a device graph and computes Routes
 	start := time.Now()
 	var pt time.Time
-	dg := NewDeviceGraph(logicalDeviceId, getDevice)
+	dg := NewDeviceGraph(logicalDeviceID, getDevice)
 	for k, lp := range ld.Ports {
 		if k == len(ld.Ports)-1 {
 			pt = time.Now()
@@ -247,7 +247,7 @@
 	// Create a device graph and computes Routes
 	start := time.Now()
 	var pt time.Time
-	dg := NewDeviceGraph(logicalDeviceId, getDevice)
+	dg := NewDeviceGraph(logicalDeviceID, getDevice)
 	for k, lp := range ld.Ports {
 		if k == len(ld.Ports)-1 {
 			pt = time.Now()
@@ -274,7 +274,7 @@
 	// Create a device graph and computes Routes
 	start := time.Now()
 	var pt time.Time
-	dg := NewDeviceGraph(logicalDeviceId, getDevice)
+	dg := NewDeviceGraph(logicalDeviceID, getDevice)
 	for k, lp := range ld.Ports {
 		if k == len(ld.Ports)-1 {
 			pt = time.Now()
diff --git a/rw_core/main.go b/rw_core/main.go
index 8ad3833..c066275 100644
--- a/rw_core/main.go
+++ b/rw_core/main.go
@@ -13,27 +13,28 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package main
 
 import (
 	"context"
 	"errors"
 	"fmt"
-	"github.com/opencord/voltha-go/rw_core/config"
-	c "github.com/opencord/voltha-go/rw_core/core"
-	"github.com/opencord/voltha-go/rw_core/utils"
-	"github.com/opencord/voltha-lib-go/v2/pkg/db/kvstore"
-	grpcserver "github.com/opencord/voltha-lib-go/v2/pkg/grpc"
-	"github.com/opencord/voltha-lib-go/v2/pkg/kafka"
-	"github.com/opencord/voltha-lib-go/v2/pkg/log"
-	"github.com/opencord/voltha-lib-go/v2/pkg/probe"
-	"github.com/opencord/voltha-lib-go/v2/pkg/version"
-	ic "github.com/opencord/voltha-protos/v2/go/inter_container"
 	"os"
 	"os/signal"
 	"strconv"
 	"syscall"
 	"time"
+
+	"github.com/opencord/voltha-go/rw_core/config"
+	c "github.com/opencord/voltha-go/rw_core/core"
+	"github.com/opencord/voltha-go/rw_core/utils"
+	"github.com/opencord/voltha-lib-go/v2/pkg/db/kvstore"
+	"github.com/opencord/voltha-lib-go/v2/pkg/kafka"
+	"github.com/opencord/voltha-lib-go/v2/pkg/log"
+	"github.com/opencord/voltha-lib-go/v2/pkg/probe"
+	"github.com/opencord/voltha-lib-go/v2/pkg/version"
+	ic "github.com/opencord/voltha-protos/v2/go/inter_container"
 )
 
 type rwCore struct {
@@ -42,7 +43,6 @@
 	halted      bool
 	exitChannel chan int
 	//kmp         *kafka.KafkaMessagingProxy
-	grpcServer  *grpcserver.GrpcServer
 	kafkaClient kafka.Client
 	core        *c.Core
 	//For test
@@ -50,7 +50,10 @@
 }
 
 func init() {
-	log.AddPackage(log.JSON, log.DebugLevel, nil)
+	_, err := log.AddPackage(log.JSON, log.DebugLevel, nil)
+	if err != nil {
+		log.Errorw("unable-to-register-package-to-the-log-map", log.Fields{"error": err})
+	}
 }
 
 func newKVClient(storeType string, address string, timeout int) (kvstore.Client, error) {
@@ -110,18 +113,7 @@
 	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 (rw *rwCore) start(ctx context.Context, instanceId string) {
+func (rw *rwCore) start(ctx context.Context, instanceID string) {
 	log.Info("Starting RW Core components")
 
 	// Setup KV Client
@@ -130,7 +122,7 @@
 	if err == nil {
 		// Setup KV transaction context
 		txnPrefix := rw.config.KVStoreDataPrefix + "/transactions/"
-		if err = c.SetTransactionContext(instanceId,
+		if err = c.SetTransactionContext(instanceID,
 			txnPrefix,
 			rw.kvClient,
 			rw.config.KVStoreTimeout); err != nil {
@@ -142,13 +134,13 @@
 	if rw.kafkaClient, err = newKafkaClient("sarama",
 		rw.config.KafkaAdapterHost,
 		rw.config.KafkaAdapterPort,
-		instanceId,
+		instanceID,
 		rw.config.LiveProbeInterval/2); err != nil {
 		log.Fatal("Unsupported-kafka-client")
 	}
 
 	// Create the core service
-	rw.core = c.NewCore(instanceId, rw.config, rw.kvClient, rw.kafkaClient)
+	rw.core = c.NewCore(instanceID, rw.config, rw.kvClient, rw.kafkaClient)
 
 	// start the core
 	rw.core.Start(ctx)
@@ -229,21 +221,21 @@
 	cf.ParseCommandArguments()
 
 	// Set the instance ID as the hostname
-	var instanceId string
+	var instanceID string
 	hostName := utils.GetHostName()
 	if len(hostName) > 0 {
-		instanceId = hostName
+		instanceID = hostName
 	} else {
 		log.Fatal("HOSTNAME not set")
 	}
 
 	//Setup default logger - applies for packages that do not have specific logger set
-	if _, err := log.SetDefaultLogger(log.JSON, cf.LogLevel, log.Fields{"instanceId": instanceId}); err != nil {
+	if _, err := log.SetDefaultLogger(log.JSON, cf.LogLevel, log.Fields{"instanceId": instanceID}); err != nil {
 		log.With(log.Fields{"error": err}).Fatal("Cannot setup logging")
 	}
 
 	// Update all loggers (provisioned via init) with a common field
-	if err := log.UpdateAllLoggers(log.Fields{"instanceId": instanceId}); err != nil {
+	if err := log.UpdateAllLoggers(log.Fields{"instanceId": instanceID}); err != nil {
 		log.With(log.Fields{"error": err}).Fatal("Cannot setup logging")
 	}
 
@@ -252,7 +244,12 @@
 
 	//log.SetPackageLogLevel("github.com/opencord/voltha-go/rw_core/core", log.DebugLevel)
 
-	defer log.CleanUp()
+	defer func() {
+		err := log.CleanUp()
+		if err != nil {
+			log.Errorw("unable-to-flush-any-buffered-log-entries", log.Fields{"error": err})
+		}
+	}()
 
 	// Print version / build information and exit
 	if cf.DisplayVersionOnly {
@@ -286,7 +283,7 @@
 	probeCtx := context.WithValue(ctx, probe.ProbeContextKey, p)
 
 	// Start the core
-	go rw.start(probeCtx, instanceId)
+	go rw.start(probeCtx, instanceID)
 
 	code := waitForExit()
 	log.Infow("received-a-closing-signal", log.Fields{"code": code})
@@ -295,5 +292,5 @@
 	rw.stop(probeCtx)
 
 	elapsed := time.Since(start)
-	log.Infow("rw-core-run-time", log.Fields{"core": instanceId, "time": elapsed / time.Second})
+	log.Infow("rw-core-run-time", log.Fields{"core": instanceID, "time": elapsed / time.Second})
 }
diff --git a/rw_core/mocks/adapter.go b/rw_core/mocks/adapter.go
index a510e58..4908573 100644
--- a/rw_core/mocks/adapter.go
+++ b/rw_core/mocks/adapter.go
@@ -13,18 +13,20 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package mocks
 
 import (
+	"strconv"
+	"strings"
+	"sync"
+
 	"github.com/opencord/voltha-lib-go/v2/pkg/adapters/adapterif"
 	ic "github.com/opencord/voltha-protos/v2/go/inter_container"
 	of "github.com/opencord/voltha-protos/v2/go/openflow_13"
 	"github.com/opencord/voltha-protos/v2/go/voltha"
 	"google.golang.org/grpc/codes"
 	"google.golang.org/grpc/status"
-	"strconv"
-	"strings"
-	"sync"
 )
 
 func macAddressToUint32Array(mac string) []uint32 {
@@ -41,11 +43,13 @@
 	return result
 }
 
+// Adapter represents adapter attributes
 type Adapter struct {
 	coreProxy adapterif.CoreProxy
 	devices   sync.Map
 }
 
+// NewAdapter creates adapter instance
 func NewAdapter(cp adapterif.CoreProxy) *Adapter {
 	return &Adapter{
 		coreProxy: cp,
@@ -58,10 +62,6 @@
 	}
 }
 
-func (ta *Adapter) deleteDevice(id string) {
-	ta.devices.Delete(id)
-}
-
 func (ta *Adapter) getDevice(id string) *voltha.Device {
 	if val, ok := ta.devices.Load(id); ok && val != nil {
 		if device, ok := val.(*voltha.Device); ok {
@@ -80,75 +80,98 @@
 	return nil
 }
 
-func (ta *Adapter) Adapter_descriptor() error {
+// Adapter_descriptor -
+func (ta *Adapter) Adapter_descriptor() error { // nolint
 	return nil
 }
-func (ta *Adapter) Device_types() (*voltha.DeviceTypes, error) {
+
+// Device_types -
+func (ta *Adapter) Device_types() (*voltha.DeviceTypes, error) { // nolint
 	return nil, nil
 }
+
+// Health -
 func (ta *Adapter) Health() (*voltha.HealthStatus, error) {
 	return nil, nil
 }
-func (ta *Adapter) Adopt_device(device *voltha.Device) error {
+
+// Adopt_device -
+func (ta *Adapter) Adopt_device(device *voltha.Device) error { // nolint
 	return nil
 }
 
-func (ta *Adapter) Reconcile_device(device *voltha.Device) error {
+// Reconcile_device -
+func (ta *Adapter) Reconcile_device(device *voltha.Device) error { // nolint
 	return nil
 }
 
-func (ta *Adapter) Abandon_device(device *voltha.Device) error {
+// Abandon_device -
+func (ta *Adapter) Abandon_device(device *voltha.Device) error { // nolint
 	return nil
 }
 
-func (ta *Adapter) Disable_device(device *voltha.Device) error {
+// Disable_device -
+func (ta *Adapter) Disable_device(device *voltha.Device) error { // nolint
 	return nil
 }
 
-func (ta *Adapter) Reenable_device(device *voltha.Device) error {
+// Reenable_device -
+func (ta *Adapter) Reenable_device(device *voltha.Device) error { // nolint
 	return nil
 }
 
-func (ta *Adapter) Reboot_device(device *voltha.Device) error {
+// Reboot_device -
+func (ta *Adapter) Reboot_device(device *voltha.Device) error { // nolint
 	return nil
 }
 
-func (ta *Adapter) Self_test_device(device *voltha.Device) error {
+// Self_test_device -
+func (ta *Adapter) Self_test_device(device *voltha.Device) error { // nolint
 	return nil
 }
 
-func (ta *Adapter) Delete_device(device *voltha.Device) error {
+// Delete_device -
+func (ta *Adapter) Delete_device(device *voltha.Device) error { // nolint
 	return nil
 }
 
-func (ta *Adapter) Get_device_details(device *voltha.Device) error {
+// Get_device_details -
+func (ta *Adapter) Get_device_details(device *voltha.Device) error { // nolint
 	return nil
 }
 
-func (ta *Adapter) Update_flows_bulk(device *voltha.Device, flows *voltha.Flows, groups *voltha.FlowGroups, flowMetadata *voltha.FlowMetadata) error {
+// Update_flows_bulk -
+func (ta *Adapter) Update_flows_bulk(device *voltha.Device, flows *voltha.Flows, groups *voltha.FlowGroups, flowMetadata *voltha.FlowMetadata) error { // nolint
 	return nil
 }
 
-func (ta *Adapter) Update_flows_incrementally(device *voltha.Device, flows *of.FlowChanges, groups *of.FlowGroupChanges, flowMetadata *voltha.FlowMetadata) error {
-	return nil
-}
-func (ta *Adapter) Update_pm_config(device *voltha.Device, pm_configs *voltha.PmConfigs) error {
+// Update_flows_incrementally -
+func (ta *Adapter) Update_flows_incrementally(device *voltha.Device, flows *of.FlowChanges, groups *of.FlowGroupChanges, flowMetadata *voltha.FlowMetadata) error { // nolint
 	return nil
 }
 
-func (ta *Adapter) Receive_packet_out(deviceId string, egress_port_no int, msg *of.OfpPacketOut) error {
+// Update_pm_config -
+func (ta *Adapter) Update_pm_config(device *voltha.Device, pmConfigs *voltha.PmConfigs) error { // nolint
 	return nil
 }
 
-func (ta *Adapter) Suppress_alarm(filter *voltha.AlarmFilter) error {
+// Receive_packet_out -
+func (ta *Adapter) Receive_packet_out(deviceID string, egressPortNo int, msg *of.OfpPacketOut) error { // nolint
 	return nil
 }
 
-func (ta *Adapter) Unsuppress_alarm(filter *voltha.AlarmFilter) error {
+// Suppress_alarm -
+func (ta *Adapter) Suppress_alarm(filter *voltha.AlarmFilter) error { // nolint
 	return nil
 }
 
-func (ta *Adapter) Get_ofp_device_info(device *voltha.Device) (*ic.SwitchCapability, error) {
+// Unsuppress_alarm -
+func (ta *Adapter) Unsuppress_alarm(filter *voltha.AlarmFilter) error { // nolint
+	return nil
+}
+
+// Get_ofp_device_info -
+func (ta *Adapter) Get_ofp_device_info(device *voltha.Device) (*ic.SwitchCapability, error) { // nolint
 	return &ic.SwitchCapability{
 		Desc: &of.OfpDesc{
 			HwDesc:    "adapter_mock",
@@ -166,7 +189,8 @@
 	}, nil
 }
 
-func (ta *Adapter) Get_ofp_port_info(device *voltha.Device, port_no int64) (*ic.PortCapability, error) {
+// Get_ofp_port_info -
+func (ta *Adapter) Get_ofp_port_info(device *voltha.Device, portNo int64) (*ic.PortCapability, error) { // nolint
 	capability := uint32(of.OfpPortFeatures_OFPPF_1GB_FD | of.OfpPortFeatures_OFPPF_FIBER)
 	return &ic.PortCapability{
 		Port: &voltha.LogicalPort{
@@ -181,31 +205,37 @@
 				MaxSpeed:   uint32(of.OfpPortFeatures_OFPPF_1GB_FD),
 			},
 			DeviceId:     device.Id,
-			DevicePortNo: uint32(port_no),
+			DevicePortNo: uint32(portNo),
 		},
 	}, nil
 }
 
-func (ta *Adapter) Process_inter_adapter_message(msg *ic.InterAdapterMessage) error {
+// Process_inter_adapter_message -
+func (ta *Adapter) Process_inter_adapter_message(msg *ic.InterAdapterMessage) error { // nolint
 	return nil
 }
 
-func (ta *Adapter) Download_image(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
+// Download_image -
+func (ta *Adapter) Download_image(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) { // nolint
 	return nil, nil
 }
 
-func (ta *Adapter) Get_image_download_status(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
+// Get_image_download_status -
+func (ta *Adapter) Get_image_download_status(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) { // nolint
 	return nil, nil
 }
 
-func (ta *Adapter) Cancel_image_download(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
+// Cancel_image_download -
+func (ta *Adapter) Cancel_image_download(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) { // nolint
 	return nil, nil
 }
 
-func (ta *Adapter) Activate_image_update(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
+// Activate_image_update -
+func (ta *Adapter) Activate_image_update(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) { // nolint
 	return nil, nil
 }
 
-func (ta *Adapter) Revert_image_update(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
+// Revert_image_update -
+func (ta *Adapter) Revert_image_update(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) { // nolint
 	return nil, nil
 }
diff --git a/rw_core/mocks/adapter_olt.go b/rw_core/mocks/adapter_olt.go
index 89f6c20..7cf0d47 100644
--- a/rw_core/mocks/adapter_olt.go
+++ b/rw_core/mocks/adapter_olt.go
@@ -13,11 +13,14 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package mocks
 
 import (
 	"context"
 	"fmt"
+	"strings"
+
 	"github.com/gogo/protobuf/proto"
 	"github.com/opencord/voltha-lib-go/v2/pkg/adapters/adapterif"
 	com "github.com/opencord/voltha-lib-go/v2/pkg/adapters/common"
@@ -25,24 +28,26 @@
 	ic "github.com/opencord/voltha-protos/v2/go/inter_container"
 	of "github.com/opencord/voltha-protos/v2/go/openflow_13"
 	"github.com/opencord/voltha-protos/v2/go/voltha"
-	"strings"
 )
 
 const (
 	numONUPerOLT = 4
 )
 
+// OLTAdapter represent OLT adapter
 type OLTAdapter struct {
 	Adapter
 }
 
+// NewOLTAdapter - creates OLT adapter instance
 func NewOLTAdapter(cp adapterif.CoreProxy) *OLTAdapter {
 	a := &OLTAdapter{}
 	a.coreProxy = cp
 	return a
 }
 
-func (oltA *OLTAdapter) Adopt_device(device *voltha.Device) error {
+// Adopt_device creates new handler for added device
+func (oltA *OLTAdapter) Adopt_device(device *voltha.Device) error { // nolint
 	go func() {
 		d := proto.Clone(device).(*voltha.Device)
 		d.Root = true
@@ -112,7 +117,8 @@
 	return nil
 }
 
-func (oltA *OLTAdapter) Get_ofp_device_info(device *voltha.Device) (*ic.SwitchCapability, error) {
+// Get_ofp_device_info returns ofp device info
+func (oltA *OLTAdapter) Get_ofp_device_info(device *voltha.Device) (*ic.SwitchCapability, error) { // nolint
 	if d := oltA.getDevice(device.Id); d == nil {
 		log.Fatalf("device-not-found-%s", device.Id)
 	}
@@ -133,7 +139,8 @@
 	}, nil
 }
 
-func (oltA *OLTAdapter) Get_ofp_port_info(device *voltha.Device, port_no int64) (*ic.PortCapability, error) {
+// Get_ofp_port_info returns ofp port info
+func (oltA *OLTAdapter) Get_ofp_port_info(device *voltha.Device, portNo int64) (*ic.PortCapability, error) { // nolint
 	if d := oltA.getDevice(device.Id); d == nil {
 		log.Fatalf("device-not-found-%s", device.Id)
 	}
@@ -151,16 +158,18 @@
 				MaxSpeed:   uint32(of.OfpPortFeatures_OFPPF_1GB_FD),
 			},
 			DeviceId:     device.Id,
-			DevicePortNo: uint32(port_no),
+			DevicePortNo: uint32(portNo),
 		},
 	}, nil
 }
 
+// GetNumONUPerOLT returns number of ONUs per OLT
 func (oltA *OLTAdapter) GetNumONUPerOLT() int {
 	return numONUPerOLT
 }
 
-func (oltA *OLTAdapter) Disable_device(device *voltha.Device) error {
+// Disable_device disables device
+func (oltA *OLTAdapter) Disable_device(device *voltha.Device) error { // nolint
 	go func() {
 		if d := oltA.getDevice(device.Id); d == nil {
 			log.Fatalf("device-not-found-%s", device.Id)
@@ -192,7 +201,8 @@
 	return nil
 }
 
-func (oltA *OLTAdapter) Reenable_device(device *voltha.Device) error {
+// Reenable_device reenables device
+func (oltA *OLTAdapter) Reenable_device(device *voltha.Device) error { // nolint
 	go func() {
 		if d := oltA.getDevice(device.Id); d == nil {
 			log.Fatalf("device-not-found-%s", device.Id)
diff --git a/rw_core/mocks/adapter_olt_test.go b/rw_core/mocks/adapter_olt_test.go
index 6d61e1f..aa91ab5 100644
--- a/rw_core/mocks/adapter_olt_test.go
+++ b/rw_core/mocks/adapter_olt_test.go
@@ -17,8 +17,9 @@
 package mocks
 
 import (
-	"github.com/opencord/voltha-lib-go/v2/pkg/adapters"
 	"testing"
+
+	"github.com/opencord/voltha-lib-go/v2/pkg/adapters"
 )
 
 func TestOLTAdapterImplementsIAdapter(t *testing.T) {
diff --git a/rw_core/mocks/adapter_onu.go b/rw_core/mocks/adapter_onu.go
index 66a3538..bb6f58a 100644
--- a/rw_core/mocks/adapter_onu.go
+++ b/rw_core/mocks/adapter_onu.go
@@ -13,11 +13,14 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package mocks
 
 import (
 	"context"
 	"fmt"
+	"strings"
+
 	"github.com/gogo/protobuf/proto"
 	"github.com/opencord/voltha-lib-go/v2/pkg/adapters/adapterif"
 	com "github.com/opencord/voltha-lib-go/v2/pkg/adapters/common"
@@ -25,21 +28,23 @@
 	ic "github.com/opencord/voltha-protos/v2/go/inter_container"
 	of "github.com/opencord/voltha-protos/v2/go/openflow_13"
 	"github.com/opencord/voltha-protos/v2/go/voltha"
-	"strings"
 )
 
+// ONUAdapter represent ONU adapter attributes
 type ONUAdapter struct {
 	coreProxy adapterif.CoreProxy
 	Adapter
 }
 
+// NewONUAdapter creates ONU adapter
 func NewONUAdapter(cp adapterif.CoreProxy) *ONUAdapter {
 	a := &ONUAdapter{}
 	a.coreProxy = cp
 	return a
 }
 
-func (onuA *ONUAdapter) Adopt_device(device *voltha.Device) error {
+// Adopt_device creates new handler for added device
+func (onuA *ONUAdapter) Adopt_device(device *voltha.Device) error { // nolint
 	go func() {
 		d := proto.Clone(device).(*voltha.Device)
 		d.Root = false
@@ -89,7 +94,7 @@
 			Peers: []*voltha.Port_PeerPort{{DeviceId: d.ParentId, // Peer device  is OLT
 				PortNo: uniPortNo}}, // Peer port is UNI port
 		}
-		if err := onuA.coreProxy.PortCreated(context.TODO(), d.Id, ponPort); err != nil {
+		if err = onuA.coreProxy.PortCreated(context.TODO(), d.Id, ponPort); err != nil {
 			log.Fatalf("PortCreated-failed-%s", err)
 		}
 
@@ -111,7 +116,8 @@
 	return nil
 }
 
-func (onuA *ONUAdapter) Get_ofp_port_info(device *voltha.Device, port_no int64) (*ic.PortCapability, error) {
+// Get_ofp_port_info returns ofp device info
+func (onuA *ONUAdapter) Get_ofp_port_info(device *voltha.Device, portNo int64) (*ic.PortCapability, error) { // nolint
 	if d := onuA.getDevice(device.Id); d == nil {
 		log.Fatalf("device-not-found-%s", device.Id)
 	}
@@ -129,12 +135,13 @@
 				MaxSpeed:   uint32(of.OfpPortFeatures_OFPPF_1GB_FD),
 			},
 			DeviceId:     device.Id,
-			DevicePortNo: uint32(port_no),
+			DevicePortNo: uint32(portNo),
 		},
 	}, nil
 }
 
-func (onuA *ONUAdapter) Disable_device(device *voltha.Device) error {
+// Disable_device disables device
+func (onuA *ONUAdapter) Disable_device(device *voltha.Device) error { // nolint
 	go func() {
 		if d := onuA.getDevice(device.Id); d == nil {
 			log.Fatalf("device-not-found-%s", device.Id)
@@ -158,7 +165,8 @@
 	return nil
 }
 
-func (onuA *ONUAdapter) Reenable_device(device *voltha.Device) error {
+// Reenable_device reenables device
+func (onuA *ONUAdapter) Reenable_device(device *voltha.Device) error { // nolint
 	go func() {
 		if d := onuA.getDevice(device.Id); d == nil {
 			log.Fatalf("device-not-found-%s", device.Id)
diff --git a/rw_core/mocks/device_manager.go b/rw_core/mocks/device_manager.go
index c8bf1ca..1968efa 100644
--- a/rw_core/mocks/device_manager.go
+++ b/rw_core/mocks/device_manager.go
@@ -13,129 +13,166 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package mocks
 
 import (
 	"context"
+
 	"github.com/opencord/voltha-protos/v2/go/voltha"
 )
 
+// DeviceManager -
 type DeviceManager struct {
 }
 
-func (dm *DeviceManager) GetDevice(deviceId string) (*voltha.Device, error) {
+// GetDevice -
+func (dm *DeviceManager) GetDevice(deviceID string) (*voltha.Device, error) {
 	return nil, nil
 }
-func (dm *DeviceManager) IsRootDevice(deviceId string) (bool, error) {
+
+// IsRootDevice -
+func (dm *DeviceManager) IsRootDevice(deviceID string) (bool, error) {
 	return false, nil
 }
 
+// NotifyInvalidTransition -
 func (dm *DeviceManager) NotifyInvalidTransition(pcDevice *voltha.Device) error {
 	return nil
 }
 
+// SetAdminStateToEnable -
 func (dm *DeviceManager) SetAdminStateToEnable(cDevice *voltha.Device) error {
 	return nil
 }
 
+// CreateLogicalDevice -
 func (dm *DeviceManager) CreateLogicalDevice(cDevice *voltha.Device) error {
 	return nil
 }
 
+// SetupUNILogicalPorts -
 func (dm *DeviceManager) SetupUNILogicalPorts(cDevice *voltha.Device) error {
 	return nil
 }
 
+// DisableAllChildDevices -
 func (dm *DeviceManager) DisableAllChildDevices(cDevice *voltha.Device) error {
 	return nil
 }
 
+// DeleteLogicalDevice -
 func (dm *DeviceManager) DeleteLogicalDevice(cDevice *voltha.Device) error {
 	return nil
 }
 
+// DeleteLogicalPorts -
 func (dm *DeviceManager) DeleteLogicalPorts(cDevice *voltha.Device) error {
 	return nil
 }
 
+// DeleteAllChildDevices -
 func (dm *DeviceManager) DeleteAllChildDevices(cDevice *voltha.Device) error {
 	return nil
 }
 
+// RunPostDeviceDelete -
 func (dm *DeviceManager) RunPostDeviceDelete(cDevice *voltha.Device) error {
 	return nil
 }
 
+// ListDevices -
 func (dm *DeviceManager) ListDevices() (*voltha.Devices, error) {
 	return nil, nil
 }
 
+// ListDeviceIds -
 func (dm *DeviceManager) ListDeviceIds() (*voltha.IDs, error) {
 	return nil, nil
 }
 
+// ReconcileDevices -
 func (dm *DeviceManager) ReconcileDevices(ctx context.Context, ids *voltha.IDs, ch chan interface{}) {
 }
 
+// CreateDevice -
 func (dm *DeviceManager) CreateDevice(ctx context.Context, device *voltha.Device, ch chan interface{}) {
 }
 
+// EnableDevice -
 func (dm *DeviceManager) EnableDevice(ctx context.Context, id *voltha.ID, ch chan interface{}) {
 }
 
+// DisableDevice -
 func (dm *DeviceManager) DisableDevice(ctx context.Context, id *voltha.ID, ch chan interface{}) {
 }
 
+// RebootDevice -
 func (dm *DeviceManager) RebootDevice(ctx context.Context, id *voltha.ID, ch chan interface{}) {
 }
 
+// DeleteDevice -
 func (dm *DeviceManager) DeleteDevice(ctx context.Context, id *voltha.ID, ch chan interface{}) {
 }
 
+// StopManagingDevice -
 func (dm *DeviceManager) StopManagingDevice(id string) {
 }
 
+// DownloadImage -
 func (dm *DeviceManager) DownloadImage(ctx context.Context, img *voltha.ImageDownload, ch chan interface{}) {
 }
 
+// CancelImageDownload -
 func (dm *DeviceManager) CancelImageDownload(ctx context.Context, img *voltha.ImageDownload, ch chan interface{}) {
 }
 
+// ActivateImage -
 func (dm *DeviceManager) ActivateImage(ctx context.Context, img *voltha.ImageDownload, ch chan interface{}) {
 }
 
+// RevertImage -
 func (dm *DeviceManager) RevertImage(ctx context.Context, img *voltha.ImageDownload, ch chan interface{}) {
 }
 
+// GetImageDownloadStatus -
 func (dm *DeviceManager) GetImageDownloadStatus(ctx context.Context, img *voltha.ImageDownload, ch chan interface{}) {
 }
 
-func (dm *DeviceManager) UpdateImageDownload(deviceId string, img *voltha.ImageDownload) error {
+// UpdateImageDownload -
+func (dm *DeviceManager) UpdateImageDownload(deviceID string, img *voltha.ImageDownload) error {
 	return nil
 }
 
+// SimulateAlarm -
 func (dm *DeviceManager) SimulateAlarm(ctx context.Context, simulatereq *voltha.SimulateAlarmRequest, ch chan interface{}) {
 }
 
+// GetImageDownload -
 func (dm *DeviceManager) GetImageDownload(ctx context.Context, img *voltha.ImageDownload) (*voltha.ImageDownload, error) {
 	return nil, nil
 }
 
-func (dm *DeviceManager) ListImageDownloads(ctx context.Context, deviceId string) (*voltha.ImageDownloads, error) {
+// ListImageDownloads -
+func (dm *DeviceManager) ListImageDownloads(ctx context.Context, deviceID string) (*voltha.ImageDownloads, error) {
 	return nil, nil
 }
 
+// UpdatePmConfigs -
 func (dm *DeviceManager) UpdatePmConfigs(ctx context.Context, pmConfigs *voltha.PmConfigs, ch chan interface{}) {
 }
 
-func (dm *DeviceManager) ListPmConfigs(ctx context.Context, deviceId string) (*voltha.PmConfigs, error) {
+// ListPmConfigs -
+func (dm *DeviceManager) ListPmConfigs(ctx context.Context, deviceID string) (*voltha.PmConfigs, error) {
 	return nil, nil
 }
 
-func (dm *DeviceManager) DeletePeerPorts(fromDeviceId string, deviceId string) error {
+// DeletePeerPorts -
+func (dm *DeviceManager) DeletePeerPorts(fromDeviceID string, deviceID string) error {
 	return nil
 }
 
+// ProcessTransition -
 func (dm *DeviceManager) ProcessTransition(previous *voltha.Device, current *voltha.Device) error {
 	return nil
 }
diff --git a/rw_core/mocks/device_manager_test.go b/rw_core/mocks/device_manager_test.go
index ab2226b..e92d62f 100644
--- a/rw_core/mocks/device_manager_test.go
+++ b/rw_core/mocks/device_manager_test.go
@@ -17,14 +17,15 @@
 package mocks
 
 import (
-	"github.com/opencord/voltha-go/rw_core/coreIf"
 	"testing"
+
+	"github.com/opencord/voltha-go/rw_core/coreif"
 )
 
 func TestDeviceManagerImplementsDeviceManagerIf(t *testing.T) {
 	deviceMgr := &DeviceManager{}
 
-	if _, ok := interface{}(deviceMgr).(coreIf.DeviceManager); !ok {
-		t.Error("Device manager does not implement the coreIf.DeviceManager interface")
+	if _, ok := interface{}(deviceMgr).(coreif.DeviceManager); !ok {
+		t.Error("Device manager does not implement the coreif.DeviceManager interface")
 	}
 }
diff --git a/rw_core/utils/core_utils.go b/rw_core/utils/core_utils.go
index 3a71623..584d923 100644
--- a/rw_core/utils/core_utils.go
+++ b/rw_core/utils/core_utils.go
@@ -13,27 +13,33 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package utils
 
 import (
-	"google.golang.org/grpc/codes"
-	"google.golang.org/grpc/status"
 	"os"
 	"time"
+
+	"google.golang.org/grpc/codes"
+	"google.golang.org/grpc/status"
 )
 
+// DeviceID represent device id attribute
 type DeviceID struct {
-	Id string
+	ID string
 }
 
+// LogicalDeviceID rpresent logical device id attribute
 type LogicalDeviceID struct {
-	Id string
+	ID string
 }
 
+// GetHostName returns host name
 func GetHostName() string {
 	return os.Getenv("HOSTNAME")
 }
 
+// Response -
 type Response struct {
 	*response
 }
@@ -43,6 +49,7 @@
 	done bool
 }
 
+// NewResponse -
 func NewResponse() Response {
 	return Response{
 		&response{
diff --git a/rw_core/utils/core_utils_test.go b/rw_core/utils/core_utils_test.go
index 9f8dd87..cc48b10 100644
--- a/rw_core/utils/core_utils_test.go
+++ b/rw_core/utils/core_utils_test.go
@@ -16,13 +16,14 @@
 package utils
 
 import (
+	"math/rand"
+	"testing"
+	"time"
+
 	"github.com/opencord/voltha-lib-go/v2/pkg/log"
 	"github.com/stretchr/testify/assert"
 	"google.golang.org/grpc/codes"
 	"google.golang.org/grpc/status"
-	"math/rand"
-	"testing"
-	"time"
 )
 
 var (
@@ -31,7 +32,10 @@
 )
 
 func init() {
-	log.AddPackage(log.JSON, log.WarnLevel, nil)
+	_, err := log.AddPackage(log.JSON, log.WarnLevel, nil)
+	if err != nil {
+		log.Errorw("unable-to-register-package-to-the-log-map", log.Fields{"error": err})
+	}
 	timeoutError = status.Errorf(codes.Aborted, "timeout")
 	taskFailureError = status.Error(codes.Internal, "test failure task")
 }
@@ -56,7 +60,7 @@
 		responses[i] = NewResponse()
 		if numSuccessfulTaskCreated < numSuccessfulTask {
 			go runSuccessfulTask(responses[i], taskDurationRange)
-			numSuccessfulTaskCreated += 1
+			numSuccessfulTaskCreated++
 			continue
 		}
 		go runFailureTask(responses[i], taskDurationRange)
@@ -71,11 +75,11 @@
 	for _, input := range inputs {
 		if input != nil {
 			if input.Error() == timeoutError.Error() {
-				numTimeout += 1
+				numTimeout++
 			}
-			numFailure += 1
+			numFailure++
 		} else {
-			numSuccess += 1
+			numSuccess++
 		}
 	}
 	return
