diff --git a/src/main/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImpl.java b/src/main/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImpl.java
index cb867d59533860d1a5cc0b1b8956a5edb0f62af5..acefd38da967efede69ac45cb00318a5295eac8a 100755
--- a/src/main/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImpl.java
+++ b/src/main/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImpl.java
@@ -1151,9 +1151,9 @@ public class DeviceManagerImpl implements IDeviceService, IOFMessageListener, IT
 
 	protected Command processPacketInMessage(IOFSwitch sw, OFPacketIn pi, FloodlightContext cntx) {
 		Ethernet eth = IFloodlightProviderService.bcStore.get(cntx,IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
-
+		OFPort inPort = (pi.getVersion().compareTo(OFVersion.OF_12) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT));
 		// Extract source entity information
-		Entity srcEntity = getSourceEntityFromPacket(eth, sw.getId(), (pi.getVersion().compareTo(OFVersion.OF_13) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT)));
+		Entity srcEntity = getSourceEntityFromPacket(eth, sw.getId(), inPort);
 		if (srcEntity == null) {
 			cntInvalidSource.increment();
 			return Command.STOP;
@@ -1165,7 +1165,7 @@ public class DeviceManagerImpl implements IDeviceService, IOFMessageListener, IT
 		// the IP to MAC mapping of the VRRP IP address.  The source
 		// entity will not have that information.  Hence, a separate call
 		// to learn devices in such cases.
-		learnDeviceFromArpResponseData(eth, sw.getId(), (pi.getVersion().compareTo(OFVersion.OF_13) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT)));
+		learnDeviceFromArpResponseData(eth, sw.getId(), inPort);
 
 		// Learn/lookup device information
 		Device srcDevice = learnDeviceByEntity(srcEntity);
@@ -1198,7 +1198,7 @@ public class DeviceManagerImpl implements IDeviceService, IOFMessageListener, IT
 		if (logger.isTraceEnabled()) {
 			logger.trace("Received PI: {} on switch {}, port {} *** eth={}" +
 					" *** srcDev={} *** dstDev={} *** ",
-					new Object[] { pi, sw.getId().toString(), (pi.getVersion().compareTo(OFVersion.OF_13) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT)), eth,
+					new Object[] { pi, sw.getId().toString(), inPort, eth,
 					srcDevice, dstDevice });
 		}
 
diff --git a/src/main/java/net/floodlightcontroller/firewall/AllowDropPair.java b/src/main/java/net/floodlightcontroller/firewall/AllowDropPair.java
index 719e067b9633eb4145dafb23ee1d725c424bd9bc..e769fadfb8425ae4da6c45e5ca40c458b1ff631a 100644
--- a/src/main/java/net/floodlightcontroller/firewall/AllowDropPair.java
+++ b/src/main/java/net/floodlightcontroller/firewall/AllowDropPair.java
@@ -17,6 +17,7 @@
 
 package net.floodlightcontroller.firewall;
 
+import org.projectfloodlight.openflow.protocol.OFFactory;
 import org.projectfloodlight.openflow.protocol.match.Match;
 
 
@@ -25,4 +26,12 @@ public class AllowDropPair {
     //public int drop = OFMatch.OFPFW_ALL;
     public Match.Builder allow;
     public Match.Builder drop;
+    
+    @SuppressWarnings("unused")
+	private AllowDropPair() {};
+    
+    public AllowDropPair(OFFactory factory) {
+    	allow = factory.buildMatch();
+    	drop = factory.buildMatch();
+    }
 }
diff --git a/src/main/java/net/floodlightcontroller/firewall/Firewall.java b/src/main/java/net/floodlightcontroller/firewall/Firewall.java
index e95a7d4e47b10fd662b414f62ae2c2d61d0cb843..c500977586d42aa5f6c5ac45e1f27fb90e56d9be 100644
--- a/src/main/java/net/floodlightcontroller/firewall/Firewall.java
+++ b/src/main/java/net/floodlightcontroller/firewall/Firewall.java
@@ -27,6 +27,8 @@ import java.util.Map;
 import org.projectfloodlight.openflow.protocol.OFMessage;
 import org.projectfloodlight.openflow.protocol.OFPacketIn;
 import org.projectfloodlight.openflow.protocol.OFType;
