diff --git a/tests/flow_stats.py b/tests/flow_stats.py
index f7a8ad2..91c67a6 100644
--- a/tests/flow_stats.py
+++ b/tests/flow_stats.py
@@ -20,13 +20,13 @@
 from testutils import *
 from time import sleep
 
-#@var port_map Local copy of the configuration map from OF port
+#@var fs_port_map Local copy of the configuration map from OF port
 # numbers to OS interfaces
-pa_port_map = None
-#@var pa_logger Local logger object
-pa_logger = None
-#@var pa_config Local copy of global configuration data
-pa_config = None
+fs_port_map = None
+#@var fs_logger Local logger object
+fs_logger = None
+#@var fs_config Local copy of global configuration data
+fs_config = None
 
 # TODO: ovs has problems with VLAN id?
 WILDCARD_VALUES = [ofp.OFPFW_IN_PORT,
@@ -49,14 +49,14 @@
     @param config The configuration dictionary; see oft
     """
 
-    global pa_port_map
-    global pa_logger
-    global pa_config
+    global fs_port_map
+    global fs_logger
+    global fs_config
 
-    pa_logger = logging.getLogger("pkt_act")
-    pa_logger.info("Initializing test set")
-    pa_port_map = config["port_map"]
-    pa_config = config
+    fs_logger = logging.getLogger("flow_stats")
+    fs_logger.info("Initializing test set")
+    fs_port_map = config["port_map"]
+    fs_config = config
 
 class SingleFlowStats(basic.SimpleDataPlane):
     """
@@ -77,13 +77,13 @@
 
         all_packets_received = 0
         for i in range(0,test_timeout):
-            pa_logger.info("Sending stats request")
-            rv = self.controller.message_send(stat_req)
-            self.assertTrue(rv != -1, "Error sending flow stat req")
-            do_barrier(self.controller)
-
-            (response, raw) = self.controller.poll(ofp.OFPT_STATS_REPLY, 2)
-            self.assertTrue(len(response.stats) == 1, "Did not receive flow stats reply")
+            fs_logger.info("Sending stats request")
+            response, pkt = self.controller.transact(stat_req,
+                                                     timeout=test_timeout)
+            self.assertTrue(response is not None, 
+                            "No response to stats request")
+            self.assertTrue(len(response.stats) == 1,
+                            "Did not receive flow stats reply")
             for obj in response.stats:
                 # TODO: pad1 and pad2 fields may be nonzero, is this a bug?
                 # for now, just clear them so the assert is simpler
@@ -91,7 +91,7 @@
                 #obj.match.pad2 = [0, 0]
                 #self.assertEqual(match, obj.match,
                 #                 "Matches do not match")
-                pa_logger.info("Received " + str(obj.packet_count) + " packets")
+                fs_logger.info("Received " + str(obj.packet_count) + " packets")
                 if obj.packet_count == packet_count:
                     all_packets_received = 1
 
@@ -103,16 +103,16 @@
                         "Packet count does not match number sent")
 
     def runTest(self):
-        global pa_port_map
+        global fs_port_map
 
         # TODO: set from command-line parameter
         test_timeout = 60
 
-        of_ports = pa_port_map.keys()
+        of_ports = fs_port_map.keys()
         of_ports.sort()
         self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
 
-        rc = delete_all_flows(self.controller, pa_logger)
+        rc = delete_all_flows(self.controller, fs_logger)
         self.assertEqual(rc, 0, "Failed to delete all flows")
 
         # build packet
@@ -126,7 +126,7 @@
         # build flow
         ingress_port = of_ports[0];
         egress_port = of_ports[1];
