Hierarchical error messages plus some more tweaks

- hierarchical error messages for different error types
- renamed ofp_stats_types to ofp_stats_type
- renamed OFP_VENDOR to OFP_EXPERIMENTER in OF 1.0 input file
- use ofp_capabilities enum in of_features_reply
- use boolean type for l2_table_enable field in of_bsn_set_l2_table_(request|reply)
- return Set<OFActionType> for actions field in of_features_reply
- added DatapathId class that's returned for datapath_id field of of_features_reply
- removed unused read/write routines from OFBufferId
- added getOFVersioon method to factory classes/interfaces
- renamed OFPT_MULTIPART_(REQUEST|REPLY) to OFPT_STATS_(REQUEST|REPLY) in OF 1.3 input file
- renamed ofp_multipart_types to ofp_stats_type in OF 1.3 input file
- tweaked python backend to work with consistent use of of_stats_xyz vs. of_multipart_xyz in 1.3
diff --git a/java_gen/codegen.py b/java_gen/codegen.py
index d94d78a..776b8c5 100644
--- a/java_gen/codegen.py
+++ b/java_gen/codegen.py
@@ -50,7 +50,6 @@
         shutil.rmtree(basedir)
     os.makedirs(basedir)
     copy_prewrite_tree(basedir)
-    java_model.adjust_ir()
     gen = JavaGenerator(basedir)
     gen.create_of_interfaces()
     gen.create_of_classes()
diff --git a/java_gen/java_model.py b/java_gen/java_model.py
index f2a1c01..68c2316 100644
--- a/java_gen/java_model.py
+++ b/java_gen/java_model.py
@@ -46,97 +46,6 @@
 import java_gen.java_type as java_type
 from java_gen.java_type import erase_type_annotation
 
-# Key is modified name of error code; value is OFErrorType value string
-error_type_map = {}
-
-def adjust_ir():
-    """
-    For Java we change of_error_message to combine the 16-bit type and code
-    fields into a single 32-bit code field and we combine the per-error-type
-    code enums into a single ofp_error_code enum. This enables the generated
-    OFErrorMsg class to have a getCode method that can return all supported
-    error codes. Otherwise we'd need to do something like having per-error-type
-    subclasses of OFErrorMsg that had a getCode that returned the different
-    error codes for each error type, which would be less convenient for clients
-    and would also entail changing the LOXI OF input files and impacting other
-    language backends.
-    """
-    for version in of_g.target_version_list:
-        of_protocol = of_g.ir[version]
-        error_type = find(lambda e: e.name == "ofp_error_type", of_protocol.enums)
-        if error_type == None:
-            raise Exception("ofp_error_type enum not found; OF version: " + str(version))
-        error_code_entries = []
-        # For each error type value look up the corresponding error code enum.
-        # Add those values to the combined entries for the new ofp_error_code
-        # enum. The name of the new value is formed by concatenating the name
-        # of the error type value with the name of the old error code value.
-        for error_type_entry in error_type.entries:
-            # Strip off the OFPxx prefix
-            prefix_length = error_type_entry.name.find('_')
-            if prefix_length < 0:
-                raise Exception("OFPET prefix not found for ofp_error_type value " + error_type_entry.name + "; OF version: " + str(version))
-            error_type_entry_name = error_type_entry.name[prefix_length+1:]
-            if error_type_entry_name == "EXPERIMENTER":
-                # There isn't an error code enum defined for the experimenter error type
-                # FIXME: Need to add support for the message ofp_error_experimenter_msg format
-                continue
-            # The per-error-type code enums follow a naming conventions where
-            # the middle part of the enum name is the same as the name of the
-            # error type value (except lower-case).
-            error_code_enum_name = "ofp_" + error_type_entry_name.lower() + "_code"
-            # Look up the error code enum from the IR
-            error_code_enum = None
-            for i, enum in enumerate(of_protocol.enums):
-                if enum.name == error_code_enum_name:
-                    error_code_enum = enum
-                    # We don't want to generate code for the per-error-type
-                    # enum so remove it from the IR
-                    del of_protocol.enums[i]
-                    break
-            if error_code_enum == None:
-                raise Exception("Error code enum not found: " + error_code_enum_name + "; OF version: " + str(version))
-            for error_code_entry in error_code_enum.entries:
-                # Strip off the prefix from the entry name
-                prefix_length = error_code_entry.name.find('_')
-                if prefix_length < 0:
-                    raise Exception("Prefix not found for error code value " + error_code_entry.name + "; OF version: " + str(version))
-                error_code_entry_name = error_code_entry.name[prefix_length+1:]
-                # Combine the entry type name and the error code name
-                error_code_entry_name = error_type_entry_name + "_" + error_code_entry_name
-                # Combine the entry type value and the error code value
-                error_code_entry_value = (error_type_entry.value << 16) + error_code_entry.value
-                # Add the enum entry to the combined ofp_error_code
-                # Note that the "OFPEC" prefix is arbitrary. It will be stripped
-                # off again during Java code generation, but there needs to be
-                # some/any prefix
-                error_code_entries.append(OFEnumEntry("OFPEC_" + error_code_entry_name, error_code_entry_value, {}))
-                error_type_map[error_code_entry_name] = error_type_entry_name
-        # We've collected all of the entries. Now we can add the enum to the IR
-        of_protocol.enums.append(OFEnum("ofp_error_code", error_code_entries, {'wire_type': 'uint32_t'}))
-
-        # We also need to patch the of_error_msg class to combine the 16-bit error
-        # type and code fields into a single 32-bit error code field
-        error_msg = find(lambda c: c.name == "of_error_msg", of_protocol.classes)
-        if error_msg == None:
-            raise Exception("of_error_msg class not found; OF version: " + str(version))
-        err_type_index = None
-        for i, member in enumerate(error_msg.members):
-            if member.name == "err_type":
-                # Keep track of the error type index so we can remove it once
-                # we've finished iterating
-                err_type_index = i
-            elif member.name == 'code':
-                # Change the code to be a 32-bit ofp_error_code enum value
-                error_msg.members[i] = OFDataMember("code", "ofp_error_code")
-        if err_type_index == None:
-            raise Exception("err_type member of of_error_msg not found; OF version: " + str(version))
-        del error_msg.members[err_type_index]
-
-
-def gen_error_type(enum_entry):
-    return "OFErrorType." + error_type_map[enum_entry.name]
-
 class JavaModel(object):
     # registry for enums that should not be generated
     # set(${java_enum_name})