+import org.projectfloodlight.openflow.protocol.OFVersion;
+import org.projectfloodlight.openflow.protocol.match.MatchField;
 import org.projectfloodlight.openflow.types.DatapathId;
 import org.projectfloodlight.openflow.types.EthType;
 import org.projectfloodlight.openflow.types.IPv4AddressWithMask;
@@ -65,6 +67,7 @@ import org.slf4j.LoggerFactory;
  * 
  * @author Amer Tahir
  * @edited KC Wang
+ * @edited Ryan Izard
  */
 public class Firewall implements IFirewallService, IOFMessageListener,
         IFloodlightModule {
@@ -455,7 +458,7 @@ public class Firewall implements IFirewallService, IOFMessageListener,
     protected RuleMatchPair matchWithRule(IOFSwitch sw, OFPacketIn pi, FloodlightContext cntx) {
         FirewallRule matched_rule = null;
         Ethernet eth = IFloodlightProviderService.bcStore.get(cntx, IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
-        AllowDropPair adp = new AllowDropPair();
+        AllowDropPair adp = new AllowDropPair(sw.getOFFactory());
 
         synchronized (rules) {
             Iterator<FirewallRule> iter = this.rules.iterator();
@@ -468,7 +471,7 @@ public class Firewall implements IFirewallService, IOFMessageListener,
                 // check if rule matches
                 // AllowDropPair adp's allow and drop matches will modified with what matches
                 // TODO @Ryan might need to re-init adp each time (look into later) 
-                if (rule.matchesThisPacket(sw.getId(), pi.getInPort(), eth, adp) == true) {
+                if (rule.matchesThisPacket(sw.getId(), (pi.getVersion().compareTo(OFVersion.OF_12) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT)), eth, adp) == true) {
                     matched_rule = rule;
                     break;
                 }
@@ -502,7 +505,8 @@ public class Firewall implements IFirewallService, IOFMessageListener,
 
     public Command processPacketInMessage(IOFSwitch sw, OFPacketIn pi, IRoutingDecision decision, FloodlightContext cntx) {
         Ethernet eth = IFloodlightProviderService.bcStore.get(cntx, IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
-
+        OFPort inPort = (pi.getVersion().compareTo(OFVersion.OF_12) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT));
+        
         // Allowing L2 broadcast + ARP broadcast request (also deny malformed
         // broadcasts -> L2 broadcast + L3 unicast)
         if (eth.isBroadcast() == true) {
@@ -517,7 +521,7 @@ public class Firewall implements IFirewallService, IOFMessageListener,
                     logger.trace("Allowing broadcast traffic for PacketIn={}", pi);
                 }
                                         
-                decision = new RoutingDecision(sw.getId(), pi.getInPort(), 
+                decision = new RoutingDecision(sw.getId(), inPort, 
                 		IDeviceService.fcStore.get(cntx, IDeviceService.CONTEXT_SRC_DEVICE),
                         IRoutingDecision.RoutingAction.MULTICAST);
                 decision.addToContext(cntx);
@@ -526,7 +530,7 @@ public class Firewall implements IFirewallService, IOFMessageListener,
                     logger.trace("Blocking malformed broadcast traffic for PacketIn={}", pi);
                 }
 
-                decision = new RoutingDecision(sw.getId(), pi.getInPort(),
+                decision = new RoutingDecision(sw.getId(), inPort,
                 		IDeviceService.fcStore.get(cntx, IDeviceService.CONTEXT_SRC_DEVICE),
                         IRoutingDecision.RoutingAction.DROP);
                 decision.addToContext(cntx);
@@ -552,7 +556,7 @@ public class Firewall implements IFirewallService, IOFMessageListener,
 
             // Drop the packet if we don't have a rule allowing or dropping it or if we explicitly drop it
             if (rule == null || rule.action == FirewallRule.FirewallAction.DROP) {
-                decision = new RoutingDecision(sw.getId(), pi.getInPort(), 
+                decision = new RoutingDecision(sw.getId(), inPort, 
                 		IDeviceService.fcStore.get(cntx, IDeviceService.CONTEXT_SRC_DEVICE), 
                 		IRoutingDecision.RoutingAction.DROP);
                 decision.setMatch(rmp.match);
@@ -566,7 +570,7 @@ public class Firewall implements IFirewallService, IOFMessageListener,
                 }
             // Found a rule and the rule is not a drop, so allow the packet
             } else {
-                decision = new RoutingDecision(sw.getId(), pi.getInPort(), 
+                decision = new RoutingDecision(sw.getId(), inPort, 
                 		IDeviceService.fcStore.get(cntx, IDeviceService.CONTEXT_SRC_DEVICE),
                         IRoutingDecision.RoutingAction.FORWARD_OR_FLOOD);
                 decision.setMatch(rmp.match);
diff --git a/src/main/java/net/floodlightcontroller/firewall/FirewallRule.java b/src/main/java/net/floodlightcontroller/firewall/FirewallRule.java
index b32d9c10ace35606a59447094f74585d58443f41..fdb3c1b278cb0fd322366507a5610f8ec4e32529 100644
--- a/src/main/java/net/floodlightcontroller/firewall/FirewallRule.java
+++ b/src/main/java/net/floodlightcontroller/firewall/FirewallRule.java
@@ -81,7 +81,7 @@ public class FirewallRule implements Comparable<FirewallRule> {
      * The default rule is to match on anything.
      */
     public FirewallRule() {
-        this.in_port = OFPort.ZERO; 
+        this.in_port = OFPort.ANY; 
         this.dl_src = MacAddress.NONE;
         this.nw_src_prefix_and_mask = IPv4AddressWithMask.NONE;
         //this.nw_src_maskbits = 0; 
diff --git a/src/main/java/net/floodlightcontroller/forwarding/Forwarding.java b/src/main/java/net/floodlightcontroller/forwarding/Forwarding.java
index 781cda91704b55f8c53548ba02ab49689e0db8b5..8788a41769f6ed6b4c7f7aed6ab03394a642b051 100644
--- a/src/main/java/net/floodlightcontroller/forwarding/Forwarding.java
+++ b/src/main/java/net/floodlightcontroller/forwarding/Forwarding.java
@@ -171,7 +171,7 @@ public class Forwarding extends ForwardingBase implements IFloodlightModule {
 	}
 
 	protected void doForwardFlow(IOFSwitch sw, OFPacketIn pi, FloodlightContext cntx, boolean requestFlowRemovedNotifn) {
-		OFPort inPort = (pi.getVersion().compareTo(OFVersion.OF_13) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT));
+		OFPort inPort = (pi.getVersion().compareTo(OFVersion.OF_12) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT));
 		// Check if we have the location of the destination
 		IDevice dstDevice = IDeviceService.fcStore.get(cntx, IDeviceService.CONTEXT_DST_DEVICE);
 
@@ -185,7 +185,7 @@ public class Forwarding extends ForwardingBase implements IFloodlightModule {
 			}
 			if (srcIsland == null) {
 				log.debug("No openflow island found for source {}/{}",
-						sw.getId().toString(), (pi.getVersion().compareTo(OFVersion.OF_13) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT)));
+						sw.getId().toString(), inPort);
 				return;
 			}
 
@@ -198,7 +198,7 @@ public class Forwarding extends ForwardingBase implements IFloodlightModule {
 				DatapathId dstIsland = topologyService.getL2DomainId(dstSwDpid);
 				if ((dstIsland != null) && dstIsland.equals(srcIsland)) {
 					on_same_island = true;
-					if ((sw.getId().equals(dstSwDpid)) && ((pi.getVersion().compareTo(OFVersion.OF_13) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT)).equals(dstDap.getPort()))) {
+					if (sw.getId().equals(dstSwDpid) && inPort.equals(dstDap.getPort())) {
 						on_same_if = true;
 					}
 					break;
@@ -219,7 +219,7 @@ public class Forwarding extends ForwardingBase implements IFloodlightModule {
 				if (log.isTraceEnabled()) {
 					log.trace("Both source and destination are on the same " +
 							"switch/port {}/{}, Action = NOP",
-							sw.toString(), (pi.getVersion().compareTo(OFVersion.OF_13) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT)));
+							sw.toString(), inPort);
 				}
 				return;
 			}
@@ -336,11 +336,12 @@ public class Forwarding extends ForwardingBase implements IFloodlightModule {
 							"out message to the switch",
 							recommendation=LogMessageDoc.CHECK_SWITCH)
 	protected void doFlood(IOFSwitch sw, OFPacketIn pi, FloodlightContext cntx) {
-		if (topologyService.isIncomingBroadcastAllowed(sw.getId(), (pi.getVersion().compareTo(OFVersion.OF_13) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT))) == false) {
+		OFPort inPort = (pi.getVersion().compareTo(OFVersion.OF_12) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT));
+		if (topologyService.isIncomingBroadcastAllowed(sw.getId(), inPort) == false) {
 			if (log.isTraceEnabled()) {
 				log.trace("doFlood, drop broadcast packet, pi={}, " +
 						"from a blocked port, srcSwitch=[{},{}], linkInfo={}",
-						new Object[] {pi, sw.getId(), (pi.getVersion().compareTo(OFVersion.OF_13) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT))});
+						new Object[] {pi, sw.getId(), inPort});
 			}
 			return;
 		}
@@ -357,7 +358,7 @@ public class Forwarding extends ForwardingBase implements IFloodlightModule {
 
 		// set buffer-id, in-port and packet-data based on packet-in
 		pob.setBufferId(OFBufferId.NO_BUFFER);
-		pob.setInPort((pi.getVersion().compareTo(OFVersion.OF_13) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT)));
+		pob.setInPort(inPort);
 		pob.setData(pi.getData());
 
 		try {
diff --git a/src/main/java/net/floodlightcontroller/hub/Hub.java b/src/main/java/net/floodlightcontroller/hub/Hub.java
index ed5efe236d83ce6d617f63e6425d556458caa175..4d3ccf51389721223fa3de196081f54d74f84455 100644
--- a/src/main/java/net/floodlightcontroller/hub/Hub.java
+++ b/src/main/java/net/floodlightcontroller/hub/Hub.java
@@ -99,7 +99,7 @@ public class Hub implements IFloodlightModule, IOFMessageListener {
     private OFMessage createHubPacketOut(IOFSwitch sw, OFMessage msg) {
     	OFPacketIn pi = (OFPacketIn) msg;
         OFPacketOut.Builder pob = sw.getOFFactory().buildPacketOut();
-        pob.setBufferId(pi.getBufferId()).setXid(pi.getXid()).setInPort((pi.getVersion().compareTo(OFVersion.OF_13) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT)));
+        pob.setBufferId(pi.getBufferId()).setXid(pi.getXid()).setInPort((pi.getVersion().compareTo(OFVersion.OF_12) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT)));
 
         // set actions
         OFActionOutput.Builder actionBuilder = sw.getOFFactory().actions().buildOutput();
diff --git a/src/main/java/net/floodlightcontroller/learningswitch/LearningSwitch.java b/src/main/java/net/floodlightcontroller/learningswitch/LearningSwitch.java
index 89c15550bad0712ab8673e5cf9c0b2a2a5aad7d6..57b534086e27dec7af5bc3f2112c38f563edf61b 100644
--- a/src/main/java/net/floodlightcontroller/learningswitch/LearningSwitch.java
+++ b/src/main/java/net/floodlightcontroller/learningswitch/LearningSwitch.java
@@ -291,11 +291,13 @@ public class LearningSwitch
         if (pi == null) {
             return;
         }
+        
+        OFPort inPort = (pi.getVersion().compareTo(OFVersion.OF_12) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT));
 
         // The assumption here is (sw) is the switch that generated the
         // packet-in. If the input port is the same as output port, then
         // the packet-out should be ignored.
-        if ((pi.getVersion() == OFVersion.OF_10 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT)).equals(outport)) {
+        if (inPort.equals(outport)) {
             if (log.isDebugEnabled()) {
                 log.debug("Attempting to do packet-out to the same " +
                           "interface as packet-in. Dropping packet. " +
@@ -328,7 +330,7 @@ public class LearningSwitch
             pob.setBufferId(pi.getBufferId());
         }
 
-        pob.setInPort(pi.getVersion() == OFVersion.OF_10 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT));
+        pob.setInPort(inPort);
 
         // If the buffer id is none or the switch doesn's support buffering
         // we send the data with the packet out
@@ -361,7 +363,7 @@ public class LearningSwitch
 
         // Set buffer_id, in_port, actions_len
         pob.setBufferId(packetInMessage.getBufferId());
-        pob.setInPort(sw.getOFFactory().getVersion() == OFVersion.OF_10 ? packetInMessage.getInPort() : packetInMessage.getMatch().get(MatchField.IN_PORT));
+        pob.setInPort(packetInMessage.getVersion().compareTo(OFVersion.OF_12) < 0 ? packetInMessage.getInPort() : packetInMessage.getMatch().get(MatchField.IN_PORT));
 
         // set actions
         List<OFAction> actions = new ArrayList<OFAction>(1);
@@ -392,6 +394,7 @@ public class LearningSwitch
     private Command processPacketInMessage(IOFSwitch sw, OFPacketIn pi, FloodlightContext cntx) {
         // Read in packet data headers by using OFMatch
         Match m = pi.getMatch();
+        OFPort inPort = (pi.getVersion().compareTo(OFVersion.OF_12) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT));
         MacAddress sourceMac = m.get(MatchField.ETH_SRC);
         MacAddress destMac = m.get(MatchField.ETH_DST);
         OFVlanVidMatch vlan = m.get(MatchField.VLAN_VID);
@@ -415,7 +418,6 @@ public class LearningSwitch
         }
         if ((sourceMac.getLong() & 0x010000000000L) == 0) {
             // If source MAC is a unicast address, learn the port for this MAC/VLAN
-        	OFPort inPort = (pi.getVersion() == OFVersion.OF_10 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT));
             this.addToPortMap(sw, sourceMac, vlan.getVlanVid(), inPort);
         }
 
@@ -428,7 +430,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(m.get(MatchField.IN_PORT))) {
+        } else if (outPort.equals(inPort)) {
             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() });
@@ -470,7 +472,7 @@ public class LearningSwitch
             	}
             	mb2.setExact(MatchField.IN_PORT, outPort);
 
-            	this.writeFlowMod(sw, OFFlowModCommand.ADD, OFBufferId.NO_BUFFER, mb2.build(), m.get(MatchField.IN_PORT));
+            	this.writeFlowMod(sw, OFFlowModCommand.ADD, OFBufferId.NO_BUFFER, mb2.build(), inPort);
             }
         }
         return Command.CONTINUE;
