diff --git a/VERSION b/VERSION
index 1e4ec5e..38f77a6 100755
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.0.1-dev
+2.0.1
diff --git a/cmd/openonu-adapter/main.go b/cmd/openonu-adapter/main.go
index ce5dc6f..8a7971b 100644
--- a/cmd/openonu-adapter/main.go
+++ b/cmd/openonu-adapter/main.go
@@ -46,7 +46,7 @@
 	ic "github.com/opencord/voltha-protos/v5/go/inter_container"
 
 	"github.com/opencord/voltha-openonu-adapter-go/internal/pkg/config"
-	ac "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/onuadaptercore"
+	ac "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/core"
 )
 
 const (
diff --git a/internal/pkg/onuadaptercore/alarm_manager.go b/internal/pkg/almgr/alarm_manager.go
old mode 100644
new mode 100755
similarity index 73%
rename from internal/pkg/onuadaptercore/alarm_manager.go
rename to internal/pkg/almgr/alarm_manager.go
index b9d4d68..91651fe
--- a/internal/pkg/onuadaptercore/alarm_manager.go
+++ b/internal/pkg/almgr/alarm_manager.go
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package almgr provides the utilities for managing alarm notifications
+package almgr
 
 import (
 	"context"
@@ -30,6 +30,7 @@
 	me "github.com/opencord/omci-lib-go/generated"
 	"github.com/opencord/voltha-lib-go/v7/pkg/events/eventif"
 	"github.com/opencord/voltha-lib-go/v7/pkg/log"
+	cmn "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/common"
 	"github.com/opencord/voltha-protos/v5/go/voltha"
 )
 
@@ -42,18 +43,19 @@
 	alarmBitMapSizeBytes                           = 28
 )
 
+// events of alarm sync FSM
 const (
-	// events of alarm sync FSM
-	asEvStart   = "asEvStart"
-	asEvStop    = "asEvStop"
-	asEvAudit   = "asEvAudit"
-	asEvSync    = "asEvSync"
-	asEvSuccess = "asEvSuccess"
-	asEvFailure = "asEvFailure"
-	asEvResync  = "asEvResync"
+	AsEvStart   = "AsEvStart"
+	AsEvStop    = "AsEvStop"
+	AsEvAudit   = "AsEvAudit"
+	AsEvSync    = "AsEvSync"
+	AsEvSuccess = "AsEvSuccess"
+	AsEvFailure = "AsEvFailure"
+	AsEvResync  = "AsEvResync"
 )
+
+// states of alarm sync FSM
 const (
-	// states of alarm sync FSM
 	asStStarting        = "asStStarting"
 	asStDisabled        = "asStDisabled"
 	asStInSync          = "asStInSync"
@@ -78,25 +80,6 @@
 }
 
 type alarmBitMapDB map[meAlarmKey][alarmBitMapSizeBytes]byte
-type onuAlarmManager struct {
-	pDeviceHandler             *deviceHandler
-	eventProxy                 eventif.EventProxy
-	stopProcessingOmciMessages chan bool
-	eventChannel               chan Message
-	onuAlarmManagerLock        sync.RWMutex
-	processMessage             bool
-	activeAlarms               alarms
-	alarmBitMapDB              alarmBitMapDB
-	onuEventsList              map[onuDevice]onuDeviceEvent
-	lastAlarmSequence          uint8
-	alarmSyncFsm               *AdapterFsm
-	oltDbCopy                  alarmBitMapDB
-	onuDBCopy                  alarmBitMapDB
-	bufferedNotifications      []*omci.AlarmNotificationMsg
-	alarmUploadSeqNo           uint16
-	alarmUploadNoOfCmds        uint16
-	stopAlarmAuditTimer        chan struct{}
-}
 
 type onuDevice struct {
 	classID me.ClassID
@@ -109,17 +92,43 @@
 	EventDescription string
 }
 
-func newAlarmManager(ctx context.Context, dh *deviceHandler) *onuAlarmManager {
-	var alarmManager onuAlarmManager
-	logger.Debugw(ctx, "init-alarm-manager", log.Fields{"device-id": dh.deviceID})
+// OnuAlarmManager holds alarm manager related data
+type OnuAlarmManager struct {
+	deviceID                   string
+	pDeviceHandler             cmn.IdeviceHandler
+	pOnuDeviceEntry            cmn.IonuDeviceEntry
+	eventProxy                 eventif.EventProxy
+	StopProcessingOmciMessages chan bool
+	eventChannel               chan cmn.Message
+	onuAlarmManagerLock        sync.RWMutex
+	processMessage             bool
+	activeAlarms               alarms
+	alarmBitMapDB              alarmBitMapDB
+	onuEventsList              map[onuDevice]onuDeviceEvent
+	lastAlarmSequence          uint8
+	AlarmSyncFsm               *cmn.AdapterFsm
+	oltDbCopy                  alarmBitMapDB
+	onuDBCopy                  alarmBitMapDB
+	bufferedNotifications      []*omci.AlarmNotificationMsg
+	alarmUploadSeqNo           uint16
+	alarmUploadNoOfCmds        uint16
+	StopAlarmAuditTimer        chan struct{}
+}
+
+// NewAlarmManager - TODO: add comment
+func NewAlarmManager(ctx context.Context, dh cmn.IdeviceHandler, onuDev cmn.IonuDeviceEntry) *OnuAlarmManager {
+	var alarmManager OnuAlarmManager
+	alarmManager.deviceID = dh.GetDeviceID()
+	logger.Debugw(ctx, "init-alarm-manager", log.Fields{"device-id": alarmManager.deviceID})
 	alarmManager.pDeviceHandler = dh
-	alarmManager.eventProxy = dh.EventProxy // Or event proxy should be on cluster address ??
-	alarmManager.eventChannel = make(chan Message)
-	alarmManager.stopProcessingOmciMessages = make(chan bool)
+	alarmManager.pOnuDeviceEntry = onuDev
+	alarmManager.eventProxy = dh.GetEventProxy() // Or event proxy should be on cluster address ??
+	alarmManager.eventChannel = make(chan cmn.Message)
+	alarmManager.StopProcessingOmciMessages = make(chan bool)
 	alarmManager.processMessage = false
 	alarmManager.activeAlarms = make(map[alarmInfo]struct{})
 	alarmManager.alarmBitMapDB = make(map[meAlarmKey][alarmBitMapSizeBytes]byte)
-	alarmManager.stopAlarmAuditTimer = make(chan struct{})
+	alarmManager.StopAlarmAuditTimer = make(chan struct{})
 	alarmManager.onuEventsList = map[onuDevice]onuDeviceEvent{
 		{classID: circuitPackClassID, alarmno: 0}: {EventName: "ONU_EQUIPMENT",
 			EventCategory: voltha.EventCategory_EQUIPMENT, EventSubCategory: voltha.EventSubCategory_ONU, EventDescription: "onu equipment"},
@@ -158,20 +167,20 @@
 		{classID: aniGClassID, alarmno: 6}: {EventName: "ONU_LASER_BIAS_CURRENT",
 			EventCategory: voltha.EventCategory_EQUIPMENT, EventSubCategory: voltha.EventSubCategory_ONU, EventDescription: "onu laser bias current"},
 	}
-	alarmManager.alarmSyncFsm = NewAdapterFsm("AlarmSync", dh.deviceID, alarmManager.eventChannel)
-	alarmManager.alarmSyncFsm.pFsm = fsm.NewFSM(
+	alarmManager.AlarmSyncFsm = cmn.NewAdapterFsm("AlarmSync", alarmManager.deviceID, alarmManager.eventChannel)
+	alarmManager.AlarmSyncFsm.PFsm = fsm.NewFSM(
 		asStDisabled,
 		fsm.Events{
-			{Name: asEvStart, Src: []string{asStDisabled}, Dst: asStStarting},
-			{Name: asEvAudit, Src: []string{asStStarting, asStInSync}, Dst: asStAuditing},
-			{Name: asEvSync, Src: []string{asStStarting}, Dst: asStInSync},
-			{Name: asEvSuccess, Src: []string{asStAuditing, asStResynchronizing}, Dst: asStInSync},
-			{Name: asEvFailure, Src: []string{asStAuditing, asStResynchronizing}, Dst: asStAuditing},
-			{Name: asEvResync, Src: []string{asStAuditing}, Dst: asStResynchronizing},
-			{Name: asEvStop, Src: []string{asStDisabled, asStStarting, asStAuditing, asStInSync, asStIdle, asStResynchronizing}, Dst: asStDisabled},
+			{Name: AsEvStart, Src: []string{asStDisabled}, Dst: asStStarting},
+			{Name: AsEvAudit, Src: []string{asStStarting, asStInSync}, Dst: asStAuditing},
+			{Name: AsEvSync, Src: []string{asStStarting}, Dst: asStInSync},
+			{Name: AsEvSuccess, Src: []string{asStAuditing, asStResynchronizing}, Dst: asStInSync},
+			{Name: AsEvFailure, Src: []string{asStAuditing, asStResynchronizing}, Dst: asStAuditing},
+			{Name: AsEvResync, Src: []string{asStAuditing}, Dst: asStResynchronizing},
+			{Name: AsEvStop, Src: []string{asStDisabled, asStStarting, asStAuditing, asStInSync, asStIdle, asStResynchronizing}, Dst: asStDisabled},
 		},
 		fsm.Callbacks{
-			"enter_state":                  func(e *fsm.Event) { alarmManager.alarmSyncFsm.logFsmStateChange(ctx, e) },
+			"enter_state":                  func(e *fsm.Event) { alarmManager.AlarmSyncFsm.LogFsmStateChange(ctx, e) },
 			"enter_" + asStStarting:        func(e *fsm.Event) { alarmManager.asFsmStarting(ctx, e) },
 			"enter_" + asStAuditing:        func(e *fsm.Event) { alarmManager.asFsmAuditing(ctx, e) },
 			"enter_" + asStInSync:          func(e *fsm.Event) { alarmManager.asFsmInSync(ctx, e) },
@@ -181,35 +190,35 @@
 	return &alarmManager
 }
 
-func (am *onuAlarmManager) asFsmStarting(ctx context.Context, e *fsm.Event) {
-	logger.Debugw(ctx, "alarm-sync-fsm-start-processing-msgs-in-state", log.Fields{"state": e.FSM.Current(), "device-id": am.pDeviceHandler.deviceID})
+func (am *OnuAlarmManager) asFsmStarting(ctx context.Context, e *fsm.Event) {
+	logger.Debugw(ctx, "alarm-sync-fsm-start-processing-msgs-in-state", log.Fields{"state": e.FSM.Current(), "device-id": am.deviceID})
 	go am.processAlarmSyncMessages(ctx)
 	// Start the first audit, if audit interval configured, else reach the sync state
-	if am.pDeviceHandler.pOnuOmciDevice.alarmAuditInterval > 0 {
+	if am.pDeviceHandler.GetAlarmAuditInterval() > 0 {
 		select {
 		//Transition into auditing state, using a very shorter timeout delay here, hence it is the first audit
 		case <-time.After(defaultTimeoutDelay * time.Second):
 			go func() {
-				if err := am.alarmSyncFsm.pFsm.Event(asEvAudit); err != nil {
-					logger.Debugw(ctx, "alarm-sync-fsm-cannot-go-to-state-auditing", log.Fields{"device-id": am.pDeviceHandler.deviceID, "err": err})
+				if err := am.AlarmSyncFsm.PFsm.Event(AsEvAudit); err != nil {
+					logger.Debugw(ctx, "alarm-sync-fsm-cannot-go-to-state-auditing", log.Fields{"device-id": am.deviceID, "err": err})
 				}
 			}()
-		case <-am.stopAlarmAuditTimer:
-			logger.Infow(ctx, "stopping-alarm-timer", log.Fields{"device-id": am.pDeviceHandler.deviceID})
+		case <-am.StopAlarmAuditTimer:
+			logger.Infow(ctx, "stopping-alarm-timer", log.Fields{"device-id": am.deviceID})
 			return
 		}
 	} else {
 		// Transition into sync state directly.
 		go func() {
-			if err := am.alarmSyncFsm.pFsm.Event(asEvSync); err != nil {
-				logger.Debugw(ctx, "alarm-sync-fsm-cannot-go-to-state-sync", log.Fields{"device-id": am.pDeviceHandler.deviceID, "err": err})
+			if err := am.AlarmSyncFsm.PFsm.Event(AsEvSync); err != nil {
+				logger.Debugw(ctx, "alarm-sync-fsm-cannot-go-to-state-sync", log.Fields{"device-id": am.deviceID, "err": err})
 			}
 		}()
 	}
 }
 
-func (am *onuAlarmManager) asFsmAuditing(ctx context.Context, e *fsm.Event) {
-	logger.Debugw(ctx, "alarm-sync-fsm-start-auditing", log.Fields{"state": e.FSM.Current(), "device-id": am.pDeviceHandler.deviceID})
+func (am *OnuAlarmManager) asFsmAuditing(ctx context.Context, e *fsm.Event) {
+	logger.Debugw(ctx, "alarm-sync-fsm-start-auditing", log.Fields{"state": e.FSM.Current(), "device-id": am.deviceID})
 	// Always reset the buffered notifications and db copies before starting the audit
 	am.onuAlarmManagerLock.Lock()
 	am.bufferedNotifications = make([]*omci.AlarmNotificationMsg, 0)
@@ -217,22 +226,22 @@
 	am.onuDBCopy = make(map[meAlarmKey][alarmBitMapSizeBytes]byte)
 	am.onuAlarmManagerLock.Unlock()
 	failureTransition := func() {
-		if err := am.alarmSyncFsm.pFsm.Event(asEvFailure); err != nil {
-			logger.Debugw(ctx, "alarm-sync-fsm-cannot-go-to-state-failure", log.Fields{"device-id": am.pDeviceHandler.deviceID, "err": err})
+		if err := am.AlarmSyncFsm.PFsm.Event(AsEvFailure); err != nil {
+			logger.Debugw(ctx, "alarm-sync-fsm-cannot-go-to-state-failure", log.Fields{"device-id": am.deviceID, "err": err})
 		}
 	}
-	if err := am.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.sendGetAllAlarm(log.WithSpanFromContext(context.TODO(), ctx), 0,
-		am.pDeviceHandler.pOpenOnuAc.omciTimeout, true); err != nil {
+	if err := am.pOnuDeviceEntry.GetDevOmciCC().SendGetAllAlarm(log.WithSpanFromContext(context.TODO(), ctx), 0,
+		am.pDeviceHandler.GetOmciTimeout(), true); err != nil {
 		// Transition to failure so that alarm sync can be restarted again
 		go failureTransition()
 	}
 }
 
-func (am *onuAlarmManager) asFsmResynchronizing(ctx context.Context, e *fsm.Event) {
-	logger.Debugw(ctx, "alarm-sync-fsm", log.Fields{"state": e.FSM.Current(), "device-id": am.pDeviceHandler.deviceID})
+func (am *OnuAlarmManager) asFsmResynchronizing(ctx context.Context, e *fsm.Event) {
+	logger.Debugw(ctx, "alarm-sync-fsm", log.Fields{"state": e.FSM.Current(), "device-id": am.deviceID})
 	failureTransition := func() {
-		if err := am.alarmSyncFsm.pFsm.Event(asEvFailure); err != nil {
-			logger.Debugw(ctx, "alarm-sync-fsm-cannot-go-to-state-failure", log.Fields{"device-id": am.pDeviceHandler.deviceID, "err": err})
+		if err := am.AlarmSyncFsm.PFsm.Event(AsEvFailure); err != nil {
+			logger.Debugw(ctx, "alarm-sync-fsm-cannot-go-to-state-failure", log.Fields{"device-id": am.deviceID, "err": err})
 		}
 	}
 	// See if there is any onu only diff, meaning the class and entity is only in onu DB
@@ -250,7 +259,7 @@
 				AlarmBitmap: am.onuDBCopy[alarm],
 			}
 			if err := am.processAlarmData(ctx, omciAlarmMessage); err != nil {
-				logger.Errorw(ctx, "unable-to-process-alarm-notification", log.Fields{"device-id": am.pDeviceHandler.deviceID})
+				logger.Errorw(ctx, "unable-to-process-alarm-notification", log.Fields{"device-id": am.deviceID})
 				// Transition to failure.
 				go failureTransition()
 				return
@@ -272,7 +281,7 @@
 				AlarmBitmap: am.oltDbCopy[alarm],
 			}
 			if err := am.processAlarmData(ctx, omciAlarmMessage); err != nil {
-				logger.Errorw(ctx, "unable-to-process-alarm-notification", log.Fields{"device-id": am.pDeviceHandler.deviceID})
+				logger.Errorw(ctx, "unable-to-process-alarm-notification", log.Fields{"device-id": am.deviceID})
 				// Transition to failure
 				go failureTransition()
 				return
@@ -292,7 +301,7 @@
 				}
 				// We will assume that onudb is correct always in this case and process the changed bitmap.
 				if err := am.processAlarmData(ctx, omciAlarmMessage); err != nil {
-					logger.Errorw(ctx, "unable-to-process-alarm-notification", log.Fields{"device-id": am.pDeviceHandler.deviceID})
+					logger.Errorw(ctx, "unable-to-process-alarm-notification", log.Fields{"device-id": am.deviceID})
 					// Transition to failure
 					go failureTransition()
 					return
@@ -302,57 +311,57 @@
 	}
 	// Send the buffered notifications if no failure.
 	for _, notif := range am.bufferedNotifications {
-		logger.Debugw(ctx, "processing-buffered-alarm-notification", log.Fields{"device-id": am.pDeviceHandler.deviceID,
+		logger.Debugw(ctx, "processing-buffered-alarm-notification", log.Fields{"device-id": am.deviceID,
 			"notification": notif})
 		if err := am.processAlarmData(ctx, notif); err != nil {
-			logger.Errorw(ctx, "unable-to-process-alarm-notification", log.Fields{"device-id": am.pDeviceHandler.deviceID})
+			logger.Errorw(ctx, "unable-to-process-alarm-notification", log.Fields{"device-id": am.deviceID})
 			go failureTransition()
 		}
 	}
 	go func() {
-		if err := am.alarmSyncFsm.pFsm.Event(asEvSuccess); err != nil {
-			logger.Debugw(ctx, "alarm-sync-fsm-cannot-go-to-state-sync", log.Fields{"device-id": am.pDeviceHandler.deviceID, "err": err})
+		if err := am.AlarmSyncFsm.PFsm.Event(AsEvSuccess); err != nil {
+			logger.Debugw(ctx, "alarm-sync-fsm-cannot-go-to-state-sync", log.Fields{"device-id": am.deviceID, "err": err})
 		}
 	}()
 }
 
-func (am *onuAlarmManager) asFsmInSync(ctx context.Context, e *fsm.Event) {
-	logger.Debugw(ctx, "alarm-sync-fsm", log.Fields{"state": e.FSM.Current(), "device-id": am.pDeviceHandler.deviceID})
-	if am.pDeviceHandler.pOnuOmciDevice.alarmAuditInterval > 0 {
+func (am *OnuAlarmManager) asFsmInSync(ctx context.Context, e *fsm.Event) {
+	logger.Debugw(ctx, "alarm-sync-fsm", log.Fields{"state": e.FSM.Current(), "device-id": am.deviceID})
+	if am.pDeviceHandler.GetAlarmAuditInterval() > 0 {
 		select {
-		case <-time.After(am.pDeviceHandler.pOnuOmciDevice.alarmAuditInterval):
+		case <-time.After(am.pDeviceHandler.GetAlarmAuditInterval()):
 			go func() {
-				if err := am.alarmSyncFsm.pFsm.Event(asEvAudit); err != nil {
-					logger.Debugw(ctx, "alarm-sync-fsm-cannot-go-to-state-auditing", log.Fields{"device-id": am.pDeviceHandler.deviceID, "err": err})
+				if err := am.AlarmSyncFsm.PFsm.Event(AsEvAudit); err != nil {
+					logger.Debugw(ctx, "alarm-sync-fsm-cannot-go-to-state-auditing", log.Fields{"device-id": am.deviceID, "err": err})
 				}
 			}()
-		case <-am.stopAlarmAuditTimer:
-			logger.Infow(ctx, "stopping-alarm-timer", log.Fields{"device-id": am.pDeviceHandler.deviceID})
+		case <-am.StopAlarmAuditTimer:
+			logger.Infow(ctx, "stopping-alarm-timer", log.Fields{"device-id": am.deviceID})
 			return
 		}
 	}
 }
 
-func (am *onuAlarmManager) processAlarmSyncMessages(ctx context.Context) {
-	logger.Debugw(ctx, "start-routine-to-process-omci-messages-for-alarm-sync", log.Fields{"device-id": am.pDeviceHandler.deviceID})
+func (am *OnuAlarmManager) processAlarmSyncMessages(ctx context.Context) {
+	logger.Debugw(ctx, "start-routine-to-process-omci-messages-for-alarm-sync", log.Fields{"device-id": am.deviceID})
 	for {
 		select {
 		case message, ok := <-am.eventChannel:
 			if !ok {
-				logger.Info(ctx, "alarm-sync-omci-message-could-not-be-read-from-channel", log.Fields{"device-id": am.pDeviceHandler.deviceID})
+				logger.Info(ctx, "alarm-sync-omci-message-could-not-be-read-from-channel", log.Fields{"device-id": am.deviceID})
 				continue
 			}
-			logger.Debugw(ctx, "alarm-sync-omci-message-received", log.Fields{"device-id": am.pDeviceHandler.deviceID})
+			logger.Debugw(ctx, "alarm-sync-omci-message-received", log.Fields{"device-id": am.deviceID})
 
 			switch message.Type {
-			case OMCI:
-				msg, _ := message.Data.(OmciMessage)
+			case cmn.OMCI:
+				msg, _ := message.Data.(cmn.OmciMessage)
 				am.handleOmciMessage(ctx, msg)
 			default:
-				logger.Warn(ctx, "alarm-sync-unknown-message-type-received", log.Fields{"device-id": am.pDeviceHandler.deviceID, "message.Type": message.Type})
+				logger.Warn(ctx, "alarm-sync-unknown-message-type-received", log.Fields{"device-id": am.deviceID, "message.Type": message.Type})
 			}
-		case <-am.stopProcessingOmciMessages:
-			logger.Infow(ctx, "alarm-manager-stop-omci-alarm-message-processing-routines", log.Fields{"device-id": am.pDeviceHandler.deviceID})
+		case <-am.StopProcessingOmciMessages:
+			logger.Infow(ctx, "alarm-manager-stop-omci-alarm-message-processing-routines", log.Fields{"device-id": am.deviceID})
 			am.onuAlarmManagerLock.Lock()
 			am.processMessage = false
 			am.activeAlarms = nil
@@ -366,8 +375,8 @@
 	}
 }
 
-func (am *onuAlarmManager) handleOmciMessage(ctx context.Context, msg OmciMessage) {
-	logger.Debugw(ctx, "alarm-sync-omci-message-received", log.Fields{"device-id": am.pDeviceHandler.deviceID,
+func (am *OnuAlarmManager) handleOmciMessage(ctx context.Context, msg cmn.OmciMessage) {
+	logger.Debugw(ctx, "alarm-sync-omci-message-received", log.Fields{"device-id": am.deviceID,
 		"msg-type": msg.OmciMsg.MessageType, "msg": msg})
 	switch msg.OmciMsg.MessageType {
 	case omci.GetAllAlarmsResponseType:
@@ -380,28 +389,28 @@
 	}
 }
 
-func (am *onuAlarmManager) handleOmciGetAllAlarmsResponseMessage(ctx context.Context, msg OmciMessage) {
+func (am *OnuAlarmManager) handleOmciGetAllAlarmsResponseMessage(ctx context.Context, msg cmn.OmciMessage) {
 	msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeGetAllAlarmsResponse)
 	if msgLayer == nil {
-		logger.Errorw(ctx, "omci-msg-layer-could-not-be-detected", log.Fields{"device-id": am.pDeviceHandler.deviceID})
+		logger.Errorw(ctx, "omci-msg-layer-could-not-be-detected", log.Fields{"device-id": am.deviceID})
 		return
 	}
 	msgObj, msgOk := msgLayer.(*omci.GetAllAlarmsResponse)
 	if !msgOk {
-		logger.Errorw(ctx, "omci-msg-layer-could-not-be-assigned", log.Fields{"device-id": am.pDeviceHandler.deviceID})
+		logger.Errorw(ctx, "omci-msg-layer-could-not-be-assigned", log.Fields{"device-id": am.deviceID})
 		return
 	}
-	logger.Debugw(ctx, "get-all-alarm-response-data", log.Fields{"device-id": am.pDeviceHandler.deviceID, "data-fields": msgObj})
-	if am.alarmSyncFsm.pFsm.Is(asStDisabled) {
-		logger.Debugw(ctx, "alarm-sync-fsm-is-disabled-ignoring-response-message", log.Fields{"device-id": am.pDeviceHandler.deviceID, "data-fields": msgObj})
+	logger.Debugw(ctx, "get-all-alarm-response-data", log.Fields{"device-id": am.deviceID, "data-fields": msgObj})
+	if am.AlarmSyncFsm.PFsm.Is(asStDisabled) {
+		logger.Debugw(ctx, "alarm-sync-fsm-is-disabled-ignoring-response-message", log.Fields{"device-id": am.deviceID, "data-fields": msgObj})
 		return
 	}
 	am.onuAlarmManagerLock.Lock()
 	am.alarmUploadNoOfCmds = msgObj.NumberOfCommands
 	am.onuAlarmManagerLock.Unlock()
 	failureTransition := func() {
-		if err := am.alarmSyncFsm.pFsm.Event(asEvFailure); err != nil {
-			logger.Debugw(ctx, "alarm-sync-fsm-cannot-go-to-state-failure", log.Fields{"device-id": am.pDeviceHandler.deviceID, "err": err})
+		if err := am.AlarmSyncFsm.PFsm.Event(AsEvFailure); err != nil {
+			logger.Debugw(ctx, "alarm-sync-fsm-cannot-go-to-state-failure", log.Fields{"device-id": am.deviceID, "err": err})
 		}
 	}
 	am.onuAlarmManagerLock.Lock()
@@ -413,8 +422,8 @@
 			am.oltDbCopy[alarms] = bitmap
 		}
 		am.onuAlarmManagerLock.Unlock()
-		if err := am.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.sendGetAllAlarmNext(
-			log.WithSpanFromContext(context.TODO(), ctx), am.pDeviceHandler.pOpenOnuAc.omciTimeout, true); err != nil {
+		if err := am.pOnuDeviceEntry.GetDevOmciCC().SendGetAllAlarmNext(
+			log.WithSpanFromContext(context.TODO(), ctx), am.pDeviceHandler.GetOmciTimeout(), true); err != nil {
 			// Transition to failure
 			go failureTransition()
 		}
@@ -429,40 +438,40 @@
 		if am.isAlarmDBDiffPresent(ctx) {
 			// transition to resync state
 			go func() {
-				if err := am.alarmSyncFsm.pFsm.Event(asEvResync); err != nil {
-					logger.Debugw(ctx, "alarm-sync-fsm-cannot-go-to-state-resynchronizing", log.Fields{"device-id": am.pDeviceHandler.deviceID, "err": err})
+				if err := am.AlarmSyncFsm.PFsm.Event(AsEvResync); err != nil {
+					logger.Debugw(ctx, "alarm-sync-fsm-cannot-go-to-state-resynchronizing", log.Fields{"device-id": am.deviceID, "err": err})
 				}
 			}()
 		} else {
 			// Transition to sync state
 			go func() {
-				if err := am.alarmSyncFsm.pFsm.Event(asEvSuccess); err != nil {
-					logger.Debugw(ctx, "alarm-sync-fsm-cannot-go-to-state-sync", log.Fields{"device-id": am.pDeviceHandler.deviceID, "err": err})
+				if err := am.AlarmSyncFsm.PFsm.Event(AsEvSuccess); err != nil {
+					logger.Debugw(ctx, "alarm-sync-fsm-cannot-go-to-state-sync", log.Fields{"device-id": am.deviceID, "err": err})
 				}
 			}()
 		}
 	} else {
-		logger.Errorw(ctx, "invalid-number-of-commands-received", log.Fields{"device-id": am.pDeviceHandler.deviceID,
+		logger.Errorw(ctx, "invalid-number-of-commands-received", log.Fields{"device-id": am.deviceID,
 			"upload-no-of-cmds": am.alarmUploadNoOfCmds, "upload-seq-no": am.alarmUploadSeqNo})
 		am.onuAlarmManagerLock.Unlock()
 		go failureTransition()
 	}
 }
 
-func (am *onuAlarmManager) handleOmciGetAllAlarmNextResponseMessage(ctx context.Context, msg OmciMessage) {
+func (am *OnuAlarmManager) handleOmciGetAllAlarmNextResponseMessage(ctx context.Context, msg cmn.OmciMessage) {
 	msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeGetAllAlarmsNextResponse)
 
 	if msgLayer == nil {
-		logger.Errorw(ctx, "omci-msg-layer-could-not-be-detected", log.Fields{"device-id": am.pDeviceHandler.deviceID})
+		logger.Errorw(ctx, "omci-msg-layer-could-not-be-detected", log.Fields{"device-id": am.deviceID})
 		return
 	}
 	msgObj, msgOk := msgLayer.(*omci.GetAllAlarmsNextResponse)
 	if !msgOk {
-		logger.Errorw(ctx, "omci-msg-layer-could-not-be-assigned", log.Fields{"device-id": am.pDeviceHandler.deviceID})
+		logger.Errorw(ctx, "omci-msg-layer-could-not-be-assigned", log.Fields{"device-id": am.deviceID})
 		return
 	}
 	logger.Debugw(ctx, "get-all-alarms-next-response-data",
-		log.Fields{"device-id": am.pDeviceHandler.deviceID, "data-fields": msgObj})
+		log.Fields{"device-id": am.deviceID, "data-fields": msgObj})
 	meClassID := msgObj.AlarmEntityClass
 	meEntityID := msgObj.AlarmEntityInstance
 	meAlarmBitMap := msgObj.AlarmBitMap
@@ -474,15 +483,15 @@
 	}] = meAlarmBitMap
 	am.onuAlarmManagerLock.Unlock()
 	failureTransition := func() {
-		if err := am.alarmSyncFsm.pFsm.Event(asEvFailure); err != nil {
-			logger.Debugw(ctx, "alarm-sync-fsm-cannot-go-to-state-failure", log.Fields{"device-id": am.pDeviceHandler.deviceID, "err": err})
+		if err := am.AlarmSyncFsm.PFsm.Event(AsEvFailure); err != nil {
+			logger.Debugw(ctx, "alarm-sync-fsm-cannot-go-to-state-failure", log.Fields{"device-id": am.deviceID, "err": err})
 		}
 	}
 	am.onuAlarmManagerLock.RLock()
 	if am.alarmUploadSeqNo < am.alarmUploadNoOfCmds {
 		am.onuAlarmManagerLock.RUnlock()
-		if err := am.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.sendGetAllAlarmNext(
-			log.WithSpanFromContext(context.TODO(), ctx), am.pDeviceHandler.pOpenOnuAc.omciTimeout, true); err != nil {
+		if err := am.pOnuDeviceEntry.GetDevOmciCC().SendGetAllAlarmNext(
+			log.WithSpanFromContext(context.TODO(), ctx), am.pDeviceHandler.GetOmciTimeout(), true); err != nil {
 			// Transition to failure
 			go failureTransition()
 		} //TODO: needs to handle timeouts
@@ -491,23 +500,24 @@
 		if am.isAlarmDBDiffPresent(ctx) {
 			// transition to resync state
 			go func() {
-				if err := am.alarmSyncFsm.pFsm.Event(asEvResync); err != nil {
-					logger.Debugw(ctx, "alarm-sync-fsm-cannot-go-to-state-resynchronizing", log.Fields{"device-id": am.pDeviceHandler.deviceID, "err": err})
+				if err := am.AlarmSyncFsm.PFsm.Event(AsEvResync); err != nil {
+					logger.Debugw(ctx, "alarm-sync-fsm-cannot-go-to-state-resynchronizing", log.Fields{"device-id": am.deviceID, "err": err})
 				}
 			}()
 		} else {
 			// Transition to sync state
 			go func() {
-				if err := am.alarmSyncFsm.pFsm.Event(asEvSuccess); err != nil {
-					logger.Debugw(ctx, "alarm-sync-fsm-cannot-go-to-state-sync", log.Fields{"device-id": am.pDeviceHandler.deviceID, "err": err})
+				if err := am.AlarmSyncFsm.PFsm.Event(AsEvSuccess); err != nil {
+					logger.Debugw(ctx, "alarm-sync-fsm-cannot-go-to-state-sync", log.Fields{"device-id": am.deviceID, "err": err})
 				}
 			}()
 		}
 	}
 }
 
-func (am *onuAlarmManager) startOMCIAlarmMessageProcessing(ctx context.Context) {
-	logger.Infow(ctx, "alarm-manager-start-omci-alarm-message-processing-routines", log.Fields{"device-id": am.pDeviceHandler.deviceID})
+// StartOMCIAlarmMessageProcessing - TODO: add comment: add comment
+func (am *OnuAlarmManager) StartOMCIAlarmMessageProcessing(ctx context.Context) {
+	logger.Infow(ctx, "alarm-manager-start-omci-alarm-message-processing-routines", log.Fields{"device-id": am.deviceID})
 	am.onuAlarmManagerLock.Lock()
 	am.processMessage = true
 	if am.activeAlarms == nil {
@@ -517,45 +527,46 @@
 	am.onuAlarmManagerLock.Unlock()
 	am.flushAlarmSyncChannels(ctx) // Need to do this first as there might be stale data on the channels and the start state waits on same channels
 
-	if am.alarmSyncFsm.pFsm.Is(asStDisabled) {
-		if err := am.alarmSyncFsm.pFsm.Event(asEvStart); err != nil {
-			logger.Errorw(ctx, "alarm-sync-fsm-can-not-go-to-state-starting", log.Fields{"device-id": am.pDeviceHandler.deviceID, "err": err})
+	if am.AlarmSyncFsm.PFsm.Is(asStDisabled) {
+		if err := am.AlarmSyncFsm.PFsm.Event(AsEvStart); err != nil {
+			logger.Errorw(ctx, "alarm-sync-fsm-can-not-go-to-state-starting", log.Fields{"device-id": am.deviceID, "err": err})
 			return
 		}
 	} else {
-		logger.Errorw(ctx, "wrong-state-of-alarm-sync-fsm-want-disabled", log.Fields{"state": string(am.alarmSyncFsm.pFsm.Current()),
-			"device-id": am.pDeviceHandler.deviceID})
+		logger.Errorw(ctx, "wrong-state-of-alarm-sync-fsm-want-disabled", log.Fields{"state": string(am.AlarmSyncFsm.PFsm.Current()),
+			"device-id": am.deviceID})
 		return
 	}
-	logger.Debugw(ctx, "alarm-sync-fsm-started", log.Fields{"state": string(am.alarmSyncFsm.pFsm.Current())})
+	logger.Debugw(ctx, "alarm-sync-fsm-started", log.Fields{"state": string(am.AlarmSyncFsm.PFsm.Current())})
 }
 
-func (am *onuAlarmManager) handleOmciAlarmNotificationMessage(ctx context.Context, msg OmciMessage) {
-	logger.Debugw(ctx, "omci-alarm-notification-msg", log.Fields{"device-id": am.pDeviceHandler.deviceID,
+// HandleOmciAlarmNotificationMessage - TODO: add comment
+func (am *OnuAlarmManager) HandleOmciAlarmNotificationMessage(ctx context.Context, msg cmn.OmciMessage) {
+	logger.Debugw(ctx, "omci-alarm-notification-msg", log.Fields{"device-id": am.deviceID,
 		"msg-type": msg.OmciMsg.MessageType})
 
 	msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeAlarmNotification)
 	if msgLayer == nil {
 		logger.Errorw(ctx, "omci-msg-layer-could-not-be-detected-for-alarm-notification",
-			log.Fields{"device-id": am.pDeviceHandler.deviceID})
+			log.Fields{"device-id": am.deviceID})
 		return
 	}
 	msgObj, msgOk := msgLayer.(*omci.AlarmNotificationMsg)
 	if !msgOk {
 		logger.Errorw(ctx, "omci-msg-layer-could-not-be-assigned-for-alarm-notification",
-			log.Fields{"device-id": am.pDeviceHandler.deviceID})
+			log.Fields{"device-id": am.deviceID})
 		return
 	}
 	//Alarm Notification decoding at omci lib validates that the me class ID supports the
 	// alarm notifications.
-	logger.Debugw(ctx, "alarm-notification-data-received", log.Fields{"device-id": am.pDeviceHandler.deviceID, "data-fields": msgObj})
+	logger.Debugw(ctx, "alarm-notification-data-received", log.Fields{"device-id": am.deviceID, "data-fields": msgObj})
 	if err := am.processAlarmData(ctx, msgObj); err != nil {
-		logger.Errorw(ctx, "unable-to-process-alarm-notification", log.Fields{"device-id": am.pDeviceHandler.deviceID})
+		logger.Errorw(ctx, "unable-to-process-alarm-notification", log.Fields{"device-id": am.deviceID})
 	}
 
 }
 
-func (am *onuAlarmManager) processAlarmData(ctx context.Context, msg *omci.AlarmNotificationMsg) error {
+func (am *OnuAlarmManager) processAlarmData(ctx context.Context, msg *omci.AlarmNotificationMsg) error {
 	classID := msg.EntityClass
 	sequenceNo := msg.AlarmSequenceNumber
 	meInstance := msg.EntityInstance
@@ -566,26 +577,26 @@
 	defer am.onuAlarmManagerLock.Unlock()
 	if !am.processMessage {
 		logger.Warnw(ctx, "ignoring-alarm-notification-received-for-me-as-channel-for-processing-is-closed",
-			log.Fields{"device-id": am.pDeviceHandler.deviceID})
+			log.Fields{"device-id": am.deviceID})
 		return fmt.Errorf("alarm-manager-is-in-stopped-state")
 	}
-	if _, present := am.pDeviceHandler.pOnuOmciDevice.pOnuDB.meDb[classID][meInstance]; !present {
+	if _, present := am.pOnuDeviceEntry.GetOnuDB().MeDb[classID][meInstance]; !present {
 		logger.Errorw(ctx, "me-class-instance-not-present", log.Fields{"class-id": classID, "instance-id": meInstance})
 		return fmt.Errorf("me-class-%d-instance-%d-not-present", classID, meInstance)
 	}
 	if sequenceNo > 0 {
-		if am.alarmSyncFsm.pFsm.Is(asStAuditing) || am.alarmSyncFsm.pFsm.Is(asStResynchronizing) {
+		if am.AlarmSyncFsm.PFsm.Is(asStAuditing) || am.AlarmSyncFsm.PFsm.Is(asStResynchronizing) {
 			am.bufferedNotifications = append(am.bufferedNotifications, msg)
-			logger.Debugw(ctx, "adding-notification-to-buffered-notification-list", log.Fields{"device-id": am.pDeviceHandler.deviceID,
+			logger.Debugw(ctx, "adding-notification-to-buffered-notification-list", log.Fields{"device-id": am.deviceID,
 				"notification": msg})
 			return nil
 		}
 		am.incrementAlarmSequence()
-		if sequenceNo != am.lastAlarmSequence && am.pDeviceHandler.pOnuOmciDevice.alarmAuditInterval > 0 {
+		if sequenceNo != am.lastAlarmSequence && am.pDeviceHandler.GetAlarmAuditInterval() > 0 {
 			// signal early audit, if no match(if we are reaching here it means that audit is not going on currently)
 			go func() {
-				if err := am.alarmSyncFsm.pFsm.Event(asEvAudit); err != nil {
-					logger.Debugw(ctx, "alarm-sync-fsm-cannot-go-to-state-auditing", log.Fields{"device-id": am.pDeviceHandler.deviceID, "err": err})
+				if err := am.AlarmSyncFsm.PFsm.Event(AsEvAudit); err != nil {
+					logger.Debugw(ctx, "alarm-sync-fsm-cannot-go-to-state-auditing", log.Fields{"device-id": am.deviceID, "err": err})
 				}
 			}()
 		}
@@ -644,7 +655,7 @@
 	return nil
 }
 
-func (am *onuAlarmManager) raiseAlarm(ctx context.Context, classID me.ClassID, instanceID uint16, alarm uint8) {
+func (am *OnuAlarmManager) raiseAlarm(ctx context.Context, classID me.ClassID, instanceID uint16, alarm uint8) {
 	am.activeAlarms[alarmInfo{
 		classID:    classID,
 		instanceID: instanceID,
@@ -654,7 +665,7 @@
 	go am.sendAlarm(ctx, classID, instanceID, alarm, true)
 }
 
-func (am *onuAlarmManager) clearAlarm(ctx context.Context, classID me.ClassID, instanceID uint16, alarm uint8) {
+func (am *OnuAlarmManager) clearAlarm(ctx context.Context, classID me.ClassID, instanceID uint16, alarm uint8) {
 	go am.sendAlarm(ctx, classID, instanceID, alarm, false)
 	delete(am.activeAlarms, alarmInfo{
 		classID:    classID,
@@ -670,17 +681,17 @@
 	}
 }
 
-func (am *onuAlarmManager) getIntfIDAlarm(ctx context.Context, classID me.ClassID, instanceID uint16) *uint32 {
+func (am *OnuAlarmManager) getIntfIDAlarm(ctx context.Context, classID me.ClassID, instanceID uint16) *uint32 {
 	var intfID *uint32
 	if classID == circuitPackClassID || classID == physicalPathTerminationPointEthernetUniClassID {
-		for _, uniPort := range am.pDeviceHandler.uniEntityMap {
-			if uniPort.entityID == instanceID {
-				intfID = &uniPort.portNo
+		for _, uniPort := range *am.pDeviceHandler.GetUniEntityMap() {
+			if uniPort.EntityID == instanceID {
+				intfID = &uniPort.PortNo
 				return intfID
 			}
 		}
 	} else if classID == aniGClassID || classID == onuGClassID {
-		intfID = &am.pDeviceHandler.ponPortNumber
+		intfID = am.pDeviceHandler.GetPonPortNumber()
 		return intfID
 	} else {
 		logger.Warnw(ctx, "me-not-supported", log.Fields{"class-id": classID, "instance-id": instanceID})
@@ -688,13 +699,11 @@
 	return nil
 }
 
-func (am *onuAlarmManager) sendAlarm(ctx context.Context, classID me.ClassID, instanceID uint16, alarm uint8, raised bool) {
+func (am *OnuAlarmManager) sendAlarm(ctx context.Context, classID me.ClassID, instanceID uint16, alarm uint8, raised bool) {
 	context := make(map[string]string)
 	intfID := am.getIntfIDAlarm(ctx, classID, instanceID)
-	onuID := am.pDeviceHandler.deviceID
-	am.pDeviceHandler.pOnuOmciDevice.mutexPersOnuConfig.RLock()
-	serialNo := am.pDeviceHandler.pOnuOmciDevice.sOnuPersistentData.PersSerialNumber
-	am.pDeviceHandler.pOnuOmciDevice.mutexPersOnuConfig.RUnlock()
+	onuID := am.deviceID
+	serialNo := am.pOnuDeviceEntry.GetPersSerialNumber()
 	if intfID == nil {
 		logger.Warn(ctx, "intf-id-for-alarm-not-found", log.Fields{"alarm-no": alarm, "class-id": classID})
 		return
@@ -724,11 +733,11 @@
 		raisedTimestamp)
 }
 
-func (am *onuAlarmManager) isAlarmDBDiffPresent(ctx context.Context) bool {
+func (am *OnuAlarmManager) isAlarmDBDiffPresent(ctx context.Context) bool {
 	return !reflect.DeepEqual(am.onuDBCopy, am.oltDbCopy)
 }
 
-func (am *onuAlarmManager) incrementAlarmSequence() {
+func (am *OnuAlarmManager) incrementAlarmSequence() {
 	//alarm sequence number wraps from 255 to 1.
 	if am.lastAlarmSequence == 255 {
 		am.lastAlarmSequence = 1
@@ -737,12 +746,12 @@
 	}
 }
 
-func (am *onuAlarmManager) resetAlarmSequence() {
+func (am *OnuAlarmManager) resetAlarmSequence() {
 	am.lastAlarmSequence = 0
 }
 
 // flushAlarmSyncChannels flushes all alarm sync channels to discard any previous response
-func (am *onuAlarmManager) flushAlarmSyncChannels(ctx context.Context) {
+func (am *OnuAlarmManager) flushAlarmSyncChannels(ctx context.Context) {
 	// flush alarm sync channel
 	select {
 	case <-am.eventChannel:
@@ -750,14 +759,14 @@
 	default:
 	}
 	select {
-	case <-am.stopAlarmAuditTimer:
+	case <-am.StopAlarmAuditTimer:
 		logger.Debug(ctx, "flushed-alarm-audit-timer-channel")
 	default:
 	}
 }
 
 // getDeviceEventData returns the event data for a device
-func (am *onuAlarmManager) getDeviceEventData(ctx context.Context, classID me.ClassID, alarmNo uint8) (onuDeviceEvent, error) {
+func (am *OnuAlarmManager) getDeviceEventData(ctx context.Context, classID me.ClassID, alarmNo uint8) (onuDeviceEvent, error) {
 	if onuEventDetails, ok := am.onuEventsList[onuDevice{classID: classID, alarmno: alarmNo}]; ok {
 		return onuEventDetails, nil
 	}
@@ -765,7 +774,7 @@
 }
 
 //ResetAlarmUploadCounters resets alarm upload sequence number and number of commands
-func (am *onuAlarmManager) ResetAlarmUploadCounters() {
+func (am *OnuAlarmManager) ResetAlarmUploadCounters() {
 	am.onuAlarmManagerLock.Lock()
 	am.alarmUploadSeqNo = 0
 	am.alarmUploadNoOfCmds = 0
@@ -773,16 +782,21 @@
 }
 
 //IncrementAlarmUploadSeqNo increments alarm upload sequence number
-func (am *onuAlarmManager) IncrementAlarmUploadSeqNo() {
+func (am *OnuAlarmManager) IncrementAlarmUploadSeqNo() {
 	am.onuAlarmManagerLock.Lock()
 	am.alarmUploadSeqNo++
 	am.onuAlarmManagerLock.Unlock()
 }
 
 //GetAlarmUploadSeqNo gets alarm upload sequence number
-func (am *onuAlarmManager) GetAlarmUploadSeqNo() uint16 {
+func (am *OnuAlarmManager) GetAlarmUploadSeqNo() uint16 {
 	am.onuAlarmManagerLock.RLock()
 	value := am.alarmUploadSeqNo
 	am.onuAlarmManagerLock.RUnlock()
 	return value
 }
+
+//GetAlarmMgrEventChannel gets alarm manager event channel
+func (am *OnuAlarmManager) GetAlarmMgrEventChannel() chan cmn.Message {
+	return am.eventChannel
+}
diff --git a/internal/pkg/onuadaptercore/common.go b/internal/pkg/almgr/common.go
old mode 100644
new mode 100755
similarity index 86%
copy from internal/pkg/onuadaptercore/common.go
copy to internal/pkg/almgr/common.go
index b0b10e3..541bff6
--- a/internal/pkg/onuadaptercore/common.go
+++ b/internal/pkg/almgr/common.go
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package almgr provides the utilities for managing alarm notifications
+package almgr
 
 import (
 	"github.com/opencord/voltha-lib-go/v7/pkg/log"
@@ -26,7 +26,7 @@
 func init() {
 	// Setup this package so that it's log level can be modified at run time
 	var err error
-	logger, err = log.RegisterPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "adaptercoreonu"})
+	logger, err = log.RegisterPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "almgr"})
 	if err != nil {
 		panic(err)
 	}
diff --git a/internal/pkg/onuadaptercore/common.go b/internal/pkg/avcfg/common.go
old mode 100644
new mode 100755
similarity index 86%
copy from internal/pkg/onuadaptercore/common.go
copy to internal/pkg/avcfg/common.go
index b0b10e3..8e02fe0
--- a/internal/pkg/onuadaptercore/common.go
+++ b/internal/pkg/avcfg/common.go
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package avcfg provides anig and vlan configuration functionality
+package avcfg
 
 import (
 	"github.com/opencord/voltha-lib-go/v7/pkg/log"
@@ -26,7 +26,7 @@
 func init() {
 	// Setup this package so that it's log level can be modified at run time
 	var err error
-	logger, err = log.RegisterPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "adaptercoreonu"})
+	logger, err = log.RegisterPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "avcfg"})
 	if err != nil {
 		panic(err)
 	}
diff --git a/internal/pkg/onuadaptercore/omci_ani_config.go b/internal/pkg/avcfg/omci_ani_config.go
old mode 100644
new mode 100755
similarity index 74%
rename from internal/pkg/onuadaptercore/omci_ani_config.go
rename to internal/pkg/avcfg/omci_ani_config.go
index a236950..6ade746
--- a/internal/pkg/onuadaptercore/omci_ani_config.go
+++ b/internal/pkg/avcfg/omci_ani_config.go
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package avcfg provides anig and vlan configuration functionality
+package avcfg
 
 import (
 	"context"
@@ -31,9 +31,12 @@
 	"github.com/opencord/omci-lib-go"
 	me "github.com/opencord/omci-lib-go/generated"
 	"github.com/opencord/voltha-lib-go/v7/pkg/log"
+
 	//ic "github.com/opencord/voltha-protos/v5/go/inter_container"
 	//"github.com/opencord/voltha-protos/v5/go/openflow_13"
 	//"github.com/opencord/voltha-protos/v5/go/voltha"
+	cmn "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/common"
+	"github.com/opencord/voltha-openonu-adapter-go/internal/pkg/devdb"
 )
 
 const (
@@ -86,12 +89,14 @@
 	aniStRemoveDone          = "aniStRemoveDone"
 	aniStResetting           = "aniStResetting"
 )
-const cAniFsmIdleState = aniStConfigDone
 
 const (
 	bitTrafficSchedulerPtrSetPermitted = 0x0002 // Refer section 9.1.2 ONU-2G, table for "Quality of service (QoS) configuration flexibility" IE
 )
 
+// CAniFsmIdleState - TODO: add comment
+const CAniFsmIdleState = aniStConfigDone
+
 type ponAniGemPortAttribs struct {
 	gemPortID      uint16
 	upQueueID      uint16
@@ -106,22 +111,23 @@
 	dynamicACL     string
 }
 
-//uniPonAniConfigFsm defines the structure for the state machine to config the PON ANI ports of ONU UNI ports via OMCI
-type uniPonAniConfigFsm struct {
-	pDeviceHandler           *deviceHandler
+//UniPonAniConfigFsm defines the structure for the state machine to config the PON ANI ports of ONU UNI ports via OMCI
+type UniPonAniConfigFsm struct {
 	deviceID                 string
-	pOmciCC                  *omciCC
-	pOnuUniPort              *onuUniPort
-	pUniTechProf             *onuUniTechProf
-	pOnuDB                   *onuDeviceDB
+	pDeviceHandler           cmn.IdeviceHandler
+	pOnuDeviceEntry          cmn.IonuDeviceEntry
+	pOmciCC                  *cmn.OmciCC
+	pOnuUniPort              *cmn.OnuUniPort
+	pUniTechProf             *OnuUniTechProf
+	pOnuDB                   *devdb.OnuDeviceDB
 	techProfileID            uint8
 	uniTpKey                 uniTP
-	requestEvent             OnuDeviceEvent
+	requestEvent             cmn.OnuDeviceEvent
 	mutexIsAwaitingResponse  sync.RWMutex
 	isCanceled               bool
 	isAwaitingResponse       bool
 	omciMIdsResponseReceived chan bool //separate channel needed for checking multiInstance OMCI message responses
-	pAdaptFsm                *AdapterFsm
+	PAdaptFsm                *cmn.AdapterFsm
 	chSuccess                chan<- uint8
 	procStep                 uint8
 	mutexChanSet             sync.RWMutex
@@ -139,33 +145,34 @@
 	tcontSetBefore           bool
 }
 
-//newUniPonAniConfigFsm is the 'constructor' for the state machine to config the PON ANI ports of ONU UNI ports via OMCI
-func newUniPonAniConfigFsm(ctx context.Context, apDevOmciCC *omciCC, apUniPort *onuUniPort, apUniTechProf *onuUniTechProf,
-	apOnuDB *onuDeviceDB, aTechProfileID uint8, aRequestEvent OnuDeviceEvent, aName string,
-	apDeviceHandler *deviceHandler, aCommChannel chan Message) *uniPonAniConfigFsm {
-	instFsm := &uniPonAniConfigFsm{
-		pDeviceHandler: apDeviceHandler,
-		deviceID:       apDeviceHandler.deviceID,
-		pOmciCC:        apDevOmciCC,
-		pOnuUniPort:    apUniPort,
-		pUniTechProf:   apUniTechProf,
-		pOnuDB:         apOnuDB,
-		techProfileID:  aTechProfileID,
-		requestEvent:   aRequestEvent,
-		chanSet:        false,
-		tcontSetBefore: false,
+//NewUniPonAniConfigFsm is the 'constructor' for the state machine to config the PON ANI ports of ONU UNI ports via OMCI
+func NewUniPonAniConfigFsm(ctx context.Context, apDevOmciCC *cmn.OmciCC, apUniPort *cmn.OnuUniPort, apUniTechProf *OnuUniTechProf,
+	apOnuDB *devdb.OnuDeviceDB, aTechProfileID uint8, aRequestEvent cmn.OnuDeviceEvent, aName string,
+	apDeviceHandler cmn.IdeviceHandler, apOnuDeviceEntry cmn.IonuDeviceEntry, aCommChannel chan cmn.Message) *UniPonAniConfigFsm {
+	instFsm := &UniPonAniConfigFsm{
+		pDeviceHandler:  apDeviceHandler,
+		pOnuDeviceEntry: apOnuDeviceEntry,
+		deviceID:        apDeviceHandler.GetDeviceID(),
+		pOmciCC:         apDevOmciCC,
+		pOnuUniPort:     apUniPort,
+		pUniTechProf:    apUniTechProf,
+		pOnuDB:          apOnuDB,
+		techProfileID:   aTechProfileID,
+		requestEvent:    aRequestEvent,
+		chanSet:         false,
+		tcontSetBefore:  false,
 	}
-	instFsm.uniTpKey = uniTP{uniID: apUniPort.uniID, tpID: aTechProfileID}
+	instFsm.uniTpKey = uniTP{uniID: apUniPort.UniID, tpID: aTechProfileID}
 	instFsm.waitFlowDeleteChannel = make(chan bool)
 
-	instFsm.pAdaptFsm = NewAdapterFsm(aName, instFsm.deviceID, aCommChannel)
-	if instFsm.pAdaptFsm == nil {
-		logger.Errorw(ctx, "uniPonAniConfigFsm's AdapterFsm could not be instantiated!!", log.Fields{
+	instFsm.PAdaptFsm = cmn.NewAdapterFsm(aName, instFsm.deviceID, aCommChannel)
+	if instFsm.PAdaptFsm == nil {
+		logger.Errorw(ctx, "UniPonAniConfigFsm's cmn.AdapterFsm could not be instantiated!!", log.Fields{
 			"device-id": instFsm.deviceID})
 		return nil
 	}
 
-	instFsm.pAdaptFsm.pFsm = fsm.NewFSM(
+	instFsm.PAdaptFsm.PFsm = fsm.NewFSM(
 		aniStDisabled,
 		fsm.Events{
 
@@ -216,7 +223,7 @@
 		},
 
 		fsm.Callbacks{
-			"enter_state":                         func(e *fsm.Event) { instFsm.pAdaptFsm.logFsmStateChange(ctx, e) },
+			"enter_state":                         func(e *fsm.Event) { instFsm.PAdaptFsm.LogFsmStateChange(ctx, e) },
 			("enter_" + aniStStarting):            func(e *fsm.Event) { instFsm.enterConfigStartingState(ctx, e) },
 			("enter_" + aniStCreatingDot1PMapper): func(e *fsm.Event) { instFsm.enterCreatingDot1PMapper(ctx, e) },
 			("enter_" + aniStCreatingMBPCD):       func(e *fsm.Event) { instFsm.enterCreatingMBPCD(ctx, e) },
@@ -238,27 +245,27 @@
 			("enter_" + aniStDisabled):            func(e *fsm.Event) { instFsm.enterDisabledState(ctx, e) },
 		},
 	)
-	if instFsm.pAdaptFsm.pFsm == nil {
-		logger.Errorw(ctx, "uniPonAniConfigFsm's Base FSM could not be instantiated!!", log.Fields{
+	if instFsm.PAdaptFsm.PFsm == nil {
+		logger.Errorw(ctx, "UniPonAniConfigFsm's Base FSM could not be instantiated!!", log.Fields{
 			"device-id": instFsm.deviceID})
 		return nil
 	}
 
-	logger.Debugw(ctx, "uniPonAniConfigFsm created", log.Fields{"device-id": instFsm.deviceID})
+	logger.Debugw(ctx, "UniPonAniConfigFsm created", log.Fields{"device-id": instFsm.deviceID})
 	return instFsm
 }
 
 //setFsmCompleteChannel sets the requested channel and channel result for transfer on success
-func (oFsm *uniPonAniConfigFsm) setFsmCompleteChannel(aChSuccess chan<- uint8, aProcStep uint8) {
+func (oFsm *UniPonAniConfigFsm) setFsmCompleteChannel(aChSuccess chan<- uint8, aProcStep uint8) {
 	oFsm.chSuccess = aChSuccess
 	oFsm.procStep = aProcStep
 	oFsm.setChanSet(true)
 }
 
 //CancelProcessing ensures that suspended processing at waiting on some response is aborted and reset of FSM
-func (oFsm *uniPonAniConfigFsm) CancelProcessing(ctx context.Context) {
+func (oFsm *UniPonAniConfigFsm) CancelProcessing(ctx context.Context) {
 	//early indication about started reset processing
-	oFsm.pUniTechProf.setProfileResetting(ctx, oFsm.pOnuUniPort.uniID, oFsm.techProfileID, true)
+	oFsm.pUniTechProf.setProfileResetting(ctx, oFsm.pOnuUniPort.UniID, oFsm.techProfileID, true)
 	//mutex protection is required for possible concurrent access to FSM members
 	oFsm.mutexIsAwaitingResponse.Lock()
 	oFsm.isCanceled = true
@@ -282,14 +289,14 @@
 	}
 
 	// in any case (even if it might be automatically requested by above cancellation of waiting) ensure resetting the FSM
-	pAdaptFsm := oFsm.pAdaptFsm
-	if pAdaptFsm != nil {
+	PAdaptFsm := oFsm.PAdaptFsm
+	if PAdaptFsm != nil {
 		// obviously calling some FSM event here directly does not work - so trying to decouple it ...
-		go func(aPAFsm *AdapterFsm) {
-			if aPAFsm.pFsm != nil {
-				_ = oFsm.pAdaptFsm.pFsm.Event(aniEvReset)
+		go func(aPAFsm *cmn.AdapterFsm) {
+			if aPAFsm.PFsm != nil {
+				_ = oFsm.PAdaptFsm.PFsm.Event(aniEvReset)
 			}
-		}(pAdaptFsm)
+		}(PAdaptFsm)
 	}
 
 	// possible access conflicts on internal data by next needed data clearance
@@ -298,21 +305,21 @@
 	//   as it may result in deadlock situations (as observed at soft-reboot handling where
 	//   TpProcMutex is already locked by some ongoing TechProfile config/removal processing
 	//remove all TechProf related internal data to allow for new configuration
-	oFsm.pUniTechProf.clearAniSideConfig(ctx, oFsm.pOnuUniPort.uniID, oFsm.techProfileID)
+	oFsm.pUniTechProf.clearAniSideConfig(ctx, oFsm.pOnuUniPort.UniID, oFsm.techProfileID)
 }
 
 //nolint: gocyclo
 //TODO:visit here for refactoring for gocyclo
-func (oFsm *uniPonAniConfigFsm) prepareAndEnterConfigState(ctx context.Context, aPAFsm *AdapterFsm) {
-	if aPAFsm != nil && aPAFsm.pFsm != nil {
+func (oFsm *UniPonAniConfigFsm) prepareAndEnterConfigState(ctx context.Context, aPAFsm *cmn.AdapterFsm) {
+	if aPAFsm != nil && aPAFsm.PFsm != nil {
 		var err error
-		oFsm.mapperSP0ID, err = generateIeeMaperServiceProfileEID(uint16(oFsm.pOnuUniPort.macBpNo), uint16(oFsm.techProfileID))
+		oFsm.mapperSP0ID, err = cmn.GenerateIeeMaperServiceProfileEID(uint16(oFsm.pOnuUniPort.MacBpNo), uint16(oFsm.techProfileID))
 		if err != nil {
 			logger.Errorw(ctx, "error generating maper id", log.Fields{"device-id": oFsm.deviceID,
 				"techProfileID": oFsm.techProfileID, "error": err})
 			return
 		}
-		oFsm.macBPCD0ID, err = generateANISideMBPCDEID(uint16(oFsm.pOnuUniPort.macBpNo), uint16(oFsm.techProfileID))
+		oFsm.macBPCD0ID, err = cmn.GenerateANISideMBPCDEID(uint16(oFsm.pOnuUniPort.MacBpNo), uint16(oFsm.techProfileID))
 		if err != nil {
 			logger.Errorw(ctx, "error generating mbpcd id", log.Fields{"device-id": oFsm.deviceID,
 				"techProfileID": oFsm.techProfileID, "error": err})
@@ -320,17 +327,16 @@
 		}
 		logger.Debugw(ctx, "generated ids for ani config", log.Fields{"mapperSP0ID": strconv.FormatInt(int64(oFsm.mapperSP0ID), 16),
 			"macBPCD0ID": strconv.FormatInt(int64(oFsm.macBPCD0ID), 16), "device-id": oFsm.deviceID,
-			"macBpNo": oFsm.pOnuUniPort.macBpNo, "techProfileID": oFsm.techProfileID})
-		pDevEntry := oFsm.pDeviceHandler.getOnuDeviceEntry(ctx, false)
-		if pDevEntry == nil {
+			"macBpNo": oFsm.pOnuUniPort.MacBpNo, "techProfileID": oFsm.techProfileID})
+		if oFsm.pOnuDeviceEntry == nil {
 			logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": oFsm.deviceID})
 			return
 		}
-		tcontInstID, tcontAlreadyExist, err := pDevEntry.allocateFreeTcont(ctx, oFsm.pUniTechProf.mapPonAniConfig[oFsm.uniTpKey].tcontParams.allocID)
+		tcontInstID, tcontAlreadyExist, err := oFsm.pOnuDeviceEntry.AllocateFreeTcont(ctx, oFsm.pUniTechProf.mapPonAniConfig[oFsm.uniTpKey].tcontParams.allocID)
 		if err != nil {
 			logger.Errorw(ctx, "No TCont instances found", log.Fields{"device-id": oFsm.deviceID, "err": err})
 			//reset the state machine to enable usage on subsequent requests
-			_ = aPAFsm.pFsm.Event(aniEvReset)
+			_ = aPAFsm.PFsm.Event(aniEvReset)
 			return
 		}
 		oFsm.tcont0ID = tcontInstID
@@ -352,7 +358,7 @@
 
 			//collect all GemConfigData in a separate Fsm related slice (needed also to avoid mix-up with unsorted mapPonAniConfig)
 
-			if queueInstKeys := oFsm.pOnuDB.getSortedInstKeys(ctx, me.PriorityQueueClassID); len(queueInstKeys) > 0 {
+			if queueInstKeys := oFsm.pOnuDB.GetSortedInstKeys(ctx, me.PriorityQueueClassID); len(queueInstKeys) > 0 {
 
 				loGemPortAttribs.gemPortID = gemEntry.gemPortID
 				// MibDb usage: upstream PrioQueue.RelatedPort = xxxxyyyy with xxxx=TCont.Entity(incl. slot) and yyyy=prio
@@ -361,11 +367,11 @@
 				usQrelPortMask := uint32((((uint32)(oFsm.tcont0ID)) << 16) + uint32(gemEntry.prioQueueIndex))
 
 				// MibDb usage: downstream PrioQueue.RelatedPort = xxyyzzzz with xx=slot, yy=UniPort and zzzz=prio
-				// i.e.: search PrioQueue list with yy=actual pOnuUniPort.uniID,
+				// i.e.: search PrioQueue list with yy=actual pOnuUniPort.UniID,
 				// from that list use the PrioQueue.Entity with gemEntry.prioQueueIndex == zzzz (expect 0..7)
 				// Note: As we do not maintain any slot numbering, slot number will be excluded from seatch pattern.
 				//       Furthermore OMCI Onu port-Id is expected to start with 1 (not 0).
-				dsQrelPortMask := uint32((((uint32)(oFsm.pOnuUniPort.uniID + 1)) << 16) + uint32(gemEntry.prioQueueIndex))
+				dsQrelPortMask := uint32((((uint32)(oFsm.pOnuUniPort.UniID + 1)) << 16) + uint32(gemEntry.prioQueueIndex))
 
 				usQueueFound := false
 				dsQueueFound := false
@@ -373,7 +379,7 @@
 					if meAttributes := oFsm.pOnuDB.GetMe(me.PriorityQueueClassID, mgmtEntityID); meAttributes != nil {
 						returnVal := meAttributes["RelatedPort"]
 						if returnVal != nil {
-							if relatedPort, err := oFsm.pOnuDB.getUint32Attrib(returnVal); err == nil {
+							if relatedPort, err := oFsm.pOnuDB.GetUint32Attrib(returnVal); err == nil {
 								if relatedPort == usQrelPortMask {
 									loGemPortAttribs.upQueueID = mgmtEntityID
 									logger.Debugw(ctx, "UpQueue for GemPort found:", log.Fields{"gemPortID": loGemPortAttribs.gemPortID,
@@ -437,22 +443,22 @@
 
 			oFsm.gemPortAttribsSlice = append(oFsm.gemPortAttribsSlice, loGemPortAttribs)
 		}
-		if !oFsm.pDeviceHandler.isSkipOnuConfigReconciling() {
-			_ = aPAFsm.pFsm.Event(aniEvStartConfig)
+		if !oFsm.pDeviceHandler.IsSkipOnuConfigReconciling() {
+			_ = aPAFsm.PFsm.Event(aniEvStartConfig)
 		} else {
 			logger.Debugw(ctx, "reconciling - skip omci-config of ANI side ", log.Fields{"device-id": oFsm.deviceID})
-			_ = aPAFsm.pFsm.Event(aniEvSkipOmciConfig)
+			_ = aPAFsm.PFsm.Event(aniEvSkipOmciConfig)
 		}
 	}
 }
 
-func (oFsm *uniPonAniConfigFsm) enterConfigStartingState(ctx context.Context, e *fsm.Event) {
+func (oFsm *UniPonAniConfigFsm) enterConfigStartingState(ctx context.Context, e *fsm.Event) {
 	logger.Debugw(ctx, "UniPonAniConfigFsm start", log.Fields{
-		"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID})
+		"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID})
 	// in case the used channel is not yet defined (can be re-used after restarts)
 	if oFsm.omciMIdsResponseReceived == nil {
 		oFsm.omciMIdsResponseReceived = make(chan bool)
-		logger.Debug(ctx, "uniPonAniConfigFsm - OMCI multiInstance RxChannel defined")
+		logger.Debug(ctx, "UniPonAniConfigFsm - OMCI multiInstance RxChannel defined")
 	} else {
 		// as we may 're-use' this instance of FSM and the connected channel
 		// make sure there is no 'lingering' request in the already existing channel:
@@ -472,7 +478,7 @@
 	go oFsm.processOmciAniMessages(ctx)
 
 	//let the state machine run forward from here directly
-	pConfigAniStateAFsm := oFsm.pAdaptFsm
+	pConfigAniStateAFsm := oFsm.PAdaptFsm
 	if pConfigAniStateAFsm != nil {
 		// obviously calling some FSM event here directly does not work - so trying to decouple it ...
 		go oFsm.prepareAndEnterConfigState(ctx, pConfigAniStateAFsm)
@@ -480,24 +486,24 @@
 	}
 }
 
-func (oFsm *uniPonAniConfigFsm) enterCreatingDot1PMapper(ctx context.Context, e *fsm.Event) {
-	logger.Debugw(ctx, "uniPonAniConfigFsm Tx Create::Dot1PMapper", log.Fields{
+func (oFsm *UniPonAniConfigFsm) enterCreatingDot1PMapper(ctx context.Context, e *fsm.Event) {
+	logger.Debugw(ctx, "UniPonAniConfigFsm Tx Create::Dot1PMapper", log.Fields{
 		"EntitytId": strconv.FormatInt(int64(oFsm.mapperSP0ID), 16),
-		"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID})
+		"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID})
 	oFsm.requestEventOffset = 0 //0 offset for last config request activity
 	oFsm.mutexPLastTxMeInstance.Lock()
-	meInstance, err := oFsm.pOmciCC.sendCreateDot1PMapper(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
-		oFsm.mapperSP0ID, oFsm.pAdaptFsm.commChan)
+	meInstance, err := oFsm.pOmciCC.SendCreateDot1PMapper(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), true,
+		oFsm.mapperSP0ID, oFsm.PAdaptFsm.CommChan)
 	if err != nil {
-		logger.Errorw(ctx, "Dot1PMapper create failed, aborting uniPonAniConfigFsm!",
+		logger.Errorw(ctx, "Dot1PMapper create failed, aborting UniPonAniConfigFsm!",
 			log.Fields{"device-id": oFsm.deviceID})
-		pConfigAniStateAFsm := oFsm.pAdaptFsm
+		pConfigAniStateAFsm := oFsm.PAdaptFsm
 		if pConfigAniStateAFsm != nil {
 			oFsm.mutexPLastTxMeInstance.Unlock()
 			// obviously calling some FSM event here directly does not work - so trying to decouple it ...
-			go func(aPAFsm *AdapterFsm) {
-				if aPAFsm != nil && aPAFsm.pFsm != nil {
-					_ = aPAFsm.pFsm.Event(aniEvReset)
+			go func(aPAFsm *cmn.AdapterFsm) {
+				if aPAFsm != nil && aPAFsm.PFsm != nil {
+					_ = aPAFsm.PFsm.Event(aniEvReset)
 				}
 			}(pConfigAniStateAFsm)
 			return
@@ -510,12 +516,12 @@
 
 }
 
-func (oFsm *uniPonAniConfigFsm) enterCreatingMBPCD(ctx context.Context, e *fsm.Event) {
-	logger.Debugw(ctx, "uniPonAniConfigFsm Tx Create::MBPCD", log.Fields{
+func (oFsm *UniPonAniConfigFsm) enterCreatingMBPCD(ctx context.Context, e *fsm.Event) {
+	logger.Debugw(ctx, "UniPonAniConfigFsm Tx Create::MBPCD", log.Fields{
 		"EntitytId": strconv.FormatInt(int64(oFsm.macBPCD0ID), 16),
 		"TPPtr":     strconv.FormatInt(int64(oFsm.mapperSP0ID), 16),
-		"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID})
-	bridgePtr := macBridgeServiceProfileEID + uint16(oFsm.pOnuUniPort.macBpNo) //cmp also omci_cc.go::sendCreateMBServiceProfile
+		"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID})
+	bridgePtr := cmn.MacBridgeServiceProfileEID + uint16(oFsm.pOnuUniPort.MacBpNo) //cmp also omci_cc.go::sendCreateMBServiceProfile
 	meParams := me.ParamData{
 		EntityID: oFsm.macBPCD0ID,
 		Attributes: me.AttributeValueMap{
@@ -526,18 +532,18 @@
 		},
 	}
 	oFsm.mutexPLastTxMeInstance.Lock()
-	meInstance, err := oFsm.pOmciCC.sendCreateMBPConfigDataVar(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
-		oFsm.pAdaptFsm.commChan, meParams)
+	meInstance, err := oFsm.pOmciCC.SendCreateMBPConfigDataVar(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), true,
+		oFsm.PAdaptFsm.CommChan, meParams)
 	if err != nil {
-		logger.Errorw(ctx, "MBPConfigDataVar create failed, aborting uniPonAniConfigFsm!",
+		logger.Errorw(ctx, "MBPConfigDataVar create failed, aborting UniPonAniConfigFsm!",
 			log.Fields{"device-id": oFsm.deviceID})
-		pConfigAniStateAFsm := oFsm.pAdaptFsm
+		pConfigAniStateAFsm := oFsm.PAdaptFsm
 		if pConfigAniStateAFsm != nil {
 			oFsm.mutexPLastTxMeInstance.Unlock()
 			// obviously calling some FSM event here directly does not work - so trying to decouple it ...
-			go func(aPAFsm *AdapterFsm) {
-				if aPAFsm != nil && aPAFsm.pFsm != nil {
-					_ = aPAFsm.pFsm.Event(aniEvReset)
+			go func(aPAFsm *cmn.AdapterFsm) {
+				if aPAFsm != nil && aPAFsm.PFsm != nil {
+					_ = aPAFsm.PFsm.Event(aniEvReset)
 				}
 			}(pConfigAniStateAFsm)
 			return
@@ -550,19 +556,19 @@
 
 }
 
-func (oFsm *uniPonAniConfigFsm) enterSettingTconts(ctx context.Context, e *fsm.Event) {
-	logger.Debugw(ctx, "uniPonAniConfigFsm Tx Set::Tcont", log.Fields{
+func (oFsm *UniPonAniConfigFsm) enterSettingTconts(ctx context.Context, e *fsm.Event) {
+	logger.Debugw(ctx, "UniPonAniConfigFsm Tx Set::Tcont", log.Fields{
 		"EntitytId": strconv.FormatInt(int64(oFsm.tcont0ID), 16),
 		"AllocId":   strconv.FormatInt(int64(oFsm.alloc0ID), 16),
-		"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID,
+		"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID,
 		"tcontExist": oFsm.tcontSetBefore})
 	//If tcont was set before, then no need to set it again. Let state machine to proceed.
 	if oFsm.tcontSetBefore {
-		go func(aPAFsm *AdapterFsm) {
-			if aPAFsm != nil && aPAFsm.pFsm != nil {
-				_ = aPAFsm.pFsm.Event(aniEvRxTcontsResp)
+		go func(aPAFsm *cmn.AdapterFsm) {
+			if aPAFsm != nil && aPAFsm.PFsm != nil {
+				_ = aPAFsm.PFsm.Event(aniEvRxTcontsResp)
 			}
-		}(oFsm.pAdaptFsm)
+		}(oFsm.PAdaptFsm)
 		return
 	}
 	meParams := me.ParamData{
@@ -572,18 +578,18 @@
 		},
 	}
 	oFsm.mutexPLastTxMeInstance.Lock()
-	meInstance, err := oFsm.pOmciCC.sendSetTcontVar(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
-		oFsm.pAdaptFsm.commChan, meParams)
+	meInstance, err := oFsm.pOmciCC.SendSetTcontVar(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), true,
+		oFsm.PAdaptFsm.CommChan, meParams)
 	if err != nil {
-		logger.Errorw(ctx, "TcontVar set failed, aborting uniPonAniConfigFsm!",
+		logger.Errorw(ctx, "TcontVar set failed, aborting UniPonAniConfigFsm!",
 			log.Fields{"device-id": oFsm.deviceID})
-		pConfigAniStateAFsm := oFsm.pAdaptFsm
+		pConfigAniStateAFsm := oFsm.PAdaptFsm
 		if pConfigAniStateAFsm != nil {
 			oFsm.mutexPLastTxMeInstance.Unlock()
 			// obviously calling some FSM event here directly does not work - so trying to decouple it ...
-			go func(aPAFsm *AdapterFsm) {
-				if aPAFsm != nil && aPAFsm.pFsm != nil {
-					_ = aPAFsm.pFsm.Event(aniEvReset)
+			go func(aPAFsm *cmn.AdapterFsm) {
+				if aPAFsm != nil && aPAFsm.PFsm != nil {
+					_ = aPAFsm.PFsm.Event(aniEvReset)
 				}
 			}(pConfigAniStateAFsm)
 			return
@@ -596,31 +602,31 @@
 
 }
 
-func (oFsm *uniPonAniConfigFsm) enterCreatingGemNCTPs(ctx context.Context, e *fsm.Event) {
-	logger.Debugw(ctx, "uniPonAniConfigFsm - start creating GemNWCtp loop", log.Fields{
-		"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID})
+func (oFsm *UniPonAniConfigFsm) enterCreatingGemNCTPs(ctx context.Context, e *fsm.Event) {
+	logger.Debugw(ctx, "UniPonAniConfigFsm - start creating GemNWCtp loop", log.Fields{
+		"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID})
 	go oFsm.performCreatingGemNCTPs(ctx)
 }
 
-func (oFsm *uniPonAniConfigFsm) enterCreatingGemIWs(ctx context.Context, e *fsm.Event) {
-	logger.Debugw(ctx, "uniPonAniConfigFsm - start creating GemIwTP loop", log.Fields{
-		"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID})
+func (oFsm *UniPonAniConfigFsm) enterCreatingGemIWs(ctx context.Context, e *fsm.Event) {
+	logger.Debugw(ctx, "UniPonAniConfigFsm - start creating GemIwTP loop", log.Fields{
+		"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID})
 	go oFsm.performCreatingGemIWs(ctx)
 }
 
-func (oFsm *uniPonAniConfigFsm) enterSettingPQs(ctx context.Context, e *fsm.Event) {
-	logger.Debugw(ctx, "uniPonAniConfigFsm - start setting PrioQueue loop", log.Fields{
+func (oFsm *UniPonAniConfigFsm) enterSettingPQs(ctx context.Context, e *fsm.Event) {
+	logger.Debugw(ctx, "UniPonAniConfigFsm - start setting PrioQueue loop", log.Fields{
 		"in state": e.FSM.Current(), "device-id": oFsm.deviceID})
 	go oFsm.performSettingPQs(ctx)
 }
 
-func (oFsm *uniPonAniConfigFsm) enterSettingDot1PMapper(ctx context.Context, e *fsm.Event) {
+func (oFsm *UniPonAniConfigFsm) enterSettingDot1PMapper(ctx context.Context, e *fsm.Event) {
 
-	logger.Debugw(ctx, "uniPonAniConfigFsm Tx Set::.1pMapper with all PBits set", log.Fields{"EntitytId": 0x8042, /*cmp above*/
+	logger.Debugw(ctx, "UniPonAniConfigFsm Tx Set::.1pMapper with all PBits set", log.Fields{"EntitytId": 0x8042, /*cmp above*/
 		"toGemIw":   1024, /* cmp above */
-		"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID})
+		"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID})
 
-	logger.Debugw(ctx, "uniPonAniConfigFsm Tx Set::1pMapper", log.Fields{
+	logger.Debugw(ctx, "UniPonAniConfigFsm Tx Set::1pMapper", log.Fields{
 		"EntitytId": strconv.FormatInt(int64(oFsm.mapperSP0ID), 16),
 		"in state":  e.FSM.Current(), "device-id": oFsm.deviceID})
 
@@ -633,13 +639,13 @@
 	var loPrioGemPortArray [8]uint16
 	for _, gemPortAttribs := range oFsm.gemPortAttribsSlice {
 		if gemPortAttribs.isMulticast {
-			logger.Debugw(ctx, "uniPonAniConfigFsm Port is Multicast, ignoring .1pMapper", log.Fields{
+			logger.Debugw(ctx, "UniPonAniConfigFsm Port is Multicast, ignoring .1pMapper", log.Fields{
 				"device-id": oFsm.deviceID, "GemPort": gemPortAttribs.gemPortID,
 				"prioString": gemPortAttribs.pbitString})
 			continue
 		}
 		if gemPortAttribs.pbitString == "" {
-			logger.Warnw(ctx, "uniPonAniConfigFsm PrioString empty string error", log.Fields{
+			logger.Warnw(ctx, "UniPonAniConfigFsm PrioString empty string error", log.Fields{
 				"device-id": oFsm.deviceID, "GemPort": gemPortAttribs.gemPortID,
 				"prioString": gemPortAttribs.pbitString})
 			continue
@@ -651,13 +657,13 @@
 					if loPrioGemPortArray[i] == 0 {
 						loPrioGemPortArray[i] = gemPortAttribs.gemPortID //gemPortId=EntityID and unique
 					} else {
-						logger.Warnw(ctx, "uniPonAniConfigFsm PrioString not unique", log.Fields{
+						logger.Warnw(ctx, "UniPonAniConfigFsm PrioString not unique", log.Fields{
 							"device-id": oFsm.deviceID, "IgnoredGemPort": gemPortAttribs.gemPortID,
 							"SetGemPort": loPrioGemPortArray[i]})
 					}
 				}
 			} else {
-				logger.Warnw(ctx, "uniPonAniConfigFsm PrioString evaluation error", log.Fields{
+				logger.Warnw(ctx, "UniPonAniConfigFsm PrioString evaluation error", log.Fields{
 					"device-id": oFsm.deviceID, "GemPort": gemPortAttribs.gemPortID,
 					"prioString": gemPortAttribs.pbitString, "position": i})
 			}
@@ -693,39 +699,39 @@
 		//TODO With multicast is possible that no upstream gem ports are not present in the tech profile,
 		// this reset needs to be performed only if the tech profile provides upstream gem ports but no priority is set
 		//let's reset the state machine in order to release all resources now
-		//pConfigAniStateAFsm := oFsm.pAdaptFsm
+		//pConfigAniStateAFsm := oFsm.PAdaptFsm
 		//if pConfigAniStateAFsm != nil {
 		//	// obviously calling some FSM event here directly does not work - so trying to decouple it ...
-		//	go func(aPAFsm *AdapterFsm) {
-		//		if aPAFsm != nil && aPAFsm.pFsm != nil {
-		//			_ = aPAFsm.pFsm.Event(aniEvReset)
+		//	go func(aPAFsm *cmn.AdapterFsm) {
+		//		if aPAFsm != nil && aPAFsm.PFsm != nil {
+		//			_ = aPAFsm.PFsm.Event(aniEvReset)
 		//		}
 		//	}(pConfigAniStateAFsm)
 		//}
 		//Moving forward the FSM as if the response was received correctly.
-		pConfigAniStateAFsm := oFsm.pAdaptFsm
+		pConfigAniStateAFsm := oFsm.PAdaptFsm
 		if pConfigAniStateAFsm != nil {
 			// obviously calling some FSM event here directly does not work - so trying to decouple it ...
-			go func(aPAFsm *AdapterFsm) {
-				if aPAFsm != nil && aPAFsm.pFsm != nil {
-					_ = aPAFsm.pFsm.Event(aniEvRxDot1pmapSResp)
+			go func(aPAFsm *cmn.AdapterFsm) {
+				if aPAFsm != nil && aPAFsm.PFsm != nil {
+					_ = aPAFsm.PFsm.Event(aniEvRxDot1pmapSResp)
 				}
 			}(pConfigAniStateAFsm)
 		}
 	} else {
 		oFsm.mutexPLastTxMeInstance.Lock()
-		meInstance, err := oFsm.pOmciCC.sendSetDot1PMapperVar(context.TODO(), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
-			oFsm.pAdaptFsm.commChan, meParams)
+		meInstance, err := oFsm.pOmciCC.SendSetDot1PMapperVar(context.TODO(), oFsm.pDeviceHandler.GetOmciTimeout(), true,
+			oFsm.PAdaptFsm.CommChan, meParams)
 		if err != nil {
-			logger.Errorw(ctx, "Dot1PMapperVar set failed, aborting uniPonAniConfigFsm!",
+			logger.Errorw(ctx, "Dot1PMapperVar set failed, aborting UniPonAniConfigFsm!",
 				log.Fields{"device-id": oFsm.deviceID})
-			pConfigAniStateAFsm := oFsm.pAdaptFsm
+			pConfigAniStateAFsm := oFsm.PAdaptFsm
 			if pConfigAniStateAFsm != nil {
 				oFsm.mutexPLastTxMeInstance.Unlock()
 				// obviously calling some FSM event here directly does not work - so trying to decouple it ...
-				go func(aPAFsm *AdapterFsm) {
-					if aPAFsm != nil && aPAFsm.pFsm != nil {
-						_ = aPAFsm.pFsm.Event(aniEvReset)
+				go func(aPAFsm *cmn.AdapterFsm) {
+					if aPAFsm != nil && aPAFsm.PFsm != nil {
+						_ = aPAFsm.PFsm.Event(aniEvReset)
 					}
 				}(pConfigAniStateAFsm)
 				return
@@ -738,25 +744,25 @@
 	}
 }
 
-func (oFsm *uniPonAniConfigFsm) enterAniConfigDone(ctx context.Context, e *fsm.Event) {
-	logger.Debugw(ctx, "uniPonAniConfigFsm ani config done", log.Fields{
-		"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID, "techProfile-id": oFsm.techProfileID})
+func (oFsm *UniPonAniConfigFsm) enterAniConfigDone(ctx context.Context, e *fsm.Event) {
+	logger.Debugw(ctx, "UniPonAniConfigFsm ani config done", log.Fields{
+		"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID, "techProfile-id": oFsm.techProfileID})
 	//store that the UNI related techProfile processing is done for the given Profile and Uni
-	oFsm.pUniTechProf.setConfigDone(oFsm.pOnuUniPort.uniID, oFsm.techProfileID, true)
-	if !oFsm.pDeviceHandler.isSkipOnuConfigReconciling() {
+	oFsm.pUniTechProf.setConfigDone(oFsm.pOnuUniPort.UniID, oFsm.techProfileID, true)
+	if !oFsm.pDeviceHandler.IsSkipOnuConfigReconciling() {
 		//use DeviceHandler event notification directly
-		oFsm.pDeviceHandler.deviceProcStatusUpdate(ctx, OnuDeviceEvent((uint8(oFsm.requestEvent) + oFsm.requestEventOffset)))
+		oFsm.pDeviceHandler.DeviceProcStatusUpdate(ctx, cmn.OnuDeviceEvent((uint8(oFsm.requestEvent) + oFsm.requestEventOffset)))
 		//if techProfile processing is done it must be checked, if some prior/parallel flow configuration is pending
 		//  but only in case the techProfile was configured (not deleted)
 		if oFsm.requestEventOffset == 0 {
-			go oFsm.pDeviceHandler.verifyUniVlanConfigRequest(ctx, oFsm.pOnuUniPort, oFsm.techProfileID)
+			go oFsm.pDeviceHandler.VerifyUniVlanConfigRequest(ctx, oFsm.pOnuUniPort, oFsm.techProfileID)
 		}
 	} else {
 		logger.Debugw(ctx, "reconciling - skip AniConfigDone processing", log.Fields{"device-id": oFsm.deviceID})
 	}
 	if oFsm.isChanSet() {
 		// indicate processing done to the caller
-		logger.Debugw(ctx, "uniPonAniConfigFsm processingDone on channel", log.Fields{
+		logger.Debugw(ctx, "UniPonAniConfigFsm processingDone on channel", log.Fields{
 			"ProcessingStep": oFsm.procStep, "from_State": e.FSM.Current(), "device-id": oFsm.deviceID})
 		oFsm.chSuccess <- oFsm.procStep
 		oFsm.setChanSet(false) //reset the internal channel state
@@ -765,7 +771,7 @@
 	//the FSM is left active in this state as long as no specific reset or remove is requested from outside
 }
 
-func (oFsm *uniPonAniConfigFsm) enterRemovingGemIW(ctx context.Context, e *fsm.Event) {
+func (oFsm *UniPonAniConfigFsm) enterRemovingGemIW(ctx context.Context, e *fsm.Event) {
 	// no need to protect access to oFsm.waitFlowDeleteChannel, only used in synchronized state entries
 	//  or CancelProcessing() that uses separate isWaitingForFlowDelete to write to the channel
 	//flush the waitFlowDeleteChannel - possibly already/still set by some previous activity
@@ -775,22 +781,23 @@
 	default:
 	}
 
-	if oFsm.pDeviceHandler.UniVlanConfigFsmMap[oFsm.pOnuUniPort.uniID] != nil {
+	uniVlanConfigFsm := oFsm.pDeviceHandler.GetUniVlanConfigFsm(oFsm.pOnuUniPort.UniID)
+	if uniVlanConfigFsm != nil {
 		// ensure mutexTPState not locked before calling some VlanConfigFsm activity (that might already be pending on it)
-		if oFsm.pDeviceHandler.UniVlanConfigFsmMap[oFsm.pOnuUniPort.uniID].IsFlowRemovePending(oFsm.waitFlowDeleteChannel) {
+		if uniVlanConfigFsm.IsFlowRemovePending(oFsm.waitFlowDeleteChannel) {
 			logger.Debugw(ctx, "flow remove pending - wait before processing gem port delete",
-				log.Fields{"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID, "techProfile-id": oFsm.techProfileID})
+				log.Fields{"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID, "techProfile-id": oFsm.techProfileID})
 			// if flow remove is pending then wait for flow remove to finish first before proceeding with gem port delete
-			pConfigAniStateAFsm := oFsm.pAdaptFsm
+			pConfigAniStateAFsm := oFsm.PAdaptFsm
 			if pConfigAniStateAFsm != nil {
 				// obviously calling some FSM event here directly does not work - so trying to decouple it ...
-				go func(aPAFsm *AdapterFsm) {
-					if aPAFsm != nil && aPAFsm.pFsm != nil {
-						_ = aPAFsm.pFsm.Event(aniEvWaitFlowRem)
+				go func(aPAFsm *cmn.AdapterFsm) {
+					if aPAFsm != nil && aPAFsm.PFsm != nil {
+						_ = aPAFsm.PFsm.Event(aniEvWaitFlowRem)
 					}
 				}(pConfigAniStateAFsm)
 			} else {
-				logger.Errorw(ctx, "pConfigAniStateAFsm is nil", log.Fields{"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID, "techProfile-id": oFsm.techProfileID})
+				logger.Errorw(ctx, "pConfigAniStateAFsm is nil", log.Fields{"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID, "techProfile-id": oFsm.techProfileID})
 			}
 			return
 		}
@@ -803,25 +810,25 @@
 	// get the related GemPort entity Id from pUniTechProf, OMCI Gem* entityID is set to be equal to GemPortId!
 	loGemPortID := (*(oFsm.pUniTechProf.mapRemoveGemEntry[oFsm.uniTpKey])).gemPortID
 	oFsm.pUniTechProf.mutexTPState.RUnlock()
-	logger.Debugw(ctx, "uniPonAniConfigFsm - start removing one GemIwTP", log.Fields{
-		"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID,
+	logger.Debugw(ctx, "UniPonAniConfigFsm - start removing one GemIwTP", log.Fields{
+		"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID,
 		"GemIwTp-entity-id": loGemPortID})
 	oFsm.requestEventOffset = 1 //offset 1 to indicate last activity = remove
 
 	// this state entry is only expected in a suitable state (checked outside in onu_uni_tp)
 	oFsm.mutexPLastTxMeInstance.Lock()
-	meInstance, err := oFsm.pOmciCC.sendDeleteGemIWTP(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
-		oFsm.pAdaptFsm.commChan, loGemPortID)
+	meInstance, err := oFsm.pOmciCC.SendDeleteGemIWTP(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), true,
+		oFsm.PAdaptFsm.CommChan, loGemPortID)
 	if err != nil {
-		logger.Errorw(ctx, "GemIWTP delete failed, aborting uniPonAniConfigFsm!",
+		logger.Errorw(ctx, "GemIWTP delete failed, aborting UniPonAniConfigFsm!",
 			log.Fields{"device-id": oFsm.deviceID})
-		pConfigAniStateAFsm := oFsm.pAdaptFsm
+		pConfigAniStateAFsm := oFsm.PAdaptFsm
 		if pConfigAniStateAFsm != nil {
 			oFsm.mutexPLastTxMeInstance.Unlock()
 			// obviously calling some FSM event here directly does not work - so trying to decouple it ...
-			go func(aPAFsm *AdapterFsm) {
-				if aPAFsm != nil && aPAFsm.pFsm != nil {
-					_ = oFsm.pAdaptFsm.pFsm.Event(aniEvReset)
+			go func(aPAFsm *cmn.AdapterFsm) {
+				if aPAFsm != nil && aPAFsm.PFsm != nil {
+					_ = oFsm.PAdaptFsm.PFsm.Event(aniEvReset)
 				}
 			}(pConfigAniStateAFsm)
 			return
@@ -831,7 +838,7 @@
 	oFsm.mutexPLastTxMeInstance.Unlock()
 }
 
-func (oFsm *uniPonAniConfigFsm) enterWaitingFlowRem(ctx context.Context, e *fsm.Event) {
+func (oFsm *UniPonAniConfigFsm) enterWaitingFlowRem(ctx context.Context, e *fsm.Event) {
 	oFsm.mutexIsAwaitingResponse.Lock()
 	oFsm.isWaitingForFlowDelete = true
 	oFsm.mutexIsAwaitingResponse.Unlock()
@@ -840,60 +847,60 @@
 	// case <-ctx.Done():
 	// 		logger.Infow("LockState-bridge-init message reception canceled", log.Fields{"for device-id": oFsm.deviceID})
 	case <-time.After(2 * oFsm.pOmciCC.GetMaxOmciTimeoutWithRetries() * time.Second): //give flow processing enough time to finish (but try to be less than rwCore flow timeouts)
-		logger.Warnw(ctx, "uniPonAniConfigFsm WaitingFlowRem timeout", log.Fields{
-			"for device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID, "techProfile-id": oFsm.techProfileID})
+		logger.Warnw(ctx, "UniPonAniConfigFsm WaitingFlowRem timeout", log.Fields{
+			"for device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID, "techProfile-id": oFsm.techProfileID})
 		oFsm.mutexIsAwaitingResponse.Lock()
 		oFsm.isWaitingForFlowDelete = false
 		oFsm.mutexIsAwaitingResponse.Unlock()
 		//if the flow is not removed as expected we just try to continue with GemPort removal and hope things are clearing up afterwards
-		pConfigAniStateAFsm := oFsm.pAdaptFsm
+		pConfigAniStateAFsm := oFsm.PAdaptFsm
 		if pConfigAniStateAFsm != nil {
 			// obviously calling some FSM event here directly does not work - so trying to decouple it ...
-			go func(aPAFsm *AdapterFsm) {
-				if aPAFsm != nil && aPAFsm.pFsm != nil {
-					_ = aPAFsm.pFsm.Event(aniEvFlowRemDone)
+			go func(aPAFsm *cmn.AdapterFsm) {
+				if aPAFsm != nil && aPAFsm.PFsm != nil {
+					_ = aPAFsm.PFsm.Event(aniEvFlowRemDone)
 				}
 			}(pConfigAniStateAFsm)
 		} else {
 			logger.Errorw(ctx, "pConfigAniStateAFsm is nil", log.Fields{
-				"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID, "techProfile-id": oFsm.techProfileID})
+				"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID, "techProfile-id": oFsm.techProfileID})
 		}
 		return
 
 	case success := <-oFsm.waitFlowDeleteChannel:
 		if success {
-			logger.Debugw(ctx, "uniPonAniConfigFsm flow removed info received", log.Fields{
-				"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID, "techProfile-id": oFsm.techProfileID})
+			logger.Debugw(ctx, "UniPonAniConfigFsm flow removed info received", log.Fields{
+				"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID, "techProfile-id": oFsm.techProfileID})
 			oFsm.mutexIsAwaitingResponse.Lock()
 			oFsm.isWaitingForFlowDelete = false
 			oFsm.mutexIsAwaitingResponse.Unlock()
-			pConfigAniStateAFsm := oFsm.pAdaptFsm
+			pConfigAniStateAFsm := oFsm.PAdaptFsm
 			if pConfigAniStateAFsm != nil {
 				// obviously calling some FSM event here directly does not work - so trying to decouple it ...
-				go func(aPAFsm *AdapterFsm) {
-					if aPAFsm != nil && aPAFsm.pFsm != nil {
-						_ = aPAFsm.pFsm.Event(aniEvFlowRemDone)
+				go func(aPAFsm *cmn.AdapterFsm) {
+					if aPAFsm != nil && aPAFsm.PFsm != nil {
+						_ = aPAFsm.PFsm.Event(aniEvFlowRemDone)
 					}
 				}(pConfigAniStateAFsm)
 			} else {
 				logger.Errorw(ctx, "pConfigAniStateAFsm is nil", log.Fields{
-					"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID, "techProfile-id": oFsm.techProfileID})
+					"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID, "techProfile-id": oFsm.techProfileID})
 			}
 			return
 		}
 		// waiting was aborted (probably on external request)
-		logger.Debugw(ctx, "uniPonAniConfigFsm WaitingFlowRem aborted", log.Fields{
-			"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID, "techProfile-id": oFsm.techProfileID})
+		logger.Debugw(ctx, "UniPonAniConfigFsm WaitingFlowRem aborted", log.Fields{
+			"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID, "techProfile-id": oFsm.techProfileID})
 		oFsm.mutexIsAwaitingResponse.Lock()
 		oFsm.isWaitingForFlowDelete = false
 		oFsm.mutexIsAwaitingResponse.Unlock()
 		//to be sure we can just generate the reset-event to ensure leaving this state towards 'reset'
-		pConfigAniStateAFsm := oFsm.pAdaptFsm
+		pConfigAniStateAFsm := oFsm.PAdaptFsm
 		if pConfigAniStateAFsm != nil {
 			// obviously calling some FSM event here directly does not work - so trying to decouple it ...
-			go func(aPAFsm *AdapterFsm) {
-				if aPAFsm != nil && aPAFsm.pFsm != nil {
-					_ = aPAFsm.pFsm.Event(aniEvReset)
+			go func(aPAFsm *cmn.AdapterFsm) {
+				if aPAFsm != nil && aPAFsm.PFsm != nil {
+					_ = aPAFsm.PFsm.Event(aniEvReset)
 				}
 			}(pConfigAniStateAFsm)
 		}
@@ -901,27 +908,27 @@
 	}
 }
 
-func (oFsm *uniPonAniConfigFsm) enterRemovingGemNCTP(ctx context.Context, e *fsm.Event) {
+func (oFsm *UniPonAniConfigFsm) enterRemovingGemNCTP(ctx context.Context, e *fsm.Event) {
 	oFsm.pUniTechProf.mutexTPState.RLock()
 	loGemPortID := (*(oFsm.pUniTechProf.mapRemoveGemEntry[oFsm.uniTpKey])).gemPortID
 	oFsm.pUniTechProf.mutexTPState.RUnlock()
-	logger.Debugw(ctx, "uniPonAniConfigFsm - start removing one GemNCTP", log.Fields{
-		"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID,
+	logger.Debugw(ctx, "UniPonAniConfigFsm - start removing one GemNCTP", log.Fields{
+		"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID,
 		"GemNCTP-entity-id": loGemPortID})
 	// this state entry is only expected in a suitable state (checked outside in onu_uni_tp)
 	oFsm.mutexPLastTxMeInstance.Lock()
-	meInstance, err := oFsm.pOmciCC.sendDeleteGemNCTP(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
-		oFsm.pAdaptFsm.commChan, loGemPortID)
+	meInstance, err := oFsm.pOmciCC.SendDeleteGemNCTP(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), true,
+		oFsm.PAdaptFsm.CommChan, loGemPortID)
 	if err != nil {
-		logger.Errorw(ctx, "GemNCTP delete failed, aborting uniPonAniConfigFsm!",
+		logger.Errorw(ctx, "GemNCTP delete failed, aborting UniPonAniConfigFsm!",
 			log.Fields{"device-id": oFsm.deviceID})
-		pConfigAniStateAFsm := oFsm.pAdaptFsm
+		pConfigAniStateAFsm := oFsm.PAdaptFsm
 		if pConfigAniStateAFsm != nil {
 			oFsm.mutexPLastTxMeInstance.Unlock()
 			// obviously calling some FSM event here directly does not work - so trying to decouple it ...
-			go func(aPAFsm *AdapterFsm) {
-				if aPAFsm != nil && aPAFsm.pFsm != nil {
-					_ = aPAFsm.pFsm.Event(aniEvReset)
+			go func(aPAFsm *cmn.AdapterFsm) {
+				if aPAFsm != nil && aPAFsm.PFsm != nil {
+					_ = aPAFsm.PFsm.Event(aniEvReset)
 				}
 			}(pConfigAniStateAFsm)
 			return
@@ -931,32 +938,33 @@
 	oFsm.mutexPLastTxMeInstance.Unlock()
 
 	// Mark the gem port to be removed for Performance History monitoring
-	if oFsm.pDeviceHandler.pOnuMetricsMgr != nil {
-		oFsm.pDeviceHandler.pOnuMetricsMgr.RemoveGemPortForPerfMonitoring(ctx, loGemPortID)
+	OnuMetricsManager := oFsm.pDeviceHandler.GetOnuMetricsManager()
+	if OnuMetricsManager != nil {
+		OnuMetricsManager.RemoveGemPortForPerfMonitoring(ctx, loGemPortID)
 	}
 }
-func (oFsm *uniPonAniConfigFsm) enterRemovingTD(ctx context.Context, e *fsm.Event) {
+func (oFsm *UniPonAniConfigFsm) enterRemovingTD(ctx context.Context, e *fsm.Event) {
 	oFsm.pUniTechProf.mutexTPState.RLock()
 	loGemPortID := (*(oFsm.pUniTechProf.mapRemoveGemEntry[oFsm.uniTpKey])).gemPortID
 	oFsm.pUniTechProf.mutexTPState.RUnlock()
-	logger.Debugw(ctx, "uniPonAniConfigFsm - start removing Traffic Descriptor", log.Fields{
-		"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID,
+	logger.Debugw(ctx, "UniPonAniConfigFsm - start removing Traffic Descriptor", log.Fields{
+		"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID,
 		"TD-entity-id": loGemPortID})
 
 	oFsm.mutexPLastTxMeInstance.Lock()
-	meInstance, err := oFsm.pOmciCC.sendDeleteTD(log.WithSpanFromContext(context.TODO(), ctx),
-		oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true, oFsm.pAdaptFsm.commChan, loGemPortID)
+	meInstance, err := oFsm.pOmciCC.SendDeleteTD(log.WithSpanFromContext(context.TODO(), ctx),
+		oFsm.pDeviceHandler.GetOmciTimeout(), true, oFsm.PAdaptFsm.CommChan, loGemPortID)
 
 	if err != nil {
 		logger.Errorw(ctx, "TD delete failed - proceed fsm",
 			log.Fields{"device-id": oFsm.deviceID, "gemPortID": loGemPortID})
-		pConfigAniStateAFsm := oFsm.pAdaptFsm
+		pConfigAniStateAFsm := oFsm.PAdaptFsm
 		if pConfigAniStateAFsm != nil {
 			oFsm.mutexPLastTxMeInstance.Unlock()
 			// obviously calling some FSM event here directly does not work - so trying to decouple it ...
-			go func(aPAFsm *AdapterFsm) {
-				if aPAFsm != nil && aPAFsm.pFsm != nil {
-					_ = aPAFsm.pFsm.Event(aniEvReset)
+			go func(aPAFsm *cmn.AdapterFsm) {
+				if aPAFsm != nil && aPAFsm.PFsm != nil {
+					_ = aPAFsm.PFsm.Event(aniEvReset)
 				}
 			}(pConfigAniStateAFsm)
 			return
@@ -966,31 +974,31 @@
 	oFsm.mutexPLastTxMeInstance.Unlock()
 }
 
-func (oFsm *uniPonAniConfigFsm) enterResettingTcont(ctx context.Context, e *fsm.Event) {
-	logger.Debugw(ctx, "uniPonAniConfigFsm - start resetting the TCont", log.Fields{
-		"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID})
+func (oFsm *UniPonAniConfigFsm) enterResettingTcont(ctx context.Context, e *fsm.Event) {
+	logger.Debugw(ctx, "UniPonAniConfigFsm - start resetting the TCont", log.Fields{
+		"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID})
 
 	oFsm.requestEventOffset = 1 //offset 1 for last remove activity
 	// this state entry is only expected in a suitable state (checked outside in onu_uni_tp)
 	meParams := me.ParamData{
 		EntityID: oFsm.tcont0ID,
 		Attributes: me.AttributeValueMap{
-			"AllocId": unusedTcontAllocID,
+			"AllocId": cmn.UnusedTcontAllocID,
 		},
 	}
 	oFsm.mutexPLastTxMeInstance.Lock()
-	meInstance, err := oFsm.pOmciCC.sendSetTcontVar(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
-		oFsm.pAdaptFsm.commChan, meParams)
+	meInstance, err := oFsm.pOmciCC.SendSetTcontVar(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), true,
+		oFsm.PAdaptFsm.CommChan, meParams)
 	if err != nil {
-		logger.Errorw(ctx, "TcontVar set failed, aborting uniPonAniConfigFsm!",
+		logger.Errorw(ctx, "TcontVar set failed, aborting UniPonAniConfigFsm!",
 			log.Fields{"device-id": oFsm.deviceID})
-		pConfigAniStateAFsm := oFsm.pAdaptFsm
+		pConfigAniStateAFsm := oFsm.PAdaptFsm
 		if pConfigAniStateAFsm != nil {
 			oFsm.mutexPLastTxMeInstance.Unlock()
 			// obviously calling some FSM event here directly does not work - so trying to decouple it ...
-			go func(aPAFsm *AdapterFsm) {
-				if aPAFsm != nil && aPAFsm.pFsm != nil {
-					_ = aPAFsm.pFsm.Event(aniEvReset)
+			go func(aPAFsm *cmn.AdapterFsm) {
+				if aPAFsm != nil && aPAFsm.PFsm != nil {
+					_ = aPAFsm.PFsm.Event(aniEvReset)
 				}
 			}(pConfigAniStateAFsm)
 			return
@@ -1001,9 +1009,9 @@
 
 }
 
-func (oFsm *uniPonAniConfigFsm) enterRemoving1pMapper(ctx context.Context, e *fsm.Event) {
-	logger.Debugw(ctx, "uniPonAniConfigFsm - start deleting the .1pMapper", log.Fields{
-		"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID})
+func (oFsm *UniPonAniConfigFsm) enterRemoving1pMapper(ctx context.Context, e *fsm.Event) {
+	logger.Debugw(ctx, "UniPonAniConfigFsm - start deleting the .1pMapper", log.Fields{
+		"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID})
 	mapGemPortParams := oFsm.pUniTechProf.mapPonAniConfig[oFsm.uniTpKey].mapGemPortParams
 	unicastGemCount := 0
 	for _, gemEntry := range mapGemPortParams {
@@ -1012,35 +1020,35 @@
 		}
 	}
 	if unicastGemCount > 1 {
-		logger.Debugw(ctx, "uniPonAniConfigFsm - Not the last gem in fsm. Skip the rest", log.Fields{
-			"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID, "unicast-gem-count": unicastGemCount, "gem-count": len(mapGemPortParams)})
-		pConfigAniStateAFsm := oFsm.pAdaptFsm
+		logger.Debugw(ctx, "UniPonAniConfigFsm - Not the last gem in fsm. Skip the rest", log.Fields{
+			"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID, "unicast-gem-count": unicastGemCount, "gem-count": len(mapGemPortParams)})
+		pConfigAniStateAFsm := oFsm.PAdaptFsm
 		if pConfigAniStateAFsm != nil {
 			// obviously calling some FSM event here directly does not work - so trying to decouple it ...
-			go func(aPAFsm *AdapterFsm) {
-				if aPAFsm != nil && aPAFsm.pFsm != nil {
-					_ = aPAFsm.pFsm.Event(aniEvRemGemDone)
+			go func(aPAFsm *cmn.AdapterFsm) {
+				if aPAFsm != nil && aPAFsm.PFsm != nil {
+					_ = aPAFsm.PFsm.Event(aniEvRemGemDone)
 				}
 			}(pConfigAniStateAFsm)
 			return
 		}
 	}
-	logger.Debugw(ctx, "uniPonAniConfigFsm - Last gem in fsm. Continue with Mapper removal", log.Fields{
-		"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID, "unicast-gem-count": unicastGemCount, "gem-count": len(mapGemPortParams)})
+	logger.Debugw(ctx, "UniPonAniConfigFsm - Last gem in fsm. Continue with Mapper removal", log.Fields{
+		"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID, "unicast-gem-count": unicastGemCount, "gem-count": len(mapGemPortParams)})
 
 	oFsm.mutexPLastTxMeInstance.Lock()
-	meInstance, err := oFsm.pOmciCC.sendDeleteDot1PMapper(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
-		oFsm.pAdaptFsm.commChan, oFsm.mapperSP0ID)
+	meInstance, err := oFsm.pOmciCC.SendDeleteDot1PMapper(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), true,
+		oFsm.PAdaptFsm.CommChan, oFsm.mapperSP0ID)
 	if err != nil {
-		logger.Errorw(ctx, "Dot1Mapper delete failed, aborting uniPonAniConfigFsm!",
+		logger.Errorw(ctx, "Dot1Mapper delete failed, aborting UniPonAniConfigFsm!",
 			log.Fields{"device-id": oFsm.deviceID})
-		pConfigAniStateAFsm := oFsm.pAdaptFsm
+		pConfigAniStateAFsm := oFsm.PAdaptFsm
 		if pConfigAniStateAFsm != nil {
 			oFsm.mutexPLastTxMeInstance.Unlock()
 			// obviously calling some FSM event here directly does not work - so trying to decouple it ...
-			go func(aPAFsm *AdapterFsm) {
-				if aPAFsm != nil && aPAFsm.pFsm != nil {
-					_ = aPAFsm.pFsm.Event(aniEvReset)
+			go func(aPAFsm *cmn.AdapterFsm) {
+				if aPAFsm != nil && aPAFsm.PFsm != nil {
+					_ = aPAFsm.PFsm.Event(aniEvReset)
 				}
 			}(pConfigAniStateAFsm)
 			return
@@ -1051,23 +1059,23 @@
 
 }
 
-func (oFsm *uniPonAniConfigFsm) enterRemovingAniBPCD(ctx context.Context, e *fsm.Event) {
-	logger.Debugw(ctx, "uniPonAniConfigFsm - start deleting the ANI MBCD", log.Fields{
-		"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID})
+func (oFsm *UniPonAniConfigFsm) enterRemovingAniBPCD(ctx context.Context, e *fsm.Event) {
+	logger.Debugw(ctx, "UniPonAniConfigFsm - start deleting the ANI MBCD", log.Fields{
+		"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID})
 
 	oFsm.mutexPLastTxMeInstance.Lock()
-	meInstance, err := oFsm.pOmciCC.sendDeleteMBPConfigData(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
-		oFsm.pAdaptFsm.commChan, oFsm.macBPCD0ID)
+	meInstance, err := oFsm.pOmciCC.SendDeleteMBPConfigData(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), true,
+		oFsm.PAdaptFsm.CommChan, oFsm.macBPCD0ID)
 	if err != nil {
-		logger.Errorw(ctx, "MBPConfigData delete failed, aborting uniPonAniConfigFsm!",
+		logger.Errorw(ctx, "MBPConfigData delete failed, aborting UniPonAniConfigFsm!",
 			log.Fields{"device-id": oFsm.deviceID})
-		pConfigAniStateAFsm := oFsm.pAdaptFsm
+		pConfigAniStateAFsm := oFsm.PAdaptFsm
 		if pConfigAniStateAFsm != nil {
 			oFsm.mutexPLastTxMeInstance.Unlock()
 			// obviously calling some FSM event here directly does not work - so trying to decouple it ...
-			go func(aPAFsm *AdapterFsm) {
-				if aPAFsm != nil && aPAFsm.pFsm != nil {
-					_ = aPAFsm.pFsm.Event(aniEvReset)
+			go func(aPAFsm *cmn.AdapterFsm) {
+				if aPAFsm != nil && aPAFsm.PFsm != nil {
+					_ = aPAFsm.PFsm.Event(aniEvReset)
 				}
 			}(pConfigAniStateAFsm)
 			return
@@ -1077,104 +1085,104 @@
 	oFsm.mutexPLastTxMeInstance.Unlock()
 }
 
-func (oFsm *uniPonAniConfigFsm) enterAniRemoveDone(ctx context.Context, e *fsm.Event) {
-	logger.Debugw(ctx, "uniPonAniConfigFsm ani removal done", log.Fields{
-		"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID})
+func (oFsm *UniPonAniConfigFsm) enterAniRemoveDone(ctx context.Context, e *fsm.Event) {
+	logger.Debugw(ctx, "UniPonAniConfigFsm ani removal done", log.Fields{
+		"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID})
 	//use DeviceHandler event notification directly
-	oFsm.pDeviceHandler.deviceProcStatusUpdate(ctx, OnuDeviceEvent((uint8(oFsm.requestEvent) + oFsm.requestEventOffset)))
+	oFsm.pDeviceHandler.DeviceProcStatusUpdate(ctx, cmn.OnuDeviceEvent((uint8(oFsm.requestEvent) + oFsm.requestEventOffset)))
 	if oFsm.isChanSet() {
 		// indicate processing done to the caller
-		logger.Debugw(ctx, "uniPonAniConfigFsm processingDone on channel", log.Fields{
+		logger.Debugw(ctx, "UniPonAniConfigFsm processingDone on channel", log.Fields{
 			"ProcessingStep": oFsm.procStep, "from_State": e.FSM.Current(), "device-id": oFsm.deviceID})
 		oFsm.chSuccess <- oFsm.procStep
 		oFsm.setChanSet(false) //reset the internal channel state
 	}
 
 	//let's reset the state machine in order to release all resources now
-	pConfigAniStateAFsm := oFsm.pAdaptFsm
+	pConfigAniStateAFsm := oFsm.PAdaptFsm
 	if pConfigAniStateAFsm != nil {
 		// obviously calling some FSM event here directly does not work - so trying to decouple it ...
-		go func(aPAFsm *AdapterFsm) {
-			if aPAFsm != nil && aPAFsm.pFsm != nil {
-				_ = aPAFsm.pFsm.Event(aniEvReset)
+		go func(aPAFsm *cmn.AdapterFsm) {
+			if aPAFsm != nil && aPAFsm.PFsm != nil {
+				_ = aPAFsm.PFsm.Event(aniEvReset)
 			}
 		}(pConfigAniStateAFsm)
 	}
 }
 
-func (oFsm *uniPonAniConfigFsm) enterResettingState(ctx context.Context, e *fsm.Event) {
-	logger.Debugw(ctx, "uniPonAniConfigFsm resetting", log.Fields{
-		"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID})
+func (oFsm *UniPonAniConfigFsm) enterResettingState(ctx context.Context, e *fsm.Event) {
+	logger.Debugw(ctx, "UniPonAniConfigFsm resetting", log.Fields{
+		"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID})
 
 	if oFsm.isChanSet() {
 		// indicate processing error to the caller (in case there was still some open request)
-		logger.Debugw(ctx, "uniPonAniConfigFsm processingError on channel", log.Fields{
+		logger.Debugw(ctx, "UniPonAniConfigFsm processingError on channel", log.Fields{
 			"ProcessingStep": oFsm.procStep, "from_State": e.FSM.Current(), "device-id": oFsm.deviceID})
 		//use non-blocking channel send to avoid blocking because of non-existing receiver
 		//  (even though the channel is checked on 'set', the outside receiver channel might (theoretically) already be deleted)
 		select {
 		case oFsm.chSuccess <- 0:
 		default:
-			logger.Debugw(ctx, "uniPonAniConfigFsm processingError not send on channel (no receiver)", log.Fields{
+			logger.Debugw(ctx, "UniPonAniConfigFsm processingError not send on channel (no receiver)", log.Fields{
 				"device-id": oFsm.deviceID})
 		}
 		oFsm.setChanSet(false) //reset the internal channel state
 	}
 
-	pConfigAniStateAFsm := oFsm.pAdaptFsm
+	pConfigAniStateAFsm := oFsm.PAdaptFsm
 	if pConfigAniStateAFsm != nil {
 		// abort running message processing
-		fsmAbortMsg := Message{
-			Type: TestMsg,
-			Data: TestMessage{
-				TestMessageVal: AbortMessageProcessing,
+		fsmAbortMsg := cmn.Message{
+			Type: cmn.TestMsg,
+			Data: cmn.TestMessage{
+				TestMessageVal: cmn.AbortMessageProcessing,
 			},
 		}
-		pConfigAniStateAFsm.commChan <- fsmAbortMsg
+		pConfigAniStateAFsm.CommChan <- fsmAbortMsg
 
 		//try to restart the FSM to 'disabled', decouple event transfer
-		go func(aPAFsm *AdapterFsm) {
-			if aPAFsm != nil && aPAFsm.pFsm != nil {
-				_ = aPAFsm.pFsm.Event(aniEvRestart)
+		go func(aPAFsm *cmn.AdapterFsm) {
+			if aPAFsm != nil && aPAFsm.PFsm != nil {
+				_ = aPAFsm.PFsm.Event(aniEvRestart)
 			}
 		}(pConfigAniStateAFsm)
 	}
 }
 
-func (oFsm *uniPonAniConfigFsm) enterDisabledState(ctx context.Context, e *fsm.Event) {
-	logger.Debugw(ctx, "uniPonAniConfigFsm enters disabled state", log.Fields{
-		"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID})
+func (oFsm *UniPonAniConfigFsm) enterDisabledState(ctx context.Context, e *fsm.Event) {
+	logger.Debugw(ctx, "UniPonAniConfigFsm enters disabled state", log.Fields{
+		"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID})
 	oFsm.mutexPLastTxMeInstance.Lock()
 	defer oFsm.mutexPLastTxMeInstance.Unlock()
 	oFsm.pLastTxMeInstance = nil
 }
 
-func (oFsm *uniPonAniConfigFsm) processOmciAniMessages(ctx context.Context) {
-	logger.Debugw(ctx, "Start uniPonAniConfigFsm Msg processing", log.Fields{"for device-id": oFsm.deviceID})
+func (oFsm *UniPonAniConfigFsm) processOmciAniMessages(ctx context.Context) {
+	logger.Debugw(ctx, "Start UniPonAniConfigFsm Msg processing", log.Fields{"for device-id": oFsm.deviceID})
 loop:
 	for {
 		// case <-ctx.Done():
 		// 	logger.Info("MibSync Msg", log.Fields{"Message handling canceled via context for device-id": oFsm.deviceID})
 		// 	break loop
-		message, ok := <-oFsm.pAdaptFsm.commChan
+		message, ok := <-oFsm.PAdaptFsm.CommChan
 		if !ok {
 			logger.Info(ctx, "UniPonAniConfigFsm Rx Msg - could not read from channel", log.Fields{"device-id": oFsm.deviceID})
 			// but then we have to ensure a restart of the FSM as well - as exceptional procedure
-			_ = oFsm.pAdaptFsm.pFsm.Event(aniEvReset)
+			_ = oFsm.PAdaptFsm.PFsm.Event(aniEvReset)
 			break loop
 		}
 		logger.Debugw(ctx, "UniPonAniConfigFsm Rx Msg", log.Fields{"device-id": oFsm.deviceID})
 
 		switch message.Type {
-		case TestMsg:
-			msg, _ := message.Data.(TestMessage)
-			if msg.TestMessageVal == AbortMessageProcessing {
+		case cmn.TestMsg:
+			msg, _ := message.Data.(cmn.TestMessage)
+			if msg.TestMessageVal == cmn.AbortMessageProcessing {
 				logger.Infow(ctx, "UniPonAniConfigFsm abort ProcessMsg", log.Fields{"for device-id": oFsm.deviceID})
 				break loop
 			}
 			logger.Warnw(ctx, "UniPonAniConfigFsm unknown TestMessage", log.Fields{"device-id": oFsm.deviceID, "MessageVal": msg.TestMessageVal})
-		case OMCI:
-			msg, _ := message.Data.(OmciMessage)
+		case cmn.OMCI:
+			msg, _ := message.Data.(cmn.OmciMessage)
 			oFsm.handleOmciAniConfigMessage(ctx, msg)
 		default:
 			logger.Warn(ctx, "UniPonAniConfigFsm Rx unknown message", log.Fields{"device-id": oFsm.deviceID,
@@ -1182,10 +1190,10 @@
 		}
 
 	}
-	logger.Infow(ctx, "End uniPonAniConfigFsm Msg processing", log.Fields{"device-id": oFsm.deviceID})
+	logger.Infow(ctx, "End UniPonAniConfigFsm Msg processing", log.Fields{"device-id": oFsm.deviceID})
 }
 
-func (oFsm *uniPonAniConfigFsm) handleOmciAniConfigCreateResponseMessage(ctx context.Context, msg OmciMessage) {
+func (oFsm *UniPonAniConfigFsm) handleOmciAniConfigCreateResponseMessage(ctx context.Context, msg cmn.OmciMessage) {
 	msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeCreateResponse)
 	if msgLayer == nil {
 		logger.Errorw(ctx, "Omci Msg layer could not be detected for CreateResponse",
@@ -1211,12 +1219,12 @@
 				case "Ieee8021PMapperServiceProfile":
 					{ // let the FSM proceed ...
 						oFsm.mutexPLastTxMeInstance.RUnlock()
-						_ = oFsm.pAdaptFsm.pFsm.Event(aniEvRxDot1pmapCResp)
+						_ = oFsm.PAdaptFsm.PFsm.Event(aniEvRxDot1pmapCResp)
 					}
 				case "MacBridgePortConfigurationData":
 					{ // let the FSM proceed ...
 						oFsm.mutexPLastTxMeInstance.RUnlock()
-						_ = oFsm.pAdaptFsm.pFsm.Event(aniEvRxMbpcdResp)
+						_ = oFsm.PAdaptFsm.PFsm.Event(aniEvRxMbpcdResp)
 					}
 				case "GemPortNetworkCtp", "GemInterworkingTerminationPoint", "MulticastGemInterworkingTerminationPoint":
 					{ // let aniConfig Multi-Id processing proceed by stopping the wait function
@@ -1244,7 +1252,7 @@
 		return
 	}
 }
-func (oFsm *uniPonAniConfigFsm) handleOmciAniConfigSetFailResponseMessage(ctx context.Context, msgObj *omci.SetResponse) {
+func (oFsm *UniPonAniConfigFsm) handleOmciAniConfigSetFailResponseMessage(ctx context.Context, msgObj *omci.SetResponse) {
 	//If TCONT fails, then we need to revert the allocated TCONT in DB.
 	//Because FSMs are running sequentially, we don't expect the same TCONT hit by another tech-profile FSM while this FSM is running.
 	oFsm.mutexPLastTxMeInstance.RLock()
@@ -1258,8 +1266,8 @@
 			if oFsm.requestEventOffset == 0 && !oFsm.tcontSetBefore && oFsm.pUniTechProf.mapPonAniConfig[oFsm.uniTpKey] != nil {
 				logger.Debugw(ctx, "UniPonAniConfigFsm TCONT creation failed on device. Freeing alloc id", log.Fields{"device-id": oFsm.deviceID,
 					"alloc-id": oFsm.pUniTechProf.mapPonAniConfig[oFsm.uniTpKey].tcontParams.allocID, "uni-tp": oFsm.uniTpKey})
-				if pDevEntry := oFsm.pDeviceHandler.getOnuDeviceEntry(ctx, false); pDevEntry != nil {
-					pDevEntry.freeTcont(ctx, oFsm.pUniTechProf.mapPonAniConfig[oFsm.uniTpKey].tcontParams.allocID)
+				if oFsm.pOnuDeviceEntry != nil {
+					oFsm.pOnuDeviceEntry.FreeTcont(ctx, oFsm.pUniTechProf.mapPonAniConfig[oFsm.uniTpKey].tcontParams.allocID)
 				} else {
 					logger.Warnw(ctx, "Unable to get device entry! couldn't free tcont",
 						log.Fields{"ME name": oFsm.pLastTxMeInstance.GetName(), "device-id": oFsm.deviceID})
@@ -1271,7 +1279,7 @@
 		}
 	}
 }
-func (oFsm *uniPonAniConfigFsm) handleOmciAniConfigSetResponseMessage(ctx context.Context, msg OmciMessage) {
+func (oFsm *UniPonAniConfigFsm) handleOmciAniConfigSetResponseMessage(ctx context.Context, msg cmn.OmciMessage) {
 	msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeSetResponse)
 	if msgLayer == nil {
 		logger.Errorw(ctx, "UniPonAniConfigFsm - Omci Msg layer could not be detected for SetResponse",
@@ -1306,9 +1314,9 @@
 				{ // let the FSM proceed ...
 					oFsm.mutexPLastTxMeInstance.RUnlock()
 					if oFsm.requestEventOffset == 0 { //from TCont config request
-						_ = oFsm.pAdaptFsm.pFsm.Event(aniEvRxTcontsResp)
+						_ = oFsm.PAdaptFsm.PFsm.Event(aniEvRxTcontsResp)
 					} else { // from T-Cont reset request
-						_ = oFsm.pAdaptFsm.pFsm.Event(aniEvRxResetTcontResp)
+						_ = oFsm.PAdaptFsm.PFsm.Event(aniEvRxResetTcontResp)
 					}
 				}
 			case "PriorityQueue", "MulticastGemInterworkingTerminationPoint":
@@ -1319,7 +1327,7 @@
 			case "Ieee8021PMapperServiceProfile":
 				{ // let the FSM proceed ...
 					oFsm.mutexPLastTxMeInstance.RUnlock()
-					_ = oFsm.pAdaptFsm.pFsm.Event(aniEvRxDot1pmapSResp)
+					_ = oFsm.PAdaptFsm.PFsm.Event(aniEvRxDot1pmapSResp)
 				}
 			default:
 				{
@@ -1337,7 +1345,7 @@
 	}
 }
 
-func (oFsm *uniPonAniConfigFsm) handleOmciAniConfigDeleteResponseMessage(ctx context.Context, msg OmciMessage) {
+func (oFsm *UniPonAniConfigFsm) handleOmciAniConfigDeleteResponseMessage(ctx context.Context, msg cmn.OmciMessage) {
 	msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeDeleteResponse)
 	if msgLayer == nil {
 		logger.Errorw(ctx, "UniPonAniConfigFsm - Omci Msg layer could not be detected for DeleteResponse",
@@ -1369,27 +1377,27 @@
 			case "GemInterworkingTerminationPoint":
 				{ // let the FSM proceed ...
 					oFsm.mutexPLastTxMeInstance.RUnlock()
-					_ = oFsm.pAdaptFsm.pFsm.Event(aniEvRxRemGemiwResp)
+					_ = oFsm.PAdaptFsm.PFsm.Event(aniEvRxRemGemiwResp)
 				}
 			case "GemPortNetworkCtp":
 				{ // let the FSM proceed ...
 					oFsm.mutexPLastTxMeInstance.RUnlock()
-					_ = oFsm.pAdaptFsm.pFsm.Event(aniEvRxRemGemntpResp)
+					_ = oFsm.PAdaptFsm.PFsm.Event(aniEvRxRemGemntpResp)
 				}
 			case "TrafficDescriptor":
 				{ // let the FSM proceed ...
 					oFsm.mutexPLastTxMeInstance.RUnlock()
-					_ = oFsm.pAdaptFsm.pFsm.Event(aniEvRxRemTdResp)
+					_ = oFsm.PAdaptFsm.PFsm.Event(aniEvRxRemTdResp)
 				}
 			case "Ieee8021PMapperServiceProfile":
 				{ // let the FSM proceed ...
 					oFsm.mutexPLastTxMeInstance.RUnlock()
-					_ = oFsm.pAdaptFsm.pFsm.Event(aniEvRxRem1pMapperResp)
+					_ = oFsm.PAdaptFsm.PFsm.Event(aniEvRxRem1pMapperResp)
 				}
 			case "MacBridgePortConfigurationData":
 				{ // this is the last event of the T-Cont cleanup procedure, FSM may be reset here
 					oFsm.mutexPLastTxMeInstance.RUnlock()
-					_ = oFsm.pAdaptFsm.pFsm.Event(aniEvRxRemAniBPCDResp)
+					_ = oFsm.PAdaptFsm.PFsm.Event(aniEvRxRemAniBPCDResp)
 				}
 			default:
 				{
@@ -1407,7 +1415,7 @@
 	}
 }
 
-func (oFsm *uniPonAniConfigFsm) handleOmciAniConfigMessage(ctx context.Context, msg OmciMessage) {
+func (oFsm *UniPonAniConfigFsm) handleOmciAniConfigMessage(ctx context.Context, msg cmn.OmciMessage) {
 	logger.Debugw(ctx, "Rx OMCI UniPonAniConfigFsm Msg", log.Fields{"device-id": oFsm.deviceID,
 		"msgType": msg.OmciMsg.MessageType})
 
@@ -1429,17 +1437,17 @@
 		} //DeleteResponseType
 	default:
 		{
-			logger.Errorw(ctx, "uniPonAniConfigFsm - Rx OMCI unhandled MsgType",
+			logger.Errorw(ctx, "UniPonAniConfigFsm - Rx OMCI unhandled MsgType",
 				log.Fields{"omciMsgType": msg.OmciMsg.MessageType, "device-id": oFsm.deviceID})
 			return
 		}
 	}
 }
 
-func (oFsm *uniPonAniConfigFsm) performCreatingGemNCTPs(ctx context.Context) {
+func (oFsm *UniPonAniConfigFsm) performCreatingGemNCTPs(ctx context.Context) {
 	// for all GemPorts of this T-Cont as given by the size of set gemPortAttribsSlice
 	for gemIndex, gemPortAttribs := range oFsm.gemPortAttribsSlice {
-		logger.Debugw(ctx, "uniPonAniConfigFsm Tx Create::GemNWCtp", log.Fields{
+		logger.Debugw(ctx, "UniPonAniConfigFsm Tx Create::GemNWCtp", log.Fields{
 			"EntitytId": strconv.FormatInt(int64(gemPortAttribs.gemPortID), 16),
 			"TcontId":   strconv.FormatInt(int64(oFsm.tcont0ID), 16),
 			"device-id": oFsm.deviceID})
@@ -1456,13 +1464,13 @@
 			},
 		}
 		oFsm.mutexPLastTxMeInstance.Lock()
-		meInstance, err := oFsm.pOmciCC.sendCreateGemNCTPVar(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
-			oFsm.pAdaptFsm.commChan, meParams)
+		meInstance, err := oFsm.pOmciCC.SendCreateGemNCTPVar(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), true,
+			oFsm.PAdaptFsm.CommChan, meParams)
 		if err != nil {
 			oFsm.mutexPLastTxMeInstance.Unlock()
-			logger.Errorw(ctx, "GemNCTPVar create failed, aborting uniPonAniConfigFsm!",
+			logger.Errorw(ctx, "GemNCTPVar create failed, aborting UniPonAniConfigFsm!",
 				log.Fields{"device-id": oFsm.deviceID})
-			_ = oFsm.pAdaptFsm.pFsm.Event(aniEvReset)
+			_ = oFsm.PAdaptFsm.PFsm.Event(aniEvReset)
 			return
 		}
 		//accept also nil as (error) return value for writing to LastTx
@@ -1474,20 +1482,21 @@
 		if err != nil {
 			logger.Errorw(ctx, "GemNWCtp create failed, aborting AniConfig FSM!",
 				log.Fields{"device-id": oFsm.deviceID, "GemIndex": gemIndex})
-			_ = oFsm.pAdaptFsm.pFsm.Event(aniEvReset)
+			_ = oFsm.PAdaptFsm.PFsm.Event(aniEvReset)
 			return
 		}
 		// Mark the gem port to be added for Performance History monitoring
-		if oFsm.pDeviceHandler.pOnuMetricsMgr != nil {
-			oFsm.pDeviceHandler.pOnuMetricsMgr.AddGemPortForPerfMonitoring(ctx, gemPortAttribs.gemPortID)
+		OnuMetricsManager := oFsm.pDeviceHandler.GetOnuMetricsManager()
+		if OnuMetricsManager != nil {
+			OnuMetricsManager.AddGemPortForPerfMonitoring(ctx, gemPortAttribs.gemPortID)
 		}
 	} //for all GemPorts of this T-Cont
 
 	// if Config has been done for all GemPort instances let the FSM proceed
 	logger.Debugw(ctx, "GemNWCtp create loop finished", log.Fields{"device-id": oFsm.deviceID})
-	_ = oFsm.pAdaptFsm.pFsm.Event(aniEvRxGemntcpsResp)
+	_ = oFsm.PAdaptFsm.PFsm.Event(aniEvRxGemntcpsResp)
 }
-func (oFsm *uniPonAniConfigFsm) hasMulticastGem(ctx context.Context) bool {
+func (oFsm *UniPonAniConfigFsm) hasMulticastGem(ctx context.Context) bool {
 	for _, gemPortAttribs := range oFsm.gemPortAttribsSlice {
 		if gemPortAttribs.isMulticast {
 			logger.Debugw(ctx, "Found multicast gem", log.Fields{"device-id": oFsm.deviceID})
@@ -1497,10 +1506,10 @@
 	return false
 }
 
-func (oFsm *uniPonAniConfigFsm) performCreatingGemIWs(ctx context.Context) {
+func (oFsm *UniPonAniConfigFsm) performCreatingGemIWs(ctx context.Context) {
 	// for all GemPorts of this T-Cont as given by the size of set gemPortAttribsSlice
 	for gemIndex, gemPortAttribs := range oFsm.gemPortAttribsSlice {
-		logger.Debugw(ctx, "uniPonAniConfigFsm Tx Create::GemIwTp", log.Fields{
+		logger.Debugw(ctx, "UniPonAniConfigFsm Tx Create::GemIwTp", log.Fields{
 			"EntitytId": strconv.FormatInt(int64(gemPortAttribs.gemPortID), 16),
 			"SPPtr":     strconv.FormatInt(int64(oFsm.mapperSP0ID), 16),
 			"device-id": oFsm.deviceID})
@@ -1514,7 +1523,7 @@
 					"GemPortNetworkCtpConnectivityPointer": gemPortAttribs.multicastGemID,
 					"InterworkingOption":                   0, // Don't Care
 					"ServiceProfilePointer":                0, // Don't Care
-					"GalProfilePointer":                    galEthernetEID,
+					"GalProfilePointer":                    cmn.GalEthernetEID,
 				},
 			}
 			if oFsm.pUniTechProf.multicastConfiguredForOtherUniTps(ctx, oFsm.uniTpKey) {
@@ -1522,13 +1531,13 @@
 				continue
 			}
 			oFsm.mutexPLastTxMeInstance.Lock()
-			meInstance, err := oFsm.pOmciCC.sendCreateMulticastGemIWTPVar(context.TODO(), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout,
-				true, oFsm.pAdaptFsm.commChan, meParams)
+			meInstance, err := oFsm.pOmciCC.SendCreateMulticastGemIWTPVar(context.TODO(), oFsm.pDeviceHandler.GetOmciTimeout(),
+				true, oFsm.PAdaptFsm.CommChan, meParams)
 			if err != nil {
 				oFsm.mutexPLastTxMeInstance.Unlock()
-				logger.Errorw(ctx, "MulticastGemIWTPVar create failed, aborting uniPonAniConfigFsm!",
+				logger.Errorw(ctx, "MulticastGemIWTPVar create failed, aborting UniPonAniConfigFsm!",
 					log.Fields{"device-id": oFsm.deviceID})
-				_ = oFsm.pAdaptFsm.pFsm.Event(aniEvReset)
+				_ = oFsm.PAdaptFsm.PFsm.Event(aniEvReset)
 				return
 
 			}
@@ -1539,7 +1548,7 @@
 			if err != nil {
 				logger.Errorw(ctx, "MulticastGemIWTP create failed, aborting AniConfig FSM!",
 					log.Fields{"device-id": oFsm.deviceID, "GemIndex": gemIndex})
-				_ = oFsm.pAdaptFsm.pFsm.Event(aniEvReset)
+				_ = oFsm.PAdaptFsm.PFsm.Event(aniEvReset)
 				return
 			}
 			ipv4MulticastTable := make([]uint8, 12)
@@ -1548,9 +1557,9 @@
 			//Secondary Key
 			binary.BigEndian.PutUint16(ipv4MulticastTable[2:], 0)
 			// Multicast IP range start This is the 224.0.0.1 address
-			binary.BigEndian.PutUint32(ipv4MulticastTable[4:], IPToInt32(net.IPv4(224, 0, 0, 0)))
+			binary.BigEndian.PutUint32(ipv4MulticastTable[4:], cmn.IPToInt32(net.IPv4(224, 0, 0, 0)))
 			// MulticastIp range stop
-			binary.BigEndian.PutUint32(ipv4MulticastTable[8:], IPToInt32(net.IPv4(239, 255, 255, 255)))
+			binary.BigEndian.PutUint32(ipv4MulticastTable[8:], cmn.IPToInt32(net.IPv4(239, 255, 255, 255)))
 
 			meIPV4MCTableParams := me.ParamData{
 				EntityID: gemPortAttribs.multicastGemID,
@@ -1559,13 +1568,13 @@
 				},
 			}
 			oFsm.mutexPLastTxMeInstance.Lock()
-			meIPV4MCTableInstance, err := oFsm.pOmciCC.sendSetMulticastGemIWTPVar(context.TODO(), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout,
-				true, oFsm.pAdaptFsm.commChan, meIPV4MCTableParams)
+			meIPV4MCTableInstance, err := oFsm.pOmciCC.SendSetMulticastGemIWTPVar(context.TODO(), oFsm.pDeviceHandler.GetOmciTimeout(),
+				true, oFsm.PAdaptFsm.CommChan, meIPV4MCTableParams)
 			if err != nil {
 				oFsm.mutexPLastTxMeInstance.Unlock()
-				logger.Errorw(ctx, "MulticastGemIWTPVar set failed, aborting uniPonAniConfigFsm!",
+				logger.Errorw(ctx, "MulticastGemIWTPVar set failed, aborting UniPonAniConfigFsm!",
 					log.Fields{"device-id": oFsm.deviceID})
-				_ = oFsm.pAdaptFsm.pFsm.Event(aniEvReset)
+				_ = oFsm.PAdaptFsm.PFsm.Event(aniEvReset)
 				return
 			}
 			oFsm.pLastTxMeInstance = meIPV4MCTableInstance
@@ -1579,17 +1588,17 @@
 					"InterworkingOption":                   5,                        //fixed model:: G.998 .1pMapper
 					"ServiceProfilePointer":                oFsm.mapperSP0ID,
 					"InterworkingTerminationPointPointer":  0, //not used with .1PMapper Mac bridge
-					"GalProfilePointer":                    galEthernetEID,
+					"GalProfilePointer":                    cmn.GalEthernetEID,
 				},
 			}
 			oFsm.mutexPLastTxMeInstance.Lock()
-			meInstance, err := oFsm.pOmciCC.sendCreateGemIWTPVar(context.TODO(), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
-				oFsm.pAdaptFsm.commChan, meParams)
+			meInstance, err := oFsm.pOmciCC.SendCreateGemIWTPVar(context.TODO(), oFsm.pDeviceHandler.GetOmciTimeout(), true,
+				oFsm.PAdaptFsm.CommChan, meParams)
 			if err != nil {
 				oFsm.mutexPLastTxMeInstance.Unlock()
-				logger.Errorw(ctx, "GEMIWTPVar create failed, aborting uniPonAniConfigFsm!",
+				logger.Errorw(ctx, "GEMIWTPVar create failed, aborting UniPonAniConfigFsm!",
 					log.Fields{"device-id": oFsm.deviceID})
-				_ = oFsm.pAdaptFsm.pFsm.Event(aniEvReset)
+				_ = oFsm.PAdaptFsm.PFsm.Event(aniEvReset)
 				return
 			}
 			//accept also nil as (error) return value for writing to LastTx
@@ -1602,28 +1611,28 @@
 		if err != nil {
 			logger.Errorw(ctx, "GemTP create failed, aborting AniConfig FSM!",
 				log.Fields{"device-id": oFsm.deviceID, "GemIndex": gemIndex})
-			_ = oFsm.pAdaptFsm.pFsm.Event(aniEvReset)
+			_ = oFsm.PAdaptFsm.PFsm.Event(aniEvReset)
 			return
 		}
 	} //for all GemPort's of this T-Cont
 
 	// if Config has been done for all GemPort instances let the FSM proceed
 	logger.Debugw(ctx, "GemIwTp create loop finished", log.Fields{"device-id": oFsm.deviceID})
-	_ = oFsm.pAdaptFsm.pFsm.Event(aniEvRxGemiwsResp)
+	_ = oFsm.PAdaptFsm.PFsm.Event(aniEvRxGemiwsResp)
 }
 
-func (oFsm *uniPonAniConfigFsm) performSettingPQs(ctx context.Context) {
+func (oFsm *UniPonAniConfigFsm) performSettingPQs(ctx context.Context) {
 	//If upstream PQs were set before, then no need to set them again. Let state machine to proceed.
 	if oFsm.tcontSetBefore {
 		logger.Debugw(ctx, "No need to set PQs again.", log.Fields{
 			"device-id": oFsm.deviceID, "tcont": oFsm.alloc0ID,
-			"uni-id":         oFsm.pOnuUniPort.uniID,
+			"uni-id":         oFsm.pOnuUniPort.UniID,
 			"techProfile-id": oFsm.techProfileID})
-		go func(aPAFsm *AdapterFsm) {
-			if aPAFsm != nil && aPAFsm.pFsm != nil {
-				_ = aPAFsm.pFsm.Event(aniEvRxPrioqsResp)
+		go func(aPAFsm *cmn.AdapterFsm) {
+			if aPAFsm != nil && aPAFsm.PFsm != nil {
+				_ = aPAFsm.PFsm.Event(aniEvRxPrioqsResp)
 			}
-		}(oFsm.pAdaptFsm)
+		}(oFsm.PAdaptFsm)
 		return
 	}
 	const cu16StrictPrioWeight uint16 = 0xFFFF
@@ -1631,7 +1640,7 @@
 	loQueueMap := ordered_map.NewOrderedMap()
 	for _, gemPortAttribs := range oFsm.gemPortAttribsSlice {
 		if gemPortAttribs.isMulticast {
-			logger.Debugw(ctx, "uniPonAniConfigFsm Port is Multicast, ignoring PQs", log.Fields{
+			logger.Debugw(ctx, "UniPonAniConfigFsm Port is Multicast, ignoring PQs", log.Fields{
 				"device-id": oFsm.deviceID, "GemPort": gemPortAttribs.gemPortID,
 				"prioString": gemPortAttribs.pbitString})
 			continue
@@ -1647,29 +1656,29 @@
 	}
 
 	trafficSchedPtrSetSupported := false
-	loOnu2g := oFsm.pOnuDB.GetMe(me.Onu2GClassID, onu2gMeID)
+	loOnu2g := oFsm.pOnuDB.GetMe(me.Onu2GClassID, cmn.Onu2gMeID)
 	if loOnu2g == nil {
 		logger.Errorw(ctx, "onu2g is nil, cannot read qos configuration flexibility parameter",
 			log.Fields{"device-id": oFsm.deviceID})
-		_ = oFsm.pAdaptFsm.pFsm.Event(aniEvReset)
+		_ = oFsm.PAdaptFsm.PFsm.Event(aniEvReset)
 		return
 	}
 	returnVal := loOnu2g["QualityOfServiceQosConfigurationFlexibility"]
 	if returnVal != nil {
-		if qosCfgFlexParam, err := oFsm.pOnuDB.getUint16Attrib(returnVal); err == nil {
+		if qosCfgFlexParam, err := oFsm.pOnuDB.GetUint16Attrib(returnVal); err == nil {
 			trafficSchedPtrSetSupported = qosCfgFlexParam&bitTrafficSchedulerPtrSetPermitted == bitTrafficSchedulerPtrSetPermitted
 			logger.Debugw(ctx, "trafficSchedPtrSetSupported set",
 				log.Fields{"qosCfgFlexParam": qosCfgFlexParam, "trafficSchedPtrSetSupported": trafficSchedPtrSetSupported})
 		} else {
 			logger.Errorw(ctx, "Cannot extract qos configuration flexibility parameter",
 				log.Fields{"device-id": oFsm.deviceID})
-			_ = oFsm.pAdaptFsm.pFsm.Event(aniEvReset)
+			_ = oFsm.PAdaptFsm.PFsm.Event(aniEvReset)
 			return
 		}
 	} else {
 		logger.Errorw(ctx, "Cannot read qos configuration flexibility parameter",
 			log.Fields{"device-id": oFsm.deviceID})
-		_ = oFsm.pAdaptFsm.pFsm.Event(aniEvReset)
+		_ = oFsm.PAdaptFsm.PFsm.Event(aniEvReset)
 		return
 	}
 
@@ -1724,13 +1733,13 @@
 			meParams.Attributes["Weight"] = uint8(kv.Value.(uint16))
 		}
 		oFsm.mutexPLastTxMeInstance.Lock()
-		meInstance, err := oFsm.pOmciCC.sendSetPrioQueueVar(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
-			oFsm.pAdaptFsm.commChan, meParams)
+		meInstance, err := oFsm.pOmciCC.SendSetPrioQueueVar(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), true,
+			oFsm.PAdaptFsm.CommChan, meParams)
 		if err != nil {
 			oFsm.mutexPLastTxMeInstance.Unlock()
-			logger.Errorw(ctx, "PrioQueueVar set failed, aborting uniPonAniConfigFsm!",
+			logger.Errorw(ctx, "PrioQueueVar set failed, aborting UniPonAniConfigFsm!",
 				log.Fields{"device-id": oFsm.deviceID})
-			_ = oFsm.pAdaptFsm.pFsm.Event(aniEvReset)
+			_ = oFsm.PAdaptFsm.PFsm.Event(aniEvReset)
 			return
 		}
 		//accept also nil as (error) return value for writing to LastTx
@@ -1743,7 +1752,7 @@
 		if err != nil {
 			logger.Errorw(ctx, "PrioQueue set failed, aborting AniConfig FSM!",
 				log.Fields{"device-id": oFsm.deviceID, "QueueId": strconv.FormatInt(int64(queueIndex), 16)})
-			_ = oFsm.pAdaptFsm.pFsm.Event(aniEvReset)
+			_ = oFsm.PAdaptFsm.PFsm.Event(aniEvReset)
 			return
 		}
 
@@ -1756,16 +1765,16 @@
 
 	// if Config has been done for all PrioQueue instances let the FSM proceed
 	logger.Debugw(ctx, "PrioQueue set loop finished", log.Fields{"device-id": oFsm.deviceID})
-	_ = oFsm.pAdaptFsm.pFsm.Event(aniEvRxPrioqsResp)
+	_ = oFsm.PAdaptFsm.PFsm.Event(aniEvRxPrioqsResp)
 }
 
-func (oFsm *uniPonAniConfigFsm) waitforOmciResponse(ctx context.Context) error {
+func (oFsm *UniPonAniConfigFsm) waitforOmciResponse(ctx context.Context) error {
 	oFsm.mutexIsAwaitingResponse.Lock()
 	if oFsm.isCanceled {
 		// FSM already canceled before entering wait
-		logger.Debugw(ctx, "uniPonAniConfigFsm wait-for-multi-entity-response aborted (on enter)", log.Fields{"for device-id": oFsm.deviceID})
+		logger.Debugw(ctx, "UniPonAniConfigFsm wait-for-multi-entity-response aborted (on enter)", log.Fields{"for device-id": oFsm.deviceID})
 		oFsm.mutexIsAwaitingResponse.Unlock()
-		return fmt.Errorf(cErrWaitAborted)
+		return fmt.Errorf(cmn.CErrWaitAborted)
 	}
 	oFsm.isAwaitingResponse = true
 	oFsm.mutexIsAwaitingResponse.Unlock()
@@ -1781,28 +1790,28 @@
 		return fmt.Errorf("uniPonAniConfigFsm multi entity timeout %s", oFsm.deviceID)
 	case success := <-oFsm.omciMIdsResponseReceived:
 		if success {
-			logger.Debugw(ctx, "uniPonAniConfigFsm multi entity response received", log.Fields{"for device-id": oFsm.deviceID})
+			logger.Debugw(ctx, "UniPonAniConfigFsm multi entity response received", log.Fields{"for device-id": oFsm.deviceID})
 			oFsm.mutexIsAwaitingResponse.Lock()
 			oFsm.isAwaitingResponse = false
 			oFsm.mutexIsAwaitingResponse.Unlock()
 			return nil
 		}
 		// waiting was aborted (probably on external request)
-		logger.Debugw(ctx, "uniPonAniConfigFsm wait-for-multi-entity-response aborted", log.Fields{"for device-id": oFsm.deviceID})
+		logger.Debugw(ctx, "UniPonAniConfigFsm wait-for-multi-entity-response aborted", log.Fields{"for device-id": oFsm.deviceID})
 		oFsm.mutexIsAwaitingResponse.Lock()
 		oFsm.isAwaitingResponse = false
 		oFsm.mutexIsAwaitingResponse.Unlock()
-		return fmt.Errorf(cErrWaitAborted)
+		return fmt.Errorf(cmn.CErrWaitAborted)
 	}
 }
 
-func (oFsm *uniPonAniConfigFsm) setChanSet(flagValue bool) {
+func (oFsm *UniPonAniConfigFsm) setChanSet(flagValue bool) {
 	oFsm.mutexChanSet.Lock()
 	oFsm.chanSet = flagValue
 	oFsm.mutexChanSet.Unlock()
 }
 
-func (oFsm *uniPonAniConfigFsm) isChanSet() bool {
+func (oFsm *UniPonAniConfigFsm) isChanSet() bool {
 	oFsm.mutexChanSet.RLock()
 	flagValue := oFsm.chanSet
 	oFsm.mutexChanSet.RUnlock()
diff --git a/internal/pkg/onuadaptercore/omci_vlan_config.go b/internal/pkg/avcfg/omci_vlan_config.go
old mode 100644
new mode 100755
similarity index 84%
rename from internal/pkg/onuadaptercore/omci_vlan_config.go
rename to internal/pkg/avcfg/omci_vlan_config.go
index c6311e4..4a690f7
--- a/internal/pkg/onuadaptercore/omci_vlan_config.go
+++ b/internal/pkg/avcfg/omci_vlan_config.go
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package avcfg provides anig and vlan configuration functionality
+package avcfg
 
 import (
 	"context"
@@ -35,6 +35,8 @@
 	"github.com/opencord/omci-lib-go"
 	me "github.com/opencord/omci-lib-go/generated"
 	"github.com/opencord/voltha-lib-go/v7/pkg/log"
+	cmn "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/common"
+	"github.com/opencord/voltha-openonu-adapter-go/internal/pkg/devdb"
 	of "github.com/opencord/voltha-protos/v5/go/openflow_13"
 )
 
@@ -47,11 +49,11 @@
 )
 
 const (
-	//  internal offsets for requestEvent according to definition in onu_device_entry::OnuDeviceEvent
+	//  internal offsets for requestEvent according to definition in onu_device_entry::cmn.OnuDeviceEvent
 	cDeviceEventOffsetAddWithKvStore    = 0 //OmciVlanFilterAddDone - OmciVlanFilterAddDone cannot use because of lint
-	cDeviceEventOffsetAddNoKvStore      = OmciVlanFilterAddDoneNoKvStore - OmciVlanFilterAddDone
-	cDeviceEventOffsetRemoveWithKvStore = OmciVlanFilterRemDone - OmciVlanFilterAddDone
-	cDeviceEventOffsetRemoveNoKvStore   = OmciVlanFilterRemDoneNoKvStore - OmciVlanFilterAddDone
+	cDeviceEventOffsetAddNoKvStore      = cmn.OmciVlanFilterAddDoneNoKvStore - cmn.OmciVlanFilterAddDone
+	cDeviceEventOffsetRemoveWithKvStore = cmn.OmciVlanFilterRemDone - cmn.OmciVlanFilterAddDone
+	cDeviceEventOffsetRemoveNoKvStore   = cmn.OmciVlanFilterRemDoneNoKvStore - cmn.OmciVlanFilterAddDone
 )
 
 const (
@@ -88,82 +90,71 @@
 	cSetOutputTpidCopyDei uint32 = 4
 )
 
+// events of config UNI port VLAN FSM
 const (
-	// events of config UNI port VLAN FSM
-	vlanEvStart                   = "vlanEvStart"
-	vlanEvPrepareDone             = "vlanEvPrepareDone"
-	vlanEvWaitTechProf            = "vlanEvWaitTechProf"
-	vlanEvCancelOutstandingConfig = "vlanEvCancelOutstandingConfig"
-	vlanEvContinueConfig          = "vlanEvContinueConfig"
-	vlanEvStartConfig             = "vlanEvStartConfig"
-	vlanEvRxConfigVtfd            = "vlanEvRxConfigVtfd"
-	vlanEvRxConfigEvtocd          = "vlanEvRxConfigEvtocd"
-	vlanEvWaitTPIncr              = "vlanEvWaitTPIncr"
-	vlanEvIncrFlowConfig          = "vlanEvIncrFlowConfig"
-	vlanEvRenew                   = "vlanEvRenew"
-	vlanEvRemFlowConfig           = "vlanEvRemFlowConfig"
-	vlanEvRemFlowDone             = "vlanEvRemFlowDone"
-	vlanEvFlowDataRemoved         = "vlanEvFlowDataRemoved"
-	//vlanEvTimeoutSimple  = "vlanEvTimeoutSimple"
-	//vlanEvTimeoutMids    = "vlanEvTimeoutMids"
-	vlanEvReset             = "vlanEvReset"
-	vlanEvRestart           = "vlanEvRestart"
-	vlanEvSkipOmciConfig    = "vlanEvSkipOmciConfig"
-	vlanEvSkipIncFlowConfig = "vlanEvSkipIncFlowConfig"
+	VlanEvStart                   = "VlanEvStart"
+	VlanEvPrepareDone             = "VlanEvPrepareDone"
+	VlanEvWaitTechProf            = "VlanEvWaitTechProf"
+	VlanEvCancelOutstandingConfig = "VlanEvCancelOutstandingConfig"
+	VlanEvContinueConfig          = "VlanEvContinueConfig"
+	VlanEvStartConfig             = "VlanEvStartConfig"
+	VlanEvRxConfigVtfd            = "VlanEvRxConfigVtfd"
+	VlanEvRxConfigEvtocd          = "VlanEvRxConfigEvtocd"
+	VlanEvWaitTPIncr              = "VlanEvWaitTPIncr"
+	VlanEvIncrFlowConfig          = "VlanEvIncrFlowConfig"
+	VlanEvRenew                   = "VlanEvRenew"
+	VlanEvRemFlowConfig           = "VlanEvRemFlowConfig"
+	VlanEvRemFlowDone             = "VlanEvRemFlowDone"
+	VlanEvFlowDataRemoved         = "VlanEvFlowDataRemoved"
+	//VlanEvTimeoutSimple  = "VlanEvTimeoutSimple"
+	//VlanEvTimeoutMids    = "VlanEvTimeoutMids"
+	VlanEvReset             = "VlanEvReset"
+	VlanEvRestart           = "VlanEvRestart"
+	VlanEvSkipOmciConfig    = "VlanEvSkipOmciConfig"
+	VlanEvSkipIncFlowConfig = "VlanEvSkipIncFlowConfig"
 )
 
+// states of config UNI port VLAN FSM
 const (
-	// states of config UNI port VLAN FSM
-	vlanStDisabled        = "vlanStDisabled"
-	vlanStPreparing       = "vlanStPreparing"
-	vlanStStarting        = "vlanStStarting"
-	vlanStWaitingTechProf = "vlanStWaitingTechProf"
-	vlanStConfigVtfd      = "vlanStConfigVtfd"
-	vlanStConfigEvtocd    = "vlanStConfigEvtocd"
-	vlanStConfigDone      = "vlanStConfigDone"
-	vlanStIncrFlowWaitTP  = "vlanStIncrFlowWaitTP"
-	vlanStConfigIncrFlow  = "vlanStConfigIncrFlow"
-	vlanStRemoveFlow      = "vlanStRemoveFlow"
-	vlanStCleanupDone     = "vlanStCleanupDone"
-	vlanStResetting       = "vlanStResetting"
+	VlanStDisabled        = "VlanStDisabled"
+	VlanStPreparing       = "VlanStPreparing"
+	VlanStStarting        = "VlanStStarting"
+	VlanStWaitingTechProf = "VlanStWaitingTechProf"
+	VlanStConfigVtfd      = "VlanStConfigVtfd"
+	VlanStConfigEvtocd    = "VlanStConfigEvtocd"
+	VlanStConfigDone      = "VlanStConfigDone"
+	VlanStIncrFlowWaitTP  = "VlanStIncrFlowWaitTP"
+	VlanStConfigIncrFlow  = "VlanStConfigIncrFlow"
+	VlanStRemoveFlow      = "VlanStRemoveFlow"
+	VlanStCleanupDone     = "VlanStCleanupDone"
+	VlanStResetting       = "VlanStResetting"
 )
-const cVlanFsmIdleState = vlanStConfigDone       // state where no OMCI activity is done (for a longer time)
-const cVlanFsmConfiguredState = vlanStConfigDone // state that indicates that at least some valid user related VLAN configuration should exist
 
-type uniVlanRuleParams struct {
-	TpID         uint8  `json:"tp_id"`
-	MatchVid     uint32 `json:"match_vid"` //use uint32 types for allowing immediate bitshifting
-	MatchPcp     uint32 `json:"match_pcp"`
-	TagsToRemove uint32 `json:"tags_to_remove"`
-	SetVid       uint32 `json:"set_vid"`
-	SetPcp       uint32 `json:"set_pcp"`
-}
-
-type uniVlanFlowParams struct {
-	CookieSlice    []uint64               `json:"cookie_slice"`
-	VlanRuleParams uniVlanRuleParams      `json:"vlan_rule_params"`
-	Meter          *voltha.OfpMeterConfig `json:"flow_meter"`
-}
+// CVlanFsmIdleState - TODO: add comment
+const CVlanFsmIdleState = VlanStConfigDone // state where no OMCI activity is done (for a longer time)
+// CVlanFsmConfiguredState - TODO: add comment
+const CVlanFsmConfiguredState = VlanStConfigDone // state that indicates that at least some valid user related VLAN configuration should exist
 
 type uniRemoveVlanFlowParams struct {
 	isSuspendedOnAdd bool
 	removeChannel    chan bool
 	cookie           uint64 //just the last cookie valid for removal
-	vlanRuleParams   uniVlanRuleParams
+	vlanRuleParams   cmn.UniVlanRuleParams
 }
 
 //UniVlanConfigFsm defines the structure for the state machine for configuration of the VLAN related setting via OMCI
 //  builds upon 'VLAN rules' that are derived from multiple flows
 type UniVlanConfigFsm struct {
-	pDeviceHandler              *deviceHandler
+	pDeviceHandler              cmn.IdeviceHandler
+	pOnuDeviceEntry             cmn.IonuDeviceEntry
 	deviceID                    string
-	pOmciCC                     *omciCC
-	pOnuUniPort                 *onuUniPort
-	pUniTechProf                *onuUniTechProf
-	pOnuDB                      *onuDeviceDB
-	requestEvent                OnuDeviceEvent
+	pOmciCC                     *cmn.OmciCC
+	pOnuUniPort                 *cmn.OnuUniPort
+	pUniTechProf                *OnuUniTechProf
+	pOnuDB                      *devdb.OnuDeviceDB
+	requestEvent                cmn.OnuDeviceEvent
 	omciMIdsResponseReceived    chan bool //seperate channel needed for checking multiInstance OMCI message responses
-	pAdaptFsm                   *AdapterFsm
+	PAdaptFsm                   *cmn.AdapterFsm
 	acceptIncrementalEvtoOption bool
 	clearPersistency            bool
 	isCanceled                  bool
@@ -171,12 +162,12 @@
 	mutexIsAwaitingResponse     sync.RWMutex
 	mutexFlowParams             sync.RWMutex
 	chCookieDeleted             chan bool //channel to indicate that a specific cookie (related to the active rule) was deleted
-	actualUniVlanConfigRule     uniVlanRuleParams
+	actualUniVlanConfigRule     cmn.UniVlanRuleParams
 	actualUniVlanConfigMeter    *voltha.OfpMeterConfig
-	uniVlanFlowParamsSlice      []uniVlanFlowParams
+	uniVlanFlowParamsSlice      []cmn.UniVlanFlowParams
 	uniRemoveFlowsSlice         []uniRemoveVlanFlowParams
-	numUniFlows                 uint8 // expected number of flows should be less than 12
-	configuredUniFlow           uint8
+	NumUniFlows                 uint8 // expected number of flows should be less than 12
+	ConfiguredUniFlow           uint8
 	numRemoveFlows              uint8
 	numVlanFilterEntries        uint8
 	vlanFilterList              [cVtfdTableSize]uint16
@@ -196,84 +187,85 @@
 
 //NewUniVlanConfigFsm is the 'constructor' for the state machine to config the PON ANI ports
 //  of ONU UNI ports via OMCI
-func NewUniVlanConfigFsm(ctx context.Context, apDeviceHandler *deviceHandler, apDevOmciCC *omciCC, apUniPort *onuUniPort,
-	apUniTechProf *onuUniTechProf, apOnuDB *onuDeviceDB, aTechProfileID uint8,
-	aRequestEvent OnuDeviceEvent, aName string, aCommChannel chan Message, aAcceptIncrementalEvto bool,
+func NewUniVlanConfigFsm(ctx context.Context, apDeviceHandler cmn.IdeviceHandler, apOnuDeviceEntry cmn.IonuDeviceEntry, apDevOmciCC *cmn.OmciCC, apUniPort *cmn.OnuUniPort,
+	apUniTechProf *OnuUniTechProf, apOnuDB *devdb.OnuDeviceDB, aTechProfileID uint8,
+	aRequestEvent cmn.OnuDeviceEvent, aName string, aCommChannel chan cmn.Message, aAcceptIncrementalEvto bool,
 	aCookieSlice []uint64, aMatchVlan uint16, aSetVlan uint16, aSetPcp uint8, lastFlowToRec bool, aMeter *voltha.OfpMeterConfig) *UniVlanConfigFsm {
 	instFsm := &UniVlanConfigFsm{
 		pDeviceHandler:              apDeviceHandler,
-		deviceID:                    apDeviceHandler.deviceID,
+		pOnuDeviceEntry:             apOnuDeviceEntry,
+		deviceID:                    apDeviceHandler.GetDeviceID(),
 		pOmciCC:                     apDevOmciCC,
 		pOnuUniPort:                 apUniPort,
 		pUniTechProf:                apUniTechProf,
 		pOnuDB:                      apOnuDB,
 		requestEvent:                aRequestEvent,
 		acceptIncrementalEvtoOption: aAcceptIncrementalEvto,
-		numUniFlows:                 0,
-		configuredUniFlow:           0,
+		NumUniFlows:                 0,
+		ConfiguredUniFlow:           0,
 		numRemoveFlows:              0,
 		clearPersistency:            true,
 		lastFlowToReconcile:         lastFlowToRec,
 	}
 
-	instFsm.pAdaptFsm = NewAdapterFsm(aName, instFsm.deviceID, aCommChannel)
-	if instFsm.pAdaptFsm == nil {
-		logger.Errorw(ctx, "UniVlanConfigFsm's AdapterFsm could not be instantiated!!", log.Fields{
+	instFsm.PAdaptFsm = cmn.NewAdapterFsm(aName, instFsm.deviceID, aCommChannel)
+	if instFsm.PAdaptFsm == nil {
+		logger.Errorw(ctx, "UniVlanConfigFsm's cmn.AdapterFsm could not be instantiated!!", log.Fields{
 			"device-id": instFsm.deviceID})
 		return nil
 	}
-	instFsm.pAdaptFsm.pFsm = fsm.NewFSM(
-		vlanStDisabled,
+	instFsm.PAdaptFsm.PFsm = fsm.NewFSM(
+		VlanStDisabled,
 		fsm.Events{
-			{Name: vlanEvStart, Src: []string{vlanStDisabled}, Dst: vlanStPreparing},
-			{Name: vlanEvPrepareDone, Src: []string{vlanStPreparing}, Dst: vlanStStarting},
-			{Name: vlanEvWaitTechProf, Src: []string{vlanStStarting}, Dst: vlanStWaitingTechProf},
-			{Name: vlanEvCancelOutstandingConfig, Src: []string{vlanStWaitingTechProf}, Dst: vlanStConfigDone},
-			{Name: vlanEvContinueConfig, Src: []string{vlanStWaitingTechProf}, Dst: vlanStConfigVtfd},
-			{Name: vlanEvStartConfig, Src: []string{vlanStStarting}, Dst: vlanStConfigVtfd},
-			{Name: vlanEvRxConfigVtfd, Src: []string{vlanStConfigVtfd}, Dst: vlanStConfigEvtocd},
-			{Name: vlanEvRxConfigEvtocd, Src: []string{vlanStConfigEvtocd, vlanStConfigIncrFlow},
-				Dst: vlanStConfigDone},
-			{Name: vlanEvRenew, Src: []string{vlanStConfigDone}, Dst: vlanStStarting},
-			{Name: vlanEvWaitTPIncr, Src: []string{vlanStConfigDone}, Dst: vlanStIncrFlowWaitTP},
-			{Name: vlanEvIncrFlowConfig, Src: []string{vlanStConfigDone, vlanStIncrFlowWaitTP},
-				Dst: vlanStConfigIncrFlow},
-			{Name: vlanEvRemFlowConfig, Src: []string{vlanStConfigDone}, Dst: vlanStRemoveFlow},
-			{Name: vlanEvRemFlowDone, Src: []string{vlanStRemoveFlow}, Dst: vlanStCleanupDone},
-			{Name: vlanEvFlowDataRemoved, Src: []string{vlanStCleanupDone}, Dst: vlanStConfigDone},
+			{Name: VlanEvStart, Src: []string{VlanStDisabled}, Dst: VlanStPreparing},
+			{Name: VlanEvPrepareDone, Src: []string{VlanStPreparing}, Dst: VlanStStarting},
+			{Name: VlanEvWaitTechProf, Src: []string{VlanStStarting}, Dst: VlanStWaitingTechProf},
+			{Name: VlanEvCancelOutstandingConfig, Src: []string{VlanStWaitingTechProf}, Dst: VlanStConfigDone},
+			{Name: VlanEvContinueConfig, Src: []string{VlanStWaitingTechProf}, Dst: VlanStConfigVtfd},
+			{Name: VlanEvStartConfig, Src: []string{VlanStStarting}, Dst: VlanStConfigVtfd},
+			{Name: VlanEvRxConfigVtfd, Src: []string{VlanStConfigVtfd}, Dst: VlanStConfigEvtocd},
+			{Name: VlanEvRxConfigEvtocd, Src: []string{VlanStConfigEvtocd, VlanStConfigIncrFlow},
+				Dst: VlanStConfigDone},
+			{Name: VlanEvRenew, Src: []string{VlanStConfigDone}, Dst: VlanStStarting},
+			{Name: VlanEvWaitTPIncr, Src: []string{VlanStConfigDone}, Dst: VlanStIncrFlowWaitTP},
+			{Name: VlanEvIncrFlowConfig, Src: []string{VlanStConfigDone, VlanStIncrFlowWaitTP},
+				Dst: VlanStConfigIncrFlow},
+			{Name: VlanEvRemFlowConfig, Src: []string{VlanStConfigDone}, Dst: VlanStRemoveFlow},
+			{Name: VlanEvRemFlowDone, Src: []string{VlanStRemoveFlow}, Dst: VlanStCleanupDone},
+			{Name: VlanEvFlowDataRemoved, Src: []string{VlanStCleanupDone}, Dst: VlanStConfigDone},
 			/*
-				{Name: vlanEvTimeoutSimple, Src: []string{
-					vlanStCreatingDot1PMapper, vlanStCreatingMBPCD, vlanStSettingTconts, vlanStSettingDot1PMapper}, Dst: vlanStStarting},
-				{Name: vlanEvTimeoutMids, Src: []string{
-					vlanStCreatingGemNCTPs, vlanStCreatingGemIWs, vlanStSettingPQs}, Dst: vlanStStarting},
+				{Name: VlanEvTimeoutSimple, Src: []string{
+					VlanStCreatingDot1PMapper, VlanStCreatingMBPCD, VlanStSettingTconts, VlanStSettingDot1PMapper}, Dst: VlanStStarting},
+				{Name: VlanEvTimeoutMids, Src: []string{
+					VlanStCreatingGemNCTPs, VlanStCreatingGemIWs, VlanStSettingPQs}, Dst: VlanStStarting},
 			*/
-			// exceptional treatment for all states except vlanStResetting
-			{Name: vlanEvReset, Src: []string{vlanStStarting, vlanStWaitingTechProf,
-				vlanStConfigVtfd, vlanStConfigEvtocd, vlanStConfigDone, vlanStConfigIncrFlow,
-				vlanStRemoveFlow, vlanStCleanupDone},
-				Dst: vlanStResetting},
+			// exceptional treatment for all states except VlanStResetting
+			{Name: VlanEvReset, Src: []string{VlanStStarting, VlanStWaitingTechProf,
+				VlanStConfigVtfd, VlanStConfigEvtocd, VlanStConfigDone, VlanStConfigIncrFlow,
+				VlanStRemoveFlow, VlanStCleanupDone},
+				Dst: VlanStResetting},
 			// the only way to get to resource-cleared disabled state again is via "resseting"
-			{Name: vlanEvRestart, Src: []string{vlanStResetting}, Dst: vlanStDisabled},
+			{Name: VlanEvRestart, Src: []string{VlanStResetting}, Dst: VlanStDisabled},
 			// transitions for reconcile handling according to VOL-3834
-			{Name: vlanEvSkipOmciConfig, Src: []string{vlanStPreparing}, Dst: vlanStConfigDone},
-			{Name: vlanEvSkipOmciConfig, Src: []string{vlanStConfigDone}, Dst: vlanStConfigIncrFlow},
-			{Name: vlanEvSkipIncFlowConfig, Src: []string{vlanStConfigIncrFlow}, Dst: vlanStConfigDone},
+			{Name: VlanEvSkipOmciConfig, Src: []string{VlanStPreparing}, Dst: VlanStConfigDone},
+			{Name: VlanEvSkipOmciConfig, Src: []string{VlanStConfigDone}, Dst: VlanStConfigIncrFlow},
+			{Name: VlanEvSkipIncFlowConfig, Src: []string{VlanStConfigIncrFlow}, Dst: VlanStConfigDone},
 		},
 		fsm.Callbacks{
-			"enter_state":                   func(e *fsm.Event) { instFsm.pAdaptFsm.logFsmStateChange(ctx, e) },
-			"enter_" + vlanStPreparing:      func(e *fsm.Event) { instFsm.enterPreparing(ctx, e) },
-			"enter_" + vlanStStarting:       func(e *fsm.Event) { instFsm.enterConfigStarting(ctx, e) },
-			"enter_" + vlanStConfigVtfd:     func(e *fsm.Event) { instFsm.enterConfigVtfd(ctx, e) },
-			"enter_" + vlanStConfigEvtocd:   func(e *fsm.Event) { instFsm.enterConfigEvtocd(ctx, e) },
-			"enter_" + vlanStConfigDone:     func(e *fsm.Event) { instFsm.enterVlanConfigDone(ctx, e) },
-			"enter_" + vlanStConfigIncrFlow: func(e *fsm.Event) { instFsm.enterConfigIncrFlow(ctx, e) },
-			"enter_" + vlanStRemoveFlow:     func(e *fsm.Event) { instFsm.enterRemoveFlow(ctx, e) },
-			"enter_" + vlanStCleanupDone:    func(e *fsm.Event) { instFsm.enterVlanCleanupDone(ctx, e) },
-			"enter_" + vlanStResetting:      func(e *fsm.Event) { instFsm.enterResetting(ctx, e) },
-			"enter_" + vlanStDisabled:       func(e *fsm.Event) { instFsm.enterDisabled(ctx, e) },
+			"enter_state":                   func(e *fsm.Event) { instFsm.PAdaptFsm.LogFsmStateChange(ctx, e) },
+			"enter_" + VlanStPreparing:      func(e *fsm.Event) { instFsm.enterPreparing(ctx, e) },
+			"enter_" + VlanStStarting:       func(e *fsm.Event) { instFsm.enterConfigStarting(ctx, e) },
+			"enter_" + VlanStConfigVtfd:     func(e *fsm.Event) { instFsm.enterConfigVtfd(ctx, e) },
+			"enter_" + VlanStConfigEvtocd:   func(e *fsm.Event) { instFsm.enterConfigEvtocd(ctx, e) },
+			"enter_" + VlanStConfigDone:     func(e *fsm.Event) { instFsm.enterVlanConfigDone(ctx, e) },
+			"enter_" + VlanStConfigIncrFlow: func(e *fsm.Event) { instFsm.enterConfigIncrFlow(ctx, e) },
+			"enter_" + VlanStRemoveFlow:     func(e *fsm.Event) { instFsm.enterRemoveFlow(ctx, e) },
+			"enter_" + VlanStCleanupDone:    func(e *fsm.Event) { instFsm.enterVlanCleanupDone(ctx, e) },
+			"enter_" + VlanStResetting:      func(e *fsm.Event) { instFsm.enterResetting(ctx, e) },
+			"enter_" + VlanStDisabled:       func(e *fsm.Event) { instFsm.enterDisabled(ctx, e) },
 		},
 	)
-	if instFsm.pAdaptFsm.pFsm == nil {
+	if instFsm.PAdaptFsm.PFsm == nil {
 		logger.Errorw(ctx, "UniVlanConfigFsm's Base FSM could not be instantiated!!", log.Fields{
 			"device-id": instFsm.deviceID})
 		return nil
@@ -289,7 +281,7 @@
 //initUniFlowParams is a simplified form of SetUniFlowParams() used for first flow parameters configuration
 func (oFsm *UniVlanConfigFsm) initUniFlowParams(ctx context.Context, aTpID uint8, aCookieSlice []uint64,
 	aMatchVlan uint16, aSetVlan uint16, aSetPcp uint8, aMeter *voltha.OfpMeterConfig) error {
-	loRuleParams := uniVlanRuleParams{
+	loRuleParams := cmn.UniVlanRuleParams{
 		TpID:     aTpID,
 		MatchVid: uint32(aMatchVlan),
 		SetVid:   uint32(aSetVlan),
@@ -323,7 +315,7 @@
 		}
 	}
 
-	loFlowParams := uniVlanFlowParams{VlanRuleParams: loRuleParams}
+	loFlowParams := cmn.UniVlanFlowParams{VlanRuleParams: loRuleParams}
 	loFlowParams.CookieSlice = make([]uint64, 0)
 	loFlowParams.CookieSlice = append(loFlowParams.CookieSlice, aCookieSlice...)
 	if aMeter != nil {
@@ -331,23 +323,23 @@
 	}
 
 	//no mutex protection is required for initial access and adding the first flow is always possible
-	oFsm.uniVlanFlowParamsSlice = make([]uniVlanFlowParams, 0)
+	oFsm.uniVlanFlowParamsSlice = make([]cmn.UniVlanFlowParams, 0)
 	oFsm.uniVlanFlowParamsSlice = append(oFsm.uniVlanFlowParamsSlice, loFlowParams)
 	logger.Debugw(ctx, "first UniVlanConfigFsm flow added", log.Fields{
 		"Cookies":   oFsm.uniVlanFlowParamsSlice[0].CookieSlice,
 		"MatchVid":  strconv.FormatInt(int64(loRuleParams.MatchVid), 16),
 		"SetVid":    strconv.FormatInt(int64(loRuleParams.SetVid), 16),
 		"SetPcp":    loRuleParams.SetPcp,
-		"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID})
+		"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID})
 
-	if oFsm.pDeviceHandler.isSkipOnuConfigReconciling() {
+	if oFsm.pDeviceHandler.IsSkipOnuConfigReconciling() {
 		oFsm.reconcileVlanFilterList(ctx, uint16(loRuleParams.SetVid))
 	}
-	oFsm.numUniFlows = 1
+	oFsm.NumUniFlows = 1
 	oFsm.uniRemoveFlowsSlice = make([]uniRemoveVlanFlowParams, 0) //initially nothing to remove
 
 	//permanently store flow config for reconcile case
-	if err := oFsm.pDeviceHandler.storePersUniFlowConfig(ctx, oFsm.pOnuUniPort.uniID,
+	if err := oFsm.pDeviceHandler.StorePersUniFlowConfig(ctx, oFsm.pOnuUniPort.UniID,
 		&oFsm.uniVlanFlowParamsSlice, true); err != nil {
 		logger.Errorw(ctx, err.Error(), log.Fields{"device-id": oFsm.deviceID})
 		return err
@@ -372,11 +364,11 @@
 	}
 
 	// in any case (even if it might be automatically requested by above cancellation of waiting) ensure resetting the FSM
-	pAdaptFsm := oFsm.pAdaptFsm
-	if pAdaptFsm != nil {
-		if fsmErr := pAdaptFsm.pFsm.Event(vlanEvReset); fsmErr != nil {
+	PAdaptFsm := oFsm.PAdaptFsm
+	if PAdaptFsm != nil {
+		if fsmErr := PAdaptFsm.PFsm.Event(VlanEvReset); fsmErr != nil {
 			logger.Errorw(ctx, "reset-event failed in UniVlanConfigFsm!",
-				log.Fields{"fsmState": oFsm.pAdaptFsm.pFsm.Current(), "error": fsmErr, "device-id": oFsm.deviceID})
+				log.Fields{"fsmState": oFsm.PAdaptFsm.PFsm.Current(), "error": fsmErr, "device-id": oFsm.deviceID})
 		}
 	}
 }
@@ -404,7 +396,7 @@
 // nolint: gocyclo
 func (oFsm *UniVlanConfigFsm) SetUniFlowParams(ctx context.Context, aTpID uint8, aCookieSlice []uint64,
 	aMatchVlan uint16, aSetVlan uint16, aSetPcp uint8, lastFlowToReconcile bool, aMeter *voltha.OfpMeterConfig) error {
-	loRuleParams := uniVlanRuleParams{
+	loRuleParams := cmn.UniVlanRuleParams{
 		TpID:     aTpID,
 		MatchVid: uint32(aMatchVlan),
 		SetVid:   uint32(aSetVlan),
@@ -482,7 +474,7 @@
 				"MatchVid":  strconv.FormatInt(int64(loRuleParams.MatchVid), 16),
 				"SetVid":    strconv.FormatInt(int64(loRuleParams.SetVid), 16),
 				"SetPcp":    loRuleParams.SetPcp,
-				"device-id": oFsm.deviceID, " uni-id": oFsm.pOnuUniPort.uniID})
+				"device-id": oFsm.deviceID, " uni-id": oFsm.pOnuUniPort.UniID})
 			var cookieMatch bool
 			for _, newCookie := range aCookieSlice { // for all cookies available in the arguments
 				cookieMatch = false
@@ -538,8 +530,8 @@
 	kvStoreWrite := false //default setting is to not write to kvStore immediately - will be done on FSM execution finally
 	if requestAppendRule {
 		oFsm.mutexFlowParams.Lock()
-		if oFsm.numUniFlows < cMaxAllowedFlows {
-			loFlowParams := uniVlanFlowParams{VlanRuleParams: loRuleParams}
+		if oFsm.NumUniFlows < cMaxAllowedFlows {
+			loFlowParams := cmn.UniVlanFlowParams{VlanRuleParams: loRuleParams}
 			loFlowParams.CookieSlice = make([]uint64, 0)
 			loFlowParams.CookieSlice = append(loFlowParams.CookieSlice, aCookieSlice...)
 			if aMeter != nil {
@@ -547,28 +539,28 @@
 			}
 			oFsm.uniVlanFlowParamsSlice = append(oFsm.uniVlanFlowParamsSlice, loFlowParams)
 			logger.Debugw(ctx, "UniVlanConfigFsm flow add", log.Fields{
-				"Cookies":  oFsm.uniVlanFlowParamsSlice[oFsm.numUniFlows].CookieSlice,
+				"Cookies":  oFsm.uniVlanFlowParamsSlice[oFsm.NumUniFlows].CookieSlice,
 				"MatchVid": strconv.FormatInt(int64(loRuleParams.MatchVid), 16),
 				"SetVid":   strconv.FormatInt(int64(loRuleParams.SetVid), 16),
-				"SetPcp":   loRuleParams.SetPcp, "numberofFlows": oFsm.numUniFlows + 1,
-				"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID})
+				"SetPcp":   loRuleParams.SetPcp, "numberofFlows": oFsm.NumUniFlows + 1,
+				"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID})
 
-			if oFsm.pDeviceHandler.isSkipOnuConfigReconciling() {
+			if oFsm.pDeviceHandler.IsSkipOnuConfigReconciling() {
 				oFsm.reconcileVlanFilterList(ctx, uint16(loRuleParams.SetVid))
 			}
-			oFsm.numUniFlows++
-			pConfigVlanStateBaseFsm := oFsm.pAdaptFsm.pFsm
+			oFsm.NumUniFlows++
+			pConfigVlanStateBaseFsm := oFsm.PAdaptFsm.PFsm
 
-			if oFsm.pDeviceHandler.isSkipOnuConfigReconciling() {
+			if oFsm.pDeviceHandler.IsSkipOnuConfigReconciling() {
 				logger.Debugw(ctx, "reconciling - skip omci-config of additional vlan rule",
-					log.Fields{"fsmState": oFsm.pAdaptFsm.pFsm.Current(), "device-id": oFsm.deviceID})
+					log.Fields{"fsmState": oFsm.PAdaptFsm.PFsm.Current(), "device-id": oFsm.deviceID})
 				//attention: take care to release the mutexFlowParams when calling the FSM directly -
 				//  synchronous FSM 'event/state' functions may rely on this mutex
 				oFsm.mutexFlowParams.Unlock()
-				if pConfigVlanStateBaseFsm.Is(vlanStConfigDone) {
-					if fsmErr := pConfigVlanStateBaseFsm.Event(vlanEvSkipOmciConfig); fsmErr != nil {
+				if pConfigVlanStateBaseFsm.Is(VlanStConfigDone) {
+					if fsmErr := pConfigVlanStateBaseFsm.Event(VlanEvSkipOmciConfig); fsmErr != nil {
 						logger.Errorw(ctx, "error in FsmEvent handling UniVlanConfigFsm!",
-							log.Fields{"fsmState": oFsm.pAdaptFsm.pFsm.Current(), "error": fsmErr, "device-id": oFsm.deviceID})
+							log.Fields{"fsmState": oFsm.PAdaptFsm.PFsm.Current(), "error": fsmErr, "device-id": oFsm.deviceID})
 					}
 				}
 				return nil
@@ -578,31 +570,31 @@
 			//  but that is getting quite complicated - maybe a future optimization in case it should prove reasonable
 			// anyway the precondition here is that the FSM checks for rules to delete first and adds new rules afterwards
 
-			if pConfigVlanStateBaseFsm.Is(vlanStConfigDone) {
+			if pConfigVlanStateBaseFsm.Is(VlanStConfigDone) {
 				//have to re-trigger the FSM to proceed with outstanding incremental flow configuration
-				if oFsm.configuredUniFlow == 0 {
+				if oFsm.ConfiguredUniFlow == 0 {
 					// this is a restart with a complete new flow, we can re-use the initial flow config control
 					// including the check, if the related techProfile is (still) available (probably also removed in between)
 					//attention: take care to release the mutexFlowParams when calling the FSM directly -
 					//  synchronous FSM 'event/state' functions may rely on this mutex
 					oFsm.mutexFlowParams.Unlock()
-					if fsmErr := pConfigVlanStateBaseFsm.Event(vlanEvRenew); fsmErr != nil {
+					if fsmErr := pConfigVlanStateBaseFsm.Event(VlanEvRenew); fsmErr != nil {
 						logger.Errorw(ctx, "error in FsmEvent handling UniVlanConfigFsm!",
 							log.Fields{"fsmState": pConfigVlanStateBaseFsm.Current(), "error": fsmErr, "device-id": oFsm.deviceID})
 					}
 				} else {
 					//some further flows are to be configured
 					//store the actual rule that shall be worked upon in the following transient states
-					if len(oFsm.uniVlanFlowParamsSlice) < int(oFsm.configuredUniFlow) {
+					if len(oFsm.uniVlanFlowParamsSlice) < int(oFsm.ConfiguredUniFlow) {
 						//check introduced after having observed some panic here
 						logger.Errorw(ctx, "error in FsmEvent handling UniVlanConfigFsm - inconsistent counter",
-							log.Fields{"configuredUniFlow": oFsm.configuredUniFlow,
+							log.Fields{"ConfiguredUniFlow": oFsm.ConfiguredUniFlow,
 								"sliceLen": len(oFsm.uniVlanFlowParamsSlice), "device-id": oFsm.deviceID})
 						oFsm.mutexFlowParams.Unlock()
 						return fmt.Errorf("abort UniVlanConfigFsm on add due to internal counter mismatch %s", oFsm.deviceID)
 					}
-					oFsm.actualUniVlanConfigRule = oFsm.uniVlanFlowParamsSlice[oFsm.configuredUniFlow].VlanRuleParams
-					oFsm.actualUniVlanConfigMeter = oFsm.uniVlanFlowParamsSlice[oFsm.configuredUniFlow].Meter
+					oFsm.actualUniVlanConfigRule = oFsm.uniVlanFlowParamsSlice[oFsm.ConfiguredUniFlow].VlanRuleParams
+					oFsm.actualUniVlanConfigMeter = oFsm.uniVlanFlowParamsSlice[oFsm.ConfiguredUniFlow].Meter
 					//tpId of the next rule to be configured
 					tpID := oFsm.actualUniVlanConfigRule.TpID
 					oFsm.TpIDWaitingFor = tpID
@@ -612,18 +604,18 @@
 					//  but it must be released already before calling getTechProfileDone() as it may already be locked
 					//  by the techProfile processing call to VlanFsm.IsFlowRemovePending() (see VOL-4207)
 					oFsm.mutexFlowParams.Unlock()
-					loTechProfDone := oFsm.pUniTechProf.getTechProfileDone(ctx, oFsm.pOnuUniPort.uniID, tpID)
+					loTechProfDone := oFsm.pUniTechProf.getTechProfileDone(ctx, oFsm.pOnuUniPort.UniID, tpID)
 					logger.Debugw(ctx, "UniVlanConfigFsm - incremental config request (on setConfig)", log.Fields{
-						"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID,
+						"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID,
 						"set-Vlan": loSetVlan, "tp-id": tpID, "ProfDone": loTechProfDone})
 
 					var fsmErr error
 					if loTechProfDone {
 						// let the vlan processing continue with next rule
-						fsmErr = pConfigVlanStateBaseFsm.Event(vlanEvIncrFlowConfig)
+						fsmErr = pConfigVlanStateBaseFsm.Event(VlanEvIncrFlowConfig)
 					} else {
 						// set to waiting for Techprofile
-						fsmErr = pConfigVlanStateBaseFsm.Event(vlanEvWaitTPIncr)
+						fsmErr = pConfigVlanStateBaseFsm.Event(VlanEvWaitTPIncr)
 					}
 					if fsmErr != nil {
 						logger.Errorw(ctx, "error in FsmEvent handling UniVlanConfigFsm!",
@@ -637,7 +629,7 @@
 			}
 		} else {
 			logger.Errorw(ctx, "UniVlanConfigFsm flow limit exceeded", log.Fields{
-				"device-id": oFsm.deviceID, "flow-number": oFsm.numUniFlows})
+				"device-id": oFsm.deviceID, "flow-number": oFsm.NumUniFlows})
 			oFsm.mutexFlowParams.Unlock()
 			return fmt.Errorf(" UniVlanConfigFsm flow limit exceeded %s", oFsm.deviceID)
 		}
@@ -645,7 +637,7 @@
 		// no activity within the FSM for OMCI processing, the deviceReason may be updated immediately
 		kvStoreWrite = true // ensure actual data write to kvStore immediately (no FSM activity)
 		oFsm.mutexFlowParams.RLock()
-		if oFsm.numUniFlows == oFsm.configuredUniFlow {
+		if oFsm.NumUniFlows == oFsm.ConfiguredUniFlow {
 			//all requested rules really have been configured
 			// state transition notification is checked in deviceHandler
 			oFsm.mutexFlowParams.RUnlock()
@@ -653,15 +645,15 @@
 				//also the related TechProfile was already configured
 				logger.Debugw(ctx, "UniVlanConfigFsm rule already set - send immediate add-success event for reason update", log.Fields{
 					"device-id": oFsm.deviceID})
-				// success indication without the need to write to kvStore (done already below with updated data from storePersUniFlowConfig())
-				go oFsm.pDeviceHandler.deviceProcStatusUpdate(ctx, OnuDeviceEvent(oFsm.requestEvent+cDeviceEventOffsetAddNoKvStore))
+				// success indication without the need to write to kvStore (done already below with updated data from StorePersUniFlowConfig())
+				go oFsm.pDeviceHandler.DeviceProcStatusUpdate(ctx, cmn.OnuDeviceEvent(oFsm.requestEvent+cDeviceEventOffsetAddNoKvStore))
 			}
 		} else {
 			//  avoid device reason update as the rule config connected to this flow may still be in progress
 			//  and the device reason should only be updated on success of rule config
 			logger.Debugw(ctx, "UniVlanConfigFsm rule already set but configuration ongoing, suppress early add-success event for reason update",
 				log.Fields{"device-id": oFsm.deviceID,
-					"NumberofRules": oFsm.numUniFlows, "Configured rules": oFsm.configuredUniFlow})
+					"NumberofRules": oFsm.NumUniFlows, "Configured rules": oFsm.ConfiguredUniFlow})
 			oFsm.mutexFlowParams.RUnlock()
 		}
 	}
@@ -669,7 +661,7 @@
 	if flowCookieModify { // some change was done to the flow entries
 		//permanently store flow config for reconcile case
 		oFsm.mutexFlowParams.RLock()
-		if err := oFsm.pDeviceHandler.storePersUniFlowConfig(ctx, oFsm.pOnuUniPort.uniID,
+		if err := oFsm.pDeviceHandler.StorePersUniFlowConfig(ctx, oFsm.pOnuUniPort.UniID,
 			&oFsm.uniVlanFlowParamsSlice, kvStoreWrite); err != nil {
 			oFsm.mutexFlowParams.RUnlock()
 			logger.Errorw(ctx, err.Error(), log.Fields{"device-id": oFsm.deviceID})
@@ -761,7 +753,7 @@
 }
 
 //returns flowModified, RuleAppendRequest
-func (oFsm *UniVlanConfigFsm) reviseFlowConstellation(ctx context.Context, aCookie uint64, aUniVlanRuleParams uniVlanRuleParams) (bool, bool) {
+func (oFsm *UniVlanConfigFsm) reviseFlowConstellation(ctx context.Context, aCookie uint64, aUniVlanRuleParams cmn.UniVlanRuleParams) (bool, bool) {
 	flowEntryMatch := false
 	oFsm.mutexFlowParams.Lock()
 	defer oFsm.mutexFlowParams.Unlock()
@@ -828,8 +820,8 @@
 					// no activity within the FSM for OMCI processing, the deviceReason may be updated immediately
 					// state transition notification is checked in deviceHandler
 					if oFsm.pDeviceHandler != nil {
-						// success indication without the need to write to kvStore (done already below with updated data from storePersUniFlowConfig())
-						go oFsm.pDeviceHandler.deviceProcStatusUpdate(ctx, OnuDeviceEvent(oFsm.requestEvent+cDeviceEventOffsetRemoveNoKvStore))
+						// success indication without the need to write to kvStore (done already below with updated data from StorePersUniFlowConfig())
+						go oFsm.pDeviceHandler.DeviceProcStatusUpdate(ctx, cmn.OnuDeviceEvent(oFsm.requestEvent+cDeviceEventOffsetRemoveNoKvStore))
 					}
 					logger.Debugw(ctx, "UniVlanConfigFsm flow removal - rule persists with still valid cookies", log.Fields{
 						"device-id": oFsm.deviceID, "cookies": oFsm.uniVlanFlowParamsSlice[flow].CookieSlice})
@@ -843,7 +835,7 @@
 					}
 					//permanently store the modified flow config for reconcile case and immediately write to KvStore
 					if oFsm.pDeviceHandler != nil {
-						if err := oFsm.pDeviceHandler.storePersUniFlowConfig(ctx, oFsm.pOnuUniPort.uniID,
+						if err := oFsm.pDeviceHandler.StorePersUniFlowConfig(ctx, oFsm.pOnuUniPort.UniID,
 							&oFsm.uniVlanFlowParamsSlice, true); err != nil {
 							logger.Errorw(ctx, err.Error(), log.Fields{"device-id": oFsm.deviceID})
 							return err
@@ -862,7 +854,7 @@
 		// state transition notification is checked in deviceHandler
 		if oFsm.pDeviceHandler != nil {
 			// success indication without the need to write to kvStore (no change)
-			go oFsm.pDeviceHandler.deviceProcStatusUpdate(ctx, OnuDeviceEvent(oFsm.requestEvent+cDeviceEventOffsetRemoveNoKvStore))
+			go oFsm.pDeviceHandler.DeviceProcStatusUpdate(ctx, cmn.OnuDeviceEvent(oFsm.requestEvent+cDeviceEventOffsetRemoveNoKvStore))
 		}
 		return nil
 	} //unknown cookie
@@ -873,8 +865,8 @@
 // removeRuleComplete initiates the complete removal of a VLAN rule (from single cookie element)
 // requires mutexFlowParams to be locked at call
 func (oFsm *UniVlanConfigFsm) removeRuleComplete(ctx context.Context,
-	aUniFlowParams uniVlanFlowParams, aCookie uint64) bool {
-	pConfigVlanStateBaseFsm := oFsm.pAdaptFsm.pFsm
+	aUniFlowParams cmn.UniVlanFlowParams, aCookie uint64) bool {
+	pConfigVlanStateBaseFsm := oFsm.PAdaptFsm.PFsm
 	var cancelPendingConfig bool = false
 	var loRemoveParams uniRemoveVlanFlowParams = uniRemoveVlanFlowParams{}
 	logger.Debugw(ctx, "UniVlanConfigFsm flow removal - full flow removal", log.Fields{
@@ -883,7 +875,7 @@
 	//  as the one still waiting in the FSM as toAdd but waiting for TechProfileConfig
 	//  so we have to check if we have to abort the outstanding AddRequest and regard the current DelRequest as done
 	//  if the Fsm is in some other transient (config) state, we will reach the DelRequest later and correctly process it then
-	if pConfigVlanStateBaseFsm.Is(vlanStWaitingTechProf) {
+	if pConfigVlanStateBaseFsm.Is(VlanStWaitingTechProf) {
 		logger.Debugw(ctx, "UniVlanConfigFsm was waiting for TechProf config with add-request, just aborting the outstanding add",
 			log.Fields{"device-id": oFsm.deviceID})
 		cancelPendingConfig = true
@@ -907,7 +899,7 @@
 			logger.Debugw(ctx, "UniVlanConfigFsm flow removal requested - set TechProfile to-delete", log.Fields{
 				"device-id": oFsm.deviceID})
 			if oFsm.pUniTechProf != nil {
-				oFsm.pUniTechProf.setProfileToDelete(oFsm.pOnuUniPort.uniID, usedTpID, true)
+				oFsm.pUniTechProf.SetProfileToDelete(oFsm.pOnuUniPort.UniID, usedTpID, true)
 			}
 			oFsm.mutexFlowParams.Lock()
 		}
@@ -919,12 +911,12 @@
 	//trigger the FSM to remove the relevant rule
 	if cancelPendingConfig {
 		//as the uniFlow parameters are already stored (for add) but no explicit removal is done anymore
-		//  the paramSlice has to be updated with rule-removal, which also then updates numUniFlows
+		//  the paramSlice has to be updated with rule-removal, which also then updates NumUniFlows
 		//call from 'non-configured' state of the rules
 		if err := oFsm.removeFlowFromParamsSlice(ctx, aCookie, false); err != nil {
 			//something quite inconsistent detected, perhaps just try to recover with FSM reset
 			oFsm.mutexFlowParams.Unlock()
-			if fsmErr := pConfigVlanStateBaseFsm.Event(vlanEvReset); fsmErr != nil {
+			if fsmErr := pConfigVlanStateBaseFsm.Event(VlanEvReset); fsmErr != nil {
 				logger.Errorw(ctx, "error in FsmEvent handling UniVlanConfigFsm!",
 					log.Fields{"fsmState": pConfigVlanStateBaseFsm.Current(), "error": fsmErr, "device-id": oFsm.deviceID})
 			}
@@ -935,23 +927,23 @@
 		//attention: take care to release and re-take the mutexFlowParams when calling the FSM directly -
 		//  synchronous FSM 'event/state' functions may rely on this mutex
 		oFsm.mutexFlowParams.Unlock()
-		if fsmErr := pConfigVlanStateBaseFsm.Event(vlanEvCancelOutstandingConfig); fsmErr != nil {
+		if fsmErr := pConfigVlanStateBaseFsm.Event(VlanEvCancelOutstandingConfig); fsmErr != nil {
 			logger.Errorw(ctx, "error in FsmEvent handling UniVlanConfigFsm!",
 				log.Fields{"fsmState": pConfigVlanStateBaseFsm.Current(), "error": fsmErr, "device-id": oFsm.deviceID})
 		}
 		oFsm.mutexFlowParams.Lock()
 		return true
 	}
-	if pConfigVlanStateBaseFsm.Is(vlanStConfigDone) {
+	if pConfigVlanStateBaseFsm.Is(VlanStConfigDone) {
 		logger.Debugw(ctx, "UniVlanConfigFsm rule removal request", log.Fields{
-			"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID,
+			"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID,
 			"tp-id":    loRemoveParams.vlanRuleParams.TpID,
 			"set-Vlan": loRemoveParams.vlanRuleParams.SetVid})
 		//have to re-trigger the FSM to proceed with outstanding incremental flow configuration
 		//attention: take care to release and re-take the mutexFlowParams when calling the FSM directly -
 		//  synchronous FSM 'event/state' functions may rely on this mutex
 		oFsm.mutexFlowParams.Unlock()
-		if fsmErr := pConfigVlanStateBaseFsm.Event(vlanEvRemFlowConfig); fsmErr != nil {
+		if fsmErr := pConfigVlanStateBaseFsm.Event(VlanEvRemFlowConfig); fsmErr != nil {
 			logger.Errorw(ctx, "error in FsmEvent handling UniVlanConfigFsm!",
 				log.Fields{"fsmState": pConfigVlanStateBaseFsm.Current(), "error": fsmErr, "device-id": oFsm.deviceID})
 		}
@@ -999,17 +991,17 @@
 			//remove the actual element from the addVlanFlow slice
 			// oFsm.uniVlanFlowParamsSlice[flow].CookieSlice = nil //automatically done by garbage collector
 			if len(oFsm.uniVlanFlowParamsSlice) <= 1 {
-				oFsm.numUniFlows = 0              //no more flows
-				oFsm.configuredUniFlow = 0        //no more flows configured
+				oFsm.NumUniFlows = 0              //no more flows
+				oFsm.ConfiguredUniFlow = 0        //no more flows configured
 				oFsm.uniVlanFlowParamsSlice = nil //reset the slice
 				//at this point it is evident that no flow anymore refers to a still possibly active Techprofile
 				//request that this profile gets deleted before a new flow add is allowed
 				logger.Debugw(ctx, "UniVlanConfigFsm flow removal from ParamsSlice - no more flows", log.Fields{
 					"device-id": oFsm.deviceID})
 			} else {
-				oFsm.numUniFlows--
-				if aWasConfigured && oFsm.configuredUniFlow > 0 {
-					oFsm.configuredUniFlow--
+				oFsm.NumUniFlows--
+				if aWasConfigured && oFsm.ConfiguredUniFlow > 0 {
+					oFsm.ConfiguredUniFlow--
 				}
 				//cut off the requested flow by slicing out this element
 				oFsm.uniVlanFlowParamsSlice = append(
@@ -1027,7 +1019,7 @@
 	}
 	//if the cookie was found and removed from uniVlanFlowParamsSlice above now write the modified persistency data
 	//  KVStore update will be done after reaching the requested FSM end state (not immediately here)
-	if err := oFsm.pDeviceHandler.storePersUniFlowConfig(ctx, oFsm.pOnuUniPort.uniID,
+	if err := oFsm.pDeviceHandler.StorePersUniFlowConfig(ctx, oFsm.pOnuUniPort.UniID,
 		&oFsm.uniVlanFlowParamsSlice, false); err != nil {
 		logger.Errorw(ctx, err.Error(), log.Fields{"device-id": oFsm.deviceID})
 		return err
@@ -1056,7 +1048,7 @@
 		oFsm.mutexFlowParams.Unlock()
 		if oFsm.pUniTechProf != nil {
 			//request that this profile gets deleted before a new flow add is allowed
-			oFsm.pUniTechProf.setProfileToDelete(oFsm.pOnuUniPort.uniID, usedTpID, true)
+			oFsm.pUniTechProf.SetProfileToDelete(oFsm.pOnuUniPort.UniID, usedTpID, true)
 		}
 		oFsm.mutexFlowParams.Lock()
 	}
@@ -1072,20 +1064,20 @@
 	// start go routine for processing of LockState messages
 	go oFsm.processOmciVlanMessages(ctx)
 	//let the state machine run forward from here directly
-	pConfigVlanStateAFsm := oFsm.pAdaptFsm
+	pConfigVlanStateAFsm := oFsm.PAdaptFsm
 	if pConfigVlanStateAFsm != nil {
-		if oFsm.pDeviceHandler.isSkipOnuConfigReconciling() {
+		if oFsm.pDeviceHandler.IsSkipOnuConfigReconciling() {
 			logger.Debugw(ctx, "reconciling - skip omci-config of vlan rule",
-				log.Fields{"fsmState": oFsm.pAdaptFsm.pFsm.Current(), "device-id": oFsm.deviceID})
+				log.Fields{"fsmState": oFsm.PAdaptFsm.PFsm.Current(), "device-id": oFsm.deviceID})
 			// Can't call FSM Event directly, decoupling it
-			go func(a_pAFsm *AdapterFsm) {
-				_ = a_pAFsm.pFsm.Event(vlanEvSkipOmciConfig)
+			go func(a_pAFsm *cmn.AdapterFsm) {
+				_ = a_pAFsm.PFsm.Event(VlanEvSkipOmciConfig)
 			}(pConfigVlanStateAFsm)
 			return
 		}
 		// Can't call FSM Event directly, decoupling it
-		go func(a_pAFsm *AdapterFsm) {
-			_ = a_pAFsm.pFsm.Event(vlanEvPrepareDone)
+		go func(a_pAFsm *cmn.AdapterFsm) {
+			_ = a_pAFsm.PFsm.Event(VlanEvPrepareDone)
 		}(pConfigVlanStateAFsm)
 		return
 	}
@@ -1096,7 +1088,7 @@
 
 func (oFsm *UniVlanConfigFsm) enterConfigStarting(ctx context.Context, e *fsm.Event) {
 	logger.Debugw(ctx, "UniVlanConfigFsm start vlan configuration", log.Fields{"device-id": oFsm.deviceID})
-	pConfigVlanStateAFsm := oFsm.pAdaptFsm
+	pConfigVlanStateAFsm := oFsm.PAdaptFsm
 	if pConfigVlanStateAFsm != nil {
 		oFsm.mutexFlowParams.Lock()
 		//possibly the entry is not valid anymore based on intermediate delete requests
@@ -1106,8 +1098,8 @@
 			logger.Debugw(ctx, "UniVlanConfigFsm start: no rule entry anymore available", log.Fields{
 				"device-id": oFsm.deviceID})
 			// Can't call FSM Event directly, decoupling it
-			go func(a_pAFsm *AdapterFsm) {
-				_ = a_pAFsm.pFsm.Event(vlanEvReset)
+			go func(a_pAFsm *cmn.AdapterFsm) {
+				_ = a_pAFsm.PFsm.Event(VlanEvReset)
 			}(pConfigVlanStateAFsm)
 			return
 		}
@@ -1118,27 +1110,27 @@
 		tpID := oFsm.actualUniVlanConfigRule.TpID
 		oFsm.TpIDWaitingFor = tpID
 		//cmp also usage in EVTOCDE create in omci_cc
-		oFsm.evtocdID = macBridgeServiceProfileEID + uint16(oFsm.pOnuUniPort.macBpNo)
+		oFsm.evtocdID = cmn.MacBridgeServiceProfileEID + uint16(oFsm.pOnuUniPort.MacBpNo)
 		loSetVlan := oFsm.actualUniVlanConfigRule.SetVid
 		//attention: take care to release the mutexFlowParams when calling the FSM directly -
 		//  synchronous FSM 'event/state' functions may rely on this mutex
 		//  but it must be released already before calling getTechProfileDone() as it may already be locked
 		//  by the techProfile processing call to VlanFsm.IsFlowRemovePending() (see VOL-4207)
 		oFsm.mutexFlowParams.Unlock()
-		loTechProfDone := oFsm.pUniTechProf.getTechProfileDone(ctx, oFsm.pOnuUniPort.uniID, uint8(tpID))
+		loTechProfDone := oFsm.pUniTechProf.getTechProfileDone(ctx, oFsm.pOnuUniPort.UniID, uint8(tpID))
 		logger.Debugw(ctx, "UniVlanConfigFsm - start with first rule", log.Fields{
-			"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID,
+			"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID,
 			"set-Vlan": loSetVlan, "tp-id": tpID, "ProfDone": loTechProfDone})
 
 		// Can't call FSM Event directly, decoupling it
-		go func(aPAFsm *AdapterFsm, aTechProfDone bool) {
-			if aPAFsm != nil && aPAFsm.pFsm != nil {
+		go func(aPAFsm *cmn.AdapterFsm, aTechProfDone bool) {
+			if aPAFsm != nil && aPAFsm.PFsm != nil {
 				if aTechProfDone {
 					// let the vlan processing begin
-					_ = aPAFsm.pFsm.Event(vlanEvStartConfig)
+					_ = aPAFsm.PFsm.Event(VlanEvStartConfig)
 				} else {
 					// set to waiting for Techprofile
-					_ = aPAFsm.pFsm.Event(vlanEvWaitTechProf)
+					_ = aPAFsm.PFsm.Event(VlanEvWaitTechProf)
 				}
 			}
 		}(pConfigVlanStateAFsm, loTechProfDone)
@@ -1160,19 +1152,19 @@
 		logger.Debugw(ctx, "UniVlanConfigFsm: no VTFD config required", log.Fields{
 			"in state": e.FSM.Current(), "device-id": oFsm.deviceID})
 		// let the FSM proceed ... (from within this state all internal pointers may be expected to be correct)
-		pConfigVlanStateAFsm := oFsm.pAdaptFsm
+		pConfigVlanStateAFsm := oFsm.PAdaptFsm
 		// Can't call FSM Event directly, decoupling it
-		go func(a_pAFsm *AdapterFsm) {
-			_ = a_pAFsm.pFsm.Event(vlanEvRxConfigVtfd)
+		go func(a_pAFsm *cmn.AdapterFsm) {
+			_ = a_pAFsm.PFsm.Event(VlanEvRxConfigVtfd)
 		}(pConfigVlanStateAFsm)
 	} else {
 		// This attribute uniquely identifies each instance of this managed entity. Through an identical ID,
 		// this managed entity is implicitly linked to an instance of the MAC bridge port configuration data ME.
-		vtfdID, _ := generateANISideMBPCDEID(uint16(oFsm.pOnuUniPort.macBpNo), uint16(oFsm.actualUniVlanConfigRule.TpID))
+		vtfdID, _ := cmn.GenerateANISideMBPCDEID(uint16(oFsm.pOnuUniPort.MacBpNo), uint16(oFsm.actualUniVlanConfigRule.TpID))
 		logger.Debugw(ctx, "UniVlanConfigFsm create VTFD", log.Fields{
 			"EntitytId": strconv.FormatInt(int64(vtfdID), 16),
 			"in state":  e.FSM.Current(), "device-id": oFsm.deviceID,
-			"macBpNo": oFsm.pOnuUniPort.macBpNo, "TpID": oFsm.actualUniVlanConfigRule.TpID})
+			"macBpNo": oFsm.pOnuUniPort.MacBpNo, "TpID": oFsm.actualUniVlanConfigRule.TpID})
 		// setVid is assumed to be masked already by the caller to 12 bit
 		oFsm.vlanFilterList[0] = uint16(oFsm.actualUniVlanConfigRule.SetVid)
 		oFsm.mutexFlowParams.Unlock()
@@ -1190,16 +1182,16 @@
 		logger.Debugw(ctx, "UniVlanConfigFsm sendcreate VTFD", log.Fields{
 			"in state": e.FSM.Current(), "device-id": oFsm.deviceID})
 		oFsm.mutexPLastTxMeInstance.Lock()
-		meInstance, err := oFsm.pOmciCC.sendCreateVtfdVar(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
-			oFsm.pAdaptFsm.commChan, meParams)
+		meInstance, err := oFsm.pOmciCC.SendCreateVtfdVar(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), true,
+			oFsm.PAdaptFsm.CommChan, meParams)
 		if err != nil {
 			oFsm.mutexPLastTxMeInstance.Unlock()
 			logger.Errorw(ctx, "VTFD create failed, aborting UniVlanConfig FSM!",
 				log.Fields{"device-id": oFsm.deviceID})
-			pConfigVlanStateAFsm := oFsm.pAdaptFsm
+			pConfigVlanStateAFsm := oFsm.PAdaptFsm
 			if pConfigVlanStateAFsm != nil {
-				go func(a_pAFsm *AdapterFsm) {
-					_ = a_pAFsm.pFsm.Event(vlanEvReset)
+				go func(a_pAFsm *cmn.AdapterFsm) {
+					_ = a_pAFsm.PFsm.Event(VlanEvReset)
 				}(pConfigVlanStateAFsm)
 			}
 			return
@@ -1226,37 +1218,37 @@
 			oFsm.mutexFlowParams.RLock()
 			tpID := oFsm.actualUniVlanConfigRule.TpID
 			vlanID := oFsm.actualUniVlanConfigRule.SetVid
-			configuredUniFlows := oFsm.configuredUniFlow
+			configuredUniFlows := oFsm.ConfiguredUniFlow
 			// ensure mutexFlowParams not locked before calling some TPProcessing activity (that might already be pending on it)
 			oFsm.mutexFlowParams.RUnlock()
-			for _, gemPort := range oFsm.pUniTechProf.getMulticastGemPorts(ctx, oFsm.pOnuUniPort.uniID, uint8(tpID)) {
+			for _, gemPort := range oFsm.pUniTechProf.getMulticastGemPorts(ctx, oFsm.pOnuUniPort.UniID, uint8(tpID)) {
 				logger.Infow(ctx, "Setting multicast MEs, with first flow", log.Fields{"deviceID": oFsm.deviceID,
-					"techProfile": tpID, "gemPort": gemPort, "vlanID": vlanID, "configuredUniFlow": configuredUniFlows})
+					"techProfile": tpID, "gemPort": gemPort, "vlanID": vlanID, "ConfiguredUniFlow": configuredUniFlows})
 				errCreateAllMulticastME := oFsm.performSettingMulticastME(ctx, tpID, gemPort,
 					vlanID)
 				if errCreateAllMulticastME != nil {
 					logger.Errorw(ctx, "Multicast ME create failed, aborting AniConfig FSM!",
 						log.Fields{"device-id": oFsm.deviceID})
-					_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+					_ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
 				}
 			}
 			//If this first flow contains a meter, then create TD for related gems.
 			if oFsm.actualUniVlanConfigMeter != nil {
 				logger.Debugw(ctx, "Creating Traffic Descriptor", log.Fields{"device-id": oFsm.deviceID, "meter": oFsm.actualUniVlanConfigMeter})
-				for _, gemPort := range oFsm.pUniTechProf.getBidirectionalGemPortIDsForTP(ctx, oFsm.pOnuUniPort.uniID, tpID) {
+				for _, gemPort := range oFsm.pUniTechProf.getBidirectionalGemPortIDsForTP(ctx, oFsm.pOnuUniPort.UniID, tpID) {
 					logger.Debugw(ctx, "Creating Traffic Descriptor for gem", log.Fields{"device-id": oFsm.deviceID, "meter": oFsm.actualUniVlanConfigMeter, "gem": gemPort})
 					errCreateTrafficDescriptor := oFsm.createTrafficDescriptor(ctx, oFsm.actualUniVlanConfigMeter, tpID,
-						oFsm.pOnuUniPort.uniID, gemPort)
+						oFsm.pOnuUniPort.UniID, gemPort)
 					if errCreateTrafficDescriptor != nil {
 						logger.Errorw(ctx, "Create Traffic Descriptor create failed, aborting Ani Config FSM!",
 							log.Fields{"device-id": oFsm.deviceID})
-						_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+						_ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
 					}
 				}
 			}
 
 			//TODO Possibly insert new state for multicast --> possibly another jira/later time.
-			_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvRxConfigEvtocd)
+			_ = oFsm.PAdaptFsm.PFsm.Event(VlanEvRxConfigEvtocd)
 		}
 	}()
 }
@@ -1267,8 +1259,8 @@
 
 	logger.Infow(ctx, "UniVlanConfigFsm config done - checking on more flows", log.Fields{
 		"device-id":         oFsm.deviceID,
-		"overall-uni-rules": oFsm.numUniFlows, "configured-uni-rules": oFsm.configuredUniFlow})
-	pConfigVlanStateAFsm := oFsm.pAdaptFsm
+		"overall-uni-rules": oFsm.NumUniFlows, "configured-uni-rules": oFsm.ConfiguredUniFlow})
+	pConfigVlanStateAFsm := oFsm.PAdaptFsm
 	if pConfigVlanStateAFsm == nil {
 		oFsm.mutexFlowParams.Unlock()
 		logger.Errorw(ctx, "UniVlanConfigFsm abort: invalid FSM pointer", log.Fields{
@@ -1276,59 +1268,59 @@
 		//should never happen, else: recovery would be needed from outside the FSM
 		return
 	}
-	pConfigVlanStateBaseFsm := pConfigVlanStateAFsm.pFsm
+	pConfigVlanStateBaseFsm := pConfigVlanStateAFsm.PFsm
 	if len(oFsm.uniRemoveFlowsSlice) > 0 {
 		//some further flows are to be removed, removal always starts with the first element
 		logger.Debugw(ctx, "UniVlanConfigFsm rule removal from ConfigDone", log.Fields{
-			"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID,
+			"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID,
 			"tp-id":    oFsm.uniRemoveFlowsSlice[0].vlanRuleParams.TpID,
 			"set-Vlan": oFsm.uniRemoveFlowsSlice[0].vlanRuleParams.SetVid})
 		oFsm.mutexFlowParams.Unlock()
 		// Can't call FSM Event directly, decoupling it
 		go func(a_pBaseFsm *fsm.FSM) {
-			_ = a_pBaseFsm.Event(vlanEvRemFlowConfig)
+			_ = a_pBaseFsm.Event(VlanEvRemFlowConfig)
 		}(pConfigVlanStateBaseFsm)
 		return
 	}
-	if oFsm.pDeviceHandler.isSkipOnuConfigReconciling() {
-		oFsm.configuredUniFlow = oFsm.numUniFlows
+	if oFsm.pDeviceHandler.IsSkipOnuConfigReconciling() {
+		oFsm.ConfiguredUniFlow = oFsm.NumUniFlows
 		if oFsm.lastFlowToReconcile {
 			logger.Debugw(ctx, "reconciling - flow processing finished", log.Fields{"device-id": oFsm.deviceID})
-			oFsm.pDeviceHandler.setReconcilingFlows(false)
-			oFsm.pDeviceHandler.chReconcilingFlowsFinished <- true
+			oFsm.pOnuDeviceEntry.SetReconcilingFlows(false)
+			oFsm.pOnuDeviceEntry.SetChReconcilingFlowsFinished(true)
 		}
 		logger.Debugw(ctx, "reconciling - skip enterVlanConfigDone processing",
-			log.Fields{"numUniFlows": oFsm.numUniFlows, "configuredUniFlow": oFsm.configuredUniFlow, "device-id": oFsm.deviceID})
+			log.Fields{"NumUniFlows": oFsm.NumUniFlows, "ConfiguredUniFlow": oFsm.ConfiguredUniFlow, "device-id": oFsm.deviceID})
 		oFsm.mutexFlowParams.Unlock()
 		return
 	}
-	if oFsm.numUniFlows > oFsm.configuredUniFlow {
-		if oFsm.configuredUniFlow == 0 {
+	if oFsm.NumUniFlows > oFsm.ConfiguredUniFlow {
+		if oFsm.ConfiguredUniFlow == 0 {
 			oFsm.mutexFlowParams.Unlock()
 			// this is a restart with a complete new flow, we can re-use the initial flow config control
 			// including the check, if the related techProfile is (still) available (probably also removed in between)
 			// Can't call FSM Event directly, decoupling it
 			go func(a_pBaseFsm *fsm.FSM) {
-				_ = a_pBaseFsm.Event(vlanEvRenew)
+				_ = a_pBaseFsm.Event(VlanEvRenew)
 			}(pConfigVlanStateBaseFsm)
 			return
 		}
 
 		//some further flows are to be configured
 		//store the actual rule that shall be worked upon in the following transient states
-		if len(oFsm.uniVlanFlowParamsSlice) < int(oFsm.configuredUniFlow) {
+		if len(oFsm.uniVlanFlowParamsSlice) < int(oFsm.ConfiguredUniFlow) {
 			//check introduced after having observed some panic in this processing
 			logger.Errorw(ctx, "error in FsmEvent handling UniVlanConfigFsm in ConfigDone - inconsistent counter",
-				log.Fields{"configuredUniFlow": oFsm.configuredUniFlow,
+				log.Fields{"ConfiguredUniFlow": oFsm.ConfiguredUniFlow,
 					"sliceLen": len(oFsm.uniVlanFlowParamsSlice), "device-id": oFsm.deviceID})
 			oFsm.mutexFlowParams.Unlock()
-			go func(a_pAFsm *AdapterFsm) {
-				_ = a_pAFsm.pFsm.Event(vlanEvReset)
+			go func(a_pAFsm *cmn.AdapterFsm) {
+				_ = a_pAFsm.PFsm.Event(VlanEvReset)
 			}(pConfigVlanStateAFsm)
 			return
 		}
-		oFsm.actualUniVlanConfigRule = oFsm.uniVlanFlowParamsSlice[oFsm.configuredUniFlow].VlanRuleParams
-		oFsm.actualUniVlanConfigMeter = oFsm.uniVlanFlowParamsSlice[oFsm.configuredUniFlow].Meter
+		oFsm.actualUniVlanConfigRule = oFsm.uniVlanFlowParamsSlice[oFsm.ConfiguredUniFlow].VlanRuleParams
+		oFsm.actualUniVlanConfigMeter = oFsm.uniVlanFlowParamsSlice[oFsm.ConfiguredUniFlow].Meter
 		//tpId of the next rule to be configured
 		tpID := oFsm.actualUniVlanConfigRule.TpID
 		oFsm.TpIDWaitingFor = tpID
@@ -1338,19 +1330,19 @@
 		//  but it must be released already before calling getTechProfileDone() as it may already be locked
 		//  by the techProfile processing call to VlanFsm.IsFlowRemovePending() (see VOL-4207)
 		oFsm.mutexFlowParams.Unlock()
-		loTechProfDone := oFsm.pUniTechProf.getTechProfileDone(ctx, oFsm.pOnuUniPort.uniID, tpID)
+		loTechProfDone := oFsm.pUniTechProf.getTechProfileDone(ctx, oFsm.pOnuUniPort.UniID, tpID)
 		logger.Debugw(ctx, "UniVlanConfigFsm - incremental config request", log.Fields{
-			"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID,
+			"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID,
 			"set-Vlan": loSetVlan, "tp-id": tpID, "ProfDone": loTechProfDone})
 
 		// Can't call FSM Event directly, decoupling it
 		go func(aPBaseFsm *fsm.FSM, aTechProfDone bool) {
 			if aTechProfDone {
 				// let the vlan processing continue with next rule
-				_ = aPBaseFsm.Event(vlanEvIncrFlowConfig)
+				_ = aPBaseFsm.Event(VlanEvIncrFlowConfig)
 			} else {
 				// set to waiting for Techprofile
-				_ = aPBaseFsm.Event(vlanEvWaitTPIncr)
+				_ = aPBaseFsm.Event(VlanEvWaitTPIncr)
 			}
 		}(pConfigVlanStateBaseFsm, loTechProfDone)
 		return
@@ -1363,23 +1355,23 @@
 	// note: 'flowPushed' event is only generated if all 'pending' rules are configured
 	if oFsm.pDeviceHandler != nil {
 		//making use of the add->remove successor enum assumption/definition
-		go oFsm.pDeviceHandler.deviceProcStatusUpdate(ctx, OnuDeviceEvent(uint8(oFsm.requestEvent)+oFsm.requestEventOffset))
+		go oFsm.pDeviceHandler.DeviceProcStatusUpdate(ctx, cmn.OnuDeviceEvent(uint8(oFsm.requestEvent)+oFsm.requestEventOffset))
 	}
 }
 
 func (oFsm *UniVlanConfigFsm) enterConfigIncrFlow(ctx context.Context, e *fsm.Event) {
 
-	if oFsm.pDeviceHandler.isSkipOnuConfigReconciling() {
+	if oFsm.pDeviceHandler.IsSkipOnuConfigReconciling() {
 		logger.Debugw(ctx, "reconciling - skip further processing for incremental flow",
-			log.Fields{"fsmState": oFsm.pAdaptFsm.pFsm.Current(), "device-id": oFsm.deviceID})
+			log.Fields{"fsmState": oFsm.PAdaptFsm.PFsm.Current(), "device-id": oFsm.deviceID})
 		go func(a_pBaseFsm *fsm.FSM) {
-			_ = a_pBaseFsm.Event(vlanEvSkipIncFlowConfig)
-		}(oFsm.pAdaptFsm.pFsm)
+			_ = a_pBaseFsm.Event(VlanEvSkipIncFlowConfig)
+		}(oFsm.PAdaptFsm.PFsm)
 		return
 	}
 	oFsm.mutexFlowParams.Lock()
 	logger.Debugw(ctx, "UniVlanConfigFsm - start config further incremental flow", log.Fields{
-		"recent flow-number": oFsm.configuredUniFlow,
+		"recent flow-number": oFsm.ConfiguredUniFlow,
 		"device-id":          oFsm.deviceID})
 	oFsm.TpIDWaitingFor = 0 //reset indication to avoid misinterpretation
 
@@ -1395,12 +1387,12 @@
 		if oFsm.numVlanFilterEntries == 0 {
 			// This attribute uniquely identifies each instance of this managed entity. Through an identical ID,
 			// this managed entity is implicitly linked to an instance of the MAC bridge port configuration data ME.
-			vtfdID, _ := generateANISideMBPCDEID(uint16(oFsm.pOnuUniPort.macBpNo), uint16(oFsm.actualUniVlanConfigRule.TpID))
+			vtfdID, _ := cmn.GenerateANISideMBPCDEID(uint16(oFsm.pOnuUniPort.MacBpNo), uint16(oFsm.actualUniVlanConfigRule.TpID))
 			//no VTFD yet created
 			logger.Debugw(ctx, "UniVlanConfigFsm create VTFD", log.Fields{
 				"EntitytId": strconv.FormatInt(int64(vtfdID), 16),
 				"device-id": oFsm.deviceID,
-				"macBpNo":   oFsm.pOnuUniPort.macBpNo, "TpID": oFsm.actualUniVlanConfigRule.TpID})
+				"macBpNo":   oFsm.pOnuUniPort.MacBpNo, "TpID": oFsm.actualUniVlanConfigRule.TpID})
 			// 'SetVid' below is assumed to be masked already by the caller to 12 bit
 			oFsm.vlanFilterList[0] = uint16(oFsm.actualUniVlanConfigRule.SetVid)
 
@@ -1416,17 +1408,17 @@
 				},
 			}
 			oFsm.mutexPLastTxMeInstance.Lock()
-			meInstance, err := oFsm.pOmciCC.sendCreateVtfdVar(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
-				oFsm.pAdaptFsm.commChan, meParams)
+			meInstance, err := oFsm.pOmciCC.SendCreateVtfdVar(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), true,
+				oFsm.PAdaptFsm.CommChan, meParams)
 			if err != nil {
 				oFsm.mutexPLastTxMeInstance.Unlock()
 				oFsm.mutexFlowParams.Unlock()
 				logger.Errorw(ctx, "VTFD create failed, aborting UniVlanConfig FSM!",
 					log.Fields{"device-id": oFsm.deviceID})
-				pConfigVlanStateAFsm := oFsm.pAdaptFsm
+				pConfigVlanStateAFsm := oFsm.PAdaptFsm
 				if pConfigVlanStateAFsm != nil {
-					go func(a_pAFsm *AdapterFsm) {
-						_ = a_pAFsm.pFsm.Event(vlanEvReset)
+					go func(a_pAFsm *cmn.AdapterFsm) {
+						_ = a_pAFsm.PFsm.Event(VlanEvReset)
 					}(pConfigVlanStateAFsm)
 				}
 				return
@@ -1441,12 +1433,12 @@
 		} else {
 			// This attribute uniquely identifies each instance of this managed entity. Through an identical ID,
 			// this managed entity is implicitly linked to an instance of the MAC bridge port configuration data ME.
-			vtfdID, _ := generateANISideMBPCDEID(uint16(oFsm.pOnuUniPort.macBpNo), uint16(oFsm.actualUniVlanConfigRule.TpID))
+			vtfdID, _ := cmn.GenerateANISideMBPCDEID(uint16(oFsm.pOnuUniPort.MacBpNo), uint16(oFsm.actualUniVlanConfigRule.TpID))
 
 			logger.Debugw(ctx, "UniVlanConfigFsm set VTFD", log.Fields{
 				"EntitytId": strconv.FormatInt(int64(vtfdID), 16),
 				"device-id": oFsm.deviceID,
-				"macBpNo":   oFsm.pOnuUniPort.macBpNo, "TpID": oFsm.actualUniVlanConfigRule.TpID})
+				"macBpNo":   oFsm.pOnuUniPort.MacBpNo, "TpID": oFsm.actualUniVlanConfigRule.TpID})
 			// setVid is assumed to be masked already by the caller to 12 bit
 			oFsm.vlanFilterList[oFsm.numVlanFilterEntries] =
 				uint16(oFsm.actualUniVlanConfigRule.SetVid)
@@ -1467,14 +1459,14 @@
 				},
 			}
 			oFsm.mutexPLastTxMeInstance.Lock()
-			meInstance, err := oFsm.pOmciCC.sendCreateVtfdVar(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
-				oFsm.pAdaptFsm.commChan, meParams)
+			meInstance, err := oFsm.pOmciCC.SendCreateVtfdVar(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), true,
+				oFsm.PAdaptFsm.CommChan, meParams)
 			if err != nil {
 				oFsm.mutexPLastTxMeInstance.Unlock()
 				oFsm.mutexFlowParams.Unlock()
 				logger.Errorw(ctx, "UniVlanFsm create Vlan Tagging Filter ME result error",
 					log.Fields{"device-id": oFsm.deviceID, "Error": err})
-				_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+				_ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
 				return
 			}
 			//accept also nil as (error) return value for writing to LastTx
@@ -1491,10 +1483,10 @@
 			oFsm.mutexFlowParams.Unlock()
 			logger.Errorw(ctx, "VTFD create/set failed, aborting VlanConfig FSM!",
 				log.Fields{"device-id": oFsm.deviceID})
-			pConfigVlanStateBaseFsm := oFsm.pAdaptFsm.pFsm
+			pConfigVlanStateBaseFsm := oFsm.PAdaptFsm.PFsm
 			// Can't call FSM Event directly, decoupling it
 			go func(a_pBaseFsm *fsm.FSM) {
-				_ = a_pBaseFsm.Event(vlanEvReset)
+				_ = a_pBaseFsm.Event(VlanEvReset)
 			}(pConfigVlanStateBaseFsm)
 			return
 		}
@@ -1505,41 +1497,41 @@
 	go func() {
 		oFsm.mutexFlowParams.RLock()
 		tpID := oFsm.actualUniVlanConfigRule.TpID
-		configuredUniFlow := oFsm.configuredUniFlow
+		ConfiguredUniFlow := oFsm.ConfiguredUniFlow
 		// ensure mutexFlowParams not locked before calling some TPProcessing activity (that might already be pending on it)
 		oFsm.mutexFlowParams.RUnlock()
-		errEvto := oFsm.performConfigEvtocdEntries(ctx, configuredUniFlow)
+		errEvto := oFsm.performConfigEvtocdEntries(ctx, ConfiguredUniFlow)
 		//This is correct passing scenario
 		if errEvto == nil {
 			//TODO Possibly insert new state for multicast --> possibly another jira/later time.
-			for _, gemPort := range oFsm.pUniTechProf.getMulticastGemPorts(ctx, oFsm.pOnuUniPort.uniID, uint8(tpID)) {
+			for _, gemPort := range oFsm.pUniTechProf.getMulticastGemPorts(ctx, oFsm.pOnuUniPort.UniID, uint8(tpID)) {
 				oFsm.mutexFlowParams.RLock()
 				vlanID := oFsm.actualUniVlanConfigRule.SetVid
 				logger.Infow(ctx, "Setting multicast MEs for additional flows", log.Fields{"deviceID": oFsm.deviceID,
 					"techProfile": tpID, "gemPort": gemPort,
-					"vlanID": vlanID, "configuredUniFlow": configuredUniFlow})
+					"vlanID": vlanID, "ConfiguredUniFlow": ConfiguredUniFlow})
 				oFsm.mutexFlowParams.RUnlock()
 				errCreateAllMulticastME := oFsm.performSettingMulticastME(ctx, tpID, gemPort, vlanID)
 				if errCreateAllMulticastME != nil {
 					logger.Errorw(ctx, "Multicast ME create failed, aborting AniConfig FSM!",
 						log.Fields{"device-id": oFsm.deviceID})
-					_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+					_ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
 				}
 			}
 			//If this incremental flow contains a meter, then create TD for related gems.
 			if oFsm.actualUniVlanConfigMeter != nil {
-				for _, gemPort := range oFsm.pUniTechProf.getBidirectionalGemPortIDsForTP(ctx, oFsm.pOnuUniPort.uniID, tpID) {
+				for _, gemPort := range oFsm.pUniTechProf.getBidirectionalGemPortIDsForTP(ctx, oFsm.pOnuUniPort.UniID, tpID) {
 					logger.Debugw(ctx, "Creating Traffic Descriptor for gem", log.Fields{"device-id": oFsm.deviceID, "meter": oFsm.actualUniVlanConfigMeter, "gem": gemPort})
 					errCreateTrafficDescriptor := oFsm.createTrafficDescriptor(ctx, oFsm.actualUniVlanConfigMeter, tpID,
-						oFsm.pOnuUniPort.uniID, gemPort)
+						oFsm.pOnuUniPort.UniID, gemPort)
 					if errCreateTrafficDescriptor != nil {
 						logger.Errorw(ctx, "Create Traffic Descriptor create failed, aborting Ani Config FSM!",
 							log.Fields{"device-id": oFsm.deviceID})
-						_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+						_ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
 					}
 				}
 			}
-			_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvRxConfigEvtocd)
+			_ = oFsm.PAdaptFsm.PFsm.Event(VlanEvRxConfigEvtocd)
 		}
 	}()
 }
@@ -1550,8 +1542,8 @@
 		"with last cookie": oFsm.uniRemoveFlowsSlice[0].cookie,
 		"device-id":        oFsm.deviceID})
 
-	pConfigVlanStateBaseFsm := oFsm.pAdaptFsm.pFsm
-	loAllowSpecificOmciConfig := oFsm.pDeviceHandler.isReadyForOmciConfig()
+	pConfigVlanStateBaseFsm := oFsm.PAdaptFsm.PFsm
+	loAllowSpecificOmciConfig := oFsm.pDeviceHandler.IsReadyForOmciConfig()
 	loVlanEntryClear := uint8(0)
 	loVlanEntryRmPos := uint8(0x80) //with indication 'invalid' in bit 7
 	//shallow copy is sufficient as no reference variables are used within struct
@@ -1569,30 +1561,30 @@
 	} else {
 		vtfdFilterList := make([]uint16, cVtfdTableSize) //needed for parameter serialization and 're-copy'
 		if oFsm.numVlanFilterEntries == 1 {
-			vtfdID, _ := generateANISideMBPCDEID(uint16(oFsm.pOnuUniPort.macBpNo), uint16(loRuleParams.TpID))
+			vtfdID, _ := cmn.GenerateANISideMBPCDEID(uint16(oFsm.pOnuUniPort.MacBpNo), uint16(loRuleParams.TpID))
 			//only one active VLAN entry (hopefully the SetVID we want to remove - should be, but not verified ..)
 			//  so we can just delete the VTFD entry
 			logger.Debugw(ctx, "UniVlanConfigFsm: VTFD delete (no more vlan filters)",
 				log.Fields{"current vlan list": oFsm.vlanFilterList, "EntitytId": strconv.FormatInt(int64(vtfdID), 16),
 					"device-id": oFsm.deviceID,
-					"macBpNo":   oFsm.pOnuUniPort.macBpNo, "TpID": loRuleParams.TpID})
+					"macBpNo":   oFsm.pOnuUniPort.MacBpNo, "TpID": loRuleParams.TpID})
 			loVlanEntryClear = 1           //full VlanFilter clear request
 			if loAllowSpecificOmciConfig { //specific OMCI config is expected to work acc. to the device state
 				oFsm.mutexPLastTxMeInstance.Lock()
-				meInstance, err := oFsm.pOmciCC.sendDeleteVtfd(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
-					oFsm.pAdaptFsm.commChan, vtfdID)
+				meInstance, err := oFsm.pOmciCC.SendDeleteVtfd(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), true,
+					oFsm.PAdaptFsm.CommChan, vtfdID)
 				if err != nil {
 					oFsm.mutexPLastTxMeInstance.Unlock()
 					logger.Errorw(ctx, "UniVlanFsm delete Vlan Tagging Filter ME result error",
 						log.Fields{"device-id": oFsm.deviceID, "Error": err})
-					_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+					_ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
 					return
 				}
 				oFsm.pLastTxMeInstance = meInstance
 				oFsm.mutexPLastTxMeInstance.Unlock()
 			} else {
 				logger.Debugw(ctx, "UniVlanConfigFsm delete VTFD OMCI handling skipped based on device state", log.Fields{
-					"device-id": oFsm.deviceID, "device-state": oFsm.pDeviceHandler.getDeviceReasonString()})
+					"device-id": oFsm.deviceID, "device-state": oFsm.pDeviceHandler.GetDeviceReasonString()})
 			}
 		} else {
 			//many VTFD already should exists - find and remove the one concerned by the actual remove rule
@@ -1607,7 +1599,7 @@
 				}
 			}
 			if loVlanEntryRmPos < cVtfdTableSize {
-				vtfdID, _ := generateANISideMBPCDEID(uint16(oFsm.pOnuUniPort.macBpNo), uint16(loRuleParams.TpID))
+				vtfdID, _ := cmn.GenerateANISideMBPCDEID(uint16(oFsm.pOnuUniPort.MacBpNo), uint16(loRuleParams.TpID))
 				//valid entry was found - to be eclipsed
 				loVlanEntryClear = 2 //VlanFilter remove request for a specific entry
 				for i := uint8(0); i < oFsm.numVlanFilterEntries; i++ {
@@ -1622,25 +1614,25 @@
 				logger.Debugw(ctx, "UniVlanConfigFsm set VTFD", log.Fields{
 					"EntitytId":     strconv.FormatInt(int64(vtfdID), 16),
 					"new vlan list": vtfdFilterList, "device-id": oFsm.deviceID,
-					"macBpNo": oFsm.pOnuUniPort.macBpNo, "TpID": loRuleParams.TpID})
+					"macBpNo": oFsm.pOnuUniPort.MacBpNo, "TpID": loRuleParams.TpID})
 
 				if loAllowSpecificOmciConfig { //specific OMCI config is expected to work acc. to the device state
 					// FIXME: VOL-3685: Issues with resetting a table entry in EVTOCD ME
 					oFsm.mutexPLastTxMeInstance.Lock()
-					meInstance, err := oFsm.pOmciCC.sendDeleteVtfd(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
-						oFsm.pAdaptFsm.commChan, vtfdID)
+					meInstance, err := oFsm.pOmciCC.SendDeleteVtfd(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), true,
+						oFsm.PAdaptFsm.CommChan, vtfdID)
 					if err != nil {
 						oFsm.mutexPLastTxMeInstance.Unlock()
 						logger.Errorw(ctx, "UniVlanFsm delete Vlan Tagging Filter ME result error",
 							log.Fields{"device-id": oFsm.deviceID, "Error": err})
-						_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+						_ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
 						return
 					}
 					oFsm.pLastTxMeInstance = meInstance
 					oFsm.mutexPLastTxMeInstance.Unlock()
 				} else {
 					logger.Debugw(ctx, "UniVlanConfigFsm set VTFD OMCI handling skipped based on device state", log.Fields{
-						"device-id": oFsm.deviceID, "device-state": oFsm.pDeviceHandler.getDeviceReasonString()})
+						"device-id": oFsm.deviceID, "device-state": oFsm.pDeviceHandler.GetDeviceReasonString()})
 				}
 			} else {
 				logger.Warnw(ctx, "UniVlanConfigFsm: requested VLAN for removal not found in list - ignore and continue (no VTFD set)",
@@ -1656,7 +1648,7 @@
 						log.Fields{"device-id": oFsm.deviceID})
 					// Can't call FSM Event directly, decoupling it
 					go func(a_pBaseFsm *fsm.FSM) {
-						_ = a_pBaseFsm.Event(vlanEvReset)
+						_ = a_pBaseFsm.Event(VlanEvReset)
 					}(pConfigVlanStateBaseFsm)
 					return
 				}
@@ -1686,7 +1678,7 @@
 			"device-id": oFsm.deviceID})
 		// Can't call FSM Event directly, decoupling it
 		go func(a_pBaseFsm *fsm.FSM) {
-			_ = a_pBaseFsm.Event(vlanEvRemFlowDone, loRuleParams.TpID)
+			_ = a_pBaseFsm.Event(VlanEvRemFlowDone, loRuleParams.TpID)
 		}(pConfigVlanStateBaseFsm)
 	}
 }
@@ -1703,7 +1695,7 @@
 	oFsm.mutexFlowParams.Lock()
 	deletedCookie := oFsm.uniRemoveFlowsSlice[0].cookie
 
-	pConfigVlanStateAFsm := oFsm.pAdaptFsm
+	pConfigVlanStateAFsm := oFsm.PAdaptFsm
 	if pConfigVlanStateAFsm == nil {
 		logger.Errorw(ctx, "invalid Fsm pointer - unresolvable - abort",
 			log.Fields{"device-id": oFsm.deviceID})
@@ -1718,8 +1710,8 @@
 		//something quite inconsistent detected, perhaps just try to recover with FSM reset
 		oFsm.mutexFlowParams.Unlock()
 		logger.Errorw(ctx, "UniVlanConfigFsm - could not clear database - abort", log.Fields{"device-id": oFsm.deviceID})
-		go func(a_pAFsm *AdapterFsm) {
-			_ = a_pAFsm.pFsm.Event(vlanEvReset)
+		go func(a_pAFsm *cmn.AdapterFsm) {
+			_ = a_pAFsm.PFsm.Event(VlanEvReset)
 		}(pConfigVlanStateAFsm)
 		return
 	}
@@ -1751,8 +1743,8 @@
 	oFsm.requestEventOffset = uint8(cDeviceEventOffsetRemoveWithKvStore) //offset for last flow-remove activity (with kvStore request)
 	//return to the basic config verification state
 	// Can't call FSM Event directly, decoupling it
-	go func(a_pAFsm *AdapterFsm) {
-		_ = a_pAFsm.pFsm.Event(vlanEvFlowDataRemoved)
+	go func(a_pAFsm *cmn.AdapterFsm) {
+		_ = a_pAFsm.PFsm.Event(VlanEvFlowDataRemoved)
 	}(pConfigVlanStateAFsm)
 
 	oFsm.mutexFlowParams.Lock()
@@ -1781,22 +1773,22 @@
 func (oFsm *UniVlanConfigFsm) enterResetting(ctx context.Context, e *fsm.Event) {
 	logger.Debugw(ctx, "UniVlanConfigFsm resetting", log.Fields{"device-id": oFsm.deviceID})
 
-	pConfigVlanStateAFsm := oFsm.pAdaptFsm
+	pConfigVlanStateAFsm := oFsm.PAdaptFsm
 	if pConfigVlanStateAFsm != nil {
 		// abort running message processing
-		fsmAbortMsg := Message{
-			Type: TestMsg,
-			Data: TestMessage{
-				TestMessageVal: AbortMessageProcessing,
+		fsmAbortMsg := cmn.Message{
+			Type: cmn.TestMsg,
+			Data: cmn.TestMessage{
+				TestMessageVal: cmn.AbortMessageProcessing,
 			},
 		}
-		pConfigVlanStateAFsm.commChan <- fsmAbortMsg
+		pConfigVlanStateAFsm.CommChan <- fsmAbortMsg
 
 		//try to restart the FSM to 'disabled'
 		// Can't call FSM Event directly, decoupling it
-		go func(a_pAFsm *AdapterFsm) {
-			if a_pAFsm != nil && a_pAFsm.pFsm != nil {
-				_ = a_pAFsm.pFsm.Event(vlanEvRestart)
+		go func(a_pAFsm *cmn.AdapterFsm) {
+			if a_pAFsm != nil && a_pAFsm.PFsm != nil {
+				_ = a_pAFsm.PFsm.Event(VlanEvRestart)
 			}
 		}(pConfigVlanStateAFsm)
 	}
@@ -1836,8 +1828,8 @@
 		if oFsm.clearPersistency {
 			//permanently remove possibly stored persistent data
 			if len(oFsm.uniVlanFlowParamsSlice) > 0 {
-				var emptySlice = make([]uniVlanFlowParams, 0)
-				_ = oFsm.pDeviceHandler.storePersUniFlowConfig(ctx, oFsm.pOnuUniPort.uniID, &emptySlice, true) //ignore errors
+				var emptySlice = make([]cmn.UniVlanFlowParams, 0)
+				_ = oFsm.pDeviceHandler.StorePersUniFlowConfig(ctx, oFsm.pOnuUniPort.UniID, &emptySlice, true) //ignore errors
 			}
 		} else {
 			logger.Debugw(ctx, "UniVlanConfigFsm persistency data not cleared", log.Fields{"device-id": oFsm.deviceID})
@@ -1857,25 +1849,25 @@
 		// case <-ctx.Done():
 		// 	logger.Info(ctx,"MibSync Msg", log.Fields{"Message handling canceled via context for device-id": oFsm.deviceID})
 		// 	break loop
-		message, ok := <-oFsm.pAdaptFsm.commChan
+		message, ok := <-oFsm.PAdaptFsm.CommChan
 		if !ok {
 			logger.Info(ctx, "UniVlanConfigFsm Rx Msg - could not read from channel", log.Fields{"device-id": oFsm.deviceID})
 			// but then we have to ensure a restart of the FSM as well - as exceptional procedure
-			_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+			_ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
 			break loop
 		}
 		logger.Debugw(ctx, "UniVlanConfigFsm Rx Msg", log.Fields{"device-id": oFsm.deviceID})
 
 		switch message.Type {
-		case TestMsg:
-			msg, _ := message.Data.(TestMessage)
-			if msg.TestMessageVal == AbortMessageProcessing {
+		case cmn.TestMsg:
+			msg, _ := message.Data.(cmn.TestMessage)
+			if msg.TestMessageVal == cmn.AbortMessageProcessing {
 				logger.Infow(ctx, "UniVlanConfigFsm abort ProcessMsg", log.Fields{"for device-id": oFsm.deviceID})
 				break loop
 			}
 			logger.Warnw(ctx, "UniVlanConfigFsm unknown TestMessage", log.Fields{"device-id": oFsm.deviceID, "MessageVal": msg.TestMessageVal})
-		case OMCI:
-			msg, _ := message.Data.(OmciMessage)
+		case cmn.OMCI:
+			msg, _ := message.Data.(cmn.OmciMessage)
 			oFsm.handleOmciVlanConfigMessage(ctx, msg)
 		default:
 			logger.Warn(ctx, "UniVlanConfigFsm Rx unknown message", log.Fields{"device-id": oFsm.deviceID,
@@ -1885,7 +1877,7 @@
 	logger.Infow(ctx, "End UniVlanConfigFsm Msg processing", log.Fields{"device-id": oFsm.deviceID})
 }
 
-func (oFsm *UniVlanConfigFsm) handleOmciVlanConfigMessage(ctx context.Context, msg OmciMessage) {
+func (oFsm *UniVlanConfigFsm) handleOmciVlanConfigMessage(ctx context.Context, msg cmn.OmciMessage) {
 	logger.Debugw(ctx, "Rx OMCI UniVlanConfigFsm Msg", log.Fields{"device-id": oFsm.deviceID,
 		"msgType": msg.OmciMsg.MessageType})
 
@@ -1991,9 +1983,9 @@
 				"ExtendedVlanTaggingOperationConfigurationData", "TrafficDescriptor":
 				{
 					oFsm.mutexPLastTxMeInstance.RUnlock()
-					if oFsm.pAdaptFsm.pFsm.Current() == vlanStConfigVtfd {
+					if oFsm.PAdaptFsm.PFsm.Current() == VlanStConfigVtfd {
 						// Only if CreateResponse is received from first flow entry - let the FSM proceed ...
-						_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvRxConfigVtfd)
+						_ = oFsm.PAdaptFsm.PFsm.Event(VlanEvRxConfigVtfd)
 					} else { // let the MultiEntity config proceed by stopping the wait function
 						oFsm.omciMIdsResponseReceived <- true
 					}
@@ -2074,8 +2066,8 @@
 			"EntitytId":  strconv.FormatInt(int64(evtocdID), 16),
 			"i/oEthType": strconv.FormatInt(int64(cDefaultTpid), 16),
 			"device-id":  oFsm.deviceID})
-		associationType := 2 // default to uniPPTP
-		if oFsm.pOnuUniPort.portType == uniVEIP {
+		associationType := 2 // default to UniPPTP
+		if oFsm.pOnuUniPort.PortType == cmn.UniVEIP {
 			associationType = 10
 		}
 		// Create the EVTOCD ME
@@ -2083,17 +2075,17 @@
 			EntityID: evtocdID,
 			Attributes: me.AttributeValueMap{
 				"AssociationType":     uint8(associationType),
-				"AssociatedMePointer": oFsm.pOnuUniPort.entityID,
+				"AssociatedMePointer": oFsm.pOnuUniPort.EntityID,
 			},
 		}
 		oFsm.mutexPLastTxMeInstance.Lock()
-		meInstance, err := oFsm.pOmciCC.sendCreateEvtocdVar(context.TODO(), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout,
-			true, oFsm.pAdaptFsm.commChan, meParams)
+		meInstance, err := oFsm.pOmciCC.SendCreateEvtocdVar(context.TODO(), oFsm.pDeviceHandler.GetOmciTimeout(),
+			true, oFsm.PAdaptFsm.CommChan, meParams)
 		if err != nil {
 			oFsm.mutexPLastTxMeInstance.Unlock()
 			logger.Errorw(ctx, "CreateEvtocdVar create failed, aborting UniVlanConfigFsm!",
 				log.Fields{"device-id": oFsm.deviceID})
-			_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+			_ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
 			return fmt.Errorf("evtocd instance create failed %s, error %s", oFsm.deviceID, err)
 		}
 		//accept also nil as (error) return value for writing to LastTx
@@ -2106,7 +2098,7 @@
 		if err != nil {
 			logger.Errorw(ctx, "Evtocd create failed, aborting VlanConfig FSM!",
 				log.Fields{"device-id": oFsm.deviceID})
-			_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+			_ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
 			return fmt.Errorf("evtocd create failed %s, error %s", oFsm.deviceID, err)
 		}
 
@@ -2120,14 +2112,14 @@
 			},
 		}
 		oFsm.mutexPLastTxMeInstance.Lock()
-		meInstance, err = oFsm.pOmciCC.sendSetEvtocdVar(log.WithSpanFromContext(context.TODO(), ctx),
-			oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
-			oFsm.pAdaptFsm.commChan, meParams)
+		meInstance, err = oFsm.pOmciCC.SendSetEvtocdVar(log.WithSpanFromContext(context.TODO(), ctx),
+			oFsm.pDeviceHandler.GetOmciTimeout(), true,
+			oFsm.PAdaptFsm.CommChan, meParams)
 		if err != nil {
 			oFsm.mutexPLastTxMeInstance.Unlock()
 			logger.Errorw(ctx, "SetEvtocdVar set failed, aborting UniVlanConfigFsm!",
 				log.Fields{"device-id": oFsm.deviceID})
-			_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+			_ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
 			return fmt.Errorf("evtocd instance set failed %s, error %s", oFsm.deviceID, err)
 		}
 		//accept also nil as (error) return value for writing to LastTx
@@ -2140,7 +2132,7 @@
 		if err != nil {
 			logger.Errorw(ctx, "Evtocd set TPID failed, aborting VlanConfig FSM!",
 				log.Fields{"device-id": oFsm.deviceID})
-			_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+			_ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
 			return fmt.Errorf("evtocd set TPID failed %s, error %s", oFsm.deviceID, err)
 		}
 	} //first flow element
@@ -2182,14 +2174,14 @@
 			},
 		}
 		oFsm.mutexPLastTxMeInstance.Lock()
-		meInstance, err := oFsm.pOmciCC.sendSetEvtocdVar(log.WithSpanFromContext(context.TODO(), ctx),
-			oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
-			oFsm.pAdaptFsm.commChan, meParams)
+		meInstance, err := oFsm.pOmciCC.SendSetEvtocdVar(log.WithSpanFromContext(context.TODO(), ctx),
+			oFsm.pDeviceHandler.GetOmciTimeout(), true,
+			oFsm.PAdaptFsm.CommChan, meParams)
 		if err != nil {
 			oFsm.mutexPLastTxMeInstance.Unlock()
 			logger.Errorw(ctx, "SetEvtocdVar set failed, aborting UniVlanConfigFsm!",
 				log.Fields{"device-id": oFsm.deviceID})
-			_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+			_ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
 			return fmt.Errorf("evtocd instance set failed %s, error %s", oFsm.deviceID, err)
 		}
 		//accept also nil as (error) return value for writing to LastTx
@@ -2202,7 +2194,7 @@
 		if err != nil {
 			logger.Errorw(ctx, "Evtocd set transparent singletagged rule failed, aborting VlanConfig FSM!",
 				log.Fields{"device-id": oFsm.deviceID})
-			_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+			_ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
 			return fmt.Errorf("evtocd set transparent singletagged rule failed %s, error %s", oFsm.deviceID, err)
 
 		}
@@ -2248,14 +2240,14 @@
 				},
 			}
 			oFsm.mutexPLastTxMeInstance.Lock()
-			meInstance, err := oFsm.pOmciCC.sendSetEvtocdVar(log.WithSpanFromContext(context.TODO(), ctx),
-				oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
-				oFsm.pAdaptFsm.commChan, meParams)
+			meInstance, err := oFsm.pOmciCC.SendSetEvtocdVar(log.WithSpanFromContext(context.TODO(), ctx),
+				oFsm.pDeviceHandler.GetOmciTimeout(), true,
+				oFsm.PAdaptFsm.CommChan, meParams)
 			if err != nil {
 				oFsm.mutexPLastTxMeInstance.Unlock()
 				logger.Errorw(ctx, "SetEvtocdVar set failed, aborting UniVlanConfigFsm!",
 					log.Fields{"device-id": oFsm.deviceID})
-				_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+				_ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
 				return fmt.Errorf("evtocd instance set failed %s, error %s", oFsm.deviceID, err)
 			}
 			//accept also nil as (error) return value for writing to LastTx
@@ -2268,7 +2260,7 @@
 			if err != nil {
 				logger.Errorw(ctx, "Evtocd set singletagged translation rule failed, aborting VlanConfig FSM!",
 					log.Fields{"device-id": oFsm.deviceID})
-				_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+				_ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
 				return fmt.Errorf("evtocd set singletagged translation rule failed %s, error %s", oFsm.deviceID, err)
 			}
 		} else {
@@ -2310,14 +2302,14 @@
 					},
 				}
 				oFsm.mutexPLastTxMeInstance.Lock()
-				meInstance, err := oFsm.pOmciCC.sendSetEvtocdVar(log.WithSpanFromContext(context.TODO(), ctx),
-					oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
-					oFsm.pAdaptFsm.commChan, meParams)
+				meInstance, err := oFsm.pOmciCC.SendSetEvtocdVar(log.WithSpanFromContext(context.TODO(), ctx),
+					oFsm.pDeviceHandler.GetOmciTimeout(), true,
+					oFsm.PAdaptFsm.CommChan, meParams)
 				if err != nil {
 					oFsm.mutexPLastTxMeInstance.Unlock()
 					logger.Errorw(ctx, "SetEvtocdVar set failed, aborting UniVlanConfigFsm!",
 						log.Fields{"device-id": oFsm.deviceID})
-					_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+					_ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
 					return fmt.Errorf("evtocd instance set failed %s, error %s", oFsm.deviceID, err)
 				}
 				//accept also nil as (error) return value for writing to LastTx
@@ -2330,7 +2322,7 @@
 				if err != nil {
 					logger.Errorw(ctx, "Evtocd set untagged->singletagged rule failed, aborting VlanConfig FSM!",
 						log.Fields{"device-id": oFsm.deviceID})
-					_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+					_ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
 					return fmt.Errorf("evtocd set untagged->singletagged rule failed %s, error %s", oFsm.deviceID, err)
 
 				}
@@ -2373,14 +2365,14 @@
 					},
 				}
 				oFsm.mutexPLastTxMeInstance.Lock()
-				meInstance, err := oFsm.pOmciCC.sendSetEvtocdVar(log.WithSpanFromContext(context.TODO(), ctx),
-					oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
-					oFsm.pAdaptFsm.commChan, meParams)
+				meInstance, err := oFsm.pOmciCC.SendSetEvtocdVar(log.WithSpanFromContext(context.TODO(), ctx),
+					oFsm.pDeviceHandler.GetOmciTimeout(), true,
+					oFsm.PAdaptFsm.CommChan, meParams)
 				if err != nil {
 					oFsm.mutexPLastTxMeInstance.Unlock()
 					logger.Errorw(ctx, "SetEvtocdVar set failed, aborting UniVlanConfigFsm!",
 						log.Fields{"device-id": oFsm.deviceID})
-					_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+					_ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
 					return fmt.Errorf("evtocd instance set failed %s, error %s", oFsm.deviceID, err)
 				}
 				//accept also nil as (error) return value for writing to LastTx
@@ -2393,7 +2385,7 @@
 				if err != nil {
 					logger.Errorw(ctx, "Evtocd set priotagged->singletagged rule failed, aborting VlanConfig FSM!",
 						log.Fields{"device-id": oFsm.deviceID})
-					_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+					_ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
 					return fmt.Errorf("evtocd set priotagged->singletagged rule failed %s, error %s", oFsm.deviceID, err)
 
 				}
@@ -2404,12 +2396,12 @@
 	// if Config has been done for all EVTOCD entries let the FSM proceed
 	logger.Debugw(ctx, "EVTOCD set loop finished", log.Fields{"device-id": oFsm.deviceID})
 	oFsm.mutexFlowParams.Lock()
-	oFsm.configuredUniFlow++ // one (more) flow configured
+	oFsm.ConfiguredUniFlow++ // one (more) flow configured
 	oFsm.mutexFlowParams.Unlock()
 	return nil
 }
 
-func (oFsm *UniVlanConfigFsm) removeEvtocdEntries(ctx context.Context, aRuleParams uniVlanRuleParams) {
+func (oFsm *UniVlanConfigFsm) removeEvtocdEntries(ctx context.Context, aRuleParams cmn.UniVlanRuleParams) {
 	oFsm.mutexFlowParams.RLock()
 	evtocdID := oFsm.evtocdID
 	oFsm.mutexFlowParams.RUnlock()
@@ -2452,14 +2444,14 @@
 			},
 		}
 		oFsm.mutexPLastTxMeInstance.Lock()
-		meInstance, err := oFsm.pOmciCC.sendSetEvtocdVar(log.WithSpanFromContext(context.TODO(), ctx),
-			oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
-			oFsm.pAdaptFsm.commChan, meParams)
+		meInstance, err := oFsm.pOmciCC.SendSetEvtocdVar(log.WithSpanFromContext(context.TODO(), ctx),
+			oFsm.pDeviceHandler.GetOmciTimeout(), true,
+			oFsm.PAdaptFsm.CommChan, meParams)
 		if err != nil {
 			oFsm.mutexPLastTxMeInstance.Unlock()
 			logger.Errorw(ctx, "SetEvtocdVar set failed, aborting UniVlanConfigFsm!",
 				log.Fields{"device-id": oFsm.deviceID})
-			_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+			_ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
 			return
 		}
 		//accept also nil as (error) return value for writing to LastTx
@@ -2472,7 +2464,7 @@
 		if err != nil {
 			logger.Errorw(ctx, "Evtocd reset singletagged rule failed, aborting VlanConfig FSM!",
 				log.Fields{"device-id": oFsm.deviceID})
-			_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+			_ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
 			return
 		}
 	} else {
@@ -2507,14 +2499,14 @@
 				},
 			}
 			oFsm.mutexPLastTxMeInstance.Lock()
-			meInstance, err := oFsm.pOmciCC.sendSetEvtocdVar(log.WithSpanFromContext(context.TODO(), ctx),
-				oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
-				oFsm.pAdaptFsm.commChan, meParams)
+			meInstance, err := oFsm.pOmciCC.SendSetEvtocdVar(log.WithSpanFromContext(context.TODO(), ctx),
+				oFsm.pDeviceHandler.GetOmciTimeout(), true,
+				oFsm.PAdaptFsm.CommChan, meParams)
 			if err != nil {
 				oFsm.mutexPLastTxMeInstance.Unlock()
 				logger.Errorw(ctx, "SetEvtocdVar set failed, aborting UniVlanConfigFsm!",
 					log.Fields{"device-id": oFsm.deviceID})
-				_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+				_ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
 				return
 			}
 			//accept also nil as (error) return value for writing to LastTx
@@ -2527,7 +2519,7 @@
 			if err != nil {
 				logger.Errorw(ctx, "Evtocd clear singletagged translation rule failed, aborting VlanConfig FSM!",
 					log.Fields{"device-id": oFsm.deviceID, "match-vlan": aRuleParams.MatchVid})
-				_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+				_ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
 				return
 			}
 		} else {
@@ -2541,7 +2533,7 @@
 			// there is only one service vlan (oFsm.acceptIncrementalEvtoOption is false in this case).
 			// Interstingly this problem has not been observed in multi-tcont (or multi-service) scenario (in
 			// which case the oFsm.acceptIncrementalEvtoOption is set to true).
-			if oFsm.configuredUniFlow == 1 && !oFsm.acceptIncrementalEvtoOption {
+			if oFsm.ConfiguredUniFlow == 1 && !oFsm.acceptIncrementalEvtoOption {
 				oFsm.mutexFlowParams.RUnlock()
 				logger.Debugw(ctx, "UniVlanConfigFsm Tx Remove::EVTOCD", log.Fields{"device-id": oFsm.deviceID})
 				// When there are no more EVTOCD vlan configurations on the ONU and acceptIncrementalEvtoOption
@@ -2550,14 +2542,14 @@
 					EntityID: evtocdID,
 				}
 				oFsm.mutexPLastTxMeInstance.Lock()
-				meInstance, err := oFsm.pOmciCC.sendDeleteEvtocd(log.WithSpanFromContext(context.TODO(), ctx),
-					oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
-					oFsm.pAdaptFsm.commChan, meParams)
+				meInstance, err := oFsm.pOmciCC.SendDeleteEvtocd(log.WithSpanFromContext(context.TODO(), ctx),
+					oFsm.pDeviceHandler.GetOmciTimeout(), true,
+					oFsm.PAdaptFsm.CommChan, meParams)
 				if err != nil {
 					oFsm.mutexPLastTxMeInstance.Unlock()
 					logger.Errorw(ctx, "DeleteEvtocdVar delete failed, aborting UniVlanConfigFsm!",
 						log.Fields{"device-id": oFsm.deviceID})
-					_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+					_ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
 					return
 				}
 				//accept also nil as (error) return value for writing to LastTx
@@ -2570,14 +2562,14 @@
 				if err != nil {
 					logger.Errorw(ctx, "Evtocd delete rule failed, aborting VlanConfig FSM!",
 						log.Fields{"device-id": oFsm.deviceID})
-					_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+					_ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
 					return
 				}
 			} else {
 				// NOTE : We should ideally never ether this section when oFsm.acceptIncrementalEvtoOption is set to false
 				// This is true for only ATT/DT workflow
 				logger.Debugw(ctx, "UniVlanConfigFsm: Remove EVTOCD set operation",
-					log.Fields{"configured-flow": oFsm.configuredUniFlow, "incremental-evto": oFsm.acceptIncrementalEvtoOption})
+					log.Fields{"configured-flow": oFsm.ConfiguredUniFlow, "incremental-evto": oFsm.acceptIncrementalEvtoOption})
 				oFsm.mutexFlowParams.RUnlock()
 				//not transparent and not acceptIncrementalEvtoOption: untagged/priotagged->singletagged
 				{ // just for local var's
@@ -2619,14 +2611,14 @@
 						},
 					}
 					oFsm.mutexPLastTxMeInstance.Lock()
-					meInstance, err := oFsm.pOmciCC.sendSetEvtocdVar(context.TODO(),
-						oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
-						oFsm.pAdaptFsm.commChan, meParams)
+					meInstance, err := oFsm.pOmciCC.SendSetEvtocdVar(context.TODO(),
+						oFsm.pDeviceHandler.GetOmciTimeout(), true,
+						oFsm.PAdaptFsm.CommChan, meParams)
 					if err != nil {
 						oFsm.mutexPLastTxMeInstance.Unlock()
 						logger.Errorw(ctx, "SetEvtocdVar set failed, aborting UniVlanConfigFsm!",
 							log.Fields{"device-id": oFsm.deviceID})
-						_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+						_ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
 						return
 					}
 					//accept also nil as (error) return value for writing to LastTx
@@ -2639,7 +2631,7 @@
 					if err != nil {
 						logger.Errorw(ctx, "Evtocd reset untagged rule to default failed, aborting VlanConfig FSM!",
 							log.Fields{"device-id": oFsm.deviceID})
-						_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+						_ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
 						return
 					}
 				} // just for local var's
@@ -2671,14 +2663,14 @@
 						},
 					}
 					oFsm.mutexPLastTxMeInstance.Lock()
-					meInstance, err := oFsm.pOmciCC.sendSetEvtocdVar(log.WithSpanFromContext(context.TODO(), ctx),
-						oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
-						oFsm.pAdaptFsm.commChan, meParams)
+					meInstance, err := oFsm.pOmciCC.SendSetEvtocdVar(log.WithSpanFromContext(context.TODO(), ctx),
+						oFsm.pDeviceHandler.GetOmciTimeout(), true,
+						oFsm.PAdaptFsm.CommChan, meParams)
 					if err != nil {
 						oFsm.mutexPLastTxMeInstance.Unlock()
 						logger.Errorw(ctx, "SetEvtocdVar set failed, aborting UniVlanConfigFsm!",
 							log.Fields{"device-id": oFsm.deviceID})
-						_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+						_ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
 						return
 					}
 					//accept also nil as (error) return value for writing to LastTx
@@ -2691,7 +2683,7 @@
 					if err != nil {
 						logger.Errorw(ctx, "Evtocd delete priotagged rule failed, aborting VlanConfig FSM!",
 							log.Fields{"device-id": oFsm.deviceID})
-						_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+						_ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
 						return
 					}
 				}
@@ -2700,7 +2692,7 @@
 	}
 	// if Config has been done for all EVTOCD entries let the FSM proceed
 	logger.Debugw(ctx, "EVTOCD filter remove loop finished", log.Fields{"device-id": oFsm.deviceID})
-	_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvRemFlowDone, aRuleParams.TpID)
+	_ = oFsm.PAdaptFsm.PFsm.Event(VlanEvRemFlowDone, aRuleParams.TpID)
 }
 
 func (oFsm *UniVlanConfigFsm) waitforOmciResponse(ctx context.Context) error {
@@ -2709,7 +2701,7 @@
 		// FSM already canceled before entering wait
 		logger.Debugw(ctx, "UniVlanConfigFsm wait-for-multi-entity-response aborted (on enter)", log.Fields{"for device-id": oFsm.deviceID})
 		oFsm.mutexIsAwaitingResponse.Unlock()
-		return fmt.Errorf(cErrWaitAborted)
+		return fmt.Errorf(cmn.CErrWaitAborted)
 	}
 	oFsm.isAwaitingResponse = true
 	oFsm.mutexIsAwaitingResponse.Unlock()
@@ -2736,7 +2728,7 @@
 		oFsm.mutexIsAwaitingResponse.Lock()
 		oFsm.isAwaitingResponse = false
 		oFsm.mutexIsAwaitingResponse.Unlock()
-		return fmt.Errorf(cErrWaitAborted)
+		return fmt.Errorf(cmn.CErrWaitAborted)
 	}
 }
 
@@ -2747,7 +2739,7 @@
 	if errCreateMOP != nil {
 		logger.Errorw(ctx, "MulticastOperationProfile create failed, aborting AniConfig FSM!",
 			log.Fields{"device-id": oFsm.deviceID})
-		_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+		_ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
 		return fmt.Errorf("creatingMulticastSubscriberConfigInfo responseError %s, error %s", oFsm.deviceID, errCreateMOP)
 	}
 
@@ -2755,7 +2747,7 @@
 	if errSettingMOP != nil {
 		logger.Errorw(ctx, "MulticastOperationProfile setting failed, aborting AniConfig FSM!",
 			log.Fields{"device-id": oFsm.deviceID})
-		_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+		_ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
 		return fmt.Errorf("creatingMulticastSubscriberConfigInfo responseError %s, error %s", oFsm.deviceID, errSettingMOP)
 	}
 
@@ -2763,37 +2755,37 @@
 	if errCreateMSCI != nil {
 		logger.Errorw(ctx, "MulticastOperationProfile setting failed, aborting AniConfig FSM!",
 			log.Fields{"device-id": oFsm.deviceID})
-		_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+		_ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
 		return fmt.Errorf("creatingMulticastSubscriberConfigInfo responseError %s, error %s", oFsm.deviceID, errCreateMSCI)
 	}
-	macBpCdEID, errMacBpCdEID := generateMcastANISideMBPCDEID(uint16(oFsm.pOnuUniPort.macBpNo))
+	macBpCdEID, errMacBpCdEID := cmn.GenerateMcastANISideMBPCDEID(uint16(oFsm.pOnuUniPort.MacBpNo))
 	if errMacBpCdEID != nil {
 		logger.Errorw(ctx, "MulticastMacBridgePortConfigData entity id generation failed, aborting AniConfig FSM!",
 			log.Fields{"device-id": oFsm.deviceID})
-		_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+		_ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
 		return fmt.Errorf("generateMcastANISideMBPCDEID responseError %s, error %s", oFsm.deviceID, errMacBpCdEID)
 
 	}
 	logger.Debugw(ctx, "UniVlanConfigFsm set macBpCdEID for mcast", log.Fields{
-		"EntitytId": strconv.FormatInt(int64(macBpCdEID), 16), "macBpNo": oFsm.pOnuUniPort.macBpNo,
-		"in state": oFsm.pAdaptFsm.pFsm.Current(), "device-id": oFsm.deviceID})
+		"EntitytId": strconv.FormatInt(int64(macBpCdEID), 16), "macBpNo": oFsm.pOnuUniPort.MacBpNo,
+		"in state": oFsm.PAdaptFsm.PFsm.Current(), "device-id": oFsm.deviceID})
 	meParams := me.ParamData{
 		EntityID: macBpCdEID,
 		Attributes: me.AttributeValueMap{
-			"BridgeIdPointer": macBridgeServiceProfileEID + uint16(oFsm.pOnuUniPort.macBpNo),
+			"BridgeIdPointer": cmn.MacBridgeServiceProfileEID + uint16(oFsm.pOnuUniPort.MacBpNo),
 			"PortNum":         0xf0, //fixed unique ANI side indication
 			"TpType":          6,    //MCGemIWTP
 			"TpPointer":       multicastGemPortID,
 		},
 	}
 	oFsm.mutexPLastTxMeInstance.Lock()
-	meInstance, err := oFsm.pOmciCC.sendCreateMBPConfigDataVar(context.TODO(),
-		oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true, oFsm.pAdaptFsm.commChan, meParams)
+	meInstance, err := oFsm.pOmciCC.SendCreateMBPConfigDataVar(context.TODO(),
+		oFsm.pDeviceHandler.GetOmciTimeout(), true, oFsm.PAdaptFsm.CommChan, meParams)
 	if err != nil {
 		oFsm.mutexPLastTxMeInstance.Unlock()
 		logger.Errorw(ctx, "MBPConfigDataVar create failed, aborting AniConfig FSM!",
 			log.Fields{"device-id": oFsm.deviceID})
-		_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+		_ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
 		return fmt.Errorf("creatingMulticastSubscriberConfigInfo createError #{oFsm.deviceID}, error #{err}")
 	}
 	//accept also nil as (error) return value for writing to LastTx
@@ -2803,8 +2795,8 @@
 	err = oFsm.waitforOmciResponse(ctx)
 	if err != nil {
 		logger.Errorw(ctx, "CreateMBPConfigData failed, aborting AniConfig FSM!",
-			log.Fields{"device-id": oFsm.deviceID, "MBPConfigDataID": macBridgeServiceProfileEID})
-		_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+			log.Fields{"device-id": oFsm.deviceID, "MBPConfigDataID": cmn.MacBridgeServiceProfileEID})
+		_ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
 		return fmt.Errorf("creatingMulticastSubscriberConfigInfo responseError %s, error %s", oFsm.deviceID, err)
 	}
 
@@ -2816,7 +2808,7 @@
 
 	logger.Debugw(ctx, "UniVlanConfigFsm set VTFD for mcast", log.Fields{
 		"EntitytId": strconv.FormatInt(int64(mcastVtfdID), 16), "mcastVlanID": vlanID,
-		"in state": oFsm.pAdaptFsm.pFsm.Current(), "device-id": oFsm.deviceID})
+		"in state": oFsm.PAdaptFsm.PFsm.Current(), "device-id": oFsm.deviceID})
 	vtfdFilterList := make([]uint16, cVtfdTableSize) //needed for parameter serialization
 
 	// FIXME: VOL-3685: Issues with resetting a table entry in EVTOCD ME
@@ -2833,13 +2825,13 @@
 		},
 	}
 	oFsm.mutexPLastTxMeInstance.Lock()
-	meInstance, err = oFsm.pOmciCC.sendCreateVtfdVar(context.TODO(),
-		oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true, oFsm.pAdaptFsm.commChan, meParams)
+	meInstance, err = oFsm.pOmciCC.SendCreateVtfdVar(context.TODO(),
+		oFsm.pDeviceHandler.GetOmciTimeout(), true, oFsm.PAdaptFsm.CommChan, meParams)
 	if err != nil {
 		oFsm.mutexPLastTxMeInstance.Unlock()
 		logger.Errorw(ctx, "CreateVtfdVar create failed, aborting UniVlanConfigFsm!",
 			log.Fields{"device-id": oFsm.deviceID})
-		_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+		_ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
 		return fmt.Errorf("createMcastVlanFilterData creationError %s, error %s", oFsm.deviceID, err)
 	}
 	oFsm.pLastTxMeInstance = meInstance
@@ -2848,7 +2840,7 @@
 	if err != nil {
 		logger.Errorw(ctx, "CreateMcastVlanFilterData failed, aborting AniConfig FSM!",
 			log.Fields{"device-id": oFsm.deviceID, "mcastVtfdID": mcastVtfdID})
-		_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+		_ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
 		return fmt.Errorf("createMcastVlanFilterData responseError %s, error %s", oFsm.deviceID, err)
 	}
 
@@ -2856,7 +2848,7 @@
 }
 
 func (oFsm *UniVlanConfigFsm) performCreatingMulticastSubscriberConfigInfo(ctx context.Context) error {
-	instID, err := generateUNISideMBPCDEID(uint16(oFsm.pOnuUniPort.macBpNo))
+	instID, err := cmn.GenerateUNISideMBPCDEID(uint16(oFsm.pOnuUniPort.MacBpNo))
 	if err != nil {
 		logger.Errorw(ctx, "error generrating me instance id",
 			log.Fields{"device-id": oFsm.deviceID, "error": err})
@@ -2874,14 +2866,14 @@
 		},
 	}
 	oFsm.mutexPLastTxMeInstance.Lock()
-	meInstance, err := oFsm.pOmciCC.sendCreateMulticastSubConfigInfoVar(context.TODO(),
-		oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
-		oFsm.pAdaptFsm.commChan, meParams)
+	meInstance, err := oFsm.pOmciCC.SendCreateMulticastSubConfigInfoVar(context.TODO(),
+		oFsm.pDeviceHandler.GetOmciTimeout(), true,
+		oFsm.PAdaptFsm.CommChan, meParams)
 	if err != nil {
 		oFsm.mutexPLastTxMeInstance.Unlock()
 		logger.Errorw(ctx, "CreateMulticastSubConfigInfoVar create failed, aborting UniVlanConfigFSM!",
 			log.Fields{"device-id": oFsm.deviceID})
-		_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+		_ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
 		return fmt.Errorf("creatingMulticastSubscriberConfigInfo interface creationError %s, error %s",
 			oFsm.deviceID, err)
 	}
@@ -2900,7 +2892,7 @@
 }
 
 func (oFsm *UniVlanConfigFsm) performCreatingMulticastOperationProfile(ctx context.Context) error {
-	instID, err := generateUNISideMBPCDEID(uint16(oFsm.pOnuUniPort.macBpNo))
+	instID, err := cmn.GenerateUNISideMBPCDEID(uint16(oFsm.pOnuUniPort.MacBpNo))
 	if err != nil {
 		logger.Errorw(ctx, "error generating me instance id",
 			log.Fields{"device-id": oFsm.deviceID, "error": err})
@@ -2925,14 +2917,14 @@
 		},
 	}
 	oFsm.mutexPLastTxMeInstance.Lock()
-	meInstance, err := oFsm.pOmciCC.sendCreateMulticastOperationProfileVar(context.TODO(),
-		oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
-		oFsm.pAdaptFsm.commChan, meParams)
+	meInstance, err := oFsm.pOmciCC.SendCreateMulticastOperationProfileVar(context.TODO(),
+		oFsm.pDeviceHandler.GetOmciTimeout(), true,
+		oFsm.PAdaptFsm.CommChan, meParams)
 	if err != nil {
 		oFsm.mutexPLastTxMeInstance.Unlock()
 		logger.Errorw(ctx, "CreateMulticastOperationProfileVar create failed, aborting UniVlanConfigFsm!",
 			log.Fields{"device-id": oFsm.deviceID})
-		_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+		_ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
 		return fmt.Errorf("createMulticastOperationProfileVar responseError %s, error %s", oFsm.deviceID, err)
 	}
 	//accept also nil as (error) return value for writing to LastTx
@@ -2950,7 +2942,7 @@
 }
 
 func (oFsm *UniVlanConfigFsm) performSettingMulticastOperationProfile(ctx context.Context, multicastGemPortID uint16, vlanID uint32) error {
-	instID, err := generateUNISideMBPCDEID(uint16(oFsm.pOnuUniPort.macBpNo))
+	instID, err := cmn.GenerateUNISideMBPCDEID(uint16(oFsm.pOnuUniPort.MacBpNo))
 	if err != nil {
 		logger.Errorw(ctx, "error generating me instance id",
 			log.Fields{"device-id": oFsm.deviceID, "error": err})
@@ -2965,7 +2957,7 @@
 	//test = 0
 	//rowKey = 0
 	tableCtrlStr := "0100000000000000"
-	tableCtrl := AsByteSlice(tableCtrlStr)
+	tableCtrl := cmn.AsByteSlice(tableCtrlStr)
 	dynamicAccessCL := make([]uint8, 24)
 	copy(dynamicAccessCL, tableCtrl)
 	//Multicast GemPortId
@@ -2974,12 +2966,12 @@
 	// brcm_openomci_onu_handler.py
 	binary.BigEndian.PutUint16(dynamicAccessCL[4:], uint16(vlanID))
 	//Source IP all to 0
-	binary.BigEndian.PutUint32(dynamicAccessCL[6:], IPToInt32(net.IPv4(0, 0, 0, 0)))
+	binary.BigEndian.PutUint32(dynamicAccessCL[6:], cmn.IPToInt32(net.IPv4(0, 0, 0, 0)))
 	//TODO start and end are hardcoded, get from TP
 	// Destination IP address start of range
-	binary.BigEndian.PutUint32(dynamicAccessCL[10:], IPToInt32(net.IPv4(225, 0, 0, 0)))
+	binary.BigEndian.PutUint32(dynamicAccessCL[10:], cmn.IPToInt32(net.IPv4(225, 0, 0, 0)))
 	// Destination IP address end of range
-	binary.BigEndian.PutUint32(dynamicAccessCL[14:], IPToInt32(net.IPv4(239, 255, 255, 255)))
+	binary.BigEndian.PutUint32(dynamicAccessCL[14:], cmn.IPToInt32(net.IPv4(239, 255, 255, 255)))
 	//imputed group bandwidth
 	binary.BigEndian.PutUint16(dynamicAccessCL[18:], 0)
 
@@ -2990,14 +2982,14 @@
 		},
 	}
 	oFsm.mutexPLastTxMeInstance.Lock()
-	meInstance, err := oFsm.pOmciCC.sendSetMulticastOperationProfileVar(context.TODO(),
-		oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
-		oFsm.pAdaptFsm.commChan, meParams)
+	meInstance, err := oFsm.pOmciCC.SendSetMulticastOperationProfileVar(context.TODO(),
+		oFsm.pDeviceHandler.GetOmciTimeout(), true,
+		oFsm.PAdaptFsm.CommChan, meParams)
 	if err != nil {
 		oFsm.mutexPLastTxMeInstance.Unlock()
 		logger.Errorw(ctx, "SetMulticastOperationProfileVar set failed, aborting UniVlanConfigFsm!",
 			log.Fields{"device-id": oFsm.deviceID})
-		_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+		_ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
 		return fmt.Errorf("setMulticastOperationProfile responseError %s, error %s", oFsm.deviceID, err)
 	}
 	//accept also nil as (error) return value for writing to LastTx
@@ -3049,8 +3041,8 @@
 		},
 	}
 	oFsm.mutexPLastTxMeInstance.Lock()
-	meInstance, errCreateTD := oFsm.pOmciCC.sendCreateTDVar(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout,
-		true, oFsm.pAdaptFsm.commChan, meParams)
+	meInstance, errCreateTD := oFsm.pOmciCC.SendCreateTDVar(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(),
+		true, oFsm.PAdaptFsm.CommChan, meParams)
 	if errCreateTD != nil {
 		oFsm.mutexPLastTxMeInstance.Unlock()
 		logger.Errorw(ctx, "Traffic Descriptor create failed", log.Fields{"device-id": oFsm.deviceID})
@@ -3085,8 +3077,8 @@
 		},
 	}
 	oFsm.mutexPLastTxMeInstance.Lock()
-	meInstance, err := oFsm.pOmciCC.sendSetGemNCTPVar(log.WithSpanFromContext(context.TODO(), ctx),
-		oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true, oFsm.pAdaptFsm.commChan, meParams)
+	meInstance, err := oFsm.pOmciCC.SendSetGemNCTPVar(log.WithSpanFromContext(context.TODO(), ctx),
+		oFsm.pDeviceHandler.GetOmciTimeout(), true, oFsm.PAdaptFsm.CommChan, meParams)
 	if err != nil {
 		oFsm.mutexPLastTxMeInstance.Unlock()
 		logger.Errorw(ctx, "GemNCTP set failed", log.Fields{"device-id": oFsm.deviceID})
diff --git a/internal/pkg/onuadaptercore/onu_uni_tp.go b/internal/pkg/avcfg/onu_uni_tp.go
old mode 100644
new mode 100755
similarity index 88%
rename from internal/pkg/onuadaptercore/onu_uni_tp.go
rename to internal/pkg/avcfg/onu_uni_tp.go
index 1e3f9af..efb69be
--- a/internal/pkg/onuadaptercore/onu_uni_tp.go
+++ b/internal/pkg/avcfg/onu_uni_tp.go
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package avcfg provides anig and vlan configuration functionality
+package avcfg
 
 import (
 	"context"
@@ -25,6 +25,7 @@
 	"sync"
 
 	"github.com/opencord/voltha-lib-go/v7/pkg/log"
+	cmn "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/common"
 	"github.com/opencord/voltha-protos/v5/go/tech_profile"
 )
 
@@ -37,11 +38,13 @@
 	//binaryBit1 = '1'
 )
 
-type resourceEntry int
+// ResourceEntry - TODO: add comment
+type ResourceEntry int
 
+// TODO: add comment
 const (
-	cResourceGemPort resourceEntry = 1
-	cResourceTcont   resourceEntry = 2
+	CResourceGemPort ResourceEntry = 1
+	CResourceTcont   ResourceEntry = 2
 )
 
 type tTechProfileIndication struct {
@@ -87,15 +90,16 @@
 	tpID  uint8
 }
 
-//onuUniTechProf structure holds information about the TechProfiles attached to Uni Ports of the ONU
-type onuUniTechProf struct {
-	baseDeviceHandler        *deviceHandler
+//OnuUniTechProf structure holds information about the TechProfiles attached to Uni Ports of the ONU
+type OnuUniTechProf struct {
 	deviceID                 string
+	baseDeviceHandler        cmn.IdeviceHandler
+	onuDevice                cmn.IonuDeviceEntry
 	tpProcMutex              sync.RWMutex
 	chTpConfigProcessingStep chan uint8
 	mapUniTpIndication       map[uniTP]*tTechProfileIndication //use pointer values to ease assignments to the map
 	mapPonAniConfig          map[uniTP]*tcontGemList           //per UNI: use pointer values to ease assignments to the map
-	pAniConfigFsm            map[uniTP]*uniPonAniConfigFsm
+	PAniConfigFsm            map[uniTP]*UniPonAniConfigFsm
 	procResult               map[uniTP]error //error indication of processing
 	mutexTPState             sync.RWMutex
 	tpProfileExists          map[uniTP]bool
@@ -103,8 +107,8 @@
 	mapRemoveGemEntry        map[uniTP]*gemPortParamStruct //per UNI: pointer to GemEntry to be removed
 }
 
-func (onuTP *onuUniTechProf) multicastConfiguredForOtherUniTps(ctx context.Context, uniTpKey uniTP) bool {
-	for _, aniFsm := range onuTP.pAniConfigFsm {
+func (onuTP *OnuUniTechProf) multicastConfiguredForOtherUniTps(ctx context.Context, uniTpKey uniTP) bool {
+	for _, aniFsm := range onuTP.PAniConfigFsm {
 		if aniFsm.uniTpKey.uniID == uniTpKey.uniID && aniFsm.uniTpKey.tpID == uniTpKey.tpID {
 			continue
 		}
@@ -115,13 +119,15 @@
 	return false
 }
 
-//newOnuUniTechProf returns the instance of a OnuUniTechProf
+//NewOnuUniTechProf returns the instance of a OnuUniTechProf
 //(one instance per ONU/deviceHandler for all possible UNI's)
-func newOnuUniTechProf(ctx context.Context, aDeviceHandler *deviceHandler) *onuUniTechProf {
-	logger.Debugw(ctx, "init-OnuUniTechProf", log.Fields{"device-id": aDeviceHandler.deviceID})
-	var onuTP onuUniTechProf
+func NewOnuUniTechProf(ctx context.Context, aDeviceHandler cmn.IdeviceHandler, aOnuDev cmn.IonuDeviceEntry) *OnuUniTechProf {
+
+	var onuTP OnuUniTechProf
+	onuTP.deviceID = aDeviceHandler.GetDeviceID()
+	logger.Debugw(ctx, "init-OnuUniTechProf", log.Fields{"device-id": onuTP.deviceID})
 	onuTP.baseDeviceHandler = aDeviceHandler
-	onuTP.deviceID = aDeviceHandler.deviceID
+	onuTP.onuDevice = aOnuDev
 	onuTP.chTpConfigProcessingStep = make(chan uint8)
 	onuTP.mapUniTpIndication = make(map[uniTP]*tTechProfileIndication)
 	onuTP.mapPonAniConfig = make(map[uniTP]*tcontGemList)
@@ -133,40 +139,41 @@
 	return &onuTP
 }
 
-// lockTpProcMutex locks OnuUniTechProf processing mutex
-func (onuTP *onuUniTechProf) lockTpProcMutex() {
+// LockTpProcMutex locks OnuUniTechProf processing mutex
+func (onuTP *OnuUniTechProf) LockTpProcMutex() {
 	onuTP.tpProcMutex.Lock()
 }
 
-// unlockTpProcMutex unlocks OnuUniTechProf processing mutex
-func (onuTP *onuUniTechProf) unlockTpProcMutex() {
+// UnlockTpProcMutex unlocks OnuUniTechProf processing mutex
+func (onuTP *OnuUniTechProf) UnlockTpProcMutex() {
 	onuTP.tpProcMutex.Unlock()
 }
 
-// resetTpProcessingErrorIndication resets the internal error indication
+// ResetTpProcessingErrorIndication resets the internal error indication
 // need to be called before evaluation of any subsequent processing (given by waitForTpCompletion())
-func (onuTP *onuUniTechProf) resetTpProcessingErrorIndication(aUniID uint8, aTpID uint8) {
+func (onuTP *OnuUniTechProf) ResetTpProcessingErrorIndication(aUniID uint8, aTpID uint8) {
 	onuTP.mutexTPState.Lock()
 	defer onuTP.mutexTPState.Unlock()
 	onuTP.procResult[uniTP{uniID: aUniID, tpID: aTpID}] = nil
 }
 
-func (onuTP *onuUniTechProf) getTpProcessingErrorIndication(aUniID uint8, aTpID uint8) error {
+// GetTpProcessingErrorIndication - TODO: add comment
+func (onuTP *OnuUniTechProf) GetTpProcessingErrorIndication(aUniID uint8, aTpID uint8) error {
 	onuTP.mutexTPState.RLock()
 	defer onuTP.mutexTPState.RUnlock()
 	return onuTP.procResult[uniTP{uniID: aUniID, tpID: aTpID}]
 }
 
-// configureUniTp checks existing tp resources to configure and starts the corresponding OMCI configuation of the UNI port
+// ConfigureUniTp checks existing tp resources to configure and starts the corresponding OMCI configuation of the UNI port
 // all possibly blocking processing must be run in background to allow for deadline supervision!
 // but take care on sequential background processing when needed (logical dependencies)
 //   use waitForTimeoutOrCompletion(ctx, chTpConfigProcessingStep, processingStep) for internal synchronization
-func (onuTP *onuUniTechProf) configureUniTp(ctx context.Context,
+func (onuTP *OnuUniTechProf) ConfigureUniTp(ctx context.Context,
 	aUniID uint8, aPathString string, tpInst tech_profile.TechProfileInstance, wg *sync.WaitGroup) {
 	defer wg.Done() //always decrement the waitGroup on return
 	logger.Debugw(ctx, "configure the Uni according to TpPath", log.Fields{
 		"device-id": onuTP.deviceID, "uni-id": aUniID, "path": aPathString})
-	tpID, err := GetTpIDFromTpPath(aPathString)
+	tpID, err := cmn.GetTpIDFromTpPath(aPathString)
 	uniTpKey := uniTP{uniID: aUniID, tpID: tpID}
 	if err != nil {
 		logger.Errorw(ctx, "error-extracting-tp-id-from-tp-path", log.Fields{"device-id": onuTP.deviceID, "uni-id": aUniID, "path": aPathString})
@@ -174,10 +181,10 @@
 	}
 
 	//ensure that the given uniID is available (configured) in the UniPort class (used for OMCI entities)
-	var pCurrentUniPort *onuUniPort
-	for _, uniPort := range onuTP.baseDeviceHandler.uniEntityMap {
+	var pCurrentUniPort *cmn.OnuUniPort
+	for _, uniPort := range *onuTP.baseDeviceHandler.GetUniEntityMap() {
 		// only if this port is validated for operState transfer
-		if uniPort.uniID == aUniID {
+		if uniPort.UniID == aUniID {
 			pCurrentUniPort = uniPort
 			break //found - end search loop
 		}
@@ -204,7 +211,7 @@
 	}
 	var processingStep uint8 = 1 // used to synchronize the different processing steps with chTpConfigProcessingStep
 
-	//according to updateOnuUniTpPath() logic the assumption here is, that this configuration is only called
+	//according to UpdateOnuUniTpPath() logic the assumption here is, that this configuration is only called
 	//  in case the KVPath has changed for the given UNI,
 	//  as T-Cont and Gem-Id's are dependent on TechProfile-Id this means, that possibly previously existing
 	//  (ANI) configuration of this port has to be removed first
@@ -280,8 +287,8 @@
 				//this issue here means that the AniConfigFsm has not finished successfully
 				//which requires to reset it to allow for new usage, e.g. also on a different UNI
 				//(without that it would be reset on device down indication latest)
-				if _, ok := onuTP.pAniConfigFsm[uniTpKey]; ok {
-					_ = onuTP.pAniConfigFsm[uniTpKey].pAdaptFsm.pFsm.Event(aniEvReset)
+				if _, ok := onuTP.PAniConfigFsm[uniTpKey]; ok {
+					_ = onuTP.PAniConfigFsm[uniTpKey].PAdaptFsm.PFsm.Event(aniEvReset)
 				}
 				return
 			}
@@ -309,7 +316,7 @@
 
 /* internal methods *********************/
 // nolint: gocyclo
-func (onuTP *onuUniTechProf) readAniSideConfigFromTechProfile(
+func (onuTP *OnuUniTechProf) readAniSideConfigFromTechProfile(
 	ctx context.Context, aUniID uint8, aTpID uint8, aPathString string, tpInst tech_profile.TechProfileInstance, aProcessingStep uint8) {
 	var err error
 	//store profile type and identifier for later usage within the OMCI identifier and possibly ME setup
@@ -525,33 +532,33 @@
 	onuTP.chTpConfigProcessingStep <- aProcessingStep //done
 }
 
-func (onuTP *onuUniTechProf) setAniSideConfigFromTechProfile(
-	ctx context.Context, aUniID uint8, aTpID uint8, apCurrentUniPort *onuUniPort, aProcessingStep uint8) error {
+func (onuTP *OnuUniTechProf) setAniSideConfigFromTechProfile(
+	ctx context.Context, aUniID uint8, aTpID uint8, apCurrentUniPort *cmn.OnuUniPort, aProcessingStep uint8) error {
 
 	//OMCI transfer of ANI data acc. to mapPonAniConfig
 	// also the FSM's are running in background,
 	//   hence we have to make sure they indicate 'success' on chTpConfigProcessingStep with aProcessingStep
 	uniTPKey := uniTP{uniID: aUniID, tpID: aTpID}
-	if onuTP.pAniConfigFsm == nil {
-		return onuTP.createAniConfigFsm(ctx, aUniID, aTpID, apCurrentUniPort, OmciAniConfigDone, aProcessingStep)
-	} else if _, ok := onuTP.pAniConfigFsm[uniTPKey]; !ok {
-		return onuTP.createAniConfigFsm(ctx, aUniID, aTpID, apCurrentUniPort, OmciAniConfigDone, aProcessingStep)
+	if onuTP.PAniConfigFsm == nil {
+		return onuTP.createAniConfigFsm(ctx, aUniID, aTpID, apCurrentUniPort, cmn.OmciAniConfigDone, aProcessingStep)
+	} else if _, ok := onuTP.PAniConfigFsm[uniTPKey]; !ok {
+		return onuTP.createAniConfigFsm(ctx, aUniID, aTpID, apCurrentUniPort, cmn.OmciAniConfigDone, aProcessingStep)
 	}
 	//AniConfigFsm already init
 	return onuTP.runAniConfigFsm(ctx, aniEvStart, aProcessingStep, aUniID, aTpID)
 }
 
-// deleteTpResource removes Resources from the ONU's specified Uni
+// DeleteTpResource removes Resources from the ONU's specified Uni
 // nolint: gocyclo
-func (onuTP *onuUniTechProf) deleteTpResource(ctx context.Context,
-	aUniID uint8, aTpID uint8, aPathString string, aResource resourceEntry, aEntryID uint32,
+func (onuTP *OnuUniTechProf) DeleteTpResource(ctx context.Context,
+	aUniID uint8, aTpID uint8, aPathString string, aResource ResourceEntry, aEntryID uint32,
 	wg *sync.WaitGroup) {
 	defer wg.Done()
 	logger.Debugw(ctx, "will remove TP resources from ONU's UNI", log.Fields{
 		"device-id": onuTP.deviceID, "uni-id": aUniID, "path": aPathString, "Resource": aResource})
 	uniTPKey := uniTP{uniID: aUniID, tpID: aTpID}
 
-	if cResourceGemPort == aResource {
+	if CResourceGemPort == aResource {
 		logger.Debugw(ctx, "remove GemPort from the list of existing ones of the TP", log.Fields{
 			"device-id": onuTP.deviceID, "uni-id": aUniID, "path": aPathString, "GemPort": aEntryID})
 
@@ -589,11 +596,11 @@
 			*/
 			return
 		}
-		if onuTP.baseDeviceHandler.isReadyForOmciConfig() {
+		if onuTP.baseDeviceHandler.IsReadyForOmciConfig() {
 			// check that the TpConfigRequest was done before
 			//   -> that is implicitly done using the AniConfigFsm,
 			//      which must be in the according state to remove something
-			if onuTP.pAniConfigFsm == nil {
+			if onuTP.PAniConfigFsm == nil {
 				logger.Errorw(ctx, "abort GemPort removal - no AniConfigFsm available",
 					log.Fields{"device-id": onuTP.deviceID, "uni-id": aUniID})
 				/* Do not set some error indication to the outside system interface on delete (see above)
@@ -610,7 +617,7 @@
 				onuTP.mutexTPState.Unlock()
 				return
 			}
-			if _, ok := onuTP.pAniConfigFsm[uniTPKey]; !ok {
+			if _, ok := onuTP.PAniConfigFsm[uniTPKey]; !ok {
 				logger.Errorw(ctx, "abort GemPort removal - no AniConfigFsm available for this uni/tp",
 					log.Fields{"device-id": onuTP.deviceID, "uni-id": aUniID, "tp-id": aTpID})
 				/* Do not set some error indication to the outside system interface on delete (see above)
@@ -656,8 +663,8 @@
 				//this issue here means that the AniConfigFsm has not finished successfully
 				//which requires to reset it to allow for new usage, e.g. also on a different UNI
 				//(without that it would be reset on device down indication latest)
-				if _, ok := onuTP.pAniConfigFsm[uniTPKey]; ok {
-					_ = onuTP.pAniConfigFsm[uniTPKey].pAdaptFsm.pFsm.Event(aniEvReset)
+				if _, ok := onuTP.PAniConfigFsm[uniTPKey]; ok {
+					_ = onuTP.PAniConfigFsm[uniTPKey].PAdaptFsm.PFsm.Event(aniEvReset)
 				}
 				//TP related data cleared by FSM error treatment or re-used by FSM error-recovery (if implemented)
 				return
@@ -668,19 +675,19 @@
 			//as a consequence a possible remove-flow does not see any dependency on the TechProfile anymore and is executed (pro forma) directly
 			//a later TechProfile removal would cause the device-reason to be updated to 'techProfile-delete-success' which is not the expected state
 			// and anyway is no real useful information at that stage
-			logger.Debugw(ctx, "uniPonAniConfigFsm delete Gem on OMCI skipped based on device state", log.Fields{
-				"device-id": onuTP.deviceID, "device-state": onuTP.baseDeviceHandler.getDeviceReasonString()})
+			logger.Debugw(ctx, "UniPonAniConfigFsm delete Gem on OMCI skipped based on device state", log.Fields{
+				"device-id": onuTP.deviceID, "device-state": onuTP.baseDeviceHandler.GetDeviceReasonString()})
 		}
 		// remove GemPort from config DB
 		//ensure write protection for access to mapPonAniConfig
-		logger.Debugw(ctx, "uniPonAniConfigFsm removing gem from config data and clearing ani FSM", log.Fields{
+		logger.Debugw(ctx, "UniPonAniConfigFsm removing gem from config data and clearing ani FSM", log.Fields{
 			"device-id": onuTP.deviceID, "gem-id": onuTP.mapRemoveGemEntry[uniTPKey].removeGemID, "uniTPKey": uniTPKey})
 		onuTP.mutexTPState.Lock()
 		delete(onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams, onuTP.mapRemoveGemEntry[uniTPKey].removeGemID)
 		// remove the removeEntry
 		delete(onuTP.mapRemoveGemEntry, uniTPKey)
 		onuTP.mutexTPState.Unlock()
-	} else { //if cResourceTcont == aResource {
+	} else { //if CResourceTcont == aResource {
 		logger.Debugw(ctx, "reset TCont with AllocId", log.Fields{
 			"device-id": onuTP.deviceID, "uni-id": aUniID, "path": aPathString, "allocId": aEntryID})
 
@@ -710,7 +717,7 @@
 		//T-Cont to be reset found
 		logger.Debugw(ctx, "Reset-T-Cont AllocId found - valid", log.Fields{
 			"device-id": onuTP.deviceID, "uni-id": aUniID, "AllocId": aEntryID})
-		if onuTP.pAniConfigFsm == nil {
+		if onuTP.PAniConfigFsm == nil {
 			logger.Errorw(ctx, "no TCont removal on OMCI - no AniConfigFsm available",
 				log.Fields{"device-id": onuTP.deviceID, "uni-id": aUniID})
 			/* Do not set some error indication to the outside system interface on delete (see above)
@@ -719,7 +726,7 @@
 			*/
 			return
 		}
-		if _, ok := onuTP.pAniConfigFsm[uniTPKey]; !ok {
+		if _, ok := onuTP.PAniConfigFsm[uniTPKey]; !ok {
 			logger.Errorw(ctx, "no TCont removal on OMCI - no AniConfigFsm available for this uni/tp",
 				log.Fields{"device-id": onuTP.deviceID, "uni-id": aUniID, "tp-id": aTpID})
 			//even if the FSM invocation did not work we don't indicate a problem within procResult
@@ -727,7 +734,7 @@
 			//if the FSM is not valid, also TP related data should not be valid - clear the internal store profile data
 			return
 		}
-		if onuTP.baseDeviceHandler.isReadyForOmciConfig() {
+		if onuTP.baseDeviceHandler.IsReadyForOmciConfig() {
 			// check that the TpConfigRequest was done before
 			//   -> that is implicitly done using the AniConfigFsm,
 			//      which must be in the according state to remove something
@@ -754,24 +761,25 @@
 				//this issue here means that the AniConfigFsm has not finished successfully
 				//which requires to reset it to allow for new usage, e.g. also on a different UNI
 				//(without that it would be reset on device down indication latest)
-				if _, ok := onuTP.pAniConfigFsm[uniTPKey]; ok {
-					_ = onuTP.pAniConfigFsm[uniTPKey].pAdaptFsm.pFsm.Event(aniEvReset)
+				if _, ok := onuTP.PAniConfigFsm[uniTPKey]; ok {
+					_ = onuTP.PAniConfigFsm[uniTPKey].PAdaptFsm.PFsm.Event(aniEvReset)
 				}
 				//TP related data cleared by FSM error treatment or re-used by FSM error-recovery (if implemented)
 				return
 			}
 		} else {
 			//see gemPort comments
-			logger.Debugw(ctx, "uniPonAniConfigFsm TCont cleanup on OMCI skipped based on device state", log.Fields{
-				"device-id": onuTP.deviceID, "device-state": onuTP.baseDeviceHandler.getDeviceReasonString()})
+			logger.Debugw(ctx, "UniPonAniConfigFsm TCont cleanup on OMCI skipped based on device state", log.Fields{
+				"device-id": onuTP.deviceID, "device-state": onuTP.baseDeviceHandler.GetDeviceReasonString()})
 		}
 	}
 
 }
 
-func (onuTP *onuUniTechProf) isTechProfileConfigCleared(ctx context.Context, uniID uint8, tpID uint8) bool {
+// IsTechProfileConfigCleared - TODO: add comment
+func (onuTP *OnuUniTechProf) IsTechProfileConfigCleared(ctx context.Context, uniID uint8, tpID uint8) bool {
 	uniTPKey := uniTP{uniID: uniID, tpID: tpID}
-	logger.Debugw(ctx, "isTechProfileConfigCleared", log.Fields{"device-id": onuTP.deviceID})
+	logger.Debugw(ctx, "IsTechProfileConfigCleared", log.Fields{"device-id": onuTP.deviceID})
 	if onuTP.mapPonAniConfig[uniTPKey] != nil {
 		mapGemPortParams := onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams
 		unicastGemCount := 0
@@ -784,17 +792,17 @@
 			logger.Debugw(ctx, "clearing-ani-side-config", log.Fields{
 				"device-id": onuTP.deviceID, "uniTpKey": uniTPKey})
 			onuTP.clearAniSideConfig(ctx, uniID, tpID)
-			if _, ok := onuTP.pAniConfigFsm[uniTPKey]; ok {
-				_ = onuTP.pAniConfigFsm[uniTPKey].pAdaptFsm.pFsm.Event(aniEvReset)
+			if _, ok := onuTP.PAniConfigFsm[uniTPKey]; ok {
+				_ = onuTP.PAniConfigFsm[uniTPKey].PAdaptFsm.PFsm.Event(aniEvReset)
 			}
-			go onuTP.baseDeviceHandler.deviceProcStatusUpdate(ctx, OmciAniResourceRemoved)
+			go onuTP.baseDeviceHandler.DeviceProcStatusUpdate(ctx, cmn.OmciAniResourceRemoved)
 			return true
 		}
 	}
 	return false
 }
 
-func (onuTP *onuUniTechProf) waitForTimeoutOrCompletion(
+func (onuTP *OnuUniTechProf) waitForTimeoutOrCompletion(
 	ctx context.Context, aChTpProcessingStep <-chan uint8, aProcessingStep uint8) bool {
 	select {
 	case <-ctx.Done():
@@ -814,44 +822,43 @@
 }
 
 // createAniConfigFsm initializes and runs the AniConfig FSM to transfer the OMCI related commands for ANI side configuration
-func (onuTP *onuUniTechProf) createAniConfigFsm(ctx context.Context, aUniID uint8, aTpID uint8,
-	apCurrentUniPort *onuUniPort, devEvent OnuDeviceEvent, aProcessingStep uint8) error {
+func (onuTP *OnuUniTechProf) createAniConfigFsm(ctx context.Context, aUniID uint8, aTpID uint8,
+	apCurrentUniPort *cmn.OnuUniPort, devEvent cmn.OnuDeviceEvent, aProcessingStep uint8) error {
 	logger.Debugw(ctx, "createAniConfigFsm", log.Fields{"device-id": onuTP.deviceID})
-	chAniConfigFsm := make(chan Message, 2048)
+	chAniConfigFsm := make(chan cmn.Message, 2048)
 	uniTPKey := uniTP{uniID: aUniID, tpID: aTpID}
-	pDevEntry := onuTP.baseDeviceHandler.getOnuDeviceEntry(ctx, true)
-	if pDevEntry == nil {
+	if onuTP.onuDevice == nil {
 		logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": onuTP.deviceID})
 		return fmt.Errorf("no valid OnuDevice: %s", onuTP.deviceID)
 	}
-	pAniCfgFsm := newUniPonAniConfigFsm(ctx, pDevEntry.PDevOmciCC, apCurrentUniPort, onuTP,
-		pDevEntry.pOnuDB, aTpID, devEvent,
-		"AniConfigFsm", onuTP.baseDeviceHandler, chAniConfigFsm)
+	pAniCfgFsm := NewUniPonAniConfigFsm(ctx, onuTP.onuDevice.GetDevOmciCC(), apCurrentUniPort, onuTP,
+		onuTP.onuDevice.GetOnuDB(), aTpID, devEvent,
+		"AniConfigFsm", onuTP.baseDeviceHandler, onuTP.onuDevice, chAniConfigFsm)
 	if pAniCfgFsm == nil {
 		logger.Errorw(ctx, "AniConfigFSM could not be created - abort!!", log.Fields{"device-id": onuTP.deviceID})
 		return fmt.Errorf("could not create AniConfigFSM: %s", onuTP.deviceID)
 	}
-	if onuTP.pAniConfigFsm == nil {
-		onuTP.pAniConfigFsm = make(map[uniTP]*uniPonAniConfigFsm)
+	if onuTP.PAniConfigFsm == nil {
+		onuTP.PAniConfigFsm = make(map[uniTP]*UniPonAniConfigFsm)
 	}
-	onuTP.pAniConfigFsm[uniTPKey] = pAniCfgFsm
+	onuTP.PAniConfigFsm[uniTPKey] = pAniCfgFsm
 	return onuTP.runAniConfigFsm(ctx, aniEvStart, aProcessingStep, aUniID, aTpID)
 }
 
 // runAniConfigFsm starts the AniConfig FSM to transfer the OMCI related commands for  ANI side configuration
-func (onuTP *onuUniTechProf) runAniConfigFsm(ctx context.Context, aEvent string, aProcessingStep uint8, aUniID uint8, aTpID uint8) error {
+func (onuTP *OnuUniTechProf) runAniConfigFsm(ctx context.Context, aEvent string, aProcessingStep uint8, aUniID uint8, aTpID uint8) error {
 	/*  Uni related ANI config procedure -
 	 ***** should run via 'aniConfigDone' state and generate the argument requested event *****
 	 */
 	uniTpKey := uniTP{uniID: aUniID, tpID: aTpID}
 
-	pACStatemachine := onuTP.pAniConfigFsm[uniTpKey].pAdaptFsm.pFsm
+	pACStatemachine := onuTP.PAniConfigFsm[uniTpKey].PAdaptFsm.PFsm
 	if pACStatemachine != nil {
 		if aEvent == aniEvStart {
 			if !pACStatemachine.Is(aniStDisabled) {
 				logger.Errorw(ctx, "wrong state of AniConfigFSM to start - want: Disabled", log.Fields{
 					"have": pACStatemachine.Current(), "device-id": onuTP.deviceID})
-				// maybe try a FSM reset and then again ... - TODO!!!
+				// maybe try a FSM reset and then again ... - TODO: add comment!!!
 				return fmt.Errorf("wrong state of AniConfigFSM to start: %s", onuTP.deviceID)
 			}
 		} else if !pACStatemachine.Is(aniStConfigDone) {
@@ -860,7 +867,7 @@
 			return fmt.Errorf("wrong state of AniConfigFSM to remove: %s", onuTP.deviceID)
 		}
 		//FSM init requirement to get informed about FSM completion! (otherwise timeout of the TechProf config)
-		onuTP.pAniConfigFsm[uniTpKey].setFsmCompleteChannel(onuTP.chTpConfigProcessingStep, aProcessingStep)
+		onuTP.PAniConfigFsm[uniTpKey].setFsmCompleteChannel(onuTP.chTpConfigProcessingStep, aProcessingStep)
 		if err := pACStatemachine.Event(aEvent); err != nil {
 			logger.Errorw(ctx, "AniConfigFSM: can't trigger event", log.Fields{"err": err})
 			return fmt.Errorf("can't trigger event in AniConfigFSM: %s", onuTP.deviceID)
@@ -871,12 +878,12 @@
 		return nil
 	}
 	logger.Errorw(ctx, "AniConfigFSM StateMachine invalid - cannot be executed!!", log.Fields{"device-id": onuTP.deviceID})
-	// maybe try a FSM reset and then again ... - TODO!!!
+	// maybe try a FSM reset and then again ... - TODO: add comment!!!
 	return fmt.Errorf("stateMachine AniConfigFSM invalid: %s", onuTP.deviceID)
 }
 
 // clearAniSideConfig deletes internal TechProfile related data connected to the requested UniPort and TpID
-func (onuTP *onuUniTechProf) clearAniSideConfig(ctx context.Context, aUniID uint8, aTpID uint8) {
+func (onuTP *OnuUniTechProf) clearAniSideConfig(ctx context.Context, aUniID uint8, aTpID uint8) {
 	logger.Debugw(ctx, "removing TpIndication and PonAniConfig data", log.Fields{
 		"device-id": onuTP.deviceID, "uni-id": aUniID})
 	uniTpKey := uniTP{uniID: aUniID, tpID: aTpID}
@@ -892,7 +899,7 @@
 }
 
 // setConfigDone sets the requested techProfile config state (if possible)
-func (onuTP *onuUniTechProf) setConfigDone(aUniID uint8, aTpID uint8, aState bool) {
+func (onuTP *OnuUniTechProf) setConfigDone(aUniID uint8, aTpID uint8, aState bool) {
 	uniTpKey := uniTP{uniID: aUniID, tpID: aTpID}
 	onuTP.mutexTPState.Lock()
 	defer onuTP.mutexTPState.Unlock()
@@ -902,7 +909,7 @@
 }
 
 // getTechProfileDone checks if the Techprofile processing with the requested TechProfile ID was done
-func (onuTP *onuUniTechProf) getTechProfileDone(ctx context.Context, aUniID uint8, aTpID uint8) bool {
+func (onuTP *OnuUniTechProf) getTechProfileDone(ctx context.Context, aUniID uint8, aTpID uint8) bool {
 	uniTpKey := uniTP{uniID: aUniID, tpID: aTpID}
 	onuTP.mutexTPState.RLock()
 	defer onuTP.mutexTPState.RUnlock()
@@ -920,8 +927,8 @@
 	return false
 }
 
-// setProfileToDelete sets the requested techProfile toDelete state (if possible)
-func (onuTP *onuUniTechProf) setProfileToDelete(aUniID uint8, aTpID uint8, aState bool) {
+// SetProfileToDelete sets the requested techProfile toDelete state (if possible)
+func (onuTP *OnuUniTechProf) SetProfileToDelete(aUniID uint8, aTpID uint8, aState bool) {
 	uniTpKey := uniTP{uniID: aUniID, tpID: aTpID}
 	onuTP.mutexTPState.Lock()
 	defer onuTP.mutexTPState.Unlock()
@@ -930,8 +937,7 @@
 	} //else: the state is just ignored (does not exist)
 }
 
-// setProfileToDelete sets the requested techProfile toDelete state (if possible)
-func (onuTP *onuUniTechProf) getMulticastGemPorts(ctx context.Context, aUniID uint8, aTpID uint8) []uint16 {
+func (onuTP *OnuUniTechProf) getMulticastGemPorts(ctx context.Context, aUniID uint8, aTpID uint8) []uint16 {
 	uniTpKey := uniTP{uniID: aUniID, tpID: aTpID}
 	onuTP.mutexTPState.RLock()
 	defer onuTP.mutexTPState.RUnlock()
@@ -949,7 +955,7 @@
 	return gemPortIds
 }
 
-func (onuTP *onuUniTechProf) getBidirectionalGemPortIDsForTP(ctx context.Context, aUniID uint8, aTpID uint8) []uint16 {
+func (onuTP *OnuUniTechProf) getBidirectionalGemPortIDsForTP(ctx context.Context, aUniID uint8, aTpID uint8) []uint16 {
 	uniTpKey := uniTP{uniID: aUniID, tpID: aTpID}
 	onuTP.mutexTPState.RLock()
 	defer onuTP.mutexTPState.RUnlock()
@@ -971,7 +977,8 @@
 	return gemPortIds
 }
 
-func (onuTP *onuUniTechProf) GetAllBidirectionalGemPortIDsForOnu() []uint16 {
+// GetAllBidirectionalGemPortIDsForOnu - TODO: add comment
+func (onuTP *OnuUniTechProf) GetAllBidirectionalGemPortIDsForOnu() []uint16 {
 	var gemPortInstIDs []uint16
 	onuTP.mutexTPState.RLock()
 	defer onuTP.mutexTPState.RUnlock()
@@ -986,7 +993,7 @@
 }
 
 // setProfileResetting sets/resets the indication, that a reset of the TechProfileConfig/Removal is ongoing
-func (onuTP *onuUniTechProf) setProfileResetting(ctx context.Context, aUniID uint8, aTpID uint8, aState bool) {
+func (onuTP *OnuUniTechProf) setProfileResetting(ctx context.Context, aUniID uint8, aTpID uint8, aState bool) {
 	uniTpKey := uniTP{uniID: aUniID, tpID: aTpID}
 	onuTP.mutexTPState.Lock()
 	defer onuTP.mutexTPState.Unlock()
@@ -994,7 +1001,7 @@
 }
 
 // getProfileResetting returns true, if the the according indication for started reset procedure is set
-func (onuTP *onuUniTechProf) getProfileResetting(aUniTpKey uniTP) bool {
+func (onuTP *OnuUniTechProf) getProfileResetting(aUniTpKey uniTP) bool {
 	onuTP.mutexTPState.RLock()
 	defer onuTP.mutexTPState.RUnlock()
 	if isResetting, exist := onuTP.tpProfileResetting[aUniTpKey]; exist {
diff --git a/internal/pkg/onuadaptercore/common.go b/internal/pkg/common/common.go
old mode 100644
new mode 100755
similarity index 86%
rename from internal/pkg/onuadaptercore/common.go
rename to internal/pkg/common/common.go
index b0b10e3..5019a75
--- a/internal/pkg/onuadaptercore/common.go
+++ b/internal/pkg/common/common.go
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package common provides global definitions
+package common
 
 import (
 	"github.com/opencord/voltha-lib-go/v7/pkg/log"
@@ -26,7 +26,7 @@
 func init() {
 	// Setup this package so that it's log level can be modified at run time
 	var err error
-	logger, err = log.RegisterPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "adaptercoreonu"})
+	logger, err = log.RegisterPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "common"})
 	if err != nil {
 		panic(err)
 	}
diff --git a/internal/pkg/common/defines.go b/internal/pkg/common/defines.go
new file mode 100755
index 0000000..2c597c1
--- /dev/null
+++ b/internal/pkg/common/defines.go
@@ -0,0 +1,329 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+
+ * http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//Package common provides global definitions
+package common
+
+import (
+	"context"
+	"time"
+
+	gp "github.com/google/gopacket"
+	"github.com/looplab/fsm"
+	"github.com/opencord/omci-lib-go"
+	vc "github.com/opencord/voltha-protos/v5/go/common"
+	"github.com/opencord/voltha-protos/v5/go/voltha"
+)
+
+// MessageType - Message Protocol Type
+type MessageType uint8
+
+const (
+	// TestMsg - Message type for non OMCI messages
+	TestMsg MessageType = iota
+	//OMCI - OMCI protocol type msg
+	OMCI
+)
+
+// String - Return the text representation of the message type based on integer
+func (m MessageType) String() string {
+	names := [...]string{
+		"TestMsg",
+		"OMCI",
+	}
+	return names[m]
+}
+
+// Message - message type and data(OMCI)
+type Message struct {
+	Type MessageType
+	Data interface{}
+}
+
+//TestMessageType - message data for various events
+type TestMessageType uint8
+
+const (
+	// LoadMibTemplateOk - message data for getting mib template successfully
+	LoadMibTemplateOk TestMessageType = iota + 1
+	// LoadMibTemplateFailed - message data for failure for getting mib template
+	LoadMibTemplateFailed
+	// TimeOutOccurred - message data for timeout
+	TimeOutOccurred
+	// AbortMessageProcessing - message data for aborting running message
+	AbortMessageProcessing
+)
+
+//TestMessage - Struct to hold the message data
+//TODO: place holder to have a second interface variant - to be replaced by real variant later on
+type TestMessage struct {
+	TestMessageVal TestMessageType
+}
+
+//OmciMessage - OMCI protocol messages for managing and monitoring ONUs
+type OmciMessage struct {
+	//OnuSN   *openolt.SerialNumber
+	//OnuID   uint32
+	OmciMsg    *omci.OMCI
+	OmciPacket *gp.Packet
+}
+
+///////////////////////////////////////////////////////////
+
+// device reasons
+const (
+	DrUnset                            = 0
+	DrActivatingOnu                    = 1
+	DrStartingOpenomci                 = 2
+	DrDiscoveryMibsyncComplete         = 3
+	DrInitialMibDownloaded             = 4
+	DrTechProfileConfigDownloadSuccess = 5
+	DrOmciFlowsPushed                  = 6
+	DrOmciAdminLock                    = 7
+	DrOnuReenabled                     = 8
+	DrStoppingOpenomci                 = 9
+	DrRebooting                        = 10
+	DrOmciFlowsDeleted                 = 11
+	DrTechProfileConfigDeleteSuccess   = 12
+	DrReconcileFailed                  = 13
+	DrReconcileMaxTimeout              = 14
+	DrReconcileCanceled                = 15
+	DrTechProfileConfigDownloadFailed  = 16
+)
+
+// DeviceReasonMap holds device reason strings
+var DeviceReasonMap = map[uint8]string{
+	DrUnset:                            "unset",
+	DrActivatingOnu:                    "activating-onu",
+	DrStartingOpenomci:                 "starting-openomci",
+	DrDiscoveryMibsyncComplete:         "discovery-mibsync-complete",
+	DrInitialMibDownloaded:             "initial-mib-downloaded",
+	DrTechProfileConfigDownloadSuccess: "tech-profile-config-download-success",
+	DrTechProfileConfigDownloadFailed:  "tech-profile-config-download-failed",
+	DrOmciFlowsPushed:                  "omci-flows-pushed",
+	DrOmciAdminLock:                    "omci-admin-lock",
+	DrOnuReenabled:                     "onu-reenabled",
+	DrStoppingOpenomci:                 "stopping-openomci",
+	DrRebooting:                        "rebooting",
+	DrOmciFlowsDeleted:                 "omci-flows-deleted",
+	DrTechProfileConfigDeleteSuccess:   "tech-profile-config-delete-success",
+	DrReconcileFailed:                  "reconcile-failed",
+	DrReconcileMaxTimeout:              "reconcile-max-timeout",
+	DrReconcileCanceled:                "reconciling-canceled",
+}
+
+// UsedOmciConfigFsms type for FSMs dealing with OMCI messages
+type UsedOmciConfigFsms int
+
+// FSMs dealing with OMCI messages
+const (
+	CUploadFsm UsedOmciConfigFsms = iota
+	CDownloadFsm
+	CUniLockFsm
+	CUniUnLockFsm
+	CAniConfigFsm
+	CUniVlanConfigFsm
+	CL2PmFsm
+	COnuUpgradeFsm
+)
+
+// OnuDeviceEvent - TODO: add comment
+type OnuDeviceEvent int
+
+// Events of interest to Device Adapters and OpenOMCI State Machines
+const (
+	// DeviceStatusInit - default start state
+	DeviceStatusInit OnuDeviceEvent = iota
+	// MibDatabaseSync - MIB database sync (upload done)
+	MibDatabaseSync
+	// OmciCapabilitiesDone - OMCI ME and message type capabilities known
+	OmciCapabilitiesDone
+	// MibDownloadDone - // MIB download done
+	MibDownloadDone
+	// UniLockStateDone - Uni ports admin set to lock
+	UniLockStateDone
+	// UniUnlockStateDone - Uni ports admin set to unlock
+	UniUnlockStateDone
+	// UniDisableStateDone - Uni ports admin set to lock based on device disable
+	UniDisableStateDone
+	// UniEnableStateDone - Uni ports admin set to unlock based on device re-enable
+	UniEnableStateDone
+	// PortLinkUp - Port link state change
+	PortLinkUp
+	// PortLinkDw - Port link state change
+	PortLinkDw
+	// OmciAniConfigDone -  AniSide config according to TechProfile done
+	OmciAniConfigDone
+	// OmciAniResourceRemoved - AniSide TechProfile related resource (Gem/TCont) removed
+	OmciAniResourceRemoved // needs to be the successor of OmciAniConfigDone!
+	// OmciVlanFilterAddDone - Omci Vlan config done according to flow-add with request to write kvStore
+	OmciVlanFilterAddDone
+	// OmciVlanFilterAddDoneNoKvStore - Omci Vlan config done according to flow-add without writing kvStore
+	OmciVlanFilterAddDoneNoKvStore // needs to be the successor of OmciVlanFilterAddDone!
+	// OmciVlanFilterRemDone - Omci Vlan config done according to flow-remove with request to write kvStore
+	OmciVlanFilterRemDone // needs to be the successor of OmciVlanFilterAddDoneNoKvStore!
+	// OmciVlanFilterRemDoneNoKvStore - Omci Vlan config done according to flow-remove without writing kvStore
+	OmciVlanFilterRemDoneNoKvStore // needs to be the successor of OmciVlanFilterRemDone!
+	// OmciOnuSwUpgradeDone - SoftwareUpgrade to ONU finished
+	OmciOnuSwUpgradeDone
+	// Add other events here as needed (alarms separate???)
+)
+
+///////////////////////////////////////////////////////////
+
+//definitions as per G.988 softwareImage::valid ME IDs
+const (
+	FirstSwImageMeID  = 0
+	SecondSwImageMeID = 1
+)
+
+//definitions as per G.988 softwareImage::IsCommitted
+const (
+	SwIsUncommitted = 0
+	SwIsCommitted   = 1
+)
+
+//definitions as per G.988 softwareImage::IsActive
+const (
+	SwIsInactive = 0
+	SwIsActive   = 1
+)
+
+//definitions as per G.988 softwareImage::IsValid
+const (
+	SwIsInvalid = 0
+	SwIsValid   = 1
+)
+
+// SEntrySwImageIndication - TODO: add comment
+type SEntrySwImageIndication struct {
+	Valid       bool
+	EntityID    uint16
+	Version     string
+	IsCommitted uint8
+}
+
+// SswImageIndications - TODO: add comment
+type SswImageIndications struct {
+	ActiveEntityEntry   SEntrySwImageIndication
+	InActiveEntityEntry SEntrySwImageIndication
+}
+
+///////////////////////////////////////////////////////////
+
+type activityDescr struct {
+	DatabaseClass func(context.Context) error
+	//advertiseEvents bool
+	AuditInterval time.Duration
+	//tasks           map[string]func() error
+}
+
+// OmciDeviceFsms - FSM event mapping to database class and time to wait between audits
+type OmciDeviceFsms map[string]activityDescr
+
+// AdapterFsm - Adapter FSM details including channel, event and  device
+type AdapterFsm struct {
+	fsmName  string
+	deviceID string
+	CommChan chan Message
+	PFsm     *fsm.FSM
+}
+
+//CErrWaitAborted - AdapterFsm related error string
+//error string could be checked on waitforOmciResponse() e.g. to avoid misleading error log
+// but not used that way so far (permit error log even for wanted cancellation)
+const CErrWaitAborted = "waitResponse aborted"
+
+///////////////////////////////////////////////////////////
+
+// UniPortType holds possible UNI port types
+type UniPortType uint8
+
+// UniPPTP Interface type - re-use values from G.988 (Chapter 9.3.4) TP type definition (directly used in OMCI!)
+const (
+	// UniPPTP relates to PPTP
+	UniPPTP UniPortType = 1 // relates to PPTP
+	// UniVEIP relates to VEIP
+	UniVEIP UniPortType = 11 // relates to VEIP
+	// UniPPTPPots relates to PPTP POTS
+	UniPPTPPots UniPortType = 4 // relates to IP host config data (for Voice Services)
+)
+
+//OnuUniPort structure holds information about the ONU attached Uni Ports
+type OnuUniPort struct {
+	Enabled    bool
+	Name       string
+	PortNo     uint32
+	PortType   UniPortType
+	OfpPortNo  string
+	UniID      uint8
+	MacBpNo    uint8
+	EntityID   uint16
+	AdminState vc.AdminState_Types
+	OperState  vc.OperStatus_Types
+	PPort      *voltha.Port
+}
+
+// OnuUniPortMap - TODO: add comment
+type OnuUniPortMap map[uint32]*OnuUniPort
+
+///////////////////////////////////////////////////////////
+
+const (
+	tpIDStart = 64
+	tpIDEnd   = 256
+	tpRange   = tpIDEnd - tpIDStart
+	maxUni    = 256
+)
+
+// TODO
+const (
+	IeeMaperServiceProfileBaseEID = uint16(0x1001)
+	MacBridgePortAniBaseEID       = uint16(0x1001)
+	MacBridgePortUniBaseEID       = uint16(0x201)
+	MacBridgePortAniMcastBaseEID  = uint16(0xA01)
+	GalEthernetEID                = uint16(1)
+	MacBridgeServiceProfileEID    = uint16(0x201)
+)
+
+// UniVlanRuleParams - TODO: add comment
+type UniVlanRuleParams struct {
+	TpID         uint8  `json:"tp_id"`
+	MatchVid     uint32 `json:"match_vid"` //use uint32 types for allowing immediate bitshifting
+	MatchPcp     uint32 `json:"match_pcp"`
+	TagsToRemove uint32 `json:"tags_to_remove"`
+	SetVid       uint32 `json:"set_vid"`
+	SetPcp       uint32 `json:"set_pcp"`
+}
+
+// UniVlanFlowParams - TODO: add comment
+type UniVlanFlowParams struct {
+	CookieSlice    []uint64               `json:"cookie_slice"`
+	VlanRuleParams UniVlanRuleParams      `json:"vlan_rule_params"`
+	Meter          *voltha.OfpMeterConfig `json:"flow_meter"`
+}
+
+///////////////////////////////////////////////////////////
+
+//definitions as per G.988
+const (
+	OnuDataMeID          = 0
+	Onu2gMeID            = 0
+	OnugMeID             = 0
+	IPHostConfigDataMeID = 1
+	OnugSerialNumberLen  = 8
+	OmciMacAddressLen    = 6
+)
diff --git a/internal/pkg/common/interfaces.go b/internal/pkg/common/interfaces.go
new file mode 100755
index 0000000..a15bf35
--- /dev/null
+++ b/internal/pkg/common/interfaces.go
@@ -0,0 +1,178 @@
+/*
+ * Copyright 2020-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//Package common provides global definitions
+package common
+
+import (
+	"context"
+	"time"
+
+	//"github.com/opencord/voltha-lib-go/v5/pkg/adapters/adapterif"
+	"github.com/opencord/voltha-lib-go/v7/pkg/db"
+	"github.com/opencord/voltha-lib-go/v7/pkg/events/eventif"
+	"github.com/opencord/voltha-openonu-adapter-go/internal/pkg/devdb"
+	ic "github.com/opencord/voltha-protos/v5/go/inter_container"
+	"github.com/opencord/voltha-protos/v5/go/openolt"
+	"github.com/opencord/voltha-protos/v5/go/voltha"
+)
+
+// IopenONUAC interface to openONUAC
+type IopenONUAC interface {
+	GetSupportedFsms() *OmciDeviceFsms
+	LockMutexMibTemplateGenerated()
+	UnlockMutexMibTemplateGenerated()
+	GetMibTemplatesGenerated(string) (bool, bool)
+	SetMibTemplatesGenerated(string, bool)
+	RLockMutexDeviceHandlersMap()
+	RUnlockMutexDeviceHandlersMap()
+	GetDeviceHandler(string) (IdeviceHandler, bool)
+}
+
+// IdeviceHandler interface to deviceHandler
+type IdeviceHandler interface {
+	GetDeviceID() string
+	GetLogicalDeviceID() string
+	GetDevice() *voltha.Device
+	GetDeviceType() string
+	GetProxyAddressID() string
+	GetProxyAddressType() string
+	GetProxyAddress() *voltha.Device_ProxyAddress
+	GetEventProxy() eventif.EventProxy
+	GetOmciTimeout() int
+	GetAlarmAuditInterval() time.Duration
+	GetDlToOnuTimeout4M() time.Duration
+	GetUniEntityMap() *OnuUniPortMap
+	GetUniPortMask() int
+	GetPonPortNumber() *uint32
+	GetOnuIndication() *openolt.OnuIndication
+	GetUniVlanConfigFsm(uint8) IuniVlanConfigFsm
+
+	GetDeviceReasonString() string
+	SetDeviceReason(uint8)
+
+	GetCollectorIsRunning() bool
+	StartCollector(context.Context)
+	InitPmConfigs()
+	GetPmConfigs() *voltha.PmConfigs
+	GetMetricsEnabled() bool
+	GetOnuMetricsManager() IonuMetricsManager
+	GetOnuAlarmManager() IonuAlarmManager
+	GetOnuTP() IonuUniTechProf
+
+	GetAlarmManagerIsRunning(context.Context) bool
+	StartAlarmManager(context.Context)
+
+	CheckAuditStartCondition(context.Context, UsedOmciConfigFsms) bool
+
+	RemoveOnuUpgradeFsm(context.Context, *voltha.ImageState)
+	DeviceProcStatusUpdate(context.Context, OnuDeviceEvent)
+
+	SetReadyForOmciConfig(bool)
+	IsReadyForOmciConfig() bool
+
+	StorePersistentData(context.Context) error
+	StorePersUniFlowConfig(context.Context, uint8, *[]UniVlanFlowParams, bool) error
+
+	StartReconciling(context.Context, bool)
+	StopReconciling(context.Context, bool)
+	IsReconciling() bool
+	IsSkipOnuConfigReconciling() bool
+	PrepareReconcilingWithActiveAdapter(context.Context)
+	ReconcileDeviceTechProf(context.Context)
+	ReconcileDeviceFlowConfig(context.Context)
+
+	VerifyUniVlanConfigRequest(context.Context, *OnuUniPort, uint8)
+	VerifyVlanConfigRequest(context.Context, uint8, uint8)
+	AddAllUniPorts(context.Context)
+	RemoveVlanFilterFsm(context.Context, *OnuUniPort)
+
+	EnableUniPortStateUpdate(context.Context)
+	DisableUniPortStateUpdate(context.Context)
+
+	SetBackend(context.Context, string) *db.Backend
+	GetBackendPathPrefix() string
+
+	RLockMutexDeletionInProgressFlag()
+	RUnlockMutexDeletionInProgressFlag()
+	GetDeletionInProgress() bool
+
+	SendOMCIRequest(context.Context, string, *ic.OmciMessage) error
+	CreatePortInCore(context.Context, *voltha.Port) error
+}
+
+// IonuDeviceEntry interface to onuDeviceEntry
+type IonuDeviceEntry interface {
+	GetDevOmciCC() *OmciCC
+	GetOnuDB() *devdb.OnuDeviceDB
+	GetPersSerialNumber() string
+	GetPersVendorID() string
+	GetPersEquipmentID() string
+
+	GetMibUploadFsmCommChan() chan Message
+	GetMibDownloadFsmCommChan() chan Message
+
+	GetOmciRebootMsgRevChan() chan Message
+	WaitForRebootResponse(context.Context, chan Message) error
+
+	IncrementMibDataSync(context.Context)
+
+	GetActiveImageMeID(context.Context) (uint16, error)
+	LockMutexOnuSwImageIndications()
+	UnlockMutexOnuSwImageIndications()
+	GetOnuSwImageIndications() SswImageIndications
+	SetOnuSwImageIndications(SswImageIndications)
+	GetPersActiveSwVersion() string
+	SetPersActiveSwVersion(string)
+	GetActiveImageVersion(context.Context) string
+	ModifySwImageInactiveVersion(context.Context, string)
+	ModifySwImageActiveCommit(context.Context, uint8)
+
+	AllocateFreeTcont(context.Context, uint16) (uint16, bool, error)
+	FreeTcont(context.Context, uint16)
+
+	LockMutexPersOnuConfig()
+	UnlockMutexPersOnuConfig()
+
+	SetReconcilingFlows(bool)
+	SetChReconcilingFlowsFinished(bool)
+}
+
+// IonuMetricsManager interface to onuMetricsManager
+type IonuMetricsManager interface {
+	AddGemPortForPerfMonitoring(context.Context, uint16)
+	RemoveGemPortForPerfMonitoring(context.Context, uint16)
+}
+
+// IonuAlarmManager interface to onuAlarmManager
+type IonuAlarmManager interface {
+	HandleOmciAlarmNotificationMessage(context.Context, OmciMessage)
+	ResetAlarmUploadCounters()
+	GetAlarmMgrEventChannel() chan Message
+	GetAlarmUploadSeqNo() uint16
+	IncrementAlarmUploadSeqNo()
+}
+
+// IonuUniTechProf interface to onuUniTechProf
+type IonuUniTechProf interface {
+	GetAllBidirectionalGemPortIDsForOnu() []uint16
+	SetProfileToDelete(uint8, uint8, bool)
+}
+
+// IuniVlanConfigFsm interface to uniVlanConfigFsm
+type IuniVlanConfigFsm interface {
+	IsFlowRemovePending(chan<- bool) bool
+}
diff --git a/internal/pkg/onuadaptercore/omci_cc.go b/internal/pkg/common/omci_cc.go
old mode 100644
new mode 100755
similarity index 80%
rename from internal/pkg/onuadaptercore/omci_cc.go
rename to internal/pkg/common/omci_cc.go
index be930b8..363a59f
--- a/internal/pkg/onuadaptercore/omci_cc.go
+++ b/internal/pkg/common/omci_cc.go
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package common provides global definitions
+package common
 
 import (
 	"container/list"
@@ -51,7 +51,9 @@
 
 //const defaultTPID = uint16(0x8100)
 //const broadComDefaultVID = uint16(4091)
-const unusedTcontAllocID = uint16(0xFFFF) //common unused AllocId for G.984 and G.987 systems
+
+// UnusedTcontAllocID - TODO: add comment
+const UnusedTcontAllocID = uint16(0xFFFF) //common unused AllocId for G.984 and G.987 systems
 
 const cOmciBaseMessageTrailerLen = 40
 
@@ -67,39 +69,42 @@
 	cOmciMessageReceiveErrorMissTrailer
 )
 
-const cDefaultRetries = 2
+// CDefaultRetries - TODO: add comment
+const CDefaultRetries = 2
 
 // ### OMCI related definitions - end
 
-//callbackPairEntry to be used for OMCI send/receive correlation
-type callbackPairEntry struct {
-	cbRespChannel chan Message
-	cbFunction    func(context.Context, *omci.OMCI, *gp.Packet, chan Message) error
-	framePrint    bool //true for printing
+//CallbackPairEntry to be used for OMCI send/receive correlation
+type CallbackPairEntry struct {
+	CbRespChannel chan Message
+	CbFunction    func(context.Context, *omci.OMCI, *gp.Packet, chan Message) error
+	FramePrint    bool //true for printing
 }
 
-//callbackPair to be used for ReceiveCallback init
-type callbackPair struct {
-	cbKey   uint16
-	cbEntry callbackPairEntry
+//CallbackPair to be used for ReceiveCallback init
+type CallbackPair struct {
+	CbKey   uint16
+	CbEntry CallbackPairEntry
 }
 
-type omciTransferStructure struct {
+// OmciTransferStructure - TODO: add comment
+type OmciTransferStructure struct {
 	txFrame        []byte
 	timeout        int
 	retries        int
 	highPrio       bool
 	withFramePrint bool
-	cbPair         callbackPair
+	cbPair         CallbackPair
 	chSuccess      chan bool
 }
 
-//omciCC structure holds information needed for OMCI communication (to/from OLT Adapter)
-type omciCC struct {
+//OmciCC structure holds information needed for OMCI communication (to/from OLT Adapter)
+type OmciCC struct {
 	enabled            bool
-	pOnuDeviceEntry    *OnuDeviceEntry
+	pBaseDeviceHandler IdeviceHandler
+	pOnuDeviceEntry    IonuDeviceEntry
+	pOnuAlarmManager   IonuAlarmManager
 	deviceID           string
-	pBaseDeviceHandler *deviceHandler
 	coreClient         *vgrpc.Client
 	supportExtMsg      bool
 	rxOmciFrameError   tOmciReceiveError
@@ -112,17 +117,15 @@
 	tid            uint16
 	mutexHpTid     sync.Mutex
 	hpTid          uint16
-	uploadSequNo   uint16
-	uploadNoOfCmds uint16
+	UploadSequNo   uint16
+	UploadNoOfCmds uint16
 
-	mutexTxQueue           sync.Mutex
-	txQueue                *list.List
-	mutexRxSchedMap        sync.Mutex
-	rxSchedulerMap         map[uint16]callbackPairEntry
-	mutexMonReq            sync.RWMutex
-	monitoredRequests      map[uint16]omciTransferStructure
-	mutexPLastTxMeInstance sync.RWMutex
-	pLastTxMeInstance      *me.ManagedEntity
+	mutexTxQueue      sync.Mutex
+	txQueue           *list.List
+	mutexRxSchedMap   sync.Mutex
+	rxSchedulerMap    map[uint16]CallbackPairEntry
+	mutexMonReq       sync.RWMutex
+	monitoredRequests map[uint16]OmciTransferStructure
 }
 
 var responsesWithMibDataSync = []omci.MessageType{
@@ -135,17 +138,18 @@
 	omci.CommitSoftwareResponseType,
 }
 
-//newOmciCC constructor returns a new instance of a OmciCC
+//NewOmciCC constructor returns a new instance of a OmciCC
 //mib_db (as well as not inluded alarm_db not really used in this code? VERIFY!!)
-func newOmciCC(ctx context.Context, onuDeviceEntry *OnuDeviceEntry,
-	deviceID string, deviceHandler *deviceHandler,
-	coreClient *vgrpc.Client) *omciCC {
+func NewOmciCC(ctx context.Context, deviceID string, deviceHandler IdeviceHandler,
+	onuDeviceEntry IonuDeviceEntry, onuAlarmManager IonuAlarmManager,
+	coreClient *vgrpc.Client) *OmciCC {
 	logger.Debugw(ctx, "init-omciCC", log.Fields{"device-id": deviceID})
-	var omciCC omciCC
+	var omciCC OmciCC
 	omciCC.enabled = false
+	omciCC.pBaseDeviceHandler = deviceHandler
+	omciCC.pOnuAlarmManager = onuAlarmManager
 	omciCC.pOnuDeviceEntry = onuDeviceEntry
 	omciCC.deviceID = deviceID
-	omciCC.pBaseDeviceHandler = deviceHandler
 	omciCC.coreClient = coreClient
 	omciCC.supportExtMsg = false
 	omciCC.rxOmciFrameError = cOmciMessageReceiveNoError
@@ -156,17 +160,17 @@
 	omciCC.rxOnuDiscards = 0
 	omciCC.tid = 0x1
 	omciCC.hpTid = 0x8000
-	omciCC.uploadSequNo = 0
-	omciCC.uploadNoOfCmds = 0
+	omciCC.UploadSequNo = 0
+	omciCC.UploadNoOfCmds = 0
 	omciCC.txQueue = list.New()
-	omciCC.rxSchedulerMap = make(map[uint16]callbackPairEntry)
-	omciCC.monitoredRequests = make(map[uint16]omciTransferStructure)
+	omciCC.rxSchedulerMap = make(map[uint16]CallbackPairEntry)
+	omciCC.monitoredRequests = make(map[uint16]OmciTransferStructure)
 
 	return &omciCC
 }
 
-//stop stops/resets the omciCC
-func (oo *omciCC) stop(ctx context.Context) error {
+//Stop stops/resets the omciCC
+func (oo *OmciCC) Stop(ctx context.Context) error {
 	logger.Debugw(ctx, "omciCC-stopping", log.Fields{"device-id": oo.deviceID})
 	//reseting all internal data, which might also be helpful for discarding any lingering tx/rx requests
 	oo.CancelRequestMonitoring(ctx)
@@ -185,8 +189,8 @@
 	oo.tid = 1 //reset the low prio transactionId
 	oo.mutexTid.Unlock()
 	//reset control values
-	oo.uploadSequNo = 0
-	oo.uploadNoOfCmds = 0
+	oo.UploadSequNo = 0
+	oo.UploadNoOfCmds = 0
 	oo.rxOmciFrameError = cOmciMessageReceiveNoError
 	//reset the stats counter - which might be topic of discussion ...
 	oo.txFrames = 0
@@ -199,7 +203,7 @@
 }
 
 // Rx handler for omci messages
-func (oo *omciCC) receiveOnuMessage(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet) error {
+func (oo *OmciCC) receiveOnuMessage(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet) error {
 	logger.Debugw(ctx, "rx-onu-autonomous-message", log.Fields{"omciMsgType": omciMsg.MessageType,
 		"payload": hex.EncodeToString(omciMsg.Payload)})
 	switch omciMsg.MessageType {
@@ -208,7 +212,7 @@
 			OmciMsg:    omciMsg,
 			OmciPacket: packet,
 		}
-		go oo.pBaseDeviceHandler.pAlarmMgr.handleOmciAlarmNotificationMessage(ctx, data)
+		go oo.pOnuAlarmManager.HandleOmciAlarmNotificationMessage(ctx, data)
 		return nil
 	default:
 		return fmt.Errorf("receiveOnuMessageType %s unimplemented", omciMsg.MessageType.String())
@@ -258,7 +262,7 @@
 	*/
 }
 
-func (oo *omciCC) printRxMessage(ctx context.Context, rxMsg []byte) {
+func (oo *OmciCC) printRxMessage(ctx context.Context, rxMsg []byte) {
 	//assuming omci message content is hex coded!
 	// with restricted output of 16bytes would be ...rxMsg[:16]
 	logger.Debugw(ctx, "omci-message-received:", log.Fields{
@@ -266,9 +270,9 @@
 		"device-id":     oo.deviceID})
 }
 
-// Rx handler for onu messages
+// ReceiveMessage - Rx handler for onu messages
 //    e.g. would call ReceiveOnuMessage() in case of TID=0 or Action=test ...
-func (oo *omciCC) receiveMessage(ctx context.Context, rxMsg []byte) error {
+func (oo *OmciCC) ReceiveMessage(ctx context.Context, rxMsg []byte) error {
 	//logger.Debugw(ctx,"cc-receive-omci-message", log.Fields{"RxOmciMessage-x2s": hex.EncodeToString(rxMsg)})
 	if len(rxMsg) >= 44 { // then it should normally include the BaseFormat trailer Len
 		// NOTE: autocorrection only valid for OmciBaseFormat, which is not specifically verified here!!!
@@ -342,15 +346,15 @@
 	//logger.Debug(ctx,"RxMsg is a Omci Response Message: try to schedule it to the requester")
 	oo.mutexRxSchedMap.Lock()
 	rxCallbackEntry, ok := oo.rxSchedulerMap[omciMsg.TransactionID]
-	if ok && rxCallbackEntry.cbFunction != nil {
-		if rxCallbackEntry.framePrint {
+	if ok && rxCallbackEntry.CbFunction != nil {
+		if rxCallbackEntry.FramePrint {
 			oo.printRxMessage(ctx, rxMsg)
 		}
 		//disadvantage of decoupling: error verification made difficult, but anyway the question is
 		// how to react on erroneous frame reception, maybe can simply be ignored
-		go rxCallbackEntry.cbFunction(ctx, omciMsg, &packet, rxCallbackEntry.cbRespChannel)
+		go rxCallbackEntry.CbFunction(ctx, omciMsg, &packet, rxCallbackEntry.CbRespChannel)
 		if isSuccessfulResponseWithMibDataSync(omciMsg, &packet) {
-			oo.pOnuDeviceEntry.incrementMibDataSync(ctx)
+			oo.pOnuDeviceEntry.IncrementMibDataSync(ctx)
 		}
 
 		// If omciMsg.MessageType is omci.TestResponseType, we still expect the TestResult OMCI message,
@@ -478,26 +482,26 @@
 */
 
 // ReleaseTid releases OMCI transaction identifier from rxSchedulerMap
-func (oo *omciCC) ReleaseTid(ctx context.Context, tid uint16) {
+func (oo *OmciCC) ReleaseTid(ctx context.Context, tid uint16) {
 	logger.Debugw(ctx, "releasing tid from rxSchedulerMap", log.Fields{"tid": tid})
 	delete(oo.rxSchedulerMap, tid)
 }
 
-//Queue the OMCI Frame for a transmit to the ONU via the proxy_channel
-func (oo *omciCC) send(ctx context.Context, txFrame []byte, timeout int, retry int, highPrio bool,
-	receiveCallbackPair callbackPair) error {
+// Send - Queue the OMCI Frame for a transmit to the ONU via the proxy_channel
+func (oo *OmciCC) Send(ctx context.Context, txFrame []byte, timeout int, retry int, highPrio bool,
+	receiveCallbackPair CallbackPair) error {
 
 	if timeout != 0 {
-		logger.Debugw(ctx, "register-response-callback:", log.Fields{"for TansCorrId": receiveCallbackPair.cbKey})
+		logger.Debugw(ctx, "register-response-callback:", log.Fields{"for TansCorrId": receiveCallbackPair.CbKey})
 		oo.mutexRxSchedMap.Lock()
 		// it could be checked, if the callback key is already registered - but simply overwrite may be acceptable ...
-		oo.rxSchedulerMap[receiveCallbackPair.cbKey] = receiveCallbackPair.cbEntry
+		oo.rxSchedulerMap[receiveCallbackPair.CbKey] = receiveCallbackPair.CbEntry
 		oo.mutexRxSchedMap.Unlock()
 	} //else timeout 0 indicates that no response is expected - fire and forget
 
-	printFrame := receiveCallbackPair.cbEntry.framePrint //printFrame true means debug print of frame is requested
+	printFrame := receiveCallbackPair.CbEntry.FramePrint //printFrame true means debug print of frame is requested
 	//just use a simple list for starting - might need some more effort, especially for multi source write access
-	omciTxRequest := omciTransferStructure{
+	omciTxRequest := OmciTransferStructure{
 		txFrame,
 		timeout,
 		retry,
@@ -508,19 +512,19 @@
 	}
 	oo.mutexMonReq.Lock()
 	defer oo.mutexMonReq.Unlock()
-	if _, exist := oo.monitoredRequests[receiveCallbackPair.cbKey]; !exist {
+	if _, exist := oo.monitoredRequests[receiveCallbackPair.CbKey]; !exist {
 		// do not call processRequestMonitoring in background here to ensure correct sequencing
 		// of requested messages into txQueue (especially for non-response-supervised messages)
 		oo.processRequestMonitoring(ctx, omciTxRequest)
 		return nil
 	}
 	logger.Errorw(ctx, "A message with this tid is processed already!",
-		log.Fields{"tid": receiveCallbackPair.cbKey, "device-id": oo.deviceID})
+		log.Fields{"tid": receiveCallbackPair.CbKey, "device-id": oo.deviceID})
 	return fmt.Errorf("message with tid is processed already %s", oo.deviceID)
 }
 
 //Pull next tx request and send it
-func (oo *omciCC) sendNextRequest(ctx context.Context) error {
+func (oo *OmciCC) sendNextRequest(ctx context.Context) error {
 	//	return errors.New("sendNextRequest unimplemented")
 
 	// just try to get something transferred !!
@@ -531,7 +535,7 @@
 	defer oo.mutexTxQueue.Unlock()
 	for oo.txQueue.Len() > 0 {
 		queueElement := oo.txQueue.Front() // First element
-		omciTxRequest := queueElement.Value.(omciTransferStructure)
+		omciTxRequest := queueElement.Value.(OmciTransferStructure)
 		/* compare olt device handler code:
 		func (dh *DeviceHandler) omciIndication(omciInd *oop.OmciIndication) {
 			logger.Debugw(ctx,"omci indication", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId})
@@ -588,18 +592,18 @@
 			logger.Debugw(ctx, "omci-message-to-send:", log.Fields{
 				"TxOmciMessage": hex.EncodeToString(omciTxRequest.txFrame),
 				"device-id":     oo.deviceID,
-				"toDeviceType":  oo.pBaseDeviceHandler.ProxyAddressType,
-				"proxyDeviceID": oo.pBaseDeviceHandler.ProxyAddressID,
-				"proxyAddress":  oo.pBaseDeviceHandler.device.ProxyAddress})
+				"toDeviceType":  oo.pBaseDeviceHandler.GetProxyAddressType(),
+				"proxyDeviceID": oo.pBaseDeviceHandler.GetProxyAddressID(),
+				"proxyAddress":  oo.pBaseDeviceHandler.GetProxyAddress()})
 		}
 		omciMsg := &ic.OmciMessage{
-			ParentDeviceId: oo.pBaseDeviceHandler.ProxyAddressID,
+			ParentDeviceId: oo.pBaseDeviceHandler.GetProxyAddressID(),
 			ChildDeviceId:  oo.deviceID,
 			Message:        omciTxRequest.txFrame,
-			ProxyAddress:   oo.pBaseDeviceHandler.device.ProxyAddress,
+			ProxyAddress:   oo.pBaseDeviceHandler.GetProxyAddress(),
 			ConnectStatus:  common.ConnectStatus_REACHABLE, // If we are sending OMCI messages means we are connected, else we should not be here
 		}
-		sendErr := oo.pBaseDeviceHandler.sendOMCIRequest(ctx, oo.pBaseDeviceHandler.device.ProxyAddress.AdapterEndpoint, omciMsg)
+		sendErr := oo.pBaseDeviceHandler.SendOMCIRequest(ctx, oo.pBaseDeviceHandler.GetProxyAddress().AdapterEndpoint, omciMsg)
 		if sendErr != nil {
 			logger.Errorw(ctx, "send omci request error", log.Fields{"ChildId": oo.deviceID, "error": sendErr})
 			return sendErr
@@ -609,7 +613,8 @@
 	return nil
 }
 
-func (oo *omciCC) getNextTid(highPriority bool) uint16 {
+// GetNextTid - TODO: add comment
+func (oo *OmciCC) GetNextTid(highPriority bool) uint16 {
 	var next uint16
 	if highPriority {
 		oo.mutexHpTid.Lock()
@@ -633,7 +638,9 @@
 
 // ###################################################################################
 // # utility methods provided to work on OMCI messages
-func serialize(ctx context.Context, msgType omci.MessageType, request gopacket.SerializableLayer, tid uint16) ([]byte, error) {
+
+// Serialize - TODO: add comment
+func Serialize(ctx context.Context, msgType omci.MessageType, request gopacket.SerializableLayer, tid uint16) ([]byte, error) {
 	omciLayer := &omci.OMCI{
 		TransactionID: tid,
 		MessageType:   msgType,
@@ -663,7 +670,7 @@
 */
 
 //supply a response handler for omci response messages to be transferred to the requested FSM
-func (oo *omciCC) receiveOmciResponse(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet, respChan chan Message) error {
+func (oo *OmciCC) receiveOmciResponse(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet, respChan chan Message) error {
 
 	logger.Debugw(ctx, "omci-message-response - transfer on omciRespChannel", log.Fields{"omciMsgType": omciMsg.MessageType,
 		"transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "device-id": oo.deviceID})
@@ -703,7 +710,8 @@
 	return nil
 }
 
-func (oo *omciCC) sendMibReset(ctx context.Context, timeout int, highPrio bool) error {
+// SendMibReset sends MibResetRequest
+func (oo *OmciCC) SendMibReset(ctx context.Context, timeout int, highPrio bool) error {
 
 	logger.Debugw(ctx, "send MibReset-msg to:", log.Fields{"device-id": oo.deviceID})
 	request := &omci.MibResetRequest{
@@ -711,106 +719,110 @@
 			EntityClass: me.OnuDataClassID,
 		},
 	}
-	tid := oo.getNextTid(highPrio)
-	pkt, err := serialize(ctx, omci.MibResetRequestType, request, tid)
+	tid := oo.GetNextTid(highPrio)
+	pkt, err := Serialize(ctx, omci.MibResetRequestType, request, tid)
 	if err != nil {
 		logger.Errorw(ctx, "Cannot serialize MibResetRequest", log.Fields{
 			"Err": err, "device-id": oo.deviceID})
 		return err
 	}
-	omciRxCallbackPair := callbackPair{
-		cbKey:   tid,
-		cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse, true},
+	omciRxCallbackPair := CallbackPair{
+		CbKey:   tid,
+		CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibUploadFsmCommChan(), oo.receiveOmciResponse, true},
 	}
-	return oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+	return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
 }
 
-func (oo *omciCC) sendReboot(ctx context.Context, timeout int, highPrio bool, responseChannel chan Message) error {
-	logger.Debugw(ctx, "send Reboot-msg to:", log.Fields{"device-id": oo.deviceID})
+// SendReboot sends RebootRequest
+func (oo *OmciCC) SendReboot(ctx context.Context, timeout int, highPrio bool, responseChannel chan Message) error {
+	logger.Debugw(ctx, "send reboot-msg to:", log.Fields{"device-id": oo.deviceID})
 	request := &omci.RebootRequest{
 		MeBasePacket: omci.MeBasePacket{
 			EntityClass: me.OnuGClassID,
 		},
 	}
-	tid := oo.getNextTid(highPrio)
-	pkt, err := serialize(ctx, omci.RebootRequestType, request, tid)
+	tid := oo.GetNextTid(highPrio)
+	pkt, err := Serialize(ctx, omci.RebootRequestType, request, tid)
 	if err != nil {
 		logger.Errorw(ctx, "Cannot serialize RebootRequest", log.Fields{
 			"Err": err, "device-id": oo.deviceID})
 		return err
 	}
-	omciRxCallbackPair := callbackPair{
-		cbKey:   tid,
-		cbEntry: callbackPairEntry{oo.pOnuDeviceEntry.omciRebootMessageReceivedChannel, oo.receiveOmciResponse, true},
+	omciRxCallbackPair := CallbackPair{
+		CbKey:   tid,
+		CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetOmciRebootMsgRevChan(), oo.receiveOmciResponse, true},
 	}
 
-	err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+	err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
 	if err != nil {
 		logger.Errorw(ctx, "Cannot send RebootRequest", log.Fields{
 			"Err": err, "device-id": oo.deviceID})
 		return err
 	}
-	err = oo.pOnuDeviceEntry.waitForRebootResponse(ctx, responseChannel)
+	err = oo.pOnuDeviceEntry.WaitForRebootResponse(ctx, responseChannel)
 	if err != nil {
-		logger.Errorw(ctx, "aborting ONU Reboot!", log.Fields{
+		logger.Errorw(ctx, "aborting ONU reboot!", log.Fields{
 			"Err": err, "device-id": oo.deviceID})
 		return err
 	}
 	return nil
 }
 
-func (oo *omciCC) sendMibUpload(ctx context.Context, timeout int, highPrio bool) error {
+// SendMibUpload sends MibUploadRequest
+func (oo *OmciCC) SendMibUpload(ctx context.Context, timeout int, highPrio bool) error {
 	logger.Debugw(ctx, "send MibUpload-msg to:", log.Fields{"device-id": oo.deviceID})
 	request := &omci.MibUploadRequest{
 		MeBasePacket: omci.MeBasePacket{
 			EntityClass: me.OnuDataClassID,
 		},
 	}
-	tid := oo.getNextTid(highPrio)
-	pkt, err := serialize(ctx, omci.MibUploadRequestType, request, tid)
+	tid := oo.GetNextTid(highPrio)
+	pkt, err := Serialize(ctx, omci.MibUploadRequestType, request, tid)
 	if err != nil {
 		logger.Errorw(ctx, "Cannot serialize MibUploadRequest", log.Fields{
 			"Err": err, "device-id": oo.deviceID})
 		return err
 	}
-	oo.uploadSequNo = 0
-	oo.uploadNoOfCmds = 0
+	oo.UploadSequNo = 0
+	oo.UploadNoOfCmds = 0
 
-	omciRxCallbackPair := callbackPair{
-		cbKey:   tid,
-		cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse, true},
+	omciRxCallbackPair := CallbackPair{
+		CbKey:   tid,
+		CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibUploadFsmCommChan(), oo.receiveOmciResponse, true},
 	}
-	return oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+	return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
 }
 
-func (oo *omciCC) sendMibUploadNext(ctx context.Context, timeout int, highPrio bool) error {
-	logger.Debugw(ctx, "send MibUploadNext-msg to:", log.Fields{"device-id": oo.deviceID, "uploadSequNo": oo.uploadSequNo})
+// SendMibUploadNext sends MibUploadNextRequest
+func (oo *OmciCC) SendMibUploadNext(ctx context.Context, timeout int, highPrio bool) error {
+	logger.Debugw(ctx, "send MibUploadNext-msg to:", log.Fields{"device-id": oo.deviceID, "UploadSequNo": oo.UploadSequNo})
 	request := &omci.MibUploadNextRequest{
 		MeBasePacket: omci.MeBasePacket{
 			EntityClass: me.OnuDataClassID,
 		},
-		CommandSequenceNumber: oo.uploadSequNo,
+		CommandSequenceNumber: oo.UploadSequNo,
 	}
-	tid := oo.getNextTid(highPrio)
-	pkt, err := serialize(ctx, omci.MibUploadNextRequestType, request, tid)
+	tid := oo.GetNextTid(highPrio)
+	pkt, err := Serialize(ctx, omci.MibUploadNextRequestType, request, tid)
 	if err != nil {
 		logger.Errorw(ctx, "Cannot serialize MibUploadNextRequest", log.Fields{
 			"Err": err, "device-id": oo.deviceID})
 		return err
 	}
-	oo.uploadSequNo++
+	oo.UploadSequNo++
 
-	omciRxCallbackPair := callbackPair{
-		cbKey: tid,
+	omciRxCallbackPair := CallbackPair{
+		CbKey: tid,
 		//frame printing for MibUpload frames disabled now per default to avoid log file abort situations (size/speed?)
 		// if wanted, rx frame printing should be specifically done within the MibUpload FSM or controlled via extra parameter
 		// compare also software upgrade download section handling
-		cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse, true},
+		CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibUploadFsmCommChan(), oo.receiveOmciResponse, true},
 	}
-	return oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+	return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
 }
 
-func (oo *omciCC) sendGetAllAlarm(ctx context.Context, alarmRetreivalMode uint8, timeout int, highPrio bool) error {
+// SendGetAllAlarm gets all alarm ME instances
+func (oo *OmciCC) SendGetAllAlarm(ctx context.Context, alarmRetreivalMode uint8, timeout int, highPrio bool) error {
 	logger.Debugw(ctx, "send GetAllAlarms-msg to:", log.Fields{"device-id": oo.deviceID})
 	request := &omci.GetAllAlarmsRequest{
 		MeBasePacket: omci.MeBasePacket{
@@ -818,26 +830,26 @@
 		},
 		AlarmRetrievalMode: byte(alarmRetreivalMode),
 	}
-	tid := oo.getNextTid(highPrio)
-	pkt, err := serialize(ctx, omci.GetAllAlarmsRequestType, request, tid)
+	tid := oo.GetNextTid(highPrio)
+	pkt, err := Serialize(ctx, omci.GetAllAlarmsRequestType, request, tid)
 	if err != nil {
 		logger.Errorw(ctx, "Cannot serialize GetAllAlarmsRequest", log.Fields{
 			"Err": err, "device-id": oo.deviceID})
 		return err
 	}
-	oo.pBaseDeviceHandler.pAlarmMgr.ResetAlarmUploadCounters()
+	oo.pOnuAlarmManager.ResetAlarmUploadCounters()
 
-	omciRxCallbackPair := callbackPair{
-		cbKey: tid,
-		cbEntry: callbackPairEntry{(*oo.pBaseDeviceHandler.pAlarmMgr).eventChannel,
-			oo.receiveOmciResponse, true},
+	omciRxCallbackPair := CallbackPair{
+		CbKey:   tid,
+		CbEntry: CallbackPairEntry{oo.pOnuAlarmManager.GetAlarmMgrEventChannel(), oo.receiveOmciResponse, true},
 	}
-	return oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+	return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
 }
 
-func (oo *omciCC) sendGetAllAlarmNext(ctx context.Context, timeout int, highPrio bool) error {
-	alarmUploadSeqNo := oo.pBaseDeviceHandler.pAlarmMgr.GetAlarmUploadSeqNo()
-	logger.Debugw(ctx, "send sendGetAllAlarmNext-msg to:", log.Fields{"device-id": oo.deviceID,
+// SendGetAllAlarmNext gets next alarm ME instance
+func (oo *OmciCC) SendGetAllAlarmNext(ctx context.Context, timeout int, highPrio bool) error {
+	alarmUploadSeqNo := oo.pOnuAlarmManager.GetAlarmUploadSeqNo()
+	logger.Debugw(ctx, "send SendGetAllAlarmNext-msg to:", log.Fields{"device-id": oo.deviceID,
 		"alarmUploadSeqNo": alarmUploadSeqNo})
 	request := &omci.GetAllAlarmsNextRequest{
 		MeBasePacket: omci.MeBasePacket{
@@ -845,29 +857,30 @@
 		},
 		CommandSequenceNumber: alarmUploadSeqNo,
 	}
-	tid := oo.getNextTid(highPrio)
-	pkt, err := serialize(ctx, omci.GetAllAlarmsNextRequestType, request, tid)
+	tid := oo.GetNextTid(highPrio)
+	pkt, err := Serialize(ctx, omci.GetAllAlarmsNextRequestType, request, tid)
 	if err != nil {
 		logger.Errorw(ctx, "Cannot serialize GetAllAlarmsNextRequest", log.Fields{
 			"Err": err, "device-id": oo.deviceID})
 		return err
 	}
-	oo.pBaseDeviceHandler.pAlarmMgr.IncrementAlarmUploadSeqNo()
+	oo.pOnuAlarmManager.IncrementAlarmUploadSeqNo()
 
-	omciRxCallbackPair := callbackPair{
-		cbKey:   tid,
-		cbEntry: callbackPairEntry{(*oo.pBaseDeviceHandler.pAlarmMgr).eventChannel, oo.receiveOmciResponse, true},
+	omciRxCallbackPair := CallbackPair{
+		CbKey:   tid,
+		CbEntry: CallbackPairEntry{oo.pOnuAlarmManager.GetAlarmMgrEventChannel(), oo.receiveOmciResponse, true},
 	}
-	return oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+	return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
 }
 
-func (oo *omciCC) sendCreateGalEthernetProfile(ctx context.Context, timeout int, highPrio bool) (*me.ManagedEntity, error) {
-	tid := oo.getNextTid(highPrio)
+// SendCreateGalEthernetProfile creates GalEthernetProfile ME instance
+func (oo *OmciCC) SendCreateGalEthernetProfile(ctx context.Context, timeout int, highPrio bool) (*me.ManagedEntity, error) {
+	tid := oo.GetNextTid(highPrio)
 	logger.Debugw(ctx, "send GalEnetProfile-Create-msg:", log.Fields{"device-id": oo.deviceID,
 		"SequNo": strconv.FormatInt(int64(tid), 16)})
 
 	meParams := me.ParamData{
-		EntityID:   galEthernetEID,
+		EntityID:   GalEthernetEID,
 		Attributes: me.AttributeValueMap{"MaximumGemPayloadSize": maxGemPayloadSize},
 	}
 	meInstance, omciErr := me.NewGalEthernetProfile(meParams)
@@ -887,11 +900,11 @@
 			return nil, err
 		}
 
-		omciRxCallbackPair := callbackPair{
-			cbKey:   tid,
-			cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true},
+		omciRxCallbackPair := CallbackPair{
+			CbKey:   tid,
+			CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
 		}
-		err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+		err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
 		if err != nil {
 			logger.Errorw(ctx, "Cannot send GalEnetProfile create", log.Fields{
 				"Err": err, "device-id": oo.deviceID})
@@ -905,9 +918,10 @@
 	return nil, omciErr.GetError()
 }
 
+// SendSetOnu2g sets Onu2G ME instance
 // might be needed to extend for parameter arguments, here just for setting the ConnectivityMode!!
-func (oo *omciCC) sendSetOnu2g(ctx context.Context, timeout int, highPrio bool) (*me.ManagedEntity, error) {
-	tid := oo.getNextTid(highPrio)
+func (oo *OmciCC) SendSetOnu2g(ctx context.Context, timeout int, highPrio bool) (*me.ManagedEntity, error) {
+	tid := oo.GetNextTid(highPrio)
 	logger.Debugw(ctx, "send ONU2-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
 		"SequNo": strconv.FormatInt(int64(tid), 16)})
 
@@ -935,11 +949,11 @@
 			return nil, err
 		}
 
-		omciRxCallbackPair := callbackPair{
-			cbKey:   tid,
-			cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true},
+		omciRxCallbackPair := CallbackPair{
+			CbKey:   tid,
+			CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
 		}
-		err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+		err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
 		if err != nil {
 			logger.Errorw(ctx, "Cannot send ONU2-G set", log.Fields{
 				"Err": err, "device-id": oo.deviceID})
@@ -953,10 +967,11 @@
 	return nil, omciErr.GetError()
 }
 
-func (oo *omciCC) sendCreateMBServiceProfile(ctx context.Context,
-	aPUniPort *onuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
-	tid := oo.getNextTid(highPrio)
-	instID := macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo)
+// SendCreateMBServiceProfile creates MacBridgeServiceProfile ME instance
+func (oo *OmciCC) SendCreateMBServiceProfile(ctx context.Context,
+	aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
+	tid := oo.GetNextTid(highPrio)
+	instID := MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo)
 	logger.Debugw(ctx, "send MBSP-Create-msg:", log.Fields{"device-id": oo.deviceID,
 		"SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
 
@@ -989,11 +1004,11 @@
 			return nil, err
 		}
 
-		omciRxCallbackPair := callbackPair{
-			cbKey:   tid,
-			cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true},
+		omciRxCallbackPair := CallbackPair{
+			CbKey:   tid,
+			CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
 		}
-		err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+		err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
 		if err != nil {
 			logger.Errorw(ctx, "Cannot send MBSP create", log.Fields{
 				"Err": err, "device-id": oo.deviceID})
@@ -1007,25 +1022,26 @@
 	return nil, omciErr.GetError()
 }
 
-func (oo *omciCC) sendCreateMBPConfigDataUniSide(ctx context.Context,
-	aPUniPort *onuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
-	tid := oo.getNextTid(highPrio)
-	instID, idErr := generateUNISideMBPCDEID(uint16(aPUniPort.macBpNo))
+// SendCreateMBPConfigDataUniSide creates MacBridgePortConfigurationData ME instance
+func (oo *OmciCC) SendCreateMBPConfigDataUniSide(ctx context.Context,
+	aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
+	tid := oo.GetNextTid(highPrio)
+	instID, idErr := GenerateUNISideMBPCDEID(uint16(aPUniPort.MacBpNo))
 	if idErr != nil {
 		logger.Errorw(ctx, "Cannot generate MBPCD entity id", log.Fields{
 			"Err": idErr, "device-id": oo.deviceID})
 		return nil, idErr
 	}
 	logger.Debugw(ctx, "send MBPCD-Create-msg  for uni side:", log.Fields{"device-id": oo.deviceID,
-		"SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16), "macBpNo": aPUniPort.macBpNo})
+		"SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16), "macBpNo": aPUniPort.MacBpNo})
 
 	meParams := me.ParamData{
 		EntityID: instID,
 		Attributes: me.AttributeValueMap{
-			"BridgeIdPointer": macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo),
-			"PortNum":         aPUniPort.macBpNo,
-			"TpType":          uint8(aPUniPort.portType),
-			"TpPointer":       aPUniPort.entityID,
+			"BridgeIdPointer": MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo),
+			"PortNum":         aPUniPort.MacBpNo,
+			"TpType":          uint8(aPUniPort.PortType),
+			"TpPointer":       aPUniPort.EntityID,
 		},
 	}
 	meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams)
@@ -1046,11 +1062,11 @@
 			return nil, err
 		}
 
-		omciRxCallbackPair := callbackPair{
-			cbKey:   tid,
-			cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true},
+		omciRxCallbackPair := CallbackPair{
+			CbKey:   tid,
+			CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
 		}
-		err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+		err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
 		if err != nil {
 			logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{
 				"Err": err, "device-id": oo.deviceID})
@@ -1064,11 +1080,12 @@
 	return nil, omciErr.GetError()
 }
 
-func (oo *omciCC) sendCreateEVTOConfigData(ctx context.Context,
-	aPUniPort *onuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
-	tid := oo.getNextTid(highPrio)
+// SendCreateEVTOConfigData creates ExtendedVlanTaggingOperationConfigurationData ME instance
+func (oo *OmciCC) SendCreateEVTOConfigData(ctx context.Context,
+	aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
+	tid := oo.GetNextTid(highPrio)
 	//same entityId is used as for MBSP (see there), but just arbitrary ...
-	instID := macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo)
+	instID := MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo)
 	logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
 		"SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
 
@@ -1076,14 +1093,14 @@
 	//   (setting TPID values for the create would probably anyway be ignored by the omci lib)
 	//    but perhaps we have to be aware of possible problems at get(Next) Request handling for EVTOOCD tables later ...
 	assType := uint8(2) // default AssociationType is PPTPEthUni
-	if aPUniPort.portType == uniVEIP {
+	if aPUniPort.PortType == UniVEIP {
 		assType = uint8(10) // for VEIP
 	}
 	meParams := me.ParamData{
 		EntityID: instID,
 		Attributes: me.AttributeValueMap{
 			"AssociationType":     assType,
-			"AssociatedMePointer": aPUniPort.entityID,
+			"AssociatedMePointer": aPUniPort.EntityID,
 		},
 	}
 	meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(meParams)
@@ -1103,11 +1120,11 @@
 			return nil, err
 		}
 
-		omciRxCallbackPair := callbackPair{
-			cbKey:   tid,
-			cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true},
+		omciRxCallbackPair := CallbackPair{
+			CbKey:   tid,
+			CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
 		}
-		err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+		err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
 		if err != nil {
 			logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{
 				"Err": err, "device-id": oo.deviceID})
@@ -1121,9 +1138,10 @@
 	return nil, omciErr.GetError()
 }
 
-func (oo *omciCC) sendSetOnuGLS(ctx context.Context, timeout int,
+// SendSetOnuGLS sets OnuG ME instance
+func (oo *OmciCC) SendSetOnuGLS(ctx context.Context, timeout int,
 	highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) {
-	tid := oo.getNextTid(highPrio)
+	tid := oo.GetNextTid(highPrio)
 	logger.Debugw(ctx, "send ONU-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
 		"SequNo": strconv.FormatInt(int64(tid), 16)})
 
@@ -1148,11 +1166,11 @@
 			return nil, err
 		}
 
-		omciRxCallbackPair := callbackPair{
-			cbKey:   tid,
-			cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+		omciRxCallbackPair := CallbackPair{
+			CbKey:   tid,
+			CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
 		}
-		err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+		err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
 		if err != nil {
 			logger.Errorw(ctx, "Cannot send ONU-G set", log.Fields{
 				"Err": err, "device-id": oo.deviceID})
@@ -1166,9 +1184,10 @@
 	return nil, omciErr.GetError()
 }
 
-func (oo *omciCC) sendSetPptpEthUniLS(ctx context.Context, aInstNo uint16, timeout int,
+// SendSetPptpEthUniLS sets PhysicalPathTerminationPointEthernetUni ME instance
+func (oo *OmciCC) SendSetPptpEthUniLS(ctx context.Context, aInstNo uint16, timeout int,
 	highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) {
-	tid := oo.getNextTid(highPrio)
+	tid := oo.GetNextTid(highPrio)
 	logger.Debugw(ctx, "send PPTPEthUni-Set-msg:", log.Fields{"device-id": oo.deviceID,
 		"SequNo": strconv.FormatInt(int64(tid), 16)})
 
@@ -1193,11 +1212,11 @@
 			return nil, err
 		}
 
-		omciRxCallbackPair := callbackPair{
-			cbKey:   tid,
-			cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+		omciRxCallbackPair := CallbackPair{
+			CbKey:   tid,
+			CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
 		}
-		err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+		err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
 		if err != nil {
 			logger.Errorw(ctx, "Cannot send PPTPEthUni-Set", log.Fields{
 				"Err": err, "device-id": oo.deviceID})
@@ -1215,7 +1234,7 @@
    UniG AdminState anyway should be ignored by ONU acc. to G988
 func (oo *omciCC) sendSetUniGLS(ctx context.Context, aInstNo uint16, timeout int,
 	highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
-	tid := oo.getNextTid(highPrio)
+	tid := oo.GetNextTid(highPrio)
 	logger.Debugw(ctx,"send UNI-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
 		"SequNo": strconv.FormatInt(int64(tid), 16)})
 
@@ -1240,11 +1259,11 @@
 			return nil
 		}
 
-		omciRxCallbackPair := callbackPair{
-			cbKey:   tid,
-			cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+		omciRxCallbackPair := CallbackPair{
+			CbKey:   tid,
+			CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
 		}
-		err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+		err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
 		if err != nil {
 			logger.Errorw(ctx,"Cannot send UNIG-G-Set", log.Fields{
 				"Err": err, "device-id": oo.deviceID})
@@ -1259,9 +1278,10 @@
 }
 */
 
-func (oo *omciCC) sendSetVeipLS(ctx context.Context, aInstNo uint16, timeout int,
+// SendSetVeipLS sets VirtualEthernetInterfacePoint ME instance
+func (oo *OmciCC) SendSetVeipLS(ctx context.Context, aInstNo uint16, timeout int,
 	highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) {
-	tid := oo.getNextTid(highPrio)
+	tid := oo.GetNextTid(highPrio)
 	logger.Debugw(ctx, "send VEIP-Set-msg:", log.Fields{"device-id": oo.deviceID,
 		"SequNo": strconv.FormatInt(int64(tid), 16)})
 
@@ -1286,11 +1306,11 @@
 			return nil, err
 		}
 
-		omciRxCallbackPair := callbackPair{
-			cbKey:   tid,
-			cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+		omciRxCallbackPair := CallbackPair{
+			CbKey:   tid,
+			CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
 		}
-		err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+		err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
 		if err != nil {
 			logger.Errorw(ctx, "Cannot send VEIP-Set", log.Fields{
 				"Err": err, "device-id": oo.deviceID})
@@ -1304,10 +1324,11 @@
 	return nil, omciErr.GetError()
 }
 
-func (oo *omciCC) sendGetMe(ctx context.Context, classID me.ClassID, entityID uint16, requestedAttributes me.AttributeValueMap,
+// SendGetMe gets ME instance
+func (oo *OmciCC) SendGetMe(ctx context.Context, classID me.ClassID, entityID uint16, requestedAttributes me.AttributeValueMap,
 	timeout int, highPrio bool, rxChan chan Message) (*me.ManagedEntity, error) {
 
-	tid := oo.getNextTid(highPrio)
+	tid := oo.GetNextTid(highPrio)
 	logger.Debugw(ctx, "send get-request-msg", log.Fields{"classID": classID, "device-id": oo.deviceID,
 		"SequNo": strconv.FormatInt(int64(tid), 16)})
 
@@ -1328,11 +1349,11 @@
 			logger.Errorw(ctx, "Cannot serialize get-request", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
 			return nil, err
 		}
-		omciRxCallbackPair := callbackPair{
-			cbKey:   tid,
-			cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+		omciRxCallbackPair := CallbackPair{
+			CbKey:   tid,
+			CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
 		}
-		err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+		err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
 		if err != nil {
 			logger.Errorw(ctx, "Cannot send get-request-msg", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
 			return nil, err
@@ -1344,10 +1365,11 @@
 	return nil, omciErr.GetError()
 }
 
-func (oo *omciCC) sendGetMeWithAttributeMask(ctx context.Context, classID me.ClassID, entityID uint16, requestedAttributesMask uint16,
+// SendGetMeWithAttributeMask gets ME instance with attribute mask
+func (oo *OmciCC) SendGetMeWithAttributeMask(ctx context.Context, classID me.ClassID, entityID uint16, requestedAttributesMask uint16,
 	timeout int, highPrio bool, rxChan chan Message) error {
 
-	tid := oo.getNextTid(highPrio)
+	tid := oo.GetNextTid(highPrio)
 	logger.Debugw(ctx, "send get-request-msg", log.Fields{"classID": classID, "device-id": oo.deviceID,
 		"SequNo": strconv.FormatInt(int64(tid), 16)})
 
@@ -1359,16 +1381,16 @@
 		AttributeMask: requestedAttributesMask,
 	}
 
-	pkt, err := serialize(ctx, omci.GetRequestType, request, tid)
+	pkt, err := Serialize(ctx, omci.GetRequestType, request, tid)
 	if err != nil {
 		logger.Errorw(ctx, "Cannot serialize get-request", log.Fields{"meClassIDName": classID, "Err": err, "device-id": oo.deviceID})
 		return err
 	}
-	omciRxCallbackPair := callbackPair{
-		cbKey:   tid,
-		cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+	omciRxCallbackPair := CallbackPair{
+		CbKey:   tid,
+		CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
 	}
-	err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+	err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
 	if err != nil {
 		logger.Errorw(ctx, "Cannot send get-request-msg", log.Fields{"meClassIDName": classID, "Err": err, "device-id": oo.deviceID})
 		return err
@@ -1377,9 +1399,10 @@
 	return nil
 }
 
-func (oo *omciCC) sendCreateDot1PMapper(ctx context.Context, timeout int, highPrio bool,
+// SendCreateDot1PMapper creates Ieee8021PMapperServiceProfile ME instance
+func (oo *OmciCC) SendCreateDot1PMapper(ctx context.Context, timeout int, highPrio bool,
 	aInstID uint16, rxChan chan Message) (*me.ManagedEntity, error) {
-	tid := oo.getNextTid(highPrio)
+	tid := oo.GetNextTid(highPrio)
 	logger.Debugw(ctx, "send .1pMapper-Create-msg:", log.Fields{"device-id": oo.deviceID,
 		"SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(aInstID), 16)})
 
@@ -1416,11 +1439,11 @@
 			return nil, err
 		}
 
-		omciRxCallbackPair := callbackPair{
-			cbKey:   tid,
-			cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+		omciRxCallbackPair := CallbackPair{
+			CbKey:   tid,
+			CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
 		}
-		err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+		err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
 		if err != nil {
 			logger.Errorw(ctx, "Cannot send .1pMapper create", log.Fields{
 				"Err": err, "device-id": oo.deviceID})
@@ -1434,9 +1457,10 @@
 	return nil, omciErr.GetError()
 }
 
-func (oo *omciCC) sendCreateMBPConfigDataVar(ctx context.Context, timeout int, highPrio bool,
+// SendCreateMBPConfigDataVar creates MacBridgePortConfigurationData ME instance
+func (oo *OmciCC) SendCreateMBPConfigDataVar(ctx context.Context, timeout int, highPrio bool,
 	rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
-	tid := oo.getNextTid(highPrio)
+	tid := oo.GetNextTid(highPrio)
 	logger.Debugw(ctx, "send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
 		"SequNo": strconv.FormatInt(int64(tid), 16),
 		"InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
@@ -1459,11 +1483,11 @@
 			return nil, err
 		}
 
-		omciRxCallbackPair := callbackPair{
-			cbKey:   tid,
-			cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+		omciRxCallbackPair := CallbackPair{
+			CbKey:   tid,
+			CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
 		}
-		err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+		err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
 		if err != nil {
 			logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{
 				"Err": err, "device-id": oo.deviceID})
@@ -1477,9 +1501,10 @@
 	return nil, omciErr.GetError()
 }
 
-func (oo *omciCC) sendCreateGemNCTPVar(ctx context.Context, timeout int, highPrio bool,
+// SendCreateGemNCTPVar creates GemPortNetworkCtp ME instance
+func (oo *OmciCC) SendCreateGemNCTPVar(ctx context.Context, timeout int, highPrio bool,
 	rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
-	tid := oo.getNextTid(highPrio)
+	tid := oo.GetNextTid(highPrio)
 	logger.Debugw(ctx, "send GemNCTP-Create-msg:", log.Fields{"device-id": oo.deviceID,
 		"SequNo": strconv.FormatInt(int64(tid), 16),
 		"InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
@@ -1502,11 +1527,11 @@
 			return nil, err
 		}
 
-		omciRxCallbackPair := callbackPair{
-			cbKey:   tid,
-			cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+		omciRxCallbackPair := CallbackPair{
+			CbKey:   tid,
+			CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
 		}
-		err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+		err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
 		if err != nil {
 			logger.Errorw(ctx, "Cannot send GemNCTP create", log.Fields{
 				"Err": err, "device-id": oo.deviceID})
@@ -1520,8 +1545,9 @@
 	return nil, omciErr.GetError()
 }
 
-func (oo *omciCC) sendSetGemNCTPVar(ctx context.Context, timeout int, highPrio bool, rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
-	tid := oo.getNextTid(highPrio)
+// SendSetGemNCTPVar sets GemPortNetworkCtp ME instance
+func (oo *OmciCC) SendSetGemNCTPVar(ctx context.Context, timeout int, highPrio bool, rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
+	tid := oo.GetNextTid(highPrio)
 	logger.Debugw(ctx, "send GemNCTP-Set-msg:", log.Fields{"device-id": oo.deviceID,
 		"SequNo": strconv.FormatInt(int64(tid), 16),
 		"InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
@@ -1544,11 +1570,11 @@
 			return nil, err
 		}
 
-		omciRxCallbackPair := callbackPair{
-			cbKey:   tid,
-			cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+		omciRxCallbackPair := CallbackPair{
+			CbKey:   tid,
+			CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
 		}
-		err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+		err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
 		if err != nil {
 			logger.Errorw(ctx, "Cannot send GemNCTP set", log.Fields{
 				"Err": err, "device-id": oo.deviceID})
@@ -1562,9 +1588,10 @@
 	return nil, omciErr.GetError()
 }
 
-func (oo *omciCC) sendCreateGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
+// SendCreateGemIWTPVar creates GemInterworkingTerminationPoint ME instance
+func (oo *OmciCC) SendCreateGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
 	rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
-	tid := oo.getNextTid(highPrio)
+	tid := oo.GetNextTid(highPrio)
 	logger.Debugw(ctx, "send GemIwTp-Create-msg:", log.Fields{"device-id": oo.deviceID,
 		"SequNo": strconv.FormatInt(int64(tid), 16),
 		"InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
@@ -1587,11 +1614,11 @@
 			return nil, err
 		}
 
-		omciRxCallbackPair := callbackPair{
-			cbKey:   tid,
-			cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+		omciRxCallbackPair := CallbackPair{
+			CbKey:   tid,
+			CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
 		}
-		err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+		err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
 		if err != nil {
 			logger.Errorw(ctx, "Cannot send GemIwTp create", log.Fields{
 				"Err": err, "device-id": oo.deviceID})
@@ -1605,9 +1632,10 @@
 	return nil, omciErr.GetError()
 }
 
-func (oo *omciCC) sendSetTcontVar(ctx context.Context, timeout int, highPrio bool,
+// SendSetTcontVar sets TCont ME instance
+func (oo *OmciCC) SendSetTcontVar(ctx context.Context, timeout int, highPrio bool,
 	rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
-	tid := oo.getNextTid(highPrio)
+	tid := oo.GetNextTid(highPrio)
 	logger.Debugw(ctx, "send TCont-Set-msg:", log.Fields{"device-id": oo.deviceID,
 		"SequNo": strconv.FormatInt(int64(tid), 16),
 		"InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
@@ -1628,11 +1656,11 @@
 			return nil, err
 		}
 
-		omciRxCallbackPair := callbackPair{
-			cbKey:   tid,
-			cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+		omciRxCallbackPair := CallbackPair{
+			CbKey:   tid,
+			CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
 		}
-		err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+		err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
 		if err != nil {
 			logger.Errorw(ctx, "Cannot send TCont set", log.Fields{
 				"Err": err, "device-id": oo.deviceID})
@@ -1646,9 +1674,10 @@
 	return nil, omciErr.GetError()
 }
 
-func (oo *omciCC) sendSetPrioQueueVar(ctx context.Context, timeout int, highPrio bool,
+// SendSetPrioQueueVar sets PriorityQueue ME instance
+func (oo *OmciCC) SendSetPrioQueueVar(ctx context.Context, timeout int, highPrio bool,
 	rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
-	tid := oo.getNextTid(highPrio)
+	tid := oo.GetNextTid(highPrio)
 	logger.Debugw(ctx, "send PrioQueue-Set-msg:", log.Fields{"device-id": oo.deviceID,
 		"SequNo": strconv.FormatInt(int64(tid), 16),
 		"InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
@@ -1669,11 +1698,11 @@
 			return nil, err
 		}
 
-		omciRxCallbackPair := callbackPair{
-			cbKey:   tid,
-			cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+		omciRxCallbackPair := CallbackPair{
+			CbKey:   tid,
+			CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
 		}
-		err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+		err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
 		if err != nil {
 			logger.Errorw(ctx, "Cannot send PrioQueue set", log.Fields{
 				"Err": err, "device-id": oo.deviceID})
@@ -1687,9 +1716,10 @@
 	return nil, omciErr.GetError()
 }
 
-func (oo *omciCC) sendSetDot1PMapperVar(ctx context.Context, timeout int, highPrio bool,
+// SendSetDot1PMapperVar sets Ieee8021PMapperServiceProfile ME instance
+func (oo *OmciCC) SendSetDot1PMapperVar(ctx context.Context, timeout int, highPrio bool,
 	rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
-	tid := oo.getNextTid(highPrio)
+	tid := oo.GetNextTid(highPrio)
 	logger.Debugw(ctx, "send 1PMapper-Set-msg:", log.Fields{"device-id": oo.deviceID,
 		"SequNo": strconv.FormatInt(int64(tid), 16),
 		"InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
@@ -1710,11 +1740,11 @@
 			return nil, err
 		}
 
-		omciRxCallbackPair := callbackPair{
-			cbKey:   tid,
-			cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+		omciRxCallbackPair := CallbackPair{
+			CbKey:   tid,
+			CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
 		}
-		err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+		err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
 		if err != nil {
 			logger.Errorw(ctx, "Cannot send 1PMapper set", log.Fields{
 				"Err": err, "device-id": oo.deviceID})
@@ -1728,9 +1758,10 @@
 	return nil, omciErr.GetError()
 }
 
-func (oo *omciCC) sendCreateVtfdVar(ctx context.Context, timeout int, highPrio bool,
+// SendCreateVtfdVar creates VlanTaggingFilterData ME instance
+func (oo *OmciCC) SendCreateVtfdVar(ctx context.Context, timeout int, highPrio bool,
 	rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
-	tid := oo.getNextTid(highPrio)
+	tid := oo.GetNextTid(highPrio)
 	logger.Debugw(ctx, "send VTFD-Create-msg:", log.Fields{"device-id": oo.deviceID,
 		"SequNo": strconv.FormatInt(int64(tid), 16),
 		"InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
@@ -1756,11 +1787,11 @@
 			return nil, err
 		}
 
-		omciRxCallbackPair := callbackPair{
-			cbKey:   tid,
-			cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+		omciRxCallbackPair := CallbackPair{
+			CbKey:   tid,
+			CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
 		}
-		err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+		err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
 		if err != nil {
 			logger.Errorw(ctx, "Cannot send VTFD create", log.Fields{
 				"Err": err, "device-id": oo.deviceID})
@@ -1775,9 +1806,9 @@
 }
 
 // nolint: unused
-func (oo *omciCC) sendSetVtfdVar(ctx context.Context, timeout int, highPrio bool,
+func (oo *OmciCC) sendSetVtfdVar(ctx context.Context, timeout int, highPrio bool,
 	rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
-	tid := oo.getNextTid(highPrio)
+	tid := oo.GetNextTid(highPrio)
 	logger.Debugw(ctx, "send VTFD-Set-msg:", log.Fields{"device-id": oo.deviceID,
 		"SequNo": strconv.FormatInt(int64(tid), 16),
 		"InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
@@ -1802,11 +1833,11 @@
 			return nil, err
 		}
 
-		omciRxCallbackPair := callbackPair{
-			cbKey:   tid,
-			cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+		omciRxCallbackPair := CallbackPair{
+			CbKey:   tid,
+			CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
 		}
-		err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+		err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
 		if err != nil {
 			logger.Errorw(ctx, "Cannot send VTFD set", log.Fields{
 				"Err": err, "device-id": oo.deviceID})
@@ -1820,9 +1851,10 @@
 	return nil, omciErr.GetError()
 }
 
-func (oo *omciCC) sendCreateEvtocdVar(ctx context.Context, timeout int, highPrio bool,
+// SendCreateEvtocdVar creates ExtendedVlanTaggingOperationConfigurationData ME instance
+func (oo *OmciCC) SendCreateEvtocdVar(ctx context.Context, timeout int, highPrio bool,
 	rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
-	tid := oo.getNextTid(highPrio)
+	tid := oo.GetNextTid(highPrio)
 	logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
 		"SequNo": strconv.FormatInt(int64(tid), 16),
 		"InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
@@ -1843,11 +1875,11 @@
 			return nil, err
 		}
 
-		omciRxCallbackPair := callbackPair{
-			cbKey:   tid,
-			cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+		omciRxCallbackPair := CallbackPair{
+			CbKey:   tid,
+			CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
 		}
-		err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+		err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
 		if err != nil {
 			logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{
 				"Err": err, "device-id": oo.deviceID})
@@ -1861,9 +1893,10 @@
 	return nil, omciErr.GetError()
 }
 
-func (oo *omciCC) sendSetEvtocdVar(ctx context.Context, timeout int, highPrio bool,
+// SendSetEvtocdVar sets ExtendedVlanTaggingOperationConfigurationData ME instance
+func (oo *OmciCC) SendSetEvtocdVar(ctx context.Context, timeout int, highPrio bool,
 	rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
-	tid := oo.getNextTid(highPrio)
+	tid := oo.GetNextTid(highPrio)
 	logger.Debugw(ctx, "send EVTOCD-Set-msg:", log.Fields{"device-id": oo.deviceID,
 		"SequNo": strconv.FormatInt(int64(tid), 16),
 		"InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
@@ -1884,11 +1917,11 @@
 			return nil, err
 		}
 
-		omciRxCallbackPair := callbackPair{
-			cbKey:   tid,
-			cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+		omciRxCallbackPair := CallbackPair{
+			CbKey:   tid,
+			CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
 		}
-		err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+		err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
 		if err != nil {
 			logger.Errorw(ctx, "Cannot send EVTOCD set", log.Fields{
 				"Err": err, "device-id": oo.deviceID})
@@ -1902,9 +1935,10 @@
 	return nil, omciErr.GetError()
 }
 
-func (oo *omciCC) sendDeleteEvtocd(ctx context.Context, timeout int, highPrio bool,
+// SendDeleteEvtocd deletes ExtendedVlanTaggingOperationConfigurationData ME instance
+func (oo *OmciCC) SendDeleteEvtocd(ctx context.Context, timeout int, highPrio bool,
 	rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
-	tid := oo.getNextTid(highPrio)
+	tid := oo.GetNextTid(highPrio)
 	logger.Debugw(ctx, "send EVTOCD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
 		"SequNo": strconv.FormatInt(int64(tid), 16),
 		"InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
@@ -1925,11 +1959,11 @@
 			return nil, err
 		}
 
-		omciRxCallbackPair := callbackPair{
-			cbKey:   tid,
-			cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+		omciRxCallbackPair := CallbackPair{
+			CbKey:   tid,
+			CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
 		}
-		err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+		err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
 		if err != nil {
 			logger.Errorw(ctx, "Cannot send EVTOCD delete", log.Fields{
 				"Err": err, "device-id": oo.deviceID})
@@ -1943,9 +1977,10 @@
 	return nil, omciErr.GetError()
 }
 
-func (oo *omciCC) sendDeleteVtfd(ctx context.Context, timeout int, highPrio bool,
+// SendDeleteVtfd deletes VlanTaggingFilterData ME instance
+func (oo *OmciCC) SendDeleteVtfd(ctx context.Context, timeout int, highPrio bool,
 	rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
-	tid := oo.getNextTid(highPrio)
+	tid := oo.GetNextTid(highPrio)
 	logger.Debugw(ctx, "send VTFD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
 		"SequNo": strconv.FormatInt(int64(tid), 16),
 		"InstId": strconv.FormatInt(int64(aInstID), 16)})
@@ -1971,11 +2006,11 @@
 			return nil, err
 		}
 
-		omciRxCallbackPair := callbackPair{
-			cbKey:   tid,
-			cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+		omciRxCallbackPair := CallbackPair{
+			CbKey:   tid,
+			CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
 		}
-		err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+		err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
 		if err != nil {
 			logger.Errorw(ctx, "Cannot send VTFD delete", log.Fields{
 				"Err": err, "device-id": oo.deviceID})
@@ -1989,8 +2024,9 @@
 	return nil, omciErr.GetError()
 }
 
-func (oo *omciCC) sendCreateTDVar(ctx context.Context, timeout int, highPrio bool, rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
-	tid := oo.getNextTid(highPrio)
+// SendCreateTDVar creates TrafficDescriptor ME instance
+func (oo *OmciCC) SendCreateTDVar(ctx context.Context, timeout int, highPrio bool, rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
+	tid := oo.GetNextTid(highPrio)
 	logger.Debugw(ctx, "send TD-Create-msg:", log.Fields{"device-id": oo.deviceID,
 		"SequNo": strconv.FormatInt(int64(tid), 16),
 		"InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
@@ -2006,11 +2042,11 @@
 			logger.Errorw(ctx, "Cannot serialize TD create", log.Fields{"Err": err, "device-id": oo.deviceID})
 			return nil, err
 		}
-		omciRxCallbackPair := callbackPair{
-			cbKey:   tid,
-			cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+		omciRxCallbackPair := CallbackPair{
+			CbKey:   tid,
+			CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
 		}
-		err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+		err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
 		if err != nil {
 			logger.Errorw(ctx, "Cannot send TD create", log.Fields{"Err": err, "device-id": oo.deviceID})
 			return nil, err
@@ -2023,9 +2059,9 @@
 }
 
 // nolint: unused
-func (oo *omciCC) sendSetTDVar(ctx context.Context, timeout int, highPrio bool,
+func (oo *OmciCC) sendSetTDVar(ctx context.Context, timeout int, highPrio bool,
 	rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
-	tid := oo.getNextTid(highPrio)
+	tid := oo.GetNextTid(highPrio)
 	logger.Debugw(ctx, "send TD-Set-msg:", log.Fields{"device-id": oo.deviceID,
 		"SequNo": strconv.FormatInt(int64(tid), 16),
 		"InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
@@ -2042,11 +2078,11 @@
 			logger.Errorw(ctx, "Cannot serialize TD set", log.Fields{"Err": err, "device-id": oo.deviceID})
 			return nil, err
 		}
-		omciRxCallbackPair := callbackPair{
-			cbKey:   tid,
-			cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+		omciRxCallbackPair := CallbackPair{
+			CbKey:   tid,
+			CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
 		}
-		err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+		err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
 		if err != nil {
 			logger.Errorw(ctx, "Cannot send TD set", log.Fields{"Err": err, "device-id": oo.deviceID})
 			return nil, err
@@ -2059,10 +2095,10 @@
 
 }
 
-// nolint: unused
-func (oo *omciCC) sendDeleteTD(ctx context.Context, timeout int, highPrio bool,
+// SendDeleteTD - TODO: add comment
+func (oo *OmciCC) SendDeleteTD(ctx context.Context, timeout int, highPrio bool,
 	rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
-	tid := oo.getNextTid(highPrio)
+	tid := oo.GetNextTid(highPrio)
 	logger.Debugw(ctx, "send TD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
 		"SequNo": strconv.FormatInt(int64(tid), 16),
 		"InstId": strconv.FormatInt(int64(aInstID), 16)})
@@ -2080,11 +2116,11 @@
 			logger.Errorw(ctx, "Cannot serialize TD delete", log.Fields{"Err": err, "device-id": oo.deviceID})
 			return nil, err
 		}
-		omciRxCallbackPair := callbackPair{
-			cbKey:   tid,
-			cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+		omciRxCallbackPair := CallbackPair{
+			CbKey:   tid,
+			CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
 		}
-		err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+		err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
 		if err != nil {
 			logger.Errorw(ctx, "Cannot send TD delete", log.Fields{"Err": err, "device-id": oo.deviceID})
 			return nil, err
@@ -2097,9 +2133,10 @@
 
 }
 
-func (oo *omciCC) sendDeleteGemIWTP(ctx context.Context, timeout int, highPrio bool,
+// SendDeleteGemIWTP deletes GemInterworkingTerminationPoint ME instance
+func (oo *OmciCC) SendDeleteGemIWTP(ctx context.Context, timeout int, highPrio bool,
 	rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
-	tid := oo.getNextTid(highPrio)
+	tid := oo.GetNextTid(highPrio)
 	logger.Debugw(ctx, "send GemIwTp-Delete-msg:", log.Fields{"device-id": oo.deviceID,
 		"SequNo": strconv.FormatInt(int64(tid), 16),
 		"InstId": strconv.FormatInt(int64(aInstID), 16)})
@@ -2125,11 +2162,11 @@
 			return nil, err
 		}
 
-		omciRxCallbackPair := callbackPair{
-			cbKey:   tid,
-			cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+		omciRxCallbackPair := CallbackPair{
+			CbKey:   tid,
+			CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
 		}
-		err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+		err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
 		if err != nil {
 			logger.Errorw(ctx, "Cannot send GemIwTp delete", log.Fields{
 				"Err": err, "device-id": oo.deviceID})
@@ -2143,9 +2180,10 @@
 	return nil, omciErr.GetError()
 }
 
-func (oo *omciCC) sendDeleteGemNCTP(ctx context.Context, timeout int, highPrio bool,
+// SendDeleteGemNCTP deletes GemPortNetworkCtp ME instance
+func (oo *OmciCC) SendDeleteGemNCTP(ctx context.Context, timeout int, highPrio bool,
 	rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
-	tid := oo.getNextTid(highPrio)
+	tid := oo.GetNextTid(highPrio)
 	logger.Debugw(ctx, "send GemNCtp-Delete-msg:", log.Fields{"device-id": oo.deviceID,
 		"SequNo": strconv.FormatInt(int64(tid), 16),
 		"InstId": strconv.FormatInt(int64(aInstID), 16)})
@@ -2171,11 +2209,11 @@
 			return nil, err
 		}
 
-		omciRxCallbackPair := callbackPair{
-			cbKey:   tid,
-			cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+		omciRxCallbackPair := CallbackPair{
+			CbKey:   tid,
+			CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
 		}
-		err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+		err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
 		if err != nil {
 			logger.Errorw(ctx, "Cannot send GemNCtp delete", log.Fields{
 				"Err": err, "device-id": oo.deviceID})
@@ -2189,9 +2227,10 @@
 	return nil, omciErr.GetError()
 }
 
-func (oo *omciCC) sendDeleteDot1PMapper(ctx context.Context, timeout int, highPrio bool,
+// SendDeleteDot1PMapper deletes Ieee8021PMapperServiceProfile ME instance
+func (oo *OmciCC) SendDeleteDot1PMapper(ctx context.Context, timeout int, highPrio bool,
 	rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
-	tid := oo.getNextTid(highPrio)
+	tid := oo.GetNextTid(highPrio)
 	logger.Debugw(ctx, "send .1pMapper-Delete-msg:", log.Fields{"device-id": oo.deviceID,
 		"SequNo": strconv.FormatInt(int64(tid), 16),
 		"InstId": strconv.FormatInt(int64(aInstID), 16)})
@@ -2217,11 +2256,11 @@
 			return nil, err
 		}
 
-		omciRxCallbackPair := callbackPair{
-			cbKey:   tid,
-			cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+		omciRxCallbackPair := CallbackPair{
+			CbKey:   tid,
+			CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
 		}
-		err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+		err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
 		if err != nil {
 			logger.Errorw(ctx, "Cannot send .1pMapper delete", log.Fields{
 				"Err": err, "device-id": oo.deviceID})
@@ -2235,9 +2274,10 @@
 	return nil, omciErr.GetError()
 }
 
-func (oo *omciCC) sendDeleteMBPConfigData(ctx context.Context, timeout int, highPrio bool,
+// SendDeleteMBPConfigData deletes MacBridgePortConfigurationData ME instance
+func (oo *OmciCC) SendDeleteMBPConfigData(ctx context.Context, timeout int, highPrio bool,
 	rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
-	tid := oo.getNextTid(highPrio)
+	tid := oo.GetNextTid(highPrio)
 	logger.Debugw(ctx, "send MBPCD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
 		"SequNo": strconv.FormatInt(int64(tid), 16),
 		"InstId": strconv.FormatInt(int64(aInstID), 16)})
@@ -2263,11 +2303,11 @@
 			return nil, err
 		}
 
-		omciRxCallbackPair := callbackPair{
-			cbKey:   tid,
-			cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+		omciRxCallbackPair := CallbackPair{
+			CbKey:   tid,
+			CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
 		}
-		err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+		err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
 		if err != nil {
 			logger.Errorw(ctx, "Cannot send MBPCD delete", log.Fields{
 				"Err": err, "device-id": oo.deviceID})
@@ -2281,9 +2321,10 @@
 	return nil, omciErr.GetError()
 }
 
-func (oo *omciCC) sendCreateMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
+// SendCreateMulticastGemIWTPVar creates MulticastGemInterworkingTerminationPoint ME instance
+func (oo *OmciCC) SendCreateMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
 	rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
-	tid := oo.getNextTid(highPrio)
+	tid := oo.GetNextTid(highPrio)
 	logger.Debugw(ctx, "send MulticastGemIWTP-create-msg:", log.Fields{"device-id": oo.deviceID,
 		"SequNo": strconv.FormatInt(int64(tid), 16),
 		"InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
@@ -2303,10 +2344,10 @@
 			return nil, err
 		}
 
-		omciRxCallbackPair := callbackPair{cbKey: tid,
-			cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+		omciRxCallbackPair := CallbackPair{CbKey: tid,
+			CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
 		}
-		err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+		err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
 		if err != nil {
 			logger.Errorw(ctx, "Cannot send MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
 			return nil, err
@@ -2319,9 +2360,10 @@
 	return nil, omciErr.GetError()
 }
 
-func (oo *omciCC) sendSetMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
+// SendSetMulticastGemIWTPVar sets MulticastGemInterworkingTerminationPoint ME instance
+func (oo *OmciCC) SendSetMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
 	rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
-	tid := oo.getNextTid(highPrio)
+	tid := oo.GetNextTid(highPrio)
 	logger.Debugw(ctx, "send MulticastGemIWTP-set-msg:", log.Fields{"device-id": oo.deviceID,
 		"SequNo": strconv.FormatInt(int64(tid), 16),
 		"InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
@@ -2341,10 +2383,10 @@
 			return nil, err
 		}
 
-		omciRxCallbackPair := callbackPair{cbKey: tid,
-			cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+		omciRxCallbackPair := CallbackPair{CbKey: tid,
+			CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
 		}
-		err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+		err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
 		if err != nil {
 			logger.Errorw(ctx, "Cannot send MulticastGEMIWTP set", log.Fields{"Err": err, "device-id": oo.deviceID})
 			return nil, err
@@ -2357,9 +2399,10 @@
 	return nil, omciErr.GetError()
 }
 
-func (oo *omciCC) sendCreateMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool,
+// SendCreateMulticastOperationProfileVar creates MulticastOperationsProfile ME instance
+func (oo *OmciCC) SendCreateMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool,
 	rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
-	tid := oo.getNextTid(highPrio)
+	tid := oo.GetNextTid(highPrio)
 	logger.Debugw(ctx, "send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
 		"SequNo": strconv.FormatInt(int64(tid), 16),
 		"InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
@@ -2381,10 +2424,10 @@
 			return nil, err
 		}
 
-		omciRxCallbackPair := callbackPair{cbKey: tid,
-			cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+		omciRxCallbackPair := CallbackPair{CbKey: tid,
+			CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
 		}
-		err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+		err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
 		if err != nil {
 			logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err,
 				"device-id": oo.deviceID})
@@ -2398,9 +2441,10 @@
 	return nil, omciErr.GetError()
 }
 
-func (oo *omciCC) sendSetMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool,
+// SendSetMulticastOperationProfileVar sets MulticastOperationsProfile ME instance
+func (oo *OmciCC) SendSetMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool,
 	rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
-	tid := oo.getNextTid(highPrio)
+	tid := oo.GetNextTid(highPrio)
 	logger.Debugw(ctx, "send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
 		"SequNo": strconv.FormatInt(int64(tid), 16),
 		"InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
@@ -2422,10 +2466,10 @@
 			return nil, err
 		}
 
-		omciRxCallbackPair := callbackPair{cbKey: tid,
-			cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+		omciRxCallbackPair := CallbackPair{CbKey: tid,
+			CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
 		}
-		err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+		err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
 		if err != nil {
 			logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err,
 				"device-id": oo.deviceID})
@@ -2439,9 +2483,10 @@
 	return nil, omciErr.GetError()
 }
 
-func (oo *omciCC) sendCreateMulticastSubConfigInfoVar(ctx context.Context, timeout int, highPrio bool,
+// SendCreateMulticastSubConfigInfoVar creates MulticastSubscriberConfigInfo ME instance
+func (oo *OmciCC) SendCreateMulticastSubConfigInfoVar(ctx context.Context, timeout int, highPrio bool,
 	rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
-	tid := oo.getNextTid(highPrio)
+	tid := oo.GetNextTid(highPrio)
 	logger.Debugw(ctx, "send MulticastSubConfigInfo-create-msg:", log.Fields{"device-id": oo.deviceID,
 		"SequNo": strconv.FormatInt(int64(tid), 16),
 		"InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
@@ -2463,10 +2508,10 @@
 			return nil, err
 		}
 
-		omciRxCallbackPair := callbackPair{cbKey: tid,
-			cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+		omciRxCallbackPair := CallbackPair{CbKey: tid,
+			CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
 		}
-		err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+		err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
 		if err != nil {
 			logger.Errorw(ctx, "Cannot send MulticastSubConfigInfo create", log.Fields{"Err": err,
 				"device-id": oo.deviceID})
@@ -2480,8 +2525,9 @@
 	return nil, omciErr.GetError()
 }
 
-func (oo *omciCC) sendSyncTime(ctx context.Context, timeout int, highPrio bool, rxChan chan Message) error {
-	tid := oo.getNextTid(highPrio)
+// SendSyncTime sends SynchronizeTimeRequest
+func (oo *OmciCC) SendSyncTime(ctx context.Context, timeout int, highPrio bool, rxChan chan Message) error {
+	tid := oo.GetNextTid(highPrio)
 	logger.Debugw(ctx, "send synchronize time request:", log.Fields{"device-id": oo.deviceID,
 		"SequNo": strconv.FormatInt(int64(tid), 16)})
 
@@ -2512,10 +2558,10 @@
 		return err
 	}
 
-	omciRxCallbackPair := callbackPair{cbKey: tid,
-		cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+	omciRxCallbackPair := CallbackPair{CbKey: tid,
+		CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
 	}
-	err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+	err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
 	if err != nil {
 		logger.Errorw(ctx, "Cannot send synchronize time request", log.Fields{"Err": err,
 			"device-id": oo.deviceID})
@@ -2525,9 +2571,10 @@
 	return nil
 }
 
-func (oo *omciCC) sendCreateOrDeleteEthernetPerformanceMonitoringHistoryME(ctx context.Context, timeout int, highPrio bool,
+// SendCreateOrDeleteEthernetPerformanceMonitoringHistoryME creates or deletes EthernetFramePerformanceMonitoringHistoryData ME instance
+func (oo *OmciCC) SendCreateOrDeleteEthernetPerformanceMonitoringHistoryME(ctx context.Context, timeout int, highPrio bool,
 	upstream bool, create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
-	tid := oo.getNextTid(highPrio)
+	tid := oo.GetNextTid(highPrio)
 	logger.Debugw(ctx, "send ethernet-performance-monitoring-history-me-msg:", log.Fields{"device-id": oo.deviceID,
 		"SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create, "upstream": upstream})
 	meParam := me.ParamData{EntityID: entityID}
@@ -2562,10 +2609,10 @@
 			return nil, err
 		}
 
-		omciRxCallbackPair := callbackPair{cbKey: tid,
-			cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+		omciRxCallbackPair := CallbackPair{CbKey: tid,
+			CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
 		}
-		err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+		err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
 		if err != nil {
 			logger.Errorw(ctx, "Cannot send ethernet frame performance monitoring history data ME",
 				log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
@@ -2580,9 +2627,10 @@
 	return nil, omciErr.GetError()
 }
 
-func (oo *omciCC) sendCreateOrDeleteEthernetUniHistoryME(ctx context.Context, timeout int, highPrio bool,
+// SendCreateOrDeleteEthernetUniHistoryME creates or deletes EthernetPerformanceMonitoringHistoryData ME instance
+func (oo *OmciCC) SendCreateOrDeleteEthernetUniHistoryME(ctx context.Context, timeout int, highPrio bool,
 	create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
-	tid := oo.getNextTid(highPrio)
+	tid := oo.GetNextTid(highPrio)
 	logger.Debugw(ctx, "send ethernet-uni-history-me-msg:", log.Fields{"device-id": oo.deviceID,
 		"SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
 	meParam := me.ParamData{EntityID: entityID}
@@ -2614,10 +2662,10 @@
 			return nil, err
 		}
 
-		omciRxCallbackPair := callbackPair{cbKey: tid,
-			cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+		omciRxCallbackPair := CallbackPair{CbKey: tid,
+			CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
 		}
-		err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+		err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
 		if err != nil {
 			logger.Errorw(ctx, "Cannot send ethernet uni history data ME",
 				log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
@@ -2632,9 +2680,10 @@
 	return nil, omciErr.GetError()
 }
 
-func (oo *omciCC) sendCreateOrDeleteFecHistoryME(ctx context.Context, timeout int, highPrio bool,
+// SendCreateOrDeleteFecHistoryME creates or deletes FecPerformanceMonitoringHistoryData ME instance
+func (oo *OmciCC) SendCreateOrDeleteFecHistoryME(ctx context.Context, timeout int, highPrio bool,
 	create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
-	tid := oo.getNextTid(highPrio)
+	tid := oo.GetNextTid(highPrio)
 	logger.Debugw(ctx, "send fec-history-me-msg:", log.Fields{"device-id": oo.deviceID,
 		"SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
 	meParam := me.ParamData{EntityID: entityID}
@@ -2666,10 +2715,10 @@
 			return nil, err
 		}
 
-		omciRxCallbackPair := callbackPair{cbKey: tid,
-			cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+		omciRxCallbackPair := CallbackPair{CbKey: tid,
+			CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
 		}
-		err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+		err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
 		if err != nil {
 			logger.Errorw(ctx, "Cannot send fec history data ME",
 				log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
@@ -2684,9 +2733,10 @@
 	return nil, omciErr.GetError()
 }
 
-func (oo *omciCC) sendCreateOrDeleteGemPortHistoryME(ctx context.Context, timeout int, highPrio bool,
+// SendCreateOrDeleteGemPortHistoryME deletes GemPortNetworkCtpPerformanceMonitoringHistoryData ME instance
+func (oo *OmciCC) SendCreateOrDeleteGemPortHistoryME(ctx context.Context, timeout int, highPrio bool,
 	create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
-	tid := oo.getNextTid(highPrio)
+	tid := oo.GetNextTid(highPrio)
 	logger.Debugw(ctx, "send gemport-history-me-msg:", log.Fields{"device-id": oo.deviceID,
 		"SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
 	meParam := me.ParamData{EntityID: entityID}
@@ -2718,10 +2768,10 @@
 			return nil, err
 		}
 
-		omciRxCallbackPair := callbackPair{cbKey: tid,
-			cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+		omciRxCallbackPair := CallbackPair{CbKey: tid,
+			CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
 		}
-		err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+		err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
 		if err != nil {
 			logger.Errorw(ctx, "Cannot send gemport history data ME",
 				log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
@@ -2736,9 +2786,10 @@
 	return nil, omciErr.GetError()
 }
 
-func (oo *omciCC) sendStartSoftwareDownload(ctx context.Context, timeout int, highPrio bool,
+// SendStartSoftwareDownload sends StartSoftwareDownloadRequest
+func (oo *OmciCC) SendStartSoftwareDownload(ctx context.Context, timeout int, highPrio bool,
 	rxChan chan Message, aImageMeID uint16, aDownloadWindowSize uint8, aFileLen uint32) error {
-	tid := oo.getNextTid(highPrio)
+	tid := oo.GetNextTid(highPrio)
 	logger.Debugw(ctx, "send StartSwDlRequest:", log.Fields{"device-id": oo.deviceID,
 		"SequNo": strconv.FormatInt(int64(tid), 16),
 		"InstId": strconv.FormatInt(int64(aImageMeID), 16)})
@@ -2771,10 +2822,10 @@
 	}
 	outgoingPacket := buffer.Bytes()
 
-	omciRxCallbackPair := callbackPair{cbKey: tid,
-		cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+	omciRxCallbackPair := CallbackPair{CbKey: tid,
+		CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
 	}
-	err = oo.send(ctx, outgoingPacket, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+	err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
 	if err != nil {
 		logger.Errorw(ctx, "Cannot send StartSwDlRequest", log.Fields{"Err": err,
 			"device-id": oo.deviceID})
@@ -2784,9 +2835,10 @@
 	return nil
 }
 
-func (oo *omciCC) sendDownloadSection(ctx context.Context, aTimeout int, highPrio bool,
+// SendDownloadSection sends DownloadSectionRequestWithResponse
+func (oo *OmciCC) SendDownloadSection(ctx context.Context, aTimeout int, highPrio bool,
 	rxChan chan Message, aImageMeID uint16, aAckRequest uint8, aDownloadSectionNo uint8, aSection []byte, aPrint bool) error {
-	tid := oo.getNextTid(highPrio)
+	tid := oo.GetNextTid(highPrio)
 	logger.Debugw(ctx, "send DlSectionRequest:", log.Fields{"device-id": oo.deviceID,
 		"SequNo": strconv.FormatInt(int64(tid), 16),
 		"InstId": strconv.FormatInt(int64(aImageMeID), 16), "omci-ack": aAckRequest})
@@ -2834,12 +2886,12 @@
 		printFrame = true
 	}
 
-	omciRxCallbackPair := callbackPair{cbKey: tid,
+	omciRxCallbackPair := CallbackPair{CbKey: tid,
 		// the callback is set even though no response might be required here, the tid (key) setting is needed here anyway
 		//   (used to avoid retransmission of frames with the same TID)
-		cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, printFrame /*aPrint*/},
+		CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, printFrame /*aPrint*/},
 	}
-	err = oo.send(ctx, outgoingPacket, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+	err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
 	if err != nil {
 		logger.Errorw(ctx, "Cannot send DlSectionRequest", log.Fields{"Err": err,
 			"device-id": oo.deviceID})
@@ -2849,9 +2901,10 @@
 	return nil
 }
 
-func (oo *omciCC) sendEndSoftwareDownload(ctx context.Context, timeout int, highPrio bool,
+//SendEndSoftwareDownload sends EndSoftwareDownloadRequest
+func (oo *OmciCC) SendEndSoftwareDownload(ctx context.Context, timeout int, highPrio bool,
 	rxChan chan Message, aImageMeID uint16, aFileLen uint32, aImageCrc uint32) error {
-	tid := oo.getNextTid(highPrio)
+	tid := oo.GetNextTid(highPrio)
 	logger.Debugw(ctx, "send EndSwDlRequest:", log.Fields{"device-id": oo.deviceID,
 		"SequNo": strconv.FormatInt(int64(tid), 16),
 		"InstId": strconv.FormatInt(int64(aImageMeID), 16)})
@@ -2884,10 +2937,10 @@
 	}
 	outgoingPacket := buffer.Bytes()
 
-	omciRxCallbackPair := callbackPair{cbKey: tid,
-		cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+	omciRxCallbackPair := CallbackPair{CbKey: tid,
+		CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
 	}
-	err = oo.send(ctx, outgoingPacket, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+	err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
 	if err != nil {
 		logger.Errorw(ctx, "Cannot send EndSwDlRequest", log.Fields{"Err": err,
 			"device-id": oo.deviceID})
@@ -2897,9 +2950,10 @@
 	return nil
 }
 
-func (oo *omciCC) sendActivateSoftware(ctx context.Context, timeout int, highPrio bool,
+// SendActivateSoftware sends ActivateSoftwareRequest
+func (oo *OmciCC) SendActivateSoftware(ctx context.Context, timeout int, highPrio bool,
 	rxChan chan Message, aImageMeID uint16) error {
-	tid := oo.getNextTid(highPrio)
+	tid := oo.GetNextTid(highPrio)
 	logger.Debugw(ctx, "send ActivateSwRequest:", log.Fields{"device-id": oo.deviceID,
 		"SequNo": strconv.FormatInt(int64(tid), 16),
 		"InstId": strconv.FormatInt(int64(aImageMeID), 16)})
@@ -2929,10 +2983,10 @@
 	}
 	outgoingPacket := buffer.Bytes()
 
-	omciRxCallbackPair := callbackPair{cbKey: tid,
-		cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+	omciRxCallbackPair := CallbackPair{CbKey: tid,
+		CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
 	}
-	err = oo.send(ctx, outgoingPacket, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+	err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
 	if err != nil {
 		logger.Errorw(ctx, "Cannot send ActivateSwRequest", log.Fields{"Err": err,
 			"device-id": oo.deviceID})
@@ -2942,9 +2996,10 @@
 	return nil
 }
 
-func (oo *omciCC) sendCommitSoftware(ctx context.Context, timeout int, highPrio bool,
+// SendCommitSoftware sends CommitSoftwareRequest
+func (oo *OmciCC) SendCommitSoftware(ctx context.Context, timeout int, highPrio bool,
 	rxChan chan Message, aImageMeID uint16) error {
-	tid := oo.getNextTid(highPrio)
+	tid := oo.GetNextTid(highPrio)
 	logger.Debugw(ctx, "send CommitSwRequest:", log.Fields{"device-id": oo.deviceID,
 		"SequNo": strconv.FormatInt(int64(tid), 16),
 		"InstId": strconv.FormatInt(int64(aImageMeID), 16)})
@@ -2973,10 +3028,10 @@
 	}
 	outgoingPacket := buffer.Bytes()
 
-	omciRxCallbackPair := callbackPair{cbKey: tid,
-		cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+	omciRxCallbackPair := CallbackPair{CbKey: tid,
+		CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
 	}
-	err = oo.send(ctx, outgoingPacket, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+	err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
 	if err != nil {
 		logger.Errorw(ctx, "Cannot send CommitSwRequest", log.Fields{"Err": err,
 			"device-id": oo.deviceID})
@@ -2986,8 +3041,9 @@
 	return nil
 }
 
-func (oo *omciCC) sendSelfTestReq(ctx context.Context, classID me.ClassID, instdID uint16, timeout int, highPrio bool, rxChan chan Message) error {
-	tid := oo.getNextTid(highPrio)
+//SendSelfTestReq sends TestRequest
+func (oo *OmciCC) SendSelfTestReq(ctx context.Context, classID me.ClassID, instdID uint16, timeout int, highPrio bool, rxChan chan Message) error {
+	tid := oo.GetNextTid(highPrio)
 	logger.Debugw(ctx, "send self test request:", log.Fields{"device-id": oo.deviceID,
 		"SequNo": strconv.FormatInt(int64(tid), 16),
 		"InstId": strconv.FormatInt(int64(instdID), 16)})
@@ -3000,7 +3056,7 @@
 
 	var request *omci.OpticalLineSupervisionTestRequest
 	switch classID {
-	case aniGClassID:
+	case me.AniGClassID:
 		request = &omci.OpticalLineSupervisionTestRequest{
 			MeBasePacket: omci.MeBasePacket{
 				EntityClass:    classID,
@@ -3027,10 +3083,10 @@
 	}
 	outgoingPacket := buffer.Bytes()
 
-	omciRxCallbackPair := callbackPair{cbKey: tid,
-		cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+	omciRxCallbackPair := CallbackPair{CbKey: tid,
+		CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
 	}
-	err = oo.send(ctx, outgoingPacket, timeout, 0, highPrio, omciRxCallbackPair)
+	err = oo.Send(ctx, outgoingPacket, timeout, 0, highPrio, omciRxCallbackPair)
 	if err != nil {
 		logger.Errorw(ctx, "Cannot send self test request", log.Fields{"Err": err,
 			"device-id": oo.deviceID})
@@ -3095,7 +3151,7 @@
 	return false
 }
 
-func (oo *omciCC) processRequestMonitoring(ctx context.Context, aOmciTxRequest omciTransferStructure) {
+func (oo *OmciCC) processRequestMonitoring(ctx context.Context, aOmciTxRequest OmciTransferStructure) {
 	timeout := aOmciTxRequest.timeout
 	if timeout == 0 {
 		//timeout 0 indicates that no response is expected - fire and forget
@@ -3112,10 +3168,10 @@
 	}
 }
 
-func (oo *omciCC) sendWithRxSupervision(ctx context.Context, aOmciTxRequest omciTransferStructure, aTimeout int) {
+func (oo *OmciCC) sendWithRxSupervision(ctx context.Context, aOmciTxRequest OmciTransferStructure, aTimeout int) {
 	chSuccess := make(chan bool)
 	aOmciTxRequest.chSuccess = chSuccess
-	tid := aOmciTxRequest.cbPair.cbKey
+	tid := aOmciTxRequest.cbPair.CbKey
 	oo.mutexMonReq.Lock()
 	oo.monitoredRequests[tid] = aOmciTxRequest
 	oo.mutexMonReq.Unlock()
@@ -3158,7 +3214,7 @@
 }
 
 //CancelRequestMonitoring terminates monitoring of outstanding omci requests
-func (oo *omciCC) CancelRequestMonitoring(ctx context.Context) {
+func (oo *OmciCC) CancelRequestMonitoring(ctx context.Context) {
 	oo.mutexMonReq.RLock()
 	for k := range oo.monitoredRequests {
 		//implement non-blocking channel send to avoid blocking on mutexMonReq later
@@ -3174,13 +3230,14 @@
 
 //GetMaxOmciTimeoutWithRetries provides a timeout value greater than the maximum
 //time consumed for retry processing of a particular OMCI-request
-func (oo *omciCC) GetMaxOmciTimeoutWithRetries() time.Duration {
-	return time.Duration((cDefaultRetries+1)*oo.pOnuDeviceEntry.pOpenOnuAc.omciTimeout + 1)
+func (oo *OmciCC) GetMaxOmciTimeoutWithRetries() time.Duration {
+	return time.Duration((CDefaultRetries+1)*oo.pBaseDeviceHandler.GetOmciTimeout() + 1)
 }
 
-func (oo *omciCC) sendCreateOrDeleteEthernetFrameExtendedPMME(ctx context.Context, timeout int, highPrio bool,
+// SendCreateOrDeleteEthernetFrameExtendedPMME deletes EthernetFrameExtendedPm ME instance
+func (oo *OmciCC) SendCreateOrDeleteEthernetFrameExtendedPMME(ctx context.Context, timeout int, highPrio bool,
 	upstream bool, create bool, rxChan chan Message, entityID uint16, classID me.ClassID, controlBlock []uint16) (*me.ManagedEntity, error) {
-	tid := oo.getNextTid(highPrio)
+	tid := oo.GetNextTid(highPrio)
 	logger.Debugw(ctx, "send-ethernet-frame-extended-pm-me-msg:", log.Fields{"device-id": oo.deviceID,
 		"SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create, "upstream": upstream})
 
@@ -3219,10 +3276,10 @@
 			return nil, err
 		}
 
-		omciRxCallbackPair := callbackPair{cbKey: tid,
-			cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+		omciRxCallbackPair := CallbackPair{CbKey: tid,
+			CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
 		}
-		err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+		err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
 		if err != nil {
 			logger.Errorw(ctx, "Cannot send ethernet-frame-extended-pm-me",
 				log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
@@ -3236,3 +3293,24 @@
 		log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
 	return nil, omciErr.GetError()
 }
+
+// RLockMutexMonReq lock read access to monitoredRequests
+func (oo *OmciCC) RLockMutexMonReq() {
+	oo.mutexMonReq.RLock()
+}
+
+// RUnlockMutexMonReq unlock read access to monitoredRequests
+func (oo *OmciCC) RUnlockMutexMonReq() {
+	oo.mutexMonReq.RUnlock()
+}
+
+// GetMonitoredRequest get OmciTransferStructure for an omciTransID
+func (oo *OmciCC) GetMonitoredRequest(omciTransID uint16) (value OmciTransferStructure, exist bool) {
+	value, exist = oo.monitoredRequests[omciTransID]
+	return value, exist
+}
+
+// SetChMonitoredRequest sets chSuccess to indicate whether response was received or not
+func (oo *OmciCC) SetChMonitoredRequest(omciTransID uint16, chVal bool) {
+	oo.monitoredRequests[omciTransID].chSuccess <- chVal
+}
diff --git a/internal/pkg/common/onu_uni_port.go b/internal/pkg/common/onu_uni_port.go
new file mode 100755
index 0000000..77cce60
--- /dev/null
+++ b/internal/pkg/common/onu_uni_port.go
@@ -0,0 +1,158 @@
+/*
+ * Copyright 2020-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//Package common provides global definitions
+package common
+
+import (
+	"context"
+	"fmt"
+	"strconv"
+	"strings"
+	"time"
+
+	//"sync"
+	//"time"
+
+	//"github.com/opencord/voltha-lib-go/v7/pkg/kafka"
+	"github.com/opencord/voltha-lib-go/v7/pkg/log"
+	vc "github.com/opencord/voltha-protos/v5/go/common"
+	of "github.com/opencord/voltha-protos/v5/go/openflow_13"
+	"github.com/opencord/voltha-protos/v5/go/voltha"
+)
+
+//NewOnuUniPort returns a new instance of a OnuUniPort
+func NewOnuUniPort(ctx context.Context, aUniID uint8, aPortNo uint32, aInstNo uint16,
+	aPortType UniPortType) *OnuUniPort {
+	logger.Infow(ctx, "init-onuUniPort", log.Fields{"uniID": aUniID,
+		"portNo": aPortNo, "InstNo": aInstNo, "type": aPortType})
+	var OnuUniPort OnuUniPort
+	OnuUniPort.Enabled = false
+	OnuUniPort.Name = "uni-" + strconv.FormatUint(uint64(aPortNo), 10)
+	OnuUniPort.PortNo = aPortNo
+	OnuUniPort.PortType = aPortType
+	// so far it seems as here ofpPortNo/Name ist the same as the original port name ...??
+	OnuUniPort.OfpPortNo = OnuUniPort.Name
+	OnuUniPort.UniID = aUniID
+	OnuUniPort.MacBpNo = aUniID + 1 //ensure >0 instanceNo
+	OnuUniPort.EntityID = aInstNo
+	OnuUniPort.AdminState = vc.AdminState_ENABLED //enabled per create
+	OnuUniPort.OperState = vc.OperStatus_UNKNOWN
+	OnuUniPort.PPort = nil // to be set on create
+	return &OnuUniPort
+}
+
+//CreateVolthaPort creates the Voltha port based on ONU UNI Port and informs the core about it
+func (oo *OnuUniPort) CreateVolthaPort(ctx context.Context, apDeviceHandler IdeviceHandler) error {
+	logger.Debugw(ctx, "creating-voltha-uni-port", log.Fields{
+		"device-id": apDeviceHandler.GetDevice().Id, "portNo": oo.PortNo})
+	//200630: per [VOL-3202] OF port info is now to be delivered within UniPort create
+	//  not doing so crashes rw_core processing (at least still in 200630 version)
+	name := apDeviceHandler.GetDevice().SerialNumber + "-" + strconv.FormatUint(uint64(oo.MacBpNo), 10)
+	var macOctets [6]uint8
+	macOctets[5] = 0x08
+	macOctets[4] = uint8(*apDeviceHandler.GetPonPortNumber() >> 8)
+	macOctets[3] = uint8(*apDeviceHandler.GetPonPortNumber())
+	macOctets[2] = uint8(oo.PortNo >> 16)
+	macOctets[1] = uint8(oo.PortNo >> 8)
+	macOctets[0] = uint8(oo.PortNo)
+	hwAddr := genMacFromOctets(macOctets)
+	ofHwAddr := macAddressToUint32Array(hwAddr)
+	capacity := uint32(of.OfpPortFeatures_OFPPF_1GB_FD | of.OfpPortFeatures_OFPPF_FIBER)
+	ofUniPortState := of.OfpPortState_OFPPS_LINK_DOWN
+	/* as the VOLTHA port create is only called directly after Uni Port create
+	   the OfPortOperState is always Down
+	   Note: this way the OfPortOperState won't ever change (directly in adapter)
+	   maybe that was already always the case, but looks a bit weird - to be kept in mind ...
+		if pUniPort.operState == vc.OperStatus_ACTIVE {
+			ofUniPortState = of.OfpPortState_OFPPS_LIVE
+		}
+	*/
+	logger.Debugw(ctx, "ofPort values", log.Fields{
+		"forUniPortName": oo.Name, "forMacBase": hwAddr,
+		"name": name, "hwAddr": ofHwAddr, "OperState": ofUniPortState})
+
+	pUniPort := &voltha.Port{
+		DeviceId:   apDeviceHandler.GetDevice().Id,
+		PortNo:     oo.PortNo,
+		Label:      oo.Name,
+		Type:       voltha.Port_ETHERNET_UNI,
+		AdminState: oo.AdminState,
+		OperStatus: oo.OperState,
+		// obviously empty peer setting
+		OfpPort: &of.OfpPort{
+			Name:       name,
+			HwAddr:     ofHwAddr,
+			Config:     0,
+			State:      uint32(ofUniPortState),
+			Curr:       capacity,
+			Advertised: capacity,
+			Peer:       capacity,
+			CurrSpeed:  1000,
+			MaxSpeed:   1000,
+		},
+	}
+	maxRetry := 3
+	retryCnt := 0
+	var err error
+	for retryCnt = 0; retryCnt < maxRetry; retryCnt++ {
+		if err = apDeviceHandler.CreatePortInCore(ctx, pUniPort); err != nil {
+			logger.Errorf(ctx, "Device FSM: PortCreated-failed-%s, retrying after a delay", err)
+			// retry after a sleep
+			time.Sleep(2 * time.Second)
+		} else {
+			// success, break from retry loop
+			break
+		}
+	}
+	if retryCnt == maxRetry { // maxed out..
+		logger.Errorf(ctx, "Device FSM: PortCreated-failed-%s", err)
+		return fmt.Errorf("device-fsm-port-create-failed-%s", err)
+	}
+	logger.Infow(ctx, "Voltha OnuUniPort-added", log.Fields{
+		"device-id": apDeviceHandler.GetDevice().Id, "PortNo": oo.PortNo})
+	oo.PPort = pUniPort
+	oo.OperState = vc.OperStatus_DISCOVERED
+
+	return nil
+}
+
+//SetOperState modifies OperState of the the UniPort
+func (oo *OnuUniPort) SetOperState(aNewOperState vc.OperStatus_Types) {
+	oo.OperState = aNewOperState
+}
+
+// uni port related utility functions (so far only used here)
+func genMacFromOctets(aOctets [6]uint8) string {
+	return fmt.Sprintf("%02x:%02x:%02x:%02x:%02x:%02x",
+		aOctets[5], aOctets[4], aOctets[3],
+		aOctets[2], aOctets[1], aOctets[0])
+}
+
+//copied from OLT Adapter: unify centrally ?
+func macAddressToUint32Array(mac string) []uint32 {
+	slist := strings.Split(mac, ":")
+	result := make([]uint32, len(slist))
+	var err error
+	var tmp int64
+	for index, val := range slist {
+		if tmp, err = strconv.ParseInt(val, 16, 32); err != nil {
+			return []uint32{1, 2, 3, 4, 5, 6}
+		}
+		result[index] = uint32(tmp)
+	}
+	return result
+}
diff --git a/internal/pkg/common/utils.go b/internal/pkg/common/utils.go
new file mode 100755
index 0000000..8ea2624
--- /dev/null
+++ b/internal/pkg/common/utils.go
@@ -0,0 +1,155 @@
+/*
+ * Copyright 2020-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//Package common provides global definitions
+package common
+
+import (
+	"bytes"
+	"context"
+	"encoding/binary"
+	"errors"
+	"fmt"
+	"net"
+	"regexp"
+	"strconv"
+	"strings"
+
+	"github.com/looplab/fsm"
+	me "github.com/opencord/omci-lib-go/generated"
+	"github.com/opencord/voltha-lib-go/v7/pkg/log"
+)
+
+// GetTpIDFromTpPath extracts TpID from the TpPath.
+// On success it returns a valid TpID and nil error.
+// On failure it returns TpID as 0 and the error.
+func GetTpIDFromTpPath(tpPath string) (uint8, error) {
+	// tpPath is of the format  <technology>/<table_id>/olt-{}/pon-{}/onu-{}/uni-{}
+	// A sample tpPath is ==> XGS-PON/64/olt-{12345abcd}/pon-{0}/onu-{1}/uni-{1}
+	var tpPathFormat = regexp.MustCompile(`^[a-zA-Z\-_]+/[0-9]+/olt-{[a-z0-9\-]+}/pon-{[0-9]+}/onu-{[0-9]+}/uni-{[0-9]+}$`)
+
+	// Ensure tpPath is of the format  <technology>/<table_id>/<uni_port_name>
+	if !tpPathFormat.Match([]byte(tpPath)) {
+		return 0, errors.New("tp-path-not-confirming-to-format")
+	}
+	// Extract the TP table-id field.
+	tpID, err := strconv.Atoi(strings.Split(tpPath, "/")[1])
+	// Atoi returns uint64 and need to be type-casted to uint8 as tpID is uint8 size.
+	return uint8(tpID), err
+}
+
+//IPToInt32 transforms an IP of net.Ip type to int32
+func IPToInt32(ip net.IP) uint32 {
+	if len(ip) == 16 {
+		return binary.BigEndian.Uint32(ip[12:16])
+	}
+	return binary.BigEndian.Uint32(ip)
+}
+
+//AsByteSlice transforms a string of manually set bits to a byt array
+func AsByteSlice(bitString string) []byte {
+	var out []byte
+	var str string
+
+	for i := len(bitString); i > 0; i -= 8 {
+		if i-8 < 0 {
+			str = bitString[0:i]
+		} else {
+			str = bitString[i-8 : i]
+		}
+		v, err := strconv.ParseUint(str, 2, 8)
+		if err != nil {
+			panic(err)
+		}
+		out = append([]byte{byte(v)}, out...)
+	}
+	return out
+}
+
+// TwosComplementToSignedInt16 convert 2s complement to signed int16
+func TwosComplementToSignedInt16(val uint16) int16 {
+	var uint16MsbMask uint16 = 0x8000
+	if val&uint16MsbMask == uint16MsbMask {
+		return int16(^val+1) * -1
+	}
+
+	return int16(val)
+}
+
+// TrimStringFromMeOctet trim string out of Me octet
+func TrimStringFromMeOctet(input interface{}) string {
+	ifBytes, _ := me.InterfaceToOctets(input)
+	return fmt.Sprintf("%s", bytes.Trim(ifBytes, "\x00"))
+}
+
+////////////////////////////////////////////////////////////////////////
+
+//NewAdapterFsm - FSM details including event, device and channel.
+func NewAdapterFsm(aName string, aDeviceID string, aCommChannel chan Message) *AdapterFsm {
+	aFsm := &AdapterFsm{
+		fsmName:  aName,
+		deviceID: aDeviceID,
+		CommChan: aCommChannel,
+	}
+	return aFsm
+}
+
+// LogFsmStateChange logs FSM state changes
+func (oo *AdapterFsm) LogFsmStateChange(ctx context.Context, e *fsm.Event) {
+	logger.Debugw(ctx, "FSM state change", log.Fields{"device-id": oo.deviceID, "FSM name": oo.fsmName,
+		"event name": string(e.Event), "src state": string(e.Src), "dst state": string(e.Dst)})
+}
+
+////////////////////////////////////////////////////////////////////////
+
+// GenerateIeeMaperServiceProfileEID returns IeeMaperServiceProfileEntityID
+func GenerateIeeMaperServiceProfileEID(uniPortMacBpNo uint16, tpID uint16) (uint16, error) {
+	if tpID < tpIDStart || tpID >= tpIDEnd {
+		return 0, fmt.Errorf("tech profile id out of range - %d", tpID)
+	}
+	if uniPortMacBpNo > maxUni {
+		return 0, fmt.Errorf("uni macbpno out of range - %d", uniPortMacBpNo)
+	}
+	return (IeeMaperServiceProfileBaseEID + uniPortMacBpNo*tpRange + tpID - tpIDStart), nil
+}
+
+// GenerateANISideMBPCDEID returns ANISideMacBridgePortConfigurationDataEntryID
+func GenerateANISideMBPCDEID(uniPortMacBpNo uint16, tpID uint16) (uint16, error) {
+	if tpID < tpIDStart || tpID >= tpIDEnd {
+		return 0, fmt.Errorf("tech profile id out of range - %d", tpID)
+	}
+	if uniPortMacBpNo > maxUni {
+		return 0, fmt.Errorf("uni macbpno out of range - %d", uniPortMacBpNo)
+	}
+	return (MacBridgePortAniBaseEID + uniPortMacBpNo*tpRange + tpID - tpIDStart), nil
+}
+
+// GenerateUNISideMBPCDEID returns UNISideMacBridgePortConfigurationDataEntityID
+func GenerateUNISideMBPCDEID(uniPortMacBpNo uint16) (uint16, error) {
+	if uniPortMacBpNo > maxUni {
+		return 0, fmt.Errorf("uni macbpno out of range - %d", uniPortMacBpNo)
+	}
+	return (MacBridgePortUniBaseEID + uniPortMacBpNo), nil
+}
+
+// GenerateMcastANISideMBPCDEID returns McastANISideMacBridgePortConfigurationDataEntityID
+func GenerateMcastANISideMBPCDEID(uniPortMacBpNo uint16) (uint16, error) {
+
+	if uniPortMacBpNo > maxUni {
+		return 0, fmt.Errorf("uni macbpno out of range - %d", uniPortMacBpNo)
+	}
+	return (MacBridgePortAniMcastBaseEID + uniPortMacBpNo), nil
+}
diff --git a/internal/pkg/onuadaptercore/common.go b/internal/pkg/core/common.go
old mode 100644
new mode 100755
similarity index 86%
copy from internal/pkg/onuadaptercore/common.go
copy to internal/pkg/core/common.go
index b0b10e3..c18ae16
--- a/internal/pkg/onuadaptercore/common.go
+++ b/internal/pkg/core/common.go
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package core provides the utility for onu devices, flows and statistics
+package core
 
 import (
 	"github.com/opencord/voltha-lib-go/v7/pkg/log"
@@ -26,7 +26,7 @@
 func init() {
 	// Setup this package so that it's log level can be modified at run time
 	var err error
-	logger, err = log.RegisterPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "adaptercoreonu"})
+	logger, err = log.RegisterPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "core"})
 	if err != nil {
 		panic(err)
 	}
diff --git a/internal/pkg/onuadaptercore/device_handler.go b/internal/pkg/core/device_handler.go
old mode 100644
new mode 100755
similarity index 71%
rename from internal/pkg/onuadaptercore/device_handler.go
rename to internal/pkg/core/device_handler.go
index 2c5a4c8..22f08f8
--- a/internal/pkg/onuadaptercore/device_handler.go
+++ b/internal/pkg/core/device_handler.go
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package core provides the utility for onu devices, flows and statistics
+package core
 
 import (
 	"context"
@@ -26,6 +26,7 @@
 	"time"
 
 	"github.com/opencord/voltha-openonu-adapter-go/internal/pkg/config"
+	"github.com/opencord/voltha-protos/v5/go/openolt"
 	"github.com/opencord/voltha-protos/v5/go/tech_profile"
 
 	"github.com/gogo/protobuf/proto"
@@ -36,6 +37,14 @@
 	flow "github.com/opencord/voltha-lib-go/v7/pkg/flows"
 	vgrpc "github.com/opencord/voltha-lib-go/v7/pkg/grpc"
 	"github.com/opencord/voltha-lib-go/v7/pkg/log"
+	almgr "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/almgr"
+	avcfg "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/avcfg"
+	cmn "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/common"
+	mib "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/mib"
+	otst "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/omcitst"
+	pmmgr "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/pmmgr"
+	"github.com/opencord/voltha-openonu-adapter-go/internal/pkg/swupg"
+	uniprt "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/uniprt"
 	vc "github.com/opencord/voltha-protos/v5/go/common"
 	"github.com/opencord/voltha-protos/v5/go/extension"
 	ic "github.com/opencord/voltha-protos/v5/go/inter_container"
@@ -88,74 +97,20 @@
 	cOnuActivatedEvent = "ONU_ACTIVATED"
 )
 
-type usedOmciConfigFsms int
-
-const (
-	cUploadFsm usedOmciConfigFsms = iota
-	cDownloadFsm
-	cUniLockFsm
-	cUniUnLockFsm
-	cAniConfigFsm
-	cUniVlanConfigFsm
-	cL2PmFsm
-	cOnuUpgradeFsm
-)
-
 type omciIdleCheckStruct struct {
-	omciIdleCheckFunc func(*deviceHandler, context.Context, usedOmciConfigFsms, string) bool
+	omciIdleCheckFunc func(*deviceHandler, context.Context, cmn.UsedOmciConfigFsms, string) bool
 	omciIdleState     string
 }
 
-var fsmOmciIdleStateFuncMap = map[usedOmciConfigFsms]omciIdleCheckStruct{
-	cUploadFsm:        {(*deviceHandler).isFsmInOmciIdleStateDefault, cMibUlFsmIdleState},
-	cDownloadFsm:      {(*deviceHandler).isFsmInOmciIdleStateDefault, cMibDlFsmIdleState},
-	cUniLockFsm:       {(*deviceHandler).isFsmInOmciIdleStateDefault, cUniFsmIdleState},
-	cUniUnLockFsm:     {(*deviceHandler).isFsmInOmciIdleStateDefault, cUniFsmIdleState},
-	cAniConfigFsm:     {(*deviceHandler).isAniConfigFsmInOmciIdleState, cAniFsmIdleState},
-	cUniVlanConfigFsm: {(*deviceHandler).isUniVlanConfigFsmInOmciIdleState, cVlanFsmIdleState},
-	cL2PmFsm:          {(*deviceHandler).isFsmInOmciIdleStateDefault, cL2PmFsmIdleState},
-	cOnuUpgradeFsm:    {(*deviceHandler).isFsmInOmciIdleStateDefault, cOnuUpgradeFsmIdleState},
-}
-
-const (
-	// device reasons
-	drUnset                            = 0
-	drActivatingOnu                    = 1
-	drStartingOpenomci                 = 2
-	drDiscoveryMibsyncComplete         = 3
-	drInitialMibDownloaded             = 4
-	drTechProfileConfigDownloadSuccess = 5
-	drOmciFlowsPushed                  = 6
-	drOmciAdminLock                    = 7
-	drOnuReenabled                     = 8
-	drStoppingOpenomci                 = 9
-	drRebooting                        = 10
-	drOmciFlowsDeleted                 = 11
-	drTechProfileConfigDeleteSuccess   = 12
-	drReconcileFailed                  = 13
-	drReconcileMaxTimeout              = 14
-	drReconcileCanceled                = 15
-	drTechProfileConfigDownloadFailed  = 16
-)
-
-var deviceReasonMap = map[uint8]string{
-	drUnset:                            "unset",
-	drActivatingOnu:                    "activating-onu",
-	drStartingOpenomci:                 "starting-openomci",
-	drDiscoveryMibsyncComplete:         "discovery-mibsync-complete",
-	drInitialMibDownloaded:             "initial-mib-downloaded",
-	drTechProfileConfigDownloadSuccess: "tech-profile-config-download-success",
-	drTechProfileConfigDownloadFailed:  "tech-profile-config-download-failed",
-	drOmciFlowsPushed:                  "omci-flows-pushed",
-	drOmciAdminLock:                    "omci-admin-lock",
-	drOnuReenabled:                     "onu-reenabled",
-	drStoppingOpenomci:                 "stopping-openomci",
-	drRebooting:                        "rebooting",
-	drOmciFlowsDeleted:                 "omci-flows-deleted",
-	drTechProfileConfigDeleteSuccess:   "tech-profile-config-delete-success",
-	drReconcileFailed:                  "reconcile-failed",
-	drReconcileMaxTimeout:              "reconcile-max-timeout",
-	drReconcileCanceled:                "reconciling-canceled",
+var fsmOmciIdleStateFuncMap = map[cmn.UsedOmciConfigFsms]omciIdleCheckStruct{
+	cmn.CUploadFsm:        {(*deviceHandler).isFsmInOmciIdleStateDefault, mib.CMibUlFsmIdleState},
+	cmn.CDownloadFsm:      {(*deviceHandler).isFsmInOmciIdleStateDefault, mib.CMibDlFsmIdleState},
+	cmn.CUniLockFsm:       {(*deviceHandler).isFsmInOmciIdleStateDefault, uniprt.CUniFsmIdleState},
+	cmn.CUniUnLockFsm:     {(*deviceHandler).isFsmInOmciIdleStateDefault, uniprt.CUniFsmIdleState},
+	cmn.CAniConfigFsm:     {(*deviceHandler).isAniConfigFsmInOmciIdleState, avcfg.CAniFsmIdleState},
+	cmn.CUniVlanConfigFsm: {(*deviceHandler).isUniVlanConfigFsmInOmciIdleState, avcfg.CVlanFsmIdleState},
+	cmn.CL2PmFsm:          {(*deviceHandler).isFsmInOmciIdleStateDefault, pmmgr.CL2PmFsmIdleState},
+	cmn.COnuUpgradeFsm:    {(*deviceHandler).isFsmInOmciIdleStateDefault, swupg.COnuUpgradeFsmIdleState},
 }
 
 const (
@@ -166,7 +121,7 @@
 
 //deviceHandler will interact with the ONU ? device.
 type deviceHandler struct {
-	deviceID         string
+	DeviceID         string
 	DeviceType       string
 	adminState       string
 	device           *voltha.Device
@@ -186,18 +141,18 @@
 	pDeviceStateFsm *fsm.FSM
 	//pPonPort        *voltha.Port
 	deviceEntrySet    chan bool //channel for DeviceEntry set event
-	pOnuOmciDevice    *OnuDeviceEntry
-	pOnuTP            *onuUniTechProf
-	pOnuMetricsMgr    *onuMetricsManager
-	pAlarmMgr         *onuAlarmManager
-	pSelfTestHdlr     *selfTestControlBlock
+	pOnuOmciDevice    *mib.OnuDeviceEntry
+	pOnuTP            *avcfg.OnuUniTechProf
+	pOnuMetricsMgr    *pmmgr.OnuMetricsManager
+	pAlarmMgr         *almgr.OnuAlarmManager
+	pSelfTestHdlr     *otst.SelfTestControlBlock
 	exitChannel       chan int
 	lockDevice        sync.RWMutex
 	pOnuIndication    *oop.OnuIndication
 	deviceReason      uint8
 	mutexDeviceReason sync.RWMutex
-	pLockStateFsm     *lockStateFsm
-	pUnlockStateFsm   *lockStateFsm
+	pLockStateFsm     *uniprt.LockStateFsm
+	pUnlockStateFsm   *uniprt.LockStateFsm
 
 	//flowMgr       *OpenOltFlowMgr
 	//eventMgr      *OpenOltEventMgr
@@ -213,19 +168,16 @@
 	mutextAlarmManagerFlag      sync.RWMutex
 	stopAlarmManager            chan bool
 	stopHeartbeatCheck          chan bool
-	uniEntityMap                map[uint32]*onuUniPort
+	uniEntityMap                cmn.OnuUniPortMap
 	mutexKvStoreContext         sync.Mutex
 	lockVlanConfig              sync.RWMutex
 	lockVlanAdd                 sync.RWMutex
-	UniVlanConfigFsmMap         map[uint8]*UniVlanConfigFsm
+	UniVlanConfigFsmMap         map[uint8]*avcfg.UniVlanConfigFsm
 	lockUpgradeFsm              sync.RWMutex
-	pOnuUpradeFsm               *OnuUpgradeFsm
+	pOnuUpradeFsm               *swupg.OnuUpgradeFsm
 	reconciling                 uint8
 	mutexReconcilingFlag        sync.RWMutex
 	chReconcilingFinished       chan bool //channel to indicate that reconciling has been finished
-	reconcilingFlows            bool
-	mutexReconcilingFlowsFlag   sync.RWMutex
-	chReconcilingFlowsFinished  chan bool //channel to indicate that reconciling of flows has been finished
 	mutexReadyForOmciConfig     sync.RWMutex
 	readyForOmciConfig          bool
 	deletionInProgress          bool
@@ -241,7 +193,7 @@
 	dh.EventProxy = ep
 	dh.config = adapter.config
 	cloned := (proto.Clone(device)).(*voltha.Device)
-	dh.deviceID = cloned.Id
+	dh.DeviceID = cloned.Id
 	dh.DeviceType = cloned.Type
 	dh.adminState = "up"
 	dh.device = cloned
@@ -256,15 +208,13 @@
 	dh.stopHeartbeatCheck = make(chan bool, 2)
 	//dh.metrics = pmmetrics.NewPmMetrics(cloned.Id, pmmetrics.Frequency(150), pmmetrics.FrequencyOverride(false), pmmetrics.Grouped(false), pmmetrics.Metrics(pmNames))
 	//TODO initialize the support classes.
-	dh.uniEntityMap = make(map[uint32]*onuUniPort)
+	dh.uniEntityMap = make(map[uint32]*cmn.OnuUniPort)
 	dh.lockVlanConfig = sync.RWMutex{}
 	dh.lockVlanAdd = sync.RWMutex{}
 	dh.lockUpgradeFsm = sync.RWMutex{}
-	dh.UniVlanConfigFsmMap = make(map[uint8]*UniVlanConfigFsm)
+	dh.UniVlanConfigFsmMap = make(map[uint8]*avcfg.UniVlanConfigFsm)
 	dh.reconciling = cNoReconciling
 	dh.chReconcilingFinished = make(chan bool)
-	dh.reconcilingFlows = false
-	dh.chReconcilingFlowsFinished = make(chan bool)
 	dh.readyForOmciConfig = false
 	dh.deletionInProgress = false
 	dh.pLastUpgradeImageState = &voltha.ImageState{
@@ -307,7 +257,7 @@
 
 // start save the device to the data model
 func (dh *deviceHandler) start(ctx context.Context) {
-	logger.Debugw(ctx, "starting-device-handler", log.Fields{"device": dh.device, "device-id": dh.deviceID})
+	logger.Debugw(ctx, "starting-device-handler", log.Fields{"device": dh.device, "device-id": dh.DeviceID})
 	// Add the initial device to the local model
 	logger.Debug(ctx, "device-handler-started")
 }
@@ -337,7 +287,7 @@
 		if device.PmConfigs == nil {
 			// Now, set the initial PM configuration for that device
 			if err := dh.updatePMConfigInCore(ctx, dh.pmConfigs); err != nil {
-				logger.Errorw(ctx, "error updating pm config to core", log.Fields{"device-id": dh.deviceID, "err": err})
+				logger.Errorw(ctx, "error updating pm config to core", log.Fields{"device-id": dh.DeviceID, "err": err})
 			}
 		}
 	} else {
@@ -351,38 +301,37 @@
 	//assuming omci message content is hex coded!
 	// with restricted output of 16(?) bytes would be ...omciMsg.Message[:16]
 	logger.Debugw(ctx, "inter-adapter-recv-omci", log.Fields{
-		"device-id": dh.deviceID, "RxOmciMessage": hex.EncodeToString(omciMsg.Message)})
+		"device-id": dh.DeviceID, "RxOmciMessage": hex.EncodeToString(omciMsg.Message)})
 	*/
-
-	pDevEntry := dh.getOnuDeviceEntry(ctx, true)
+	pDevEntry := dh.GetOnuDeviceEntry(ctx, true)
 	if pDevEntry != nil {
 		if pDevEntry.PDevOmciCC != nil {
-			return pDevEntry.PDevOmciCC.receiveMessage(log.WithSpanFromContext(context.TODO(), ctx), msg.Message)
+			return pDevEntry.PDevOmciCC.ReceiveMessage(log.WithSpanFromContext(context.TODO(), ctx), msg.Message)
 		}
 		logger.Debugw(ctx, "omciCC not ready to receive omci messages - incoming omci message ignored", log.Fields{"rxMsg": msg.Message})
 	}
-	logger.Errorw(ctx, "No valid OnuDevice -aborting", log.Fields{"device-id": dh.deviceID})
-	return fmt.Errorf("no valid OnuDevice: %s", dh.deviceID)
+	logger.Errorw(ctx, "No valid OnuDevice -aborting", log.Fields{"device-id": dh.DeviceID})
+	return fmt.Errorf("no valid OnuDevice: %s", dh.DeviceID)
 }
 
 func (dh *deviceHandler) handleTechProfileDownloadRequest(ctx context.Context, techProfMsg *ic.TechProfileDownloadMessage) error {
-	logger.Infow(ctx, "tech-profile-download-request", log.Fields{"device-id": dh.deviceID})
+	logger.Infow(ctx, "tech-profile-download-request", log.Fields{"device-id": dh.DeviceID})
 
-	pDevEntry := dh.getOnuDeviceEntry(ctx, true)
+	pDevEntry := dh.GetOnuDeviceEntry(ctx, true)
 	if pDevEntry == nil {
-		logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
-		return fmt.Errorf("no valid OnuDevice: %s", dh.deviceID)
+		logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.DeviceID})
+		return fmt.Errorf("no valid OnuDevice: %s", dh.DeviceID)
 	}
 	if dh.pOnuTP == nil {
 		//should normally not happen ...
 		logger.Errorw(ctx, "onuTechProf instance not set up for DLMsg request - ignoring request",
-			log.Fields{"device-id": dh.deviceID})
-		return fmt.Errorf("techProfile DLMsg request while onuTechProf instance not setup: %s", dh.deviceID)
+			log.Fields{"device-id": dh.DeviceID})
+		return fmt.Errorf("techProfile DLMsg request while onuTechProf instance not setup: %s", dh.DeviceID)
 	}
-	if !dh.isReadyForOmciConfig() {
-		logger.Errorw(ctx, "TechProf-set rejected: improper device state", log.Fields{"device-id": dh.deviceID,
-			"device-state": dh.getDeviceReasonString()})
-		return fmt.Errorf("improper device state %s on device %s", dh.getDeviceReasonString(), dh.deviceID)
+	if !dh.IsReadyForOmciConfig() {
+		logger.Errorw(ctx, "TechProf-set rejected: improper device state", log.Fields{"device-id": dh.DeviceID,
+			"device-state": dh.GetDeviceReasonString()})
+		return fmt.Errorf("improper device state %s on device %s", dh.GetDeviceReasonString(), dh.DeviceID)
 	}
 	//previous state test here was just this one, now extended for more states to reject the SetRequest:
 	// at least 'mib-downloaded' should be reached for processing of this specific ONU configuration
@@ -391,22 +340,22 @@
 	// we have to lock access to TechProfile processing based on different messageType calls or
 	// even to fast subsequent calls of the same messageType as well as OnuKVStore processing due
 	// to possible concurrent access by flow processing
-	dh.pOnuTP.lockTpProcMutex()
-	defer dh.pOnuTP.unlockTpProcMutex()
+	dh.pOnuTP.LockTpProcMutex()
+	defer dh.pOnuTP.UnlockTpProcMutex()
 
 	if techProfMsg.UniId > 255 {
 		return fmt.Errorf(fmt.Sprintf("received UniId value exceeds range: %d, device-id: %s",
-			techProfMsg.UniId, dh.deviceID))
+			techProfMsg.UniId, dh.DeviceID))
 	}
 	uniID := uint8(techProfMsg.UniId)
-	tpID, err := GetTpIDFromTpPath(techProfMsg.TpInstancePath)
+	tpID, err := cmn.GetTpIDFromTpPath(techProfMsg.TpInstancePath)
 	if err != nil {
 		logger.Errorw(ctx, "error-parsing-tpid-from-tppath", log.Fields{"err": err, "tp-path": techProfMsg.TpInstancePath})
 		return err
 	}
 	logger.Debugw(ctx, "unmarshal-techprof-msg-body", log.Fields{"uniID": uniID, "tp-path": techProfMsg.TpInstancePath, "tpID": tpID})
 
-	if bTpModify := pDevEntry.updateOnuUniTpPath(ctx, uniID, uint8(tpID), techProfMsg.TpInstancePath); bTpModify {
+	if bTpModify := pDevEntry.UpdateOnuUniTpPath(ctx, uniID, uint8(tpID), techProfMsg.TpInstancePath); bTpModify {
 
 		switch tpInst := techProfMsg.TechTpInstance.(type) {
 		case *ic.TechProfileDownloadMessage_TpInstance:
@@ -423,25 +372,25 @@
 			deadline := time.Now().Add(dh.pOpenOnuAc.maxTimeoutInterAdapterComm) //allowed run time to finish before execution
 			dctx, cancel := context.WithDeadline(context.Background(), deadline)
 
-			dh.pOnuTP.resetTpProcessingErrorIndication(uniID, tpID)
+			dh.pOnuTP.ResetTpProcessingErrorIndication(uniID, tpID)
 
 			var wg sync.WaitGroup
 			wg.Add(1) // for the 1 go routine to finish
 			// attention: deadline completion check and wg.Done is to be done in both routines
-			go dh.pOnuTP.configureUniTp(log.WithSpanFromContext(dctx, ctx), uniID, techProfMsg.TpInstancePath, *tpInst.TpInstance, &wg)
+			go dh.pOnuTP.ConfigureUniTp(log.WithSpanFromContext(dctx, ctx), uniID, techProfMsg.TpInstancePath, *tpInst.TpInstance, &wg)
 			dh.waitForCompletion(ctx, cancel, &wg, "TechProfDwld") //wait for background process to finish
-			if tpErr := dh.pOnuTP.getTpProcessingErrorIndication(uniID, tpID); tpErr != nil {
-				logger.Errorw(ctx, "error-processing-tp", log.Fields{"device-id": dh.deviceID, "err": tpErr, "tp-path": techProfMsg.TpInstancePath})
+			if tpErr := dh.pOnuTP.GetTpProcessingErrorIndication(uniID, tpID); tpErr != nil {
+				logger.Errorw(ctx, "error-processing-tp", log.Fields{"device-id": dh.DeviceID, "err": tpErr, "tp-path": techProfMsg.TpInstancePath})
 				return tpErr
 			}
 			deadline = time.Now().Add(dh.pOpenOnuAc.maxTimeoutInterAdapterComm) //allowed run time to finish before execution
 			dctx2, cancel2 := context.WithDeadline(context.Background(), deadline)
-			pDevEntry.resetKvProcessingErrorIndication()
+			pDevEntry.ResetKvProcessingErrorIndication()
 			wg.Add(1) // for the 1 go routine to finish
-			go pDevEntry.updateOnuKvStore(log.WithSpanFromContext(dctx2, ctx), &wg)
+			go pDevEntry.UpdateOnuKvStore(log.WithSpanFromContext(dctx2, ctx), &wg)
 			dh.waitForCompletion(ctx, cancel2, &wg, "TechProfDwld") //wait for background process to finish
-			if kvErr := pDevEntry.getKvProcessingErrorIndication(); kvErr != nil {
-				logger.Errorw(ctx, "error-updating-KV", log.Fields{"device-id": dh.deviceID, "err": kvErr, "tp-path": techProfMsg.TpInstancePath})
+			if kvErr := pDevEntry.GetKvProcessingErrorIndication(); kvErr != nil {
+				logger.Errorw(ctx, "error-updating-KV", log.Fields{"device-id": dh.DeviceID, "err": kvErr, "tp-path": techProfMsg.TpInstancePath})
 				return kvErr
 			}
 			return nil
@@ -456,84 +405,84 @@
 }
 
 func (dh *deviceHandler) handleDeleteGemPortRequest(ctx context.Context, delGemPortMsg *ic.DeleteGemPortMessage) error {
-	logger.Infow(ctx, "delete-gem-port-request", log.Fields{"device-id": dh.deviceID})
+	logger.Infow(ctx, "delete-gem-port-request", log.Fields{"device-id": dh.DeviceID})
 
 	if dh.pOnuTP == nil {
 		//should normally not happen ...
 		logger.Warnw(ctx, "onuTechProf instance not set up for DelGem request - ignoring request",
-			log.Fields{"device-id": dh.deviceID})
-		return fmt.Errorf("techProfile DelGem request while onuTechProf instance not setup: %s", dh.deviceID)
+			log.Fields{"device-id": dh.DeviceID})
+		return fmt.Errorf("techProfile DelGem request while onuTechProf instance not setup: %s", dh.DeviceID)
 	}
 	//compare TECH_PROFILE_DOWNLOAD_REQUEST
-	dh.pOnuTP.lockTpProcMutex()
-	defer dh.pOnuTP.unlockTpProcMutex()
+	dh.pOnuTP.LockTpProcMutex()
+	defer dh.pOnuTP.UnlockTpProcMutex()
 
 	if delGemPortMsg.UniId > 255 {
 		return fmt.Errorf(fmt.Sprintf("received UniId value exceeds range: %d, device-id: %s",
-			delGemPortMsg.UniId, dh.deviceID))
+			delGemPortMsg.UniId, dh.DeviceID))
 	}
 	uniID := uint8(delGemPortMsg.UniId)
-	tpID, err := GetTpIDFromTpPath(delGemPortMsg.TpInstancePath)
+	tpID, err := cmn.GetTpIDFromTpPath(delGemPortMsg.TpInstancePath)
 	if err != nil {
 		logger.Errorw(ctx, "error-extracting-tp-id-from-tp-path", log.Fields{"err": err, "tp-path": delGemPortMsg.TpInstancePath})
 		return err
 	}
-	logger.Infow(ctx, "delete-gem-port-request", log.Fields{"device-id": dh.deviceID, "uni-id": uniID, "tpID": tpID, "gem": delGemPortMsg.GemPortId})
+	logger.Infow(ctx, "delete-gem-port-request", log.Fields{"device-id": dh.DeviceID, "uni-id": uniID, "tpID": tpID, "gem": delGemPortMsg.GemPortId})
 	//a removal of some GemPort would never remove the complete TechProfile entry (done on T-Cont)
 
 	return dh.deleteTechProfileResource(ctx, uniID, tpID, delGemPortMsg.TpInstancePath,
-		cResourceGemPort, delGemPortMsg.GemPortId)
+		avcfg.CResourceGemPort, delGemPortMsg.GemPortId)
 
 }
 
 func (dh *deviceHandler) handleDeleteTcontRequest(ctx context.Context, delTcontMsg *ic.DeleteTcontMessage) error {
-	logger.Infow(ctx, "delete-tcont-request", log.Fields{"device-id": dh.deviceID})
+	logger.Infow(ctx, "delete-tcont-request", log.Fields{"device-id": dh.DeviceID})
 
-	pDevEntry := dh.getOnuDeviceEntry(ctx, true)
+	pDevEntry := dh.GetOnuDeviceEntry(ctx, true)
 	if pDevEntry == nil {
-		logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
-		return fmt.Errorf("no valid OnuDevice: %s", dh.deviceID)
+		logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.DeviceID})
+		return fmt.Errorf("no valid OnuDevice: %s", dh.DeviceID)
 	}
 	if dh.pOnuTP == nil {
 		//should normally not happen ...
 		logger.Warnw(ctx, "onuTechProf instance not set up for DelTcont request - ignoring request",
-			log.Fields{"device-id": dh.deviceID})
-		return fmt.Errorf("techProfile DelTcont request while onuTechProf instance not setup: %s", dh.deviceID)
+			log.Fields{"device-id": dh.DeviceID})
+		return fmt.Errorf("techProfile DelTcont request while onuTechProf instance not setup: %s", dh.DeviceID)
 	}
 
 	//compare TECH_PROFILE_DOWNLOAD_REQUEST
-	dh.pOnuTP.lockTpProcMutex()
-	defer dh.pOnuTP.unlockTpProcMutex()
+	dh.pOnuTP.LockTpProcMutex()
+	defer dh.pOnuTP.UnlockTpProcMutex()
 
 	if delTcontMsg.UniId > 255 {
 		return fmt.Errorf(fmt.Sprintf("received UniId value exceeds range: %d, device-id: %s",
-			delTcontMsg.UniId, dh.deviceID))
+			delTcontMsg.UniId, dh.DeviceID))
 	}
 	uniID := uint8(delTcontMsg.UniId)
 	tpPath := delTcontMsg.TpInstancePath
-	tpID, err := GetTpIDFromTpPath(tpPath)
+	tpID, err := cmn.GetTpIDFromTpPath(tpPath)
 	if err != nil {
 		logger.Errorw(ctx, "error-extracting-tp-id-from-tp-path", log.Fields{"err": err, "tp-path": tpPath})
 		return err
 	}
-	logger.Infow(ctx, "delete-tcont-request", log.Fields{"device-id": dh.deviceID, "uni-id": uniID, "tpID": tpID, "tcont": delTcontMsg.AllocId})
+	logger.Infow(ctx, "delete-tcont-request", log.Fields{"device-id": dh.DeviceID, "uni-id": uniID, "tpID": tpID, "tcont": delTcontMsg.AllocId})
 
-	pDevEntry.freeTcont(ctx, uint16(delTcontMsg.AllocId))
+	pDevEntry.FreeTcont(ctx, uint16(delTcontMsg.AllocId))
 
 	return dh.deleteTechProfileResource(ctx, uniID, tpID, delTcontMsg.TpInstancePath,
-		cResourceTcont, delTcontMsg.AllocId)
+		avcfg.CResourceTcont, delTcontMsg.AllocId)
 
 }
 
 func (dh *deviceHandler) deleteTechProfileResource(ctx context.Context,
-	uniID uint8, tpID uint8, pathString string, resource resourceEntry, entryID uint32) error {
-	pDevEntry := dh.getOnuDeviceEntry(ctx, true)
+	uniID uint8, tpID uint8, pathString string, resource avcfg.ResourceEntry, entryID uint32) error {
+	pDevEntry := dh.GetOnuDeviceEntry(ctx, true)
 	if pDevEntry == nil {
-		logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
-		return fmt.Errorf("no valid OnuDevice: %s", dh.deviceID)
+		logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.DeviceID})
+		return fmt.Errorf("no valid OnuDevice: %s", dh.DeviceID)
 	}
 	var resourceName string
-	if cResourceGemPort == resource {
+	if avcfg.CResourceGemPort == resource {
 		resourceName = "Gem"
 	} else {
 		resourceName = "Tcont"
@@ -543,36 +492,36 @@
 	deadline := time.Now().Add(dh.pOpenOnuAc.maxTimeoutInterAdapterComm) //allowed run time to finish before execution
 	dctx, cancel := context.WithDeadline(context.Background(), deadline)
 
-	dh.pOnuTP.resetTpProcessingErrorIndication(uniID, tpID)
+	dh.pOnuTP.ResetTpProcessingErrorIndication(uniID, tpID)
 
 	var wg sync.WaitGroup
 	wg.Add(1) // for the 1 go routine to finish
-	go dh.pOnuTP.deleteTpResource(log.WithSpanFromContext(dctx, ctx), uniID, tpID, pathString,
+	go dh.pOnuTP.DeleteTpResource(log.WithSpanFromContext(dctx, ctx), uniID, tpID, pathString,
 		resource, entryID, &wg)
 	dh.waitForCompletion(ctx, cancel, &wg, resourceName+"Delete") //wait for background process to finish
-	if err := dh.pOnuTP.getTpProcessingErrorIndication(uniID, tpID); err != nil {
-		logger.Errorw(ctx, err.Error(), log.Fields{"device-id": dh.deviceID})
+	if err := dh.pOnuTP.GetTpProcessingErrorIndication(uniID, tpID); err != nil {
+		logger.Errorw(ctx, err.Error(), log.Fields{"device-id": dh.DeviceID})
 		return err
 	}
 
-	if dh.pOnuTP.isTechProfileConfigCleared(ctx, uniID, tpID) {
-		logger.Debugw(ctx, "techProfile-config-cleared", log.Fields{"device-id": dh.deviceID, "uni-id": uniID, "tpID": tpID})
-		if bTpModify := pDevEntry.updateOnuUniTpPath(ctx, uniID, tpID, ""); bTpModify {
-			pDevEntry.resetKvProcessingErrorIndication()
+	if dh.pOnuTP.IsTechProfileConfigCleared(ctx, uniID, tpID) {
+		logger.Debugw(ctx, "techProfile-config-cleared", log.Fields{"device-id": dh.DeviceID, "uni-id": uniID, "tpID": tpID})
+		if bTpModify := pDevEntry.UpdateOnuUniTpPath(ctx, uniID, tpID, ""); bTpModify {
+			pDevEntry.ResetKvProcessingErrorIndication()
 			var wg2 sync.WaitGroup
 			dctx2, cancel2 := context.WithDeadline(context.Background(), deadline)
 			wg2.Add(1)
 			// Removal of the gem id mapping represents the removal of the tech profile
-			logger.Infow(ctx, "remove-techProfile-indication-in-kv", log.Fields{"device-id": dh.deviceID, "uni-id": uniID, "tpID": tpID})
-			go pDevEntry.updateOnuKvStore(log.WithSpanFromContext(dctx2, ctx), &wg2)
+			logger.Infow(ctx, "remove-techProfile-indication-in-kv", log.Fields{"device-id": dh.DeviceID, "uni-id": uniID, "tpID": tpID})
+			go pDevEntry.UpdateOnuKvStore(log.WithSpanFromContext(dctx2, ctx), &wg2)
 			dh.waitForCompletion(ctx, cancel2, &wg2, "TechProfileDeleteOn"+resourceName) //wait for background process to finish
-			if err := pDevEntry.getKvProcessingErrorIndication(); err != nil {
-				logger.Errorw(ctx, err.Error(), log.Fields{"device-id": dh.deviceID})
+			if err := pDevEntry.GetKvProcessingErrorIndication(); err != nil {
+				logger.Errorw(ctx, err.Error(), log.Fields{"device-id": dh.DeviceID})
 				return err
 			}
 		}
 	}
-	logger.Debugw(ctx, "delete-tech-profile-resource-completed", log.Fields{"device-id": dh.deviceID,
+	logger.Debugw(ctx, "delete-tech-profile-resource-completed", log.Fields{"device-id": dh.DeviceID,
 		"uni-id": uniID, "tpID": tpID, "resource-type": resourceName, "resource-id": entryID})
 	return nil
 }
@@ -581,49 +530,49 @@
 func (dh *deviceHandler) FlowUpdateIncremental(ctx context.Context,
 	apOfFlowChanges *of.FlowChanges,
 	apOfGroupChanges *of.FlowGroupChanges, apFlowMetaData *voltha.FlowMetadata) error {
-	logger.Debugw(ctx, "FlowUpdateIncremental started", log.Fields{"device-id": dh.deviceID, "metadata": apFlowMetaData})
+	logger.Debugw(ctx, "FlowUpdateIncremental started", log.Fields{"device-id": dh.DeviceID, "metadata": apFlowMetaData})
 	var retError error = nil
 	//Remove flows (always remove flows first - remove old and add new with same cookie may be part of the same request)
 	if apOfFlowChanges.ToRemove != nil {
 		for _, flowItem := range apOfFlowChanges.ToRemove.Items {
 			if flowItem.GetCookie() == 0 {
 				logger.Warnw(ctx, "flow-remove no cookie: ignore and continuing on checking further flows", log.Fields{
-					"device-id": dh.deviceID})
-				retError = fmt.Errorf("flow-remove no cookie, device-id %s", dh.deviceID)
+					"device-id": dh.DeviceID})
+				retError = fmt.Errorf("flow-remove no cookie, device-id %s", dh.DeviceID)
 				continue
 			}
 			flowInPort := flow.GetInPort(flowItem)
 			if flowInPort == uint32(of.OfpPortNo_OFPP_INVALID) {
-				logger.Warnw(ctx, "flow-remove inPort invalid: ignore and continuing on checking further flows", log.Fields{"device-id": dh.deviceID})
-				retError = fmt.Errorf("flow-remove inPort invalid, device-id %s", dh.deviceID)
+				logger.Warnw(ctx, "flow-remove inPort invalid: ignore and continuing on checking further flows", log.Fields{"device-id": dh.DeviceID})
+				retError = fmt.Errorf("flow-remove inPort invalid, device-id %s", dh.DeviceID)
 				continue
-				//return fmt.Errorf("flow inPort invalid: %s", dh.deviceID)
+				//return fmt.Errorf("flow inPort invalid: %s", dh.DeviceID)
 			} else if flowInPort == dh.ponPortNumber {
 				//this is some downstream flow, not regarded as error, just ignored
 				logger.Debugw(ctx, "flow-remove for downstream: ignore and continuing on checking further flows", log.Fields{
-					"device-id": dh.deviceID, "inPort": flowInPort})
+					"device-id": dh.DeviceID, "inPort": flowInPort})
 				continue
 			} else {
 				// this is the relevant upstream flow
-				var loUniPort *onuUniPort
+				var loUniPort *cmn.OnuUniPort
 				if uniPort, exist := dh.uniEntityMap[flowInPort]; exist {
 					loUniPort = uniPort
 				} else {
 					logger.Warnw(ctx, "flow-remove inPort not found in UniPorts: ignore and continuing on checking further flows",
-						log.Fields{"device-id": dh.deviceID, "inPort": flowInPort})
+						log.Fields{"device-id": dh.DeviceID, "inPort": flowInPort})
 					retError = fmt.Errorf("flow-remove inPort not found in UniPorts, inPort %d, device-id %s",
-						flowInPort, dh.deviceID)
+						flowInPort, dh.DeviceID)
 					continue
 				}
 				flowOutPort := flow.GetOutPort(flowItem)
 				logger.Debugw(ctx, "flow-remove port indications", log.Fields{
-					"device-id": dh.deviceID, "inPort": flowInPort, "outPort": flowOutPort,
-					"uniPortName": loUniPort.name})
+					"device-id": dh.DeviceID, "inPort": flowInPort, "outPort": flowOutPort,
+					"uniPortName": loUniPort.Name})
 				err := dh.removeFlowItemFromUniPort(ctx, flowItem, loUniPort)
 				//try next flow after processing error
 				if err != nil {
 					logger.Warnw(ctx, "flow-remove processing error: continuing on checking further flows",
-						log.Fields{"device-id": dh.deviceID, "error": err})
+						log.Fields{"device-id": dh.DeviceID, "error": err})
 					retError = err
 					continue
 					//return err
@@ -637,31 +586,31 @@
 		for _, flowItem := range apOfFlowChanges.ToAdd.Items {
 			if flowItem.GetCookie() == 0 {
 				logger.Debugw(ctx, "incremental flow-add no cookie: ignore and continuing on checking further flows", log.Fields{
-					"device-id": dh.deviceID})
-				retError = fmt.Errorf("flow-add no cookie, device-id %s", dh.deviceID)
+					"device-id": dh.DeviceID})
+				retError = fmt.Errorf("flow-add no cookie, device-id %s", dh.DeviceID)
 				continue
 			}
 			flowInPort := flow.GetInPort(flowItem)
 			if flowInPort == uint32(of.OfpPortNo_OFPP_INVALID) {
-				logger.Warnw(ctx, "flow-add inPort invalid: ignore and continuing on checking further flows", log.Fields{"device-id": dh.deviceID})
-				retError = fmt.Errorf("flow-add inPort invalid, device-id %s", dh.deviceID)
+				logger.Warnw(ctx, "flow-add inPort invalid: ignore and continuing on checking further flows", log.Fields{"device-id": dh.DeviceID})
+				retError = fmt.Errorf("flow-add inPort invalid, device-id %s", dh.DeviceID)
 				continue
-				//return fmt.Errorf("flow inPort invalid: %s", dh.deviceID)
+				//return fmt.Errorf("flow inPort invalid: %s", dh.DeviceID)
 			} else if flowInPort == dh.ponPortNumber {
 				//this is some downstream flow
 				logger.Debugw(ctx, "flow-add for downstream: ignore and continuing on checking further flows", log.Fields{
-					"device-id": dh.deviceID, "inPort": flowInPort})
+					"device-id": dh.DeviceID, "inPort": flowInPort})
 				continue
 			} else {
 				// this is the relevant upstream flow
-				var loUniPort *onuUniPort
+				var loUniPort *cmn.OnuUniPort
 				if uniPort, exist := dh.uniEntityMap[flowInPort]; exist {
 					loUniPort = uniPort
 				} else {
 					logger.Warnw(ctx, "flow-add inPort not found in UniPorts: ignore and continuing on checking further flows",
-						log.Fields{"device-id": dh.deviceID, "inPort": flowInPort})
+						log.Fields{"device-id": dh.DeviceID, "inPort": flowInPort})
 					retError = fmt.Errorf("flow-add inPort not found in UniPorts, inPort %d, device-id %s",
-						flowInPort, dh.deviceID)
+						flowInPort, dh.DeviceID)
 					continue
 					//return fmt.Errorf("flow-parameter inPort %d not found in internal UniPorts", flowInPort)
 				}
@@ -671,21 +620,21 @@
 				//   after the device gets active automatically (and still with its dependency to the TechProfile)
 				// for state checking compare also code here: processInterAdapterTechProfileDownloadReqMessage
 				// also abort for the other still possible flows here
-				if !dh.isReadyForOmciConfig() {
-					logger.Errorw(ctx, "flow-add rejected: improper device state", log.Fields{"device-id": dh.deviceID,
-						"last device-reason": dh.getDeviceReasonString()})
-					return fmt.Errorf("improper device state on device %s", dh.deviceID)
+				if !dh.IsReadyForOmciConfig() {
+					logger.Errorw(ctx, "flow-add rejected: improper device state", log.Fields{"device-id": dh.DeviceID,
+						"last device-reason": dh.GetDeviceReasonString()})
+					return fmt.Errorf("improper device state on device %s", dh.DeviceID)
 				}
 
 				flowOutPort := flow.GetOutPort(flowItem)
 				logger.Debugw(ctx, "flow-add port indications", log.Fields{
-					"device-id": dh.deviceID, "inPort": flowInPort, "outPort": flowOutPort,
-					"uniPortName": loUniPort.name})
+					"device-id": dh.DeviceID, "inPort": flowInPort, "outPort": flowOutPort,
+					"uniPortName": loUniPort.Name})
 				err := dh.addFlowItemToUniPort(ctx, flowItem, loUniPort, apFlowMetaData)
 				//try next flow after processing error
 				if err != nil {
 					logger.Warnw(ctx, "flow-add processing error: continuing on checking further flows",
-						log.Fields{"device-id": dh.deviceID, "error": err})
+						log.Fields{"device-id": dh.DeviceID, "error": err})
 					retError = err
 					continue
 					//return err
@@ -709,34 +658,34 @@
 	//note that disableDevice sequences in some 'ONU active' state may yield also
 	// "tech...delete-success" or "omci-flow-deleted" according to further received requests in the end
 	// - inblock state checking to prevent possibly unneeded processing (on command repitition)
-	if dh.getDeviceReason() != drOmciAdminLock {
+	if dh.getDeviceReason() != cmn.DrOmciAdminLock {
 		//disable-device shall be just a UNi/ONU-G related admin state setting
 		//all other configurations/FSM's shall not be impacted and shall execute as required by the system
 
-		if dh.isReadyForOmciConfig() {
+		if dh.IsReadyForOmciConfig() {
 			// disable UNI ports/ONU
 			// *** should generate UniDisableStateDone event - used to disable the port(s) on success
 			if dh.pLockStateFsm == nil {
-				dh.createUniLockFsm(ctx, true, UniDisableStateDone)
+				dh.createUniLockFsm(ctx, true, cmn.UniDisableStateDone)
 			} else { //LockStateFSM already init
-				dh.pLockStateFsm.setSuccessEvent(UniDisableStateDone)
+				dh.pLockStateFsm.SetSuccessEvent(cmn.UniDisableStateDone)
 				dh.runUniLockFsm(ctx, true)
 			}
 		} else {
 			logger.Debugw(ctx, "DeviceStateUpdate upon disable", log.Fields{"ConnectStatus": voltha.ConnectStatus_REACHABLE,
-				"OperStatus": voltha.OperStatus_UNKNOWN, "device-id": dh.deviceID})
+				"OperStatus": voltha.OperStatus_UNKNOWN, "device-id": dh.DeviceID})
 			if err := dh.updateDeviceStateInCore(ctx, &ic.DeviceStateFilter{
-				DeviceId:   dh.deviceID,
+				DeviceId:   dh.DeviceID,
 				ConnStatus: voltha.ConnectStatus_REACHABLE,
 				OperStatus: voltha.OperStatus_UNKNOWN,
 			}); err != nil {
 				//TODO with VOL-3045/VOL-3046: return the error and stop further processing
-				logger.Errorw(ctx, "error-updating-device-state", log.Fields{"device-id": dh.deviceID, "error": err})
+				logger.Errorw(ctx, "error-updating-device-state", log.Fields{"device-id": dh.DeviceID, "error": err})
 			}
 			// DeviceReason to update acc.to modified py code as per beginning of Sept 2020
 
 			//TODO with VOL-3045/VOL-3046: catch and return error, valid for all occurrences in the codebase
-			_ = dh.deviceReasonUpdate(ctx, drOmciAdminLock, true)
+			_ = dh.deviceReasonUpdate(ctx, cmn.DrOmciAdminLock, true)
 		}
 	}
 }
@@ -753,67 +702,67 @@
 	//		OnuIndication-Dw (or not active at all) (- disable) - enable: here already the LockFsm may run into timeout (no OmciResponse)
 	//      but that anyway is hopefully resolved by some OnuIndication-Up event (maybe to be tested)
 	//      one could also argue, that a device-enable should also enable attempts for specific omci configuration
-	dh.setReadyForOmciConfig(true) //needed to allow subsequent flow/techProf config (on BBSIM)
+	dh.SetReadyForOmciConfig(true) //needed to allow subsequent flow/techProf config (on BBSIM)
 
 	// enable ONU/UNI ports
-	// *** should generate UniEnableStateDone event - used to disable the port(s) on success
+	// *** should generate cmn.UniEnableStateDone event - used to disable the port(s) on success
 	if dh.pUnlockStateFsm == nil {
-		dh.createUniLockFsm(ctx, false, UniEnableStateDone)
+		dh.createUniLockFsm(ctx, false, cmn.UniEnableStateDone)
 	} else { //UnlockStateFSM already init
-		dh.pUnlockStateFsm.setSuccessEvent(UniEnableStateDone)
+		dh.pUnlockStateFsm.SetSuccessEvent(cmn.UniEnableStateDone)
 		dh.runUniLockFsm(ctx, false)
 	}
 }
 
 func (dh *deviceHandler) reconcileDeviceOnuInd(ctx context.Context) {
-	logger.Debugw(ctx, "reconciling - simulate onu indication", log.Fields{"device-id": dh.deviceID})
+	logger.Debugw(ctx, "reconciling - simulate onu indication", log.Fields{"device-id": dh.DeviceID})
 
-	pDevEntry := dh.getOnuDeviceEntry(ctx, true)
+	pDevEntry := dh.GetOnuDeviceEntry(ctx, true)
 	if pDevEntry == nil {
-		logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
+		logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.DeviceID})
 		return
 	}
-	if err := pDevEntry.restoreDataFromOnuKvStore(log.WithSpanFromContext(context.TODO(), ctx)); err != nil {
+	if err := pDevEntry.RestoreDataFromOnuKvStore(log.WithSpanFromContext(context.TODO(), ctx)); err != nil {
 		if err == fmt.Errorf("no-ONU-data-found") {
-			logger.Debugw(ctx, "no persistent data found - abort reconciling", log.Fields{"device-id": dh.deviceID})
+			logger.Debugw(ctx, "no persistent data found - abort reconciling", log.Fields{"device-id": dh.DeviceID})
 		} else {
-			logger.Errorw(ctx, "reconciling - restoring OnuTp-data failed - abort", log.Fields{"err": err, "device-id": dh.deviceID})
+			logger.Errorw(ctx, "reconciling - restoring OnuTp-data failed - abort", log.Fields{"err": err, "device-id": dh.DeviceID})
 		}
-		dh.stopReconciling(ctx, false)
+		dh.StopReconciling(ctx, false)
 		return
 	}
 	var onuIndication oop.OnuIndication
-	pDevEntry.mutexPersOnuConfig.RLock()
-	onuIndication.IntfId = pDevEntry.sOnuPersistentData.PersIntfID
-	onuIndication.OnuId = pDevEntry.sOnuPersistentData.PersOnuID
-	onuIndication.OperState = pDevEntry.sOnuPersistentData.PersOperState
-	onuIndication.AdminState = pDevEntry.sOnuPersistentData.PersAdminState
-	pDevEntry.mutexPersOnuConfig.RUnlock()
+	pDevEntry.MutexPersOnuConfig.RLock()
+	onuIndication.IntfId = pDevEntry.SOnuPersistentData.PersIntfID
+	onuIndication.OnuId = pDevEntry.SOnuPersistentData.PersOnuID
+	onuIndication.OperState = pDevEntry.SOnuPersistentData.PersOperState
+	onuIndication.AdminState = pDevEntry.SOnuPersistentData.PersAdminState
+	pDevEntry.MutexPersOnuConfig.RUnlock()
 	_ = dh.createInterface(ctx, &onuIndication)
 }
 
-func (dh *deviceHandler) reconcileDeviceTechProf(ctx context.Context) {
-	logger.Debugw(ctx, "reconciling - trigger tech profile config", log.Fields{"device-id": dh.deviceID})
+func (dh *deviceHandler) ReconcileDeviceTechProf(ctx context.Context) {
+	logger.Debugw(ctx, "reconciling - trigger tech profile config", log.Fields{"device-id": dh.DeviceID})
 
-	pDevEntry := dh.getOnuDeviceEntry(ctx, true)
+	pDevEntry := dh.GetOnuDeviceEntry(ctx, true)
 	if pDevEntry == nil {
-		logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
-		if !dh.isSkipOnuConfigReconciling() {
-			dh.stopReconciling(ctx, false)
+		logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.DeviceID})
+		if !dh.IsSkipOnuConfigReconciling() {
+			dh.StopReconciling(ctx, false)
 		}
 		return
 	}
-	dh.pOnuTP.lockTpProcMutex()
-	defer dh.pOnuTP.unlockTpProcMutex()
+	dh.pOnuTP.LockTpProcMutex()
+	defer dh.pOnuTP.UnlockTpProcMutex()
 
-	pDevEntry.mutexPersOnuConfig.RLock()
+	pDevEntry.MutexPersOnuConfig.RLock()
 	persMutexLock := true
-	if len(pDevEntry.sOnuPersistentData.PersUniConfig) == 0 {
-		pDevEntry.mutexPersOnuConfig.RUnlock()
+	if len(pDevEntry.SOnuPersistentData.PersUniConfig) == 0 {
+		pDevEntry.MutexPersOnuConfig.RUnlock()
 		logger.Debugw(ctx, "reconciling - no uni-configs have been stored before adapter restart - terminate reconcilement",
-			log.Fields{"device-id": dh.deviceID})
-		if !dh.isSkipOnuConfigReconciling() {
-			dh.stopReconciling(ctx, true)
+			log.Fields{"device-id": dh.DeviceID})
+		if !dh.IsSkipOnuConfigReconciling() {
+			dh.StopReconciling(ctx, true)
 		}
 		return
 	}
@@ -821,17 +770,17 @@
 	techProfsFound := false
 	techProfInstLoadFailed := false
 outerLoop:
-	for _, uniData := range pDevEntry.sOnuPersistentData.PersUniConfig {
+	for _, uniData := range pDevEntry.SOnuPersistentData.PersUniConfig {
 		//TODO: check for uni-port specific reconcilement in case of multi-uni-port-per-onu-support
 		if len(uniData.PersTpPathMap) == 0 {
 			logger.Debugw(ctx, "reconciling - no TPs stored for uniID",
-				log.Fields{"uni-id": uniData.PersUniID, "device-id": dh.deviceID})
+				log.Fields{"uni-id": uniData.PersUniID, "device-id": dh.DeviceID})
 			continue
 		}
-		//release mutexPersOnuConfig before TechProfile (ANIConfig) processing as otherwise the reception of
-		//  OMCI frames may get completely stuck due to lock request within incrementMibDataSync() at OMCI
+		//release MutexPersOnuConfig before TechProfile (ANIConfig) processing as otherwise the reception of
+		//  OMCI frames may get completely stuck due to lock request within IncrementMibDataSync() at OMCI
 		//  frame reception may also lock the complete OMCI reception processing based on mutexRxSchedMap
-		pDevEntry.mutexPersOnuConfig.RUnlock()
+		pDevEntry.MutexPersOnuConfig.RUnlock()
 		persMutexLock = false
 		techProfsFound = true // set to true if we found TP once for any UNI port
 		for tpID := range uniData.PersTpPathMap {
@@ -848,7 +797,7 @@
 				})
 			if err != nil || iaTechTpInst == nil {
 				logger.Errorw(ctx, "error fetching tp instance",
-					log.Fields{"tp-id": tpID, "tpPath": uniData.PersTpPathMap[tpID], "uni-id": uniData.PersUniID, "device-id": dh.deviceID, "err": err})
+					log.Fields{"tp-id": tpID, "tpPath": uniData.PersTpPathMap[tpID], "uni-id": uniData.PersUniID, "device-id": dh.DeviceID, "err": err})
 				techProfInstLoadFailed = true // stop loading tp instance as soon as we hit failure
 				break outerLoop
 			}
@@ -857,10 +806,10 @@
 			case *ic.TechProfileDownloadMessage_TpInstance: // supports only GPON, XGPON, XGS-PON
 				tpInst = *techTpInst.TpInstance
 				logger.Debugw(ctx, "received-tp-instance-successfully-after-reconcile", log.Fields{
-					"tp-id": tpID, "tpPath": uniData.PersTpPathMap[tpID], "uni-id": uniData.PersUniID, "device-id": dh.deviceID})
+					"tp-id": tpID, "tpPath": uniData.PersTpPathMap[tpID], "uni-id": uniData.PersUniID, "device-id": dh.DeviceID})
 			default: // do not support epon or other tech
 				logger.Errorw(ctx, "unsupported-tech-profile", log.Fields{
-					"tp-id": tpID, "tpPath": uniData.PersTpPathMap[tpID], "uni-id": uniData.PersUniID, "device-id": dh.deviceID})
+					"tp-id": tpID, "tpPath": uniData.PersTpPathMap[tpID], "uni-id": uniData.PersUniID, "device-id": dh.DeviceID})
 				techProfInstLoadFailed = true // stop loading tp instance as soon as we hit failure
 				break outerLoop
 			}
@@ -870,13 +819,13 @@
 			deadline := time.Now().Add(dh.pOpenOnuAc.maxTimeoutInterAdapterComm) //allowed run time to finish before execution
 			dctx, cancel := context.WithDeadline(ctx, deadline)
 
-			dh.pOnuTP.resetTpProcessingErrorIndication(uniData.PersUniID, tpID)
+			dh.pOnuTP.ResetTpProcessingErrorIndication(uniData.PersUniID, tpID)
 			var wg sync.WaitGroup
 			wg.Add(1) // for the 1 go routine to finish
-			go dh.pOnuTP.configureUniTp(log.WithSpanFromContext(dctx, ctx), uniData.PersUniID, uniData.PersTpPathMap[tpID], tpInst, &wg)
+			go dh.pOnuTP.ConfigureUniTp(log.WithSpanFromContext(dctx, ctx), uniData.PersUniID, uniData.PersTpPathMap[tpID], tpInst, &wg)
 			dh.waitForCompletion(ctx, cancel, &wg, "TechProfReconcile") //wait for background process to finish
-			if err := dh.pOnuTP.getTpProcessingErrorIndication(uniData.PersUniID, tpID); err != nil {
-				logger.Errorw(ctx, err.Error(), log.Fields{"device-id": dh.deviceID})
+			if err := dh.pOnuTP.GetTpProcessingErrorIndication(uniData.PersUniID, tpID); err != nil {
+				logger.Errorw(ctx, err.Error(), log.Fields{"device-id": dh.DeviceID})
 				techProfInstLoadFailed = true // stop loading tp instance as soon as we hit failure
 				break outerLoop
 			}
@@ -884,11 +833,11 @@
 		if len(uniData.PersFlowParams) != 0 {
 			flowsFound = true
 		}
-		pDevEntry.mutexPersOnuConfig.RLock() //set protection again for loop test on sOnuPersistentData
+		pDevEntry.MutexPersOnuConfig.RLock() //set protection again for loop test on SOnuPersistentData
 		persMutexLock = true
-	} // for all UNI entries from sOnuPersistentData
-	if persMutexLock { // if loop was left with mutexPersOnuConfig still set
-		pDevEntry.mutexPersOnuConfig.RUnlock()
+	} // for all UNI entries from SOnuPersistentData
+	if persMutexLock { // if loop was left with MutexPersOnuConfig still set
+		pDevEntry.MutexPersOnuConfig.RUnlock()
 	}
 
 	//had to move techProf/flow result evaluation into separate function due to SCA complexity limit
@@ -899,89 +848,87 @@
 	abTechProfsFound bool, abTechProfInstLoadFailed bool, abFlowsFound bool) {
 	if !abTechProfsFound {
 		logger.Debugw(ctx, "reconciling - no TPs have been stored before adapter restart - terminate reconcilement",
-			log.Fields{"device-id": dh.deviceID})
-		if !dh.isSkipOnuConfigReconciling() {
-			dh.stopReconciling(ctx, true)
+			log.Fields{"device-id": dh.DeviceID})
+		if !dh.IsSkipOnuConfigReconciling() {
+			dh.StopReconciling(ctx, true)
 		}
 		return
 	}
 	if abTechProfInstLoadFailed {
-		dh.setDeviceReason(drTechProfileConfigDownloadFailed)
-		dh.stopReconciling(ctx, false)
+		dh.SetDeviceReason(cmn.DrTechProfileConfigDownloadFailed)
+		dh.StopReconciling(ctx, false)
 		return
-	} else if dh.isSkipOnuConfigReconciling() {
-		dh.setDeviceReason(drTechProfileConfigDownloadSuccess)
+	} else if dh.IsSkipOnuConfigReconciling() {
+		dh.SetDeviceReason(cmn.DrTechProfileConfigDownloadSuccess)
 	}
 	if !abFlowsFound {
 		logger.Debugw(ctx, "reconciling - no flows have been stored before adapter restart - terminate reconcilement",
-			log.Fields{"device-id": dh.deviceID})
-		if !dh.isSkipOnuConfigReconciling() {
-			dh.stopReconciling(ctx, true)
+			log.Fields{"device-id": dh.DeviceID})
+		if !dh.IsSkipOnuConfigReconciling() {
+			dh.StopReconciling(ctx, true)
 		}
 	}
 }
 
-func (dh *deviceHandler) reconcileDeviceFlowConfig(ctx context.Context) {
-	logger.Debugw(ctx, "reconciling - trigger flow config", log.Fields{"device-id": dh.deviceID})
+func (dh *deviceHandler) ReconcileDeviceFlowConfig(ctx context.Context) {
+	logger.Debugw(ctx, "reconciling - trigger flow config", log.Fields{"device-id": dh.DeviceID})
 
-	pDevEntry := dh.getOnuDeviceEntry(ctx, true)
+	pDevEntry := dh.GetOnuDeviceEntry(ctx, true)
 	if pDevEntry == nil {
-		logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
-		if !dh.isSkipOnuConfigReconciling() {
-			dh.stopReconciling(ctx, false)
+		logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.DeviceID})
+		if !dh.IsSkipOnuConfigReconciling() {
+			dh.StopReconciling(ctx, false)
 		}
 		return
 	}
 
-	pDevEntry.mutexPersOnuConfig.RLock()
-	if len(pDevEntry.sOnuPersistentData.PersUniConfig) == 0 {
-		pDevEntry.mutexPersOnuConfig.RUnlock()
+	pDevEntry.MutexPersOnuConfig.RLock()
+	if len(pDevEntry.SOnuPersistentData.PersUniConfig) == 0 {
+		pDevEntry.MutexPersOnuConfig.RUnlock()
 		logger.Debugw(ctx, "reconciling - no uni-configs have been stored before adapter restart - terminate reconcilement",
-			log.Fields{"device-id": dh.deviceID})
-		if !dh.isSkipOnuConfigReconciling() {
-			dh.stopReconciling(ctx, true)
+			log.Fields{"device-id": dh.DeviceID})
+		if !dh.IsSkipOnuConfigReconciling() {
+			dh.StopReconciling(ctx, true)
 		}
 		return
 	}
 	flowsFound := false
-	for _, uniData := range pDevEntry.sOnuPersistentData.PersUniConfig {
+	for _, uniData := range pDevEntry.SOnuPersistentData.PersUniConfig {
 		//TODO: check for uni-port specific reconcilement in case of multi-uni-port-per-onu-support
 		if len(uniData.PersFlowParams) == 0 {
 			logger.Debugw(ctx, "reconciling - no flows stored for uniID",
-				log.Fields{"uni-id": uniData.PersUniID, "device-id": dh.deviceID})
+				log.Fields{"uni-id": uniData.PersUniID, "device-id": dh.DeviceID})
 			continue
 		}
 		if len(uniData.PersTpPathMap) == 0 {
 			logger.Warnw(ctx, "reconciling - flows but no TPs stored for uniID",
-				log.Fields{"uni-id": uniData.PersUniID, "device-id": dh.deviceID})
+				log.Fields{"uni-id": uniData.PersUniID, "device-id": dh.DeviceID})
 			// It doesn't make sense to configure any flows if no TPs are available
 			continue
 		}
-		//release mutexPersOnuConfig before VlanConfig processing as otherwise the reception of
-		//  OMCI frames may get completely stuck due to lock request within incrementMibDataSync() at OMCI
+		//release MutexPersOnuConfig before VlanConfig processing as otherwise the reception of
+		//  OMCI frames may get completely stuck due to lock request within IncrementMibDataSync() at OMCI
 		//  frame reception may also lock the complete OMCI reception processing based on mutexRxSchedMap
-		pDevEntry.mutexPersOnuConfig.RUnlock()
+		pDevEntry.MutexPersOnuConfig.RUnlock()
 
-		var uniPort *onuUniPort
+		var uniPort *cmn.OnuUniPort
 		var exist bool
 		uniNo := mkUniPortNum(ctx, dh.pOnuIndication.GetIntfId(), dh.pOnuIndication.GetOnuId(), uint32(uniData.PersUniID))
 		if uniPort, exist = dh.uniEntityMap[uniNo]; !exist {
-			logger.Errorw(ctx, "reconciling - onuUniPort data not found  - terminate reconcilement",
-				log.Fields{"uniNo": uniNo, "device-id": dh.deviceID})
-			if !dh.isSkipOnuConfigReconciling() {
-				dh.stopReconciling(ctx, false)
+			logger.Errorw(ctx, "reconciling - OnuUniPort data not found  - terminate reconcilement",
+				log.Fields{"uniNo": uniNo, "device-id": dh.DeviceID})
+			if !dh.IsSkipOnuConfigReconciling() {
+				dh.StopReconciling(ctx, false)
 			}
 			return
 		}
 		flowsFound = true
 		lastFlowToReconcile := false
 		flowsProcessed := 0
-		dh.setReconcilingFlows(true)
+		pDevEntry.SetReconcilingFlows(true)
 		for _, flowData := range uniData.PersFlowParams {
 			logger.Debugw(ctx, "reconciling - add flow with cookie slice", log.Fields{
-				"device-id": dh.deviceID, "uni-id": uniData.PersUniID, "cookies": flowData.CookieSlice})
-			// If this is the last flow for the device we need to announce it the waiting
-			// chReconcilingFlowsFinished channel
+				"device-id": dh.DeviceID, "uni-id": uniData.PersUniID, "cookies": flowData.CookieSlice})
 			if flowsProcessed == len(uniData.PersFlowParams)-1 {
 				lastFlowToReconcile = true
 			}
@@ -991,55 +938,55 @@
 				if err := dh.UniVlanConfigFsmMap[uniData.PersUniID].SetUniFlowParams(ctx, flowData.VlanRuleParams.TpID,
 					flowData.CookieSlice, uint16(flowData.VlanRuleParams.MatchVid), uint16(flowData.VlanRuleParams.SetVid),
 					uint8(flowData.VlanRuleParams.SetPcp), lastFlowToReconcile, flowData.Meter); err != nil {
-					logger.Errorw(ctx, err.Error(), log.Fields{"device-id": dh.deviceID})
+					logger.Errorw(ctx, err.Error(), log.Fields{"device-id": dh.DeviceID})
 				}
 			} else {
 				if err := dh.createVlanFilterFsm(ctx, uniPort, flowData.VlanRuleParams.TpID, flowData.CookieSlice,
 					uint16(flowData.VlanRuleParams.MatchVid), uint16(flowData.VlanRuleParams.SetVid),
-					uint8(flowData.VlanRuleParams.SetPcp), OmciVlanFilterAddDone, lastFlowToReconcile, flowData.Meter); err != nil {
-					logger.Errorw(ctx, err.Error(), log.Fields{"device-id": dh.deviceID})
+					uint8(flowData.VlanRuleParams.SetPcp), cmn.OmciVlanFilterAddDone, lastFlowToReconcile, flowData.Meter); err != nil {
+					logger.Errorw(ctx, err.Error(), log.Fields{"device-id": dh.DeviceID})
 				}
 			}
 			dh.lockVlanConfig.Unlock()
 			flowsProcessed++
 		} //for all flows of this UNI
 		logger.Debugw(ctx, "reconciling - flows processed", log.Fields{
-			"device-id": dh.deviceID, "uni-id": uniData.PersUniID, "flowsProcessed": flowsProcessed,
-			"numUniFlows":       dh.UniVlanConfigFsmMap[uniData.PersUniID].numUniFlows,
-			"configuredUniFlow": dh.UniVlanConfigFsmMap[uniData.PersUniID].configuredUniFlow})
+			"device-id": dh.DeviceID, "uni-id": uniData.PersUniID, "flowsProcessed": flowsProcessed,
+			"NumUniFlows":       dh.UniVlanConfigFsmMap[uniData.PersUniID].NumUniFlows,
+			"ConfiguredUniFlow": dh.UniVlanConfigFsmMap[uniData.PersUniID].ConfiguredUniFlow})
 		// this can't be used as global finished reconciling flag because
 		// assumes is getting called before the state machines for the last flow is completed,
 		// while this is not guaranteed.
-		//dh.setReconcilingFlows(false)
-		pDevEntry.mutexPersOnuConfig.RLock() //set protection again for loop test on sOnuPersistentData
-	} // for all UNI entries from sOnuPersistentData
-	pDevEntry.mutexPersOnuConfig.RUnlock()
+		//dh.SetReconcilingFlows(false)
+		pDevEntry.MutexPersOnuConfig.RLock() //set protection again for loop test on SOnuPersistentData
+	} // for all UNI entries from SOnuPersistentData
+	pDevEntry.MutexPersOnuConfig.RUnlock()
 
 	if !flowsFound {
 		logger.Debugw(ctx, "reconciling - no flows have been stored before adapter restart - terminate reconcilement",
-			log.Fields{"device-id": dh.deviceID})
-		if !dh.isSkipOnuConfigReconciling() {
-			dh.stopReconciling(ctx, true)
+			log.Fields{"device-id": dh.DeviceID})
+		if !dh.IsSkipOnuConfigReconciling() {
+			dh.StopReconciling(ctx, true)
 		}
 		return
 	}
-	if dh.isSkipOnuConfigReconciling() {
-		dh.setDeviceReason(drOmciFlowsPushed)
+	if dh.IsSkipOnuConfigReconciling() {
+		dh.SetDeviceReason(cmn.DrOmciFlowsPushed)
 	}
 }
 
 func (dh *deviceHandler) reconcileEnd(ctx context.Context) {
-	logger.Debugw(ctx, "reconciling - completed!", log.Fields{"device-id": dh.deviceID})
-	dh.stopReconciling(ctx, true)
+	logger.Debugw(ctx, "reconciling - completed!", log.Fields{"device-id": dh.DeviceID})
+	dh.StopReconciling(ctx, true)
 }
 
 func (dh *deviceHandler) deleteDevicePersistencyData(ctx context.Context) error {
-	logger.Debugw(ctx, "delete device persistency data", log.Fields{"device-id": dh.deviceID})
+	logger.Debugw(ctx, "delete device persistency data", log.Fields{"device-id": dh.DeviceID})
 
-	pDevEntry := dh.getOnuDeviceEntry(ctx, false)
+	pDevEntry := dh.GetOnuDeviceEntry(ctx, false)
 	if pDevEntry == nil {
 		//IfDevEntry does not exist here, no problem - no persistent data should have been stored
-		logger.Debugw(ctx, "OnuDevice does not exist - nothing to delete", log.Fields{"device-id": dh.deviceID})
+		logger.Debugw(ctx, "OnuDevice does not exist - nothing to delete", log.Fields{"device-id": dh.DeviceID})
 		return nil
 	}
 
@@ -1048,51 +995,51 @@
 	deadline := time.Now().Add(dh.pOpenOnuAc.maxTimeoutInterAdapterComm) //allowed run time to finish before execution
 	dctx, cancel := context.WithDeadline(ctx, deadline)
 
-	pDevEntry.resetKvProcessingErrorIndication()
+	pDevEntry.ResetKvProcessingErrorIndication()
 
 	var wg sync.WaitGroup
 	wg.Add(1) // for the 1 go routine to finish
-	go pDevEntry.deleteDataFromOnuKvStore(log.WithSpanFromContext(dctx, ctx), &wg)
+	go pDevEntry.DeleteDataFromOnuKvStore(log.WithSpanFromContext(dctx, ctx), &wg)
 	dh.waitForCompletion(ctx, cancel, &wg, "DeleteDevice") //wait for background process to finish
 
 	// TODO: further actions - stop metrics and FSMs, remove device ...
-	return pDevEntry.getKvProcessingErrorIndication()
+	return pDevEntry.GetKvProcessingErrorIndication()
 }
 
 //func (dh *deviceHandler) rebootDevice(ctx context.Context, device *voltha.Device) error {
 // before this change here return like this was used:
-// 		return fmt.Errorf("device-unreachable: %s, %s", dh.deviceID, device.SerialNumber)
+// 		return fmt.Errorf("device-unreachable: %s, %s", dh.DeviceID, device.SerialNumber)
 //was and is called in background - error return does not make sense
 func (dh *deviceHandler) rebootDevice(ctx context.Context, aCheckDeviceState bool, device *voltha.Device) {
-	logger.Infow(ctx, "reboot-device", log.Fields{"device-id": dh.deviceID, "SerialNumber": dh.device.SerialNumber})
+	logger.Infow(ctx, "reboot-device", log.Fields{"device-id": dh.DeviceID, "SerialNumber": dh.device.SerialNumber})
 	if aCheckDeviceState && device.ConnectStatus != voltha.ConnectStatus_REACHABLE {
 		logger.Errorw(ctx, "device-unreachable", log.Fields{"device-id": device.Id, "SerialNumber": device.SerialNumber})
 		return
 	}
-	if err := dh.pOnuOmciDevice.reboot(log.WithSpanFromContext(context.TODO(), ctx)); err != nil {
+	if err := dh.pOnuOmciDevice.Reboot(log.WithSpanFromContext(context.TODO(), ctx)); err != nil {
 		//TODO with VOL-3045/VOL-3046: return the error and stop further processing
-		logger.Errorw(ctx, "error-rebooting-device", log.Fields{"device-id": dh.deviceID, "error": err})
+		logger.Errorw(ctx, "error-rebooting-device", log.Fields{"device-id": dh.DeviceID, "error": err})
 		return
 	}
 
 	//transfer the possibly modified logical uni port state
-	dh.disableUniPortStateUpdate(ctx)
+	dh.DisableUniPortStateUpdate(ctx)
 
 	logger.Debugw(ctx, "call DeviceStateUpdate upon reboot", log.Fields{"ConnectStatus": voltha.ConnectStatus_REACHABLE,
-		"OperStatus": voltha.OperStatus_DISCOVERED, "device-id": dh.deviceID})
+		"OperStatus": voltha.OperStatus_DISCOVERED, "device-id": dh.DeviceID})
 	if err := dh.updateDeviceStateInCore(ctx, &ic.DeviceStateFilter{
-		DeviceId:   dh.deviceID,
+		DeviceId:   dh.DeviceID,
 		ConnStatus: voltha.ConnectStatus_REACHABLE,
 		OperStatus: voltha.OperStatus_DISCOVERED,
 	}); err != nil {
 		//TODO with VOL-3045/VOL-3046: return the error and stop further processing
-		logger.Errorw(ctx, "error-updating-device-state", log.Fields{"device-id": dh.deviceID, "error": err})
+		logger.Errorw(ctx, "error-updating-device-state", log.Fields{"device-id": dh.DeviceID, "error": err})
 		return
 	}
-	if err := dh.deviceReasonUpdate(ctx, drRebooting, true); err != nil {
+	if err := dh.deviceReasonUpdate(ctx, cmn.DrRebooting, true); err != nil {
 		return
 	}
-	dh.setReadyForOmciConfig(false)
+	dh.SetReadyForOmciConfig(false)
 	//no specific activity to synchronize any internal FSM to the 'rebooted' state is explicitly done here
 	//  the expectation ids for a real device, that it will be synced with the expected following 'down' indication
 	//  as BBSIM does not support this testing requires explicite disable/enable device calls in which sequence also
@@ -1102,46 +1049,50 @@
 //doOnuSwUpgrade initiates the SW download transfer to the ONU and on success activates the (inactive) image
 //  used only for old - R2.7 style - upgrade API
 func (dh *deviceHandler) doOnuSwUpgrade(ctx context.Context, apImageDsc *voltha.ImageDownload,
-	apDownloadManager *adapterDownloadManager) error {
+	apDownloadManager *swupg.AdapterDownloadManager) error {
 	logger.Debugw(ctx, "onuSwUpgrade requested", log.Fields{
-		"device-id": dh.deviceID, "image-name": (*apImageDsc).Name})
+		"device-id": dh.DeviceID, "image-name": (*apImageDsc).Name})
 
 	var err error
-	pDevEntry := dh.getOnuDeviceEntry(ctx, true)
+	pDevEntry := dh.GetOnuDeviceEntry(ctx, true)
 	if pDevEntry == nil {
-		logger.Errorw(ctx, "start Onu SW upgrade rejected: no valid OnuDevice", log.Fields{"device-id": dh.deviceID})
-		return fmt.Errorf("start Onu SW upgrade rejected: no valid OnuDevice for device-id: %s", dh.deviceID)
+		logger.Errorw(ctx, "start Onu SW upgrade rejected: no valid OnuDevice", log.Fields{"device-id": dh.DeviceID})
+		return fmt.Errorf("start Onu SW upgrade rejected: no valid OnuDevice for device-id: %s", dh.DeviceID)
 	}
 
-	if dh.isReadyForOmciConfig() {
+	if dh.IsReadyForOmciConfig() {
 		var inactiveImageID uint16
 		if inactiveImageID, err = pDevEntry.GetInactiveImageMeID(ctx); err == nil {
 			dh.lockUpgradeFsm.Lock()
 			defer dh.lockUpgradeFsm.Unlock()
 			if dh.pOnuUpradeFsm == nil {
-				err = dh.createOnuUpgradeFsm(ctx, pDevEntry, OmciOnuSwUpgradeDone)
+				err = dh.createOnuUpgradeFsm(ctx, pDevEntry, cmn.OmciOnuSwUpgradeDone)
 				if err == nil {
 					if err = dh.pOnuUpradeFsm.SetDownloadParams(ctx, inactiveImageID, apImageDsc, apDownloadManager); err != nil {
 						logger.Errorw(ctx, "onu upgrade fsm could not set parameters", log.Fields{
-							"device-id": dh.deviceID, "error": err})
+							"device-id": dh.DeviceID, "error": err})
 					}
 				} else {
 					logger.Errorw(ctx, "onu upgrade fsm could not be created", log.Fields{
-						"device-id": dh.deviceID, "error": err})
+						"device-id": dh.DeviceID, "error": err})
 				}
 			} else { //OnuSw upgrade already running - restart (with possible abort of running)
-				logger.Debugw(ctx, "Onu SW upgrade already running - abort", log.Fields{"device-id": dh.deviceID})
+				logger.Debugw(ctx, "Onu SW upgrade already running - abort", log.Fields{"device-id": dh.DeviceID})
+				dh.pOnuUpradeFsm.CancelProcessing(ctx, true, voltha.ImageState_CANCELLED_ON_REQUEST) //complete abort
+				//no effort spent anymore for the old API to automatically cancel and restart the download
+				//  like done for the new API
+				logger.Debugw(ctx, "Onu SW upgrade already running - abort", log.Fields{"device-id": dh.DeviceID})
 				dh.pOnuUpradeFsm.CancelProcessing(ctx, true, voltha.ImageState_CANCELLED_ON_REQUEST) //complete abort
 				//no effort spent anymore for the old API to automatically cancel and restart the download
 				//  like done for the new API
 			}
 		} else {
 			logger.Errorw(ctx, "start Onu SW upgrade rejected: no inactive image", log.Fields{
-				"device-id": dh.deviceID, "error": err})
+				"device-id": dh.DeviceID, "error": err})
 		}
 	} else {
-		logger.Errorw(ctx, "start Onu SW upgrade rejected: no active OMCI connection", log.Fields{"device-id": dh.deviceID})
-		err = fmt.Errorf("start Onu SW upgrade rejected: no active OMCI connection for device-id: %s", dh.deviceID)
+		logger.Errorw(ctx, "start Onu SW upgrade rejected: no active OMCI connection", log.Fields{"device-id": dh.DeviceID})
+		err = fmt.Errorf("start Onu SW upgrade rejected: no active OMCI connection for device-id: %s", dh.DeviceID)
 	}
 	return err
 }
@@ -1149,28 +1100,28 @@
 //onuSwUpgradeAfterDownload initiates the SW download transfer to the ONU with activate and commit options
 // after the OnuImage has been downloaded to the adapter, called in background
 func (dh *deviceHandler) onuSwUpgradeAfterDownload(ctx context.Context, apImageRequest *voltha.DeviceImageDownloadRequest,
-	apDownloadManager *fileDownloadManager, aImageIdentifier string) {
+	apDownloadManager *swupg.FileDownloadManager, aImageIdentifier string) {
 
 	var err error
-	pDevEntry := dh.getOnuDeviceEntry(ctx, true)
+	pDevEntry := dh.GetOnuDeviceEntry(ctx, true)
 	if pDevEntry == nil {
-		logger.Errorw(ctx, "start Onu SW upgrade rejected: no valid OnuDevice", log.Fields{"device-id": dh.deviceID})
+		logger.Errorw(ctx, "start Onu SW upgrade rejected: no valid OnuDevice", log.Fields{"device-id": dh.DeviceID})
 		return
 	}
 
 	var inactiveImageID uint16
 	if inactiveImageID, err = pDevEntry.GetInactiveImageMeID(ctx); err == nil {
 		logger.Debugw(ctx, "onuSwUpgrade requested", log.Fields{
-			"device-id": dh.deviceID, "image-version": apImageRequest.Image.Version, "to onu-image": inactiveImageID})
+			"device-id": dh.DeviceID, "image-version": apImageRequest.Image.Version, "to onu-image": inactiveImageID})
 
 		dh.lockUpgradeFsm.RLock()
 		lopOnuUpradeFsm := dh.pOnuUpradeFsm
-		//lockUpgradeFsm must be release before cancellation as this may implicitly request removeOnuUpgradeFsm()
+		//lockUpgradeFsm must be release before cancellation as this may implicitly request RemoveOnuUpgradeFsm()
 		dh.lockUpgradeFsm.RUnlock()
 		if lopOnuUpradeFsm != nil {
 			//OnuSw upgrade already running on this device (e.g. with activate/commit not yet set)
 			// abort the current processing, running upgrades are always aborted by newer request
-			logger.Debugw(ctx, "Onu SW upgrade already running - abort previous activity", log.Fields{"device-id": dh.deviceID})
+			logger.Debugw(ctx, "Onu SW upgrade already running - abort previous activity", log.Fields{"device-id": dh.DeviceID})
 			//flush the remove upgradeFsmChan channel
 			select {
 			case <-dh.upgradeFsmChan:
@@ -1180,33 +1131,33 @@
 			lopOnuUpradeFsm.CancelProcessing(ctx, true, voltha.ImageState_CANCELLED_ON_REQUEST) //complete abort
 			select {
 			case <-time.After(cTimeOutRemoveUpgrade * time.Second):
-				logger.Errorw(ctx, "could not remove Upgrade FSM in time, aborting", log.Fields{"device-id": dh.deviceID})
+				logger.Errorw(ctx, "could not remove Upgrade FSM in time, aborting", log.Fields{"device-id": dh.DeviceID})
 				//should not appear, can't proceed with new upgrade, perhaps operator can retry manually later
 				return
 			case <-dh.upgradeFsmChan:
-				logger.Debugw(ctx, "recent Upgrade FSM removed, proceed with new request", log.Fields{"device-id": dh.deviceID})
+				logger.Debugw(ctx, "recent Upgrade FSM removed, proceed with new request", log.Fields{"device-id": dh.DeviceID})
 			}
 		}
 
 		//here it can be assumed that no running upgrade processing exists (anymore)
 		//OmciOnuSwUpgradeDone could be used to create some Kafka event with information on upgrade completion,
 		//  but none yet defined
-		err = dh.createOnuUpgradeFsm(ctx, pDevEntry, OmciOnuSwUpgradeDone)
+		err = dh.createOnuUpgradeFsm(ctx, pDevEntry, cmn.OmciOnuSwUpgradeDone)
 		if err == nil {
 			if err = dh.pOnuUpradeFsm.SetDownloadParamsAfterDownload(ctx, inactiveImageID,
 				apImageRequest, apDownloadManager, aImageIdentifier); err != nil {
 				logger.Errorw(ctx, "onu upgrade fsm could not set parameters", log.Fields{
-					"device-id": dh.deviceID, "error": err})
+					"device-id": dh.DeviceID, "error": err})
 				return
 			}
 		} else {
 			logger.Errorw(ctx, "onu upgrade fsm could not be created", log.Fields{
-				"device-id": dh.deviceID, "error": err})
+				"device-id": dh.DeviceID, "error": err})
 		}
 		return
 	}
 	logger.Errorw(ctx, "start Onu SW upgrade rejected: no inactive image", log.Fields{
-		"device-id": dh.deviceID, "error": err})
+		"device-id": dh.DeviceID, "error": err})
 }
 
 //onuSwActivateRequest ensures activation of the requested image with commit options
@@ -1217,18 +1168,18 @@
 	//  1.) activation of the image for a started upgrade process (in case the running upgrade runs on the requested image)
 	//  2.) activation of the inactive image
 
-	pDevEntry := dh.getOnuDeviceEntry(ctx, true)
+	pDevEntry := dh.GetOnuDeviceEntry(ctx, true)
 	if pDevEntry == nil {
-		logger.Errorw(ctx, "Onu image activation rejected: no valid OnuDevice", log.Fields{"device-id": dh.deviceID})
-		return nil, fmt.Errorf("no valid OnuDevice for device-id: %s", dh.deviceID)
+		logger.Errorw(ctx, "Onu image activation rejected: no valid OnuDevice", log.Fields{"device-id": dh.DeviceID})
+		return nil, fmt.Errorf("no valid OnuDevice for device-id: %s", dh.DeviceID)
 	}
 	dh.lockUpgradeFsm.RLock()
 	if dh.pOnuUpradeFsm != nil {
 		dh.lockUpgradeFsm.RUnlock()
-		onuVolthaDevice, getErr := dh.getDeviceFromCore(ctx, dh.deviceID)
+		onuVolthaDevice, getErr := dh.getDeviceFromCore(ctx, dh.DeviceID)
 		if getErr != nil || onuVolthaDevice == nil {
-			logger.Errorw(ctx, "Failed to fetch Onu device for image activation", log.Fields{"device-id": dh.deviceID, "err": getErr})
-			return nil, fmt.Errorf("could not fetch device for device-id: %s", dh.deviceID)
+			logger.Errorw(ctx, "Failed to fetch Onu device for image activation", log.Fields{"device-id": dh.DeviceID, "err": getErr})
+			return nil, fmt.Errorf("could not fetch device for device-id: %s", dh.DeviceID)
 		}
 		//  use the OnuVendor identification from this device for the internal unique name
 		imageIdentifier := onuVolthaDevice.VendorId + aVersion //head on vendor ID of the ONU
@@ -1236,11 +1187,11 @@
 		if err = dh.pOnuUpradeFsm.SetActivationParamsRunning(ctx, imageIdentifier, aCommitRequest); err != nil {
 			//if some ONU upgrade is ongoing we do not accept some explicit ONU image-version related activation
 			logger.Errorw(ctx, "onu upgrade fsm did not accept activation while running", log.Fields{
-				"device-id": dh.deviceID, "error": err})
-			return nil, fmt.Errorf("activation not accepted for this version for device-id: %s", dh.deviceID)
+				"device-id": dh.DeviceID, "error": err})
+			return nil, fmt.Errorf("activation not accepted for this version for device-id: %s", dh.DeviceID)
 		}
 		logger.Debugw(ctx, "image activation acknowledged by onu upgrade processing", log.Fields{
-			"device-id": dh.deviceID, "image-id": imageIdentifier})
+			"device-id": dh.DeviceID, "image-id": imageIdentifier})
 		pImageStates := dh.pOnuUpradeFsm.GetImageStates(ctx, "", aVersion)
 		return pImageStates, nil
 	} //else
@@ -1251,25 +1202,25 @@
 	var inactiveImageID uint16
 	if inactiveImageID, err = pDevEntry.GetInactiveImageMeID(ctx); err != nil || inactiveImageID > 1 {
 		logger.Errorw(ctx, "get inactive image failed", log.Fields{
-			"device-id": dh.deviceID, "err": err, "image-id": inactiveImageID})
-		return nil, fmt.Errorf("no valid inactive image found for device-id: %s", dh.deviceID)
+			"device-id": dh.DeviceID, "err": err, "image-id": inactiveImageID})
+		return nil, fmt.Errorf("no valid inactive image found for device-id: %s", dh.DeviceID)
 	}
-	err = dh.createOnuUpgradeFsm(ctx, pDevEntry, OmciOnuSwUpgradeDone)
+	err = dh.createOnuUpgradeFsm(ctx, pDevEntry, cmn.OmciOnuSwUpgradeDone)
 	if err == nil {
 		if err = dh.pOnuUpradeFsm.SetActivationParamsStart(ctx, aVersion,
 			inactiveImageID, aCommitRequest); err != nil {
 			logger.Errorw(ctx, "onu upgrade fsm did not accept activation to start", log.Fields{
-				"device-id": dh.deviceID, "error": err})
-			return nil, fmt.Errorf("activation to start from scratch not accepted for device-id: %s", dh.deviceID)
+				"device-id": dh.DeviceID, "error": err})
+			return nil, fmt.Errorf("activation to start from scratch not accepted for device-id: %s", dh.DeviceID)
 		}
 		logger.Debugw(ctx, "inactive image activation acknowledged by onu upgrade", log.Fields{
-			"device-id": dh.deviceID, "image-version": aVersion})
+			"device-id": dh.DeviceID, "image-version": aVersion})
 		pImageStates := dh.pOnuUpradeFsm.GetImageStates(ctx, "", aVersion)
 		return pImageStates, nil
 	} //else
 	logger.Errorw(ctx, "onu upgrade fsm could not be created", log.Fields{
-		"device-id": dh.deviceID, "error": err})
-	return nil, fmt.Errorf("could not start upgradeFsm for device-id: %s", dh.deviceID)
+		"device-id": dh.DeviceID, "error": err})
+	return nil, fmt.Errorf("could not start upgradeFsm for device-id: %s", dh.DeviceID)
 }
 
 //onuSwCommitRequest ensures commitment of the requested image
@@ -1280,18 +1231,18 @@
 	//  1.) commitment of the image for a started upgrade process (in case the running upgrade runs on the requested image)
 	//  2.) commitment of the active image
 
-	pDevEntry := dh.getOnuDeviceEntry(ctx, true)
+	pDevEntry := dh.GetOnuDeviceEntry(ctx, true)
 	if pDevEntry == nil {
-		logger.Errorw(ctx, "Onu image commitment rejected: no valid OnuDevice", log.Fields{"device-id": dh.deviceID})
-		return nil, fmt.Errorf("no valid OnuDevice for device-id: %s", dh.deviceID)
+		logger.Errorw(ctx, "Onu image commitment rejected: no valid OnuDevice", log.Fields{"device-id": dh.DeviceID})
+		return nil, fmt.Errorf("no valid OnuDevice for device-id: %s", dh.DeviceID)
 	}
 	dh.lockUpgradeFsm.RLock()
 	if dh.pOnuUpradeFsm != nil {
 		dh.lockUpgradeFsm.RUnlock()
-		onuVolthaDevice, getErr := dh.getDeviceFromCore(ctx, dh.deviceID)
+		onuVolthaDevice, getErr := dh.getDeviceFromCore(ctx, dh.DeviceID)
 		if getErr != nil || onuVolthaDevice == nil {
-			logger.Errorw(ctx, "Failed to fetch Onu device for image commitment", log.Fields{"device-id": dh.deviceID, "err": getErr})
-			return nil, fmt.Errorf("could not fetch device for device-id: %s", dh.deviceID)
+			logger.Errorw(ctx, "Failed to fetch Onu device for image commitment", log.Fields{"device-id": dh.DeviceID, "err": getErr})
+			return nil, fmt.Errorf("could not fetch device for device-id: %s", dh.DeviceID)
 		}
 		//  use the OnuVendor identification from this device for the internal unique name
 		imageIdentifier := onuVolthaDevice.VendorId + aVersion //head on vendor ID of the ONU
@@ -1301,11 +1252,11 @@
 		if err = dh.pOnuUpradeFsm.SetCommitmentParamsRunning(ctx, imageIdentifier, aVersion); err != nil {
 			//if some ONU upgrade is ongoing we do not accept some explicit different ONU image-version related commitment
 			logger.Errorw(ctx, "onu upgrade fsm did not accept commitment while running", log.Fields{
-				"device-id": dh.deviceID, "error": err})
-			return nil, fmt.Errorf("commitment not accepted for this version for device-id: %s", dh.deviceID)
+				"device-id": dh.DeviceID, "error": err})
+			return nil, fmt.Errorf("commitment not accepted for this version for device-id: %s", dh.DeviceID)
 		}
 		logger.Debugw(ctx, "image commitment acknowledged by onu upgrade processing", log.Fields{
-			"device-id": dh.deviceID, "image-id": imageIdentifier})
+			"device-id": dh.DeviceID, "image-id": imageIdentifier})
 		pImageStates := dh.pOnuUpradeFsm.GetImageStates(ctx, "", aVersion)
 		return pImageStates, nil
 	} //else
@@ -1315,24 +1266,24 @@
 	var activeImageID uint16
 	if activeImageID, err = pDevEntry.GetActiveImageMeID(ctx); err != nil || activeImageID > 1 {
 		logger.Errorw(ctx, "get active image failed", log.Fields{
-			"device-id": dh.deviceID, "err": err, "image-id": activeImageID})
-		return nil, fmt.Errorf("no valid active image found for device-id: %s", dh.deviceID)
+			"device-id": dh.DeviceID, "err": err, "image-id": activeImageID})
+		return nil, fmt.Errorf("no valid active image found for device-id: %s", dh.DeviceID)
 	}
-	err = dh.createOnuUpgradeFsm(ctx, pDevEntry, OmciOnuSwUpgradeDone)
+	err = dh.createOnuUpgradeFsm(ctx, pDevEntry, cmn.OmciOnuSwUpgradeDone)
 	if err == nil {
 		if err = dh.pOnuUpradeFsm.SetCommitmentParamsStart(ctx, aVersion, activeImageID); err != nil {
 			logger.Errorw(ctx, "onu upgrade fsm did not accept commitment to start", log.Fields{
-				"device-id": dh.deviceID, "error": err})
-			return nil, fmt.Errorf("commitment to start from scratch not accepted for device-id: %s", dh.deviceID)
+				"device-id": dh.DeviceID, "error": err})
+			return nil, fmt.Errorf("commitment to start from scratch not accepted for device-id: %s", dh.DeviceID)
 		}
 		logger.Debugw(ctx, "active image commitment acknowledged by onu upgrade", log.Fields{
-			"device-id": dh.deviceID, "image-version": aVersion})
+			"device-id": dh.DeviceID, "image-version": aVersion})
 		pImageStates := dh.pOnuUpradeFsm.GetImageStates(ctx, "", aVersion)
 		return pImageStates, nil
 	} //else
 	logger.Errorw(ctx, "onu upgrade fsm could not be created", log.Fields{
-		"device-id": dh.deviceID, "error": err})
-	return nil, fmt.Errorf("could not start upgradeFsm for device-id: %s", dh.deviceID)
+		"device-id": dh.DeviceID, "error": err})
+	return nil, fmt.Errorf("could not start upgradeFsm for device-id: %s", dh.DeviceID)
 }
 
 func (dh *deviceHandler) requestOnuSwUpgradeState(ctx context.Context, aImageIdentifier string,
@@ -1360,7 +1311,7 @@
 
 func (dh *deviceHandler) cancelOnuSwUpgrade(ctx context.Context, aImageIdentifier string,
 	aVersion string, pDeviceImageState *voltha.DeviceImageState) {
-	pDeviceImageState.DeviceId = dh.deviceID
+	pDeviceImageState.DeviceId = dh.DeviceID
 	pDeviceImageState.ImageState.Version = aVersion
 	dh.lockUpgradeFsm.RLock()
 	if dh.pOnuUpradeFsm != nil {
@@ -1395,23 +1346,23 @@
 
 func (dh *deviceHandler) getOnuImages(ctx context.Context) (*voltha.OnuImages, error) {
 
-	var onuImageStatus *OnuImageStatus
+	var onuImageStatus *swupg.OnuImageStatus
 
-	pDevEntry := dh.getOnuDeviceEntry(ctx, false)
+	pDevEntry := dh.GetOnuDeviceEntry(ctx, false)
 	if pDevEntry != nil {
-		onuImageStatus = NewOnuImageStatus(pDevEntry)
-		pDevEntry.mutexOnuImageStatus.Lock()
-		pDevEntry.pOnuImageStatus = onuImageStatus
-		pDevEntry.mutexOnuImageStatus.Unlock()
+		onuImageStatus = swupg.NewOnuImageStatus(dh, pDevEntry)
+		pDevEntry.MutexOnuImageStatus.Lock()
+		pDevEntry.POnuImageStatus = onuImageStatus
+		pDevEntry.MutexOnuImageStatus.Unlock()
 
 	} else {
-		logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
+		logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.DeviceID})
 		return nil, fmt.Errorf("no-valid-OnuDevice-aborting")
 	}
-	images, err := onuImageStatus.getOnuImageStatus(ctx)
-	pDevEntry.mutexOnuImageStatus.Lock()
-	pDevEntry.pOnuImageStatus = nil
-	pDevEntry.mutexOnuImageStatus.Unlock()
+	images, err := onuImageStatus.GetOnuImageStatus(ctx)
+	pDevEntry.MutexOnuImageStatus.Lock()
+	pDevEntry.POnuImageStatus = nil
+	pDevEntry.MutexOnuImageStatus.Unlock()
 	return images, err
 }
 
@@ -1422,7 +1373,7 @@
 // deviceHandler StateMachine related state transition methods ##### begin #########
 
 func (dh *deviceHandler) logStateChange(ctx context.Context, e *fsm.Event) {
-	logger.Debugw(ctx, "Device FSM: ", log.Fields{"event name": string(e.Event), "src state": string(e.Src), "dst state": string(e.Dst), "device-id": dh.deviceID})
+	logger.Debugw(ctx, "Device FSM: ", log.Fields{"event name": string(e.Event), "src state": string(e.Src), "dst state": string(e.Dst), "device-id": dh.DeviceID})
 }
 
 // doStateInit provides the device update to the core
@@ -1435,20 +1386,20 @@
 	dh.device.Root = false
 	dh.device.Vendor = "OpenONU"
 	dh.device.Model = "go"
-	dh.device.Reason = deviceReasonMap[drActivatingOnu]
-	dh.setDeviceReason(drActivatingOnu)
+	dh.device.Reason = cmn.DeviceReasonMap[cmn.DrActivatingOnu]
+	dh.SetDeviceReason(cmn.DrActivatingOnu)
 
-	dh.logicalDeviceID = dh.deviceID // really needed - what for ??? //TODO!!!
+	dh.logicalDeviceID = dh.DeviceID // really needed - what for ??? //TODO!!!
 
-	if !dh.isReconciling() {
-		logger.Infow(ctx, "DeviceUpdate", log.Fields{"deviceReason": dh.device.Reason, "device-id": dh.deviceID})
+	if !dh.IsReconciling() {
+		logger.Infow(ctx, "DeviceUpdate", log.Fields{"deviceReason": dh.device.Reason, "device-id": dh.DeviceID})
 		if err := dh.updateDeviceInCore(ctx, dh.device); err != nil {
 			logger.Errorw(ctx, "device-update-failed", log.Fields{"device-id": dh.device.Id, "error": err})
 		}
 		//TODO Need to Update Device Reason To CORE as part of device update userstory
 	} else {
 		logger.Debugw(ctx, "reconciling - don't notify core about DeviceUpdate",
-			log.Fields{"device-id": dh.deviceID})
+			log.Fields{"device-id": dh.DeviceID})
 	}
 
 	dh.parentID = dh.device.ParentId
@@ -1457,7 +1408,7 @@
 	// store proxy parameters for later communication - assumption: invariant, else they have to be requested dynamically!!
 	dh.ProxyAddressID = dh.device.ProxyAddress.GetDeviceId()
 	dh.ProxyAddressType = dh.device.ProxyAddress.GetDeviceType()
-	logger.Debugw(ctx, "device-updated", log.Fields{"device-id": dh.deviceID, "proxyAddressID": dh.ProxyAddressID,
+	logger.Debugw(ctx, "device-updated", log.Fields{"device-id": dh.DeviceID, "proxyAddressID": dh.ProxyAddressID,
 		"proxyAddressType": dh.ProxyAddressType, "SNR": dh.device.SerialNumber,
 		"ParentId": dh.parentID, "ParentPortNo": dh.ponPortNumber})
 
@@ -1470,15 +1421,15 @@
 				   oper_status=self._pon.get_port().oper_status,
 				   )
 	*/
-	if !dh.isReconciling() {
-		logger.Debugw(ctx, "adding-pon-port", log.Fields{"device-id": dh.deviceID, "ponPortNo": dh.ponPortNumber})
+	if !dh.IsReconciling() {
+		logger.Debugw(ctx, "adding-pon-port", log.Fields{"device-id": dh.DeviceID, "ponPortNo": dh.ponPortNumber})
 		var ponPortNo uint32 = 1
 		if dh.ponPortNumber != 0 {
 			ponPortNo = dh.ponPortNumber
 		}
 
 		pPonPort := &voltha.Port{
-			DeviceId:   dh.deviceID,
+			DeviceId:   dh.DeviceID,
 			PortNo:     ponPortNo,
 			Label:      fmt.Sprintf("pon-%d", ponPortNo),
 			Type:       voltha.Port_PON_ONU,
@@ -1486,13 +1437,13 @@
 			Peers: []*voltha.Port_PeerPort{{DeviceId: dh.parentID, // Peer device  is OLT
 				PortNo: ponPortNo}}, // Peer port is parent's port number
 		}
-		if err = dh.createPortInCore(ctx, pPonPort); err != nil {
+		if err = dh.CreatePortInCore(ctx, pPonPort); err != nil {
 			logger.Fatalf(ctx, "Device FSM: PortCreated-failed-%s", err)
 			e.Cancel(err)
 			return
 		}
 	} else {
-		logger.Debugw(ctx, "reconciling - pon-port already added", log.Fields{"device-id": dh.deviceID})
+		logger.Debugw(ctx, "reconciling - pon-port already added", log.Fields{"device-id": dh.DeviceID})
 	}
 	logger.Debug(ctx, "doStateInit-done")
 }
@@ -1513,7 +1464,7 @@
 		return
 	}
 
-	if dh.isReconciling() {
+	if dh.IsReconciling() {
 		go dh.reconcileDeviceOnuInd(ctx)
 		// reconcilement will be continued after mib download is done
 	}
@@ -1557,7 +1508,7 @@
 										   exclusive=False,
 										   **kwargs_omci_test_action)
 
-			self.enabled = True
+			self.Enabled = True
 		else:
 			self.logger.info('onu-already-activated')
 	*/
@@ -1605,7 +1556,7 @@
 	device := dh.device
 	if device == nil {
 		/*TODO: needs to handle error scenarios */
-		logger.Errorw(ctx, "Failed to fetch handler device", log.Fields{"device-id": dh.deviceID})
+		logger.Errorw(ctx, "Failed to fetch handler device", log.Fields{"device-id": dh.DeviceID})
 		e.Cancel(err)
 		return
 	}
@@ -1640,7 +1591,7 @@
 			// Update onu state as down in onu adapter
 			onuInd := oop.OnuIndication{}
 			onuInd.OperState = "down"
-			er := dh.AdapterProxy.SendInterAdapterMessage(ctx, &onuInd, ic.InterAdapterMessageType_ONU_IND_REQUEST,
+			er := dh.adapterProxy.SendInterAdapterMessage(ctx, &onuInd, ic.InterAdapterMessageType_ONU_IND_REQUEST,
 				"openolt", onuDevice.Type, onuDevice.Id, onuDevice.ProxyAddress.DeviceId, "")
 			if er != nil {
 				logger.Errorw("Failed to send inter-adapter-message", log.Fields{"OnuInd": onuInd,
@@ -1665,22 +1616,22 @@
 // ###################################################
 // deviceHandler utility methods ##### begin #########
 
-//getOnuDeviceEntry gets the ONU device entry and may wait until its value is defined
-func (dh *deviceHandler) getOnuDeviceEntry(ctx context.Context, aWait bool) *OnuDeviceEntry {
+//GetOnuDeviceEntry gets the ONU device entry and may wait until its value is defined
+func (dh *deviceHandler) GetOnuDeviceEntry(ctx context.Context, aWait bool) *mib.OnuDeviceEntry {
 	dh.lockDevice.RLock()
 	pOnuDeviceEntry := dh.pOnuOmciDevice
 	if aWait && pOnuDeviceEntry == nil {
 		//keep the read sema short to allow for subsequent write
 		dh.lockDevice.RUnlock()
-		logger.Debugw(ctx, "Waiting for DeviceEntry to be set ...", log.Fields{"device-id": dh.deviceID})
+		logger.Debugw(ctx, "Waiting for DeviceEntry to be set ...", log.Fields{"device-id": dh.DeviceID})
 		// based on concurrent processing the deviceEntry setup may not yet be finished at his point
 		// so it might be needed to wait here for that event with some timeout
 		select {
 		case <-time.After(60 * time.Second): //timer may be discussed ...
-			logger.Errorw(ctx, "No valid DeviceEntry set after maxTime", log.Fields{"device-id": dh.deviceID})
+			logger.Errorw(ctx, "No valid DeviceEntry set after maxTime", log.Fields{"device-id": dh.DeviceID})
 			return nil
 		case <-dh.deviceEntrySet:
-			logger.Debugw(ctx, "devicEntry ready now - continue", log.Fields{"device-id": dh.deviceID})
+			logger.Debugw(ctx, "devicEntry ready now - continue", log.Fields{"device-id": dh.DeviceID})
 			// if written now, we can return the written value without sema
 			return dh.pOnuOmciDevice
 		}
@@ -1689,9 +1640,9 @@
 	return pOnuDeviceEntry
 }
 
-//setOnuDeviceEntry sets the ONU device entry within the handler
-func (dh *deviceHandler) setOnuDeviceEntry(
-	apDeviceEntry *OnuDeviceEntry, apOnuTp *onuUniTechProf, apOnuMetricsMgr *onuMetricsManager, apOnuAlarmMgr *onuAlarmManager, apSelfTestHdlr *selfTestControlBlock) {
+//setDeviceHandlerEntries sets the ONU device entry within the handler
+func (dh *deviceHandler) setDeviceHandlerEntries(apDeviceEntry *mib.OnuDeviceEntry, apOnuTp *avcfg.OnuUniTechProf,
+	apOnuMetricsMgr *pmmgr.OnuMetricsManager, apOnuAlarmMgr *almgr.OnuAlarmManager, apSelfTestHdlr *otst.SelfTestControlBlock) {
 	dh.lockDevice.Lock()
 	defer dh.lockDevice.Unlock()
 	dh.pOnuOmciDevice = apDeviceEntry
@@ -1703,26 +1654,26 @@
 
 //addOnuDeviceEntry creates a new ONU device or returns the existing
 func (dh *deviceHandler) addOnuDeviceEntry(ctx context.Context) error {
-	logger.Debugw(ctx, "adding-deviceEntry", log.Fields{"device-id": dh.deviceID})
+	logger.Debugw(ctx, "adding-deviceEntry", log.Fields{"device-id": dh.DeviceID})
 
-	deviceEntry := dh.getOnuDeviceEntry(ctx, false)
+	deviceEntry := dh.GetOnuDeviceEntry(ctx, false)
 	if deviceEntry == nil {
 		/* costum_me_map in python code seems always to be None,
 		   we omit that here first (declaration unclear) -> todo at Adapter specialization ...*/
 		/* also no 'clock' argument - usage open ...*/
 		/* and no alarm_db yet (oo.alarm_db)  */
-		deviceEntry = newOnuDeviceEntry(ctx, dh)
-		onuTechProfProc := newOnuUniTechProf(ctx, dh)
-		onuMetricsMgr := newonuMetricsManager(ctx, dh)
-		onuAlarmManager := newAlarmManager(ctx, dh)
-		selfTestHdlr := newSelfTestMsgHandlerCb(ctx, dh)
+		deviceEntry = mib.NewOnuDeviceEntry(ctx, dh.coreClient, dh, dh.pOpenOnuAc)
+		onuTechProfProc := avcfg.NewOnuUniTechProf(ctx, dh, deviceEntry)
+		onuMetricsMgr := pmmgr.NewOnuMetricsManager(ctx, dh, deviceEntry)
+		onuAlarmManager := almgr.NewAlarmManager(ctx, dh, deviceEntry)
+		selfTestHdlr := otst.NewSelfTestMsgHandlerCb(ctx, dh, deviceEntry)
 		//error treatment possible //TODO!!!
-		dh.setOnuDeviceEntry(deviceEntry, onuTechProfProc, onuMetricsMgr, onuAlarmManager, selfTestHdlr)
+		dh.setDeviceHandlerEntries(deviceEntry, onuTechProfProc, onuMetricsMgr, onuAlarmManager, selfTestHdlr)
 		// fire deviceEntry ready event to spread to possibly waiting processing
 		dh.deviceEntrySet <- true
-		logger.Debugw(ctx, "onuDeviceEntry-added", log.Fields{"device-id": dh.deviceID})
+		logger.Debugw(ctx, "onuDeviceEntry-added", log.Fields{"device-id": dh.DeviceID})
 	} else {
-		logger.Debugw(ctx, "onuDeviceEntry-add: Device already exists", log.Fields{"device-id": dh.deviceID})
+		logger.Debugw(ctx, "onuDeviceEntry-add: Device already exists", log.Fields{"device-id": dh.DeviceID})
 	}
 	// might be updated with some error handling !!!
 	return nil
@@ -1734,45 +1685,45 @@
 
 	dh.pOnuIndication = onuind // let's revise if storing the pointer is sufficient...
 
-	pDevEntry := dh.getOnuDeviceEntry(ctx, true)
+	pDevEntry := dh.GetOnuDeviceEntry(ctx, true)
 	if pDevEntry == nil {
-		logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
-		return fmt.Errorf("no valid OnuDevice: %s", dh.deviceID)
+		logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.DeviceID})
+		return fmt.Errorf("no valid OnuDevice: %s", dh.DeviceID)
 	}
-	if !dh.isReconciling() {
-		if err := dh.storePersistentData(ctx); err != nil {
+	if !dh.IsReconciling() {
+		if err := dh.StorePersistentData(ctx); err != nil {
 			logger.Warnw(ctx, "store persistent data error - continue as there will be additional write attempts",
-				log.Fields{"device-id": dh.deviceID, "err": err})
+				log.Fields{"device-id": dh.DeviceID, "err": err})
 		}
 		logger.Debugw(ctx, "call DeviceStateUpdate upon create interface", log.Fields{"ConnectStatus": voltha.ConnectStatus_REACHABLE,
-			"OperStatus": voltha.OperStatus_ACTIVATING, "device-id": dh.deviceID})
+			"OperStatus": voltha.OperStatus_ACTIVATING, "device-id": dh.DeviceID})
 
 		if err := dh.updateDeviceStateInCore(ctx, &ic.DeviceStateFilter{
-			DeviceId:   dh.deviceID,
+			DeviceId:   dh.DeviceID,
 			OperStatus: voltha.OperStatus_ACTIVATING,
 			ConnStatus: voltha.ConnectStatus_REACHABLE,
 		}); err != nil {
 			//TODO with VOL-3045/VOL-3046: return the error and stop further processing
-			logger.Errorw(ctx, "error-updating-device-state", log.Fields{"device-id": dh.deviceID, "error": err})
+			logger.Errorw(ctx, "error-updating-device-state", log.Fields{"device-id": dh.DeviceID, "error": err})
 		}
 	} else {
 		logger.Debugw(ctx, "reconciling - don't notify core about DeviceStateUpdate to ACTIVATING",
-			log.Fields{"device-id": dh.deviceID})
+			log.Fields{"device-id": dh.DeviceID})
 
-		pDevEntry.mutexPersOnuConfig.RLock()
-		if !pDevEntry.sOnuPersistentData.PersUniUnlockDone {
-			pDevEntry.mutexPersOnuConfig.RUnlock()
+		pDevEntry.MutexPersOnuConfig.RLock()
+		if !pDevEntry.SOnuPersistentData.PersUniUnlockDone {
+			pDevEntry.MutexPersOnuConfig.RUnlock()
 			logger.Debugw(ctx, "reconciling - uni-ports were not unlocked before adapter restart - resume with a normal start-up",
-				log.Fields{"device-id": dh.deviceID})
-			dh.stopReconciling(ctx, true)
+				log.Fields{"device-id": dh.DeviceID})
+			dh.StopReconciling(ctx, true)
 		} else {
-			pDevEntry.mutexPersOnuConfig.RUnlock()
+			pDevEntry.MutexPersOnuConfig.RUnlock()
 		}
 	}
 	// It does not look to me as if makes sense to work with the real core device here, (not the stored clone)?
 	// in this code the GetDevice would just make a check if the DeviceID's Device still exists in core
 	// in python code it looks as the started onu_omci_device might have been updated with some new instance state of the core device
-	// but I would not know why, and the go code anyway does not work with the device directly anymore in the OnuDeviceEntry
+	// but I would not know why, and the go code anyway does not work with the device directly anymore in the mib.OnuDeviceEntry
 	// so let's just try to keep it simple ...
 	/*
 			device, err := dh.coreProxy.GetDevice(log.WithSpanFromContext(context.TODO(), ctx), dh.device.Id, dh.device.Id)
@@ -1783,18 +1734,18 @@
 			}
 	*/
 
-	if err := pDevEntry.start(log.WithSpanFromContext(context.TODO(), ctx)); err != nil {
+	if err := pDevEntry.Start(log.WithSpanFromContext(context.TODO(), ctx)); err != nil {
 		return err
 	}
 
-	_ = dh.deviceReasonUpdate(ctx, drStartingOpenomci, !dh.isReconciling())
+	_ = dh.deviceReasonUpdate(ctx, cmn.DrStartingOpenomci, !dh.IsReconciling())
 
 	/* this might be a good time for Omci Verify message?  */
 	verifyExec := make(chan bool)
-	omciVerify := newOmciTestRequest(log.WithSpanFromContext(context.TODO(), ctx),
+	omciVerify := otst.NewOmciTestRequest(log.WithSpanFromContext(context.TODO(), ctx),
 		dh.device.Id, pDevEntry.PDevOmciCC,
 		true, true) //exclusive and allowFailure (anyway not yet checked)
-	omciVerify.performOmciTest(log.WithSpanFromContext(context.TODO(), ctx), verifyExec)
+	omciVerify.PerformOmciTest(log.WithSpanFromContext(context.TODO(), ctx), verifyExec)
 
 	/* 	give the handler some time here to wait for the OMCi verification result
 	after Timeout start and try MibUpload FSM anyway
@@ -1877,44 +1828,44 @@
 	*/
 
 	// PM related heartbeat??? !!!TODO....
-	//self._heartbeat.enabled = True
+	//self._heartbeat.Enabled = True
 
 	/* Note: Even though FSM calls look 'synchronous' here, FSM is running in background with the effect that possible errors
 	 * 	 within the MibUpload are not notified in the OnuIndication response, this might be acceptable here,
 	 *   as further OltAdapter processing may rely on the deviceReason event 'MibUploadDone' as a result of the FSM processing
 	 *   otherwise some processing synchronization would be required - cmp. e.g TechProfile processing
 	 */
-	//call MibUploadFSM - transition up to state ulStInSync
-	pMibUlFsm := pDevEntry.pMibUploadFsm.pFsm
+	//call MibUploadFSM - transition up to state UlStInSync
+	pMibUlFsm := pDevEntry.PMibUploadFsm.PFsm
 	if pMibUlFsm != nil {
-		if pMibUlFsm.Is(ulStDisabled) {
-			if err := pMibUlFsm.Event(ulEvStart); err != nil {
-				logger.Errorw(ctx, "MibSyncFsm: Can't go to state starting", log.Fields{"device-id": dh.deviceID, "err": err})
-				return fmt.Errorf("can't go to state starting: %s", dh.deviceID)
+		if pMibUlFsm.Is(mib.UlStDisabled) {
+			if err := pMibUlFsm.Event(mib.UlEvStart); err != nil {
+				logger.Errorw(ctx, "MibSyncFsm: Can't go to state starting", log.Fields{"device-id": dh.DeviceID, "err": err})
+				return fmt.Errorf("can't go to state starting: %s", dh.DeviceID)
 			}
 			logger.Debugw(ctx, "MibSyncFsm", log.Fields{"state": string(pMibUlFsm.Current())})
 			//Determine ONU status and start/re-start MIB Synchronization tasks
 			//Determine if this ONU has ever synchronized
-			if pDevEntry.isNewOnu() {
-				if err := pMibUlFsm.Event(ulEvResetMib); err != nil {
-					logger.Errorw(ctx, "MibSyncFsm: Can't go to state resetting_mib", log.Fields{"device-id": dh.deviceID, "err": err})
-					return fmt.Errorf("can't go to state resetting_mib: %s", dh.deviceID)
+			if pDevEntry.IsNewOnu() {
+				if err := pMibUlFsm.Event(mib.UlEvResetMib); err != nil {
+					logger.Errorw(ctx, "MibSyncFsm: Can't go to state resetting_mib", log.Fields{"device-id": dh.DeviceID, "err": err})
+					return fmt.Errorf("can't go to state resetting_mib: %s", dh.DeviceID)
 				}
 			} else {
-				if err := pMibUlFsm.Event(ulEvExamineMds); err != nil {
-					logger.Errorw(ctx, "MibSyncFsm: Can't go to state examine_mds", log.Fields{"device-id": dh.deviceID, "err": err})
-					return fmt.Errorf("can't go to examine_mds: %s", dh.deviceID)
+				if err := pMibUlFsm.Event(mib.UlEvExamineMds); err != nil {
+					logger.Errorw(ctx, "MibSyncFsm: Can't go to state examine_mds", log.Fields{"device-id": dh.DeviceID, "err": err})
+					return fmt.Errorf("can't go to examine_mds: %s", dh.DeviceID)
 				}
 				logger.Debugw(ctx, "state of MibSyncFsm", log.Fields{"state": string(pMibUlFsm.Current())})
 			}
 		} else {
 			logger.Errorw(ctx, "wrong state of MibSyncFsm - want: disabled", log.Fields{"have": string(pMibUlFsm.Current()),
-				"device-id": dh.deviceID})
-			return fmt.Errorf("wrong state of MibSyncFsm: %s", dh.deviceID)
+				"device-id": dh.DeviceID})
+			return fmt.Errorf("wrong state of MibSyncFsm: %s", dh.DeviceID)
 		}
 	} else {
-		logger.Errorw(ctx, "MibSyncFsm invalid - cannot be executed!!", log.Fields{"device-id": dh.deviceID})
-		return fmt.Errorf("can't execute MibSync: %s", dh.deviceID)
+		logger.Errorw(ctx, "MibSyncFsm invalid - cannot be executed!!", log.Fields{"device-id": dh.DeviceID})
+		return fmt.Errorf("can't execute MibSync: %s", dh.DeviceID)
 	}
 	return nil
 }
@@ -1922,15 +1873,15 @@
 func (dh *deviceHandler) updateInterface(ctx context.Context, onuind *oop.OnuIndication) error {
 	//state checking to prevent unneeded processing (eg. on ONU 'unreachable' and 'down')
 	// (but note that the deviceReason may also have changed to e.g. TechProf*Delete_Success in between)
-	if dh.getDeviceReason() != drStoppingOpenomci {
-		logger.Debugw(ctx, "updateInterface-started - stopping-device", log.Fields{"device-id": dh.deviceID})
+	if dh.getDeviceReason() != cmn.DrStoppingOpenomci {
+		logger.Debugw(ctx, "updateInterface-started - stopping-device", log.Fields{"device-id": dh.DeviceID})
 
 		//stop all running FSM processing - make use of the DH-state as mirrored in the deviceReason
 		//here no conflict with aborted FSM's should arise as a complete OMCI initialization is assumed on ONU-Up
 		//but that might change with some simple MDS check on ONU-Up treatment -> attention!!!
 		if err := dh.resetFsms(ctx, true); err != nil {
 			logger.Errorw(ctx, "error-updateInterface at FSM stop",
-				log.Fields{"device-id": dh.deviceID, "error": err})
+				log.Fields{"device-id": dh.DeviceID, "error": err})
 			// abort: system behavior is just unstable ...
 			return err
 		}
@@ -1940,12 +1891,12 @@
 		//deviceEntry stop without omciCC reset here, regarding the OMCI_CC still valid for this ONU
 		// - in contrary to disableDevice - compare with processUniDisableStateDoneEvent
 		//stop the device entry which resets the attached omciCC
-		pDevEntry := dh.getOnuDeviceEntry(ctx, false)
+		pDevEntry := dh.GetOnuDeviceEntry(ctx, false)
 		if pDevEntry == nil {
-			logger.Errorw(ctx, "No valid OnuDevice -aborting", log.Fields{"device-id": dh.deviceID})
-			return fmt.Errorf("no valid OnuDevice: %s", dh.deviceID)
+			logger.Errorw(ctx, "No valid OnuDevice -aborting", log.Fields{"device-id": dh.DeviceID})
+			return fmt.Errorf("no valid OnuDevice: %s", dh.DeviceID)
 		}
-		_ = pDevEntry.stop(log.WithSpanFromContext(context.TODO(), ctx), false)
+		_ = pDevEntry.Stop(log.WithSpanFromContext(context.TODO(), ctx), false)
 
 		//TODO!!! remove existing traffic profiles
 		/* from py code, if TP's exist, remove them - not yet implemented
@@ -1957,29 +1908,29 @@
 			self._tech_profile_download_done[uni_id].clear()
 		*/
 
-		dh.disableUniPortStateUpdate(ctx)
+		dh.DisableUniPortStateUpdate(ctx)
 
-		dh.setReadyForOmciConfig(false)
+		dh.SetReadyForOmciConfig(false)
 
-		if err := dh.deviceReasonUpdate(ctx, drStoppingOpenomci, true); err != nil {
+		if err := dh.deviceReasonUpdate(ctx, cmn.DrStoppingOpenomci, true); err != nil {
 			// abort: system behavior is just unstable ...
 			return err
 		}
 		logger.Debugw(ctx, "call DeviceStateUpdate upon update interface", log.Fields{"ConnectStatus": voltha.ConnectStatus_UNREACHABLE,
-			"OperStatus": voltha.OperStatus_DISCOVERED, "device-id": dh.deviceID})
+			"OperStatus": voltha.OperStatus_DISCOVERED, "device-id": dh.DeviceID})
 		if err := dh.updateDeviceStateInCore(ctx, &ic.DeviceStateFilter{
-			DeviceId:   dh.deviceID,
+			DeviceId:   dh.DeviceID,
 			ConnStatus: voltha.ConnectStatus_UNREACHABLE,
 			OperStatus: voltha.OperStatus_DISCOVERED,
 		}); err != nil {
 			//TODO with VOL-3045/VOL-3046: return the error and stop further processing
 			logger.Errorw(ctx, "error-updating-device-state unreachable-discovered",
-				log.Fields{"device-id": dh.deviceID, "error": err})
+				log.Fields{"device-id": dh.DeviceID, "error": err})
 			// abort: system behavior is just unstable ...
 			return err
 		}
 	} else {
-		logger.Debugw(ctx, "updateInterface - device already stopped", log.Fields{"device-id": dh.deviceID})
+		logger.Debugw(ctx, "updateInterface - device already stopped", log.Fields{"device-id": dh.DeviceID})
 	}
 	return nil
 }
@@ -1990,48 +1941,48 @@
 	//  as after down/up procedures all FSM's might be active/ongoing (in theory)
 	//  and using the stop/reset event should never harm
 
-	pDevEntry := dh.getOnuDeviceEntry(ctx, false)
+	pDevEntry := dh.GetOnuDeviceEntry(ctx, false)
 	if pDevEntry == nil {
-		logger.Errorw(ctx, "No valid OnuDevice -aborting", log.Fields{"device-id": dh.deviceID})
-		return fmt.Errorf("no valid OnuDevice: %s", dh.deviceID)
+		logger.Errorw(ctx, "No valid OnuDevice -aborting", log.Fields{"device-id": dh.DeviceID})
+		return fmt.Errorf("no valid OnuDevice: %s", dh.DeviceID)
 	}
 	if pDevEntry.PDevOmciCC != nil {
 		pDevEntry.PDevOmciCC.CancelRequestMonitoring(ctx)
 	}
-	pDevEntry.mutexOnuImageStatus.RLock()
-	if pDevEntry.pOnuImageStatus != nil {
-		pDevEntry.pOnuImageStatus.CancelProcessing(ctx)
+	pDevEntry.MutexOnuImageStatus.RLock()
+	if pDevEntry.POnuImageStatus != nil {
+		pDevEntry.POnuImageStatus.CancelProcessing(ctx)
 	}
-	pDevEntry.mutexOnuImageStatus.RUnlock()
+	pDevEntry.MutexOnuImageStatus.RUnlock()
 
 	if includingMibSyncFsm {
 		pDevEntry.CancelProcessing(ctx)
 	}
 	//MibDownload may run
-	pMibDlFsm := pDevEntry.pMibDownloadFsm.pFsm
+	pMibDlFsm := pDevEntry.PMibDownloadFsm.PFsm
 	if pMibDlFsm != nil {
-		_ = pMibDlFsm.Event(dlEvReset)
+		_ = pMibDlFsm.Event(mib.DlEvReset)
 	}
 	//port lock/unlock FSM's may be active
 	if dh.pUnlockStateFsm != nil {
-		_ = dh.pUnlockStateFsm.pAdaptFsm.pFsm.Event(uniEvReset)
+		_ = dh.pUnlockStateFsm.PAdaptFsm.PFsm.Event(uniprt.UniEvReset)
 	}
 	if dh.pLockStateFsm != nil {
-		_ = dh.pLockStateFsm.pAdaptFsm.pFsm.Event(uniEvReset)
+		_ = dh.pLockStateFsm.PAdaptFsm.PFsm.Event(uniprt.UniEvReset)
 	}
 	//techProfile related PonAniConfigFsm FSM may be active
 	if dh.pOnuTP != nil {
 		// should always be the case here
 		// FSM  stop maybe encapsulated as OnuTP method - perhaps later in context of module splitting
-		if dh.pOnuTP.pAniConfigFsm != nil {
-			for uniTP := range dh.pOnuTP.pAniConfigFsm {
-				dh.pOnuTP.pAniConfigFsm[uniTP].CancelProcessing(ctx)
+		if dh.pOnuTP.PAniConfigFsm != nil {
+			for uniTP := range dh.pOnuTP.PAniConfigFsm {
+				dh.pOnuTP.PAniConfigFsm[uniTP].CancelProcessing(ctx)
 			}
 		}
 		for _, uniPort := range dh.uniEntityMap {
 			// reset the possibly existing VlanConfigFsm
 			dh.lockVlanConfig.RLock()
-			if pVlanFilterFsm, exist := dh.UniVlanConfigFsmMap[uniPort.uniID]; exist {
+			if pVlanFilterFsm, exist := dh.UniVlanConfigFsmMap[uniPort.UniID]; exist {
 				//VlanFilterFsm exists and was already started
 				dh.lockVlanConfig.RUnlock()
 				//reset of all Fsm is always accompanied by global persistency data removal
@@ -2044,41 +1995,41 @@
 			}
 		}
 	}
-	if dh.getCollectorIsRunning() {
+	if dh.GetCollectorIsRunning() {
 		// Stop collector routine
 		dh.stopCollector <- true
 	}
-	if dh.getAlarmManagerIsRunning(ctx) {
+	if dh.GetAlarmManagerIsRunning(ctx) {
 		dh.stopAlarmManager <- true
 	}
 	if dh.pSelfTestHdlr.GetSelfTestHandlerIsRunning() {
-		dh.pSelfTestHdlr.stopSelfTestModule <- true
+		dh.pSelfTestHdlr.StopSelfTestModule <- true
 	}
 
 	//reset a possibly running upgrade FSM
-	//  (note the Upgrade FSM may stay alive e.g. in state upgradeStWaitForCommit to endure the ONU reboot)
+	//  (note the Upgrade FSM may stay alive e.g. in state UpgradeStWaitForCommit to endure the ONU reboot)
 	dh.lockUpgradeFsm.RLock()
 	lopOnuUpradeFsm := dh.pOnuUpradeFsm
-	//lockUpgradeFsm must be release before cancellation as this may implicitly request removeOnuUpgradeFsm()
+	//lockUpgradeFsm must be release before cancellation as this may implicitly request RemoveOnuUpgradeFsm()
 	dh.lockUpgradeFsm.RUnlock()
 	if lopOnuUpradeFsm != nil {
 		lopOnuUpradeFsm.CancelProcessing(ctx, false, voltha.ImageState_CANCELLED_ON_ONU_STATE) //conditional cancel
 	}
 
-	logger.Infow(ctx, "resetFsms done", log.Fields{"device-id": dh.deviceID})
+	logger.Infow(ctx, "resetFsms done", log.Fields{"device-id": dh.DeviceID})
 	return nil
 }
 
-func (dh *deviceHandler) processMibDatabaseSyncEvent(ctx context.Context, devEvent OnuDeviceEvent) {
-	logger.Debugw(ctx, "MibInSync event received, adding uni ports and locking the ONU interfaces", log.Fields{"device-id": dh.deviceID})
+func (dh *deviceHandler) processMibDatabaseSyncEvent(ctx context.Context, devEvent cmn.OnuDeviceEvent) {
+	logger.Debugw(ctx, "MibInSync event received, adding uni ports and locking the ONU interfaces", log.Fields{"device-id": dh.DeviceID})
 
 	// store persistent data collected during MIB upload processing
-	if err := dh.storePersistentData(ctx); err != nil {
+	if err := dh.StorePersistentData(ctx); err != nil {
 		logger.Warnw(ctx, "store persistent data error - continue as there will be additional write attempts",
-			log.Fields{"device-id": dh.deviceID, "err": err})
+			log.Fields{"device-id": dh.DeviceID, "err": err})
 	}
-	_ = dh.deviceReasonUpdate(ctx, drDiscoveryMibsyncComplete, !dh.isReconciling())
-	dh.addAllUniPorts(ctx)
+	_ = dh.deviceReasonUpdate(ctx, cmn.DrDiscoveryMibsyncComplete, !dh.IsReconciling())
+	dh.AddAllUniPorts(ctx)
 
 	/* 200605: lock processing after initial MIBUpload removed now as the ONU should be in the lock state per default here */
 	/* 201117: build_dt-berlin-pod-openonugo_1T8GEM_voltha_DT_openonugo_master_test runs into error TC
@@ -2093,34 +2044,34 @@
 	// Init Uni Ports to Admin locked state
 	// *** should generate UniLockStateDone event *****
 	if dh.pLockStateFsm == nil {
-		dh.createUniLockFsm(ctx, true, UniLockStateDone)
+		dh.createUniLockFsm(ctx, true, cmn.UniLockStateDone)
 	} else { //LockStateFSM already init
-		dh.pLockStateFsm.setSuccessEvent(UniLockStateDone)
+		dh.pLockStateFsm.SetSuccessEvent(cmn.UniLockStateDone)
 		dh.runUniLockFsm(ctx, true)
 	}
 }
 
-func (dh *deviceHandler) processUniLockStateDoneEvent(ctx context.Context, devEvent OnuDeviceEvent) {
-	logger.Infow(ctx, "UniLockStateDone event: Starting MIB download", log.Fields{"device-id": dh.deviceID})
+func (dh *deviceHandler) processUniLockStateDoneEvent(ctx context.Context, devEvent cmn.OnuDeviceEvent) {
+	logger.Infow(ctx, "UniLockStateDone event: Starting MIB download", log.Fields{"device-id": dh.DeviceID})
 	/*  Mib download procedure -
 	***** should run over 'downloaded' state and generate MibDownloadDone event *****
 	 */
-	pDevEntry := dh.getOnuDeviceEntry(ctx, false)
+	pDevEntry := dh.GetOnuDeviceEntry(ctx, false)
 	if pDevEntry == nil {
-		logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
+		logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.DeviceID})
 		return
 	}
-	pMibDlFsm := pDevEntry.pMibDownloadFsm.pFsm
+	pMibDlFsm := pDevEntry.PMibDownloadFsm.PFsm
 	if pMibDlFsm != nil {
-		if pMibDlFsm.Is(dlStDisabled) {
-			if err := pMibDlFsm.Event(dlEvStart); err != nil {
-				logger.Errorw(ctx, "MibDownloadFsm: Can't go to state starting", log.Fields{"device-id": dh.deviceID, "err": err})
+		if pMibDlFsm.Is(mib.DlStDisabled) {
+			if err := pMibDlFsm.Event(mib.DlEvStart); err != nil {
+				logger.Errorw(ctx, "MibDownloadFsm: Can't go to state starting", log.Fields{"device-id": dh.DeviceID, "err": err})
 				// maybe try a FSM reset and then again ... - TODO!!!
 			} else {
 				logger.Debugw(ctx, "MibDownloadFsm", log.Fields{"state": string(pMibDlFsm.Current())})
 				// maybe use more specific states here for the specific download steps ...
-				if err := pMibDlFsm.Event(dlEvCreateGal); err != nil {
-					logger.Errorw(ctx, "MibDownloadFsm: Can't start CreateGal", log.Fields{"device-id": dh.deviceID, "err": err})
+				if err := pMibDlFsm.Event(mib.DlEvCreateGal); err != nil {
+					logger.Errorw(ctx, "MibDownloadFsm: Can't start CreateGal", log.Fields{"device-id": dh.DeviceID, "err": err})
 				} else {
 					logger.Debugw(ctx, "state of MibDownloadFsm", log.Fields{"state": string(pMibDlFsm.Current())})
 					//Begin MIB data download (running autonomously)
@@ -2128,349 +2079,349 @@
 			}
 		} else {
 			logger.Errorw(ctx, "wrong state of MibDownloadFsm - want: disabled", log.Fields{"have": string(pMibDlFsm.Current()),
-				"device-id": dh.deviceID})
+				"device-id": dh.DeviceID})
 			// maybe try a FSM reset and then again ... - TODO!!!
 		}
 		/***** Mib download started */
 	} else {
-		logger.Errorw(ctx, "MibDownloadFsm invalid - cannot be executed!!", log.Fields{"device-id": dh.deviceID})
+		logger.Errorw(ctx, "MibDownloadFsm invalid - cannot be executed!!", log.Fields{"device-id": dh.DeviceID})
 	}
 }
 
-func (dh *deviceHandler) processMibDownloadDoneEvent(ctx context.Context, devEvent OnuDeviceEvent) {
-	logger.Debugw(ctx, "MibDownloadDone event received, unlocking the ONU interfaces", log.Fields{"device-id": dh.deviceID})
+func (dh *deviceHandler) processMibDownloadDoneEvent(ctx context.Context, devEvent cmn.OnuDeviceEvent) {
+	logger.Debugw(ctx, "MibDownloadDone event received, unlocking the ONU interfaces", log.Fields{"device-id": dh.DeviceID})
 	//initiate DevStateUpdate
-	if !dh.isReconciling() {
+	if !dh.IsReconciling() {
 		logger.Debugw(ctx, "call DeviceStateUpdate upon mib-download done", log.Fields{"ConnectStatus": voltha.ConnectStatus_REACHABLE,
-			"OperStatus": voltha.OperStatus_ACTIVE, "device-id": dh.deviceID})
+			"OperStatus": voltha.OperStatus_ACTIVE, "device-id": dh.DeviceID})
 		//we allow a possible OnuSw image commit only in the normal startup, not at reconciling
 		// in case of adapter restart connected to an ONU upgrade I would not rely on the image quality
 		// maybe some 'forced' commitment can be done in this situation from system management (or upgrade restarted)
 		dh.checkOnOnuImageCommit(ctx)
 		if err := dh.updateDeviceStateInCore(ctx, &ic.DeviceStateFilter{
-			DeviceId:   dh.deviceID,
+			DeviceId:   dh.DeviceID,
 			ConnStatus: voltha.ConnectStatus_REACHABLE,
 			OperStatus: voltha.OperStatus_ACTIVE,
 		}); err != nil {
 			//TODO with VOL-3045/VOL-3046: return the error and stop further processing
-			logger.Errorw(ctx, "error-updating-device-state", log.Fields{"device-id": dh.deviceID, "error": err})
+			logger.Errorw(ctx, "error-updating-device-state", log.Fields{"device-id": dh.DeviceID, "error": err})
 		} else {
-			logger.Debugw(ctx, "dev state updated to 'Oper.Active'", log.Fields{"device-id": dh.deviceID})
+			logger.Debugw(ctx, "dev state updated to 'Oper.Active'", log.Fields{"device-id": dh.DeviceID})
 		}
 	} else {
 		logger.Debugw(ctx, "reconciling - don't notify core about DeviceStateUpdate to ACTIVE",
-			log.Fields{"device-id": dh.deviceID})
+			log.Fields{"device-id": dh.DeviceID})
 	}
-	_ = dh.deviceReasonUpdate(ctx, drInitialMibDownloaded, !dh.isReconciling())
+	_ = dh.deviceReasonUpdate(ctx, cmn.DrInitialMibDownloaded, !dh.IsReconciling())
 
-	if !dh.getCollectorIsRunning() {
+	if !dh.GetCollectorIsRunning() {
 		// Start PM collector routine
-		go dh.startCollector(ctx)
+		go dh.StartCollector(ctx)
 	}
-	if !dh.getAlarmManagerIsRunning(ctx) {
-		go dh.startAlarmManager(ctx)
+	if !dh.GetAlarmManagerIsRunning(ctx) {
+		go dh.StartAlarmManager(ctx)
 	}
 
 	// Initialize classical L2 PM Interval Counters
-	if err := dh.pOnuMetricsMgr.pAdaptFsm.pFsm.Event(l2PmEventInit); err != nil {
+	if err := dh.pOnuMetricsMgr.PAdaptFsm.PFsm.Event(pmmgr.L2PmEventInit); err != nil {
 		// There is no way we should be landing here, but if we do then
 		// there is nothing much we can do about this other than log error
 		logger.Errorw(ctx, "error starting l2 pm fsm", log.Fields{"device-id": dh.device.Id, "err": err})
 	}
 
-	dh.setReadyForOmciConfig(true)
+	dh.SetReadyForOmciConfig(true)
 
-	pDevEntry := dh.getOnuDeviceEntry(ctx, false)
+	pDevEntry := dh.GetOnuDeviceEntry(ctx, false)
 	if pDevEntry == nil {
-		logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
+		logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.DeviceID})
 		return
 	}
-	pDevEntry.mutexPersOnuConfig.RLock()
-	if dh.isReconciling() && pDevEntry.sOnuPersistentData.PersUniDisableDone {
-		pDevEntry.mutexPersOnuConfig.RUnlock()
+	pDevEntry.MutexPersOnuConfig.RLock()
+	if dh.IsReconciling() && pDevEntry.SOnuPersistentData.PersUniDisableDone {
+		pDevEntry.MutexPersOnuConfig.RUnlock()
 		logger.Debugw(ctx, "reconciling - uni-ports were disabled by admin before adapter restart - keep the ports locked",
-			log.Fields{"device-id": dh.deviceID})
-		go dh.reconcileDeviceTechProf(ctx)
+			log.Fields{"device-id": dh.DeviceID})
+		go dh.ReconcileDeviceTechProf(ctx)
 		// reconcilement will be continued after ani config is done
 	} else {
-		pDevEntry.mutexPersOnuConfig.RUnlock()
+		pDevEntry.MutexPersOnuConfig.RUnlock()
 		// *** should generate UniUnlockStateDone event *****
 		if dh.pUnlockStateFsm == nil {
-			dh.createUniLockFsm(ctx, false, UniUnlockStateDone)
+			dh.createUniLockFsm(ctx, false, cmn.UniUnlockStateDone)
 		} else { //UnlockStateFSM already init
-			dh.pUnlockStateFsm.setSuccessEvent(UniUnlockStateDone)
+			dh.pUnlockStateFsm.SetSuccessEvent(cmn.UniUnlockStateDone)
 			dh.runUniLockFsm(ctx, false)
 		}
 	}
 }
 
-func (dh *deviceHandler) processUniUnlockStateDoneEvent(ctx context.Context, devEvent OnuDeviceEvent) {
-	dh.enableUniPortStateUpdate(ctx) //cmp python yield self.enable_ports()
+func (dh *deviceHandler) processUniUnlockStateDoneEvent(ctx context.Context, devEvent cmn.OnuDeviceEvent) {
+	dh.EnableUniPortStateUpdate(ctx) //cmp python yield self.enable_ports()
 
-	if !dh.isReconciling() {
-		logger.Infow(ctx, "UniUnlockStateDone event: Sending OnuUp event", log.Fields{"device-id": dh.deviceID})
+	if !dh.IsReconciling() {
+		logger.Infow(ctx, "UniUnlockStateDone event: Sending OnuUp event", log.Fields{"device-id": dh.DeviceID})
 		raisedTs := time.Now().Unix()
-		go dh.sendOnuOperStateEvent(ctx, voltha.OperStatus_ACTIVE, dh.deviceID, raisedTs) //cmp python onu_active_event
-		pDevEntry := dh.getOnuDeviceEntry(ctx, false)
+		go dh.sendOnuOperStateEvent(ctx, voltha.OperStatus_ACTIVE, dh.DeviceID, raisedTs) //cmp python onu_active_event
+		pDevEntry := dh.GetOnuDeviceEntry(ctx, false)
 		if pDevEntry == nil {
-			logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
+			logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.DeviceID})
 			return
 		}
-		pDevEntry.mutexPersOnuConfig.Lock()
-		pDevEntry.sOnuPersistentData.PersUniUnlockDone = true
-		pDevEntry.mutexPersOnuConfig.Unlock()
-		if err := dh.storePersistentData(ctx); err != nil {
+		pDevEntry.MutexPersOnuConfig.Lock()
+		pDevEntry.SOnuPersistentData.PersUniUnlockDone = true
+		pDevEntry.MutexPersOnuConfig.Unlock()
+		if err := dh.StorePersistentData(ctx); err != nil {
 			logger.Warnw(ctx, "store persistent data error - continue for now as there will be additional write attempts",
-				log.Fields{"device-id": dh.deviceID, "err": err})
+				log.Fields{"device-id": dh.DeviceID, "err": err})
 		}
 	} else {
 		logger.Debugw(ctx, "reconciling - don't notify core that onu went to active but trigger tech profile config",
-			log.Fields{"device-id": dh.deviceID})
-		go dh.reconcileDeviceTechProf(ctx)
+			log.Fields{"device-id": dh.DeviceID})
+		go dh.ReconcileDeviceTechProf(ctx)
 		// reconcilement will be continued after ani config is done
 	}
 }
 
-func (dh *deviceHandler) processUniDisableStateDoneEvent(ctx context.Context, devEvent OnuDeviceEvent) {
+func (dh *deviceHandler) processUniDisableStateDoneEvent(ctx context.Context, devEvent cmn.OnuDeviceEvent) {
 	logger.Debugw(ctx, "DeviceStateUpdate upon disable", log.Fields{"ConnectStatus": voltha.ConnectStatus_REACHABLE,
-		"OperStatus": voltha.OperStatus_UNKNOWN, "device-id": dh.deviceID})
+		"OperStatus": voltha.OperStatus_UNKNOWN, "device-id": dh.DeviceID})
 
 	if err := dh.updateDeviceStateInCore(ctx, &ic.DeviceStateFilter{
-		DeviceId:   dh.deviceID,
+		DeviceId:   dh.DeviceID,
 		ConnStatus: voltha.ConnectStatus_REACHABLE,
 		OperStatus: voltha.OperStatus_UNKNOWN,
 	}); err != nil {
 		//TODO with VOL-3045/VOL-3046: return the error and stop further processing
-		logger.Errorw(ctx, "error-updating-device-state", log.Fields{"device-id": dh.deviceID, "error": err})
+		logger.Errorw(ctx, "error-updating-device-state", log.Fields{"device-id": dh.DeviceID, "error": err})
 	}
 
-	logger.Debugw(ctx, "DeviceReasonUpdate upon disable", log.Fields{"reason": deviceReasonMap[drOmciAdminLock], "device-id": dh.deviceID})
+	logger.Debugw(ctx, "DeviceReasonUpdate upon disable", log.Fields{"reason": cmn.DeviceReasonMap[cmn.DrOmciAdminLock], "device-id": dh.DeviceID})
 	// DeviceReason to update acc.to modified py code as per beginning of Sept 2020
-	_ = dh.deviceReasonUpdate(ctx, drOmciAdminLock, true)
+	_ = dh.deviceReasonUpdate(ctx, cmn.DrOmciAdminLock, true)
 
 	//transfer the modified logical uni port state
-	dh.disableUniPortStateUpdate(ctx)
+	dh.DisableUniPortStateUpdate(ctx)
 
-	pDevEntry := dh.getOnuDeviceEntry(ctx, false)
+	pDevEntry := dh.GetOnuDeviceEntry(ctx, false)
 	if pDevEntry == nil {
-		logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
+		logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.DeviceID})
 		return
 	}
-	pDevEntry.mutexPersOnuConfig.Lock()
-	pDevEntry.sOnuPersistentData.PersUniDisableDone = true
-	pDevEntry.mutexPersOnuConfig.Unlock()
-	if err := dh.storePersistentData(ctx); err != nil {
+	pDevEntry.MutexPersOnuConfig.Lock()
+	pDevEntry.SOnuPersistentData.PersUniDisableDone = true
+	pDevEntry.MutexPersOnuConfig.Unlock()
+	if err := dh.StorePersistentData(ctx); err != nil {
 		logger.Warnw(ctx, "store persistent data error - continue for now as there will be additional write attempts",
-			log.Fields{"device-id": dh.deviceID, "err": err})
+			log.Fields{"device-id": dh.DeviceID, "err": err})
 	}
 }
 
-func (dh *deviceHandler) processUniEnableStateDoneEvent(ctx context.Context, devEvent OnuDeviceEvent) {
+func (dh *deviceHandler) processUniEnableStateDoneEvent(ctx context.Context, devEvent cmn.OnuDeviceEvent) {
 	logger.Debugw(ctx, "DeviceStateUpdate upon re-enable", log.Fields{"ConnectStatus": voltha.ConnectStatus_REACHABLE,
-		"OperStatus": voltha.OperStatus_ACTIVE, "device-id": dh.deviceID})
+		"OperStatus": voltha.OperStatus_ACTIVE, "device-id": dh.DeviceID})
 	if err := dh.updateDeviceStateInCore(ctx, &ic.DeviceStateFilter{
-		DeviceId:   dh.deviceID,
+		DeviceId:   dh.DeviceID,
 		ConnStatus: voltha.ConnectStatus_REACHABLE,
 		OperStatus: voltha.OperStatus_ACTIVE,
 	}); err != nil {
 		//TODO with VOL-3045/VOL-3046: return the error and stop further processing
-		logger.Errorw(ctx, "error-updating-device-state", log.Fields{"device-id": dh.deviceID, "error": err})
+		logger.Errorw(ctx, "error-updating-device-state", log.Fields{"device-id": dh.DeviceID, "error": err})
 	}
 
 	logger.Debugw(ctx, "DeviceReasonUpdate upon re-enable", log.Fields{
-		"reason": deviceReasonMap[drOnuReenabled], "device-id": dh.deviceID})
+		"reason": cmn.DeviceReasonMap[cmn.DrOnuReenabled], "device-id": dh.DeviceID})
 	// DeviceReason to update acc.to modified py code as per beginning of Sept 2020
-	_ = dh.deviceReasonUpdate(ctx, drOnuReenabled, true)
+	_ = dh.deviceReasonUpdate(ctx, cmn.DrOnuReenabled, true)
 
 	//transfer the modified logical uni port state
-	dh.enableUniPortStateUpdate(ctx)
+	dh.EnableUniPortStateUpdate(ctx)
 
-	pDevEntry := dh.getOnuDeviceEntry(ctx, false)
+	pDevEntry := dh.GetOnuDeviceEntry(ctx, false)
 	if pDevEntry == nil {
-		logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
+		logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.DeviceID})
 		return
 	}
-	pDevEntry.mutexPersOnuConfig.Lock()
-	pDevEntry.sOnuPersistentData.PersUniDisableDone = false
-	pDevEntry.mutexPersOnuConfig.Unlock()
-	if err := dh.storePersistentData(ctx); err != nil {
+	pDevEntry.MutexPersOnuConfig.Lock()
+	pDevEntry.SOnuPersistentData.PersUniDisableDone = false
+	pDevEntry.MutexPersOnuConfig.Unlock()
+	if err := dh.StorePersistentData(ctx); err != nil {
 		logger.Warnw(ctx, "store persistent data error - continue for now as there will be additional write attempts",
-			log.Fields{"device-id": dh.deviceID, "err": err})
+			log.Fields{"device-id": dh.DeviceID, "err": err})
 	}
 }
 
-func (dh *deviceHandler) processOmciAniConfigDoneEvent(ctx context.Context, devEvent OnuDeviceEvent) {
-	if devEvent == OmciAniConfigDone {
-		logger.Debugw(ctx, "OmciAniConfigDone event received", log.Fields{"device-id": dh.deviceID})
+func (dh *deviceHandler) processOmciAniConfigDoneEvent(ctx context.Context, devEvent cmn.OnuDeviceEvent) {
+	if devEvent == cmn.OmciAniConfigDone {
+		logger.Debugw(ctx, "OmciAniConfigDone event received", log.Fields{"device-id": dh.DeviceID})
 		// attention: the device reason update is done based on ONU-UNI-Port related activity
 		//  - which may cause some inconsistency
-		if dh.getDeviceReason() != drTechProfileConfigDownloadSuccess {
+		if dh.getDeviceReason() != cmn.DrTechProfileConfigDownloadSuccess {
 			// which may be the case from some previous actvity even on this UNI Port (but also other UNI ports)
-			_ = dh.deviceReasonUpdate(ctx, drTechProfileConfigDownloadSuccess, !dh.isReconciling())
+			_ = dh.deviceReasonUpdate(ctx, cmn.DrTechProfileConfigDownloadSuccess, !dh.IsReconciling())
 		}
-		if dh.isReconciling() {
-			go dh.reconcileDeviceFlowConfig(ctx)
+		if dh.IsReconciling() {
+			go dh.ReconcileDeviceFlowConfig(ctx)
 		}
 	} else { // should be the OmciAniResourceRemoved block
-		logger.Debugw(ctx, "OmciAniResourceRemoved event received", log.Fields{"device-id": dh.deviceID})
+		logger.Debugw(ctx, "OmciAniResourceRemoved event received", log.Fields{"device-id": dh.DeviceID})
 		// attention: the device reason update is done based on ONU-UNI-Port related activity
 		//  - which may cause some inconsistency
-		if dh.getDeviceReason() != drTechProfileConfigDeleteSuccess {
+		if dh.getDeviceReason() != cmn.DrTechProfileConfigDeleteSuccess {
 			// which may be the case from some previous actvity even on this ONU port (but also other UNI ports)
-			_ = dh.deviceReasonUpdate(ctx, drTechProfileConfigDeleteSuccess, true)
+			_ = dh.deviceReasonUpdate(ctx, cmn.DrTechProfileConfigDeleteSuccess, true)
 		}
 	}
 }
 
-func (dh *deviceHandler) processOmciVlanFilterDoneEvent(ctx context.Context, aDevEvent OnuDeviceEvent) {
+func (dh *deviceHandler) processOmciVlanFilterDoneEvent(ctx context.Context, aDevEvent cmn.OnuDeviceEvent) {
 	logger.Debugw(ctx, "OmciVlanFilterDone event received",
-		log.Fields{"device-id": dh.deviceID, "event": aDevEvent})
+		log.Fields{"device-id": dh.DeviceID, "event": aDevEvent})
 	// attention: the device reason update is done based on ONU-UNI-Port related activity
 	//  - which may cause some inconsistency
 
-	if aDevEvent == OmciVlanFilterAddDone || aDevEvent == OmciVlanFilterAddDoneNoKvStore {
-		if dh.getDeviceReason() != drOmciFlowsPushed {
+	if aDevEvent == cmn.OmciVlanFilterAddDone || aDevEvent == cmn.OmciVlanFilterAddDoneNoKvStore {
+		if dh.getDeviceReason() != cmn.DrOmciFlowsPushed {
 			// which may be the case from some previous actvity on another UNI Port of the ONU
 			// or even some previous flow add activity on the same port
-			_ = dh.deviceReasonUpdate(ctx, drOmciFlowsPushed, !dh.isReconciling())
-			if dh.isReconciling() {
+			_ = dh.deviceReasonUpdate(ctx, cmn.DrOmciFlowsPushed, !dh.IsReconciling())
+			if dh.IsReconciling() {
 				go dh.reconcileEnd(ctx)
 			}
 		}
 	} else {
-		if dh.getDeviceReason() != drOmciFlowsDeleted {
+		if dh.getDeviceReason() != cmn.DrOmciFlowsDeleted {
 			//not relevant for reconcile
-			_ = dh.deviceReasonUpdate(ctx, drOmciFlowsDeleted, true)
+			_ = dh.deviceReasonUpdate(ctx, cmn.DrOmciFlowsDeleted, true)
 		}
 	}
 
-	if aDevEvent == OmciVlanFilterAddDone || aDevEvent == OmciVlanFilterRemDone {
+	if aDevEvent == cmn.OmciVlanFilterAddDone || aDevEvent == cmn.OmciVlanFilterRemDone {
 		//events that request KvStore write
-		if err := dh.storePersistentData(ctx); err != nil {
+		if err := dh.StorePersistentData(ctx); err != nil {
 			logger.Warnw(ctx, "store persistent data error - continue for now as there will be additional write attempts",
-				log.Fields{"device-id": dh.deviceID, "err": err})
+				log.Fields{"device-id": dh.DeviceID, "err": err})
 		}
 	} else {
 		logger.Debugw(ctx, "OmciVlanFilter*Done* - write to KvStore not requested",
-			log.Fields{"device-id": dh.deviceID})
+			log.Fields{"device-id": dh.DeviceID})
 	}
 }
 
-//deviceProcStatusUpdate evaluates possible processing events and initiates according next activities
-func (dh *deviceHandler) deviceProcStatusUpdate(ctx context.Context, devEvent OnuDeviceEvent) {
+//DeviceProcStatusUpdate evaluates possible processing events and initiates according next activities
+func (dh *deviceHandler) DeviceProcStatusUpdate(ctx context.Context, devEvent cmn.OnuDeviceEvent) {
 	switch devEvent {
-	case MibDatabaseSync:
+	case cmn.MibDatabaseSync:
 		{
 			dh.processMibDatabaseSyncEvent(ctx, devEvent)
 		}
-	case UniLockStateDone:
+	case cmn.UniLockStateDone:
 		{
 			dh.processUniLockStateDoneEvent(ctx, devEvent)
 		}
-	case MibDownloadDone:
+	case cmn.MibDownloadDone:
 		{
 			dh.processMibDownloadDoneEvent(ctx, devEvent)
 		}
-	case UniUnlockStateDone:
+	case cmn.UniUnlockStateDone:
 		{
 			dh.processUniUnlockStateDoneEvent(ctx, devEvent)
 		}
-	case UniEnableStateDone:
+	case cmn.UniEnableStateDone:
 		{
 			dh.processUniEnableStateDoneEvent(ctx, devEvent)
 		}
-	case UniDisableStateDone:
+	case cmn.UniDisableStateDone:
 		{
 			dh.processUniDisableStateDoneEvent(ctx, devEvent)
 		}
-	case OmciAniConfigDone, OmciAniResourceRemoved:
+	case cmn.OmciAniConfigDone, cmn.OmciAniResourceRemoved:
 		{
 			dh.processOmciAniConfigDoneEvent(ctx, devEvent)
 		}
-	case OmciVlanFilterAddDone, OmciVlanFilterAddDoneNoKvStore, OmciVlanFilterRemDone, OmciVlanFilterRemDoneNoKvStore:
+	case cmn.OmciVlanFilterAddDone, cmn.OmciVlanFilterAddDoneNoKvStore, cmn.OmciVlanFilterRemDone, cmn.OmciVlanFilterRemDoneNoKvStore:
 		{
 			dh.processOmciVlanFilterDoneEvent(ctx, devEvent)
 		}
 	default:
 		{
-			logger.Debugw(ctx, "unhandled-device-event", log.Fields{"device-id": dh.deviceID, "event": devEvent})
+			logger.Debugw(ctx, "unhandled-device-event", log.Fields{"device-id": dh.DeviceID, "event": devEvent})
 		}
 	} //switch
 }
 
-func (dh *deviceHandler) addUniPort(ctx context.Context, aUniInstNo uint16, aUniID uint8, aPortType uniPortType) {
+func (dh *deviceHandler) addUniPort(ctx context.Context, aUniInstNo uint16, aUniID uint8, aPortType cmn.UniPortType) {
 	// parameters are IntfId, OnuId, uniId
 	uniNo := mkUniPortNum(ctx, dh.pOnuIndication.GetIntfId(), dh.pOnuIndication.GetOnuId(),
 		uint32(aUniID))
 	if _, present := dh.uniEntityMap[uniNo]; present {
-		logger.Warnw(ctx, "onuUniPort-add: Port already exists", log.Fields{"for InstanceId": aUniInstNo})
+		logger.Warnw(ctx, "OnuUniPort-add: Port already exists", log.Fields{"for InstanceId": aUniInstNo})
 	} else {
 		//with arguments aUniID, a_portNo, aPortType
-		pUniPort := newOnuUniPort(ctx, aUniID, uniNo, aUniInstNo, aPortType)
+		pUniPort := cmn.NewOnuUniPort(ctx, aUniID, uniNo, aUniInstNo, aPortType)
 		if pUniPort == nil {
-			logger.Warnw(ctx, "onuUniPort-add: Could not create Port", log.Fields{"for InstanceId": aUniInstNo})
+			logger.Warnw(ctx, "OnuUniPort-add: Could not create Port", log.Fields{"for InstanceId": aUniInstNo})
 		} else {
 			//store UniPort with the System-PortNumber key
 			dh.uniEntityMap[uniNo] = pUniPort
-			if !dh.isReconciling() {
+			if !dh.IsReconciling() {
 				// create announce the UniPort to the core as VOLTHA Port object
-				if err := pUniPort.createVolthaPort(ctx, dh); err == nil {
-					logger.Infow(ctx, "onuUniPort-added", log.Fields{"for PortNo": uniNo})
+				if err := pUniPort.CreateVolthaPort(ctx, dh); err == nil {
+					logger.Infow(ctx, "OnuUniPort-added", log.Fields{"for PortNo": uniNo})
 				} //error logging already within UniPort method
 			} else {
-				logger.Debugw(ctx, "reconciling - onuUniPort already added", log.Fields{"for PortNo": uniNo, "device-id": dh.deviceID})
+				logger.Debugw(ctx, "reconciling - OnuUniPort already added", log.Fields{"for PortNo": uniNo, "device-id": dh.DeviceID})
 			}
 		}
 	}
 }
 
-func (dh *deviceHandler) addAllUniPorts(ctx context.Context) {
-	pDevEntry := dh.getOnuDeviceEntry(ctx, false)
+func (dh *deviceHandler) AddAllUniPorts(ctx context.Context) {
+	pDevEntry := dh.GetOnuDeviceEntry(ctx, false)
 	if pDevEntry == nil {
-		logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
+		logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.DeviceID})
 		return
 	}
 	i := uint8(0) //UNI Port limit: see MaxUnisPerOnu (by now 16) (OMCI supports max 255 p.b.)
-	if pptpInstKeys := pDevEntry.pOnuDB.getSortedInstKeys(
+	if pptpInstKeys := pDevEntry.GetOnuDB().GetSortedInstKeys(
 		ctx, me.PhysicalPathTerminationPointEthernetUniClassID); len(pptpInstKeys) > 0 {
 		for _, mgmtEntityID := range pptpInstKeys {
 			logger.Debugw(ctx, "Add PPTPEthUni port for MIB-stored instance:", log.Fields{
-				"device-id": dh.deviceID, "PPTPEthUni EntityID": mgmtEntityID})
-			dh.addUniPort(ctx, mgmtEntityID, i, uniPPTP)
+				"device-id": dh.DeviceID, "PPTPEthUni EntityID": mgmtEntityID})
+			dh.addUniPort(ctx, mgmtEntityID, i, cmn.UniPPTP)
 			i++
 		}
 	} else {
-		logger.Debugw(ctx, "No PPTP instances found", log.Fields{"device-id": dh.deviceID})
+		logger.Debugw(ctx, "No PPTP instances found", log.Fields{"device-id": dh.DeviceID})
 	}
-	if veipInstKeys := pDevEntry.pOnuDB.getSortedInstKeys(
+	if veipInstKeys := pDevEntry.GetOnuDB().GetSortedInstKeys(
 		ctx, me.VirtualEthernetInterfacePointClassID); len(veipInstKeys) > 0 {
 		for _, mgmtEntityID := range veipInstKeys {
 			logger.Debugw(ctx, "Add VEIP for MIB-stored instance:", log.Fields{
-				"device-id": dh.deviceID, "VEIP EntityID": mgmtEntityID})
-			dh.addUniPort(ctx, mgmtEntityID, i, uniVEIP)
+				"device-id": dh.DeviceID, "VEIP EntityID": mgmtEntityID})
+			dh.addUniPort(ctx, mgmtEntityID, i, cmn.UniVEIP)
 			i++
 		}
 	} else {
-		logger.Debugw(ctx, "No VEIP instances found", log.Fields{"device-id": dh.deviceID})
+		logger.Debugw(ctx, "No VEIP instances found", log.Fields{"device-id": dh.DeviceID})
 	}
-	if potsInstKeys := pDevEntry.pOnuDB.getSortedInstKeys(
+	if potsInstKeys := pDevEntry.GetOnuDB().GetSortedInstKeys(
 		ctx, me.PhysicalPathTerminationPointPotsUniClassID); len(potsInstKeys) > 0 {
 		for _, mgmtEntityID := range potsInstKeys {
 			logger.Debugw(ctx, "Add PPTP Pots UNI for MIB-stored instance:", log.Fields{
-				"device-id": dh.deviceID, "PPTP Pots UNI EntityID": mgmtEntityID})
-			dh.addUniPort(ctx, mgmtEntityID, i, uniPPTPPots)
+				"device-id": dh.DeviceID, "PPTP Pots UNI EntityID": mgmtEntityID})
+			dh.addUniPort(ctx, mgmtEntityID, i, cmn.UniPPTPPots)
 			i++
 		}
 	} else {
-		logger.Debugw(ctx, "No PPTP Pots UNI instances found", log.Fields{"device-id": dh.deviceID})
+		logger.Debugw(ctx, "No PPTP Pots UNI instances found", log.Fields{"device-id": dh.DeviceID})
 	}
 	if i == 0 {
-		logger.Warnw(ctx, "No UniG instances found", log.Fields{"device-id": dh.deviceID})
+		logger.Warnw(ctx, "No UniG instances found", log.Fields{"device-id": dh.DeviceID})
 	}
 }
 
-// enableUniPortStateUpdate enables UniPortState and update core port state accordingly
-func (dh *deviceHandler) enableUniPortStateUpdate(ctx context.Context) {
+// EnableUniPortStateUpdate enables UniPortState and update core port state accordingly
+func (dh *deviceHandler) EnableUniPortStateUpdate(ctx context.Context) {
 	//  py code was updated 2003xx to activate the real ONU UNI ports per OMCI (VEIP or PPTP)
 	//    but towards core only the first port active state is signaled
 	//    with following remark:
@@ -2481,52 +2432,52 @@
 
 	for uniNo, uniPort := range dh.uniEntityMap {
 		// only if this port is validated for operState transfer
-		if (1<<uniPort.uniID)&dh.pOpenOnuAc.config.UniPortMask == (1 << uniPort.uniID) {
-			logger.Infow(ctx, "onuUniPort-forced-OperState-ACTIVE", log.Fields{"for PortNo": uniNo, "device-id": dh.deviceID})
-			uniPort.setOperState(vc.OperStatus_ACTIVE)
-			if !dh.isReconciling() {
+		if (1<<uniPort.UniID)&dh.pOpenOnuAc.config.UniPortMask == (1 << uniPort.UniID) {
+			logger.Infow(ctx, "OnuUniPort-forced-OperState-ACTIVE", log.Fields{"for PortNo": uniNo, "device-id": dh.DeviceID})
+			uniPort.SetOperState(vc.OperStatus_ACTIVE)
+			if !dh.IsReconciling() {
 				//maybe also use getter functions on uniPort - perhaps later ...
-				go func(port *onuUniPort) {
+				go func(port *cmn.OnuUniPort) {
 					if err := dh.updatePortStateInCore(ctx, &ic.PortState{
-						DeviceId:   dh.deviceID,
+						DeviceId:   dh.DeviceID,
 						PortType:   voltha.Port_ETHERNET_UNI,
-						PortNo:     port.portNo,
-						OperStatus: port.operState,
+						PortNo:     port.PortNo,
+						OperStatus: port.OperState,
 					}); err != nil {
-						logger.Errorw(ctx, "port-state-update-failed", log.Fields{"error": err, "port-no": uniPort.portNo, "device-id": dh.deviceID})
+						logger.Errorw(ctx, "port-state-update-failed", log.Fields{"error": err, "port-no": uniPort.PortNo, "device-id": dh.DeviceID})
 					}
 				}(uniPort)
 			} else {
-				logger.Debugw(ctx, "reconciling - don't notify core about PortStateUpdate", log.Fields{"device-id": dh.deviceID})
+				logger.Debugw(ctx, "reconciling - don't notify core about PortStateUpdate", log.Fields{"device-id": dh.DeviceID})
 			}
 		}
 	}
 }
 
 // Disable UniPortState and update core port state accordingly
-func (dh *deviceHandler) disableUniPortStateUpdate(ctx context.Context) {
-	// compare enableUniPortStateUpdate() above
+func (dh *deviceHandler) DisableUniPortStateUpdate(ctx context.Context) {
+	// compare EnableUniPortStateUpdate() above
 	//   -> use current restriction to operate only on first UNI port as inherited from actual Py code
 	for uniNo, uniPort := range dh.uniEntityMap {
 		// only if this port is validated for operState transfer
 
-		if (1<<uniPort.uniID)&dh.pOpenOnuAc.config.UniPortMask == (1 << uniPort.uniID) {
-			logger.Infow(ctx, "onuUniPort-forced-OperState-UNKNOWN", log.Fields{"for PortNo": uniNo, "device-id": dh.deviceID})
-			uniPort.setOperState(vc.OperStatus_UNKNOWN)
-			if !dh.isReconciling() {
+		if (1<<uniPort.UniID)&dh.pOpenOnuAc.config.UniPortMask == (1 << uniPort.UniID) {
+			logger.Infow(ctx, "OnuUniPort-forced-OperState-UNKNOWN", log.Fields{"for PortNo": uniNo, "device-id": dh.DeviceID})
+			uniPort.SetOperState(vc.OperStatus_UNKNOWN)
+			if !dh.IsReconciling() {
 				//maybe also use getter functions on uniPort - perhaps later ...
-				go func(port *onuUniPort) {
+				go func(port *cmn.OnuUniPort) {
 					if err := dh.updatePortStateInCore(ctx, &ic.PortState{
-						DeviceId:   dh.deviceID,
+						DeviceId:   dh.DeviceID,
 						PortType:   voltha.Port_ETHERNET_UNI,
-						PortNo:     port.portNo,
-						OperStatus: port.operState,
+						PortNo:     port.PortNo,
+						OperStatus: port.OperState,
 					}); err != nil {
-						logger.Errorw(ctx, "port-state-update-failed", log.Fields{"error": err, "port-no": uniPort.portNo, "device-id": dh.deviceID})
+						logger.Errorw(ctx, "port-state-update-failed", log.Fields{"error": err, "port-no": uniPort.PortNo, "device-id": dh.DeviceID})
 					}
 				}(uniPort)
 			} else {
-				logger.Debugw(ctx, "reconciling - don't notify core about PortStateUpdate", log.Fields{"device-id": dh.deviceID})
+				logger.Debugw(ctx, "reconciling - don't notify core about PortStateUpdate", log.Fields{"device-id": dh.DeviceID})
 			}
 
 		}
@@ -2555,15 +2506,15 @@
 	eventContext["device-id"] = aDeviceID
 	eventContext["registration-id"] = aDeviceID //py: string(device_id)??
 	eventContext["num-of-unis"] = strconv.Itoa(len(dh.uniEntityMap))
-	if deviceEntry := dh.getOnuDeviceEntry(ctx, false); deviceEntry != nil {
-		deviceEntry.mutexPersOnuConfig.RLock()
-		eventContext["equipment-id"] = deviceEntry.sOnuPersistentData.PersEquipmentID
-		deviceEntry.mutexPersOnuConfig.RUnlock()
-		eventContext["software-version"] = deviceEntry.getActiveImageVersion(ctx)
-		deviceEntry.mutexPersOnuConfig.RLock()
-		eventContext["vendor"] = deviceEntry.sOnuPersistentData.PersVendorID
-		deviceEntry.mutexPersOnuConfig.RUnlock()
-		eventContext["inactive-software-version"] = deviceEntry.getInactiveImageVersion(ctx)
+	if deviceEntry := dh.GetOnuDeviceEntry(ctx, false); deviceEntry != nil {
+		deviceEntry.MutexPersOnuConfig.RLock()
+		eventContext["equipment-id"] = deviceEntry.SOnuPersistentData.PersEquipmentID
+		deviceEntry.MutexPersOnuConfig.RUnlock()
+		eventContext["software-version"] = deviceEntry.GetActiveImageVersion(ctx)
+		deviceEntry.MutexPersOnuConfig.RLock()
+		eventContext["vendor"] = deviceEntry.SOnuPersistentData.PersVendorID
+		deviceEntry.MutexPersOnuConfig.RUnlock()
+		eventContext["inactive-software-version"] = deviceEntry.GetInactiveImageVersion(ctx)
 		logger.Debugw(ctx, "prepare ONU_ACTIVATED event",
 			log.Fields{"device-id": aDeviceID, "EventContext": eventContext})
 	} else {
@@ -2594,24 +2545,23 @@
 }
 
 // createUniLockFsm initializes and runs the UniLock FSM to transfer the OMCI related commands for port lock/unlock
-func (dh *deviceHandler) createUniLockFsm(ctx context.Context, aAdminState bool, devEvent OnuDeviceEvent) {
-	chLSFsm := make(chan Message, 2048)
+func (dh *deviceHandler) createUniLockFsm(ctx context.Context, aAdminState bool, devEvent cmn.OnuDeviceEvent) {
+	chLSFsm := make(chan cmn.Message, 2048)
 	var sFsmName string
 	if aAdminState {
-		logger.Debugw(ctx, "createLockStateFSM", log.Fields{"device-id": dh.deviceID})
+		logger.Debugw(ctx, "createLockStateFSM", log.Fields{"device-id": dh.DeviceID})
 		sFsmName = "LockStateFSM"
 	} else {
-		logger.Debugw(ctx, "createUnlockStateFSM", log.Fields{"device-id": dh.deviceID})
+		logger.Debugw(ctx, "createUnlockStateFSM", log.Fields{"device-id": dh.DeviceID})
 		sFsmName = "UnLockStateFSM"
 	}
 
-	pDevEntry := dh.getOnuDeviceEntry(ctx, true)
+	pDevEntry := dh.GetOnuDeviceEntry(ctx, true)
 	if pDevEntry == nil {
-		logger.Errorw(ctx, "No valid OnuDevice -aborting", log.Fields{"device-id": dh.deviceID})
+		logger.Errorw(ctx, "No valid OnuDevice -aborting", log.Fields{"device-id": dh.DeviceID})
 		return
 	}
-	pLSFsm := newLockStateFsm(ctx, pDevEntry.PDevOmciCC, aAdminState, devEvent,
-		sFsmName, dh, chLSFsm)
+	pLSFsm := uniprt.NewLockStateFsm(ctx, aAdminState, devEvent, sFsmName, dh, pDevEntry, chLSFsm)
 	if pLSFsm != nil {
 		if aAdminState {
 			dh.pLockStateFsm = pLSFsm
@@ -2620,7 +2570,7 @@
 		}
 		dh.runUniLockFsm(ctx, aAdminState)
 	} else {
-		logger.Errorw(ctx, "LockStateFSM could not be created - abort!!", log.Fields{"device-id": dh.deviceID})
+		logger.Errorw(ctx, "LockStateFSM could not be created - abort!!", log.Fields{"device-id": dh.DeviceID})
 	}
 }
 
@@ -2631,58 +2581,58 @@
 	 */
 	var pLSStatemachine *fsm.FSM
 	if aAdminState {
-		pLSStatemachine = dh.pLockStateFsm.pAdaptFsm.pFsm
+		pLSStatemachine = dh.pLockStateFsm.PAdaptFsm.PFsm
 		//make sure the opposite FSM is not running and if so, terminate it as not relevant anymore
 		if (dh.pUnlockStateFsm != nil) &&
-			(dh.pUnlockStateFsm.pAdaptFsm.pFsm.Current() != uniStDisabled) {
-			_ = dh.pUnlockStateFsm.pAdaptFsm.pFsm.Event(uniEvReset)
+			(dh.pUnlockStateFsm.PAdaptFsm.PFsm.Current() != uniprt.UniStDisabled) {
+			_ = dh.pUnlockStateFsm.PAdaptFsm.PFsm.Event(uniprt.UniEvReset)
 		}
 	} else {
-		pLSStatemachine = dh.pUnlockStateFsm.pAdaptFsm.pFsm
+		pLSStatemachine = dh.pUnlockStateFsm.PAdaptFsm.PFsm
 		//make sure the opposite FSM is not running and if so, terminate it as not relevant anymore
 		if (dh.pLockStateFsm != nil) &&
-			(dh.pLockStateFsm.pAdaptFsm.pFsm.Current() != uniStDisabled) {
-			_ = dh.pLockStateFsm.pAdaptFsm.pFsm.Event(uniEvReset)
+			(dh.pLockStateFsm.PAdaptFsm.PFsm.Current() != uniprt.UniStDisabled) {
+			_ = dh.pLockStateFsm.PAdaptFsm.PFsm.Event(uniprt.UniEvReset)
 		}
 	}
 	if pLSStatemachine != nil {
-		if pLSStatemachine.Is(uniStDisabled) {
-			if err := pLSStatemachine.Event(uniEvStart); err != nil {
+		if pLSStatemachine.Is(uniprt.UniStDisabled) {
+			if err := pLSStatemachine.Event(uniprt.UniEvStart); err != nil {
 				logger.Warnw(ctx, "LockStateFSM: can't start", log.Fields{"err": err})
 				// maybe try a FSM reset and then again ... - TODO!!!
 			} else {
 				/***** LockStateFSM started */
 				logger.Debugw(ctx, "LockStateFSM started", log.Fields{
-					"state": pLSStatemachine.Current(), "device-id": dh.deviceID})
+					"state": pLSStatemachine.Current(), "device-id": dh.DeviceID})
 			}
 		} else {
 			logger.Warnw(ctx, "wrong state of LockStateFSM - want: disabled", log.Fields{
-				"have": pLSStatemachine.Current(), "device-id": dh.deviceID})
+				"have": pLSStatemachine.Current(), "device-id": dh.DeviceID})
 			// maybe try a FSM reset and then again ... - TODO!!!
 		}
 	} else {
-		logger.Errorw(ctx, "LockStateFSM StateMachine invalid - cannot be executed!!", log.Fields{"device-id": dh.deviceID})
+		logger.Errorw(ctx, "LockStateFSM StateMachine invalid - cannot be executed!!", log.Fields{"device-id": dh.DeviceID})
 		// maybe try a FSM reset and then again ... - TODO!!!
 	}
 }
 
 // createOnuUpgradeFsm initializes and runs the Onu Software upgrade FSM
-func (dh *deviceHandler) createOnuUpgradeFsm(ctx context.Context, apDevEntry *OnuDeviceEntry, aDevEvent OnuDeviceEvent) error {
+func (dh *deviceHandler) createOnuUpgradeFsm(ctx context.Context, apDevEntry *mib.OnuDeviceEntry, aDevEvent cmn.OnuDeviceEvent) error {
 	//in here lockUpgradeFsm is already locked
-	chUpgradeFsm := make(chan Message, 2048)
+	chUpgradeFsm := make(chan cmn.Message, 2048)
 	var sFsmName = "OnuSwUpgradeFSM"
-	logger.Debugw(ctx, "create OnuSwUpgradeFSM", log.Fields{"device-id": dh.deviceID})
+	logger.Debugw(ctx, "create OnuSwUpgradeFSM", log.Fields{"device-id": dh.DeviceID})
 	if apDevEntry.PDevOmciCC == nil {
-		logger.Errorw(ctx, "no valid OnuDevice or omciCC - abort", log.Fields{"device-id": dh.deviceID})
+		logger.Errorw(ctx, "no valid OnuDevice or omciCC - abort", log.Fields{"device-id": dh.DeviceID})
 		return fmt.Errorf(fmt.Sprintf("no valid omciCC - abort for device-id: %s", dh.device.Id))
 	}
-	dh.pOnuUpradeFsm = NewOnuUpgradeFsm(ctx, dh, apDevEntry, apDevEntry.pOnuDB, aDevEvent,
+	dh.pOnuUpradeFsm = swupg.NewOnuUpgradeFsm(ctx, dh, apDevEntry, apDevEntry.GetOnuDB(), aDevEvent,
 		sFsmName, chUpgradeFsm)
 	if dh.pOnuUpradeFsm != nil {
-		pUpgradeStatemachine := dh.pOnuUpradeFsm.pAdaptFsm.pFsm
+		pUpgradeStatemachine := dh.pOnuUpradeFsm.PAdaptFsm.PFsm
 		if pUpgradeStatemachine != nil {
-			if pUpgradeStatemachine.Is(upgradeStDisabled) {
-				if err := pUpgradeStatemachine.Event(upgradeEvStart); err != nil {
+			if pUpgradeStatemachine.Is(swupg.UpgradeStDisabled) {
+				if err := pUpgradeStatemachine.Event(swupg.UpgradeEvStart); err != nil {
 					logger.Errorw(ctx, "OnuSwUpgradeFSM: can't start", log.Fields{"err": err})
 					// maybe try a FSM reset and then again ... - TODO!!!
 					return fmt.Errorf(fmt.Sprintf("OnuSwUpgradeFSM could not be started for device-id: %s", dh.device.Id))
@@ -2693,29 +2643,29 @@
 				(*dh.pLastUpgradeImageState).Reason = voltha.ImageState_NO_ERROR
 				(*dh.pLastUpgradeImageState).ImageState = voltha.ImageState_IMAGE_UNKNOWN
 				logger.Debugw(ctx, "OnuSwUpgradeFSM started", log.Fields{
-					"state": pUpgradeStatemachine.Current(), "device-id": dh.deviceID})
+					"state": pUpgradeStatemachine.Current(), "device-id": dh.DeviceID})
 			} else {
 				logger.Errorw(ctx, "wrong state of OnuSwUpgradeFSM to start - want: disabled", log.Fields{
-					"have": pUpgradeStatemachine.Current(), "device-id": dh.deviceID})
+					"have": pUpgradeStatemachine.Current(), "device-id": dh.DeviceID})
 				// maybe try a FSM reset and then again ... - TODO!!!
 				return fmt.Errorf(fmt.Sprintf("OnuSwUpgradeFSM could not be started for device-id: %s, wrong internal state", dh.device.Id))
 			}
 		} else {
-			logger.Errorw(ctx, "OnuSwUpgradeFSM internal FSM invalid - cannot be executed!!", log.Fields{"device-id": dh.deviceID})
+			logger.Errorw(ctx, "OnuSwUpgradeFSM internal FSM invalid - cannot be executed!!", log.Fields{"device-id": dh.DeviceID})
 			// maybe try a FSM reset and then again ... - TODO!!!
 			return fmt.Errorf(fmt.Sprintf("OnuSwUpgradeFSM internal FSM could not be created for device-id: %s", dh.device.Id))
 		}
 	} else {
-		logger.Errorw(ctx, "OnuSwUpgradeFSM could not be created  - abort", log.Fields{"device-id": dh.deviceID})
+		logger.Errorw(ctx, "OnuSwUpgradeFSM could not be created  - abort", log.Fields{"device-id": dh.DeviceID})
 		return fmt.Errorf(fmt.Sprintf("OnuSwUpgradeFSM could not be created - abort for device-id: %s", dh.device.Id))
 	}
 	return nil
 }
 
-// removeOnuUpgradeFsm clears the Onu Software upgrade FSM
-func (dh *deviceHandler) removeOnuUpgradeFsm(ctx context.Context, apImageState *voltha.ImageState) {
+// RemoveOnuUpgradeFsm clears the Onu Software upgrade FSM
+func (dh *deviceHandler) RemoveOnuUpgradeFsm(ctx context.Context, apImageState *voltha.ImageState) {
 	logger.Debugw(ctx, "remove OnuSwUpgradeFSM StateMachine", log.Fields{
-		"device-id": dh.deviceID})
+		"device-id": dh.DeviceID})
 	dh.lockUpgradeFsm.Lock()
 	dh.pOnuUpradeFsm = nil //resource clearing is left to garbage collector
 	dh.pLastUpgradeImageState = apImageState
@@ -2725,65 +2675,65 @@
 	case dh.upgradeFsmChan <- struct{}{}:
 	default:
 		logger.Debugw(ctx, "removed-UpgradeFsm signal not send on upgradeFsmChan (no receiver)", log.Fields{
-			"device-id": dh.deviceID})
+			"device-id": dh.DeviceID})
 	}
 }
 
 // checkOnOnuImageCommit verifies if the ONU is in some upgrade state that allows for image commit and if tries to commit
 func (dh *deviceHandler) checkOnOnuImageCommit(ctx context.Context) {
-	pDevEntry := dh.getOnuDeviceEntry(ctx, false)
+	pDevEntry := dh.GetOnuDeviceEntry(ctx, false)
 	if pDevEntry == nil {
-		logger.Errorw(ctx, "No valid OnuDevice -aborting checkOnOnuImageCommit", log.Fields{"device-id": dh.deviceID})
+		logger.Errorw(ctx, "No valid OnuDevice -aborting checkOnOnuImageCommit", log.Fields{"device-id": dh.DeviceID})
 		return
 	}
 
 	dh.lockUpgradeFsm.RLock()
 	defer dh.lockUpgradeFsm.RUnlock()
 	if dh.pOnuUpradeFsm != nil {
-		pUpgradeStatemachine := dh.pOnuUpradeFsm.pAdaptFsm.pFsm
+		pUpgradeStatemachine := dh.pOnuUpradeFsm.PAdaptFsm.PFsm
 		if pUpgradeStatemachine != nil {
 			// commit is only processed in case out upgrade FSM indicates the according state (for automatic commit)
 			//  (some manual forced commit could do without)
-			upgradeState := pUpgradeStatemachine.Current()
-			if (upgradeState == upgradeStWaitForCommit) ||
-				(upgradeState == upgradeStRequestingActivate) {
-				// also include upgradeStRequestingActivate as it may be left in case the ActivateResponse just got lost
+			UpgradeState := pUpgradeStatemachine.Current()
+			if (UpgradeState == swupg.UpgradeStWaitForCommit) ||
+				(UpgradeState == swupg.UpgradeStRequestingActivate) {
+				// also include UpgradeStRequestingActivate as it may be left in case the ActivateResponse just got lost
 				// here no need to update the upgrade image state to activated as the state will be immediately be set to committing
-				if pDevEntry.IsImageToBeCommitted(ctx, dh.pOnuUpradeFsm.inactiveImageMeID) {
+				if pDevEntry.IsImageToBeCommitted(ctx, dh.pOnuUpradeFsm.InactiveImageMeID) {
 					activeImageID, errImg := pDevEntry.GetActiveImageMeID(ctx)
 					if errImg != nil {
 						logger.Errorw(ctx, "OnuSwUpgradeFSM abort - could not get active image after reboot",
-							log.Fields{"device-id": dh.deviceID})
+							log.Fields{"device-id": dh.DeviceID})
 						dh.pOnuUpradeFsm.CancelProcessing(ctx, true, voltha.ImageState_CANCELLED_ON_ONU_STATE) //complete abort
 						return
 					}
-					if activeImageID == dh.pOnuUpradeFsm.inactiveImageMeID {
-						if (upgradeState == upgradeStRequestingActivate) && !dh.pOnuUpradeFsm.GetCommitFlag(ctx) {
+					if activeImageID == dh.pOnuUpradeFsm.InactiveImageMeID {
+						if (UpgradeState == swupg.UpgradeStRequestingActivate) && !dh.pOnuUpradeFsm.GetCommitFlag(ctx) {
 							// if FSM was waiting on activateResponse, new image is active, but FSM shall not commit, then:
-							if err := pUpgradeStatemachine.Event(upgradeEvActivationDone); err != nil {
+							if err := pUpgradeStatemachine.Event(swupg.UpgradeEvActivationDone); err != nil {
 								logger.Errorw(ctx, "OnuSwUpgradeFSM: can't call activate-done event", log.Fields{"err": err})
 								return
 							}
 							logger.Debugw(ctx, "OnuSwUpgradeFSM activate-done after reboot", log.Fields{
-								"state": upgradeState, "device-id": dh.deviceID})
+								"state": UpgradeState, "device-id": dh.DeviceID})
 						} else {
-							//FSM in waitForCommit or (upgradeStRequestingActivate [lost ActivateResp] and commit allowed)
-							if err := pUpgradeStatemachine.Event(upgradeEvCommitSw); err != nil {
+							//FSM in waitForCommit or (UpgradeStRequestingActivate [lost ActivateResp] and commit allowed)
+							if err := pUpgradeStatemachine.Event(swupg.UpgradeEvCommitSw); err != nil {
 								logger.Errorw(ctx, "OnuSwUpgradeFSM: can't call commit event", log.Fields{"err": err})
 								return
 							}
 							logger.Debugw(ctx, "OnuSwUpgradeFSM commit image requested", log.Fields{
-								"state": upgradeState, "device-id": dh.deviceID})
+								"state": UpgradeState, "device-id": dh.DeviceID})
 						}
 					} else {
 						logger.Errorw(ctx, "OnuSwUpgradeFSM waiting to commit/on ActivateResponse, but load did not start with expected image Id",
-							log.Fields{"device-id": dh.deviceID})
+							log.Fields{"device-id": dh.DeviceID})
 						dh.pOnuUpradeFsm.CancelProcessing(ctx, true, voltha.ImageState_CANCELLED_ON_ONU_STATE) //complete abort
 						return
 					}
 				} else {
 					logger.Errorw(ctx, "OnuSwUpgradeFSM waiting to commit, but nothing to commit on ONU - abort upgrade",
-						log.Fields{"device-id": dh.deviceID})
+						log.Fields{"device-id": dh.DeviceID})
 					dh.pOnuUpradeFsm.CancelProcessing(ctx, true, voltha.ImageState_CANCELLED_ON_ONU_STATE) //complete abort
 					return
 				}
@@ -2791,24 +2741,24 @@
 				//upgrade FSM is active but not waiting for commit: maybe because commit flag is not set
 				// upgrade FSM is to be informed if the current active image is the one that was used in upgrade for the download
 				if activeImageID, err := pDevEntry.GetActiveImageMeID(ctx); err == nil {
-					if dh.pOnuUpradeFsm.inactiveImageMeID == activeImageID {
+					if dh.pOnuUpradeFsm.InactiveImageMeID == activeImageID {
 						logger.Debugw(ctx, "OnuSwUpgradeFSM image state set to activated", log.Fields{
-							"state": pUpgradeStatemachine.Current(), "device-id": dh.deviceID})
+							"state": pUpgradeStatemachine.Current(), "device-id": dh.DeviceID})
 						dh.pOnuUpradeFsm.SetImageStateActive(ctx)
 					}
 				}
 			}
 		}
 	} else {
-		logger.Debugw(ctx, "no ONU image to be committed", log.Fields{"device-id": dh.deviceID})
+		logger.Debugw(ctx, "no ONU image to be committed", log.Fields{"device-id": dh.DeviceID})
 	}
 }
 
-//setBackend provides a DB backend for the specified path on the existing KV client
-func (dh *deviceHandler) setBackend(ctx context.Context, aBasePathKvStore string) *db.Backend {
+//SetBackend provides a DB backend for the specified path on the existing KV client
+func (dh *deviceHandler) SetBackend(ctx context.Context, aBasePathKvStore string) *db.Backend {
 
 	logger.Debugw(ctx, "SetKVStoreBackend", log.Fields{"IpTarget": dh.pOpenOnuAc.KVStoreAddress,
-		"BasePathKvStore": aBasePathKvStore, "device-id": dh.deviceID})
+		"BasePathKvStore": aBasePathKvStore, "device-id": dh.DeviceID})
 	// kvbackend := db.NewBackend(ctx, dh.pOpenOnuAc.KVStoreType, dh.pOpenOnuAc.KVStoreAddress, dh.pOpenOnuAc.KVStoreTimeout, aBasePathKvStore)
 	kvbackend := &db.Backend{
 		Client:    dh.pOpenOnuAc.kvClient,
@@ -2827,20 +2777,20 @@
 		switch field.Type {
 		case of.OxmOfbFieldTypes_OFPXMT_OFB_ETH_TYPE:
 			{
-				logger.Debugw(ctx, "flow type EthType", log.Fields{"device-id": dh.deviceID,
+				logger.Debugw(ctx, "flow type EthType", log.Fields{"device-id": dh.DeviceID,
 					"EthType": strconv.FormatInt(int64(field.GetEthType()), 16)})
 			}
 		/* TT related temporary workaround - should not be needed anymore
 		case of.OxmOfbFieldTypes_OFPXMT_OFB_IP_PROTO:
 			{
 				*loIPProto = field.GetIpProto()
-				logger.Debugw("flow type IpProto", log.Fields{"device-id": dh.deviceID,
+				logger.Debugw("flow type IpProto", log.Fields{"device-id": dh.DeviceID,
 					"IpProto": strconv.FormatInt(int64(*loIPProto), 16)})
 				if *loIPProto == 2 {
 					// some workaround for TT workflow at proto == 2 (IGMP trap) -> ignore the flow
 					// avoids installing invalid EVTOCD rule
 					logger.Debugw("flow type IpProto 2: TT workaround: ignore flow",
-						log.Fields{"device-id": dh.deviceID})
+						log.Fields{"device-id": dh.DeviceID})
 					return
 				}
 			}
@@ -2853,38 +2803,38 @@
 					loMatchVlanMask == uint16(of.OfpVlanId_OFPVID_PRESENT)) {
 					*loMatchVlan = *loMatchVlan & 0xFFF // not transparent: copy only ID bits
 				}
-				logger.Debugw(ctx, "flow field type", log.Fields{"device-id": dh.deviceID,
+				logger.Debugw(ctx, "flow field type", log.Fields{"device-id": dh.DeviceID,
 					"VID": strconv.FormatInt(int64(*loMatchVlan), 16)})
 			}
 		case of.OxmOfbFieldTypes_OFPXMT_OFB_VLAN_PCP:
 			{
 				*loAddPcp = uint8(field.GetVlanPcp())
-				logger.Debugw(ctx, "flow field type", log.Fields{"device-id": dh.deviceID,
+				logger.Debugw(ctx, "flow field type", log.Fields{"device-id": dh.DeviceID,
 					"PCP": loAddPcp})
 			}
 		case of.OxmOfbFieldTypes_OFPXMT_OFB_UDP_DST:
 			{
-				logger.Debugw(ctx, "flow field type", log.Fields{"device-id": dh.deviceID,
+				logger.Debugw(ctx, "flow field type", log.Fields{"device-id": dh.DeviceID,
 					"UDP-DST": strconv.FormatInt(int64(field.GetUdpDst()), 16)})
 			}
 		case of.OxmOfbFieldTypes_OFPXMT_OFB_UDP_SRC:
 			{
-				logger.Debugw(ctx, "flow field type", log.Fields{"device-id": dh.deviceID,
+				logger.Debugw(ctx, "flow field type", log.Fields{"device-id": dh.DeviceID,
 					"UDP-SRC": strconv.FormatInt(int64(field.GetUdpSrc()), 16)})
 			}
 		case of.OxmOfbFieldTypes_OFPXMT_OFB_IPV4_DST:
 			{
-				logger.Debugw(ctx, "flow field type", log.Fields{"device-id": dh.deviceID,
+				logger.Debugw(ctx, "flow field type", log.Fields{"device-id": dh.DeviceID,
 					"IPv4-DST": field.GetIpv4Dst()})
 			}
 		case of.OxmOfbFieldTypes_OFPXMT_OFB_IPV4_SRC:
 			{
-				logger.Debugw(ctx, "flow field type", log.Fields{"device-id": dh.deviceID,
+				logger.Debugw(ctx, "flow field type", log.Fields{"device-id": dh.DeviceID,
 					"IPv4-SRC": field.GetIpv4Src()})
 			}
 		case of.OxmOfbFieldTypes_OFPXMT_OFB_METADATA:
 			{
-				logger.Debugw(ctx, "flow field type", log.Fields{"device-id": dh.deviceID,
+				logger.Debugw(ctx, "flow field type", log.Fields{"device-id": dh.DeviceID,
 					"Metadata": field.GetTableMetadata()})
 			}
 			/*
@@ -2903,32 +2853,32 @@
 		/* not used:
 		case of.OfpActionType_OFPAT_OUTPUT:
 			{
-				logger.Debugw("flow action type", log.Fields{"device-id": dh.deviceID,
+				logger.Debugw("flow action type", log.Fields{"device-id": dh.DeviceID,
 					"Output": action.GetOutput()})
 			}
 		*/
 		case of.OfpActionType_OFPAT_PUSH_VLAN:
 			{
-				logger.Debugw(ctx, "flow action type", log.Fields{"device-id": dh.deviceID,
+				logger.Debugw(ctx, "flow action type", log.Fields{"device-id": dh.DeviceID,
 					"PushEthType": strconv.FormatInt(int64(action.GetPush().Ethertype), 16)})
 			}
 		case of.OfpActionType_OFPAT_SET_FIELD:
 			{
 				pActionSetField := action.GetSetField()
 				if pActionSetField.Field.OxmClass != of.OfpOxmClass_OFPXMC_OPENFLOW_BASIC {
-					logger.Warnw(ctx, "flow action SetField invalid OxmClass (ignored)", log.Fields{"device-id": dh.deviceID,
+					logger.Warnw(ctx, "flow action SetField invalid OxmClass (ignored)", log.Fields{"device-id": dh.DeviceID,
 						"OxcmClass": pActionSetField.Field.OxmClass})
 				}
 				if pActionSetField.Field.GetOfbField().Type == of.OxmOfbFieldTypes_OFPXMT_OFB_VLAN_VID {
 					*loSetVlan = uint16(pActionSetField.Field.GetOfbField().GetVlanVid())
-					logger.Debugw(ctx, "flow Set VLAN from SetField action", log.Fields{"device-id": dh.deviceID,
+					logger.Debugw(ctx, "flow Set VLAN from SetField action", log.Fields{"device-id": dh.DeviceID,
 						"SetVlan": strconv.FormatInt(int64(*loSetVlan), 16)})
 				} else if pActionSetField.Field.GetOfbField().Type == of.OxmOfbFieldTypes_OFPXMT_OFB_VLAN_PCP {
 					*loSetPcp = uint8(pActionSetField.Field.GetOfbField().GetVlanPcp())
-					logger.Debugw(ctx, "flow Set PCP from SetField action", log.Fields{"device-id": dh.deviceID,
+					logger.Debugw(ctx, "flow Set PCP from SetField action", log.Fields{"device-id": dh.DeviceID,
 						"SetPcp": *loSetPcp})
 				} else {
-					logger.Warnw(ctx, "flow action SetField invalid FieldType", log.Fields{"device-id": dh.deviceID,
+					logger.Warnw(ctx, "flow action SetField invalid FieldType", log.Fields{"device-id": dh.DeviceID,
 						"Type": pActionSetField.Field.GetOfbField().Type})
 				}
 			}
@@ -2943,7 +2893,7 @@
 }
 
 //addFlowItemToUniPort parses the actual flow item to add it to the UniPort
-func (dh *deviceHandler) addFlowItemToUniPort(ctx context.Context, apFlowItem *of.OfpFlowStats, apUniPort *onuUniPort,
+func (dh *deviceHandler) addFlowItemToUniPort(ctx context.Context, apFlowItem *of.OfpFlowStats, apUniPort *cmn.OnuUniPort,
 	apFlowMetaData *voltha.FlowMetadata) error {
 	var loSetVlan uint16 = uint16(of.OfpVlanId_OFPVID_NONE)      //noValidEntry
 	var loMatchVlan uint16 = uint16(of.OfpVlanId_OFPVID_PRESENT) //reserved VLANID entry
@@ -2962,13 +2912,13 @@
 	metadata := flow.GetMetadataFromWriteMetadataAction(ctx, apFlowItem)
 	if metadata == 0 {
 		logger.Debugw(ctx, "flow-add invalid metadata - abort",
-			log.Fields{"device-id": dh.deviceID})
-		return fmt.Errorf("flow-add invalid metadata: %s", dh.deviceID)
+			log.Fields{"device-id": dh.DeviceID})
+		return fmt.Errorf("flow-add invalid metadata: %s", dh.DeviceID)
 	}
 	loTpID := uint8(flow.GetTechProfileIDFromWriteMetaData(ctx, metadata))
 	loCookie := apFlowItem.GetCookie()
 	loCookieSlice := []uint64{loCookie}
-	logger.Debugw(ctx, "flow-add base indications", log.Fields{"device-id": dh.deviceID,
+	logger.Debugw(ctx, "flow-add base indications", log.Fields{"device-id": dh.DeviceID,
 		"TechProf-Id": loTpID, "cookie": loCookie})
 
 	dh.getFlowOfbFields(ctx, apFlowItem, &loMatchVlan, &loAddPcp, &loIPProto)
@@ -2977,7 +2927,7 @@
 		// some workaround for TT workflow at proto == 2 (IGMP trap) -> ignore the flow
 		// avoids installing invalid EVTOCD rule
 		logger.Debugw("flow-add type IpProto 2: TT workaround: ignore flow",
-			log.Fields{"device-id": dh.deviceID})
+			log.Fields{"device-id": dh.DeviceID})
 		return nil
 	}
 	*/
@@ -2985,15 +2935,15 @@
 
 	if loSetVlan == uint16(of.OfpVlanId_OFPVID_NONE) && loMatchVlan != uint16(of.OfpVlanId_OFPVID_PRESENT) {
 		logger.Errorw(ctx, "flow-add aborted - SetVlanId undefined, but MatchVid set", log.Fields{
-			"device-id": dh.deviceID, "UniPort": apUniPort.portNo,
+			"device-id": dh.DeviceID, "UniPort": apUniPort.PortNo,
 			"set_vid":   strconv.FormatInt(int64(loSetVlan), 16),
 			"match_vid": strconv.FormatInt(int64(loMatchVlan), 16)})
 		//TODO!!: Use DeviceId within the error response to rwCore
 		//  likewise also in other error response cases to calling components as requested in [VOL-3458]
-		return fmt.Errorf("flow-add Set/Match VlanId inconsistent: %s", dh.deviceID)
+		return fmt.Errorf("flow-add Set/Match VlanId inconsistent: %s", dh.DeviceID)
 	}
 	if loSetVlan == uint16(of.OfpVlanId_OFPVID_NONE) && loMatchVlan == uint16(of.OfpVlanId_OFPVID_PRESENT) {
-		logger.Debugw(ctx, "flow-add vlan-any/copy", log.Fields{"device-id": dh.deviceID})
+		logger.Debugw(ctx, "flow-add vlan-any/copy", log.Fields{"device-id": dh.DeviceID})
 		loSetVlan = loMatchVlan //both 'transparent' (copy any)
 	} else {
 		//looks like OMCI value 4097 (copyFromOuter - for Uni double tagged) is not supported here
@@ -3001,7 +2951,7 @@
 			// not set to transparent
 			loSetVlan &= 0x0FFF //mask VID bits as prerequisite for vlanConfigFsm
 		}
-		logger.Debugw(ctx, "flow-add vlan-set", log.Fields{"device-id": dh.deviceID})
+		logger.Debugw(ctx, "flow-add vlan-set", log.Fields{"device-id": dh.DeviceID})
 	}
 
 	var meter *voltha.OfpMeterConfig
@@ -3014,11 +2964,11 @@
 	//  (also vlan persistency data does not support multiple FSM's on the same UNI correctly!)
 	dh.lockVlanAdd.Lock()     //prevent multiple add activities to start in parallel
 	dh.lockVlanConfig.RLock() //read protection on UniVlanConfigFsmMap (removeFlowItemFromUniPort)
-	logger.Debugw(ctx, "flow-add got lock", log.Fields{"device-id": dh.deviceID, "tpID": loTpID, "uniID": apUniPort.uniID})
-	if _, exist := dh.UniVlanConfigFsmMap[apUniPort.uniID]; exist {
+	logger.Debugw(ctx, "flow-add got lock", log.Fields{"device-id": dh.DeviceID, "tpID": loTpID, "uniID": apUniPort.UniID})
+	if _, exist := dh.UniVlanConfigFsmMap[apUniPort.UniID]; exist {
 		//SetUniFlowParams() may block on some rule that is suspended-to-add
 		//  in order to allow for according flow removal lockVlanConfig may only be used with RLock here
-		err := dh.UniVlanConfigFsmMap[apUniPort.uniID].SetUniFlowParams(ctx, loTpID, loCookieSlice,
+		err := dh.UniVlanConfigFsmMap[apUniPort.UniID].SetUniFlowParams(ctx, loTpID, loCookieSlice,
 			loMatchVlan, loSetVlan, loSetPcp, false, meter)
 		dh.lockVlanConfig.RUnlock()
 		dh.lockVlanAdd.Unlock() //re-admit new Add-flow-processing
@@ -3027,14 +2977,14 @@
 	dh.lockVlanConfig.RUnlock()
 	dh.lockVlanConfig.Lock() //createVlanFilterFsm should always be a non-blocking operation and requires r+w lock
 	err := dh.createVlanFilterFsm(ctx, apUniPort, loTpID, loCookieSlice,
-		loMatchVlan, loSetVlan, loSetPcp, OmciVlanFilterAddDone, false, meter)
+		loMatchVlan, loSetVlan, loSetPcp, cmn.OmciVlanFilterAddDone, false, meter)
 	dh.lockVlanConfig.Unlock()
 	dh.lockVlanAdd.Unlock() //re-admit new Add-flow-processing
 	return err
 }
 
 //removeFlowItemFromUniPort parses the actual flow item to remove it from the UniPort
-func (dh *deviceHandler) removeFlowItemFromUniPort(ctx context.Context, apFlowItem *of.OfpFlowStats, apUniPort *onuUniPort) error {
+func (dh *deviceHandler) removeFlowItemFromUniPort(ctx context.Context, apFlowItem *of.OfpFlowStats, apUniPort *cmn.OnuUniPort) error {
 	//optimization and assumption: the flow cookie uniquely identifies the flow and with that the internal rule
 	//hence only the cookie is used here to find the relevant flow and possibly remove the rule
 	//no extra check is done on the rule parameters
@@ -3044,18 +2994,18 @@
 	// from addFlow - where at reconcilement multiple cookies per flow ) can be configured in one sequence)
 	// - some possible 'delete-all' sequence would have to be implemented separately (where the cookies are don't care anyway)
 	loCookie := apFlowItem.GetCookie()
-	logger.Debugw(ctx, "flow-remove base indications", log.Fields{"device-id": dh.deviceID, "cookie": loCookie})
+	logger.Debugw(ctx, "flow-remove base indications", log.Fields{"device-id": dh.DeviceID, "cookie": loCookie})
 
 	/* TT related temporary workaround - should not be needed anymore
 	for _, field := range flow.GetOfbFields(apFlowItem) {
 		if field.Type == of.OxmOfbFieldTypes_OFPXMT_OFB_IP_PROTO {
 			loIPProto := field.GetIpProto()
-			logger.Debugw(ctx, "flow type IpProto", log.Fields{"device-id": dh.deviceID,
+			logger.Debugw(ctx, "flow type IpProto", log.Fields{"device-id": dh.DeviceID,
 				"IpProto": strconv.FormatInt(int64(loIPProto), 16)})
 			if loIPProto == 2 {
 				// some workaround for TT workflow on proto == 2 (IGMP trap) -> the flow was not added, no need to remove
 				logger.Debugw(ctx, "flow-remove type IpProto 2: TT workaround: ignore flow",
-					log.Fields{"device-id": dh.deviceID})
+					log.Fields{"device-id": dh.DeviceID})
 				return nil
 			}
 		}
@@ -3065,15 +3015,15 @@
 	//mutex protection as the update_flow rpc maybe running concurrently for different flows, perhaps also activities
 	dh.lockVlanConfig.RLock()
 	defer dh.lockVlanConfig.RUnlock()
-	logger.Debugw(ctx, "flow-remove got RLock", log.Fields{"device-id": dh.deviceID, "uniID": apUniPort.uniID})
-	if _, exist := dh.UniVlanConfigFsmMap[apUniPort.uniID]; exist {
-		return dh.UniVlanConfigFsmMap[apUniPort.uniID].RemoveUniFlowParams(ctx, loCookie)
+	logger.Debugw(ctx, "flow-remove got RLock", log.Fields{"device-id": dh.DeviceID, "uniID": apUniPort.UniID})
+	if _, exist := dh.UniVlanConfigFsmMap[apUniPort.UniID]; exist {
+		return dh.UniVlanConfigFsmMap[apUniPort.UniID].RemoveUniFlowParams(ctx, loCookie)
 	}
 	logger.Debugw(ctx, "flow-remove called, but no flow is configured (no VlanConfigFsm, flow already removed) ",
-		log.Fields{"device-id": dh.deviceID})
+		log.Fields{"device-id": dh.DeviceID})
 	//but as we regard the flow as not existing = removed we respond just ok
 	// and treat the reason accordingly (which in the normal removal procedure is initiated by the FSM)
-	go dh.deviceProcStatusUpdate(ctx, OmciVlanFilterRemDone)
+	go dh.DeviceProcStatusUpdate(ctx, cmn.OmciVlanFilterRemDone)
 
 	return nil
 }
@@ -3081,48 +3031,48 @@
 // createVlanFilterFsm initializes and runs the VlanFilter FSM to transfer OMCI related VLAN config
 // if this function is called from possibly concurrent processes it must be mutex-protected from the caller!
 // precondition: dh.lockVlanConfig is locked by the caller!
-func (dh *deviceHandler) createVlanFilterFsm(ctx context.Context, apUniPort *onuUniPort, aTpID uint8, aCookieSlice []uint64,
-	aMatchVlan uint16, aSetVlan uint16, aSetPcp uint8, aDevEvent OnuDeviceEvent, lastFlowToReconcile bool, aMeter *voltha.OfpMeterConfig) error {
-	chVlanFilterFsm := make(chan Message, 2048)
+func (dh *deviceHandler) createVlanFilterFsm(ctx context.Context, apUniPort *cmn.OnuUniPort, aTpID uint8, aCookieSlice []uint64,
+	aMatchVlan uint16, aSetVlan uint16, aSetPcp uint8, aDevEvent cmn.OnuDeviceEvent, lastFlowToReconcile bool, aMeter *voltha.OfpMeterConfig) error {
+	chVlanFilterFsm := make(chan cmn.Message, 2048)
 
-	pDevEntry := dh.getOnuDeviceEntry(ctx, true)
+	pDevEntry := dh.GetOnuDeviceEntry(ctx, true)
 	if pDevEntry == nil {
-		logger.Errorw(ctx, "No valid OnuDevice -aborting", log.Fields{"device-id": dh.deviceID})
-		return fmt.Errorf("no valid OnuDevice for device-id %x - aborting", dh.deviceID)
+		logger.Errorw(ctx, "No valid OnuDevice -aborting", log.Fields{"device-id": dh.DeviceID})
+		return fmt.Errorf("no valid OnuDevice for device-id %x - aborting", dh.DeviceID)
 	}
 
-	pVlanFilterFsm := NewUniVlanConfigFsm(ctx, dh, pDevEntry.PDevOmciCC, apUniPort, dh.pOnuTP,
-		pDevEntry.pOnuDB, aTpID, aDevEvent, "UniVlanConfigFsm", chVlanFilterFsm,
+	pVlanFilterFsm := avcfg.NewUniVlanConfigFsm(ctx, dh, pDevEntry, pDevEntry.PDevOmciCC, apUniPort, dh.pOnuTP,
+		pDevEntry.GetOnuDB(), aTpID, aDevEvent, "UniVlanConfigFsm", chVlanFilterFsm,
 		dh.pOpenOnuAc.AcceptIncrementalEvto, aCookieSlice, aMatchVlan, aSetVlan, aSetPcp, lastFlowToReconcile, aMeter)
 	if pVlanFilterFsm != nil {
 		//dh.lockVlanConfig is locked (by caller) throughout the state transition to 'starting'
 		// to prevent unintended (ignored) events to be sent there (from parallel processing)
-		dh.UniVlanConfigFsmMap[apUniPort.uniID] = pVlanFilterFsm
-		pVlanFilterStatemachine := pVlanFilterFsm.pAdaptFsm.pFsm
+		dh.UniVlanConfigFsmMap[apUniPort.UniID] = pVlanFilterFsm
+		pVlanFilterStatemachine := pVlanFilterFsm.PAdaptFsm.PFsm
 		if pVlanFilterStatemachine != nil {
-			if pVlanFilterStatemachine.Is(vlanStDisabled) {
-				if err := pVlanFilterStatemachine.Event(vlanEvStart); err != nil {
+			if pVlanFilterStatemachine.Is(avcfg.VlanStDisabled) {
+				if err := pVlanFilterStatemachine.Event(avcfg.VlanEvStart); err != nil {
 					logger.Warnw(ctx, "UniVlanConfigFsm: can't start", log.Fields{"err": err})
-					return fmt.Errorf("can't start UniVlanConfigFsm for device-id %x", dh.deviceID)
+					return fmt.Errorf("can't start UniVlanConfigFsm for device-id %x", dh.DeviceID)
 				}
 				/***** UniVlanConfigFsm started */
 				logger.Debugw(ctx, "UniVlanConfigFsm started", log.Fields{
-					"state": pVlanFilterStatemachine.Current(), "device-id": dh.deviceID,
-					"UniPort": apUniPort.portNo})
+					"state": pVlanFilterStatemachine.Current(), "device-id": dh.DeviceID,
+					"UniPort": apUniPort.PortNo})
 			} else {
 				logger.Warnw(ctx, "wrong state of UniVlanConfigFsm - want: disabled", log.Fields{
-					"have": pVlanFilterStatemachine.Current(), "device-id": dh.deviceID})
-				return fmt.Errorf("uniVlanConfigFsm not in expected disabled state for device-id %x", dh.deviceID)
+					"have": pVlanFilterStatemachine.Current(), "device-id": dh.DeviceID})
+				return fmt.Errorf("uniVlanConfigFsm not in expected disabled state for device-id %x", dh.DeviceID)
 			}
 		} else {
 			logger.Errorw(ctx, "UniVlanConfigFsm StateMachine invalid - cannot be executed!!", log.Fields{
-				"device-id": dh.deviceID})
-			return fmt.Errorf("uniVlanConfigFsm invalid for device-id %x", dh.deviceID)
+				"device-id": dh.DeviceID})
+			return fmt.Errorf("uniVlanConfigFsm invalid for device-id %x", dh.DeviceID)
 		}
 	} else {
 		logger.Errorw(ctx, "UniVlanConfigFsm could not be created - abort!!", log.Fields{
-			"device-id": dh.deviceID, "UniPort": apUniPort.portNo})
-		return fmt.Errorf("uniVlanConfigFsm could not be created for device-id %x", dh.deviceID)
+			"device-id": dh.DeviceID, "UniPort": apUniPort.PortNo})
+		return fmt.Errorf("uniVlanConfigFsm could not be created for device-id %x", dh.DeviceID)
 	}
 	return nil
 }
@@ -3131,69 +3081,69 @@
 // and starts verification of flow config based on that
 func (dh *deviceHandler) VerifyVlanConfigRequest(ctx context.Context, aUniID uint8, aTpID uint8) {
 	//ensure that the given uniID is available (configured) in the UniPort class (used for OMCI entities)
-	var pCurrentUniPort *onuUniPort
+	var pCurrentUniPort *cmn.OnuUniPort
 	for _, uniPort := range dh.uniEntityMap {
 		// only if this port is validated for operState transfer
-		if uniPort.uniID == uint8(aUniID) {
+		if uniPort.UniID == uint8(aUniID) {
 			pCurrentUniPort = uniPort
 			break //found - end search loop
 		}
 	}
 	if pCurrentUniPort == nil {
 		logger.Debugw(ctx, "VerifyVlanConfig aborted: requested uniID not found in PortDB",
-			log.Fields{"device-id": dh.deviceID, "uni-id": aUniID})
+			log.Fields{"device-id": dh.DeviceID, "uni-id": aUniID})
 		return
 	}
-	dh.verifyUniVlanConfigRequest(ctx, pCurrentUniPort, aTpID)
+	dh.VerifyUniVlanConfigRequest(ctx, pCurrentUniPort, aTpID)
 }
 
-//verifyUniVlanConfigRequest checks on existence of flow configuration and starts it accordingly
-func (dh *deviceHandler) verifyUniVlanConfigRequest(ctx context.Context, apUniPort *onuUniPort, aTpID uint8) {
+//VerifyUniVlanConfigRequest checks on existence of flow configuration and starts it accordingly
+func (dh *deviceHandler) VerifyUniVlanConfigRequest(ctx context.Context, apUniPort *cmn.OnuUniPort, aTpID uint8) {
 	//TODO!! verify and start pending flow configuration
 	//some pending config request my exist in case the UniVlanConfig FSM was already started - with internal data -
 	//but execution was set to 'on hold' as first the TechProfile config had to be applied
 
 	dh.lockVlanConfig.RLock()
-	if pVlanFilterFsm, exist := dh.UniVlanConfigFsmMap[apUniPort.uniID]; exist {
+	if pVlanFilterFsm, exist := dh.UniVlanConfigFsmMap[apUniPort.UniID]; exist {
 		dh.lockVlanConfig.RUnlock()
 		//VlanFilterFsm exists and was already started (assumed to wait for TechProfile execution here)
-		pVlanFilterStatemachine := pVlanFilterFsm.pAdaptFsm.pFsm
+		pVlanFilterStatemachine := pVlanFilterFsm.PAdaptFsm.PFsm
 		if pVlanFilterStatemachine != nil {
 			//if this was an event of the TP processing that was waited for in the VlanFilterFsm
 			if pVlanFilterFsm.GetWaitingTpID() == aTpID {
-				if pVlanFilterStatemachine.Is(vlanStWaitingTechProf) {
-					if err := pVlanFilterStatemachine.Event(vlanEvContinueConfig); err != nil {
+				if pVlanFilterStatemachine.Is(avcfg.VlanStWaitingTechProf) {
+					if err := pVlanFilterStatemachine.Event(avcfg.VlanEvContinueConfig); err != nil {
 						logger.Warnw(ctx, "UniVlanConfigFsm: can't continue processing", log.Fields{"err": err,
-							"device-id": dh.deviceID, "UniPort": apUniPort.portNo})
+							"device-id": dh.DeviceID, "UniPort": apUniPort.PortNo})
 					} else {
 						/***** UniVlanConfigFsm continued */
 						logger.Debugw(ctx, "UniVlanConfigFsm continued", log.Fields{
-							"state": pVlanFilterStatemachine.Current(), "device-id": dh.deviceID,
-							"UniPort": apUniPort.portNo})
+							"state": pVlanFilterStatemachine.Current(), "device-id": dh.DeviceID,
+							"UniPort": apUniPort.PortNo})
 					}
-				} else if pVlanFilterStatemachine.Is(vlanStIncrFlowWaitTP) {
-					if err := pVlanFilterStatemachine.Event(vlanEvIncrFlowConfig); err != nil {
+				} else if pVlanFilterStatemachine.Is(avcfg.VlanStIncrFlowWaitTP) {
+					if err := pVlanFilterStatemachine.Event(avcfg.VlanEvIncrFlowConfig); err != nil {
 						logger.Warnw(ctx, "UniVlanConfigFsm: can't continue processing", log.Fields{"err": err,
-							"device-id": dh.deviceID, "UniPort": apUniPort.portNo})
+							"device-id": dh.DeviceID, "UniPort": apUniPort.PortNo})
 					} else {
 						/***** UniVlanConfigFsm continued */
 						logger.Debugw(ctx, "UniVlanConfigFsm continued with incremental flow", log.Fields{
-							"state": pVlanFilterStatemachine.Current(), "device-id": dh.deviceID,
-							"UniPort": apUniPort.portNo})
+							"state": pVlanFilterStatemachine.Current(), "device-id": dh.DeviceID,
+							"UniPort": apUniPort.PortNo})
 					}
 				} else {
 					logger.Debugw(ctx, "no state of UniVlanConfigFsm to be continued", log.Fields{
-						"have": pVlanFilterStatemachine.Current(), "device-id": dh.deviceID,
-						"UniPort": apUniPort.portNo})
+						"have": pVlanFilterStatemachine.Current(), "device-id": dh.DeviceID,
+						"UniPort": apUniPort.PortNo})
 				}
 			} else {
 				logger.Debugw(ctx, "TechProfile Ready event for TpId that was not waited for in the VlanConfigFsm - continue waiting", log.Fields{
-					"state": pVlanFilterStatemachine.Current(), "device-id": dh.deviceID,
-					"UniPort": apUniPort.portNo, "techprofile-id (done)": aTpID})
+					"state": pVlanFilterStatemachine.Current(), "device-id": dh.DeviceID,
+					"UniPort": apUniPort.PortNo, "techprofile-id (done)": aTpID})
 			}
 		} else {
 			logger.Debugw(ctx, "UniVlanConfigFsm StateMachine does not exist, no flow processing", log.Fields{
-				"device-id": dh.deviceID, "UniPort": apUniPort.portNo})
+				"device-id": dh.DeviceID, "UniPort": apUniPort.PortNo})
 		}
 	} else {
 		dh.lockVlanConfig.RUnlock()
@@ -3202,17 +3152,17 @@
 
 //RemoveVlanFilterFsm deletes the stored pointer to the VlanConfigFsm
 // intention is to provide this method to be called from VlanConfigFsm itself, when resources (and methods!) are cleaned up
-func (dh *deviceHandler) RemoveVlanFilterFsm(ctx context.Context, apUniPort *onuUniPort) {
+func (dh *deviceHandler) RemoveVlanFilterFsm(ctx context.Context, apUniPort *cmn.OnuUniPort) {
 	logger.Debugw(ctx, "remove UniVlanConfigFsm StateMachine", log.Fields{
-		"device-id": dh.deviceID, "uniPort": apUniPort.portNo})
+		"device-id": dh.DeviceID, "uniPort": apUniPort.PortNo})
 	//save to do, even if entry dows not exist
 	dh.lockVlanConfig.Lock()
-	delete(dh.UniVlanConfigFsmMap, apUniPort.uniID)
+	delete(dh.UniVlanConfigFsmMap, apUniPort.UniID)
 	dh.lockVlanConfig.Unlock()
 }
 
 //startWritingOnuDataToKvStore initiates the KVStore write of ONU persistent data
-func (dh *deviceHandler) startWritingOnuDataToKvStore(ctx context.Context, aPDevEntry *OnuDeviceEntry) error {
+func (dh *deviceHandler) startWritingOnuDataToKvStore(ctx context.Context, aPDevEntry *mib.OnuDeviceEntry) error {
 	dh.mutexKvStoreContext.Lock()         //this write routine may (could) be called with the same context,
 	defer dh.mutexKvStoreContext.Unlock() //this write routine may (could) be called with the same context,
 	// obviously then parallel processing on the cancel must be avoided
@@ -3221,33 +3171,33 @@
 	deadline := time.Now().Add(dh.pOpenOnuAc.maxTimeoutInterAdapterComm) //allowed run time to finish before execution
 	dctx, cancel := context.WithDeadline(context.Background(), deadline)
 
-	aPDevEntry.resetKvProcessingErrorIndication()
+	aPDevEntry.ResetKvProcessingErrorIndication()
 	var wg sync.WaitGroup
 	wg.Add(1) // for the 1 go routine to finish
 
-	go aPDevEntry.updateOnuKvStore(log.WithSpanFromContext(dctx, ctx), &wg)
+	go aPDevEntry.UpdateOnuKvStore(log.WithSpanFromContext(dctx, ctx), &wg)
 	dh.waitForCompletion(ctx, cancel, &wg, "UpdateKvStore") //wait for background process to finish
 
-	return aPDevEntry.getKvProcessingErrorIndication()
+	return aPDevEntry.GetKvProcessingErrorIndication()
 }
 
-//storePersUniFlowConfig updates local storage of OnuUniFlowConfig and writes it into kv-store afterwards to have it
+//StorePersUniFlowConfig updates local storage of OnuUniFlowConfig and writes it into kv-store afterwards to have it
 //available for potential reconcilement
-func (dh *deviceHandler) storePersUniFlowConfig(ctx context.Context, aUniID uint8,
-	aUniVlanFlowParams *[]uniVlanFlowParams, aWriteToKvStore bool) error {
+func (dh *deviceHandler) StorePersUniFlowConfig(ctx context.Context, aUniID uint8,
+	aUniVlanFlowParams *[]cmn.UniVlanFlowParams, aWriteToKvStore bool) error {
 
-	if dh.isReconciling() {
-		logger.Debugw(ctx, "reconciling - don't store persistent UniFlowConfig", log.Fields{"device-id": dh.deviceID})
+	if dh.IsReconciling() {
+		logger.Debugw(ctx, "reconciling - don't store persistent UniFlowConfig", log.Fields{"device-id": dh.DeviceID})
 		return nil
 	}
-	logger.Debugw(ctx, "Store or clear persistent UniFlowConfig", log.Fields{"device-id": dh.deviceID})
+	logger.Debugw(ctx, "Store or clear persistent UniFlowConfig", log.Fields{"device-id": dh.DeviceID})
 
-	pDevEntry := dh.getOnuDeviceEntry(ctx, true)
+	pDevEntry := dh.GetOnuDeviceEntry(ctx, true)
 	if pDevEntry == nil {
-		logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
-		return fmt.Errorf("no valid OnuDevice: %s", dh.deviceID)
+		logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.DeviceID})
+		return fmt.Errorf("no valid OnuDevice: %s", dh.DeviceID)
 	}
-	pDevEntry.updateOnuUniFlowConfig(aUniID, aUniVlanFlowParams)
+	pDevEntry.UpdateOnuUniFlowConfig(aUniID, aUniVlanFlowParams)
 
 	if aWriteToKvStore {
 		return dh.startWritingOnuDataToKvStore(ctx, pDevEntry)
@@ -3259,34 +3209,34 @@
 	defer cancel() //ensure termination of context (may be pro forma)
 	wg.Wait()
 	logger.Debugw(ctx, "WaitGroup processing completed", log.Fields{
-		"device-id": dh.deviceID, "called from": aCallerIdent})
+		"device-id": dh.DeviceID, "called from": aCallerIdent})
 }
 
 func (dh *deviceHandler) deviceReasonUpdate(ctx context.Context, deviceReason uint8, notifyCore bool) error {
 
-	dh.setDeviceReason(deviceReason)
+	dh.SetDeviceReason(deviceReason)
 	if notifyCore {
 		//TODO with VOL-3045/VOL-3046: return the error and stop further processing at calling position
 		if err := dh.updateDeviceReasonInCore(ctx, &ic.DeviceReason{
-			DeviceId: dh.deviceID,
-			Reason:   deviceReasonMap[deviceReason],
+			DeviceId: dh.DeviceID,
+			Reason:   cmn.DeviceReasonMap[deviceReason],
 		}); err != nil {
 			logger.Errorf(ctx, "DeviceReasonUpdate error: %s",
-				log.Fields{"device-id": dh.deviceID, "error": err}, deviceReasonMap[deviceReason])
+				log.Fields{"device-id": dh.DeviceID, "error": err}, cmn.DeviceReasonMap[deviceReason])
 			return err
 		}
-		logger.Infof(ctx, "DeviceReasonUpdate success: %s - device-id: %s", deviceReasonMap[deviceReason], dh.deviceID)
+		logger.Infof(ctx, "DeviceReasonUpdate success: %s - device-id: %s", cmn.DeviceReasonMap[deviceReason], dh.DeviceID)
 		return nil
 	}
-	logger.Infof(ctx, "Don't notify core about DeviceReasonUpdate: %s - device-id: %s", deviceReasonMap[deviceReason], dh.deviceID)
+	logger.Infof(ctx, "Don't notify core about DeviceReasonUpdate: %s - device-id: %s", cmn.DeviceReasonMap[deviceReason], dh.DeviceID)
 	return nil
 }
 
-func (dh *deviceHandler) storePersistentData(ctx context.Context) error {
-	pDevEntry := dh.getOnuDeviceEntry(ctx, true)
+func (dh *deviceHandler) StorePersistentData(ctx context.Context) error {
+	pDevEntry := dh.GetOnuDeviceEntry(ctx, true)
 	if pDevEntry == nil {
-		logger.Warnw(ctx, "No valid OnuDevice", log.Fields{"device-id": dh.deviceID})
-		return fmt.Errorf("no valid OnuDevice: %s", dh.deviceID)
+		logger.Warnw(ctx, "No valid OnuDevice", log.Fields{"device-id": dh.DeviceID})
+		return fmt.Errorf("no valid OnuDevice: %s", dh.DeviceID)
 	}
 	return dh.startWritingOnuDataToKvStore(ctx, pDevEntry)
 }
@@ -3297,7 +3247,7 @@
 	dh.lockDevice.RLock()
 	defer dh.lockDevice.RUnlock()
 	if uniPort, ok := dh.uniEntityMap[uniPortNo]; ok {
-		return uniPort.entityID, nil
+		return uniPort.EntityID, nil
 	}
 	return 0, errors.New("error-fetching-uni-port")
 }
@@ -3316,10 +3266,10 @@
 	// TODO: Although it is possible to revert to old config in case of partial failure, the code becomes quite complex. Needs more investigation
 	// Is it possible the rw-core reverts to old config on partial failure but adapter retains a partial new config?
 	if len(errorsList) > 0 {
-		logger.Errorw(ctx, "one-or-more-pm-config-failed", log.Fields{"device-id": dh.deviceID, "pmConfig": dh.pmConfigs})
+		logger.Errorw(ctx, "one-or-more-pm-config-failed", log.Fields{"device-id": dh.DeviceID, "pmConfig": dh.pmConfigs})
 		return fmt.Errorf("errors-handling-one-or-more-pm-config, errors:%v", errorsList)
 	}
-	logger.Infow(ctx, "pm-config-updated", log.Fields{"device-id": dh.deviceID, "pmConfig": dh.pmConfigs})
+	logger.Infow(ctx, "pm-config-updated", log.Fields{"device-id": dh.DeviceID, "pmConfig": dh.pmConfigs})
 	return nil
 }
 
@@ -3329,7 +3279,7 @@
 	logger.Infow(ctx, "handling-global-pm-config-params - start", log.Fields{"device-id": dh.device.Id})
 
 	if pmConfigs.DefaultFreq != dh.pmConfigs.DefaultFreq {
-		if err = dh.pOnuMetricsMgr.updateDefaultFrequency(ctx, pmConfigs); err != nil {
+		if err = dh.pOnuMetricsMgr.UpdateDefaultFrequency(ctx, pmConfigs); err != nil {
 			errorsList = append(errorsList, err)
 		}
 	}
@@ -3344,17 +3294,17 @@
 	logger.Debugw(ctx, "handling-group-pm-config-params - start", log.Fields{"device-id": dh.device.Id})
 	// Check if group metric related config is updated
 	for _, v := range pmConfigs.Groups {
-		dh.pOnuMetricsMgr.onuMetricsManagerLock.RLock()
-		m, ok := dh.pOnuMetricsMgr.groupMetricMap[v.GroupName]
-		dh.pOnuMetricsMgr.onuMetricsManagerLock.RUnlock()
+		dh.pOnuMetricsMgr.OnuMetricsManagerLock.RLock()
+		m, ok := dh.pOnuMetricsMgr.GroupMetricMap[v.GroupName]
+		dh.pOnuMetricsMgr.OnuMetricsManagerLock.RUnlock()
 
-		if ok && m.frequency != v.GroupFreq {
-			if err = dh.pOnuMetricsMgr.updateGroupFreq(ctx, v.GroupName, pmConfigs); err != nil {
+		if ok && m.Frequency != v.GroupFreq {
+			if err = dh.pOnuMetricsMgr.UpdateGroupFreq(ctx, v.GroupName, pmConfigs); err != nil {
 				errorsList = append(errorsList, err)
 			}
 		}
-		if ok && m.enabled != v.Enabled {
-			if err = dh.pOnuMetricsMgr.updateGroupSupport(ctx, v.GroupName, pmConfigs); err != nil {
+		if ok && m.Enabled != v.Enabled {
+			if err = dh.pOnuMetricsMgr.UpdateGroupSupport(ctx, v.GroupName, pmConfigs); err != nil {
 				errorsList = append(errorsList, err)
 			}
 		}
@@ -3369,17 +3319,17 @@
 	logger.Debugw(ctx, "handling-individual-pm-config-params - start", log.Fields{"device-id": dh.device.Id})
 	// Check if standalone metric related config is updated
 	for _, v := range pmConfigs.Metrics {
-		dh.pOnuMetricsMgr.onuMetricsManagerLock.RLock()
-		m, ok := dh.pOnuMetricsMgr.standaloneMetricMap[v.Name]
-		dh.pOnuMetricsMgr.onuMetricsManagerLock.RUnlock()
+		dh.pOnuMetricsMgr.OnuMetricsManagerLock.RLock()
+		m, ok := dh.pOnuMetricsMgr.StandaloneMetricMap[v.Name]
+		dh.pOnuMetricsMgr.OnuMetricsManagerLock.RUnlock()
 
-		if ok && m.frequency != v.SampleFreq {
-			if err = dh.pOnuMetricsMgr.updateMetricFreq(ctx, v.Name, pmConfigs); err != nil {
+		if ok && m.Frequency != v.SampleFreq {
+			if err = dh.pOnuMetricsMgr.UpdateMetricFreq(ctx, v.Name, pmConfigs); err != nil {
 				errorsList = append(errorsList, err)
 			}
 		}
-		if ok && m.enabled != v.Enabled {
-			if err = dh.pOnuMetricsMgr.updateMetricSupport(ctx, v.Name, pmConfigs); err != nil {
+		if ok && m.Enabled != v.Enabled {
+			if err = dh.pOnuMetricsMgr.UpdateMetricSupport(ctx, v.Name, pmConfigs); err != nil {
 				errorsList = append(errorsList, err)
 			}
 		}
@@ -3389,17 +3339,17 @@
 }
 
 // nolint: gocyclo
-func (dh *deviceHandler) startCollector(ctx context.Context) {
+func (dh *deviceHandler) StartCollector(ctx context.Context) {
 	logger.Debugf(ctx, "startingCollector")
 
 	// Start routine to process OMCI GET Responses
-	go dh.pOnuMetricsMgr.processOmciMessages(ctx)
+	go dh.pOnuMetricsMgr.ProcessOmciMessages(ctx)
 	// Create Extended Frame PM ME
-	go dh.pOnuMetricsMgr.createEthernetFrameExtendedPMME(ctx)
+	go dh.pOnuMetricsMgr.CreateEthernetFrameExtendedPMME(ctx)
 	// Initialize the next metric collection time.
 	// Normally done when the onu_metrics_manager is initialized the first time, but needed again later when ONU is
 	// reset like onu rebooted.
-	dh.pOnuMetricsMgr.initializeMetricCollectionTime(ctx)
+	dh.pOnuMetricsMgr.InitializeMetricCollectionTime(ctx)
 	dh.setCollectorIsRunning(true)
 	for {
 		select {
@@ -3408,67 +3358,67 @@
 			logger.Debugw(ctx, "stopping-collector-for-onu", log.Fields{"device-id": dh.device.Id})
 			// Stop the L2 PM FSM
 			go func() {
-				if dh.pOnuMetricsMgr.pAdaptFsm != nil && dh.pOnuMetricsMgr.pAdaptFsm.pFsm != nil {
-					if err := dh.pOnuMetricsMgr.pAdaptFsm.pFsm.Event(l2PmEventStop); err != nil {
-						logger.Errorw(ctx, "error calling event", log.Fields{"device-id": dh.deviceID, "err": err})
+				if dh.pOnuMetricsMgr.PAdaptFsm != nil && dh.pOnuMetricsMgr.PAdaptFsm.PFsm != nil {
+					if err := dh.pOnuMetricsMgr.PAdaptFsm.PFsm.Event(pmmgr.L2PmEventStop); err != nil {
+						logger.Errorw(ctx, "error calling event", log.Fields{"device-id": dh.DeviceID, "err": err})
 					}
 				} else {
-					logger.Errorw(ctx, "metrics manager fsm not initialized", log.Fields{"device-id": dh.deviceID})
+					logger.Errorw(ctx, "metrics manager fsm not initialized", log.Fields{"device-id": dh.DeviceID})
 				}
 			}()
-			if dh.pOnuMetricsMgr.getOmciProcessingStatus() {
-				dh.pOnuMetricsMgr.stopProcessingOmciResponses <- true // Stop the OMCI GET response processing routine
+			if dh.pOnuMetricsMgr.GetOmciProcessingStatus() {
+				dh.pOnuMetricsMgr.StopProcessingOmciResponses <- true // Stop the OMCI GET response processing routine
 			}
-			if dh.pOnuMetricsMgr.getTickGenerationStatus() {
-				dh.pOnuMetricsMgr.stopTicks <- true
+			if dh.pOnuMetricsMgr.GetTickGenerationStatus() {
+				dh.pOnuMetricsMgr.StopTicks <- true
 			}
 
 			return
-		case <-time.After(time.Duration(FrequencyGranularity) * time.Second): // Check every FrequencyGranularity to see if it is time for collecting metrics
-			if !dh.pmConfigs.FreqOverride { // If FreqOverride is false, then nextGlobalMetricCollectionTime applies
-				// If the current time is eqaul to or greater than the nextGlobalMetricCollectionTime, collect the group and standalone metrics
-				if time.Now().Equal(dh.pOnuMetricsMgr.nextGlobalMetricCollectionTime) || time.Now().After(dh.pOnuMetricsMgr.nextGlobalMetricCollectionTime) {
-					go dh.pOnuMetricsMgr.collectAllGroupAndStandaloneMetrics(ctx)
+		case <-time.After(time.Duration(pmmgr.FrequencyGranularity) * time.Second): // Check every FrequencyGranularity to see if it is time for collecting metrics
+			if !dh.pmConfigs.FreqOverride { // If FreqOverride is false, then NextGlobalMetricCollectionTime applies
+				// If the current time is eqaul to or greater than the NextGlobalMetricCollectionTime, collect the group and standalone metrics
+				if time.Now().Equal(dh.pOnuMetricsMgr.NextGlobalMetricCollectionTime) || time.Now().After(dh.pOnuMetricsMgr.NextGlobalMetricCollectionTime) {
+					go dh.pOnuMetricsMgr.CollectAllGroupAndStandaloneMetrics(ctx)
 					// Update the next metric collection time.
-					dh.pOnuMetricsMgr.nextGlobalMetricCollectionTime = time.Now().Add(time.Duration(dh.pmConfigs.DefaultFreq) * time.Second)
+					dh.pOnuMetricsMgr.NextGlobalMetricCollectionTime = time.Now().Add(time.Duration(dh.pmConfigs.DefaultFreq) * time.Second)
 				}
 			} else {
 				if dh.pmConfigs.Grouped { // metrics are managed as a group
 					// parse through the group and standalone metrics to see it is time to collect their metrics
-					dh.pOnuMetricsMgr.onuMetricsManagerLock.RLock() // Rlock as we are reading groupMetricMap and standaloneMetricMap
+					dh.pOnuMetricsMgr.OnuMetricsManagerLock.RLock() // Rlock as we are reading GroupMetricMap and StandaloneMetricMap
 
-					for n, g := range dh.pOnuMetricsMgr.groupMetricMap {
-						// If the group is enabled AND (current time is equal to OR after nextCollectionInterval, collect the group metric)
+					for n, g := range dh.pOnuMetricsMgr.GroupMetricMap {
+						// If the group is enabled AND (current time is equal to OR after NextCollectionInterval, collect the group metric)
 						// Since the L2 PM counters are collected in a separate FSM, we should avoid those counters in the check.
-						if g.enabled && !g.isL2PMCounter && (time.Now().Equal(g.nextCollectionInterval) || time.Now().After(g.nextCollectionInterval)) {
-							go dh.pOnuMetricsMgr.collectGroupMetric(ctx, n)
+						if g.Enabled && !g.IsL2PMCounter && (time.Now().Equal(g.NextCollectionInterval) || time.Now().After(g.NextCollectionInterval)) {
+							go dh.pOnuMetricsMgr.CollectGroupMetric(ctx, n)
 						}
 					}
-					for n, m := range dh.pOnuMetricsMgr.standaloneMetricMap {
-						// If the standalone is enabled AND (current time is equal to OR after nextCollectionInterval, collect the metric)
-						if m.enabled && (time.Now().Equal(m.nextCollectionInterval) || time.Now().After(m.nextCollectionInterval)) {
-							go dh.pOnuMetricsMgr.collectStandaloneMetric(ctx, n)
+					for n, m := range dh.pOnuMetricsMgr.StandaloneMetricMap {
+						// If the standalone is enabled AND (current time is equal to OR after NextCollectionInterval, collect the metric)
+						if m.Enabled && (time.Now().Equal(m.NextCollectionInterval) || time.Now().After(m.NextCollectionInterval)) {
+							go dh.pOnuMetricsMgr.CollectStandaloneMetric(ctx, n)
 						}
 					}
-					dh.pOnuMetricsMgr.onuMetricsManagerLock.RUnlock()
+					dh.pOnuMetricsMgr.OnuMetricsManagerLock.RUnlock()
 
 					// parse through the group and update the next metric collection time
-					dh.pOnuMetricsMgr.onuMetricsManagerLock.Lock() // Lock as we are writing the next metric collection time
-					for _, g := range dh.pOnuMetricsMgr.groupMetricMap {
-						// If group enabled, and the nextCollectionInterval is old (before or equal to current time), update the next collection time stamp
+					dh.pOnuMetricsMgr.OnuMetricsManagerLock.Lock() // Lock as we are writing the next metric collection time
+					for _, g := range dh.pOnuMetricsMgr.GroupMetricMap {
+						// If group enabled, and the NextCollectionInterval is old (before or equal to current time), update the next collection time stamp
 						// Since the L2 PM counters are collected and managed in a separate FSM, we should avoid those counters in the check.
-						if g.enabled && !g.isL2PMCounter && (g.nextCollectionInterval.Before(time.Now()) || g.nextCollectionInterval.Equal(time.Now())) {
-							g.nextCollectionInterval = time.Now().Add(time.Duration(g.frequency) * time.Second)
+						if g.Enabled && !g.IsL2PMCounter && (g.NextCollectionInterval.Before(time.Now()) || g.NextCollectionInterval.Equal(time.Now())) {
+							g.NextCollectionInterval = time.Now().Add(time.Duration(g.Frequency) * time.Second)
 						}
 					}
 					// parse through the standalone metrics and update the next metric collection time
-					for _, m := range dh.pOnuMetricsMgr.standaloneMetricMap {
-						// If standalone metrics enabled, and the nextCollectionInterval is old (before or equal to current time), update the next collection time stamp
-						if m.enabled && (m.nextCollectionInterval.Before(time.Now()) || m.nextCollectionInterval.Equal(time.Now())) {
-							m.nextCollectionInterval = time.Now().Add(time.Duration(m.frequency) * time.Second)
+					for _, m := range dh.pOnuMetricsMgr.StandaloneMetricMap {
+						// If standalone metrics enabled, and the NextCollectionInterval is old (before or equal to current time), update the next collection time stamp
+						if m.Enabled && (m.NextCollectionInterval.Before(time.Now()) || m.NextCollectionInterval.Equal(time.Now())) {
+							m.NextCollectionInterval = time.Now().Add(time.Duration(m.Frequency) * time.Second)
 						}
 					}
-					dh.pOnuMetricsMgr.onuMetricsManagerLock.Unlock()
+					dh.pOnuMetricsMgr.OnuMetricsManagerLock.Unlock()
 				} /* else { // metrics are not managed as a group
 					// TODO: We currently do not have standalone metrics. When available, add code here to fetch the metric.
 				} */
@@ -3477,10 +3427,10 @@
 	}
 }
 
-func (dh *deviceHandler) getUniPortStatus(ctx context.Context, uniInfo *extension.GetOnuUniInfoRequest) *extension.SingleGetValueResponse {
+func (dh *deviceHandler) GetUniPortStatus(ctx context.Context, uniInfo *extension.GetOnuUniInfoRequest) *extension.SingleGetValueResponse {
 
-	portStatus := NewUniPortStatus(dh.pOnuOmciDevice.PDevOmciCC)
-	return portStatus.getUniPortStatus(ctx, uniInfo.UniIndex)
+	portStatus := uniprt.NewUniPortStatus(dh, dh.pOnuOmciDevice.PDevOmciCC)
+	return portStatus.GetUniPortStatus(ctx, uniInfo.UniIndex)
 }
 
 func (dh *deviceHandler) getOnuOMCICounters(ctx context.Context, onuInfo *extension.GetOmciEthernetFrameExtendedPmRequest) *extension.SingleGetValueResponse {
@@ -3492,75 +3442,75 @@
 			},
 		}
 	}
-	resp := dh.pOnuMetricsMgr.collectEthernetFrameExtendedPMCounters(ctx)
+	resp := dh.pOnuMetricsMgr.CollectEthernetFrameExtendedPMCounters(ctx)
 	return resp
 }
 
-func (dh *deviceHandler) isFsmInOmciIdleState(ctx context.Context, pFsm *fsm.FSM, wantedState string) bool {
-	if pFsm == nil {
+func (dh *deviceHandler) isFsmInOmciIdleState(ctx context.Context, PFsm *fsm.FSM, wantedState string) bool {
+	if PFsm == nil {
 		return true //FSM not active - so there is no activity on omci
 	}
-	return pFsm.Current() == wantedState
+	return PFsm.Current() == wantedState
 }
 
-func (dh *deviceHandler) isFsmInOmciIdleStateDefault(ctx context.Context, omciFsm usedOmciConfigFsms, wantedState string) bool {
-	var pFsm *fsm.FSM
+func (dh *deviceHandler) isFsmInOmciIdleStateDefault(ctx context.Context, omciFsm cmn.UsedOmciConfigFsms, wantedState string) bool {
+	var PFsm *fsm.FSM
 	//note/TODO!!: might be that access to all these specific FSM; pointers need a semaphore protection as well, cmp lockUpgradeFsm
 	switch omciFsm {
-	case cUploadFsm:
+	case cmn.CUploadFsm:
 		{
-			pFsm = dh.pOnuOmciDevice.pMibUploadFsm.pFsm
+			PFsm = dh.pOnuOmciDevice.PMibUploadFsm.PFsm
 		}
-	case cDownloadFsm:
+	case cmn.CDownloadFsm:
 		{
-			pFsm = dh.pOnuOmciDevice.pMibDownloadFsm.pFsm
+			PFsm = dh.pOnuOmciDevice.PMibDownloadFsm.PFsm
 		}
-	case cUniLockFsm:
+	case cmn.CUniLockFsm:
 		{
-			pFsm = dh.pLockStateFsm.pAdaptFsm.pFsm
+			PFsm = dh.pLockStateFsm.PAdaptFsm.PFsm
 		}
-	case cUniUnLockFsm:
+	case cmn.CUniUnLockFsm:
 		{
-			pFsm = dh.pUnlockStateFsm.pAdaptFsm.pFsm
+			PFsm = dh.pUnlockStateFsm.PAdaptFsm.PFsm
 		}
-	case cL2PmFsm:
+	case cmn.CL2PmFsm:
 		{
-			if dh.pOnuMetricsMgr != nil && dh.pOnuMetricsMgr.pAdaptFsm != nil {
-				pFsm = dh.pOnuMetricsMgr.pAdaptFsm.pFsm
+			if dh.pOnuMetricsMgr != nil && dh.pOnuMetricsMgr.PAdaptFsm != nil {
+				PFsm = dh.pOnuMetricsMgr.PAdaptFsm.PFsm
 			} else {
 				return true //FSM not active - so there is no activity on omci
 			}
 		}
-	case cOnuUpgradeFsm:
+	case cmn.COnuUpgradeFsm:
 		{
 			dh.lockUpgradeFsm.RLock()
 			defer dh.lockUpgradeFsm.RUnlock()
-			pFsm = dh.pOnuUpradeFsm.pAdaptFsm.pFsm
+			PFsm = dh.pOnuUpradeFsm.PAdaptFsm.PFsm
 		}
 	default:
 		{
 			logger.Errorw(ctx, "invalid stateMachine selected for idle check", log.Fields{
-				"device-id": dh.deviceID, "selectedFsm number": omciFsm})
+				"device-id": dh.DeviceID, "selectedFsm number": omciFsm})
 			return false //logical error in FSM check, do not not indicate 'idle' - we can't be sure
 		}
 	}
-	return dh.isFsmInOmciIdleState(ctx, pFsm, wantedState)
+	return dh.isFsmInOmciIdleState(ctx, PFsm, wantedState)
 }
 
-func (dh *deviceHandler) isAniConfigFsmInOmciIdleState(ctx context.Context, omciFsm usedOmciConfigFsms, idleState string) bool {
-	for _, v := range dh.pOnuTP.pAniConfigFsm {
-		if !dh.isFsmInOmciIdleState(ctx, v.pAdaptFsm.pFsm, idleState) {
+func (dh *deviceHandler) isAniConfigFsmInOmciIdleState(ctx context.Context, omciFsm cmn.UsedOmciConfigFsms, idleState string) bool {
+	for _, v := range dh.pOnuTP.PAniConfigFsm {
+		if !dh.isFsmInOmciIdleState(ctx, v.PAdaptFsm.PFsm, idleState) {
 			return false
 		}
 	}
 	return true
 }
 
-func (dh *deviceHandler) isUniVlanConfigFsmInOmciIdleState(ctx context.Context, omciFsm usedOmciConfigFsms, idleState string) bool {
+func (dh *deviceHandler) isUniVlanConfigFsmInOmciIdleState(ctx context.Context, omciFsm cmn.UsedOmciConfigFsms, idleState string) bool {
 	dh.lockVlanConfig.RLock()
 	defer dh.lockVlanConfig.RUnlock()
 	for _, v := range dh.UniVlanConfigFsmMap {
-		if !dh.isFsmInOmciIdleState(ctx, v.pAdaptFsm.pFsm, idleState) {
+		if !dh.isFsmInOmciIdleState(ctx, v.PAdaptFsm.PFsm, idleState) {
 			return false
 		}
 	}
@@ -3571,8 +3521,8 @@
 	dh.lockVlanConfig.RLock()
 	defer dh.lockVlanConfig.RUnlock()
 	for _, v := range dh.UniVlanConfigFsmMap {
-		if v.pAdaptFsm.pFsm != nil {
-			if v.pAdaptFsm.pFsm.Is(cVlanFsmConfiguredState) {
+		if v.PAdaptFsm.PFsm != nil {
+			if v.PAdaptFsm.PFsm.Is(avcfg.CVlanFsmConfiguredState) {
 				return true //there is at least one VLAN FSM with some active configuration
 			}
 		}
@@ -3580,7 +3530,7 @@
 	return false //there is no VLAN FSM with some active configuration
 }
 
-func (dh *deviceHandler) checkAuditStartCondition(ctx context.Context, callingFsm usedOmciConfigFsms) bool {
+func (dh *deviceHandler) CheckAuditStartCondition(ctx context.Context, callingFsm cmn.UsedOmciConfigFsms) bool {
 	for fsmName, fsmStruct := range fsmOmciIdleStateFuncMap {
 		if fsmName != callingFsm && !fsmStruct.omciIdleCheckFunc(dh, ctx, fsmName, fsmStruct.omciIdleState) {
 			return false
@@ -3591,15 +3541,15 @@
 	return dh.checkUserServiceExists(ctx)
 }
 
-func (dh *deviceHandler) prepareReconcilingWithActiveAdapter(ctx context.Context) {
+func (dh *deviceHandler) PrepareReconcilingWithActiveAdapter(ctx context.Context) {
 	logger.Debugw(ctx, "prepare to reconcile the ONU with adapter using persistency data", log.Fields{"device-id": dh.device.Id})
 	if err := dh.resetFsms(ctx, false); err != nil {
-		logger.Errorw(ctx, "reset of FSMs failed!", log.Fields{"device-id": dh.deviceID, "error": err})
+		logger.Errorw(ctx, "reset of FSMs failed!", log.Fields{"device-id": dh.DeviceID, "error": err})
 		// TODO: fatal error reset ONU, delete deviceHandler!
 		return
 	}
-	dh.uniEntityMap = make(map[uint32]*onuUniPort)
-	dh.startReconciling(ctx, false)
+	dh.uniEntityMap = make(map[uint32]*cmn.OnuUniPort)
+	dh.StartReconciling(ctx, false)
 }
 
 func (dh *deviceHandler) setCollectorIsRunning(flagValue bool) {
@@ -3608,7 +3558,7 @@
 	dh.mutexCollectorFlag.Unlock()
 }
 
-func (dh *deviceHandler) getCollectorIsRunning() bool {
+func (dh *deviceHandler) GetCollectorIsRunning() bool {
 	dh.mutexCollectorFlag.RLock()
 	flagValue := dh.collectorIsRunning
 	dh.mutexCollectorFlag.RUnlock()
@@ -3621,7 +3571,7 @@
 	dh.mutextAlarmManagerFlag.Unlock()
 }
 
-func (dh *deviceHandler) getAlarmManagerIsRunning(ctx context.Context) bool {
+func (dh *deviceHandler) GetAlarmManagerIsRunning(ctx context.Context) bool {
 	dh.mutextAlarmManagerFlag.RLock()
 	flagValue := dh.alarmManagerIsRunning
 	logger.Debugw(ctx, "alarm-manager-is-running", log.Fields{"flag": dh.alarmManagerIsRunning})
@@ -3629,95 +3579,95 @@
 	return flagValue
 }
 
-func (dh *deviceHandler) startAlarmManager(ctx context.Context) {
+func (dh *deviceHandler) StartAlarmManager(ctx context.Context) {
 	logger.Debugf(ctx, "startingAlarmManager")
 
 	// Start routine to process OMCI GET Responses
-	go dh.pAlarmMgr.startOMCIAlarmMessageProcessing(ctx)
+	go dh.pAlarmMgr.StartOMCIAlarmMessageProcessing(ctx)
 	dh.setAlarmManagerIsRunning(true)
 	if stop := <-dh.stopAlarmManager; stop {
 		logger.Debugw(ctx, "stopping-collector-for-onu", log.Fields{"device-id": dh.device.Id})
 		dh.setAlarmManagerIsRunning(false)
 		go func() {
-			if dh.pAlarmMgr.alarmSyncFsm != nil && dh.pAlarmMgr.alarmSyncFsm.pFsm != nil {
-				_ = dh.pAlarmMgr.alarmSyncFsm.pFsm.Event(asEvStop)
+			if dh.pAlarmMgr.AlarmSyncFsm != nil && dh.pAlarmMgr.AlarmSyncFsm.PFsm != nil {
+				_ = dh.pAlarmMgr.AlarmSyncFsm.PFsm.Event(almgr.AsEvStop)
 			}
 		}()
-		dh.pAlarmMgr.stopProcessingOmciMessages <- true // Stop the OMCI routines if any(This will stop the fsms also)
-		dh.pAlarmMgr.stopAlarmAuditTimer <- struct{}{}
+		dh.pAlarmMgr.StopProcessingOmciMessages <- true // Stop the OMCI routines if any(This will stop the fsms also)
+		dh.pAlarmMgr.StopAlarmAuditTimer <- struct{}{}
 		logger.Debugw(ctx, "sent-all-stop-signals-to-alarm-manager", log.Fields{"device-id": dh.device.Id})
 	}
 }
 
-func (dh *deviceHandler) startReconciling(ctx context.Context, skipOnuConfig bool) {
-	logger.Debugw(ctx, "start reconciling", log.Fields{"skipOnuConfig": skipOnuConfig, "device-id": dh.deviceID})
+func (dh *deviceHandler) StartReconciling(ctx context.Context, skipOnuConfig bool) {
+	logger.Debugw(ctx, "start reconciling", log.Fields{"skipOnuConfig": skipOnuConfig, "device-id": dh.DeviceID})
 
 	connectStatus := voltha.ConnectStatus_UNREACHABLE
 	operState := voltha.OperStatus_UNKNOWN
 
-	if !dh.isReconciling() {
+	if !dh.IsReconciling() {
 		go func() {
 			logger.Debugw(ctx, "wait for channel signal or timeout",
-				log.Fields{"timeout": dh.pOpenOnuAc.maxTimeoutReconciling, "device-id": dh.deviceID})
+				log.Fields{"timeout": dh.pOpenOnuAc.maxTimeoutReconciling, "device-id": dh.DeviceID})
 			select {
 			case success := <-dh.chReconcilingFinished:
 				if success {
-					if onuDevEntry := dh.getOnuDeviceEntry(ctx, true); onuDevEntry == nil {
+					if onuDevEntry := dh.GetOnuDeviceEntry(ctx, true); onuDevEntry == nil {
 						logger.Errorw(ctx, "No valid OnuDevice - aborting Core DeviceStateUpdate",
-							log.Fields{"device-id": dh.deviceID})
+							log.Fields{"device-id": dh.DeviceID})
 					} else {
-						if onuDevEntry.sOnuPersistentData.PersOperState == "up" {
+						if onuDevEntry.SOnuPersistentData.PersOperState == "up" {
 							connectStatus = voltha.ConnectStatus_REACHABLE
-							if !onuDevEntry.sOnuPersistentData.PersUniDisableDone {
-								if onuDevEntry.sOnuPersistentData.PersUniUnlockDone {
+							if !onuDevEntry.SOnuPersistentData.PersUniDisableDone {
+								if onuDevEntry.SOnuPersistentData.PersUniUnlockDone {
 									operState = voltha.OperStatus_ACTIVE
 								} else {
 									operState = voltha.OperStatus_ACTIVATING
 								}
 							}
-						} else if onuDevEntry.sOnuPersistentData.PersOperState == "down" ||
-							onuDevEntry.sOnuPersistentData.PersOperState == "unknown" ||
-							onuDevEntry.sOnuPersistentData.PersOperState == "" {
+						} else if onuDevEntry.SOnuPersistentData.PersOperState == "down" ||
+							onuDevEntry.SOnuPersistentData.PersOperState == "unknown" ||
+							onuDevEntry.SOnuPersistentData.PersOperState == "" {
 							operState = voltha.OperStatus_DISCOVERED
 						}
 
 						logger.Debugw(ctx, "Core DeviceStateUpdate", log.Fields{"connectStatus": connectStatus, "operState": operState})
 					}
 					logger.Debugw(ctx, "reconciling has been finished in time",
-						log.Fields{"device-id": dh.deviceID})
+						log.Fields{"device-id": dh.DeviceID})
 					if err := dh.updateDeviceStateInCore(ctx, &ic.DeviceStateFilter{
-						DeviceId:   dh.deviceID,
+						DeviceId:   dh.DeviceID,
 						ConnStatus: connectStatus,
 						OperStatus: operState,
 					}); err != nil {
 						logger.Errorw(ctx, "unable to update device state to core",
-							log.Fields{"device-id": dh.deviceID, "Err": err})
+							log.Fields{"device-id": dh.DeviceID, "Err": err})
 					}
 				} else {
 					logger.Errorw(ctx, "wait for reconciling aborted",
-						log.Fields{"device-id": dh.deviceID})
+						log.Fields{"device-id": dh.DeviceID})
 
-					if onuDevEntry := dh.getOnuDeviceEntry(ctx, true); onuDevEntry == nil {
+					if onuDevEntry := dh.GetOnuDeviceEntry(ctx, true); onuDevEntry == nil {
 						logger.Errorw(ctx, "No valid OnuDevice",
-							log.Fields{"device-id": dh.deviceID})
-					} else if onuDevEntry.sOnuPersistentData.PersOperState == "up" {
+							log.Fields{"device-id": dh.DeviceID})
+					} else if onuDevEntry.SOnuPersistentData.PersOperState == "up" {
 						connectStatus = voltha.ConnectStatus_REACHABLE
 					}
 
-					dh.deviceReconcileFailedUpdate(ctx, drReconcileCanceled, connectStatus)
+					dh.deviceReconcileFailedUpdate(ctx, cmn.DrReconcileCanceled, connectStatus)
 				}
 			case <-time.After(dh.pOpenOnuAc.maxTimeoutReconciling):
 				logger.Errorw(ctx, "timeout waiting for reconciling to be finished!",
-					log.Fields{"device-id": dh.deviceID})
+					log.Fields{"device-id": dh.DeviceID})
 
-				if onuDevEntry := dh.getOnuDeviceEntry(ctx, true); onuDevEntry == nil {
+				if onuDevEntry := dh.GetOnuDeviceEntry(ctx, true); onuDevEntry == nil {
 					logger.Errorw(ctx, "No valid OnuDevice",
-						log.Fields{"device-id": dh.deviceID})
-				} else if onuDevEntry.sOnuPersistentData.PersOperState == "up" {
+						log.Fields{"device-id": dh.DeviceID})
+				} else if onuDevEntry.SOnuPersistentData.PersOperState == "up" {
 					connectStatus = voltha.ConnectStatus_REACHABLE
 				}
 
-				dh.deviceReconcileFailedUpdate(ctx, drReconcileMaxTimeout, connectStatus)
+				dh.deviceReconcileFailedUpdate(ctx, cmn.DrReconcileMaxTimeout, connectStatus)
 
 			}
 			dh.mutexReconcilingFlag.Lock()
@@ -3734,28 +3684,28 @@
 	dh.mutexReconcilingFlag.Unlock()
 }
 
-func (dh *deviceHandler) stopReconciling(ctx context.Context, success bool) {
-	logger.Debugw(ctx, "stop reconciling", log.Fields{"device-id": dh.deviceID, "success": success})
-	if dh.isReconciling() {
+func (dh *deviceHandler) StopReconciling(ctx context.Context, success bool) {
+	logger.Debugw(ctx, "stop reconciling", log.Fields{"device-id": dh.DeviceID, "success": success})
+	if dh.IsReconciling() {
 		dh.chReconcilingFinished <- success
 	} else {
-		logger.Infow(ctx, "reconciling is not running", log.Fields{"device-id": dh.deviceID})
+		logger.Infow(ctx, "reconciling is not running", log.Fields{"device-id": dh.DeviceID})
 	}
 }
 
-func (dh *deviceHandler) isReconciling() bool {
+func (dh *deviceHandler) IsReconciling() bool {
 	dh.mutexReconcilingFlag.RLock()
 	defer dh.mutexReconcilingFlag.RUnlock()
 	return dh.reconciling != cNoReconciling
 }
 
-func (dh *deviceHandler) isSkipOnuConfigReconciling() bool {
+func (dh *deviceHandler) IsSkipOnuConfigReconciling() bool {
 	dh.mutexReconcilingFlag.RLock()
 	defer dh.mutexReconcilingFlag.RUnlock()
 	return dh.reconciling == cSkipOnuConfigReconciling
 }
 
-func (dh *deviceHandler) setDeviceReason(value uint8) {
+func (dh *deviceHandler) SetDeviceReason(value uint8) {
 	dh.mutexDeviceReason.Lock()
 	dh.deviceReason = value
 	dh.mutexDeviceReason.Unlock()
@@ -3768,29 +3718,16 @@
 	return value
 }
 
-func (dh *deviceHandler) getDeviceReasonString() string {
-	return deviceReasonMap[dh.getDeviceReason()]
+func (dh *deviceHandler) GetDeviceReasonString() string {
+	return cmn.DeviceReasonMap[dh.getDeviceReason()]
 }
 
-func (dh *deviceHandler) setReconcilingFlows(value bool) {
-	dh.mutexReconcilingFlowsFlag.Lock()
-	dh.reconcilingFlows = value
-	dh.mutexReconcilingFlowsFlag.Unlock()
-}
-
-func (dh *deviceHandler) isReconcilingFlows() bool {
-	dh.mutexReconcilingFlowsFlag.RLock()
-	value := dh.reconcilingFlows
-	dh.mutexReconcilingFlowsFlag.RUnlock()
-	return value
-}
-
-func (dh *deviceHandler) setReadyForOmciConfig(flagValue bool) {
+func (dh *deviceHandler) SetReadyForOmciConfig(flagValue bool) {
 	dh.mutexReadyForOmciConfig.Lock()
 	dh.readyForOmciConfig = flagValue
 	dh.mutexReadyForOmciConfig.Unlock()
 }
-func (dh *deviceHandler) isReadyForOmciConfig() bool {
+func (dh *deviceHandler) IsReadyForOmciConfig() bool {
 	dh.mutexReadyForOmciConfig.RLock()
 	flagValue := dh.readyForOmciConfig
 	dh.mutexReadyForOmciConfig.RUnlock()
@@ -3800,17 +3737,17 @@
 func (dh *deviceHandler) deviceReconcileFailedUpdate(ctx context.Context, deviceReason uint8, connectStatus voltha.ConnectStatus_Types) {
 	if err := dh.deviceReasonUpdate(ctx, deviceReason, true); err != nil {
 		logger.Errorw(ctx, "unable to update device reason to core",
-			log.Fields{"device-id": dh.deviceID, "Err": err})
+			log.Fields{"device-id": dh.DeviceID, "Err": err})
 	}
 
 	logger.Debugw(ctx, "Core DeviceStateUpdate", log.Fields{"connectStatus": connectStatus, "operState": voltha.OperStatus_RECONCILING_FAILED})
 	if err := dh.updateDeviceStateInCore(ctx, &ic.DeviceStateFilter{
-		DeviceId:   dh.deviceID,
+		DeviceId:   dh.DeviceID,
 		ConnStatus: connectStatus,
 		OperStatus: voltha.OperStatus_RECONCILING_FAILED,
 	}); err != nil {
 		logger.Errorw(ctx, "unable to update device state to core",
-			log.Fields{"device-id": dh.deviceID, "Err": err})
+			log.Fields{"device-id": dh.DeviceID, "Err": err})
 	}
 }
 
@@ -3865,7 +3802,7 @@
 	return err
 }
 
-func (dh *deviceHandler) createPortInCore(ctx context.Context, port *voltha.Port) error {
+func (dh *deviceHandler) CreatePortInCore(ctx context.Context, port *voltha.Port) error {
 	cClient, err := dh.coreClient.GetCoreServiceClient()
 	if err != nil || cClient == nil {
 		return err
@@ -3917,7 +3854,7 @@
 	return pgClient.GetTechProfileInstance(subCtx, request)
 }
 
-func (dh *deviceHandler) sendOMCIRequest(ctx context.Context, parentEndpoint string, request *ic.OmciMessage) error {
+func (dh *deviceHandler) SendOMCIRequest(ctx context.Context, parentEndpoint string, request *ic.OmciMessage) error {
 	pgClient, err := dh.pOpenOnuAc.getParentAdapterServiceClient(parentEndpoint)
 	if err != nil || pgClient == nil {
 		return err
@@ -3931,3 +3868,133 @@
 	}
 	return err
 }
+
+// GetDeviceID - TODO: add comment
+func (dh *deviceHandler) GetDeviceID() string {
+	return dh.DeviceID
+}
+
+// GetProxyAddressID - TODO: add comment
+func (dh *deviceHandler) GetProxyAddressID() string {
+	return dh.device.ProxyAddress.GetDeviceId()
+}
+
+// GetProxyAddressType - TODO: add comment
+func (dh *deviceHandler) GetProxyAddressType() string {
+	return dh.device.ProxyAddress.GetDeviceType()
+}
+
+// GetProxyAddress - TODO: add comment
+func (dh *deviceHandler) GetProxyAddress() *voltha.Device_ProxyAddress {
+	return dh.device.ProxyAddress
+}
+
+// GetEventProxy - TODO: add comment
+func (dh *deviceHandler) GetEventProxy() eventif.EventProxy {
+	return dh.EventProxy
+}
+
+// GetOmciTimeout - TODO: add comment
+func (dh *deviceHandler) GetOmciTimeout() int {
+	return dh.pOpenOnuAc.omciTimeout
+}
+
+// GetAlarmAuditInterval - TODO: add comment
+func (dh *deviceHandler) GetAlarmAuditInterval() time.Duration {
+	return dh.pOpenOnuAc.alarmAuditInterval
+}
+
+// GetDlToOnuTimeout4M - TODO: add comment
+func (dh *deviceHandler) GetDlToOnuTimeout4M() time.Duration {
+	return dh.pOpenOnuAc.dlToOnuTimeout4M
+}
+
+// GetUniEntityMap - TODO: add comment
+func (dh *deviceHandler) GetUniEntityMap() *cmn.OnuUniPortMap {
+	return &dh.uniEntityMap
+}
+
+// GetPonPortNumber - TODO: add comment
+func (dh *deviceHandler) GetPonPortNumber() *uint32 {
+	return &dh.ponPortNumber
+}
+
+// GetUniVlanConfigFsm - TODO: add comment
+func (dh *deviceHandler) GetUniVlanConfigFsm(uniID uint8) cmn.IuniVlanConfigFsm {
+	return dh.UniVlanConfigFsmMap[uniID]
+}
+
+// GetOnuAlarmManager - TODO: add comment
+func (dh *deviceHandler) GetOnuAlarmManager() cmn.IonuAlarmManager {
+	return dh.pAlarmMgr
+}
+
+// GetOnuMetricsManager - TODO: add comment
+func (dh *deviceHandler) GetOnuMetricsManager() cmn.IonuMetricsManager {
+	return dh.pOnuMetricsMgr
+}
+
+// GetOnuTP - TODO: add comment
+func (dh *deviceHandler) GetOnuTP() cmn.IonuUniTechProf {
+	return dh.pOnuTP
+}
+
+// GetBackendPathPrefix - TODO: add comment
+func (dh *deviceHandler) GetBackendPathPrefix() string {
+	return dh.pOpenOnuAc.cm.Backend.PathPrefix
+}
+
+// GetOnuIndication - TODO: add comment
+func (dh *deviceHandler) GetOnuIndication() *openolt.OnuIndication {
+	return dh.pOnuIndication
+}
+
+// RLockMutexDeletionInProgressFlag - TODO: add comment
+func (dh *deviceHandler) RLockMutexDeletionInProgressFlag() {
+	dh.mutexDeletionInProgressFlag.RLock()
+}
+
+// RUnlockMutexDeletionInProgressFlag - TODO: add comment
+func (dh *deviceHandler) RUnlockMutexDeletionInProgressFlag() {
+	dh.mutexDeletionInProgressFlag.RUnlock()
+}
+
+// GetDeletionInProgress - TODO: add comment
+func (dh *deviceHandler) GetDeletionInProgress() bool {
+	return dh.deletionInProgress
+}
+
+// GetPmConfigs - TODO: add comment
+func (dh *deviceHandler) GetPmConfigs() *voltha.PmConfigs {
+	return dh.pmConfigs
+}
+
+// GetDeviceType - TODO: add comment
+func (dh *deviceHandler) GetDeviceType() string {
+	return dh.DeviceType
+}
+
+// GetLogicalDeviceID - TODO: add comment
+func (dh *deviceHandler) GetLogicalDeviceID() string {
+	return dh.logicalDeviceID
+}
+
+// GetDevice - TODO: add comment
+func (dh *deviceHandler) GetDevice() *voltha.Device {
+	return dh.device
+}
+
+// GetMetricsEnabled - TODO: add comment
+func (dh *deviceHandler) GetMetricsEnabled() bool {
+	return dh.pOpenOnuAc.MetricsEnabled
+}
+
+// InitPmConfigs - TODO: add comment
+func (dh *deviceHandler) InitPmConfigs() {
+	dh.pmConfigs = &voltha.PmConfigs{}
+}
+
+// GetUniPortMask - TODO: add comment
+func (dh *deviceHandler) GetUniPortMask() int {
+	return dh.pOpenOnuAc.config.UniPortMask
+}
diff --git a/internal/pkg/onuadaptercore/openonu.go b/internal/pkg/core/openonu.go
old mode 100644
new mode 100755
similarity index 92%
rename from internal/pkg/onuadaptercore/openonu.go
rename to internal/pkg/core/openonu.go
index eecd002..a7ad35c
--- a/internal/pkg/onuadaptercore/openonu.go
+++ b/internal/pkg/core/openonu.go
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package core provides the utility for onu devices, flows and statistics
+package core
 
 import (
 	"context"
@@ -39,14 +39,17 @@
 	ic "github.com/opencord/voltha-protos/v5/go/inter_container"
 	"github.com/opencord/voltha-protos/v5/go/voltha"
 
+	cmn "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/common"
 	"github.com/opencord/voltha-openonu-adapter-go/internal/pkg/config"
+	"github.com/opencord/voltha-openonu-adapter-go/internal/pkg/swupg"
+	uniprt "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/uniprt"
 )
 
 //OpenONUAC structure holds the ONU core information
 type OpenONUAC struct {
 	deviceHandlers              map[string]*deviceHandler
 	deviceHandlersCreateChan    map[string]chan bool //channels for deviceHandler create events
-	lockDeviceHandlersMap       sync.RWMutex
+	mutexDeviceHandlersMap      sync.RWMutex
 	coreClient                  *vgrpc.Client
 	parentAdapterClients        map[string]*vgrpc.Client
 	lockParentAdapterClients    sync.RWMutex
@@ -59,18 +62,18 @@
 	KVStoreType                 string
 	KVStoreTimeout              time.Duration
 	mibTemplatesGenerated       map[string]bool
-	lockMibTemplateGenerated    sync.RWMutex
+	mutexMibTemplateGenerated   sync.RWMutex
 	exitChannel                 chan int
 	HeartbeatCheckInterval      time.Duration
 	HeartbeatFailReportInterval time.Duration
 	AcceptIncrementalEvto       bool
 	//GrpcTimeoutInterval         time.Duration
-	pSupportedFsms             *OmciDeviceFsms
+	pSupportedFsms             *cmn.OmciDeviceFsms
 	maxTimeoutInterAdapterComm time.Duration
 	maxTimeoutReconciling      time.Duration
-	pDownloadManager           *adapterDownloadManager
-	pFileManager               *fileDownloadManager //let coexist 'old and new' DownloadManager as long as 'old' does not get obsolete
-	metricsEnabled             bool
+	pDownloadManager           *swupg.AdapterDownloadManager
+	pFileManager               *swupg.FileDownloadManager //let coexist 'old and new' DownloadManager as long as 'old' does not get obsolete
+	MetricsEnabled             bool
 	mibAuditInterval           time.Duration
 	omciTimeout                int // in seconds
 	alarmAuditInterval         time.Duration
@@ -86,7 +89,7 @@
 	openOnuAc.deviceHandlers = make(map[string]*deviceHandler)
 	openOnuAc.deviceHandlersCreateChan = make(map[string]chan bool)
 	openOnuAc.parentAdapterClients = make(map[string]*vgrpc.Client)
-	openOnuAc.lockDeviceHandlersMap = sync.RWMutex{}
+	openOnuAc.mutexDeviceHandlersMap = sync.RWMutex{}
 	openOnuAc.config = cfg
 	openOnuAc.cm = cm
 	openOnuAc.coreClient = coreClient
@@ -97,14 +100,14 @@
 	openOnuAc.KVStoreType = cfg.KVStoreType
 	openOnuAc.KVStoreTimeout = cfg.KVStoreTimeout
 	openOnuAc.mibTemplatesGenerated = make(map[string]bool)
-	openOnuAc.lockMibTemplateGenerated = sync.RWMutex{}
+	openOnuAc.mutexMibTemplateGenerated = sync.RWMutex{}
 	openOnuAc.HeartbeatCheckInterval = cfg.HeartbeatCheckInterval
 	openOnuAc.HeartbeatFailReportInterval = cfg.HeartbeatFailReportInterval
 	openOnuAc.AcceptIncrementalEvto = cfg.AccIncrEvto
 	openOnuAc.maxTimeoutInterAdapterComm = cfg.MaxTimeoutInterAdapterComm
 	openOnuAc.maxTimeoutReconciling = cfg.MaxTimeoutReconciling
 	//openOnuAc.GrpcTimeoutInterval = cfg.GrpcTimeoutInterval
-	openOnuAc.metricsEnabled = cfg.MetricsEnabled
+	openOnuAc.MetricsEnabled = cfg.MetricsEnabled
 	openOnuAc.mibAuditInterval = cfg.MibAuditInterval
 	// since consumers of OMCI timeout value everywhere in code is in "int seconds", do this useful conversion
 	openOnuAc.omciTimeout = int(cfg.OmciTimeout.Seconds())
@@ -112,12 +115,12 @@
 	openOnuAc.dlToOnuTimeout4M = cfg.DownloadToOnuTimeout4MB
 	openOnuAc.rpcTimeout = cfg.RPCTimeout
 
-	openOnuAc.pSupportedFsms = &OmciDeviceFsms{
+	openOnuAc.pSupportedFsms = &cmn.OmciDeviceFsms{
 		"mib-synchronizer": {
 			//mibSyncFsm,        // Implements the MIB synchronization state machine
-			mibDbVolatileDictImpl, // Implements volatile ME MIB database
+			DatabaseClass: mibDbVolatileDictImpl, // Implements volatile ME MIB database
 			//true,                  // Advertise events on OpenOMCI event bus
-			openOnuAc.mibAuditInterval, // Time to wait between MIB audits.  0 to disable audits.
+			AuditInterval: openOnuAc.mibAuditInterval, // Time to wait between MIB audits.  0 to disable audits.
 			// map[string]func() error{
 			// 	"mib-upload":    onuDeviceEntry.MibUploadTask,
 			// 	"mib-template":  onuDeviceEntry.MibTemplateTask,
@@ -129,8 +132,8 @@
 		},
 	}
 
-	openOnuAc.pDownloadManager = newAdapterDownloadManager(ctx)
-	openOnuAc.pFileManager = newFileDownloadManager(ctx)
+	openOnuAc.pDownloadManager = swupg.NewAdapterDownloadManager(ctx)
+	openOnuAc.pFileManager = swupg.NewFileDownloadManager(ctx)
 	openOnuAc.pFileManager.SetDownloadTimeout(ctx, cfg.DownloadToAdapterTimeout)
 
 	return &openOnuAc
@@ -154,28 +157,28 @@
 */
 
 func (oo *OpenONUAC) addDeviceHandlerToMap(ctx context.Context, agent *deviceHandler) {
-	oo.lockDeviceHandlersMap.Lock()
-	defer oo.lockDeviceHandlersMap.Unlock()
-	if _, exist := oo.deviceHandlers[agent.deviceID]; !exist {
-		oo.deviceHandlers[agent.deviceID] = agent
-		oo.deviceHandlers[agent.deviceID].start(ctx)
-		if _, exist := oo.deviceHandlersCreateChan[agent.deviceID]; exist {
-			logger.Debugw(ctx, "deviceHandler created - trigger processing of pending ONU_IND_REQUEST", log.Fields{"device-id": agent.deviceID})
-			oo.deviceHandlersCreateChan[agent.deviceID] <- true
+	oo.mutexDeviceHandlersMap.Lock()
+	defer oo.mutexDeviceHandlersMap.Unlock()
+	if _, exist := oo.deviceHandlers[agent.DeviceID]; !exist {
+		oo.deviceHandlers[agent.DeviceID] = agent
+		oo.deviceHandlers[agent.DeviceID].start(ctx)
+		if _, exist := oo.deviceHandlersCreateChan[agent.DeviceID]; exist {
+			logger.Debugw(ctx, "deviceHandler created - trigger processing of pending ONU_IND_REQUEST", log.Fields{"device-id": agent.DeviceID})
+			oo.deviceHandlersCreateChan[agent.DeviceID] <- true
 		}
 	}
 }
 
 func (oo *OpenONUAC) deleteDeviceHandlerToMap(agent *deviceHandler) {
-	oo.lockDeviceHandlersMap.Lock()
-	defer oo.lockDeviceHandlersMap.Unlock()
-	delete(oo.deviceHandlers, agent.deviceID)
-	delete(oo.deviceHandlersCreateChan, agent.deviceID)
+	oo.mutexDeviceHandlersMap.Lock()
+	defer oo.mutexDeviceHandlersMap.Unlock()
+	delete(oo.deviceHandlers, agent.DeviceID)
+	delete(oo.deviceHandlersCreateChan, agent.DeviceID)
 }
 
 //getDeviceHandler gets the ONU deviceHandler and may wait until it is created
 func (oo *OpenONUAC) getDeviceHandler(ctx context.Context, deviceID string, aWait bool) *deviceHandler {
-	oo.lockDeviceHandlersMap.Lock()
+	oo.mutexDeviceHandlersMap.Lock()
 	agent, ok := oo.deviceHandlers[deviceID]
 	if aWait && !ok {
 		logger.Infow(ctx, "Race condition: deviceHandler not present - wait for creation or timeout",
@@ -185,7 +188,7 @@
 		}
 		deviceCreateChan := oo.deviceHandlersCreateChan[deviceID]
 		//keep the read sema short to allow for subsequent write
-		oo.lockDeviceHandlersMap.Unlock()
+		oo.mutexDeviceHandlersMap.Unlock()
 		// based on concurrent processing the deviceHandler creation may not yet be finished at his point
 		// so it might be needed to wait here for that event with some timeout
 		select {
@@ -194,12 +197,12 @@
 			return nil
 		case <-deviceCreateChan:
 			logger.Debugw(ctx, "deviceHandler is ready now - continue", log.Fields{"device-id": deviceID})
-			oo.lockDeviceHandlersMap.RLock()
-			defer oo.lockDeviceHandlersMap.RUnlock()
+			oo.mutexDeviceHandlersMap.RLock()
+			defer oo.mutexDeviceHandlersMap.RUnlock()
 			return oo.deviceHandlers[deviceID]
 		}
 	}
-	oo.lockDeviceHandlersMap.Unlock()
+	oo.mutexDeviceHandlersMap.Unlock()
 	return agent
 }
 
@@ -256,7 +259,7 @@
 			return nil, err
 		}
 
-		handler.startReconciling(log.WithSpanFromContext(context.Background(), ctx), false)
+		handler.StartReconciling(log.WithSpanFromContext(context.Background(), ctx), false)
 		go handler.adoptOrReconcileDevice(log.WithSpanFromContext(context.Background(), ctx), handler.device)
 		// reconcilement will be continued after onu-device entry is added
 	} else {
@@ -315,23 +318,23 @@
 		}
 
 		// Stop PM, Alarm and Self Test event handler routines
-		if handler.getCollectorIsRunning() {
+		if handler.GetCollectorIsRunning() {
 			handler.stopCollector <- true
 			logger.Debugw(ctx, "sent stop signal to metric collector routine", log.Fields{"device-id": device.Id})
 
 		}
-		if handler.getAlarmManagerIsRunning(ctx) {
+		if handler.GetAlarmManagerIsRunning(ctx) {
 			handler.stopAlarmManager <- true
 			logger.Debugw(ctx, "sent stop signal to alarm manager", log.Fields{"device-id": device.Id})
 		}
 		if handler.pSelfTestHdlr.GetSelfTestHandlerIsRunning() {
-			handler.pSelfTestHdlr.stopSelfTestModule <- true
+			handler.pSelfTestHdlr.StopSelfTestModule <- true
 			logger.Debugw(ctx, "sent stop signal to self test handler module", log.Fields{"device-id": device.Id})
 		}
 
 		// Clear PM data on the KV store
 		if handler.pOnuMetricsMgr != nil {
-			if err := handler.pOnuMetricsMgr.clearAllPmData(ctx); err != nil {
+			if err := handler.pOnuMetricsMgr.ClearAllPmData(ctx); err != nil {
 				errorsList = append(errorsList, err)
 			}
 		}
@@ -396,11 +399,11 @@
 func (oo *OpenONUAC) DownloadImage(ctx context.Context, imageInfo *ic.ImageDownloadMessage) (*voltha.ImageDownload, error) {
 	ctx = log.WithSpanFromContext(context.Background(), ctx)
 	if imageInfo != nil && imageInfo.Image != nil && imageInfo.Image.Name != "" {
-		if !oo.pDownloadManager.imageExists(ctx, imageInfo.Image) {
+		if !oo.pDownloadManager.ImageExists(ctx, imageInfo.Image) {
 			logger.Debugw(ctx, "start image download", log.Fields{"image-description": imageInfo.Image})
 			// Download_image is not supposed to be blocking, anyway let's call the DownloadManager still synchronously to detect 'fast' problems
 			// the download itself is later done in background
-			if err := oo.pDownloadManager.startDownload(ctx, imageInfo.Image); err != nil {
+			if err := oo.pDownloadManager.StartDownload(ctx, imageInfo.Image); err != nil {
 				return nil, err
 			}
 			return imageInfo.Image, nil
@@ -418,7 +421,7 @@
 //The ImageDownload needs to be called `request`due to library reflection requirements
 func (oo *OpenONUAC) ActivateImageUpdate(ctx context.Context, imageInfo *ic.ImageDownloadMessage) (*voltha.ImageDownload, error) {
 	if imageInfo != nil && imageInfo.Image != nil && imageInfo.Image.Name != "" {
-		if oo.pDownloadManager.imageLocallyDownloaded(ctx, imageInfo.Image) {
+		if oo.pDownloadManager.ImageLocallyDownloaded(ctx, imageInfo.Image) {
 			if handler := oo.getDeviceHandler(ctx, imageInfo.Device.Id, false); handler != nil {
 				logger.Debugw(ctx, "image download on omci requested", log.Fields{
 					"image-description": imageInfo.Image, "device-id": imageInfo.Device.Id})
@@ -443,12 +446,12 @@
 	if handler := oo.getDeviceHandler(ctx, request.TargetId, false); handler != nil {
 		switch reqType := request.GetRequest().GetRequest().(type) {
 		case *extension.GetValueRequest_UniInfo:
-			return handler.getUniPortStatus(ctx, reqType.UniInfo), nil
+			return handler.GetUniPortStatus(ctx, reqType.UniInfo), nil
 		case *extension.GetValueRequest_OnuOpticalInfo:
-			commChan := make(chan Message)
+			CommChan := make(chan cmn.Message)
 			respChan := make(chan extension.SingleGetValueResponse)
 			// Initiate the self test request
-			if err := handler.pSelfTestHdlr.SelfTestRequestStart(ctx, *request, commChan, respChan); err != nil {
+			if err := handler.pSelfTestHdlr.SelfTestRequestStart(ctx, *request, CommChan, respChan); err != nil {
 				return &extension.SingleGetValueResponse{
 					Response: &extension.GetValueResponse{
 						Status:    extension.GetValueResponse_ERROR,
@@ -462,12 +465,12 @@
 		case *extension.GetValueRequest_OnuInfo:
 			return handler.getOnuOMCICounters(ctx, reqType.OnuInfo), nil
 		default:
-			return postUniStatusErrResponse(extension.GetValueResponse_UNSUPPORTED), nil
+			return uniprt.PostUniStatusErrResponse(extension.GetValueResponse_UNSUPPORTED), nil
 
 		}
 	}
 	logger.Errorw(ctx, "Single_get_value_request failed ", log.Fields{"request": request})
-	return postUniStatusErrResponse(extension.GetValueResponse_INVALID_DEVICE_ID), nil
+	return uniprt.PostUniStatusErrResponse(extension.GetValueResponse_INVALID_DEVICE_ID), nil
 }
 
 //if update >= 4.3.0
@@ -1130,3 +1133,45 @@
 func (oo *OpenONUAC) ChildDeviceLost(ctx context.Context, childDevice *voltha.Device) (*empty.Empty, error) {
 	return nil, errors.New("unImplemented")
 }
+
+// GetSupportedFsms - TODO: add comment
+func (oo *OpenONUAC) GetSupportedFsms() *cmn.OmciDeviceFsms {
+	return oo.pSupportedFsms
+}
+
+// LockMutexMibTemplateGenerated - TODO: add comment
+func (oo *OpenONUAC) LockMutexMibTemplateGenerated() {
+	oo.mutexMibTemplateGenerated.Lock()
+}
+
+// UnlockMutexMibTemplateGenerated - TODO: add comment
+func (oo *OpenONUAC) UnlockMutexMibTemplateGenerated() {
+	oo.mutexMibTemplateGenerated.Unlock()
+}
+
+// GetMibTemplatesGenerated - TODO: add comment
+func (oo *OpenONUAC) GetMibTemplatesGenerated(mibTemplatePath string) (value bool, exist bool) {
+	value, exist = oo.mibTemplatesGenerated[mibTemplatePath]
+	return value, exist
+}
+
+// SetMibTemplatesGenerated - TODO: add comment
+func (oo *OpenONUAC) SetMibTemplatesGenerated(mibTemplatePath string, value bool) {
+	oo.mibTemplatesGenerated[mibTemplatePath] = value
+}
+
+// RLockMutexDeviceHandlersMap - TODO: add comment
+func (oo *OpenONUAC) RLockMutexDeviceHandlersMap() {
+	oo.mutexDeviceHandlersMap.RLock()
+}
+
+// RUnlockMutexDeviceHandlersMap - TODO: add comment
+func (oo *OpenONUAC) RUnlockMutexDeviceHandlersMap() {
+	oo.mutexDeviceHandlersMap.RUnlock()
+}
+
+// GetDeviceHandler - TODO: add comment
+func (oo *OpenONUAC) GetDeviceHandler(deviceID string) (value cmn.IdeviceHandler, exist bool) {
+	value, exist = oo.deviceHandlers[deviceID]
+	return value, exist
+}
diff --git a/internal/pkg/onuadaptercore/openonuimpl.go b/internal/pkg/core/openonuimpl.go
old mode 100644
new mode 100755
similarity index 96%
rename from internal/pkg/onuadaptercore/openonuimpl.go
rename to internal/pkg/core/openonuimpl.go
index efa4e96..8017d48
--- a/internal/pkg/onuadaptercore/openonuimpl.go
+++ b/internal/pkg/core/openonuimpl.go
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package core provides the utility for onu devices, flows and statistics
+package core
 
 import (
 	"context"
diff --git a/internal/pkg/onuadaptercore/platform.go b/internal/pkg/core/platform.go
old mode 100644
new mode 100755
similarity index 98%
rename from internal/pkg/onuadaptercore/platform.go
rename to internal/pkg/core/platform.go
index 6ad3e7b..9430e92
--- a/internal/pkg/onuadaptercore/platform.go
+++ b/internal/pkg/core/platform.go
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package core provides the utility for onu devices, flows and statistics
+package core
 
 import "context"
 
diff --git a/internal/pkg/onuadaptercore/common.go b/internal/pkg/devdb/common.go
old mode 100644
new mode 100755
similarity index 86%
copy from internal/pkg/onuadaptercore/common.go
copy to internal/pkg/devdb/common.go
index b0b10e3..74fdf31
--- a/internal/pkg/onuadaptercore/common.go
+++ b/internal/pkg/devdb/common.go
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package devdb provides access to internal device ME DB
+package devdb
 
 import (
 	"github.com/opencord/voltha-lib-go/v7/pkg/log"
@@ -26,7 +26,7 @@
 func init() {
 	// Setup this package so that it's log level can be modified at run time
 	var err error
-	logger, err = log.RegisterPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "adaptercoreonu"})
+	logger, err = log.RegisterPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "devdb"})
 	if err != nil {
 		panic(err)
 	}
diff --git a/internal/pkg/onuadaptercore/onu_device_db.go b/internal/pkg/devdb/onu_device_db.go
old mode 100644
new mode 100755
similarity index 63%
rename from internal/pkg/onuadaptercore/onu_device_db.go
rename to internal/pkg/devdb/onu_device_db.go
index 00a1945..1bee2ec
--- a/internal/pkg/onuadaptercore/onu_device_db.go
+++ b/internal/pkg/devdb/onu_device_db.go
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package devdb provides access to internal device ME DB
+package devdb
 
 import (
 	"context"
@@ -30,76 +30,79 @@
 
 type meDbMap map[me.ClassID]map[uint16]me.AttributeValueMap
 
-//onuDeviceDB structure holds information about known ME's
-type onuDeviceDB struct {
-	ctx             context.Context
-	pOnuDeviceEntry *OnuDeviceEntry
-	meDb            meDbMap
-	meDbLock        sync.RWMutex
+//OnuDeviceDB structure holds information about known ME's
+type OnuDeviceDB struct {
+	ctx      context.Context
+	deviceID string
+	MeDb     meDbMap
+	meDbLock sync.RWMutex
 }
 
-//newOnuDeviceDB returns a new instance for a specific ONU_Device_Entry
-func newOnuDeviceDB(ctx context.Context, aPOnuDeviceEntry *OnuDeviceEntry) *onuDeviceDB {
-	logger.Debugw(ctx, "Init OnuDeviceDB for:", log.Fields{"device-id": aPOnuDeviceEntry.deviceID})
-	var onuDeviceDB onuDeviceDB
-	onuDeviceDB.ctx = ctx
-	onuDeviceDB.pOnuDeviceEntry = aPOnuDeviceEntry
-	onuDeviceDB.meDb = make(meDbMap)
+//NewOnuDeviceDB returns a new instance for a specific ONU_Device_Entry
+func NewOnuDeviceDB(ctx context.Context, aDeviceID string) *OnuDeviceDB {
+	logger.Debugw(ctx, "Init OnuDeviceDB for:", log.Fields{"device-id": aDeviceID})
+	var OnuDeviceDB OnuDeviceDB
+	OnuDeviceDB.ctx = ctx
+	OnuDeviceDB.deviceID = aDeviceID
+	OnuDeviceDB.MeDb = make(meDbMap)
 
-	return &onuDeviceDB
+	return &OnuDeviceDB
 }
 
-func (onuDeviceDB *onuDeviceDB) PutMe(ctx context.Context, meClassID me.ClassID, meEntityID uint16, meAttributes me.AttributeValueMap) {
-	onuDeviceDB.meDbLock.Lock()
-	defer onuDeviceDB.meDbLock.Unlock()
+//PutMe puts an ME instance into internal ONU DB
+func (OnuDeviceDB *OnuDeviceDB) PutMe(ctx context.Context, meClassID me.ClassID, meEntityID uint16, meAttributes me.AttributeValueMap) {
+	OnuDeviceDB.meDbLock.Lock()
+	defer OnuDeviceDB.meDbLock.Unlock()
 	//filter out the OnuData
 	if me.OnuDataClassID == meClassID {
 		return
 	}
 
-	//logger.Debugw(ctx,"Search for key data :", log.Fields{"deviceId": onuDeviceDB.pOnuDeviceEntry.deviceID, "meClassID": meClassID, "meEntityID": meEntityID})
-	meInstMap, ok := onuDeviceDB.meDb[meClassID]
+	//logger.Debugw(ctx,"Search for key data :", log.Fields{"deviceId": OnuDeviceDB.deviceID, "meClassID": meClassID, "meEntityID": meEntityID})
+	meInstMap, ok := OnuDeviceDB.MeDb[meClassID]
 	if !ok {
-		logger.Debugw(ctx, "meClassID not found - add to db :", log.Fields{"device-id": onuDeviceDB.pOnuDeviceEntry.deviceID})
+		logger.Debugw(ctx, "meClassID not found - add to db :", log.Fields{"device-id": OnuDeviceDB.deviceID})
 		meInstMap = make(map[uint16]me.AttributeValueMap)
-		onuDeviceDB.meDb[meClassID] = meInstMap
-		onuDeviceDB.meDb[meClassID][meEntityID] = meAttributes
+		OnuDeviceDB.MeDb[meClassID] = meInstMap
+		OnuDeviceDB.MeDb[meClassID][meEntityID] = meAttributes
 	} else {
 		meAttribs, ok := meInstMap[meEntityID]
 		if !ok {
 			/* verbose logging, avoid in >= debug level
-			logger.Debugw(ctx,"meEntityId not found - add to db :", log.Fields{"device-id": onuDeviceDB.pOnuDeviceEntry.deviceID})
+			logger.Debugw(ctx,"meEntityId not found - add to db :", log.Fields{"device-id": OnuDeviceDB.deviceID})
 			*/
 			meInstMap[meEntityID] = meAttributes
 		} else {
 			/* verbose logging, avoid in >= debug level
-			logger.Debugw(ctx,"ME-Instance exists already: merge attribute data :", log.Fields{"device-id": onuDeviceDB.pOnuDeviceEntry.deviceID, "meAttribs": meAttribs})
+			logger.Debugw(ctx,"ME-Instance exists already: merge attribute data :", log.Fields{"device-id": OnuDeviceDB.deviceID, "meAttribs": meAttribs})
 			*/
 			for k, v := range meAttributes {
 				meAttribs[k] = v
 			}
 			meInstMap[meEntityID] = meAttribs
 			/* verbose logging, avoid in >= debug level
-			logger.Debugw(ctx,"ME-Instance updated :", log.Fields{"device-id": onuDeviceDB.pOnuDeviceEntry.deviceID, "meAttribs": meAttribs})
+			logger.Debugw(ctx,"ME-Instance updated :", log.Fields{"device-id": OnuDeviceDB.deviceID, "meAttribs": meAttribs})
 			*/
 		}
 	}
 }
 
-func (onuDeviceDB *onuDeviceDB) GetMe(meClassID me.ClassID, meEntityID uint16) me.AttributeValueMap {
-	onuDeviceDB.meDbLock.RLock()
-	defer onuDeviceDB.meDbLock.RUnlock()
-	if meAttributes, present := onuDeviceDB.meDb[meClassID][meEntityID]; present {
+//GetMe returns an ME instance from internal ONU DB
+func (OnuDeviceDB *OnuDeviceDB) GetMe(meClassID me.ClassID, meEntityID uint16) me.AttributeValueMap {
+	OnuDeviceDB.meDbLock.RLock()
+	defer OnuDeviceDB.meDbLock.RUnlock()
+	if meAttributes, present := OnuDeviceDB.MeDb[meClassID][meEntityID]; present {
 		/* verbose logging, avoid in >= debug level
 		logger.Debugw(ctx,"ME found:", log.Fields{"meClassID": meClassID, "meEntityID": meEntityID, "meAttributes": meAttributes,
-			"device-id": onuDeviceDB.pOnuDeviceEntry.deviceID})
+			"device-id": OnuDeviceDB.deviceID})
 		*/
 		return meAttributes
 	}
 	return nil
 }
 
-func (onuDeviceDB *onuDeviceDB) getUint32Attrib(meAttribute interface{}) (uint32, error) {
+//GetUint32Attrib converts JSON numbers to uint32
+func (OnuDeviceDB *OnuDeviceDB) GetUint32Attrib(meAttribute interface{}) (uint32, error) {
 
 	switch reflect.TypeOf(meAttribute).Kind() {
 	case reflect.Float64:
@@ -108,11 +111,12 @@
 	case reflect.Uint32:
 		return meAttribute.(uint32), nil
 	default:
-		return uint32(0), fmt.Errorf(fmt.Sprintf("wrong-interface-type-%v-received-for-device-%s", reflect.TypeOf(meAttribute).Kind(), onuDeviceDB.pOnuDeviceEntry.deviceID))
+		return uint32(0), fmt.Errorf(fmt.Sprintf("wrong-interface-type-%v-received-for-device-%s", reflect.TypeOf(meAttribute).Kind(), OnuDeviceDB.deviceID))
 	}
 }
 
-func (onuDeviceDB *onuDeviceDB) getUint16Attrib(meAttribute interface{}) (uint16, error) {
+//GetUint16Attrib converts JSON numbers to uint16
+func (OnuDeviceDB *OnuDeviceDB) GetUint16Attrib(meAttribute interface{}) (uint16, error) {
 
 	switch reflect.TypeOf(meAttribute).Kind() {
 	case reflect.Float64:
@@ -121,16 +125,17 @@
 	case reflect.Uint16:
 		return meAttribute.(uint16), nil
 	default:
-		return uint16(0), fmt.Errorf(fmt.Sprintf("wrong-interface-type-%v-received-for-device-%s", reflect.TypeOf(meAttribute).Kind(), onuDeviceDB.pOnuDeviceEntry.deviceID))
+		return uint16(0), fmt.Errorf(fmt.Sprintf("wrong-interface-type-%v-received-for-device-%s", reflect.TypeOf(meAttribute).Kind(), OnuDeviceDB.deviceID))
 	}
 }
 
-func (onuDeviceDB *onuDeviceDB) getSortedInstKeys(ctx context.Context, meClassID me.ClassID) []uint16 {
+//GetSortedInstKeys returns a sorted list of all instances of an ME
+func (OnuDeviceDB *OnuDeviceDB) GetSortedInstKeys(ctx context.Context, meClassID me.ClassID) []uint16 {
 
 	var meInstKeys []uint16
-	onuDeviceDB.meDbLock.RLock()
-	defer onuDeviceDB.meDbLock.RUnlock()
-	meInstMap := onuDeviceDB.meDb[meClassID]
+	OnuDeviceDB.meDbLock.RLock()
+	defer OnuDeviceDB.meDbLock.RUnlock()
+	meInstMap := OnuDeviceDB.MeDb[meClassID]
 
 	for k := range meInstMap {
 		meInstKeys = append(meInstKeys, k)
@@ -141,11 +146,12 @@
 	return meInstKeys
 }
 
-func (onuDeviceDB *onuDeviceDB) logMeDb(ctx context.Context) {
-	logger.Debugw(ctx, "ME instances stored for :", log.Fields{"device-id": onuDeviceDB.pOnuDeviceEntry.deviceID})
-	for meClassID, meInstMap := range onuDeviceDB.meDb {
+//LogMeDb logs content of internal ONU DB
+func (OnuDeviceDB *OnuDeviceDB) LogMeDb(ctx context.Context) {
+	logger.Debugw(ctx, "ME instances stored for :", log.Fields{"device-id": OnuDeviceDB.deviceID})
+	for meClassID, meInstMap := range OnuDeviceDB.MeDb {
 		for meEntityID, meAttribs := range meInstMap {
-			logger.Debugw(ctx, "ME instance: ", log.Fields{"meClassID": meClassID, "meEntityID": meEntityID, "meAttribs": meAttribs, "device-id": onuDeviceDB.pOnuDeviceEntry.deviceID})
+			logger.Debugw(ctx, "ME instance: ", log.Fields{"meClassID": meClassID, "meEntityID": meEntityID, "meAttribs": meAttribs, "device-id": OnuDeviceDB.deviceID})
 		}
 	}
 }
diff --git a/internal/pkg/onuadaptercore/common.go b/internal/pkg/mib/common.go
old mode 100644
new mode 100755
similarity index 86%
copy from internal/pkg/onuadaptercore/common.go
copy to internal/pkg/mib/common.go
index b0b10e3..e9d39c3
--- a/internal/pkg/onuadaptercore/common.go
+++ b/internal/pkg/mib/common.go
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package mib provides the utilities for managing the onu mib
+package mib
 
 import (
 	"github.com/opencord/voltha-lib-go/v7/pkg/log"
@@ -26,7 +26,7 @@
 func init() {
 	// Setup this package so that it's log level can be modified at run time
 	var err error
-	logger, err = log.RegisterPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "adaptercoreonu"})
+	logger, err = log.RegisterPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "mib"})
 	if err != nil {
 		panic(err)
 	}
diff --git a/internal/pkg/onuadaptercore/mib_download.go b/internal/pkg/mib/mib_download.go
old mode 100644
new mode 100755
similarity index 70%
rename from internal/pkg/onuadaptercore/mib_download.go
rename to internal/pkg/mib/mib_download.go
index 5d77931..9c49f9b
--- a/internal/pkg/onuadaptercore/mib_download.go
+++ b/internal/pkg/mib/mib_download.go
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package mib provides the utilities for managing the onu mib
+package mib
 
 import (
 	"context"
@@ -30,6 +30,7 @@
 	//ic "github.com/opencord/voltha-protos/v5/go/inter_container"
 	//"github.com/opencord/voltha-protos/v5/go/openflow_13"
 	//"github.com/opencord/voltha-protos/v5/go/voltha"
+	cmn "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/common"
 )
 
 func (onuDeviceEntry *OnuDeviceEntry) enterDLStartingState(ctx context.Context, e *fsm.Event) {
@@ -45,47 +46,48 @@
 
 func (onuDeviceEntry *OnuDeviceEntry) enterCreatingGalState(ctx context.Context, e *fsm.Event) {
 	logger.Debugw(ctx, "MibDownload FSM", log.Fields{"Tx create::GAL Ethernet Profile in state": e.FSM.Current(), "device-id": onuDeviceEntry.deviceID})
-	onuDeviceEntry.PDevOmciCC.mutexPLastTxMeInstance.Lock()
-	meInstance, err := onuDeviceEntry.PDevOmciCC.sendCreateGalEthernetProfile(log.WithSpanFromContext(context.TODO(), ctx), onuDeviceEntry.pOpenOnuAc.omciTimeout, true)
+	onuDeviceEntry.mutexPLastTxMeInstance.Lock()
+	meInstance, err := onuDeviceEntry.PDevOmciCC.SendCreateGalEthernetProfile(log.WithSpanFromContext(context.TODO(), ctx),
+		onuDeviceEntry.baseDeviceHandler.GetOmciTimeout(), true)
 	//accept also nil as (error) return value for writing to LastTx
 	//  - this avoids misinterpretation of new received OMCI messages
 	if err != nil {
-		onuDeviceEntry.PDevOmciCC.mutexPLastTxMeInstance.Unlock()
+		onuDeviceEntry.mutexPLastTxMeInstance.Unlock()
 		logger.Errorw(ctx, "GalEthernetProfile create failed, aborting MibDownload FSM!",
 			log.Fields{"device-id": onuDeviceEntry.deviceID})
-		pMibDlFsm := onuDeviceEntry.pMibDownloadFsm
+		pMibDlFsm := onuDeviceEntry.PMibDownloadFsm
 		if pMibDlFsm != nil {
-			go func(a_pAFsm *AdapterFsm) {
-				_ = a_pAFsm.pFsm.Event(dlEvReset)
+			go func(a_pAFsm *cmn.AdapterFsm) {
+				_ = a_pAFsm.PFsm.Event(DlEvReset)
 			}(pMibDlFsm)
 		}
 		return
 	}
-	onuDeviceEntry.PDevOmciCC.pLastTxMeInstance = meInstance
-	onuDeviceEntry.PDevOmciCC.mutexPLastTxMeInstance.Unlock()
+	onuDeviceEntry.pLastTxMeInstance = meInstance
+	onuDeviceEntry.mutexPLastTxMeInstance.Unlock()
 }
 
 func (onuDeviceEntry *OnuDeviceEntry) enterSettingOnu2gState(ctx context.Context, e *fsm.Event) {
 	logger.Debugw(ctx, "MibDownload FSM", log.Fields{"Tx Set::ONU2-G in state": e.FSM.Current(), "device-id": onuDeviceEntry.deviceID})
-	onuDeviceEntry.PDevOmciCC.mutexPLastTxMeInstance.Lock()
-	meInstance, err := onuDeviceEntry.PDevOmciCC.sendSetOnu2g(log.WithSpanFromContext(context.TODO(), ctx),
-		onuDeviceEntry.pOpenOnuAc.omciTimeout, true)
+	onuDeviceEntry.mutexPLastTxMeInstance.Lock()
+	meInstance, err := onuDeviceEntry.PDevOmciCC.SendSetOnu2g(log.WithSpanFromContext(context.TODO(), ctx),
+		onuDeviceEntry.baseDeviceHandler.GetOmciTimeout(), true)
 	//accept also nil as (error) return value for writing to LastTx
 	//  - this avoids misinterpretation of new received OMCI messages
 	if err != nil {
-		onuDeviceEntry.PDevOmciCC.mutexPLastTxMeInstance.Unlock()
+		onuDeviceEntry.mutexPLastTxMeInstance.Unlock()
 		logger.Errorw(ctx, "ONU2-G set failed, aborting MibDownload FSM!",
 			log.Fields{"device-id": onuDeviceEntry.deviceID})
-		pMibDlFsm := onuDeviceEntry.pMibDownloadFsm
+		pMibDlFsm := onuDeviceEntry.PMibDownloadFsm
 		if pMibDlFsm != nil {
-			go func(a_pAFsm *AdapterFsm) {
-				_ = a_pAFsm.pFsm.Event(dlEvReset)
+			go func(a_pAFsm *cmn.AdapterFsm) {
+				_ = a_pAFsm.PFsm.Event(DlEvReset)
 			}(pMibDlFsm)
 		}
 		return
 	}
-	onuDeviceEntry.PDevOmciCC.pLastTxMeInstance = meInstance
-	onuDeviceEntry.PDevOmciCC.mutexPLastTxMeInstance.Unlock()
+	onuDeviceEntry.pLastTxMeInstance = meInstance
+	onuDeviceEntry.mutexPLastTxMeInstance.Unlock()
 }
 
 func (onuDeviceEntry *OnuDeviceEntry) enterBridgeInitState(ctx context.Context, e *fsm.Event) {
@@ -96,14 +98,14 @@
 
 func (onuDeviceEntry *OnuDeviceEntry) enterDownloadedState(ctx context.Context, e *fsm.Event) {
 	logger.Debugw(ctx, "MibDownload FSM", log.Fields{"send notification to core in State": e.FSM.Current(), "device-id": onuDeviceEntry.deviceID})
-	onuDeviceEntry.transferSystemEvent(ctx, MibDownloadDone)
+	onuDeviceEntry.transferSystemEvent(ctx, cmn.MibDownloadDone)
 	//let's reset the state machine in order to release all resources now
-	pMibDlFsm := onuDeviceEntry.pMibDownloadFsm
+	pMibDlFsm := onuDeviceEntry.PMibDownloadFsm
 	if pMibDlFsm != nil {
 		// obviously calling some FSM event here directly does not work - so trying to decouple it ...
-		go func(a_pAFsm *AdapterFsm) {
-			if a_pAFsm != nil && a_pAFsm.pFsm != nil {
-				_ = a_pAFsm.pFsm.Event(dlEvReset)
+		go func(a_pAFsm *cmn.AdapterFsm) {
+			if a_pAFsm != nil && a_pAFsm.PFsm != nil {
+				_ = a_pAFsm.PFsm.Event(DlEvReset)
 			}
 		}(pMibDlFsm)
 	}
@@ -111,22 +113,22 @@
 
 func (onuDeviceEntry *OnuDeviceEntry) enterResettingState(ctx context.Context, e *fsm.Event) {
 	logger.Debugw(ctx, "MibDownload FSM resetting", log.Fields{"device-id": onuDeviceEntry.deviceID})
-	pMibDlFsm := onuDeviceEntry.pMibDownloadFsm
+	pMibDlFsm := onuDeviceEntry.PMibDownloadFsm
 	if pMibDlFsm != nil {
 		// abort running message processing
-		fsmAbortMsg := Message{
-			Type: TestMsg,
-			Data: TestMessage{
-				TestMessageVal: AbortMessageProcessing,
+		fsmAbortMsg := cmn.Message{
+			Type: cmn.TestMsg,
+			Data: cmn.TestMessage{
+				TestMessageVal: cmn.AbortMessageProcessing,
 			},
 		}
-		pMibDlFsm.commChan <- fsmAbortMsg
+		pMibDlFsm.CommChan <- fsmAbortMsg
 
 		//try to restart the FSM to 'disabled'
 		// see DownloadedState: decouple event transfer
-		go func(a_pAFsm *AdapterFsm) {
-			if a_pAFsm != nil && a_pAFsm.pFsm != nil {
-				_ = a_pAFsm.pFsm.Event(dlEvRestart)
+		go func(a_pAFsm *cmn.AdapterFsm) {
+			if a_pAFsm != nil && a_pAFsm.PFsm != nil {
+				_ = a_pAFsm.PFsm.Event(DlEvRestart)
 			}
 		}(pMibDlFsm)
 	}
@@ -140,25 +142,25 @@
 		// 	logger.Info("MibSync Msg", log.Fields{"Message handling canceled via context for device-id": onuDeviceEntry.deviceID})
 		// 	break loop
 		// unless multiple channels are not involved, we should not use select
-		message, ok := <-onuDeviceEntry.pMibDownloadFsm.commChan
+		message, ok := <-onuDeviceEntry.PMibDownloadFsm.CommChan
 		if !ok {
 			logger.Info(ctx, "MibDownload Rx Msg", log.Fields{"Message couldn't be read from channel for device-id": onuDeviceEntry.deviceID})
 			// but then we have to ensure a restart of the FSM as well - as exceptional procedure
-			_ = onuDeviceEntry.pMibDownloadFsm.pFsm.Event(dlEvRestart)
+			_ = onuDeviceEntry.PMibDownloadFsm.PFsm.Event(DlEvRestart)
 			break loop
 		}
 		logger.Debugw(ctx, "MibDownload Rx Msg", log.Fields{"Received message for device-id": onuDeviceEntry.deviceID})
 
 		switch message.Type {
-		case TestMsg:
-			msg, _ := message.Data.(TestMessage)
-			if msg.TestMessageVal == AbortMessageProcessing {
+		case cmn.TestMsg:
+			msg, _ := message.Data.(cmn.TestMessage)
+			if msg.TestMessageVal == cmn.AbortMessageProcessing {
 				logger.Debugw(ctx, "MibDownload abort ProcessMsg", log.Fields{"for device-id": onuDeviceEntry.deviceID})
 				break loop
 			}
 			logger.Warnw(ctx, "MibDownload unknown TestMessage", log.Fields{"device-id": onuDeviceEntry.deviceID, "MessageVal": msg.TestMessageVal})
-		case OMCI:
-			msg, _ := message.Data.(OmciMessage)
+		case cmn.OMCI:
+			msg, _ := message.Data.(cmn.OmciMessage)
 			onuDeviceEntry.handleOmciMibDownloadMessage(ctx, msg)
 		default:
 			logger.Warn(ctx, "MibDownload Rx Msg", log.Fields{"Unknown message type received for device-id": onuDeviceEntry.deviceID,
@@ -169,7 +171,7 @@
 	logger.Debugw(ctx, "End MibDownload Msg processing", log.Fields{"for device-id": onuDeviceEntry.deviceID})
 }
 
-func (onuDeviceEntry *OnuDeviceEntry) handleOmciMibDownloadCreateResponseMessage(ctx context.Context, msg OmciMessage) {
+func (onuDeviceEntry *OnuDeviceEntry) handleOmciMibDownloadCreateResponseMessage(ctx context.Context, msg cmn.OmciMessage) {
 	msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeCreateResponse)
 	if msgLayer == nil {
 		logger.Errorw(ctx, "Omci Msg layer could not be detected for CreateResponse", log.Fields{"device-id": onuDeviceEntry.deviceID})
@@ -192,46 +194,46 @@
 	// but as that is not straightforward to me I insert the type checkes manually here
 	//   and feed the FSM with only 'pre-defined' events ...
 
-	onuDeviceEntry.PDevOmciCC.mutexPLastTxMeInstance.RLock()
-	if onuDeviceEntry.PDevOmciCC.pLastTxMeInstance != nil {
-		if msgObj.EntityClass == onuDeviceEntry.PDevOmciCC.pLastTxMeInstance.GetClassID() &&
-			msgObj.EntityInstance == onuDeviceEntry.PDevOmciCC.pLastTxMeInstance.GetEntityID() {
+	onuDeviceEntry.mutexPLastTxMeInstance.RLock()
+	if onuDeviceEntry.pLastTxMeInstance != nil {
+		if msgObj.EntityClass == onuDeviceEntry.pLastTxMeInstance.GetClassID() &&
+			msgObj.EntityInstance == onuDeviceEntry.pLastTxMeInstance.GetEntityID() {
 			//store the created ME into DB //TODO??? obviously the Python code does not store the config ...
 			// if, then something like:
 			//onuDeviceEntry.pOnuDB.StoreMe(msgObj)
 
 			// maybe we can use just the same eventName for different state transitions like "forward"
 			//   - might be checked, but so far I go for sure and have to inspect the concrete state events ...
-			switch onuDeviceEntry.PDevOmciCC.pLastTxMeInstance.GetName() {
+			switch onuDeviceEntry.pLastTxMeInstance.GetName() {
 			case "GalEthernetProfile":
 				{ // let the FSM proceed ...
-					onuDeviceEntry.PDevOmciCC.mutexPLastTxMeInstance.RUnlock()
-					_ = onuDeviceEntry.pMibDownloadFsm.pFsm.Event(dlEvRxGalResp)
+					onuDeviceEntry.mutexPLastTxMeInstance.RUnlock()
+					_ = onuDeviceEntry.PMibDownloadFsm.PFsm.Event(DlEvRxGalResp)
 				}
 			case "MacBridgeServiceProfile",
 				"MacBridgePortConfigurationData",
 				"ExtendedVlanTaggingOperationConfigurationData":
 				{ // let bridge init proceed by stopping the wait function
-					onuDeviceEntry.PDevOmciCC.mutexPLastTxMeInstance.RUnlock()
+					onuDeviceEntry.mutexPLastTxMeInstance.RUnlock()
 					onuDeviceEntry.omciMessageReceived <- true
 				}
 			default:
 				{
 					logger.Warnw(ctx, "Unsupported ME name received!",
-						log.Fields{"ME name": onuDeviceEntry.PDevOmciCC.pLastTxMeInstance.GetName(), "device-id": onuDeviceEntry.deviceID})
-					onuDeviceEntry.PDevOmciCC.mutexPLastTxMeInstance.RUnlock()
+						log.Fields{"ME name": onuDeviceEntry.pLastTxMeInstance.GetName(), "device-id": onuDeviceEntry.deviceID})
+					onuDeviceEntry.mutexPLastTxMeInstance.RUnlock()
 				}
 			}
 		} else {
-			onuDeviceEntry.PDevOmciCC.mutexPLastTxMeInstance.RUnlock()
+			onuDeviceEntry.mutexPLastTxMeInstance.RUnlock()
 		}
 	} else {
-		onuDeviceEntry.PDevOmciCC.mutexPLastTxMeInstance.RUnlock()
+		onuDeviceEntry.mutexPLastTxMeInstance.RUnlock()
 		logger.Errorw(ctx, "Pointer to last Tx MeInstance is nil!", log.Fields{"device-id": onuDeviceEntry.deviceID})
 	}
 }
 
-func (onuDeviceEntry *OnuDeviceEntry) handleOmciMibDownloadSetResponseMessage(ctx context.Context, msg OmciMessage) {
+func (onuDeviceEntry *OnuDeviceEntry) handleOmciMibDownloadSetResponseMessage(ctx context.Context, msg cmn.OmciMessage) {
 	msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeSetResponse)
 	if msgLayer == nil {
 		logger.Errorw(ctx, "Omci Msg layer could not be detected for SetResponse", log.Fields{"device-id": onuDeviceEntry.deviceID})
@@ -251,39 +253,39 @@
 	}
 	// compare comments above for CreateResponse (apply also here ...)
 
-	onuDeviceEntry.PDevOmciCC.mutexPLastTxMeInstance.RLock()
-	if onuDeviceEntry.PDevOmciCC.pLastTxMeInstance != nil {
-		if msgObj.EntityClass == onuDeviceEntry.PDevOmciCC.pLastTxMeInstance.GetClassID() &&
-			msgObj.EntityInstance == onuDeviceEntry.PDevOmciCC.pLastTxMeInstance.GetEntityID() {
+	onuDeviceEntry.mutexPLastTxMeInstance.RLock()
+	if onuDeviceEntry.pLastTxMeInstance != nil {
+		if msgObj.EntityClass == onuDeviceEntry.pLastTxMeInstance.GetClassID() &&
+			msgObj.EntityInstance == onuDeviceEntry.pLastTxMeInstance.GetEntityID() {
 			//store the created ME into DB //TODO??? obviously the Python code does not store the config ...
 			// if, then something like:
 			//onuDeviceEntry.pOnuDB.StoreMe(msgObj)
 
-			switch onuDeviceEntry.PDevOmciCC.pLastTxMeInstance.GetName() {
+			switch onuDeviceEntry.pLastTxMeInstance.GetName() {
 			case "Onu2G":
 				{ // let the FSM proceed ...
-					onuDeviceEntry.PDevOmciCC.mutexPLastTxMeInstance.RUnlock()
-					_ = onuDeviceEntry.pMibDownloadFsm.pFsm.Event(dlEvRxOnu2gResp)
+					onuDeviceEntry.mutexPLastTxMeInstance.RUnlock()
+					_ = onuDeviceEntry.PMibDownloadFsm.PFsm.Event(DlEvRxOnu2gResp)
 				}
 				//so far that was the only MibDownlad Set Element ...
 			default:
 				{
 					logger.Warnw(ctx, "Unsupported ME name received!",
-						log.Fields{"ME name": onuDeviceEntry.PDevOmciCC.pLastTxMeInstance.GetName(), "device-id": onuDeviceEntry.deviceID})
-					onuDeviceEntry.PDevOmciCC.mutexPLastTxMeInstance.RUnlock()
+						log.Fields{"ME name": onuDeviceEntry.pLastTxMeInstance.GetName(), "device-id": onuDeviceEntry.deviceID})
+					onuDeviceEntry.mutexPLastTxMeInstance.RUnlock()
 				}
 
 			}
 		} else {
-			onuDeviceEntry.PDevOmciCC.mutexPLastTxMeInstance.RUnlock()
+			onuDeviceEntry.mutexPLastTxMeInstance.RUnlock()
 		}
 	} else {
-		onuDeviceEntry.PDevOmciCC.mutexPLastTxMeInstance.RUnlock()
+		onuDeviceEntry.mutexPLastTxMeInstance.RUnlock()
 		logger.Errorw(ctx, "Pointer to last Tx MeInstance is nil!", log.Fields{"device-id": onuDeviceEntry.deviceID})
 	}
 }
 
-func (onuDeviceEntry *OnuDeviceEntry) handleOmciMibDownloadMessage(ctx context.Context, msg OmciMessage) {
+func (onuDeviceEntry *OnuDeviceEntry) handleOmciMibDownloadMessage(ctx context.Context, msg cmn.OmciMessage) {
 	logger.Debugw(ctx, "Rx OMCI MibDownload Msg", log.Fields{"device-id": onuDeviceEntry.deviceID,
 		"msgType": msg.OmciMsg.MessageType})
 
@@ -291,7 +293,7 @@
 	case omci.CreateResponseType:
 		onuDeviceEntry.handleOmciMibDownloadCreateResponseMessage(ctx, msg)
 	//TODO
-	//	onuDeviceEntry.pMibDownloadFsm.pFsm.Event("rx_evtocd_resp")
+	//	onuDeviceEntry.PMibDownloadFsm.PFsm.Event("rx_evtocd_resp")
 	case omci.SetResponseType:
 		onuDeviceEntry.handleOmciMibDownloadSetResponseMessage(ctx, msg)
 	default:
@@ -304,79 +306,79 @@
 }
 
 func (onuDeviceEntry *OnuDeviceEntry) performInitialBridgeSetup(ctx context.Context) {
-	for uniNo, uniPort := range onuDeviceEntry.baseDeviceHandler.uniEntityMap {
+	for uniNo, uniPort := range *onuDeviceEntry.baseDeviceHandler.GetUniEntityMap() {
 		logger.Debugw(ctx, "Starting IntialBridgeSetup", log.Fields{
 			"device-id": onuDeviceEntry.deviceID, "for PortNo": uniNo})
 
 		//create MBSP
-		onuDeviceEntry.PDevOmciCC.mutexPLastTxMeInstance.Lock()
-		meInstance, err := onuDeviceEntry.PDevOmciCC.sendCreateMBServiceProfile(
-			log.WithSpanFromContext(context.TODO(), ctx), uniPort, onuDeviceEntry.pOpenOnuAc.omciTimeout, true)
+		onuDeviceEntry.mutexPLastTxMeInstance.Lock()
+		meInstance, err := onuDeviceEntry.PDevOmciCC.SendCreateMBServiceProfile(
+			log.WithSpanFromContext(context.TODO(), ctx), uniPort, onuDeviceEntry.baseDeviceHandler.GetOmciTimeout(), true)
 		if err != nil {
-			onuDeviceEntry.PDevOmciCC.mutexPLastTxMeInstance.Unlock()
+			onuDeviceEntry.mutexPLastTxMeInstance.Unlock()
 			logger.Errorw(ctx, "MBServiceProfile create failed, aborting MibDownload FSM!", log.Fields{"device-id": onuDeviceEntry.deviceID})
-			_ = onuDeviceEntry.pMibDownloadFsm.pFsm.Event(dlEvReset)
+			_ = onuDeviceEntry.PMibDownloadFsm.PFsm.Event(DlEvReset)
 			return
 		}
-		onuDeviceEntry.PDevOmciCC.pLastTxMeInstance = meInstance
-		onuDeviceEntry.PDevOmciCC.mutexPLastTxMeInstance.Unlock()
+		onuDeviceEntry.pLastTxMeInstance = meInstance
+		onuDeviceEntry.mutexPLastTxMeInstance.Unlock()
 		//verify response
 		err = onuDeviceEntry.waitforOmciResponse(ctx, meInstance)
 		if err != nil {
 			logger.Errorw(ctx, "InitialBridgeSetup failed at MBSP, aborting MIB Download!",
 				log.Fields{"device-id": onuDeviceEntry.deviceID})
-			_ = onuDeviceEntry.pMibDownloadFsm.pFsm.Event(dlEvReset)
+			_ = onuDeviceEntry.PMibDownloadFsm.PFsm.Event(DlEvReset)
 			return
 		}
 
 		//create MBPCD
-		onuDeviceEntry.PDevOmciCC.mutexPLastTxMeInstance.Lock()
-		meInstance, err = onuDeviceEntry.PDevOmciCC.sendCreateMBPConfigDataUniSide(
-			log.WithSpanFromContext(context.TODO(), ctx), uniPort, onuDeviceEntry.pOpenOnuAc.omciTimeout, true)
+		onuDeviceEntry.mutexPLastTxMeInstance.Lock()
+		meInstance, err = onuDeviceEntry.PDevOmciCC.SendCreateMBPConfigDataUniSide(
+			log.WithSpanFromContext(context.TODO(), ctx), uniPort, onuDeviceEntry.baseDeviceHandler.GetOmciTimeout(), true)
 		if err != nil {
-			onuDeviceEntry.PDevOmciCC.mutexPLastTxMeInstance.Unlock()
+			onuDeviceEntry.mutexPLastTxMeInstance.Unlock()
 			logger.Errorw(ctx, "MBPConfigData create failed, aborting MibDownload FSM!",
 				log.Fields{"device-id": onuDeviceEntry.deviceID})
-			_ = onuDeviceEntry.pMibDownloadFsm.pFsm.Event(dlEvReset)
+			_ = onuDeviceEntry.PMibDownloadFsm.PFsm.Event(DlEvReset)
 			return
 		}
-		onuDeviceEntry.PDevOmciCC.pLastTxMeInstance = meInstance
-		onuDeviceEntry.PDevOmciCC.mutexPLastTxMeInstance.Unlock()
+		onuDeviceEntry.pLastTxMeInstance = meInstance
+		onuDeviceEntry.mutexPLastTxMeInstance.Unlock()
 		//verify response
 		err = onuDeviceEntry.waitforOmciResponse(ctx, meInstance)
 		if err != nil {
 			logger.Errorw(ctx, "InitialBridgeSetup failed at MBPCD, aborting MIB Download!",
 				log.Fields{"device-id": onuDeviceEntry.deviceID})
-			_ = onuDeviceEntry.pMibDownloadFsm.pFsm.Event(dlEvReset)
+			_ = onuDeviceEntry.PMibDownloadFsm.PFsm.Event(DlEvReset)
 			return
 		}
 
 		//create EVTOCD
-		onuDeviceEntry.PDevOmciCC.mutexPLastTxMeInstance.Lock()
-		meInstance, err = onuDeviceEntry.PDevOmciCC.sendCreateEVTOConfigData(
-			log.WithSpanFromContext(context.TODO(), ctx), uniPort, onuDeviceEntry.pOpenOnuAc.omciTimeout, true)
+		onuDeviceEntry.mutexPLastTxMeInstance.Lock()
+		meInstance, err = onuDeviceEntry.PDevOmciCC.SendCreateEVTOConfigData(
+			log.WithSpanFromContext(context.TODO(), ctx), uniPort, onuDeviceEntry.baseDeviceHandler.GetOmciTimeout(), true)
 		if err != nil {
-			onuDeviceEntry.PDevOmciCC.mutexPLastTxMeInstance.Unlock()
+			onuDeviceEntry.mutexPLastTxMeInstance.Unlock()
 			logger.Errorw(ctx, "EVTOConfigData create failed, aborting MibDownload FSM!",
 				log.Fields{"device-id": onuDeviceEntry.deviceID})
-			_ = onuDeviceEntry.pMibDownloadFsm.pFsm.Event(dlEvReset)
+			_ = onuDeviceEntry.PMibDownloadFsm.PFsm.Event(DlEvReset)
 			return
 		}
-		onuDeviceEntry.PDevOmciCC.pLastTxMeInstance = meInstance
-		onuDeviceEntry.PDevOmciCC.mutexPLastTxMeInstance.Unlock()
+		onuDeviceEntry.pLastTxMeInstance = meInstance
+		onuDeviceEntry.mutexPLastTxMeInstance.Unlock()
 		//verify response
 		err = onuDeviceEntry.waitforOmciResponse(ctx, meInstance)
 		if err != nil {
 			logger.Errorw(ctx, "InitialBridgeSetup failed at EVTOCD, aborting MIB Download!",
 				log.Fields{"device-id": onuDeviceEntry.deviceID})
-			_ = onuDeviceEntry.pMibDownloadFsm.pFsm.Event(dlEvReset)
+			_ = onuDeviceEntry.PMibDownloadFsm.PFsm.Event(DlEvReset)
 			return
 		}
 	}
 	// if Config has been done for all UNI related instances let the FSM proceed
 	// while we did not check here, if there is some port at all - !?
 	logger.Infow(ctx, "IntialBridgeSetup finished", log.Fields{"device-id": onuDeviceEntry.deviceID})
-	_ = onuDeviceEntry.pMibDownloadFsm.pFsm.Event(dlEvRxBridgeResp)
+	_ = onuDeviceEntry.PMibDownloadFsm.PFsm.Event(DlEvRxBridgeResp)
 }
 
 func (onuDeviceEntry *OnuDeviceEntry) waitforOmciResponse(ctx context.Context, apMeInstance *me.ManagedEntity) error {
diff --git a/internal/pkg/onuadaptercore/mib_sync.go b/internal/pkg/mib/mib_sync.go
old mode 100644
new mode 100755
similarity index 74%
rename from internal/pkg/onuadaptercore/mib_sync.go
rename to internal/pkg/mib/mib_sync.go
index 1660791..871b6de
--- a/internal/pkg/onuadaptercore/mib_sync.go
+++ b/internal/pkg/mib/mib_sync.go
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package mib provides the utilities for managing the onu mib
+package mib
 
 import (
 	"context"
@@ -34,6 +34,8 @@
 	me "github.com/opencord/omci-lib-go/generated"
 	"github.com/opencord/voltha-lib-go/v7/pkg/db/kvstore"
 	"github.com/opencord/voltha-lib-go/v7/pkg/log"
+	cmn "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/common"
+	devdb "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/devdb"
 )
 
 type sLastTxMeParameter struct {
@@ -64,25 +66,25 @@
 	// 347 // definitions for ME "IPv6 host config data" are currently missing in omci-lib-go!
 }
 
-var fsmMsg TestMessageType
+var fsmMsg cmn.TestMessageType
 
 func (oo *OnuDeviceEntry) enterStartingState(ctx context.Context, e *fsm.Event) {
 	logger.Debugw(ctx, "MibSync FSM", log.Fields{"Start processing MibSync-msgs in State": e.FSM.Current(), "device-id": oo.deviceID})
-	oo.pOnuDB = newOnuDeviceDB(log.WithSpanFromContext(context.TODO(), ctx), oo)
+	oo.pOnuDB = devdb.NewOnuDeviceDB(log.WithSpanFromContext(context.TODO(), ctx), oo.deviceID)
 	go oo.processMibSyncMessages(ctx)
 }
 
 func (oo *OnuDeviceEntry) enterResettingMibState(ctx context.Context, e *fsm.Event) {
 	logger.Debugw(ctx, "MibSync FSM", log.Fields{"Start MibTemplate processing in State": e.FSM.Current(), "device-id": oo.deviceID})
 
-	if (!oo.isNewOnu() && !oo.baseDeviceHandler.isReconciling()) || //use case: re-auditing failed
-		oo.baseDeviceHandler.isSkipOnuConfigReconciling() { //use case: reconciling without omci-config failed
-		oo.baseDeviceHandler.prepareReconcilingWithActiveAdapter(ctx)
-		oo.devState = DeviceStatusInit
+	if (!oo.IsNewOnu() && !oo.baseDeviceHandler.IsReconciling()) || //use case: re-auditing failed
+		oo.baseDeviceHandler.IsSkipOnuConfigReconciling() { //use case: reconciling without omci-config failed
+		oo.baseDeviceHandler.PrepareReconcilingWithActiveAdapter(ctx)
+		oo.devState = cmn.DeviceStatusInit
 	}
 	logger.Debugw(ctx, "MibSync FSM", log.Fields{"send mibReset in State": e.FSM.Current(), "device-id": oo.deviceID})
 	oo.mutexLastTxParamStruct.Lock()
-	_ = oo.PDevOmciCC.sendMibReset(log.WithSpanFromContext(context.TODO(), ctx), oo.pOpenOnuAc.omciTimeout, true)
+	_ = oo.PDevOmciCC.SendMibReset(log.WithSpanFromContext(context.TODO(), ctx), oo.baseDeviceHandler.GetOmciTimeout(), true)
 	//TODO: needs to handle timeouts
 	//even though lastTxParameters are currently not used for checking the ResetResponse message we have to ensure
 	//  that the lastTxMessageType is correctly set to avoid misinterpreting other responses
@@ -95,16 +97,16 @@
 	logger.Debugw(ctx, "MibSync FSM", log.Fields{"Start getting VendorId and SerialNumber in State": e.FSM.Current(), "device-id": oo.deviceID})
 	requestedAttributes := me.AttributeValueMap{"VendorId": "", "SerialNumber": 0}
 	oo.mutexLastTxParamStruct.Lock()
-	meInstance, err := oo.PDevOmciCC.sendGetMe(log.WithSpanFromContext(context.TODO(), ctx), me.OnuGClassID, onugMeID, requestedAttributes, oo.pOpenOnuAc.omciTimeout, true, oo.pMibUploadFsm.commChan)
+	meInstance, err := oo.PDevOmciCC.SendGetMe(log.WithSpanFromContext(context.TODO(), ctx), me.OnuGClassID, cmn.OnugMeID, requestedAttributes, oo.baseDeviceHandler.GetOmciTimeout(), true, oo.PMibUploadFsm.CommChan)
 	//accept also nil as (error) return value for writing to LastTx
 	//  - this avoids misinterpretation of new received OMCI messages
 	if err != nil {
 		oo.mutexLastTxParamStruct.Unlock()
 		logger.Errorw(ctx, "ONU-G get failed, aborting MibSync FSM", log.Fields{"device-id": oo.deviceID})
-		pMibUlFsm := oo.pMibUploadFsm
+		pMibUlFsm := oo.PMibUploadFsm
 		if pMibUlFsm != nil {
-			go func(a_pAFsm *AdapterFsm) {
-				_ = oo.pMibUploadFsm.pFsm.Event(ulEvStop)
+			go func(a_pAFsm *cmn.AdapterFsm) {
+				_ = oo.PMibUploadFsm.PFsm.Event(UlEvStop)
 			}(pMibUlFsm)
 		}
 		return
@@ -118,16 +120,16 @@
 	logger.Debugw(ctx, "MibSync FSM", log.Fields{"Start getting EquipmentId in State": e.FSM.Current(), "device-id": oo.deviceID})
 	requestedAttributes := me.AttributeValueMap{"EquipmentId": ""}
 	oo.mutexLastTxParamStruct.Lock()
-	meInstance, err := oo.PDevOmciCC.sendGetMe(log.WithSpanFromContext(context.TODO(), ctx), me.Onu2GClassID, onu2gMeID, requestedAttributes, oo.pOpenOnuAc.omciTimeout, true, oo.pMibUploadFsm.commChan)
+	meInstance, err := oo.PDevOmciCC.SendGetMe(log.WithSpanFromContext(context.TODO(), ctx), me.Onu2GClassID, cmn.Onu2gMeID, requestedAttributes, oo.baseDeviceHandler.GetOmciTimeout(), true, oo.PMibUploadFsm.CommChan)
 	//accept also nil as (error) return value for writing to LastTx
 	//  - this avoids misinterpretation of new received OMCI messages
 	if err != nil {
 		oo.mutexLastTxParamStruct.Unlock()
 		logger.Errorw(ctx, "ONU2-G get failed, aborting MibSync FSM!", log.Fields{"device-id": oo.deviceID})
-		pMibUlFsm := oo.pMibUploadFsm
+		pMibUlFsm := oo.PMibUploadFsm
 		if pMibUlFsm != nil {
-			go func(a_pAFsm *AdapterFsm) {
-				_ = oo.pMibUploadFsm.pFsm.Event(ulEvStop)
+			go func(a_pAFsm *cmn.AdapterFsm) {
+				_ = oo.PMibUploadFsm.PFsm.Event(UlEvStop)
 			}(pMibUlFsm)
 		}
 		return
@@ -141,16 +143,16 @@
 	logger.Debugw(ctx, "MibSync FSM", log.Fields{"Start getting IsActive and Version of first SW-image in State": e.FSM.Current(), "device-id": oo.deviceID})
 	requestedAttributes := me.AttributeValueMap{"IsCommitted": 0, "IsActive": 0, "Version": ""}
 	oo.mutexLastTxParamStruct.Lock()
-	meInstance, err := oo.PDevOmciCC.sendGetMe(log.WithSpanFromContext(context.TODO(), ctx), me.SoftwareImageClassID, firstSwImageMeID, requestedAttributes, oo.pOpenOnuAc.omciTimeout, true, oo.pMibUploadFsm.commChan)
+	meInstance, err := oo.PDevOmciCC.SendGetMe(log.WithSpanFromContext(context.TODO(), ctx), me.SoftwareImageClassID, cmn.FirstSwImageMeID, requestedAttributes, oo.baseDeviceHandler.GetOmciTimeout(), true, oo.PMibUploadFsm.CommChan)
 	//accept also nil as (error) return value for writing to LastTx
 	//  - this avoids misinterpretation of new received OMCI messages
 	if err != nil {
 		oo.mutexLastTxParamStruct.Unlock()
 		logger.Errorw(ctx, "SoftwareImage get failed, aborting MibSync FSM", log.Fields{"device-id": oo.deviceID})
-		pMibUlFsm := oo.pMibUploadFsm
+		pMibUlFsm := oo.PMibUploadFsm
 		if pMibUlFsm != nil {
-			go func(a_pAFsm *AdapterFsm) {
-				_ = oo.pMibUploadFsm.pFsm.Event(ulEvStop)
+			go func(a_pAFsm *cmn.AdapterFsm) {
+				_ = oo.PMibUploadFsm.PFsm.Event(UlEvStop)
 			}(pMibUlFsm)
 		}
 		return
@@ -164,16 +166,16 @@
 	logger.Debugw(ctx, "MibSync FSM", log.Fields{"Start getting IsActive and Version of second SW-image in State": e.FSM.Current(), "device-id": oo.deviceID})
 	requestedAttributes := me.AttributeValueMap{"IsCommitted": 0, "IsActive": 0, "Version": ""}
 	oo.mutexLastTxParamStruct.Lock()
-	meInstance, err := oo.PDevOmciCC.sendGetMe(log.WithSpanFromContext(context.TODO(), ctx), me.SoftwareImageClassID, secondSwImageMeID, requestedAttributes, oo.pOpenOnuAc.omciTimeout, true, oo.pMibUploadFsm.commChan)
+	meInstance, err := oo.PDevOmciCC.SendGetMe(log.WithSpanFromContext(context.TODO(), ctx), me.SoftwareImageClassID, cmn.SecondSwImageMeID, requestedAttributes, oo.baseDeviceHandler.GetOmciTimeout(), true, oo.PMibUploadFsm.CommChan)
 	//accept also nil as (error) return value for writing to LastTx
 	//  - this avoids misinterpretation of new received OMCI messages
 	if err != nil {
 		oo.mutexLastTxParamStruct.Unlock()
 		logger.Errorw(ctx, "SoftwareImage get failed, aborting MibSync FSM", log.Fields{"device-id": oo.deviceID})
-		pMibUlFsm := oo.pMibUploadFsm
+		pMibUlFsm := oo.PMibUploadFsm
 		if pMibUlFsm != nil {
-			go func(a_pAFsm *AdapterFsm) {
-				_ = oo.pMibUploadFsm.pFsm.Event(ulEvStop)
+			go func(a_pAFsm *cmn.AdapterFsm) {
+				_ = oo.PMibUploadFsm.PFsm.Event(UlEvStop)
 			}(pMibUlFsm)
 		}
 		return
@@ -187,16 +189,16 @@
 	logger.Debugw(ctx, "MibSync FSM", log.Fields{"Start getting MacAddress in State": e.FSM.Current(), "device-id": oo.deviceID})
 	requestedAttributes := me.AttributeValueMap{"MacAddress": ""}
 	oo.mutexLastTxParamStruct.Lock()
-	meInstance, err := oo.PDevOmciCC.sendGetMe(log.WithSpanFromContext(context.TODO(), ctx), me.IpHostConfigDataClassID, ipHostConfigDataMeID, requestedAttributes, oo.pOpenOnuAc.omciTimeout, true, oo.pMibUploadFsm.commChan)
+	meInstance, err := oo.PDevOmciCC.SendGetMe(log.WithSpanFromContext(context.TODO(), ctx), me.IpHostConfigDataClassID, cmn.IPHostConfigDataMeID, requestedAttributes, oo.baseDeviceHandler.GetOmciTimeout(), true, oo.PMibUploadFsm.CommChan)
 	//accept also nil as (error) return value for writing to LastTx
 	//  - this avoids misinterpretation of new received OMCI messages
 	if err != nil {
 		oo.mutexLastTxParamStruct.Unlock()
 		logger.Errorw(ctx, "IpHostConfigData get failed, aborting MibSync FSM", log.Fields{"device-id": oo.deviceID})
-		pMibUlFsm := oo.pMibUploadFsm
+		pMibUlFsm := oo.PMibUploadFsm
 		if pMibUlFsm != nil {
-			go func(a_pAFsm *AdapterFsm) {
-				_ = oo.pMibUploadFsm.pFsm.Event(ulEvStop)
+			go func(a_pAFsm *cmn.AdapterFsm) {
+				_ = oo.PMibUploadFsm.PFsm.Event(UlEvStop)
 			}(pMibUlFsm)
 		}
 		return
@@ -209,10 +211,10 @@
 func (oo *OnuDeviceEntry) enterGettingMibTemplateState(ctx context.Context, e *fsm.Event) {
 
 	oo.mutexOnuSwImageIndications.RLock()
-	if oo.onuSwImageIndications.activeEntityEntry.valid {
-		oo.mutexPersOnuConfig.Lock()
-		oo.sOnuPersistentData.PersActiveSwVersion = oo.onuSwImageIndications.activeEntityEntry.version
-		oo.mutexPersOnuConfig.Unlock()
+	if oo.onuSwImageIndications.ActiveEntityEntry.Valid {
+		oo.MutexPersOnuConfig.Lock()
+		oo.SOnuPersistentData.PersActiveSwVersion = oo.onuSwImageIndications.ActiveEntityEntry.Version
+		oo.MutexPersOnuConfig.Unlock()
 		oo.mutexOnuSwImageIndications.RUnlock()
 	} else {
 		oo.mutexOnuSwImageIndications.RUnlock()
@@ -221,35 +223,35 @@
 	}
 	if oo.getMibFromTemplate(ctx) {
 		logger.Debug(ctx, "MibSync FSM - valid MEs stored from template")
-		oo.pOnuDB.logMeDb(ctx)
-		fsmMsg = LoadMibTemplateOk
+		oo.pOnuDB.LogMeDb(ctx)
+		fsmMsg = cmn.LoadMibTemplateOk
 	} else {
 		logger.Debug(ctx, "MibSync FSM - no valid MEs stored from template - perform MIB-upload!")
-		fsmMsg = LoadMibTemplateFailed
+		fsmMsg = cmn.LoadMibTemplateFailed
 
-		oo.pOpenOnuAc.lockMibTemplateGenerated.Lock()
-		if mibTemplateIsGenerated, exist := oo.pOpenOnuAc.mibTemplatesGenerated[oo.mibTemplatePath]; exist {
+		oo.pOpenOnuAc.LockMutexMibTemplateGenerated()
+		if mibTemplateIsGenerated, exist := oo.pOpenOnuAc.GetMibTemplatesGenerated(oo.mibTemplatePath); exist {
 			if mibTemplateIsGenerated {
 				logger.Debugw(ctx,
 					"MibSync FSM - template was successfully generated before, but doesn't exist or isn't usable anymore - reset flag in map",
 					log.Fields{"path": oo.mibTemplatePath, "device-id": oo.deviceID})
-				oo.pOpenOnuAc.mibTemplatesGenerated[oo.mibTemplatePath] = false
+				oo.pOpenOnuAc.SetMibTemplatesGenerated(oo.mibTemplatePath, false)
 			}
 		}
-		oo.pOpenOnuAc.lockMibTemplateGenerated.Unlock()
+		oo.pOpenOnuAc.UnlockMutexMibTemplateGenerated()
 	}
-	mibSyncMsg := Message{
-		Type: TestMsg,
-		Data: TestMessage{
+	mibSyncMsg := cmn.Message{
+		Type: cmn.TestMsg,
+		Data: cmn.TestMessage{
 			TestMessageVal: fsmMsg,
 		},
 	}
-	oo.pMibUploadFsm.commChan <- mibSyncMsg
+	oo.PMibUploadFsm.CommChan <- mibSyncMsg
 }
 
 func (oo *OnuDeviceEntry) enterUploadingState(ctx context.Context, e *fsm.Event) {
 	logger.Debugw(ctx, "MibSync FSM", log.Fields{"send MibUpload in State": e.FSM.Current(), "device-id": oo.deviceID})
-	_ = oo.PDevOmciCC.sendMibUpload(log.WithSpanFromContext(context.TODO(), ctx), oo.pOpenOnuAc.omciTimeout, true)
+	_ = oo.PDevOmciCC.SendMibUpload(log.WithSpanFromContext(context.TODO(), ctx), oo.baseDeviceHandler.GetOmciTimeout(), true)
 	//even though lastTxParameters are currently not used for checking the ResetResponse message we have to ensure
 	//  that the lastTxMessageType is correctly set to avoid misinterpreting other responses
 	oo.mutexLastTxParamStruct.Lock()
@@ -259,21 +261,21 @@
 
 func (oo *OnuDeviceEntry) enterUploadDoneState(ctx context.Context, e *fsm.Event) {
 	logger.Debugw(ctx, "MibSync FSM", log.Fields{"send notification to core in State": e.FSM.Current(), "device-id": oo.deviceID})
-	oo.transferSystemEvent(ctx, MibDatabaseSync)
+	oo.transferSystemEvent(ctx, cmn.MibDatabaseSync)
 	go func() {
-		_ = oo.pMibUploadFsm.pFsm.Event(ulEvSuccess)
+		_ = oo.PMibUploadFsm.PFsm.Event(UlEvSuccess)
 	}()
 }
 
 func (oo *OnuDeviceEntry) enterInSyncState(ctx context.Context, e *fsm.Event) {
-	oo.mutexPersOnuConfig.Lock()
-	oo.sOnuPersistentData.PersMibLastDbSync = uint32(time.Now().Unix())
-	oo.mutexPersOnuConfig.Unlock()
+	oo.MutexPersOnuConfig.Lock()
+	oo.SOnuPersistentData.PersMibLastDbSync = uint32(time.Now().Unix())
+	oo.MutexPersOnuConfig.Unlock()
 	if oo.mibAuditInterval > 0 {
 		logger.Debugw(ctx, "MibSync FSM", log.Fields{"trigger next Audit in State": e.FSM.Current(), "oo.mibAuditInterval": oo.mibAuditInterval, "device-id": oo.deviceID})
 		go func() {
 			time.Sleep(oo.mibAuditInterval)
-			if err := oo.pMibUploadFsm.pFsm.Event(ulEvAuditMib); err != nil {
+			if err := oo.PMibUploadFsm.PFsm.Event(UlEvAuditMib); err != nil {
 				logger.Debugw(ctx, "MibSyncFsm: Can't go to state auditing", log.Fields{"device-id": oo.deviceID, "err": err})
 			}
 		}()
@@ -300,20 +302,20 @@
 		log.Fields{"Start processing on examining MDS success in State": e.FSM.Current(), "device-id": oo.deviceID})
 
 	if oo.getMibFromTemplate(ctx) {
-		oo.baseDeviceHandler.startReconciling(ctx, true)
-		oo.baseDeviceHandler.addAllUniPorts(ctx)
-		oo.baseDeviceHandler.setDeviceReason(drInitialMibDownloaded)
-		oo.baseDeviceHandler.setReadyForOmciConfig(true)
+		oo.baseDeviceHandler.StartReconciling(ctx, true)
+		oo.baseDeviceHandler.AddAllUniPorts(ctx)
+		oo.baseDeviceHandler.SetDeviceReason(cmn.DrInitialMibDownloaded)
+		oo.baseDeviceHandler.SetReadyForOmciConfig(true)
 
-		if !oo.baseDeviceHandler.getCollectorIsRunning() {
+		if !oo.baseDeviceHandler.GetCollectorIsRunning() {
 			// Start PM collector routine
-			go oo.baseDeviceHandler.startCollector(ctx)
+			go oo.baseDeviceHandler.StartCollector(ctx)
 		}
-		if !oo.baseDeviceHandler.getAlarmManagerIsRunning(ctx) {
-			go oo.baseDeviceHandler.startAlarmManager(ctx)
+		if !oo.baseDeviceHandler.GetAlarmManagerIsRunning(ctx) {
+			go oo.baseDeviceHandler.StartAlarmManager(ctx)
 		}
 		// no need to reconcile additional data for MibDownloadFsm, LockStateFsm, or UnlockStateFsm
-		oo.baseDeviceHandler.reconcileDeviceTechProf(ctx)
+		oo.baseDeviceHandler.ReconcileDeviceTechProf(ctx)
 
 		// start go routine with select() on reconciling flow channel before
 		// starting flow reconciling process to prevent loss of any signal
@@ -322,66 +324,66 @@
 			// we get a signal that the processing of the last step to rebuild the adapter internal
 			// flow data is finished.
 			select {
-			case success := <-oo.baseDeviceHandler.chReconcilingFlowsFinished:
+			case success := <-oo.chReconcilingFlowsFinished:
 				if success {
 					logger.Debugw(ctx, "reconciling flows has been finished in time",
 						log.Fields{"device-id": oo.deviceID})
-					oo.baseDeviceHandler.stopReconciling(ctx, true)
-					_ = oo.pMibUploadFsm.pFsm.Event(ulEvSuccess)
+					oo.baseDeviceHandler.StopReconciling(ctx, true)
+					_ = oo.PMibUploadFsm.PFsm.Event(UlEvSuccess)
 
 				} else {
 					logger.Debugw(ctx, "wait for reconciling flows aborted",
 						log.Fields{"device-id": oo.deviceID})
-					oo.baseDeviceHandler.setReconcilingFlows(false)
+					oo.SetReconcilingFlows(false)
 				}
 			case <-time.After(500 * time.Millisecond):
 				logger.Errorw(ctx, "timeout waiting for reconciling flows to be finished!",
 					log.Fields{"device-id": oo.deviceID})
-				oo.baseDeviceHandler.setReconcilingFlows(false)
-				_ = oo.pMibUploadFsm.pFsm.Event(ulEvMismatch)
+				oo.SetReconcilingFlows(false)
+				_ = oo.PMibUploadFsm.PFsm.Event(UlEvMismatch)
 			}
 		}()
-		oo.baseDeviceHandler.reconcileDeviceFlowConfig(ctx)
+		oo.baseDeviceHandler.ReconcileDeviceFlowConfig(ctx)
 
-		oo.mutexPersOnuConfig.RLock()
-		if oo.sOnuPersistentData.PersUniDisableDone {
-			oo.mutexPersOnuConfig.RUnlock()
-			oo.baseDeviceHandler.disableUniPortStateUpdate(ctx)
-			oo.baseDeviceHandler.setDeviceReason(drOmciAdminLock)
+		oo.MutexPersOnuConfig.RLock()
+		if oo.SOnuPersistentData.PersUniDisableDone {
+			oo.MutexPersOnuConfig.RUnlock()
+			oo.baseDeviceHandler.DisableUniPortStateUpdate(ctx)
+			oo.baseDeviceHandler.SetDeviceReason(cmn.DrOmciAdminLock)
 		} else {
-			oo.mutexPersOnuConfig.RUnlock()
-			oo.baseDeviceHandler.enableUniPortStateUpdate(ctx)
+			oo.MutexPersOnuConfig.RUnlock()
+			oo.baseDeviceHandler.EnableUniPortStateUpdate(ctx)
 		}
 	} else {
 		logger.Debugw(ctx, "MibSync FSM",
 			log.Fields{"Getting MIB from template not successful": e.FSM.Current(), "device-id": oo.deviceID})
 		go func() {
 			//switch to reconciling with OMCI config
-			_ = oo.pMibUploadFsm.pFsm.Event(ulEvMismatch)
+			_ = oo.PMibUploadFsm.PFsm.Event(UlEvMismatch)
 		}()
 	}
 }
 
 func (oo *OnuDeviceEntry) enterAuditingState(ctx context.Context, e *fsm.Event) {
 	logger.Debugw(ctx, "MibSync FSM", log.Fields{"Start MibAudit processing in State": e.FSM.Current(), "device-id": oo.deviceID})
-	if oo.baseDeviceHandler.checkAuditStartCondition(ctx, cUploadFsm) {
+	if oo.baseDeviceHandler.CheckAuditStartCondition(ctx, cmn.CUploadFsm) {
 		oo.requestMdsValue(ctx)
 	} else {
 		logger.Debugw(ctx, "MibSync FSM", log.Fields{"Configuration is ongoing or missing - skip auditing!": e.FSM.Current(), "device-id": oo.deviceID})
 		go func() {
-			_ = oo.pMibUploadFsm.pFsm.Event(ulEvSuccess)
+			_ = oo.PMibUploadFsm.PFsm.Event(UlEvSuccess)
 		}()
 	}
 }
 
 func (oo *OnuDeviceEntry) enterReAuditingState(ctx context.Context, e *fsm.Event) {
 	logger.Debugw(ctx, "MibSync FSM", log.Fields{"Start retest MdsValue processing in State": e.FSM.Current(), "device-id": oo.deviceID})
-	if oo.baseDeviceHandler.checkAuditStartCondition(ctx, cUploadFsm) {
+	if oo.baseDeviceHandler.CheckAuditStartCondition(ctx, cmn.CUploadFsm) {
 		oo.requestMdsValue(ctx)
 	} else {
 		logger.Debugw(ctx, "MibSync FSM", log.Fields{"Configuration is ongoing or missing - skip re-auditing!": e.FSM.Current(), "device-id": oo.deviceID})
 		go func() {
-			_ = oo.pMibUploadFsm.pFsm.Event(ulEvSuccess)
+			_ = oo.PMibUploadFsm.PFsm.Event(UlEvSuccess)
 		}()
 	}
 }
@@ -398,7 +400,7 @@
 		// case <-ctx.Done():
 		// 	logger.Info("MibSync Msg", log.Fields{"Message handling canceled via context for device-id": onuDeviceEntry.deviceID})
 		// 	break loop
-		message, ok := <-oo.pMibUploadFsm.commChan
+		message, ok := <-oo.PMibUploadFsm.CommChan
 		if !ok {
 			logger.Info(ctx, "MibSync Msg", log.Fields{"Message couldn't be read from channel for device-id": oo.deviceID})
 			break loop
@@ -406,11 +408,11 @@
 		logger.Debugw(ctx, "MibSync Msg", log.Fields{"Received message on ONU MibSyncChan for device-id": oo.deviceID})
 
 		switch message.Type {
-		case TestMsg:
-			msg, _ := message.Data.(TestMessage)
+		case cmn.TestMsg:
+			msg, _ := message.Data.(cmn.TestMessage)
 			oo.handleTestMsg(ctx, msg)
-		case OMCI:
-			msg, _ := message.Data.(OmciMessage)
+		case cmn.OMCI:
+			msg, _ := message.Data.(cmn.OmciMessage)
 			oo.handleOmciMessage(ctx, msg)
 		default:
 			logger.Warn(ctx, "MibSync Msg", log.Fields{"Unknown message type received for device-id": oo.deviceID, "message.Type": message.Type})
@@ -418,38 +420,38 @@
 	}
 	logger.Info(ctx, "MibSync Msg", log.Fields{"Stopped handling of MibSyncChan for device-id": oo.deviceID})
 	// TODO: only this action?
-	_ = oo.pMibUploadFsm.pFsm.Event(ulEvStop)
+	_ = oo.PMibUploadFsm.PFsm.Event(UlEvStop)
 }
 
-func (oo *OnuDeviceEntry) handleTestMsg(ctx context.Context, msg TestMessage) {
+func (oo *OnuDeviceEntry) handleTestMsg(ctx context.Context, msg cmn.TestMessage) {
 
 	logger.Debugw(ctx, "MibSync Msg", log.Fields{"TestMessage received for device-id": oo.deviceID, "msg.TestMessageVal": msg.TestMessageVal})
 
 	switch msg.TestMessageVal {
-	case LoadMibTemplateFailed:
-		_ = oo.pMibUploadFsm.pFsm.Event(ulEvUploadMib)
-		logger.Debugw(ctx, "MibSync Msg", log.Fields{"state": string(oo.pMibUploadFsm.pFsm.Current())})
-	case LoadMibTemplateOk:
-		_ = oo.pMibUploadFsm.pFsm.Event(ulEvSuccess)
-		logger.Debugw(ctx, "MibSync Msg", log.Fields{"state": string(oo.pMibUploadFsm.pFsm.Current())})
+	case cmn.LoadMibTemplateFailed:
+		_ = oo.PMibUploadFsm.PFsm.Event(UlEvUploadMib)
+		logger.Debugw(ctx, "MibSync Msg", log.Fields{"state": string(oo.PMibUploadFsm.PFsm.Current())})
+	case cmn.LoadMibTemplateOk:
+		_ = oo.PMibUploadFsm.PFsm.Event(UlEvSuccess)
+		logger.Debugw(ctx, "MibSync Msg", log.Fields{"state": string(oo.PMibUploadFsm.PFsm.Current())})
 	default:
 		logger.Warn(ctx, "MibSync Msg", log.Fields{"Unknown message type received for device-id": oo.deviceID, "msg.TestMessageVal": msg.TestMessageVal})
 	}
 }
 
-func (oo *OnuDeviceEntry) handleOmciMibResetResponseMessage(ctx context.Context, msg OmciMessage) {
-	if oo.pMibUploadFsm.pFsm.Is(ulStResettingMib) {
+func (oo *OnuDeviceEntry) handleOmciMibResetResponseMessage(ctx context.Context, msg cmn.OmciMessage) {
+	if oo.PMibUploadFsm.PFsm.Is(UlStResettingMib) {
 		msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeMibResetResponse)
 		if msgLayer != nil {
 			msgObj, msgOk := msgLayer.(*omci.MibResetResponse)
 			if msgOk {
 				logger.Debugw(ctx, "MibResetResponse Data", log.Fields{"data-fields": msgObj})
 				if msgObj.Result == me.Success {
-					oo.mutexPersOnuConfig.Lock()
-					oo.sOnuPersistentData.PersMibDataSyncAdpt = 0
-					oo.mutexPersOnuConfig.Unlock()
+					oo.MutexPersOnuConfig.Lock()
+					oo.SOnuPersistentData.PersMibDataSyncAdpt = 0
+					oo.MutexPersOnuConfig.Unlock()
 					// trigger retrieval of VendorId and SerialNumber
-					_ = oo.pMibUploadFsm.pFsm.Event(ulEvGetVendorAndSerial)
+					_ = oo.PMibUploadFsm.PFsm.Event(UlEvGetVendorAndSerial)
 					return
 				}
 				logger.Errorw(ctx, "Omci MibResetResponse Error", log.Fields{"device-id": oo.deviceID, "Error": msgObj.Result})
@@ -467,12 +469,12 @@
 		if oo.lastTxParamStruct.lastTxMessageType == omci.GetRequestType && oo.lastTxParamStruct.repeatCount == 0 {
 			logger.Debugw(ctx, "MibSync FSM - repeat MdsGetRequest (updated SequenceNumber)", log.Fields{"device-id": oo.deviceID})
 			requestedAttributes := me.AttributeValueMap{"MibDataSync": ""}
-			_, err := oo.PDevOmciCC.sendGetMe(log.WithSpanFromContext(context.TODO(), ctx),
-				me.OnuDataClassID, onuDataMeID, requestedAttributes, oo.pOpenOnuAc.omciTimeout, true, oo.pMibUploadFsm.commChan)
+			_, err := oo.PDevOmciCC.SendGetMe(log.WithSpanFromContext(context.TODO(), ctx),
+				me.OnuDataClassID, cmn.OnuDataMeID, requestedAttributes, oo.baseDeviceHandler.GetOmciTimeout(), true, oo.PMibUploadFsm.CommChan)
 			if err != nil {
 				oo.mutexLastTxParamStruct.Unlock()
 				logger.Errorw(ctx, "ONUData get failed, aborting MibSync", log.Fields{"device-id": oo.deviceID})
-				_ = oo.pMibUploadFsm.pFsm.Event(ulEvStop)
+				_ = oo.PMibUploadFsm.PFsm.Event(UlEvStop)
 				return
 			}
 			//TODO: needs extra handling of timeouts
@@ -486,10 +488,10 @@
 		return
 	}
 	logger.Info(ctx, "MibSync Msg", log.Fields{"Stopped handling of MibSyncChan for device-id": oo.deviceID})
-	_ = oo.pMibUploadFsm.pFsm.Event(ulEvStop)
+	_ = oo.PMibUploadFsm.PFsm.Event(UlEvStop)
 }
 
-func (oo *OnuDeviceEntry) handleOmciMibUploadResponseMessage(ctx context.Context, msg OmciMessage) {
+func (oo *OnuDeviceEntry) handleOmciMibUploadResponseMessage(ctx context.Context, msg cmn.OmciMessage) {
 	msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeMibUploadResponse)
 	if msgLayer == nil {
 		logger.Errorw(ctx, "Omci Msg layer could not be detected", log.Fields{"device-id": oo.deviceID})
@@ -502,22 +504,22 @@
 	}
 	logger.Debugw(ctx, "MibUploadResponse Data for:", log.Fields{"device-id": oo.deviceID, "data-fields": msgObj})
 	/* to be verified / reworked !!! */
-	oo.PDevOmciCC.uploadNoOfCmds = msgObj.NumberOfCommands
-	if oo.PDevOmciCC.uploadSequNo < oo.PDevOmciCC.uploadNoOfCmds {
-		_ = oo.PDevOmciCC.sendMibUploadNext(log.WithSpanFromContext(context.TODO(), ctx), oo.pOpenOnuAc.omciTimeout, true)
+	oo.PDevOmciCC.UploadNoOfCmds = msgObj.NumberOfCommands
+	if oo.PDevOmciCC.UploadSequNo < oo.PDevOmciCC.UploadNoOfCmds {
+		_ = oo.PDevOmciCC.SendMibUploadNext(log.WithSpanFromContext(context.TODO(), ctx), oo.baseDeviceHandler.GetOmciTimeout(), true)
 		//even though lastTxParameters are currently not used for checking the ResetResponse message we have to ensure
 		//  that the lastTxMessageType is correctly set to avoid misinterpreting other responses
 		oo.mutexLastTxParamStruct.Lock()
 		oo.lastTxParamStruct.lastTxMessageType = omci.MibUploadNextRequestType
 		oo.mutexLastTxParamStruct.Unlock()
 	} else {
-		logger.Errorw(ctx, "Invalid number of commands received for:", log.Fields{"device-id": oo.deviceID, "uploadNoOfCmds": oo.PDevOmciCC.uploadNoOfCmds})
+		logger.Errorw(ctx, "Invalid number of commands received for:", log.Fields{"device-id": oo.deviceID, "UploadNoOfCmds": oo.PDevOmciCC.UploadNoOfCmds})
 		//TODO right action?
-		_ = oo.pMibUploadFsm.pFsm.Event(ulEvTimeout)
+		_ = oo.PMibUploadFsm.PFsm.Event(UlEvTimeout)
 	}
 }
 
-func (oo *OnuDeviceEntry) handleOmciMibUploadNextResponseMessage(ctx context.Context, msg OmciMessage) {
+func (oo *OnuDeviceEntry) handleOmciMibUploadNextResponseMessage(ctx context.Context, msg cmn.OmciMessage) {
 	msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeMibUploadNextResponse)
 
 	if msgLayer == nil {
@@ -541,25 +543,25 @@
 		meAttributes := msgObj.ReportedME.GetAttributeValueMap()
 		oo.pOnuDB.PutMe(ctx, meClassID, meEntityID, meAttributes)
 	}
-	if oo.PDevOmciCC.uploadSequNo < oo.PDevOmciCC.uploadNoOfCmds {
-		_ = oo.PDevOmciCC.sendMibUploadNext(log.WithSpanFromContext(context.TODO(), ctx), oo.pOpenOnuAc.omciTimeout, true)
+	if oo.PDevOmciCC.UploadSequNo < oo.PDevOmciCC.UploadNoOfCmds {
+		_ = oo.PDevOmciCC.SendMibUploadNext(log.WithSpanFromContext(context.TODO(), ctx), oo.baseDeviceHandler.GetOmciTimeout(), true)
 		//even though lastTxParameters are currently not used for checking the ResetResponse message we have to ensure
 		//  that the lastTxMessageType is correctly set to avoid misinterpreting other responses
 		oo.mutexLastTxParamStruct.Lock()
 		oo.lastTxParamStruct.lastTxMessageType = omci.MibUploadNextRequestType
 		oo.mutexLastTxParamStruct.Unlock()
 	} else {
-		oo.pOnuDB.logMeDb(ctx)
+		oo.pOnuDB.LogMeDb(ctx)
 		err := oo.createAndPersistMibTemplate(ctx)
 		if err != nil {
 			logger.Errorw(ctx, "MibSync - MibTemplate - Failed to create and persist the mib template", log.Fields{"error": err, "device-id": oo.deviceID})
 		}
 
-		_ = oo.pMibUploadFsm.pFsm.Event(ulEvSuccess)
+		_ = oo.PMibUploadFsm.PFsm.Event(UlEvSuccess)
 	}
 }
 
-func (oo *OnuDeviceEntry) handleOmciGetResponseMessage(ctx context.Context, msg OmciMessage) error {
+func (oo *OnuDeviceEntry) handleOmciGetResponseMessage(ctx context.Context, msg cmn.OmciMessage) error {
 	var err error = nil
 
 	oo.mutexLastTxParamStruct.RLock()
@@ -570,7 +572,7 @@
 		//  then we may force the ONU to react on the MIB reset with a new message that uses an increased Sequence number
 		if oo.lastTxParamStruct.lastTxMessageType == omci.MibResetRequestType && oo.lastTxParamStruct.repeatCount == 0 {
 			logger.Debugw(ctx, "MibSync FSM - repeat mibReset (updated SequenceNumber)", log.Fields{"device-id": oo.deviceID})
-			_ = oo.PDevOmciCC.sendMibReset(log.WithSpanFromContext(context.TODO(), ctx), oo.pOpenOnuAc.omciTimeout, true)
+			_ = oo.PDevOmciCC.SendMibReset(log.WithSpanFromContext(context.TODO(), ctx), oo.baseDeviceHandler.GetOmciTimeout(), true)
 			//TODO: needs extra handling of timeouts
 			oo.lastTxParamStruct.repeatCount = 1
 			oo.mutexLastTxParamStruct.RUnlock()
@@ -585,13 +587,13 @@
 	msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeGetResponse)
 	if msgLayer == nil {
 		logger.Errorw(ctx, "omci Msg layer could not be detected for GetResponse - handling of MibSyncChan stopped", log.Fields{"device-id": oo.deviceID})
-		_ = oo.pMibUploadFsm.pFsm.Event(ulEvStop)
+		_ = oo.PMibUploadFsm.PFsm.Event(UlEvStop)
 		return fmt.Errorf("omci Msg layer could not be detected for GetResponse - handling of MibSyncChan stopped: %s", oo.deviceID)
 	}
 	msgObj, msgOk := msgLayer.(*omci.GetResponse)
 	if !msgOk {
 		logger.Errorw(ctx, "omci Msg layer could not be assigned for GetResponse - handling of MibSyncChan stopped", log.Fields{"device-id": oo.deviceID})
-		_ = oo.pMibUploadFsm.pFsm.Event(ulEvStop)
+		_ = oo.PMibUploadFsm.PFsm.Event(UlEvStop)
 		return fmt.Errorf("omci Msg layer could not be assigned for GetResponse - handling of MibSyncChan stopped: %s", oo.deviceID)
 	}
 	logger.Debugw(ctx, "MibSync FSM - GetResponse Data", log.Fields{"device-id": oo.deviceID, "data-fields": msgObj})
@@ -605,36 +607,36 @@
 			switch meInstance {
 			case "OnuG":
 				oo.mutexLastTxParamStruct.RUnlock()
-				oo.mutexPersOnuConfig.Lock()
-				oo.sOnuPersistentData.PersVendorID = TrimStringFromMeOctet(meAttributes["VendorId"])
+				oo.MutexPersOnuConfig.Lock()
+				oo.SOnuPersistentData.PersVendorID = cmn.TrimStringFromMeOctet(meAttributes["VendorId"])
 				snBytes, _ := me.InterfaceToOctets(meAttributes["SerialNumber"])
-				if onugSerialNumberLen == len(snBytes) {
+				if cmn.OnugSerialNumberLen == len(snBytes) {
 					snVendorPart := fmt.Sprintf("%s", snBytes[:4])
 					snNumberPart := hex.EncodeToString(snBytes[4:])
-					oo.sOnuPersistentData.PersSerialNumber = snVendorPart + snNumberPart
+					oo.SOnuPersistentData.PersSerialNumber = snVendorPart + snNumberPart
 					logger.Debugw(ctx, "MibSync FSM - GetResponse Data for Onu-G - VendorId/SerialNumber", log.Fields{"device-id": oo.deviceID,
-						"onuDeviceEntry.vendorID": oo.sOnuPersistentData.PersVendorID, "onuDeviceEntry.serialNumber": oo.sOnuPersistentData.PersSerialNumber})
+						"onuDeviceEntry.vendorID": oo.SOnuPersistentData.PersVendorID, "onuDeviceEntry.serialNumber": oo.SOnuPersistentData.PersSerialNumber})
 				} else {
 					logger.Infow(ctx, "MibSync FSM - SerialNumber has wrong length - fill serialNumber with zeros", log.Fields{"device-id": oo.deviceID, "length": len(snBytes)})
-					oo.sOnuPersistentData.PersSerialNumber = cEmptySerialNumberString
+					oo.SOnuPersistentData.PersSerialNumber = cEmptySerialNumberString
 				}
-				oo.mutexPersOnuConfig.Unlock()
+				oo.MutexPersOnuConfig.Unlock()
 				// trigger retrieval of EquipmentId
-				_ = oo.pMibUploadFsm.pFsm.Event(ulEvGetEquipmentID)
+				_ = oo.PMibUploadFsm.PFsm.Event(UlEvGetEquipmentID)
 				return nil
 			case "Onu2G":
 				oo.mutexLastTxParamStruct.RUnlock()
-				oo.mutexPersOnuConfig.Lock()
-				oo.sOnuPersistentData.PersEquipmentID = TrimStringFromMeOctet(meAttributes["EquipmentId"])
+				oo.MutexPersOnuConfig.Lock()
+				oo.SOnuPersistentData.PersEquipmentID = cmn.TrimStringFromMeOctet(meAttributes["EquipmentId"])
 				logger.Debugw(ctx, "MibSync FSM - GetResponse Data for Onu2-G - EquipmentId", log.Fields{"device-id": oo.deviceID,
-					"onuDeviceEntry.equipmentID": oo.sOnuPersistentData.PersEquipmentID})
-				oo.mutexPersOnuConfig.Unlock()
+					"onuDeviceEntry.equipmentID": oo.SOnuPersistentData.PersEquipmentID})
+				oo.MutexPersOnuConfig.Unlock()
 				// trigger retrieval of 1st SW-image info
-				_ = oo.pMibUploadFsm.pFsm.Event(ulEvGetFirstSwVersion)
+				_ = oo.PMibUploadFsm.PFsm.Event(UlEvGetFirstSwVersion)
 				return nil
 			case "SoftwareImage":
 				oo.mutexLastTxParamStruct.RUnlock()
-				if entityID > secondSwImageMeID {
+				if entityID > cmn.SecondSwImageMeID {
 					logger.Errorw(ctx, "mibSync FSM - Failed to GetResponse Data for SoftwareImage with expected EntityId",
 						log.Fields{"device-id": oo.deviceID, "entity-ID": entityID})
 					return fmt.Errorf("mibSync FSM - SwResponse Data with unexpected EntityId: %s %x",
@@ -646,18 +648,18 @@
 			case "IpHostConfigData":
 				oo.mutexLastTxParamStruct.RUnlock()
 				macBytes, _ := me.InterfaceToOctets(meAttributes["MacAddress"])
-				oo.mutexPersOnuConfig.Lock()
-				if omciMacAddressLen == len(macBytes) {
-					oo.sOnuPersistentData.PersMacAddress = hex.EncodeToString(macBytes[:])
+				oo.MutexPersOnuConfig.Lock()
+				if cmn.OmciMacAddressLen == len(macBytes) {
+					oo.SOnuPersistentData.PersMacAddress = hex.EncodeToString(macBytes[:])
 					logger.Debugw(ctx, "MibSync FSM - GetResponse Data for IpHostConfigData - MacAddress", log.Fields{"device-id": oo.deviceID,
-						"macAddress": oo.sOnuPersistentData.PersMacAddress})
+						"macAddress": oo.SOnuPersistentData.PersMacAddress})
 				} else {
 					logger.Infow(ctx, "MibSync FSM - MacAddress wrong length - fill macAddress with zeros", log.Fields{"device-id": oo.deviceID, "length": len(macBytes)})
-					oo.sOnuPersistentData.PersMacAddress = cEmptyMacAddrString
+					oo.SOnuPersistentData.PersMacAddress = cEmptyMacAddrString
 				}
-				oo.mutexPersOnuConfig.Unlock()
+				oo.MutexPersOnuConfig.Unlock()
 				// trigger retrieval of mib template
-				_ = oo.pMibUploadFsm.pFsm.Event(ulEvGetMibTemplate)
+				_ = oo.PMibUploadFsm.PFsm.Event(UlEvGetMibTemplate)
 				return nil
 			case "OnuData":
 				oo.mutexLastTxParamStruct.RUnlock()
@@ -680,86 +682,86 @@
 		}
 	}
 	logger.Info(ctx, "MibSync Msg", log.Fields{"Stopped handling of MibSyncChan for device-id": oo.deviceID})
-	_ = oo.pMibUploadFsm.pFsm.Event(ulEvStop)
+	_ = oo.PMibUploadFsm.PFsm.Event(UlEvStop)
 	return err
 }
 
 func (oo *OnuDeviceEntry) handleSwImageIndications(ctx context.Context, entityID uint16, meAttributes me.AttributeValueMap) {
 	imageIsCommitted := meAttributes["IsCommitted"].(uint8)
 	imageIsActive := meAttributes["IsActive"].(uint8)
-	imageVersion := TrimStringFromMeOctet(meAttributes["Version"])
-	oo.mutexPersOnuConfig.RLock()
+	imageVersion := cmn.TrimStringFromMeOctet(meAttributes["Version"])
+	oo.MutexPersOnuConfig.RLock()
 	logger.Infow(ctx, "MibSync FSM - GetResponse Data for SoftwareImage",
 		log.Fields{"device-id": oo.deviceID, "entityID": entityID,
-			"version": imageVersion, "isActive": imageIsActive, "isCommitted": imageIsCommitted, "SNR": oo.sOnuPersistentData.PersSerialNumber})
-	oo.mutexPersOnuConfig.RUnlock()
-	if firstSwImageMeID == entityID {
+			"version": imageVersion, "isActive": imageIsActive, "isCommitted": imageIsCommitted, "SNR": oo.SOnuPersistentData.PersSerialNumber})
+	oo.MutexPersOnuConfig.RUnlock()
+	if cmn.FirstSwImageMeID == entityID {
 		//always accept the state of the first image (2nd image info should not yet be available)
 		oo.mutexOnuSwImageIndications.Lock()
-		if imageIsActive == swIsActive {
-			oo.onuSwImageIndications.activeEntityEntry.entityID = entityID
-			oo.onuSwImageIndications.activeEntityEntry.valid = true
-			oo.onuSwImageIndications.activeEntityEntry.version = imageVersion
-			oo.onuSwImageIndications.activeEntityEntry.isCommitted = imageIsCommitted
+		if imageIsActive == cmn.SwIsActive {
+			oo.onuSwImageIndications.ActiveEntityEntry.EntityID = entityID
+			oo.onuSwImageIndications.ActiveEntityEntry.Valid = true
+			oo.onuSwImageIndications.ActiveEntityEntry.Version = imageVersion
+			oo.onuSwImageIndications.ActiveEntityEntry.IsCommitted = imageIsCommitted
 			//as the SW version indication may stem from some ONU Down/up event
 			//the complementary image state is to be invalidated
 			//  (state of the second image is always expected afterwards or just invalid)
-			oo.onuSwImageIndications.inactiveEntityEntry.valid = false
+			oo.onuSwImageIndications.InActiveEntityEntry.Valid = false
 		} else {
-			oo.onuSwImageIndications.inactiveEntityEntry.entityID = entityID
-			oo.onuSwImageIndications.inactiveEntityEntry.valid = true
-			oo.onuSwImageIndications.inactiveEntityEntry.version = imageVersion
-			oo.onuSwImageIndications.inactiveEntityEntry.isCommitted = imageIsCommitted
+			oo.onuSwImageIndications.InActiveEntityEntry.EntityID = entityID
+			oo.onuSwImageIndications.InActiveEntityEntry.Valid = true
+			oo.onuSwImageIndications.InActiveEntityEntry.Version = imageVersion
+			oo.onuSwImageIndications.InActiveEntityEntry.IsCommitted = imageIsCommitted
 			//as the SW version indication may stem form some ONU Down/up event
 			//the complementary image state is to be invalidated
 			//  (state of the second image is always expected afterwards or just invalid)
-			oo.onuSwImageIndications.activeEntityEntry.valid = false
+			oo.onuSwImageIndications.ActiveEntityEntry.Valid = false
 		}
 		oo.mutexOnuSwImageIndications.Unlock()
-		_ = oo.pMibUploadFsm.pFsm.Event(ulEvGetSecondSwVersion)
+		_ = oo.PMibUploadFsm.PFsm.Event(UlEvGetSecondSwVersion)
 		return
-	} else if secondSwImageMeID == entityID {
+	} else if cmn.SecondSwImageMeID == entityID {
 		//2nd image info might conflict with first image info, in which case we priorize first image info!
 		oo.mutexOnuSwImageIndications.Lock()
-		if imageIsActive == swIsActive { //2nd image reported to be active
-			if oo.onuSwImageIndications.activeEntityEntry.valid {
+		if imageIsActive == cmn.SwIsActive { //2nd image reported to be active
+			if oo.onuSwImageIndications.ActiveEntityEntry.Valid {
 				//conflict exists - state of first image is left active
 				logger.Warnw(ctx, "mibSync FSM - both ONU images are reported as active - assuming 2nd to be inactive",
 					log.Fields{"device-id": oo.deviceID})
-				oo.onuSwImageIndications.inactiveEntityEntry.entityID = entityID
-				oo.onuSwImageIndications.inactiveEntityEntry.valid = true ////to indicate that at least something has been reported
-				oo.onuSwImageIndications.inactiveEntityEntry.version = imageVersion
-				oo.onuSwImageIndications.inactiveEntityEntry.isCommitted = imageIsCommitted
+				oo.onuSwImageIndications.InActiveEntityEntry.EntityID = entityID
+				oo.onuSwImageIndications.InActiveEntityEntry.Valid = true ////to indicate that at least something has been reported
+				oo.onuSwImageIndications.InActiveEntityEntry.Version = imageVersion
+				oo.onuSwImageIndications.InActiveEntityEntry.IsCommitted = imageIsCommitted
 			} else { //first image inactive, this one active
-				oo.onuSwImageIndications.activeEntityEntry.entityID = entityID
-				oo.onuSwImageIndications.activeEntityEntry.valid = true
-				oo.onuSwImageIndications.activeEntityEntry.version = imageVersion
-				oo.onuSwImageIndications.activeEntityEntry.isCommitted = imageIsCommitted
+				oo.onuSwImageIndications.ActiveEntityEntry.EntityID = entityID
+				oo.onuSwImageIndications.ActiveEntityEntry.Valid = true
+				oo.onuSwImageIndications.ActiveEntityEntry.Version = imageVersion
+				oo.onuSwImageIndications.ActiveEntityEntry.IsCommitted = imageIsCommitted
 			}
 		} else { //2nd image reported to be inactive
-			if oo.onuSwImageIndications.inactiveEntityEntry.valid {
+			if oo.onuSwImageIndications.InActiveEntityEntry.Valid {
 				//conflict exists - both images inactive - regard it as ONU failure and assume first image to be active
 				logger.Warnw(ctx, "mibSync FSM - both ONU images are reported as inactive, defining first to be active",
 					log.Fields{"device-id": oo.deviceID})
-				oo.onuSwImageIndications.activeEntityEntry.entityID = firstSwImageMeID
-				oo.onuSwImageIndications.activeEntityEntry.valid = true //to indicate that at least something has been reported
+				oo.onuSwImageIndications.ActiveEntityEntry.EntityID = cmn.FirstSwImageMeID
+				oo.onuSwImageIndications.ActiveEntityEntry.Valid = true //to indicate that at least something has been reported
 				//copy active commit/version from the previously stored inactive position
-				oo.onuSwImageIndications.activeEntityEntry.version = oo.onuSwImageIndications.inactiveEntityEntry.version
-				oo.onuSwImageIndications.activeEntityEntry.isCommitted = oo.onuSwImageIndications.inactiveEntityEntry.isCommitted
+				oo.onuSwImageIndications.ActiveEntityEntry.Version = oo.onuSwImageIndications.InActiveEntityEntry.Version
+				oo.onuSwImageIndications.ActiveEntityEntry.IsCommitted = oo.onuSwImageIndications.InActiveEntityEntry.IsCommitted
 			}
 			//in any case we indicate (and possibly overwrite) the second image indications as inactive
-			oo.onuSwImageIndications.inactiveEntityEntry.entityID = entityID
-			oo.onuSwImageIndications.inactiveEntityEntry.valid = true
-			oo.onuSwImageIndications.inactiveEntityEntry.version = imageVersion
-			oo.onuSwImageIndications.inactiveEntityEntry.isCommitted = imageIsCommitted
+			oo.onuSwImageIndications.InActiveEntityEntry.EntityID = entityID
+			oo.onuSwImageIndications.InActiveEntityEntry.Valid = true
+			oo.onuSwImageIndications.InActiveEntityEntry.Version = imageVersion
+			oo.onuSwImageIndications.InActiveEntityEntry.IsCommitted = imageIsCommitted
 		}
 		oo.mutexOnuSwImageIndications.Unlock()
-		_ = oo.pMibUploadFsm.pFsm.Event(ulEvGetMacAddress)
+		_ = oo.PMibUploadFsm.PFsm.Event(UlEvGetMacAddress)
 		return
 	}
 }
 
-func (oo *OnuDeviceEntry) handleOmciMessage(ctx context.Context, msg OmciMessage) {
+func (oo *OnuDeviceEntry) handleOmciMessage(ctx context.Context, msg cmn.OmciMessage) {
 	logger.Debugw(ctx, "MibSync Msg", log.Fields{"OmciMessage received for device-id": oo.deviceID,
 		"msgType": msg.OmciMsg.MessageType, "msg": msg})
 	//further analysis could be done here based on msg.OmciMsg.Payload, e.g. verification of error code ...
@@ -798,11 +800,11 @@
 					oo.mutexLastTxParamStruct.RUnlock()
 					logger.Debugw(ctx, "MibSync FSM - erroneous result for IpHostConfigData received - ONU doesn't support ME - fill macAddress with zeros",
 						log.Fields{"device-id": oo.deviceID, "data-fields": msgObj})
-					oo.mutexPersOnuConfig.Lock()
-					oo.sOnuPersistentData.PersMacAddress = cEmptyMacAddrString
-					oo.mutexPersOnuConfig.Unlock()
+					oo.MutexPersOnuConfig.Lock()
+					oo.SOnuPersistentData.PersMacAddress = cEmptyMacAddrString
+					oo.MutexPersOnuConfig.Unlock()
 					// trigger retrieval of mib template
-					_ = oo.pMibUploadFsm.pFsm.Event(ulEvGetMibTemplate)
+					_ = oo.PMibUploadFsm.PFsm.Event(UlEvGetMibTemplate)
 					return nil
 				default:
 					oo.mutexLastTxParamStruct.RUnlock()
@@ -823,10 +825,11 @@
 	return err
 }
 
-func (oo *OnuDeviceEntry) isNewOnu() bool {
-	oo.mutexPersOnuConfig.RLock()
-	defer oo.mutexPersOnuConfig.RUnlock()
-	return oo.sOnuPersistentData.PersMibLastDbSync == 0
+// IsNewOnu - TODO: add comment
+func (oo *OnuDeviceEntry) IsNewOnu() bool {
+	oo.MutexPersOnuConfig.RLock()
+	defer oo.MutexPersOnuConfig.RUnlock()
+	return oo.SOnuPersistentData.PersMibLastDbSync == 0
 }
 
 func isSupportedClassID(meClassID me.ClassID) bool {
@@ -850,12 +853,12 @@
 	logger.Debugw(ctx, "MibSync - MibTemplate - path name", log.Fields{"path": oo.mibTemplatePath,
 		"device-id": oo.deviceID})
 
-	oo.pOpenOnuAc.lockMibTemplateGenerated.Lock()
-	if mibTemplateIsGenerated, exist := oo.pOpenOnuAc.mibTemplatesGenerated[oo.mibTemplatePath]; exist {
+	oo.pOpenOnuAc.LockMutexMibTemplateGenerated()
+	if mibTemplateIsGenerated, exist := oo.pOpenOnuAc.GetMibTemplatesGenerated(oo.mibTemplatePath); exist {
 		if mibTemplateIsGenerated {
 			logger.Debugw(ctx, "MibSync - MibTemplate - another thread has already started to generate it - skip",
 				log.Fields{"path": oo.mibTemplatePath, "device-id": oo.deviceID})
-			oo.pOpenOnuAc.lockMibTemplateGenerated.Unlock()
+			oo.pOpenOnuAc.UnlockMutexMibTemplateGenerated()
 			return nil
 		}
 		logger.Debugw(ctx, "MibSync - MibTemplate - previous generation attempt seems to be failed - try again",
@@ -864,15 +867,15 @@
 		logger.Debugw(ctx, "MibSync - MibTemplate - first ONU-instance of this kind - start generation",
 			log.Fields{"path": oo.mibTemplatePath, "device-id": oo.deviceID})
 	}
-	oo.pOpenOnuAc.mibTemplatesGenerated[oo.mibTemplatePath] = true
-	oo.pOpenOnuAc.lockMibTemplateGenerated.Unlock()
+	oo.pOpenOnuAc.SetMibTemplatesGenerated(oo.mibTemplatePath, true)
+	oo.pOpenOnuAc.UnlockMutexMibTemplateGenerated()
 
 	currentTime := time.Now()
 	templateMap := make(map[string]interface{})
 	templateMap["TemplateName"] = oo.mibTemplatePath
 	templateMap["TemplateCreated"] = currentTime.Format("2006-01-02 15:04:05.000000")
 
-	firstLevelMap := oo.pOnuDB.meDb
+	firstLevelMap := oo.pOnuDB.MeDb
 	for firstLevelKey, firstLevelValue := range firstLevelMap {
 		logger.Debugw(ctx, "MibSync - MibTemplate - firstLevelKey", log.Fields{"firstLevelKey": firstLevelKey})
 		classID := strconv.Itoa(int(firstLevelKey))
@@ -902,17 +905,17 @@
 	mibTemplate, err := json.Marshal(&templateMap)
 	if err != nil {
 		logger.Errorw(ctx, "MibSync - MibTemplate - Failed to marshal mibTemplate", log.Fields{"error": err, "device-id": oo.deviceID})
-		oo.pOpenOnuAc.lockMibTemplateGenerated.Lock()
-		oo.pOpenOnuAc.mibTemplatesGenerated[oo.mibTemplatePath] = false
-		oo.pOpenOnuAc.lockMibTemplateGenerated.Unlock()
+		oo.pOpenOnuAc.LockMutexMibTemplateGenerated()
+		oo.pOpenOnuAc.SetMibTemplatesGenerated(oo.mibTemplatePath, false)
+		oo.pOpenOnuAc.UnlockMutexMibTemplateGenerated()
 		return err
 	}
 	err = oo.mibTemplateKVStore.Put(log.WithSpanFromContext(context.TODO(), ctx), oo.mibTemplatePath, string(mibTemplate))
 	if err != nil {
 		logger.Errorw(ctx, "MibSync - MibTemplate - Failed to store template in etcd", log.Fields{"error": err, "device-id": oo.deviceID})
-		oo.pOpenOnuAc.lockMibTemplateGenerated.Lock()
-		oo.pOpenOnuAc.mibTemplatesGenerated[oo.mibTemplatePath] = false
-		oo.pOpenOnuAc.lockMibTemplateGenerated.Unlock()
+		oo.pOpenOnuAc.LockMutexMibTemplateGenerated()
+		oo.pOpenOnuAc.SetMibTemplatesGenerated(oo.mibTemplatePath, false)
+		oo.pOpenOnuAc.UnlockMutexMibTemplateGenerated()
 		return err
 	}
 	logger.Debugw(ctx, "MibSync - MibTemplate - Stored the template to etcd", log.Fields{"device-id": oo.deviceID})
@@ -922,16 +925,16 @@
 func (oo *OnuDeviceEntry) requestMdsValue(ctx context.Context) {
 	logger.Debugw(ctx, "Request MDS value", log.Fields{"device-id": oo.deviceID})
 	requestedAttributes := me.AttributeValueMap{"MibDataSync": ""}
-	meInstance, err := oo.PDevOmciCC.sendGetMe(log.WithSpanFromContext(context.TODO(), ctx),
-		me.OnuDataClassID, onuDataMeID, requestedAttributes, oo.pOpenOnuAc.omciTimeout, true, oo.pMibUploadFsm.commChan)
+	meInstance, err := oo.PDevOmciCC.SendGetMe(log.WithSpanFromContext(context.TODO(), ctx),
+		me.OnuDataClassID, cmn.OnuDataMeID, requestedAttributes, oo.baseDeviceHandler.GetOmciTimeout(), true, oo.PMibUploadFsm.CommChan)
 	//accept also nil as (error) return value for writing to LastTx
 	//  - this avoids misinterpretation of new received OMCI messages
 	if err != nil {
 		logger.Errorw(ctx, "ONUData get failed, aborting MibSync FSM!", log.Fields{"device-id": oo.deviceID})
-		pMibUlFsm := oo.pMibUploadFsm
+		pMibUlFsm := oo.PMibUploadFsm
 		if pMibUlFsm != nil {
-			go func(a_pAFsm *AdapterFsm) {
-				_ = oo.pMibUploadFsm.pFsm.Event(ulEvStop)
+			go func(a_pAFsm *cmn.AdapterFsm) {
+				_ = oo.PMibUploadFsm.PFsm.Event(UlEvStop)
 			}(pMibUlFsm)
 		}
 		return
@@ -944,47 +947,47 @@
 }
 
 func (oo *OnuDeviceEntry) checkMdsValue(ctx context.Context, mibDataSyncOnu uint8) {
-	oo.mutexPersOnuConfig.RLock()
+	oo.MutexPersOnuConfig.RLock()
 	logger.Debugw(ctx, "MibSync FSM - GetResponse Data for Onu-Data - MibDataSync", log.Fields{"device-id": oo.deviceID,
-		"mibDataSyncOnu": mibDataSyncOnu, "PersMibDataSyncAdpt": oo.sOnuPersistentData.PersMibDataSyncAdpt})
+		"mibDataSyncOnu": mibDataSyncOnu, "PersMibDataSyncAdpt": oo.SOnuPersistentData.PersMibDataSyncAdpt})
 
-	mdsValuesAreEqual := oo.sOnuPersistentData.PersMibDataSyncAdpt == mibDataSyncOnu
-	oo.mutexPersOnuConfig.RUnlock()
-	if oo.pMibUploadFsm.pFsm.Is(ulStAuditing) {
+	mdsValuesAreEqual := oo.SOnuPersistentData.PersMibDataSyncAdpt == mibDataSyncOnu
+	oo.MutexPersOnuConfig.RUnlock()
+	if oo.PMibUploadFsm.PFsm.Is(UlStAuditing) {
 		if mdsValuesAreEqual {
 			logger.Debugw(ctx, "MibSync FSM - mib audit - MDS check ok", log.Fields{"device-id": oo.deviceID})
-			_ = oo.pMibUploadFsm.pFsm.Event(ulEvSuccess)
+			_ = oo.PMibUploadFsm.PFsm.Event(UlEvSuccess)
 		} else {
 			logger.Warnw(ctx, "MibSync FSM - mib audit - MDS check failed for the first time!", log.Fields{"device-id": oo.deviceID})
-			_ = oo.pMibUploadFsm.pFsm.Event(ulEvMismatch)
+			_ = oo.PMibUploadFsm.PFsm.Event(UlEvMismatch)
 		}
-	} else if oo.pMibUploadFsm.pFsm.Is(ulStReAuditing) {
+	} else if oo.PMibUploadFsm.PFsm.Is(UlStReAuditing) {
 		if mdsValuesAreEqual {
 			logger.Debugw(ctx, "MibSync FSM - mib reaudit - MDS check ok", log.Fields{"device-id": oo.deviceID})
-			_ = oo.pMibUploadFsm.pFsm.Event(ulEvSuccess)
+			_ = oo.PMibUploadFsm.PFsm.Event(UlEvSuccess)
 		} else {
 			logger.Errorw(ctx, "MibSync FSM - mib audit - MDS check failed for the second time!", log.Fields{"device-id": oo.deviceID})
 			//TODO: send new event notification "MDS counter mismatch" to the core
-			_ = oo.pMibUploadFsm.pFsm.Event(ulEvMismatch)
+			_ = oo.PMibUploadFsm.PFsm.Event(UlEvMismatch)
 		}
-	} else if oo.pMibUploadFsm.pFsm.Is(ulStExaminingMds) {
+	} else if oo.PMibUploadFsm.PFsm.Is(UlStExaminingMds) {
 		if mdsValuesAreEqual && mibDataSyncOnu != 0 {
 			logger.Debugw(ctx, "MibSync FSM - MDS examination ok", log.Fields{"device-id": oo.deviceID})
-			_ = oo.pMibUploadFsm.pFsm.Event(ulEvSuccess)
+			_ = oo.PMibUploadFsm.PFsm.Event(UlEvSuccess)
 		} else {
 			logger.Debugw(ctx, "MibSync FSM - MDS examination failed - new provisioning", log.Fields{"device-id": oo.deviceID})
-			_ = oo.pMibUploadFsm.pFsm.Event(ulEvMismatch)
+			_ = oo.PMibUploadFsm.PFsm.Event(UlEvMismatch)
 		}
 	} else {
-		logger.Warnw(ctx, "wrong state for MDS evaluation!", log.Fields{"state": oo.pMibUploadFsm.pFsm.Current(), "device-id": oo.deviceID})
+		logger.Warnw(ctx, "wrong state for MDS evaluation!", log.Fields{"state": oo.PMibUploadFsm.PFsm.Current(), "device-id": oo.deviceID})
 	}
 }
 
 //GetActiveImageMeID returns the Omci MeId of the active ONU image together with error code for validity
 func (oo *OnuDeviceEntry) GetActiveImageMeID(ctx context.Context) (uint16, error) {
 	oo.mutexOnuSwImageIndications.RLock()
-	if oo.onuSwImageIndications.activeEntityEntry.valid {
-		value := oo.onuSwImageIndications.activeEntityEntry.entityID
+	if oo.onuSwImageIndications.ActiveEntityEntry.Valid {
+		value := oo.onuSwImageIndications.ActiveEntityEntry.EntityID
 		oo.mutexOnuSwImageIndications.RUnlock()
 		return value, nil
 	}
@@ -995,8 +998,8 @@
 //GetInactiveImageMeID returns the Omci MeId of the inactive ONU image together with error code for validity
 func (oo *OnuDeviceEntry) GetInactiveImageMeID(ctx context.Context) (uint16, error) {
 	oo.mutexOnuSwImageIndications.RLock()
-	if oo.onuSwImageIndications.inactiveEntityEntry.valid {
-		value := oo.onuSwImageIndications.inactiveEntityEntry.entityID
+	if oo.onuSwImageIndications.InActiveEntityEntry.Valid {
+		value := oo.onuSwImageIndications.InActiveEntityEntry.EntityID
 		oo.mutexOnuSwImageIndications.RUnlock()
 		return value, nil
 	}
@@ -1007,9 +1010,9 @@
 //IsImageToBeCommitted returns true if the active image is still uncommitted
 func (oo *OnuDeviceEntry) IsImageToBeCommitted(ctx context.Context, aImageID uint16) bool {
 	oo.mutexOnuSwImageIndications.RLock()
-	if oo.onuSwImageIndications.activeEntityEntry.valid {
-		if oo.onuSwImageIndications.activeEntityEntry.entityID == aImageID {
-			if oo.onuSwImageIndications.activeEntityEntry.isCommitted == swIsUncommitted {
+	if oo.onuSwImageIndications.ActiveEntityEntry.Valid {
+		if oo.onuSwImageIndications.ActiveEntityEntry.EntityID == aImageID {
+			if oo.onuSwImageIndications.ActiveEntityEntry.IsCommitted == cmn.SwIsUncommitted {
 				oo.mutexOnuSwImageIndications.RUnlock()
 				return true
 			}
@@ -1032,10 +1035,10 @@
 
 			// swap out tokens with specific data
 			mibTmpString, _ := kvstore.ToString(Value.Value)
-			oo.mutexPersOnuConfig.RLock()
-			mibTmpString2 := strings.Replace(mibTmpString, "%SERIAL_NUMBER%", oo.sOnuPersistentData.PersSerialNumber, -1)
-			mibTmpString = strings.Replace(mibTmpString2, "%MAC_ADDRESS%", oo.sOnuPersistentData.PersMacAddress, -1)
-			oo.mutexPersOnuConfig.RUnlock()
+			oo.MutexPersOnuConfig.RLock()
+			mibTmpString2 := strings.Replace(mibTmpString, "%SERIAL_NUMBER%", oo.SOnuPersistentData.PersSerialNumber, -1)
+			mibTmpString = strings.Replace(mibTmpString2, "%MAC_ADDRESS%", oo.SOnuPersistentData.PersMacAddress, -1)
+			oo.MutexPersOnuConfig.RUnlock()
 			mibTmpBytes := []byte(mibTmpString)
 			logger.Debugf(ctx, "MibSync FSM - Mib template tokens swapped out: %s", mibTmpBytes)
 
@@ -1085,16 +1088,16 @@
 //CancelProcessing terminates potentially running reconciling processes and stops the FSM
 func (oo *OnuDeviceEntry) CancelProcessing(ctx context.Context) {
 
-	if oo.baseDeviceHandler.isReconcilingFlows() {
-		oo.baseDeviceHandler.chReconcilingFlowsFinished <- false
+	if oo.IsReconcilingFlows() {
+		oo.chReconcilingFlowsFinished <- false
 	}
-	if oo.baseDeviceHandler.isReconciling() {
-		oo.baseDeviceHandler.stopReconciling(ctx, false)
+	if oo.baseDeviceHandler.IsReconciling() {
+		oo.baseDeviceHandler.StopReconciling(ctx, false)
 	}
 	//the MibSync FSM might be active all the ONU-active time,
 	// hence it must be stopped unconditionally
-	pMibUlFsm := oo.pMibUploadFsm.pFsm
+	pMibUlFsm := oo.PMibUploadFsm.PFsm
 	if pMibUlFsm != nil {
-		_ = pMibUlFsm.Event(ulEvStop)
+		_ = pMibUlFsm.Event(UlEvStop)
 	}
 }
diff --git a/internal/pkg/mib/onu_device_entry.go b/internal/pkg/mib/onu_device_entry.go
new file mode 100755
index 0000000..ebf8de8
--- /dev/null
+++ b/internal/pkg/mib/onu_device_entry.go
@@ -0,0 +1,992 @@
+/*
+ * Copyright 2020-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//Package mib provides the utilities for managing the onu mib
+package mib
+
+import (
+	"context"
+	"encoding/json"
+	"errors"
+	"fmt"
+	"sync"
+	"time"
+
+	"github.com/looplab/fsm"
+	"github.com/opencord/omci-lib-go"
+	me "github.com/opencord/omci-lib-go/generated"
+	"github.com/opencord/voltha-lib-go/v7/pkg/db"
+	"github.com/opencord/voltha-lib-go/v7/pkg/db/kvstore"
+	vgrpc "github.com/opencord/voltha-lib-go/v7/pkg/grpc"
+
+	"github.com/opencord/voltha-lib-go/v7/pkg/log"
+
+	cmn "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/common"
+	devdb "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/devdb"
+	"github.com/opencord/voltha-openonu-adapter-go/internal/pkg/swupg"
+)
+
+// events of MibUpload FSM
+const (
+	UlEvStart              = "UlEvStart"
+	UlEvResetMib           = "UlEvResetMib"
+	UlEvGetVendorAndSerial = "UlEvGetVendorAndSerial"
+	UlEvGetEquipmentID     = "UlEvGetEquipmentId"
+	UlEvGetFirstSwVersion  = "UlEvGetFirstSwVersion"
+	UlEvGetSecondSwVersion = "UlEvGetSecondSwVersion"
+	UlEvGetMacAddress      = "UlEvGetMacAddress"
+	UlEvGetMibTemplate     = "UlEvGetMibTemplate"
+	UlEvUploadMib          = "UlEvUploadMib"
+	UlEvExamineMds         = "UlEvExamineMds"
+	UlEvSuccess            = "UlEvSuccess"
+	UlEvMismatch           = "UlEvMismatch"
+	UlEvAuditMib           = "UlEvAuditMib"
+	UlEvForceResync        = "UlEvForceResync"
+	UlEvDiffsFound         = "UlEvDiffsFound"
+	UlEvTimeout            = "UlEvTimeout"
+	UlEvStop               = "UlEvStop"
+)
+
+// states of MibUpload FSM
+const (
+	UlStDisabled               = "UlStDisabled"
+	UlStStarting               = "UlStStarting"
+	UlStResettingMib           = "UlStResettingMib"
+	UlStGettingVendorAndSerial = "UlStGettingVendorAndSerial"
+	UlStGettingEquipmentID     = "UlStGettingEquipmentID"
+	UlStGettingFirstSwVersion  = "UlStGettingFirstSwVersion"
+	UlStGettingSecondSwVersion = "UlStGettingSecondSwVersion"
+	UlStGettingMacAddress      = "UlStGettingMacAddress"
+	UlStGettingMibTemplate     = "UlStGettingMibTemplate"
+	UlStUploading              = "UlStUploading"
+	UlStUploadDone             = "UlStUploadDone"
+	UlStInSync                 = "UlStInSync"
+	UlStExaminingMds           = "UlStExaminingMds"
+	UlStResynchronizing        = "UlStResynchronizing"
+	UlStExaminingMdsSuccess    = "UlStExaminingMdsSuccess"
+	UlStAuditing               = "UlStAuditing"
+	UlStReAuditing             = "UlStReAuditing"
+	UlStOutOfSync              = "UlStOutOfSync"
+)
+
+// CMibUlFsmIdleState - TODO: add comment
+const CMibUlFsmIdleState = UlStInSync
+
+// events of MibDownload FSM
+const (
+	DlEvStart         = "DlEvStart"
+	DlEvCreateGal     = "DlEvCreateGal"
+	DlEvRxGalResp     = "DlEvRxGalResp"
+	DlEvRxOnu2gResp   = "DlEvRxOnu2gResp"
+	DlEvRxBridgeResp  = "DlEvRxBridgeResp"
+	DlEvTimeoutSimple = "DlEvTimeoutSimple"
+	DlEvTimeoutBridge = "DlEvTimeoutBridge"
+	DlEvReset         = "DlEvReset"
+	DlEvRestart       = "DlEvRestart"
+)
+
+// states of MibDownload FSM
+const (
+	DlStDisabled     = "DlStDisabled"
+	DlStStarting     = "DlStStarting"
+	DlStCreatingGal  = "DlStCreatingGal"
+	DlStSettingOnu2g = "DlStSettingOnu2g"
+	DlStBridgeInit   = "DlStBridgeInit"
+	DlStDownloaded   = "DlStDownloaded"
+	DlStResetting    = "DlStResetting"
+)
+
+// CMibDlFsmIdleState - TODO: add comment
+const CMibDlFsmIdleState = DlStDisabled
+
+const (
+	// NOTE that this hardcoded to service/voltha as the MIB template is shared across stacks
+	cBasePathMibTemplateKvStore = "service/voltha/omci_mibs/go_templates"
+	cSuffixMibTemplateKvStore   = "%s/%s/%s"
+	cBasePathOnuKVStore         = "%s/openonu"
+)
+
+const cEmptyMacAddrString = "000000000000"
+const cEmptySerialNumberString = "0000000000000000"
+
+type uniPersConfig struct {
+	PersUniID      uint8                   `json:"uni_id"`
+	PersTpPathMap  map[uint8]string        `json:"PersTpPathMap"` // tp-id to tp-path map
+	PersFlowParams []cmn.UniVlanFlowParams `json:"flow_params"`   //as defined in omci_ani_config.go
+}
+
+type onuPersistentData struct {
+	PersOnuID              uint32            `json:"onu_id"`
+	PersIntfID             uint32            `json:"intf_id"`
+	PersSerialNumber       string            `json:"serial_number"`
+	PersMacAddress         string            `json:"mac_address"`
+	PersVendorID           string            `json:"vendor_id"`
+	PersEquipmentID        string            `json:"equipment_id"`
+	PersActiveSwVersion    string            `json:"active_sw_version"`
+	PersAdminState         string            `json:"admin_state"`
+	PersOperState          string            `json:"oper_state"`
+	PersUniUnlockDone      bool              `json:"uni_unlock_done"`
+	PersUniDisableDone     bool              `json:"uni_disable_done"`
+	PersMibAuditInterval   time.Duration     `json:"mib_audit_interval"`
+	PersMibLastDbSync      uint32            `json:"mib_last_db_sync"`
+	PersMibDataSyncAdpt    uint8             `json:"mib_data_sync_adpt"`
+	PersUniConfig          []uniPersConfig   `json:"uni_config"`
+	PersAlarmAuditInterval time.Duration     `json:"alarm_audit_interval"`
+	PersTcontMap           map[uint16]uint16 `json:"tcont_map"` //alloc-id to me-instance-id map
+}
+
+// OnuDeviceEntry - ONU device info and FSM events.
+type OnuDeviceEntry struct {
+	deviceID                   string
+	baseDeviceHandler          cmn.IdeviceHandler
+	pOpenOnuAc                 cmn.IopenONUAC
+	pOnuTP                     cmn.IonuUniTechProf
+	coreClient                 *vgrpc.Client
+	PDevOmciCC                 *cmn.OmciCC
+	pOnuDB                     *devdb.OnuDeviceDB
+	mibTemplateKVStore         *db.Backend
+	MutexPersOnuConfig         sync.RWMutex
+	SOnuPersistentData         onuPersistentData
+	reconcilingFlows           bool
+	mutexReconcilingFlowsFlag  sync.RWMutex
+	chReconcilingFlowsFinished chan bool //channel to indicate that reconciling of flows has been finished
+	mibTemplatePath            string
+	mutexOnuKVStore            sync.RWMutex
+	onuKVStore                 *db.Backend
+	onuKVStorePath             string
+	mutexOnuKVStoreProcResult  sync.RWMutex
+	onuKVStoreProcResult       error //error indication of processing
+	chOnuKvProcessingStep      chan uint8
+	mutexOnuSwImageIndications sync.RWMutex
+	onuSwImageIndications      cmn.SswImageIndications
+	MutexOnuImageStatus        sync.RWMutex
+	POnuImageStatus            *swupg.OnuImageStatus
+	//lockDeviceEntries           sync.RWMutex
+	mibDbClass    func(context.Context) error
+	supportedFsms cmn.OmciDeviceFsms
+	devState      cmn.OnuDeviceEvent
+	// Audit and MDS
+	mibAuditInterval   time.Duration
+	alarmAuditInterval time.Duration
+	// TODO: periodical mib resync will be implemented with story VOL-3792
+	//mibNextDbResync uint32
+
+	// for mibUpload
+	PMibUploadFsm          *cmn.AdapterFsm //could be handled dynamically and more general as pcmn.AdapterFsm - perhaps later
+	mutexLastTxParamStruct sync.RWMutex
+	lastTxParamStruct      sLastTxMeParameter
+	// for mibDownload
+	PMibDownloadFsm *cmn.AdapterFsm //could be handled dynamically and more general as pcmn.AdapterFsm - perhaps later
+	//remark: general usage of pAdapterFsm would require generalization of CommChan  usage and internal event setting
+	//  within the FSM event procedures
+	mutexPLastTxMeInstance           sync.RWMutex
+	pLastTxMeInstance                *me.ManagedEntity
+	omciMessageReceived              chan bool        //seperate channel needed by DownloadFsm
+	omciRebootMessageReceivedChannel chan cmn.Message // channel needed by reboot request
+
+	mutexTcontMap sync.RWMutex
+}
+
+//NewOnuDeviceEntry returns a new instance of a OnuDeviceEntry
+//mib_db (as well as not inluded alarm_db not really used in this code? VERIFY!!)
+func NewOnuDeviceEntry(ctx context.Context, cc *vgrpc.Client, dh cmn.IdeviceHandler,
+	openonu cmn.IopenONUAC) *OnuDeviceEntry {
+	var onuDeviceEntry OnuDeviceEntry
+	onuDeviceEntry.deviceID = dh.GetDeviceID()
+	logger.Debugw(ctx, "init-onuDeviceEntry", log.Fields{"device-id": onuDeviceEntry.deviceID})
+	onuDeviceEntry.baseDeviceHandler = dh
+	onuDeviceEntry.pOpenOnuAc = openonu
+	onuDeviceEntry.coreClient = cc
+	onuDeviceEntry.devState = cmn.DeviceStatusInit
+	onuDeviceEntry.SOnuPersistentData.PersUniConfig = make([]uniPersConfig, 0)
+	onuDeviceEntry.SOnuPersistentData.PersTcontMap = make(map[uint16]uint16)
+	onuDeviceEntry.chReconcilingFlowsFinished = make(chan bool)
+	onuDeviceEntry.reconcilingFlows = false
+	onuDeviceEntry.chOnuKvProcessingStep = make(chan uint8)
+	onuDeviceEntry.omciRebootMessageReceivedChannel = make(chan cmn.Message, 2048)
+	//openomciagent.lockDeviceHandlersMap = sync.RWMutex{}
+	//OMCI related databases are on a per-agent basis. State machines and tasks
+	//are per ONU Vendor
+	//
+	// MIB Synchronization Database - possible overloading from arguments
+	supportedFsms := onuDeviceEntry.pOpenOnuAc.GetSupportedFsms()
+	if supportedFsms != nil {
+		onuDeviceEntry.supportedFsms = *supportedFsms
+	} else {
+		// This branch is currently not used and is for potential future usage of alternative MIB Sync FSMs only!
+		//var mibSyncFsm = NewMibSynchronizer()
+		// use some internal defaults, if not defined from outside
+		onuDeviceEntry.supportedFsms = cmn.OmciDeviceFsms{
+			"mib-synchronizer": {
+				//mibSyncFsm,        // Implements the MIB synchronization state machine
+				DatabaseClass: onuDeviceEntry.mibDbVolatileDict, // Implements volatile ME MIB database
+				//true,                             // Advertise events on OpenOMCI event bus
+				AuditInterval: dh.GetAlarmAuditInterval(), // Time to wait between MIB audits.  0 to disable audits.
+				// map[string]func() error{
+				// 	"mib-upload":    onuDeviceEntry.MibUploadTask,
+				// 	"mib-template":  onuDeviceEntry.MibTemplateTask,
+				// 	"get-mds":       onuDeviceEntry.GetMdsTask,
+				// 	"mib-audit":     onuDeviceEntry.GetMdsTask,
+				// 	"mib-resync":    onuDeviceEntry.MibResyncTask,
+				// 	"mib-reconcile": onuDeviceEntry.MibReconcileTask,
+				// },
+			},
+		}
+	}
+	onuDeviceEntry.mibDbClass = onuDeviceEntry.supportedFsms["mib-synchronizer"].DatabaseClass
+	logger.Debug(ctx, "access2mibDbClass")
+	go onuDeviceEntry.mibDbClass(ctx)
+	if !dh.IsReconciling() {
+		onuDeviceEntry.mibAuditInterval = onuDeviceEntry.supportedFsms["mib-synchronizer"].AuditInterval
+		onuDeviceEntry.SOnuPersistentData.PersMibAuditInterval = onuDeviceEntry.mibAuditInterval
+		onuDeviceEntry.alarmAuditInterval = dh.GetAlarmAuditInterval()
+		onuDeviceEntry.SOnuPersistentData.PersAlarmAuditInterval = onuDeviceEntry.alarmAuditInterval
+	} else {
+		logger.Debugw(ctx, "reconciling - take audit interval from persistent data", log.Fields{"device-id": onuDeviceEntry.deviceID})
+		// TODO: This is a preparation for VOL-VOL-3811 to preserve config history in case of
+		// vendor- or deviceID-specific configurations via voltctl-commands
+		onuDeviceEntry.mibAuditInterval = onuDeviceEntry.SOnuPersistentData.PersMibAuditInterval
+		onuDeviceEntry.alarmAuditInterval = onuDeviceEntry.SOnuPersistentData.PersAlarmAuditInterval
+	}
+	logger.Debugw(ctx, "MibAuditInterval and AlarmAuditInterval is set to", log.Fields{"mib-audit-interval": onuDeviceEntry.mibAuditInterval,
+		"alarm-audit-interval": onuDeviceEntry.alarmAuditInterval})
+	// TODO: periodical mib resync will be implemented with story VOL-3792
+	//onuDeviceEntry.mibNextDbResync = 0
+
+	// Omci related Mib upload sync state machine
+	mibUploadChan := make(chan cmn.Message, 2048)
+	onuDeviceEntry.PMibUploadFsm = cmn.NewAdapterFsm("MibUpload", onuDeviceEntry.deviceID, mibUploadChan)
+	onuDeviceEntry.PMibUploadFsm.PFsm = fsm.NewFSM(
+		UlStDisabled,
+		fsm.Events{
+
+			{Name: UlEvStart, Src: []string{UlStDisabled}, Dst: UlStStarting},
+
+			{Name: UlEvResetMib, Src: []string{UlStStarting}, Dst: UlStResettingMib},
+			{Name: UlEvGetVendorAndSerial, Src: []string{UlStResettingMib}, Dst: UlStGettingVendorAndSerial},
+			{Name: UlEvGetEquipmentID, Src: []string{UlStGettingVendorAndSerial}, Dst: UlStGettingEquipmentID},
+			{Name: UlEvGetFirstSwVersion, Src: []string{UlStGettingEquipmentID}, Dst: UlStGettingFirstSwVersion},
+			{Name: UlEvGetSecondSwVersion, Src: []string{UlStGettingFirstSwVersion}, Dst: UlStGettingSecondSwVersion},
+			{Name: UlEvGetMacAddress, Src: []string{UlStGettingSecondSwVersion}, Dst: UlStGettingMacAddress},
+			{Name: UlEvGetMibTemplate, Src: []string{UlStGettingMacAddress}, Dst: UlStGettingMibTemplate},
+
+			{Name: UlEvUploadMib, Src: []string{UlStGettingMibTemplate}, Dst: UlStUploading},
+			{Name: UlEvExamineMds, Src: []string{UlStStarting}, Dst: UlStExaminingMds},
+
+			{Name: UlEvSuccess, Src: []string{UlStGettingMibTemplate}, Dst: UlStUploadDone},
+			{Name: UlEvSuccess, Src: []string{UlStUploading}, Dst: UlStUploadDone},
+
+			{Name: UlEvSuccess, Src: []string{UlStUploadDone}, Dst: UlStInSync},
+			//{Name: UlEvSuccess, Src: []string{UlStExaminingMds}, Dst: UlStInSync},
+			{Name: UlEvSuccess, Src: []string{UlStExaminingMds}, Dst: UlStExaminingMdsSuccess},
+			// TODO: As long as mib-resynchronizing is not implemented, failed MDS-examination triggers
+			// mib-reset and new provisioning at this point
+			//{Name: UlEvMismatch, Src: []string{UlStExaminingMds}, Dst: UlStResynchronizing},
+			{Name: UlEvMismatch, Src: []string{UlStExaminingMds}, Dst: UlStResettingMib},
+
+			{Name: UlEvSuccess, Src: []string{UlStExaminingMdsSuccess}, Dst: UlStInSync},
+			{Name: UlEvMismatch, Src: []string{UlStExaminingMdsSuccess}, Dst: UlStResettingMib},
+
+			{Name: UlEvAuditMib, Src: []string{UlStInSync}, Dst: UlStAuditing},
+
+			{Name: UlEvSuccess, Src: []string{UlStOutOfSync}, Dst: UlStInSync},
+			{Name: UlEvAuditMib, Src: []string{UlStOutOfSync}, Dst: UlStAuditing},
+
+			{Name: UlEvSuccess, Src: []string{UlStAuditing}, Dst: UlStInSync},
+			{Name: UlEvMismatch, Src: []string{UlStAuditing}, Dst: UlStReAuditing},
+			{Name: UlEvForceResync, Src: []string{UlStAuditing}, Dst: UlStResynchronizing},
+
+			{Name: UlEvSuccess, Src: []string{UlStReAuditing}, Dst: UlStInSync},
+			{Name: UlEvMismatch, Src: []string{UlStReAuditing}, Dst: UlStResettingMib},
+
+			{Name: UlEvSuccess, Src: []string{UlStResynchronizing}, Dst: UlStInSync},
+			{Name: UlEvDiffsFound, Src: []string{UlStResynchronizing}, Dst: UlStOutOfSync},
+
+			{Name: UlEvTimeout, Src: []string{UlStResettingMib, UlStGettingVendorAndSerial, UlStGettingEquipmentID, UlStGettingFirstSwVersion,
+				UlStGettingSecondSwVersion, UlStGettingMacAddress, UlStGettingMibTemplate, UlStUploading, UlStResynchronizing, UlStExaminingMds,
+				UlStUploadDone, UlStInSync, UlStOutOfSync, UlStAuditing, UlStReAuditing}, Dst: UlStStarting},
+
+			{Name: UlEvStop, Src: []string{UlStStarting, UlStResettingMib, UlStGettingVendorAndSerial, UlStGettingEquipmentID, UlStGettingFirstSwVersion,
+				UlStGettingSecondSwVersion, UlStGettingMacAddress, UlStGettingMibTemplate, UlStUploading, UlStResynchronizing, UlStExaminingMds,
+				UlStUploadDone, UlStInSync, UlStOutOfSync, UlStAuditing, UlStReAuditing}, Dst: UlStDisabled},
+		},
+
+		fsm.Callbacks{
+			"enter_state":                         func(e *fsm.Event) { onuDeviceEntry.PMibUploadFsm.LogFsmStateChange(ctx, e) },
+			"enter_" + UlStStarting:               func(e *fsm.Event) { onuDeviceEntry.enterStartingState(ctx, e) },
+			"enter_" + UlStResettingMib:           func(e *fsm.Event) { onuDeviceEntry.enterResettingMibState(ctx, e) },
+			"enter_" + UlStGettingVendorAndSerial: func(e *fsm.Event) { onuDeviceEntry.enterGettingVendorAndSerialState(ctx, e) },
+			"enter_" + UlStGettingEquipmentID:     func(e *fsm.Event) { onuDeviceEntry.enterGettingEquipmentIDState(ctx, e) },
+			"enter_" + UlStGettingFirstSwVersion:  func(e *fsm.Event) { onuDeviceEntry.enterGettingFirstSwVersionState(ctx, e) },
+			"enter_" + UlStGettingSecondSwVersion: func(e *fsm.Event) { onuDeviceEntry.enterGettingSecondSwVersionState(ctx, e) },
+			"enter_" + UlStGettingMacAddress:      func(e *fsm.Event) { onuDeviceEntry.enterGettingMacAddressState(ctx, e) },
+			"enter_" + UlStGettingMibTemplate:     func(e *fsm.Event) { onuDeviceEntry.enterGettingMibTemplateState(ctx, e) },
+			"enter_" + UlStUploading:              func(e *fsm.Event) { onuDeviceEntry.enterUploadingState(ctx, e) },
+			"enter_" + UlStUploadDone:             func(e *fsm.Event) { onuDeviceEntry.enterUploadDoneState(ctx, e) },
+			"enter_" + UlStExaminingMds:           func(e *fsm.Event) { onuDeviceEntry.enterExaminingMdsState(ctx, e) },
+			"enter_" + UlStResynchronizing:        func(e *fsm.Event) { onuDeviceEntry.enterResynchronizingState(ctx, e) },
+			"enter_" + UlStExaminingMdsSuccess:    func(e *fsm.Event) { onuDeviceEntry.enterExaminingMdsSuccessState(ctx, e) },
+			"enter_" + UlStAuditing:               func(e *fsm.Event) { onuDeviceEntry.enterAuditingState(ctx, e) },
+			"enter_" + UlStReAuditing:             func(e *fsm.Event) { onuDeviceEntry.enterReAuditingState(ctx, e) },
+			"enter_" + UlStOutOfSync:              func(e *fsm.Event) { onuDeviceEntry.enterOutOfSyncState(ctx, e) },
+			"enter_" + UlStInSync:                 func(e *fsm.Event) { onuDeviceEntry.enterInSyncState(ctx, e) },
+		},
+	)
+	// Omci related Mib download state machine
+	mibDownloadChan := make(chan cmn.Message, 2048)
+	onuDeviceEntry.PMibDownloadFsm = cmn.NewAdapterFsm("MibDownload", onuDeviceEntry.deviceID, mibDownloadChan)
+	onuDeviceEntry.PMibDownloadFsm.PFsm = fsm.NewFSM(
+		DlStDisabled,
+		fsm.Events{
+
+			{Name: DlEvStart, Src: []string{DlStDisabled}, Dst: DlStStarting},
+
+			{Name: DlEvCreateGal, Src: []string{DlStStarting}, Dst: DlStCreatingGal},
+			{Name: DlEvRxGalResp, Src: []string{DlStCreatingGal}, Dst: DlStSettingOnu2g},
+			{Name: DlEvRxOnu2gResp, Src: []string{DlStSettingOnu2g}, Dst: DlStBridgeInit},
+			// the bridge state is used for multi ME config for alle UNI related ports
+			// maybe such could be reflected in the state machine as well (port number parametrized)
+			// but that looks not straightforward here - so we keep it simple here for the beginning(?)
+			{Name: DlEvRxBridgeResp, Src: []string{DlStBridgeInit}, Dst: DlStDownloaded},
+
+			{Name: DlEvTimeoutSimple, Src: []string{DlStCreatingGal, DlStSettingOnu2g}, Dst: DlStStarting},
+			{Name: DlEvTimeoutBridge, Src: []string{DlStBridgeInit}, Dst: DlStStarting},
+
+			{Name: DlEvReset, Src: []string{DlStStarting, DlStCreatingGal, DlStSettingOnu2g,
+				DlStBridgeInit, DlStDownloaded}, Dst: DlStResetting},
+			// exceptional treatment for all states except DlStResetting
+			{Name: DlEvRestart, Src: []string{DlStStarting, DlStCreatingGal, DlStSettingOnu2g,
+				DlStBridgeInit, DlStDownloaded, DlStResetting}, Dst: DlStDisabled},
+		},
+
+		fsm.Callbacks{
+			"enter_state":               func(e *fsm.Event) { onuDeviceEntry.PMibDownloadFsm.LogFsmStateChange(ctx, e) },
+			"enter_" + DlStStarting:     func(e *fsm.Event) { onuDeviceEntry.enterDLStartingState(ctx, e) },
+			"enter_" + DlStCreatingGal:  func(e *fsm.Event) { onuDeviceEntry.enterCreatingGalState(ctx, e) },
+			"enter_" + DlStSettingOnu2g: func(e *fsm.Event) { onuDeviceEntry.enterSettingOnu2gState(ctx, e) },
+			"enter_" + DlStBridgeInit:   func(e *fsm.Event) { onuDeviceEntry.enterBridgeInitState(ctx, e) },
+			"enter_" + DlStDownloaded:   func(e *fsm.Event) { onuDeviceEntry.enterDownloadedState(ctx, e) },
+			"enter_" + DlStResetting:    func(e *fsm.Event) { onuDeviceEntry.enterResettingState(ctx, e) },
+		},
+	)
+	if onuDeviceEntry.PMibDownloadFsm == nil || onuDeviceEntry.PMibDownloadFsm.PFsm == nil {
+		logger.Errorw(ctx, "MibDownloadFsm could not be instantiated", log.Fields{"device-id": onuDeviceEntry.deviceID})
+		// TODO some specific error treatment - or waiting for crash ?
+	}
+
+	onuDeviceEntry.mibTemplateKVStore = onuDeviceEntry.baseDeviceHandler.SetBackend(ctx, cBasePathMibTemplateKvStore)
+	if onuDeviceEntry.mibTemplateKVStore == nil {
+		logger.Errorw(ctx, "Can't access mibTemplateKVStore - no backend connection to service",
+			log.Fields{"device-id": onuDeviceEntry.deviceID, "service": cBasePathMibTemplateKvStore})
+	}
+
+	onuDeviceEntry.onuKVStorePath = onuDeviceEntry.deviceID
+	baseKvStorePath := fmt.Sprintf(cBasePathOnuKVStore, dh.GetBackendPathPrefix())
+	onuDeviceEntry.onuKVStore = onuDeviceEntry.baseDeviceHandler.SetBackend(ctx, baseKvStorePath)
+	if onuDeviceEntry.onuKVStore == nil {
+		logger.Errorw(ctx, "Can't access onuKVStore - no backend connection to service",
+			log.Fields{"device-id": onuDeviceEntry.deviceID, "service": baseKvStorePath})
+	}
+
+	// Alarm Synchronization Database
+
+	//self._alarm_db = None
+	//self._alarm_database_cls = support_classes['alarm-synchronizer']['database']
+	return &onuDeviceEntry
+}
+
+//Start starts (logs) the omci agent
+func (oo *OnuDeviceEntry) Start(ctx context.Context) error {
+	logger.Debugw(ctx, "OnuDeviceEntry-starting", log.Fields{"for device-id": oo.deviceID})
+	if oo.PDevOmciCC == nil {
+		oo.PDevOmciCC = cmn.NewOmciCC(ctx, oo.deviceID, oo.baseDeviceHandler, oo, oo.baseDeviceHandler.GetOnuAlarmManager(), oo.coreClient)
+		if oo.PDevOmciCC == nil {
+			logger.Errorw(ctx, "Could not create devOmciCc - abort", log.Fields{"for device-id": oo.deviceID})
+			return fmt.Errorf("could not create devOmciCc %s", oo.deviceID)
+		}
+	}
+	return nil
+}
+
+//Stop stops/resets the omciCC
+func (oo *OnuDeviceEntry) Stop(ctx context.Context, abResetOmciCC bool) error {
+	logger.Debugw(ctx, "OnuDeviceEntry-stopping", log.Fields{"for device-id": oo.deviceID})
+	if abResetOmciCC && (oo.PDevOmciCC != nil) {
+		_ = oo.PDevOmciCC.Stop(ctx)
+	}
+	//to allow for all event notifications again when re-using the device and omciCC
+	oo.devState = cmn.DeviceStatusInit
+	return nil
+}
+
+// Reboot - TODO: add comment
+func (oo *OnuDeviceEntry) Reboot(ctx context.Context) error {
+	logger.Debugw(ctx, "OnuDeviceEntry-rebooting", log.Fields{"for device-id": oo.deviceID})
+	if oo.PDevOmciCC != nil {
+		if err := oo.PDevOmciCC.SendReboot(ctx, oo.baseDeviceHandler.GetOmciTimeout(), true, oo.omciRebootMessageReceivedChannel); err != nil {
+			logger.Errorw(ctx, "onu didn't reboot", log.Fields{"for device-id": oo.deviceID})
+			return err
+		}
+	}
+	return nil
+}
+
+// WaitForRebootResponse - TODO: add comment
+func (oo *OnuDeviceEntry) WaitForRebootResponse(ctx context.Context, responseChannel chan cmn.Message) error {
+	select {
+	case <-time.After(oo.PDevOmciCC.GetMaxOmciTimeoutWithRetries() * time.Second): //3s was detected to be to less in 8*8 bbsim test with debug Info/Debug
+		logger.Warnw(ctx, "reboot timeout", log.Fields{"for device-id": oo.deviceID})
+		return fmt.Errorf("rebootTimeout")
+	case data := <-responseChannel:
+		switch data.Data.(cmn.OmciMessage).OmciMsg.MessageType {
+		case omci.RebootResponseType:
+			{
+				msgLayer := (*data.Data.(cmn.OmciMessage).OmciPacket).Layer(omci.LayerTypeRebootResponse)
+				if msgLayer == nil {
+					return fmt.Errorf("omci Msg layer could not be detected for RebootResponseType")
+				}
+				msgObj, msgOk := msgLayer.(*omci.RebootResponse)
+				if !msgOk {
+					return fmt.Errorf("omci Msg layer could not be assigned for RebootResponseType %s", oo.deviceID)
+				}
+				logger.Debugw(ctx, "RebootResponse data", log.Fields{"device-id": oo.deviceID, "data-fields": msgObj})
+				if msgObj.Result != me.Success {
+					logger.Errorw(ctx, "Omci RebootResponse result error", log.Fields{"device-id": oo.deviceID, "Error": msgObj.Result})
+					// possibly force FSM into abort or ignore some errors for some messages? store error for mgmt display?
+					return fmt.Errorf("omci RebootResponse result error indication %s for device %s",
+						msgObj.Result, oo.deviceID)
+				}
+				return nil
+			}
+		}
+		logger.Warnw(ctx, "Reboot response message type error", log.Fields{"for device-id": oo.deviceID})
+		return fmt.Errorf("unexpected OmciResponse type received %s", oo.deviceID)
+	}
+}
+
+//Relay the InSync message via Handler to Rw core - Status update
+func (oo *OnuDeviceEntry) transferSystemEvent(ctx context.Context, devEvent cmn.OnuDeviceEvent) {
+	logger.Debugw(ctx, "relaying system-event", log.Fields{"Event": devEvent})
+	// decouple the handler transfer from further processing here
+	// TODO!!! check if really no synch is required within the system e.g. to ensure following steps ..
+	if devEvent == cmn.MibDatabaseSync {
+		if oo.devState < cmn.MibDatabaseSync { //devState has not been synced yet
+			oo.devState = cmn.MibDatabaseSync
+			go oo.baseDeviceHandler.DeviceProcStatusUpdate(ctx, devEvent)
+			//TODO!!! device control: next step: start MIB capability verification from here ?!!!
+		} else {
+			logger.Debugw(ctx, "mibinsync-event in some already synced state - ignored", log.Fields{"state": oo.devState})
+		}
+	} else if devEvent == cmn.MibDownloadDone {
+		if oo.devState < cmn.MibDownloadDone { //devState has not been synced yet
+			oo.devState = cmn.MibDownloadDone
+			go oo.baseDeviceHandler.DeviceProcStatusUpdate(ctx, devEvent)
+		} else {
+			logger.Debugw(ctx, "mibdownloaddone-event was already seen - ignored", log.Fields{"state": oo.devState})
+		}
+	} else {
+		logger.Warnw(ctx, "device-event not yet handled", log.Fields{"state": devEvent})
+	}
+}
+
+// RestoreDataFromOnuKvStore - TODO: add comment
+func (oo *OnuDeviceEntry) RestoreDataFromOnuKvStore(ctx context.Context) error {
+	if oo.onuKVStore == nil {
+		logger.Debugw(ctx, "onuKVStore not set - abort", log.Fields{"device-id": oo.deviceID})
+		return fmt.Errorf(fmt.Sprintf("onuKVStore-not-set-abort-%s", oo.deviceID))
+	}
+	oo.MutexPersOnuConfig.Lock()
+	defer oo.MutexPersOnuConfig.Unlock()
+	oo.SOnuPersistentData =
+		onuPersistentData{0, 0, "", "", "", "", "", "", "", false, false, oo.mibAuditInterval, 0, 0, make([]uniPersConfig, 0), oo.alarmAuditInterval, make(map[uint16]uint16)}
+	oo.mutexOnuKVStore.RLock()
+	Value, err := oo.onuKVStore.Get(ctx, oo.onuKVStorePath)
+	oo.mutexOnuKVStore.RUnlock()
+	if err == nil {
+		if Value != nil {
+			logger.Debugw(ctx, "ONU-data read",
+				log.Fields{"Key": Value.Key, "device-id": oo.deviceID})
+			tmpBytes, _ := kvstore.ToByte(Value.Value)
+
+			if err = json.Unmarshal(tmpBytes, &oo.SOnuPersistentData); err != nil {
+				logger.Errorw(ctx, "unable to unmarshal ONU-data", log.Fields{"error": err, "device-id": oo.deviceID})
+				return fmt.Errorf(fmt.Sprintf("unable-to-unmarshal-ONU-data-%s", oo.deviceID))
+			}
+			logger.Debugw(ctx, "ONU-data", log.Fields{"SOnuPersistentData": oo.SOnuPersistentData,
+				"device-id": oo.deviceID})
+		} else {
+			logger.Debugw(ctx, "no ONU-data found", log.Fields{"path": oo.onuKVStorePath, "device-id": oo.deviceID})
+			return fmt.Errorf("no-ONU-data-found")
+		}
+	} else {
+		logger.Errorw(ctx, "unable to read from KVstore", log.Fields{"device-id": oo.deviceID})
+		return fmt.Errorf(fmt.Sprintf("unable-to-read-from-KVstore-%s", oo.deviceID))
+	}
+	return nil
+}
+
+// DeleteDataFromOnuKvStore - TODO: add comment
+func (oo *OnuDeviceEntry) DeleteDataFromOnuKvStore(ctx context.Context, wg *sync.WaitGroup) {
+	defer wg.Done()
+
+	if oo.onuKVStore == nil {
+		logger.Debugw(ctx, "onuKVStore not set - abort", log.Fields{"device-id": oo.deviceID})
+		oo.setKvProcessingErrorIndication(errors.New("onu-data delete aborted: onuKVStore not set"))
+		return
+	}
+	var processingStep uint8 = 1 // used to synchronize the different processing steps with chOnuKvProcessingStep
+	go oo.deletePersistentData(ctx, processingStep)
+	if !oo.waitForTimeoutOrCompletion(ctx, oo.chOnuKvProcessingStep, processingStep) {
+		//timeout or error detected
+		logger.Debugw(ctx, "ONU-data not deleted - abort", log.Fields{"device-id": oo.deviceID})
+		oo.setKvProcessingErrorIndication(errors.New("onu-data delete aborted: during kv-access"))
+		return
+	}
+}
+
+func (oo *OnuDeviceEntry) deletePersistentData(ctx context.Context, aProcessingStep uint8) {
+
+	logger.Debugw(ctx, "delete and clear internal persistency data", log.Fields{"device-id": oo.deviceID})
+
+	oo.MutexPersOnuConfig.Lock()
+	defer oo.MutexPersOnuConfig.Unlock()
+
+	oo.SOnuPersistentData.PersUniConfig = nil //releasing all UniConfig entries to garbage collector default entry
+	oo.SOnuPersistentData =
+		onuPersistentData{0, 0, "", "", "", "", "", "", "", false, false, oo.mibAuditInterval, 0, 0, make([]uniPersConfig, 0), oo.alarmAuditInterval, make(map[uint16]uint16)}
+	logger.Debugw(ctx, "delete ONU-data from KVStore", log.Fields{"device-id": oo.deviceID})
+	oo.mutexOnuKVStore.Lock()
+	err := oo.onuKVStore.Delete(ctx, oo.onuKVStorePath)
+	oo.mutexOnuKVStore.Unlock()
+	if err != nil {
+		logger.Errorw(ctx, "unable to delete in KVstore", log.Fields{"device-id": oo.deviceID, "err": err})
+		oo.chOnuKvProcessingStep <- 0 //error indication
+		return
+	}
+	oo.chOnuKvProcessingStep <- aProcessingStep //done
+}
+
+// UpdateOnuKvStore - TODO: add comment
+func (oo *OnuDeviceEntry) UpdateOnuKvStore(ctx context.Context, wg *sync.WaitGroup) {
+	defer wg.Done()
+
+	if oo.onuKVStore == nil {
+		logger.Debugw(ctx, "onuKVStore not set - abort", log.Fields{"device-id": oo.deviceID})
+		oo.setKvProcessingErrorIndication(errors.New("onu-data update aborted: onuKVStore not set"))
+		return
+	}
+	var processingStep uint8 = 1 // used to synchronize the different processing steps with chOnuKvProcessingStep
+	go oo.storeDataInOnuKvStore(ctx, processingStep)
+	if !oo.waitForTimeoutOrCompletion(ctx, oo.chOnuKvProcessingStep, processingStep) {
+		//timeout or error detected
+		logger.Debugw(ctx, "ONU-data not written - abort", log.Fields{"device-id": oo.deviceID})
+		oo.setKvProcessingErrorIndication(errors.New("onu-data update aborted: during writing process"))
+		return
+	}
+}
+
+func (oo *OnuDeviceEntry) storeDataInOnuKvStore(ctx context.Context, aProcessingStep uint8) {
+
+	oo.MutexPersOnuConfig.Lock()
+	defer oo.MutexPersOnuConfig.Unlock()
+	//assign values which are not already present when NewOnuDeviceEntry() is called
+	onuIndication := oo.baseDeviceHandler.GetOnuIndication()
+	oo.SOnuPersistentData.PersOnuID = onuIndication.OnuId
+	oo.SOnuPersistentData.PersIntfID = onuIndication.IntfId
+	//TODO: verify usage of these values during restart UC
+	oo.SOnuPersistentData.PersAdminState = onuIndication.AdminState
+	oo.SOnuPersistentData.PersOperState = onuIndication.OperState
+
+	logger.Debugw(ctx, "Update ONU-data in KVStore", log.Fields{"device-id": oo.deviceID, "SOnuPersistentData": oo.SOnuPersistentData})
+
+	Value, err := json.Marshal(oo.SOnuPersistentData)
+	if err != nil {
+		logger.Errorw(ctx, "unable to marshal ONU-data", log.Fields{"SOnuPersistentData": oo.SOnuPersistentData,
+			"device-id": oo.deviceID, "err": err})
+		oo.chOnuKvProcessingStep <- 0 //error indication
+		return
+	}
+	oo.pOpenOnuAc.RLockMutexDeviceHandlersMap()
+	if _, exist := oo.pOpenOnuAc.GetDeviceHandler(oo.deviceID); !exist {
+		logger.Debugw(ctx, "delete_device in progress - skip write request", log.Fields{"device-id": oo.deviceID})
+		oo.chOnuKvProcessingStep <- aProcessingStep
+		oo.pOpenOnuAc.RUnlockMutexDeviceHandlersMap()
+		return
+	}
+	oo.baseDeviceHandler.RLockMutexDeletionInProgressFlag()
+	if oo.baseDeviceHandler.GetDeletionInProgress() {
+		logger.Debugw(ctx, "delete_device in progress - skip write request", log.Fields{"device-id": oo.deviceID})
+		oo.chOnuKvProcessingStep <- aProcessingStep
+		oo.pOpenOnuAc.RUnlockMutexDeviceHandlersMap()
+		oo.baseDeviceHandler.RUnlockMutexDeletionInProgressFlag()
+		return
+	}
+	oo.pOpenOnuAc.RUnlockMutexDeviceHandlersMap()
+	oo.baseDeviceHandler.RUnlockMutexDeletionInProgressFlag()
+
+	oo.mutexOnuKVStore.Lock()
+	err = oo.onuKVStore.Put(ctx, oo.onuKVStorePath, Value)
+	oo.mutexOnuKVStore.Unlock()
+	if err != nil {
+		logger.Errorw(ctx, "unable to write ONU-data into KVstore", log.Fields{"device-id": oo.deviceID, "err": err})
+		oo.chOnuKvProcessingStep <- 0 //error indication
+		return
+	}
+	oo.chOnuKvProcessingStep <- aProcessingStep //done
+}
+
+// UpdateOnuUniTpPath - TODO: add comment
+func (oo *OnuDeviceEntry) UpdateOnuUniTpPath(ctx context.Context, aUniID uint8, aTpID uint8, aPathString string) bool {
+	/* within some specific InterAdapter processing request write/read access to data is ensured to be sequentially,
+	   as also the complete sequence is ensured to 'run to completion' before some new request is accepted
+	   no specific concurrency protection to SOnuPersistentData is required here
+	*/
+	oo.MutexPersOnuConfig.Lock()
+	defer oo.MutexPersOnuConfig.Unlock()
+
+	for k, v := range oo.SOnuPersistentData.PersUniConfig {
+		if v.PersUniID == aUniID {
+			existingPath, ok := oo.SOnuPersistentData.PersUniConfig[k].PersTpPathMap[aTpID]
+			logger.Debugw(ctx, "PersUniConfig-entry exists", log.Fields{"device-id": oo.deviceID, "uniID": aUniID,
+				"tpID": aTpID, "path": aPathString, "existingPath": existingPath, "ok": ok})
+			if !ok {
+				logger.Debugw(ctx, "tp-does-not-exist", log.Fields{"device-id": oo.deviceID, "uniID": aUniID, "tpID": aTpID, "path": aPathString})
+			}
+			if existingPath != aPathString {
+				if aPathString == "" {
+					//existing entry to be deleted
+					logger.Debugw(ctx, "UniTp delete path value", log.Fields{"device-id": oo.deviceID, "uniID": aUniID, "path": aPathString})
+					oo.SOnuPersistentData.PersUniConfig[k].PersTpPathMap[aTpID] = ""
+				} else {
+					//existing entry to be modified
+					logger.Debugw(ctx, "UniTp modify path value", log.Fields{"device-id": oo.deviceID, "uniID": aUniID, "path": aPathString})
+					oo.SOnuPersistentData.PersUniConfig[k].PersTpPathMap[aTpID] = aPathString
+				}
+				return true
+			}
+			//entry already exists
+			if aPathString == "" {
+				//no active TechProfile
+				logger.Debugw(ctx, "UniTp path has already been removed - no AniSide config to be removed", log.Fields{
+					"device-id": oo.deviceID, "uniID": aUniID})
+			} else {
+				//the given TechProfile already exists and is assumed to be active - update devReason as if the config has been done here
+				//was needed e.g. in voltha POD Tests:Validate authentication on a disabled ONU
+				//  (as here the TechProfile has not been removed with the disable-device before the new enable-device)
+				logger.Debugw(ctx, "UniTp path already exists - TechProfile supposed to be active", log.Fields{
+					"device-id": oo.deviceID, "uniID": aUniID, "path": aPathString})
+				//no deviceReason update (DeviceProcStatusUpdate) here to ensure 'omci_flows_pushed' state within disable/enable procedure of ATT scenario
+				//  (during which the flows are removed/re-assigned but the techProf is left active)
+				//and as the TechProfile is regarded as active we have to verify, if some flow configuration still waits on it
+				//  (should not be the case, but should not harm or be more robust ...)
+				// and to be sure, that for some reason the corresponding TpDelete was lost somewhere in history
+				//  we also reset a possibly outstanding delete request - repeated TpConfig is regarded as valid for waiting flow config
+				if oo.pOnuTP != nil {
+					oo.pOnuTP.SetProfileToDelete(aUniID, aTpID, false)
+				}
+				go oo.baseDeviceHandler.VerifyVlanConfigRequest(ctx, aUniID, aTpID)
+			}
+			return false //indicate 'no change' - nothing more to do, TechProf inter-adapter message is return with success anyway here
+		}
+	}
+	//no entry exists for uniId
+
+	if aPathString == "" {
+		//delete request in non-existing state , accept as no change
+		logger.Debugw(ctx, "UniTp path already removed", log.Fields{"device-id": oo.deviceID, "uniID": aUniID})
+		return false
+	}
+	//new entry to be created
+	logger.Debugw(ctx, "New UniTp path set", log.Fields{"device-id": oo.deviceID, "uniID": aUniID, "path": aPathString})
+	perSubTpPathMap := make(map[uint8]string)
+	perSubTpPathMap[aTpID] = aPathString
+	oo.SOnuPersistentData.PersUniConfig =
+		append(oo.SOnuPersistentData.PersUniConfig, uniPersConfig{PersUniID: aUniID, PersTpPathMap: perSubTpPathMap, PersFlowParams: make([]cmn.UniVlanFlowParams, 0)})
+	return true
+}
+
+// UpdateOnuUniFlowConfig - TODO: add comment
+func (oo *OnuDeviceEntry) UpdateOnuUniFlowConfig(aUniID uint8, aUniVlanFlowParams *[]cmn.UniVlanFlowParams) {
+
+	oo.MutexPersOnuConfig.Lock()
+	defer oo.MutexPersOnuConfig.Unlock()
+
+	for k, v := range oo.SOnuPersistentData.PersUniConfig {
+		if v.PersUniID == aUniID {
+			oo.SOnuPersistentData.PersUniConfig[k].PersFlowParams = make([]cmn.UniVlanFlowParams, len(*aUniVlanFlowParams))
+			copy(oo.SOnuPersistentData.PersUniConfig[k].PersFlowParams, *aUniVlanFlowParams)
+			return
+		}
+	}
+	//flow update was faster than tp-config - create PersUniConfig-entry
+	//TODO!!: following activity to 'add' some new uni entry might not be quite correct if this function is called to clear the data
+	//  (e.g after flow removal from RemoveUniFlowParams()).
+	//  This has the effect of misleading indication that there is still some active UNI entry, even though there might be only some nil flow entry
+	//  The effect of this flaw is that at TechProfile removal there is an additional attempt to remove the entry even though no techProfile exists anymore
+	//  The code is not changed here because of the current release lane, changes might have unexpected secondary effects, perhaps later with more elaborate tests
+	tmpConfig := uniPersConfig{PersUniID: aUniID, PersTpPathMap: make(map[uint8]string), PersFlowParams: make([]cmn.UniVlanFlowParams, len(*aUniVlanFlowParams))}
+	copy(tmpConfig.PersFlowParams, *aUniVlanFlowParams)
+	oo.SOnuPersistentData.PersUniConfig = append(oo.SOnuPersistentData.PersUniConfig, tmpConfig)
+}
+
+func (oo *OnuDeviceEntry) waitForTimeoutOrCompletion(
+	ctx context.Context, aChOnuProcessingStep <-chan uint8, aProcessingStep uint8) bool {
+	select {
+	case <-ctx.Done():
+		logger.Warnw(ctx, "processing not completed in-time!",
+			log.Fields{"device-id": oo.deviceID, "error": ctx.Err()})
+		return false
+	case rxStep := <-aChOnuProcessingStep:
+		if rxStep == aProcessingStep {
+			return true
+		}
+		//all other values are not accepted - including 0 for error indication
+		logger.Warnw(ctx, "Invalid processing step received: abort!",
+			log.Fields{"device-id": oo.deviceID,
+				"wantedStep": aProcessingStep, "haveStep": rxStep})
+		return false
+	}
+}
+
+// ResetKvProcessingErrorIndication - TODO: add comment
+func (oo *OnuDeviceEntry) ResetKvProcessingErrorIndication() {
+	oo.mutexOnuKVStoreProcResult.Lock()
+	oo.onuKVStoreProcResult = nil
+	oo.mutexOnuKVStoreProcResult.Unlock()
+}
+
+// GetKvProcessingErrorIndication - TODO: add comment
+func (oo *OnuDeviceEntry) GetKvProcessingErrorIndication() error {
+	oo.mutexOnuKVStoreProcResult.RLock()
+	value := oo.onuKVStoreProcResult
+	oo.mutexOnuKVStoreProcResult.RUnlock()
+	return value
+}
+
+func (oo *OnuDeviceEntry) setKvProcessingErrorIndication(value error) {
+	oo.mutexOnuKVStoreProcResult.Lock()
+	oo.onuKVStoreProcResult = value
+	oo.mutexOnuKVStoreProcResult.Unlock()
+}
+
+// IncrementMibDataSync - TODO: add comment
+func (oo *OnuDeviceEntry) IncrementMibDataSync(ctx context.Context) {
+	oo.MutexPersOnuConfig.Lock()
+	defer oo.MutexPersOnuConfig.Unlock()
+	if oo.SOnuPersistentData.PersMibDataSyncAdpt < 255 {
+		oo.SOnuPersistentData.PersMibDataSyncAdpt++
+	} else {
+		// per G.984 and G.988 overflow starts over at 1 given 0 is reserved for reset
+		oo.SOnuPersistentData.PersMibDataSyncAdpt = 1
+	}
+	logger.Debugf(ctx, "mibDataSync updated - mds: %d - device-id: %s", oo.SOnuPersistentData.PersMibDataSyncAdpt, oo.deviceID)
+}
+
+// ModifySwImageInactiveVersion - updates the inactive SW image version stored
+func (oo *OnuDeviceEntry) ModifySwImageInactiveVersion(ctx context.Context, aImageVersion string) {
+	oo.mutexOnuSwImageIndications.Lock()
+	defer oo.mutexOnuSwImageIndications.Unlock()
+	logger.Debugw(ctx, "software-image set inactive version", log.Fields{
+		"device-id": oo.deviceID, "version": aImageVersion})
+	oo.onuSwImageIndications.InActiveEntityEntry.Version = aImageVersion
+	//inactive SW version is not part of persistency data (yet) - no need to update that
+}
+
+// ModifySwImageActiveCommit - updates the active SW commit flag stored
+func (oo *OnuDeviceEntry) ModifySwImageActiveCommit(ctx context.Context, aCommitted uint8) {
+	oo.mutexOnuSwImageIndications.Lock()
+	defer oo.mutexOnuSwImageIndications.Unlock()
+	logger.Debugw(ctx, "software-image set active entity commit flag", log.Fields{
+		"device-id": oo.deviceID, "committed": aCommitted})
+	oo.onuSwImageIndications.ActiveEntityEntry.IsCommitted = aCommitted
+	//commit flag is not part of persistency data (yet) - no need to update that
+}
+
+// GetActiveImageVersion - returns the active SW image version stored
+func (oo *OnuDeviceEntry) GetActiveImageVersion(ctx context.Context) string {
+	oo.mutexOnuSwImageIndications.RLock()
+	if oo.onuSwImageIndications.ActiveEntityEntry.Valid {
+		value := oo.onuSwImageIndications.ActiveEntityEntry.Version
+		oo.mutexOnuSwImageIndications.RUnlock()
+		return value
+	}
+	oo.mutexOnuSwImageIndications.RUnlock()
+	logger.Debugw(ctx, "Active Image is not valid", log.Fields{"device-id": oo.deviceID})
+	return ""
+}
+
+// GetInactiveImageVersion - TODO: add comment
+func (oo *OnuDeviceEntry) GetInactiveImageVersion(ctx context.Context) string {
+	oo.mutexOnuSwImageIndications.RLock()
+	if oo.onuSwImageIndications.InActiveEntityEntry.Valid {
+		value := oo.onuSwImageIndications.InActiveEntityEntry.Version
+		oo.mutexOnuSwImageIndications.RUnlock()
+		return value
+	}
+	oo.mutexOnuSwImageIndications.RUnlock()
+	logger.Debugw(ctx, "Inactive Image is not valid", log.Fields{"device-id": oo.deviceID})
+	return ""
+}
+
+func (oo *OnuDeviceEntry) buildMibTemplatePath() string {
+	oo.MutexPersOnuConfig.RLock()
+	defer oo.MutexPersOnuConfig.RUnlock()
+	return fmt.Sprintf(cSuffixMibTemplateKvStore, oo.SOnuPersistentData.PersVendorID, oo.SOnuPersistentData.PersEquipmentID, oo.SOnuPersistentData.PersActiveSwVersion)
+}
+
+// AllocateFreeTcont - TODO: add comment
+func (oo *OnuDeviceEntry) AllocateFreeTcont(ctx context.Context, allocID uint16) (uint16, bool, error) {
+	logger.Debugw(ctx, "allocate-free-tcont", log.Fields{"device-id": oo.deviceID, "allocID": allocID,
+		"allocated-instances": oo.SOnuPersistentData.PersTcontMap})
+
+	oo.mutexTcontMap.Lock()
+	defer oo.mutexTcontMap.Unlock()
+	if entityID, ok := oo.SOnuPersistentData.PersTcontMap[allocID]; ok {
+		//tcont already allocated before, return the used instance-id
+		return entityID, true, nil
+	}
+	//First allocation of tcont. Find a free instance
+	if tcontInstKeys := oo.pOnuDB.GetSortedInstKeys(ctx, me.TContClassID); len(tcontInstKeys) > 0 {
+		logger.Debugw(ctx, "allocate-free-tcont-db-keys", log.Fields{"device-id": oo.deviceID, "keys": tcontInstKeys})
+		for _, instID := range tcontInstKeys {
+			instExist := false
+			//If this instance exist in map, it means it is not  empty. It is allocated before
+			for _, v := range oo.SOnuPersistentData.PersTcontMap {
+				if v == instID {
+					instExist = true
+					break
+				}
+			}
+			if !instExist {
+				oo.SOnuPersistentData.PersTcontMap[allocID] = instID
+				return instID, false, nil
+			}
+		}
+	}
+	return 0, false, fmt.Errorf(fmt.Sprintf("no-free-tcont-left-for-device-%s", oo.deviceID))
+
+}
+
+// FreeTcont - TODO: add comment
+func (oo *OnuDeviceEntry) FreeTcont(ctx context.Context, allocID uint16) {
+	logger.Debugw(ctx, "free-tcont", log.Fields{"device-id": oo.deviceID, "alloc": allocID})
+	oo.mutexTcontMap.Lock()
+	defer oo.mutexTcontMap.Unlock()
+	delete(oo.SOnuPersistentData.PersTcontMap, allocID)
+}
+
+// GetDevOmciCC - TODO: add comment
+func (oo *OnuDeviceEntry) GetDevOmciCC() *cmn.OmciCC {
+	return oo.PDevOmciCC
+}
+
+// GetOnuDB - TODO: add comment
+func (oo *OnuDeviceEntry) GetOnuDB() *devdb.OnuDeviceDB {
+	return oo.pOnuDB
+}
+
+// GetPersSerialNumber - TODO: add comment
+func (oo *OnuDeviceEntry) GetPersSerialNumber() string {
+	value := oo.SOnuPersistentData.PersSerialNumber
+	return value
+}
+
+// GetPersVendorID - TODO: add comment
+func (oo *OnuDeviceEntry) GetPersVendorID() string {
+	value := oo.SOnuPersistentData.PersVendorID
+	return value
+}
+
+// GetPersEquipmentID - TODO: add comment
+func (oo *OnuDeviceEntry) GetPersEquipmentID() string {
+	value := oo.SOnuPersistentData.PersEquipmentID
+	return value
+}
+
+// GetMibUploadFsmCommChan - TODO: add comment
+func (oo *OnuDeviceEntry) GetMibUploadFsmCommChan() chan cmn.Message {
+	return oo.PMibUploadFsm.CommChan
+}
+
+// GetMibDownloadFsmCommChan - TODO: add comment
+func (oo *OnuDeviceEntry) GetMibDownloadFsmCommChan() chan cmn.Message {
+	return oo.PMibDownloadFsm.CommChan
+}
+
+// GetOmciRebootMsgRevChan - TODO: add comment
+func (oo *OnuDeviceEntry) GetOmciRebootMsgRevChan() chan cmn.Message {
+	return oo.omciRebootMessageReceivedChannel
+}
+
+// LockMutexOnuSwImageIndications - TODO: add comment
+func (oo *OnuDeviceEntry) LockMutexOnuSwImageIndications() {
+	oo.mutexOnuSwImageIndications.Lock()
+}
+
+// UnlockMutexOnuSwImageIndications - TODO: add comment
+func (oo *OnuDeviceEntry) UnlockMutexOnuSwImageIndications() {
+	oo.mutexOnuSwImageIndications.Unlock()
+}
+
+// GetOnuSwImageIndications - TODO: add comment
+func (oo *OnuDeviceEntry) GetOnuSwImageIndications() cmn.SswImageIndications {
+	return oo.onuSwImageIndications
+}
+
+// SetOnuSwImageIndications - TODO: add comment
+func (oo *OnuDeviceEntry) SetOnuSwImageIndications(value cmn.SswImageIndications) {
+	oo.onuSwImageIndications = value
+}
+
+// LockMutexPersOnuConfig - TODO: add comment
+func (oo *OnuDeviceEntry) LockMutexPersOnuConfig() {
+	oo.MutexPersOnuConfig.Lock()
+}
+
+// UnlockMutexPersOnuConfig - TODO: add comment
+func (oo *OnuDeviceEntry) UnlockMutexPersOnuConfig() {
+	oo.MutexPersOnuConfig.Unlock()
+}
+
+// GetPersActiveSwVersion - TODO: add comment
+func (oo *OnuDeviceEntry) GetPersActiveSwVersion() string {
+	return oo.SOnuPersistentData.PersActiveSwVersion
+}
+
+// SetPersActiveSwVersion - TODO: add comment
+func (oo *OnuDeviceEntry) SetPersActiveSwVersion(value string) {
+	oo.SOnuPersistentData.PersActiveSwVersion = value
+}
+
+// SetReconcilingFlows - TODO: add comment
+func (oo *OnuDeviceEntry) SetReconcilingFlows(value bool) {
+	oo.mutexReconcilingFlowsFlag.Lock()
+	oo.reconcilingFlows = value
+	oo.mutexReconcilingFlowsFlag.Unlock()
+}
+
+// SetChReconcilingFlowsFinished - TODO: add comment
+func (oo *OnuDeviceEntry) SetChReconcilingFlowsFinished(value bool) {
+	oo.chReconcilingFlowsFinished <- value
+}
+
+// IsReconcilingFlows - TODO: add comment
+func (oo *OnuDeviceEntry) IsReconcilingFlows() bool {
+	oo.mutexReconcilingFlowsFlag.RLock()
+	value := oo.reconcilingFlows
+	oo.mutexReconcilingFlowsFlag.RUnlock()
+	return value
+}
diff --git a/internal/pkg/onuadaptercore/common.go b/internal/pkg/omcitst/common.go
old mode 100644
new mode 100755
similarity index 86%
copy from internal/pkg/onuadaptercore/common.go
copy to internal/pkg/omcitst/common.go
index b0b10e3..7ec4687
--- a/internal/pkg/onuadaptercore/common.go
+++ b/internal/pkg/omcitst/common.go
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package omcitst provides the omci test functionality
+package omcitst
 
 import (
 	"github.com/opencord/voltha-lib-go/v7/pkg/log"
@@ -26,7 +26,7 @@
 func init() {
 	// Setup this package so that it's log level can be modified at run time
 	var err error
-	logger, err = log.RegisterPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "adaptercoreonu"})
+	logger, err = log.RegisterPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "omcitst"})
 	if err != nil {
 		panic(err)
 	}
diff --git a/internal/pkg/onuadaptercore/omci_self_test_handler.go b/internal/pkg/omcitst/omci_self_test_handler.go
old mode 100644
new mode 100755
similarity index 78%
rename from internal/pkg/onuadaptercore/omci_self_test_handler.go
rename to internal/pkg/omcitst/omci_self_test_handler.go
index 13b6ec3..5809228
--- a/internal/pkg/onuadaptercore/omci_self_test_handler.go
+++ b/internal/pkg/omcitst/omci_self_test_handler.go
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package omcitst provides the omci test functionality
+package omcitst
 
 import (
 	"context"
@@ -26,7 +26,9 @@
 	"github.com/looplab/fsm"
 	"github.com/opencord/omci-lib-go"
 	"github.com/opencord/omci-lib-go/generated"
+	me "github.com/opencord/omci-lib-go/generated"
 	"github.com/opencord/voltha-lib-go/v7/pkg/log"
+	cmn "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/common"
 	"github.com/opencord/voltha-protos/v5/go/extension"
 )
 
@@ -52,60 +54,67 @@
 
 // We initiate an fsmCb per Self Test Request
 type fsmCb struct {
-	fsm          *AdapterFsm
+	fsm          *cmn.AdapterFsm
 	reqMsg       extension.SingleGetValueRequest
 	respChan     chan extension.SingleGetValueResponse
 	stopOmciChan chan bool
 }
 
-type selfTestControlBlock struct {
-	pDeviceHandler *deviceHandler
+// SelfTestControlBlock - TODO: add comment
+type SelfTestControlBlock struct {
 	deviceID       string
+	pDeviceHandler cmn.IdeviceHandler
+	pDevEntry      cmn.IonuDeviceEntry
 
 	selfTestFsmMap  map[generated.ClassID]*fsmCb // The fsmCb is indexed by ME Class ID of the Test Action procedure
 	selfTestFsmLock sync.RWMutex
 
 	selfTestHandlerLock   sync.RWMutex
 	selfTestHandlerActive bool
-	stopSelfTestModule    chan bool
+	StopSelfTestModule    chan bool
 }
 
-// newSelfTestMsgHandlerCb creates the selfTestControlBlock
+// NewSelfTestMsgHandlerCb creates the SelfTestControlBlock
 // Self Test Handler module supports sending SelfTestRequest and handling of SelfTestResponse/SelfTestResults
 // An ephemeral Self Test FSM is initiated for every Self Test request and multiple Self Tests on different
 // MEs (that support it) can be handled in parallel.
 // At the time of creating this module, only ANI-G self-test is supported.
-func newSelfTestMsgHandlerCb(ctx context.Context, dh *deviceHandler) *selfTestControlBlock {
-	selfTestCb := selfTestControlBlock{pDeviceHandler: dh}
+func NewSelfTestMsgHandlerCb(ctx context.Context, dh cmn.IdeviceHandler, devEntry cmn.IonuDeviceEntry) *SelfTestControlBlock {
+	selfTestCb := SelfTestControlBlock{
+		deviceID:       dh.GetDeviceID(),
+		pDeviceHandler: dh,
+		pDevEntry:      devEntry,
+	}
 	selfTestCb.selfTestFsmMap = make(map[generated.ClassID]*fsmCb)
-	selfTestCb.deviceID = selfTestCb.pDeviceHandler.deviceID
-	selfTestCb.stopSelfTestModule = make(chan bool)
+	selfTestCb.StopSelfTestModule = make(chan bool)
 
 	go selfTestCb.waitForStopSelfTestModuleSignal(ctx)
 
 	return &selfTestCb
 }
 
-func (selfTestCb *selfTestControlBlock) initiateNewSelfTestFsm(ctx context.Context, reqMsg extension.SingleGetValueRequest, commChan chan Message, classID generated.ClassID, respChan chan extension.SingleGetValueResponse) error {
-	aFsm := NewAdapterFsm("selfTestFsm", selfTestCb.deviceID, commChan)
+func (selfTestCb *SelfTestControlBlock) initiateNewSelfTestFsm(ctx context.Context, reqMsg extension.SingleGetValueRequest,
+	CommChan chan cmn.Message, classID generated.ClassID, respChan chan extension.SingleGetValueResponse) error {
+	aFsm := cmn.NewAdapterFsm("selfTestFsm", selfTestCb.deviceID, CommChan)
 
 	if aFsm == nil {
-		logger.Errorw(ctx, "selfTestFsm AdapterFsm could not be instantiated!!", log.Fields{
+		logger.Errorw(ctx, "selfTestFsm cmn.AdapterFsm could not be instantiated!!", log.Fields{
 			"device-id": selfTestCb.deviceID})
 		return fmt.Errorf("nil-adapter-fsm")
 	}
 	// Self Test FSM related state machine
-	aFsm.pFsm = fsm.NewFSM(
+	aFsm.PFsm = fsm.NewFSM(
 
 		selfTestStNull,
 		fsm.Events{
 			{Name: selfTestEventTestRequest, Src: []string{selfTestStNull}, Dst: selfTestStHandleSelfTestReq},
 			{Name: selfTestEventTestResponseSuccess, Src: []string{selfTestStHandleSelfTestReq}, Dst: selfTestStHandleSelfTestResp},
 			{Name: selfTestEventTestResultSuccess, Src: []string{selfTestStHandleSelfTestResp}, Dst: selfTestStNull},
-			{Name: selfTestEventAbort, Src: []string{selfTestStHandleSelfTestReq, selfTestStHandleSelfTestReq, selfTestStHandleTestResult, selfTestStNull}, Dst: selfTestStNull},
+			{Name: selfTestEventAbort, Src: []string{selfTestStHandleSelfTestReq, selfTestStHandleSelfTestReq, selfTestStHandleTestResult,
+				selfTestStNull}, Dst: selfTestStNull},
 		},
 		fsm.Callbacks{
-			"enter_state":                           func(e *fsm.Event) { aFsm.logFsmStateChange(ctx, e) },
+			"enter_state":                           func(e *fsm.Event) { aFsm.LogFsmStateChange(ctx, e) },
 			"enter_" + selfTestStHandleSelfTestReq:  func(e *fsm.Event) { selfTestCb.selfTestFsmHandleSelfTestRequest(ctx, e) },
 			"enter_" + selfTestStHandleSelfTestResp: func(e *fsm.Event) { selfTestCb.selfTestFsmHandleSelfTestResponse(ctx, e) },
 		},
@@ -122,7 +131,7 @@
 
 ///// FSM Handlers
 
-func (selfTestCb *selfTestControlBlock) selfTestFsmHandleSelfTestRequest(ctx context.Context, e *fsm.Event) {
+func (selfTestCb *SelfTestControlBlock) selfTestFsmHandleSelfTestRequest(ctx context.Context, e *fsm.Event) {
 	classID := e.Args[0].(generated.ClassID)
 	selfTestCb.selfTestFsmLock.RLock()
 	pFsmCb, ok := selfTestCb.selfTestFsmMap[classID]
@@ -131,10 +140,12 @@
 		// This case is impossible. Would be curious to see if this happens
 		logger.Fatalw(ctx, "class-id-not-found", log.Fields{"device-id": selfTestCb.deviceID, "classID": classID})
 	}
-	instKeys := selfTestCb.pDeviceHandler.pOnuOmciDevice.pOnuDB.getSortedInstKeys(ctx, classID)
+	instKeys := selfTestCb.pDevEntry.GetOnuDB().GetSortedInstKeys(ctx, classID)
 
-	// TODO: Choosing the first index from the instance keys. For ANI-G, this is fine as there is only one ANI-G instance. How do we handle and report self test for multiple instances?
-	if err := selfTestCb.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.sendSelfTestReq(ctx, classID, instKeys[0], selfTestCb.pDeviceHandler.pOpenOnuAc.omciTimeout, false, pFsmCb.fsm.commChan); err != nil {
+	// TODO: Choosing the first index from the instance keys. For ANI-G, this is fine as there is only one ANI-G instance.
+	// How do we handle and report self test for multiple instances?
+	if err := selfTestCb.pDevEntry.GetDevOmciCC().SendSelfTestReq(ctx, classID, instKeys[0], selfTestCb.pDeviceHandler.GetOmciTimeout(),
+		false, pFsmCb.fsm.CommChan); err != nil {
 		logger.Errorw(ctx, "error sending self test request", log.Fields{"device-id": selfTestCb.deviceID, "classID": classID})
 		selfTestCb.triggerFsmEvent(pFsmCb.fsm, selfTestEventAbort)
 		selfTestCb.submitFailureGetValueResponse(ctx, pFsmCb.respChan, extension.GetValueResponse_INTERNAL_ERROR, extension.GetValueResponse_ERROR)
@@ -144,7 +155,7 @@
 	go selfTestCb.handleOmciResponse(ctx, classID)
 }
 
-func (selfTestCb *selfTestControlBlock) selfTestFsmHandleSelfTestResponse(ctx context.Context, e *fsm.Event) {
+func (selfTestCb *SelfTestControlBlock) selfTestFsmHandleSelfTestResponse(ctx context.Context, e *fsm.Event) {
 	classID := e.Args[0].(generated.ClassID)
 	// Pass the test result processing to another routine
 	go selfTestCb.handleOmciResponse(ctx, classID)
@@ -153,27 +164,28 @@
 
 ///// Utility functions
 
-func (selfTestCb *selfTestControlBlock) getMeClassID(ctx context.Context, reqMsg extension.SingleGetValueRequest) (generated.ClassID, error) {
+func (selfTestCb *SelfTestControlBlock) getMeClassID(ctx context.Context, reqMsg extension.SingleGetValueRequest) (generated.ClassID, error) {
 	switch reqMsg.GetRequest().GetRequest().(type) {
 	case *extension.GetValueRequest_OnuOpticalInfo:
-		return aniGClassID, nil
+		return me.AniGClassID, nil
 	default:
 		logger.Warnw(ctx, "unsupported me class id for self test", log.Fields{"device-id": selfTestCb.deviceID})
 		return 0, fmt.Errorf("unsupported me class id for self test %v", selfTestCb.deviceID)
 	}
 }
 
-func (selfTestCb *selfTestControlBlock) triggerFsmEvent(pSelfTestFsm *AdapterFsm, event string, args ...generated.ClassID) {
+func (selfTestCb *SelfTestControlBlock) triggerFsmEvent(pSelfTestFsm *cmn.AdapterFsm, event string, args ...generated.ClassID) {
 	go func() {
 		if len(args) > 0 {
-			_ = pSelfTestFsm.pFsm.Event(event, args[0])
+			_ = pSelfTestFsm.PFsm.Event(event, args[0])
 		} else {
-			_ = pSelfTestFsm.pFsm.Event(event)
+			_ = pSelfTestFsm.PFsm.Event(event)
 		}
 	}()
 }
 
-func (selfTestCb *selfTestControlBlock) submitFailureGetValueResponse(ctx context.Context, respChan chan extension.SingleGetValueResponse, errorCode extension.GetValueResponse_ErrorReason, statusCode extension.GetValueResponse_Status) {
+func (selfTestCb *SelfTestControlBlock) submitFailureGetValueResponse(ctx context.Context, respChan chan extension.SingleGetValueResponse,
+	errorCode extension.GetValueResponse_ErrorReason, statusCode extension.GetValueResponse_Status) {
 	singleValResp := extension.SingleGetValueResponse{
 		Response: &extension.GetValueResponse{
 			Status:    statusCode,
@@ -185,7 +197,7 @@
 	logger.Infow(ctx, "OMCI test response failure - pushing failure response complete", log.Fields{"device-id": selfTestCb.deviceID})
 }
 
-func (selfTestCb *selfTestControlBlock) handleOmciMessage(ctx context.Context, msg OmciMessage, cb *fsmCb, classID generated.ClassID) {
+func (selfTestCb *SelfTestControlBlock) handleOmciMessage(ctx context.Context, msg cmn.OmciMessage, cb *fsmCb, classID generated.ClassID) {
 	logger.Debugw(ctx, "omci Msg", log.Fields{"device-id": selfTestCb.deviceID, "msgType": msg.OmciMsg.MessageType, "msg": msg})
 	switch msg.OmciMsg.MessageType {
 	case omci.TestResponseType:
@@ -199,11 +211,11 @@
 	}
 }
 
-func (selfTestCb *selfTestControlBlock) handleOmciTestResponse(ctx context.Context, msg OmciMessage, cb *fsmCb, classID generated.ClassID) {
+func (selfTestCb *SelfTestControlBlock) handleOmciTestResponse(ctx context.Context, msg cmn.OmciMessage, cb *fsmCb, classID generated.ClassID) {
 	msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeTestResponse)
 	if msgLayer == nil {
 		logger.Errorw(ctx, "omci Msg layer nil self test response", log.Fields{"device-id": selfTestCb.deviceID, "classID": classID})
-		selfTestCb.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.ReleaseTid(ctx, msg.OmciMsg.TransactionID)
+		selfTestCb.pDevEntry.GetDevOmciCC().ReleaseTid(ctx, msg.OmciMsg.TransactionID)
 		selfTestCb.triggerFsmEvent(cb.fsm, selfTestEventAbort)
 		selfTestCb.submitFailureGetValueResponse(ctx, cb.respChan, extension.GetValueResponse_INTERNAL_ERROR, extension.GetValueResponse_ERROR)
 		return
@@ -211,7 +223,7 @@
 	msgObj, msgOk := msgLayer.(*omci.TestResponse)
 	if !msgOk {
 		logger.Errorw(ctx, "omci Msg layer could not be detected for self test response", log.Fields{"device-id": selfTestCb.deviceID, "classID": classID})
-		selfTestCb.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.ReleaseTid(ctx, msg.OmciMsg.TransactionID)
+		selfTestCb.pDevEntry.GetDevOmciCC().ReleaseTid(ctx, msg.OmciMsg.TransactionID)
 		selfTestCb.triggerFsmEvent(cb.fsm, selfTestEventAbort)
 		selfTestCb.submitFailureGetValueResponse(ctx, cb.respChan, extension.GetValueResponse_INTERNAL_ERROR, extension.GetValueResponse_ERROR)
 		return
@@ -224,12 +236,12 @@
 	}
 
 	logger.Infow(ctx, "OMCI test response failure", log.Fields{"device-id": selfTestCb.deviceID, "classID": classID})
-	selfTestCb.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.ReleaseTid(ctx, msg.OmciMsg.TransactionID)
+	selfTestCb.pDevEntry.GetDevOmciCC().ReleaseTid(ctx, msg.OmciMsg.TransactionID)
 	selfTestCb.triggerFsmEvent(cb.fsm, selfTestEventAbort)
 	selfTestCb.submitFailureGetValueResponse(ctx, cb.respChan, extension.GetValueResponse_UNSUPPORTED, extension.GetValueResponse_ERROR)
 }
 
-func (selfTestCb *selfTestControlBlock) handleOmciTestResult(ctx context.Context, msg OmciMessage, cb *fsmCb, classID generated.ClassID) {
+func (selfTestCb *SelfTestControlBlock) handleOmciTestResult(ctx context.Context, msg cmn.OmciMessage, cb *fsmCb, classID generated.ClassID) {
 	msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeTestResult)
 	if msgLayer == nil {
 		logger.Errorw(ctx, "omci Msg layer nil self test result", log.Fields{"device-id": selfTestCb.deviceID, "classID": classID})
@@ -240,7 +252,7 @@
 	var msgObj *omci.OpticalLineSupervisionTestResult
 	var msgOk bool
 	switch classID {
-	case aniGClassID:
+	case me.AniGClassID:
 		msgObj, msgOk = msgLayer.(*omci.OpticalLineSupervisionTestResult)
 	default:
 		// We should not really land here
@@ -267,18 +279,18 @@
 			Response: &extension.GetValueResponse_OnuOpticalInfo{
 				OnuOpticalInfo: &extension.GetOnuPonOpticalInfoResponse{
 					// OMCI representation is Volts, 2s compliment, 20mV resolution
-					PowerFeedVoltage: float32(TwosComplementToSignedInt16(msgObj.PowerFeedVoltage)) * 0.02,
+					PowerFeedVoltage: float32(cmn.TwosComplementToSignedInt16(msgObj.PowerFeedVoltage)) * 0.02,
 					// OMCI representation is Decibel-microwatts, 2s compliment, 0.002dB resolution.
 					// Subtract 30 to convert the unit from dBu to dBm (as expected by proto interface)
-					ReceivedOpticalPower: float32(TwosComplementToSignedInt16(msgObj.ReceivedOpticalPower))*0.002 - 30,
+					ReceivedOpticalPower: float32(cmn.TwosComplementToSignedInt16(msgObj.ReceivedOpticalPower))*0.002 - 30,
 					// OMCI representation is Decibel-microwatts, 2s compliment, 0.002dB resolution
 					// Subtract 30 to convert the unit from dBu to dBm (as expected by proto interface)
-					MeanOpticalLaunchPower: float32(TwosComplementToSignedInt16(msgObj.MeanOpticalLaunch))*0.002 - 30,
+					MeanOpticalLaunchPower: float32(cmn.TwosComplementToSignedInt16(msgObj.MeanOpticalLaunch))*0.002 - 30,
 					// OMCI representation is unsigned int, 2uA resolution
 					// units of gRPC interface is mA.
 					LaserBiasCurrent: float32(msgObj.LaserBiasCurrent) * 0.000002 * 1000, // multiply by 1000 to get units in mA
 					// OMCI representation is 2s complement, 1/256 degree Celsius resolution
-					Temperature: float32(TwosComplementToSignedInt16(msgObj.Temperature)) / 256.0,
+					Temperature: float32(cmn.TwosComplementToSignedInt16(msgObj.Temperature)) / 256.0,
 				},
 			},
 		},
@@ -297,7 +309,7 @@
 	logger.Infow(ctx, "OMCI test result success - pushing results complete", log.Fields{"device-id": selfTestCb.deviceID, "classID": classID})
 }
 
-func (selfTestCb *selfTestControlBlock) handleOmciResponse(ctx context.Context, classID generated.ClassID) {
+func (selfTestCb *SelfTestControlBlock) handleOmciResponse(ctx context.Context, classID generated.ClassID) {
 	selfTestCb.selfTestFsmLock.RLock()
 	pFsmCb, ok := selfTestCb.selfTestFsmMap[classID]
 	selfTestCb.selfTestFsmLock.RUnlock()
@@ -310,7 +322,7 @@
 		logger.Infow(ctx, "omci processing stopped", log.Fields{"device-id": selfTestCb.deviceID, "class-id": classID})
 		selfTestCb.triggerFsmEvent(pFsmCb.fsm, selfTestEventAbort)
 		selfTestCb.submitFailureGetValueResponse(ctx, pFsmCb.respChan, extension.GetValueResponse_REASON_UNDEFINED, extension.GetValueResponse_ERROR)
-	case message, ok := <-pFsmCb.fsm.commChan:
+	case message, ok := <-pFsmCb.fsm.CommChan:
 		if !ok {
 			logger.Errorw(ctx, "Message couldn't be read from channel", log.Fields{"device-id": selfTestCb.deviceID})
 			selfTestCb.triggerFsmEvent(pFsmCb.fsm, selfTestEventAbort)
@@ -319,8 +331,8 @@
 		logger.Debugw(ctx, "Received message on self test result channel", log.Fields{"device-id": selfTestCb.deviceID})
 
 		switch message.Type {
-		case OMCI:
-			msg, _ := message.Data.(OmciMessage)
+		case cmn.OMCI:
+			msg, _ := message.Data.(cmn.OmciMessage)
 			selfTestCb.handleOmciMessage(ctx, msg, pFsmCb, classID)
 		default:
 			logger.Errorw(ctx, "Unknown message type received", log.Fields{"device-id": selfTestCb.deviceID, "message.Type": message.Type})
@@ -334,7 +346,7 @@
 }
 
 // selfTestRequestComplete removes the fsmCb from the local cache if found
-func (selfTestCb *selfTestControlBlock) selfTestRequestComplete(ctx context.Context, reqMsg extension.SingleGetValueRequest) {
+func (selfTestCb *SelfTestControlBlock) selfTestRequestComplete(ctx context.Context, reqMsg extension.SingleGetValueRequest) {
 	meClassID, err := selfTestCb.getMeClassID(ctx, reqMsg)
 	if err != nil {
 		return
@@ -344,9 +356,9 @@
 	delete(selfTestCb.selfTestFsmMap, meClassID)
 }
 
-func (selfTestCb *selfTestControlBlock) waitForStopSelfTestModuleSignal(ctx context.Context) {
+func (selfTestCb *SelfTestControlBlock) waitForStopSelfTestModuleSignal(ctx context.Context) {
 	selfTestCb.SetSelfTestHandlerIsRunning(true)
-	<-selfTestCb.stopSelfTestModule // block on stop signal
+	<-selfTestCb.StopSelfTestModule // block on stop signal
 	selfTestCb.SetSelfTestHandlerIsRunning(false)
 
 	logger.Infow(ctx, "received stop signal - clean up start", log.Fields{"device-id": selfTestCb.deviceID})
@@ -367,23 +379,24 @@
 
 //// Exported functions
 
-// SetSelfTestHandlerActive sets the value to selfTestCb.selfTestHandlerActive
-func (selfTestCb *selfTestControlBlock) SetSelfTestHandlerIsRunning(active bool) {
+// SetSelfTestHandlerIsRunning sets the value to selfTestCb.selfTestHandlerActive
+func (selfTestCb *SelfTestControlBlock) SetSelfTestHandlerIsRunning(active bool) {
 	selfTestCb.selfTestHandlerLock.Lock()
 	defer selfTestCb.selfTestHandlerLock.Unlock()
 	selfTestCb.selfTestHandlerActive = active
 }
 
-// GetSelfTestHandlerActive gets selfTestCb.selfTestHandlerActive
-func (selfTestCb *selfTestControlBlock) GetSelfTestHandlerIsRunning() bool {
+// GetSelfTestHandlerIsRunning gets selfTestCb.selfTestHandlerActive
+func (selfTestCb *SelfTestControlBlock) GetSelfTestHandlerIsRunning() bool {
 	selfTestCb.selfTestHandlerLock.RLock()
 	defer selfTestCb.selfTestHandlerLock.RUnlock()
 	return selfTestCb.selfTestHandlerActive
 }
 
-// selfTestRequest initiate Test Request handling procedure. The results are asynchronously conveyed on the respChan.
+// SelfTestRequestStart initiate Test Request handling procedure. The results are asynchronously conveyed on the respChan.
 // If the return from selfTestRequest is NOT nil, the caller shall not wait for async response.
-func (selfTestCb *selfTestControlBlock) SelfTestRequestStart(ctx context.Context, reqMsg extension.SingleGetValueRequest, commChan chan Message, respChan chan extension.SingleGetValueResponse) error {
+func (selfTestCb *SelfTestControlBlock) SelfTestRequestStart(ctx context.Context, reqMsg extension.SingleGetValueRequest,
+	CommChan chan cmn.Message, respChan chan extension.SingleGetValueResponse) error {
 	meClassID, err := selfTestCb.getMeClassID(ctx, reqMsg)
 	if err != nil {
 		return err
@@ -395,5 +408,5 @@
 	logger.Infow(ctx, "self test request initiated", log.Fields{"device-id": selfTestCb.deviceID, "meClassID": meClassID})
 	// indicates only if the FSM was initiated correctly. Response is asynchronous on respChan.
 	// If the return from here is NOT nil, the caller shall not wait for async response.
-	return selfTestCb.initiateNewSelfTestFsm(ctx, reqMsg, commChan, meClassID, respChan)
+	return selfTestCb.initiateNewSelfTestFsm(ctx, reqMsg, CommChan, meClassID, respChan)
 }
diff --git a/internal/pkg/onuadaptercore/omci_test_request.go b/internal/pkg/omcitst/omci_test_request.go
old mode 100644
new mode 100755
similarity index 66%
rename from internal/pkg/onuadaptercore/omci_test_request.go
rename to internal/pkg/omcitst/omci_test_request.go
index 235f21d..33db828
--- a/internal/pkg/onuadaptercore/omci_test_request.go
+++ b/internal/pkg/omcitst/omci_test_request.go
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package omcitst provides the omci test functionality
+package omcitst
 
 import (
 	"context"
@@ -24,14 +24,15 @@
 	gp "github.com/google/gopacket"
 	"github.com/opencord/omci-lib-go"
 	me "github.com/opencord/omci-lib-go/generated"
+	cmn "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/common"
 
 	"github.com/opencord/voltha-lib-go/v7/pkg/log"
 )
 
-//omciTestRequest structure holds the information for the OMCI test
-type omciTestRequest struct {
+//OmciTestRequest structure holds the information for the OMCI test
+type OmciTestRequest struct {
 	deviceID     string
-	pDevOmciCC   *omciCC
+	pDevOmciCC   *cmn.OmciCC
 	started      bool
 	result       bool
 	exclusiveCc  bool
@@ -40,41 +41,45 @@
 	verifyDone   chan<- bool
 }
 
-//newOmciTestRequest returns a new instance of OmciTestRequest
-func newOmciTestRequest(ctx context.Context,
-	deviceID string, omciCc *omciCC,
-	exclusive bool, allowFailure bool) *omciTestRequest {
-	logger.Debug(ctx, "omciTestRequest-init")
-	var omciTestRequest omciTestRequest
-	omciTestRequest.deviceID = deviceID
-	omciTestRequest.pDevOmciCC = omciCc
-	omciTestRequest.started = false
-	omciTestRequest.result = false
-	omciTestRequest.exclusiveCc = exclusive
-	omciTestRequest.allowFailure = allowFailure
+//NewOmciTestRequest returns a new instance of OmciTestRequest
+func NewOmciTestRequest(ctx context.Context,
+	deviceID string, omciCc *cmn.OmciCC,
+	exclusive bool, allowFailure bool) *OmciTestRequest {
+	logger.Debug(ctx, "OmciTestRequest-init")
+	var OmciTestRequest OmciTestRequest
+	OmciTestRequest.deviceID = deviceID
+	OmciTestRequest.pDevOmciCC = omciCc
+	OmciTestRequest.started = false
+	OmciTestRequest.result = false
+	OmciTestRequest.exclusiveCc = exclusive
+	OmciTestRequest.allowFailure = allowFailure
 
-	return &omciTestRequest
+	return &OmciTestRequest
 }
 
-//
-func (oo *omciTestRequest) performOmciTest(ctx context.Context, execChannel chan<- bool) {
-	logger.Debug(ctx, "omciTestRequest-start-test")
+// PerformOmciTest - TODO: add comment
+func (oo *OmciTestRequest) PerformOmciTest(ctx context.Context, execChannel chan<- bool) {
+	logger.Debug(ctx, "OmciTestRequest-start-test")
 
 	if oo.pDevOmciCC != nil {
 		oo.verifyDone = execChannel
 		// test functionality is limited to ONU-2G get request for the moment
 		// without yet checking the received response automatically here (might be improved ??)
-		tid := oo.pDevOmciCC.getNextTid(false)
+		tid := oo.pDevOmciCC.GetNextTid(false)
 		onu2gBaseGet, _ := oo.createOnu2gBaseGet(ctx, tid)
-		omciRxCallbackPair := callbackPair{
-			cbKey:   tid,
-			cbEntry: callbackPairEntry{nil, oo.receiveOmciVerifyResponse, true},
+		omciRxCallbackPair := cmn.CallbackPair{
+			CbKey: tid,
+			CbEntry: cmn.CallbackPairEntry{
+				CbRespChannel: nil,
+				CbFunction:    oo.ReceiveOmciVerifyResponse,
+				FramePrint:    true,
+			},
 		}
 
 		logger.Debugw(ctx, "performOmciTest-start sending frame", log.Fields{"for device-id": oo.deviceID})
 		// send with default timeout and normal prio
 		// Note: No reference to fetch the OMCI timeout value from configuration, so hardcode it to 10s
-		go oo.pDevOmciCC.send(ctx, onu2gBaseGet, 10, cDefaultRetries, false, omciRxCallbackPair)
+		go oo.pDevOmciCC.Send(ctx, onu2gBaseGet, 10, cmn.CDefaultRetries, false, omciRxCallbackPair)
 
 	} else {
 		logger.Errorw(ctx, "performOmciTest: Device does not exist", log.Fields{"for device-id": oo.deviceID})
@@ -84,7 +89,7 @@
 // these are OMCI related functions, could/should be collected in a separate file? TODO!!!
 // for a simple start just included in here
 //basic approach copied from bbsim, cmp /devices/onu.go and /internal/common/omci/mibpackets.go
-func (oo *omciTestRequest) createOnu2gBaseGet(ctx context.Context, tid uint16) ([]byte, error) {
+func (oo *OmciTestRequest) createOnu2gBaseGet(ctx context.Context, tid uint16) ([]byte, error) {
 
 	request := &omci.GetRequest{
 		MeBasePacket: omci.MeBasePacket{
@@ -95,7 +100,7 @@
 	}
 
 	oo.txSeqNo = tid
-	pkt, err := serialize(ctx, omci.GetRequestType, request, tid)
+	pkt, err := cmn.Serialize(ctx, omci.GetRequestType, request, tid)
 	if err != nil {
 		//omciLogger.WithFields(log.Fields{ ...
 		logger.Errorw(ctx, "Cannot serialize Onu2-G GetRequest", log.Fields{"device-id": oo.deviceID, "Err": err})
@@ -106,8 +111,8 @@
 	return pkt, nil
 }
 
-//supply a response handler - in this testobject the message is evaluated directly, no response channel used
-func (oo *omciTestRequest) receiveOmciVerifyResponse(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet, respChan chan Message) error {
+//ReceiveOmciVerifyResponse supply a response handler - in this testobject the message is evaluated directly, no response channel used
+func (oo *OmciTestRequest) ReceiveOmciVerifyResponse(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet, respChan chan cmn.Message) error {
 
 	logger.Debugw(ctx, "verify-omci-message-response received:", log.Fields{"omciMsgType": omciMsg.MessageType,
 		"transCorrId": omciMsg.TransactionID, "DeviceIdent": omciMsg.DeviceIdentifier})
@@ -131,14 +136,14 @@
 
 	//TODO!!! further tests on the payload should be done here ...
 
-	oo.pDevOmciCC.mutexMonReq.RLock()
-	if _, exist := oo.pDevOmciCC.monitoredRequests[omciMsg.TransactionID]; exist {
-		oo.pDevOmciCC.monitoredRequests[omciMsg.TransactionID].chSuccess <- true
+	oo.pDevOmciCC.RLockMutexMonReq()
+	if _, exist := oo.pDevOmciCC.GetMonitoredRequest(omciMsg.TransactionID); exist {
+		oo.pDevOmciCC.SetChMonitoredRequest(omciMsg.TransactionID, true)
 	} else {
 		logger.Infow(ctx, "reqMon: map entry does not exist!",
 			log.Fields{"tid": omciMsg.TransactionID, "device-id": oo.deviceID})
 	}
-	oo.pDevOmciCC.mutexMonReq.RUnlock()
+	oo.pDevOmciCC.RUnlockMutexMonReq()
 
 	oo.result = true
 	oo.verifyDone <- true
diff --git a/internal/pkg/onuadaptercore/me_config.go b/internal/pkg/onuadaptercore/me_config.go
deleted file mode 100644
index 11ffe87..0000000
--- a/internal/pkg/onuadaptercore/me_config.go
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright 2020-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
-
-import (
-	"fmt"
-)
-
-const (
-	tpIDStart                     = 64
-	tpIDEnd                       = 256
-	tpRange                       = tpIDEnd - tpIDStart
-	maxUni                        = 256
-	ieeMaperServiceProfileBaseEID = uint16(0x1001)
-	macBridgePortAniBaseEID       = uint16(0x1001)
-	macBridgePortUniBaseEID       = uint16(0x201)
-	macBridgePortAniMcastBaseEID  = uint16(0xA01)
-	galEthernetEID                = uint16(1)
-	macBridgeServiceProfileEID    = uint16(0x201)
-)
-
-func generateIeeMaperServiceProfileEID(uniPortMacBpNo uint16, tpID uint16) (uint16, error) {
-	if tpID < tpIDStart || tpID >= tpIDEnd {
-		return 0, fmt.Errorf("tech profile id out of range - %d", tpID)
-	}
-	if uniPortMacBpNo > maxUni {
-		return 0, fmt.Errorf("uni macbpno out of range - %d", uniPortMacBpNo)
-	}
-	return (ieeMaperServiceProfileBaseEID + uniPortMacBpNo*tpRange + tpID - tpIDStart), nil
-}
-
-func generateANISideMBPCDEID(uniPortMacBpNo uint16, tpID uint16) (uint16, error) {
-	if tpID < tpIDStart || tpID >= tpIDEnd {
-		return 0, fmt.Errorf("tech profile id out of range - %d", tpID)
-	}
-	if uniPortMacBpNo > maxUni {
-		return 0, fmt.Errorf("uni macbpno out of range - %d", uniPortMacBpNo)
-	}
-	return (macBridgePortAniBaseEID + uniPortMacBpNo*tpRange + tpID - tpIDStart), nil
-}
-
-func generateUNISideMBPCDEID(uniPortMacBpNo uint16) (uint16, error) {
-	if uniPortMacBpNo > maxUni {
-		return 0, fmt.Errorf("uni macbpno out of range - %d", uniPortMacBpNo)
-	}
-	return (macBridgePortUniBaseEID + uniPortMacBpNo), nil
-}
-
-func generateMcastANISideMBPCDEID(uniPortMacBpNo uint16) (uint16, error) {
-
-	if uniPortMacBpNo > maxUni {
-		return 0, fmt.Errorf("uni macbpno out of range - %d", uniPortMacBpNo)
-	}
-	return (macBridgePortAniMcastBaseEID + uniPortMacBpNo), nil
-}
diff --git a/internal/pkg/onuadaptercore/messageTypes.go b/internal/pkg/onuadaptercore/messageTypes.go
deleted file mode 100644
index 2f5bac6..0000000
--- a/internal/pkg/onuadaptercore/messageTypes.go
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright 2018-present Open Networking Foundation
-
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
-
- * http://www.apache.org/licenses/LICENSE-2.0
-
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
-
-import (
-	gp "github.com/google/gopacket"
-	"github.com/opencord/omci-lib-go"
-)
-
-// MessageType - Message Protocol Type
-type MessageType uint8
-
-const (
-	// TestMsg - Message type for non OMCI messages
-	TestMsg MessageType = iota
-	//OMCI - OMCI protocol type msg
-	OMCI
-)
-
-// String - Return the text representation of the message type based on integer
-func (m MessageType) String() string {
-	names := [...]string{
-		"TestMsg",
-		"OMCI",
-	}
-	return names[m]
-}
-
-// Message - message type and data(OMCI)
-type Message struct {
-	Type MessageType
-	Data interface{}
-}
-
-//TestMessageType - message data for various events
-type TestMessageType uint8
-
-const (
-	// LoadMibTemplateOk - message data for getting mib template successfully
-	LoadMibTemplateOk TestMessageType = iota + 1
-	// LoadMibTemplateFailed - message data for failure for getting mib template
-	LoadMibTemplateFailed
-	// TimeOutOccurred - message data for timeout
-	TimeOutOccurred
-	// AbortMessageProcessing - message data for aborting running message
-	AbortMessageProcessing
-)
-
-//TestMessage - Struct to hold the message data
-//TODO: place holder to have a second interface variant - to be replaced by real variant later on
-type TestMessage struct {
-	TestMessageVal TestMessageType
-}
-
-//OmciMessage - OMCI protocol messages for managing and monitoring ONUs
-type OmciMessage struct {
-	//OnuSN   *openolt.SerialNumber
-	//OnuID   uint32
-	OmciMsg    *omci.OMCI
-	OmciPacket *gp.Packet
-}
diff --git a/internal/pkg/onuadaptercore/onu_device_entry.go b/internal/pkg/onuadaptercore/onu_device_entry.go
deleted file mode 100644
index bfb1ab5..0000000
--- a/internal/pkg/onuadaptercore/onu_device_entry.go
+++ /dev/null
@@ -1,970 +0,0 @@
-/*
- * Copyright 2020-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
-
-import (
-	"context"
-	"encoding/json"
-	"errors"
-	"fmt"
-	"sync"
-	"time"
-
-	"github.com/looplab/fsm"
-	"github.com/opencord/omci-lib-go"
-	me "github.com/opencord/omci-lib-go/generated"
-	"github.com/opencord/voltha-lib-go/v7/pkg/db"
-	"github.com/opencord/voltha-lib-go/v7/pkg/db/kvstore"
-	vgrpc "github.com/opencord/voltha-lib-go/v7/pkg/grpc"
-
-	"github.com/opencord/voltha-lib-go/v7/pkg/log"
-)
-
-const (
-	// events of MibUpload FSM
-	ulEvStart              = "ulEvStart"
-	ulEvResetMib           = "ulEvResetMib"
-	ulEvGetVendorAndSerial = "ulEvGetVendorAndSerial"
-	ulEvGetEquipmentID     = "ulEvGetEquipmentId"
-	ulEvGetFirstSwVersion  = "ulEvGetFirstSwVersion"
-	ulEvGetSecondSwVersion = "ulEvGetSecondSwVersion"
-	ulEvGetMacAddress      = "ulEvGetMacAddress"
-	ulEvGetMibTemplate     = "ulEvGetMibTemplate"
-	ulEvUploadMib          = "ulEvUploadMib"
-	ulEvExamineMds         = "ulEvExamineMds"
-	ulEvSuccess            = "ulEvSuccess"
-	ulEvMismatch           = "ulEvMismatch"
-	ulEvAuditMib           = "ulEvAuditMib"
-	ulEvForceResync        = "ulEvForceResync"
-	ulEvDiffsFound         = "ulEvDiffsFound"
-	ulEvTimeout            = "ulEvTimeout"
-	ulEvStop               = "ulEvStop"
-)
-const (
-	// states of MibUpload FSM
-	ulStDisabled               = "ulStDisabled"
-	ulStStarting               = "ulStStarting"
-	ulStResettingMib           = "ulStResettingMib"
-	ulStGettingVendorAndSerial = "ulStGettingVendorAndSerial"
-	ulStGettingEquipmentID     = "ulStGettingEquipmentID"
-	ulStGettingFirstSwVersion  = "ulStGettingFirstSwVersion"
-	ulStGettingSecondSwVersion = "ulStGettingSecondSwVersion"
-	ulStGettingMacAddress      = "ulStGettingMacAddress"
-	ulStGettingMibTemplate     = "ulStGettingMibTemplate"
-	ulStUploading              = "ulStUploading"
-	ulStUploadDone             = "ulStUploadDone"
-	ulStInSync                 = "ulStInSync"
-	ulStExaminingMds           = "ulStExaminingMds"
-	ulStResynchronizing        = "ulStResynchronizing"
-	ulStExaminingMdsSuccess    = "ulStExaminingMdsSuccess"
-	ulStAuditing               = "ulStAuditing"
-	ulStReAuditing             = "ulStReAuditing"
-	ulStOutOfSync              = "ulStOutOfSync"
-)
-const cMibUlFsmIdleState = ulStInSync
-
-const (
-	// events of MibDownload FSM
-	dlEvStart         = "dlEvStart"
-	dlEvCreateGal     = "dlEvCreateGal"
-	dlEvRxGalResp     = "dlEvRxGalResp"
-	dlEvRxOnu2gResp   = "dlEvRxOnu2gResp"
-	dlEvRxBridgeResp  = "dlEvRxBridgeResp"
-	dlEvTimeoutSimple = "dlEvTimeoutSimple"
-	dlEvTimeoutBridge = "dlEvTimeoutBridge"
-	dlEvReset         = "dlEvReset"
-	dlEvRestart       = "dlEvRestart"
-)
-const (
-	// states of MibDownload FSM
-	dlStDisabled     = "dlStDisabled"
-	dlStStarting     = "dlStStarting"
-	dlStCreatingGal  = "dlStCreatingGal"
-	dlStSettingOnu2g = "dlStSettingOnu2g"
-	dlStBridgeInit   = "dlStBridgeInit"
-	dlStDownloaded   = "dlStDownloaded"
-	dlStResetting    = "dlStResetting"
-)
-const cMibDlFsmIdleState = dlStDisabled
-
-const (
-	// NOTE that this hardcoded to service/voltha as the MIB template is shared across stacks
-	cBasePathMibTemplateKvStore = "service/voltha/omci_mibs/go_templates"
-	cSuffixMibTemplateKvStore   = "%s/%s/%s"
-	cBasePathOnuKVStore         = "%s/openonu"
-)
-
-// OnuDeviceEvent - event of interest to Device Adapters and OpenOMCI State Machines
-type OnuDeviceEvent int
-
-const (
-	// Events of interest to Device Adapters and OpenOMCI State Machines
-
-	// DeviceStatusInit - default start state
-	DeviceStatusInit OnuDeviceEvent = iota
-	// MibDatabaseSync - MIB database sync (upload done)
-	MibDatabaseSync
-	// OmciCapabilitiesDone - OMCI ME and message type capabilities known
-	OmciCapabilitiesDone
-	// MibDownloadDone - // MIB download done
-	MibDownloadDone
-	// UniLockStateDone - Uni ports admin set to lock
-	UniLockStateDone
-	// UniUnlockStateDone - Uni ports admin set to unlock
-	UniUnlockStateDone
-	// UniDisableStateDone - Uni ports admin set to lock based on device disable
-	UniDisableStateDone
-	// UniEnableStateDone - Uni ports admin set to unlock based on device re-enable
-	UniEnableStateDone
-	// PortLinkUp - Port link state change
-	PortLinkUp
-	// PortLinkDw - Port link state change
-	PortLinkDw
-	// OmciAniConfigDone -  AniSide config according to TechProfile done
-	OmciAniConfigDone
-	// OmciAniResourceRemoved - AniSide TechProfile related resource (Gem/TCont) removed
-	OmciAniResourceRemoved // needs to be the successor of OmciAniConfigDone!
-	// OmciVlanFilterAddDone - Omci Vlan config done according to flow-add with request to write kvStore
-	OmciVlanFilterAddDone
-	// OmciVlanFilterAddDoneNoKvStore - Omci Vlan config done according to flow-add without writing kvStore
-	OmciVlanFilterAddDoneNoKvStore // needs to be the successor of OmciVlanFilterAddDone!
-	// OmciVlanFilterRemDone - Omci Vlan config done according to flow-remove with request to write kvStore
-	OmciVlanFilterRemDone // needs to be the successor of OmciVlanFilterAddDoneNoKvStore!
-	// OmciVlanFilterRemDoneNoKvStore - Omci Vlan config done according to flow-remove without writing kvStore
-	OmciVlanFilterRemDoneNoKvStore // needs to be the successor of OmciVlanFilterRemDone!
-	// OmciOnuSwUpgradeDone - SoftwareUpgrade to ONU finished
-	OmciOnuSwUpgradeDone
-	// Add other events here as needed (alarms separate???)
-)
-
-//AdapterFsm related error string
-//error string could be checked on waitforOmciResponse() e.g. to avoid misleading error log
-// but not used that way so far (permit error log even for wanted cancellation)
-const cErrWaitAborted = "waitResponse aborted"
-
-type activityDescr struct {
-	databaseClass func(context.Context) error
-	//advertiseEvents bool
-	auditInterval time.Duration
-	//tasks           map[string]func() error
-}
-
-// OmciDeviceFsms - FSM event mapping to database class and time to wait between audits
-type OmciDeviceFsms map[string]activityDescr
-
-// AdapterFsm - Adapter FSM details including channel, event and  device
-type AdapterFsm struct {
-	fsmName  string
-	deviceID string
-	commChan chan Message
-	pFsm     *fsm.FSM
-}
-
-//NewAdapterFsm - FSM details including event, device and channel.
-func NewAdapterFsm(aName string, aDeviceID string, aCommChannel chan Message) *AdapterFsm {
-	aFsm := &AdapterFsm{
-		fsmName:  aName,
-		deviceID: aDeviceID,
-		commChan: aCommChannel,
-	}
-	return aFsm
-}
-
-//Start starts (logs) the omci agent
-func (oo *AdapterFsm) logFsmStateChange(ctx context.Context, e *fsm.Event) {
-	logger.Debugw(ctx, "FSM state change", log.Fields{"device-id": oo.deviceID, "FSM name": oo.fsmName,
-		"event name": string(e.Event), "src state": string(e.Src), "dst state": string(e.Dst)})
-}
-
-//OntDeviceEntry structure holds information about the attached FSM'as and their communication
-
-const (
-	firstSwImageMeID  = 0
-	secondSwImageMeID = 1
-)
-const ( //definitions as per G.988 softwareImage::IsCommitted
-	swIsUncommitted = 0
-	swIsCommitted   = 1
-)
-const ( //definitions as per G.988 softwareImage::IsActive
-	swIsInactive = 0
-	swIsActive   = 1
-)
-const ( //definitions as per G.988 softwareImage::IsValid
-	//swIsInvalid = 0  not yet used
-	swIsValid = 1
-)
-const onuDataMeID = 0
-const onugMeID = 0
-const onu2gMeID = 0
-const ipHostConfigDataMeID = 1
-const onugSerialNumberLen = 8
-const omciMacAddressLen = 6
-
-const cEmptyMacAddrString = "000000000000"
-const cEmptySerialNumberString = "0000000000000000"
-
-type sEntrySwImageIndication struct {
-	valid       bool
-	entityID    uint16
-	version     string
-	isCommitted uint8
-}
-type sSwImageIndications struct {
-	activeEntityEntry   sEntrySwImageIndication
-	inactiveEntityEntry sEntrySwImageIndication
-}
-
-type uniPersConfig struct {
-	PersUniID      uint8               `json:"uni_id"`
-	PersTpPathMap  map[uint8]string    `json:"PersTpPathMap"` // tp-id to tp-path map
-	PersFlowParams []uniVlanFlowParams `json:"flow_params"`   //as defined in omci_ani_config.go
-}
-
-type onuPersistentData struct {
-	PersOnuID              uint32            `json:"onu_id"`
-	PersIntfID             uint32            `json:"intf_id"`
-	PersSerialNumber       string            `json:"serial_number"`
-	PersMacAddress         string            `json:"mac_address"`
-	PersVendorID           string            `json:"vendor_id"`
-	PersEquipmentID        string            `json:"equipment_id"`
-	PersActiveSwVersion    string            `json:"active_sw_version"`
-	PersAdminState         string            `json:"admin_state"`
-	PersOperState          string            `json:"oper_state"`
-	PersUniUnlockDone      bool              `json:"uni_unlock_done"`
-	PersUniDisableDone     bool              `json:"uni_disable_done"`
-	PersMibAuditInterval   time.Duration     `json:"mib_audit_interval"`
-	PersMibLastDbSync      uint32            `json:"mib_last_db_sync"`
-	PersMibDataSyncAdpt    uint8             `json:"mib_data_sync_adpt"`
-	PersUniConfig          []uniPersConfig   `json:"uni_config"`
-	PersAlarmAuditInterval time.Duration     `json:"alarm_audit_interval"`
-	PersTcontMap           map[uint16]uint16 `json:"tcont_map"` //alloc-id to me-instance-id map
-}
-
-// OnuDeviceEntry - ONU device info and FSM events.
-type OnuDeviceEntry struct {
-	deviceID                   string
-	baseDeviceHandler          *deviceHandler
-	pOpenOnuAc                 *OpenONUAC
-	coreClient                 *vgrpc.Client
-	PDevOmciCC                 *omciCC
-	pOnuDB                     *onuDeviceDB
-	mibTemplateKVStore         *db.Backend
-	mutexPersOnuConfig         sync.RWMutex
-	sOnuPersistentData         onuPersistentData
-	mibTemplatePath            string
-	mutexOnuKVStore            sync.RWMutex
-	onuKVStore                 *db.Backend
-	onuKVStorePath             string
-	mutexOnuKVStoreProcResult  sync.RWMutex
-	onuKVStoreProcResult       error //error indication of processing
-	chOnuKvProcessingStep      chan uint8
-	mutexOnuSwImageIndications sync.RWMutex
-	onuSwImageIndications      sSwImageIndications
-	mutexOnuImageStatus        sync.RWMutex
-	pOnuImageStatus            *OnuImageStatus
-	//lockDeviceEntries           sync.RWMutex
-	mibDbClass    func(context.Context) error
-	supportedFsms OmciDeviceFsms
-	devState      OnuDeviceEvent
-	// Audit and MDS
-	mibAuditInterval   time.Duration
-	alarmAuditInterval time.Duration
-	// TODO: periodical mib resync will be implemented with story VOL-3792
-	//mibNextDbResync uint32
-
-	// for mibUpload
-	pMibUploadFsm          *AdapterFsm //could be handled dynamically and more general as pAdapterFsm - perhaps later
-	mutexLastTxParamStruct sync.RWMutex
-	lastTxParamStruct      sLastTxMeParameter
-	// for mibDownload
-	pMibDownloadFsm *AdapterFsm //could be handled dynamically and more general as pAdapterFsm - perhaps later
-	//remark: general usage of pAdapterFsm would require generalization of commChan  usage and internal event setting
-	//  within the FSM event procedures
-	omciMessageReceived              chan bool    //seperate channel needed by DownloadFsm
-	omciRebootMessageReceivedChannel chan Message // channel needed by Reboot request
-
-	mutexTcontMap sync.RWMutex
-}
-
-//newOnuDeviceEntry returns a new instance of a OnuDeviceEntry
-//mib_db (as well as not inluded alarm_db not really used in this code? VERIFY!!)
-func newOnuDeviceEntry(ctx context.Context, dh *deviceHandler) *OnuDeviceEntry {
-	logger.Debugw(ctx, "init-onuDeviceEntry", log.Fields{"device-id": dh.deviceID})
-	var onuDeviceEntry OnuDeviceEntry
-	onuDeviceEntry.deviceID = dh.deviceID
-	onuDeviceEntry.baseDeviceHandler = dh
-	onuDeviceEntry.pOpenOnuAc = dh.pOpenOnuAc
-	onuDeviceEntry.coreClient = dh.coreClient
-	onuDeviceEntry.devState = DeviceStatusInit
-	onuDeviceEntry.sOnuPersistentData.PersUniConfig = make([]uniPersConfig, 0)
-	onuDeviceEntry.sOnuPersistentData.PersTcontMap = make(map[uint16]uint16)
-	onuDeviceEntry.chOnuKvProcessingStep = make(chan uint8)
-	onuDeviceEntry.omciRebootMessageReceivedChannel = make(chan Message, 2048)
-	//openomciagent.lockDeviceHandlersMap = sync.RWMutex{}
-	//OMCI related databases are on a per-agent basis. State machines and tasks
-	//are per ONU Vendor
-	//
-	// MIB Synchronization Database - possible overloading from arguments
-	if dh.pOpenOnuAc.pSupportedFsms != nil {
-		onuDeviceEntry.supportedFsms = *dh.pOpenOnuAc.pSupportedFsms
-	} else {
-		// This branch is currently not used and is for potential future usage of alternative MIB Sync FSMs only!
-		//var mibSyncFsm = NewMibSynchronizer()
-		// use some internal defaults, if not defined from outside
-		onuDeviceEntry.supportedFsms = OmciDeviceFsms{
-			"mib-synchronizer": {
-				//mibSyncFsm,        // Implements the MIB synchronization state machine
-				onuDeviceEntry.mibDbVolatileDict, // Implements volatile ME MIB database
-				//true,                             // Advertise events on OpenOMCI event bus
-				dh.pOpenOnuAc.mibAuditInterval, // Time to wait between MIB audits.  0 to disable audits.
-				// map[string]func() error{
-				// 	"mib-upload":    onuDeviceEntry.MibUploadTask,
-				// 	"mib-template":  onuDeviceEntry.MibTemplateTask,
-				// 	"get-mds":       onuDeviceEntry.GetMdsTask,
-				// 	"mib-audit":     onuDeviceEntry.GetMdsTask,
-				// 	"mib-resync":    onuDeviceEntry.MibResyncTask,
-				// 	"mib-reconcile": onuDeviceEntry.MibReconcileTask,
-				// },
-			},
-		}
-	}
-	onuDeviceEntry.mibDbClass = onuDeviceEntry.supportedFsms["mib-synchronizer"].databaseClass
-	logger.Debug(ctx, "access2mibDbClass")
-	go onuDeviceEntry.mibDbClass(ctx)
-	if !dh.isReconciling() {
-		onuDeviceEntry.mibAuditInterval = onuDeviceEntry.supportedFsms["mib-synchronizer"].auditInterval
-		onuDeviceEntry.sOnuPersistentData.PersMibAuditInterval = onuDeviceEntry.mibAuditInterval
-		onuDeviceEntry.alarmAuditInterval = dh.pOpenOnuAc.alarmAuditInterval
-		onuDeviceEntry.sOnuPersistentData.PersAlarmAuditInterval = onuDeviceEntry.alarmAuditInterval
-	} else {
-		logger.Debugw(ctx, "reconciling - take audit interval from persistent data", log.Fields{"device-id": dh.deviceID})
-		// TODO: This is a preparation for VOL-VOL-3811 to preserve config history in case of
-		// vendor- or deviceID-specific configurations via voltctl-commands
-		onuDeviceEntry.mibAuditInterval = onuDeviceEntry.sOnuPersistentData.PersMibAuditInterval
-		onuDeviceEntry.alarmAuditInterval = onuDeviceEntry.sOnuPersistentData.PersAlarmAuditInterval
-	}
-	logger.Debugw(ctx, "MibAuditInterval and AlarmAuditInterval is set to", log.Fields{"mib-audit-interval": onuDeviceEntry.mibAuditInterval,
-		"alarm-audit-interval": onuDeviceEntry.alarmAuditInterval})
-	// TODO: periodical mib resync will be implemented with story VOL-3792
-	//onuDeviceEntry.mibNextDbResync = 0
-
-	// Omci related Mib upload sync state machine
-	mibUploadChan := make(chan Message, 2048)
-	onuDeviceEntry.pMibUploadFsm = NewAdapterFsm("MibUpload", dh.deviceID, mibUploadChan)
-	onuDeviceEntry.pMibUploadFsm.pFsm = fsm.NewFSM(
-		ulStDisabled,
-		fsm.Events{
-
-			{Name: ulEvStart, Src: []string{ulStDisabled}, Dst: ulStStarting},
-
-			{Name: ulEvResetMib, Src: []string{ulStStarting}, Dst: ulStResettingMib},
-			{Name: ulEvGetVendorAndSerial, Src: []string{ulStResettingMib}, Dst: ulStGettingVendorAndSerial},
-			{Name: ulEvGetEquipmentID, Src: []string{ulStGettingVendorAndSerial}, Dst: ulStGettingEquipmentID},
-			{Name: ulEvGetFirstSwVersion, Src: []string{ulStGettingEquipmentID}, Dst: ulStGettingFirstSwVersion},
-			{Name: ulEvGetSecondSwVersion, Src: []string{ulStGettingFirstSwVersion}, Dst: ulStGettingSecondSwVersion},
-			{Name: ulEvGetMacAddress, Src: []string{ulStGettingSecondSwVersion}, Dst: ulStGettingMacAddress},
-			{Name: ulEvGetMibTemplate, Src: []string{ulStGettingMacAddress}, Dst: ulStGettingMibTemplate},
-
-			{Name: ulEvUploadMib, Src: []string{ulStGettingMibTemplate}, Dst: ulStUploading},
-			{Name: ulEvExamineMds, Src: []string{ulStStarting}, Dst: ulStExaminingMds},
-
-			{Name: ulEvSuccess, Src: []string{ulStGettingMibTemplate}, Dst: ulStUploadDone},
-			{Name: ulEvSuccess, Src: []string{ulStUploading}, Dst: ulStUploadDone},
-
-			{Name: ulEvSuccess, Src: []string{ulStUploadDone}, Dst: ulStInSync},
-			//{Name: ulEvSuccess, Src: []string{ulStExaminingMds}, Dst: ulStInSync},
-			{Name: ulEvSuccess, Src: []string{ulStExaminingMds}, Dst: ulStExaminingMdsSuccess},
-			// TODO: As long as mib-resynchronizing is not implemented, failed MDS-examination triggers
-			// mib-reset and new provisioning at this point
-			//{Name: ulEvMismatch, Src: []string{ulStExaminingMds}, Dst: ulStResynchronizing},
-			{Name: ulEvMismatch, Src: []string{ulStExaminingMds}, Dst: ulStResettingMib},
-
-			{Name: ulEvSuccess, Src: []string{ulStExaminingMdsSuccess}, Dst: ulStInSync},
-			{Name: ulEvMismatch, Src: []string{ulStExaminingMdsSuccess}, Dst: ulStResettingMib},
-
-			{Name: ulEvAuditMib, Src: []string{ulStInSync}, Dst: ulStAuditing},
-
-			{Name: ulEvSuccess, Src: []string{ulStOutOfSync}, Dst: ulStInSync},
-			{Name: ulEvAuditMib, Src: []string{ulStOutOfSync}, Dst: ulStAuditing},
-
-			{Name: ulEvSuccess, Src: []string{ulStAuditing}, Dst: ulStInSync},
-			{Name: ulEvMismatch, Src: []string{ulStAuditing}, Dst: ulStReAuditing},
-			{Name: ulEvForceResync, Src: []string{ulStAuditing}, Dst: ulStResynchronizing},
-
-			{Name: ulEvSuccess, Src: []string{ulStReAuditing}, Dst: ulStInSync},
-			{Name: ulEvMismatch, Src: []string{ulStReAuditing}, Dst: ulStResettingMib},
-
-			{Name: ulEvSuccess, Src: []string{ulStResynchronizing}, Dst: ulStInSync},
-			{Name: ulEvDiffsFound, Src: []string{ulStResynchronizing}, Dst: ulStOutOfSync},
-
-			{Name: ulEvTimeout, Src: []string{ulStResettingMib, ulStGettingVendorAndSerial, ulStGettingEquipmentID, ulStGettingFirstSwVersion,
-				ulStGettingSecondSwVersion, ulStGettingMacAddress, ulStGettingMibTemplate, ulStUploading, ulStResynchronizing, ulStExaminingMds,
-				ulStUploadDone, ulStInSync, ulStOutOfSync, ulStAuditing, ulStReAuditing}, Dst: ulStStarting},
-
-			{Name: ulEvStop, Src: []string{ulStStarting, ulStResettingMib, ulStGettingVendorAndSerial, ulStGettingEquipmentID, ulStGettingFirstSwVersion,
-				ulStGettingSecondSwVersion, ulStGettingMacAddress, ulStGettingMibTemplate, ulStUploading, ulStResynchronizing, ulStExaminingMds,
-				ulStUploadDone, ulStInSync, ulStOutOfSync, ulStAuditing, ulStReAuditing}, Dst: ulStDisabled},
-		},
-
-		fsm.Callbacks{
-			"enter_state":                         func(e *fsm.Event) { onuDeviceEntry.pMibUploadFsm.logFsmStateChange(ctx, e) },
-			"enter_" + ulStStarting:               func(e *fsm.Event) { onuDeviceEntry.enterStartingState(ctx, e) },
-			"enter_" + ulStResettingMib:           func(e *fsm.Event) { onuDeviceEntry.enterResettingMibState(ctx, e) },
-			"enter_" + ulStGettingVendorAndSerial: func(e *fsm.Event) { onuDeviceEntry.enterGettingVendorAndSerialState(ctx, e) },
-			"enter_" + ulStGettingEquipmentID:     func(e *fsm.Event) { onuDeviceEntry.enterGettingEquipmentIDState(ctx, e) },
-			"enter_" + ulStGettingFirstSwVersion:  func(e *fsm.Event) { onuDeviceEntry.enterGettingFirstSwVersionState(ctx, e) },
-			"enter_" + ulStGettingSecondSwVersion: func(e *fsm.Event) { onuDeviceEntry.enterGettingSecondSwVersionState(ctx, e) },
-			"enter_" + ulStGettingMacAddress:      func(e *fsm.Event) { onuDeviceEntry.enterGettingMacAddressState(ctx, e) },
-			"enter_" + ulStGettingMibTemplate:     func(e *fsm.Event) { onuDeviceEntry.enterGettingMibTemplateState(ctx, e) },
-			"enter_" + ulStUploading:              func(e *fsm.Event) { onuDeviceEntry.enterUploadingState(ctx, e) },
-			"enter_" + ulStUploadDone:             func(e *fsm.Event) { onuDeviceEntry.enterUploadDoneState(ctx, e) },
-			"enter_" + ulStExaminingMds:           func(e *fsm.Event) { onuDeviceEntry.enterExaminingMdsState(ctx, e) },
-			"enter_" + ulStResynchronizing:        func(e *fsm.Event) { onuDeviceEntry.enterResynchronizingState(ctx, e) },
-			"enter_" + ulStExaminingMdsSuccess:    func(e *fsm.Event) { onuDeviceEntry.enterExaminingMdsSuccessState(ctx, e) },
-			"enter_" + ulStAuditing:               func(e *fsm.Event) { onuDeviceEntry.enterAuditingState(ctx, e) },
-			"enter_" + ulStReAuditing:             func(e *fsm.Event) { onuDeviceEntry.enterReAuditingState(ctx, e) },
-			"enter_" + ulStOutOfSync:              func(e *fsm.Event) { onuDeviceEntry.enterOutOfSyncState(ctx, e) },
-			"enter_" + ulStInSync:                 func(e *fsm.Event) { onuDeviceEntry.enterInSyncState(ctx, e) },
-		},
-	)
-	// Omci related Mib download state machine
-	mibDownloadChan := make(chan Message, 2048)
-	onuDeviceEntry.pMibDownloadFsm = NewAdapterFsm("MibDownload", dh.deviceID, mibDownloadChan)
-	onuDeviceEntry.pMibDownloadFsm.pFsm = fsm.NewFSM(
-		dlStDisabled,
-		fsm.Events{
-
-			{Name: dlEvStart, Src: []string{dlStDisabled}, Dst: dlStStarting},
-
-			{Name: dlEvCreateGal, Src: []string{dlStStarting}, Dst: dlStCreatingGal},
-			{Name: dlEvRxGalResp, Src: []string{dlStCreatingGal}, Dst: dlStSettingOnu2g},
-			{Name: dlEvRxOnu2gResp, Src: []string{dlStSettingOnu2g}, Dst: dlStBridgeInit},
-			// the bridge state is used for multi ME config for alle UNI related ports
-			// maybe such could be reflected in the state machine as well (port number parametrized)
-			// but that looks not straightforward here - so we keep it simple here for the beginning(?)
-			{Name: dlEvRxBridgeResp, Src: []string{dlStBridgeInit}, Dst: dlStDownloaded},
-
-			{Name: dlEvTimeoutSimple, Src: []string{dlStCreatingGal, dlStSettingOnu2g}, Dst: dlStStarting},
-			{Name: dlEvTimeoutBridge, Src: []string{dlStBridgeInit}, Dst: dlStStarting},
-
-			{Name: dlEvReset, Src: []string{dlStStarting, dlStCreatingGal, dlStSettingOnu2g,
-				dlStBridgeInit, dlStDownloaded}, Dst: dlStResetting},
-			// exceptional treatment for all states except dlStResetting
-			{Name: dlEvRestart, Src: []string{dlStStarting, dlStCreatingGal, dlStSettingOnu2g,
-				dlStBridgeInit, dlStDownloaded, dlStResetting}, Dst: dlStDisabled},
-		},
-
-		fsm.Callbacks{
-			"enter_state":               func(e *fsm.Event) { onuDeviceEntry.pMibDownloadFsm.logFsmStateChange(ctx, e) },
-			"enter_" + dlStStarting:     func(e *fsm.Event) { onuDeviceEntry.enterDLStartingState(ctx, e) },
-			"enter_" + dlStCreatingGal:  func(e *fsm.Event) { onuDeviceEntry.enterCreatingGalState(ctx, e) },
-			"enter_" + dlStSettingOnu2g: func(e *fsm.Event) { onuDeviceEntry.enterSettingOnu2gState(ctx, e) },
-			"enter_" + dlStBridgeInit:   func(e *fsm.Event) { onuDeviceEntry.enterBridgeInitState(ctx, e) },
-			"enter_" + dlStDownloaded:   func(e *fsm.Event) { onuDeviceEntry.enterDownloadedState(ctx, e) },
-			"enter_" + dlStResetting:    func(e *fsm.Event) { onuDeviceEntry.enterResettingState(ctx, e) },
-		},
-	)
-	if onuDeviceEntry.pMibDownloadFsm == nil || onuDeviceEntry.pMibDownloadFsm.pFsm == nil {
-		logger.Errorw(ctx, "MibDownloadFsm could not be instantiated", log.Fields{"device-id": dh.deviceID})
-		// TODO some specific error treatment - or waiting for crash ?
-	}
-
-	onuDeviceEntry.mibTemplateKVStore = onuDeviceEntry.baseDeviceHandler.setBackend(ctx, cBasePathMibTemplateKvStore)
-	if onuDeviceEntry.mibTemplateKVStore == nil {
-		logger.Errorw(ctx, "Can't access mibTemplateKVStore - no backend connection to service",
-			log.Fields{"device-id": dh.deviceID, "service": cBasePathMibTemplateKvStore})
-	}
-
-	onuDeviceEntry.onuKVStorePath = onuDeviceEntry.deviceID
-	baseKvStorePath := fmt.Sprintf(cBasePathOnuKVStore, dh.pOpenOnuAc.cm.Backend.PathPrefix)
-	onuDeviceEntry.onuKVStore = onuDeviceEntry.baseDeviceHandler.setBackend(ctx, baseKvStorePath)
-	if onuDeviceEntry.onuKVStore == nil {
-		logger.Errorw(ctx, "Can't access onuKVStore - no backend connection to service",
-			log.Fields{"device-id": dh.deviceID, "service": baseKvStorePath})
-	}
-
-	// Alarm Synchronization Database
-
-	//self._alarm_db = None
-	//self._alarm_database_cls = support_classes['alarm-synchronizer']['database']
-	return &onuDeviceEntry
-}
-
-//start starts (logs) the omci agent
-func (oo *OnuDeviceEntry) start(ctx context.Context) error {
-	logger.Debugw(ctx, "OnuDeviceEntry-starting", log.Fields{"for device-id": oo.deviceID})
-	if oo.PDevOmciCC == nil {
-		oo.PDevOmciCC = newOmciCC(ctx, oo, oo.deviceID, oo.baseDeviceHandler, oo.coreClient)
-		if oo.PDevOmciCC == nil {
-			logger.Errorw(ctx, "Could not create devOmciCc - abort", log.Fields{"for device-id": oo.deviceID})
-			return fmt.Errorf("could not create devOmciCc %s", oo.deviceID)
-		}
-	}
-	return nil
-}
-
-//stop stops/resets the omciCC
-func (oo *OnuDeviceEntry) stop(ctx context.Context, abResetOmciCC bool) error {
-	logger.Debugw(ctx, "OnuDeviceEntry-stopping", log.Fields{"for device-id": oo.deviceID})
-	if abResetOmciCC && (oo.PDevOmciCC != nil) {
-		_ = oo.PDevOmciCC.stop(ctx)
-	}
-	//to allow for all event notifications again when re-using the device and omciCC
-	oo.devState = DeviceStatusInit
-	return nil
-}
-
-func (oo *OnuDeviceEntry) reboot(ctx context.Context) error {
-	logger.Debugw(ctx, "OnuDeviceEntry-rebooting", log.Fields{"for device-id": oo.deviceID})
-	if oo.PDevOmciCC != nil {
-		if err := oo.PDevOmciCC.sendReboot(ctx, oo.pOpenOnuAc.omciTimeout, true, oo.omciRebootMessageReceivedChannel); err != nil {
-			logger.Errorw(ctx, "onu didn't reboot", log.Fields{"for device-id": oo.deviceID})
-			return err
-		}
-	}
-	return nil
-}
-
-func (oo *OnuDeviceEntry) waitForRebootResponse(ctx context.Context, responseChannel chan Message) error {
-	select {
-	case <-time.After(oo.PDevOmciCC.GetMaxOmciTimeoutWithRetries() * time.Second): //3s was detected to be to less in 8*8 bbsim test with debug Info/Debug
-		logger.Warnw(ctx, "Reboot timeout", log.Fields{"for device-id": oo.deviceID})
-		return fmt.Errorf("rebootTimeout")
-	case data := <-responseChannel:
-		switch data.Data.(OmciMessage).OmciMsg.MessageType {
-		case omci.RebootResponseType:
-			{
-				msgLayer := (*data.Data.(OmciMessage).OmciPacket).Layer(omci.LayerTypeRebootResponse)
-				if msgLayer == nil {
-					return fmt.Errorf("omci Msg layer could not be detected for RebootResponseType")
-				}
-				msgObj, msgOk := msgLayer.(*omci.RebootResponse)
-				if !msgOk {
-					return fmt.Errorf("omci Msg layer could not be assigned for RebootResponseType %s", oo.deviceID)
-				}
-				logger.Debugw(ctx, "RebootResponse data", log.Fields{"device-id": oo.deviceID, "data-fields": msgObj})
-				if msgObj.Result != me.Success {
-					logger.Errorw(ctx, "Omci RebootResponse result error", log.Fields{"device-id": oo.deviceID, "Error": msgObj.Result})
-					// possibly force FSM into abort or ignore some errors for some messages? store error for mgmt display?
-					return fmt.Errorf("omci RebootResponse result error indication %s for device %s",
-						msgObj.Result, oo.deviceID)
-				}
-				return nil
-			}
-		}
-		logger.Warnw(ctx, "Reboot response message type error", log.Fields{"for device-id": oo.deviceID})
-		return fmt.Errorf("unexpected OmciResponse type received %s", oo.deviceID)
-	}
-}
-
-//Relay the InSync message via Handler to Rw core - Status update
-func (oo *OnuDeviceEntry) transferSystemEvent(ctx context.Context, devEvent OnuDeviceEvent) {
-	logger.Debugw(ctx, "relaying system-event", log.Fields{"Event": devEvent})
-	// decouple the handler transfer from further processing here
-	// TODO!!! check if really no synch is required within the system e.g. to ensure following steps ..
-	if devEvent == MibDatabaseSync {
-		if oo.devState < MibDatabaseSync { //devState has not been synced yet
-			oo.devState = MibDatabaseSync
-			go oo.baseDeviceHandler.deviceProcStatusUpdate(ctx, devEvent)
-			//TODO!!! device control: next step: start MIB capability verification from here ?!!!
-		} else {
-			logger.Debugw(ctx, "mibinsync-event in some already synced state - ignored", log.Fields{"state": oo.devState})
-		}
-	} else if devEvent == MibDownloadDone {
-		if oo.devState < MibDownloadDone { //devState has not been synced yet
-			oo.devState = MibDownloadDone
-			go oo.baseDeviceHandler.deviceProcStatusUpdate(ctx, devEvent)
-		} else {
-			logger.Debugw(ctx, "mibdownloaddone-event was already seen - ignored", log.Fields{"state": oo.devState})
-		}
-	} else {
-		logger.Warnw(ctx, "device-event not yet handled", log.Fields{"state": devEvent})
-	}
-}
-
-func (oo *OnuDeviceEntry) restoreDataFromOnuKvStore(ctx context.Context) error {
-	if oo.onuKVStore == nil {
-		logger.Debugw(ctx, "onuKVStore not set - abort", log.Fields{"device-id": oo.deviceID})
-		return fmt.Errorf(fmt.Sprintf("onuKVStore-not-set-abort-%s", oo.deviceID))
-	}
-	oo.mutexPersOnuConfig.Lock()
-	defer oo.mutexPersOnuConfig.Unlock()
-	oo.sOnuPersistentData =
-		onuPersistentData{0, 0, "", "", "", "", "", "", "", false, false, oo.mibAuditInterval, 0, 0, make([]uniPersConfig, 0), oo.alarmAuditInterval, make(map[uint16]uint16)}
-	oo.mutexOnuKVStore.RLock()
-	Value, err := oo.onuKVStore.Get(ctx, oo.onuKVStorePath)
-	oo.mutexOnuKVStore.RUnlock()
-	if err == nil {
-		if Value != nil {
-			logger.Debugw(ctx, "ONU-data read",
-				log.Fields{"Key": Value.Key, "device-id": oo.deviceID})
-			tmpBytes, _ := kvstore.ToByte(Value.Value)
-
-			if err = json.Unmarshal(tmpBytes, &oo.sOnuPersistentData); err != nil {
-				logger.Errorw(ctx, "unable to unmarshal ONU-data", log.Fields{"error": err, "device-id": oo.deviceID})
-				return fmt.Errorf(fmt.Sprintf("unable-to-unmarshal-ONU-data-%s", oo.deviceID))
-			}
-			logger.Debugw(ctx, "ONU-data", log.Fields{"sOnuPersistentData": oo.sOnuPersistentData,
-				"device-id": oo.deviceID})
-		} else {
-			logger.Debugw(ctx, "no ONU-data found", log.Fields{"path": oo.onuKVStorePath, "device-id": oo.deviceID})
-			return fmt.Errorf("no-ONU-data-found")
-		}
-	} else {
-		logger.Errorw(ctx, "unable to read from KVstore", log.Fields{"device-id": oo.deviceID})
-		return fmt.Errorf(fmt.Sprintf("unable-to-read-from-KVstore-%s", oo.deviceID))
-	}
-	return nil
-}
-
-func (oo *OnuDeviceEntry) deleteDataFromOnuKvStore(ctx context.Context, wg *sync.WaitGroup) {
-	defer wg.Done()
-
-	if oo.onuKVStore == nil {
-		logger.Debugw(ctx, "onuKVStore not set - abort", log.Fields{"device-id": oo.deviceID})
-		oo.setKvProcessingErrorIndication(errors.New("onu-data delete aborted: onuKVStore not set"))
-		return
-	}
-	var processingStep uint8 = 1 // used to synchronize the different processing steps with chOnuKvProcessingStep
-	go oo.deletePersistentData(ctx, processingStep)
-	if !oo.waitForTimeoutOrCompletion(ctx, oo.chOnuKvProcessingStep, processingStep) {
-		//timeout or error detected
-		logger.Debugw(ctx, "ONU-data not deleted - abort", log.Fields{"device-id": oo.deviceID})
-		oo.setKvProcessingErrorIndication(errors.New("onu-data delete aborted: during kv-access"))
-		return
-	}
-}
-
-func (oo *OnuDeviceEntry) deletePersistentData(ctx context.Context, aProcessingStep uint8) {
-
-	logger.Debugw(ctx, "delete and clear internal persistency data", log.Fields{"device-id": oo.deviceID})
-
-	oo.mutexPersOnuConfig.Lock()
-	defer oo.mutexPersOnuConfig.Unlock()
-
-	oo.sOnuPersistentData.PersUniConfig = nil //releasing all UniConfig entries to garbage collector default entry
-	oo.sOnuPersistentData =
-		onuPersistentData{0, 0, "", "", "", "", "", "", "", false, false, oo.mibAuditInterval, 0, 0, make([]uniPersConfig, 0), oo.alarmAuditInterval, make(map[uint16]uint16)}
-	logger.Debugw(ctx, "delete ONU-data from KVStore", log.Fields{"device-id": oo.deviceID})
-	oo.mutexOnuKVStore.Lock()
-	err := oo.onuKVStore.Delete(ctx, oo.onuKVStorePath)
-	oo.mutexOnuKVStore.Unlock()
-	if err != nil {
-		logger.Errorw(ctx, "unable to delete in KVstore", log.Fields{"device-id": oo.deviceID, "err": err})
-		oo.chOnuKvProcessingStep <- 0 //error indication
-		return
-	}
-	oo.chOnuKvProcessingStep <- aProcessingStep //done
-}
-
-func (oo *OnuDeviceEntry) updateOnuKvStore(ctx context.Context, wg *sync.WaitGroup) {
-	defer wg.Done()
-
-	if oo.onuKVStore == nil {
-		logger.Debugw(ctx, "onuKVStore not set - abort", log.Fields{"device-id": oo.deviceID})
-		oo.setKvProcessingErrorIndication(errors.New("onu-data update aborted: onuKVStore not set"))
-		return
-	}
-	var processingStep uint8 = 1 // used to synchronize the different processing steps with chOnuKvProcessingStep
-	go oo.storeDataInOnuKvStore(ctx, processingStep)
-	if !oo.waitForTimeoutOrCompletion(ctx, oo.chOnuKvProcessingStep, processingStep) {
-		//timeout or error detected
-		logger.Debugw(ctx, "ONU-data not written - abort", log.Fields{"device-id": oo.deviceID})
-		oo.setKvProcessingErrorIndication(errors.New("onu-data update aborted: during writing process"))
-		return
-	}
-}
-
-func (oo *OnuDeviceEntry) storeDataInOnuKvStore(ctx context.Context, aProcessingStep uint8) {
-
-	oo.mutexPersOnuConfig.Lock()
-	defer oo.mutexPersOnuConfig.Unlock()
-	//assign values which are not already present when newOnuDeviceEntry() is called
-	oo.sOnuPersistentData.PersOnuID = oo.baseDeviceHandler.pOnuIndication.OnuId
-	oo.sOnuPersistentData.PersIntfID = oo.baseDeviceHandler.pOnuIndication.IntfId
-	//TODO: verify usage of these values during restart UC
-	oo.sOnuPersistentData.PersAdminState = oo.baseDeviceHandler.pOnuIndication.AdminState
-	oo.sOnuPersistentData.PersOperState = oo.baseDeviceHandler.pOnuIndication.OperState
-
-	logger.Debugw(ctx, "Update ONU-data in KVStore", log.Fields{"device-id": oo.deviceID, "sOnuPersistentData": oo.sOnuPersistentData})
-
-	Value, err := json.Marshal(oo.sOnuPersistentData)
-	if err != nil {
-		logger.Errorw(ctx, "unable to marshal ONU-data", log.Fields{"sOnuPersistentData": oo.sOnuPersistentData,
-			"device-id": oo.deviceID, "err": err})
-		oo.chOnuKvProcessingStep <- 0 //error indication
-		return
-	}
-	oo.pOpenOnuAc.lockDeviceHandlersMap.RLock()
-	if _, exist := oo.pOpenOnuAc.deviceHandlers[oo.deviceID]; !exist {
-		logger.Debugw(ctx, "delete_device in progress - skip write request", log.Fields{"device-id": oo.deviceID})
-		oo.chOnuKvProcessingStep <- aProcessingStep
-		oo.pOpenOnuAc.lockDeviceHandlersMap.RUnlock()
-		return
-	}
-	oo.baseDeviceHandler.mutexDeletionInProgressFlag.RLock()
-	if oo.baseDeviceHandler.deletionInProgress {
-		logger.Debugw(ctx, "delete_device in progress - skip write request", log.Fields{"device-id": oo.deviceID})
-		oo.chOnuKvProcessingStep <- aProcessingStep
-		oo.pOpenOnuAc.lockDeviceHandlersMap.RUnlock()
-		oo.baseDeviceHandler.mutexDeletionInProgressFlag.RUnlock()
-		return
-	}
-	oo.pOpenOnuAc.lockDeviceHandlersMap.RUnlock()
-	oo.baseDeviceHandler.mutexDeletionInProgressFlag.RUnlock()
-
-	oo.mutexOnuKVStore.Lock()
-	err = oo.onuKVStore.Put(ctx, oo.onuKVStorePath, Value)
-	oo.mutexOnuKVStore.Unlock()
-	if err != nil {
-		logger.Errorw(ctx, "unable to write ONU-data into KVstore", log.Fields{"device-id": oo.deviceID, "err": err})
-		oo.chOnuKvProcessingStep <- 0 //error indication
-		return
-	}
-	oo.chOnuKvProcessingStep <- aProcessingStep //done
-}
-
-func (oo *OnuDeviceEntry) updateOnuUniTpPath(ctx context.Context, aUniID uint8, aTpID uint8, aPathString string) bool {
-	/* within some specific InterAdapter processing request write/read access to data is ensured to be sequentially,
-	   as also the complete sequence is ensured to 'run to completion' before some new request is accepted
-	   no specific concurrency protection to sOnuPersistentData is required here
-	*/
-	oo.mutexPersOnuConfig.Lock()
-	defer oo.mutexPersOnuConfig.Unlock()
-
-	for k, v := range oo.sOnuPersistentData.PersUniConfig {
-		if v.PersUniID == aUniID {
-			existingPath, ok := oo.sOnuPersistentData.PersUniConfig[k].PersTpPathMap[aTpID]
-			logger.Debugw(ctx, "PersUniConfig-entry exists", log.Fields{"device-id": oo.deviceID, "uniID": aUniID,
-				"tpID": aTpID, "path": aPathString, "existingPath": existingPath, "ok": ok})
-			if !ok {
-				logger.Debugw(ctx, "tp-does-not-exist", log.Fields{"device-id": oo.deviceID, "uniID": aUniID, "tpID": aTpID, "path": aPathString})
-			}
-			if existingPath != aPathString {
-				if aPathString == "" {
-					//existing entry to be deleted
-					logger.Debugw(ctx, "UniTp delete path value", log.Fields{"device-id": oo.deviceID, "uniID": aUniID, "path": aPathString})
-					oo.sOnuPersistentData.PersUniConfig[k].PersTpPathMap[aTpID] = ""
-				} else {
-					//existing entry to be modified
-					logger.Debugw(ctx, "UniTp modify path value", log.Fields{"device-id": oo.deviceID, "uniID": aUniID, "path": aPathString})
-					oo.sOnuPersistentData.PersUniConfig[k].PersTpPathMap[aTpID] = aPathString
-				}
-				return true
-			}
-			//entry already exists
-			if aPathString == "" {
-				//no active TechProfile
-				logger.Debugw(ctx, "UniTp path has already been removed - no AniSide config to be removed", log.Fields{
-					"device-id": oo.deviceID, "uniID": aUniID})
-			} else {
-				//the given TechProfile already exists and is assumed to be active - update devReason as if the config has been done here
-				//was needed e.g. in voltha POD Tests:Validate authentication on a disabled ONU
-				//  (as here the TechProfile has not been removed with the disable-device before the new enable-device)
-				logger.Debugw(ctx, "UniTp path already exists - TechProfile supposed to be active", log.Fields{
-					"device-id": oo.deviceID, "uniID": aUniID, "path": aPathString})
-				//no deviceReason update (deviceProcStatusUpdate) here to ensure 'omci_flows_pushed' state within disable/enable procedure of ATT scenario
-				//  (during which the flows are removed/re-assigned but the techProf is left active)
-				//and as the TechProfile is regarded as active we have to verify, if some flow configuration still waits on it
-				//  (should not be the case, but should not harm or be more robust ...)
-				// and to be sure, that for some reason the corresponding TpDelete was lost somewhere in history
-				//  we also reset a possibly outstanding delete request - repeated TpConfig is regarded as valid for waiting flow config
-				if oo.baseDeviceHandler.pOnuTP != nil {
-					oo.baseDeviceHandler.pOnuTP.setProfileToDelete(aUniID, aTpID, false)
-				}
-				go oo.baseDeviceHandler.VerifyVlanConfigRequest(ctx, aUniID, aTpID)
-			}
-			return false //indicate 'no change' - nothing more to do, TechProf inter-adapter message is return with success anyway here
-		}
-	}
-	//no entry exists for uniId
-
-	if aPathString == "" {
-		//delete request in non-existing state , accept as no change
-		logger.Debugw(ctx, "UniTp path already removed", log.Fields{"device-id": oo.deviceID, "uniID": aUniID})
-		return false
-	}
-	//new entry to be created
-	logger.Debugw(ctx, "New UniTp path set", log.Fields{"device-id": oo.deviceID, "uniID": aUniID, "path": aPathString})
-	perSubTpPathMap := make(map[uint8]string)
-	perSubTpPathMap[aTpID] = aPathString
-	oo.sOnuPersistentData.PersUniConfig =
-		append(oo.sOnuPersistentData.PersUniConfig, uniPersConfig{PersUniID: aUniID, PersTpPathMap: perSubTpPathMap, PersFlowParams: make([]uniVlanFlowParams, 0)})
-	return true
-}
-
-func (oo *OnuDeviceEntry) updateOnuUniFlowConfig(aUniID uint8, aUniVlanFlowParams *[]uniVlanFlowParams) {
-
-	oo.mutexPersOnuConfig.Lock()
-	defer oo.mutexPersOnuConfig.Unlock()
-
-	for k, v := range oo.sOnuPersistentData.PersUniConfig {
-		if v.PersUniID == aUniID {
-			oo.sOnuPersistentData.PersUniConfig[k].PersFlowParams = make([]uniVlanFlowParams, len(*aUniVlanFlowParams))
-			copy(oo.sOnuPersistentData.PersUniConfig[k].PersFlowParams, *aUniVlanFlowParams)
-			return
-		}
-	}
-	//flow update was faster than tp-config - create PersUniConfig-entry
-	//TODO!!: following activity to 'add' some new uni entry might not be quite correct if this function is called to clear the data
-	//  (e.g after flow removal from RemoveUniFlowParams()).
-	//  This has the effect of misleading indication that there is still some active UNI entry, even though there might be only some nil flow entry
-	//  The effect of this flaw is that at TechProfile removal there is an additional attempt to remove the entry even though no techProfile exists anymore
-	//  The code is not changed here because of the current release lane, changes might have unexpected secondary effects, perhaps later with more elaborate tests
-	tmpConfig := uniPersConfig{PersUniID: aUniID, PersTpPathMap: make(map[uint8]string), PersFlowParams: make([]uniVlanFlowParams, len(*aUniVlanFlowParams))}
-	copy(tmpConfig.PersFlowParams, *aUniVlanFlowParams)
-	oo.sOnuPersistentData.PersUniConfig = append(oo.sOnuPersistentData.PersUniConfig, tmpConfig)
-}
-
-func (oo *OnuDeviceEntry) waitForTimeoutOrCompletion(
-	ctx context.Context, aChOnuProcessingStep <-chan uint8, aProcessingStep uint8) bool {
-	select {
-	case <-ctx.Done():
-		logger.Warnw(ctx, "processing not completed in-time!",
-			log.Fields{"device-id": oo.deviceID, "error": ctx.Err()})
-		return false
-	case rxStep := <-aChOnuProcessingStep:
-		if rxStep == aProcessingStep {
-			return true
-		}
-		//all other values are not accepted - including 0 for error indication
-		logger.Warnw(ctx, "Invalid processing step received: abort!",
-			log.Fields{"device-id": oo.deviceID,
-				"wantedStep": aProcessingStep, "haveStep": rxStep})
-		return false
-	}
-}
-
-func (oo *OnuDeviceEntry) resetKvProcessingErrorIndication() {
-	oo.mutexOnuKVStoreProcResult.Lock()
-	oo.onuKVStoreProcResult = nil
-	oo.mutexOnuKVStoreProcResult.Unlock()
-}
-
-func (oo *OnuDeviceEntry) getKvProcessingErrorIndication() error {
-	oo.mutexOnuKVStoreProcResult.RLock()
-	value := oo.onuKVStoreProcResult
-	oo.mutexOnuKVStoreProcResult.RUnlock()
-	return value
-}
-
-func (oo *OnuDeviceEntry) setKvProcessingErrorIndication(value error) {
-	oo.mutexOnuKVStoreProcResult.Lock()
-	oo.onuKVStoreProcResult = value
-	oo.mutexOnuKVStoreProcResult.Unlock()
-}
-
-func (oo *OnuDeviceEntry) incrementMibDataSync(ctx context.Context) {
-	oo.mutexPersOnuConfig.Lock()
-	defer oo.mutexPersOnuConfig.Unlock()
-	if oo.sOnuPersistentData.PersMibDataSyncAdpt < 255 {
-		oo.sOnuPersistentData.PersMibDataSyncAdpt++
-	} else {
-		// per G.984 and G.988 overflow starts over at 1 given 0 is reserved for reset
-		oo.sOnuPersistentData.PersMibDataSyncAdpt = 1
-	}
-	logger.Debugf(ctx, "mibDataSync updated - mds: %d - device-id: %s", oo.sOnuPersistentData.PersMibDataSyncAdpt, oo.deviceID)
-}
-
-func (oo *OnuDeviceEntry) modifySwImageInactiveVersion(ctx context.Context, aImageVersion string) {
-	oo.mutexOnuSwImageIndications.Lock()
-	defer oo.mutexOnuSwImageIndications.Unlock()
-	logger.Debugw(ctx, "software-image set inactive version", log.Fields{
-		"device-id": oo.deviceID, "version": aImageVersion})
-	oo.onuSwImageIndications.inactiveEntityEntry.version = aImageVersion
-	//inactive SW version is not part of persistency data (yet) - no need to update that
-}
-
-func (oo *OnuDeviceEntry) modifySwImageActiveCommit(ctx context.Context, aCommitted uint8) {
-	oo.mutexOnuSwImageIndications.Lock()
-	defer oo.mutexOnuSwImageIndications.Unlock()
-	logger.Debugw(ctx, "software-image set active entity commit flag", log.Fields{
-		"device-id": oo.deviceID, "committed": aCommitted})
-	oo.onuSwImageIndications.activeEntityEntry.isCommitted = aCommitted
-	//commit flag is not part of persistency data (yet) - no need to update that
-}
-
-func (oo *OnuDeviceEntry) getActiveImageVersion(ctx context.Context) string {
-	oo.mutexOnuSwImageIndications.RLock()
-	if oo.onuSwImageIndications.activeEntityEntry.valid {
-		value := oo.onuSwImageIndications.activeEntityEntry.version
-		oo.mutexOnuSwImageIndications.RUnlock()
-		return value
-	}
-	oo.mutexOnuSwImageIndications.RUnlock()
-	logger.Debugw(ctx, "Active Image is not valid", log.Fields{"device-id": oo.deviceID})
-	return ""
-}
-
-func (oo *OnuDeviceEntry) getInactiveImageVersion(ctx context.Context) string {
-	oo.mutexOnuSwImageIndications.RLock()
-	if oo.onuSwImageIndications.inactiveEntityEntry.valid {
-		value := oo.onuSwImageIndications.inactiveEntityEntry.version
-		oo.mutexOnuSwImageIndications.RUnlock()
-		return value
-	}
-	oo.mutexOnuSwImageIndications.RUnlock()
-	logger.Debugw(ctx, "Inactive Image is not valid", log.Fields{"device-id": oo.deviceID})
-	return ""
-}
-
-func (oo *OnuDeviceEntry) buildMibTemplatePath() string {
-	oo.mutexPersOnuConfig.RLock()
-	defer oo.mutexPersOnuConfig.RUnlock()
-	return fmt.Sprintf(cSuffixMibTemplateKvStore, oo.sOnuPersistentData.PersVendorID, oo.sOnuPersistentData.PersEquipmentID, oo.sOnuPersistentData.PersActiveSwVersion)
-}
-
-func (oo *OnuDeviceEntry) allocateFreeTcont(ctx context.Context, allocID uint16) (uint16, bool, error) {
-	logger.Debugw(ctx, "allocate-free-tcont", log.Fields{"device-id": oo.deviceID, "allocID": allocID,
-		"allocated-instances": oo.sOnuPersistentData.PersTcontMap})
-
-	oo.mutexTcontMap.Lock()
-	defer oo.mutexTcontMap.Unlock()
-	if entityID, ok := oo.sOnuPersistentData.PersTcontMap[allocID]; ok {
-		//tcont already allocated before, return the used instance-id
-		return entityID, true, nil
-	}
-	//First allocation of tcont. Find a free instance
-	if tcontInstKeys := oo.pOnuDB.getSortedInstKeys(ctx, me.TContClassID); len(tcontInstKeys) > 0 {
-		logger.Debugw(ctx, "allocate-free-tcont-db-keys", log.Fields{"device-id": oo.deviceID, "keys": tcontInstKeys})
-		for _, instID := range tcontInstKeys {
-			instExist := false
-			//If this instance exist in map, it means it is not  empty. It is allocated before
-			for _, v := range oo.sOnuPersistentData.PersTcontMap {
-				if v == instID {
-					instExist = true
-					break
-				}
-			}
-			if !instExist {
-				oo.sOnuPersistentData.PersTcontMap[allocID] = instID
-				return instID, false, nil
-			}
-		}
-	}
-	return 0, false, fmt.Errorf(fmt.Sprintf("no-free-tcont-left-for-device-%s", oo.deviceID))
-
-}
-
-func (oo *OnuDeviceEntry) freeTcont(ctx context.Context, allocID uint16) {
-	logger.Debugw(ctx, "free-tcont", log.Fields{"device-id": oo.deviceID, "alloc": allocID})
-	oo.mutexTcontMap.Lock()
-	defer oo.mutexTcontMap.Unlock()
-	delete(oo.sOnuPersistentData.PersTcontMap, allocID)
-}
diff --git a/internal/pkg/onuadaptercore/onu_uni_port.go b/internal/pkg/onuadaptercore/onu_uni_port.go
deleted file mode 100644
index f4b255f..0000000
--- a/internal/pkg/onuadaptercore/onu_uni_port.go
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Copyright 2020-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
-
-import (
-	"context"
-	"fmt"
-	"strconv"
-	"strings"
-	"time"
-
-	//"sync"
-	//"time"
-
-	//"github.com/opencord/voltha-lib-go/v7/pkg/kafka"
-	"github.com/opencord/voltha-lib-go/v7/pkg/log"
-	vc "github.com/opencord/voltha-protos/v5/go/common"
-	of "github.com/opencord/voltha-protos/v5/go/openflow_13"
-	"github.com/opencord/voltha-protos/v5/go/voltha"
-)
-
-type uniPortType uint8
-
-// UniPPTP Interface type - re-use values from G.988 (Chapter 9.3.4)TP type definition (directly used in OMCI!)
-const (
-	// uniPPTP relates to PPTP
-	uniPPTP uniPortType = 1 // relates to PPTP
-	// uniVEIP relates to VEIP
-	uniVEIP uniPortType = 11 // relates to VEIP
-	// uniPPTPPots relates to PPTP POTS
-	uniPPTPPots uniPortType = 4 // relates to IP host config data (for Voice Services)
-)
-
-//onuUniPort structure holds information about the ONU attached Uni Ports
-type onuUniPort struct {
-	enabled    bool
-	name       string
-	portNo     uint32
-	portType   uniPortType
-	ofpPortNo  string
-	uniID      uint8
-	macBpNo    uint8
-	entityID   uint16
-	adminState vc.AdminState_Types
-	operState  vc.OperStatus_Types
-	pPort      *voltha.Port
-}
-
-//newOnuUniPort returns a new instance of a OnuUniPort
-func newOnuUniPort(ctx context.Context, aUniID uint8, aPortNo uint32, aInstNo uint16,
-	aPortType uniPortType) *onuUniPort {
-	logger.Infow(ctx, "init-onuUniPort", log.Fields{"uniID": aUniID,
-		"portNo": aPortNo, "InstNo": aInstNo, "type": aPortType})
-	var onuUniPort onuUniPort
-	onuUniPort.enabled = false
-	onuUniPort.name = "uni-" + strconv.FormatUint(uint64(aPortNo), 10)
-	onuUniPort.portNo = aPortNo
-	onuUniPort.portType = aPortType
-	// so far it seems as here ofpPortNo/Name ist the same as the original port name ...??
-	onuUniPort.ofpPortNo = onuUniPort.name
-	onuUniPort.uniID = aUniID
-	onuUniPort.macBpNo = aUniID + 1 //ensure >0 instanceNo
-	onuUniPort.entityID = aInstNo
-	onuUniPort.adminState = vc.AdminState_ENABLED //enabled per create
-	onuUniPort.operState = vc.OperStatus_UNKNOWN
-	onuUniPort.pPort = nil // to be set on create
-	return &onuUniPort
-}
-
-//createVolthaPort creates the Voltha port based on ONU UNI Port and informs the core about it
-func (oo *onuUniPort) createVolthaPort(ctx context.Context, apDeviceHandler *deviceHandler) error {
-	logger.Debugw(ctx, "creating-voltha-uni-port", log.Fields{
-		"device-id": apDeviceHandler.device.Id, "portNo": oo.portNo})
-	//200630: per [VOL-3202] OF port info is now to be delivered within UniPort create
-	//  not doing so crashes rw_core processing (at least still in 200630 version)
-	name := apDeviceHandler.device.SerialNumber + "-" + strconv.FormatUint(uint64(oo.macBpNo), 10)
-	var macOctets [6]uint8
-	macOctets[5] = 0x08
-	//ponPortNumber was copied from device.ParentPortNo
-	macOctets[4] = uint8(apDeviceHandler.ponPortNumber >> 8)
-	macOctets[3] = uint8(apDeviceHandler.ponPortNumber)
-	macOctets[2] = uint8(oo.portNo >> 16)
-	macOctets[1] = uint8(oo.portNo >> 8)
-	macOctets[0] = uint8(oo.portNo)
-	hwAddr := genMacFromOctets(macOctets)
-	ofHwAddr := macAddressToUint32Array(hwAddr)
-	capacity := uint32(of.OfpPortFeatures_OFPPF_1GB_FD | of.OfpPortFeatures_OFPPF_FIBER)
-	ofUniPortState := of.OfpPortState_OFPPS_LINK_DOWN
-	/* as the VOLTHA port create is only called directly after Uni Port create
-	   the OfPortOperState is always Down
-	   Note: this way the OfPortOperState won't ever change (directly in adapter)
-	   maybe that was already always the case, but looks a bit weird - to be kept in mind ...
-		if pUniPort.operState == vc.OperStatus_ACTIVE {
-			ofUniPortState = of.OfpPortState_OFPPS_LIVE
-		}
-	*/
-	logger.Debugw(ctx, "ofPort values", log.Fields{
-		"forUniPortName": oo.name, "forMacBase": hwAddr,
-		"name": name, "hwAddr": ofHwAddr, "OperState": ofUniPortState})
-
-	pUniPort := &voltha.Port{
-		DeviceId:   apDeviceHandler.deviceID,
-		PortNo:     oo.portNo,
-		Label:      oo.name,
-		Type:       voltha.Port_ETHERNET_UNI,
-		AdminState: oo.adminState,
-		OperStatus: oo.operState,
-		// obviously empty peer setting
-		OfpPort: &of.OfpPort{
-			Name:       name,
-			HwAddr:     ofHwAddr,
-			Config:     0,
-			State:      uint32(ofUniPortState),
-			Curr:       capacity,
-			Advertised: capacity,
-			Peer:       capacity,
-			CurrSpeed:  1000,
-			MaxSpeed:   1000,
-		},
-	}
-	maxRetry := 3
-	retryCnt := 0
-	var err error
-	for retryCnt = 0; retryCnt < maxRetry; retryCnt++ {
-		if err = apDeviceHandler.createPortInCore(ctx, pUniPort); err != nil {
-			logger.Errorf(ctx, "Device FSM: PortCreated-failed-%s, retrying after a delay", err)
-			// retry after a sleep
-			time.Sleep(2 * time.Second)
-		} else {
-			// success, break from retry loop
-			break
-		}
-	}
-	if retryCnt == maxRetry { // maxed out..
-		logger.Errorf(ctx, "Device FSM: PortCreated-failed-%s", err)
-		return fmt.Errorf("device-fsm-port-create-failed-%s", err)
-	}
-	logger.Infow(ctx, "Voltha onuUniPort-added", log.Fields{
-		"device-id": apDeviceHandler.device.Id, "PortNo": oo.portNo})
-	oo.pPort = pUniPort
-	oo.operState = vc.OperStatus_DISCOVERED
-
-	return nil
-}
-
-//setOperState modifies OperState of the the UniPort
-func (oo *onuUniPort) setOperState(aNewOperState vc.OperStatus_Types) {
-	oo.operState = aNewOperState
-}
-
-// uni port related utility functions (so far only used here)
-func genMacFromOctets(aOctets [6]uint8) string {
-	return fmt.Sprintf("%02x:%02x:%02x:%02x:%02x:%02x",
-		aOctets[5], aOctets[4], aOctets[3],
-		aOctets[2], aOctets[1], aOctets[0])
-}
-
-//copied from OLT Adapter: unify centrally ?
-func macAddressToUint32Array(mac string) []uint32 {
-	slist := strings.Split(mac, ":")
-	result := make([]uint32, len(slist))
-	var err error
-	var tmp int64
-	for index, val := range slist {
-		if tmp, err = strconv.ParseInt(val, 16, 32); err != nil {
-			return []uint32{1, 2, 3, 4, 5, 6}
-		}
-		result[index] = uint32(tmp)
-	}
-	return result
-}
diff --git a/internal/pkg/onuadaptercore/openonu_utils.go b/internal/pkg/onuadaptercore/openonu_utils.go
deleted file mode 100644
index 51e5e81..0000000
--- a/internal/pkg/onuadaptercore/openonu_utils.go
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright 2020-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
-
-import (
-	"bytes"
-	"encoding/binary"
-	"errors"
-	"fmt"
-	"net"
-	"regexp"
-	"strconv"
-	"strings"
-
-	me "github.com/opencord/omci-lib-go/generated"
-)
-
-// GetTpIDFromTpPath extracts TpID from the TpPath.
-// On success it returns a valid TpID and nil error.
-// On failure it returns TpID as 0 and the error.
-func GetTpIDFromTpPath(tpPath string) (uint8, error) {
-	// tpPath is of the format  <technology>/<table_id>/olt-{}/pon-{}/onu-{}/uni-{}
-	// A sample tpPath is ==> XGS-PON/64/olt-{12345abcd}/pon-{0}/onu-{1}/uni-{1}
-	var tpPathFormat = regexp.MustCompile(`^[a-zA-Z\-_]+/[0-9]+/olt-{[a-z0-9\-]+}/pon-{[0-9]+}/onu-{[0-9]+}/uni-{[0-9]+}$`)
-
-	// Ensure tpPath is of the format  <technology>/<table_id>/<uni_port_name>
-	if !tpPathFormat.Match([]byte(tpPath)) {
-		return 0, errors.New("tp-path-not-confirming-to-format")
-	}
-	// Extract the TP table-id field.
-	tpID, err := strconv.Atoi(strings.Split(tpPath, "/")[1])
-	// Atoi returns uint64 and need to be type-casted to uint8 as tpID is uint8 size.
-	return uint8(tpID), err
-}
-
-//IPToInt32 transforms an IP of net.Ip type to int32
-func IPToInt32(ip net.IP) uint32 {
-	if len(ip) == 16 {
-		return binary.BigEndian.Uint32(ip[12:16])
-	}
-	return binary.BigEndian.Uint32(ip)
-}
-
-//AsByteSlice transforms a string of manually set bits to a byt array
-func AsByteSlice(bitString string) []byte {
-	var out []byte
-	var str string
-
-	for i := len(bitString); i > 0; i -= 8 {
-		if i-8 < 0 {
-			str = bitString[0:i]
-		} else {
-			str = bitString[i-8 : i]
-		}
-		v, err := strconv.ParseUint(str, 2, 8)
-		if err != nil {
-			panic(err)
-		}
-		out = append([]byte{byte(v)}, out...)
-	}
-	return out
-}
-
-// TwosComplementToSignedInt16 convert 2s complement to signed int16
-func TwosComplementToSignedInt16(val uint16) int16 {
-	var uint16MsbMask uint16 = 0x8000
-	if val&uint16MsbMask == uint16MsbMask {
-		return int16(^val+1) * -1
-	}
-
-	return int16(val)
-}
-
-// TrimStringFromMeOctet trim string out of Me octet
-func TrimStringFromMeOctet(input interface{}) string {
-	ifBytes, _ := me.InterfaceToOctets(input)
-	return fmt.Sprintf("%s", bytes.Trim(ifBytes, "\x00"))
-}
diff --git a/internal/pkg/onuadaptercore/common.go b/internal/pkg/pmmgr/common.go
old mode 100644
new mode 100755
similarity index 86%
copy from internal/pkg/onuadaptercore/common.go
copy to internal/pkg/pmmgr/common.go
index b0b10e3..5e49dda
--- a/internal/pkg/onuadaptercore/common.go
+++ b/internal/pkg/pmmgr/common.go
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package pmmgr provides the utilities to manage onu metrics
+package pmmgr
 
 import (
 	"github.com/opencord/voltha-lib-go/v7/pkg/log"
@@ -26,7 +26,7 @@
 func init() {
 	// Setup this package so that it's log level can be modified at run time
 	var err error
-	logger, err = log.RegisterPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "adaptercoreonu"})
+	logger, err = log.RegisterPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "pmmgr"})
 	if err != nil {
 		panic(err)
 	}
diff --git a/internal/pkg/onuadaptercore/onu_metrics_manager.go b/internal/pkg/pmmgr/onu_metrics_manager.go
old mode 100644
new mode 100755
similarity index 72%
rename from internal/pkg/onuadaptercore/onu_metrics_manager.go
rename to internal/pkg/pmmgr/onu_metrics_manager.go
index c2a2ffb..d3eaf0b
--- a/internal/pkg/onuadaptercore/onu_metrics_manager.go
+++ b/internal/pkg/pmmgr/onu_metrics_manager.go
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package pmmgr provides the utilities to manage onu metrics
+package pmmgr
 
 import (
 	"context"
@@ -31,32 +31,35 @@
 	"github.com/opencord/voltha-lib-go/v7/pkg/db"
 	"github.com/opencord/voltha-lib-go/v7/pkg/db/kvstore"
 	"github.com/opencord/voltha-lib-go/v7/pkg/log"
+	cmn "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/common"
 	"github.com/opencord/voltha-protos/v5/go/extension"
 	"github.com/opencord/voltha-protos/v5/go/voltha"
 )
 
+// events of L2 PM FSM
 const (
-	// events of L2 PM FSM
-	l2PmEventInit     = "l2PmEventInit"
-	l2PmEventTick     = "l2PmEventTick"
-	l2PmEventSuccess  = "l2PmEventSuccess"
-	l2PmEventFailure  = "l2PmEventFailure"
-	l2PmEventAddMe    = "l2PmEventAddMe"
-	l2PmEventDeleteMe = "l2PmEventDeleteMe"
-	l2PmEventStop     = "l2PmEventStop"
-)
-const (
-	// states of L2 PM FSM
-	l2PmStNull        = "l2PmStNull"
-	l2PmStStarting    = "l2PmStStarting"
-	l2PmStSyncTime    = "l2PmStSyncTime"
-	l2PmStIdle        = "l2PmStIdle"
-	l2PmStCreatePmMe  = "l2PmStCreatePm"
-	l2PmStDeletePmMe  = "l2PmStDeletePmMe"
-	l2PmStCollectData = "l2PmStCollectData"
+	L2PmEventInit     = "L2PmEventInit"
+	L2PmEventTick     = "L2PmEventTick"
+	L2PmEventSuccess  = "L2PmEventSuccess"
+	L2PmEventFailure  = "L2PmEventFailure"
+	L2PmEventAddMe    = "L2PmEventAddMe"
+	L2PmEventDeleteMe = "L2PmEventDeleteMe"
+	L2PmEventStop     = "L2PmEventStop"
 )
 
-const cL2PmFsmIdleState = l2PmStIdle
+// states of L2 PM FSM
+const (
+	L2PmStNull        = "L2PmStNull"
+	L2PmStStarting    = "L2PmStStarting"
+	L2PmStSyncTime    = "L2PmStSyncTime"
+	L2PmStIdle        = "L2PmStIdle"
+	L2PmStCreatePmMe  = "L2PmStCreatePm"
+	L2PmStDeletePmMe  = "L2PmStDeletePmMe"
+	L2PmStCollectData = "L2PmStCollectData"
+)
+
+// CL2PmFsmIdleState - TODO: add comment
+const CL2PmFsmIdleState = L2PmStIdle
 
 // general constants used for overall Metric Collection management
 const (
@@ -275,25 +278,28 @@
 
 type groupMetric struct {
 	groupName              string
-	enabled                bool
-	frequency              uint32 // valid only if FrequencyOverride is enabled.
+	Enabled                bool
+	Frequency              uint32 // valid only if FrequencyOverride is enabled.
 	metricMap              map[string]voltha.PmConfig_PmType
-	nextCollectionInterval time.Time // valid only if FrequencyOverride is enabled.
-	isL2PMCounter          bool      // true for only L2 PM counters
+	NextCollectionInterval time.Time // valid only if FrequencyOverride is enabled.
+	IsL2PMCounter          bool      // true for only L2 PM counters
 	collectAttempts        uint32    // number of attempts to collect L2 PM data
 	pmMEData               *pmMEData
 }
 
 type standaloneMetric struct {
 	metricName             string
-	enabled                bool
-	frequency              uint32    // valid only if FrequencyOverride is enabled.
-	nextCollectionInterval time.Time // valid only if FrequencyOverride is enabled.
+	Enabled                bool
+	Frequency              uint32    // valid only if FrequencyOverride is enabled.
+	NextCollectionInterval time.Time // valid only if FrequencyOverride is enabled.
 }
 
-type onuMetricsManager struct {
-	pDeviceHandler *deviceHandler
-	pAdaptFsm      *AdapterFsm
+// OnuMetricsManager - TODO: add comment
+type OnuMetricsManager struct {
+	deviceID        string
+	pDeviceHandler  cmn.IdeviceHandler
+	pOnuDeviceEntry cmn.IonuDeviceEntry
+	PAdaptFsm       *cmn.AdapterFsm
 
 	opticalMetricsChan                   chan me.AttributeValueMap
 	uniStatusMetricsChan                 chan me.AttributeValueMap
@@ -307,18 +313,18 @@
 	l2PmToDelete []string // list of L2 PMs to delete
 	l2PmToAdd    []string // list of L2 PM to add
 
-	groupMetricMap      map[string]*groupMetric
-	standaloneMetricMap map[string]*standaloneMetric
+	GroupMetricMap      map[string]*groupMetric
+	StandaloneMetricMap map[string]*standaloneMetric
 
-	stopProcessingOmciResponses chan bool
+	StopProcessingOmciResponses chan bool
 	omciProcessingActive        bool
 
-	stopTicks            chan bool
+	StopTicks            chan bool
 	tickGenerationActive bool
 
-	nextGlobalMetricCollectionTime time.Time // valid only if pmConfig.FreqOverride is set to false.
+	NextGlobalMetricCollectionTime time.Time // valid only if pmConfig.FreqOverride is set to false.
 
-	onuMetricsManagerLock sync.RWMutex
+	OnuMetricsManagerLock sync.RWMutex
 
 	pmKvStore *db.Backend
 
@@ -330,20 +336,22 @@
 	isDeviceReadyToCollectExtendedPmStats         bool
 }
 
-// newonuMetricsManager returns a new instance of the newonuMetricsManager
+// NewOnuMetricsManager returns a new instance of the NewOnuMetricsManager
 // The metrics manager module is responsible for configuration and management of individual and group metrics.
 // Currently all the metrics are managed as a group which fall into two categories - L2 PM and "all others"
 // The L2 PM counters have a fixed 15min interval for PM collection while all other group counters have
 // the collection interval configurable.
 // The global PM config is part of the voltha.Device struct and is backed up on KV store (by rw-core).
 // This module also implements resiliency for L2 PM ME instances that are active/pending-delete/pending-add.
-func newonuMetricsManager(ctx context.Context, dh *deviceHandler) *onuMetricsManager {
+func NewOnuMetricsManager(ctx context.Context, dh cmn.IdeviceHandler, onuDev cmn.IonuDeviceEntry) *OnuMetricsManager {
 
-	var metricsManager onuMetricsManager
-	logger.Debugw(ctx, "init-onuMetricsManager", log.Fields{"device-id": dh.deviceID})
+	var metricsManager OnuMetricsManager
+	metricsManager.deviceID = dh.GetDeviceID()
+	logger.Debugw(ctx, "init-OnuMetricsManager", log.Fields{"device-id": metricsManager.deviceID})
 	metricsManager.pDeviceHandler = dh
+	metricsManager.pOnuDeviceEntry = onuDev
 
-	commMetricsChan := make(chan Message)
+	commMetricsChan := make(chan cmn.Message)
 	metricsManager.opticalMetricsChan = make(chan me.AttributeValueMap)
 	metricsManager.uniStatusMetricsChan = make(chan me.AttributeValueMap)
 	metricsManager.l2PmChan = make(chan me.AttributeValueMap)
@@ -353,16 +361,16 @@
 	metricsManager.l2PmCreateOrDeleteResponseChan = make(chan bool)
 	metricsManager.extendedPMCreateOrDeleteResponseChan = make(chan me.Results)
 
-	metricsManager.stopProcessingOmciResponses = make(chan bool)
-	metricsManager.stopTicks = make(chan bool)
+	metricsManager.StopProcessingOmciResponses = make(chan bool)
+	metricsManager.StopTicks = make(chan bool)
 
-	metricsManager.groupMetricMap = make(map[string]*groupMetric)
-	metricsManager.standaloneMetricMap = make(map[string]*standaloneMetric)
+	metricsManager.GroupMetricMap = make(map[string]*groupMetric)
+	metricsManager.StandaloneMetricMap = make(map[string]*standaloneMetric)
 
 	metricsManager.ethernetFrameExtendedPmUpStreamMEByEntityID = make(map[uint16]*me.ManagedEntity)
 	metricsManager.ethernetFrameExtendedPmDownStreamMEByEntityID = make(map[uint16]*me.ManagedEntity)
 
-	if dh.pmConfigs == nil { // dh.pmConfigs is NOT nil if adapter comes back from a restart. We should NOT go back to defaults in this case
+	if dh.GetPmConfigs() == nil { // dh.GetPmConfigs() is NOT nil if adapter comes back from a restart. We should NOT go back to defaults in this case
 		metricsManager.initializeAllGroupMetrics()
 	}
 
@@ -373,13 +381,13 @@
 	}
 
 	// initialize the next metric collection intervals.
-	metricsManager.initializeMetricCollectionTime(ctx)
+	metricsManager.InitializeMetricCollectionTime(ctx)
 
-	baseKvStorePath := fmt.Sprintf(cPmKvStorePrefix, dh.pOpenOnuAc.cm.Backend.PathPrefix, dh.deviceID)
-	metricsManager.pmKvStore = dh.setBackend(ctx, baseKvStorePath)
+	baseKvStorePath := fmt.Sprintf(cPmKvStorePrefix, dh.GetBackendPathPrefix(), metricsManager.deviceID)
+	metricsManager.pmKvStore = dh.SetBackend(ctx, baseKvStorePath)
 	if metricsManager.pmKvStore == nil {
 		logger.Errorw(ctx, "Can't initialize pmKvStore - no backend connection to PM module",
-			log.Fields{"device-id": dh.deviceID, "service": baseKvStorePath})
+			log.Fields{"device-id": metricsManager.deviceID, "service": baseKvStorePath})
 		return nil
 	}
 	// restore data from KV store
@@ -390,55 +398,58 @@
 		// the actual PM config and what is present on the device).
 	}
 
-	baseExtPmKvStorePath := fmt.Sprintf(cExtPmKvStorePrefix, dh.pOpenOnuAc.cm.Backend.PathPrefix)
-	metricsManager.extPmKvStore = dh.setBackend(ctx, baseExtPmKvStorePath)
+	baseExtPmKvStorePath := fmt.Sprintf(cExtPmKvStorePrefix, dh.GetBackendPathPrefix())
+	metricsManager.extPmKvStore = dh.SetBackend(ctx, baseExtPmKvStorePath)
 	if metricsManager.extPmKvStore == nil {
 		logger.Errorw(ctx, "Can't initialize extPmKvStore - no backend connection to PM module",
-			log.Fields{"device-id": dh.deviceID, "service": baseExtPmKvStorePath})
+			log.Fields{"device-id": metricsManager.deviceID, "service": baseExtPmKvStorePath})
 		return nil
 	}
 
-	logger.Info(ctx, "init-onuMetricsManager completed", log.Fields{"device-id": dh.deviceID})
+	logger.Info(ctx, "init-OnuMetricsManager completed", log.Fields{"device-id": metricsManager.deviceID})
 	return &metricsManager
 }
 
-func (mm *onuMetricsManager) initializeMetricCollectionTime(ctx context.Context) {
-	if mm.pDeviceHandler.pmConfigs.FreqOverride {
-		// If mm.pDeviceHandler.pmConfigs.FreqOverride is set to true, then group/standalone metric specific interval applies
-		mm.onuMetricsManagerLock.Lock()
-		defer mm.onuMetricsManagerLock.Unlock()
-		for _, v := range mm.groupMetricMap {
-			if v.enabled && !v.isL2PMCounter { // L2 PM counter collection is managed in a L2PmFsm
-				v.nextCollectionInterval = time.Now().Add(time.Duration(v.frequency) * time.Second)
+// InitializeMetricCollectionTime - TODO: add comment
+func (mm *OnuMetricsManager) InitializeMetricCollectionTime(ctx context.Context) {
+	if mm.pDeviceHandler.GetPmConfigs().FreqOverride {
+		// If mm.pDeviceHandler.GetPmConfigs().FreqOverride is set to true, then group/standalone metric specific interval applies
+		mm.OnuMetricsManagerLock.Lock()
+		defer mm.OnuMetricsManagerLock.Unlock()
+		for _, v := range mm.GroupMetricMap {
+			if v.Enabled && !v.IsL2PMCounter { // L2 PM counter collection is managed in a L2PmFsm
+				v.NextCollectionInterval = time.Now().Add(time.Duration(v.Frequency) * time.Second)
 			}
 		}
 
-		for _, v := range mm.standaloneMetricMap {
-			if v.enabled {
-				v.nextCollectionInterval = time.Now().Add(time.Duration(v.frequency) * time.Second)
+		for _, v := range mm.StandaloneMetricMap {
+			if v.Enabled {
+				v.NextCollectionInterval = time.Now().Add(time.Duration(v.Frequency) * time.Second)
 			}
 		}
 	} else {
-		// If mm.pDeviceHandler.pmConfigs.FreqOverride is set to false, then overall metric specific interval applies
-		mm.nextGlobalMetricCollectionTime = time.Now().Add(time.Duration(mm.pDeviceHandler.pmConfigs.DefaultFreq) * time.Second)
+		// If mm.pDeviceHandler.GetPmConfigs().FreqOverride is set to false, then overall metric specific interval applies
+		mm.NextGlobalMetricCollectionTime = time.Now().Add(time.Duration(mm.pDeviceHandler.GetPmConfigs().DefaultFreq) * time.Second)
 	}
-	logger.Infow(ctx, "initialized standalone group/metric collection time", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+	logger.Infow(ctx, "initialized standalone group/metric collection time", log.Fields{"device-id": mm.deviceID})
 }
 
-func (mm *onuMetricsManager) updateDefaultFrequency(ctx context.Context, pmConfigs *voltha.PmConfigs) error {
+// UpdateDefaultFrequency - TODO: add comment
+func (mm *OnuMetricsManager) UpdateDefaultFrequency(ctx context.Context, pmConfigs *voltha.PmConfigs) error {
 	// Verify that the configured DefaultFrequency is > 0 and is a multiple of FrequencyGranularity
 	if pmConfigs.DefaultFreq == 0 || (pmConfigs.DefaultFreq > 0 && pmConfigs.DefaultFreq%FrequencyGranularity != 0) {
 		logger.Errorf(ctx, "frequency-%u-should-be-a-multiple-of-%u", pmConfigs.DefaultFreq, FrequencyGranularity)
 		return fmt.Errorf("frequency-%d-should-be-a-multiple-of-%d", pmConfigs.DefaultFreq, FrequencyGranularity)
 	}
-	mm.pDeviceHandler.pmConfigs.DefaultFreq = pmConfigs.DefaultFreq
-	// re-set the nextGlobalMetricCollectionTime based on the new DefaultFreq
-	mm.nextGlobalMetricCollectionTime = time.Now().Add(time.Duration(mm.pDeviceHandler.pmConfigs.DefaultFreq) * time.Second)
-	logger.Debugw(ctx, "frequency-updated--new-frequency", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "frequency": mm.pDeviceHandler.pmConfigs.DefaultFreq})
+	mm.pDeviceHandler.GetPmConfigs().DefaultFreq = pmConfigs.DefaultFreq
+	// re-set the NextGlobalMetricCollectionTime based on the new DefaultFreq
+	mm.NextGlobalMetricCollectionTime = time.Now().Add(time.Duration(mm.pDeviceHandler.GetPmConfigs().DefaultFreq) * time.Second)
+	logger.Debugw(ctx, "frequency-updated--new-frequency", log.Fields{"device-id": mm.deviceID, "frequency": mm.pDeviceHandler.GetPmConfigs().DefaultFreq})
 	return nil
 }
 
-func (mm *onuMetricsManager) updateGroupFreq(ctx context.Context, aGroupName string, pmConfigs *voltha.PmConfigs) error {
+// UpdateGroupFreq - TODO: add comment
+func (mm *OnuMetricsManager) UpdateGroupFreq(ctx context.Context, aGroupName string, pmConfigs *voltha.PmConfigs) error {
 	var newGroupFreq uint32
 	found := false
 	groupSliceIdx := 0
@@ -457,33 +468,34 @@
 	}
 	// if not found update group freq and next collection interval for the group
 	if !found {
-		logger.Errorw(ctx, "group name not found", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "groupName": aGroupName})
+		logger.Errorw(ctx, "group name not found", log.Fields{"device-id": mm.deviceID, "groupName": aGroupName})
 		return fmt.Errorf("group-name-not-found-%v", aGroupName)
 	}
 
 	updated := false
-	mm.onuMetricsManagerLock.Lock()
-	defer mm.onuMetricsManagerLock.Unlock()
-	for k, v := range mm.groupMetricMap {
-		if k == aGroupName && !v.isL2PMCounter { // We cannot allow the L2 PM counter frequency to be updated. It is 15min fixed by OMCI spec
-			v.frequency = newGroupFreq
+	mm.OnuMetricsManagerLock.Lock()
+	defer mm.OnuMetricsManagerLock.Unlock()
+	for k, v := range mm.GroupMetricMap {
+		if k == aGroupName && !v.IsL2PMCounter { // We cannot allow the L2 PM counter frequency to be updated. It is 15min fixed by OMCI spec
+			v.Frequency = newGroupFreq
 			// update internal pm config
-			mm.pDeviceHandler.pmConfigs.Groups[groupSliceIdx].GroupFreq = newGroupFreq
+			mm.pDeviceHandler.GetPmConfigs().Groups[groupSliceIdx].GroupFreq = newGroupFreq
 			// Also updated the next group metric collection time from now
-			v.nextCollectionInterval = time.Now().Add(time.Duration(newGroupFreq) * time.Second)
+			v.NextCollectionInterval = time.Now().Add(time.Duration(newGroupFreq) * time.Second)
 			updated = true
-			logger.Infow(ctx, "group frequency updated", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "newGroupFreq": newGroupFreq, "groupName": aGroupName})
+			logger.Infow(ctx, "group frequency updated", log.Fields{"device-id": mm.deviceID, "newGroupFreq": newGroupFreq, "groupName": aGroupName})
 			break
 		}
 	}
 	if !updated {
-		logger.Errorw(ctx, "group frequency not updated", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "newGroupFreq": newGroupFreq, "groupName": aGroupName})
+		logger.Errorw(ctx, "group frequency not updated", log.Fields{"device-id": mm.deviceID, "newGroupFreq": newGroupFreq, "groupName": aGroupName})
 		return fmt.Errorf("internal-error-during-group-freq-update--groupname-%s-freq-%d", aGroupName, newGroupFreq)
 	}
 	return nil
 }
 
-func (mm *onuMetricsManager) updateMetricFreq(ctx context.Context, aMetricName string, pmConfigs *voltha.PmConfigs) error {
+// UpdateMetricFreq - TODO: add comment
+func (mm *OnuMetricsManager) UpdateMetricFreq(ctx context.Context, aMetricName string, pmConfigs *voltha.PmConfigs) error {
 	var newMetricFreq uint32
 	found := false
 	metricSliceIdx := 0
@@ -501,33 +513,34 @@
 		}
 	}
 	if !found {
-		logger.Errorw(ctx, "metric name not found", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "metricName": aMetricName})
+		logger.Errorw(ctx, "metric name not found", log.Fields{"device-id": mm.deviceID, "metricName": aMetricName})
 		return fmt.Errorf("metric-name-not-found-%v", aMetricName)
 	}
 
 	updated := false
-	mm.onuMetricsManagerLock.Lock()
-	defer mm.onuMetricsManagerLock.Unlock()
-	for k, v := range mm.groupMetricMap {
+	mm.OnuMetricsManagerLock.Lock()
+	defer mm.OnuMetricsManagerLock.Unlock()
+	for k, v := range mm.GroupMetricMap {
 		if k == aMetricName {
-			v.frequency = newMetricFreq
+			v.Frequency = newMetricFreq
 			// update internal pm config
-			mm.pDeviceHandler.pmConfigs.Metrics[metricSliceIdx].SampleFreq = newMetricFreq
+			mm.pDeviceHandler.GetPmConfigs().Metrics[metricSliceIdx].SampleFreq = newMetricFreq
 			// Also updated the next standalone metric collection time from now
-			v.nextCollectionInterval = time.Now().Add(time.Duration(newMetricFreq) * time.Second)
+			v.NextCollectionInterval = time.Now().Add(time.Duration(newMetricFreq) * time.Second)
 			updated = true
-			logger.Infow(ctx, "metric frequency updated", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "newMetricFreq": newMetricFreq, "aMetricName": aMetricName})
+			logger.Infow(ctx, "metric frequency updated", log.Fields{"device-id": mm.deviceID, "newMetricFreq": newMetricFreq, "aMetricName": aMetricName})
 			break
 		}
 	}
 	if !updated {
-		logger.Errorw(ctx, "metric frequency not updated", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "newMetricFreq": newMetricFreq, "aMetricName": aMetricName})
+		logger.Errorw(ctx, "metric frequency not updated", log.Fields{"device-id": mm.deviceID, "newMetricFreq": newMetricFreq, "aMetricName": aMetricName})
 		return fmt.Errorf("internal-error-during-standalone-metric-update--matricnane-%s-freq-%d", aMetricName, newMetricFreq)
 	}
 	return nil
 }
 
-func (mm *onuMetricsManager) updateGroupSupport(ctx context.Context, aGroupName string, pmConfigs *voltha.PmConfigs) error {
+// UpdateGroupSupport - TODO: add comment
+func (mm *OnuMetricsManager) UpdateGroupSupport(ctx context.Context, aGroupName string, pmConfigs *voltha.PmConfigs) error {
 	groupSliceIdx := 0
 	var group *voltha.PmGroupConfig
 
@@ -537,19 +550,19 @@
 		}
 	}
 	if group == nil {
-		logger.Errorw(ctx, "group metric not found", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "groupName": aGroupName})
+		logger.Errorw(ctx, "group metric not found", log.Fields{"device-id": mm.deviceID, "groupName": aGroupName})
 		return fmt.Errorf("group-not-found--groupName-%s", aGroupName)
 	}
 
 	updated := false
-	mm.onuMetricsManagerLock.Lock()
-	defer mm.onuMetricsManagerLock.Unlock()
-	for k, v := range mm.groupMetricMap {
-		if k == aGroupName && v.enabled != group.Enabled {
-			mm.pDeviceHandler.pmConfigs.Groups[groupSliceIdx].Enabled = group.Enabled
-			v.enabled = group.Enabled
+	mm.OnuMetricsManagerLock.Lock()
+	defer mm.OnuMetricsManagerLock.Unlock()
+	for k, v := range mm.GroupMetricMap {
+		if k == aGroupName && v.Enabled != group.Enabled {
+			mm.pDeviceHandler.GetPmConfigs().Groups[groupSliceIdx].Enabled = group.Enabled
+			v.Enabled = group.Enabled
 			if group.Enabled {
-				if v.isL2PMCounter {
+				if v.IsL2PMCounter {
 					// If it is a L2 PM counter we need to mark the PM to be added
 					mm.l2PmToAdd = mm.appendIfMissingString(mm.l2PmToAdd, v.groupName)
 					// If the group support flag toggles too soon, we need to delete the group name from l2PmToDelete slice
@@ -561,11 +574,11 @@
 					if v.groupName == GemPortHistoryName {
 						mm.updateGemPortNTPInstanceToAddForPerfMonitoring(ctx)
 					}
-				} else if mm.pDeviceHandler.pmConfigs.FreqOverride { // otherwise just update the next collection interval
-					v.nextCollectionInterval = time.Now().Add(time.Duration(v.frequency) * time.Second)
+				} else if mm.pDeviceHandler.GetPmConfigs().FreqOverride { // otherwise just update the next collection interval
+					v.NextCollectionInterval = time.Now().Add(time.Duration(v.Frequency) * time.Second)
 				}
 			} else { // group counter is disabled
-				if v.isL2PMCounter {
+				if v.IsL2PMCounter {
 					// If it is a L2 PM counter we need to mark the PM to be deleted
 					mm.l2PmToDelete = mm.appendIfMissingString(mm.l2PmToDelete, v.groupName)
 					// If the group support flag toggles too soon, we need to delete the group name from l2PmToAdd slice
@@ -580,24 +593,25 @@
 				}
 			}
 			updated = true
-			if v.isL2PMCounter {
+			if v.IsL2PMCounter {
 				logger.Infow(ctx, "l2 pm group metric support updated",
-					log.Fields{"device-id": mm.pDeviceHandler.deviceID, "groupName": aGroupName, "enabled": group.Enabled, "l2PmToAdd": mm.l2PmToAdd, "l2PmToDelete": mm.l2PmToDelete})
+					log.Fields{"device-id": mm.deviceID, "groupName": aGroupName, "enabled": group.Enabled, "l2PmToAdd": mm.l2PmToAdd, "l2PmToDelete": mm.l2PmToDelete})
 			} else {
-				logger.Infow(ctx, "group metric support updated", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "groupName": aGroupName, "enabled": group.Enabled})
+				logger.Infow(ctx, "group metric support updated", log.Fields{"device-id": mm.deviceID, "groupName": aGroupName, "enabled": group.Enabled})
 			}
 			break
 		}
 	}
 
 	if !updated {
-		logger.Errorw(ctx, "group metric support not updated", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "groupName": aGroupName})
+		logger.Errorw(ctx, "group metric support not updated", log.Fields{"device-id": mm.deviceID, "groupName": aGroupName})
 		return fmt.Errorf("internal-error-during-group-support-update--groupName-%s", aGroupName)
 	}
 	return nil
 }
 
-func (mm *onuMetricsManager) updateMetricSupport(ctx context.Context, aMetricName string, pmConfigs *voltha.PmConfigs) error {
+// UpdateMetricSupport - TODO: add comment
+func (mm *OnuMetricsManager) UpdateMetricSupport(ctx context.Context, aMetricName string, pmConfigs *voltha.PmConfigs) error {
 	metricSliceIdx := 0
 	var metric *voltha.PmConfig
 
@@ -608,48 +622,49 @@
 	}
 
 	if metric == nil {
-		logger.Errorw(ctx, "standalone metric not found", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "metricName": aMetricName})
+		logger.Errorw(ctx, "standalone metric not found", log.Fields{"device-id": mm.deviceID, "metricName": aMetricName})
 		return fmt.Errorf("metric-not-found--metricname-%s", aMetricName)
 	}
 
 	updated := false
-	mm.onuMetricsManagerLock.Lock()
-	defer mm.onuMetricsManagerLock.Unlock()
-	for k, v := range mm.standaloneMetricMap {
-		if k == aMetricName && v.enabled != metric.Enabled {
-			mm.pDeviceHandler.pmConfigs.Metrics[metricSliceIdx].Enabled = metric.Enabled
-			v.enabled = metric.Enabled
+	mm.OnuMetricsManagerLock.Lock()
+	defer mm.OnuMetricsManagerLock.Unlock()
+	for k, v := range mm.StandaloneMetricMap {
+		if k == aMetricName && v.Enabled != metric.Enabled {
+			mm.pDeviceHandler.GetPmConfigs().Metrics[metricSliceIdx].Enabled = metric.Enabled
+			v.Enabled = metric.Enabled
 			// If the standalone metric is now enabled and frequency override is enabled, set the next metric collection time
-			if metric.Enabled && mm.pDeviceHandler.pmConfigs.FreqOverride {
-				v.nextCollectionInterval = time.Now().Add(time.Duration(v.frequency) * time.Second)
+			if metric.Enabled && mm.pDeviceHandler.GetPmConfigs().FreqOverride {
+				v.NextCollectionInterval = time.Now().Add(time.Duration(v.Frequency) * time.Second)
 			}
 			updated = true
-			logger.Infow(ctx, "standalone metric support updated", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "metricName": aMetricName, "enabled": metric.Enabled})
+			logger.Infow(ctx, "standalone metric support updated", log.Fields{"device-id": mm.deviceID, "metricName": aMetricName, "enabled": metric.Enabled})
 			break
 		}
 	}
 	if !updated {
-		logger.Errorw(ctx, "standalone metric support not updated", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "metricName": aMetricName})
+		logger.Errorw(ctx, "standalone metric support not updated", log.Fields{"device-id": mm.deviceID, "metricName": aMetricName})
 		return fmt.Errorf("internal-error-during-standalone-support-update--metricname-%s", aMetricName)
 	}
 	return nil
 }
 
-func (mm *onuMetricsManager) collectAllGroupAndStandaloneMetrics(ctx context.Context) {
-	if mm.pDeviceHandler.pmConfigs.Grouped { // metrics are managed as a group.
+// CollectAllGroupAndStandaloneMetrics - TODO: add comment
+func (mm *OnuMetricsManager) CollectAllGroupAndStandaloneMetrics(ctx context.Context) {
+	if mm.pDeviceHandler.GetPmConfigs().Grouped { // metrics are managed as a group.
 		go mm.collectAllGroupMetrics(ctx)
 	} else {
 		go mm.collectAllStandaloneMetrics(ctx)
 	}
 }
 
-func (mm *onuMetricsManager) collectAllGroupMetrics(ctx context.Context) {
+func (mm *OnuMetricsManager) collectAllGroupMetrics(ctx context.Context) {
 	go func() {
 		logger.Debug(ctx, "startCollector before collecting optical metrics")
 		metricInfo, err := mm.collectOpticalMetrics(ctx)
 		if err != nil {
 			logger.Errorw(ctx, "collectOpticalMetrics failed",
-				log.Fields{"device-id": mm.pAdaptFsm.deviceID, "Error": err})
+				log.Fields{"device-id": mm.deviceID, "Error": err})
 			return
 		}
 		if metricInfo != nil {
@@ -662,7 +677,7 @@
 		metricInfo, err := mm.collectUniStatusMetrics(ctx)
 		if err != nil {
 			logger.Errorw(ctx, "collectOpticalMetrics failed",
-				log.Fields{"device-id": mm.pAdaptFsm.deviceID, "Error": err})
+				log.Fields{"device-id": mm.deviceID, "Error": err})
 			return
 		}
 		if metricInfo != nil {
@@ -673,11 +688,12 @@
 	// Add more here
 }
 
-func (mm *onuMetricsManager) collectAllStandaloneMetrics(ctx context.Context) {
+func (mm *OnuMetricsManager) collectAllStandaloneMetrics(ctx context.Context) {
 	// None exists as of now, add when available here
 }
 
-func (mm *onuMetricsManager) collectGroupMetric(ctx context.Context, groupName string) {
+// CollectGroupMetric - TODO: add comment
+func (mm *OnuMetricsManager) CollectGroupMetric(ctx context.Context, groupName string) {
 	switch groupName {
 	case OpticalPowerGroupMetricName:
 		go func() {
@@ -692,67 +708,68 @@
 			}
 		}()
 	default:
-		logger.Errorw(ctx, "unhandled group metric name", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "groupName": groupName})
+		logger.Errorw(ctx, "unhandled group metric name", log.Fields{"device-id": mm.deviceID, "groupName": groupName})
 	}
 }
 
-func (mm *onuMetricsManager) collectStandaloneMetric(ctx context.Context, metricName string) {
+// CollectStandaloneMetric - TODO: add comment
+func (mm *OnuMetricsManager) CollectStandaloneMetric(ctx context.Context, metricName string) {
 	switch metricName {
 	// None exist as of now, add when available
 	default:
-		logger.Errorw(ctx, "unhandled standalone metric name", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "metricName": metricName})
+		logger.Errorw(ctx, "unhandled standalone metric name", log.Fields{"device-id": mm.deviceID, "metricName": metricName})
 	}
 }
 
 // collectOpticalMetrics collects groups metrics related to optical power from ani-g ME.
-func (mm *onuMetricsManager) collectOpticalMetrics(ctx context.Context) ([]*voltha.MetricInformation, error) {
-	logger.Debugw(ctx, "collectOpticalMetrics", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+func (mm *OnuMetricsManager) collectOpticalMetrics(ctx context.Context) ([]*voltha.MetricInformation, error) {
+	logger.Debugw(ctx, "collectOpticalMetrics", log.Fields{"device-id": mm.deviceID})
 
-	mm.onuMetricsManagerLock.RLock()
-	if !mm.groupMetricMap[OpticalPowerGroupMetricName].enabled {
-		mm.onuMetricsManagerLock.RUnlock()
-		logger.Debugw(ctx, "optical power group metric is not enabled", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+	mm.OnuMetricsManagerLock.RLock()
+	if !mm.GroupMetricMap[OpticalPowerGroupMetricName].Enabled {
+		mm.OnuMetricsManagerLock.RUnlock()
+		logger.Debugw(ctx, "optical power group metric is not enabled", log.Fields{"device-id": mm.deviceID})
 		return nil, nil
 	}
-	mm.onuMetricsManagerLock.RUnlock()
+	mm.OnuMetricsManagerLock.RUnlock()
 
 	var metricInfoSlice []*voltha.MetricInformation
 	metricsContext := make(map[string]string)
-	metricsContext["onuID"] = fmt.Sprintf("%d", mm.pDeviceHandler.device.ProxyAddress.OnuId)
-	metricsContext["intfID"] = fmt.Sprintf("%d", mm.pDeviceHandler.device.ProxyAddress.ChannelId)
-	metricsContext["devicetype"] = mm.pDeviceHandler.DeviceType
+	metricsContext["onuID"] = fmt.Sprintf("%d", mm.pDeviceHandler.GetProxyAddress().OnuId)
+	metricsContext["intfID"] = fmt.Sprintf("%d", mm.pDeviceHandler.GetProxyAddress().ChannelId)
+	metricsContext["devicetype"] = mm.pDeviceHandler.GetDeviceType()
 
 	raisedTs := time.Now().Unix()
 	mmd := voltha.MetricMetaData{
 		Title:           OpticalPowerGroupMetricName,
 		Ts:              float64(raisedTs),
 		Context:         metricsContext,
-		DeviceId:        mm.pDeviceHandler.deviceID,
-		LogicalDeviceId: mm.pDeviceHandler.logicalDeviceID,
-		SerialNo:        mm.pDeviceHandler.device.SerialNumber,
+		DeviceId:        mm.deviceID,
+		LogicalDeviceId: mm.pDeviceHandler.GetLogicalDeviceID(),
+		SerialNo:        mm.pDeviceHandler.GetDevice().SerialNumber,
 	}
 
 	// get the ANI-G instance IDs
-	anigInstKeys := mm.pDeviceHandler.pOnuOmciDevice.pOnuDB.getSortedInstKeys(ctx, me.AniGClassID)
+	anigInstKeys := mm.pOnuDeviceEntry.GetOnuDB().GetSortedInstKeys(ctx, me.AniGClassID)
 loop:
 	for _, anigInstID := range anigInstKeys {
 		var meAttributes me.AttributeValueMap
 		opticalMetrics := make(map[string]float32)
 		// Get the ANI-G instance optical power attributes
 		requestedAttributes := me.AttributeValueMap{"OpticalSignalLevel": 0, "TransmitOpticalLevel": 0}
-		meInstance, err := mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.sendGetMe(ctx, me.AniGClassID, anigInstID, requestedAttributes, mm.pDeviceHandler.pOpenOnuAc.omciTimeout, true, mm.pAdaptFsm.commChan)
+		meInstance, err := mm.pOnuDeviceEntry.GetDevOmciCC().SendGetMe(ctx, me.AniGClassID, anigInstID, requestedAttributes, mm.pDeviceHandler.GetOmciTimeout(), true, mm.PAdaptFsm.CommChan)
 		if err != nil {
-			logger.Errorw(ctx, "GetMe failed, failure PM FSM!", log.Fields{"device-id": mm.pAdaptFsm.deviceID})
-			_ = mm.pAdaptFsm.pFsm.Event(l2PmEventFailure)
+			logger.Errorw(ctx, "GetMe failed, failure PM FSM!", log.Fields{"device-id": mm.deviceID})
+			_ = mm.PAdaptFsm.PFsm.Event(L2PmEventFailure)
 			return nil, err
 		}
 
 		if meInstance != nil {
 			select {
 			case meAttributes = <-mm.opticalMetricsChan:
-				logger.Debugw(ctx, "received optical metrics", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
-			case <-time.After(mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.GetMaxOmciTimeoutWithRetries() * time.Second):
-				logger.Errorw(ctx, "timeout waiting for omci-get response for optical metrics", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+				logger.Debugw(ctx, "received optical metrics", log.Fields{"device-id": mm.deviceID})
+			case <-time.After(mm.pOnuDeviceEntry.GetDevOmciCC().GetMaxOmciTimeoutWithRetries() * time.Second):
+				logger.Errorw(ctx, "timeout waiting for omci-get response for optical metrics", log.Fields{"device-id": mm.deviceID})
 				// The metrics will be empty in this case
 				break loop
 			}
@@ -765,11 +782,11 @@
 					}
 				case "transmit_power_dBm":
 					if val, ok := meAttributes["TransmitOpticalLevel"]; ok && val != nil {
-						opticalMetrics[k] = float32(math.Round((float64(TwosComplementToSignedInt16(val.(uint16)))/500.0)*10) / 10) // convert to dBm rounded of to single decimal place
+						opticalMetrics[k] = float32(math.Round((float64(cmn.TwosComplementToSignedInt16(val.(uint16)))/500.0)*10) / 10) // convert to dBm rounded of to single decimal place
 					}
 				case "receive_power_dBm":
 					if val, ok := meAttributes["OpticalSignalLevel"]; ok && val != nil {
-						opticalMetrics[k] = float32(math.Round((float64(TwosComplementToSignedInt16(val.(uint16)))/500.0)*10) / 10) // convert to dBm rounded of to single decimal place
+						opticalMetrics[k] = float32(math.Round((float64(cmn.TwosComplementToSignedInt16(val.(uint16)))/500.0)*10) / 10) // convert to dBm rounded of to single decimal place
 					}
 				default:
 					// do nothing
@@ -787,34 +804,34 @@
 
 // collectUniStatusMetrics collects UNI status group metric from various MEs (uni-g, pptp and veip).
 // nolint: gocyclo
-func (mm *onuMetricsManager) collectUniStatusMetrics(ctx context.Context) ([]*voltha.MetricInformation, error) {
-	logger.Debugw(ctx, "collectUniStatusMetrics", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
-	mm.onuMetricsManagerLock.RLock()
-	if !mm.groupMetricMap[UniStatusGroupMetricName].enabled {
-		mm.onuMetricsManagerLock.RUnlock()
-		logger.Debugw(ctx, "uni status group metric is not enabled", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+func (mm *OnuMetricsManager) collectUniStatusMetrics(ctx context.Context) ([]*voltha.MetricInformation, error) {
+	logger.Debugw(ctx, "collectUniStatusMetrics", log.Fields{"device-id": mm.deviceID})
+	mm.OnuMetricsManagerLock.RLock()
+	if !mm.GroupMetricMap[UniStatusGroupMetricName].Enabled {
+		mm.OnuMetricsManagerLock.RUnlock()
+		logger.Debugw(ctx, "uni status group metric is not enabled", log.Fields{"device-id": mm.deviceID})
 		return nil, nil
 	}
-	mm.onuMetricsManagerLock.RUnlock()
+	mm.OnuMetricsManagerLock.RUnlock()
 
 	var metricInfoSlice []*voltha.MetricInformation
 	metricsContext := make(map[string]string)
-	metricsContext["onuID"] = fmt.Sprintf("%d", mm.pDeviceHandler.device.ProxyAddress.OnuId)
-	metricsContext["intfID"] = fmt.Sprintf("%d", mm.pDeviceHandler.device.ProxyAddress.ChannelId)
-	metricsContext["devicetype"] = mm.pDeviceHandler.DeviceType
+	metricsContext["onuID"] = fmt.Sprintf("%d", mm.pDeviceHandler.GetDevice().ProxyAddress.OnuId)
+	metricsContext["intfID"] = fmt.Sprintf("%d", mm.pDeviceHandler.GetDevice().ProxyAddress.ChannelId)
+	metricsContext["devicetype"] = mm.pDeviceHandler.GetDeviceType()
 
 	raisedTs := time.Now().Unix()
 	mmd := voltha.MetricMetaData{
 		Title:           UniStatusGroupMetricName,
 		Ts:              float64(raisedTs),
 		Context:         metricsContext,
-		DeviceId:        mm.pDeviceHandler.deviceID,
-		LogicalDeviceId: mm.pDeviceHandler.logicalDeviceID,
-		SerialNo:        mm.pDeviceHandler.device.SerialNumber,
+		DeviceId:        mm.deviceID,
+		LogicalDeviceId: mm.pDeviceHandler.GetLogicalDeviceID(),
+		SerialNo:        mm.pDeviceHandler.GetDevice().SerialNumber,
 	}
 
 	// get the UNI-G instance IDs
-	unigInstKeys := mm.pDeviceHandler.pOnuOmciDevice.pOnuDB.getSortedInstKeys(ctx, me.UniGClassID)
+	unigInstKeys := mm.pOnuDeviceEntry.GetOnuDB().GetSortedInstKeys(ctx, me.UniGClassID)
 loop1:
 	for _, unigInstID := range unigInstKeys {
 		// TODO: Include additional information in the voltha.MetricMetaData - like portno, uni-id, instance-id
@@ -823,19 +840,19 @@
 		var meAttributes me.AttributeValueMap
 		// Get the UNI-G instance optical power attributes
 		requestedAttributes := me.AttributeValueMap{"AdministrativeState": 0}
-		meInstance, err := mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.sendGetMe(ctx, me.UniGClassID, unigInstID, requestedAttributes, mm.pDeviceHandler.pOpenOnuAc.omciTimeout, true, mm.pAdaptFsm.commChan)
+		meInstance, err := mm.pOnuDeviceEntry.GetDevOmciCC().SendGetMe(ctx, me.UniGClassID, unigInstID, requestedAttributes, mm.pDeviceHandler.GetOmciTimeout(), true, mm.PAdaptFsm.CommChan)
 		if err != nil {
-			logger.Errorw(ctx, "UNI-G failed, failure PM FSM!", log.Fields{"device-id": mm.pAdaptFsm.deviceID})
-			_ = mm.pAdaptFsm.pFsm.Event(l2PmEventFailure)
+			logger.Errorw(ctx, "UNI-G failed, failure PM FSM!", log.Fields{"device-id": mm.deviceID})
+			_ = mm.PAdaptFsm.PFsm.Event(L2PmEventFailure)
 			return nil, err
 		}
 		if meInstance != nil {
 			// Wait for metrics or timeout
 			select {
 			case meAttributes = <-mm.uniStatusMetricsChan:
-				logger.Debugw(ctx, "received uni-g metrics", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
-			case <-time.After(mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.GetMaxOmciTimeoutWithRetries() * time.Second):
-				logger.Errorw(ctx, "timeout waiting for omci-get response for uni status", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+				logger.Debugw(ctx, "received uni-g metrics", log.Fields{"device-id": mm.deviceID})
+			case <-time.After(mm.pOnuDeviceEntry.GetDevOmciCC().GetMaxOmciTimeoutWithRetries() * time.Second):
+				logger.Errorw(ctx, "timeout waiting for omci-get response for uni status", log.Fields{"device-id": mm.deviceID})
 				// The metrics could be empty in this case
 				break loop1
 			}
@@ -854,9 +871,9 @@
 				entityID := val.(uint16)
 				unigMetrics["entity_id"] = float32(entityID)
 				// TODO: Rlock needed for reading uniEntityMap? May not be needed given uniEntityMap is populated setup at initial ONU bring up
-				for _, uni := range mm.pDeviceHandler.uniEntityMap {
-					if uni.entityID == entityID {
-						unigMetrics["uni_port_no"] = float32(uni.portNo)
+				for _, uni := range *mm.pDeviceHandler.GetUniEntityMap() {
+					if uni.EntityID == entityID {
+						unigMetrics["uni_port_no"] = float32(uni.PortNo)
 						break
 					}
 				}
@@ -870,7 +887,7 @@
 	}
 
 	// get the PPTP instance IDs
-	pptpInstKeys := mm.pDeviceHandler.pOnuOmciDevice.pOnuDB.getSortedInstKeys(ctx, me.PhysicalPathTerminationPointEthernetUniClassID)
+	pptpInstKeys := mm.pOnuDeviceEntry.GetOnuDB().GetSortedInstKeys(ctx, me.PhysicalPathTerminationPointEthernetUniClassID)
 loop2:
 	for _, pptpInstID := range pptpInstKeys {
 		// TODO: Include additional information in the voltha.MetricMetaData - like portno, uni-id, instance-id
@@ -879,19 +896,19 @@
 		pptpMetrics := make(map[string]float32)
 
 		requestedAttributes := me.AttributeValueMap{"ConfigurationInd": 0, "OperationalState": 0, "AdministrativeState": 0}
-		meInstance, err := mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.sendGetMe(ctx, me.PhysicalPathTerminationPointEthernetUniClassID, pptpInstID, requestedAttributes, mm.pDeviceHandler.pOpenOnuAc.omciTimeout, true, mm.pAdaptFsm.commChan)
+		meInstance, err := mm.pOnuDeviceEntry.GetDevOmciCC().SendGetMe(ctx, me.PhysicalPathTerminationPointEthernetUniClassID, pptpInstID, requestedAttributes, mm.pDeviceHandler.GetOmciTimeout(), true, mm.PAdaptFsm.CommChan)
 		if err != nil {
-			logger.Errorw(ctx, "GetMe failed, failure PM FSM!", log.Fields{"device-id": mm.pAdaptFsm.deviceID})
-			_ = mm.pAdaptFsm.pFsm.Event(l2PmEventFailure)
+			logger.Errorw(ctx, "GetMe failed, failure PM FSM!", log.Fields{"device-id": mm.deviceID})
+			_ = mm.PAdaptFsm.PFsm.Event(L2PmEventFailure)
 			return nil, err
 		}
 		if meInstance != nil {
 			// Wait for metrics or timeout
 			select {
 			case meAttributes = <-mm.uniStatusMetricsChan:
-				logger.Debugw(ctx, "received pptp metrics", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
-			case <-time.After(mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.GetMaxOmciTimeoutWithRetries() * time.Second):
-				logger.Errorw(ctx, "timeout waiting for omci-get response for uni status", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+				logger.Debugw(ctx, "received pptp metrics", log.Fields{"device-id": mm.deviceID})
+			case <-time.After(mm.pOnuDeviceEntry.GetDevOmciCC().GetMaxOmciTimeoutWithRetries() * time.Second):
+				logger.Errorw(ctx, "timeout waiting for omci-get response for uni status", log.Fields{"device-id": mm.deviceID})
 				// The metrics could be empty in this case
 				break loop2
 			}
@@ -920,9 +937,9 @@
 			entityID := val.(uint16)
 			pptpMetrics["entity_id"] = float32(entityID)
 			// TODO: Rlock needed for reading uniEntityMap? May not be needed given uniEntityMap is populated setup at initial ONU bring up
-			for _, uni := range mm.pDeviceHandler.uniEntityMap {
-				if uni.entityID == entityID {
-					pptpMetrics["uni_port_no"] = float32(uni.portNo)
+			for _, uni := range *mm.pDeviceHandler.GetUniEntityMap() {
+				if uni.EntityID == entityID {
+					pptpMetrics["uni_port_no"] = float32(uni.PortNo)
 					break
 				}
 			}
@@ -935,7 +952,7 @@
 	}
 
 	// get the VEIP instance IDs
-	veipInstKeys := mm.pDeviceHandler.pOnuOmciDevice.pOnuDB.getSortedInstKeys(ctx, me.VirtualEthernetInterfacePointClassID)
+	veipInstKeys := mm.pOnuDeviceEntry.GetOnuDB().GetSortedInstKeys(ctx, me.VirtualEthernetInterfacePointClassID)
 loop3:
 	for _, veipInstID := range veipInstKeys {
 		// TODO: Include additional information in the voltha.MetricMetaData - like portno, uni-id, instance-id
@@ -944,19 +961,19 @@
 		veipMetrics := make(map[string]float32)
 
 		requestedAttributes := me.AttributeValueMap{"OperationalState": 0, "AdministrativeState": 0}
-		meInstance, err := mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.sendGetMe(ctx, me.VirtualEthernetInterfacePointClassID, veipInstID, requestedAttributes, mm.pDeviceHandler.pOpenOnuAc.omciTimeout, true, mm.pAdaptFsm.commChan)
+		meInstance, err := mm.pOnuDeviceEntry.GetDevOmciCC().SendGetMe(ctx, me.VirtualEthernetInterfacePointClassID, veipInstID, requestedAttributes, mm.pDeviceHandler.GetOmciTimeout(), true, mm.PAdaptFsm.CommChan)
 		if err != nil {
-			logger.Errorw(ctx, "GetMe failed, failure PM FSM!", log.Fields{"device-id": mm.pAdaptFsm.deviceID})
-			_ = mm.pAdaptFsm.pFsm.Event(l2PmEventFailure)
+			logger.Errorw(ctx, "GetMe failed, failure PM FSM!", log.Fields{"device-id": mm.deviceID})
+			_ = mm.PAdaptFsm.PFsm.Event(L2PmEventFailure)
 			return nil, err
 		}
 		if meInstance != nil {
 			// Wait for metrics or timeout
 			select {
 			case meAttributes = <-mm.uniStatusMetricsChan:
-				logger.Debugw(ctx, "received veip metrics", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
-			case <-time.After(mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.GetMaxOmciTimeoutWithRetries() * time.Second):
-				logger.Errorw(ctx, "timeout waiting for omci-get response for uni status", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+				logger.Debugw(ctx, "received veip metrics", log.Fields{"device-id": mm.deviceID})
+			case <-time.After(mm.pOnuDeviceEntry.GetDevOmciCC().GetMaxOmciTimeoutWithRetries() * time.Second):
+				logger.Errorw(ctx, "timeout waiting for omci-get response for uni status", log.Fields{"device-id": mm.deviceID})
 				// The metrics could be empty in this case
 				break loop3
 			}
@@ -982,9 +999,9 @@
 			entityID := val.(uint16)
 			veipMetrics["entity_id"] = float32(entityID)
 			// TODO: Rlock needed for reading uniEntityMap? May not be needed given uniEntityMap is populated setup at initial ONU bring up
-			for _, uni := range mm.pDeviceHandler.uniEntityMap {
-				if uni.entityID == entityID {
-					veipMetrics["uni_port_no"] = float32(uni.portNo)
+			for _, uni := range *mm.pDeviceHandler.GetUniEntityMap() {
+				if uni.EntityID == entityID {
+					veipMetrics["uni_port_no"] = float32(uni.PortNo)
 					break
 				}
 			}
@@ -1000,53 +1017,54 @@
 }
 
 // publishMetrics publishes the metrics on kafka
-func (mm *onuMetricsManager) publishMetrics(ctx context.Context, metricInfo []*voltha.MetricInformation) {
+func (mm *OnuMetricsManager) publishMetrics(ctx context.Context, metricInfo []*voltha.MetricInformation) {
 	var ke voltha.KpiEvent2
 	ts := time.Now().Unix()
 	ke.SliceData = metricInfo
 	ke.Type = voltha.KpiEventType_slice
 	ke.Ts = float64(ts)
 
-	if err := mm.pDeviceHandler.EventProxy.SendKpiEvent(ctx, "STATS_EVENT", &ke, voltha.EventCategory_EQUIPMENT, voltha.EventSubCategory_ONU, ts); err != nil {
+	if err := mm.pDeviceHandler.GetEventProxy().SendKpiEvent(ctx, "STATS_EVENT", &ke, voltha.EventCategory_EQUIPMENT, voltha.EventSubCategory_ONU, ts); err != nil {
 		logger.Errorw(ctx, "failed-to-send-pon-stats", log.Fields{"err": err})
 	}
 }
 
-func (mm *onuMetricsManager) processOmciMessages(ctx context.Context) {
-	logger.Infow(ctx, "Start routine to process OMCI-GET messages for device-id", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+// ProcessOmciMessages - TODO: add comment
+func (mm *OnuMetricsManager) ProcessOmciMessages(ctx context.Context) {
+	logger.Infow(ctx, "Start routine to process OMCI-GET messages for device-id", log.Fields{"device-id": mm.deviceID})
 	// Flush metric collection channels to be safe.
-	// It is possible that there is stale data on this channel if the processOmciMessages routine
+	// It is possible that there is stale data on this channel if the ProcessOmciMessages routine
 	// is stopped right after issuing a OMCI-GET request and started again.
-	// The processOmciMessages routine will get stopped if startCollector routine (in device_handler.go)
+	// The ProcessOmciMessages routine will get stopped if startCollector routine (in device_handler.go)
 	// is stopped - as a result of ONU going down.
 	mm.flushMetricCollectionChannels(ctx)
 	mm.updateOmciProcessingStatus(true)
 	for {
 		select {
-		case <-mm.stopProcessingOmciResponses: // stop this routine
-			logger.Infow(ctx, "Stop routine to process OMCI-GET messages for device-id", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+		case <-mm.StopProcessingOmciResponses: // stop this routine
+			logger.Infow(ctx, "Stop routine to process OMCI-GET messages for device-id", log.Fields{"device-id": mm.deviceID})
 			mm.updateOmciProcessingStatus(false)
 			return
-		case message, ok := <-mm.pAdaptFsm.commChan:
+		case message, ok := <-mm.PAdaptFsm.CommChan:
 			if !ok {
-				logger.Errorw(ctx, "Message couldn't be read from channel", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+				logger.Errorw(ctx, "Message couldn't be read from channel", log.Fields{"device-id": mm.deviceID})
 				continue
 			}
-			logger.Debugw(ctx, "Received message on ONU metrics channel", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+			logger.Debugw(ctx, "Received message on ONU metrics channel", log.Fields{"device-id": mm.deviceID})
 
 			switch message.Type {
-			case OMCI:
-				msg, _ := message.Data.(OmciMessage)
+			case cmn.OMCI:
+				msg, _ := message.Data.(cmn.OmciMessage)
 				mm.handleOmciMessage(ctx, msg)
 			default:
-				logger.Warn(ctx, "Unknown message type received", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "message.Type": message.Type})
+				logger.Warn(ctx, "Unknown message type received", log.Fields{"device-id": mm.deviceID, "message.Type": message.Type})
 			}
 		}
 	}
 }
 
-func (mm *onuMetricsManager) handleOmciMessage(ctx context.Context, msg OmciMessage) {
-	logger.Debugw(ctx, "omci Msg", log.Fields{"device-id": mm.pDeviceHandler.deviceID,
+func (mm *OnuMetricsManager) handleOmciMessage(ctx context.Context, msg cmn.OmciMessage) {
+	logger.Debugw(ctx, "omci Msg", log.Fields{"device-id": mm.deviceID,
 		"msgType": msg.OmciMsg.MessageType, "msg": msg})
 	switch msg.OmciMsg.MessageType {
 	case omci.GetResponseType:
@@ -1066,18 +1084,18 @@
 	}
 }
 
-func (mm *onuMetricsManager) handleOmciGetResponseMessage(ctx context.Context, msg OmciMessage) error {
+func (mm *OnuMetricsManager) handleOmciGetResponseMessage(ctx context.Context, msg cmn.OmciMessage) error {
 	msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeGetResponse)
 	if msgLayer == nil {
-		logger.Errorw(ctx, "omci Msg layer could not be detected for GetResponse - handling stopped", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
-		return fmt.Errorf("omci Msg layer could not be detected for GetResponse - handling stopped: %s", mm.pDeviceHandler.deviceID)
+		logger.Errorw(ctx, "omci Msg layer could not be detected for GetResponse - handling stopped", log.Fields{"device-id": mm.deviceID})
+		return fmt.Errorf("omci Msg layer could not be detected for GetResponse - handling stopped: %s", mm.deviceID)
 	}
 	msgObj, msgOk := msgLayer.(*omci.GetResponse)
 	if !msgOk {
-		logger.Errorw(ctx, "omci Msg layer could not be assigned for GetResponse - handling stopped", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
-		return fmt.Errorf("omci Msg layer could not be assigned for GetResponse - handling stopped: %s", mm.pDeviceHandler.deviceID)
+		logger.Errorw(ctx, "omci Msg layer could not be assigned for GetResponse - handling stopped", log.Fields{"device-id": mm.deviceID})
+		return fmt.Errorf("omci Msg layer could not be assigned for GetResponse - handling stopped: %s", mm.deviceID)
 	}
-	logger.Debugw(ctx, "OMCI GetResponse Data", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "data-fields": msgObj, "result": msgObj.Result})
+	logger.Debugw(ctx, "OMCI GetResponse Data", log.Fields{"device-id": mm.deviceID, "data-fields": msgObj, "result": msgObj.Result})
 	if msgObj.Result == me.Success {
 		meAttributes := msgObj.Attributes
 		switch msgObj.EntityClass {
@@ -1106,7 +1124,7 @@
 			return nil
 		default:
 			logger.Errorw(ctx, "unhandled omci get response message",
-				log.Fields{"device-id": mm.pDeviceHandler.deviceID, "class-id": msgObj.EntityClass})
+				log.Fields{"device-id": mm.deviceID, "class-id": msgObj.EntityClass})
 		}
 	} else {
 		meAttributes := msgObj.Attributes
@@ -1119,24 +1137,24 @@
 			return nil
 		default:
 			logger.Errorw(ctx, "unhandled omci get response message",
-				log.Fields{"device-id": mm.pDeviceHandler.deviceID, "class-id": msgObj.EntityClass})
+				log.Fields{"device-id": mm.deviceID, "class-id": msgObj.EntityClass})
 		}
 	}
 	return fmt.Errorf("unhandled-omci-get-response-message")
 }
 
-func (mm *onuMetricsManager) handleOmciGetCurrentDataResponseMessage(ctx context.Context, msg OmciMessage) error {
+func (mm *OnuMetricsManager) handleOmciGetCurrentDataResponseMessage(ctx context.Context, msg cmn.OmciMessage) error {
 	msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeGetCurrentDataResponse)
 	if msgLayer == nil {
-		logger.Errorw(ctx, "omci Msg layer could not be detected for GetCurrentDataResponse - handling stopped", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
-		return fmt.Errorf("omci Msg layer could not be detected for GetCurrentDataResponse - handling stopped: %s", mm.pDeviceHandler.deviceID)
+		logger.Errorw(ctx, "omci Msg layer could not be detected for GetCurrentDataResponse - handling stopped", log.Fields{"device-id": mm.deviceID})
+		return fmt.Errorf("omci Msg layer could not be detected for GetCurrentDataResponse - handling stopped: %s", mm.deviceID)
 	}
 	msgObj, msgOk := msgLayer.(*omci.GetCurrentDataResponse)
 	if !msgOk {
-		logger.Errorw(ctx, "omci Msg layer could not be assigned for GetCurrentDataResponse - handling stopped", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
-		return fmt.Errorf("omci Msg layer could not be assigned for GetCurrentDataResponse - handling stopped: %s", mm.pDeviceHandler.deviceID)
+		logger.Errorw(ctx, "omci Msg layer could not be assigned for GetCurrentDataResponse - handling stopped", log.Fields{"device-id": mm.deviceID})
+		return fmt.Errorf("omci Msg layer could not be assigned for GetCurrentDataResponse - handling stopped: %s", mm.deviceID)
 	}
-	logger.Debugw(ctx, "OMCI GetCurrentDataResponse Data", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "data-fields": msgObj, "result": msgObj.Result})
+	logger.Debugw(ctx, "OMCI GetCurrentDataResponse Data", log.Fields{"device-id": mm.deviceID, "data-fields": msgObj, "result": msgObj.Result})
 	if msgObj.Result == me.Success {
 		meAttributes := msgObj.Attributes
 		switch msgObj.EntityClass {
@@ -1146,7 +1164,7 @@
 			return nil
 		default:
 			logger.Errorw(ctx, "unhandled omci get current data response message",
-				log.Fields{"device-id": mm.pDeviceHandler.deviceID, "class-id": msgObj.EntityClass})
+				log.Fields{"device-id": mm.deviceID, "class-id": msgObj.EntityClass})
 		}
 	} else {
 		meAttributes := msgObj.Attributes
@@ -1159,33 +1177,33 @@
 			return nil
 		default:
 			logger.Errorw(ctx, "unhandled omci get current data response message",
-				log.Fields{"device-id": mm.pDeviceHandler.deviceID, "class-id": msgObj.EntityClass})
+				log.Fields{"device-id": mm.deviceID, "class-id": msgObj.EntityClass})
 		}
 	}
 	return fmt.Errorf("unhandled-omci-get-current-data-response-message")
 }
 
-func (mm *onuMetricsManager) handleOmciSynchronizeTimeResponseMessage(ctx context.Context, msg OmciMessage) error {
+func (mm *OnuMetricsManager) handleOmciSynchronizeTimeResponseMessage(ctx context.Context, msg cmn.OmciMessage) error {
 	msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeSynchronizeTimeResponse)
 	if msgLayer == nil {
-		logger.Errorw(ctx, "omci Msg layer could not be detected for synchronize time response - handling stopped", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
-		return fmt.Errorf("omci Msg layer could not be detected for synchronize time response - handling stopped: %s", mm.pDeviceHandler.deviceID)
+		logger.Errorw(ctx, "omci Msg layer could not be detected for synchronize time response - handling stopped", log.Fields{"device-id": mm.deviceID})
+		return fmt.Errorf("omci Msg layer could not be detected for synchronize time response - handling stopped: %s", mm.deviceID)
 	}
 	msgObj, msgOk := msgLayer.(*omci.SynchronizeTimeResponse)
 	if !msgOk {
-		logger.Errorw(ctx, "omci Msg layer could not be assigned for synchronize time response - handling stopped", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
-		return fmt.Errorf("omci Msg layer could not be assigned for synchronize time response - handling stopped: %s", mm.pDeviceHandler.deviceID)
+		logger.Errorw(ctx, "omci Msg layer could not be assigned for synchronize time response - handling stopped", log.Fields{"device-id": mm.deviceID})
+		return fmt.Errorf("omci Msg layer could not be assigned for synchronize time response - handling stopped: %s", mm.deviceID)
 	}
-	logger.Debugw(ctx, "OMCI synchronize time response Data", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "data-fields": msgObj})
+	logger.Debugw(ctx, "OMCI synchronize time response Data", log.Fields{"device-id": mm.deviceID, "data-fields": msgObj})
 	if msgObj.Result == me.Success {
 		switch msgObj.EntityClass {
 		case me.OnuGClassID:
-			logger.Infow(ctx, "omci synchronize time success", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+			logger.Infow(ctx, "omci synchronize time success", log.Fields{"device-id": mm.deviceID})
 			mm.syncTimeResponseChan <- true
 			return nil
 		default:
 			logger.Errorw(ctx, "unhandled omci message",
-				log.Fields{"device-id": mm.pDeviceHandler.deviceID, "class-id": msgObj.EntityClass})
+				log.Fields{"device-id": mm.deviceID, "class-id": msgObj.EntityClass})
 		}
 	}
 	mm.syncTimeResponseChan <- false
@@ -1194,10 +1212,10 @@
 }
 
 // flushMetricCollectionChannels flushes all metric collection channels for any stale OMCI responses
-func (mm *onuMetricsManager) flushMetricCollectionChannels(ctx context.Context) {
+func (mm *OnuMetricsManager) flushMetricCollectionChannels(ctx context.Context) {
 	// flush commMetricsChan
 	select {
-	case <-mm.pAdaptFsm.commChan:
+	case <-mm.PAdaptFsm.CommChan:
 		logger.Debug(ctx, "flushed common metrics channel")
 	default:
 	}
@@ -1230,10 +1248,10 @@
 	default:
 	}
 
-	// flush stopTicks
+	// flush StopTicks
 	select {
-	case <-mm.stopTicks:
-		logger.Debug(ctx, "flushed stopTicks channel")
+	case <-mm.StopTicks:
+		logger.Debug(ctx, "flushed StopTicks channel")
 	default:
 	}
 
@@ -1241,17 +1259,17 @@
 
 // ** L2 PM FSM Handlers start **
 
-func (mm *onuMetricsManager) l2PMFsmStarting(ctx context.Context, e *fsm.Event) {
+func (mm *OnuMetricsManager) l2PMFsmStarting(ctx context.Context, e *fsm.Event) {
 
 	// Loop through all the group metrics
 	// If it is a L2 PM Interval metric and it is enabled, then if it is not in the
 	// list of active L2 PM list then mark it for creation
 	// It it is a L2 PM Interval metric and it is disabled, then if it is in the
 	// list of active L2 PM list then mark it for deletion
-	mm.onuMetricsManagerLock.Lock()
-	for n, g := range mm.groupMetricMap {
-		if g.isL2PMCounter { // it is a l2 pm counter
-			if g.enabled { // metric enabled.
+	mm.OnuMetricsManagerLock.Lock()
+	for n, g := range mm.GroupMetricMap {
+		if g.IsL2PMCounter { // it is a l2 pm counter
+			if g.Enabled { // metric enabled.
 				found := false
 			inner1:
 				for _, v := range mm.activeL2Pms {
@@ -1278,25 +1296,25 @@
 			}
 		}
 	}
-	mm.onuMetricsManagerLock.Unlock()
+	mm.OnuMetricsManagerLock.Unlock()
 	logger.Debugw(ctx, "pms to add and delete",
-		log.Fields{"device-id": mm.pDeviceHandler.deviceID, "pms-to-add": mm.l2PmToAdd, "pms-to-delete": mm.l2PmToDelete})
+		log.Fields{"device-id": mm.deviceID, "pms-to-add": mm.l2PmToAdd, "pms-to-delete": mm.l2PmToDelete})
 	go func() {
 		// push a tick event to move to next state
-		if err := mm.pAdaptFsm.pFsm.Event(l2PmEventTick); err != nil {
-			logger.Errorw(ctx, "error calling event", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "err": err})
+		if err := mm.PAdaptFsm.PFsm.Event(L2PmEventTick); err != nil {
+			logger.Errorw(ctx, "error calling event", log.Fields{"device-id": mm.deviceID, "err": err})
 		}
 	}()
 }
 
-func (mm *onuMetricsManager) l2PMFsmSyncTime(ctx context.Context, e *fsm.Event) {
+func (mm *OnuMetricsManager) l2PMFsmSyncTime(ctx context.Context, e *fsm.Event) {
 	// Sync time with the ONU to establish 15min boundary for PM collection.
 	if err := mm.syncTime(ctx); err != nil {
 		go func() {
 			time.Sleep(SyncTimeRetryInterval * time.Second) // retry to sync time after this timeout
 			// This will result in FSM attempting to sync time again
-			if err := mm.pAdaptFsm.pFsm.Event(l2PmEventFailure); err != nil {
-				logger.Errorw(ctx, "error calling event", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "err": err})
+			if err := mm.PAdaptFsm.PFsm.Event(L2PmEventFailure); err != nil {
+				logger.Errorw(ctx, "error calling event", log.Fields{"device-id": mm.deviceID, "err": err})
 			}
 		}()
 	}
@@ -1304,71 +1322,71 @@
 	go mm.generateTicks(ctx)
 
 	go func() {
-		if err := mm.pAdaptFsm.pFsm.Event(l2PmEventSuccess); err != nil {
-			logger.Errorw(ctx, "error calling event", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "err": err})
+		if err := mm.PAdaptFsm.PFsm.Event(L2PmEventSuccess); err != nil {
+			logger.Errorw(ctx, "error calling event", log.Fields{"device-id": mm.deviceID, "err": err})
 		}
 	}()
 }
 
-func (mm *onuMetricsManager) l2PMFsmNull(ctx context.Context, e *fsm.Event) {
+func (mm *OnuMetricsManager) l2PMFsmNull(ctx context.Context, e *fsm.Event) {
 	// We need to reset the local data so that the L2 PM MEs are re-provisioned once the ONU is back up based on the latest PM CONFIG
-	mm.onuMetricsManagerLock.Lock()
+	mm.OnuMetricsManagerLock.Lock()
 	mm.activeL2Pms = nil
 	mm.l2PmToAdd = nil
 	mm.l2PmToDelete = nil
-	mm.onuMetricsManagerLock.Unlock()
+	mm.OnuMetricsManagerLock.Unlock()
 	// If the FSM was stopped, then clear PM data from KV store
 	// The FSM is stopped when ONU goes down. It is time to clear its data from store
-	if e.Event == l2PmEventStop {
+	if e.Event == L2PmEventStop {
 		_ = mm.clearPmGroupData(ctx) // ignore error
 	}
 
 }
-func (mm *onuMetricsManager) l2PMFsmIdle(ctx context.Context, e *fsm.Event) {
-	logger.Debugw(ctx, "Enter state idle", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+func (mm *OnuMetricsManager) l2PMFsmIdle(ctx context.Context, e *fsm.Event) {
+	logger.Debugw(ctx, "Enter state idle", log.Fields{"device-id": mm.deviceID})
 
-	mm.onuMetricsManagerLock.RLock()
+	mm.OnuMetricsManagerLock.RLock()
 	numOfPmToDelete := len(mm.l2PmToDelete)
 	numOfPmToAdd := len(mm.l2PmToAdd)
-	mm.onuMetricsManagerLock.RUnlock()
+	mm.OnuMetricsManagerLock.RUnlock()
 
 	if numOfPmToDelete > 0 {
-		logger.Debugw(ctx, "state idle - pms to delete", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "pms-to-delete": numOfPmToDelete})
+		logger.Debugw(ctx, "state idle - pms to delete", log.Fields{"device-id": mm.deviceID, "pms-to-delete": numOfPmToDelete})
 		go func() {
-			if err := mm.pAdaptFsm.pFsm.Event(l2PmEventDeleteMe); err != nil {
-				logger.Errorw(ctx, "error calling event", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "err": err})
+			if err := mm.PAdaptFsm.PFsm.Event(L2PmEventDeleteMe); err != nil {
+				logger.Errorw(ctx, "error calling event", log.Fields{"device-id": mm.deviceID, "err": err})
 			}
 		}()
 	} else if numOfPmToAdd > 0 {
-		logger.Debugw(ctx, "state idle - pms to add", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "pms-to-add": numOfPmToAdd})
+		logger.Debugw(ctx, "state idle - pms to add", log.Fields{"device-id": mm.deviceID, "pms-to-add": numOfPmToAdd})
 		go func() {
-			if err := mm.pAdaptFsm.pFsm.Event(l2PmEventAddMe); err != nil {
-				logger.Errorw(ctx, "error calling event", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "err": err})
+			if err := mm.PAdaptFsm.PFsm.Event(L2PmEventAddMe); err != nil {
+				logger.Errorw(ctx, "error calling event", log.Fields{"device-id": mm.deviceID, "err": err})
 			}
 		}()
 	}
 }
 
-func (mm *onuMetricsManager) l2PmFsmCollectData(ctx context.Context, e *fsm.Event) {
-	logger.Debugw(ctx, "state collect data", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+func (mm *OnuMetricsManager) l2PmFsmCollectData(ctx context.Context, e *fsm.Event) {
+	logger.Debugw(ctx, "state collect data", log.Fields{"device-id": mm.deviceID})
 	// Copy the activeL2Pms for which we want to collect the metrics since activeL2Pms can change dynamically
-	mm.onuMetricsManagerLock.RLock()
+	mm.OnuMetricsManagerLock.RLock()
 	copyOfActiveL2Pms := make([]string, len(mm.activeL2Pms))
 	_ = copy(copyOfActiveL2Pms, mm.activeL2Pms)
-	mm.onuMetricsManagerLock.RUnlock()
+	mm.OnuMetricsManagerLock.RUnlock()
 
 	for _, n := range copyOfActiveL2Pms {
 		var metricInfoSlice []*voltha.MetricInformation
 
-		// mm.groupMetricMap[n].pmMEData.InstancesActive could dynamically change, so make a copy
-		mm.onuMetricsManagerLock.RLock()
-		copyOfEntityIDs := make([]uint16, len(mm.groupMetricMap[n].pmMEData.InstancesActive))
-		_ = copy(copyOfEntityIDs, mm.groupMetricMap[n].pmMEData.InstancesActive)
-		mm.onuMetricsManagerLock.RUnlock()
+		// mm.GroupMetricMap[n].pmMEData.InstancesActive could dynamically change, so make a copy
+		mm.OnuMetricsManagerLock.RLock()
+		copyOfEntityIDs := make([]uint16, len(mm.GroupMetricMap[n].pmMEData.InstancesActive))
+		_ = copy(copyOfEntityIDs, mm.GroupMetricMap[n].pmMEData.InstancesActive)
+		mm.OnuMetricsManagerLock.RUnlock()
 
 		switch n {
 		case EthernetBridgeHistoryName:
-			logger.Debugw(ctx, "state collect data - collecting data for EthernetFramePerformanceMonitoringHistoryData ME", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+			logger.Debugw(ctx, "state collect data - collecting data for EthernetFramePerformanceMonitoringHistoryData ME", log.Fields{"device-id": mm.deviceID})
 			for _, entityID := range copyOfEntityIDs {
 				if metricInfo := mm.collectEthernetFramePerformanceMonitoringHistoryData(ctx, true, entityID); metricInfo != nil { // upstream
 					metricInfoSlice = append(metricInfoSlice, metricInfo)
@@ -1378,7 +1396,7 @@
 				}
 			}
 		case EthernetUniHistoryName:
-			logger.Debugw(ctx, "state collect data - collecting data for EthernetPerformanceMonitoringHistoryData ME", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+			logger.Debugw(ctx, "state collect data - collecting data for EthernetPerformanceMonitoringHistoryData ME", log.Fields{"device-id": mm.deviceID})
 			for _, entityID := range copyOfEntityIDs {
 				if metricInfo := mm.collectEthernetUniHistoryData(ctx, entityID); metricInfo != nil { // upstream
 					metricInfoSlice = append(metricInfoSlice, metricInfo)
@@ -1399,7 +1417,7 @@
 			}
 
 		default:
-			logger.Errorw(ctx, "unsupported l2 pm", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "name": n})
+			logger.Errorw(ctx, "unsupported l2 pm", log.Fields{"device-id": mm.deviceID, "name": n})
 		}
 		mm.handleMetricsPublish(ctx, n, metricInfoSlice)
 	}
@@ -1407,21 +1425,21 @@
 	// Those PMs that we failed to collect data will be attempted to collect again in the next PM collection cycle (assuming
 	// we have not exceed max attempts to collect the PM data)
 	go func() {
-		if err := mm.pAdaptFsm.pFsm.Event(l2PmEventSuccess); err != nil {
-			logger.Errorw(ctx, "error calling event", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "err": err})
+		if err := mm.PAdaptFsm.PFsm.Event(L2PmEventSuccess); err != nil {
+			logger.Errorw(ctx, "error calling event", log.Fields{"device-id": mm.deviceID, "err": err})
 		}
 	}()
 }
 
 // nolint: gocyclo
-func (mm *onuMetricsManager) l2PmFsmCreatePM(ctx context.Context, e *fsm.Event) error {
+func (mm *OnuMetricsManager) l2PmFsmCreatePM(ctx context.Context, e *fsm.Event) error {
 	// Copy the l2PmToAdd for which we want to collect the metrics since l2PmToAdd can change dynamically
-	mm.onuMetricsManagerLock.RLock()
+	mm.OnuMetricsManagerLock.RLock()
 	copyOfL2PmToAdd := make([]string, len(mm.l2PmToAdd))
 	_ = copy(copyOfL2PmToAdd, mm.l2PmToAdd)
-	mm.onuMetricsManagerLock.RUnlock()
+	mm.OnuMetricsManagerLock.RUnlock()
 
-	logger.Debugw(ctx, "state create pm - start", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "pms-to-add": copyOfL2PmToAdd})
+	logger.Debugw(ctx, "state create pm - start", log.Fields{"device-id": mm.deviceID, "pms-to-add": copyOfL2PmToAdd})
 	for _, n := range copyOfL2PmToAdd {
 		resp := false
 		atLeastOneSuccess := false // flag indicates if at least one ME instance of the PM was successfully created.
@@ -1430,26 +1448,26 @@
 		case EthernetBridgeHistoryName:
 			// Create ME twice, one for each direction. Boolean true is used to indicate upstream and false for downstream.
 			for _, direction := range []bool{true, false} {
-				for _, uniPort := range mm.pDeviceHandler.uniEntityMap {
+				for _, uniPort := range *mm.pDeviceHandler.GetUniEntityMap() {
 					// Attach the EthernetFramePerformanceMonitoringHistoryData ME to MacBridgePortConfigData on the UNI port
-					entityID := macBridgePortAniBaseEID + uniPort.entityID
+					entityID := cmn.MacBridgePortAniBaseEID + uniPort.EntityID
 					_ = mm.updatePmData(ctx, n, entityID, cPmAdd) // TODO: ignore error for now
 				inner1:
 					// retry L2PmCreateAttempts times to create the instance of PM
 					for cnt = 0; cnt < L2PmCreateAttempts; cnt++ {
-						_, err := mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.sendCreateOrDeleteEthernetPerformanceMonitoringHistoryME(
-							ctx, mm.pDeviceHandler.pOpenOnuAc.omciTimeout, true, direction, true, mm.pAdaptFsm.commChan, entityID)
+						_, err := mm.pOnuDeviceEntry.GetDevOmciCC().SendCreateOrDeleteEthernetPerformanceMonitoringHistoryME(
+							ctx, mm.pDeviceHandler.GetOmciTimeout(), true, direction, true, mm.PAdaptFsm.CommChan, entityID)
 						if err != nil {
 							logger.Errorw(ctx, "EthernetPerformanceMonitoringHistoryME create or delete failed, failure PM FSM!",
-								log.Fields{"device-id": mm.pDeviceHandler.deviceID})
-							pPMFsm := mm.pAdaptFsm
+								log.Fields{"device-id": mm.deviceID})
+							pPMFsm := mm.PAdaptFsm
 							if pPMFsm != nil {
-								go func(p_pmFsm *AdapterFsm) {
-									_ = p_pmFsm.pFsm.Event(l2PmEventFailure)
+								go func(p_pmFsm *cmn.AdapterFsm) {
+									_ = p_pmFsm.PFsm.Event(L2PmEventFailure)
 								}(pPMFsm)
 							}
 							return fmt.Errorf(fmt.Sprintf("CreateOrDeleteEthernetPerformanceMonitoringHistoryMe-failed-%s-%s",
-								mm.pDeviceHandler.deviceID, err))
+								mm.deviceID, err))
 						}
 						if resp = mm.waitForResponseOrTimeout(ctx, true, entityID, "EthernetFramePerformanceMonitoringHistoryData"); resp {
 							atLeastOneSuccess = true
@@ -1463,22 +1481,22 @@
 				}
 			}
 		case EthernetUniHistoryName:
-			for _, uniPort := range mm.pDeviceHandler.uniEntityMap {
-				if uniPort.portType == uniPPTP { // This metric is only applicable for PPTP Uni Type
+			for _, uniPort := range *mm.pDeviceHandler.GetUniEntityMap() {
+				if uniPort.PortType == cmn.UniPPTP { // This metric is only applicable for PPTP Uni Type
 					// Attach the EthernetPerformanceMonitoringHistoryData ME to PPTP port instance
-					entityID := uniPort.entityID
+					entityID := uniPort.EntityID
 					_ = mm.updatePmData(ctx, n, entityID, cPmAdd) // TODO: ignore error for now
 				inner2:
 					// retry L2PmCreateAttempts times to create the instance of PM
 					for cnt = 0; cnt < L2PmCreateAttempts; cnt++ {
-						_, err := mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.sendCreateOrDeleteEthernetUniHistoryME(
-							ctx, mm.pDeviceHandler.pOpenOnuAc.omciTimeout, true, true, mm.pAdaptFsm.commChan, entityID)
+						_, err := mm.pOnuDeviceEntry.GetDevOmciCC().SendCreateOrDeleteEthernetUniHistoryME(
+							ctx, mm.pDeviceHandler.GetOmciTimeout(), true, true, mm.PAdaptFsm.CommChan, entityID)
 						if err != nil {
 							logger.Errorw(ctx, "CreateOrDeleteEthernetUNIHistoryME failed, failure PM FSM!",
-								log.Fields{"device-id": mm.pDeviceHandler.deviceID})
-							_ = mm.pAdaptFsm.pFsm.Event(l2PmEventFailure)
+								log.Fields{"device-id": mm.deviceID})
+							_ = mm.PAdaptFsm.PFsm.Event(L2PmEventFailure)
 							return fmt.Errorf(fmt.Sprintf("CreateOrDeleteEthernetUniHistoryMe-failed-%s-%s",
-								mm.pDeviceHandler.deviceID, err))
+								mm.deviceID, err))
 						}
 						if resp = mm.waitForResponseOrTimeout(ctx, true, entityID, "EthernetPerformanceMonitoringHistoryData"); resp {
 							atLeastOneSuccess = true
@@ -1492,16 +1510,16 @@
 				}
 			}
 		case FecHistoryName:
-			for _, anigInstID := range mm.pDeviceHandler.pOnuOmciDevice.pOnuDB.getSortedInstKeys(ctx, me.AniGClassID) {
+			for _, anigInstID := range mm.pOnuDeviceEntry.GetOnuDB().GetSortedInstKeys(ctx, me.AniGClassID) {
 				// Attach the FecPerformanceMonitoringHistoryData ME to the ANI-G ME instance
-				_, err := mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.sendCreateOrDeleteFecHistoryME(
-					ctx, mm.pDeviceHandler.pOpenOnuAc.omciTimeout, true, true, mm.pAdaptFsm.commChan, anigInstID)
+				_, err := mm.pOnuDeviceEntry.GetDevOmciCC().SendCreateOrDeleteFecHistoryME(
+					ctx, mm.pDeviceHandler.GetOmciTimeout(), true, true, mm.PAdaptFsm.CommChan, anigInstID)
 				if err != nil {
 					logger.Errorw(ctx, "CreateOrDeleteFecHistoryME failed, failure PM FSM!",
-						log.Fields{"device-id": mm.pDeviceHandler.deviceID})
-					_ = mm.pAdaptFsm.pFsm.Event(l2PmEventFailure)
+						log.Fields{"device-id": mm.deviceID})
+					_ = mm.PAdaptFsm.PFsm.Event(L2PmEventFailure)
 					return fmt.Errorf(fmt.Sprintf("CreateOrDeleteFecHistoryMe-failed-%s-%s",
-						mm.pDeviceHandler.deviceID, err))
+						mm.deviceID, err))
 				}
 				_ = mm.updatePmData(ctx, n, anigInstID, cPmAdd) // TODO: ignore error for now
 			inner3:
@@ -1519,30 +1537,30 @@
 			}
 		case GemPortHistoryName:
 
-			mm.onuMetricsManagerLock.RLock()
-			copyOfGemPortInstIDsToAdd := make([]uint16, len(mm.groupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd))
-			_ = copy(copyOfGemPortInstIDsToAdd, mm.groupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd)
-			mm.onuMetricsManagerLock.RUnlock()
+			mm.OnuMetricsManagerLock.RLock()
+			copyOfGemPortInstIDsToAdd := make([]uint16, len(mm.GroupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd))
+			_ = copy(copyOfGemPortInstIDsToAdd, mm.GroupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd)
+			mm.OnuMetricsManagerLock.RUnlock()
 
 			if len(copyOfGemPortInstIDsToAdd) == 0 {
 				// If there are no gemport history MEs to be created, just skip further processing
 				// Otherwise down below (after 'switch' case handling) we assume the ME creation failed because resp and atLeastOneSuccess flag are false.
 				// Normally there are no GemPortHistory MEs to create at start up. They come in only after provisioning service on the ONU.
-				mm.onuMetricsManagerLock.Lock()
+				mm.OnuMetricsManagerLock.Lock()
 				mm.l2PmToAdd = mm.removeIfFoundString(mm.l2PmToAdd, n)
-				mm.onuMetricsManagerLock.Unlock()
+				mm.OnuMetricsManagerLock.Unlock()
 				continue
 			}
 
 			for _, v := range copyOfGemPortInstIDsToAdd {
-				_, err := mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.sendCreateOrDeleteGemPortHistoryME(
-					ctx, mm.pDeviceHandler.pOpenOnuAc.omciTimeout, true, true, mm.pAdaptFsm.commChan, v)
+				_, err := mm.pOnuDeviceEntry.GetDevOmciCC().SendCreateOrDeleteGemPortHistoryME(
+					ctx, mm.pDeviceHandler.GetOmciTimeout(), true, true, mm.PAdaptFsm.CommChan, v)
 				if err != nil {
 					logger.Errorw(ctx, "CreateOrDeleteGemPortHistoryME failed, failure PM FSM!",
-						log.Fields{"device-id": mm.pDeviceHandler.deviceID})
-					_ = mm.pAdaptFsm.pFsm.Event(l2PmEventFailure)
+						log.Fields{"device-id": mm.deviceID})
+					_ = mm.PAdaptFsm.PFsm.Event(L2PmEventFailure)
 					return fmt.Errorf(fmt.Sprintf("CreateOrDeleteGemPortHistoryMe-failed-%s-%s",
-						mm.pDeviceHandler.deviceID, err))
+						mm.deviceID, err))
 				}
 				_ = mm.updatePmData(ctx, n, v, cPmAdd) // TODO: ignore error for now
 			inner4:
@@ -1560,77 +1578,77 @@
 			}
 
 		default:
-			logger.Errorw(ctx, "unsupported l2 pm", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "name": n})
+			logger.Errorw(ctx, "unsupported l2 pm", log.Fields{"device-id": mm.deviceID, "name": n})
 		}
 		// On success of at least one instance of the PM for a given ME, update the local list maintained for active PMs and PMs to add
 		if atLeastOneSuccess {
-			mm.onuMetricsManagerLock.Lock()
+			mm.OnuMetricsManagerLock.Lock()
 			mm.activeL2Pms = mm.appendIfMissingString(mm.activeL2Pms, n)
 			// gem ports can be added dynamically for perf monitoring. We want to clear the GemPortHistoryName from mm.l2PmToAdd
 			// only if no more new gem port instances created.
-			if n != GemPortHistoryName || (n == GemPortHistoryName && len(mm.groupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd) == 0) {
+			if n != GemPortHistoryName || (n == GemPortHistoryName && len(mm.GroupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd) == 0) {
 				mm.l2PmToAdd = mm.removeIfFoundString(mm.l2PmToAdd, n)
 			}
 			logger.Debugw(ctx, "success-resp", log.Fields{"pm-name": n, "active-l2-pms": mm.activeL2Pms, "pms-to-add": mm.l2PmToAdd})
-			mm.onuMetricsManagerLock.Unlock()
+			mm.OnuMetricsManagerLock.Unlock()
 		} else {
 			// If we are here then no instance of the PM of the given ME were created successfully, so locally disable the PM
 			// and also remove it from l2PmToAdd slice so that we do not try to create the PM ME anymore
-			mm.onuMetricsManagerLock.Lock()
+			mm.OnuMetricsManagerLock.Lock()
 			logger.Debugw(ctx, "exceeded-max-add-retry-attempts--disabling-group", log.Fields{"groupName": n})
-			mm.groupMetricMap[n].enabled = false
+			mm.GroupMetricMap[n].Enabled = false
 			mm.l2PmToAdd = mm.removeIfFoundString(mm.l2PmToAdd, n)
 
 			logger.Warnw(ctx, "state create pm - failed to create pm",
-				log.Fields{"device-id": mm.pDeviceHandler.deviceID, "metricName": n,
+				log.Fields{"device-id": mm.deviceID, "metricName": n,
 					"active-l2-pms": mm.activeL2Pms, "pms-to-add": mm.l2PmToAdd})
-			mm.onuMetricsManagerLock.Unlock()
+			mm.OnuMetricsManagerLock.Unlock()
 		}
 	}
-	mm.onuMetricsManagerLock.RLock()
-	logger.Debugw(ctx, "state create pm - done", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "active-l2-pms": mm.activeL2Pms, "pms-to-add": mm.l2PmToAdd})
-	mm.onuMetricsManagerLock.RUnlock()
+	mm.OnuMetricsManagerLock.RLock()
+	logger.Debugw(ctx, "state create pm - done", log.Fields{"device-id": mm.deviceID, "active-l2-pms": mm.activeL2Pms, "pms-to-add": mm.l2PmToAdd})
+	mm.OnuMetricsManagerLock.RUnlock()
 	// Does not matter we send success or failure here.
 	// Those PMs that we failed to create will be attempted to create again in the next PM creation cycle (assuming
 	// we have not exceed max attempts to create the PM ME)
 	go func() {
-		if err := mm.pAdaptFsm.pFsm.Event(l2PmEventSuccess); err != nil {
-			logger.Errorw(ctx, "error calling event", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "err": err})
+		if err := mm.PAdaptFsm.PFsm.Event(L2PmEventSuccess); err != nil {
+			logger.Errorw(ctx, "error calling event", log.Fields{"device-id": mm.deviceID, "err": err})
 		}
 	}()
 	return nil
 }
 
 // nolint: gocyclo
-func (mm *onuMetricsManager) l2PmFsmDeletePM(ctx context.Context, e *fsm.Event) error {
+func (mm *OnuMetricsManager) l2PmFsmDeletePM(ctx context.Context, e *fsm.Event) error {
 	// Copy the l2PmToDelete for which we want to collect the metrics since l2PmToDelete can change dynamically
-	mm.onuMetricsManagerLock.RLock()
+	mm.OnuMetricsManagerLock.RLock()
 	copyOfL2PmToDelete := make([]string, len(mm.l2PmToDelete))
 	_ = copy(copyOfL2PmToDelete, mm.l2PmToDelete)
-	mm.onuMetricsManagerLock.RUnlock()
+	mm.OnuMetricsManagerLock.RUnlock()
 
-	logger.Debugw(ctx, "state delete pm", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "pms-to-delete": copyOfL2PmToDelete})
+	logger.Debugw(ctx, "state delete pm", log.Fields{"device-id": mm.deviceID, "pms-to-delete": copyOfL2PmToDelete})
 	for _, n := range copyOfL2PmToDelete {
 		resp := false
 		cnt := 0
 		atLeastOneDeleteFailure := false
 
-		// mm.groupMetricMap[n].pmMEData.InstancesActive could dynamically change, so make a copy
-		mm.onuMetricsManagerLock.RLock()
-		copyOfEntityIDs := make([]uint16, len(mm.groupMetricMap[n].pmMEData.InstancesActive))
-		_ = copy(copyOfEntityIDs, mm.groupMetricMap[n].pmMEData.InstancesActive)
-		mm.onuMetricsManagerLock.RUnlock()
+		// mm.GroupMetricMap[n].pmMEData.InstancesActive could dynamically change, so make a copy
+		mm.OnuMetricsManagerLock.RLock()
+		copyOfEntityIDs := make([]uint16, len(mm.GroupMetricMap[n].pmMEData.InstancesActive))
+		_ = copy(copyOfEntityIDs, mm.GroupMetricMap[n].pmMEData.InstancesActive)
+		mm.OnuMetricsManagerLock.RUnlock()
 
 		if len(copyOfEntityIDs) == 0 {
 			// if there are no enityIDs to remove for the PM ME just clear the PM name entry from cache and continue
-			mm.onuMetricsManagerLock.Lock()
+			mm.OnuMetricsManagerLock.Lock()
 			mm.activeL2Pms = mm.removeIfFoundString(mm.activeL2Pms, n)
 			mm.l2PmToDelete = mm.removeIfFoundString(mm.l2PmToDelete, n)
 			logger.Debugw(ctx, "success-resp", log.Fields{"pm-name": n, "active-l2-pms": mm.activeL2Pms, "pms-to-delete": mm.l2PmToDelete})
-			mm.onuMetricsManagerLock.Unlock()
+			mm.OnuMetricsManagerLock.Unlock()
 			continue
 		}
-		logger.Debugw(ctx, "entities to delete", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "metricName": n, "entityIDs": copyOfEntityIDs})
+		logger.Debugw(ctx, "entities to delete", log.Fields{"device-id": mm.deviceID, "metricName": n, "entityIDs": copyOfEntityIDs})
 		switch n {
 		case EthernetBridgeHistoryName:
 			// Create ME twice, one for each direction. Boolean true is used to indicate upstream and false for downstream.
@@ -1639,19 +1657,19 @@
 				inner1:
 					// retry L2PmDeleteAttempts times to delete the instance of PM
 					for cnt = 0; cnt < L2PmDeleteAttempts; cnt++ {
-						_, err := mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.sendCreateOrDeleteEthernetPerformanceMonitoringHistoryME(
-							ctx, mm.pDeviceHandler.pOpenOnuAc.omciTimeout, true, direction, false, mm.pAdaptFsm.commChan, entityID)
+						_, err := mm.pOnuDeviceEntry.GetDevOmciCC().SendCreateOrDeleteEthernetPerformanceMonitoringHistoryME(
+							ctx, mm.pDeviceHandler.GetOmciTimeout(), true, direction, false, mm.PAdaptFsm.CommChan, entityID)
 						if err != nil {
 							logger.Errorw(ctx, "CreateOrDeleteEthernetPerformanceMonitoringHistoryME failed, failure PM FSM!",
-								log.Fields{"device-id": mm.pDeviceHandler.deviceID})
-							pPMFsm := mm.pAdaptFsm
+								log.Fields{"device-id": mm.deviceID})
+							pPMFsm := mm.PAdaptFsm
 							if pPMFsm != nil {
-								go func(p_pmFsm *AdapterFsm) {
-									_ = mm.pAdaptFsm.pFsm.Event(l2PmEventFailure)
+								go func(p_pmFsm *cmn.AdapterFsm) {
+									_ = mm.PAdaptFsm.PFsm.Event(L2PmEventFailure)
 								}(pPMFsm)
 							}
 							return fmt.Errorf(fmt.Sprintf("CreateOrDeleteEthernetPerformanceMonitoringHistoryMe-failed-%s-%s",
-								mm.pDeviceHandler.deviceID, err))
+								mm.deviceID, err))
 						}
 						_ = mm.updatePmData(ctx, n, entityID, cPmRemove) // TODO: ignore error for now
 						if resp = mm.waitForResponseOrTimeout(ctx, false, entityID, "EthernetFramePerformanceMonitoringHistoryData"); !resp {
@@ -1671,20 +1689,20 @@
 			inner2:
 				// retry L2PmDeleteAttempts times to delete the instance of PM
 				for cnt = 0; cnt < L2PmDeleteAttempts; cnt++ {
-					_, err := mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.sendCreateOrDeleteEthernetUniHistoryME(
-						ctx, mm.pDeviceHandler.pOpenOnuAc.omciTimeout, true, false, mm.pAdaptFsm.commChan, entityID)
+					_, err := mm.pOnuDeviceEntry.GetDevOmciCC().SendCreateOrDeleteEthernetUniHistoryME(
+						ctx, mm.pDeviceHandler.GetOmciTimeout(), true, false, mm.PAdaptFsm.CommChan, entityID)
 					if err != nil {
 						logger.Errorw(ctx, "CreateOrDeleteEthernetUniHistoryME failed, failure PM FSM!",
-							log.Fields{"device-id": mm.pDeviceHandler.deviceID})
-						pmFsm := mm.pAdaptFsm
+							log.Fields{"device-id": mm.deviceID})
+						pmFsm := mm.PAdaptFsm
 						if pmFsm != nil {
-							go func(p_pmFsm *AdapterFsm) {
-								_ = p_pmFsm.pFsm.Event(l2PmEventFailure)
+							go func(p_pmFsm *cmn.AdapterFsm) {
+								_ = p_pmFsm.PFsm.Event(L2PmEventFailure)
 							}(pmFsm)
 							return err
 						}
 						return fmt.Errorf(fmt.Sprintf("CreateOrDeleteEthernetUniHistoryMe-failed-%s-%s",
-							mm.pDeviceHandler.deviceID, err))
+							mm.deviceID, err))
 					}
 					if resp = mm.waitForResponseOrTimeout(ctx, false, entityID, "EthernetPerformanceMonitoringHistoryData"); !resp {
 						atLeastOneDeleteFailure = true
@@ -1702,14 +1720,14 @@
 			inner3:
 				// retry L2PmDeleteAttempts times to delete the instance of PM
 				for cnt = 0; cnt < L2PmDeleteAttempts; cnt++ {
-					_, err := mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.sendCreateOrDeleteFecHistoryME(
-						ctx, mm.pDeviceHandler.pOpenOnuAc.omciTimeout, true, false, mm.pAdaptFsm.commChan, entityID)
+					_, err := mm.pOnuDeviceEntry.GetDevOmciCC().SendCreateOrDeleteFecHistoryME(
+						ctx, mm.pDeviceHandler.GetOmciTimeout(), true, false, mm.PAdaptFsm.CommChan, entityID)
 					if err != nil {
 						logger.Errorw(ctx, "CreateOrDeleteFecHistoryME failed, failure PM FSM!",
-							log.Fields{"device-id": mm.pDeviceHandler.deviceID})
-						_ = mm.pAdaptFsm.pFsm.Event(l2PmEventFailure)
+							log.Fields{"device-id": mm.deviceID})
+						_ = mm.PAdaptFsm.PFsm.Event(L2PmEventFailure)
 						return fmt.Errorf(fmt.Sprintf("CreateOrDeleteFecHistoryMe-failed-%s-%s",
-							mm.pDeviceHandler.deviceID, err))
+							mm.deviceID, err))
 					}
 					if resp := mm.waitForResponseOrTimeout(ctx, false, entityID, "FecPerformanceMonitoringHistoryData"); !resp {
 						atLeastOneDeleteFailure = true
@@ -1727,14 +1745,14 @@
 			inner4:
 				// retry L2PmDeleteAttempts times to delete the instance of PM
 				for cnt = 0; cnt < L2PmDeleteAttempts; cnt++ {
-					_, err := mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.sendCreateOrDeleteGemPortHistoryME(
-						ctx, mm.pDeviceHandler.pOpenOnuAc.omciTimeout, true, false, mm.pAdaptFsm.commChan, entityID)
+					_, err := mm.pOnuDeviceEntry.GetDevOmciCC().SendCreateOrDeleteGemPortHistoryME(
+						ctx, mm.pDeviceHandler.GetOmciTimeout(), true, false, mm.PAdaptFsm.CommChan, entityID)
 					if err != nil {
 						logger.Errorw(ctx, "CreateOrDeleteGemPortHistoryME failed, failure PM FSM!",
-							log.Fields{"device-id": mm.pDeviceHandler.deviceID})
-						_ = mm.pAdaptFsm.pFsm.Event(l2PmEventFailure)
+							log.Fields{"device-id": mm.deviceID})
+						_ = mm.PAdaptFsm.PFsm.Event(L2PmEventFailure)
 						return fmt.Errorf(fmt.Sprintf("CreateOrDeleteGemPortHistoryMe-failed-%s-%s",
-							mm.pDeviceHandler.deviceID, err))
+							mm.deviceID, err))
 					}
 					if resp = mm.waitForResponseOrTimeout(ctx, false, entityID, "GemPortNetworkCtpPerformanceMonitoringHistoryData"); !resp {
 						atLeastOneDeleteFailure = true
@@ -1748,39 +1766,39 @@
 				}
 			}
 		default:
-			logger.Errorw(ctx, "unsupported l2 pm", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "name": n})
+			logger.Errorw(ctx, "unsupported l2 pm", log.Fields{"device-id": mm.deviceID, "name": n})
 		}
 		// If we could not completely clean up the PM ME then just give up.
 		if atLeastOneDeleteFailure {
 			logger.Warnw(ctx, "state delete pm - failed to delete at least one instance of the PM ME",
-				log.Fields{"device-id": mm.pDeviceHandler.deviceID, "metricName": n,
+				log.Fields{"device-id": mm.deviceID, "metricName": n,
 					"active-l2-pms": mm.activeL2Pms, "pms-to-delete": mm.l2PmToDelete})
-			mm.onuMetricsManagerLock.Lock()
+			mm.OnuMetricsManagerLock.Lock()
 			logger.Debugw(ctx, "exceeded-max-delete-retry-attempts--disabling-group", log.Fields{"groupName": n})
 			mm.activeL2Pms = mm.removeIfFoundString(mm.activeL2Pms, n)
 			mm.l2PmToDelete = mm.removeIfFoundString(mm.l2PmToDelete, n)
-			mm.groupMetricMap[n].enabled = false
-			mm.onuMetricsManagerLock.Unlock()
+			mm.GroupMetricMap[n].Enabled = false
+			mm.OnuMetricsManagerLock.Unlock()
 		} else { // success case
-			mm.onuMetricsManagerLock.Lock()
+			mm.OnuMetricsManagerLock.Lock()
 			mm.activeL2Pms = mm.removeIfFoundString(mm.activeL2Pms, n)
 			// gem ports can be deleted dynamically from perf monitoring. We want to clear the GemPortHistoryName from mm.l2PmToDelete
 			// only if no more new gem port instances removed.
-			if n != GemPortHistoryName || (n == GemPortHistoryName && len(mm.groupMetricMap[GemPortHistoryName].pmMEData.InstancesToDelete) == 0) {
+			if n != GemPortHistoryName || (n == GemPortHistoryName && len(mm.GroupMetricMap[GemPortHistoryName].pmMEData.InstancesToDelete) == 0) {
 				mm.l2PmToDelete = mm.removeIfFoundString(mm.l2PmToDelete, n)
 			}
 			logger.Debugw(ctx, "success-resp", log.Fields{"pm-name": n, "active-l2-pms": mm.activeL2Pms, "pms-to-delete": mm.l2PmToDelete})
-			mm.onuMetricsManagerLock.Unlock()
+			mm.OnuMetricsManagerLock.Unlock()
 		}
 	}
-	mm.onuMetricsManagerLock.RLock()
-	logger.Debugw(ctx, "state delete pm - done", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "active-l2-pms": mm.activeL2Pms, "pms-to-delete": mm.l2PmToDelete})
-	mm.onuMetricsManagerLock.RUnlock()
+	mm.OnuMetricsManagerLock.RLock()
+	logger.Debugw(ctx, "state delete pm - done", log.Fields{"device-id": mm.deviceID, "active-l2-pms": mm.activeL2Pms, "pms-to-delete": mm.l2PmToDelete})
+	mm.OnuMetricsManagerLock.RUnlock()
 	// Does not matter we send success or failure here.
 	// Those PMs that we failed to delete will be attempted to create again in the next PM collection cycle
 	go func() {
-		if err := mm.pAdaptFsm.pFsm.Event(l2PmEventSuccess); err != nil {
-			logger.Errorw(ctx, "error calling event", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "err": err})
+		if err := mm.PAdaptFsm.PFsm.Event(L2PmEventSuccess); err != nil {
+			logger.Errorw(ctx, "error calling event", log.Fields{"device-id": mm.deviceID, "err": err})
 		}
 	}()
 	return nil
@@ -1789,41 +1807,41 @@
 // ** L2 PM FSM Handlers end **
 
 // syncTime synchronizes time with the ONU to establish a 15 min boundary for PM collection and reporting.
-func (mm *onuMetricsManager) syncTime(ctx context.Context) error {
-	if err := mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.sendSyncTime(ctx, mm.pDeviceHandler.pOpenOnuAc.omciTimeout, true, mm.pAdaptFsm.commChan); err != nil {
-		logger.Errorw(ctx, "cannot send sync time request", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+func (mm *OnuMetricsManager) syncTime(ctx context.Context) error {
+	if err := mm.pOnuDeviceEntry.GetDevOmciCC().SendSyncTime(ctx, mm.pDeviceHandler.GetOmciTimeout(), true, mm.PAdaptFsm.CommChan); err != nil {
+		logger.Errorw(ctx, "cannot send sync time request", log.Fields{"device-id": mm.deviceID})
 		return err
 	}
 
 	select {
-	case <-time.After(mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.GetMaxOmciTimeoutWithRetries() * time.Second):
-		logger.Errorw(ctx, "timed out waiting for sync time response from onu", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
-		return fmt.Errorf("timed-out-waiting-for-sync-time-response-%v", mm.pDeviceHandler.deviceID)
+	case <-time.After(mm.pOnuDeviceEntry.GetDevOmciCC().GetMaxOmciTimeoutWithRetries() * time.Second):
+		logger.Errorw(ctx, "timed out waiting for sync time response from onu", log.Fields{"device-id": mm.deviceID})
+		return fmt.Errorf("timed-out-waiting-for-sync-time-response-%v", mm.deviceID)
 	case syncTimeRes := <-mm.syncTimeResponseChan:
 		if !syncTimeRes {
-			return fmt.Errorf("failed-to-sync-time-%v", mm.pDeviceHandler.deviceID)
+			return fmt.Errorf("failed-to-sync-time-%v", mm.deviceID)
 		}
-		logger.Infow(ctx, "sync time success", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+		logger.Infow(ctx, "sync time success", log.Fields{"device-id": mm.deviceID})
 		return nil
 	}
 }
 
-func (mm *onuMetricsManager) collectEthernetFramePerformanceMonitoringHistoryData(ctx context.Context, upstream bool, entityID uint16) *voltha.MetricInformation {
+func (mm *OnuMetricsManager) collectEthernetFramePerformanceMonitoringHistoryData(ctx context.Context, upstream bool, entityID uint16) *voltha.MetricInformation {
 	var mEnt *me.ManagedEntity
 	var omciErr me.OmciErrors
 	var classID me.ClassID
 	var meAttributes me.AttributeValueMap
-	logger.Debugw(ctx, "collecting data for EthernetFramePerformanceMonitoringHistoryData", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "entityID": entityID, "upstream": upstream})
+	logger.Debugw(ctx, "collecting data for EthernetFramePerformanceMonitoringHistoryData", log.Fields{"device-id": mm.deviceID, "entityID": entityID, "upstream": upstream})
 	meParam := me.ParamData{EntityID: entityID}
 	if upstream {
 		if mEnt, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataUpstream(meParam); omciErr == nil || mEnt == nil || omciErr.GetError() != nil {
-			logger.Errorw(ctx, "error creating me", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "entityID": entityID, "upstream": upstream})
+			logger.Errorw(ctx, "error creating me", log.Fields{"device-id": mm.deviceID, "entityID": entityID, "upstream": upstream})
 			return nil
 		}
 		classID = me.EthernetFramePerformanceMonitoringHistoryDataUpstreamClassID
 	} else {
 		if mEnt, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataDownstream(meParam); omciErr == nil || mEnt == nil || omciErr.GetError() != nil {
-			logger.Errorw(ctx, "error creating me", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "entityID": entityID, "upstream": upstream})
+			logger.Errorw(ctx, "error creating me", log.Fields{"device-id": mm.deviceID, "entityID": entityID, "upstream": upstream})
 			return nil
 		}
 		classID = me.EthernetFramePerformanceMonitoringHistoryDataDownstreamClassID
@@ -1849,19 +1867,19 @@
 	metricInfo := mm.populateOnuMetricInfo(EthernetBridgeHistoryName, ethPMHistData)
 
 	logger.Debugw(ctx, "collecting data for EthernetFramePerformanceMonitoringHistoryData successful",
-		log.Fields{"device-id": mm.pDeviceHandler.deviceID, "entityID": entityID, "upstream": upstream, "metricInfo": metricInfo})
+		log.Fields{"device-id": mm.deviceID, "entityID": entityID, "upstream": upstream, "metricInfo": metricInfo})
 	return &metricInfo
 }
 
-func (mm *onuMetricsManager) collectEthernetUniHistoryData(ctx context.Context, entityID uint16) *voltha.MetricInformation {
+func (mm *OnuMetricsManager) collectEthernetUniHistoryData(ctx context.Context, entityID uint16) *voltha.MetricInformation {
 	var mEnt *me.ManagedEntity
 	var omciErr me.OmciErrors
 	var classID me.ClassID
 	var meAttributes me.AttributeValueMap
-	logger.Debugw(ctx, "collecting data for EthernetFramePerformanceMonitoringHistoryData", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "entityID": entityID})
+	logger.Debugw(ctx, "collecting data for EthernetFramePerformanceMonitoringHistoryData", log.Fields{"device-id": mm.deviceID, "entityID": entityID})
 	meParam := me.ParamData{EntityID: entityID}
 	if mEnt, omciErr = me.NewEthernetPerformanceMonitoringHistoryData(meParam); omciErr == nil || mEnt == nil || omciErr.GetError() != nil {
-		logger.Errorw(ctx, "error creating me", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "entityID": entityID})
+		logger.Errorw(ctx, "error creating me", log.Fields{"device-id": mm.deviceID, "entityID": entityID})
 		return nil
 	}
 	classID = me.EthernetPerformanceMonitoringHistoryDataClassID
@@ -1879,19 +1897,19 @@
 	metricInfo := mm.populateOnuMetricInfo(EthernetUniHistoryName, ethUniHistData)
 
 	logger.Debugw(ctx, "collecting data for EthernetPerformanceMonitoringHistoryData successful",
-		log.Fields{"device-id": mm.pDeviceHandler.deviceID, "entityID": entityID, "metricInfo": metricInfo})
+		log.Fields{"device-id": mm.deviceID, "entityID": entityID, "metricInfo": metricInfo})
 	return &metricInfo
 }
 
-func (mm *onuMetricsManager) collectFecHistoryData(ctx context.Context, entityID uint16) *voltha.MetricInformation {
+func (mm *OnuMetricsManager) collectFecHistoryData(ctx context.Context, entityID uint16) *voltha.MetricInformation {
 	var mEnt *me.ManagedEntity
 	var omciErr me.OmciErrors
 	var classID me.ClassID
 	var meAttributes me.AttributeValueMap
-	logger.Debugw(ctx, "collecting data for FecPerformanceMonitoringHistoryData", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "entityID": entityID})
+	logger.Debugw(ctx, "collecting data for FecPerformanceMonitoringHistoryData", log.Fields{"device-id": mm.deviceID, "entityID": entityID})
 	meParam := me.ParamData{EntityID: entityID}
 	if mEnt, omciErr = me.NewFecPerformanceMonitoringHistoryData(meParam); omciErr == nil || mEnt == nil || omciErr.GetError() != nil {
-		logger.Errorw(ctx, "error creating me", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "entityID": entityID})
+		logger.Errorw(ctx, "error creating me", log.Fields{"device-id": mm.deviceID, "entityID": entityID})
 		return nil
 	}
 	classID = me.FecPerformanceMonitoringHistoryDataClassID
@@ -1909,19 +1927,19 @@
 	metricInfo := mm.populateOnuMetricInfo(FecHistoryName, fecHistData)
 
 	logger.Debugw(ctx, "collecting data for FecPerformanceMonitoringHistoryData successful",
-		log.Fields{"device-id": mm.pDeviceHandler.deviceID, "entityID": entityID, "metricInfo": metricInfo})
+		log.Fields{"device-id": mm.deviceID, "entityID": entityID, "metricInfo": metricInfo})
 	return &metricInfo
 }
 
-func (mm *onuMetricsManager) collectGemHistoryData(ctx context.Context, entityID uint16) *voltha.MetricInformation {
+func (mm *OnuMetricsManager) collectGemHistoryData(ctx context.Context, entityID uint16) *voltha.MetricInformation {
 	var mEnt *me.ManagedEntity
 	var omciErr me.OmciErrors
 	var classID me.ClassID
 	var meAttributes me.AttributeValueMap
-	logger.Debugw(ctx, "collecting data for GemPortNetworkCtpPerformanceMonitoringHistoryData", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "entityID": entityID})
+	logger.Debugw(ctx, "collecting data for GemPortNetworkCtpPerformanceMonitoringHistoryData", log.Fields{"device-id": mm.deviceID, "entityID": entityID})
 	meParam := me.ParamData{EntityID: entityID}
 	if mEnt, omciErr = me.NewGemPortNetworkCtpPerformanceMonitoringHistoryData(meParam); omciErr == nil || mEnt == nil || omciErr.GetError() != nil {
-		logger.Errorw(ctx, "error creating me", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "entityID": entityID})
+		logger.Errorw(ctx, "error creating me", log.Fields{"device-id": mm.deviceID, "entityID": entityID})
 		return nil
 	}
 	classID = me.GemPortNetworkCtpPerformanceMonitoringHistoryDataClassID
@@ -1939,12 +1957,12 @@
 	metricInfo := mm.populateOnuMetricInfo(GemPortHistoryName, gemHistData)
 
 	logger.Debugw(ctx, "collecting data for GemPortNetworkCtpPerformanceMonitoringHistoryData successful",
-		log.Fields{"device-id": mm.pDeviceHandler.deviceID, "entityID": entityID, "metricInfo": metricInfo})
+		log.Fields{"device-id": mm.deviceID, "entityID": entityID, "metricInfo": metricInfo})
 	return &metricInfo
 }
 
 // nolint: gocyclo
-func (mm *onuMetricsManager) populateEthernetBridgeHistoryMetrics(ctx context.Context, classID me.ClassID, entityID uint16,
+func (mm *OnuMetricsManager) populateEthernetBridgeHistoryMetrics(ctx context.Context, classID me.ClassID, entityID uint16,
 	meAttributes me.AttributeValueMap, requestedAttributes me.AttributeValueMap, ethPMHistData map[string]float32, intervalEndTime *int) error {
 	upstream := false
 	if classID == me.EthernetFramePerformanceMonitoringHistoryDataUpstreamClassID {
@@ -1952,32 +1970,32 @@
 	}
 	// Insert "IntervalEndTime" as part of the requested attributes as we need this to compare the get responses when get request is multipart
 	requestedAttributes["IntervalEndTime"] = 0
-	meInstance, err := mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.sendGetMe(ctx, classID, entityID, requestedAttributes, mm.pDeviceHandler.pOpenOnuAc.omciTimeout, true, mm.pAdaptFsm.commChan)
+	meInstance, err := mm.pOnuDeviceEntry.GetDevOmciCC().SendGetMe(ctx, classID, entityID, requestedAttributes, mm.pDeviceHandler.GetOmciTimeout(), true, mm.PAdaptFsm.CommChan)
 	if err != nil {
-		logger.Errorw(ctx, "GetME failed, failure PM FSM!", log.Fields{"device-id": mm.pAdaptFsm.deviceID})
-		pmFsm := mm.pAdaptFsm
+		logger.Errorw(ctx, "GetME failed, failure PM FSM!", log.Fields{"device-id": mm.deviceID})
+		pmFsm := mm.PAdaptFsm
 		if pmFsm != nil {
-			go func(p_pmFsm *AdapterFsm) {
-				_ = p_pmFsm.pFsm.Event(l2PmEventFailure)
+			go func(p_pmFsm *cmn.AdapterFsm) {
+				_ = p_pmFsm.PFsm.Event(L2PmEventFailure)
 			}(pmFsm)
 			return err
 		}
-		return fmt.Errorf(fmt.Sprintf("GetME-failed-%s-%s", mm.pDeviceHandler.deviceID, err))
+		return fmt.Errorf(fmt.Sprintf("GetME-failed-%s-%s", mm.deviceID, err))
 	}
 	if meInstance != nil {
 		select {
 		case meAttributes = <-mm.l2PmChan:
 			logger.Debugw(ctx, "received ethernet pm history data metrics",
-				log.Fields{"device-id": mm.pDeviceHandler.deviceID, "upstream": upstream, "entityID": entityID})
-		case <-time.After(mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.GetMaxOmciTimeoutWithRetries() * time.Second):
+				log.Fields{"device-id": mm.deviceID, "upstream": upstream, "entityID": entityID})
+		case <-time.After(mm.pOnuDeviceEntry.GetDevOmciCC().GetMaxOmciTimeoutWithRetries() * time.Second):
 			logger.Errorw(ctx, "timeout waiting for omci-get response for ethernet pm history data",
-				log.Fields{"device-id": mm.pDeviceHandler.deviceID, "upstream": upstream, "entityID": entityID})
+				log.Fields{"device-id": mm.deviceID, "upstream": upstream, "entityID": entityID})
 			// The metrics will be empty in this case
-			return fmt.Errorf("timeout-during-l2-pm-collection-for-ethernet-bridge-history-%v", mm.pDeviceHandler.deviceID)
+			return fmt.Errorf("timeout-during-l2-pm-collection-for-ethernet-bridge-history-%v", mm.deviceID)
 		}
 		// verify that interval end time has not changed during metric collection. If it changed, we abort the procedure
 		if valid := mm.updateAndValidateIntervalEndTime(ctx, entityID, meAttributes, intervalEndTime); !valid {
-			return fmt.Errorf("interval-end-time-changed-during-metric-collection-for-ethernet-bridge-history-%v", mm.pDeviceHandler.deviceID)
+			return fmt.Errorf("interval-end-time-changed-during-metric-collection-for-ethernet-bridge-history-%v", mm.deviceID)
 		}
 	}
 	for k := range EthernetBridgeHistory {
@@ -2054,32 +2072,32 @@
 }
 
 // nolint: gocyclo
-func (mm *onuMetricsManager) populateEthernetUniHistoryMetrics(ctx context.Context, classID me.ClassID, entityID uint16,
+func (mm *OnuMetricsManager) populateEthernetUniHistoryMetrics(ctx context.Context, classID me.ClassID, entityID uint16,
 	meAttributes me.AttributeValueMap, requestedAttributes me.AttributeValueMap, ethPMUniHistData map[string]float32, intervalEndTime *int) error {
 	// Insert "IntervalEndTime" as part of the requested attributes as we need this to compare the get responses when get request is multipart
 	if _, ok := requestedAttributes["IntervalEndTime"]; !ok {
 		requestedAttributes["IntervalEndTime"] = 0
 	}
-	meInstance, err := mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.sendGetMe(ctx, classID, entityID, requestedAttributes, mm.pDeviceHandler.pOpenOnuAc.omciTimeout, true, mm.pAdaptFsm.commChan)
+	meInstance, err := mm.pOnuDeviceEntry.GetDevOmciCC().SendGetMe(ctx, classID, entityID, requestedAttributes, mm.pDeviceHandler.GetOmciTimeout(), true, mm.PAdaptFsm.CommChan)
 	if err != nil {
-		logger.Errorw(ctx, "GetMe failed, failure PM FSM!", log.Fields{"device-id": mm.pAdaptFsm.deviceID})
-		_ = mm.pAdaptFsm.pFsm.Event(l2PmEventFailure)
-		return fmt.Errorf(fmt.Sprintf("GetME-failed-%s-%s", mm.pDeviceHandler.deviceID, err))
+		logger.Errorw(ctx, "GetMe failed, failure PM FSM!", log.Fields{"device-id": mm.deviceID})
+		_ = mm.PAdaptFsm.PFsm.Event(L2PmEventFailure)
+		return fmt.Errorf(fmt.Sprintf("GetME-failed-%s-%s", mm.deviceID, err))
 	}
 	if meInstance != nil {
 		select {
 		case meAttributes = <-mm.l2PmChan:
 			logger.Debugw(ctx, "received ethernet uni history data metrics",
-				log.Fields{"device-id": mm.pDeviceHandler.deviceID, "entityID": entityID})
-		case <-time.After(mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.GetMaxOmciTimeoutWithRetries() * time.Second):
+				log.Fields{"device-id": mm.deviceID, "entityID": entityID})
+		case <-time.After(mm.pOnuDeviceEntry.GetDevOmciCC().GetMaxOmciTimeoutWithRetries() * time.Second):
 			logger.Errorw(ctx, "timeout waiting for omci-get response for ethernet uni history data",
-				log.Fields{"device-id": mm.pDeviceHandler.deviceID, "entityID": entityID})
+				log.Fields{"device-id": mm.deviceID, "entityID": entityID})
 			// The metrics will be empty in this case
-			return fmt.Errorf("timeout-during-l2-pm-collection-for-ethernet-uni-history-%v", mm.pDeviceHandler.deviceID)
+			return fmt.Errorf("timeout-during-l2-pm-collection-for-ethernet-uni-history-%v", mm.deviceID)
 		}
 		// verify that interval end time has not changed during metric collection. If it changed, we abort the procedure
 		if valid := mm.updateAndValidateIntervalEndTime(ctx, entityID, meAttributes, intervalEndTime); !valid {
-			return fmt.Errorf("interval-end-time-changed-during-metric-collection-for-ethernet-uni-history-%v", mm.pDeviceHandler.deviceID)
+			return fmt.Errorf("interval-end-time-changed-during-metric-collection-for-ethernet-uni-history-%v", mm.deviceID)
 		}
 	}
 	for k := range EthernetUniHistory {
@@ -2156,32 +2174,32 @@
 }
 
 // nolint: gocyclo
-func (mm *onuMetricsManager) populateFecHistoryMetrics(ctx context.Context, classID me.ClassID, entityID uint16,
+func (mm *OnuMetricsManager) populateFecHistoryMetrics(ctx context.Context, classID me.ClassID, entityID uint16,
 	meAttributes me.AttributeValueMap, requestedAttributes me.AttributeValueMap, fecHistData map[string]float32, intervalEndTime *int) error {
 	// Insert "IntervalEndTime" as part of the requested attributes as we need this to compare the get responses when get request is multipart
 	if _, ok := requestedAttributes["IntervalEndTime"]; !ok {
 		requestedAttributes["IntervalEndTime"] = 0
 	}
-	meInstance, err := mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.sendGetMe(ctx, classID, entityID, requestedAttributes, mm.pDeviceHandler.pOpenOnuAc.omciTimeout, true, mm.pAdaptFsm.commChan)
+	meInstance, err := mm.pOnuDeviceEntry.GetDevOmciCC().SendGetMe(ctx, classID, entityID, requestedAttributes, mm.pDeviceHandler.GetOmciTimeout(), true, mm.PAdaptFsm.CommChan)
 	if err != nil {
-		logger.Errorw(ctx, "GetMe failed, failure PM FSM!", log.Fields{"device-id": mm.pAdaptFsm.deviceID})
-		_ = mm.pAdaptFsm.pFsm.Event(l2PmEventFailure)
-		return fmt.Errorf(fmt.Sprintf("GetME-failed-%s-%s", mm.pDeviceHandler.deviceID, err))
+		logger.Errorw(ctx, "GetMe failed, failure PM FSM!", log.Fields{"device-id": mm.deviceID})
+		_ = mm.PAdaptFsm.PFsm.Event(L2PmEventFailure)
+		return fmt.Errorf(fmt.Sprintf("GetME-failed-%s-%s", mm.deviceID, err))
 	}
 	if meInstance != nil {
 		select {
 		case meAttributes = <-mm.l2PmChan:
 			logger.Debugw(ctx, "received fec history data metrics",
-				log.Fields{"device-id": mm.pDeviceHandler.deviceID, "entityID": entityID})
-		case <-time.After(mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.GetMaxOmciTimeoutWithRetries() * time.Second):
+				log.Fields{"device-id": mm.deviceID, "entityID": entityID})
+		case <-time.After(mm.pOnuDeviceEntry.GetDevOmciCC().GetMaxOmciTimeoutWithRetries() * time.Second):
 			logger.Errorw(ctx, "timeout waiting for omci-get response for fec history data",
-				log.Fields{"device-id": mm.pDeviceHandler.deviceID, "entityID": entityID})
+				log.Fields{"device-id": mm.deviceID, "entityID": entityID})
 			// The metrics will be empty in this case
-			return fmt.Errorf("timeout-during-l2-pm-collection-for-fec-history-%v", mm.pDeviceHandler.deviceID)
+			return fmt.Errorf("timeout-during-l2-pm-collection-for-fec-history-%v", mm.deviceID)
 		}
 		// verify that interval end time has not changed during metric collection. If it changed, we abort the procedure
 		if valid := mm.updateAndValidateIntervalEndTime(ctx, entityID, meAttributes, intervalEndTime); !valid {
-			return fmt.Errorf("interval-end-time-changed-during-metric-collection-for-fec-history-%v", mm.pDeviceHandler.deviceID)
+			return fmt.Errorf("interval-end-time-changed-during-metric-collection-for-fec-history-%v", mm.deviceID)
 		}
 	}
 	for k := range FecHistory {
@@ -2222,32 +2240,32 @@
 }
 
 // nolint: gocyclo
-func (mm *onuMetricsManager) populateGemPortMetrics(ctx context.Context, classID me.ClassID, entityID uint16,
+func (mm *OnuMetricsManager) populateGemPortMetrics(ctx context.Context, classID me.ClassID, entityID uint16,
 	meAttributes me.AttributeValueMap, requestedAttributes me.AttributeValueMap, gemPortHistData map[string]float32, intervalEndTime *int) error {
 	// Insert "IntervalEndTime" is part of the requested attributes as we need this to compare the get responses when get request is multipart
 	if _, ok := requestedAttributes["IntervalEndTime"]; !ok {
 		requestedAttributes["IntervalEndTime"] = 0
 	}
-	meInstance, err := mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.sendGetMe(ctx, classID, entityID, requestedAttributes, mm.pDeviceHandler.pOpenOnuAc.omciTimeout, true, mm.pAdaptFsm.commChan)
+	meInstance, err := mm.pOnuDeviceEntry.GetDevOmciCC().SendGetMe(ctx, classID, entityID, requestedAttributes, mm.pDeviceHandler.GetOmciTimeout(), true, mm.PAdaptFsm.CommChan)
 	if err != nil {
-		logger.Errorw(ctx, "GetMe failed", log.Fields{"device-id": mm.pAdaptFsm.deviceID})
-		_ = mm.pAdaptFsm.pFsm.Event(l2PmEventFailure)
-		return fmt.Errorf(fmt.Sprintf("GetME-failed-%s-%s", mm.pDeviceHandler.deviceID, err))
+		logger.Errorw(ctx, "GetMe failed", log.Fields{"device-id": mm.deviceID})
+		_ = mm.PAdaptFsm.PFsm.Event(L2PmEventFailure)
+		return fmt.Errorf(fmt.Sprintf("GetME-failed-%s-%s", mm.deviceID, err))
 	}
 	if meInstance != nil {
 		select {
 		case meAttributes = <-mm.l2PmChan:
 			logger.Debugw(ctx, "received gem port history data metrics",
-				log.Fields{"device-id": mm.pDeviceHandler.deviceID, "entityID": entityID})
-		case <-time.After(mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.GetMaxOmciTimeoutWithRetries() * time.Second):
+				log.Fields{"device-id": mm.deviceID, "entityID": entityID})
+		case <-time.After(mm.pOnuDeviceEntry.GetDevOmciCC().GetMaxOmciTimeoutWithRetries() * time.Second):
 			logger.Errorw(ctx, "timeout waiting for omci-get response for gem port history data",
-				log.Fields{"device-id": mm.pDeviceHandler.deviceID, "entityID": entityID})
+				log.Fields{"device-id": mm.deviceID, "entityID": entityID})
 			// The metrics will be empty in this case
-			return fmt.Errorf("timeout-during-l2-pm-collection-for-gemport-history-%v", mm.pDeviceHandler.deviceID)
+			return fmt.Errorf("timeout-during-l2-pm-collection-for-gemport-history-%v", mm.deviceID)
 		}
 		// verify that interval end time has not changed during metric collection. If it changed, we abort the procedure
 		if valid := mm.updateAndValidateIntervalEndTime(ctx, entityID, meAttributes, intervalEndTime); !valid {
-			return fmt.Errorf("interval-end-time-changed-during-metric-collection-for-gemport-history-%v", mm.pDeviceHandler.deviceID)
+			return fmt.Errorf("interval-end-time-changed-during-metric-collection-for-gemport-history-%v", mm.deviceID)
 		}
 	}
 	for k := range GemPortHistory {
@@ -2287,18 +2305,18 @@
 	return nil
 }
 
-func (mm *onuMetricsManager) handleOmciCreateResponseMessage(ctx context.Context, msg OmciMessage) error {
+func (mm *OnuMetricsManager) handleOmciCreateResponseMessage(ctx context.Context, msg cmn.OmciMessage) error {
 	msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeCreateResponse)
 	if msgLayer == nil {
-		logger.Errorw(ctx, "omci Msg layer could not be detected for create response - handling stopped", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
-		return fmt.Errorf("omci Msg layer could not be detected for create response - handling stopped: %s", mm.pDeviceHandler.deviceID)
+		logger.Errorw(ctx, "omci Msg layer could not be detected for create response - handling stopped", log.Fields{"device-id": mm.deviceID})
+		return fmt.Errorf("omci Msg layer could not be detected for create response - handling stopped: %s", mm.deviceID)
 	}
 	msgObj, msgOk := msgLayer.(*omci.CreateResponse)
 	if !msgOk {
-		logger.Errorw(ctx, "omci Msg layer could not be assigned for create response - handling stopped", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
-		return fmt.Errorf("omci Msg layer could not be assigned for delete response - handling stopped: %s", mm.pDeviceHandler.deviceID)
+		logger.Errorw(ctx, "omci Msg layer could not be assigned for create response - handling stopped", log.Fields{"device-id": mm.deviceID})
+		return fmt.Errorf("omci Msg layer could not be assigned for delete response - handling stopped: %s", mm.deviceID)
 	}
-	logger.Debugw(ctx, "OMCI create response Data", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "data-fields": msgObj})
+	logger.Debugw(ctx, "OMCI create response Data", log.Fields{"device-id": mm.deviceID, "data-fields": msgObj})
 	switch msgObj.EntityClass {
 	case me.EthernetFramePerformanceMonitoringHistoryDataUpstreamClassID,
 		me.EthernetFramePerformanceMonitoringHistoryDataDownstreamClassID,
@@ -2309,7 +2327,7 @@
 		if msgObj.Result == me.Success || msgObj.Result == me.InstanceExists {
 			mm.l2PmCreateOrDeleteResponseChan <- true
 		} else {
-			logger.Warnw(ctx, "failed to create me", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "class-id": msgObj.EntityClass})
+			logger.Warnw(ctx, "failed to create me", log.Fields{"device-id": mm.deviceID, "class-id": msgObj.EntityClass})
 			mm.l2PmCreateOrDeleteResponseChan <- false
 		}
 		return nil
@@ -2319,23 +2337,23 @@
 		return nil
 	default:
 		logger.Errorw(ctx, "unhandled omci create response message",
-			log.Fields{"device-id": mm.pDeviceHandler.deviceID, "class-id": msgObj.EntityClass})
+			log.Fields{"device-id": mm.deviceID, "class-id": msgObj.EntityClass})
 	}
-	return fmt.Errorf("unhandled-omci-create-response-message-%v", mm.pDeviceHandler.deviceID)
+	return fmt.Errorf("unhandled-omci-create-response-message-%v", mm.deviceID)
 }
 
-func (mm *onuMetricsManager) handleOmciDeleteResponseMessage(ctx context.Context, msg OmciMessage) error {
+func (mm *OnuMetricsManager) handleOmciDeleteResponseMessage(ctx context.Context, msg cmn.OmciMessage) error {
 	msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeDeleteResponse)
 	if msgLayer == nil {
-		logger.Errorw(ctx, "omci Msg layer could not be detected for delete response - handling stopped", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
-		return fmt.Errorf("omci Msg layer could not be detected for create response - handling stopped: %s", mm.pDeviceHandler.deviceID)
+		logger.Errorw(ctx, "omci Msg layer could not be detected for delete response - handling stopped", log.Fields{"device-id": mm.deviceID})
+		return fmt.Errorf("omci Msg layer could not be detected for create response - handling stopped: %s", mm.deviceID)
 	}
 	msgObj, msgOk := msgLayer.(*omci.DeleteResponse)
 	if !msgOk {
-		logger.Errorw(ctx, "omci Msg layer could not be assigned for delete response - handling stopped", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
-		return fmt.Errorf("omci Msg layer could not be assigned for delete response - handling stopped: %s", mm.pDeviceHandler.deviceID)
+		logger.Errorw(ctx, "omci Msg layer could not be assigned for delete response - handling stopped", log.Fields{"device-id": mm.deviceID})
+		return fmt.Errorf("omci Msg layer could not be assigned for delete response - handling stopped: %s", mm.deviceID)
 	}
-	logger.Debugw(ctx, "OMCI delete response Data", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "data-fields": msgObj})
+	logger.Debugw(ctx, "OMCI delete response Data", log.Fields{"device-id": mm.deviceID, "data-fields": msgObj})
 	switch msgObj.EntityClass {
 	case me.EthernetFramePerformanceMonitoringHistoryDataUpstreamClassID,
 		me.EthernetFramePerformanceMonitoringHistoryDataDownstreamClassID,
@@ -2346,54 +2364,54 @@
 		if msgObj.Result == me.Success || msgObj.Result == me.UnknownInstance {
 			mm.l2PmCreateOrDeleteResponseChan <- true
 		} else {
-			logger.Warnw(ctx, "failed to delete me", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "class-id": msgObj.EntityClass})
+			logger.Warnw(ctx, "failed to delete me", log.Fields{"device-id": mm.deviceID, "class-id": msgObj.EntityClass})
 			mm.l2PmCreateOrDeleteResponseChan <- false
 		}
 		return nil
 	default:
 		logger.Errorw(ctx, "unhandled omci delete response message",
-			log.Fields{"device-id": mm.pDeviceHandler.deviceID, "class-id": msgObj.EntityClass})
+			log.Fields{"device-id": mm.deviceID, "class-id": msgObj.EntityClass})
 	}
-	return fmt.Errorf("unhandled-omci-delete-response-message-%v", mm.pDeviceHandler.deviceID)
+	return fmt.Errorf("unhandled-omci-delete-response-message-%v", mm.deviceID)
 }
 
-func (mm *onuMetricsManager) generateTicks(ctx context.Context) {
+func (mm *OnuMetricsManager) generateTicks(ctx context.Context) {
 	mm.updateTickGenerationStatus(true)
 	for {
 		select {
 		case <-time.After(L2PmCollectionInterval * time.Second):
 			go func() {
-				if err := mm.pAdaptFsm.pFsm.Event(l2PmEventTick); err != nil {
-					logger.Errorw(ctx, "error calling event", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "err": err})
+				if err := mm.PAdaptFsm.PFsm.Event(L2PmEventTick); err != nil {
+					logger.Errorw(ctx, "error calling event", log.Fields{"device-id": mm.deviceID, "err": err})
 				}
 			}()
-		case <-mm.stopTicks:
-			logger.Infow(ctx, "stopping ticks", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+		case <-mm.StopTicks:
+			logger.Infow(ctx, "stopping ticks", log.Fields{"device-id": mm.deviceID})
 			mm.updateTickGenerationStatus(false)
 			return
 		}
 	}
 }
 
-func (mm *onuMetricsManager) handleMetricsPublish(ctx context.Context, metricName string, metricInfoSlice []*voltha.MetricInformation) {
+func (mm *OnuMetricsManager) handleMetricsPublish(ctx context.Context, metricName string, metricInfoSlice []*voltha.MetricInformation) {
 	// Publish metrics if it is valid
 	if metricInfoSlice != nil {
 		mm.publishMetrics(ctx, metricInfoSlice)
 	} else {
 		// If collectAttempts exceeds L2PmCollectAttempts then remove it from activeL2Pms
 		// slice so that we do not collect data from that PM ME anymore
-		mm.onuMetricsManagerLock.Lock()
-		mm.groupMetricMap[metricName].collectAttempts++
-		if mm.groupMetricMap[metricName].collectAttempts > L2PmCollectAttempts {
+		mm.OnuMetricsManagerLock.Lock()
+		mm.GroupMetricMap[metricName].collectAttempts++
+		if mm.GroupMetricMap[metricName].collectAttempts > L2PmCollectAttempts {
 			mm.activeL2Pms = mm.removeIfFoundString(mm.activeL2Pms, metricName)
 		}
 		logger.Warnw(ctx, "state collect data - no metrics collected",
-			log.Fields{"device-id": mm.pDeviceHandler.deviceID, "metricName": metricName, "collectAttempts": mm.groupMetricMap[metricName].collectAttempts})
-		mm.onuMetricsManagerLock.Unlock()
+			log.Fields{"device-id": mm.deviceID, "metricName": metricName, "collectAttempts": mm.GroupMetricMap[metricName].collectAttempts})
+		mm.OnuMetricsManagerLock.Unlock()
 	}
 }
 
-func (mm *onuMetricsManager) populateGroupSpecificMetrics(ctx context.Context, mEnt *me.ManagedEntity, classID me.ClassID, entityID uint16,
+func (mm *OnuMetricsManager) populateGroupSpecificMetrics(ctx context.Context, mEnt *me.ManagedEntity, classID me.ClassID, entityID uint16,
 	meAttributes me.AttributeValueMap, data map[string]float32, intervalEndTime *int) error {
 	var grpFunc groupMetricPopulateFunc
 	switch classID {
@@ -2425,7 +2443,7 @@
 			// Let's collect the attributes via get now and collect remaining in the next iteration
 			if err := grpFunc(ctx, classID, entityID, meAttributes, requestedAttributes, data, intervalEndTime); err != nil {
 				logger.Errorw(ctx, "error during metric collection",
-					log.Fields{"device-id": mm.pDeviceHandler.deviceID, "entityID": entityID, "err": err})
+					log.Fields{"device-id": mm.deviceID, "entityID": entityID, "err": err})
 				return err
 			}
 			requestedAttributes = make(me.AttributeValueMap) // reset map
@@ -2436,26 +2454,26 @@
 	// Collect the omci get attributes for the last bunch of attributes.
 	if err := grpFunc(ctx, classID, entityID, meAttributes, requestedAttributes, data, intervalEndTime); err != nil {
 		logger.Errorw(ctx, "error during metric collection",
-			log.Fields{"device-id": mm.pDeviceHandler.deviceID, "entityID": entityID, "err": err})
+			log.Fields{"device-id": mm.deviceID, "entityID": entityID, "err": err})
 		return err
 	}
 	return nil
 }
 
-func (mm *onuMetricsManager) populateOnuMetricInfo(title string, data map[string]float32) voltha.MetricInformation {
+func (mm *OnuMetricsManager) populateOnuMetricInfo(title string, data map[string]float32) voltha.MetricInformation {
 	metricsContext := make(map[string]string)
-	metricsContext["onuID"] = fmt.Sprintf("%d", mm.pDeviceHandler.device.ProxyAddress.OnuId)
-	metricsContext["intfID"] = fmt.Sprintf("%d", mm.pDeviceHandler.device.ProxyAddress.ChannelId)
-	metricsContext["devicetype"] = mm.pDeviceHandler.DeviceType
+	metricsContext["onuID"] = fmt.Sprintf("%d", mm.pDeviceHandler.GetDevice().ProxyAddress.OnuId)
+	metricsContext["intfID"] = fmt.Sprintf("%d", mm.pDeviceHandler.GetDevice().ProxyAddress.ChannelId)
+	metricsContext["devicetype"] = mm.pDeviceHandler.GetDeviceType()
 
 	raisedTs := time.Now().Unix()
 	mmd := voltha.MetricMetaData{
 		Title:           title,
 		Ts:              float64(raisedTs),
 		Context:         metricsContext,
-		DeviceId:        mm.pDeviceHandler.deviceID,
-		LogicalDeviceId: mm.pDeviceHandler.logicalDeviceID,
-		SerialNo:        mm.pDeviceHandler.device.SerialNumber,
+		DeviceId:        mm.deviceID,
+		LogicalDeviceId: mm.pDeviceHandler.GetLogicalDeviceID(),
+		SerialNo:        mm.pDeviceHandler.GetDevice().SerialNumber,
 	}
 
 	// create slice of metrics given that there could be more than one VEIP instance
@@ -2463,7 +2481,7 @@
 	return metricInfo
 }
 
-func (mm *onuMetricsManager) updateAndValidateIntervalEndTime(ctx context.Context, entityID uint16, meAttributes me.AttributeValueMap, intervalEndTime *int) bool {
+func (mm *OnuMetricsManager) updateAndValidateIntervalEndTime(ctx context.Context, entityID uint16, meAttributes me.AttributeValueMap, intervalEndTime *int) bool {
 	valid := false
 	if *intervalEndTime == -1 { // first time
 		// Update the interval end time
@@ -2478,7 +2496,7 @@
 		}
 		if currIntervalEndTime != *intervalEndTime { // interval end time changed during metric collection
 			logger.Errorw(ctx, "interval end time changed during metrics collection for ethernet pm history data",
-				log.Fields{"device-id": mm.pDeviceHandler.deviceID, "entityID": entityID,
+				log.Fields{"device-id": mm.deviceID, "entityID": entityID,
 					"currIntervalEndTime": *intervalEndTime, "newIntervalEndTime": currIntervalEndTime})
 		} else {
 			valid = true
@@ -2487,81 +2505,81 @@
 	return valid
 }
 
-func (mm *onuMetricsManager) waitForResponseOrTimeout(ctx context.Context, create bool, instID uint16, meClassName string) bool {
+func (mm *OnuMetricsManager) waitForResponseOrTimeout(ctx context.Context, create bool, instID uint16, meClassName string) bool {
 	logger.Debugw(ctx, "waitForResponseOrTimeout", log.Fields{"create": create, "instID": instID, "meClassName": meClassName})
 	select {
 	case resp := <-mm.l2PmCreateOrDeleteResponseChan:
 		logger.Debugw(ctx, "received l2 pm me response",
-			log.Fields{"device-id": mm.pDeviceHandler.deviceID, "resp": resp, "create": create, "meClassName": meClassName, "instID": instID})
+			log.Fields{"device-id": mm.deviceID, "resp": resp, "create": create, "meClassName": meClassName, "instID": instID})
 		return resp
-	case <-time.After(mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.GetMaxOmciTimeoutWithRetries() * time.Second):
+	case <-time.After(mm.pOnuDeviceEntry.GetDevOmciCC().GetMaxOmciTimeoutWithRetries() * time.Second):
 		logger.Errorw(ctx, "timeout waiting for l2 pm me response",
-			log.Fields{"device-id": mm.pDeviceHandler.deviceID, "resp": false, "create": create, "meClassName": meClassName, "instID": instID})
+			log.Fields{"device-id": mm.deviceID, "resp": false, "create": create, "meClassName": meClassName, "instID": instID})
 	}
 	return false
 }
 
-func (mm *onuMetricsManager) initializeGroupMetric(grpMtrcs map[string]voltha.PmConfig_PmType, grpName string, grpEnabled bool, grpFreq uint32) {
+func (mm *OnuMetricsManager) initializeGroupMetric(grpMtrcs map[string]voltha.PmConfig_PmType, grpName string, grpEnabled bool, grpFreq uint32) {
 	var pmConfigSlice []*voltha.PmConfig
 	for k, v := range grpMtrcs {
 		pmConfigSlice = append(pmConfigSlice,
 			&voltha.PmConfig{
 				Name:       k,
 				Type:       v,
-				Enabled:    grpEnabled && mm.pDeviceHandler.pOpenOnuAc.metricsEnabled,
+				Enabled:    grpEnabled && mm.pDeviceHandler.GetMetricsEnabled(),
 				SampleFreq: grpFreq})
 	}
 	groupMetric := voltha.PmGroupConfig{
 		GroupName: grpName,
-		Enabled:   grpEnabled && mm.pDeviceHandler.pOpenOnuAc.metricsEnabled,
+		Enabled:   grpEnabled && mm.pDeviceHandler.GetMetricsEnabled(),
 		GroupFreq: grpFreq,
 		Metrics:   pmConfigSlice,
 	}
-	mm.pDeviceHandler.pmConfigs.Groups = append(mm.pDeviceHandler.pmConfigs.Groups, &groupMetric)
+	mm.pDeviceHandler.GetPmConfigs().Groups = append(mm.pDeviceHandler.GetPmConfigs().Groups, &groupMetric)
 
 }
 
-func (mm *onuMetricsManager) initializeL2PmFsm(ctx context.Context, aCommChannel chan Message) error {
-	mm.pAdaptFsm = NewAdapterFsm("L2PmFSM", mm.pDeviceHandler.deviceID, aCommChannel)
-	if mm.pAdaptFsm == nil {
-		logger.Errorw(ctx, "L2PMFsm AdapterFsm could not be instantiated!!", log.Fields{
-			"device-id": mm.pDeviceHandler.deviceID})
+func (mm *OnuMetricsManager) initializeL2PmFsm(ctx context.Context, aCommChannel chan cmn.Message) error {
+	mm.PAdaptFsm = cmn.NewAdapterFsm("L2PmFSM", mm.deviceID, aCommChannel)
+	if mm.PAdaptFsm == nil {
+		logger.Errorw(ctx, "L2PMFsm cmn.AdapterFsm could not be instantiated!!", log.Fields{
+			"device-id": mm.deviceID})
 		return fmt.Errorf("nil-adapter-fsm")
 	}
 	// L2 PM FSM related state machine
-	mm.pAdaptFsm.pFsm = fsm.NewFSM(
-		l2PmStNull,
+	mm.PAdaptFsm.PFsm = fsm.NewFSM(
+		L2PmStNull,
 		fsm.Events{
-			{Name: l2PmEventInit, Src: []string{l2PmStNull}, Dst: l2PmStStarting},
-			{Name: l2PmEventTick, Src: []string{l2PmStStarting}, Dst: l2PmStSyncTime},
-			{Name: l2PmEventTick, Src: []string{l2PmStIdle, l2PmStCreatePmMe, l2PmStDeletePmMe}, Dst: l2PmStCollectData},
-			{Name: l2PmEventSuccess, Src: []string{l2PmStSyncTime, l2PmStCreatePmMe, l2PmStDeletePmMe, l2PmStCollectData}, Dst: l2PmStIdle},
-			{Name: l2PmEventFailure, Src: []string{l2PmStCreatePmMe, l2PmStDeletePmMe, l2PmStCollectData}, Dst: l2PmStIdle},
-			{Name: l2PmEventFailure, Src: []string{l2PmStSyncTime}, Dst: l2PmStSyncTime},
-			{Name: l2PmEventAddMe, Src: []string{l2PmStIdle}, Dst: l2PmStCreatePmMe},
-			{Name: l2PmEventDeleteMe, Src: []string{l2PmStIdle}, Dst: l2PmStDeletePmMe},
-			{Name: l2PmEventStop, Src: []string{l2PmStNull, l2PmStStarting, l2PmStSyncTime, l2PmStIdle, l2PmStCreatePmMe, l2PmStDeletePmMe, l2PmStCollectData}, Dst: l2PmStNull},
+			{Name: L2PmEventInit, Src: []string{L2PmStNull}, Dst: L2PmStStarting},
+			{Name: L2PmEventTick, Src: []string{L2PmStStarting}, Dst: L2PmStSyncTime},
+			{Name: L2PmEventTick, Src: []string{L2PmStIdle, L2PmStCreatePmMe, L2PmStDeletePmMe}, Dst: L2PmStCollectData},
+			{Name: L2PmEventSuccess, Src: []string{L2PmStSyncTime, L2PmStCreatePmMe, L2PmStDeletePmMe, L2PmStCollectData}, Dst: L2PmStIdle},
+			{Name: L2PmEventFailure, Src: []string{L2PmStCreatePmMe, L2PmStDeletePmMe, L2PmStCollectData}, Dst: L2PmStIdle},
+			{Name: L2PmEventFailure, Src: []string{L2PmStSyncTime}, Dst: L2PmStSyncTime},
+			{Name: L2PmEventAddMe, Src: []string{L2PmStIdle}, Dst: L2PmStCreatePmMe},
+			{Name: L2PmEventDeleteMe, Src: []string{L2PmStIdle}, Dst: L2PmStDeletePmMe},
+			{Name: L2PmEventStop, Src: []string{L2PmStNull, L2PmStStarting, L2PmStSyncTime, L2PmStIdle, L2PmStCreatePmMe, L2PmStDeletePmMe, L2PmStCollectData}, Dst: L2PmStNull},
 		},
 		fsm.Callbacks{
-			"enter_state":                func(e *fsm.Event) { mm.pAdaptFsm.logFsmStateChange(ctx, e) },
-			"enter_" + l2PmStNull:        func(e *fsm.Event) { mm.l2PMFsmNull(ctx, e) },
-			"enter_" + l2PmStIdle:        func(e *fsm.Event) { mm.l2PMFsmIdle(ctx, e) },
-			"enter_" + l2PmStStarting:    func(e *fsm.Event) { mm.l2PMFsmStarting(ctx, e) },
-			"enter_" + l2PmStSyncTime:    func(e *fsm.Event) { mm.l2PMFsmSyncTime(ctx, e) },
-			"enter_" + l2PmStCollectData: func(e *fsm.Event) { mm.l2PmFsmCollectData(ctx, e) },
-			"enter_" + l2PmStCreatePmMe:  func(e *fsm.Event) { _ = mm.l2PmFsmCreatePM(ctx, e) },
-			"enter_" + l2PmStDeletePmMe:  func(e *fsm.Event) { _ = mm.l2PmFsmDeletePM(ctx, e) },
+			"enter_state":                func(e *fsm.Event) { mm.PAdaptFsm.LogFsmStateChange(ctx, e) },
+			"enter_" + L2PmStNull:        func(e *fsm.Event) { mm.l2PMFsmNull(ctx, e) },
+			"enter_" + L2PmStIdle:        func(e *fsm.Event) { mm.l2PMFsmIdle(ctx, e) },
+			"enter_" + L2PmStStarting:    func(e *fsm.Event) { mm.l2PMFsmStarting(ctx, e) },
+			"enter_" + L2PmStSyncTime:    func(e *fsm.Event) { mm.l2PMFsmSyncTime(ctx, e) },
+			"enter_" + L2PmStCollectData: func(e *fsm.Event) { mm.l2PmFsmCollectData(ctx, e) },
+			"enter_" + L2PmStCreatePmMe:  func(e *fsm.Event) { _ = mm.l2PmFsmCreatePM(ctx, e) },
+			"enter_" + L2PmStDeletePmMe:  func(e *fsm.Event) { _ = mm.l2PmFsmDeletePM(ctx, e) },
 		},
 	)
 	return nil
 }
 
-func (mm *onuMetricsManager) initializeAllGroupMetrics() {
-	mm.pDeviceHandler.pmConfigs = &voltha.PmConfigs{}
-	mm.pDeviceHandler.pmConfigs.Id = mm.pDeviceHandler.deviceID
-	mm.pDeviceHandler.pmConfigs.DefaultFreq = DefaultMetricCollectionFrequency
-	mm.pDeviceHandler.pmConfigs.Grouped = GroupMetricEnabled
-	mm.pDeviceHandler.pmConfigs.FreqOverride = DefaultFrequencyOverrideEnabled
+func (mm *OnuMetricsManager) initializeAllGroupMetrics() {
+	mm.pDeviceHandler.InitPmConfigs()
+	mm.pDeviceHandler.GetPmConfigs().Id = mm.deviceID
+	mm.pDeviceHandler.GetPmConfigs().DefaultFreq = DefaultMetricCollectionFrequency
+	mm.pDeviceHandler.GetPmConfigs().Grouped = GroupMetricEnabled
+	mm.pDeviceHandler.GetPmConfigs().FreqOverride = DefaultFrequencyOverrideEnabled
 
 	// Populate group metrics.
 	// Lets populate irrespective of GroupMetricEnabled is true or not.
@@ -2592,42 +2610,42 @@
 	// Add standalone metric (if present) after this (will be added to dh.pmConfigs.Metrics)
 }
 
-func (mm *onuMetricsManager) populateLocalGroupMetricData(ctx context.Context) {
+func (mm *OnuMetricsManager) populateLocalGroupMetricData(ctx context.Context) {
 	// Populate local group metric structures
-	for _, g := range mm.pDeviceHandler.pmConfigs.Groups {
-		mm.groupMetricMap[g.GroupName] = &groupMetric{
+	for _, g := range mm.pDeviceHandler.GetPmConfigs().Groups {
+		mm.GroupMetricMap[g.GroupName] = &groupMetric{
 			groupName: g.GroupName,
-			enabled:   g.Enabled,
-			frequency: g.GroupFreq,
+			Enabled:   g.Enabled,
+			Frequency: g.GroupFreq,
 		}
 		switch g.GroupName {
 		case OpticalPowerGroupMetricName:
-			mm.groupMetricMap[g.GroupName].metricMap = OpticalPowerGroupMetrics
+			mm.GroupMetricMap[g.GroupName].metricMap = OpticalPowerGroupMetrics
 		case UniStatusGroupMetricName:
-			mm.groupMetricMap[g.GroupName].metricMap = UniStatusGroupMetrics
+			mm.GroupMetricMap[g.GroupName].metricMap = UniStatusGroupMetrics
 		case EthernetBridgeHistoryName:
-			mm.groupMetricMap[g.GroupName].metricMap = EthernetBridgeHistory
-			mm.groupMetricMap[g.GroupName].isL2PMCounter = true
+			mm.GroupMetricMap[g.GroupName].metricMap = EthernetBridgeHistory
+			mm.GroupMetricMap[g.GroupName].IsL2PMCounter = true
 		case EthernetUniHistoryName:
-			mm.groupMetricMap[g.GroupName].metricMap = EthernetUniHistory
-			mm.groupMetricMap[g.GroupName].isL2PMCounter = true
+			mm.GroupMetricMap[g.GroupName].metricMap = EthernetUniHistory
+			mm.GroupMetricMap[g.GroupName].IsL2PMCounter = true
 		case FecHistoryName:
-			mm.groupMetricMap[g.GroupName].metricMap = FecHistory
-			mm.groupMetricMap[g.GroupName].isL2PMCounter = true
+			mm.GroupMetricMap[g.GroupName].metricMap = FecHistory
+			mm.GroupMetricMap[g.GroupName].IsL2PMCounter = true
 		case GemPortHistoryName:
-			mm.groupMetricMap[g.GroupName].metricMap = GemPortHistory
-			mm.groupMetricMap[g.GroupName].isL2PMCounter = true
+			mm.GroupMetricMap[g.GroupName].metricMap = GemPortHistory
+			mm.GroupMetricMap[g.GroupName].IsL2PMCounter = true
 		default:
 			logger.Errorw(ctx, "unhandled-group-name", log.Fields{"groupName": g.GroupName})
 		}
 	}
 
 	// Populate local standalone metric structures
-	for _, m := range mm.pDeviceHandler.pmConfigs.Metrics {
-		mm.standaloneMetricMap[m.Name] = &standaloneMetric{
+	for _, m := range mm.pDeviceHandler.GetPmConfigs().Metrics {
+		mm.StandaloneMetricMap[m.Name] = &standaloneMetric{
 			metricName: m.Name,
-			enabled:    m.Enabled,
-			frequency:  m.SampleFreq,
+			Enabled:    m.Enabled,
+			Frequency:  m.SampleFreq,
 		}
 		switch m.Name {
 		// None exist as of now. Add when available.
@@ -2637,14 +2655,15 @@
 	}
 }
 
-func (mm *onuMetricsManager) AddGemPortForPerfMonitoring(ctx context.Context, gemPortNTPInstID uint16) {
-	mm.onuMetricsManagerLock.Lock()
-	defer mm.onuMetricsManagerLock.Unlock()
-	logger.Debugw(ctx, "add gemport for perf monitoring - start", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "gemPortID": gemPortNTPInstID})
+// AddGemPortForPerfMonitoring - TODO: add comment
+func (mm *OnuMetricsManager) AddGemPortForPerfMonitoring(ctx context.Context, gemPortNTPInstID uint16) {
+	mm.OnuMetricsManagerLock.Lock()
+	defer mm.OnuMetricsManagerLock.Unlock()
+	logger.Debugw(ctx, "add gemport for perf monitoring - start", log.Fields{"device-id": mm.deviceID, "gemPortID": gemPortNTPInstID})
 	// mark the instance for addition
-	mm.groupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd = mm.appendIfMissingUnt16(mm.groupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd, gemPortNTPInstID)
+	mm.GroupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd = mm.appendIfMissingUnt16(mm.GroupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd, gemPortNTPInstID)
 	// If the instance presence toggles too soon, we need to remove it from gemPortNCTPPerfHistInstToDelete slice
-	mm.groupMetricMap[GemPortHistoryName].pmMEData.InstancesToDelete = mm.removeIfFoundUint16(mm.groupMetricMap[GemPortHistoryName].pmMEData.InstancesToDelete, gemPortNTPInstID)
+	mm.GroupMetricMap[GemPortHistoryName].pmMEData.InstancesToDelete = mm.removeIfFoundUint16(mm.GroupMetricMap[GemPortHistoryName].pmMEData.InstancesToDelete, gemPortNTPInstID)
 
 	mm.l2PmToAdd = mm.appendIfMissingString(mm.l2PmToAdd, GemPortHistoryName)
 	// We do not need to remove from l2PmToDelete slice as we could have Add and Delete of
@@ -2653,23 +2672,24 @@
 	// gemPortNCTPPerfHistInstToAdd slice
 
 	logger.Debugw(ctx, "add gemport for perf monitoring - end",
-		log.Fields{"device-id": mm.pDeviceHandler.deviceID, "pms-to-add": mm.l2PmToAdd,
-			"instances-to-add": mm.groupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd})
+		log.Fields{"device-id": mm.deviceID, "pms-to-add": mm.l2PmToAdd,
+			"instances-to-add": mm.GroupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd})
 	go func() {
-		if err := mm.pAdaptFsm.pFsm.Event(l2PmEventAddMe); err != nil {
+		if err := mm.PAdaptFsm.PFsm.Event(L2PmEventAddMe); err != nil {
 			// log at warn level as the gem port for monitoring is going to be added eventually
-			logger.Warnw(ctx, "error calling event", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "err": err})
+			logger.Warnw(ctx, "error calling event", log.Fields{"device-id": mm.deviceID, "err": err})
 		}
 	}()
 }
 
-func (mm *onuMetricsManager) RemoveGemPortForPerfMonitoring(ctx context.Context, gemPortNTPInstID uint16) {
-	mm.onuMetricsManagerLock.Lock()
-	defer mm.onuMetricsManagerLock.Unlock()
-	logger.Debugw(ctx, "remove gemport for perf monitoring - start", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "gemPortID": gemPortNTPInstID})
-	mm.groupMetricMap[GemPortHistoryName].pmMEData.InstancesToDelete = mm.appendIfMissingUnt16(mm.groupMetricMap[GemPortHistoryName].pmMEData.InstancesToDelete, gemPortNTPInstID)
+// RemoveGemPortForPerfMonitoring - TODO: add comment
+func (mm *OnuMetricsManager) RemoveGemPortForPerfMonitoring(ctx context.Context, gemPortNTPInstID uint16) {
+	mm.OnuMetricsManagerLock.Lock()
+	defer mm.OnuMetricsManagerLock.Unlock()
+	logger.Debugw(ctx, "remove gemport for perf monitoring - start", log.Fields{"device-id": mm.deviceID, "gemPortID": gemPortNTPInstID})
+	mm.GroupMetricMap[GemPortHistoryName].pmMEData.InstancesToDelete = mm.appendIfMissingUnt16(mm.GroupMetricMap[GemPortHistoryName].pmMEData.InstancesToDelete, gemPortNTPInstID)
 	// If the instance presence toggles too soon, we need to remove it from gemPortNCTPPerfHistInstToAdd slice
-	mm.groupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd = mm.removeIfFoundUint16(mm.groupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd, gemPortNTPInstID)
+	mm.GroupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd = mm.removeIfFoundUint16(mm.GroupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd, gemPortNTPInstID)
 
 	mm.l2PmToDelete = mm.appendIfMissingString(mm.l2PmToDelete, GemPortHistoryName)
 	// We do not need to remove from l2PmToAdd slice as we could have Add and Delete of
@@ -2678,116 +2698,116 @@
 	// gemPortNCTPPerfHistInstToAdd slice
 
 	logger.Debugw(ctx, "remove gemport from perf monitoring - end",
-		log.Fields{"device-id": mm.pDeviceHandler.deviceID, "pms-to-delete": mm.l2PmToDelete,
-			"instances-to-delete": mm.groupMetricMap[GemPortHistoryName].pmMEData.InstancesToDelete})
+		log.Fields{"device-id": mm.deviceID, "pms-to-delete": mm.l2PmToDelete,
+			"instances-to-delete": mm.GroupMetricMap[GemPortHistoryName].pmMEData.InstancesToDelete})
 	go func() {
-		if err := mm.pAdaptFsm.pFsm.Event(l2PmEventDeleteMe); err != nil {
+		if err := mm.PAdaptFsm.PFsm.Event(L2PmEventDeleteMe); err != nil {
 			// log at warn level as the gem port for monitoring is going to be removed eventually
-			logger.Warnw(ctx, "error calling event", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "err": err})
+			logger.Warnw(ctx, "error calling event", log.Fields{"device-id": mm.deviceID, "err": err})
 		}
 	}()
 }
 
-func (mm *onuMetricsManager) updateGemPortNTPInstanceToAddForPerfMonitoring(ctx context.Context) {
-	if mm.pDeviceHandler.pOnuTP != nil {
-		gemPortInstIDs := mm.pDeviceHandler.pOnuTP.GetAllBidirectionalGemPortIDsForOnu()
+func (mm *OnuMetricsManager) updateGemPortNTPInstanceToAddForPerfMonitoring(ctx context.Context) {
+	if mm.pDeviceHandler.GetOnuTP() != nil {
+		gemPortInstIDs := mm.pDeviceHandler.GetOnuTP().GetAllBidirectionalGemPortIDsForOnu()
 		// NOTE: It is expected that caller of this function has acquired the required mutex for synchronization purposes
 		for _, v := range gemPortInstIDs {
 			// mark the instance for addition
-			mm.groupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd = mm.appendIfMissingUnt16(mm.groupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd, v)
+			mm.GroupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd = mm.appendIfMissingUnt16(mm.GroupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd, v)
 			// If the instance presence toggles too soon, we need to remove it from gemPortNCTPPerfHistInstToDelete slice
-			mm.groupMetricMap[GemPortHistoryName].pmMEData.InstancesToDelete = mm.removeIfFoundUint16(mm.groupMetricMap[GemPortHistoryName].pmMEData.InstancesToDelete, v)
+			mm.GroupMetricMap[GemPortHistoryName].pmMEData.InstancesToDelete = mm.removeIfFoundUint16(mm.GroupMetricMap[GemPortHistoryName].pmMEData.InstancesToDelete, v)
 		}
 		logger.Debugw(ctx, "updateGemPortNTPInstanceToAddForPerfMonitoring",
-			log.Fields{"deviceID": mm.pDeviceHandler.deviceID, "gemToAdd": mm.groupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd, "gemToDel": mm.groupMetricMap[GemPortHistoryName].pmMEData.InstancesToDelete})
+			log.Fields{"deviceID": mm.deviceID, "gemToAdd": mm.GroupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd, "gemToDel": mm.GroupMetricMap[GemPortHistoryName].pmMEData.InstancesToDelete})
 	}
 }
 
-func (mm *onuMetricsManager) updateGemPortNTPInstanceToDeleteForPerfMonitoring(ctx context.Context) {
-	if mm.pDeviceHandler.pOnuTP != nil {
-		gemPortInstIDs := mm.pDeviceHandler.pOnuTP.GetAllBidirectionalGemPortIDsForOnu()
+func (mm *OnuMetricsManager) updateGemPortNTPInstanceToDeleteForPerfMonitoring(ctx context.Context) {
+	if mm.pDeviceHandler.GetOnuTP() != nil {
+		gemPortInstIDs := mm.pDeviceHandler.GetOnuTP().GetAllBidirectionalGemPortIDsForOnu()
 		// NOTE: It is expected that caller of this function has acquired the required mutex for synchronization purposes
 		for _, v := range gemPortInstIDs {
-			mm.groupMetricMap[GemPortHistoryName].pmMEData.InstancesToDelete = mm.appendIfMissingUnt16(mm.groupMetricMap[GemPortHistoryName].pmMEData.InstancesToDelete, v)
+			mm.GroupMetricMap[GemPortHistoryName].pmMEData.InstancesToDelete = mm.appendIfMissingUnt16(mm.GroupMetricMap[GemPortHistoryName].pmMEData.InstancesToDelete, v)
 			// If the instance presence toggles too soon, we need to remove it from gemPortNCTPPerfHistInstToAdd slice
-			mm.groupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd = mm.removeIfFoundUint16(mm.groupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd, v)
+			mm.GroupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd = mm.removeIfFoundUint16(mm.GroupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd, v)
 		}
 	}
 	logger.Debugw(ctx, "updateGemPortNTPInstanceToDeleteForPerfMonitoring",
-		log.Fields{"deviceID": mm.pDeviceHandler.deviceID, "gemToAdd": mm.groupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd, "gemToDel": mm.groupMetricMap[GemPortHistoryName].pmMEData.InstancesToDelete})
+		log.Fields{"deviceID": mm.deviceID, "gemToAdd": mm.GroupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd, "gemToDel": mm.GroupMetricMap[GemPortHistoryName].pmMEData.InstancesToDelete})
 }
 
 // restorePmData restores any PM data available on the KV store to local cache
-func (mm *onuMetricsManager) restorePmData(ctx context.Context) error {
-	logger.Debugw(ctx, "restorePmData - start", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+func (mm *OnuMetricsManager) restorePmData(ctx context.Context) error {
+	logger.Debugw(ctx, "restorePmData - start", log.Fields{"device-id": mm.deviceID})
 	if mm.pmKvStore == nil {
-		logger.Errorw(ctx, "pmKvStore not set - abort", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
-		return fmt.Errorf(fmt.Sprintf("pmKvStore-not-set-abort-%s", mm.pDeviceHandler.deviceID))
+		logger.Errorw(ctx, "pmKvStore not set - abort", log.Fields{"device-id": mm.deviceID})
+		return fmt.Errorf(fmt.Sprintf("pmKvStore-not-set-abort-%s", mm.deviceID))
 	}
 	var errorsList []error
-	for groupName, group := range mm.groupMetricMap {
+	for groupName, group := range mm.GroupMetricMap {
 		group.pmMEData = &pmMEData{}
 		Value, err := mm.pmKvStore.Get(ctx, groupName)
 		if err == nil {
 			if Value != nil {
 				logger.Debugw(ctx, "PM data read",
-					log.Fields{"Key": Value.Key, "device-id": mm.pDeviceHandler.deviceID})
+					log.Fields{"Key": Value.Key, "device-id": mm.deviceID})
 				tmpBytes, _ := kvstore.ToByte(Value.Value)
 
 				if err = json.Unmarshal(tmpBytes, &group.pmMEData); err != nil {
-					logger.Errorw(ctx, "unable to unmarshal PM data", log.Fields{"error": err, "device-id": mm.pDeviceHandler.deviceID})
-					errorsList = append(errorsList, fmt.Errorf(fmt.Sprintf("unable-to-unmarshal-PM-data-%s-for-group-%s", mm.pDeviceHandler.deviceID, groupName)))
+					logger.Errorw(ctx, "unable to unmarshal PM data", log.Fields{"error": err, "device-id": mm.deviceID})
+					errorsList = append(errorsList, fmt.Errorf(fmt.Sprintf("unable-to-unmarshal-PM-data-%s-for-group-%s", mm.deviceID, groupName)))
 					continue
 				}
-				logger.Debugw(ctx, "restorePmData - success", log.Fields{"pmData": group.pmMEData, "groupName": groupName, "device-id": mm.pDeviceHandler.deviceID})
+				logger.Debugw(ctx, "restorePmData - success", log.Fields{"pmData": group.pmMEData, "groupName": groupName, "device-id": mm.deviceID})
 			} else {
-				logger.Debugw(ctx, "no PM data found", log.Fields{"groupName": groupName, "device-id": mm.pDeviceHandler.deviceID})
+				logger.Debugw(ctx, "no PM data found", log.Fields{"groupName": groupName, "device-id": mm.deviceID})
 				continue
 			}
 		} else {
-			logger.Errorw(ctx, "restorePmData - fail", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "groupName": groupName, "err": err})
-			errorsList = append(errorsList, fmt.Errorf(fmt.Sprintf("unable-to-read-from-KVstore-%s-for-group-%s", mm.pDeviceHandler.deviceID, groupName)))
+			logger.Errorw(ctx, "restorePmData - fail", log.Fields{"device-id": mm.deviceID, "groupName": groupName, "err": err})
+			errorsList = append(errorsList, fmt.Errorf(fmt.Sprintf("unable-to-read-from-KVstore-%s-for-group-%s", mm.deviceID, groupName)))
 			continue
 		}
 	}
 	if len(errorsList) > 0 {
 		return fmt.Errorf("errors-restoring-pm-data-for-one-or-more-groups--errors:%v", errorsList)
 	}
-	logger.Debugw(ctx, "restorePmData - complete success", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+	logger.Debugw(ctx, "restorePmData - complete success", log.Fields{"device-id": mm.deviceID})
 	return nil
 }
 
 // getPmData gets pmMEData from cache. Since we have write through cache implementation for pmMEData,
 // the data must be available in cache.
 // Note, it is expected that caller of this function manages the required synchronization (like using locks etc.).
-func (mm *onuMetricsManager) getPmData(ctx context.Context, groupName string) (*pmMEData, error) {
-	if grp, ok := mm.groupMetricMap[groupName]; ok {
+func (mm *OnuMetricsManager) getPmData(ctx context.Context, groupName string) (*pmMEData, error) {
+	if grp, ok := mm.GroupMetricMap[groupName]; ok {
 		return grp.pmMEData, nil
 	}
 	// Data not in cache, try to fetch from kv store.
 	data := &pmMEData{}
 	if mm.pmKvStore == nil {
-		logger.Errorw(ctx, "pmKvStore not set - abort", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
-		return data, fmt.Errorf("pmKvStore not set. device-id - %s", mm.pDeviceHandler.deviceID)
+		logger.Errorw(ctx, "pmKvStore not set - abort", log.Fields{"device-id": mm.deviceID})
+		return data, fmt.Errorf("pmKvStore not set. device-id - %s", mm.deviceID)
 	}
 	Value, err := mm.pmKvStore.Get(ctx, groupName)
 	if err == nil {
 		if Value != nil {
 			logger.Debugw(ctx, "PM data read",
-				log.Fields{"Key": Value.Key, "device-id": mm.pDeviceHandler.deviceID})
+				log.Fields{"Key": Value.Key, "device-id": mm.deviceID})
 			tmpBytes, _ := kvstore.ToByte(Value.Value)
 
 			if err = json.Unmarshal(tmpBytes, data); err != nil {
-				logger.Errorw(ctx, "unable to unmarshal PM data", log.Fields{"error": err, "device-id": mm.pDeviceHandler.deviceID})
+				logger.Errorw(ctx, "unable to unmarshal PM data", log.Fields{"error": err, "device-id": mm.deviceID})
 				return data, err
 			}
-			logger.Debugw(ctx, "PM data", log.Fields{"pmData": data, "groupName": groupName, "device-id": mm.pDeviceHandler.deviceID})
+			logger.Debugw(ctx, "PM data", log.Fields{"pmData": data, "groupName": groupName, "device-id": mm.deviceID})
 		} else {
-			logger.Debugw(ctx, "no PM data found", log.Fields{"groupName": groupName, "device-id": mm.pDeviceHandler.deviceID})
+			logger.Debugw(ctx, "no PM data found", log.Fields{"groupName": groupName, "device-id": mm.deviceID})
 			return data, err
 		}
 	} else {
-		logger.Errorw(ctx, "unable to read from KVstore", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+		logger.Errorw(ctx, "unable to read from KVstore", log.Fields{"device-id": mm.deviceID})
 		return data, err
 	}
 
@@ -2795,14 +2815,14 @@
 }
 
 // updatePmData update pmMEData to store. It is write through cache, i.e., write to cache first and then update store
-func (mm *onuMetricsManager) updatePmData(ctx context.Context, groupName string, meInstanceID uint16, pmAction string) error {
-	logger.Debugw(ctx, "updatePmData - start", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "groupName": groupName, "entityID": meInstanceID, "pmAction": pmAction})
-	mm.onuMetricsManagerLock.Lock()
-	defer mm.onuMetricsManagerLock.Unlock()
+func (mm *OnuMetricsManager) updatePmData(ctx context.Context, groupName string, meInstanceID uint16, pmAction string) error {
+	logger.Debugw(ctx, "updatePmData - start", log.Fields{"device-id": mm.deviceID, "groupName": groupName, "entityID": meInstanceID, "pmAction": pmAction})
+	mm.OnuMetricsManagerLock.Lock()
+	defer mm.OnuMetricsManagerLock.Unlock()
 
 	if mm.pmKvStore == nil {
-		logger.Errorw(ctx, "pmKvStore not set - abort", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
-		return fmt.Errorf(fmt.Sprintf("pmKvStore-not-set-abort-%s", mm.pDeviceHandler.deviceID))
+		logger.Errorw(ctx, "pmKvStore not set - abort", log.Fields{"device-id": mm.deviceID})
+		return fmt.Errorf(fmt.Sprintf("pmKvStore-not-set-abort-%s", mm.deviceID))
 	}
 
 	pmMEData, err := mm.getPmData(ctx, groupName)
@@ -2828,11 +2848,11 @@
 		pmMEData.InstancesToAdd = mm.removeIfFoundUint16(pmMEData.InstancesToAdd, meInstanceID)
 		pmMEData.InstancesActive = mm.removeIfFoundUint16(pmMEData.InstancesActive, meInstanceID)
 	default:
-		logger.Errorw(ctx, "unknown pm action", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "pmAction": pmAction, "groupName": groupName})
-		return fmt.Errorf(fmt.Sprintf("unknown-pm-action-deviceid-%s-groupName-%s-pmaction-%s", mm.pDeviceHandler.deviceID, groupName, pmAction))
+		logger.Errorw(ctx, "unknown pm action", log.Fields{"device-id": mm.deviceID, "pmAction": pmAction, "groupName": groupName})
+		return fmt.Errorf(fmt.Sprintf("unknown-pm-action-deviceid-%s-groupName-%s-pmaction-%s", mm.deviceID, groupName, pmAction))
 	}
 	// write through cache
-	mm.groupMetricMap[groupName].pmMEData = pmMEData
+	mm.GroupMetricMap[groupName].pmMEData = pmMEData
 
 	Value, err := json.Marshal(*pmMEData)
 	if err != nil {
@@ -2844,83 +2864,86 @@
 		logger.Errorw(ctx, "unable to put PM data to kv store", log.Fields{"groupName": groupName, "pmData": *pmMEData, "pmAction": pmAction, "err": err})
 		return err
 	}
-	logger.Debugw(ctx, "updatePmData - success", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "groupName": groupName, "pmData": *pmMEData, "pmAction": pmAction})
+	logger.Debugw(ctx, "updatePmData - success", log.Fields{"device-id": mm.deviceID, "groupName": groupName, "pmData": *pmMEData, "pmAction": pmAction})
 
 	return nil
 }
 
 // clearPmGroupData cleans PM Group data from store
-func (mm *onuMetricsManager) clearPmGroupData(ctx context.Context) error {
-	mm.onuMetricsManagerLock.Lock()
-	defer mm.onuMetricsManagerLock.Unlock()
-	logger.Debugw(ctx, "clearPmGroupData - start", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+func (mm *OnuMetricsManager) clearPmGroupData(ctx context.Context) error {
+	mm.OnuMetricsManagerLock.Lock()
+	defer mm.OnuMetricsManagerLock.Unlock()
+	logger.Debugw(ctx, "clearPmGroupData - start", log.Fields{"device-id": mm.deviceID})
 	if mm.pmKvStore == nil {
-		logger.Errorw(ctx, "pmKvStore not set - abort", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
-		return fmt.Errorf(fmt.Sprintf("pmKvStore-not-set-abort-%s", mm.pDeviceHandler.deviceID))
+		logger.Errorw(ctx, "pmKvStore not set - abort", log.Fields{"device-id": mm.deviceID})
+		return fmt.Errorf(fmt.Sprintf("pmKvStore-not-set-abort-%s", mm.deviceID))
 	}
 
-	for n := range mm.groupMetricMap {
+	for n := range mm.GroupMetricMap {
 		if err := mm.pmKvStore.Delete(ctx, n); err != nil {
-			logger.Errorw(ctx, "clearPmGroupData - fail", log.Fields{"deviceID": mm.pDeviceHandler.deviceID, "groupName": n, "err": err})
+			logger.Errorw(ctx, "clearPmGroupData - fail", log.Fields{"deviceID": mm.deviceID, "groupName": n, "err": err})
 			// do not abort this procedure. continue to delete next group.
 		} else {
-			logger.Debugw(ctx, "clearPmGroupData - success", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "groupName": n})
+			logger.Debugw(ctx, "clearPmGroupData - success", log.Fields{"device-id": mm.deviceID, "groupName": n})
 		}
 	}
 
 	return nil
 }
 
-// clearAllPmData clears all PM data associated with the device from KV store
-func (mm *onuMetricsManager) clearAllPmData(ctx context.Context) error {
-	mm.onuMetricsManagerLock.Lock()
-	defer mm.onuMetricsManagerLock.Unlock()
-	logger.Debugw(ctx, "clearAllPmData - start", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+// ClearAllPmData clears all PM data associated with the device from KV store
+func (mm *OnuMetricsManager) ClearAllPmData(ctx context.Context) error {
+	mm.OnuMetricsManagerLock.Lock()
+	defer mm.OnuMetricsManagerLock.Unlock()
+	logger.Debugw(ctx, "ClearAllPmData - start", log.Fields{"device-id": mm.deviceID})
 	if mm.pmKvStore == nil {
-		logger.Errorw(ctx, "pmKvStore not set - abort", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
-		return fmt.Errorf(fmt.Sprintf("pmKvStore-not-set-abort-%s", mm.pDeviceHandler.deviceID))
+		logger.Errorw(ctx, "pmKvStore not set - abort", log.Fields{"device-id": mm.deviceID})
+		return fmt.Errorf(fmt.Sprintf("pmKvStore-not-set-abort-%s", mm.deviceID))
 	}
 	var value error
-	for n := range mm.groupMetricMap {
+	for n := range mm.GroupMetricMap {
 		if err := mm.pmKvStore.Delete(ctx, n); err != nil {
-			logger.Errorw(ctx, "clearPmGroupData - fail", log.Fields{"deviceID": mm.pDeviceHandler.deviceID, "groupName": n, "err": err})
+			logger.Errorw(ctx, "clearPmGroupData - fail", log.Fields{"deviceID": mm.deviceID, "groupName": n, "err": err})
 			value = err
 			// do not abort this procedure - continue to delete next group.
 		} else {
-			logger.Debugw(ctx, "clearPmGroupData - success", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "groupName": n})
+			logger.Debugw(ctx, "clearPmGroupData - success", log.Fields{"device-id": mm.deviceID, "groupName": n})
 		}
 	}
 	if value == nil {
-		logger.Debugw(ctx, "clearAllPmData - success", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+		logger.Debugw(ctx, "ClearAllPmData - success", log.Fields{"device-id": mm.deviceID})
 	}
 	return value
 }
 
-func (mm *onuMetricsManager) updateOmciProcessingStatus(status bool) {
-	mm.onuMetricsManagerLock.Lock()
-	defer mm.onuMetricsManagerLock.Unlock()
+func (mm *OnuMetricsManager) updateOmciProcessingStatus(status bool) {
+	mm.OnuMetricsManagerLock.Lock()
+	defer mm.OnuMetricsManagerLock.Unlock()
 	mm.omciProcessingActive = status
 }
 
-func (mm *onuMetricsManager) updateTickGenerationStatus(status bool) {
-	mm.onuMetricsManagerLock.Lock()
-	defer mm.onuMetricsManagerLock.Unlock()
+// updateTickGenerationStatus - TODO: add comment
+func (mm *OnuMetricsManager) updateTickGenerationStatus(status bool) {
+	mm.OnuMetricsManagerLock.Lock()
+	defer mm.OnuMetricsManagerLock.Unlock()
 	mm.tickGenerationActive = status
 }
 
-func (mm *onuMetricsManager) getOmciProcessingStatus() bool {
-	mm.onuMetricsManagerLock.RLock()
-	defer mm.onuMetricsManagerLock.RUnlock()
+// GetOmciProcessingStatus - TODO: add comment
+func (mm *OnuMetricsManager) GetOmciProcessingStatus() bool {
+	mm.OnuMetricsManagerLock.RLock()
+	defer mm.OnuMetricsManagerLock.RUnlock()
 	return mm.omciProcessingActive
 }
 
-func (mm *onuMetricsManager) getTickGenerationStatus() bool {
-	mm.onuMetricsManagerLock.RLock()
-	defer mm.onuMetricsManagerLock.RUnlock()
+// GetTickGenerationStatus - TODO: add comment
+func (mm *OnuMetricsManager) GetTickGenerationStatus() bool {
+	mm.OnuMetricsManagerLock.RLock()
+	defer mm.OnuMetricsManagerLock.RUnlock()
 	return mm.tickGenerationActive
 }
 
-func (mm *onuMetricsManager) appendIfMissingString(slice []string, n string) []string {
+func (mm *OnuMetricsManager) appendIfMissingString(slice []string, n string) []string {
 	for _, ele := range slice {
 		if ele == n {
 			return slice
@@ -2929,7 +2952,7 @@
 	return append(slice, n)
 }
 
-func (mm *onuMetricsManager) removeIfFoundString(slice []string, n string) []string {
+func (mm *OnuMetricsManager) removeIfFoundString(slice []string, n string) []string {
 	for i, ele := range slice {
 		if ele == n {
 			return append(slice[:i], slice[i+1:]...)
@@ -2938,7 +2961,7 @@
 	return slice
 }
 
-func (mm *onuMetricsManager) appendIfMissingUnt16(slice []uint16, n uint16) []uint16 {
+func (mm *OnuMetricsManager) appendIfMissingUnt16(slice []uint16, n uint16) []uint16 {
 	for _, ele := range slice {
 		if ele == n {
 			return slice
@@ -2947,7 +2970,7 @@
 	return append(slice, n)
 }
 
-func (mm *onuMetricsManager) removeIfFoundUint16(slice []uint16, n uint16) []uint16 {
+func (mm *OnuMetricsManager) removeIfFoundUint16(slice []uint16, n uint16) []uint16 {
 	for i, ele := range slice {
 		if ele == n {
 			return append(slice[:i], slice[i+1:]...)
@@ -2956,41 +2979,41 @@
 	return slice
 }
 
-func (mm *onuMetricsManager) getEthernetFrameExtendedMETypeFromKvStore(ctx context.Context) (bool, error) {
+func (mm *OnuMetricsManager) getEthernetFrameExtendedMETypeFromKvStore(ctx context.Context) (bool, error) {
 	// Check if the data is already available in KV store, if yes, do not send the request for get me.
 	var data me.ClassID
-	key := fmt.Sprintf("%s/%s/%s", mm.pDeviceHandler.pOnuOmciDevice.sOnuPersistentData.PersVendorID,
-		mm.pDeviceHandler.pOnuOmciDevice.sOnuPersistentData.PersEquipmentID,
-		mm.pDeviceHandler.pOnuOmciDevice.sOnuPersistentData.PersActiveSwVersion)
+	key := fmt.Sprintf("%s/%s/%s", mm.pOnuDeviceEntry.GetPersVendorID(),
+		mm.pOnuDeviceEntry.GetPersEquipmentID(),
+		mm.pOnuDeviceEntry.GetPersActiveSwVersion())
 	Value, err := mm.extPmKvStore.Get(ctx, key)
 	if err == nil {
 		if Value != nil {
 			logger.Debugw(ctx, "me-type-read",
-				log.Fields{"key": Value.Key, "device-id": mm.pDeviceHandler.deviceID})
+				log.Fields{"key": Value.Key, "device-id": mm.deviceID})
 			tmpBytes, _ := kvstore.ToByte(Value.Value)
 
 			if err = json.Unmarshal(tmpBytes, &data); err != nil {
-				logger.Errorw(ctx, "unable-to-unmarshal-data", log.Fields{"error": err, "device-id": mm.pDeviceHandler.deviceID})
+				logger.Errorw(ctx, "unable-to-unmarshal-data", log.Fields{"error": err, "device-id": mm.deviceID})
 				return false, err
 			}
-			logger.Debugw(ctx, "me-ext-pm-class-data", log.Fields{"class-id": data, "device-id": mm.pDeviceHandler.deviceID})
+			logger.Debugw(ctx, "me-ext-pm-class-data", log.Fields{"class-id": data, "device-id": mm.deviceID})
 			// We have found the data from db, no need to get through omci get message.
 			mm.supportedEthernetFrameExtendedPMClass = data
 			return true, nil
 		}
-		logger.Debugw(ctx, "no-me-ext-pm-class-data-found", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+		logger.Debugw(ctx, "no-me-ext-pm-class-data-found", log.Fields{"device-id": mm.deviceID})
 		return false, nil
 	}
-	logger.Errorw(ctx, "unable-to-read-from-kv-store", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+	logger.Errorw(ctx, "unable-to-read-from-kv-store", log.Fields{"device-id": mm.deviceID})
 	return false, err
 }
 
-func (mm *onuMetricsManager) waitForEthernetFrameCreateOrDeleteResponseOrTimeout(ctx context.Context, create bool, instID uint16, meClassID me.ClassID, upstream bool) (bool, error) {
+func (mm *OnuMetricsManager) waitForEthernetFrameCreateOrDeleteResponseOrTimeout(ctx context.Context, create bool, instID uint16, meClassID me.ClassID, upstream bool) (bool, error) {
 	logger.Debugw(ctx, "wait-for-ethernet-frame-create-or-delete-response-or-timeout", log.Fields{"create": create, "instID": instID, "meClassID": meClassID})
 	select {
 	case resp := <-mm.extendedPMCreateOrDeleteResponseChan:
 		logger.Debugw(ctx, "received-extended-pm-me-response",
-			log.Fields{"device-id": mm.pDeviceHandler.deviceID, "resp": resp, "create": create, "meClassID": meClassID, "instID": instID, "upstream": upstream})
+			log.Fields{"device-id": mm.deviceID, "resp": resp, "create": create, "meClassID": meClassID, "instID": instID, "upstream": upstream})
 		// If the result is me.InstanceExists it means the entity was already created. It is ok handled that as success
 		if resp == me.Success || resp == me.InstanceExists {
 			return true, nil
@@ -2998,40 +3021,40 @@
 			resp == me.ProcessingError || resp == me.NotSupported || resp == me.AttributeFailure {
 			return false, fmt.Errorf("not-supported-me--resp-code-%v", resp)
 		} else {
-			logger.Warnw(ctx, "failed to create me", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "resp": resp, "class-id": meClassID, "instID": instID, "upstream": upstream})
+			logger.Warnw(ctx, "failed to create me", log.Fields{"device-id": mm.deviceID, "resp": resp, "class-id": meClassID, "instID": instID, "upstream": upstream})
 			return true, fmt.Errorf("error-while-creating-me--resp-code-%v", resp)
 		}
-	case <-time.After(mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.GetMaxOmciTimeoutWithRetries() * time.Second):
+	case <-time.After(mm.pOnuDeviceEntry.GetDevOmciCC().GetMaxOmciTimeoutWithRetries() * time.Second):
 		logger.Errorw(ctx, "timeout-waiting-for-ext-pm-me-response",
-			log.Fields{"device-id": mm.pDeviceHandler.deviceID, "resp": false, "create": create, "meClassID": meClassID, "instID": instID, "upstream": upstream})
+			log.Fields{"device-id": mm.deviceID, "resp": false, "create": create, "meClassID": meClassID, "instID": instID, "upstream": upstream})
 	}
 	return false, fmt.Errorf("timeout-while-waiting-for-response")
 }
 
-func (mm *onuMetricsManager) tryCreateExtPmMe(ctx context.Context, meType me.ClassID) (bool, error) {
+func (mm *OnuMetricsManager) tryCreateExtPmMe(ctx context.Context, meType me.ClassID) (bool, error) {
 	cnt := 0
 	// Create ME twice, one for each direction. Boolean true is used to indicate upstream and false for downstream.
 	for _, direction := range []bool{true, false} {
-		for _, uniPort := range mm.pDeviceHandler.uniEntityMap {
+		for _, uniPort := range *mm.pDeviceHandler.GetUniEntityMap() {
 			var entityID uint16
 			if direction {
-				entityID = uniPort.entityID + 0x100
+				entityID = uniPort.EntityID + 0x100
 			} else {
-				entityID = uniPort.entityID
+				entityID = uniPort.EntityID
 			}
 
 			// parent entity id will be same for both direction
-			controlBlock := mm.getControlBlockForExtendedPMDirection(ctx, direction, uniPort.entityID)
+			controlBlock := mm.getControlBlockForExtendedPMDirection(ctx, direction, uniPort.EntityID)
 
 		inner1:
 			// retry ExtendedPmCreateAttempts times to create the instance of PM
 			for cnt = 0; cnt < ExtendedPmCreateAttempts; cnt++ {
-				meEnt, err := mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.sendCreateOrDeleteEthernetFrameExtendedPMME(
-					ctx, mm.pDeviceHandler.pOpenOnuAc.omciTimeout, true, direction, true,
-					mm.pAdaptFsm.commChan, entityID, meType, controlBlock)
+				meEnt, err := mm.pOnuDeviceEntry.GetDevOmciCC().SendCreateOrDeleteEthernetFrameExtendedPMME(
+					ctx, mm.pDeviceHandler.GetOmciTimeout(), true, direction, true,
+					mm.PAdaptFsm.CommChan, entityID, meType, controlBlock)
 				if err != nil {
 					logger.Errorw(ctx, "EthernetFrameExtendedPMME-create-or-delete-failed",
-						log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+						log.Fields{"device-id": mm.deviceID})
 					return false, err
 				}
 				if supported, err := mm.waitForEthernetFrameCreateOrDeleteResponseOrTimeout(ctx, true, entityID, meType, direction); err == nil && supported {
@@ -3058,10 +3081,10 @@
 	return true, nil
 }
 
-func (mm *onuMetricsManager) putExtPmMeKvStore(ctx context.Context) {
-	key := fmt.Sprintf("%s/%s/%s", mm.pDeviceHandler.pOnuOmciDevice.sOnuPersistentData.PersVendorID,
-		mm.pDeviceHandler.pOnuOmciDevice.sOnuPersistentData.PersEquipmentID,
-		mm.pDeviceHandler.pOnuOmciDevice.sOnuPersistentData.PersActiveSwVersion)
+func (mm *OnuMetricsManager) putExtPmMeKvStore(ctx context.Context) {
+	key := fmt.Sprintf("%s/%s/%s", mm.pOnuDeviceEntry.GetPersVendorID(),
+		mm.pOnuDeviceEntry.GetPersEquipmentID(),
+		mm.pOnuDeviceEntry.GetPersActiveSwVersion())
 	// check if we get the supported type me for ethernet frame extended pm class id
 	if mm.supportedEthernetFrameExtendedPMClass == 0 {
 		logger.Error(ctx, "unable-to-get-any-supported-extended-pm-me-class")
@@ -3075,12 +3098,14 @@
 	}
 }
 
-func (mm *onuMetricsManager) setAllExtPmMeCreatedFlag() {
+func (mm *OnuMetricsManager) setAllExtPmMeCreatedFlag() {
 	mm.onuEthernetFrameExtendedPmLock.Lock()
 	mm.isDeviceReadyToCollectExtendedPmStats = true
 	mm.onuEthernetFrameExtendedPmLock.Unlock()
 }
-func (mm *onuMetricsManager) createEthernetFrameExtendedPMME(ctx context.Context) {
+
+// CreateEthernetFrameExtendedPMME - TODO: add comment
+func (mm *OnuMetricsManager) CreateEthernetFrameExtendedPMME(ctx context.Context) {
 	//get the type of extended frame pm me supported by onu first
 	exist, err := mm.getEthernetFrameExtendedMETypeFromKvStore(ctx)
 	if err != nil {
@@ -3090,7 +3115,7 @@
 	if exist {
 		// we have the me type, go ahead with the me type supported.
 		if _, err := mm.tryCreateExtPmMe(ctx, mm.supportedEthernetFrameExtendedPMClass); err != nil {
-			logger.Errorw(ctx, "unable-to-create-me-type", log.Fields{"device-id": mm.pDeviceHandler.deviceID,
+			logger.Errorw(ctx, "unable-to-create-me-type", log.Fields{"device-id": mm.deviceID,
 				"meClassID": mm.supportedEthernetFrameExtendedPMClass})
 			return
 		}
@@ -3102,11 +3127,11 @@
 	supported64Bit, err := mm.tryCreateExtPmMe(ctx, me.EthernetFrameExtendedPm64BitClassID)
 	if err != nil && !supported64Bit {
 		logger.Errorw(ctx, "unable-to-create-me-type-as-it-is-not-supported",
-			log.Fields{"device-id": mm.pDeviceHandler.deviceID, "meClassID": me.EthernetFrameExtendedPm64BitClassID,
+			log.Fields{"device-id": mm.deviceID, "meClassID": me.EthernetFrameExtendedPm64BitClassID,
 				"supported": supported64Bit})
 		// Then Try with 32 bit type
 		if supported32Bit, err := mm.tryCreateExtPmMe(ctx, me.EthernetFrameExtendedPmClassID); err != nil {
-			logger.Errorw(ctx, "unable-to-create-me-type", log.Fields{"device-id": mm.pDeviceHandler.deviceID,
+			logger.Errorw(ctx, "unable-to-create-me-type", log.Fields{"device-id": mm.deviceID,
 				"meClassID": me.EthernetFrameExtendedPmClassID, "supported": supported32Bit})
 		} else if supported32Bit {
 			mm.supportedEthernetFrameExtendedPMClass = me.EthernetFrameExtendedPmClassID
@@ -3120,7 +3145,8 @@
 	}
 }
 
-func (mm *onuMetricsManager) collectEthernetFrameExtendedPMCounters(ctx context.Context) *extension.SingleGetValueResponse {
+// CollectEthernetFrameExtendedPMCounters - TODO: add comment
+func (mm *OnuMetricsManager) CollectEthernetFrameExtendedPMCounters(ctx context.Context) *extension.SingleGetValueResponse {
 	errFunc := func(reason extension.GetValueResponse_ErrorReason) *extension.SingleGetValueResponse {
 		return &extension.SingleGetValueResponse{
 			Response: &extension.GetValueResponse{
@@ -3188,9 +3214,9 @@
 	return &singleValResp
 }
 
-func (mm *onuMetricsManager) collectEthernetFrameExtendedPMData(ctx context.Context, meEnt *me.ManagedEntity, entityID uint16, upstream bool, receivedMask *uint16) (map[string]uint64, extension.GetValueResponse_ErrorReason) {
+func (mm *OnuMetricsManager) collectEthernetFrameExtendedPMData(ctx context.Context, meEnt *me.ManagedEntity, entityID uint16, upstream bool, receivedMask *uint16) (map[string]uint64, extension.GetValueResponse_ErrorReason) {
 	var classID me.ClassID
-	logger.Debugw(ctx, "collecting-data-for-ethernet-frame-extended-pm", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "entityID": entityID, "upstream": upstream})
+	logger.Debugw(ctx, "collecting-data-for-ethernet-frame-extended-pm", log.Fields{"device-id": mm.deviceID, "entityID": entityID, "upstream": upstream})
 
 	classID = mm.supportedEthernetFrameExtendedPMClass
 	attributeMaskList := maskToEthernetFrameExtendedPM64Bit
@@ -3202,7 +3228,7 @@
 	for mask := range attributeMaskList {
 		if errResp, err := mm.populateEthernetFrameExtendedPMMetrics(ctx, classID, entityID, mask, ethPMData, upstream, &sumReceivedMask); err != nil {
 			logger.Errorw(ctx, "error-during-metric-collection",
-				log.Fields{"device-id": mm.pDeviceHandler.deviceID, "entityID": entityID, "err": err})
+				log.Fields{"device-id": mm.deviceID, "entityID": entityID, "err": err})
 			return nil, errResp
 		}
 		if (mask == 0x3F00 || mask == 0x3800) && sumReceivedMask == 0 {
@@ -3217,22 +3243,22 @@
 }
 
 // nolint: gocyclo
-func (mm *onuMetricsManager) populateEthernetFrameExtendedPMMetrics(ctx context.Context, classID me.ClassID, entityID uint16,
+func (mm *OnuMetricsManager) populateEthernetFrameExtendedPMMetrics(ctx context.Context, classID me.ClassID, entityID uint16,
 	requestedAttributesMask uint16, ethFrameExtPMData map[string]uint64, upstream bool, sumReceivedMask *uint16) (extension.GetValueResponse_ErrorReason, error) {
 	var meAttributes me.AttributeValueMap
 	logger.Debugw(ctx, "requesting-attributes", log.Fields{"attributes-mask": requestedAttributesMask, "entityID": entityID, "classID": classID})
-	err := mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.sendGetMeWithAttributeMask(ctx, classID, entityID, requestedAttributesMask, mm.pDeviceHandler.pOpenOnuAc.omciTimeout, true, mm.pAdaptFsm.commChan)
+	err := mm.pOnuDeviceEntry.GetDevOmciCC().SendGetMeWithAttributeMask(ctx, classID, entityID, requestedAttributesMask, mm.pDeviceHandler.GetOmciTimeout(), true, mm.PAdaptFsm.CommChan)
 	if err != nil {
-		logger.Errorw(ctx, "get-me-failed", log.Fields{"device-id": mm.pAdaptFsm.deviceID})
+		logger.Errorw(ctx, "get-me-failed", log.Fields{"device-id": mm.deviceID})
 		return extension.GetValueResponse_INTERNAL_ERROR, err
 	}
 	select {
 	case meAttributes = <-mm.extendedPmMeChan:
 		logger.Debugw(ctx, "received-extended-pm-data",
-			log.Fields{"device-id": mm.pDeviceHandler.deviceID, "upstream": upstream, "entityID": entityID})
-	case <-time.After(mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.GetMaxOmciTimeoutWithRetries() * time.Second):
+			log.Fields{"device-id": mm.deviceID, "upstream": upstream, "entityID": entityID})
+	case <-time.After(mm.pOnuDeviceEntry.GetDevOmciCC().GetMaxOmciTimeoutWithRetries() * time.Second):
 		logger.Errorw(ctx, "timeout-waiting-for-omci-get-response-for-received-extended-pm-data",
-			log.Fields{"device-id": mm.pDeviceHandler.deviceID, "upstream": upstream, "entityID": entityID})
+			log.Fields{"device-id": mm.deviceID, "upstream": upstream, "entityID": entityID})
 		return extension.GetValueResponse_TIMEOUT, fmt.Errorf("timeout-waiting-for-omci-get-response-for-received-extended-pm-data")
 	}
 	if mm.supportedEthernetFrameExtendedPMClass == me.EthernetFrameExtendedPmClassID {
@@ -3248,7 +3274,7 @@
 	return extension.GetValueResponse_REASON_UNDEFINED, nil
 }
 
-func (mm *onuMetricsManager) fillAllErrorCountersEthernetFrameExtendedPM(ethFrameExtPMData map[string]uint64) {
+func (mm *OnuMetricsManager) fillAllErrorCountersEthernetFrameExtendedPM(ethFrameExtPMData map[string]uint64) {
 	sourceMap := maskToEthernetFrameExtendedPM64Bit
 	errorCounterValue := UnsupportedCounterValue64bit
 	if mm.supportedEthernetFrameExtendedPMClass == me.EthernetFrameExtendedPmClassID {
@@ -3265,7 +3291,7 @@
 }
 
 // nolint: gocyclo
-func (mm *onuMetricsManager) getEthFrameExtPMDataFromResponse(ctx context.Context, ethFrameExtPMData map[string]uint64, meAttributes me.AttributeValueMap, requestedAttributesMask uint16) uint16 {
+func (mm *OnuMetricsManager) getEthFrameExtPMDataFromResponse(ctx context.Context, ethFrameExtPMData map[string]uint64, meAttributes me.AttributeValueMap, requestedAttributesMask uint16) uint16 {
 	receivedMask := uint16(0)
 	switch requestedAttributesMask {
 	case 0x3F00:
@@ -3400,7 +3426,7 @@
 }
 
 // nolint: gocyclo
-func (mm *onuMetricsManager) getEthFrameExtPM64BitDataFromResponse(ctx context.Context, ethFrameExtPMData map[string]uint64, meAttributes me.AttributeValueMap, requestedAttributesMask uint16) uint16 {
+func (mm *OnuMetricsManager) getEthFrameExtPM64BitDataFromResponse(ctx context.Context, ethFrameExtPMData map[string]uint64, meAttributes me.AttributeValueMap, requestedAttributesMask uint16) uint16 {
 	receivedMask := uint16(0)
 	switch requestedAttributesMask {
 	case 0x3800:
@@ -3544,7 +3570,7 @@
 	return receivedMask
 }
 
-func (mm *onuMetricsManager) aggregateEthernetFrameExtendedPM(pmDataIn map[string]uint64, pmData extension.OmciEthernetFrameExtendedPm, aggregate bool) extension.OmciEthernetFrameExtendedPm {
+func (mm *OnuMetricsManager) aggregateEthernetFrameExtendedPM(pmDataIn map[string]uint64, pmData extension.OmciEthernetFrameExtendedPm, aggregate bool) extension.OmciEthernetFrameExtendedPm {
 	mm.onuEthernetFrameExtendedPmLock.Lock()
 	defer mm.onuEthernetFrameExtendedPmLock.Unlock()
 	errorCounterValue := UnsupportedCounterValue64bit
@@ -3642,7 +3668,7 @@
 	return pmDataOut
 }
 
-func (mm *onuMetricsManager) getControlBlockForExtendedPMDirection(ctx context.Context, upstream bool, entityID uint16) []uint16 {
+func (mm *OnuMetricsManager) getControlBlockForExtendedPMDirection(ctx context.Context, upstream bool, entityID uint16) []uint16 {
 	controlBlock := make([]uint16, 8)
 	// Control Block First two bytes are for threshold data 1/2 id - does not matter here
 	controlBlock[0] = 0
diff --git a/internal/pkg/onuadaptercore/adapter_download_manager.go b/internal/pkg/swupg/adapter_download_manager.go
old mode 100644
new mode 100755
similarity index 89%
rename from internal/pkg/onuadaptercore/adapter_download_manager.go
rename to internal/pkg/swupg/adapter_download_manager.go
index 6328f72..64f5324
--- a/internal/pkg/onuadaptercore/adapter_download_manager.go
+++ b/internal/pkg/swupg/adapter_download_manager.go
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package swupg provides the utilities for onu sw upgrade
+package swupg
 
 import (
 	"bufio"
@@ -43,23 +43,23 @@
 
 // ### downloadToAdapter  			    - end ####
 
-//adapterDownloadManager structure holds information needed for downloading to and storing images within the adapter
-type adapterDownloadManager struct {
+//AdapterDownloadManager structure holds information needed for downloading to and storing images within the adapter
+type AdapterDownloadManager struct {
 	mutexDownloadImageDsc sync.RWMutex
 	downloadImageDscSlice []*voltha.ImageDownload
 }
 
-//newAdapterDownloadManager constructor returns a new instance of a adapterDownloadManager
+//NewAdapterDownloadManager constructor returns a new instance of a AdapterDownloadManager
 //mib_db (as well as not inluded alarm_db not really used in this code? VERIFY!!)
-func newAdapterDownloadManager(ctx context.Context) *adapterDownloadManager {
-	logger.Debug(ctx, "init-adapterDownloadManager")
-	var localDnldMgr adapterDownloadManager
+func NewAdapterDownloadManager(ctx context.Context) *AdapterDownloadManager {
+	logger.Debug(ctx, "init-AdapterDownloadManager")
+	var localDnldMgr AdapterDownloadManager
 	localDnldMgr.downloadImageDscSlice = make([]*voltha.ImageDownload, 0)
 	return &localDnldMgr
 }
 
-//imageExists returns true if the requested image already exists within the adapter
-func (dm *adapterDownloadManager) imageExists(ctx context.Context, apImageDsc *voltha.ImageDownload) bool {
+//ImageExists returns true if the requested image already exists within the adapter
+func (dm *AdapterDownloadManager) ImageExists(ctx context.Context, apImageDsc *voltha.ImageDownload) bool {
 	logger.Debugw(ctx, "checking on existence of the image", log.Fields{"image-name": (*apImageDsc).Name})
 	dm.mutexDownloadImageDsc.RLock()
 	defer dm.mutexDownloadImageDsc.RUnlock()
@@ -74,8 +74,8 @@
 	return false
 }
 
-//imageLocallyDownloaded returns true if the requested image already exists within the adapter
-func (dm *adapterDownloadManager) imageLocallyDownloaded(ctx context.Context, apImageDsc *voltha.ImageDownload) bool {
+//ImageLocallyDownloaded returns true if the requested image already exists within the adapter
+func (dm *AdapterDownloadManager) ImageLocallyDownloaded(ctx context.Context, apImageDsc *voltha.ImageDownload) bool {
 	logger.Debugw(ctx, "checking if image is fully downloaded", log.Fields{"image-name": (*apImageDsc).Name})
 	dm.mutexDownloadImageDsc.RLock()
 	defer dm.mutexDownloadImageDsc.RUnlock()
@@ -96,8 +96,8 @@
 	return false
 }
 
-//startDownload returns true if the download of the requested image could be started
-func (dm *adapterDownloadManager) startDownload(ctx context.Context, apImageDsc *voltha.ImageDownload) error {
+//StartDownload returns true if the download of the requested image could be started
+func (dm *AdapterDownloadManager) StartDownload(ctx context.Context, apImageDsc *voltha.ImageDownload) error {
 	if apImageDsc.LocalDir != "" {
 		logger.Infow(ctx, "image download-to-adapter requested", log.Fields{
 			"image-path": apImageDsc.LocalDir, "image-name": apImageDsc.Name})
@@ -120,7 +120,7 @@
 }
 
 //downloadFile downloads the specified file from the given http location
-func (dm *adapterDownloadManager) downloadFile(ctx context.Context, aURLName string, aFilePath string, aFileName string) error {
+func (dm *AdapterDownloadManager) downloadFile(ctx context.Context, aURLName string, aFilePath string, aFileName string) error {
 	// Get the data
 	logger.Infow(ctx, "downloading from http", log.Fields{"url": aURLName, "localPath": aFilePath})
 	// http command is already part of the aURLName argument
@@ -173,7 +173,7 @@
 	return nil
 }
 
-func (dm *adapterDownloadManager) requestDownload(ctx context.Context, urlBase *url.URL, aFilePath, aFileName string) {
+func (dm *AdapterDownloadManager) requestDownload(ctx context.Context, urlBase *url.URL, aFilePath, aFileName string) {
 	req, err2 := http.NewRequest("GET", urlBase.String(), nil)
 	if err2 != nil {
 		logger.Errorw(ctx, "could not generate http request", log.Fields{"url": urlBase.String(), "error": err2})
@@ -238,7 +238,7 @@
 }
 
 //getImageBufferLen returns the length of the specified file in bytes (file size)
-func (dm *adapterDownloadManager) getImageBufferLen(ctx context.Context, aFileName string,
+func (dm *AdapterDownloadManager) getImageBufferLen(ctx context.Context, aFileName string,
 	aLocalPath string) (int64, error) {
 	//maybe we can also use FileSize from dm.downloadImageDscSlice - future option?
 
@@ -262,7 +262,7 @@
 }
 
 //getDownloadImageBuffer returns the content of the requested file as byte slice
-func (dm *adapterDownloadManager) getDownloadImageBuffer(ctx context.Context, aFileName string,
+func (dm *AdapterDownloadManager) getDownloadImageBuffer(ctx context.Context, aFileName string,
 	aLocalPath string) ([]byte, error) {
 	file, err := os.Open(filepath.Clean(aLocalPath + "/" + aFileName))
 	if err != nil {
diff --git a/internal/pkg/onuadaptercore/common.go b/internal/pkg/swupg/common.go
old mode 100644
new mode 100755
similarity index 86%
copy from internal/pkg/onuadaptercore/common.go
copy to internal/pkg/swupg/common.go
index b0b10e3..b933bef
--- a/internal/pkg/onuadaptercore/common.go
+++ b/internal/pkg/swupg/common.go
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package swupg provides the utilities for onu sw upgrade
+package swupg
 
 import (
 	"github.com/opencord/voltha-lib-go/v7/pkg/log"
@@ -26,7 +26,7 @@
 func init() {
 	// Setup this package so that it's log level can be modified at run time
 	var err error
-	logger, err = log.RegisterPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "adaptercoreonu"})
+	logger, err = log.RegisterPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "swupg"})
 	if err != nil {
 		panic(err)
 	}
diff --git a/internal/pkg/onuadaptercore/file_download_manager.go b/internal/pkg/swupg/file_download_manager.go
old mode 100644
new mode 100755
similarity index 92%
rename from internal/pkg/onuadaptercore/file_download_manager.go
rename to internal/pkg/swupg/file_download_manager.go
index 5c3226e..900ba5a
--- a/internal/pkg/onuadaptercore/file_download_manager.go
+++ b/internal/pkg/swupg/file_download_manager.go
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package swupg provides the utilities for onu sw upgrade
+package swupg
 
 import (
 	"bufio"
@@ -57,19 +57,19 @@
 
 type requesterChannelMap map[chan<- bool]struct{} //using an empty structure map for easier (unique) element appending
 
-//fileDownloadManager structure holds information needed for downloading to and storing images within the adapter
-type fileDownloadManager struct {
+//FileDownloadManager structure holds information needed for downloading to and storing images within the adapter
+type FileDownloadManager struct {
 	mutexDownloadImageDsc sync.RWMutex
 	downloadImageDscSlice []downloadImageParams
 	dnldImgReadyWaiting   map[string]requesterChannelMap
 	dlToAdapterTimeout    time.Duration
 }
 
-//newFileDownloadManager constructor returns a new instance of a fileDownloadManager
+//NewFileDownloadManager constructor returns a new instance of a FileDownloadManager
 //mib_db (as well as not inluded alarm_db not really used in this code? VERIFY!!)
-func newFileDownloadManager(ctx context.Context) *fileDownloadManager {
-	logger.Debug(ctx, "init-fileDownloadManager")
-	var localDnldMgr fileDownloadManager
+func NewFileDownloadManager(ctx context.Context) *FileDownloadManager {
+	logger.Debug(ctx, "init-FileDownloadManager")
+	var localDnldMgr FileDownloadManager
 	localDnldMgr.downloadImageDscSlice = make([]downloadImageParams, 0)
 	localDnldMgr.dnldImgReadyWaiting = make(map[string]requesterChannelMap)
 	localDnldMgr.dlToAdapterTimeout = 10 * time.Second //default timeout, should be overwritten immediately after start
@@ -77,7 +77,7 @@
 }
 
 //SetDownloadTimeout configures the timeout used to supervice the download of the image to the adapter (assumed in seconds)
-func (dm *fileDownloadManager) SetDownloadTimeout(ctx context.Context, aDlTimeout time.Duration) {
+func (dm *FileDownloadManager) SetDownloadTimeout(ctx context.Context, aDlTimeout time.Duration) {
 	dm.mutexDownloadImageDsc.Lock()
 	defer dm.mutexDownloadImageDsc.Unlock()
 	logger.Debugw(ctx, "setting download timeout", log.Fields{"timeout": aDlTimeout})
@@ -85,14 +85,14 @@
 }
 
 //GetDownloadTimeout delivers the timeout used to supervice the download of the image to the adapter (assumed in seconds)
-func (dm *fileDownloadManager) GetDownloadTimeout(ctx context.Context) time.Duration {
+func (dm *FileDownloadManager) GetDownloadTimeout(ctx context.Context) time.Duration {
 	dm.mutexDownloadImageDsc.RLock()
 	defer dm.mutexDownloadImageDsc.RUnlock()
 	return dm.dlToAdapterTimeout
 }
 
 //ImageExists returns true if the requested image already exists within the adapter
-func (dm *fileDownloadManager) ImageExists(ctx context.Context, aImageName string) bool {
+func (dm *FileDownloadManager) ImageExists(ctx context.Context, aImageName string) bool {
 	logger.Debugw(ctx, "checking on existence of the image", log.Fields{"image-name": aImageName})
 	dm.mutexDownloadImageDsc.RLock()
 	defer dm.mutexDownloadImageDsc.RUnlock()
@@ -108,7 +108,7 @@
 }
 
 //StartDownload returns true if the download of the requested image could be started for the given file name and URL
-func (dm *fileDownloadManager) StartDownload(ctx context.Context, aImageName string, aURLCommand string) error {
+func (dm *FileDownloadManager) StartDownload(ctx context.Context, aImageName string, aURLCommand string) error {
 	logger.Infow(ctx, "image download-to-adapter requested", log.Fields{
 		"image-name": aImageName, "url-command": aURLCommand})
 	loDownloadImageParams := downloadImageParams{
@@ -126,7 +126,7 @@
 }
 
 //GetImageBufferLen returns the length of the specified file in bytes (file size) - as detected after download
-func (dm *fileDownloadManager) GetImageBufferLen(ctx context.Context, aFileName string) (int64, error) {
+func (dm *FileDownloadManager) GetImageBufferLen(ctx context.Context, aFileName string) (int64, error) {
 	dm.mutexDownloadImageDsc.RLock()
 	defer dm.mutexDownloadImageDsc.RUnlock()
 	for _, dnldImgDsc := range dm.downloadImageDscSlice {
@@ -139,7 +139,7 @@
 }
 
 //GetDownloadImageBuffer returns the content of the requested file as byte slice
-func (dm *fileDownloadManager) GetDownloadImageBuffer(ctx context.Context, aFileName string) ([]byte, error) {
+func (dm *FileDownloadManager) GetDownloadImageBuffer(ctx context.Context, aFileName string) ([]byte, error) {
 	file, err := os.Open(filepath.Clean(cDefaultLocalDir + "/" + aFileName))
 	if err != nil {
 		return nil, err
@@ -166,7 +166,7 @@
 }
 
 //RequestDownloadReady receives a channel that has to be used to inform the requester in case the concerned file is downloaded
-func (dm *fileDownloadManager) RequestDownloadReady(ctx context.Context, aFileName string, aWaitChannel chan<- bool) {
+func (dm *FileDownloadManager) RequestDownloadReady(ctx context.Context, aFileName string, aWaitChannel chan<- bool) {
 	//mutexDownloadImageDsc must already be locked here to avoid an update of the dnldImgReadyWaiting map
 	//  just after returning false on imageLocallyDownloaded() (not found) and immediate handling of the
 	//  download success (within updateFileState())
@@ -201,7 +201,7 @@
 }
 
 //RemoveReadyRequest removes the specified channel from the requester(channel) map for the given file name
-func (dm *fileDownloadManager) RemoveReadyRequest(ctx context.Context, aFileName string, aWaitChannel chan bool) {
+func (dm *FileDownloadManager) RemoveReadyRequest(ctx context.Context, aFileName string, aWaitChannel chan bool) {
 	dm.mutexDownloadImageDsc.Lock()
 	defer dm.mutexDownloadImageDsc.Unlock()
 	for imageName, channelMap := range dm.dnldImgReadyWaiting {
@@ -223,7 +223,7 @@
 
 //imageLocallyDownloaded returns true if the requested image already exists within the adapter
 //  requires mutexDownloadImageDsc to be locked (at least RLocked)
-func (dm *fileDownloadManager) imageLocallyDownloaded(ctx context.Context, aImageName string) bool {
+func (dm *FileDownloadManager) imageLocallyDownloaded(ctx context.Context, aImageName string) bool {
 	logger.Debugw(ctx, "checking if image is fully downloaded to adapter", log.Fields{"image-name": aImageName})
 	for _, dnldImgDsc := range dm.downloadImageDscSlice {
 		if dnldImgDsc.downloadImageName == aImageName {
@@ -242,7 +242,7 @@
 }
 
 //updateDownloadCancel sets context cancel function to be used in case the download is to be aborted
-func (dm *fileDownloadManager) updateDownloadCancel(ctx context.Context,
+func (dm *FileDownloadManager) updateDownloadCancel(ctx context.Context,
 	aImageName string, aCancelFn context.CancelFunc) {
 	dm.mutexDownloadImageDsc.Lock()
 	defer dm.mutexDownloadImageDsc.Unlock()
@@ -259,7 +259,7 @@
 }
 
 //updateFileState sets the new active (downloaded) file state and informs possibly waiting requesters on this change
-func (dm *fileDownloadManager) updateFileState(ctx context.Context, aImageName string, aFileSize int64) {
+func (dm *FileDownloadManager) updateFileState(ctx context.Context, aImageName string, aFileSize int64) {
 	dm.mutexDownloadImageDsc.Lock()
 	defer dm.mutexDownloadImageDsc.Unlock()
 	for imgKey, dnldImgDsc := range dm.downloadImageDscSlice {
@@ -287,7 +287,7 @@
 }
 
 //downloadFile downloads the specified file from the given http location
-func (dm *fileDownloadManager) downloadFile(ctx context.Context, aURLCommand string, aFilePath string, aFileName string) error {
+func (dm *FileDownloadManager) downloadFile(ctx context.Context, aURLCommand string, aFilePath string, aFileName string) error {
 	// Get the data
 	logger.Infow(ctx, "downloading with URL", log.Fields{"url": aURLCommand, "localPath": aFilePath})
 	// verifying the complete URL by parsing it to its URL elements
@@ -402,7 +402,7 @@
 }
 
 //removeImage deletes the given image according to the Image name from filesystem and downloadImageDscSlice
-func (dm *fileDownloadManager) removeImage(ctx context.Context, aImageName string, aDelFs bool) {
+func (dm *FileDownloadManager) removeImage(ctx context.Context, aImageName string, aDelFs bool) {
 	logger.Debugw(ctx, "remove the image from Adapter", log.Fields{"image-name": aImageName})
 	dm.mutexDownloadImageDsc.RLock()
 	defer dm.mutexDownloadImageDsc.RUnlock()
@@ -431,7 +431,7 @@
 }
 
 //CancelDownload stops the download and clears all entires concerning this aimageName
-func (dm *fileDownloadManager) CancelDownload(ctx context.Context, aImageName string) {
+func (dm *FileDownloadManager) CancelDownload(ctx context.Context, aImageName string) {
 	// for the moment that would only support to wait for the download end and remove the image then
 	//   further reactions while still downloading can be considered with some effort, but does it make sense (synchronous load here!)
 	dm.mutexDownloadImageDsc.RLock()
diff --git a/internal/pkg/onuadaptercore/omci_onu_upgrade.go b/internal/pkg/swupg/omci_onu_upgrade.go
old mode 100644
new mode 100755
similarity index 79%
rename from internal/pkg/onuadaptercore/omci_onu_upgrade.go
rename to internal/pkg/swupg/omci_onu_upgrade.go
index 8e8a82e..dbcb141
--- a/internal/pkg/onuadaptercore/omci_onu_upgrade.go
+++ b/internal/pkg/swupg/omci_onu_upgrade.go
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package swupg provides the utilities for onu sw upgrade
+package swupg
 
 import (
 	"context"
@@ -30,6 +30,8 @@
 	"github.com/opencord/omci-lib-go"
 	me "github.com/opencord/omci-lib-go/generated"
 	"github.com/opencord/voltha-lib-go/v7/pkg/log"
+	cmn "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/common"
+	"github.com/opencord/voltha-openonu-adapter-go/internal/pkg/devdb"
 	"github.com/opencord/voltha-protos/v5/go/voltha"
 )
 
@@ -47,71 +49,71 @@
 	//cOmciDownloadCompleteTimeout = 5400 //in s for the complete timeout (may be better scale to image size/ noOfWindows)
 )
 
+// events of config PON ANI port FSM
 const (
-	// events of config PON ANI port FSM
-	upgradeEvStart              = "upgradeEvStart"
-	upgradeEvDisable            = "upgradeEvDisable"
-	upgradeEvAdapterDownload    = "upgradeEvAdapterDownload"
-	upgradeEvPrepareSwDownload  = "upgradeEvPrepareSwDownload"
-	upgradeEvRxStartSwDownload  = "upgradeEvRxStartSwDownload"
-	upgradeEvWaitWindowAck      = "upgradeEvWaitWindowAck"
-	upgradeEvContinueNextWindow = "upgradeEvContinueNextWindow"
-	upgradeEvEndSwDownload      = "upgradeEvEndSwDownload"
-	upgradeEvWaitEndDownload    = "upgradeEvWaitEndDownload"
-	upgradeEvContinueFinalize   = "upgradeEvContinueFinalize"
-	upgradeEvCheckImageName     = "upgradeEvCheckImageName"
-	upgradeEvWaitForActivate    = "upgradeEvWaitForActivate"
-	upgradeEvRequestActivate    = "upgradeEvRequestActivate"
-	upgradeEvActivationDone     = "upgradeEvActivationDone"
-	upgradeEvWaitForCommit      = "upgradeEvWaitForCommit"
-	upgradeEvCommitSw           = "upgradeEvCommitSw"
-	upgradeEvCheckCommitted     = "upgradeEvCheckCommitted"
+	UpgradeEvStart              = "UpgradeEvStart"
+	UpgradeEvDisable            = "UpgradeEvDisable"
+	UpgradeEvAdapterDownload    = "UpgradeEvAdapterDownload"
+	UpgradeEvPrepareSwDownload  = "UpgradeEvPrepareSwDownload"
+	UpgradeEvRxStartSwDownload  = "UpgradeEvRxStartSwDownload"
+	UpgradeEvWaitWindowAck      = "UpgradeEvWaitWindowAck"
+	UpgradeEvContinueNextWindow = "UpgradeEvContinueNextWindow"
+	UpgradeEvEndSwDownload      = "UpgradeEvEndSwDownload"
+	UpgradeEvWaitEndDownload    = "UpgradeEvWaitEndDownload"
+	UpgradeEvContinueFinalize   = "UpgradeEvContinueFinalize"
+	UpgradeEvCheckImageName     = "UpgradeEvCheckImageName"
+	UpgradeEvWaitForActivate    = "UpgradeEvWaitForActivate"
+	UpgradeEvRequestActivate    = "UpgradeEvRequestActivate"
+	UpgradeEvActivationDone     = "UpgradeEvActivationDone"
+	UpgradeEvWaitForCommit      = "UpgradeEvWaitForCommit"
+	UpgradeEvCommitSw           = "UpgradeEvCommitSw"
+	UpgradeEvCheckCommitted     = "UpgradeEvCheckCommitted"
 
-	//upgradeEvTimeoutSimple  = "upgradeEvTimeoutSimple"
-	//upgradeEvTimeoutMids    = "upgradeEvTimeoutMids"
-	upgradeEvReset           = "upgradeEvReset"
-	upgradeEvAbort           = "upgradeEvAbort"
-	upgradeEvRestart         = "upgradeEvRestart"
-	upgradeEvAbortSwDownload = "upgradeEvAbortSwDownload"
+	//UpgradeEvTimeoutSimple  = "UpgradeEvTimeoutSimple"
+	//UpgradeEvTimeoutMids    = "UpgradeEvTimeoutMids"
+	UpgradeEvReset           = "UpgradeEvReset"
+	UpgradeEvAbort           = "UpgradeEvAbort"
+	UpgradeEvRestart         = "UpgradeEvRestart"
+	UpgradeEvAbortSwDownload = "UpgradeEvAbortSwDownload"
 )
 
+// states of config PON ANI port FSM
 const (
-	// states of config PON ANI port FSM
-	upgradeStDisabled           = "upgradeStDisabled"
-	upgradeStStarting           = "upgradeStStarting"
-	upgradeStWaitingAdapterDL   = "upgradeStWaitingAdapterDL"
-	upgradeStPreparingDL        = "upgradeStPreparingDL"
-	upgradeStDLSection          = "upgradeStDLSection"
-	upgradeStVerifyWindow       = "upgradeStVerifyWindow"
-	upgradeStFinalizeDL         = "upgradeStFinalizeDL"
-	upgradeStWaitEndDL          = "upgradeStWaitEndDL"
-	upgradeStCheckImageName     = "upgradeStCheckImageName"
-	upgradeStWaitForActivate    = "upgradeStWaitForActivate"
-	upgradeStRequestingActivate = "upgradeStRequestingActivate"
-	upgradeStActivated          = "upgradeStActivated"
-	upgradeStWaitForCommit      = "upgradeStWaitForCommit"
-	upgradeStCommitSw           = "upgradeStCommitSw"
-	upgradeStCheckCommitted     = "upgradeStCheckCommitted"
-	upgradeStResetting          = "upgradeStResetting"
-	upgradeStRestarting         = "upgradeStRestarting"
-	upgradeStAbortingDL         = "upgradeStAbortingDL"
+	UpgradeStDisabled           = "UpgradeStDisabled"
+	UpgradeStStarting           = "UpgradeStStarting"
+	UpgradeStWaitingAdapterDL   = "UpgradeStWaitingAdapterDL"
+	UpgradeStPreparingDL        = "UpgradeStPreparingDL"
+	UpgradeStDLSection          = "UpgradeStDLSection"
+	UpgradeStVerifyWindow       = "UpgradeStVerifyWindow"
+	UpgradeStFinalizeDL         = "UpgradeStFinalizeDL"
+	UpgradeStWaitEndDL          = "UpgradeStWaitEndDL"
+	UpgradeStCheckImageName     = "UpgradeStCheckImageName"
+	UpgradeStWaitForActivate    = "UpgradeStWaitForActivate"
+	UpgradeStRequestingActivate = "UpgradeStRequestingActivate"
+	UpgradeStActivated          = "UpgradeStActivated"
+	UpgradeStWaitForCommit      = "UpgradeStWaitForCommit"
+	UpgradeStCommitSw           = "UpgradeStCommitSw"
+	UpgradeStCheckCommitted     = "UpgradeStCheckCommitted"
+	UpgradeStResetting          = "UpgradeStResetting"
+	UpgradeStRestarting         = "UpgradeStRestarting"
+	UpgradeStAbortingDL         = "UpgradeStAbortingDL"
 )
 
-//required definition for IdleState detection for activities on OMCI
-const cOnuUpgradeFsmIdleState = upgradeStWaitForCommit
+//COnuUpgradeFsmIdleState - required definition for IdleState detection for activities on OMCI
+const COnuUpgradeFsmIdleState = UpgradeStWaitForCommit
 
 //OnuUpgradeFsm defines the structure for the state machine to config the PON ANI ports of ONU UNI ports via OMCI
 type OnuUpgradeFsm struct {
-	pDeviceHandler   *deviceHandler
-	pDownloadManager *adapterDownloadManager
-	pFileManager     *fileDownloadManager //used from R2.8 with new API version
+	pDeviceHandler   cmn.IdeviceHandler
+	pDownloadManager *AdapterDownloadManager
+	pFileManager     *FileDownloadManager //used from R2.8 with new API version
 	deviceID         string
-	pDevEntry        *OnuDeviceEntry
-	pOmciCC          *omciCC
-	pOnuDB           *onuDeviceDB
-	requestEvent     OnuDeviceEvent
+	pDevEntry        cmn.IonuDeviceEntry
+	pOmciCC          *cmn.OmciCC
+	pOnuDB           *devdb.OnuDeviceDB
+	requestEvent     cmn.OnuDeviceEvent
 	//omciMIdsResponseReceived chan bool //seperate channel needed for checking multiInstance OMCI message responses
-	pAdaptFsm                        *AdapterFsm
+	PAdaptFsm                        *cmn.AdapterFsm
 	pImageDsc                        *voltha.ImageDownload
 	imageBuffer                      []byte
 	origImageLength                  uint32        //as also limited by OMCI
@@ -124,7 +126,7 @@
 	nextDownloadSectionsWindow       uint8         //number of next section to download within current window
 	noOfWindows                      uint32        //uint32 range for windows should be sufficient for very long images
 	nextDownloadWindow               uint32        //number of next window to download
-	inactiveImageMeID                uint16        //ME-ID of the inactive image
+	InactiveImageMeID                uint16        //ME-ID of the inactive image
 	downloadToOnuTimeout4MB          time.Duration //timeout for downloading the image to the ONU for a 4MB image slice
 	omciSectionInterleaveDelay       time.Duration //DownloadSectionInterleave delay in milliseconds
 	delayEndSwDl                     bool          //flag to provide a delay between last section and EndSwDl
@@ -154,19 +156,19 @@
 
 //NewOnuUpgradeFsm is the 'constructor' for the state machine to config the PON ANI ports
 //  of ONU UNI ports via OMCI
-func NewOnuUpgradeFsm(ctx context.Context, apDeviceHandler *deviceHandler,
-	apDevEntry *OnuDeviceEntry, apOnuDB *onuDeviceDB,
-	aRequestEvent OnuDeviceEvent, aName string, aCommChannel chan Message) *OnuUpgradeFsm {
+func NewOnuUpgradeFsm(ctx context.Context, apDeviceHandler cmn.IdeviceHandler,
+	apDevEntry cmn.IonuDeviceEntry, apOnuDB *devdb.OnuDeviceDB,
+	aRequestEvent cmn.OnuDeviceEvent, aName string, aCommChannel chan cmn.Message) *OnuUpgradeFsm {
 	instFsm := &OnuUpgradeFsm{
 		pDeviceHandler:              apDeviceHandler,
-		deviceID:                    apDeviceHandler.deviceID,
+		deviceID:                    apDeviceHandler.GetDeviceID(),
 		pDevEntry:                   apDevEntry,
-		pOmciCC:                     apDevEntry.PDevOmciCC,
+		pOmciCC:                     apDevEntry.GetDevOmciCC(),
 		pOnuDB:                      apOnuDB,
 		requestEvent:                aRequestEvent,
 		omciDownloadWindowSizeLimit: cOmciDownloadWindowSizeLimit,
 		omciSectionInterleaveDelay:  cOmciSectionInterleaveMilliseconds,
-		downloadToOnuTimeout4MB:     apDeviceHandler.pOpenOnuAc.dlToOnuTimeout4M,
+		downloadToOnuTimeout4MB:     apDeviceHandler.GetDlToOnuTimeout4M(),
 		waitCountEndSwDl:            cWaitCountEndSwDl,
 		waitDelayEndSwDl:            cWaitDelayEndSwDlSeconds,
 		volthaDownloadState:         voltha.ImageState_DOWNLOAD_STARTED, //if FSM created we can assume that the download (to adapter) really started
@@ -179,81 +181,81 @@
 	instFsm.chOnuDlReady = make(chan bool)
 	instFsm.chReceiveAbortEndSwDlResponse = make(chan bool)
 
-	instFsm.pAdaptFsm = NewAdapterFsm(aName, instFsm.deviceID, aCommChannel)
-	if instFsm.pAdaptFsm == nil {
+	instFsm.PAdaptFsm = cmn.NewAdapterFsm(aName, instFsm.deviceID, aCommChannel)
+	if instFsm.PAdaptFsm == nil {
 		logger.Errorw(ctx, "OnuUpgradeFsm's AdapterFsm could not be instantiated!!", log.Fields{
 			"device-id": instFsm.deviceID})
 		return nil
 	}
-	instFsm.pAdaptFsm.pFsm = fsm.NewFSM(
-		upgradeStDisabled,
+	instFsm.PAdaptFsm.PFsm = fsm.NewFSM(
+		UpgradeStDisabled,
 		fsm.Events{
-			{Name: upgradeEvStart, Src: []string{upgradeStDisabled}, Dst: upgradeStStarting},
-			{Name: upgradeEvAdapterDownload, Src: []string{upgradeStStarting}, Dst: upgradeStWaitingAdapterDL},
-			{Name: upgradeEvPrepareSwDownload, Src: []string{upgradeStStarting, upgradeStWaitingAdapterDL}, Dst: upgradeStPreparingDL},
-			{Name: upgradeEvRxStartSwDownload, Src: []string{upgradeStPreparingDL}, Dst: upgradeStDLSection},
-			{Name: upgradeEvWaitWindowAck, Src: []string{upgradeStDLSection}, Dst: upgradeStVerifyWindow},
-			{Name: upgradeEvContinueNextWindow, Src: []string{upgradeStVerifyWindow}, Dst: upgradeStDLSection},
-			{Name: upgradeEvEndSwDownload, Src: []string{upgradeStVerifyWindow}, Dst: upgradeStFinalizeDL},
-			{Name: upgradeEvWaitEndDownload, Src: []string{upgradeStFinalizeDL}, Dst: upgradeStWaitEndDL},
-			{Name: upgradeEvContinueFinalize, Src: []string{upgradeStWaitEndDL}, Dst: upgradeStFinalizeDL},
-			//upgradeStCheckImageName only used with useAPIVersion43
-			{Name: upgradeEvCheckImageName, Src: []string{upgradeStWaitEndDL}, Dst: upgradeStCheckImageName},
-			//upgradeEvWaitForActivate state transitions depend on useAPIVersion43
-			{Name: upgradeEvWaitForActivate, Src: []string{upgradeStWaitEndDL, upgradeStCheckImageName}, Dst: upgradeStWaitForActivate},
-			//upgradeEvRequestActivate state transitions depend on useAPIVersion43
-			{Name: upgradeEvRequestActivate, Src: []string{upgradeStStarting, upgradeStWaitEndDL, upgradeStCheckImageName,
-				upgradeStWaitForActivate}, Dst: upgradeStRequestingActivate}, //allows also for direct activation (without download) [TODO!!!]
-			{Name: upgradeEvActivationDone, Src: []string{upgradeStRequestingActivate}, Dst: upgradeStActivated},
-			{Name: upgradeEvWaitForCommit, Src: []string{upgradeStRequestingActivate}, Dst: upgradeStWaitForCommit},
-			{Name: upgradeEvCommitSw, Src: []string{upgradeStStarting, upgradeStRequestingActivate, upgradeStWaitForCommit,
-				upgradeStActivated}, Dst: upgradeStCommitSw}, //allows also for direct commitment (without download) [TODO!!!]
-			{Name: upgradeEvCheckCommitted, Src: []string{upgradeStCommitSw}, Dst: upgradeStCheckCommitted},
+			{Name: UpgradeEvStart, Src: []string{UpgradeStDisabled}, Dst: UpgradeStStarting},
+			{Name: UpgradeEvAdapterDownload, Src: []string{UpgradeStStarting}, Dst: UpgradeStWaitingAdapterDL},
+			{Name: UpgradeEvPrepareSwDownload, Src: []string{UpgradeStStarting, UpgradeStWaitingAdapterDL}, Dst: UpgradeStPreparingDL},
+			{Name: UpgradeEvRxStartSwDownload, Src: []string{UpgradeStPreparingDL}, Dst: UpgradeStDLSection},
+			{Name: UpgradeEvWaitWindowAck, Src: []string{UpgradeStDLSection}, Dst: UpgradeStVerifyWindow},
+			{Name: UpgradeEvContinueNextWindow, Src: []string{UpgradeStVerifyWindow}, Dst: UpgradeStDLSection},
+			{Name: UpgradeEvEndSwDownload, Src: []string{UpgradeStVerifyWindow}, Dst: UpgradeStFinalizeDL},
+			{Name: UpgradeEvWaitEndDownload, Src: []string{UpgradeStFinalizeDL}, Dst: UpgradeStWaitEndDL},
+			{Name: UpgradeEvContinueFinalize, Src: []string{UpgradeStWaitEndDL}, Dst: UpgradeStFinalizeDL},
+			//UpgradeStCheckImageName only used with useAPIVersion43
+			{Name: UpgradeEvCheckImageName, Src: []string{UpgradeStWaitEndDL}, Dst: UpgradeStCheckImageName},
+			//UpgradeEvWaitForActivate state transitions depend on useAPIVersion43
+			{Name: UpgradeEvWaitForActivate, Src: []string{UpgradeStWaitEndDL, UpgradeStCheckImageName}, Dst: UpgradeStWaitForActivate},
+			//UpgradeEvRequestActivate state transitions depend on useAPIVersion43
+			{Name: UpgradeEvRequestActivate, Src: []string{UpgradeStStarting, UpgradeStWaitEndDL, UpgradeStCheckImageName,
+				UpgradeStWaitForActivate}, Dst: UpgradeStRequestingActivate}, //allows also for direct activation (without download) [TODO!!!]
+			{Name: UpgradeEvActivationDone, Src: []string{UpgradeStRequestingActivate}, Dst: UpgradeStActivated},
+			{Name: UpgradeEvWaitForCommit, Src: []string{UpgradeStRequestingActivate}, Dst: UpgradeStWaitForCommit},
+			{Name: UpgradeEvCommitSw, Src: []string{UpgradeStStarting, UpgradeStRequestingActivate, UpgradeStWaitForCommit,
+				UpgradeStActivated}, Dst: UpgradeStCommitSw}, //allows also for direct commitment (without download) [TODO!!!]
+			{Name: UpgradeEvCheckCommitted, Src: []string{UpgradeStCommitSw}, Dst: UpgradeStCheckCommitted},
 
 			/*
-				{Name: upgradeEvTimeoutSimple, Src: []string{
-					upgradeStCreatingDot1PMapper, upgradeStCreatingMBPCD, upgradeStSettingTconts, upgradeStSettingDot1PMapper}, Dst: upgradeStStarting},
-				{Name: upgradeEvTimeoutMids, Src: []string{
-					upgradeStCreatingGemNCTPs, upgradeStCreatingGemIWs, upgradeStSettingPQs}, Dst: upgradeStStarting},
+				{Name: UpgradeEvTimeoutSimple, Src: []string{
+					UpgradeStCreatingDot1PMapper, UpgradeStCreatingMBPCD, UpgradeStSettingTconts, UpgradeStSettingDot1PMapper}, Dst: UpgradeStStarting},
+				{Name: UpgradeEvTimeoutMids, Src: []string{
+					UpgradeStCreatingGemNCTPs, UpgradeStCreatingGemIWs, UpgradeStSettingPQs}, Dst: UpgradeStStarting},
 			*/
 			// exceptional treatments
-			//on upgradeEvReset: upgradeStRequestingActivate, upgradeStWaitForCommit and upgradeStActivated are not reset
+			//on UpgradeEvReset: UpgradeStRequestingActivate, UpgradeStWaitForCommit and UpgradeStActivated are not reset
 			// (to let the FSM survive the expected OnuDown indication)
-			{Name: upgradeEvReset, Src: []string{upgradeStStarting, upgradeStWaitingAdapterDL, upgradeStPreparingDL, upgradeStDLSection,
-				upgradeStVerifyWindow, upgradeStDLSection, upgradeStFinalizeDL, upgradeStWaitEndDL, upgradeStCheckImageName,
-				upgradeStWaitForActivate,
-				upgradeStCommitSw, upgradeStCheckCommitted},
-				Dst: upgradeStResetting},
-			{Name: upgradeEvAbort, Src: []string{upgradeStStarting, upgradeStWaitingAdapterDL, upgradeStPreparingDL, upgradeStDLSection,
-				upgradeStVerifyWindow, upgradeStDLSection, upgradeStFinalizeDL, upgradeStWaitEndDL, upgradeStCheckImageName,
-				upgradeStWaitForActivate,
-				upgradeStRequestingActivate, upgradeStActivated, upgradeStWaitForCommit,
-				upgradeStCommitSw, upgradeStCheckCommitted},
-				Dst: upgradeStResetting},
-			{Name: upgradeEvAbortSwDownload, Src: []string{upgradeStResetting}, Dst: upgradeStAbortingDL},
-			{Name: upgradeEvRestart, Src: []string{upgradeStResetting, upgradeStAbortingDL}, Dst: upgradeStRestarting},
-			{Name: upgradeEvDisable, Src: []string{upgradeStRestarting}, Dst: upgradeStDisabled},
+			{Name: UpgradeEvReset, Src: []string{UpgradeStStarting, UpgradeStWaitingAdapterDL, UpgradeStPreparingDL, UpgradeStDLSection,
+				UpgradeStVerifyWindow, UpgradeStDLSection, UpgradeStFinalizeDL, UpgradeStWaitEndDL, UpgradeStCheckImageName,
+				UpgradeStWaitForActivate,
+				UpgradeStCommitSw, UpgradeStCheckCommitted},
+				Dst: UpgradeStResetting},
+			{Name: UpgradeEvAbort, Src: []string{UpgradeStStarting, UpgradeStWaitingAdapterDL, UpgradeStPreparingDL, UpgradeStDLSection,
+				UpgradeStVerifyWindow, UpgradeStDLSection, UpgradeStFinalizeDL, UpgradeStWaitEndDL, UpgradeStCheckImageName,
+				UpgradeStWaitForActivate,
+				UpgradeStRequestingActivate, UpgradeStActivated, UpgradeStWaitForCommit,
+				UpgradeStCommitSw, UpgradeStCheckCommitted},
+				Dst: UpgradeStResetting},
+			{Name: UpgradeEvAbortSwDownload, Src: []string{UpgradeStResetting}, Dst: UpgradeStAbortingDL},
+			{Name: UpgradeEvRestart, Src: []string{UpgradeStResetting, UpgradeStAbortingDL}, Dst: UpgradeStRestarting},
+			{Name: UpgradeEvDisable, Src: []string{UpgradeStRestarting}, Dst: UpgradeStDisabled},
 		},
 		fsm.Callbacks{
-			"enter_state":                          func(e *fsm.Event) { instFsm.pAdaptFsm.logFsmStateChange(ctx, e) },
-			"enter_" + upgradeStStarting:           func(e *fsm.Event) { instFsm.enterStarting(ctx, e) },
-			"enter_" + upgradeStWaitingAdapterDL:   func(e *fsm.Event) { instFsm.enterWaitingAdapterDL(ctx, e) },
-			"enter_" + upgradeStPreparingDL:        func(e *fsm.Event) { instFsm.enterPreparingDL(ctx, e) },
-			"enter_" + upgradeStDLSection:          func(e *fsm.Event) { instFsm.enterDownloadSection(ctx, e) },
-			"enter_" + upgradeStVerifyWindow:       func(e *fsm.Event) { instFsm.enterVerifyWindow(ctx, e) },
-			"enter_" + upgradeStFinalizeDL:         func(e *fsm.Event) { instFsm.enterFinalizeDL(ctx, e) },
-			"enter_" + upgradeStWaitEndDL:          func(e *fsm.Event) { instFsm.enterWaitEndDL(ctx, e) },
-			"enter_" + upgradeStCheckImageName:     func(e *fsm.Event) { instFsm.enterCheckImageName(ctx, e) },
-			"enter_" + upgradeStRequestingActivate: func(e *fsm.Event) { instFsm.enterActivateSw(ctx, e) },
-			"enter_" + upgradeStCommitSw:           func(e *fsm.Event) { instFsm.enterCommitSw(ctx, e) },
-			"enter_" + upgradeStCheckCommitted:     func(e *fsm.Event) { instFsm.enterCheckCommitted(ctx, e) },
-			"enter_" + upgradeStResetting:          func(e *fsm.Event) { instFsm.enterResetting(ctx, e) },
-			"enter_" + upgradeStAbortingDL:         func(e *fsm.Event) { instFsm.enterAbortingDL(ctx, e) },
-			"enter_" + upgradeStRestarting:         func(e *fsm.Event) { instFsm.enterRestarting(ctx, e) },
-			"enter_" + upgradeStDisabled:           func(e *fsm.Event) { instFsm.enterDisabled(ctx, e) },
+			"enter_state":                          func(e *fsm.Event) { instFsm.PAdaptFsm.LogFsmStateChange(ctx, e) },
+			"enter_" + UpgradeStStarting:           func(e *fsm.Event) { instFsm.enterStarting(ctx, e) },
+			"enter_" + UpgradeStWaitingAdapterDL:   func(e *fsm.Event) { instFsm.enterWaitingAdapterDL(ctx, e) },
+			"enter_" + UpgradeStPreparingDL:        func(e *fsm.Event) { instFsm.enterPreparingDL(ctx, e) },
+			"enter_" + UpgradeStDLSection:          func(e *fsm.Event) { instFsm.enterDownloadSection(ctx, e) },
+			"enter_" + UpgradeStVerifyWindow:       func(e *fsm.Event) { instFsm.enterVerifyWindow(ctx, e) },
+			"enter_" + UpgradeStFinalizeDL:         func(e *fsm.Event) { instFsm.enterFinalizeDL(ctx, e) },
+			"enter_" + UpgradeStWaitEndDL:          func(e *fsm.Event) { instFsm.enterWaitEndDL(ctx, e) },
+			"enter_" + UpgradeStCheckImageName:     func(e *fsm.Event) { instFsm.enterCheckImageName(ctx, e) },
+			"enter_" + UpgradeStRequestingActivate: func(e *fsm.Event) { instFsm.enterActivateSw(ctx, e) },
+			"enter_" + UpgradeStCommitSw:           func(e *fsm.Event) { instFsm.enterCommitSw(ctx, e) },
+			"enter_" + UpgradeStCheckCommitted:     func(e *fsm.Event) { instFsm.enterCheckCommitted(ctx, e) },
+			"enter_" + UpgradeStResetting:          func(e *fsm.Event) { instFsm.enterResetting(ctx, e) },
+			"enter_" + UpgradeStAbortingDL:         func(e *fsm.Event) { instFsm.enterAbortingDL(ctx, e) },
+			"enter_" + UpgradeStRestarting:         func(e *fsm.Event) { instFsm.enterRestarting(ctx, e) },
+			"enter_" + UpgradeStDisabled:           func(e *fsm.Event) { instFsm.enterDisabled(ctx, e) },
 		},
 	)
-	if instFsm.pAdaptFsm.pFsm == nil {
+	if instFsm.PAdaptFsm.PFsm == nil {
 		logger.Errorw(ctx, "OnuUpgradeFsm's Base FSM could not be instantiated!!", log.Fields{
 			"device-id": instFsm.deviceID})
 		return nil
@@ -266,13 +268,13 @@
 //SetDownloadParams configures the needed parameters for a specific download to the ONU
 //  called from 'old' API Activate_image_update()
 func (oFsm *OnuUpgradeFsm) SetDownloadParams(ctx context.Context, aInactiveImageID uint16,
-	apImageDsc *voltha.ImageDownload, apDownloadManager *adapterDownloadManager) error {
-	pBaseFsm := oFsm.pAdaptFsm.pFsm
-	if pBaseFsm != nil && pBaseFsm.Is(upgradeStStarting) {
+	apImageDsc *voltha.ImageDownload, apDownloadManager *AdapterDownloadManager) error {
+	pBaseFsm := oFsm.PAdaptFsm.PFsm
+	if pBaseFsm != nil && pBaseFsm.Is(UpgradeStStarting) {
 		oFsm.mutexUpgradeParams.Lock()
 		logger.Debugw(ctx, "OnuUpgradeFsm Parameter setting", log.Fields{
 			"device-id": oFsm.deviceID, "image-description": apImageDsc})
-		oFsm.inactiveImageMeID = aInactiveImageID //upgrade state machines run on configured inactive ImageId
+		oFsm.InactiveImageMeID = aInactiveImageID //upgrade state machines run on configured inactive ImageId
 		oFsm.pImageDsc = apImageDsc
 		oFsm.pDownloadManager = apDownloadManager
 		oFsm.activateImage = true
@@ -281,7 +283,7 @@
 
 		go func(aPBaseFsm *fsm.FSM) {
 			// let the upgrade FSM proceed to PreparingDL
-			_ = aPBaseFsm.Event(upgradeEvPrepareSwDownload)
+			_ = aPBaseFsm.Event(UpgradeEvPrepareSwDownload)
 		}(pBaseFsm)
 		return nil
 	}
@@ -294,18 +296,18 @@
 //  updated API interface with R2.8: start download to ONU if the image is downloaded to the adapter
 //  called from 'new' API Download_onu_image
 func (oFsm *OnuUpgradeFsm) SetDownloadParamsAfterDownload(ctx context.Context, aInactiveImageID uint16,
-	apImageRequest *voltha.DeviceImageDownloadRequest, apDownloadManager *fileDownloadManager,
+	apImageRequest *voltha.DeviceImageDownloadRequest, apDownloadManager *FileDownloadManager,
 	aImageIdentifier string) error {
 	oFsm.mutexUpgradeParams.Lock()
 	var pBaseFsm *fsm.FSM = nil
-	if oFsm.pAdaptFsm != nil {
-		pBaseFsm = oFsm.pAdaptFsm.pFsm
+	if oFsm.PAdaptFsm != nil {
+		pBaseFsm = oFsm.PAdaptFsm.PFsm
 	}
-	if pBaseFsm != nil && pBaseFsm.Is(upgradeStStarting) {
+	if pBaseFsm != nil && pBaseFsm.Is(UpgradeStStarting) {
 		logger.Debugw(ctx, "OnuUpgradeFsm Parameter setting", log.Fields{
 			"device-id": oFsm.deviceID, "image-description": apImageRequest})
 		oFsm.useAPIVersion43 = true
-		oFsm.inactiveImageMeID = aInactiveImageID //upgrade state machines run on configured inactive ImageId
+		oFsm.InactiveImageMeID = aInactiveImageID //upgrade state machines run on configured inactive ImageId
 		oFsm.pFileManager = apDownloadManager
 		oFsm.imageIdentifier = aImageIdentifier
 		oFsm.imageVersion = apImageRequest.Image.Version
@@ -314,7 +316,7 @@
 		//TODO: currently straightforward options activate and commit are expected to be set and (unconditionally) done
 		//  for separate handling of these options the FSM must accordingly branch from the concerned states - later
 		oFsm.mutexUpgradeParams.Unlock()
-		_ = pBaseFsm.Event(upgradeEvAdapterDownload) //no need to call the FSM event in background here
+		_ = pBaseFsm.Event(UpgradeEvAdapterDownload) //no need to call the FSM event in background here
 		return nil
 	}
 	oFsm.mutexUpgradeParams.Unlock()
@@ -342,15 +344,15 @@
 	oFsm.activateImage = true
 	oFsm.commitImage = aCommit
 	var pBaseFsm *fsm.FSM = nil
-	if oFsm.pAdaptFsm != nil {
-		pBaseFsm = oFsm.pAdaptFsm.pFsm
+	if oFsm.PAdaptFsm != nil {
+		pBaseFsm = oFsm.PAdaptFsm.PFsm
 	}
 	if pBaseFsm != nil {
-		if pBaseFsm.Is(upgradeStWaitForActivate) {
+		if pBaseFsm.Is(UpgradeStWaitForActivate) {
 			oFsm.volthaDownloadState = voltha.ImageState_DOWNLOAD_STARTED //better choice would be 'UpgradeState=Started'
 			oFsm.mutexUpgradeParams.Unlock()
 			logger.Debugw(ctx, "OnuUpgradeFsm finish waiting for activate", log.Fields{"device-id": oFsm.deviceID})
-			_ = pBaseFsm.Event(upgradeEvRequestActivate) //no need to call the FSM event in background here
+			_ = pBaseFsm.Event(UpgradeEvRequestActivate) //no need to call the FSM event in background here
 		} else {
 			oFsm.mutexUpgradeParams.Unlock()
 			logger.Debugw(ctx, "OnuUpgradeFsm not (yet?) waiting for activate", log.Fields{
@@ -368,14 +370,14 @@
 func (oFsm *OnuUpgradeFsm) SetActivationParamsStart(ctx context.Context, aImageVersion string, aInactiveImageID uint16, aCommit bool) error {
 	oFsm.mutexUpgradeParams.Lock()
 	var pBaseFsm *fsm.FSM = nil
-	if oFsm.pAdaptFsm != nil {
-		pBaseFsm = oFsm.pAdaptFsm.pFsm
+	if oFsm.PAdaptFsm != nil {
+		pBaseFsm = oFsm.PAdaptFsm.PFsm
 	}
-	if pBaseFsm != nil && pBaseFsm.Is(upgradeStStarting) {
+	if pBaseFsm != nil && pBaseFsm.Is(UpgradeStStarting) {
 		logger.Debugw(ctx, "OnuUpgradeFsm Parameter setting to start with activation", log.Fields{
 			"device-id": oFsm.deviceID, "image-version": aImageVersion})
 		oFsm.useAPIVersion43 = true
-		oFsm.inactiveImageMeID = aInactiveImageID //upgrade state machines run on configured inactive ImageId
+		oFsm.InactiveImageMeID = aInactiveImageID //upgrade state machines run on configured inactive ImageId
 		oFsm.imageVersion = aImageVersion
 		oFsm.activateImage = true
 		oFsm.commitImage = aCommit
@@ -384,7 +386,7 @@
 		oFsm.volthaImageState = voltha.ImageState_IMAGE_INACTIVE      //as simply applied for inactive image
 		oFsm.mutexUpgradeParams.Unlock()
 		//directly request the FSM to activate the image
-		_ = pBaseFsm.Event(upgradeEvRequestActivate) //no need to call the FSM event in background here
+		_ = pBaseFsm.Event(UpgradeEvRequestActivate) //no need to call the FSM event in background here
 		return nil
 	}
 	oFsm.mutexUpgradeParams.Unlock()
@@ -414,14 +416,14 @@
 	oFsm.volthaDownloadState = voltha.ImageState_DOWNLOAD_STARTED //better choice would be 'UpgradeState=Started'
 	oFsm.mutexUpgradeParams.Unlock()
 	var pBaseFsm *fsm.FSM = nil
-	if oFsm.pAdaptFsm != nil {
-		pBaseFsm = oFsm.pAdaptFsm.pFsm
+	if oFsm.PAdaptFsm != nil {
+		pBaseFsm = oFsm.PAdaptFsm.PFsm
 	}
 	if pBaseFsm != nil {
 		//let the FSM decide if it is ready to process the event
 		logger.Debugw(ctx, "OnuUpgradeFsm requesting commit",
 			log.Fields{"device-id": oFsm.deviceID, "current FsmState": pBaseFsm.Current()})
-		_ = pBaseFsm.Event(upgradeEvCommitSw) //no need to call the FSM event in background here
+		_ = pBaseFsm.Event(UpgradeEvCommitSw) //no need to call the FSM event in background here
 		return nil
 	}
 	//should never occur
@@ -435,21 +437,21 @@
 func (oFsm *OnuUpgradeFsm) SetCommitmentParamsStart(ctx context.Context, aImageVersion string, aActiveImageID uint16) error {
 	oFsm.mutexUpgradeParams.Lock()
 	var pBaseFsm *fsm.FSM = nil
-	if oFsm.pAdaptFsm != nil {
-		pBaseFsm = oFsm.pAdaptFsm.pFsm
+	if oFsm.PAdaptFsm != nil {
+		pBaseFsm = oFsm.PAdaptFsm.PFsm
 	}
-	if pBaseFsm != nil && pBaseFsm.Is(upgradeStStarting) {
+	if pBaseFsm != nil && pBaseFsm.Is(UpgradeStStarting) {
 		logger.Debugw(ctx, "OnuUpgradeFsm Parameter setting to start with commitment", log.Fields{
 			"device-id": oFsm.deviceID, "image-version": aImageVersion})
 		oFsm.useAPIVersion43 = true
-		oFsm.inactiveImageMeID = aActiveImageID //upgrade state machines inactive ImageId is the new active ImageId
+		oFsm.InactiveImageMeID = aActiveImageID //upgrade state machines inactive ImageId is the new active ImageId
 		oFsm.imageVersion = aImageVersion
 		oFsm.commitImage = true
 		oFsm.volthaDownloadState = voltha.ImageState_DOWNLOAD_STARTED //better choice would be 'UpgradeState=Started'
 		oFsm.volthaImageState = voltha.ImageState_IMAGE_ACTIVE        //as simply applied for active image
 		oFsm.mutexUpgradeParams.Unlock()
 		//directly request the FSM to commit the image
-		_ = pBaseFsm.Event(upgradeEvCommitSw) //no need to call the FSM event in background here
+		_ = pBaseFsm.Event(UpgradeEvCommitSw) //no need to call the FSM event in background here
 		return nil
 	}
 	oFsm.mutexUpgradeParams.Unlock()
@@ -533,12 +535,12 @@
 
 	// in any case (even if it might be automatically requested by above cancellation of waiting) ensure resetting the FSM
 	// specific here: See definition of state changes: some states are excluded from reset for possible later commit
-	pAdaptFsm := oFsm.pAdaptFsm
-	if pAdaptFsm != nil {
+	PAdaptFsm := oFsm.PAdaptFsm
+	if PAdaptFsm != nil {
 		// calling FSM events in background to avoid blocking of the caller
-		go func(aPAFsm *AdapterFsm) {
-			if aPAFsm.pFsm != nil {
-				if aPAFsm.pFsm.Is(upgradeStWaitEndDL) {
+		go func(aPAFsm *cmn.AdapterFsm) {
+			if aPAFsm.PFsm != nil {
+				if aPAFsm.PFsm.Is(UpgradeStWaitEndDL) {
 					oFsm.chReceiveExpectedResponse <- false //which aborts the FSM in WaitEndDL state
 				}
 				// in case of state-conditional request the
@@ -555,11 +557,11 @@
 					}
 					oFsm.volthaDownloadReason = aReason
 					oFsm.mutexUpgradeParams.Unlock()
-					err = aPAFsm.pFsm.Event(upgradeEvAbort) //as unconditional default FSM cancellation
+					err = aPAFsm.PFsm.Event(UpgradeEvAbort) //as unconditional default FSM cancellation
 				} else {
 					//at conditional request the image states are set when reaching the reset state
 					oFsm.conditionalCancelRequested = true
-					err = aPAFsm.pFsm.Event(upgradeEvReset) //as state-conditional default FSM cleanup
+					err = aPAFsm.PFsm.Event(UpgradeEvReset) //as state-conditional default FSM cleanup
 				}
 				if err != nil {
 					//error return is expected in case of conditional request and no state transition
@@ -567,7 +569,7 @@
 						"device-id": oFsm.deviceID, "error": err})
 				}
 			} //else the FSM seems already to be in some released state
-		}(pAdaptFsm)
+		}(PAdaptFsm)
 	}
 }
 
@@ -610,10 +612,10 @@
 		oFsm.mutexUpgradeParams.Unlock()
 		logger.Errorw(ctx, "OnuUpgradeFsm abort: problems getting image buffer length", log.Fields{
 			"device-id": oFsm.deviceID, "error": err, "length": fileLen})
-		pBaseFsm := oFsm.pAdaptFsm
+		pBaseFsm := oFsm.PAdaptFsm
 		// Can't call FSM Event directly, decoupling it
-		go func(a_pAFsm *AdapterFsm) {
-			_ = a_pAFsm.pFsm.Event(upgradeEvAbort)
+		go func(a_pAFsm *cmn.AdapterFsm) {
+			_ = a_pAFsm.PFsm.Event(UpgradeEvAbort)
 		}(pBaseFsm)
 		return
 	}
@@ -632,10 +634,10 @@
 		oFsm.mutexUpgradeParams.Unlock()
 		logger.Errorw(ctx, "OnuUpgradeFsm abort: can't get image buffer", log.Fields{
 			"device-id": oFsm.deviceID, "error": err})
-		pBaseFsm := oFsm.pAdaptFsm
+		pBaseFsm := oFsm.PAdaptFsm
 		// Can't call FSM Event directly, decoupling it
-		go func(a_pAFsm *AdapterFsm) {
-			_ = a_pAFsm.pFsm.Event(upgradeEvAbort)
+		go func(a_pAFsm *cmn.AdapterFsm) {
+			_ = a_pAFsm.PFsm.Event(UpgradeEvAbort)
 		}(pBaseFsm)
 		return
 	}
@@ -650,7 +652,7 @@
 	oFsm.origImageLength = uint32(fileLen)
 	oFsm.imageLength = uint32(len(oFsm.imageBuffer))
 	logger.Infow(ctx, "OnuUpgradeFsm starts with StartSwDl values", log.Fields{
-		"MeId": oFsm.inactiveImageMeID, "windowSizeLimit": oFsm.omciDownloadWindowSizeLimit,
+		"MeId": oFsm.InactiveImageMeID, "windowSizeLimit": oFsm.omciDownloadWindowSizeLimit,
 		"ImageSize": oFsm.imageLength, "original file size": fileLen})
 	//"NumberOfCircuitPacks": oFsm.numberCircuitPacks, "CircuitPacks MeId": 0}) //parallel circuit packs download not supported
 
@@ -664,8 +666,8 @@
 	}
 	go oFsm.waitOnDownloadToOnuReady(ctx, oFsm.chOnuDlReady) // start supervision of the complete download-to-ONU procedure
 
-	err = oFsm.pOmciCC.sendStartSoftwareDownload(log.WithSpanFromContext(context.Background(), ctx), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, false,
-		oFsm.pAdaptFsm.commChan, oFsm.inactiveImageMeID, oFsm.omciDownloadWindowSizeLimit, oFsm.origImageLength)
+	err = oFsm.pOmciCC.SendStartSoftwareDownload(log.WithSpanFromContext(context.Background(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), false,
+		oFsm.PAdaptFsm.CommChan, oFsm.InactiveImageMeID, oFsm.omciDownloadWindowSizeLimit, oFsm.origImageLength)
 	if err != nil {
 		logger.Errorw(ctx, "StartSwDl abort: can't send section", log.Fields{
 			"device-id": oFsm.deviceID, "error": err})
@@ -683,11 +685,11 @@
 	var bufferStartOffset uint32
 	var bufferEndOffset uint32
 	var downloadSection []byte
-	framePrint := false //default no printing of downloadSection frames
+	FramePrint := false //default no printing of downloadSection frames
 	oFsm.mutexUpgradeParams.Lock()
 	if oFsm.nextDownloadSectionsAbsolute == 0 {
 		//debug print of first section frame
-		framePrint = true
+		FramePrint = true
 		oFsm.volthaImageState = voltha.ImageState_IMAGE_DOWNLOADING
 	}
 
@@ -703,10 +705,10 @@
 			oFsm.volthaDownloadReason = oFsm.abortRequested
 			oFsm.mutexAbortRequest.RUnlock()
 			oFsm.mutexUpgradeParams.Unlock()
-			pBaseFsm := oFsm.pAdaptFsm
+			pBaseFsm := oFsm.PAdaptFsm
 			// Can't call FSM Event directly, decoupling it
-			go func(a_pAFsm *AdapterFsm) {
-				_ = a_pAFsm.pFsm.Event(upgradeEvAbort)
+			go func(a_pAFsm *cmn.AdapterFsm) {
+				_ = a_pAFsm.PFsm.Event(UpgradeEvAbort)
 			}(pBaseFsm)
 			return
 		}
@@ -726,10 +728,10 @@
 			oFsm.volthaDownloadReason = voltha.ImageState_UNKNOWN_ERROR //something like 'LOCAL_FILE_ERROR' would be better (proto)
 			oFsm.mutexUpgradeParams.Unlock()
 			//logical error -- reset the FSM
-			pBaseFsm := oFsm.pAdaptFsm
+			pBaseFsm := oFsm.PAdaptFsm
 			// Can't call FSM Event directly, decoupling it
-			go func(a_pAFsm *AdapterFsm) {
-				_ = a_pAFsm.pFsm.Event(upgradeEvAbort)
+			go func(a_pAFsm *cmn.AdapterFsm) {
+				_ = a_pAFsm.PFsm.Event(UpgradeEvAbort)
 			}(pBaseFsm)
 			return
 		}
@@ -741,14 +743,14 @@
 		}
 		if oFsm.nextDownloadSectionsAbsolute+1 >= oFsm.noOfSections {
 			windowAckRequest = 1
-			framePrint = true //debug print of last frame
+			FramePrint = true //debug print of last frame
 			oFsm.omciDownloadWindowSizeLast = oFsm.nextDownloadSectionsWindow
 			logger.Infow(ctx, "DlSection expect Response for last window (section)", log.Fields{
 				"device-id": oFsm.deviceID, "DlSectionNoAbsolute": oFsm.nextDownloadSectionsAbsolute})
 		}
 		oFsm.mutexUpgradeParams.Unlock() //unlock here to give other functions some chance to process during/after the send request
-		err := oFsm.pOmciCC.sendDownloadSection(log.WithSpanFromContext(context.Background(), ctx), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, false,
-			oFsm.pAdaptFsm.commChan, oFsm.inactiveImageMeID, windowAckRequest, oFsm.nextDownloadSectionsWindow, downloadSection, framePrint)
+		err := oFsm.pOmciCC.SendDownloadSection(log.WithSpanFromContext(context.Background(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), false,
+			oFsm.PAdaptFsm.CommChan, oFsm.InactiveImageMeID, windowAckRequest, oFsm.nextDownloadSectionsWindow, downloadSection, FramePrint)
 		if err != nil {
 			logger.Errorw(ctx, "DlSection abort: can't send section", log.Fields{
 				"device-id": oFsm.deviceID, "section absolute": oFsm.nextDownloadSectionsAbsolute, "error": err})
@@ -758,15 +760,15 @@
 		oFsm.mutexUpgradeParams.Lock()
 		oFsm.nextDownloadSectionsAbsolute++ //always increase the absolute section counter after having sent one
 		if windowAckRequest == 1 {
-			pBaseFsm := oFsm.pAdaptFsm
+			pBaseFsm := oFsm.PAdaptFsm
 			// Can't call FSM Event directly, decoupling it
 			oFsm.mutexUpgradeParams.Unlock()
-			go func(a_pAFsm *AdapterFsm) {
-				_ = a_pAFsm.pFsm.Event(upgradeEvWaitWindowAck) //state transition to upgradeStVerifyWindow
+			go func(a_pAFsm *cmn.AdapterFsm) {
+				_ = a_pAFsm.PFsm.Event(UpgradeEvWaitWindowAck) //state transition to UpgradeStVerifyWindow
 			}(pBaseFsm)
 			return
 		}
-		framePrint = false                //for the next Section frame (if wanted, can be enabled in logic before sendXXX())
+		FramePrint = false                //for the next Section frame (if wanted, can be enabled in logic before sendXXX())
 		oFsm.nextDownloadSectionsWindow++ //increase the window related section counter only if not in the last section
 		if oFsm.omciSectionInterleaveDelay > 0 {
 			//ensure a defined intersection-time-gap to leave space for further processing, other ONU's ...
@@ -796,7 +798,7 @@
 		oFsm.mutexUpgradeParams.RUnlock()
 	}
 
-	pBaseFsm := oFsm.pAdaptFsm
+	pBaseFsm := oFsm.PAdaptFsm
 	if pBaseFsm == nil {
 		logger.Errorw(ctx, "EndSwDl abort: BaseFsm invalid", log.Fields{"device-id": oFsm.deviceID})
 		oFsm.mutexUpgradeParams.Lock()
@@ -804,13 +806,13 @@
 		oFsm.volthaDownloadReason = voltha.ImageState_UNKNOWN_ERROR
 		oFsm.mutexUpgradeParams.Unlock()
 		// Can't call FSM Event directly, decoupling it
-		go func(a_pAFsm *AdapterFsm) {
-			_ = a_pAFsm.pFsm.Event(upgradeEvAbort)
+		go func(a_pAFsm *cmn.AdapterFsm) {
+			_ = a_pAFsm.PFsm.Event(UpgradeEvAbort)
 		}(pBaseFsm)
 		return
 	}
-	err := oFsm.pOmciCC.sendEndSoftwareDownload(log.WithSpanFromContext(context.Background(), ctx), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, false,
-		oFsm.pAdaptFsm.commChan, oFsm.inactiveImageMeID, oFsm.origImageLength, oFsm.imageCRC)
+	err := oFsm.pOmciCC.SendEndSoftwareDownload(log.WithSpanFromContext(context.Background(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), false,
+		oFsm.PAdaptFsm.CommChan, oFsm.InactiveImageMeID, oFsm.origImageLength, oFsm.imageCRC)
 
 	oFsm.isEndSwDlOpen = false // also to be reset in case of OMCI error, as further send attempts would not make sense
 	if err != nil {
@@ -821,8 +823,8 @@
 	}
 	// go waiting for the EndSwDLResponse and check, if the ONU is ready for activation
 	// Can't call FSM Event directly, decoupling it
-	go func(a_pAFsm *AdapterFsm) {
-		_ = a_pAFsm.pFsm.Event(upgradeEvWaitEndDownload)
+	go func(a_pAFsm *cmn.AdapterFsm) {
+		_ = a_pAFsm.PFsm.Event(UpgradeEvWaitEndDownload)
 	}(pBaseFsm)
 }
 
@@ -832,7 +834,7 @@
 	if oFsm.waitCountEndSwDl == 0 {
 		logger.Errorw(ctx, "WaitEndDl abort: max limit of EndSwDL reached", log.Fields{
 			"device-id": oFsm.deviceID})
-		pBaseFsm := oFsm.pAdaptFsm
+		pBaseFsm := oFsm.PAdaptFsm
 		if pBaseFsm == nil {
 			logger.Errorw(ctx, "WaitEndDl abort: BaseFsm invalid", log.Fields{
 				"device-id": oFsm.deviceID})
@@ -842,8 +844,8 @@
 		oFsm.volthaDownloadState = voltha.ImageState_DOWNLOAD_FAILED
 		oFsm.volthaDownloadReason = voltha.ImageState_IMAGE_REFUSED_BY_ONU //something like 'END_DOWNLOAD_TIMEOUT' would be better (proto)
 		oFsm.mutexUpgradeParams.Unlock()
-		go func(a_pAFsm *AdapterFsm) {
-			_ = a_pAFsm.pFsm.Event(upgradeEvAbort)
+		go func(a_pAFsm *cmn.AdapterFsm) {
+			_ = a_pAFsm.PFsm.Event(UpgradeEvAbort)
 		}(pBaseFsm)
 		return
 	}
@@ -851,7 +853,7 @@
 	oFsm.waitCountEndSwDl--
 	select {
 	case <-time.After(oFsm.waitDelayEndSwDl * time.Second):
-		pBaseFsm := oFsm.pAdaptFsm
+		pBaseFsm := oFsm.PAdaptFsm
 		if pBaseFsm == nil {
 			logger.Errorw(ctx, "WaitEndDl abort: BaseFsm invalid", log.Fields{
 				"device-id": oFsm.deviceID})
@@ -862,13 +864,13 @@
 		oFsm.mutexUpgradeParams.Lock()
 		oFsm.delayEndSwDl = false //no more extra delay for the request
 		oFsm.mutexUpgradeParams.Unlock()
-		go func(a_pAFsm *AdapterFsm) {
-			_ = a_pAFsm.pFsm.Event(upgradeEvContinueFinalize)
+		go func(a_pAFsm *cmn.AdapterFsm) {
+			_ = a_pAFsm.PFsm.Event(UpgradeEvContinueFinalize)
 		}(pBaseFsm)
 		return
 	case success := <-oFsm.chReceiveExpectedResponse:
 		logger.Debugw(ctx, "WaitEndDl stop  wait timer", log.Fields{"device-id": oFsm.deviceID})
-		pBaseFsm := oFsm.pAdaptFsm
+		pBaseFsm := oFsm.PAdaptFsm
 		if pBaseFsm == nil {
 			logger.Errorw(ctx, "WaitEndDl abort: BaseFsm invalid", log.Fields{
 				"device-id": oFsm.deviceID})
@@ -879,19 +881,19 @@
 			//answer received with ready indication
 			//useAPIVersion43 may not conflict in concurrency in this state function
 			if oFsm.useAPIVersion43 { // newer API usage requires verification of downloaded image version
-				go func(a_pAFsm *AdapterFsm) {
-					_ = a_pAFsm.pFsm.Event(upgradeEvCheckImageName)
+				go func(a_pAFsm *cmn.AdapterFsm) {
+					_ = a_pAFsm.PFsm.Event(UpgradeEvCheckImageName)
 				}(pBaseFsm)
 			} else { // elder API usage does not support image version check -immediately consider download as successful
 				if oFsm.activateImage {
 					//immediate activation requested
-					go func(a_pAFsm *AdapterFsm) {
-						_ = a_pAFsm.pFsm.Event(upgradeEvRequestActivate)
+					go func(a_pAFsm *cmn.AdapterFsm) {
+						_ = a_pAFsm.PFsm.Event(UpgradeEvRequestActivate)
 					}(pBaseFsm)
 				} else {
 					//have to wait on explicit activation request
-					go func(a_pAFsm *AdapterFsm) {
-						_ = a_pAFsm.pFsm.Event(upgradeEvWaitForActivate)
+					go func(a_pAFsm *cmn.AdapterFsm) {
+						_ = a_pAFsm.PFsm.Event(UpgradeEvWaitForActivate)
 					}(pBaseFsm)
 				}
 			}
@@ -905,11 +907,11 @@
 
 func (oFsm *OnuUpgradeFsm) enterCheckImageName(ctx context.Context, e *fsm.Event) {
 	logger.Debugw(ctx, "OnuUpgradeFsm checking downloaded image name", log.Fields{
-		"device-id": oFsm.deviceID, "me-id": oFsm.inactiveImageMeID})
+		"device-id": oFsm.deviceID, "me-id": oFsm.InactiveImageMeID})
 	requestedAttributes := me.AttributeValueMap{"IsCommitted": 0, "IsActive": 0, "Version": ""}
-	meInstance, err := oFsm.pOmciCC.sendGetMe(log.WithSpanFromContext(context.Background(), ctx),
-		me.SoftwareImageClassID, oFsm.inactiveImageMeID, requestedAttributes, oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout,
-		false, oFsm.pAdaptFsm.commChan)
+	meInstance, err := oFsm.pOmciCC.SendGetMe(log.WithSpanFromContext(context.Background(), ctx),
+		me.SoftwareImageClassID, oFsm.InactiveImageMeID, requestedAttributes, oFsm.pDeviceHandler.GetOmciTimeout(),
+		false, oFsm.PAdaptFsm.CommChan)
 	if err != nil {
 		logger.Errorw(ctx, "OnuUpgradeFsm get Software Image ME result error",
 			log.Fields{"device-id": oFsm.deviceID, "Error": err})
@@ -921,10 +923,10 @@
 
 func (oFsm *OnuUpgradeFsm) enterActivateSw(ctx context.Context, e *fsm.Event) {
 	logger.Infow(ctx, "OnuUpgradeFsm activate SW", log.Fields{
-		"device-id": oFsm.deviceID, "me-id": oFsm.inactiveImageMeID})
+		"device-id": oFsm.deviceID, "me-id": oFsm.InactiveImageMeID})
 
-	err := oFsm.pOmciCC.sendActivateSoftware(log.WithSpanFromContext(context.Background(), ctx), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, false,
-		oFsm.pAdaptFsm.commChan, oFsm.inactiveImageMeID)
+	err := oFsm.pOmciCC.SendActivateSoftware(log.WithSpanFromContext(context.Background(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), false,
+		oFsm.PAdaptFsm.CommChan, oFsm.InactiveImageMeID)
 	if err != nil {
 		logger.Errorw(ctx, "ActivateSw abort: can't send activate frame", log.Fields{
 			"device-id": oFsm.deviceID, "error": err})
@@ -938,20 +940,20 @@
 
 func (oFsm *OnuUpgradeFsm) enterCommitSw(ctx context.Context, e *fsm.Event) {
 	logger.Debugw(ctx, "OnuUpgradeFsm start commit SW", log.Fields{
-		"device-id": oFsm.deviceID, "me-id": oFsm.inactiveImageMeID})
+		"device-id": oFsm.deviceID, "me-id": oFsm.InactiveImageMeID})
 	//any abort request (also conditional) is still regarded as valid as the commit indication might not be possible to verify
 	// (which is a bit problematic as the ONU might already be in committed state,
 	// in this case (committing failed) always 'onuimage list' should be used to verify the real state (if ONU is reachable))
 	if activeImageID, err := oFsm.pDevEntry.GetActiveImageMeID(ctx); err == nil {
 		oFsm.mutexUpgradeParams.Lock()
-		if activeImageID == oFsm.inactiveImageMeID {
-			inactiveImageID := oFsm.inactiveImageMeID
+		if activeImageID == oFsm.InactiveImageMeID {
+			inactiveImageID := oFsm.InactiveImageMeID
 			logger.Infow(ctx, "OnuUpgradeFsm commit SW", log.Fields{
 				"device-id": oFsm.deviceID, "me-id": inactiveImageID}) //more efficient activeImageID with above check
 			oFsm.volthaImageState = voltha.ImageState_IMAGE_COMMITTING
 			oFsm.mutexUpgradeParams.Unlock()
-			err := oFsm.pOmciCC.sendCommitSoftware(log.WithSpanFromContext(context.Background(), ctx), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, false,
-				oFsm.pAdaptFsm.commChan, inactiveImageID) //more efficient activeImageID with above check
+			err := oFsm.pOmciCC.SendCommitSoftware(log.WithSpanFromContext(context.Background(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), false,
+				oFsm.PAdaptFsm.CommChan, inactiveImageID) //more efficient activeImageID with above check
 			if err != nil {
 				logger.Errorw(ctx, "CommitSw abort: can't send commit sw frame", log.Fields{
 					"device-id": oFsm.deviceID, "error": err})
@@ -962,7 +964,7 @@
 		}
 		oFsm.mutexUpgradeParams.Unlock()
 		logger.Errorw(ctx, "OnuUpgradeFsm active ImageId <> IdToCommit", log.Fields{
-			"device-id": oFsm.deviceID, "active ID": activeImageID, "to commit ID": oFsm.inactiveImageMeID})
+			"device-id": oFsm.deviceID, "active ID": activeImageID, "to commit ID": oFsm.InactiveImageMeID})
 	} else {
 		logger.Errorw(ctx, "OnuUpgradeFsm can't commit, no valid active image", log.Fields{
 			"device-id": oFsm.deviceID})
@@ -974,19 +976,19 @@
 	oFsm.volthaImageState = voltha.ImageState_IMAGE_COMMIT_ABORTED
 	oFsm.mutexUpgradeParams.Unlock()
 	//TODO!!!: possibly send event information for aborted upgrade (aborted by omci processing)??
-	pBaseFsm := oFsm.pAdaptFsm
+	pBaseFsm := oFsm.PAdaptFsm
 	// Can't call FSM Event directly, decoupling it
-	go func(a_pAFsm *AdapterFsm) {
-		_ = a_pAFsm.pFsm.Event(upgradeEvAbort)
+	go func(a_pAFsm *cmn.AdapterFsm) {
+		_ = a_pAFsm.PFsm.Event(UpgradeEvAbort)
 	}(pBaseFsm)
 }
 
 func (oFsm *OnuUpgradeFsm) enterCheckCommitted(ctx context.Context, e *fsm.Event) {
 	logger.Debugw(ctx, "OnuUpgradeFsm checking committed SW", log.Fields{
-		"device-id": oFsm.deviceID, "me-id": oFsm.inactiveImageMeID})
+		"device-id": oFsm.deviceID, "me-id": oFsm.InactiveImageMeID})
 	requestedAttributes := me.AttributeValueMap{"IsCommitted": 0, "IsActive": 0, "Version": ""}
-	meInstance, err := oFsm.pOmciCC.sendGetMe(log.WithSpanFromContext(context.Background(), ctx),
-		me.SoftwareImageClassID, oFsm.inactiveImageMeID, requestedAttributes, oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, false, oFsm.pAdaptFsm.commChan)
+	meInstance, err := oFsm.pOmciCC.SendGetMe(log.WithSpanFromContext(context.Background(), ctx),
+		me.SoftwareImageClassID, oFsm.InactiveImageMeID, requestedAttributes, oFsm.pDeviceHandler.GetOmciTimeout(), false, oFsm.PAdaptFsm.CommChan)
 	if err != nil {
 		logger.Errorw(ctx, "OnuUpgradeFsm get Software Image ME result error",
 			log.Fields{"device-id": oFsm.deviceID, "Error": err})
@@ -1014,43 +1016,43 @@
 	case oFsm.chOnuDlReady <- false:
 	default:
 	}
-	pConfigupgradeStateAFsm := oFsm.pAdaptFsm
-	if pConfigupgradeStateAFsm != nil {
+	pConfigUpgradeStateAFsm := oFsm.PAdaptFsm
+	if pConfigUpgradeStateAFsm != nil {
 		var nextEvent string
 		if oFsm.isEndSwDlOpen {
-			nextEvent = upgradeEvAbortSwDownload
+			nextEvent = UpgradeEvAbortSwDownload
 		} else {
-			nextEvent = upgradeEvRestart
+			nextEvent = UpgradeEvRestart
 		}
 		// Can't call FSM Event directly, decoupling it
-		go func(a_pAFsm *AdapterFsm) {
-			if a_pAFsm != nil && a_pAFsm.pFsm != nil {
-				_ = a_pAFsm.pFsm.Event(nextEvent)
+		go func(a_pAFsm *cmn.AdapterFsm) {
+			if a_pAFsm != nil && a_pAFsm.PFsm != nil {
+				_ = a_pAFsm.PFsm.Event(nextEvent)
 			}
-		}(pConfigupgradeStateAFsm)
+		}(pConfigUpgradeStateAFsm)
 	}
 }
 
 func (oFsm *OnuUpgradeFsm) enterAbortingDL(ctx context.Context, e *fsm.Event) {
 	logger.Debugw(ctx, "OnuUpgradeFsm aborting download to ONU", log.Fields{"device-id": oFsm.deviceID})
 
-	pBaseFsm := oFsm.pAdaptFsm
+	pBaseFsm := oFsm.PAdaptFsm
 	if pBaseFsm == nil {
 		logger.Errorw(ctx, "OnuUpgradeFsm aborting download: BaseFsm invalid", log.Fields{"device-id": oFsm.deviceID})
 		return
 	}
 	// abort the download operation by sending an end software download message with invalid CRC and image size
-	err := oFsm.pOmciCC.sendEndSoftwareDownload(log.WithSpanFromContext(context.Background(), ctx), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, false,
-		oFsm.pAdaptFsm.commChan, oFsm.inactiveImageMeID, 0, 0xFFFFFFFF)
+	err := oFsm.pOmciCC.SendEndSoftwareDownload(log.WithSpanFromContext(context.Background(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), false,
+		oFsm.PAdaptFsm.CommChan, oFsm.InactiveImageMeID, 0, 0xFFFFFFFF)
 
 	oFsm.isEndSwDlOpen = false // also to be reset in case of OMCI error, as further send attempts would not make sense
 
 	if err != nil {
 		logger.Errorw(ctx, "OnuUpgradeFsm aborting download: can't send EndSwDl request", log.Fields{"device-id": oFsm.deviceID})
 		// Can't call FSM Event directly, decoupling it
-		go func(a_pAFsm *AdapterFsm) {
-			if a_pAFsm != nil && a_pAFsm.pFsm != nil {
-				_ = a_pAFsm.pFsm.Event(upgradeEvRestart)
+		go func(a_pAFsm *cmn.AdapterFsm) {
+			if a_pAFsm != nil && a_pAFsm.PFsm != nil {
+				_ = a_pAFsm.PFsm.Event(UpgradeEvRestart)
 			}
 		}(pBaseFsm)
 		return
@@ -1058,17 +1060,17 @@
 	select {
 	case <-time.After(oFsm.pOmciCC.GetMaxOmciTimeoutWithRetries() * time.Second):
 		logger.Warnw(ctx, "OnuUpgradeFsm aborting download: timeout - no response received", log.Fields{"device-id": oFsm.deviceID})
-		go func(a_pAFsm *AdapterFsm) {
-			if a_pAFsm != nil && a_pAFsm.pFsm != nil {
-				_ = a_pAFsm.pFsm.Event(upgradeEvRestart)
+		go func(a_pAFsm *cmn.AdapterFsm) {
+			if a_pAFsm != nil && a_pAFsm.PFsm != nil {
+				_ = a_pAFsm.PFsm.Event(UpgradeEvRestart)
 			}
 		}(pBaseFsm)
 		return
 	case <-oFsm.chReceiveAbortEndSwDlResponse:
 		logger.Debug(ctx, "OnuUpgradeFsm aborting download: response received")
-		go func(a_pAFsm *AdapterFsm) {
-			if a_pAFsm != nil && a_pAFsm.pFsm != nil {
-				_ = a_pAFsm.pFsm.Event(upgradeEvRestart)
+		go func(a_pAFsm *cmn.AdapterFsm) {
+			if a_pAFsm != nil && a_pAFsm.PFsm != nil {
+				_ = a_pAFsm.PFsm.Event(UpgradeEvRestart)
 			}
 		}(pBaseFsm)
 		return
@@ -1077,24 +1079,24 @@
 
 func (oFsm *OnuUpgradeFsm) enterRestarting(ctx context.Context, e *fsm.Event) {
 	logger.Debugw(ctx, "OnuUpgradeFsm restarting", log.Fields{"device-id": oFsm.deviceID})
-	pConfigupgradeStateAFsm := oFsm.pAdaptFsm
-	if pConfigupgradeStateAFsm != nil {
+	pConfigUpgradeStateAFsm := oFsm.PAdaptFsm
+	if pConfigUpgradeStateAFsm != nil {
 		// abort running message processing
-		fsmAbortMsg := Message{
-			Type: TestMsg,
-			Data: TestMessage{
-				TestMessageVal: AbortMessageProcessing,
+		fsmAbortMsg := cmn.Message{
+			Type: cmn.TestMsg,
+			Data: cmn.TestMessage{
+				TestMessageVal: cmn.AbortMessageProcessing,
 			},
 		}
-		pConfigupgradeStateAFsm.commChan <- fsmAbortMsg
+		pConfigUpgradeStateAFsm.CommChan <- fsmAbortMsg
 
 		//try to restart the FSM to 'disabled'
 		// Can't call FSM Event directly, decoupling it
-		go func(a_pAFsm *AdapterFsm) {
-			if a_pAFsm != nil && a_pAFsm.pFsm != nil {
-				_ = a_pAFsm.pFsm.Event(upgradeEvDisable)
+		go func(a_pAFsm *cmn.AdapterFsm) {
+			if a_pAFsm != nil && a_pAFsm.PFsm != nil {
+				_ = a_pAFsm.PFsm.Event(UpgradeEvDisable)
 			}
-		}(pConfigupgradeStateAFsm)
+		}(pConfigUpgradeStateAFsm)
 	}
 }
 
@@ -1109,7 +1111,7 @@
 			Reason:        oFsm.volthaDownloadReason,
 			ImageState:    oFsm.volthaImageState,
 		}
-		go oFsm.pDeviceHandler.removeOnuUpgradeFsm(ctx, pLastUpgradeImageState)
+		go oFsm.pDeviceHandler.RemoveOnuUpgradeFsm(ctx, pLastUpgradeImageState)
 	}
 }
 
@@ -1120,7 +1122,7 @@
 		// case <-ctx.Done():
 		// 	logger.Info(ctx,"MibSync Msg", log.Fields{"Message handling canceled via context for device-id": oFsm.deviceID})
 		// 	break loop
-		message, ok := <-oFsm.pAdaptFsm.commChan
+		message, ok := <-oFsm.PAdaptFsm.CommChan
 		if !ok {
 			logger.Info(ctx, "OnuUpgradeFsm Rx Msg - could not read from channel", log.Fields{"device-id": oFsm.deviceID})
 			// but then we have to ensure a restart of the FSM as well - as exceptional procedure
@@ -1130,15 +1132,15 @@
 		logger.Debugw(ctx, "OnuUpgradeFsm Rx Msg", log.Fields{"device-id": oFsm.deviceID})
 
 		switch message.Type {
-		case TestMsg:
-			msg, _ := message.Data.(TestMessage)
-			if msg.TestMessageVal == AbortMessageProcessing {
+		case cmn.TestMsg:
+			msg, _ := message.Data.(cmn.TestMessage)
+			if msg.TestMessageVal == cmn.AbortMessageProcessing {
 				logger.Infow(ctx, "OnuUpgradeFsm abort ProcessMsg", log.Fields{"for device-id": oFsm.deviceID})
 				break loop
 			}
 			logger.Warnw(ctx, "OnuUpgradeFsm unknown TestMessage", log.Fields{"device-id": oFsm.deviceID, "MessageVal": msg.TestMessageVal})
-		case OMCI:
-			msg, _ := message.Data.(OmciMessage)
+		case cmn.OMCI:
+			msg, _ := message.Data.(cmn.OmciMessage)
 			oFsm.handleOmciOnuUpgradeMessage(ctx, msg)
 		default:
 			logger.Warn(ctx, "OnuUpgradeFsm Rx unknown message", log.Fields{"device-id": oFsm.deviceID,
@@ -1149,7 +1151,7 @@
 }
 
 //nolint: gocyclo
-func (oFsm *OnuUpgradeFsm) handleOmciOnuUpgradeMessage(ctx context.Context, msg OmciMessage) {
+func (oFsm *OnuUpgradeFsm) handleOmciOnuUpgradeMessage(ctx context.Context, msg cmn.OmciMessage) {
 	logger.Debugw(ctx, "Rx OMCI OnuUpgradeFsm Msg", log.Fields{"device-id": oFsm.deviceID,
 		"msgType": msg.OmciMsg.MessageType})
 
@@ -1180,7 +1182,7 @@
 			}
 
 			oFsm.mutexUpgradeParams.Lock()
-			if msgObj.EntityInstance == oFsm.inactiveImageMeID {
+			if msgObj.EntityInstance == oFsm.InactiveImageMeID {
 				logger.Debugw(ctx, "Expected StartSwDlResponse received", log.Fields{"device-id": oFsm.deviceID})
 				if msgObj.WindowSize != oFsm.omciDownloadWindowSizeLimit {
 					// also response WindowSize = 0 is a valid number for used Window size 1
@@ -1200,7 +1202,7 @@
 				oFsm.nextDownloadWindow = 0
 
 				oFsm.mutexUpgradeParams.Unlock()
-				_ = oFsm.pAdaptFsm.pFsm.Event(upgradeEvRxStartSwDownload)
+				_ = oFsm.PAdaptFsm.PFsm.Event(UpgradeEvRxStartSwDownload)
 				return
 			}
 			oFsm.mutexUpgradeParams.Unlock()
@@ -1234,7 +1236,7 @@
 				return
 			}
 			oFsm.mutexUpgradeParams.Lock()
-			if msgObj.EntityInstance == oFsm.inactiveImageMeID {
+			if msgObj.EntityInstance == oFsm.InactiveImageMeID {
 				sectionNumber := msgObj.SectionNumber
 				logger.Infow(ctx, "DlSectionResponse received", log.Fields{
 					"window section-number": sectionNumber, "window": oFsm.nextDownloadWindow, "device-id": oFsm.deviceID})
@@ -1257,7 +1259,7 @@
 					binary.LittleEndian.PutUint32(byteSlice, uint32(imageCRC))
 					oFsm.imageCRC = binary.BigEndian.Uint32(byteSlice)
 					oFsm.mutexUpgradeParams.Unlock()
-					_ = oFsm.pAdaptFsm.pFsm.Event(upgradeEvEndSwDownload)
+					_ = oFsm.PAdaptFsm.PFsm.Event(UpgradeEvEndSwDownload)
 					return
 				}
 				if sectionNumber != oFsm.omciDownloadWindowSizeLimit {
@@ -1270,7 +1272,7 @@
 				}
 				oFsm.nextDownloadSectionsWindow = 0
 				oFsm.mutexUpgradeParams.Unlock()
-				_ = oFsm.pAdaptFsm.pFsm.Event(upgradeEvContinueNextWindow)
+				_ = oFsm.PAdaptFsm.PFsm.Event(UpgradeEvContinueNextWindow)
 				return
 			}
 			oFsm.mutexUpgradeParams.Unlock()
@@ -1281,11 +1283,11 @@
 		} //DownloadSectionResponseType
 	case omci.EndSoftwareDownloadResponseType:
 		{
-			if oFsm.pAdaptFsm.pFsm.Is(upgradeStAbortingDL) {
+			if oFsm.PAdaptFsm.PFsm.Is(UpgradeStAbortingDL) {
 				// calling FSM events in background to avoid blocking of the caller
-				go func(aPAFsm *AdapterFsm) {
+				go func(aPAFsm *cmn.AdapterFsm) {
 					oFsm.chReceiveAbortEndSwDlResponse <- true
-				}(oFsm.pAdaptFsm)
+				}(oFsm.PAdaptFsm)
 				return
 			}
 			msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeEndSoftwareDownloadResponse)
@@ -1317,7 +1319,7 @@
 				return
 			}
 			oFsm.mutexUpgradeParams.Lock()
-			if msgObj.EntityInstance == oFsm.inactiveImageMeID {
+			if msgObj.EntityInstance == oFsm.InactiveImageMeID {
 				//EndSwDownloadSuccess is used to indicate 'DOWNLOAD_SUCCEEDED'
 				oFsm.volthaDownloadState = voltha.ImageState_DOWNLOAD_SUCCEEDED
 				if !oFsm.useAPIVersion43 {
@@ -1373,15 +1375,15 @@
 				return
 			}
 			oFsm.mutexUpgradeParams.Lock()
-			if msgObj.EntityInstance == oFsm.inactiveImageMeID {
+			if msgObj.EntityInstance == oFsm.InactiveImageMeID {
 				// the image is regarded as active really only after ONU reboot and according indication (ONU down/up procedure)
 				oFsm.mutexUpgradeParams.Unlock()
 				logger.Infow(ctx, "Expected ActivateSwResponse received",
 					log.Fields{"device-id": oFsm.deviceID, "commit": oFsm.commitImage})
 				if oFsm.commitImage {
-					_ = oFsm.pAdaptFsm.pFsm.Event(upgradeEvWaitForCommit)
+					_ = oFsm.PAdaptFsm.PFsm.Event(UpgradeEvWaitForCommit)
 				} else {
-					_ = oFsm.pAdaptFsm.pFsm.Event(upgradeEvActivationDone) // let the FSM wait for external commit request
+					_ = oFsm.PAdaptFsm.PFsm.Event(UpgradeEvActivationDone) // let the FSM wait for external commit request
 				}
 				return
 			}
@@ -1414,11 +1416,11 @@
 				return
 			}
 			oFsm.mutexUpgradeParams.RLock()
-			if msgObj.EntityInstance == oFsm.inactiveImageMeID {
+			if msgObj.EntityInstance == oFsm.InactiveImageMeID {
 				oFsm.mutexUpgradeParams.RUnlock()
 				logger.Debugw(ctx, "OnuUpgradeFsm Expected SwImage CommitResponse received", log.Fields{"device-id": oFsm.deviceID})
 				//verifying committed image
-				_ = oFsm.pAdaptFsm.pFsm.Event(upgradeEvCheckCommitted)
+				_ = oFsm.PAdaptFsm.PFsm.Event(UpgradeEvCheckCommitted)
 				return
 			}
 			oFsm.mutexUpgradeParams.RUnlock()
@@ -1462,16 +1464,16 @@
 			meAttributes := msgObj.Attributes
 			imageIsCommitted := meAttributes["IsCommitted"].(uint8)
 			imageIsActive := meAttributes["IsActive"].(uint8)
-			imageVersion := TrimStringFromMeOctet(meAttributes["Version"])
+			imageVersion := cmn.TrimStringFromMeOctet(meAttributes["Version"])
 			logger.Debugw(ctx, "OnuUpgradeFsm - GetResponse Data for SoftwareImage",
 				log.Fields{"device-id": oFsm.deviceID, "entityID": msgObj.EntityInstance,
 					"version": imageVersion, "isActive": imageIsActive, "isCommitted": imageIsCommitted})
 
-			if oFsm.pAdaptFsm.pFsm.Current() == upgradeStCheckImageName {
+			if oFsm.PAdaptFsm.PFsm.Current() == UpgradeStCheckImageName {
 				//image name check after EndSwDownload, this state (and block) can only be taken if APIVersion43 is used
 				oFsm.mutexUpgradeParams.Lock()
-				if msgObj.EntityInstance == oFsm.inactiveImageMeID && imageIsActive == swIsInactive &&
-					imageIsCommitted == swIsUncommitted {
+				if msgObj.EntityInstance == oFsm.InactiveImageMeID && imageIsActive == cmn.SwIsInactive &&
+					imageIsCommitted == cmn.SwIsUncommitted {
 					if imageVersion != oFsm.imageVersion {
 						//new stored inactive version indicated on OMCI from ONU is not the expected version
 						logger.Errorw(ctx, "OnuUpgradeFsm SwImage GetResponse version indication not matching requested upgrade",
@@ -1490,20 +1492,20 @@
 						}
 						// TODO!!!: error treatment?
 						//TODO!!!: possibly send event information for aborted upgrade (aborted by wrong version)?
-						_ = oFsm.pAdaptFsm.pFsm.Event(upgradeEvAbort)
+						_ = oFsm.PAdaptFsm.PFsm.Event(UpgradeEvAbort)
 						return
 					}
 					//with APIVersion43 this is the point to consider the newly loaded image as valid (and inactive)
 					oFsm.volthaImageState = voltha.ImageState_IMAGE_INACTIVE
 					//store the new inactive version to onuSwImageIndications (to keep them in sync)
-					oFsm.pDevEntry.modifySwImageInactiveVersion(ctx, oFsm.imageVersion)
+					oFsm.pDevEntry.ModifySwImageInactiveVersion(ctx, oFsm.imageVersion)
 					//proceed within upgrade FSM
 					if oFsm.activateImage {
 						//immediate activation requested
 						oFsm.mutexUpgradeParams.Unlock()
 						logger.Debugw(ctx, "OnuUpgradeFsm - expected ONU image version indicated by the ONU, continue with activation",
 							log.Fields{"device-id": oFsm.deviceID})
-						_ = oFsm.pAdaptFsm.pFsm.Event(upgradeEvRequestActivate)
+						_ = oFsm.PAdaptFsm.PFsm.Event(UpgradeEvRequestActivate)
 					} else {
 						//have to wait on explicit activation request
 						// but a previously requested download activity (without activation) was successful here
@@ -1511,7 +1513,7 @@
 						oFsm.mutexUpgradeParams.Unlock()
 						logger.Infow(ctx, "OnuUpgradeFsm - expected ONU image version indicated by the ONU, wait for activate request",
 							log.Fields{"device-id": oFsm.deviceID})
-						_ = oFsm.pAdaptFsm.pFsm.Event(upgradeEvWaitForActivate)
+						_ = oFsm.PAdaptFsm.PFsm.Event(UpgradeEvWaitForActivate)
 					}
 					//use non-blocking channel (to be independent from receiver state)
 					select {
@@ -1530,14 +1532,14 @@
 					log.Fields{"device-id": oFsm.deviceID, "ResponseMeId": msgObj.EntityInstance})
 				// TODO!!!: error treatment?
 				//TODO!!!: possibly send event information for aborted upgrade (aborted by ONU state indication)?
-				_ = oFsm.pAdaptFsm.pFsm.Event(upgradeEvAbort)
+				_ = oFsm.PAdaptFsm.PFsm.Event(UpgradeEvAbort)
 				return
 			}
 
-			//assumed only relevant state here is upgradeStCheckCommitted
+			//assumed only relevant state here is UpgradeStCheckCommitted
 			oFsm.mutexUpgradeParams.Lock()
 			oFsm.conditionalCancelRequested = false //getting here any set (conditional) cancelRequest is not relevant anymore
-			if msgObj.EntityInstance == oFsm.inactiveImageMeID && imageIsActive == swIsActive {
+			if msgObj.EntityInstance == oFsm.InactiveImageMeID && imageIsActive == cmn.SwIsActive {
 				//a check on the delivered image version is not done, the ONU delivered version might be different from what might have been
 				//  indicated in the download image version string (version must be part of the image content itself)
 				//  so checking that might be quite unreliable
@@ -1555,23 +1557,23 @@
 						oFsm.volthaDownloadReason = voltha.ImageState_CANCELLED_ON_ONU_STATE //something like 'UNEXPECTED_VERSION' would be better - proto def
 						oFsm.volthaImageState = voltha.ImageState_IMAGE_UNKNOWN              //expected image not known
 						oFsm.mutexUpgradeParams.Unlock()
-						_ = oFsm.pAdaptFsm.pFsm.Event(upgradeEvAbort)
+						_ = oFsm.PAdaptFsm.PFsm.Event(UpgradeEvAbort)
 						return
 					}
 					logger.Debugw(ctx, "OnuUpgradeFsm - expected ONU image version indicated by the ONU",
 						log.Fields{"device-id": oFsm.deviceID})
 				}
-				if imageIsCommitted == swIsCommitted {
+				if imageIsCommitted == cmn.SwIsCommitted {
 					oFsm.volthaDownloadState = voltha.ImageState_DOWNLOAD_SUCCEEDED
 					oFsm.volthaImageState = voltha.ImageState_IMAGE_COMMITTED
 					//store the new commit flag to onuSwImageIndications (to keep them in sync)
-					oFsm.pDevEntry.modifySwImageActiveCommit(ctx, imageIsCommitted)
+					oFsm.pDevEntry.ModifySwImageActiveCommit(ctx, imageIsCommitted)
 					logger.Infow(ctx, "requested SW image committed, releasing OnuUpgrade", log.Fields{"device-id": oFsm.deviceID})
 					//deviceProcStatusUpdate not used anymore,
-					// replaced by transferring the last (more) upgrade state information within removeOnuUpgradeFsm
+					// replaced by transferring the last (more) upgrade state information within RemoveOnuUpgradeFsm
 					oFsm.mutexUpgradeParams.Unlock()
 					//releasing the upgrade FSM on success
-					_ = oFsm.pAdaptFsm.pFsm.Event(upgradeEvAbort)
+					_ = oFsm.PAdaptFsm.PFsm.Event(UpgradeEvAbort)
 					return
 				}
 				//if not committed, abort upgrade as failed. There is no implementation here that would trigger this test again
@@ -1584,7 +1586,7 @@
 				log.Fields{"device-id": oFsm.deviceID, "ResponseMeId": msgObj.EntityInstance})
 			// TODO!!!: error treatment?
 			//TODO!!!: possibly send event information for aborted upgrade (aborted by omci processing)??
-			_ = oFsm.pAdaptFsm.pFsm.Event(upgradeEvAbort)
+			_ = oFsm.PAdaptFsm.PFsm.Event(UpgradeEvAbort)
 			return
 		} //GetResponseType
 	default:
@@ -1609,17 +1611,17 @@
 	}
 	oFsm.mutexUpgradeParams.Unlock()
 	//TODO!!!: possibly send event information for aborted upgrade (aborted by omci processing)??
-	if oFsm.pAdaptFsm != nil {
+	if oFsm.PAdaptFsm != nil {
 		var err error
 		if aAsync { //asynchronous call requested to ensure state transition
-			go func(a_pAFsm *AdapterFsm) {
-				if a_pAFsm.pFsm != nil {
-					err = oFsm.pAdaptFsm.pFsm.Event(upgradeEvAbort)
+			go func(a_pAFsm *cmn.AdapterFsm) {
+				if a_pAFsm.PFsm != nil {
+					err = oFsm.PAdaptFsm.PFsm.Event(UpgradeEvAbort)
 				}
-			}(oFsm.pAdaptFsm)
+			}(oFsm.PAdaptFsm)
 		} else {
-			if oFsm.pAdaptFsm.pFsm != nil {
-				err = oFsm.pAdaptFsm.pFsm.Event(upgradeEvAbort)
+			if oFsm.PAdaptFsm.PFsm != nil {
+				err = oFsm.PAdaptFsm.PFsm.Event(UpgradeEvAbort)
 			}
 		}
 		if err != nil {
@@ -1658,8 +1660,8 @@
 		oFsm.volthaImageState = voltha.ImageState_IMAGE_UNKNOWN     //something like 'IMAGE_DOWNLOAD_ABORTED' would be better (proto)
 		oFsm.mutexUpgradeParams.Unlock()
 		//TODO!!!: possibly send event information for aborted upgrade (aborted by omci processing)??
-		if oFsm.pAdaptFsm != nil && oFsm.pAdaptFsm.pFsm != nil {
-			err := oFsm.pAdaptFsm.pFsm.Event(upgradeEvAbort)
+		if oFsm.PAdaptFsm != nil && oFsm.PAdaptFsm.PFsm != nil {
+			err := oFsm.PAdaptFsm.PFsm.Event(UpgradeEvAbort)
 			if err != nil {
 				logger.Warnw(ctx, "onu upgrade fsm could not abort on omci error", log.Fields{
 					"device-id": oFsm.deviceID, "error": err})
@@ -1674,9 +1676,9 @@
 			oFsm.isWaitingForAdapterDlResponse = false
 			oFsm.mutexIsAwaitingAdapterDlResponse.Unlock()
 			//let the upgrade process proceed
-			pUpgradeFsm := oFsm.pAdaptFsm
+			pUpgradeFsm := oFsm.PAdaptFsm
 			if pUpgradeFsm != nil {
-				_ = pUpgradeFsm.pFsm.Event(upgradeEvPrepareSwDownload)
+				_ = pUpgradeFsm.PFsm.Event(UpgradeEvPrepareSwDownload)
 			} else {
 				logger.Errorw(ctx, "pUpgradeFsm is nil", log.Fields{"device-id": oFsm.deviceID})
 			}
diff --git a/internal/pkg/onuadaptercore/onu_image_status.go b/internal/pkg/swupg/onu_image_status.go
similarity index 74%
rename from internal/pkg/onuadaptercore/onu_image_status.go
rename to internal/pkg/swupg/onu_image_status.go
index d226134..4e1215f 100755
--- a/internal/pkg/onuadaptercore/onu_image_status.go
+++ b/internal/pkg/swupg/onu_image_status.go
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package swupg provides the utilities for onu sw upgrade
+package swupg
 
 import (
 	"context"
@@ -27,17 +27,20 @@
 	"github.com/opencord/omci-lib-go"
 	me "github.com/opencord/omci-lib-go/generated"
 	"github.com/opencord/voltha-lib-go/v7/pkg/log"
+	cmn "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/common"
 	"github.com/opencord/voltha-protos/v5/go/voltha"
 )
 
 //OnuImageStatus implements methods to get status info of onu images
 type OnuImageStatus struct {
-	pDevEntry              *OnuDeviceEntry
 	deviceID               string
+	pDeviceHandler         cmn.IdeviceHandler
+	pDevEntry              cmn.IonuDeviceEntry
+	pOmciCC                *cmn.OmciCC
 	requestedAttributes    me.AttributeValueMap
 	mutexWaitingForResp    sync.RWMutex
 	waitingForResp         bool
-	respChannel            chan Message
+	respChannel            chan cmn.Message
 	mutexPLastTxMeInstance sync.RWMutex
 	pLastTxMeInstance      *me.ManagedEntity
 }
@@ -53,30 +56,33 @@
 const cResponse = "response: "
 
 //NewOnuImageStatus creates a new instance of OnuImageStatus
-func NewOnuImageStatus(pDevEntry *OnuDeviceEntry) *OnuImageStatus {
+func NewOnuImageStatus(apDeviceHandler cmn.IdeviceHandler, apDevEntry cmn.IonuDeviceEntry) *OnuImageStatus {
 	return &OnuImageStatus{
-		pDevEntry:           pDevEntry,
-		deviceID:            pDevEntry.deviceID,
+		deviceID:            apDeviceHandler.GetDeviceID(),
+		pDeviceHandler:      apDeviceHandler,
+		pDevEntry:           apDevEntry,
+		pOmciCC:             apDevEntry.GetDevOmciCC(),
 		requestedAttributes: make(me.AttributeValueMap),
 		waitingForResp:      false,
-		respChannel:         make(chan Message),
+		respChannel:         make(chan cmn.Message),
 	}
 }
 
-func (oo *OnuImageStatus) getOnuImageStatus(ctx context.Context) (*voltha.OnuImages, error) {
+// GetOnuImageStatus - TODO: add comment
+func (oo *OnuImageStatus) GetOnuImageStatus(ctx context.Context) (*voltha.OnuImages, error) {
 
-	if !oo.pDevEntry.baseDeviceHandler.isReadyForOmciConfig() {
+	if !oo.pDeviceHandler.IsReadyForOmciConfig() {
 		logger.Errorw(ctx, "command rejected - improper device state", log.Fields{"device-id": oo.deviceID})
 		return nil, fmt.Errorf("command-rejected-improper-device-state")
 	}
-	if oo.pDevEntry.PDevOmciCC == nil {
+	if oo.pOmciCC == nil {
 		logger.Errorw(ctx, "omciCC not ready to receive omci messages", log.Fields{"device-id": oo.deviceID})
 		return nil, fmt.Errorf("omciCC-not-ready-to-receive-omci-messages")
 	}
 	var images voltha.OnuImages
 
-	for i := firstSwImageMeID; i <= secondSwImageMeID; i++ {
-		logger.Debugw(ctx, "getOnuImageStatus for image id", log.Fields{"image-id": i, "device-id": oo.deviceID})
+	for i := cmn.FirstSwImageMeID; i <= cmn.SecondSwImageMeID; i++ {
+		logger.Debugw(ctx, "GetOnuImageStatus for image id", log.Fields{"image-id": i, "device-id": oo.deviceID})
 
 		var image voltha.OnuImage
 
@@ -110,8 +116,8 @@
 
 func (oo *OnuImageStatus) requestOnuImageAttributes(ctx context.Context, imageID uint16, image *voltha.OnuImage) error {
 	oo.mutexPLastTxMeInstance.Lock()
-	meInstance, err := oo.pDevEntry.PDevOmciCC.sendGetMe(log.WithSpanFromContext(context.TODO(), ctx), me.SoftwareImageClassID,
-		imageID, oo.requestedAttributes, oo.pDevEntry.pOpenOnuAc.omciTimeout, true, oo.respChannel)
+	meInstance, err := oo.pOmciCC.SendGetMe(log.WithSpanFromContext(context.TODO(), ctx), me.SoftwareImageClassID,
+		imageID, oo.requestedAttributes, oo.pDeviceHandler.GetOmciTimeout(), true, oo.respChannel)
 	if err != nil {
 		oo.mutexPLastTxMeInstance.Unlock()
 		logger.Errorw(ctx, "can't send omci request to get data for image id", log.Fields{"image-id": imageID, "device-id": oo.deviceID})
@@ -135,7 +141,7 @@
 		logger.Errorw(ctx, "waitForGetOnuImageStatus context done", log.Fields{"device-id": oo.deviceID})
 		oo.setWaitingForResp(false)
 		return fmt.Errorf("wait-for-image-status-context-done")
-	case <-time.After(oo.pDevEntry.PDevOmciCC.GetMaxOmciTimeoutWithRetries() * time.Second):
+	case <-time.After(oo.pOmciCC.GetMaxOmciTimeoutWithRetries() * time.Second):
 		logger.Errorw(ctx, "waitForGetOnuImageStatus timeout", log.Fields{"device-id": oo.deviceID})
 		oo.setWaitingForResp(false)
 		return fmt.Errorf("wait-for-image-status-timeout")
@@ -146,13 +152,13 @@
 			return fmt.Errorf("wait-for-image-status-response-error")
 		}
 		switch message.Type {
-		case OMCI:
-			msg, _ := message.Data.(OmciMessage)
+		case cmn.OMCI:
+			msg, _ := message.Data.(cmn.OmciMessage)
 			oo.setWaitingForResp(false)
 			return oo.processGetOnuImageStatusResp(ctx, msg, image)
-		case TestMsg:
-			msg, _ := message.Data.(TestMessage)
-			if msg.TestMessageVal == AbortMessageProcessing {
+		case cmn.TestMsg:
+			msg, _ := message.Data.(cmn.TestMessage)
+			if msg.TestMessageVal == cmn.AbortMessageProcessing {
 				logger.Info(ctx, "waitForGetOnuImageStatus abort msg received", log.Fields{"device-id": oo.deviceID})
 				oo.setWaitingForResp(false)
 				return fmt.Errorf("wait-for-image-status-abort-msg-received")
@@ -169,7 +175,7 @@
 
 }
 
-func (oo *OnuImageStatus) processGetOnuImageStatusResp(ctx context.Context, msg OmciMessage, image *voltha.OnuImage) error {
+func (oo *OnuImageStatus) processGetOnuImageStatusResp(ctx context.Context, msg cmn.OmciMessage, image *voltha.OnuImage) error {
 	if msg.OmciMsg.MessageType != omci.GetResponseType {
 		logger.Errorw(ctx, "processGetOnuImageStatusResp wrong response type received", log.Fields{"respType": msg.OmciMsg.MessageType, "device-id": oo.deviceID})
 		return fmt.Errorf("process-image-status-response-error")
@@ -219,30 +225,30 @@
 
 		// mandatory attributes
 		case cImgIsCommitted:
-			if meAttributes[cImgIsCommitted].(uint8) == swIsCommitted {
+			if meAttributes[cImgIsCommitted].(uint8) == cmn.SwIsCommitted {
 				image.IsCommited = true
 			} else {
 				image.IsCommited = false
 			}
 		case cImgIsActive:
-			if meAttributes[cImgIsActive].(uint8) == swIsActive {
+			if meAttributes[cImgIsActive].(uint8) == cmn.SwIsActive {
 				image.IsActive = true
 			} else {
 				image.IsActive = false
 			}
 		case cImgIsValid:
-			if meAttributes[cImgIsValid].(uint8) == swIsValid {
+			if meAttributes[cImgIsValid].(uint8) == cmn.SwIsValid {
 				image.IsValid = true
 			} else {
 				image.IsValid = false
 			}
 		case cImgVersion:
-			image.Version = TrimStringFromMeOctet(meAttributes[cImgVersion])
+			image.Version = cmn.TrimStringFromMeOctet(meAttributes[cImgVersion])
 
 		// optional attributes
 		case cImgProductCode:
 			if msgObj.Result == me.Success {
-				image.ProductCode = TrimStringFromMeOctet(meAttributes[cImgProductCode])
+				image.ProductCode = cmn.TrimStringFromMeOctet(meAttributes[cImgProductCode])
 			} else {
 				sResult := msgObj.Result.String()
 				logger.Infow(ctx, "processAttributesReceived - ProductCode",
@@ -266,63 +272,66 @@
 
 func (oo *OnuImageStatus) updateOnuSwImageIndications(ctx context.Context, images *voltha.OnuImages) {
 
-	oo.pDevEntry.mutexOnuSwImageIndications.Lock()
+	oo.pDevEntry.LockMutexOnuSwImageIndications()
+	onuSwImageIndications := oo.pDevEntry.GetOnuSwImageIndications()
 	validActiveImageFound := false
-	for i := firstSwImageMeID; i <= secondSwImageMeID; i++ {
+	for i := cmn.FirstSwImageMeID; i <= cmn.SecondSwImageMeID; i++ {
 		if images.Items[i].IsActive && images.Items[i].IsValid {
-			oo.pDevEntry.onuSwImageIndications.activeEntityEntry.entityID = uint16(i)
-			oo.pDevEntry.onuSwImageIndications.activeEntityEntry.valid = images.Items[i].IsValid
-			oo.pDevEntry.onuSwImageIndications.activeEntityEntry.version = images.Items[i].Version
+			onuSwImageIndications.ActiveEntityEntry.EntityID = uint16(i)
+			onuSwImageIndications.ActiveEntityEntry.Valid = images.Items[i].IsValid
+			onuSwImageIndications.ActiveEntityEntry.Version = images.Items[i].Version
 			if images.Items[i].IsCommited {
-				oo.pDevEntry.onuSwImageIndications.activeEntityEntry.isCommitted = swIsCommitted
+				onuSwImageIndications.ActiveEntityEntry.IsCommitted = cmn.SwIsCommitted
 			} else {
-				oo.pDevEntry.onuSwImageIndications.activeEntityEntry.isCommitted = swIsUncommitted
+				onuSwImageIndications.ActiveEntityEntry.IsCommitted = cmn.SwIsUncommitted
 			}
 			validActiveImageFound = true
 			break
 		}
 	}
 	if !validActiveImageFound {
-		oo.pDevEntry.onuSwImageIndications.activeEntityEntry.valid = false
+		onuSwImageIndications.ActiveEntityEntry.Valid = false
 	}
 	validInactiveImageFound := false
-	for i := firstSwImageMeID; i <= secondSwImageMeID; i++ {
+	for i := cmn.FirstSwImageMeID; i <= cmn.SecondSwImageMeID; i++ {
 		if !images.Items[i].IsActive && images.Items[i].IsValid {
-			oo.pDevEntry.onuSwImageIndications.inactiveEntityEntry.entityID = uint16(i)
-			oo.pDevEntry.onuSwImageIndications.inactiveEntityEntry.valid = images.Items[i].IsValid
-			oo.pDevEntry.onuSwImageIndications.inactiveEntityEntry.version = images.Items[i].Version
+			onuSwImageIndications.InActiveEntityEntry.EntityID = uint16(i)
+			onuSwImageIndications.InActiveEntityEntry.Valid = images.Items[i].IsValid
+			onuSwImageIndications.InActiveEntityEntry.Version = images.Items[i].Version
 			if images.Items[i].IsCommited {
-				oo.pDevEntry.onuSwImageIndications.inactiveEntityEntry.isCommitted = swIsCommitted
+				onuSwImageIndications.InActiveEntityEntry.IsCommitted = cmn.SwIsCommitted
 			} else {
-				oo.pDevEntry.onuSwImageIndications.inactiveEntityEntry.isCommitted = swIsUncommitted
+				onuSwImageIndications.InActiveEntityEntry.IsCommitted = cmn.SwIsUncommitted
 			}
 			validInactiveImageFound = true
 			break
 		}
 	}
 	if !validInactiveImageFound {
-		oo.pDevEntry.onuSwImageIndications.inactiveEntityEntry.valid = false
+		onuSwImageIndications.InActiveEntityEntry.Valid = false
 	}
-	oo.pDevEntry.mutexOnuSwImageIndications.Unlock()
+	oo.pDevEntry.SetOnuSwImageIndications(onuSwImageIndications)
+	oo.pDevEntry.UnlockMutexOnuSwImageIndications()
 }
 
 func (oo *OnuImageStatus) updateOnuSwImagePersistentData(ctx context.Context) {
 
-	activeImageVersion := oo.pDevEntry.getActiveImageVersion(ctx)
-	oo.pDevEntry.mutexPersOnuConfig.Lock()
-	if oo.pDevEntry.sOnuPersistentData.PersActiveSwVersion != activeImageVersion {
+	activeImageVersion := oo.pDevEntry.GetActiveImageVersion(ctx)
+	oo.pDevEntry.LockMutexPersOnuConfig()
+	persActiveSwVersion := oo.pDevEntry.GetPersActiveSwVersion()
+	if persActiveSwVersion != activeImageVersion {
 		logger.Infow(ctx, "Active SW version has been changed at ONU - update persistent data",
-			log.Fields{"old version": oo.pDevEntry.sOnuPersistentData.PersActiveSwVersion,
+			log.Fields{"old version": persActiveSwVersion,
 				"new version": activeImageVersion, "device-id": oo.deviceID})
-		oo.pDevEntry.sOnuPersistentData.PersActiveSwVersion = activeImageVersion
-		oo.pDevEntry.mutexPersOnuConfig.Unlock()
-		if err := oo.pDevEntry.baseDeviceHandler.storePersistentData(ctx); err != nil {
+		oo.pDevEntry.SetPersActiveSwVersion(activeImageVersion)
+		oo.pDevEntry.UnlockMutexPersOnuConfig()
+		if err := oo.pDeviceHandler.StorePersistentData(ctx); err != nil {
 			logger.Warnw(ctx, "store persistent data error - continue for now as there will be additional write attempts",
 				log.Fields{"device-id": oo.deviceID, "err": err})
 		}
 		return
 	}
-	oo.pDevEntry.mutexPersOnuConfig.Unlock()
+	oo.pDevEntry.UnlockMutexPersOnuConfig()
 }
 
 func (oo *OnuImageStatus) setWaitingForResp(value bool) {
@@ -341,10 +350,10 @@
 //CancelProcessing ensures that interrupted processing is canceled while waiting for a response
 func (oo *OnuImageStatus) CancelProcessing(ctx context.Context) {
 	if oo.isWaitingForResp() {
-		abortMsg := Message{
-			Type: TestMsg,
-			Data: TestMessage{
-				TestMessageVal: AbortMessageProcessing,
+		abortMsg := cmn.Message{
+			Type: cmn.TestMsg,
+			Data: cmn.TestMessage{
+				TestMessageVal: cmn.AbortMessageProcessing,
 			},
 		}
 		oo.respChannel <- abortMsg
diff --git a/internal/pkg/onuadaptercore/common.go b/internal/pkg/uniprt/common.go
old mode 100644
new mode 100755
similarity index 86%
copy from internal/pkg/onuadaptercore/common.go
copy to internal/pkg/uniprt/common.go
index b0b10e3..3dcfe83
--- a/internal/pkg/onuadaptercore/common.go
+++ b/internal/pkg/uniprt/common.go
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package uniprt provides the utilities for uni port configuration
+package uniprt
 
 import (
 	"github.com/opencord/voltha-lib-go/v7/pkg/log"
@@ -26,7 +26,7 @@
 func init() {
 	// Setup this package so that it's log level can be modified at run time
 	var err error
-	logger, err = log.RegisterPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "adaptercoreonu"})
+	logger, err = log.RegisterPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "uniprt"})
 	if err != nil {
 		panic(err)
 	}
diff --git a/internal/pkg/onuadaptercore/uniportadmin.go b/internal/pkg/uniprt/uniportadmin.go
old mode 100644
new mode 100755
similarity index 63%
rename from internal/pkg/onuadaptercore/uniportadmin.go
rename to internal/pkg/uniprt/uniportadmin.go
index 2ceea25..a9de1dd
--- a/internal/pkg/onuadaptercore/uniportadmin.go
+++ b/internal/pkg/uniprt/uniportadmin.go
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package uniprt provides the utilities for uni port configuration
+package uniprt
 
 import (
 	"context"
@@ -28,128 +28,134 @@
 	"github.com/opencord/omci-lib-go"
 	me "github.com/opencord/omci-lib-go/generated"
 	"github.com/opencord/voltha-lib-go/v7/pkg/log"
+	cmn "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/common"
 )
 
-//lockStateFsm defines the structure for the state machine to lock/unlock the ONU UNI ports via OMCI
-type lockStateFsm struct {
-	pDeviceHandler           *deviceHandler
+//LockStateFsm defines the structure for the state machine to lock/unlock the ONU UNI ports via OMCI
+type LockStateFsm struct {
 	deviceID                 string
-	pOmciCC                  *omciCC
+	pDeviceHandler           cmn.IdeviceHandler
+	pOnuDeviceEntry          cmn.IonuDeviceEntry
+	pOmciCC                  *cmn.OmciCC
 	mutexAdminState          sync.RWMutex
 	adminState               bool
-	requestEvent             OnuDeviceEvent
+	requestEvent             cmn.OnuDeviceEvent
 	omciLockResponseReceived chan bool //seperate channel needed for checking UNI port OMCi message responses
-	pAdaptFsm                *AdapterFsm
+	PAdaptFsm                *cmn.AdapterFsm
 	mutexPLastTxMeInstance   sync.RWMutex
 	pLastTxMeInstance        *me.ManagedEntity
 }
 
+// events of lock/unlock UNI port FSM
 const (
-	// events of lock/unlock UNI port FSM
-	uniEvStart         = "uniEvStart"
-	uniEvStartAdmin    = "uniEvStartAdmin"
-	uniEvRxUnisResp    = "uniEvRxUnisResp"
-	uniEvRxOnugResp    = "uniEvRxOnugResp"
-	uniEvTimeoutSimple = "uniEvTimeoutSimple"
-	uniEvTimeoutUnis   = "uniEvTimeoutUnis"
-	uniEvReset         = "uniEvReset"
-	uniEvRestart       = "uniEvRestart"
+	UniEvStart         = "UniEvStart"
+	UniEvStartAdmin    = "UniEvStartAdmin"
+	UniEvRxUnisResp    = "UniEvRxUnisResp"
+	UniEvRxOnugResp    = "UniEvRxOnugResp"
+	UniEvTimeoutSimple = "UniEvTimeoutSimple"
+	UniEvTimeoutUnis   = "UniEvTimeoutUnis"
+	UniEvReset         = "UniEvReset"
+	UniEvRestart       = "UniEvRestart"
 )
-const (
-	// states of lock/unlock UNI port FSM
-	uniStDisabled    = "uniStDisabled"
-	uniStStarting    = "uniStStarting"
-	uniStSettingUnis = "uniStSettingUnis"
-	uniStSettingOnuG = "uniStSettingOnuG"
-	uniStAdminDone   = "uniStAdminDone"
-	uniStResetting   = "uniStResetting"
-)
-const cUniFsmIdleState = uniStDisabled
 
-//newLockStateFsm is the 'constructor' for the state machine to lock/unlock the ONU UNI ports via OMCI
-func newLockStateFsm(ctx context.Context, apDevOmciCC *omciCC, aAdminState bool, aRequestEvent OnuDeviceEvent,
-	aName string, apDeviceHandler *deviceHandler, aCommChannel chan Message) *lockStateFsm {
-	instFsm := &lockStateFsm{
-		pDeviceHandler: apDeviceHandler,
-		deviceID:       apDeviceHandler.deviceID,
-		pOmciCC:        apDevOmciCC,
-		adminState:     aAdminState,
-		requestEvent:   aRequestEvent,
+// states of lock/unlock UNI port FSM
+const (
+	UniStDisabled    = "UniStDisabled"
+	UniStStarting    = "UniStStarting"
+	UniStSettingUnis = "UniStSettingUnis"
+	UniStSettingOnuG = "UniStSettingOnuG"
+	UniStAdminDone   = "UniStAdminDone"
+	UniStResetting   = "UniStResetting"
+)
+
+// CUniFsmIdleState - TODO: add comment
+const CUniFsmIdleState = UniStDisabled
+
+//NewLockStateFsm is the 'constructor' for the state machine to lock/unlock the ONU UNI ports via OMCI
+func NewLockStateFsm(ctx context.Context, aAdminState bool, aRequestEvent cmn.OnuDeviceEvent,
+	aName string, apDeviceHandler cmn.IdeviceHandler, apOnuDeviceEntry cmn.IonuDeviceEntry, aCommChannel chan cmn.Message) *LockStateFsm {
+	instFsm := &LockStateFsm{
+		deviceID:        apDeviceHandler.GetDeviceID(),
+		pDeviceHandler:  apDeviceHandler,
+		pOnuDeviceEntry: apOnuDeviceEntry,
+		pOmciCC:         apOnuDeviceEntry.GetDevOmciCC(),
+		adminState:      aAdminState,
+		requestEvent:    aRequestEvent,
 	}
-	instFsm.pAdaptFsm = NewAdapterFsm(aName, instFsm.deviceID, aCommChannel)
-	if instFsm.pAdaptFsm == nil {
-		logger.Errorw(ctx, "LockStateFsm's AdapterFsm could not be instantiated!!", log.Fields{
+	instFsm.PAdaptFsm = cmn.NewAdapterFsm(aName, instFsm.deviceID, aCommChannel)
+	if instFsm.PAdaptFsm == nil {
+		logger.Errorw(ctx, "LockStateFsm's cmn.AdapterFsm could not be instantiated!!", log.Fields{
 			"device-id": instFsm.deviceID})
 		return nil
 	}
 	if aAdminState { //port locking requested
-		instFsm.pAdaptFsm.pFsm = fsm.NewFSM(
-			uniStDisabled,
+		instFsm.PAdaptFsm.PFsm = fsm.NewFSM(
+			UniStDisabled,
 			fsm.Events{
 
-				{Name: uniEvStart, Src: []string{uniStDisabled}, Dst: uniStStarting},
+				{Name: UniEvStart, Src: []string{UniStDisabled}, Dst: UniStStarting},
 
-				{Name: uniEvStartAdmin, Src: []string{uniStStarting}, Dst: uniStSettingUnis},
+				{Name: UniEvStartAdmin, Src: []string{UniStStarting}, Dst: UniStSettingUnis},
 				// the settingUnis state is used for multi ME config for all UNI related ports
 				// maybe such could be reflected in the state machine as well (port number parametrized)
 				// but that looks not straightforward here - so we keep it simple here for the beginning(?)
-				{Name: uniEvRxUnisResp, Src: []string{uniStSettingUnis}, Dst: uniStSettingOnuG},
-				{Name: uniEvRxOnugResp, Src: []string{uniStSettingOnuG}, Dst: uniStAdminDone},
+				{Name: UniEvRxUnisResp, Src: []string{UniStSettingUnis}, Dst: UniStSettingOnuG},
+				{Name: UniEvRxOnugResp, Src: []string{UniStSettingOnuG}, Dst: UniStAdminDone},
 
-				{Name: uniEvTimeoutSimple, Src: []string{uniStSettingOnuG}, Dst: uniStStarting},
-				{Name: uniEvTimeoutUnis, Src: []string{uniStSettingUnis}, Dst: uniStStarting},
+				{Name: UniEvTimeoutSimple, Src: []string{UniStSettingOnuG}, Dst: UniStStarting},
+				{Name: UniEvTimeoutUnis, Src: []string{UniStSettingUnis}, Dst: UniStStarting},
 
-				{Name: uniEvReset, Src: []string{uniStStarting, uniStSettingOnuG, uniStSettingUnis,
-					uniStAdminDone}, Dst: uniStResetting},
-				// exceptional treatment for all states except uniStResetting
-				{Name: uniEvRestart, Src: []string{uniStStarting, uniStSettingOnuG, uniStSettingUnis,
-					uniStAdminDone, uniStResetting}, Dst: uniStDisabled},
+				{Name: UniEvReset, Src: []string{UniStStarting, UniStSettingOnuG, UniStSettingUnis,
+					UniStAdminDone}, Dst: UniStResetting},
+				// exceptional treatment for all states except UniStResetting
+				{Name: UniEvRestart, Src: []string{UniStStarting, UniStSettingOnuG, UniStSettingUnis,
+					UniStAdminDone, UniStResetting}, Dst: UniStDisabled},
 			},
 
 			fsm.Callbacks{
-				"enter_state":                 func(e *fsm.Event) { instFsm.pAdaptFsm.logFsmStateChange(ctx, e) },
-				("enter_" + uniStStarting):    func(e *fsm.Event) { instFsm.enterAdminStartingState(ctx, e) },
-				("enter_" + uniStSettingOnuG): func(e *fsm.Event) { instFsm.enterSettingOnuGState(ctx, e) },
-				("enter_" + uniStSettingUnis): func(e *fsm.Event) { instFsm.enterSettingUnisState(ctx, e) },
-				("enter_" + uniStAdminDone):   func(e *fsm.Event) { instFsm.enterAdminDoneState(ctx, e) },
-				("enter_" + uniStResetting):   func(e *fsm.Event) { instFsm.enterResettingState(ctx, e) },
+				"enter_state":                 func(e *fsm.Event) { instFsm.PAdaptFsm.LogFsmStateChange(ctx, e) },
+				("enter_" + UniStStarting):    func(e *fsm.Event) { instFsm.enterAdminStartingState(ctx, e) },
+				("enter_" + UniStSettingOnuG): func(e *fsm.Event) { instFsm.enterSettingOnuGState(ctx, e) },
+				("enter_" + UniStSettingUnis): func(e *fsm.Event) { instFsm.enterSettingUnisState(ctx, e) },
+				("enter_" + UniStAdminDone):   func(e *fsm.Event) { instFsm.enterAdminDoneState(ctx, e) },
+				("enter_" + UniStResetting):   func(e *fsm.Event) { instFsm.enterResettingState(ctx, e) },
 			},
 		)
 	} else { //port unlocking requested
-		instFsm.pAdaptFsm.pFsm = fsm.NewFSM(
-			uniStDisabled,
+		instFsm.PAdaptFsm.PFsm = fsm.NewFSM(
+			UniStDisabled,
 			fsm.Events{
 
-				{Name: uniEvStart, Src: []string{uniStDisabled}, Dst: uniStStarting},
+				{Name: UniEvStart, Src: []string{UniStDisabled}, Dst: UniStStarting},
 
-				{Name: uniEvStartAdmin, Src: []string{uniStStarting}, Dst: uniStSettingOnuG},
-				{Name: uniEvRxOnugResp, Src: []string{uniStSettingOnuG}, Dst: uniStSettingUnis},
+				{Name: UniEvStartAdmin, Src: []string{UniStStarting}, Dst: UniStSettingOnuG},
+				{Name: UniEvRxOnugResp, Src: []string{UniStSettingOnuG}, Dst: UniStSettingUnis},
 				// the settingUnis state is used for multi ME config for all UNI related ports
 				// maybe such could be reflected in the state machine as well (port number parametrized)
 				// but that looks not straightforward here - so we keep it simple here for the beginning(?)
-				{Name: uniEvRxUnisResp, Src: []string{uniStSettingUnis}, Dst: uniStAdminDone},
+				{Name: UniEvRxUnisResp, Src: []string{UniStSettingUnis}, Dst: UniStAdminDone},
 
-				{Name: uniEvTimeoutSimple, Src: []string{uniStSettingOnuG}, Dst: uniStStarting},
-				{Name: uniEvTimeoutUnis, Src: []string{uniStSettingUnis}, Dst: uniStStarting},
+				{Name: UniEvTimeoutSimple, Src: []string{UniStSettingOnuG}, Dst: UniStStarting},
+				{Name: UniEvTimeoutUnis, Src: []string{UniStSettingUnis}, Dst: UniStStarting},
 
-				{Name: uniEvReset, Src: []string{uniStStarting, uniStSettingOnuG, uniStSettingUnis,
-					uniStAdminDone}, Dst: uniStResetting},
-				// exceptional treatment for all states except uniStResetting
-				{Name: uniEvRestart, Src: []string{uniStStarting, uniStSettingOnuG, uniStSettingUnis,
-					uniStAdminDone, uniStResetting}, Dst: uniStDisabled},
+				{Name: UniEvReset, Src: []string{UniStStarting, UniStSettingOnuG, UniStSettingUnis,
+					UniStAdminDone}, Dst: UniStResetting},
+				// exceptional treatment for all states except UniStResetting
+				{Name: UniEvRestart, Src: []string{UniStStarting, UniStSettingOnuG, UniStSettingUnis,
+					UniStAdminDone, UniStResetting}, Dst: UniStDisabled},
 			},
 
 			fsm.Callbacks{
-				"enter_state":                 func(e *fsm.Event) { instFsm.pAdaptFsm.logFsmStateChange(ctx, e) },
-				("enter_" + uniStStarting):    func(e *fsm.Event) { instFsm.enterAdminStartingState(ctx, e) },
-				("enter_" + uniStSettingOnuG): func(e *fsm.Event) { instFsm.enterSettingOnuGState(ctx, e) },
-				("enter_" + uniStSettingUnis): func(e *fsm.Event) { instFsm.enterSettingUnisState(ctx, e) },
-				("enter_" + uniStAdminDone):   func(e *fsm.Event) { instFsm.enterAdminDoneState(ctx, e) },
-				("enter_" + uniStResetting):   func(e *fsm.Event) { instFsm.enterResettingState(ctx, e) },
+				"enter_state":                 func(e *fsm.Event) { instFsm.PAdaptFsm.LogFsmStateChange(ctx, e) },
+				("enter_" + UniStStarting):    func(e *fsm.Event) { instFsm.enterAdminStartingState(ctx, e) },
+				("enter_" + UniStSettingOnuG): func(e *fsm.Event) { instFsm.enterSettingOnuGState(ctx, e) },
+				("enter_" + UniStSettingUnis): func(e *fsm.Event) { instFsm.enterSettingUnisState(ctx, e) },
+				("enter_" + UniStAdminDone):   func(e *fsm.Event) { instFsm.enterAdminDoneState(ctx, e) },
+				("enter_" + UniStResetting):   func(e *fsm.Event) { instFsm.enterResettingState(ctx, e) },
 			},
 		)
 	}
-	if instFsm.pAdaptFsm.pFsm == nil {
+	if instFsm.PAdaptFsm.PFsm == nil {
 		logger.Errorw(ctx, "LockStateFsm's Base FSM could not be instantiated!!", log.Fields{
 			"device-id": instFsm.deviceID})
 		return nil
@@ -159,13 +165,13 @@
 	return instFsm
 }
 
-//setSuccessEvent modifies the requested event notified on success
+//SetSuccessEvent modifies the requested event notified on success
 //assumption is that this is only called in the disabled (idle) state of the FSM, hence no sem protection required
-func (oFsm *lockStateFsm) setSuccessEvent(aEvent OnuDeviceEvent) {
+func (oFsm *LockStateFsm) SetSuccessEvent(aEvent cmn.OnuDeviceEvent) {
 	oFsm.requestEvent = aEvent
 }
 
-func (oFsm *lockStateFsm) enterAdminStartingState(ctx context.Context, e *fsm.Event) {
+func (oFsm *LockStateFsm) enterAdminStartingState(ctx context.Context, e *fsm.Event) {
 	logger.Debugw(ctx, "LockStateFSM start", log.Fields{"in state": e.FSM.Current(),
 		"device-id": oFsm.deviceID})
 	// in case the used channel is not yet defined (can be re-used after restarts)
@@ -179,26 +185,26 @@
 		for len(oFsm.omciLockResponseReceived) > 0 {
 			<-oFsm.omciLockResponseReceived
 		}
-		for len(oFsm.pAdaptFsm.commChan) > 0 {
-			<-oFsm.pAdaptFsm.commChan
+		for len(oFsm.PAdaptFsm.CommChan) > 0 {
+			<-oFsm.PAdaptFsm.CommChan
 		}
 	}
 	// start go routine for processing of LockState messages
 	go oFsm.processOmciLockMessages(ctx)
 
 	//let the state machine run forward from here directly
-	pLockStateAFsm := oFsm.pAdaptFsm
+	pLockStateAFsm := oFsm.PAdaptFsm
 	if pLockStateAFsm != nil {
 		// obviously calling some FSM event here directly does not work - so trying to decouple it ...
-		go func(a_pAFsm *AdapterFsm) {
-			if a_pAFsm != nil && a_pAFsm.pFsm != nil {
-				_ = a_pAFsm.pFsm.Event(uniEvStartAdmin)
+		go func(a_pAFsm *cmn.AdapterFsm) {
+			if a_pAFsm != nil && a_pAFsm.PFsm != nil {
+				_ = a_pAFsm.PFsm.Event(UniEvStartAdmin)
 			}
 		}(pLockStateAFsm)
 	}
 }
 
-func (oFsm *lockStateFsm) enterSettingOnuGState(ctx context.Context, e *fsm.Event) {
+func (oFsm *LockStateFsm) enterSettingOnuGState(ctx context.Context, e *fsm.Event) {
 	var omciAdminState uint8 = 1 //default locked
 	oFsm.mutexAdminState.RLock()
 	if !oFsm.adminState {
@@ -209,16 +215,16 @@
 		"omciAdmin": omciAdminState, "in state": e.FSM.Current(), "device-id": oFsm.deviceID})
 	requestedAttributes := me.AttributeValueMap{"AdministrativeState": omciAdminState}
 	oFsm.mutexPLastTxMeInstance.Lock()
-	meInstance, err := oFsm.pOmciCC.sendSetOnuGLS(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
-		requestedAttributes, oFsm.pAdaptFsm.commChan)
+	meInstance, err := oFsm.pOmciCC.SendSetOnuGLS(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), true,
+		requestedAttributes, oFsm.PAdaptFsm.CommChan)
 	if err != nil {
 		oFsm.mutexPLastTxMeInstance.Unlock()
 		logger.Errorw(ctx, "OnuGLS set failed, aborting LockStateFSM", log.Fields{"device-id": oFsm.deviceID})
-		pLockStateAFsm := oFsm.pAdaptFsm
+		pLockStateAFsm := oFsm.PAdaptFsm
 		if pLockStateAFsm != nil {
-			go func(a_pAFsm *AdapterFsm) {
-				if a_pAFsm != nil && a_pAFsm.pFsm != nil {
-					_ = a_pAFsm.pFsm.Event(uniEvReset)
+			go func(a_pAFsm *cmn.AdapterFsm) {
+				if a_pAFsm != nil && a_pAFsm.PFsm != nil {
+					_ = a_pAFsm.PFsm.Event(UniEvReset)
 				}
 			}(pLockStateAFsm)
 		}
@@ -232,13 +238,13 @@
 		logger.Errorw(ctx, "could not send OMCI message from LockStateFsm", log.Fields{
 			"device-id": oFsm.deviceID})
 		//some more sophisticated approach is possible, e.g. repeating once, by now let's reset the state machine in order to release all resources now
-		pLockStateAFsm := oFsm.pAdaptFsm
+		pLockStateAFsm := oFsm.PAdaptFsm
 		if pLockStateAFsm != nil {
 
 			// obviously calling some FSM event here directly does not work - so trying to decouple it ...
-			go func(a_pAFsm *AdapterFsm) {
-				if a_pAFsm != nil && a_pAFsm.pFsm != nil {
-					_ = a_pAFsm.pFsm.Event(uniEvReset)
+			go func(a_pAFsm *cmn.AdapterFsm) {
+				if a_pAFsm != nil && a_pAFsm.PFsm != nil {
+					_ = a_pAFsm.PFsm.Event(UniEvReset)
 				}
 			}(pLockStateAFsm)
 		}
@@ -247,7 +253,7 @@
 	oFsm.mutexPLastTxMeInstance.Unlock()
 }
 
-func (oFsm *lockStateFsm) enterSettingUnisState(ctx context.Context, e *fsm.Event) {
+func (oFsm *LockStateFsm) enterSettingUnisState(ctx context.Context, e *fsm.Event) {
 	oFsm.mutexAdminState.RLock()
 	logger.Debugw(ctx, "LockStateFSM - starting UniTP adminState loop", log.Fields{
 		"in state": e.FSM.Current(), "device-id": oFsm.deviceID, "LockState": oFsm.adminState})
@@ -255,41 +261,41 @@
 	go oFsm.performUniPortAdminSet(ctx)
 }
 
-func (oFsm *lockStateFsm) enterAdminDoneState(ctx context.Context, e *fsm.Event) {
+func (oFsm *LockStateFsm) enterAdminDoneState(ctx context.Context, e *fsm.Event) {
 	logger.Debugw(ctx, "LockStateFSM", log.Fields{"send notification to core in State": e.FSM.Current(), "device-id": oFsm.deviceID})
 	//use DeviceHandler event notification directly, no need/support to update DeviceEntryState for lock/unlock
-	oFsm.pDeviceHandler.deviceProcStatusUpdate(ctx, oFsm.requestEvent)
+	oFsm.pDeviceHandler.DeviceProcStatusUpdate(ctx, oFsm.requestEvent)
 
 	//let's reset the state machine in order to release all resources now
-	pLockStateAFsm := oFsm.pAdaptFsm
+	pLockStateAFsm := oFsm.PAdaptFsm
 	if pLockStateAFsm != nil {
 		// obviously calling some FSM event here directly does not work - so trying to decouple it ...
-		go func(a_pAFsm *AdapterFsm) {
-			if a_pAFsm != nil && a_pAFsm.pFsm != nil {
-				_ = a_pAFsm.pFsm.Event(uniEvReset)
+		go func(a_pAFsm *cmn.AdapterFsm) {
+			if a_pAFsm != nil && a_pAFsm.PFsm != nil {
+				_ = a_pAFsm.PFsm.Event(UniEvReset)
 			}
 		}(pLockStateAFsm)
 	}
 }
 
-func (oFsm *lockStateFsm) enterResettingState(ctx context.Context, e *fsm.Event) {
+func (oFsm *LockStateFsm) enterResettingState(ctx context.Context, e *fsm.Event) {
 	logger.Debugw(ctx, "LockStateFSM resetting", log.Fields{"device-id": oFsm.deviceID})
-	pLockStateAFsm := oFsm.pAdaptFsm
+	pLockStateAFsm := oFsm.PAdaptFsm
 	if pLockStateAFsm != nil {
 		// abort running message processing
-		fsmAbortMsg := Message{
-			Type: TestMsg,
-			Data: TestMessage{
-				TestMessageVal: AbortMessageProcessing,
+		fsmAbortMsg := cmn.Message{
+			Type: cmn.TestMsg,
+			Data: cmn.TestMessage{
+				TestMessageVal: cmn.AbortMessageProcessing,
 			},
 		}
-		pLockStateAFsm.commChan <- fsmAbortMsg
+		pLockStateAFsm.CommChan <- fsmAbortMsg
 
 		//try to restart the FSM to 'disabled'
 		// see DownloadedState: decouple event transfer
-		go func(a_pAFsm *AdapterFsm) {
-			if a_pAFsm != nil && a_pAFsm.pFsm != nil {
-				_ = a_pAFsm.pFsm.Event(uniEvRestart)
+		go func(a_pAFsm *cmn.AdapterFsm) {
+			if a_pAFsm != nil && a_pAFsm.PFsm != nil {
+				_ = a_pAFsm.PFsm.Event(UniEvRestart)
 			}
 		}(pLockStateAFsm)
 		oFsm.mutexPLastTxMeInstance.Lock()
@@ -298,32 +304,32 @@
 	}
 }
 
-func (oFsm *lockStateFsm) processOmciLockMessages(ctx context.Context) {
+func (oFsm *LockStateFsm) processOmciLockMessages(ctx context.Context) {
 	logger.Debugw(ctx, "Start LockStateFsm Msg processing", log.Fields{"for device-id": oFsm.deviceID})
 loop:
 	for {
 		// case <-ctx.Done():
 		// 	logger.Info(ctx,"MibSync Msg", log.Fields{"Message handling canceled via context for device-id": oFsm.deviceID})
 		// 	break loop
-		message, ok := <-oFsm.pAdaptFsm.commChan
+		message, ok := <-oFsm.PAdaptFsm.CommChan
 		if !ok {
 			logger.Info(ctx, "LockStateFsm Rx Msg - could not read from channel", log.Fields{"device-id": oFsm.deviceID})
 			// but then we have to ensure a restart of the FSM as well - as exceptional procedure
-			_ = oFsm.pAdaptFsm.pFsm.Event(uniEvRestart)
+			_ = oFsm.PAdaptFsm.PFsm.Event(UniEvRestart)
 			break loop
 		}
 		logger.Debugw(ctx, "LockStateFsm Rx Msg", log.Fields{"device-id": oFsm.deviceID})
 
 		switch message.Type {
-		case TestMsg:
-			msg, _ := message.Data.(TestMessage)
-			if msg.TestMessageVal == AbortMessageProcessing {
+		case cmn.TestMsg:
+			msg, _ := message.Data.(cmn.TestMessage)
+			if msg.TestMessageVal == cmn.AbortMessageProcessing {
 				logger.Debugw(ctx, "LockStateFsm abort ProcessMsg", log.Fields{"for device-id": oFsm.deviceID})
 				break loop
 			}
 			logger.Warnw(ctx, "LockStateFsm unknown TestMessage", log.Fields{"device-id": oFsm.deviceID, "MessageVal": msg.TestMessageVal})
-		case OMCI:
-			msg, _ := message.Data.(OmciMessage)
+		case cmn.OMCI:
+			msg, _ := message.Data.(cmn.OmciMessage)
 			oFsm.handleOmciLockStateMessage(ctx, msg)
 		default:
 			logger.Warn(ctx, "LockStateFsm Rx unknown message", log.Fields{"device-id": oFsm.deviceID,
@@ -333,7 +339,7 @@
 	logger.Debugw(ctx, "End LockStateFsm Msg processing", log.Fields{"device-id": oFsm.deviceID})
 }
 
-func (oFsm *lockStateFsm) handleOmciLockStateMessage(ctx context.Context, msg OmciMessage) {
+func (oFsm *LockStateFsm) handleOmciLockStateMessage(ctx context.Context, msg cmn.OmciMessage) {
 	logger.Debugw(ctx, "Rx OMCI LockStateFsm Msg", log.Fields{"device-id": oFsm.deviceID,
 		"msgType": msg.OmciMsg.MessageType})
 
@@ -371,7 +377,7 @@
 				case "OnuG":
 					{ // let the FSM proceed ...
 						oFsm.mutexPLastTxMeInstance.RUnlock()
-						_ = oFsm.pAdaptFsm.pFsm.Event(uniEvRxOnugResp)
+						_ = oFsm.PAdaptFsm.PFsm.Event(UniEvRxOnugResp)
 					}
 				case "PhysicalPathTerminationPointEthernetUni", "VirtualEthernetInterfacePoint":
 					{ // let the PPTP init proceed by stopping the wait function
@@ -401,7 +407,7 @@
 	}
 }
 
-func (oFsm *lockStateFsm) performUniPortAdminSet(ctx context.Context) {
+func (oFsm *LockStateFsm) performUniPortAdminSet(ctx context.Context) {
 	var omciAdminState uint8 = 1 //default locked
 	oFsm.mutexAdminState.RLock()
 	if !oFsm.adminState {
@@ -411,40 +417,40 @@
 	//set PPTPEthUni or VEIP AdminState
 	requestedAttributes := me.AttributeValueMap{"AdministrativeState": omciAdminState}
 
-	for uniNo, uniPort := range oFsm.pOmciCC.pBaseDeviceHandler.uniEntityMap {
+	for uniNo, uniPort := range *oFsm.pDeviceHandler.GetUniEntityMap() {
 		// only unlock the UniPort in case it is defined for usage (R2.6 limit only one port),
-		// compare also limitation for logical voltha port in dh.enableUniPortStateUpdate()
+		// compare also limitation for logical voltha port in dh.EnableUniPortStateUpdate()
 
-		if (omciAdminState == 1) || (1<<uniPort.uniID)&oFsm.pDeviceHandler.pOpenOnuAc.config.UniPortMask == (1<<uniPort.uniID) {
+		if (omciAdminState == 1) || (1<<uniPort.UniID)&oFsm.pDeviceHandler.GetUniPortMask() == (1<<uniPort.UniID) {
 			var meInstance *me.ManagedEntity
-			if uniPort.portType == uniPPTP {
+			if uniPort.PortType == cmn.UniPPTP {
 				logger.Debugw(ctx, "Setting PPTP admin state", log.Fields{
 					"device-id": oFsm.deviceID, "for PortNo": uniNo, "state (0-unlock)": omciAdminState})
 				oFsm.mutexPLastTxMeInstance.Lock()
-				meInstance, err := oFsm.pOmciCC.sendSetPptpEthUniLS(log.WithSpanFromContext(context.TODO(), ctx),
-					uniPort.entityID, oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout,
-					true, requestedAttributes, oFsm.pAdaptFsm.commChan)
+				meInstance, err := oFsm.pOmciCC.SendSetPptpEthUniLS(log.WithSpanFromContext(context.TODO(), ctx),
+					uniPort.EntityID, oFsm.pDeviceHandler.GetOmciTimeout(),
+					true, requestedAttributes, oFsm.PAdaptFsm.CommChan)
 				if err != nil {
 					oFsm.mutexPLastTxMeInstance.Unlock()
 					logger.Errorw(ctx, "SetPptpEthUniLS set failed, aborting LockStateFsm!",
 						log.Fields{"device-id": oFsm.deviceID})
-					_ = oFsm.pAdaptFsm.pFsm.Event(uniEvReset)
+					_ = oFsm.PAdaptFsm.PFsm.Event(UniEvReset)
 					return
 				}
 				oFsm.pLastTxMeInstance = meInstance
 				oFsm.mutexPLastTxMeInstance.Unlock()
-			} else if uniPort.portType == uniVEIP {
+			} else if uniPort.PortType == cmn.UniVEIP {
 				logger.Debugw(ctx, "Setting VEIP admin state", log.Fields{
 					"device-id": oFsm.deviceID, "for PortNo": uniNo, "state (0-unlock)": omciAdminState})
 				oFsm.mutexPLastTxMeInstance.Lock()
-				meInstance, err := oFsm.pOmciCC.sendSetVeipLS(log.WithSpanFromContext(context.TODO(), ctx),
-					uniPort.entityID, oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout,
-					true, requestedAttributes, oFsm.pAdaptFsm.commChan)
+				meInstance, err := oFsm.pOmciCC.SendSetVeipLS(log.WithSpanFromContext(context.TODO(), ctx),
+					uniPort.EntityID, oFsm.pDeviceHandler.GetOmciTimeout(),
+					true, requestedAttributes, oFsm.PAdaptFsm.CommChan)
 				if err != nil {
 					oFsm.mutexPLastTxMeInstance.Unlock()
 					logger.Errorw(ctx, "SetVeipLS set failed, aborting LockStateFsm!",
 						log.Fields{"device-id": oFsm.deviceID})
-					_ = oFsm.pAdaptFsm.pFsm.Event(uniEvReset)
+					_ = oFsm.PAdaptFsm.PFsm.Event(UniEvReset)
 					return
 				}
 				oFsm.pLastTxMeInstance = meInstance
@@ -460,7 +466,7 @@
 				logger.Errorw(ctx, "could not send PortAdmin OMCI message from LockStateFsm", log.Fields{
 					"device-id": oFsm.deviceID, "Port": uniNo})
 				//some more sophisticated approach is possible, e.g. repeating once, by now let's reset the state machine in order to release all resources now
-				_ = oFsm.pAdaptFsm.pFsm.Event(uniEvReset)
+				_ = oFsm.PAdaptFsm.PFsm.Event(UniEvReset)
 				return
 			}
 			oFsm.mutexPLastTxMeInstance.RUnlock()
@@ -470,7 +476,7 @@
 			if err != nil {
 				logger.Errorw(ctx, "UniTP Admin State set failed, aborting LockState set!",
 					log.Fields{"device-id": oFsm.deviceID, "Port": uniNo})
-				_ = oFsm.pAdaptFsm.pFsm.Event(uniEvReset)
+				_ = oFsm.PAdaptFsm.PFsm.Event(UniEvReset)
 				return
 			}
 		}
@@ -478,16 +484,16 @@
 	// if Config has been done for all UNI related instances let the FSM proceed
 	// while we did not check here, if there is some port at all - !?
 	logger.Infow(ctx, "UniTP adminState loop finished", log.Fields{"device-id": oFsm.deviceID})
-	_ = oFsm.pAdaptFsm.pFsm.Event(uniEvRxUnisResp)
+	_ = oFsm.PAdaptFsm.PFsm.Event(UniEvRxUnisResp)
 }
 
-func (oFsm *lockStateFsm) waitforOmciResponse(ctx context.Context, apMeInstance *me.ManagedEntity) error {
+func (oFsm *LockStateFsm) waitforOmciResponse(ctx context.Context, apMeInstance *me.ManagedEntity) error {
 	select {
 	// maybe be also some outside cancel (but no context modeled for the moment ...)
 	// case <-ctx.Done():
 	// 		logger.Infow(ctx,"LockState-bridge-init message reception canceled", log.Fields{"for device-id": oFsm.deviceID})
 	case <-time.After(oFsm.pOmciCC.GetMaxOmciTimeoutWithRetries() * time.Second): //3s was detected to be to less in 8*8 bbsim test with debug Info/Debug
-		logger.Warnw(ctx, "LockStateFSM uni-set timeout", log.Fields{"for device-id": oFsm.deviceID})
+		logger.Warnw(ctx, "lockStateFSM uni-set timeout", log.Fields{"for device-id": oFsm.deviceID})
 		return fmt.Errorf("lockStateFsm uni-set timeout for device-id %s", oFsm.deviceID)
 	case success := <-oFsm.omciLockResponseReceived:
 		if success {
@@ -495,7 +501,7 @@
 			return nil
 		}
 		// should not happen so far
-		logger.Warnw(ctx, "LockStateFSM uni-set response error", log.Fields{"for device-id": oFsm.deviceID})
+		logger.Warnw(ctx, "lockStateFSM uni-set response error", log.Fields{"for device-id": oFsm.deviceID})
 		return fmt.Errorf("lockStateFsm uni-set responseError for device-id %s", oFsm.deviceID)
 	}
 }
diff --git a/internal/pkg/onuadaptercore/uniportstatus.go b/internal/pkg/uniprt/uniportstatus.go
old mode 100644
new mode 100755
similarity index 71%
rename from internal/pkg/onuadaptercore/uniportstatus.go
rename to internal/pkg/uniprt/uniportstatus.go
index f7cfe4b..8f8dedd
--- a/internal/pkg/onuadaptercore/uniportstatus.go
+++ b/internal/pkg/uniprt/uniportstatus.go
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package uniprt provides the utilities for uni port configuration
+package uniprt
 
 import (
 	"context"
@@ -24,6 +24,7 @@
 	"github.com/opencord/omci-lib-go"
 	me "github.com/opencord/omci-lib-go/generated"
 	"github.com/opencord/voltha-lib-go/v7/pkg/log"
+	cmn "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/common"
 	"github.com/opencord/voltha-protos/v5/go/extension"
 )
 
@@ -36,89 +37,92 @@
 
 //UniPortStatus implements methods to get uni port status info
 type UniPortStatus struct {
-	omciRespChn       chan Message
-	pOmiCC            *omciCC
+	pDeviceHandler    cmn.IdeviceHandler
+	pOmiCC            *cmn.OmciCC
+	omciRespChn       chan cmn.Message
 	pLastTxMeInstance *me.ManagedEntity
 }
 
 //NewUniPortStatus creates a new instance of UniPortStatus
-func NewUniPortStatus(pOmicc *omciCC) *UniPortStatus {
+func NewUniPortStatus(apDeviceHandler cmn.IdeviceHandler, apOmicc *cmn.OmciCC) *UniPortStatus {
 	return &UniPortStatus{
-		omciRespChn: make(chan Message),
-		pOmiCC:      pOmicc,
+		pDeviceHandler: apDeviceHandler,
+		pOmiCC:         apOmicc,
+		omciRespChn:    make(chan cmn.Message),
 	}
 
 }
 
-func (portStatus *UniPortStatus) getUniPortStatus(ctx context.Context, uniIdx uint32) *extension.SingleGetValueResponse {
-	for _, uniPort := range portStatus.pOmiCC.pBaseDeviceHandler.uniEntityMap {
+// GetUniPortStatus - TODO: add comment
+func (portStatus *UniPortStatus) GetUniPortStatus(ctx context.Context, uniIdx uint32) *extension.SingleGetValueResponse {
+	for _, uniPort := range *portStatus.pDeviceHandler.GetUniEntityMap() {
 
-		if uniPort.uniID == uint8(uniIdx) && uniPort.portType == uniPPTP {
+		if uniPort.UniID == uint8(uniIdx) && uniPort.PortType == cmn.UniPPTP {
 
 			requestedAttributes := me.AttributeValueMap{adminState: 0, operationalState: 0, configInd: 0}
 			// Note: No reference to fetch the OMCI timeout configuration value, so hard code it to 10s
-			meInstance, err := portStatus.pOmiCC.sendGetMe(ctx, me.PhysicalPathTerminationPointEthernetUniClassID, uniPort.entityID, requestedAttributes, 10, true, portStatus.omciRespChn)
+			meInstance, err := portStatus.pOmiCC.SendGetMe(ctx, me.PhysicalPathTerminationPointEthernetUniClassID, uniPort.EntityID, requestedAttributes, 10, true, portStatus.omciRespChn)
 			if err != nil {
-				return postUniStatusErrResponse(extension.GetValueResponse_INTERNAL_ERROR)
+				return PostUniStatusErrResponse(extension.GetValueResponse_INTERNAL_ERROR)
 			}
 			if meInstance != nil {
 				portStatus.pLastTxMeInstance = meInstance
 
 				//verify response
-				return portStatus.waitforgetUniPortStatus(ctx, meInstance)
+				return portStatus.waitforGetUniPortStatus(ctx, meInstance)
 			}
 		}
 	}
-	logger.Errorw(ctx, "getUniPortStatus uniIdx is not valid", log.Fields{"uniIdx": uniIdx})
-	return postUniStatusErrResponse(extension.GetValueResponse_INVALID_PORT_TYPE)
+	logger.Errorw(ctx, "GetUniPortStatus uniIdx is not valid", log.Fields{"uniIdx": uniIdx})
+	return PostUniStatusErrResponse(extension.GetValueResponse_INVALID_PORT_TYPE)
 }
 
-func (portStatus *UniPortStatus) waitforgetUniPortStatus(ctx context.Context, apMeInstance *me.ManagedEntity) *extension.SingleGetValueResponse {
+func (portStatus *UniPortStatus) waitforGetUniPortStatus(ctx context.Context, apMeInstance *me.ManagedEntity) *extension.SingleGetValueResponse {
 
 	select {
 	// maybe be also some outside cancel (but no context modeled for the moment ...)
 	case <-ctx.Done():
-		logger.Errorf(ctx, "waitforgetUniPortStatus Context done")
-		return postUniStatusErrResponse(extension.GetValueResponse_INTERNAL_ERROR)
+		logger.Errorf(ctx, "waitforGetUniPortStatus Context done")
+		return PostUniStatusErrResponse(extension.GetValueResponse_INTERNAL_ERROR)
 	case <-time.After(uniStatusTimeout * time.Second):
-		logger.Errorf(ctx, "waitforgetUniPortStatus  timeout")
-		return postUniStatusErrResponse(extension.GetValueResponse_TIMEOUT)
+		logger.Errorf(ctx, "waitforGetUniPortStatus  timeout")
+		return PostUniStatusErrResponse(extension.GetValueResponse_TIMEOUT)
 
 	case omciMsg := <-portStatus.omciRespChn:
-		if omciMsg.Type != OMCI {
-			return postUniStatusErrResponse(extension.GetValueResponse_INTERNAL_ERROR)
+		if omciMsg.Type != cmn.OMCI {
+			return PostUniStatusErrResponse(extension.GetValueResponse_INTERNAL_ERROR)
 		}
-		msg, _ := omciMsg.Data.(OmciMessage)
+		msg, _ := omciMsg.Data.(cmn.OmciMessage)
 		return portStatus.processGetUnitStatusResp(ctx, msg)
 	}
 
 }
 
-func (portStatus *UniPortStatus) processGetUnitStatusResp(ctx context.Context, msg OmciMessage) *extension.SingleGetValueResponse {
+func (portStatus *UniPortStatus) processGetUnitStatusResp(ctx context.Context, msg cmn.OmciMessage) *extension.SingleGetValueResponse {
 	logger.Debugw(ctx, "processGetUniStatusResp:", log.Fields{"msg.Omci.MessageType": msg.OmciMsg.MessageType,
 		"msg.OmciMsg.TransactionID": msg.OmciMsg.TransactionID, "DeviceIdentfier": msg.OmciMsg.DeviceIdentifier})
 
 	if msg.OmciMsg.MessageType != omci.GetResponseType {
 		logger.Debugw(ctx, "processGetUniStatusResp error", log.Fields{"incorrect RespType": msg.OmciMsg.MessageType,
 			"expected": omci.GetResponseType})
-		return postUniStatusErrResponse(extension.GetValueResponse_INTERNAL_ERROR)
+		return PostUniStatusErrResponse(extension.GetValueResponse_INTERNAL_ERROR)
 	}
 
 	msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeGetResponse)
 	if msgLayer == nil {
 		logger.Errorf(ctx, "processGetUniStatusResp omci Msg layer not found - ")
-		return postUniStatusErrResponse(extension.GetValueResponse_INTERNAL_ERROR)
+		return PostUniStatusErrResponse(extension.GetValueResponse_INTERNAL_ERROR)
 
 	}
 	msgObj, msgOk := msgLayer.(*omci.GetResponse)
 	if !msgOk {
 		logger.Errorf(ctx, "processGetUniStatusResp omci msgObj layer could not be found ")
-		return postUniStatusErrResponse(extension.GetValueResponse_INTERNAL_ERROR)
+		return PostUniStatusErrResponse(extension.GetValueResponse_INTERNAL_ERROR)
 
 	}
 
 	if msgObj.Result != me.Success {
-		return postUniStatusErrResponse(extension.GetValueResponse_INTERNAL_ERROR)
+		return PostUniStatusErrResponse(extension.GetValueResponse_INTERNAL_ERROR)
 	}
 	meAttributes := msgObj.Attributes
 
@@ -160,7 +164,8 @@
 	return &singleValResp
 }
 
-func postUniStatusErrResponse(reason extension.GetValueResponse_ErrorReason) *extension.SingleGetValueResponse {
+// PostUniStatusErrResponse - TODO: add comment
+func PostUniStatusErrResponse(reason extension.GetValueResponse_ErrorReason) *extension.SingleGetValueResponse {
 	return &extension.SingleGetValueResponse{
 		Response: &extension.GetValueResponse{
 			Status:    extension.GetValueResponse_ERROR,