@@ -293,7 +202,6 @@
     enum_metadata_map = defaultdict(lambda: JavaModel.OFEnumMetadata((), None),
             OFPortFeatures = OFEnumMetadata((OFEnumPropertyMetadata("PortSpeed", java_type.port_speed, gen_port_speed),), None),
             OFPortState = OFEnumMetadata((OFEnumPropertyMetadata("StpState", java_type.boolean, gen_stp_state),), None),
-            OFErrorCode = OFEnumMetadata((OFEnumPropertyMetadata("ErrorType", java_type.error_type, gen_error_type),), None),
     )
 
     @property
@@ -570,6 +478,8 @@
             return ("", "OFStatsRequest", None)
         elif re.match(r'OF.+StatsReply$', self.name):
             return ("", "OFStatsReply", None)
+        elif re.match(r'OF.+ErrorMsg$', self.name):
+            return ("", "OFErrorMsg", None)
         elif re.match(r'OFFlow(Add|Modify(Strict)?|Delete(Strict)?)$', self.name):
             return ("", "OFFlowMod", None)
         elif loxi_utils.class_is_message(self.c_name) and re.match(r'OFBsn.+$', self.name) and self.name != "OFBsnHeader":
@@ -1119,10 +1029,7 @@
     def __init__(self, c_name, version_enum_map):
         self.c_name = c_name
 
-        if c_name == "of_stats_types":
-            self.name = "OFStatsType"
-        else:
-            self.name   = "OF" + java_type.name_c_to_caps_camel("_".join(c_name.split("_")[1:]))
+        self.name   = "OF" + java_type.name_c_to_caps_camel("_".join(c_name.split("_")[1:]))
 
         # Port_features has constants that start with digits
         self.name_prefix = "PF_" if self.name == "OFPortFeatures" else ""
diff --git a/java_gen/java_type.py b/java_gen/java_type.py
index 87ce9d6..d43daec 100644
--- a/java_gen/java_type.py
+++ b/java_gen/java_type.py
@@ -33,11 +33,12 @@
     else:
         return camel
 
-java_primitive_types = set("byte char short int long".split(" "))
+java_primitive_types = set("boolean byte char short int long".split(" "))
 
 ### info table about java primitive types, for casting literals in the source code
 # { name : (signed?, length_in_bits) }
 java_primitives_info = {
+        'boolean' : (False, 8),
         'byte' : (True, 8),
         'char' : (False, 16),
         'short' : (True, 16),
@@ -48,7 +49,7 @@
 def format_primitive_literal(t, value):
     """ Format a primitive numeric literal for inclusion in the
         java source code. Takes care of casting the literal
-        apropriately for correct representation despite Java's
+        appropriately for correct representation despite Java's
         signed-craziness
     """
     signed, bits = java_primitives_info[t]
@@ -384,7 +385,14 @@
 
 port_speed = JType("PortSpeed")
 error_type = JType("OFErrorType")
-boolean = JType("boolean").op(default="false")
+boolean = JType("boolean", "byte") \
+        .op(read='(bb.readByte() != 0)',
+            write='bb.writeByte($name ? 1 : 0)',
+            default="false")
+datapath_id = JType("DatapathId") \
+        .op(read='DatapathId.of(bb.readLong())',
+            write='bb.writeLong($name.getLong())',
+            default='DatapathId.NONE')
 
 generic_t = JType("T")
 
@@ -475,7 +483,9 @@
         'of_match_v1': { 'vlan_vid' : vlan_vid, 'vlan_pcp': vlan_pcp,
                 'eth_type': eth_type, 'ip_dscp': ip_dscp, 'ip_proto': ip_proto,
                 'tcp_src': transport_port, 'tcp_dst': transport_port
-                }
+                },
+        'of_bsn_set_l2_table_request': { 'l2_table_enable': boolean },
+        'of_bsn_set_l2_table_reply': { 'l2_table_enable': boolean },
 }
 
 
@@ -538,12 +548,25 @@
         return JType("OFActionType", 'short') \
             .op(read='bb.readShort()', write='bb.writeShort($name)', pub_type=False)\
             .op(read="OFActionTypeSerializerVer$version.readFrom(bb)", write="OFActionTypeSerializerVer$version.writeTo(bb, $name)", pub_type=True)
+    elif field_name == "err_type":
+        return JType("OFErrorType", 'short') \
+            .op(read='bb.readShort()', write='bb.writeShort($name)')
+    elif field_name == "stats_type":
+        return JType("OFStatsType", 'short') \
+            .op(read='bb.readShort()', write='bb.writeShort($name)')
     elif field_name == "version" and c_type == "uint8_t":
         return JType("OFVersion", 'byte') \
             .op(read='bb.readByte()', write='bb.writeByte($name)')
-    elif field_name == "buffer_id" and c_type == "uint32_t":
+    elif field_name == "buffer_id":
         return JType("OFBufferId") \
             .op(read="OFBufferId.of(bb.readInt())", write="bb.writeInt($name.getInt())", default="OFBufferId.NO_BUFFER")
+    elif field_name == 'datapath_id':
+        return datapath_id
+    elif field_name == 'actions' and obj_name == 'of_features_reply':
+        return JType("Set<OFActionType>") \
+            .op(read='ChannelUtilsVer10.readSupportedActions(bb)',
+                write='ChannelUtilsVer10.writeSupportedActions(bb, $name)',
+                default='ImmutableSet.<OFActionType>of()')
     elif c_type in default_mtype_to_jtype_convert_map:
         return default_mtype_to_jtype_convert_map[c_type]
     elif re.match(r'list\(of_([a-zA-Z_]+)_t\)', c_type):
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/ver10/ChannelUtilsVer10.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/ver10/ChannelUtilsVer10.java
index 7a42d20..3f2f23f 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/ver10/ChannelUtilsVer10.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/ver10/ChannelUtilsVer10.java
@@ -1,9 +1,13 @@
 package org.projectfloodlight.openflow.protocol.ver10;
 
+import java.util.EnumSet;
+import java.util.Set;
+
 import org.jboss.netty.buffer.ChannelBuffer;
 import org.projectfloodlight.openflow.exceptions.OFParseError;
 import org.projectfloodlight.openflow.protocol.match.Match;
 import org.projectfloodlight.openflow.protocol.ver10.OFMatchV1Ver10;