diff --git a/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java b/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java
index 5ca1b5eb7adcc1456f6df195331461da8c76707a..edb512fb902370c4414710fe86d101eb565639fd 100644
--- a/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java
+++ b/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java
@@ -565,7 +565,7 @@ IFloodlightModule, IInfoProvider {
 			FloodlightContext cntx) {
 		Ethernet eth = IFloodlightProviderService.bcStore.get(cntx,
 				IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
-		OFPort inPort = (pi.getVersion().compareTo(OFVersion.OF_13) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT));
+		OFPort inPort = (pi.getVersion().compareTo(OFVersion.OF_12) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT));
 		if (eth.getPayload() instanceof BSN) {
 			BSN bsn = (BSN) eth.getPayload();
 			if (bsn == null) return Command.STOP;
@@ -595,7 +595,7 @@ IFloodlightModule, IInfoProvider {
 		}
 
 		// If packet-in is from a quarantine port, stop processing.
-		NodePortTuple npt = new NodePortTuple(sw, (pi.getVersion().compareTo(OFVersion.OF_13) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT)));
+		NodePortTuple npt = new NodePortTuple(sw, inPort);
 		if (quarantineQueue.contains(npt)) {
 			ctrQuarantineDrops.increment();
 			return Command.STOP;
diff --git a/src/main/java/net/floodlightcontroller/topology/TopologyManager.java b/src/main/java/net/floodlightcontroller/topology/TopologyManager.java
index b0a76e0634743f3a01d43aeff4d2793285aa6fab..f5473bee13c91e47ea756a975941e59b3f6ea621 100644
--- a/src/main/java/net/floodlightcontroller/topology/TopologyManager.java
+++ b/src/main/java/net/floodlightcontroller/topology/TopologyManager.java
@@ -924,14 +924,14 @@ public class TopologyManager implements IFloodlightModule, ITopologyService, IRo
 	protected Command dropFilter(DatapathId sw, OFPacketIn pi,
 			FloodlightContext cntx) {
 		Command result = Command.CONTINUE;
-		OFPort port = (pi.getVersion().compareTo(OFVersion.OF_13) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT));
+		OFPort inPort = (pi.getVersion().compareTo(OFVersion.OF_12) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT));
 
 		// If the input port is not allowed for data traffic, drop everything.
 		// BDDP packets will not reach this stage.
