diff --git a/src/main/java/net/floodlightcontroller/core/Main.java b/src/main/java/net/floodlightcontroller/core/Main.java
index 0bda3c0c55abf9497a8dcb334e0b65141bccd1c2..c437a93472142a59f86800b8aec1ee42d4f74b25 100644
--- a/src/main/java/net/floodlightcontroller/core/Main.java
+++ b/src/main/java/net/floodlightcontroller/core/Main.java
@@ -59,8 +59,6 @@ public class Main {
 			FloodlightModuleLoader fml = new FloodlightModuleLoader();
 			try {
 				IFloodlightModuleContext moduleContext = fml.loadModulesFromConfig(settings.getModuleFile());
-				// @Ryan TODO This should probably be implemented and run as a normal service for consistency;
-				// although, it does need all modules to be loaded and their prior to running.
 				IRestApiService restApi = moduleContext.getServiceImpl(IRestApiService.class);
 				restApi.run(); 
 			} catch (FloodlightModuleConfigFileNotFoundException e) {
diff --git a/src/main/java/net/floodlightcontroller/core/web/AllSwitchStatisticsResource.java b/src/main/java/net/floodlightcontroller/core/web/AllSwitchStatisticsResource.java
index 72e7698b39d23924b84e376d9e69283d4e346050..18bfcc3c045de2e61f1ad8f5f15776b4495397d2 100644
--- a/src/main/java/net/floodlightcontroller/core/web/AllSwitchStatisticsResource.java
+++ b/src/main/java/net/floodlightcontroller/core/web/AllSwitchStatisticsResource.java
@@ -41,14 +41,15 @@ import org.slf4j.LoggerFactory;
 public class AllSwitchStatisticsResource extends SwitchResourceBase {
     protected static Logger log =
         LoggerFactory.getLogger(AllSwitchStatisticsResource.class);
-
+    
     @Get("json")
     public Map<String, Object> retrieve() {
         String statType = (String) getRequestAttributes().get(CoreWebRoutable.STR_STAT_TYPE);
+        
         return retrieveInternal(statType);
     }
 
-    public Map<String, Object> retrieveInternal(String statType) {
+    private Map<String, Object> retrieveInternal(String statType) {
         HashMap<String, Object> model = new HashMap<String, Object>();
 
         OFStatsType type = null;
@@ -85,10 +86,10 @@ public class AllSwitchStatisticsResource extends SwitchResourceBase {
         default:
         	return model;
         }
-
-        IOFSwitchService switchService =
-                (IOFSwitchService) getContext().getAttributes().
-                    get(IOFSwitchService.class.getCanonicalName());
+                
+        IOFSwitchService switchService = (IOFSwitchService) getContext().getAttributes().
+                get(IOFSwitchService.class.getCanonicalName());
+        
         Set<DatapathId> switchDpids = switchService.getAllSwitchDpids();
         List<GetConcurrentStatsThread> activeThreads = new ArrayList<GetConcurrentStatsThread>(switchDpids.size());
         List<GetConcurrentStatsThread> pendingRemovalThreads = new ArrayList<GetConcurrentStatsThread>();
diff --git a/src/main/java/net/floodlightcontroller/core/web/SwitchResourceBase.java b/src/main/java/net/floodlightcontroller/core/web/SwitchResourceBase.java
index 99b4d2d830849d948e7788188eaf5215d31e3ccf..75e99083591fe2bc25597ddf119c5a1d8dac320b 100644
--- a/src/main/java/net/floodlightcontroller/core/web/SwitchResourceBase.java
+++ b/src/main/java/net/floodlightcontroller/core/web/SwitchResourceBase.java
@@ -61,6 +61,13 @@ public class SwitchResourceBase extends ServerResource {
 
 	}
 
+	/**
+	 * Use for requests that originate from the REST server that use their context to get a
+	 * reference to the switch service.
+	 * @param switchId
+	 * @param statType
+	 * @return
+	 */
 	@SuppressWarnings("unchecked")
 	@LogMessageDoc(level="ERROR",
 	message="Failure retrieving statistics from switch {switch}",
@@ -70,9 +77,7 @@ public class SwitchResourceBase extends ServerResource {
 					LogMessageDoc.GENERIC_ACTION)
 	protected List<OFStatsReply> getSwitchStatistics(DatapathId switchId,
 			OFStatsType statType) {
-		IOFSwitchService switchService =
-				(IOFSwitchService) getContext().getAttributes().
-				get(IOFSwitchService.class.getCanonicalName());
+		IOFSwitchService switchService = (IOFSwitchService) getContext().getAttributes().get(IOFSwitchService.class.getCanonicalName());
 
 		IOFSwitch sw = switchService.getSwitch(switchId);
 		ListenableFuture<?> future;
diff --git a/src/main/java/net/floodlightcontroller/devicemanager/SwitchPort.java b/src/main/java/net/floodlightcontroller/devicemanager/SwitchPort.java
index 8648e890114da81756013e8094be37444f9a9caf..abede26af415d1854dd080bc9131300ba45c142e 100644
--- a/src/main/java/net/floodlightcontroller/devicemanager/SwitchPort.java
+++ b/src/main/java/net/floodlightcontroller/devicemanager/SwitchPort.java
@@ -128,8 +128,8 @@ public class SwitchPort {
         if (getClass() != obj.getClass()) return false;
         SwitchPort other = (SwitchPort) obj;
         if (errorStatus != other.errorStatus) return false;
-        if (port != other.port) return false;
-        if (switchDPID != other.switchDPID) return false;
+        if (!port.equals(other.port)) return false;
+        if (!switchDPID.equals(other.switchDPID)) return false;
         return true;
     }
 
diff --git a/src/main/java/net/floodlightcontroller/devicemanager/internal/AttachmentPoint.java b/src/main/java/net/floodlightcontroller/devicemanager/internal/AttachmentPoint.java
index da7490f1ef9a9e80983aa48fad27f39242580779..122bb1d4a7513529e02d8622ae0a96fff6ef2e22 100644
--- a/src/main/java/net/floodlightcontroller/devicemanager/internal/AttachmentPoint.java
+++ b/src/main/java/net/floodlightcontroller/devicemanager/internal/AttachmentPoint.java
@@ -112,9 +112,9 @@ public class AttachmentPoint {
         if (getClass() != obj.getClass())
             return false;
         AttachmentPoint other = (AttachmentPoint) obj;
-        if (port.getPortNumber() != other.port.getPortNumber())
+        if (!port.equals(other.port))
             return false;
-        if (sw.getLong() != other.sw.getLong())
+        if (!sw.equals(other.sw))
             return false;
         return true;
     }
diff --git a/src/main/java/net/floodlightcontroller/devicemanager/internal/DeviceIterator.java b/src/main/java/net/floodlightcontroller/devicemanager/internal/DeviceIterator.java
index 7d4d0c35a9c141eb08a82ea52e7283993bdbafaa..796a6170d60e11a5c860e1397786e03267a4d5a7 100644
--- a/src/main/java/net/floodlightcontroller/devicemanager/internal/DeviceIterator.java
+++ b/src/main/java/net/floodlightcontroller/devicemanager/internal/DeviceIterator.java
@@ -120,11 +120,11 @@ public class DeviceIterator extends FilterIterator<Device> {
             match = false;
             for (SwitchPort sp : sps) {
                 if (switchDPID != null) {
-                    if (switchDPID.getLong() != sp.getSwitchDPID().getLong())
+                    if (!switchDPID.equals(sp.getSwitchDPID()))
                         return false;
                 }
                 if (switchPort != null) {
-                    if (switchPort.getPortNumber() != sp.getPort().getPortNumber())
+                    if (!switchPort.equals(sp.getPort()))
                         return false;
                 }
                 match = true;
diff --git a/src/main/java/net/floodlightcontroller/learningswitch/LearningSwitch.java b/src/main/java/net/floodlightcontroller/learningswitch/LearningSwitch.java
index 7e347294c30dd4822e83e3c3980ea35ac49489f0..288369cb51cbfcd640673f9d4cb5c2bd63fd89ac 100644
--- a/src/main/java/net/floodlightcontroller/learningswitch/LearningSwitch.java
+++ b/src/main/java/net/floodlightcontroller/learningswitch/LearningSwitch.java
@@ -390,10 +390,10 @@ public class LearningSwitch
      */
     private Command processPacketInMessage(IOFSwitch sw, OFPacketIn pi, FloodlightContext cntx) {
         // Read in packet data headers by using OFMatch
-        Match.Builder mb = pi.getMatch().createBuilder();
-        MacAddress sourceMac = mb.get(MatchField.ETH_SRC);
-        MacAddress destMac = mb.get(MatchField.ETH_DST);
-        OFVlanVidMatch vlan = mb.get(MatchField.VLAN_VID);
+        Match m = pi.getMatch();
+        MacAddress sourceMac = m.get(MatchField.ETH_SRC);
+        MacAddress destMac = m.get(MatchField.ETH_DST);
+        OFVlanVidMatch vlan = m.get(MatchField.VLAN_VID);
         if ((destMac.getLong() & 0xfffffffffff0L) == 0x0180c2000000L) {
             if (log.isTraceEnabled()) {
                 log.trace("ignoring packet addressed to 802.1D/Q reserved addr: switch {} vlan {} dest MAC {}",
@@ -415,7 +415,7 @@ public class LearningSwitch
             //     from port map whenever a flow expires, so you would still see
             //     a lot of floods.
             this.writePacketOutForPacketIn(sw, pi, OFPort.FLOOD);
-        } else if (outPort.equals(mb.get(MatchField.IN_PORT))) {
+        } else if (outPort.equals(m.get(MatchField.IN_PORT))) {
             log.trace("ignoring packet that arrived on same port as learned destination:"
                     + " switch {} vlan {} dest MAC {} port {}",
                     new Object[]{ sw, vlan, destMac.toString(), outPort.getPortNumber() });
@@ -430,29 +430,29 @@ public class LearningSwitch
             // FIXME: current HP switches ignore DL_SRC and DL_DST fields, so we have to match on
             // NW_SRC and NW_DST as well
             // We write FlowMods with Buffer ID none then explicitly PacketOut the buffered packet
-            this.pushPacket(sw, mb.build(), pi, outPort);
-            this.writeFlowMod(sw, OFFlowModCommand.ADD, OFBufferId.NO_BUFFER, mb.build(), outPort);
+            this.pushPacket(sw, m, pi, outPort);
+            this.writeFlowMod(sw, OFFlowModCommand.ADD, OFBufferId.NO_BUFFER, m, outPort);
             if (LEARNING_SWITCH_REVERSE_FLOW) {
-            	Match.Builder mb2 = mb.build().createBuilder();
-            	mb2.setExact(MatchField.ETH_SRC, mb.get(MatchField.ETH_DST))                         
-            	.setExact(MatchField.ETH_DST, mb.get(MatchField.ETH_SRC))                         
-            	.setExact(MatchField.IPV4_SRC, mb.get(MatchField.IPV4_DST))                         
-            	.setExact(MatchField.IPV4_DST, mb.get(MatchField.IPV4_SRC));
-            	if (mb.get(MatchField.IP_PROTO).equals(IpProtocol.TCP)) {
-            		mb2.setExact(MatchField.TCP_SRC, mb.get(MatchField.TCP_DST))
-            		.setExact(MatchField.TCP_DST, mb.get(MatchField.TCP_SRC));
-            	} else if (mb.get(MatchField.IP_PROTO).equals(IpProtocol.UDP)) {
-            		mb2.setExact(MatchField.UDP_SRC, mb.get(MatchField.UDP_DST))
-            		.setExact(MatchField.UDP_DST, mb.get(MatchField.UDP_SRC));
-            	} else if (mb.get(MatchField.IP_PROTO).equals(IpProtocol.SCTP)) {
-            		mb2.setExact(MatchField.SCTP_SRC, mb.get(MatchField.SCTP_DST))
-            		.setExact(MatchField.SCTP_DST, mb.get(MatchField.SCTP_SRC));
+            	Match.Builder mb2 = m.createBuilder();
+            	mb2.setExact(MatchField.ETH_SRC, m.get(MatchField.ETH_DST))                         
+            	.setExact(MatchField.ETH_DST, m.get(MatchField.ETH_SRC))                         
+            	.setExact(MatchField.IPV4_SRC, m.get(MatchField.IPV4_DST))                         
+            	.setExact(MatchField.IPV4_DST, m.get(MatchField.IPV4_SRC));
+            	if (m.get(MatchField.IP_PROTO).equals(IpProtocol.TCP)) {
+            		mb2.setExact(MatchField.TCP_SRC, m.get(MatchField.TCP_DST))
+            		.setExact(MatchField.TCP_DST, m.get(MatchField.TCP_SRC));
+            	} else if (m.get(MatchField.IP_PROTO).equals(IpProtocol.UDP)) {
+            		mb2.setExact(MatchField.UDP_SRC, m.get(MatchField.UDP_DST))
+            		.setExact(MatchField.UDP_DST, m.get(MatchField.UDP_SRC));
+            	} else if (m.get(MatchField.IP_PROTO).equals(IpProtocol.SCTP)) {
+            		mb2.setExact(MatchField.SCTP_SRC, m.get(MatchField.SCTP_DST))
+            		.setExact(MatchField.SCTP_DST, m.get(MatchField.SCTP_SRC));
             	} else {
-            		log.debug("In writing reverse LS flow, could not determine L4 proto (was int " + mb.get(MatchField.IP_PROTO).getIpProtocolNumber() + ")");
+            		log.debug("In writing reverse LS flow, could not determine L4 proto (was int " + m.get(MatchField.IP_PROTO).getIpProtocolNumber() + ")");
             	}
             	mb2.setExact(MatchField.IN_PORT, outPort);
 
-            	this.writeFlowMod(sw, OFFlowModCommand.ADD, OFBufferId.NO_BUFFER, mb2.build(), mb.get(MatchField.IN_PORT));
+            	this.writeFlowMod(sw, OFFlowModCommand.ADD, OFBufferId.NO_BUFFER, mb2.build(), m.get(MatchField.IN_PORT));
             }
         }
         return Command.CONTINUE;
diff --git a/src/main/java/net/floodlightcontroller/loadbalancer/LoadBalancer.java b/src/main/java/net/floodlightcontroller/loadbalancer/LoadBalancer.java
index 1309a555b6cc4c043ceef82679e1dd54abda9586..79e31c67abbe3f2a72803dcc66824ccee506a1db 100644
--- a/src/main/java/net/floodlightcontroller/loadbalancer/LoadBalancer.java
+++ b/src/main/java/net/floodlightcontroller/loadbalancer/LoadBalancer.java
@@ -29,6 +29,7 @@ import java.util.Map;
 
 import org.projectfloodlight.openflow.protocol.OFFlowMod;
 import org.projectfloodlight.openflow.protocol.match.Match;
+import org.projectfloodlight.openflow.protocol.match.MatchField;
 import org.projectfloodlight.openflow.protocol.OFMessage;
 import org.projectfloodlight.openflow.protocol.OFPacketIn;
 import org.projectfloodlight.openflow.protocol.OFPacketOut;
@@ -289,7 +290,7 @@ public class LoadBalancer implements IFloodlightModule,
                         arpRequest.getSenderProtocolAddress()));
                 
         // push ARP reply out
-        pushPacket(arpReply, sw, OFBufferId.NO_BUFFER, OFPort.ZERO, pi.getInPort(), cntx, true);
+        pushPacket(arpReply, sw, OFBufferId.NO_BUFFER, OFPort.ZERO, pi.getMatch().get(MatchField.IN_PORT), cntx, true);
         log.debug("proxy ARP reply pushed as {}", IPv4.fromIPv4Address(vips.get(vipId).address));
         
         return;
diff --git a/src/main/java/net/floodlightcontroller/routing/ForwardingBase.java b/src/main/java/net/floodlightcontroller/routing/ForwardingBase.java
index 878db1c99116ab3e4249d6c4a75a473a165a2077..11e6909b998ba1713a80b4866595eb0d2529187b 100644
--- a/src/main/java/net/floodlightcontroller/routing/ForwardingBase.java
+++ b/src/main/java/net/floodlightcontroller/routing/ForwardingBase.java
@@ -43,6 +43,7 @@ import net.floodlightcontroller.routing.IRoutingDecision;
 import net.floodlightcontroller.routing.Route;
 import net.floodlightcontroller.topology.ITopologyService;
 import net.floodlightcontroller.topology.NodePortTuple;
+import net.floodlightcontroller.util.MatchUtils;
 import net.floodlightcontroller.util.OFMessageDamper;
 import net.floodlightcontroller.util.TimedCache;
 
@@ -248,18 +249,18 @@ public abstract class ForwardingBase implements IOFMessageListener {
 			
 			OFActionOutput.Builder aob = sw.getOFFactory().actions().buildOutput();
 			List<OFAction> actions = new ArrayList<OFAction>();	
-			//Match.Builder mb = match.createBuilder();
+			Match.Builder mb = MatchUtils.createRetentiveBuilder(match);
 
 			// set input and output ports on the switch
 			OFPort outPort = switchPortList.get(indx).getPortId();
-			//OFPort inPort = switchPortList.get(indx - 1).getPortId();
-			//mb.setExact(MatchField.IN_PORT, inPort);
+			OFPort inPort = switchPortList.get(indx - 1).getPortId();
+			mb.setExact(MatchField.IN_PORT, inPort);
 			aob.setPort(outPort);
 			aob.setMaxLen(Integer.MAX_VALUE);
 			actions.add(aob.build());
 			
 			// compile
-			fmb.setMatch(match) //mb.build()
+			fmb.setMatch(mb.build()) // was match w/o modifying input port
 			.setActions(actions)
 			.setIdleTimeout(FLOWMOD_DEFAULT_IDLE_TIMEOUT)
 			.setHardTimeout(FLOWMOD_DEFAULT_HARD_TIMEOUT)
diff --git a/src/main/java/net/floodlightcontroller/routing/Link.java b/src/main/java/net/floodlightcontroller/routing/Link.java
index a2f125f5a5b2cd73c9ce6bfaa65e4b56e87d6ff6..3282bb67642187dd543695edeaf29bb925e804da 100755
--- a/src/main/java/net/floodlightcontroller/routing/Link.java
+++ b/src/main/java/net/floodlightcontroller/routing/Link.java
@@ -100,13 +100,13 @@ public class Link implements Comparable<Link> {
         if (getClass() != obj.getClass())
             return false;
         Link other = (Link) obj;
-        if (dst != other.dst)
+        if (!dst.equals(other.dst))
             return false;
-        if (dstPort != other.dstPort)
+        if (!dstPort.equals(other.dstPort))
             return false;
-        if (src != other.src)
+        if (!src.equals(other.src))
             return false;
-        if (srcPort != other.srcPort)
+        if (!srcPort.equals(other.srcPort))
             return false;
         return true;
     }
diff --git a/src/main/java/net/floodlightcontroller/topology/Cluster.java b/src/main/java/net/floodlightcontroller/topology/Cluster.java
index f896410fdc9a30c9bb8a8d9cd5ede71d06b9c86f..a9be8a36c1bdd73d900073717e7a73e0a635bf23 100644
--- a/src/main/java/net/floodlightcontroller/topology/Cluster.java
+++ b/src/main/java/net/floodlightcontroller/topology/Cluster.java
@@ -81,7 +81,7 @@ public class Cluster {
             return false;
 
         Cluster other = (Cluster) obj;
-        return (this.id == other.id);
+        return (this.id.equals(other.id));
     }
     
     public String toString() {
diff --git a/src/main/java/net/floodlightcontroller/topology/NodePortTuple.java b/src/main/java/net/floodlightcontroller/topology/NodePortTuple.java
index 758e50a9242cdd17df6cdc24075e532908fa5068..6fbf87f4a79b877bf36454deb108bc48d1dd6f4e 100644
--- a/src/main/java/net/floodlightcontroller/topology/NodePortTuple.java
+++ b/src/main/java/net/floodlightcontroller/topology/NodePortTuple.java
@@ -83,9 +83,9 @@ public class NodePortTuple implements Comparable<NodePortTuple> {
         if (getClass() != obj.getClass())
             return false;
         NodePortTuple other = (NodePortTuple) obj;
-        if (nodeId != other.nodeId)
+        if (!nodeId.equals(other.nodeId))
             return false;
-        if (portId != other.portId)
+        if (!portId.equals(other.portId))
             return false;
         return true;
     }
diff --git a/src/main/resources/floodlightdefault.properties b/src/main/resources/floodlightdefault.properties
index b9da2671aeb41291f9683458ced2acc60b3342e4..8ba99cf659ec268f1a1f4d001c110da83959b6a7 100644
--- a/src/main/resources/floodlightdefault.properties
+++ b/src/main/resources/floodlightdefault.properties
@@ -4,7 +4,6 @@ net.floodlightcontroller.storage.memory.MemoryStorageSource,\
 net.floodlightcontroller.core.internal.FloodlightProvider,\
 net.floodlightcontroller.threadpool.ThreadPool,\
 net.floodlightcontroller.debugcounter.DebugCounterServiceImpl,\
-net.floodlightcontroller.restserver.RestApiServer,\
 net.floodlightcontroller.perfmon.PktInProcessingTime,\
 net.floodlightcontroller.debugevent.DebugEventService,\
 net.floodlightcontroller.staticflowentry.StaticFlowEntryPusher,\
diff --git a/src/test/java/net/floodlightcontroller/core/internal/RoleManagerTest.java b/src/test/java/net/floodlightcontroller/core/internal/RoleManagerTest.java
index 861574b29ce04bde74fbfb1e220f45e559ead3ca..526c8e237b9784dea04a9a2d95c0fe53be930277 100644
--- a/src/test/java/net/floodlightcontroller/core/internal/RoleManagerTest.java
+++ b/src/test/java/net/floodlightcontroller/core/internal/RoleManagerTest.java
@@ -32,26 +32,19 @@ import static org.easymock.EasyMock.replay;
 import static org.easymock.EasyMock.reset;
 import static org.easymock.EasyMock.verify;
 
-import java.util.HashMap;
 
 import org.junit.After;
 
 import net.floodlightcontroller.core.HARole;
-import net.floodlightcontroller.core.IOFSwitch;
-import net.floodlightcontroller.core.IOFSwitchBackend;
 import net.floodlightcontroller.core.IShutdownService;
 import net.floodlightcontroller.core.internal.Controller.IUpdate;
-import net.floodlightcontroller.core.test.MockSwitchManager;
 import net.floodlightcontroller.debugcounter.IDebugCounterService;
 import net.floodlightcontroller.debugcounter.MockDebugCounterService;
-import org.projectfloodlight.openflow.types.DatapathId;
 
 public class RoleManagerTest extends FloodlightTestCase {
     private Controller controller;
     private RoleManager roleManager;
 
-    private static DatapathId DATAPATH_ID_1 = DatapathId.of(1);
-
     @Override
     @Before
     public void setUp() throws Exception {
@@ -134,103 +127,4 @@ public class RoleManagerTest extends FloodlightTestCase {
 
         roleManager.setRole(role, "test");
     }
-
-
-    @Test
-    public void testNotifyFollower() throws Exception {
-        // Set by default
-        assertTrue(roleManager.getRole() == HARole.ACTIVE);
-
-        reset(controller);
-        controller.addUpdateToQueue(anyObject(IUpdate.class));
-        expectLastCall().anyTimes();
-        replay(controller);
-
-        // Test ACTIVE
-        roleManager.notify();
-
-        assertTrue(roleManager.getRole() == HARole.STANDBY);
-
-        // Test STANDBY
-        roleManager.notify();
-
-        assertTrue(roleManager.getRole() == HARole.STANDBY);
-
-    }
-
-    @Test
-    public void testNotifyLeaderNoMaster() {
-        doSetUp(HARole.STANDBY);
-
-        // Another master does NOT exist
-        setupSwitchesForNotifyLeader(false);
-
-        roleManager.notify();
-
-        assertTrue(roleManager.getRole() == HARole.ACTIVE);
-    }
-
-    @Test
-    public void testNotifyLeaderAnotherMaster() {
-        doSetUp(HARole.STANDBY);
-
-        // Another master exists
-        setupSwitchesForNotifyLeader(true);
-
-        roleManager.notify();
-
-        assertTrue(roleManager.getRole() == HARole.STANDBY);
-    }
-
-    @Test
-    public void testNotifyLeaderSplitBrainProtection() throws Exception {
-        doSetUp(HARole.STANDBY);
-
-        /* Split brain protection should not allow a controller to become ACTIVE
-         * if another ACTIVE controller exists in the cluster.
-         */
-        setupSwitchesForNotifyLeader(true);
-
-        roleManager.notify();
-
-        assertTrue(roleManager.getRole() == HARole.STANDBY);
-
-        /* At this point if the leader in the split brain scenario goes down,
-        * the controller connections should be updated to reflect that and
-        * leader notification should succeed as no other ACTIVE controller exists.
-        */
-        setupSwitchesForNotifyLeader(false);
-
-        /* Since the roleManager has already been notified, the controller connections
-         * should prompt an update.
-         */
-        roleManager.notifyControllerConnectionUpdate();
-
-        assertTrue(roleManager.getRole() == HARole.ACTIVE);
-    }
-
-    /**
-     * Helper to setup switches to test NotifyLeader scenarios.
-     * @param hasAnotherMaster whether or not the switches should have another master
-     */
-    public void setupSwitchesForNotifyLeader(boolean hasAnotherMaster) {
-        reset(controller);
-        // Setup switches with another master
-        MockSwitchManager switchManager = new MockSwitchManager();
-
-        IOFSwitchBackend sw1 = createMock(IOFSwitchBackend.class);
-        reset(sw1);
-        expect(sw1.hasAnotherMaster()).andReturn(hasAnotherMaster).anyTimes();
-        replay(sw1);
-
-        HashMap<DatapathId, IOFSwitch> switches = new HashMap<DatapathId, IOFSwitch> ();
-        switches.put(DATAPATH_ID_1, sw1);
-        switchManager.setSwitches(switches);
-
-        expect(controller.getSwitchService()).andReturn(switchManager).once();
-        controller.addUpdateToQueue(anyObject(IUpdate.class));
-        expectLastCall().anyTimes();
-        replay(controller);
-
-    }
 }
\ No newline at end of file
diff --git a/src/test/java/net/floodlightcontroller/debugevent/DebugEventTest.java b/src/test/java/net/floodlightcontroller/debugevent/DebugEventTest.java
index 0c296ef4bc60253961c084e37a14ff439d69be3a..aa2acfaeae37c128e9ebaac63658fa0a8454d236 100644
--- a/src/test/java/net/floodlightcontroller/debugevent/DebugEventTest.java
+++ b/src/test/java/net/floodlightcontroller/debugevent/DebugEventTest.java
@@ -1,24 +1,42 @@
 package net.floodlightcontroller.debugevent;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.easymock.EasyMock.anyObject;
+
+import org.easymock.EasyMock;
 import org.junit.Before;
 import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
+import net.floodlightcontroller.core.IShutdownListener;
+import net.floodlightcontroller.core.IShutdownService;
+import net.floodlightcontroller.core.module.FloodlightModuleContext;
+import net.floodlightcontroller.debugevent.DebugEventResource.EventInfoResource;
+import net.floodlightcontroller.debugevent.EventResource.Metadata;
 import net.floodlightcontroller.debugevent.IDebugEventService.EventColumn;
 import net.floodlightcontroller.debugevent.IDebugEventService.EventFieldType;
 import net.floodlightcontroller.debugevent.IDebugEventService.EventType;
+import org.projectfloodlight.openflow.types.DatapathId;
 import net.floodlightcontroller.test.FloodlightTestCase;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class DebugEventTest extends FloodlightTestCase {
-    Event debugEvent;
+    DebugEventService debugEvent;
     protected static Logger log = LoggerFactory.getLogger(DebugEventTest.class);
 
     @Override
     @Before
     public void setUp() throws Exception {
-        debugEvent = new Event(System.currentTimeMillis(), 0, "test", null, 0);
-
+        debugEvent = new DebugEventService();
+        FloodlightModuleContext fmc = new FloodlightModuleContext();
+        IShutdownService shutdownService =
+                EasyMock.createMock(IShutdownService.class);
+        shutdownService.registerShutdownListener(anyObject(IShutdownListener.class));
+        EasyMock.expectLastCall().once();
+        EasyMock.replay(shutdownService);
+        fmc.addService(IShutdownService.class, shutdownService);
+        debugEvent.startUp(fmc);
+        EasyMock.verify(shutdownService);
     }
 
 
@@ -27,12 +45,20 @@ public class DebugEventTest extends FloodlightTestCase {
         assertEquals(0, debugEvent.currentEvents.size());
         IEventCategory<SwitchyEvent> event1 = null;
         IEventCategory<PacketyEvent> event2 = null;
-        event1 = debugEvent.registerEvent("dbgevtest", "switchevent",
-                                           "switchtest", EventType.ALWAYS_LOG,
-                                           SwitchyEvent.class, 100);
-        event2 = debugEvent.registerEvent("dbgevtest", "pktinevent",
-                                           "pktintest", EventType.ALWAYS_LOG,
-                                           PacketyEvent.class, 100);
+        event1 = debugEvent.buildEvent(SwitchyEvent.class)
+                .setModuleName("dbgevtest")
+                .setEventName("switchevent")
+                .setEventType(EventType.ALWAYS_LOG)
+                .setBufferCapacity(100)
+                .setAckable(false)
+                .register();
+        event2 = debugEvent.buildEvent(PacketyEvent.class)
+                .setModuleName("dbgevtest")
+                .setEventName("pktinevent")
+                .setEventType(EventType.ALWAYS_LOG)
+                .setBufferCapacity(100)
+                .setAckable(false)
+                .register();
 
         assertEquals(2, debugEvent.currentEvents.size());
         assertTrue(null != debugEvent.moduleEvents.get("dbgevtest").
@@ -47,40 +73,40 @@ public class DebugEventTest extends FloodlightTestCase {
         assertEquals(true, debugEvent.containsModuleEventName("dbgevtest","switchevent"));
         assertEquals(true, debugEvent.containsModuleEventName("dbgevtest","pktinevent"));
 
-        assertEquals(0, debugEvent.allEvents[eventId1].eventBuffer.size());
-        assertEquals(0, debugEvent.allEvents[eventId2].eventBuffer.size());
+        assertEquals(0, debugEvent.allEvents.get(eventId1).circularEventBuffer.size());
+        assertEquals(0, debugEvent.allEvents.get(eventId2).circularEventBuffer.size());
 
         // update is immediately flushed to global store
-        event1.updateEventWithFlush(new SwitchyEvent(1L, "connected"));
-        assertEquals(1, debugEvent.allEvents[eventId1].eventBuffer.size());
+        event1.newEventWithFlush(new SwitchyEvent(DatapathId.of(1L), "connected"));
+        assertEquals(1, debugEvent.allEvents.get(eventId1).circularEventBuffer.size());
 
         // update is flushed only when flush is explicitly called
-        event2.updateEventNoFlush(new PacketyEvent(1L, 24L));
-        assertEquals(0, debugEvent.allEvents[eventId2].eventBuffer.size());
+        event2.newEventNoFlush(new PacketyEvent(DatapathId.of(1L), 24L));
+        assertEquals(0, debugEvent.allEvents.get(eventId2).circularEventBuffer.size());
 
         debugEvent.flushEvents();
-        assertEquals(1, debugEvent.allEvents[eventId1].eventBuffer.size());
-        assertEquals(1, debugEvent.allEvents[eventId2].eventBuffer.size());
+        assertEquals(1, debugEvent.allEvents.get(eventId1).circularEventBuffer.size());
+        assertEquals(1, debugEvent.allEvents.get(eventId2).circularEventBuffer.size());
 
-        DebugEventInfo de = debugEvent.getSingleEventHistory("dbgevtest","switchevent", 100);
+        EventInfoResource de = debugEvent.getSingleEventHistory("dbgevtest","switchevent", 100);
         assertEquals(1, de.events.size());
-        assertEquals(true, de.events.get(0).get("dpid").equals("00:00:00:00:00:00:00:01"));
-        assertEquals(true, de.events.get(0).get("reason").equals("connected"));
+        assertTrue(de.events.get(0).getDataFields().contains(new Metadata("dpid", "00:00:00:00:00:00:00:01")));
+        assertTrue(de.events.get(0).getDataFields().contains(new Metadata("reason", "connected")));
 
-        DebugEventInfo de2 = debugEvent.getSingleEventHistory("dbgevtest","pktinevent", 100);
+        EventInfoResource de2 = debugEvent.getSingleEventHistory("dbgevtest","pktinevent", 100);
         assertEquals(1, de2.events.size());
-        assertEquals(true, de2.events.get(0).get("dpid").equals("00:00:00:00:00:00:00:01"));
-        assertEquals(true, de2.events.get(0).get("srcMac").equals("00:00:00:00:00:18"));
+        assertTrue(de2.events.get(0).getDataFields().contains(new Metadata("dpid", "00:00:00:00:00:00:00:01")));
+        assertTrue(de2.events.get(0).getDataFields().contains(new Metadata("srcMac", "00:00:00:00:00:18")));
     }
 
     public class SwitchyEvent {
         @EventColumn(name = "dpid", description = EventFieldType.DPID)
-        long dpid;
+        DatapathId dpid;
 
         @EventColumn(name = "reason", description = EventFieldType.STRING)
         String reason;
 
-        public SwitchyEvent(long dpid, String reason) {
+        public SwitchyEvent(DatapathId dpid, String reason) {
             this.dpid = dpid;
             this.reason = reason;
         }
@@ -88,14 +114,121 @@ public class DebugEventTest extends FloodlightTestCase {
 
     public class PacketyEvent {
         @EventColumn(name = "dpid", description = EventFieldType.DPID)
-        long dpid;
+        DatapathId dpid;
 
         @EventColumn(name = "srcMac", description = EventFieldType.MAC)
         long mac;
 
-        public PacketyEvent(long dpid, long mac) {
+        public PacketyEvent(DatapathId dpid, long mac) {
             this.dpid = dpid;
             this.mac = mac;
         }
-    } 
-}
+    }
+
+    public class IntEvent {
+        @EventColumn(name = "index", description = EventFieldType.PRIMITIVE)
+        int index;
+
+        public IntEvent(int i) {
+            this.index = i;
+        }
+
+        @Override
+        public String toString() {
+            return String.valueOf(index);
+        }
+    }
+
+    @Test
+    public void testEventCyclesWithFlush() throws Exception {
+        IEventCategory<IntEvent> ev = null;
+        ev = debugEvent.buildEvent(IntEvent.class)
+                .setModuleName("test")
+                .setEventName("int")
+                .setEventDescription("just a test")
+                .setEventType(EventType.ALWAYS_LOG)
+                .setBufferCapacity(20)
+                .setAckable(false)
+                .register();
+
+        for (int i=0; i<20; i++)
+            ev.newEventWithFlush(new IntEvent(i));
+        int i=19;
+        EventInfoResource dei = debugEvent.getSingleEventHistory("test","int", 100);
+        for (EventResource m : dei.events) {
+            assertTrue(m.getDataFields().get(0).getEventData().equals(String.valueOf(i)));
+            i--;
+        }
+        for (int j= 500; j<550; j++)
+            ev.newEventWithFlush(new IntEvent(j));
+        int k=549;
+        dei = debugEvent.getSingleEventHistory("test","int", 100);
+        for (EventResource m : dei.events) {
+            //log.info("{}", m.get("index"));
+            assertTrue(m.getDataFields().get(0).getEventData().equals(String.valueOf(k)));
+            k--;
+        }
+    }
+
+
+    @Test
+    public void testEventCyclesNoFlush() throws Exception {
+        IEventCategory<IntEvent> ev = null;
+        ev = debugEvent.buildEvent(IntEvent.class)
+                .setModuleName("test")
+                .setEventName("int")
+                .setEventDescription("just a test")
+                .setEventType(EventType.ALWAYS_LOG)
+                .setBufferCapacity(20)
+                .setAckable(false)
+                .register();
+
+        // flushes when local buffer fills up
+        for (int i=0; i<20; i++)
+            ev.newEventNoFlush(new IntEvent(i));
+        int i=19;
+        EventInfoResource dei = debugEvent.getSingleEventHistory("test","int", 0);
+        for (EventResource m : dei.events) {
+            assertTrue(m.getDataFields().get(0).getEventData().equals(String.valueOf(i)));
+            i--;
+        }
+        //log.info("done with first bunch");
+        // flushes when local buffer fills up or when flushEvents is explicitly called
+        for (int j= 500; j<550; j++) {
+            ev.newEventNoFlush(new IntEvent(j));
+            //if (j == 515)
+                //debugEvent.flushEvents();
+        }
+        debugEvent.flushEvents();
+
+        int k=549;
+        dei = debugEvent.getSingleEventHistory("test","int", 100);
+        for (EventResource m : dei.events) {
+            //log.info("{}", m.get("index"));
+            assertTrue(m.getDataFields().get(0).getEventData().equals(String.valueOf(k)));
+            k--;
+        }
+    }
+
+    @Test
+    public void testAckEvent() throws Exception{
+        IEventCategory<IntEvent> ev = null;
+        ev = debugEvent.buildEvent(IntEvent.class)
+                .setModuleName("test")
+                .setEventName("ack")
+                .setEventDescription("just a test")
+                .setEventType(EventType.ALWAYS_LOG)
+                .setBufferCapacity(20)
+                .setAckable(false)
+                .register();
+        //create a single event
+        IntEvent e = new IntEvent(10);
+        ev.newEventWithFlush(e);
+        EventInfoResource dei = debugEvent.getSingleEventHistory("test","ack", 1);
+        debugEvent.setAck(dei.getEventId(),
+                          dei.getEvents().get(0).getEventInstanceId(),
+                          true);
+        dei = debugEvent.getSingleEventHistory("test","ack", 1);
+        assertTrue(dei.getEvents().get(0).isAcked());
+    }
+}
\ No newline at end of file
diff --git a/src/test/java/net/floodlightcontroller/debugevent/EventTest.java b/src/test/java/net/floodlightcontroller/debugevent/EventTest.java
index 8ee0661cf3d4e115c0c508411d941f29673aef5e..03d1cd2c8507da2e546af0cd949f3a1d59750974 100644
--- a/src/test/java/net/floodlightcontroller/debugevent/EventTest.java
+++ b/src/test/java/net/floodlightcontroller/debugevent/EventTest.java
@@ -1,15 +1,20 @@
 package net.floodlightcontroller.debugevent;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
+import java.util.Date;
+import org.junit.Test;
+import net.floodlightcontroller.debugevent.Event;
+import net.floodlightcontroller.debugevent.EventResource;
+import net.floodlightcontroller.debugevent.EventResource.EventResourceBuilder;
+import net.floodlightcontroller.debugevent.EventResource.Metadata;
 import net.floodlightcontroller.debugevent.IDebugEventService.EventColumn;
 import net.floodlightcontroller.debugevent.IDebugEventService.EventFieldType;
-
-import org.junit.Test;
+import org.projectfloodlight.openflow.types.DatapathId;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -20,40 +25,63 @@ public class EventTest {
     public void testFormat() {
         River r = new River("ganges", 42);
 
-        Event e = new Event(1, 32, "test", new RiverEvent(1L, (short)10, true, "big river", 5, 4L, r), 0);
-
-        Map<String, String> expected = new HashMap<String, String>();
-        expected.put("dpid", "00:00:00:00:00:00:00:01");
-        expected.put("portId", "10");
-        expected.put("valid", "true");
-        expected.put("desc", "big river");
-        expected.put("ip", "0.0.0.5");
-        expected.put("mac", "00:00:00:00:00:04");
-        expected.put("obj", "ganges/42");
-
-        //log.info("{} \n expected {}", e.getFormattedEvent(RiverEvent.class, "test"), expected);
-        for (Entry<String, String> elem : expected.entrySet())
-            assertEquals(elem.getValue(),
-                         e.getFormattedEvent(RiverEvent.class, "test").get(elem.getKey()));
+        Event e = new Event(1L, 32, "test",
+                      new RiverEvent(DatapathId.of(1L), (short)10, true, "big river", 5, 4L, r), 10L);
+
+        EventResourceBuilder edb = new EventResourceBuilder();
+        edb.dataFields.add(new Metadata("dpid", "00:00:00:00:00:00:00:01"));
+        edb.dataFields.add(new Metadata("portId", "10"));
+        edb.dataFields.add(new Metadata("valid", "true"));
+        edb.dataFields.add(new Metadata("desc", "big river"));
+        edb.dataFields.add(new Metadata("ip", "0.0.0.5"));
+        edb.dataFields.add(new Metadata("mac", "00:00:00:00:00:04"));
+        edb.dataFields.add(new Metadata("obj", "ganges/42"));
+        edb.setThreadId(e.getThreadId());
+        edb.setThreadName(e.getThreadName());
+        edb.setTimeStamp(e.getTimeMs());
+        edb.setModuleEventName("test");
+        EventResource ed = edb.build();
+
+        // check Event.getFormattedEvent()
+        assertTrue(ed.equals(e.getFormattedEvent(RiverEvent.class, "test")));
 
         // ensure timestamp comes in ISO8601 time
-        assertEquals("1969-12-31T16:00:00.001-0800",
-                     e.getFormattedEvent(RiverEvent.class, "test2").get("Timestamp")); //1L
+        // e.g.: 1969-12-31T16:00:00.001-08:00
+        Pattern pat =
+                Pattern.compile("\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}[+-]\\d{2}:\\d{2}");
+        Date t1 = e.getFormattedEvent(RiverEvent.class, "test2").getTimestamp();
+        Matcher m1 = pat.matcher(t1.toString());
+        assertTrue(m1.matches());
 
         // ensure that cached value is not returned for incorrect class
-        for (Entry<String, String> elem : expected.entrySet())
-            assertFalse(elem.getValue().equals(
-                            e.getFormattedEvent(River.class, "test").get(elem.getKey())));
-
-        assertEquals("null event data or event-class does not match event-data",
-                     e.getFormattedEvent(River.class, "test").get("Error"));
-        assertEquals("null event data or event-class does not match event-data",
-                     e.getFormattedEvent(null, "test").get("Error"));
+        assertFalse(ed.equals(e.getFormattedEvent(River.class, "test")));
+
+        assertTrue(e.getFormattedEvent(River.class, "test").getDataFields().
+                   contains(new Metadata("Error",
+                   "null event data or event-class does not match event-data")));
+        assertTrue(e.getFormattedEvent(null, "test").getDataFields().contains(
+          new Metadata("Error",
+                   "null event data or event-class does not match event-data")));
+    }
+
+    @Test
+    public void testIncorrectAnnotation() {
+        Event e = new Event(1L, 32, "test",
+                            new LakeEvent(199), 11L); // dpid cannot be int
+        assertTrue(e.getFormattedEvent(LakeEvent.class, "test").getDataFields()
+          .contains(new Metadata("Error",
+                             "java.lang.Integer cannot be cast to org.projectfloodlight.openflow.types.DatapathId")));
+
+        Event e2 = new Event(1L, 32, "test",
+                            new LakeEvent2(199), 12L); // mac cannot be int
+        assertTrue(e2.getFormattedEvent(LakeEvent2.class, "test").getDataFields()
+                   .contains(new Metadata("Error",
+                                      "java.lang.Integer cannot be cast to java.lang.Long")));
     }
 
     class RiverEvent  {
         @EventColumn(name = "dpid", description = EventFieldType.DPID)
-        long dpid;
+        DatapathId dpid;
 
         @EventColumn(name = "portId", description = EventFieldType.PRIMITIVE)
         short srcPort;
@@ -75,7 +103,7 @@ public class EventTest {
 
         // Instances of RiverEvent ensure that that any internal object
         // (eg. River instances) has been copied before it is given to DebugEvents.
-        public RiverEvent(long dpid, short srcPort, boolean isValid,
+        public RiverEvent(DatapathId dpid, short srcPort, boolean isValid,
                             String desc, int ip, long mac, River passedin) {
             this.dpid = dpid;
             this.srcPort = srcPort;
@@ -127,5 +155,5 @@ public class EventTest {
         public LakeEvent2(int mac) {
             this.mac = mac;
         }
-    } 
-}
+    }
+}
\ No newline at end of file
diff --git a/src/test/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImplTest.java b/src/test/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImplTest.java
index df61c28e34730ca935489e5f1d7ce5e7d251969f..c539be22b35a2e5e6f66d3659f17921b13b81346 100644
--- a/src/test/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImplTest.java
+++ b/src/test/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImplTest.java
@@ -57,6 +57,12 @@ import net.floodlightcontroller.core.HARole;
 import net.floodlightcontroller.core.module.FloodlightModuleContext;
 import net.floodlightcontroller.core.module.FloodlightModuleException;
 import net.floodlightcontroller.core.test.MockThreadPoolService;
+import net.floodlightcontroller.debugcounter.DebugCounterServiceImpl;
+import net.floodlightcontroller.debugcounter.IDebugCounterService;
+import net.floodlightcontroller.debugcounter.MockDebugCounterService;
+import net.floodlightcontroller.debugevent.DebugEventService;
+import net.floodlightcontroller.debugevent.IDebugEventService;
+import net.floodlightcontroller.debugevent.MockDebugEventService;
 import net.floodlightcontroller.devicemanager.IDevice;
 import net.floodlightcontroller.devicemanager.IDeviceListener;
 import net.floodlightcontroller.devicemanager.IDeviceService;
@@ -123,6 +129,8 @@ public class DeviceManagerImplTest extends FloodlightTestCase {
 	DeviceManagerImpl deviceManager;
 	MemoryStorageSource storageSource;
 	FlowReconcileManager flowReconcileMgr;
+	IDebugCounterService debugCounterService;
+	IDebugEventService debugEventService;
 
 	private IOFSwitch makeSwitchMock(DatapathId id) {
 		IOFSwitch mockSwitch = createMock(IOFSwitch.class);
@@ -173,6 +181,8 @@ public class DeviceManagerImplTest extends FloodlightTestCase {
 		fmc.addService(IThreadPoolService.class, tp);
 		mockFloodlightProvider = getMockFloodlightProvider();
 		mockFloodlightProvider.setRole(initialRole, "");
+		debugCounterService = new MockDebugCounterService();
+		debugEventService = new MockDebugEventService();
 
 
 		deviceManager = new DeviceManagerImpl();
@@ -187,6 +197,8 @@ public class DeviceManagerImplTest extends FloodlightTestCase {
 		fmc.addService(IEntityClassifierService.class, entityClassifier);
 		fmc.addService(ITopologyService.class, topology);
 		fmc.addService(ISyncService.class, syncService);
+		fmc.addService(IDebugCounterService.class, debugCounterService);
+		fmc.addService(IDebugEventService.class, debugEventService);
 		tp.init(fmc);
 		restApi.init(fmc);
 		storageSource.init(fmc);
diff --git a/src/test/java/net/floodlightcontroller/firewall/FirewallTest.java b/src/test/java/net/floodlightcontroller/firewall/FirewallTest.java
index 6e5f4a57bb819012687c80a6ea19fcb8b6d7345d..b643349f0c6038cb799c020c7a8543d3bdf41a38 100644
--- a/src/test/java/net/floodlightcontroller/firewall/FirewallTest.java
+++ b/src/test/java/net/floodlightcontroller/firewall/FirewallTest.java
@@ -93,7 +93,6 @@ public class FirewallTest extends FloodlightTestCase {
         DatapathId dpid = DatapathId.of(TestSwitch1DPID);
         sw = EasyMock.createNiceMock(IOFSwitch.class);
         expect(sw.getId()).andReturn(dpid).anyTimes();
-        expect(sw.getId().toString()).andReturn(TestSwitch1DPID).anyTimes();
         replay(sw);
         // Load the switch map
         Map<DatapathId, IOFSwitch> switches = new HashMap<DatapathId, IOFSwitch>();
diff --git a/src/test/java/net/floodlightcontroller/forwarding/ForwardingTest.java b/src/test/java/net/floodlightcontroller/forwarding/ForwardingTest.java
index 9dec8e67163830432e2da62cc3980b22a8699a2c..b63921396c72720dbb21497df4f2037f6889ef5e 100644
--- a/src/test/java/net/floodlightcontroller/forwarding/ForwardingTest.java
+++ b/src/test/java/net/floodlightcontroller/forwarding/ForwardingTest.java
@@ -31,6 +31,10 @@ import net.floodlightcontroller.core.IFloodlightProviderService;
 import net.floodlightcontroller.core.IOFSwitch;
 import net.floodlightcontroller.core.module.FloodlightModuleContext;
 import net.floodlightcontroller.core.test.MockThreadPoolService;
+import net.floodlightcontroller.debugcounter.IDebugCounterService;
+import net.floodlightcontroller.debugcounter.MockDebugCounterService;
+import net.floodlightcontroller.debugevent.IDebugEventService;
+import net.floodlightcontroller.debugevent.MockDebugEventService;
 import net.floodlightcontroller.devicemanager.internal.DefaultEntityClassifier;
 import net.floodlightcontroller.devicemanager.test.MockDeviceManager;
 import net.floodlightcontroller.devicemanager.IDevice;
@@ -146,6 +150,8 @@ public class ForwardingTest extends FloodlightTestCase {
         fmc.addService(IFlowReconcileService.class, flowReconcileMgr);
         fmc.addService(IEntityClassifierService.class, entityClassifier);
         fmc.addService(ISyncService.class, mockSyncService);
+        fmc.addService(IDebugCounterService.class, new MockDebugCounterService());
+        fmc.addService(IDebugEventService.class, new MockDebugEventService());
 
         topology.addListener(anyObject(ITopologyListener.class));
         expectLastCall().anyTimes();
@@ -170,14 +176,10 @@ public class ForwardingTest extends FloodlightTestCase {
         sw1 = EasyMock.createMock(IOFSwitch.class);
         expect(sw1.getId()).andReturn(DatapathId.of(1L)).anyTimes();
         expect(sw1.getBuffers()).andReturn(swFeatures.getNBuffers()).anyTimes();
-        expect(sw1.getId().toString())
-                .andReturn(DatapathId.of(1L).toString()).anyTimes();
 
         sw2 = EasyMock.createMock(IOFSwitch.class);
         expect(sw2.getId()).andReturn(DatapathId.of(2L)).anyTimes();
         expect(sw2.getBuffers()).andReturn(swFeatures.getNBuffers()).anyTimes();
-        expect(sw2.getId().toString())
-                .andReturn(DatapathId.of(2L).toString()).anyTimes();
 
         expect(sw1.hasAttribute(IOFSwitch.PROP_SUPPORTS_OFPP_TABLE)).andReturn(true).anyTimes();
 
@@ -212,7 +214,6 @@ public class ForwardingTest extends FloodlightTestCase {
         testPacketSerialized = testPacket.serialize();
         packetIn = factory.buildPacketIn()
                         .setBufferId(OFBufferId.NO_BUFFER)
-                        .setInPort(OFPort.of(1))
                         .setData(testPacketSerialized)
                         .setReason(OFPacketInReason.NO_MATCH)
                         .build();
@@ -222,7 +223,6 @@ public class ForwardingTest extends FloodlightTestCase {
         poactions.add(factory.actions().output(OFPort.of(3), Integer.MAX_VALUE));
         packetOut = factory.buildPacketOut()
         		.setBufferId(this.packetIn.getBufferId())
-        		.setInPort(this.packetIn.getInPort())
         		.setActions(poactions)
         		.setData(testPacketSerialized)
         		.build();
@@ -232,7 +232,6 @@ public class ForwardingTest extends FloodlightTestCase {
         poactions.add(factory.actions().output(OFPort.FLOOD, Integer.MAX_VALUE));
         packetOutFlooded = factory.buildPacketOut()
         		.setBufferId(this.packetIn.getBufferId())
-        		.setInPort(this.packetIn.getInPort())
         		.setActions(poactions)
         		.setData(testPacketSerialized)
         		.build();
diff --git a/src/test/java/net/floodlightcontroller/learningswitch/LearningSwitchTest.java b/src/test/java/net/floodlightcontroller/learningswitch/LearningSwitchTest.java
index f0bf807fd0da056edeb369f2f6fd211b6388fd84..cfcd202cec73c25e11a7fdf4c7786f2dd5a6dec1 100644
--- a/src/test/java/net/floodlightcontroller/learningswitch/LearningSwitchTest.java
+++ b/src/test/java/net/floodlightcontroller/learningswitch/LearningSwitchTest.java
@@ -124,10 +124,13 @@ public class LearningSwitchTest extends FloodlightTestCase {
         // Build the PacketIn
         this.packetIn = factory.buildPacketIn()
             .setBufferId(OFBufferId.NO_BUFFER)
-            .setInPort(OFPort.of(1))
             .setData(this.testPacketSerialized)
             .setReason(OFPacketInReason.NO_MATCH)
             .build();
+        
+        this.learningSwitch = new LearningSwitch();
+        this.mockFloodlightProvider.addOFMessageListener(OFType.PACKET_IN, learningSwitch);
+
     }
 
     @Test
@@ -136,13 +139,12 @@ public class LearningSwitchTest extends FloodlightTestCase {
         OFPacketOut po = factory.buildPacketOut()
             .setActions(Arrays.asList((OFAction)factory.actions().output(OFPort.FLOOD, Integer.MAX_VALUE)))
             .setBufferId(OFBufferId.NO_BUFFER)
-            .setInPort(OFPort.of(1))
             .setData(this.testPacketSerialized)
 	        .build();
 
         // Mock up our expected behavior
         IOFSwitch mockSwitch = createMock(IOFSwitch.class);
-        expect(mockSwitch.getId().toString()).andReturn("00:11:22:33:44:55:66:77").anyTimes();
+        expect(mockSwitch.getId()).andReturn(DatapathId.of("00:11:22:33:44:55:66:77")).anyTimes();
         mockSwitch.write(po, null);
 
         // Start recording the replay on the mocks
diff --git a/src/test/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManagerTest.java b/src/test/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManagerTest.java
index b2ba0f446582e7a69d6c22cd012a194539d2cf96..08a490373f303bbf50721f9322aed78cedcdbd89 100644
--- a/src/test/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManagerTest.java
+++ b/src/test/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManagerTest.java
@@ -30,6 +30,7 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -38,8 +39,13 @@ import net.floodlightcontroller.core.FloodlightContext;
 import net.floodlightcontroller.core.IFloodlightProviderService;
 import net.floodlightcontroller.core.IListener.Command;
 import net.floodlightcontroller.core.IOFSwitch;
+import net.floodlightcontroller.core.internal.IOFSwitchService;
 import net.floodlightcontroller.core.module.FloodlightModuleContext;
 import net.floodlightcontroller.core.test.MockThreadPoolService;
+import net.floodlightcontroller.debugcounter.IDebugCounterService;
+import net.floodlightcontroller.debugcounter.MockDebugCounterService;
+import net.floodlightcontroller.debugevent.IDebugEventService;
+import net.floodlightcontroller.debugevent.MockDebugEventService;
 import net.floodlightcontroller.linkdiscovery.ILinkDiscoveryListener;
 import net.floodlightcontroller.linkdiscovery.ILinkDiscoveryService;
 import net.floodlightcontroller.linkdiscovery.LinkInfo;
@@ -70,6 +76,7 @@ import org.projectfloodlight.openflow.protocol.OFMessage;
 import org.projectfloodlight.openflow.protocol.OFPacketIn;
 import org.projectfloodlight.openflow.protocol.OFPacketInReason;
 import org.projectfloodlight.openflow.protocol.OFPortDesc;
+import org.projectfloodlight.openflow.protocol.OFPortFeatures;
 import org.projectfloodlight.openflow.protocol.OFVersion;
 import org.projectfloodlight.openflow.types.DatapathId;
 import org.projectfloodlight.openflow.types.MacAddress;
@@ -127,6 +134,8 @@ public class LinkDiscoveryManagerTest extends FloodlightTestCase {
         ldm = new TestLinkDiscoveryManager();
         TopologyManager routingEngine = new TopologyManager();
         ldm.linkDiscoveryAware = new ArrayList<ILinkDiscoveryListener>();
+        IDebugCounterService debugCounterService = new MockDebugCounterService();
+        IDebugEventService debugEventService = new MockDebugEventService();
         MockThreadPoolService tp = new MockThreadPoolService();
         RestApiServer restApi = new RestApiServer();
         cntx.addService(IRestApiService.class, restApi);
@@ -136,6 +145,9 @@ public class LinkDiscoveryManagerTest extends FloodlightTestCase {
         cntx.addService(ITopologyService.class, ldm);
         cntx.addService(IStorageSourceService.class, new MemoryStorageSource());
         cntx.addService(IFloodlightProviderService.class, getMockFloodlightProvider());
+        cntx.addService(IDebugCounterService.class, debugCounterService);
+        cntx.addService(IDebugEventService.class, debugEventService);
+        cntx.addService(IOFSwitchService.class, getMockSwitchService());
         restApi.init(cntx);
         tp.init(cntx);
         routingEngine.init(cntx);
@@ -170,8 +182,8 @@ public class LinkDiscoveryManagerTest extends FloodlightTestCase {
         // check invariants hold
         assertNotNull(linkDiscovery.switchLinks.get(lt.getSrc()));
         assertTrue(linkDiscovery.switchLinks.get(lt.getSrc()).contains(lt));
-        assertNotNull(linkDiscovery.portLinks.get(srcNpt));
-        assertTrue(linkDiscovery.portLinks.get(srcNpt).contains(lt));
+        assertNotNull(linkDiscovery.getPortLinks().get(srcNpt));
+        assertTrue(linkDiscovery.getPortLinks().get(srcNpt).contains(lt));
         assertNotNull(linkDiscovery.portLinks.get(dstNpt));
         assertTrue(linkDiscovery.portLinks.get(dstNpt).contains(lt));
         assertTrue(linkDiscovery.links.containsKey(lt));
@@ -290,7 +302,7 @@ public class LinkDiscoveryManagerTest extends FloodlightTestCase {
 
         Link lt = new Link(DatapathId.of(1L), OFPort.of(1), DatapathId.of(2L), OFPort.of(1));
         NodePortTuple srcNpt = new NodePortTuple(DatapathId.of(1L), OFPort.of(1));
-        NodePortTuple dstNpt = new NodePortTuple(DatapathId.of(2L), OFPort.of(2));
+        NodePortTuple dstNpt = new NodePortTuple(DatapathId.of(2L), OFPort.of(1));
 
         LinkInfo info;
 
@@ -422,15 +434,15 @@ public class LinkDiscoveryManagerTest extends FloodlightTestCase {
     @Test
     public void testSwitchAdded() throws Exception {
         LinkDiscoveryManager linkDiscovery = getLinkDiscoveryManager();
+        linkDiscovery.switchService = getMockSwitchService();
         Capture<OFMessage> wc;
         Set<OFPort> qPorts;
         OFPortDesc ofpp = OFFactories.getFactory(OFVersion.OF_13).buildPortDesc()
         .setName("eth4242")
         .setPortNo(OFPort.of(4242))
         .setHwAddr(MacAddress.of("5c:16:c7:00:00:01"))
-        .setCurr(null)
+        .setCurr(new HashSet<OFPortFeatures>()) // random
         .build();
-        OFPort p1 = ofpp.getPortNo();
         IOFSwitch sw1 = createMockSwitch(1L);
 
         // Set switch map in floodlightProvider.
@@ -449,7 +461,8 @@ public class LinkDiscoveryManagerTest extends FloodlightTestCase {
 
         // Expect switch to return those ports.
         expect(sw1.getEnabledPortNumbers()).andReturn(ports).anyTimes();
-        expect(sw1.getPort(OFPort.of(EasyMock.anyShort())).getPortNo()).andReturn(p1).anyTimes();
+        expect(sw1.getPort(OFPort.of(EasyMock.anyInt()))).andReturn(ofpp).anyTimes();
+        expect(sw1.getOFFactory()).andReturn(OFFactories.getFactory(OFVersion.OF_13)).anyTimes();
         sw1.write(capture(wc));
         expectLastCall().anyTimes();
         replay(sw1);
@@ -499,7 +512,6 @@ public class LinkDiscoveryManagerTest extends FloodlightTestCase {
         // build out input packet
         pi = OFFactories.getFactory(OFVersion.OF_13).buildPacketIn()
                 .setBufferId(OFBufferId.NO_BUFFER)
-                .setInPort(OFPort.of(1))
                 .setData(testPacketSerialized)
                 .setReason(OFPacketInReason.NO_MATCH)
                 .build();
diff --git a/src/test/java/net/floodlightcontroller/loadbalancer/LoadBalancerTest.java b/src/test/java/net/floodlightcontroller/loadbalancer/LoadBalancerTest.java
index a78460f5d00c09f62fa3ace90d7f426a8713a9f3..ce8f039046546134afa07792b037bae8cade6e0f 100644
--- a/src/test/java/net/floodlightcontroller/loadbalancer/LoadBalancerTest.java
+++ b/src/test/java/net/floodlightcontroller/loadbalancer/LoadBalancerTest.java
@@ -51,6 +51,7 @@ import org.projectfloodlight.openflow.types.OFPort;
 import org.projectfloodlight.openflow.types.U64;
 import org.projectfloodlight.openflow.protocol.OFPacketInReason;
 import org.projectfloodlight.openflow.protocol.action.OFAction;
+import org.projectfloodlight.openflow.protocol.match.MatchField;
 import org.projectfloodlight.openflow.util.HexString;
 import org.projectfloodlight.openflow.types.DatapathId;
 import org.sdnplatform.sync.ISyncService;
@@ -59,8 +60,13 @@ import org.sdnplatform.sync.test.MockSyncService;
 import net.floodlightcontroller.core.FloodlightContext;
 import net.floodlightcontroller.core.IFloodlightProviderService;
 import net.floodlightcontroller.core.IOFSwitch;
+import net.floodlightcontroller.core.internal.IOFSwitchService;
 import net.floodlightcontroller.core.module.FloodlightModuleContext;
 import net.floodlightcontroller.core.test.MockThreadPoolService;
+import net.floodlightcontroller.debugcounter.IDebugCounterService;
+import net.floodlightcontroller.debugcounter.MockDebugCounterService;
+import net.floodlightcontroller.debugevent.IDebugEventService;
+import net.floodlightcontroller.debugevent.MockDebugEventService;
 import net.floodlightcontroller.devicemanager.IDeviceService;
 import net.floodlightcontroller.devicemanager.IEntityClassifierService;
 import net.floodlightcontroller.devicemanager.internal.DefaultEntityClassifier;
@@ -103,7 +109,8 @@ public class LoadBalancerTest extends FloodlightTestCase {
 	protected PoolsResource poolsResource;
 	protected MembersResource membersResource;
 	private MockSyncService mockSyncService;
-
+	protected IDebugCounterService debugCounterService;
+	protected IDebugEventService debugEventService;
 	protected LBVip vip1, vip2;
 	protected LBPool pool1, pool2, pool3;
 	protected LBMember member1, member2, member3, member4;
@@ -127,6 +134,8 @@ public class LoadBalancerTest extends FloodlightTestCase {
 		sfp = new StaticFlowEntryPusher();
 		storage = new MemoryStorageSource(); //dependency for sfp
 		mockSyncService = new MockSyncService();
+		debugCounterService = new MockDebugCounterService();
+		debugEventService = new MockDebugEventService();
 
 		fmc.addService(IRestApiService.class, restApi);
 		fmc.addService(IFloodlightProviderService.class, getMockFloodlightProvider());
@@ -140,6 +149,9 @@ public class LoadBalancerTest extends FloodlightTestCase {
 		fmc.addService(ILoadBalancerService.class, lb);
 		fmc.addService(IStorageSourceService.class, storage);
 		fmc.addService(ISyncService.class, mockSyncService);
+		fmc.addService(IDebugCounterService.class, debugCounterService);
+		fmc.addService(IDebugEventService.class, debugEventService);
+		fmc.addService(IOFSwitchService.class, getMockSwitchService());
 
 		lb.init(fmc);
 		getMockFloodlightProvider().init(fmc);
@@ -430,8 +442,8 @@ public class LoadBalancerTest extends FloodlightTestCase {
 
 		sw1 = EasyMock.createNiceMock(IOFSwitch.class);
 		expect(sw1.getId()).andReturn(DatapathId.of(1L)).anyTimes();
-		expect(sw1.getId().toString()).andReturn("00:00:00:00:00:01").anyTimes();
 		expect(sw1.hasAttribute(IOFSwitch.PROP_SUPPORTS_OFPP_TABLE)).andReturn(true).anyTimes();
+		expect(sw1.getOFFactory()).andReturn(OFFactories.getFactory(OFVersion.OF_13)).anyTimes();
 		sw1.write(capture(wc1));
 		expectLastCall().anyTimes();
 		sw1.flush();
@@ -464,7 +476,6 @@ public class LoadBalancerTest extends FloodlightTestCase {
 		replay(topology);
 
 
-
 		// Build arp packets
 		arpRequest1 = new Ethernet()
 		.setSourceMACAddress("00:00:00:00:00:01")
@@ -487,8 +498,8 @@ public class LoadBalancerTest extends FloodlightTestCase {
 		arpRequest1Serialized = arpRequest1.serialize();
 
 		arpRequestPacketIn1 = OFFactories.getFactory(OFVersion.OF_13).buildPacketIn()
+				.setMatch(OFFactories.getFactory(OFVersion.OF_13).buildMatch().setExact(MatchField.IN_PORT, OFPort.of(1)).build())
 				.setBufferId(OFBufferId.NO_BUFFER)
-				.setInPort(OFPort.of(1))
 				.setData(arpRequest1Serialized)
 				.setReason(OFPacketInReason.NO_MATCH)
 				.build();
@@ -519,7 +530,7 @@ public class LoadBalancerTest extends FloodlightTestCase {
 		arpReply1Serialized = arpReply1.serialize();
 
 		List<OFAction> poactions = new ArrayList<OFAction>();
-		poactions.add(OFFactories.getFactory(OFVersion.OF_13).actions().output(arpRequestPacketIn1.getInPort(), (short) 0xffff));
+		poactions.add(OFFactories.getFactory(OFVersion.OF_13).actions().output(arpRequestPacketIn1.getMatch().get(MatchField.IN_PORT), (short) 0xffff));
 		arpReplyPacketOut1 = OFFactories.getFactory(OFVersion.OF_13).buildPacketOut()
 				.setBufferId(OFBufferId.NO_BUFFER)
 				.setInPort(OFPort.ANY)
diff --git a/src/test/java/net/floodlightcontroller/staticflowentry/StaticFlowTests.java b/src/test/java/net/floodlightcontroller/staticflowentry/StaticFlowTests.java
index cf73d87a60e9415ee71f8175333d57ac8c758ef6..dc9354e2e8a978227b181d8f2ce68eed8b0452b4 100644
--- a/src/test/java/net/floodlightcontroller/staticflowentry/StaticFlowTests.java
+++ b/src/test/java/net/floodlightcontroller/staticflowentry/StaticFlowTests.java
@@ -39,11 +39,19 @@ import org.projectfloodlight.openflow.types.OFPort;
 import org.projectfloodlight.openflow.protocol.action.OFAction;
 import org.projectfloodlight.openflow.util.HexString;
 
+import com.sun.org.apache.bcel.internal.generic.GETSTATIC;
+
 import net.floodlightcontroller.core.FloodlightContext;
 import net.floodlightcontroller.core.IFloodlightProviderService;
 import net.floodlightcontroller.core.IOFSwitch;
+import net.floodlightcontroller.core.internal.IOFSwitchService;
 import net.floodlightcontroller.core.module.FloodlightModuleContext;
 import net.floodlightcontroller.core.test.MockFloodlightProvider;
+import net.floodlightcontroller.core.test.MockSwitchManager;
+import net.floodlightcontroller.debugcounter.IDebugCounterService;
+import net.floodlightcontroller.debugcounter.MockDebugCounterService;
+import net.floodlightcontroller.debugevent.IDebugEventService;
+import net.floodlightcontroller.debugevent.MockDebugEventService;
 import net.floodlightcontroller.test.FloodlightTestCase;
 import net.floodlightcontroller.util.FlowModUtils;
 import net.floodlightcontroller.util.MatchUtils;
@@ -135,7 +143,7 @@ public class StaticFlowTests extends FloodlightTestCase {
         Match match;
         TestRule3.put(COLUMN_DL_DST, "00:20:30:40:50:60");
         TestRule3.put(COLUMN_DL_VLAN, 4096);
-        match = MatchUtils.fromString("dl_dst=00:20:30:40:50:60,dl_vlan=4096", factory.getVersion());
+        match = MatchUtils.fromString("dl_dst=00:20:30:40:50:60,dl_vlan=96", factory.getVersion());
         // setup actions
         TestRule3.put(COLUMN_ACTIONS, "output=controller");
         List<OFAction> actions = new LinkedList<OFAction>();
@@ -200,6 +208,7 @@ public class StaticFlowTests extends FloodlightTestCase {
 
         FloodlightModuleContext fmc = new FloodlightModuleContext();
         fmc.addService(IStorageSourceService.class, storage);
+        fmc.addService(IOFSwitchService.class, getMockSwitchService());
 
         MockFloodlightProvider mockFloodlightProvider = getMockFloodlightProvider();
         Map<DatapathId, IOFSwitch> switchMap = new HashMap<DatapathId, IOFSwitch>();
diff --git a/src/test/java/net/floodlightcontroller/topology/TopologyInstanceTest.java b/src/test/java/net/floodlightcontroller/topology/TopologyInstanceTest.java
index d05013cbc848f7056fd3542c776f51074570d94b..a8542b2ead3f6cb0b063fbb75956b0212024a8b1 100644
--- a/src/test/java/net/floodlightcontroller/topology/TopologyInstanceTest.java
+++ b/src/test/java/net/floodlightcontroller/topology/TopologyInstanceTest.java
@@ -27,6 +27,10 @@ import net.floodlightcontroller.core.IFloodlightProviderService;
 import net.floodlightcontroller.core.module.FloodlightModuleContext;
 import net.floodlightcontroller.core.test.MockFloodlightProvider;
 import net.floodlightcontroller.core.test.MockThreadPoolService;
+import net.floodlightcontroller.debugcounter.IDebugCounterService;
+import net.floodlightcontroller.debugcounter.MockDebugCounterService;
+import net.floodlightcontroller.debugevent.IDebugEventService;
+import net.floodlightcontroller.debugevent.MockDebugEventService;
 import net.floodlightcontroller.linkdiscovery.ILinkDiscovery;
 import net.floodlightcontroller.linkdiscovery.ILinkDiscoveryService;
 import net.floodlightcontroller.threadpool.IThreadPoolService;
@@ -60,6 +64,8 @@ public class TopologyInstanceTest {
         mockFloodlightProvider = new MockFloodlightProvider();
         fmc.addService(IFloodlightProviderService.class, mockFloodlightProvider);
         fmc.addService(ILinkDiscoveryService.class, linkDiscovery);
+        fmc.addService(IDebugCounterService.class, new MockDebugCounterService());
+        fmc.addService(IDebugEventService.class, new MockDebugEventService());
         MockThreadPoolService tp = new MockThreadPoolService();
         topologyManager  = new TopologyManager();
         fmc.addService(IThreadPoolService.class, tp);
diff --git a/src/test/java/net/floodlightcontroller/topology/TopologyManagerTest.java b/src/test/java/net/floodlightcontroller/topology/TopologyManagerTest.java
index 2ff76ee513484b72b78e677b5dd689c84165410e..905acbb052bbfae4366b9552895ab7ac4075276c 100644
--- a/src/test/java/net/floodlightcontroller/topology/TopologyManagerTest.java
+++ b/src/test/java/net/floodlightcontroller/topology/TopologyManagerTest.java
@@ -20,6 +20,10 @@ import static org.junit.Assert.*;
 import net.floodlightcontroller.core.IFloodlightProviderService;
 import net.floodlightcontroller.core.module.FloodlightModuleContext;
 import net.floodlightcontroller.core.test.MockThreadPoolService;
+import net.floodlightcontroller.debugcounter.IDebugCounterService;
+import net.floodlightcontroller.debugcounter.MockDebugCounterService;
+import net.floodlightcontroller.debugevent.IDebugEventService;
+import net.floodlightcontroller.debugevent.MockDebugEventService;
 import net.floodlightcontroller.linkdiscovery.ILinkDiscovery;
 import net.floodlightcontroller.test.FloodlightTestCase;
 import net.floodlightcontroller.threadpool.IThreadPoolService;
@@ -43,6 +47,8 @@ public class TopologyManagerTest extends FloodlightTestCase {
         super.setUp();
         fmc = new FloodlightModuleContext();
         fmc.addService(IFloodlightProviderService.class, getMockFloodlightProvider());
+        fmc.addService(IDebugCounterService.class, new MockDebugCounterService());
+        fmc.addService(IDebugEventService.class, new MockDebugEventService());
         MockThreadPoolService tp = new MockThreadPoolService();
         fmc.addService(IThreadPoolService.class, tp);
         tm  = new TopologyManager();
@@ -53,30 +59,30 @@ public class TopologyManagerTest extends FloodlightTestCase {
 
     @Test
     public void testBasic1() throws Exception {
-        tm.addOrUpdateLink(DatapathId.of(1), OFPort.of((short)1), DatapathId.of(2), OFPort.of((short)1), ILinkDiscovery.LinkType.DIRECT_LINK);
+        tm.addOrUpdateLink(DatapathId.of(1), OFPort.of(1), DatapathId.of(2), OFPort.of(1), ILinkDiscovery.LinkType.DIRECT_LINK);
         assertTrue(tm.getSwitchPorts().size() == 2);  // for two nodes.
-        assertTrue(tm.getSwitchPorts().get((long)1).size()==1);
-        assertTrue(tm.getSwitchPorts().get((long)2).size()==1);
+        assertTrue(tm.getSwitchPorts().get(DatapathId.of(1)).size()==1);
+        assertTrue(tm.getSwitchPorts().get(DatapathId.of(2)).size()==1);
         assertTrue(tm.getSwitchPortLinks().size()==2);
         assertTrue(tm.getPortBroadcastDomainLinks().size()==0);
         assertTrue(tm.getTunnelPorts().size()==0);
 
-        tm.addOrUpdateLink(DatapathId.of(1), OFPort.of((short)2), DatapathId.of(2), OFPort.of((short)2), ILinkDiscovery.LinkType.MULTIHOP_LINK);
+        tm.addOrUpdateLink(DatapathId.of(1), OFPort.of(2), DatapathId.of(2), OFPort.of(2), ILinkDiscovery.LinkType.MULTIHOP_LINK);
         assertTrue(tm.getSwitchPorts().size() == 2);  // for two nodes.
-        assertTrue(tm.getSwitchPorts().get((long)1).size()==2);
-        assertTrue(tm.getSwitchPorts().get((long)2).size()==2);
+        assertTrue(tm.getSwitchPorts().get(DatapathId.of(1)).size()==2);
+        assertTrue(tm.getSwitchPorts().get(DatapathId.of(2)).size()==2);
         assertTrue(tm.getSwitchPortLinks().size()==4);
         assertTrue(tm.getPortBroadcastDomainLinks().size()==2);
         assertTrue(tm.getTunnelPorts().size()==0);
 
-        tm.removeLink(DatapathId.of(1), OFPort.of((short)2), DatapathId.of(2), OFPort.of((short)2));
-        assertTrue(tm.getSwitchPorts().get((long)1).size()==1);
-        assertTrue(tm.getSwitchPorts().get((long)2).size()==1);
+        tm.removeLink(DatapathId.of(1), OFPort.of(2), DatapathId.of(2), OFPort.of(2));
+        assertTrue(tm.getSwitchPorts().get(DatapathId.of(1)).size()==1);
+        assertTrue(tm.getSwitchPorts().get(DatapathId.of(2)).size()==1);
         assertTrue(tm.getSwitchPorts().size() == 2);
         assertTrue(tm.getSwitchPortLinks().size()==2);
         assertTrue(tm.getPortBroadcastDomainLinks().size()==0);
 
-        tm.removeLink(DatapathId.of(1), OFPort.of((short)1), DatapathId.of(2), OFPort.of((short)1));
+        tm.removeLink(DatapathId.of(1), OFPort.of(1), DatapathId.of(2), OFPort.of(1));
         assertTrue(tm.getSwitchPorts().size() == 0);
         assertTrue(tm.getSwitchPortLinks().size()==0);
         assertTrue(tm.getPortBroadcastDomainLinks().size()==0);
@@ -84,41 +90,41 @@ public class TopologyManagerTest extends FloodlightTestCase {
 
     @Test
     public void testBasic2() throws Exception {
-        tm.addOrUpdateLink(DatapathId.of(1), OFPort.of((short)1), DatapathId.of(2), OFPort.of((short)1), ILinkDiscovery.LinkType.DIRECT_LINK);
-        tm.addOrUpdateLink(DatapathId.of(2), OFPort.of((short)2), DatapathId.of(3), OFPort.of((short)1), ILinkDiscovery.LinkType.MULTIHOP_LINK);
+        tm.addOrUpdateLink(DatapathId.of(1), OFPort.of(1), DatapathId.of(2), OFPort.of(1), ILinkDiscovery.LinkType.DIRECT_LINK);
+        tm.addOrUpdateLink(DatapathId.of(2), OFPort.of(2), DatapathId.of(3), OFPort.of(1), ILinkDiscovery.LinkType.MULTIHOP_LINK);
         assertTrue(tm.getSwitchPorts().size() == 3);  // for two nodes.
-        assertTrue(tm.getSwitchPorts().get((long)1).size()==1);
-        assertTrue(tm.getSwitchPorts().get((long)2).size()==2);
-        assertTrue(tm.getSwitchPorts().get((long)3).size()==1);
+        assertTrue(tm.getSwitchPorts().get(DatapathId.of(1)).size()==1);
+        assertTrue(tm.getSwitchPorts().get(DatapathId.of(2)).size()==2);
+        assertTrue(tm.getSwitchPorts().get(DatapathId.of(3)).size()==1);
         assertTrue(tm.getSwitchPortLinks().size()==4);
         assertTrue(tm.getPortBroadcastDomainLinks().size()==2);
 
-        tm.removeLink(DatapathId.of(1), OFPort.of((short)1), DatapathId.of(2), OFPort.of((short)1));
+        tm.removeLink(DatapathId.of(1), OFPort.of(1), DatapathId.of(2), OFPort.of(1));
         assertTrue(tm.getSwitchPorts().size() == 2);
-        assertTrue(tm.getSwitchPorts().get((long)1) == null);
-        assertTrue(tm.getSwitchPorts().get((long)2).size()==1);
-        assertTrue(tm.getSwitchPorts().get((long)3).size()==1);
+        assertTrue(tm.getSwitchPorts().get(DatapathId.of(1)) == null);
+        assertTrue(tm.getSwitchPorts().get(DatapathId.of(2)).size()==1);
+        assertTrue(tm.getSwitchPorts().get(DatapathId.of(3)).size()==1);
         assertTrue(tm.getSwitchPortLinks().size()==2);
         assertTrue(tm.getPortBroadcastDomainLinks().size()==2);
 
         // nonexistent link // no null pointer exceptions.
-        tm.removeLink(DatapathId.of(3), OFPort.of((short)1), DatapathId.of(2), OFPort.of((short)2));
+        tm.removeLink(DatapathId.of(3), OFPort.of(1), DatapathId.of(2), OFPort.of(2));
         assertTrue(tm.getSwitchPorts().size() == 2);
-        assertTrue(tm.getSwitchPorts().get((long)1) == null);
-        assertTrue(tm.getSwitchPorts().get((long)2).size()==1);
-        assertTrue(tm.getSwitchPorts().get((long)3).size()==1);
+        assertTrue(tm.getSwitchPorts().get(DatapathId.of(1)) == null);
+        assertTrue(tm.getSwitchPorts().get(DatapathId.of(2)).size()==1);
+        assertTrue(tm.getSwitchPorts().get(DatapathId.of(3)).size()==1);
         assertTrue(tm.getSwitchPortLinks().size()==2);
         assertTrue(tm.getPortBroadcastDomainLinks().size()==2);
 
-        tm.removeLink(DatapathId.of(3), OFPort.of((short)2), DatapathId.of(1), OFPort.of((short)2));
+        tm.removeLink(DatapathId.of(3), OFPort.of(2), DatapathId.of(1), OFPort.of(2));
         assertTrue(tm.getSwitchPorts().size() == 2);
-        assertTrue(tm.getSwitchPorts().get((long)1)==null);
-        assertTrue(tm.getSwitchPorts().get((long)2).size()==1);
-        assertTrue(tm.getSwitchPorts().get((long)3).size()==1);
+        assertTrue(tm.getSwitchPorts().get(DatapathId.of(1))==null);
+        assertTrue(tm.getSwitchPorts().get(DatapathId.of(2)).size()==1);
+        assertTrue(tm.getSwitchPorts().get(DatapathId.of(3)).size()==1);
         assertTrue(tm.getSwitchPortLinks().size()==2);
         assertTrue(tm.getPortBroadcastDomainLinks().size()==2);
 
-        tm.removeLink(DatapathId.of(2), OFPort.of((short)2), DatapathId.of(3), OFPort.of((short)1));
+        tm.removeLink(DatapathId.of(2), OFPort.of(2), DatapathId.of(3), OFPort.of(1));
         assertTrue(tm.getSwitchPorts().size() == 0);  // for two nodes.
         assertTrue(tm.getSwitchPortLinks().size()==0);
         assertTrue(tm.getPortBroadcastDomainLinks().size()==0);
diff --git a/src/test/java/net/floodlightcontroller/virtualnetwork/VirtualNetworkFilterTest.java b/src/test/java/net/floodlightcontroller/virtualnetwork/VirtualNetworkFilterTest.java
index 2eafde2369fcc60d7467fab673388743b153d199..466776fceb897e2391ae8a2916c8160a0c2e9bc2 100644
--- a/src/test/java/net/floodlightcontroller/virtualnetwork/VirtualNetworkFilterTest.java
+++ b/src/test/java/net/floodlightcontroller/virtualnetwork/VirtualNetworkFilterTest.java
@@ -45,6 +45,10 @@ import net.floodlightcontroller.core.IOFSwitch;
 import net.floodlightcontroller.core.module.FloodlightModuleContext;
 import net.floodlightcontroller.core.test.MockThreadPoolService;
 import net.floodlightcontroller.core.test.PacketFactory;
+import net.floodlightcontroller.debugcounter.IDebugCounterService;
+import net.floodlightcontroller.debugcounter.MockDebugCounterService;
+import net.floodlightcontroller.debugevent.IDebugEventService;
+import net.floodlightcontroller.debugevent.MockDebugEventService;
 import net.floodlightcontroller.devicemanager.IDeviceService;
 import net.floodlightcontroller.devicemanager.IEntityClassifierService;
 import net.floodlightcontroller.devicemanager.internal.DefaultEntityClassifier;
@@ -124,6 +128,8 @@ public class VirtualNetworkFilterTest extends FloodlightTestCase {
         fmc.addService(IEntityClassifierService.class, entityClassifier);
         fmc.addService(ITopologyService.class, topology);
         fmc.addService(ISyncService.class, mockSyncService);
+        fmc.addService(IDebugCounterService.class, new MockDebugCounterService());
+        fmc.addService(IDebugEventService.class, new MockDebugEventService());
         tps.init(fmc);
         frm.init(fmc);
         deviceService.init(fmc);
@@ -167,7 +173,6 @@ public class VirtualNetworkFilterTest extends FloodlightTestCase {
         mac1ToMac2PacketIntestPacketSerialized = mac1ToMac2PacketIntestPacket.serialize();
         mac1ToMac2PacketIn = OFFactories.getFactory(OFVersion.OF_13).buildPacketIn()
                         .setBufferId(OFBufferId.NO_BUFFER)
-                        .setInPort(OFPort.of(1))
                         .setData(mac1ToMac2PacketIntestPacketSerialized)
                         .setReason(OFPacketInReason.NO_MATCH)
                         .build();
@@ -188,7 +193,6 @@ public class VirtualNetworkFilterTest extends FloodlightTestCase {
         mac1ToMac4PacketIntestPacketSerialized = mac1ToMac4PacketIntestPacket.serialize(); 
         mac1ToMac4PacketIn = OFFactories.getFactory(OFVersion.OF_13).buildPacketIn()
                     .setBufferId(OFBufferId.NO_BUFFER)
-                    .setInPort(OFPort.of(1))
                     .setData(mac1ToMac4PacketIntestPacketSerialized)
                     .setReason(OFPacketInReason.NO_MATCH)
                     .build();
@@ -209,7 +213,6 @@ public class VirtualNetworkFilterTest extends FloodlightTestCase {
         mac1ToGwPacketIntestPacketSerialized = mac1ToGwPacketIntestPacket.serialize();
         mac1ToGwPacketIn =  OFFactories.getFactory(OFVersion.OF_13).buildPacketIn()
                     .setBufferId(OFBufferId.NO_BUFFER)
-                    .setInPort(OFPort.of(1))
                     .setData(mac1ToGwPacketIntestPacketSerialized)
                     .setReason(OFPacketInReason.NO_MATCH)
                     .build();
diff --git a/src/test/java/org/sdnplatform/sync/client/ClientTest.java b/src/test/java/org/sdnplatform/sync/client/ClientTest.java
index a4182ad3895c63e5ef19021f920753782d2af7e7..bd64765778508d395db61f1f3e230ece844120a8 100644
--- a/src/test/java/org/sdnplatform/sync/client/ClientTest.java
+++ b/src/test/java/org/sdnplatform/sync/client/ClientTest.java
@@ -8,10 +8,15 @@ import java.io.PrintStream;
 import java.util.ArrayList;
 
 import net.floodlightcontroller.core.module.FloodlightModuleContext;
+import net.floodlightcontroller.debugcounter.IDebugCounterService;
+import net.floodlightcontroller.debugcounter.MockDebugCounterService;
+import net.floodlightcontroller.debugevent.IDebugEventService;
+import net.floodlightcontroller.debugevent.MockDebugEventService;
 import net.floodlightcontroller.threadpool.IThreadPoolService;
 import net.floodlightcontroller.threadpool.ThreadPool;
 
 import com.fasterxml.jackson.databind.ObjectMapper;
+
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Rule;
@@ -30,6 +35,7 @@ public class ClientTest {
     protected SyncManager syncManager;
     protected final static ObjectMapper mapper = new ObjectMapper();
     protected String nodeString;
+    protected IDebugCounterService debugCounterService;
     ArrayList<Node> nodes;
     ThreadPool tp;
 
@@ -51,11 +57,15 @@ public class ClientTest {
         nodes.add(new Node("localhost", 40101, (short)1, (short)1));
         nodeString = mapper.writeValueAsString(nodes);
         
+        debugCounterService = new MockDebugCounterService();
+        
         tp = new ThreadPool();
         syncManager = new SyncManager();
         
         FloodlightModuleContext fmc = new FloodlightModuleContext();
         fmc.addService(IThreadPoolService.class, tp);
+        fmc.addService(IDebugCounterService.class, new MockDebugCounterService());
+        fmc.addService(IDebugEventService.class, new MockDebugEventService());
         
         fmc.addConfigParam(syncManager, "nodes", nodeString);
         fmc.addConfigParam(syncManager, "thisNode", ""+1);
diff --git a/src/test/java/org/sdnplatform/sync/internal/BootstrapTest.java b/src/test/java/org/sdnplatform/sync/internal/BootstrapTest.java
index d04cdaa4b8246d9c0b5a9217b924c46b082786ba..4aeb57ac9fd692fa07b8ab2dbe3659c47db2933a 100644
--- a/src/test/java/org/sdnplatform/sync/internal/BootstrapTest.java
+++ b/src/test/java/org/sdnplatform/sync/internal/BootstrapTest.java
@@ -2,7 +2,12 @@ package org.sdnplatform.sync.internal;
 
 import java.io.File;
 import java.util.ArrayList;
+
 import net.floodlightcontroller.core.module.FloodlightModuleContext;
+import net.floodlightcontroller.debugcounter.IDebugCounterService;
+import net.floodlightcontroller.debugcounter.MockDebugCounterService;
+import net.floodlightcontroller.debugevent.IDebugEventService;
+import net.floodlightcontroller.debugevent.MockDebugEventService;
 import net.floodlightcontroller.threadpool.IThreadPoolService;
 import net.floodlightcontroller.threadpool.ThreadPool;
 
@@ -59,6 +64,8 @@ public class BootstrapTest {
             syncManagers.add(syncManager);
 
             fmc.addService(IThreadPoolService.class, tp);
+            fmc.addService(IDebugCounterService.class, new MockDebugCounterService());
+            fmc.addService(IDebugEventService.class, new MockDebugEventService());
             String dbPath = 
                     new File(dbFolder.getRoot(), 
                              "server" + i).getAbsolutePath();
diff --git a/src/test/java/org/sdnplatform/sync/internal/SyncManagerTest.java b/src/test/java/org/sdnplatform/sync/internal/SyncManagerTest.java
index c9201b47948c498e35bbe36f7593019ade1c43c9..5bb874c269cf8e7b540180e661896d0797f4be9f 100644
--- a/src/test/java/org/sdnplatform/sync/internal/SyncManagerTest.java
+++ b/src/test/java/org/sdnplatform/sync/internal/SyncManagerTest.java
@@ -13,11 +13,16 @@ import java.util.List;
 import java.util.Map.Entry;
 
 import net.floodlightcontroller.core.module.FloodlightModuleContext;
+import net.floodlightcontroller.debugcounter.IDebugCounterService;
+import net.floodlightcontroller.debugcounter.MockDebugCounterService;
+import net.floodlightcontroller.debugevent.IDebugEventService;
+import net.floodlightcontroller.debugevent.MockDebugEventService;
 import net.floodlightcontroller.threadpool.IThreadPoolService;
 import net.floodlightcontroller.threadpool.ThreadPool;
 
 import com.fasterxml.jackson.core.type.TypeReference;
 import com.fasterxml.jackson.databind.ObjectMapper;
+
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Ignore;
@@ -68,6 +73,8 @@ public class SyncManagerTest {
                                     SyncManager syncManager, Node thisNode)
             throws Exception {        
         fmc.addService(IThreadPoolService.class, tp);
+        fmc.addService(IDebugCounterService.class, new MockDebugCounterService());
+        fmc.addService(IDebugEventService.class, new MockDebugEventService());
         fmc.addConfigParam(syncManager, "configProviders", 
                            PropertyCCProvider.class.getName());
         fmc.addConfigParam(syncManager, "nodes", nodeString);
diff --git a/src/test/java/org/sdnplatform/sync/internal/store/RemoteStoreTest.java b/src/test/java/org/sdnplatform/sync/internal/store/RemoteStoreTest.java
index 1ee7f8eefa3acbdf8ee4fa0f0b30a4fa5c424950..9ee89bae40420703d413cde266ce16c01c4db0c9 100644
--- a/src/test/java/org/sdnplatform/sync/internal/store/RemoteStoreTest.java
+++ b/src/test/java/org/sdnplatform/sync/internal/store/RemoteStoreTest.java
@@ -4,10 +4,15 @@ import java.util.ArrayList;
 import java.util.List;
 
 import net.floodlightcontroller.core.module.FloodlightModuleContext;
+import net.floodlightcontroller.debugcounter.IDebugCounterService;
+import net.floodlightcontroller.debugcounter.MockDebugCounterService;
+import net.floodlightcontroller.debugevent.IDebugEventService;
+import net.floodlightcontroller.debugevent.MockDebugEventService;
 import net.floodlightcontroller.threadpool.IThreadPoolService;
 import net.floodlightcontroller.threadpool.ThreadPool;
 
 import com.fasterxml.jackson.databind.ObjectMapper;
+
 import org.junit.After;
 import org.junit.Before;
 import org.sdnplatform.sync.ISyncService.Scope;
@@ -33,6 +38,8 @@ public class RemoteStoreTest extends AbstractStoreT<ByteArray,byte[]> {
         remoteSyncManager = new RemoteSyncManager();
 
         fmc.addService(IThreadPoolService.class, tp);
+        fmc.addService(IDebugCounterService.class, new MockDebugCounterService());
+        fmc.addService(IDebugEventService.class, new MockDebugEventService());
         fmc.addConfigParam(syncManager, "persistenceEnabled", "false");
         
         tp.init(fmc);