+import org.projectfloodlight.openflow.protocol.OFActionType;
 import org.projectfloodlight.openflow.protocol.OFBsnVportQInQ;
 
 /**
@@ -28,4 +32,63 @@
 
     }
 
+    public static Set<OFActionType> readSupportedActions(ChannelBuffer bb) {
+        int actions = bb.readInt();
+        EnumSet<OFActionType> supportedActions = EnumSet.noneOf(OFActionType.class);
+        if ((actions & (1 << OFActionTypeSerializerVer10.OUTPUT_VAL)) != 0)
+            supportedActions.add(OFActionType.OUTPUT);
+        if ((actions & (1 << OFActionTypeSerializerVer10.SET_VLAN_VID_VAL)) != 0)
+            supportedActions.add(OFActionType.SET_VLAN_VID);
+        if ((actions & (1 << OFActionTypeSerializerVer10.SET_VLAN_PCP_VAL)) != 0)
+            supportedActions.add(OFActionType.SET_VLAN_PCP);
+        if ((actions & (1 << OFActionTypeSerializerVer10.STRIP_VLAN_VAL)) != 0)
+            supportedActions.add(OFActionType.STRIP_VLAN);
+        if ((actions & (1 << OFActionTypeSerializerVer10.SET_DL_SRC_VAL)) != 0)
+            supportedActions.add(OFActionType.SET_DL_SRC);
+        if ((actions & (1 << OFActionTypeSerializerVer10.SET_DL_DST_VAL)) != 0)
+            supportedActions.add(OFActionType.SET_DL_DST);
+        if ((actions & (1 << OFActionTypeSerializerVer10.SET_NW_SRC_VAL)) != 0)
+            supportedActions.add(OFActionType.SET_NW_SRC);
+        if ((actions & (1 << OFActionTypeSerializerVer10.SET_NW_DST_VAL)) != 0)
+            supportedActions.add(OFActionType.SET_NW_DST);
+        if ((actions & (1 << OFActionTypeSerializerVer10.SET_NW_TOS_VAL)) != 0)
+            supportedActions.add(OFActionType.SET_NW_TOS);
+        if ((actions & (1 << OFActionTypeSerializerVer10.SET_TP_SRC_VAL)) != 0)
+            supportedActions.add(OFActionType.SET_TP_SRC);
+        if ((actions & (1 << OFActionTypeSerializerVer10.SET_TP_DST_VAL)) != 0)
+            supportedActions.add(OFActionType.SET_TP_DST);
+        if ((actions & (1 << OFActionTypeSerializerVer10.ENQUEUE_VAL)) != 0)
+            supportedActions.add(OFActionType.ENQUEUE);
+        return supportedActions;
+    }
+
+    public static void writeSupportedActions(ChannelBuffer bb,
+            Set<OFActionType> supportedActions) {
+        int supportedActionsVal = 0;
+        if (supportedActions.contains(OFActionType.OUTPUT))
+            supportedActionsVal |= (1 << OFActionTypeSerializerVer10.OUTPUT_VAL);
+        if (supportedActions.contains(OFActionType.SET_VLAN_VID))
+            supportedActionsVal |= (1 << OFActionTypeSerializerVer10.SET_VLAN_VID_VAL);
+        if (supportedActions.contains(OFActionType.SET_VLAN_PCP))
+            supportedActionsVal |= (1 << OFActionTypeSerializerVer10.SET_VLAN_PCP_VAL);
+        if (supportedActions.contains(OFActionType.STRIP_VLAN))
+            supportedActionsVal |= (1 << OFActionTypeSerializerVer10.STRIP_VLAN_VAL);
+        if (supportedActions.contains(OFActionType.SET_DL_SRC))
+            supportedActionsVal |= (1 << OFActionTypeSerializerVer10.SET_DL_SRC_VAL);
+        if (supportedActions.contains(OFActionType.SET_DL_DST))
+            supportedActionsVal |= (1 << OFActionTypeSerializerVer10.SET_DL_DST_VAL);
+        if (supportedActions.contains(OFActionType.SET_NW_SRC))
+            supportedActionsVal |= (1 << OFActionTypeSerializerVer10.SET_NW_SRC_VAL);
+        if (supportedActions.contains(OFActionType.SET_NW_DST))
+            supportedActionsVal |= (1 << OFActionTypeSerializerVer10.SET_NW_DST_VAL);
+        if (supportedActions.contains(OFActionType.SET_NW_TOS))
+            supportedActionsVal |= (1 << OFActionTypeSerializerVer10.SET_NW_TOS_VAL);
+        if (supportedActions.contains(OFActionType.SET_TP_SRC))
+            supportedActionsVal |= (1 << OFActionTypeSerializerVer10.SET_TP_SRC_VAL);
+        if (supportedActions.contains(OFActionType.SET_TP_DST))
+            supportedActionsVal |= (1 << OFActionTypeSerializerVer10.SET_TP_DST_VAL);
+        if (supportedActions.contains(OFActionType.ENQUEUE))
+            supportedActionsVal |= (1 << OFActionTypeSerializerVer10.ENQUEUE_VAL);
+        bb.writeInt(supportedActionsVal);
+    }
 }
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/DatapathId.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/DatapathId.java
new file mode 100644
index 0000000..aa7191a
--- /dev/null
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/DatapathId.java
@@ -0,0 +1,63 @@
+package org.projectfloodlight.openflow.types;
+
+import org.projectfloodlight.openflow.util.HexString;
+
+/**
+ * Abstraction of a datapath ID that can be set and/or accessed as either a
+ * long value or a colon-separated string.
+ * 
+ * @author Rob Vaterlaus <rob.vaterlaus@bigswitch.com>
+ */
+public class DatapathId {
+
+    public static final DatapathId NONE = new DatapathId(0);
+
+    private final long rawValue;
+
+    private DatapathId(long rawValue) {
+        this.rawValue = rawValue;
+    }
+
+    public static DatapathId of(long rawValue) {
+        return new DatapathId(rawValue);
+    }
+
+    public static DatapathId of(String s) {
+        return new DatapathId(HexString.toLong(s));
+    }
+
+    public long getLong() {
+        return rawValue;
+    }
+
+    public U64 getUnsignedLong() {
+        return U64.of(rawValue);
+    }
+
+    @Override
+    public String toString() {
+        return HexString.toHexString(rawValue);
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + (int) (rawValue ^ (rawValue >>> 32));
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        DatapathId other = (DatapathId) obj;
+        if (rawValue != other.rawValue)
+            return false;
+        return true;
+    }
+}
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/OFBufferId.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/OFBufferId.java
index 99f3e7f..1db309f 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/OFBufferId.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/OFBufferId.java
@@ -35,14 +35,6 @@
         return Long.toString(U32.f(rawValue));
     }
 