-		if (isAllowed(sw, port) == false) {
+		if (isAllowed(sw, inPort) == false) {
 			if (log.isTraceEnabled()) {
 				log.trace("Ignoring packet because of topology " +
-						"restriction on switch={}, port={}", sw.getLong(), port.getPortNumber());
+						"restriction on switch={}, port={}", sw.getLong(), inPort.getPortNumber());
 				result = Command.STOP;
 			}
 		}
@@ -1068,7 +1068,7 @@ public class TopologyManager implements IFloodlightModule, ITopologyService, IRo
 
 			// remove the incoming switch port
 			if (pinSwitch == sid) {
-				ports.remove((pi.getVersion() == OFVersion.OF_10 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT)));
+				ports.remove((pi.getVersion().compareTo(OFVersion.OF_12) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT)));
 			}
 
 			// we have all the switch ports to which we need to broadcast.
diff --git a/src/test/java/net/floodlightcontroller/firewall/FirewallTest.java b/src/test/java/net/floodlightcontroller/firewall/FirewallTest.java
index 169a977357e433a5126e1e10c078cd5e1c5a8048..245b369b0586fe523babfe5803716d601ea22b0d 100644
--- a/src/test/java/net/floodlightcontroller/firewall/FirewallTest.java
+++ b/src/test/java/net/floodlightcontroller/firewall/FirewallTest.java
@@ -29,6 +29,7 @@ import java.util.Map;
 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.packet.ARP;
 import net.floodlightcontroller.packet.Data;
@@ -94,6 +95,7 @@ public class FirewallTest extends FloodlightTestCase {
         DatapathId dpid = DatapathId.of(TestSwitch1DPID);
         sw = EasyMock.createNiceMock(IOFSwitch.class);
         expect(sw.getId()).andReturn(dpid).anyTimes();
+        expect(sw.getOFFactory()).andReturn(OFFactories.getFactory(OFVersion.OF_13)).anyTimes();
         replay(sw);
         // Load the switch map
         Map<DatapathId, IOFSwitch> switches = new HashMap<DatapathId, IOFSwitch>();
@@ -103,6 +105,7 @@ public class FirewallTest extends FloodlightTestCase {
         FloodlightModuleContext fmc = new FloodlightModuleContext();
         fmc.addService(IFloodlightProviderService.class,
                 mockFloodlightProvider);
+        fmc.addService(IOFSwitchService.class, mockSwitchManager);
         fmc.addService(IFirewallService.class, firewall);
         fmc.addService(IStorageSourceService.class, storageService);
         fmc.addService(IRestApiService.class, restApi);