diff --git a/app/src/main/java/org/opencord/aaa/impl/AaaManager.java b/app/src/main/java/org/opencord/aaa/impl/AaaManager.java
index 015f608..1c42ef5 100644
--- a/app/src/main/java/org/opencord/aaa/impl/AaaManager.java
+++ b/app/src/main/java/org/opencord/aaa/impl/AaaManager.java
@@ -959,49 +959,53 @@
         @Override
         public void event(DeviceEvent event) {
 
-             switch (event.type()) {
-                 case PORT_REMOVED:
-                     DeviceId devId = event.subject().id();
-                     PortNumber portNumber = event.port().number();
-                     String sessionId = devId.toString() + portNumber.toString();
+            switch (event.type()) {
+                case PORT_REMOVED:
+                    DeviceId devId = event.subject().id();
+                    PortNumber portNumber = event.port().number();
+                    String sessionId = devId.toString() + portNumber.toString();
 
-                     log.info("Received PORT_REMOVED event. Clearing AAA Session with Id {}", sessionId);
-                     flushStateMachineSession(sessionId,
-                             StateMachine.SessionTerminationReasons.PORT_REMOVED.getReason());
+                    log.debug("Received PORT_REMOVED event. Clearing AAA Session with Id {}", sessionId);
+                    flushStateMachineSession(sessionId,
+                            StateMachine.SessionTerminationReasons.PORT_REMOVED.getReason());
 
-                     break;
+                    break;
 
-                 case DEVICE_REMOVED:
-                     DeviceId deviceId = event.subject().id();
-                     log.info("Received DEVICE_REMOVED event for {}", deviceId);
+                case DEVICE_REMOVED:
+                    DeviceId deviceId = event.subject().id();
+                    log.debug("Received DEVICE_REMOVED event for {}", deviceId);
 
-                     Set<String> associatedSessions = Sets.newHashSet();
-                     for (Entry<String, StateMachine> stateMachineEntry : StateMachine.sessionIdMap().entrySet()) {
-                         ConnectPoint cp = stateMachineEntry.getValue().supplicantConnectpoint();
-                         if (cp != null && cp.deviceId().toString().equals(deviceId.toString())) {
-                             associatedSessions.add(stateMachineEntry.getKey());
-                         }
-                     }
+                    Set<String> associatedSessions = Sets.newHashSet();
+                    for (Entry<String, StateMachine> stateMachineEntry : StateMachine.sessionIdMap().entrySet()) {
+                        ConnectPoint cp = stateMachineEntry.getValue().supplicantConnectpoint();
+                        if (cp != null && cp.deviceId().toString().equals(deviceId.toString())) {
+                            associatedSessions.add(stateMachineEntry.getKey());
+                        }
+                    }
 
-                     for (String session : associatedSessions) {
-                         log.info("Clearing AAA Session {} associated with Removed Device", session);
-                         flushStateMachineSession(session,
-                                 StateMachine.SessionTerminationReasons.DEVICE_REMOVED.getReason());
-                     }
+                    for (String session : associatedSessions) {
+                        log.debug("Clearing AAA Session {} associated with Removed Device", session);
+                        flushStateMachineSession(session,
+                               StateMachine.SessionTerminationReasons.DEVICE_REMOVED.getReason());
+                    }
 
-                     break;
+                    break;
 
-                 default:
-                     return;
-             }
+                default:
+                    return;
+            }
         }
 
         private void flushStateMachineSession(String sessionId, String terminationReason) {
             StateMachine stateMachine = StateMachine.lookupStateMachineBySessionId(sessionId);
-            if (stateMachine != null) {
-                stateMachine.setSessionTerminateReason(terminationReason);
+            if (stateMachine == null) {
+                // No active AAA sessions for this UNI port
+                log.debug("No Active AAA Session found with Id {}", sessionId);
+                return;
             }
 
+            stateMachine.setSessionTerminateReason(terminationReason);
+
             //pushing captured machine stats to kafka
             AaaSupplicantMachineStats obj = aaaSupplicantStatsManager.getSupplicantStats(stateMachine);
             aaaSupplicantStatsManager.getMachineStatsDelegate()