-    public void write4Bytes(ChannelBuffer c) {
-        c.writeInt(this.rawValue);
-    }
-
-    public static OFBufferId read4Bytes(ChannelBuffer c) throws OFParseError {
-        return OFBufferId.of(c.readInt());
-    }
-
     @Override
     public int hashCode() {
         final int prime = 31;
diff --git a/java_gen/templates/of_class.java b/java_gen/templates/of_class.java
index aa68d04..00c7019 100644
--- a/java_gen/templates/of_class.java
+++ b/java_gen/templates/of_class.java
@@ -354,6 +354,8 @@
         //:: for prop in msg.data_members:
         //:: if prop.java_type.pub_type == 'long':
         result = prime *  (int) (${prop.name} ^ (${prop.name} >>> 32));
+        //:: elif prop.java_type.pub_type == 'boolean':
+        result = prime * result + (${prop.name} ? 1231 : 1237);
         //:: elif prop.java_type.is_primitive:
         result = prime * result + ${prop.name};
         //:: elif prop.java_type.is_array:
diff --git a/java_gen/templates/of_factory_class.java b/java_gen/templates/of_factory_class.java
index 86b092a..7329fc2 100644
--- a/java_gen/templates/of_factory_class.java
+++ b/java_gen/templates/of_factory_class.java
@@ -42,6 +42,10 @@
     public final static ${factory.name} INSTANCE = new ${factory.name}();
     private ${factory.name}() {}
 
+    public OFVersion getOFVersion() {
+        return OFVersion.OF_${factory.version.of_version};
+    }
+
     //:: for name, clazz in factory.interface.sub_factories.items():
     public ${clazz} ${name}() {
         return ${clazz}Ver${factory.version.of_version}.INSTANCE;
diff --git a/java_gen/templates/of_factory_interface.java b/java_gen/templates/of_factory_interface.java
index 634362d..5cf4052 100644
--- a/java_gen/templates/of_factory_interface.java
+++ b/java_gen/templates/of_factory_interface.java
@@ -57,9 +57,10 @@
     Match.Builder buildMatch();
 //:: #endif
 
+    OFVersion getOFVersion();
     OFMessageReader<${factory.base_class}> getReader();
-
 //:: if factory.name == 'OFOxms':
+
     public <F extends OFValueType<F>> OFOxm<F> fromValue(F value, MatchField<F> field);
     public <F extends OFValueType<F>> OFOxm<F> fromValueAndMask(F value, F mask, MatchField<F> field);
     public <F extends OFValueType<F>> OFOxm<F> fromMasked(Masked<F> masked, MatchField<F> field);
diff --git a/openflow_input/standard-1.0 b/openflow_input/standard-1.0
index 1a23ce4..026fa60 100644
--- a/openflow_input/standard-1.0
+++ b/openflow_input/standard-1.0
@@ -66,7 +66,7 @@
     OFPT_ERROR = 1,
     OFPT_ECHO_REQUEST = 2,
     OFPT_ECHO_REPLY = 3,
-    OFPT_VENDOR = 4,
+    OFPT_EXPERIMENTER = 4,
     OFPT_FEATURES_REQUEST = 5,
     OFPT_FEATURES_REPLY = 6,
     OFPT_GET_CONFIG_REQUEST = 7,
@@ -214,7 +214,7 @@
     OFPSF_REPLY_MORE = 0x1,
 };
 
-enum ofp_stats_types(wire_type=uint16_t) {
+enum ofp_stats_type(wire_type=uint16_t) {
     OFPST_DESC = 0,
     OFPST_FLOW = 1,
     OFPST_AGGREGATE = 2,
@@ -407,7 +407,7 @@
     uint32_t n_buffers;
     uint8_t n_tables;
     pad(3);
-    uint32_t capabilities;
+    enum ofp_capabilities capabilities;
     uint32_t actions;
     list(of_port_desc_t) ports;
 };
@@ -698,8 +698,66 @@
     uint8_t type == 1;
     uint16_t length;
     uint32_t xid;
-    uint16_t err_type;
-    uint16_t code;
+    uint16_t err_type == ?;
+};
+
+struct of_hello_failed_error_msg : of_error_msg {
+    uint8_t version;
+    uint8_t type == 1;
+    uint16_t length;
+    uint32_t xid;
+    uint16_t err_type == 0;
+    enum ofp_hello_failed_code code;
+    of_octets_t data;
+};
+
+struct of_bad_request_error_msg : of_error_msg {
+    uint8_t version;
+    uint8_t type == 1;
+    uint16_t length;
+    uint32_t xid;
+    uint16_t err_type == 1;
+    enum ofp_bad_request_code code;
+    of_octets_t data;
+};
+
+struct of_bad_action_error_msg : of_error_msg {
+    uint8_t version;
+    uint8_t type == 1;
+    uint16_t length;
+    uint32_t xid;
+    uint16_t err_type == 2;
+    enum ofp_bad_action_code code;
+    of_octets_t data;
+};
+
+struct of_flow_mod_failed_error_msg : of_error_msg {
+    uint8_t version;
+    uint8_t type == 1;
+    uint16_t length;
+    uint32_t xid;
+    uint16_t err_type == 3;
+    enum ofp_flow_mod_failed_code code;
+    of_octets_t data;
+};
+
+struct of_port_mod_failed_error_msg : of_error_msg {
+    uint8_t version;
+    uint8_t type == 1;
+    uint16_t length;
+    uint32_t xid;
+    uint16_t err_type == 4;
+    enum ofp_port_mod_failed_code code;
+    of_octets_t data;
+};
+
+struct of_queue_op_failed_error_msg : of_error_msg {
+    uint8_t version;
+    uint8_t type == 1;
+    uint16_t length;
+    uint32_t xid;
+    uint16_t err_type == 5;
+    enum ofp_queue_op_failed_code code;
     of_octets_t data;
 };
 
diff --git a/openflow_input/standard-1.1 b/openflow_input/standard-1.1
index 937ac52..0b58b2d 100644
--- a/openflow_input/standard-1.1
+++ b/openflow_input/standard-1.1
@@ -386,7 +386,7 @@
     OFPSCFC_BAD_LEN = 1,
 };
 