-        pa_logger.info("Ingress " + str(ingress_port) + 
+        fs_logger.info("Ingress " + str(ingress_port) + 
                        " to egress " + str(egress_port))
         match.in_port = ingress_port
         flow_mod_msg = message.flow_mod()
@@ -139,7 +139,7 @@
         self.assertTrue(flow_mod_msg.actions.add(act), "Could not add action")
        
         # send flow
-        pa_logger.info("Inserting flow")
+        fs_logger.info("Inserting flow")
         rv = self.controller.message_send(flow_mod_msg)
         self.assertTrue(rv != -1, "Error installing flow mod")
         do_barrier(self.controller)
@@ -149,15 +149,15 @@
 
         # send packet N times
         num_sends = random.randint(10,20)
-        pa_logger.info("Sending " + str(num_sends) + " test packets")
+        fs_logger.info("Sending " + str(num_sends) + " test packets")
         for i in range(0,num_sends):
-            pa_logger.info("Sending packet to dp port " + 
+            fs_logger.info("Sending packet to dp port " + 
                            str(ingress_port))
             self.dataplane.send(ingress_port, str(pkt))
             (rcv_port, rcv_pkt, pkt_time) = self.dataplane.poll(timeout=
                                                                 test_timeout)
             self.assertTrue(rcv_pkt is not None, "Did not receive packet")
-            pa_logger.debug("Packet len " + str(len(pkt)) + " in on " + 
+            fs_logger.debug("Packet len " + str(len(pkt)) + " in on " + 
                             str(rcv_port))
             self.assertEqual(rcv_port, egress_port, "Unexpected receive port")
             for j in range(0,test_timeout):
@@ -204,19 +204,19 @@
         act.port = egress_port
         self.assertTrue(flow_mod_msg.actions.add(act), "Could not add action")
 
-        pa_logger.info("Ingress " + str(ingress_port) + 
+        fs_logger.info("Ingress " + str(ingress_port) + 
                        " to egress " + str(egress_port))
 
         return flow_mod_msg
 
     def sendPacket(self, pkt, ingress_port, egress_port, test_timeout):
-        pa_logger.info("Sending packet to dp port " + 
+        fs_logger.info("Sending packet to dp port " + 
                        str(ingress_port))
         self.dataplane.send(ingress_port, str(pkt))
         (rcv_port, rcv_pkt, pkt_time) = self.dataplane.poll(timeout=
                                                             test_timeout)
         self.assertTrue(rcv_pkt is not None, "Did not receive packet")
-        pa_logger.debug("Packet len " + str(len(pkt)) + " in on " + 
+        fs_logger.debug("Packet len " + str(len(pkt)) + " in on " + 
                         str(rcv_port))
         self.assertEqual(rcv_port, egress_port, "Unexpected receive port")
         for j in range(0,test_timeout):
@@ -234,12 +234,11 @@
 
         all_packets_received = 0
         for i in range(0,test_timeout):
-            pa_logger.info("Sending stats request")
-            rv = self.controller.message_send(stat_req)
-            self.assertTrue(rv != -1, "Error sending flow stat req")
-            do_barrier(self.controller)
-
-            (response, raw) = self.controller.poll(ofp.OFPT_STATS_REPLY, 2)
+            fs_logger.info("Sending stats request")
+            response, pkt = self.controller.transact(stat_req,
+                                                     timeout=test_timeout)
+            self.assertTrue(response is not None,
+                            "No response to stats request")
             self.assertTrue(len(response.stats) >= 1,
                             "Did not receive flow stats reply")
             total_packets = 0
@@ -250,7 +249,7 @@
                 #obj.match.pad2 = [0, 0]
                 #self.assertEqual(match, obj.match,
                 #                 "Matches do not match")
-                pa_logger.info("Received " + str(obj.packet_count) + " packets")
+                fs_logger.info("Received " + str(obj.packet_count) + " packets")
                 total_packets += obj.packet_count
             if total_packets == packet_count:
                 all_packets_received = 1
@@ -261,19 +260,19 @@
                         "Packet count does not match number sent")
 
     def runTest(self):
-        global pa_port_map
+        global fs_port_map
 
         # TODO: set from command-line parameter
         test_timeout = 60
 
-        of_ports = pa_port_map.keys()
+        of_ports = fs_port_map.keys()
         of_ports.sort()
         self.assertTrue(len(of_ports) >= 3, "Not enough ports for test")
         ingress_port = of_ports[0];
         egress_port1 = of_ports[1];
         egress_port2 = of_ports[2];
 
-        rc = delete_all_flows(self.controller, pa_logger)
+        rc = delete_all_flows(self.controller, fs_logger)
         self.assertEqual(rc, 0, "Failed to delete all flows")
 
         pkt1 = simple_tcp_packet()
@@ -282,18 +281,18 @@
         pkt2 = simple_tcp_packet(dl_src='0:7:7:7:7:7')
         flow_mod_msg2 = self.buildFlowModMsg(pkt2, ingress_port, egress_port2)
        
-        pa_logger.info("Inserting flow1")
+        fs_logger.info("Inserting flow1")
         rv = self.controller.message_send(flow_mod_msg1)
         self.assertTrue(rv != -1, "Error installing flow mod")
-        pa_logger.info("Inserting flow2")
+        fs_logger.info("Inserting flow2")
         rv = self.controller.message_send(flow_mod_msg2)
         self.assertTrue(rv != -1, "Error installing flow mod")
         do_barrier(self.controller)
 
         num_pkt1s = random.randint(10,30)
-        pa_logger.info("Sending " + str(num_pkt1s) + " pkt1s")
+        fs_logger.info("Sending " + str(num_pkt1s) + " pkt1s")
         num_pkt2s = random.randint(10,30)
-        pa_logger.info("Sending " + str(num_pkt2s) + " pkt2s")
+        fs_logger.info("Sending " + str(num_pkt2s) + " pkt2s")
         for i in range(0,num_pkt1s):
             self.sendPacket(pkt1, ingress_port, egress_port1, test_timeout)
         for i in range(0,num_pkt2s):
@@ -337,19 +336,19 @@
         act.port = egress_port
         self.assertTrue(flow_mod_msg.actions.add(act), "Could not add action")
 
-        pa_logger.info("Ingress " + str(ingress_port) + 
+        fs_logger.info("Ingress " + str(ingress_port) + 
                        " to egress " + str(egress_port))
 
         return flow_mod_msg
 
     def sendPacket(self, pkt, ingress_port, egress_port, test_timeout):
-        pa_logger.info("Sending packet to dp port " + 
+        fs_logger.info("Sending packet to dp port " + 
                        str(ingress_port))
         self.dataplane.send(ingress_port, str(pkt))
         (rcv_port, rcv_pkt, pkt_time) = self.dataplane.poll(timeout=
                                                             test_timeout)
         self.assertTrue(rcv_pkt is not None, "Did not receive packet")
-        pa_logger.debug("Packet len " + str(len(pkt)) + " in on " + 
+        fs_logger.debug("Packet len " + str(len(pkt)) + " in on " + 
                         str(rcv_port))
         self.assertEqual(rcv_port, egress_port, "Unexpected receive port")
         for j in range(0,test_timeout):
@@ -368,19 +367,18 @@
 
         all_packets_received = 0
         for i in range(0,test_timeout):
-            pa_logger.info("Sending stats request")
-            rv = self.controller.message_send(stat_req)
-            self.assertTrue(rv != -1, "Error sending flow stat req")
-            do_barrier(self.controller)
-
-            (response, raw) = self.controller.poll(ofp.OFPT_STATS_REPLY, 2)
+            fs_logger.info("Sending stats request")
+            response, pkt = self.controller.transact(stat_req,
+                                                     timeout=test_timeout)
+            self.assertTrue(response is not None, 
+                            "No response to stats request")
             self.assertTrue(len(response.stats) == 1, 
                             "Did not receive flow stats reply")
             for obj in response.stats:
                 self.assertTrue(obj.flow_count == flow_count,
                                 "Flow count " + str(obj.flow_count) +
                                 " does not match expected " + str(flow_count))
-                pa_logger.info("Received " + str(obj.packet_count) + " packets")
+                fs_logger.info("Received " + str(obj.packet_count) + " packets")
                 if obj.packet_count == packet_count:
                     all_packets_received = 1
 
@@ -392,19 +390,19 @@
                         "Packet count does not match number sent")
 
     def runTest(self):
-        global pa_port_map
+        global fs_port_map
 
         # TODO: set from command-line parameter
         test_timeout = 60
 
-        of_ports = pa_port_map.keys()
+        of_ports = fs_port_map.keys()
         of_ports.sort()
         self.assertTrue(len(of_ports) >= 3, "Not enough ports for test")
         ingress_port = of_ports[0];
         egress_port1 = of_ports[1];
         egress_port2 = of_ports[2];
 
-        rc = delete_all_flows(self.controller, pa_logger)
+        rc = delete_all_flows(self.controller, fs_logger)
         self.assertEqual(rc, 0, "Failed to delete all flows")
 
         pkt1 = simple_tcp_packet()
@@ -413,18 +411,18 @@
         pkt2 = simple_tcp_packet(dl_src='0:7:7:7:7:7')
         flow_mod_msg2 = self.buildFlowModMsg(pkt2, ingress_port, egress_port2)
        
-        pa_logger.info("Inserting flow1")
+        fs_logger.info("Inserting flow1")
         rv = self.controller.message_send(flow_mod_msg1)
         self.assertTrue(rv != -1, "Error installing flow mod")
-        pa_logger.info("Inserting flow2")
+        fs_logger.info("Inserting flow2")
         rv = self.controller.message_send(flow_mod_msg2)
         self.assertTrue(rv != -1, "Error installing flow mod")
         do_barrier(self.controller)
 
         num_pkt1s = random.randint(10,30)
-        pa_logger.info("Sending " + str(num_pkt1s) + " pkt1s")
+        fs_logger.info("Sending " + str(num_pkt1s) + " pkt1s")
         num_pkt2s = random.randint(10,30)
-        pa_logger.info("Sending " + str(num_pkt2s) + " pkt2s")
+        fs_logger.info("Sending " + str(num_pkt2s) + " pkt2s")
         for i in range(0,num_pkt1s):
             self.sendPacket(pkt1, ingress_port, egress_port1, test_timeout)
         for i in range(0,num_pkt2s):
