diff --git a/src/python/loxi/of13/meter_band.py b/src/python/loxi/of13/meter_band.py
index 5573beb..9c7a23f 100644
--- a/src/python/loxi/of13/meter_band.py
+++ b/src/python/loxi/of13/meter_band.py
@@ -3,27 +3,36 @@
 # Copyright (c) 2012, 2013 Big Switch Networks, Inc.
 # See the file LICENSE.pyloxi which should have been included in the source distribution
 
-# Automatically generated by LOXI from template meter_band.py
+# Automatically generated by LOXI from template module.py
 # Do not modify
 
 import struct
+import loxi
 import const
+import common
+import action
+import instruction
+import oxm
+import action_id
+import instruction_id
+import meter_band
 import util
 import loxi.generic_util
-import loxi
 
-def unpack_list(reader):
-    def deserializer(reader, typ):
-        parser = parsers.get(typ)
-        if not parser: raise loxi.ProtocolError("unknown meter band type %d" % typ)
-        return parser(reader)
-    return loxi.generic_util.unpack_list_tlv16(reader, deserializer)
+class meter_band(loxi.OFObject):
+    subtypes = {}
 
-class MeterBand(object):
-    type = None # override in subclass
-    pass
+    @staticmethod
+    def unpack(reader):
+        subtype, = reader.peek('!H', 0)
+        try:
+            subclass = meter_band.subtypes[subtype]
+        except KeyError:
+            raise loxi.ProtocolError("unknown meter_band subtype %#x" % subtype)
+        return subclass.unpack(reader)
 
-class drop(MeterBand):
+
+class drop(meter_band):
     type = 1
 
     def __init__(self, rate=None, burst_size=None):
@@ -49,15 +58,13 @@
         return ''.join(packed)
 
     @staticmethod
-    def unpack(buf):
+    def unpack(reader):
         obj = drop()
-        if type(buf) == loxi.generic_util.OFReader:
-            reader = buf
-        else:
-            reader = loxi.generic_util.OFReader(buf)
         _type = reader.read("!H")[0]
         assert(_type == 1)
         _len = reader.read("!H")[0]
+        orig_reader = reader
+        reader = orig_reader.slice(_len - (2 + 2))
         obj.rate = reader.read("!L")[0]
         obj.burst_size = reader.read("!L")[0]
         reader.skip(4)
@@ -69,13 +76,6 @@
         if self.burst_size != other.burst_size: return False
         return True
 
-    def __ne__(self, other):
-        return not self.__eq__(other)
-
-    def show(self):
-        import loxi.pp
-        return loxi.pp.pp(self)
-
     def pretty_print(self, q):
         q.text("drop {")
         with q.group():
@@ -89,7 +89,9 @@
             q.breakable()
         q.text('}')
 
-class dscp_remark(MeterBand):
+meter_band.subtypes[1] = drop
+
+class dscp_remark(meter_band):
     type = 2
 
     def __init__(self, rate=None, burst_size=None, prec_level=None):
@@ -120,15 +122,13 @@
         return ''.join(packed)
 
     @staticmethod
-    def unpack(buf):
+    def unpack(reader):
         obj = dscp_remark()
-        if type(buf) == loxi.generic_util.OFReader:
-            reader = buf
-        else:
-            reader = loxi.generic_util.OFReader(buf)
         _type = reader.read("!H")[0]
         assert(_type == 2)
         _len = reader.read("!H")[0]
+        orig_reader = reader
+        reader = orig_reader.slice(_len - (2 + 2))
         obj.rate = reader.read("!L")[0]
         obj.burst_size = reader.read("!L")[0]
         obj.prec_level = reader.read("!B")[0]
@@ -142,13 +142,6 @@
         if self.prec_level != other.prec_level: return False
         return True
 
-    def __ne__(self, other):
-        return not self.__eq__(other)
-
-    def show(self):
-        import loxi.pp
-        return loxi.pp.pp(self)
-
     def pretty_print(self, q):
         q.text("dscp_remark {")
         with q.group():
@@ -165,7 +158,9 @@
             q.breakable()
         q.text('}')
 
-class experimenter(MeterBand):
+meter_band.subtypes[2] = dscp_remark
+
+class experimenter(meter_band):
     type = 65535
 
     def __init__(self, rate=None, burst_size=None, experimenter=None):
@@ -195,15 +190,13 @@
         return ''.join(packed)
 
     @staticmethod
-    def unpack(buf):
+    def unpack(reader):
         obj = experimenter()
-        if type(buf) == loxi.generic_util.OFReader:
-            reader = buf
-        else:
-            reader = loxi.generic_util.OFReader(buf)
         _type = reader.read("!H")[0]
         assert(_type == 65535)
         _len = reader.read("!H")[0]
+        orig_reader = reader
+        reader = orig_reader.slice(_len - (2 + 2))
         obj.rate = reader.read("!L")[0]
         obj.burst_size = reader.read("!L")[0]
         obj.experimenter = reader.read("!L")[0]
@@ -216,13 +209,6 @@
         if self.experimenter != other.experimenter: return False
         return True
 
-    def __ne__(self, other):
-        return not self.__eq__(other)
-
-    def show(self):
-        import loxi.pp
-        return loxi.pp.pp(self)
-
     def pretty_print(self, q):
         q.text("experimenter {")
         with q.group():
@@ -239,9 +225,6 @@
             q.breakable()
         q.text('}')
 
+meter_band.subtypes[65535] = experimenter
 
-parsers = {
-    const.OFPMBT_DROP : drop.unpack,
-    const.OFPMBT_DSCP_REMARK : dscp_remark.unpack,
-    const.OFPMBT_EXPERIMENTER : experimenter.unpack,
-}
+