-enum ofp_stats_types(wire_type=uint16_t) {
+enum ofp_stats_type(wire_type=uint16_t) {
     OFPST_DESC = 0,
     OFPST_FLOW = 1,
     OFPST_AGGREGATE = 2,
@@ -529,7 +529,7 @@
     uint32_t n_buffers;
     uint8_t n_tables;
     pad(3);
-    uint32_t capabilities;
+    enum ofp_capabilities capabilities;
     uint32_t reserved;
     list(of_port_desc_t) ports;
 };
@@ -1011,8 +1011,116 @@
     uint8_t type == 1;
     uint16_t length;
     uint32_t xid;
-    uint16_t err_type;
-    uint16_t code;
+    uint16_t err_type == ?;
+};
+
+struct of_hello_failed_error_msg : of_error_msg {
+    uint8_t version;
+    uint8_t type == 1;
+    uint16_t length;
+    uint32_t xid;
+    uint16_t err_type == 0;
+    enum ofp_hello_failed_code code;
+    of_octets_t data;
+};
+
+struct of_bad_request_error_msg : of_error_msg {
+    uint8_t version;
+    uint8_t type == 1;
+    uint16_t length;
+    uint32_t xid;
+    uint16_t err_type == 1;
+    enum ofp_bad_request_code code;
+    of_octets_t data;
+};
+
+struct of_bad_action_error_msg : of_error_msg {
+    uint8_t version;
+    uint8_t type == 1;
+    uint16_t length;
+    uint32_t xid;
+    uint16_t err_type == 2;
+    enum ofp_bad_action_code code;
+    of_octets_t data;
+};
+
+struct of_bad_instruction_error_msg : of_error_msg {
+    uint8_t version;
+    uint8_t type == 1;
+    uint16_t length;
+    uint32_t xid;
+    uint16_t err_type == 3;
+    enum ofp_bad_instruction_code code;
+    of_octets_t data;
+};
+
+struct of_bad_match_error_msg : of_error_msg {
+    uint8_t version;
+    uint8_t type == 1;
+    uint16_t length;
+    uint32_t xid;
+    uint16_t err_type == 4;
+    enum ofp_bad_match_code code;
+    of_octets_t data;
+};
+
+struct of_flow_mod_failed_error_msg : of_error_msg {
+    uint8_t version;
+    uint8_t type == 1;
+    uint16_t length;
+    uint32_t xid;
+    uint16_t err_type == 5;
+    enum ofp_flow_mod_failed_code code;
+    of_octets_t data;
+};
+
+struct of_group_mod_failed_error_msg : of_error_msg {
+    uint8_t version;
+    uint8_t type == 1;
+    uint16_t length;
+    uint32_t xid;
+    uint16_t err_type == 6;
+    enum ofp_group_mod_failed_code code;
+    of_octets_t data;
+};
+
+struct of_port_mod_failed_error_msg : of_error_msg {
+    uint8_t version;
+    uint8_t type == 1;
+    uint16_t length;
+    uint32_t xid;
+    uint16_t err_type == 7;
+    enum ofp_port_mod_failed_code code;
+    of_octets_t data;
+};
+
+struct of_table_mod_failed_error_msg : of_error_msg {
+    uint8_t version;
+    uint8_t type == 1;
+    uint16_t length;
+    uint32_t xid;
+    uint16_t err_type == 8;
+    enum ofp_table_mod_failed_code code;
+    of_octets_t data;
+};
+
+struct of_queue_op_failed_error_msg : of_error_msg {
+    uint8_t version;
+    uint8_t type == 1;
+    uint16_t length;
+    uint32_t xid;
+    uint16_t err_type == 9;
+    enum ofp_queue_op_failed_code code;
+    of_octets_t data;
+};
+
+struct of_switch_config_failed_error_msg : of_error_msg {
+    uint8_t version;
+    uint8_t type == 1;
+    uint16_t length;
+    uint32_t xid;
+    uint16_t err_type == 10;
+    enum ofp_switch_config_failed_code code;
     of_octets_t data;
 };
 
diff --git a/openflow_input/standard-1.2 b/openflow_input/standard-1.2
index e8f95ee..589d7bf 100644
--- a/openflow_input/standard-1.2
+++ b/openflow_input/standard-1.2
@@ -410,7 +410,7 @@
     OFPRRFC_BAD_ROLE = 2,
 };
 
-enum ofp_stats_types(wire_type=uint16_t) {
+enum ofp_stats_type(wire_type=uint16_t) {
     OFPST_DESC = 0,
     OFPST_FLOW = 1,
     OFPST_AGGREGATE = 2,
@@ -569,7 +569,7 @@
     uint32_t n_buffers;
     uint8_t n_tables;
     pad(3);
-    uint32_t capabilities;
+    enum ofp_capabilities capabilities;
     uint32_t reserved;
     list(of_port_desc_t) ports;
 };
@@ -954,21 +954,139 @@
     uint8_t type == 1;
     uint16_t length;
     uint32_t xid;
-    uint16_t err_type;
-    uint16_t code;
+    uint16_t err_type == ?;
+};
+
+struct of_hello_failed_error_msg : of_error_msg {
+    uint8_t version;
+    uint8_t type == 1;
+    uint16_t length;
+    uint32_t xid;
+    uint16_t err_type == 0;
+    enum ofp_hello_failed_code code;
     of_octets_t data;
 };
 
-// struct of_error_experimenter_msg {
-//    uint8_t version;
-//    uint8_t type;
-//    uint16_t length;
-//    uint32_t xid;
-//    uint16_t err_type;
-//    uint16_t subtype;
-//    uint32_t experimenter;
-//    of_octets_t data;
-//};
+struct of_bad_request_error_msg : of_error_msg {
+    uint8_t version;
+    uint8_t type == 1;
+    uint16_t length;
+    uint32_t xid;
+    uint16_t err_type == 1;
+    enum ofp_bad_request_code code;
+    of_octets_t data;
+};
+
+struct of_bad_action_error_msg : of_error_msg {
+    uint8_t version;
+    uint8_t type == 1;
+    uint16_t length;
+    uint32_t xid;
+    uint16_t err_type == 2;
+    enum ofp_bad_action_code code;
+    of_octets_t data;
+};
+
+struct of_bad_instruction_error_msg : of_error_msg {
+    uint8_t version;
+    uint8_t type == 1;
+    uint16_t length;
+    uint32_t xid;
+    uint16_t err_type == 3;
+    enum ofp_bad_instruction_code code;
+    of_octets_t data;
+};
+
+struct of_bad_match_error_msg : of_error_msg {
+    uint8_t version;
+    uint8_t type == 1;
+    uint16_t length;
+    uint32_t xid;
+    uint16_t err_type == 4;
+    enum ofp_bad_match_code code;
+    of_octets_t data;
+};
+
+struct of_flow_mod_failed_error_msg : of_error_msg {
+    uint8_t version;
+    uint8_t type == 1;
+    uint16_t length;
+    uint32_t xid;
+    uint16_t err_type == 5;
+    enum ofp_flow_mod_failed_code code;
+    of_octets_t data;
+};
+
+struct of_group_mod_failed_error_msg : of_error_msg {
+    uint8_t version;
+    uint8_t type == 1;
+    uint16_t length;
+    uint32_t xid;
+    uint16_t err_type == 6;
+    enum ofp_group_mod_failed_code code;
+    of_octets_t data;
+};
+
+struct of_port_mod_failed_error_msg : of_error_msg {
+    uint8_t version;
+    uint8_t type == 1;
+    uint16_t length;
+    uint32_t xid;
+    uint16_t err_type == 7;
+    enum ofp_port_mod_failed_code code;
+    of_octets_t data;
+};
+
+struct of_table_mod_failed_error_msg : of_error_msg {
+    uint8_t version;
+    uint8_t type == 1;
+    uint16_t length;
+    uint32_t xid;
+    uint16_t err_type == 8;
+    enum ofp_table_mod_failed_code code;
+    of_octets_t data;
+};
+
+struct of_queue_op_failed_error_msg : of_error_msg {
+    uint8_t version;
+    uint8_t type == 1;
+    uint16_t length;
+    uint32_t xid;
+    uint16_t err_type == 9;
+    enum ofp_queue_op_failed_code code;
+    of_octets_t data;
+};
+
+struct of_switch_config_failed_error_msg : of_error_msg {
+    uint8_t version;
+    uint8_t type == 1;
+    uint16_t length;
+    uint32_t xid;
+    uint16_t err_type == 10;
+    enum ofp_switch_config_failed_code code;
+    of_octets_t data;
+};
+
+struct of_role_request_failed_error_msg : of_error_msg {
+    uint8_t version;
+    uint8_t type == 1;
+    uint16_t length;
+    uint32_t xid;
+    uint16_t err_type == 11;
+    enum ofp_role_request_failed_code code;
+    of_octets_t data;
+};
+
+struct of_experimenter_error_msg {
+    uint8_t version;
+    uint8_t type == 1;
+    uint16_t length;
+    uint32_t xid;
+    uint16_t err_type == 0xffff;
+    uint16_t subtype;
+    uint32_t experimenter;
+    of_octets_t data;
+};
 
 // STATS ENTRIES: flow, table, port, queue, group stats, group desc stats
 // FIXME: Verify disambiguation w/ length in object and entry
diff --git a/openflow_input/standard-1.3 b/openflow_input/standard-1.3
index 24129aa..97adfd4 100644
--- a/openflow_input/standard-1.3
+++ b/openflow_input/standard-1.3
@@ -92,8 +92,8 @@
     OFPT_GROUP_MOD = 15,
     OFPT_PORT_MOD = 16,
     OFPT_TABLE_MOD = 17,
-    OFPT_MULTIPART_REQUEST = 18,
-    OFPT_MULTIPART_REPLY = 19,
+    OFPT_STATS_REQUEST = 18,
+    OFPT_STATS_REPLY = 19,
     OFPT_BARRIER_REQUEST = 20,
     OFPT_BARRIER_REPLY = 21,
     OFPT_QUEUE_GET_CONFIG_REQUEST = 22,
@@ -336,7 +336,7 @@
 enum ofp_bad_request_code(wire_type=uint16_t) {
     OFPBRC_BAD_VERSION = 0,
     OFPBRC_BAD_TYPE = 1,
-    OFPBRC_BAD_MULTIPART = 2,
+    OFPBRC_BAD_STAT = 2,
     OFPBRC_BAD_EXPERIMENTER = 3,
     OFPBRC_BAD_EXP_TYPE = 4,
     OFPBRC_EPERM = 5,
@@ -481,30 +481,30 @@
     OFPTFFC_EPERM = 5,
 };
 
-enum ofp_multipart_types(wire_type=uint16_t) {
-    OFPMP_DESC = 0,
-    OFPMP_FLOW = 1,
-    OFPMP_AGGREGATE = 2,
-    OFPMP_TABLE = 3,
-    OFPMP_PORT_STATS = 4,
-    OFPMP_QUEUE = 5,
-    OFPMP_GROUP = 6,
-    OFPMP_GROUP_DESC = 7,
-    OFPMP_GROUP_FEATURES = 8,
-    OFPMP_METER = 9,
-    OFPMP_METER_CONFIG = 10,
-    OFPMP_METER_FEATURES = 11,
-    OFPMP_TABLE_FEATURES = 12,
-    OFPMP_PORT_DESC = 13,
-    OFPMP_EXPERIMENTER = 0xffff,
+enum ofp_stats_type(wire_type=uint16_t) {
+    OFPST_DESC = 0,
+    OFPST_FLOW = 1,
+    OFPST_AGGREGATE = 2,
+    OFPST_TABLE = 3,
+    OFPST_PORT = 4,
+    OFPST_QUEUE = 5,
+    OFPST_GROUP = 6,
+    OFPST_GROUP_DESC = 7,
+    OFPST_GROUP_FEATURES = 8,
+    OFPST_METER = 9,
+    OFPST_METER_CONFIG = 10,
+    OFPST_METER_FEATURES = 11,
+    OFPST_TABLE_FEATURES = 12,
+    OFPST_PORT_DESC = 13,
+    OFPST_EXPERIMENTER = 0xffff,
 };
 
-enum ofp_multipart_request_flags(wire_type=uint16_t, bitmask=True) {
-    OFPMPF_REQ_MORE = 0x1,
+enum ofp_stats_request_flags(wire_type=uint16_t, bitmask=True) {
+    OFPSF_REQ_MORE = 0x1,
 };
 
-enum ofp_multipart_reply_flags(wire_type=uint16_t, bitmask=True) {
-    OFPMPF_REPLY_MORE = 0x1,
+enum ofp_stats_reply_flags(wire_type=uint16_t, bitmask=True) {
+    OFPSF_REPLY_MORE = 0x1,
 };
 
 enum ofp_table_feature_prop_type(wire_type=uint16_t) {
@@ -695,7 +695,7 @@
     uint8_t n_tables;
     uint8_t auxiliary_id;
     pad(2);
-    uint32_t capabilities;
+    enum ofp_capabilities capabilities;
     uint32_t reserved;
 };
 
@@ -1150,21 +1150,159 @@
     uint8_t type == 1;
     uint16_t length;
     uint32_t xid;
-    uint16_t err_type;
-    uint16_t code;
+    uint16_t err_type == ?;
+};
+
+struct of_hello_failed_error_msg : of_error_msg {
+    uint8_t version;
+    uint8_t type == 1;
+    uint16_t length;
+    uint32_t xid;
+    uint16_t err_type == 0;
+    enum ofp_hello_failed_code code;
     of_octets_t data;
 };
 
-//struct of_error_experimenter_msg {
-//    uint8_t version;
-//    uint8_t type;
-//    uint16_t length;
-//    uint32_t xid;
-//    uint16_t err_type;
-//    uint16_t subtype;
-//    uint32_t experimenter;
-//    of_octets_t data;
-//};
+struct of_bad_request_error_msg : of_error_msg {
+    uint8_t version;
+    uint8_t type == 1;
+    uint16_t length;
+    uint32_t xid;
+    uint16_t err_type == 1;
+    enum ofp_bad_request_code code;
+    of_octets_t data;
+};
+
+struct of_bad_action_error_msg : of_error_msg {
+    uint8_t version;
+    uint8_t type == 1;
+    uint16_t length;
+    uint32_t xid;
+    uint16_t err_type == 2;
+    enum ofp_bad_action_code code;
+    of_octets_t data;
+};
+
+struct of_bad_instruction_error_msg : of_error_msg {
+    uint8_t version;
+    uint8_t type == 1;
+    uint16_t length;
+    uint32_t xid;
+    uint16_t err_type == 3;
+    enum ofp_bad_instruction_code code;
+    of_octets_t data;
+};
+
+struct of_bad_match_error_msg : of_error_msg {
+    uint8_t version;
+    uint8_t type == 1;
+    uint16_t length;
+    uint32_t xid;
+    uint16_t err_type == 4;
+    enum ofp_bad_match_code code;
+    of_octets_t data;
+};
+
+struct of_flow_mod_failed_error_msg : of_error_msg {
+    uint8_t version;
+    uint8_t type == 1;
+    uint16_t length;
+    uint32_t xid;
+    uint16_t err_type == 5;
+    enum ofp_flow_mod_failed_code code;
+    of_octets_t data;
+};
+
+struct of_group_mod_failed_error_msg : of_error_msg {
+    uint8_t version;
+    uint8_t type == 1;
+    uint16_t length;
+    uint32_t xid;
+    uint16_t err_type == 6;
+    enum ofp_group_mod_failed_code code;
+    of_octets_t data;
+};
+
+struct of_port_mod_failed_error_msg : of_error_msg {
+    uint8_t version;
+    uint8_t type == 1;
+    uint16_t length;
+    uint32_t xid;
+    uint16_t err_type == 7;
+    enum ofp_port_mod_failed_code code;
+    of_octets_t data;
+};
+
+struct of_table_mod_failed_error_msg : of_error_msg {
+    uint8_t version;
+    uint8_t type == 1;
+    uint16_t length;
+    uint32_t xid;
+    uint16_t err_type == 8;
+    enum ofp_table_mod_failed_code code;
+    of_octets_t data;
+};
+
+struct of_queue_op_failed_error_msg : of_error_msg {
+    uint8_t version;
+    uint8_t type == 1;
+    uint16_t length;
+    uint32_t xid;
+    uint16_t err_type == 9;
+    enum ofp_queue_op_failed_code code;
+    of_octets_t data;
+};
+
+struct of_switch_config_failed_error_msg : of_error_msg {
+    uint8_t version;
+    uint8_t type == 1;
+    uint16_t length;
+    uint32_t xid;
+    uint16_t err_type == 10;
+    enum ofp_switch_config_failed_code code;
+    of_octets_t data;
+};
+
+struct of_role_request_failed_error_msg : of_error_msg {
+    uint8_t version;
+    uint8_t type == 1;
+    uint16_t length;
+    uint32_t xid;
+    uint16_t err_type == 11;
+    enum ofp_role_request_failed_code code;
+    of_octets_t data;
+};
+
+struct of_meter_mod_failed_error_msg : of_error_msg {
+    uint8_t version;
+    uint8_t type == 1;
+    uint16_t length;
+    uint32_t xid;
+    uint16_t err_type == 12;
+    enum ofp_meter_mod_failed_code code;
+    of_octets_t data;
+};
+
+struct of_table_features_failed_error_msg : of_error_msg {
+    uint8_t version;
+    uint8_t type == 1;
+    uint16_t length;
+    uint32_t xid;
+    uint16_t err_type == 13;
+    enum ofp_table_features_failed_code code;
+    of_octets_t data;
+};
+
+struct of_experimenter_error_msg {
+    uint8_t version;
+    uint8_t type == 1;
+    uint16_t length;
+    uint32_t xid;
+    uint16_t err_type == 0xffff;
+    uint16_t subtype;
+    uint32_t experimenter;
+    of_octets_t data;
+};
 
 // STATS ENTRIES: flow, table, port, queue, group stats, group desc stats
 
@@ -1770,7 +1908,7 @@
     list(of_meter_band_t) entries;
 };
 
-struct of_experimenter_multipart_header {
+struct of_experimenter_stats_header {
     uint32_t experimenter == ?;
     uint32_t subtype;
 };
diff --git a/py_gen/templates/message.py b/py_gen/templates/message.py
index 4ec8c46..1b2ad3f 100644
--- a/py_gen/templates/message.py
+++ b/py_gen/templates/message.py
@@ -122,6 +122,15 @@
     else:
         raise loxi.ProtocolError("unexpected message type")
 
+def parse_error(buf):
+    if len(buf) < 8 + 2:
+        raise loxi.ProtocolError("message too short")
+    err_type, = struct.unpack_from("!H", buf, 8)
+    if err_type in error_msg_parsers:
+        return error_msg_parsers[err_type](buf)
+    else:
+        raise loxi.ProtocolError("unexpected error type %u" % stats_type)
+
 def parse_flow_mod(buf):
 :: if version == 1:
 :: offset = 57
@@ -137,7 +146,6 @@
     else:
         raise loxi.ProtocolError("unexpected flow mod cmd %u" % cmd)
 
-:: if version < of_g.VERSION_1_3:
 def parse_stats_reply(buf):
     if len(buf) < 8 + 2:
         raise loxi.ProtocolError("message too short")
@@ -155,31 +163,8 @@
         return stats_request_parsers[stats_type](buf)
     else:
         raise loxi.ProtocolError("unexpected stats type %u" % stats_type)
-:: else:
-def parse_multipart_reply(buf):
-    if len(buf) < 8 + 2:
-        raise loxi.ProtocolError("message too short")
-    multipart_type, = struct.unpack_from("!H", buf, 8)
-    if multipart_type in multipart_reply_parsers:
-        return multipart_reply_parsers[multipart_type](buf)
-    else:
-        raise loxi.ProtocolError("unexpected multipart type %u" % multipart_type)
 
-def parse_multipart_request(buf):
-    if len(buf) < 8 + 2:
-        raise loxi.ProtocolError("message too short")
-    multipart_type, = struct.unpack_from("!H", buf, 8)
-    if multipart_type in multipart_request_parsers:
-        return multipart_request_parsers[multipart_type](buf)
-    else:
-        raise loxi.ProtocolError("unexpected multipart type %u" % multipart_type)
-:: #endif
-
-:: if version == of_g.VERSION_1_0:
-def parse_vendor(buf):
-:: else:
 def parse_experimenter(buf):
-:: #endif
     if len(buf) < 16:
         raise loxi.ProtocolError("experimenter message too short")
 
@@ -210,6 +195,30 @@
 :: #endfor
 }
 
+error_msg_parsers = {
+    const.OFPET_HELLO_FAILED : hello_failed_error_msg.unpack,
+    const.OFPET_BAD_REQUEST : bad_request_error_msg.unpack,
+    const.OFPET_BAD_ACTION : bad_action_error_msg.unpack,
+    const.OFPET_FLOW_MOD_FAILED : flow_mod_failed_error_msg.unpack,
+    const.OFPET_PORT_MOD_FAILED : port_mod_failed_error_msg.unpack,
+    const.OFPET_QUEUE_OP_FAILED : queue_op_failed_error_msg.unpack,
+:: if version >= of_g.VERSION_1_1:
+    const.OFPET_BAD_INSTRUCTION : bad_instruction_error_msg.unpack,
+    const.OFPET_BAD_MATCH : bad_match_error_msg.unpack,
+    const.OFPET_GROUP_MOD_FAILED : group_mod_failed_error_msg.unpack,
+    const.OFPET_TABLE_MOD_FAILED : table_mod_failed_error_msg.unpack,
+    const.OFPET_SWITCH_CONFIG_FAILED : switch_config_failed_error_msg.unpack,
+:: #endif
+:: if version >= of_g.VERSION_1_2:
+    const.OFPET_ROLE_REQUEST_FAILED : role_request_failed_error_msg.unpack,
+    const.OFPET_EXPERIMENTER : experimenter_error_msg.unpack,
+:: #endif
+:: if version >= of_g.VERSION_1_3:
+    const.OFPET_METER_MOD_FAILED : meter_mod_failed_error_msg.unpack,
+    const.OFPET_TABLE_FEATURES_FAILED : table_features_failed_error_msg.unpack,
+:: #endif
+}
+
 flow_mod_parsers = {
     const.OFPFC_ADD : flow_add.unpack,
     const.OFPFC_MODIFY : flow_modify.unpack,
@@ -218,7 +227,6 @@
     const.OFPFC_DELETE_STRICT : flow_delete_strict.unpack,
 }
 
-:: if version < of_g.VERSION_1_3:
 stats_reply_parsers = {
     const.OFPST_DESC : desc_stats_reply.unpack,
     const.OFPST_FLOW : flow_stats_reply.unpack,
@@ -233,6 +241,13 @@
 :: if version >= of_g.VERSION_1_2:
     const.OFPST_GROUP_FEATURES : group_features_stats_reply.unpack,
 :: #endif
+:: if version >= of_g.VERSION_1_3:
+    const.OFPST_METER : meter_stats_reply.unpack,
+    const.OFPST_METER_CONFIG : meter_config_stats_reply.unpack,
+    const.OFPST_METER_FEATURES : meter_features_stats_reply.unpack,
+    const.OFPST_TABLE_FEATURES : table_features_stats_reply.unpack,
+    const.OFPST_PORT_DESC : port_desc_stats_reply.unpack,
+:: #endif
 }
 
 stats_request_parsers = {
@@ -249,42 +264,14 @@
 :: if version >= of_g.VERSION_1_2:
     const.OFPST_GROUP_FEATURES : group_features_stats_request.unpack,
 :: #endif
-}
-:: else:
-multipart_reply_parsers = {
-    const.OFPMP_DESC : desc_stats_reply.unpack,
-    const.OFPMP_FLOW : flow_stats_reply.unpack,
-    const.OFPMP_AGGREGATE : aggregate_stats_reply.unpack,
-    const.OFPMP_TABLE : table_stats_reply.unpack,
-    const.OFPMP_PORT_STATS : port_stats_reply.unpack,
-    const.OFPMP_QUEUE : queue_stats_reply.unpack,
-    const.OFPMP_GROUP : group_stats_reply.unpack,
-    const.OFPMP_GROUP_DESC : group_desc_stats_reply.unpack,
-    const.OFPMP_GROUP_FEATURES : group_features_stats_reply.unpack,
-    const.OFPMP_METER : meter_stats_reply.unpack,
-    const.OFPMP_METER_CONFIG : meter_config_stats_reply.unpack,
-    const.OFPMP_METER_FEATURES : meter_features_stats_reply.unpack,
-    const.OFPMP_TABLE_FEATURES : table_features_stats_reply.unpack,
-    const.OFPMP_PORT_DESC : port_desc_stats_reply.unpack,
-}
-
-multipart_request_parsers = {
-    const.OFPMP_DESC : desc_stats_request.unpack,
-    const.OFPMP_FLOW : flow_stats_request.unpack,
-    const.OFPMP_AGGREGATE : aggregate_stats_request.unpack,
-    const.OFPMP_TABLE : table_stats_request.unpack,
-    const.OFPMP_PORT_STATS : port_stats_request.unpack,
-    const.OFPMP_QUEUE : queue_stats_request.unpack,
-    const.OFPMP_GROUP : group_stats_request.unpack,
-    const.OFPMP_GROUP_DESC : group_desc_stats_request.unpack,
-    const.OFPMP_GROUP_FEATURES : group_features_stats_request.unpack,
-    const.OFPMP_METER : meter_stats_request.unpack,
-    const.OFPMP_METER_CONFIG : meter_config_stats_request.unpack,
-    const.OFPMP_METER_FEATURES : meter_features_stats_request.unpack,
-    const.OFPMP_TABLE_FEATURES : table_features_stats_request.unpack,
-    const.OFPMP_PORT_DESC : port_desc_stats_request.unpack,
-}
+:: if version >= of_g.VERSION_1_3:
+    const.OFPST_METER : meter_stats_request.unpack,
+    const.OFPST_METER_CONFIG : meter_config_stats_request.unpack,
+    const.OFPST_METER_FEATURES : meter_features_stats_request.unpack,
+    const.OFPST_TABLE_FEATURES : table_features_stats_request.unpack,
+    const.OFPST_PORT_DESC : port_desc_stats_request.unpack,
 :: #endif
+}
 
 :: experimenter_ofclasses = [x for x in ofclasses if x.type_members[1].value == 4]
 :: sort_key = lambda x: x.type_members[2].value
diff --git a/test_data/of13/error.data b/test_data/of13/error.data
index fcb0c1c..ffe1a2b 100644
--- a/test_data/of13/error.data
+++ b/test_data/of13/error.data
@@ -6,8 +6,7 @@
 00 08 # code
 61 62 63 # data
 -- python
-ofp.message.error_msg(
+ofp.message.bad_match_error_msg(
     xid=0x12345678,
-    err_type=ofp.OFPET_BAD_MATCH,
     code=ofp.OFPBMC_BAD_MASK,
     data="abc")