Merge into master from pull request #244:
Remove dead code (https://github.com/floodlight/loxigen/pull/244)
diff --git a/.gitignore b/.gitignore
index c0b10be..f4243d4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,3 +12,5 @@
 *.cache
 openflowj-loxi
 /bin
+*,cover
+/.coverage
diff --git a/Makefile b/Makefile
index 3767fba..018db0b 100644
--- a/Makefile
+++ b/Makefile
@@ -142,4 +142,13 @@
 ctags:
 	ctags ${LOXI_PY_FILES} ${LOXI_TEMPLATE_FILES} ${INPUT_FILES} ${TEST_DATA}
 
-.PHONY: all clean debug check pylint c python
+coverage:
+	find -name '*,cover' -exec rm {} \;
+	coverage erase
+	coverage run -a ./loxigen.py --lang=c
+	coverage run -a ./loxigen.py --lang=python
+	coverage run -a ./loxigen.py --lang=java
+	coverage run -a ./loxigen.py --lang=wireshark
+	coverage annotate -i --omit tenjin.py,pyparsing.py
+
+.PHONY: all clean debug check pylint c python coverage
diff --git a/c_gen/build_of_g.py b/c_gen/build_of_g.py
index 85be353..41d8ab2 100755
--- a/c_gen/build_of_g.py
+++ b/c_gen/build_of_g.py
@@ -286,10 +286,6 @@
     for cls in of_g.ordered_list_objects:
         of_g.unified[cls]["object_id"] = of_g.object_id
         of_g.object_id += 1
-    for cls in of_g.ordered_pseudo_objects:
-        of_g.unified[cls] = {}
-        of_g.unified[cls]["object_id"] = of_g.object_id
-        of_g.object_id += 1
 
 
 def initialize_versions():
@@ -471,70 +467,3 @@
         classes = versions[version]["classes"]
         for cls in of_g.ordered_classes[wire_version]:
             add_class(wire_version, cls, classes[cls])
-
-
-def log_all_class_info():
-    """
-    Log the results of processing the input
-
-    Debug function
-    """
-
-    for cls in of_g.unified:
-        for v in of_g.unified[cls]:
-            if type(v) == type(0):
-                log("cls: %s. ver: %d. base len %d. %s" %
-                    (str(cls), v, of_g.base_length[(cls, v)],
-                     loxi_utils.class_is_var_len(cls,v) and "not fixed"
-                     or "fixed"))
-                if "use_version" in of_g.unified[cls][v]:
-                    log("cls %s: v %d mapped to %d" % (str(cls), v,
-                           of_g.unified[cls][v]["use_version"]))
-                if "members" in of_g.unified[cls][v]:
-                    for member in of_g.unified[cls][v]["members"]:
-                        log("   %-20s: type %-20s. offset %3d" %
-                            (member["name"], member["m_type"],
-                             member["offset"]))
-
-def generate_all_files():
-    """
-    Create the files for the language target
-    """
-    for (name, fn) in lang_module.targets.items():
-        path = of_g.options.install_dir + '/' + name
-        os.system("mkdir -p %s" % os.path.dirname(path))
-        with open(path, "w") as outfile:
-            fn(outfile, os.path.basename(name))
-        print("Wrote contents for " + name)
-
-if __name__ == '__main__':
-    of_g.loxigen_log_file = open("loxigen.log", "w")
-    of_g.loxigen_dbg_file = sys.stdout
-
-    of_g.process_commandline()
-    # @fixme Use command line params to select log
-
-    if not config_sanity_check():
-        debug("Config sanity check failed\n")
-        sys.exit(1)
-
-    # Import the language file
-    lang_file = "lang_%s" % of_g.options.lang
-    lang_module = __import__(lang_file)
-
-    # If list files, just list auto-gen files to stdout and exit
-    if of_g.options.list_files:
-        for name in lang_module.targets:
-            print of_g.options.install_dir + '/' + name
-        sys.exit(0)
-
-    log("\nGenerating files for target language %s\n" % of_g.options.lang)
-
-    initialize_versions()
-    read_input()
-    populate_type_maps()
-    analyze_input()
-    unify_input()
-    order_and_assign_object_ids()
-    log_all_class_info()
-    generate_all_files()
diff --git a/c_gen/c_code_gen.py b/c_gen/c_code_gen.py
index 91bd07f..4f5ee7f 100644
--- a/c_gen/c_code_gen.py
+++ b/c_gen/c_code_gen.py
@@ -306,20 +306,6 @@
     log("Generated %d identifiers" % (count - 1))
     out.write("\n#endif /* Loci identifiers header file */\n")
 
-def base_h_external(out, filename):
-    """
-    Copy contents of external file to base header
-
-    The contents of the filename are copied literally into the
-    out file handler.  This allows openflow common defines to
-    be entered into the LoxiGen code base.  The content of this
-    code must depend only on standard C headers.
-    """
-    infile = open(filename, "r")
-    contents = infile.read()
-    out.write(contents)
-    infile.close()
-
 def match_h_gen(out, name):
     """
     Generate code for
@@ -330,7 +316,6 @@
     c_match.gen_incompat_members(out)
     c_match.gen_match_struct(out)
     c_match.gen_match_comp(out)
-#    c_match.gen_match_accessors(out)
     out.write("\n#endif /* Match header file */\n")
 
 def top_h_gen(out, name):
@@ -909,12 +894,6 @@
                                    of_g.unified[cls]["object_id"]))
         last = of_g.unified[cls]["object_id"]
 
-    out.write("\n    /* Generic stats request/reply types; pseudo objects */\n")
-    for cls in of_g.ordered_pseudo_objects:
-        out.write("    %s = %d,\n" % (enum_name(cls),
-                                   of_g.unified[cls]["object_id"]))
-        last = of_g.unified[cls]["object_id"]
-
     out.write("""
     OF_OBJECT_COUNT = %d
 } of_object_id_t;
@@ -1038,23 +1017,6 @@
         sys.exit(1)
     return params
 
-def typed_function_base(cls, m_name):
-    """
-    Generate the core name for accessors based on the type
-    @param cls The class name
-    @param m_name The member name
-    """
-    (m_type, get_rv) = get_acc_rv(cls, m_name)
-    return "%s_%s" % (cls, m_type)
-
-def member_function_base(cls, m_name):
-    """
-    Generate the core name for accessors based on the member name
-    @param cls The class name
-    @param m_name The member name
-    """
-    return "%s_%s" % (cls, m_name)
-
 def field_ver_get(cls, m_name):
     """
     Generate a dict, indexed by wire version, giving a pair (type, offset)
@@ -1107,13 +1069,6 @@
 #
 ################################################################
 
-
-def gen_of_object_defs(out):
-    """
-    Generate low level of_object core operations
-    @param out The file for output, already open
-    """
-
 def gen_generics(out):
     for (cls, subclasses) in type_maps.inheritance_map.items():
         out.write("""
@@ -1314,58 +1269,6 @@
 }
 """ % dict(cls=cls, e_type=e_type, u_type=enum_name(e_type), len_str=len_str))
 
-
-def gen_bind(out, cls, m_name, m_type):
-    """
-    Generate the body of a bind function
-    @param out The file to which to write
-    @param cls The class name for which code is being generated
-    @param m_name The name of the data member
-    @param m_type The type of the data member
-    """
-
-    bparams = ",\n    ".join(param_list(cls, m_name, "bind"))
-
-    i_call = init_call(e_type, "child", "parent->version", "0", "1")
-
-    out.write("""
-/**
- * Bind the child object to the parent object for read processing
- * @param parent The parent object
- * @param child The child object
- *
- * The child obj instance is completely initialized.
- */
-
-int
-%(cls)s_%(m_name)_bind(%(cls)s_t *parent,
-    %(e_type)s_t *child)
-{
-    int rv;
-
-    %(i_call)s;
-
-    /* Derive offset and length of child in parent */
-    OF_TRY(of_object_child_attach(parent, child,
-    if ((rv = of_list_first((of_object_t *)list, (of_object_t *)obj)) < 0) {
-        return rv;
-    }
-""" % dict(cls=cls, e_type=e_type, i_call=i_call))
-
-    # Special case flow_stats_entry lists
-
-    out.write("""
-    rv = of_object_wire_init((of_object_t *) obj, %(u_type)s,
-                               list->length);
-    if ((rv == OF_ERROR_NONE) && (%(len_str)s == 0)) {
-        return OF_ERROR_PARSE;
-    }
-
-    return rv;
-}
-""" % dict(cls=cls, e_type=e_type, u_type=enum_name(e_type), len_str=len_str))
-
-
 def gen_list_next(out, cls, e_type):
     """
     Generate the body of a list_next operation
@@ -1994,20 +1897,6 @@
 #
 ################################################################
 
-
-################################################################
-# First, some utility functions for new/delete
-################################################################
-
-def del_function_proto(cls):
-    """
-    Return the prototype for the delete operator for the given class
-    @param cls The class name
-    """
-    fn = "void\n"
-    return fn
-
-
 ################################################################
 # Routines to generate the body of new/delete functions
 ################################################################
@@ -2420,201 +2309,3 @@
 """ % dict(cls=cls))
 
     out.write("#endif /* _LOCI_DOC_H_ */\n")
-
-################################################################
-#
-# For fun, here are some unified, traditional C structure representation
-#
-################################################################
-
-def gen_cof_to_wire(out):
-    pass
-
-def gen_wire_to_cof(out):
-    pass
-
-def gen_cof_instance(out, cls):
-    out.write("struct c%s_s {\n" % cls)
-    for m in of_g.ordered_members[cls]:
-        if m in of_g.skip_members:
-            continue
-        entry = of_g.unified[cls]["union"][m]
-        cof_type = type_to_cof_type(entry["m_type"])
-        out.write("    %-20s %s;\n" % (cof_type, m))
-    out.write("};\n\n");
-
-def gen_cof_structs(out):
-    """
-    Generate non-version specific (common) representation of structures
-
-    @param out The file to which to write the functions
-    """
-
-    out.write("\n/* Common, unified OpenFlow structure representations */\n")
-    for cls in of_g.standard_class_order:
-        if cls in type_maps.inheritance_map:
-            continue
-        gen_cof_instance(out, cls)
-
-################################################################
-#
-# Generate code samples for applications.
-#
-################################################################
-
-def gen_code_samples(out, name):
-    out.write("""
-#if 0 /* Do not compile in */
-/**
- * @file %(name)s
- *
- * These are code samples for inclusion in other components
- */
-
-""" % dict(name=name))
-
-    gen_jump_table_template(out)
-    # These are messages that a switch might expect.
-    msg_list = ["of_echo_request",
-                "of_hello",
-                "of_packet_in",
-                "of_packet_out",
-                "of_port_mod",
-                "of_port_stats_request",
-                "of_queue_get_config_request",
-                "of_queue_stats_request",
-                "of_flow_add",
-                "of_flow_modify",
-                "of_flow_modify_strict",
-                "of_flow_delete",
-                "of_flow_delete_strict",
-                "of_get_config_request",
-                "of_flow_stats_request",
-                "of_barrier_request",
-                "of_echo_reply",
-                "of_aggregate_stats_request",
-                "of_desc_stats_request",
-                "of_table_stats_request",
-                "of_features_request",
-                "of_table_mod",
-                "of_set_config",
-                "of_experimenter",
-                "of_experimenter_stats_request",
-                "of_group_desc_stats_request",
-                "of_group_features_stats_request",
-                "of_role_request"]
-
-    gen_message_handler_templates(out, msgs=msg_list)
-
-    out.write("""
-#endif
-""")
-
-def gen_jump_table_template(out=sys.stdout, all_unhandled=True,
-                            cxn_type="ls_cxn_handle_t",
-                            unhandled="unhandled_message"):
-    """
-    Generate a template for a jump table.
-    @param out The file to which to write the functions
-    """
-    out.write("""
-/*
- * Simple jump table definition for message handling
- */
-typedef int (*msg_handler_f)(%(cxn_type)s cxn, of_object_t *obj);
-typedef msg_handler_f msg_jump_table_t[OF_MESSAGE_OBJECT_COUNT];
-
-/* Jump table template for message objects */
-extern msg_jump_table_t jump_table;
-
-/* C-code template */
-msg_jump_table_t jump_table = {
-    %(unhandled)s, /* OF_OBJECT; place holder for generic object  */
-""" % dict(unhandled=unhandled, cxn_type=cxn_type))
-    count = 0
-    fn_name = unhandled
-    for cls in of_g.ordered_messages:
-        comma = ","
-        count += 1
-        if count == len(of_g.ordered_messages):
-            comma = " "
-        if not all_unhandled:
-            fn_name = "%s_handler" % cls[3:]
-        out.write("    %s%s /* %s */\n" % (fn_name, comma, enum_name(cls)))
-
-    out.write("};\n")
-
-def gen_message_switch_stmt_tmeplate(out=sys.stdout, all_unhandled=True,
-                                     cxn_type="ls_cxn_handle_t",
-                                     unhandled="unhandled_message"):
-    out.write("""
-/*
- * Simple switch statement for message handling
- */
-
-    switch (obj->object_id):
-""")
-    fn_name = unhandled
-    for cls in of_g.ordered_messages:
-        if not all_unhandled:
-            fn_name = "%s_handler" % cls[3:]
-        out.write("""
-    case %(enum)s:
-        rv = %(fn_name)s(cxn, obj);
-        break;
-""" % dict(fn_name=fn_name, cls=cls, enum=enum_name(cls)))
-    out.write("""
-    default:
-        rv = LS_ERROR_PARAM;
-        break;
-    }
-
-    TRACE("Handled msg %p with rv %d (%s)", obj, rv, ls_error_strings[rv]);
-
-    return rv;
-""")
-
-
-def gen_message_handler_templates(out=sys.stdout, cxn_type="ls_cxn_handle_t",
-                                  unhandled="unhandled_message", msgs=None):
-    gen_jump_table_template(out, False, cxn_type)
-    out.write("""
-/**
- * Function for unhandled message
- */
-static int
-unhandled_message(%(cxn_type)s cxn, of_object_t *obj)
-{
-    (void)cxn;
-    (void)obj;
-    TRACE("Unhandled message %%p.  Object id %%d", obj, obj->object_id);
-
-    return LS_ERROR_UNAVAIL;
-}
-""" % dict(unhandled=unhandled, cxn_type=cxn_type))
-
-    if not msgs:
-        msgs = of_g.ordered_messages
-    for cls in msgs:
-        out.write("""
-/**
- * Handle a %(s_cls)s message
- * @param cxn Connection handler for the owning connection
- * @param _obj Generic type object for the message to be coerced
- * @returns Error code
- */
-
-static int
-%(s_cls)s_handler(%(cxn_type)s cxn, of_object_t *_obj)
-{
-    %(cls)s_t *obj;
-
-    TRACE("Handling %(cls)s message: %%p.", obj);
-    obj = (%(cls)s_t *)_obj;
-
-    /* Handle object of type %(cls)s_t */
-
-    return LS_ERROR_NONE;
-}
-""" % dict(s_cls=cls[3:], cls=cls, cxn_type=cxn_type))
-    gen_message_switch_stmt_tmeplate(out, False, cxn_type)
diff --git a/c_gen/c_dump_gen.py b/c_gen/c_dump_gen.py
index a0af14e..d4a016c 100644
--- a/c_gen/c_dump_gen.py
+++ b/c_gen/c_dump_gen.py
@@ -86,9 +86,6 @@
 
 """)
 
-    type_to_emitter = dict(
-
-        )
     for version in of_g.of_version_range:
         for cls in of_g.standard_class_order:
             if not loxi_utils.class_in_version(cls, version):
diff --git a/c_gen/c_match.py b/c_gen/c_match.py
index 3aad03e..fdb8afe 100644
--- a/c_gen/c_match.py
+++ b/c_gen/c_match.py
@@ -618,7 +618,6 @@
     /* For each active member, add an OXM entry to the list */
 """)
     for key in match.match_keys_sorted:
-        entry = match.of_match_members[key]
         out.write("""\
     if (OF_MATCH_MASK_%(ku)s_ACTIVE_TEST(src)) {
         if (!OF_MATCH_MASK_%(ku)s_EXACT_TEST(src)) {
diff --git a/c_gen/c_show_gen.py b/c_gen/c_show_gen.py
index fc3edb8..9d84477 100644
--- a/c_gen/c_show_gen.py
+++ b/c_gen/c_show_gen.py
@@ -87,9 +87,6 @@
 
 """)
 
-    type_to_emitter = dict(
-
-        )
     for version in of_g.of_version_range:
         for cls in of_g.standard_class_order:
             if not loxi_utils.class_in_version(cls, version):
diff --git a/c_gen/c_test_gen.py b/c_gen/c_test_gen.py
index a0cdca1..3eaaf82 100644
--- a/c_gen/c_test_gen.py
+++ b/c_gen/c_test_gen.py
@@ -349,7 +349,6 @@
 extern int run_scalar_acc_tests(void);
 extern int run_list_tests(void);
 extern int run_message_tests(void);
-extern int run_setup_from_add_tests(void);
 
 extern int run_validator_tests(void);
 
@@ -385,9 +384,6 @@
 
     for version in of_g.of_version_range:
         for cls in of_g.ordered_list_objects:
-            if cls in type_maps.inheritance_map:
-                continue
-
             if version in of_g.unified[cls]:
                out.write("""
 extern int
@@ -693,7 +689,7 @@
 
 
 # Helper function to set up a subclass instance for a test
-def setup_instance(out, cls, subcls, instance, v_name, inst_len, version):
+def setup_instance(out, cls, subcls, instance, v_name, version):
     base_type = loxi_utils.list_to_entry_type(cls)
     setup_template = """
     %(subcls)s_init(%(inst)s, %(v_name)s, -1, 1);
@@ -710,23 +706,11 @@
     for i in range(2):
         out.write(setup_template %
                   dict(inst=instance, subcls=subcls, v_name=v_name,
-                       base_type=base_type, cls=cls, inst_len=inst_len,
+                       base_type=base_type, cls=cls,
                        version=version))
 
-def check_instance(out, cls, subcls, instance, v_name, inst_len, version, last):
-    check_template = ""
-    if inst_len >= 0:
-        check_template = """
-    TEST_ASSERT(%(inst)s->length == %(inst_len)d);
-    if (loci_class_metadata[%(inst)s->object_id].wire_length_get != NULL) {
-        int length;
-
-        loci_class_metadata[%(inst)s->object_id].wire_length_get(
-            (of_object_t *)&elt, &length);
-        TEST_ASSERT(length == %(inst_len)d);
-    }
-"""
-    check_template += """
+def check_instance(out, cls, subcls, instance, v_name, version, last):
+    check_template = """
     TEST_ASSERT(%(inst)s->object_id == %(elt_name)s);
     value = %(subcls)s_%(v_name)s_check(
         %(inst)s, value);
@@ -735,7 +719,7 @@
     out.write("\n    /* Check two instances of type %s */" % instance)
 
     out.write(check_template %
-              dict(elt_name=loxi_utils.enum_name(subcls), inst_len=inst_len,
+              dict(elt_name=loxi_utils.enum_name(subcls),
                    inst=instance, subcls=subcls,
                    v_name=loxi_utils.version_to_name(version)))
     out.write("""\
@@ -743,7 +727,7 @@
 """ % dict(cls=cls))
 
     out.write(check_template %
-              dict(elt_name=loxi_utils.enum_name(subcls), inst_len=inst_len,
+              dict(elt_name=loxi_utils.enum_name(subcls),
                    inst=instance, subcls=subcls,
                    v_name=loxi_utils.version_to_name(version)))
     if last:
@@ -792,12 +776,10 @@
             out.write("    %s = &elt.%s;\n" % (instance, instance))
 
     if len(sub_classes) == 0: # No inheritance case
-        inst_len = loxi_utils.base_type_to_length(base_type, version)
-        setup_instance(out, cls, base_type, "elt_p", v_name, inst_len, version)
+        setup_instance(out, cls, base_type, "elt_p", v_name, version)
     else:
         for instance, subcls in sub_classes:
-            inst_len = of_g.base_length[(subcls, version)]
-            setup_instance(out, cls, subcls, instance, v_name, inst_len, version)
+            setup_instance(out, cls, subcls, instance, v_name, version)
     out.write("""
 
     return value;
@@ -841,21 +823,12 @@
 
     out.write("    TEST_OK(%(cls)s_first(list, &elt));\n" % dict(cls=cls))
     if len(sub_classes) == 0: # No inheritance case
-        if loxi_utils.class_is_var_len(base_type, version):
-            inst_len = -1
-        else:
-            inst_len = loxi_utils.base_type_to_length(base_type, version)
-        check_instance(out, cls, base_type, "elt_p", v_name, inst_len,
-                       version, True)
+        check_instance(out, cls, base_type, "elt_p", v_name, version, True)
     else:
         count = 0
         for instance, subcls in sub_classes:
             count += 1
-            if loxi_utils.class_is_var_len(subcls, version):
-                inst_len = -1
-            else:
-                inst_len = of_g.base_length[(subcls, version)]
-            check_instance(out, cls, subcls, instance, v_name, inst_len,
+            check_instance(out, cls, subcls, instance, v_name,
                            version, count==len(sub_classes))
 
     out.write("""
@@ -866,9 +839,6 @@
 def gen_list_set_check_funs(out):
     for version in of_g.of_version_range:
         for cls in of_g.ordered_list_objects:
-            if cls in type_maps.inheritance_map:
-                continue
-
             if version in of_g.unified[cls]:
                 setup_list_fn(out, version, cls)
                 check_list_fn(out, version, cls)
@@ -940,8 +910,6 @@
  */
 """ % v_name)
         for cls in of_g.ordered_list_objects:
-            if cls in type_maps.inheritance_map:
-                continue
             if version in of_g.unified[cls]:
                 list_test(out, version, cls)
 
@@ -953,8 +921,6 @@
     for version in of_g.of_version_range:
         v_name = loxi_utils.version_to_name(version)
         for cls in of_g.ordered_list_objects:
-            if cls in type_maps.inheritance_map:
-                continue
             if version in of_g.unified[cls]:
                 test_name = "%s_%s" % (cls, v_name)
                 out.write("    RUN_TEST(%s);\n" % test_name)
@@ -1222,24 +1188,11 @@
         for instance, subcls in sub_classes:
             out.write("    %s = &elt.%s;\n" % (instance, instance))
 
-#     if type_maps.class_is_virtual(base_type):
-#         out.write("""\
-#     TEST_OK(%(base_type)s_header_init(
-#         (%(base_type)s_header_t *)&elt, %(v_name)s, -1, 1));
-# """ % dict(base_type=base_type, v_name=loxi_utils.version_to_name(version)))
-#     else:
-#         out.write("""\
-#     TEST_OK(%(base_type)s_init(&elt, %(v_name)s, -1, 1));
-# """ % dict(base_type=base_type, v_name=loxi_utils.version_to_name(version)))
-
     if len(sub_classes) == 0: # No inheritance case
-        inst_len = loxi_utils.base_type_to_length(base_type, version)
-        setup_instance(out, cls, base_type, "elt_p", v_name, inst_len, version)
+        setup_instance(out, cls, base_type, "elt_p", v_name, version)
     else:
         for instance, subcls in sub_classes:
-            inst_len = of_g.base_length[(subcls, version)]
-            setup_instance(out, cls, subcls, instance, v_name,
-                           inst_len, version)
+            setup_instance(out, cls, subcls, instance, v_name, version)
     out.write("""
     return value;
 }
@@ -1285,21 +1238,13 @@
 
     out.write("    TEST_OK(%(cls)s_first(list, &elt));\n" % dict(cls=cls))
     if len(sub_classes) == 0: # No inheritance case
-        if loxi_utils.class_is_var_len(base_type, version):
-            inst_len = -1
-        else:
-            inst_len = loxi_utils.base_type_to_length(base_type, version)
-        check_instance(out, cls, base_type, "elt_p", v_name, inst_len,
+        check_instance(out, cls, base_type, "elt_p", v_name,
                        version, True)
     else:
         count = 0
         for instance, subcls in sub_classes:
             count += 1
-            if loxi_utils.class_is_var_len(subcls, version):
-                inst_len = -1
-            else:
-                inst_len = of_g.base_length[(subcls, version)]
-            check_instance(out, cls, subcls, instance, v_name, inst_len,
+            check_instance(out, cls, subcls, instance, v_name,
                            version, count==len(sub_classes))
     out.write("""
 """ % dict(base_type=base_type))
diff --git a/c_gen/c_type_maps.py b/c_gen/c_type_maps.py
index 2b46932..6e6f3fe 100644
--- a/c_gen/c_type_maps.py
+++ b/c_gen/c_type_maps.py
@@ -367,7 +367,6 @@
 
     /* Do a simple if/else search for the ver, experimenter and subtype */
 """
-    first = True
     for version, experimenter_lists in type_maps.extension_message_subtype.items():
         for exp, subtypes in experimenter_lists.items():
             experimenter_function += """
diff --git a/c_gen/codegen.py b/c_gen/codegen.py
index 82de380..fe5e2ad 100644
--- a/c_gen/codegen.py
+++ b/c_gen/codegen.py
@@ -244,8 +244,6 @@
             elif uclass.name == "of_packet_queue":
                 wire_length_get = 'of_packet_queue_wire_length_get'
                 wire_length_set = 'of_packet_queue_wire_length_set'
-            elif uclass.name == "of_list_meter_band_stats":
-                wire_length_get = 'of_list_meter_band_stats_wire_length_get'
             elif uclass.name == "of_meter_stats":
                 wire_length_get = 'of_meter_stats_wire_length_get'
                 wire_length_set = 'of_meter_stats_wire_length_set'
diff --git a/c_gen/identifiers.py b/c_gen/identifiers.py
index 5862967..a3304c9 100644
--- a/c_gen/identifiers.py
+++ b/c_gen/identifiers.py
@@ -65,15 +65,6 @@
         if name not in idents_by_group[ofp_group]:
             idents_by_group[ofp_group].append(name)
 
-def all_versions_agree(all_idents, version_list, name):
-    val_list = all_idents[name]["values_by_version"]
-    for version in version_list:
-        if not version in val_list:
-            return False
-        if str(val_list[version]) != str(all_idents[name]["common_value"]):
-            return False
-    return True
-
 def defined_versions_agree(all_idents, version_list, name):
     val_list = all_idents[name]["values_by_version"]
     for version in version_list:
diff --git a/c_gen/loci_utils.py b/c_gen/loci_utils.py
deleted file mode 100644
index 686fb0f..0000000
--- a/c_gen/loci_utils.py
+++ /dev/null
@@ -1,243 +0,0 @@
-import c_gen.of_g_legacy as of_g
-
-def class_signature(members):
-    """
-    Generate a signature string for a class in canonical form
-
-    @param cls The class whose signature is to be generated
-    """
-    return ";".join([",".join([x["m_type"], x["name"], str(x["offset"])])
-                     for x in members])
-
-def type_dec_to_count_base(m_type):
-    """
-    Resolve a type declaration like uint8_t[4] to a count (4) and base_type
-    (uint8_t)
-
-    @param m_type The string type declaration to process
-    """
-    count = 1
-    chk_ar = m_type.split('[')
-    if len(chk_ar) > 1:
-        count_str = chk_ar[1].split(']')[0]
-        if count_str in of_g.ofp_constants:
-            count = of_g.ofp_constants[count_str]
-        else:
-            count = int(count_str)
-        base_type = chk_ar[0]
-    else:
-        base_type = m_type
-    return count, base_type
-
-def list_to_entry_type(cls):
-    """
-    Return the entry type for a list
-    """
-    slen = len("of_list_")
-    return "of_" + cls[slen:]
-
-def type_to_short_name(m_type):
-    if m_type in of_g.of_base_types:
-        tname = of_g.of_base_types[m_type]["short_name"]
-    elif m_type in of_g.of_mixed_types:
-        tname = of_g.of_mixed_types[m_type]["short_name"]
-    else:
-        tname = "unknown"
-    return tname
-
-def type_to_name_type(cls, member_name):
-    """
-    Generate the root name of a member for accessor functions, etc
-    @param cls The class name
-    @param member_name The member name
-    """
-    members = of_g.unified[cls]["union"]
-    if not member_name in members:
-        debug("Error:  %s is not in class %s for acc_name defn" %
-              (member_name, cls))
-        os.exit()
-
-    mem = members[member_name]
-    m_type = mem["m_type"]
-    id = mem["memid"]
-    tname = type_to_short_name(m_type)
-
-    return "o%d_m%d_%s" % (of_g.unified[cls]["object_id"], id, tname)
-
-
-def member_to_index(m_name, members):
-    """
-    Given a member name, return the index in the members dict
-    @param m_name The name of the data member to search for
-    @param members The dict of members
-    @return Index if found, -1 not found
-
-    Note we could generate an index when processing the original input
-    """
-    count = 0
-    for d in members:
-        if d["name"] == m_name:
-            return count
-        count += 1
-    return -1
-
-def member_base_type(cls, m_name):
-    """
-    Map a member to its of_ type
-    @param cls The class name
-    @param m_name The name of the member being gotten
-    @return The of_ type of the member
-    """
-    rv = of_g.unified[cls]["union"][m_name]["m_type"]
-    if rv[-2:] == "_t":
-        return rv
-    return rv + "_t"
-
-def member_type_is_octets(cls, m_name):
-    return member_base_type(cls, m_name) == "of_octets_t"
-
-def h_file_to_define(name):
-    """
-    Convert a .h file name to the define used for the header
-    """
-    h_name = name[:-2].upper()
-    h_name = "_" + h_name + "_H_"
-    return h_name
-
-def type_to_cof_type(m_type):
-    if m_type in of_g.of_base_types:
-        if "cof_type" in of_g.of_base_types[m_type]:
-            return of_g.of_base_types[m_type]["cof_type"]
-    return m_type
-
-
-def member_is_scalar(cls, m_name):
-    return of_g.unified[cls]["union"][m_name]["m_type"] in of_g.of_scalar_types
-
-def type_is_scalar(m_type):
-    return m_type in of_g.of_scalar_types
-
-def skip_member_name(name):
-    return name.find("pad") == 0 or name in of_g.skip_members
-
-def enum_name(cls):
-    """
-    Return the name used for an enum identifier for the given class
-    @param cls The class name
-    """
-    return cls.upper()
-
-def class_in_version(cls, ver):
-    """
-    Return boolean indicating if cls is defined for wire version ver
-    """
-
-    return (cls, ver) in of_g.base_length
-
-def instance_to_class(instance, parent):
-    """
-    Return the name of the class for an instance of inheritance type parent
-    """
-    return parent + "_" + instance
-
-def sub_class_to_var_name(cls):
-    """
-    Given a subclass name like of_action_output, generate the
-    name of a variable like 'output'
-    @param cls The class name
-    """
-    pass
-
-def class_is_var_len(cls, version):
-    # Match is special case.  Only version 1.2 (wire version 3) is var
-    if cls == "of_match":
-        return version == 3
-
-    return not (cls, version) in of_g.is_fixed_length
-
-def base_type_to_length(base_type, version):
-    if base_type + "_t" in of_g.of_base_types:
-        inst_len = of_g.of_base_types[base_type + "_t"]["bytes"]
-    else:
-        inst_len = of_g.base_length[(base_type, version)]
-
-def version_to_name(version):
-    """
-    Convert an integer version to the C macro name
-    """
-    return "OF_" + of_g.version_names[version]
-
-##
-# Is class a flow modify of some sort?
-
-def cls_is_flow_mod(cls):
-    return cls in ["of_flow_mod", "of_flow_modify", "of_flow_add", "of_flow_delete",
-                   "of_flow_modify_strict", "of_flow_delete_strict"]
-
-def all_member_types_get(cls, version):
-    """
-    Get the members and list of types for members of a given class
-    @param cls The class name to process
-    @param version The version for the class
-    """
-    member_types = []
-
-    if not version in of_g.unified[cls]:
-        return ([], [])
-
-    if "use_version" in of_g.unified[cls][version]:
-        v = of_g.unified[cls][version]["use_version"]
-        members = of_g.unified[cls][v]["members"]
-    else:
-        members = of_g.unified[cls][version]["members"]
-    # Accumulate variables that are supported
-    for member in members:
-        m_type = member["m_type"]
-        m_name = member["name"]
-        if skip_member_name(m_name):
-            continue
-        if not m_type in member_types:
-            member_types.append(m_type)
-
-    return (members, member_types)
-
-def list_name_extract(list_type):
-    """
-    Return the base name for a list object of the given type
-    @param list_type The type of the list as appears in the input,
-    for example list(of_port_desc_t).
-    @return A pair, (list-name, base-type) where list-name is the
-    base name for the list, for example of_list_port_desc, and base-type
-    is the type of list elements like of_port_desc_t
-    """
-    base_type = list_type[5:-1]
-    list_name = base_type
-    if list_name.find("of_") == 0:
-        list_name = list_name[3:]
-    if list_name[-2:] == "_t":
-        list_name = list_name[:-2]
-    list_name = "of_list_" + list_name
-    return (list_name, base_type)
-
-def version_to_name(version):
-    """
-    Convert an integer version to the C macro name
-    """
-    return "OF_" + of_g.version_names[version]
-
-def gen_c_copy_license(out):
-    """
-    Generate the top comments for copyright and license
-    """
-    import c_gen.util
-    c_gen.util.render_template(out, '_copyright.c')
-
-def accessor_returns_error(a_type, m_type):
-    is_var_len = (not type_is_scalar(m_type)) and \
-        [x for x in of_g.of_version_range if class_is_var_len(m_type[:-2], x)] != []
-    if a_type == "set" and is_var_len:
-        return True
-    elif m_type == "of_match_t":
-        return True
-    else:
-        return False
diff --git a/c_gen/loxi_utils_legacy.py b/c_gen/loxi_utils_legacy.py
index df93c2b..38feb44 100644
--- a/c_gen/loxi_utils_legacy.py
+++ b/c_gen/loxi_utils_legacy.py
@@ -161,122 +161,12 @@
 
     return False
 
-def class_is_action_id(cls):
-    """
-    Return True if cls_name is an action object
-
-    Note that action_id is not an action object, though it has
-    the same header.  It looks like an action header, but the type
-    is used to identify a kind of action, it does not indicate the
-    type of the object following.
-    """
-    if cls.find("of_action_id") == 0:
-        return True
-
-    # For each vendor, check for vendor specific action
-    for exp in of_g.experimenter_name_to_id:
-        if cls.find("of_action_id_" + exp) == 0:
-            return True
-
-    return False
-
-def class_is_instruction(cls):
-    """
-    Return True if cls_name is an instruction object
-    """
-    if cls.find("of_instruction_id") == 0:
-        return False
-    if cls.find("of_instruction") == 0:
-        return True
-
-    # For each vendor, check for vendor specific action
-    for exp in of_g.experimenter_name_to_id:
-        if cls.find("of_instruction" + exp) == 0:
-            return True
-
-    return False
-
-def class_is_instruction_id(cls):
-    """
-    Return True if cls_name is an action object
-
-    Note that instruction_id is not an instruction object, though it has
-    the same header.  It looks like an instruction header, but the type
-    is used to identify a kind of instruction, it does not indicate the
-    type of the object following.
-    """
-    if cls.find("of_instruction_id") == 0:
-        return True
-
-    # For each vendor, check for vendor specific action
-    for exp in of_g.experimenter_name_to_id:
-        if cls.find("of_instruction_id_" + exp) == 0:
-            return True
-
-    return False
-
-def class_is_meter_band(cls):
-    """
-    Return True if cls_name is an instruction object
-    """
-    # meter_band_stats is not a member of meter_band class hierarchy
-    if cls.find("of_meter_band_stats") == 0:
-        return False
-    if cls.find("of_meter_band") == 0:
-        return True
-    return False
-
-def class_is_hello_elem(cls):
-    """
-    Return True if cls_name is an instruction object
-    """
-    if cls.find("of_hello_elem") == 0:
-        return True
-    return False
-
-def class_is_queue_prop(cls):
-    """
-    Return True if cls_name is a queue_prop object
-    """
-    if cls.find("of_queue_prop") == 0:
-        return True
-
-    # For each vendor, check for vendor specific action
-    for exp in of_g.experimenter_name_to_id:
-        if cls.find("of_queue_prop_" + exp) == 0:
-            return True
-
-    return False
-
-def class_is_table_feature_prop(cls):
-    """
-    Return True if cls_name is a queue_prop object
-    """
-    if cls.find("of_table_feature_prop") == 0:
-        return True
-    return False
-
-def class_is_stats_message(cls):
-    """
-    Return True if cls_name is a message object based on info in unified
-    """
-
-    return "stats_type" in of_g.unified[cls]["union"]
-
 def class_is_list(cls):
     """
     Return True if cls_name is a list object
     """
     return (cls.find("of_list_") == 0)
 
-def class_is_bsn_tlv(cls):
-    """
-    Return True if cls_name is a BSN TLV object
-    """
-    if cls.find("of_bsn_tlv") == 0:
-        return True
-    return False
-
 def type_is_of_object(m_type):
     """
     Return True if m_type is an OF object type
@@ -302,26 +192,6 @@
         tname = "unknown"
     return tname
 
-def type_to_name_type(cls, member_name):
-    """
-    Generate the root name of a member for accessor functions, etc
-    @param cls The class name
-    @param member_name The member name
-    """
-    members = of_g.unified[cls]["union"]
-    if not member_name in members:
-        debug("Error:  %s is not in class %s for acc_name defn" %
-              (member_name, cls))
-        os.exit()
-
-    mem = members[member_name]
-    m_type = mem["m_type"]
-    id = mem["memid"]
-    tname = type_to_short_name(m_type)
-
-    return "o%d_m%d_%s" % (of_g.unified[cls]["object_id"], id, tname)
-
-
 def member_to_index(m_name, members):
     """
     Given a member name, return the index in the members dict
@@ -350,27 +220,6 @@
         return rv
     return rv + "_t"
 
-def member_type_is_octets(cls, m_name):
-    return member_base_type(cls, m_name) == "of_octets_t"
-
-def h_file_to_define(name):
-    """
-    Convert a .h file name to the define used for the header
-    """
-    h_name = name[:-2].upper()
-    h_name = "_" + h_name + "_H_"
-    return h_name
-
-def type_to_cof_type(m_type):
-    if m_type in of_g.of_base_types:
-        if "cof_type" in of_g.of_base_types[m_type]:
-            return of_g.of_base_types[m_type]["cof_type"]
-    return m_type
-
-
-def member_is_scalar(cls, m_name):
-    return of_g.unified[cls]["union"][m_name]["m_type"] in of_g.of_scalar_types
-
 def type_is_scalar(m_type):
     return m_type in of_g.of_scalar_types
 
@@ -397,14 +246,6 @@
     """
     return parent + "_" + instance
 
-def sub_class_to_var_name(cls):
-    """
-    Given a subclass name like of_action_output, generate the
-    name of a variable like 'output'
-    @param cls The class name
-    """
-    pass
-
 def class_is_var_len(cls, version):
     # Match is special case.  Only version 1.2 (wire version 3) is var
     if cls == "of_match":
@@ -412,18 +253,6 @@
 
     return not (cls, version) in of_g.is_fixed_length
 
-def base_type_to_length(base_type, version):
-    if base_type + "_t" in of_g.of_base_types:
-        inst_len = of_g.of_base_types[base_type + "_t"]["bytes"]
-    else:
-        inst_len = of_g.base_length[(base_type, version)]
-
-def version_to_name(version):
-    """
-    Convert an integer version to the C macro name
-    """
-    return "OF_" + of_g.version_names[version]
-
 ##
 # Is class a flow modify of some sort?
 
@@ -499,31 +328,3 @@
         return True
     else:
         return False
-
-def render_template(out, name, path, context, prefix = None):
-    """
-    Render a template using tenjin.
-    out: a file-like object
-    name: name of the template
-    path: array of directories to search for the template
-    context: dictionary of variables to pass to the template
-    prefix: optional prefix to use for embedding (for other languages than python)
-    """
-    pp = [ tenjin.PrefixedLinePreprocessor(prefix=prefix) if prefix else tenjin.PrefixedLinePreprocessor() ] # support "::" syntax
-    template_globals = { "to_str": str, "escape": str } # disable HTML escaping
-    engine = TemplateEngine(path=path, pp=pp)
-    out.write(engine.render(name, context, template_globals))
-
-def render_static(out, name, path):
-    """
-    Write out a static template.
-    out: a file-like object
-    name: name of the template
-    path: array of directories to search for the template
-    """
-    # Reuse the tenjin logic for finding the template
-    template_filename = tenjin.FileSystemLoader().find(name, path)
-    if not template_filename:
-        raise ValueError("template %s not found" % name)
-    with open(template_filename) as infile:
-        out.write(infile.read())
diff --git a/c_gen/of_g_legacy.py b/c_gen/of_g_legacy.py
index 3311282..b58ca08 100644
--- a/c_gen/of_g_legacy.py
+++ b/c_gen/of_g_legacy.py
@@ -292,47 +292,12 @@
 VERSION_1_2 = 3
 VERSION_1_3 = 4
 
-# Ignore version for some functions
-VERSION_ANY = -1
-
-## @var supported_wire_protos
-# The wire protocols this version of LoxiGen supports
-supported_wire_protos = set([1, 2, 3, 4])
 version_names = {1:"VERSION_1_0", 2:"VERSION_1_1", 3:"VERSION_1_2",
                  4:"VERSION_1_3"}
 short_version_names = {1:"OF_1_0", 2:"OF_1_1", 3:"OF_1_2", 4:"OF_1_3"}
-param_version_names = {1:"1.0", 2:"1.1", 3:"1.2", 4:"1.3"}
-
-##
-# Maps and ranges related to versioning
-
-# For parameter version indications
-of_param_version_map = {
-    "1.0":VERSION_1_0,
-    "1.1":VERSION_1_1,
-    "1.2":VERSION_1_2,
-    "1.3":VERSION_1_3
-    }
-
-# For parameter version indications
-of_version_map = {
-    "1.0":VERSION_1_0,
-    "1.1":VERSION_1_1,
-    "1.2":VERSION_1_2,
-    "1.3":VERSION_1_3
-    }
 
 # The iteration object that gives the wire versions supported
 of_version_range = [VERSION_1_0, VERSION_1_1, VERSION_1_2, VERSION_1_3]
-of_version_max = VERSION_1_3
-
-
-of_version_name2wire = dict(
-    OF_VERSION_1_0=VERSION_1_0,
-    OF_VERSION_1_1=VERSION_1_1,
-    OF_VERSION_1_2=VERSION_1_2,
-    OF_VERSION_1_3=VERSION_1_3
-    )
 
 of_version_wire2name = {
     VERSION_1_0:"OF_VERSION_1_0",
@@ -367,21 +332,3 @@
     nicira = 0x00002320,
     openflow = 0x000026e1
     )
-
-def experimenter_name_lookup(experimenter_id):
-    """
-    Map an experimenter ID to its LOXI recognized name string
-    """
-    for name, id in of_g.experimenter_name_to_id.items():
-        if id == experimenter_id:
-            return name
-    return None
-
-################################################################
-#
-# Debug
-#
-################################################################
-
-loxigen_dbg_file = sys.stdout
-loxigen_log_file = sys.stdout
diff --git a/c_gen/templates/loci_setup_from_add_fns.c b/c_gen/templates/loci_setup_from_add_fns.c
deleted file mode 100644
index 5f63d29..0000000
--- a/c_gen/templates/loci_setup_from_add_fns.c
+++ /dev/null
@@ -1,250 +0,0 @@
-:: # Copyright 2013, Big Switch Networks, Inc.
-:: #
-:: # LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
-:: # the following special exception:
-:: #
-:: # LOXI Exception
-:: #
-:: # As a special exception to the terms of the EPL, you may distribute libraries
-:: # generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
-:: # that copyright and licensing notices generated by LoxiGen are not altered or removed
-:: # from the LoxiGen Libraries and the notice provided below is (i) included in
-:: # the LoxiGen Libraries, if distributed in source code form and (ii) included in any
-:: # documentation for the LoxiGen Libraries, if distributed in binary form.
-:: #
-:: # Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
-:: #
-:: # You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
-:: # a copy of the EPL at:
-:: #
-:: # http://www.eclipse.org/legal/epl-v10.html
-:: #
-:: # Unless required by applicable law or agreed to in writing, software
-:: # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-:: # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-:: # EPL for the specific language governing permissions and limitations
-:: # under the EPL.
-:: include('_copyright.c')
-#include <loci/loci.h>
-#include <loci/of_object.h>
-#include "loci_log.h"
-#include "loci_int.h"
-
-/* Flow stats entry setup for all versions */
-
-static int
-flow_stats_entry_setup_from_flow_add_common(of_flow_stats_entry_t *obj,
-                                            of_flow_add_t *flow_add,
-                                            of_object_t *effects,
-                                            int entry_match_offset,
-                                            int add_match_offset)
-{
-    int entry_len, add_len;
-    of_wire_buffer_t *wbuf;
-    int abs_offset;
-    int delta;
-    uint16_t val16;
-    uint64_t cookie;
-    of_octets_t match_octets;
-
-    /* Transfer the match underlying object from add to stats entry */
-    wbuf = OF_OBJECT_TO_WBUF(obj);
-    entry_len = _WIRE_MATCH_PADDED_LEN(obj, entry_match_offset);
-    add_len = _WIRE_MATCH_PADDED_LEN(flow_add, add_match_offset);
-
-    match_octets.bytes = add_len;
-    match_octets.data = OF_OBJECT_BUFFER_INDEX(flow_add, add_match_offset);
-
-    /* Copy data into flow entry */
-    abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, entry_match_offset);
-    of_wire_buffer_replace_data(wbuf, abs_offset, entry_len,
-                                match_octets.data, add_len);
-
-    /* Not scalar, update lengths if needed */
-    delta = add_len - entry_len;
-    if (delta != 0) {
-        /* Update parent(s) */
-        of_object_parent_length_update((of_object_t *)obj, delta);
-    }
-
-    of_flow_add_cookie_get(flow_add, &cookie);
-    of_flow_stats_entry_cookie_set(obj, cookie);
-
-    of_flow_add_priority_get(flow_add, &val16);
-    of_flow_stats_entry_priority_set(obj, val16);
-
-    of_flow_add_idle_timeout_get(flow_add, &val16);
-    of_flow_stats_entry_idle_timeout_set(obj, val16);
-
-    of_flow_add_hard_timeout_get(flow_add, &val16);
-    of_flow_stats_entry_hard_timeout_set(obj, val16);
-
-    /* Effects may come from different places */
-    if (effects != NULL) {
-        if (obj->version == OF_VERSION_1_0) {
-            OF_TRY(of_flow_stats_entry_actions_set(obj,
-                (of_list_action_t *)effects));
-        } else {
-            OF_TRY(of_flow_stats_entry_instructions_set(obj,
-                (of_list_instruction_t *)effects));
-        }
-    } else {
-        if (obj->version == OF_VERSION_1_0) {
-            of_list_action_t actions;
-            of_flow_add_actions_bind(flow_add, &actions);
-            OF_TRY(of_flow_stats_entry_actions_set(obj, &actions));
-        } else {
-            of_list_instruction_t instructions;
-            of_flow_add_instructions_bind(flow_add, &instructions);
-            OF_TRY(of_flow_stats_entry_instructions_set(obj, &instructions));
-        }
-    }
-
-    return OF_ERROR_NONE;
-}
-
-/* Flow removed setup for all versions */
-
-static int
-flow_removed_setup_from_flow_add_common(of_flow_removed_t *obj,
-                                        of_flow_add_t *flow_add,
-                                        int removed_match_offset,
-                                        int add_match_offset)
-{
-    int add_len, removed_len;
-    of_wire_buffer_t *wbuf;
-    int abs_offset;
-    int delta;
-    uint16_t val16;
-    uint64_t cookie;
-    of_octets_t match_octets;
-
-    /* Transfer the match underlying object from add to removed obj */
-    wbuf = OF_OBJECT_TO_WBUF(obj);
-    removed_len = _WIRE_MATCH_PADDED_LEN(obj, removed_match_offset);
-    add_len = _WIRE_MATCH_PADDED_LEN(flow_add, add_match_offset);
-
-    match_octets.bytes = add_len;
-    match_octets.data = OF_OBJECT_BUFFER_INDEX(flow_add, add_match_offset);
-
-    /* Copy data into flow removed */
-    abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, removed_match_offset);
-    of_wire_buffer_replace_data(wbuf, abs_offset, removed_len,
-                                match_octets.data, add_len);
-
-    /* Not scalar, update lengths if needed */
-    delta = add_len - removed_len;
-    if (delta != 0) {
-        /* Update parent(s) */
-        of_object_parent_length_update((of_object_t *)obj, delta);
-    }
-
-    of_flow_add_cookie_get(flow_add, &cookie);
-    of_flow_removed_cookie_set(obj, cookie);
-
-    of_flow_add_priority_get(flow_add, &val16);
-    of_flow_removed_priority_set(obj, val16);
-
-    of_flow_add_idle_timeout_get(flow_add, &val16);
-    of_flow_removed_idle_timeout_set(obj, val16);
-
-    if (obj->version >= OF_VERSION_1_2) {
-        of_flow_add_hard_timeout_get(flow_add, &val16);
-        of_flow_removed_hard_timeout_set(obj, val16);
-    }
-
-    return OF_ERROR_NONE;
-}
-
-/* Set up a flow removed message from the original add */
-
-int
-of_flow_removed_setup_from_flow_add(of_flow_removed_t *obj,
-                                    of_flow_add_t *flow_add)
-{
-    switch (obj->version) {
-    case OF_VERSION_1_0:
-        return flow_removed_setup_from_flow_add_common(obj, flow_add,
-                                                       8, 8);
-        break;
-    case OF_VERSION_1_1:
-    case OF_VERSION_1_2:
-    case OF_VERSION_1_3:
-        return flow_removed_setup_from_flow_add_common(obj, flow_add,
-                                                       48, 48);
-        break;
-    default:
-        return OF_ERROR_VERSION;
-        break;
-    }
-
-    return OF_ERROR_NONE;
-}
-
-
-/* Set up a packet in message from the original add */
-
-int
-of_packet_in_setup_from_flow_add(of_packet_in_t *obj,
-                                 of_flow_add_t *flow_add)
-{
-    int add_len, pkt_in_len;
-    of_wire_buffer_t *wbuf;
-    int abs_offset;
-    int delta;
-    const int pkt_in_match_offset = 16;
-    const int add_match_offset = 48;
-    of_octets_t match_octets;
-
-    if (obj->version < OF_VERSION_1_2) {
-        /* Nothing to be done before OF 1.2 */
-        return OF_ERROR_NONE;
-    }
-
-    /* Transfer match struct from flow add to packet in object */
-    wbuf = OF_OBJECT_TO_WBUF(obj);
-    pkt_in_len = _WIRE_MATCH_PADDED_LEN(obj, pkt_in_match_offset);
-    add_len = _WIRE_MATCH_PADDED_LEN(flow_add, add_match_offset);
-
-    match_octets.bytes = add_len;
-    match_octets.data = OF_OBJECT_BUFFER_INDEX(flow_add, add_match_offset);
-
-    /* Copy data into pkt_in msg */
-    abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, pkt_in_match_offset);
-    of_wire_buffer_replace_data(wbuf, abs_offset, pkt_in_len,
-                                match_octets.data, add_len);
-
-    /* Not scalar, update lengths if needed */
-    delta = add_len - pkt_in_len;
-    if (delta != 0) {
-        /* Update parent(s) */
-        of_object_parent_length_update((of_object_t *)obj, delta);
-    }
-
-    return OF_ERROR_NONE;
-}
-
-/* Set up a stats entry from the original add */
-
-int
-of_flow_stats_entry_setup_from_flow_add(of_flow_stats_entry_t *obj,
-                                        of_flow_add_t *flow_add,
-                                        of_object_t *effects)
-{
-    switch (obj->version) {
-    case OF_VERSION_1_0:
-        return flow_stats_entry_setup_from_flow_add_common(obj, flow_add,
-                                                           effects, 4, 8);
-        break;
-    case OF_VERSION_1_1:
-    case OF_VERSION_1_2:
-    case OF_VERSION_1_3:
-        return flow_stats_entry_setup_from_flow_add_common(obj, flow_add,
-                                                           effects, 48, 48);
-        break;
-    default:
-        return OF_ERROR_VERSION;
-    }
-
-    return OF_ERROR_NONE;
-}
diff --git a/c_gen/templates/locitest/main.c b/c_gen/templates/locitest/main.c
index 86f7ae6..36bf60c 100644
--- a/c_gen/templates/locitest/main.c
+++ b/c_gen/templates/locitest/main.c
@@ -33,7 +33,6 @@
     TEST_ASSERT(run_scalar_acc_tests() == TEST_PASS);
     TEST_ASSERT(run_list_tests() == TEST_PASS);
     TEST_ASSERT(run_message_tests() == TEST_PASS);
-    TEST_ASSERT(run_setup_from_add_tests() == TEST_PASS);
 
     TEST_ASSERT(run_validator_tests() == TEST_PASS);
 
diff --git a/c_gen/templates/locitest/test_setup_from_add.c b/c_gen/templates/locitest/test_setup_from_add.c
deleted file mode 100644
index ebb4968..0000000
--- a/c_gen/templates/locitest/test_setup_from_add.c
+++ /dev/null
@@ -1,133 +0,0 @@
-:: # Copyright 2013, Big Switch Networks, Inc.
-:: #
-:: # LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
-:: # the following special exception:
-:: #
-:: # LOXI Exception
-:: #
-:: # As a special exception to the terms of the EPL, you may distribute libraries
-:: # generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
-:: # that copyright and licensing notices generated by LoxiGen are not altered or removed
-:: # from the LoxiGen Libraries and the notice provided below is (i) included in
-:: # the LoxiGen Libraries, if distributed in source code form and (ii) included in any
-:: # documentation for the LoxiGen Libraries, if distributed in binary form.
-:: #
-:: # Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
-:: #
-:: # You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
-:: # a copy of the EPL at:
-:: #
-:: # http://www.eclipse.org/legal/epl-v10.html
-:: #
-:: # Unless required by applicable law or agreed to in writing, software
-:: # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-:: # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-:: # EPL for the specific language governing permissions and limitations
-:: # under the EPL.
-::
-:: include('_copyright.c')
-
-/**
- * Test code for setup from flow add routines
- */
-
-#include <locitest/test_common.h>
-
-/* mcheck is a glibc extension */
-#if defined(__linux__)
-#include <mcheck.h>
-#define MCHECK_INIT mcheck(NULL)
-#else
-#define MCHECK_INIT do { } while (0)
-#endif
-
-
-static int
-test_removed_setup_from_add(void)
-{
-    of_flow_removed_t *removed;
-    of_flow_add_t *add;
-    of_match_t m1, m2;
-
-    TEST_ASSERT((add = of_flow_add_new(OF_VERSION_1_0)) != NULL);
-    TEST_ASSERT((removed = of_flow_removed_new(OF_VERSION_1_0)) != NULL);
-
-    TEST_ASSERT(of_flow_add_OF_VERSION_1_0_populate(add, 1) != 0);
-    TEST_ASSERT(of_flow_add_match_get(add, &m1) == 0);
-
-    TEST_ASSERT(of_flow_removed_setup_from_flow_add(removed, add) == 0);
-    TEST_ASSERT(of_flow_removed_match_get(removed, &m2) == 0);
-    TEST_ASSERT(memcmp(&m1, &m2, sizeof(m1)) == 0);
-
-    of_flow_add_delete(add);
-    of_flow_removed_delete(removed);
-
-    return TEST_PASS;
-}
-
-
-static int
-test_stats_entry_setup_from_add(void)
-{
-    of_flow_add_t *add;
-    of_flow_stats_entry_t *entry;
-    of_match_t m1, m2;
-    of_list_action_t *list;
-    of_list_action_t list_out;
-
-    TEST_ASSERT((add = of_flow_add_new(OF_VERSION_1_0)) != NULL);
-    TEST_ASSERT((entry = of_flow_stats_entry_new(OF_VERSION_1_0)) != NULL);
-
-    TEST_ASSERT(of_flow_add_OF_VERSION_1_0_populate(add, 1) != 0);
-    TEST_ASSERT(of_flow_add_match_get(add, &m1) == 0);
-
-    TEST_ASSERT(of_flow_stats_entry_setup_from_flow_add(entry, add, NULL) == 0);
-    TEST_ASSERT(of_flow_stats_entry_match_get(entry, &m2) == 0);
-    TEST_ASSERT(memcmp(&m1, &m2, sizeof(m1)) == 0);
-
-    of_flow_add_delete(add);
-    of_flow_stats_entry_delete(entry);
-
-    /* @todo check action lists agree */
-
-    /* Same with an external action list */
-
-    TEST_ASSERT((add = of_flow_add_new(OF_VERSION_1_0)) != NULL);
-    TEST_ASSERT((entry = of_flow_stats_entry_new(OF_VERSION_1_0)) != NULL);
-
-    TEST_ASSERT(of_flow_add_OF_VERSION_1_0_populate(add, 1) != 0);
-    TEST_ASSERT(of_flow_add_match_get(add, &m1) == 0);
-
-    list = of_list_action_new(OF_VERSION_1_0);
-    TEST_ASSERT(list != NULL);
-    TEST_ASSERT(of_list_action_OF_VERSION_1_0_populate(list, 1) != 0);
-
-    /* Verify matches agree */
-    TEST_ASSERT(of_flow_stats_entry_setup_from_flow_add(entry, add, list) == 0);
-    TEST_ASSERT(of_flow_stats_entry_match_get(entry, &m2) == 0);
-    TEST_ASSERT(memcmp(&m1, &m2, sizeof(m1)) == 0);
-
-    of_list_action_init(&list_out, OF_VERSION_1_0, 0, 1);
-    of_flow_stats_entry_actions_bind(entry, &list_out);
-
-    /* Verify lists agree */
-    TEST_ASSERT(list->length == list_out.length);
-    TEST_ASSERT(memcmp(WBUF_BUF(list->wbuf),
-                       WBUF_BUF(list_out.wbuf),
-                       list->length));
-
-    of_flow_add_delete(add);
-    of_list_action_delete(list);
-    of_flow_stats_entry_delete(entry);
-
-    return TEST_PASS;
-}
-
-
-int run_setup_from_add_tests(void)
-{
-    RUN_TEST(removed_setup_from_add);
-    RUN_TEST(stats_entry_setup_from_add);
-
-    return TEST_PASS;
-}
diff --git a/c_gen/type_maps.py b/c_gen/type_maps.py
index ee452fc..af43a15 100644
--- a/c_gen/type_maps.py
+++ b/c_gen/type_maps.py
@@ -41,7 +41,6 @@
 import loxi_globals
 
 invalid_type = "invalid_type"
-invalid_value = "0xeeee"  # Note, as a string
 
 ################################################################
 #
@@ -393,18 +392,6 @@
         )
     }
 
-##
-# These are the objects whose length is specified by an external
-# reference, specifically another data member in the class.
-#
-#external_length_spec = {
-#    ("of_packet_out", "actions", OF_VERSION_1_0) : "actions_len",
-#    ("of_packet_out", "actions", OF_VERSION_1_1) : "actions_len",
-#    ("of_packet_out", "actions", OF_VERSION_1_2) : "actions_len",
-#    ("of_packet_out", "actions", OF_VERSION_1_3) : "actions_len"
-#}
-
-
 ################################################################
 #
 # type_val is the primary data structure that maps an
@@ -582,236 +569,3 @@
             }
         ),
 }
-
-# Set to empty dict if no extension instructions defined
-extension_instruction_id_subtype = {
-    # version 1.0
-    of_g.VERSION_1_0:dict(),
-    of_g.VERSION_1_1:dict(),
-    of_g.VERSION_1_2:dict(),
-    of_g.VERSION_1_3:dict(
-        bsn = {   # of_instruction_bsn_
-            },
-        nicira = {   # of_instruction_nicira_
-            }
-        ),
-}
-
-# Set to empty dict if no extension instructions defined
-extension_queue_prop_subtype = {}
-
-# Set to empty dict if no extension instructions defined
-extension_table_feature_prop_subtype = {}
-
-extension_objects = [
-    extension_message_subtype,
-    extension_action_subtype,
-    extension_action_id_subtype,
-    extension_instruction_subtype,
-    extension_instruction_id_subtype,
-    extension_queue_prop_subtype,
-    extension_table_feature_prop_subtype
-]
-
-################################################################
-# These are extension type generic (for messages, actions...)
-################################################################
-
-def extension_to_experimenter_name(cls):
-    """
-    Return the name of the experimenter if class is an
-    extension, else None
-
-    This is brute force; we search all extension data for a match
-    """
-
-    for ext_obj in extension_objects:
-        for version, exp_list in ext_obj.items():
-            for exp_name, classes in exp_list.items():
-                if cls in classes:
-                    return exp_name
-    return None
-
-def extension_to_experimenter_id(cls):
-    """
-    Return the ID of the experimenter if class is an
-    extension, else None
-    """
-    exp_name = extension_to_experimenter_name(cls)
-    if exp_name:
-        return of_g.experimenter_name_to_id[exp_name]
-    return None
-
-def extension_to_experimenter_macro_name(cls):
-    """
-    Return the "macro name" of the ID of the experimenter if class is an
-    extension, else None
-    """
-    exp_name = extension_to_experimenter_name(cls)
-    if exp_name:
-        return "OF_EXPERIMENTER_ID_" + exp_name.upper()
-    return None
-
-def extension_to_subtype(cls, version):
-    """
-    Generic across all extension objects, return subtype identifier
-    """
-    for ext_obj in extension_objects:
-        for version, exp_list in ext_obj.items():
-            for exp_name, classes in exp_list.items():
-                if cls in classes:
-                    return classes[cls]
-
-def class_is_extension(cls, version):
-    """
-    Return True if class, version is recognized as an extension
-    of any type (message, action....)
-
-    Accepts of_g.OF_VERSION_ANY
-    """
-
-    for ext_obj in extension_objects:
-        if cls_is_ext_obj(cls, version, ext_obj):
-            return True
-
-    return False
-
-# Internal
-def cls_is_ext_obj(cls, version, ext_obj):
-    """
-    @brief Return True if cls in an extension of type ext_obj
-    @param cls The class to check
-    @param version The version to check
-    @param ext_obj The extension object dictionary (messages, actions...)
-
-    Accepts of_g.VERSION_ANY
-    """
-
-    # Call with each version if "any" is passed
-    if version == of_g.VERSION_ANY:
-        for v in of_g.of_version_range:
-            if cls_is_ext_obj(cls, v, ext_obj):
-                return True
-    else:   # Version specified
-        if version in ext_obj:
-            for exp, subtype_vals in ext_obj[version].items():
-                if cls in subtype_vals:
-                    return True
-
-    return False
-
-################################################################
-# These are extension message specific
-################################################################
-
-def message_is_extension(cls, version):
-    """
-    Return True if cls, version is recognized as an  extension
-    This is brute force, searching records for a match
-    """
-    return cls_is_ext_obj(cls, version, extension_message_subtype)
-
-def extension_message_to_subtype(cls, version):
-    """
-    Return the subtype of the experimenter message if the class is an
-    extension, else None
-    """
-    if version in extension_message_subtype:
-        for exp, classes in extension_message_subtype[version].items():
-            for ext_class, subtype in classes.items():
-                if cls == ext_class:
-                    return subtype
-    return None
-
-################################################################
-# These are extension action specific
-################################################################
-
-def action_is_extension(cls, version):
-    """
-    Return True if cls, version is recognized as an action extension
-    This is brute force, searching records for a match
-    """
-    return cls_is_ext_obj(cls, version, extension_action_subtype)
-
-def extension_action_to_subtype(cls, version):
-    """
-    Return the ID of the action subtype (for its experimenteer)
-    if class is an action extension, else None
-    """
-    if version in extension_action_subtype:
-        for exp, classes in extension_action_subtype[version].items():
-            if cls in classes:
-                return classes[cls]
-
-    return None
-
-################################################################
-# These are extension action specific
-################################################################
-
-def action_id_is_extension(cls, version):
-    """
-    Return True if cls, version is recognized as an action ID extension
-    This is brute force, searching records for a match
-    """
-    if version not in [of_g.VERSION_1_3]: # Action IDs only 1.3
-        return False
-    return cls_is_ext_obj(cls, version, extension_action_id_subtype)
-
-def extension_action_id_to_subtype(cls, version):
-    """
-    Return the ID of the action ID subtype (for its experimenteer)
-    if class is an action ID extension, else None
-    """
-    if version in extension_action_id_subtype:
-        for exp, classes in extension_action_id_subtype[version].items():
-            if cls in classes:
-                return classes[cls]
-
-    return None
-
-################################################################
-# These are extension instruction specific
-################################################################
-
-def instruction_is_extension(cls, version):
-    """
-    Return True if cls, version is recognized as an instruction extension
-    This is brute force, searching records for a match
-    """
-    return cls_is_ext_obj(cls, version, extension_instruction_subtype)
-
-################################################################
-# These are extension instruction specific
-################################################################
-
-def instruction_id_is_extension(cls, version):
-    """
-    Return True if cls, version is recognized as an instruction ID extension
-    This is brute force, searching records for a match
-    """
-    return cls_is_ext_obj(cls, version, extension_instruction_id_subtype)
-
-################################################################
-# These are extension queue_prop specific
-################################################################
-
-def queue_prop_is_extension(cls, version):
-    """
-    Return True if cls, version is recognized as an instruction extension
-    This is brute force, searching records for a match
-    """
-    return cls_is_ext_obj(cls, version, extension_queue_prop_subtype)
-
-################################################################
-# These are extension table_feature_prop specific
-################################################################
-
-def table_feature_prop_is_extension(cls, version):
-    """
-    Return True if cls, version is recognized as an instruction extension
-    This is brute force, searching records for a match
-    """
-    return cls_is_ext_obj(cls, version,
-                          extension_table_feature_prop_subtype)
diff --git a/c_gen/util.py b/c_gen/util.py
index 54e0f80..58a4355 100644
--- a/c_gen/util.py
+++ b/c_gen/util.py
@@ -37,6 +37,3 @@
 
 def render_template(out, name, **context):
     template_utils.render_template(out, name, template_path, context)
-
-def render_static(out, name):
-    template_utils.render_static(out, name, template_path)
diff --git a/cmdline.py b/cmdline.py
index aafa019..6395fff 100644
--- a/cmdline.py
+++ b/cmdline.py
@@ -29,14 +29,6 @@
 
 from loxi_globals import OFVersions
 
-##
-# Command line options
-options = {}
-
-##
-# Command line arguments
-args = []
-
 ##@var config_default
 # The default configuration dictionary for LOXI code generation
 options_default = {
@@ -77,10 +69,6 @@
     @param cfg_dflt The default configuration dictionary
     @return A pair (options, args) as per parser return
     """
-    global options
-    global args
-    global target_version_list
-
     parser = OptionParser(version="%prog 0.1")
 
     #@todo Add options via dictionary
diff --git a/lang_c.py b/lang_c.py
index 037c1d7..1969a83 100644
--- a/lang_c.py
+++ b/lang_c.py
@@ -84,7 +84,6 @@
     'loci/src/of_object.c': static,
     'loci/src/of_utils.c': static,
     'loci/src/of_wire_buf.c': static,
-    'loci/src/loci_setup_from_add_fns.c': static,
 
     # Static LOCI documentation
     'loci/README': static,
@@ -107,7 +106,6 @@
     'locitest/src/test_ext.c': static,
     'locitest/src/test_list_limits.c': static,
     'locitest/src/test_match_utils.c': static,
-    'locitest/src/test_setup_from_add.c': static,
     'locitest/src/test_utils.c': static,
     'locitest/src/test_validator.c': static,
     'locitest/src/main.c': static,
diff --git a/loxi_front_end/frontend.py b/loxi_front_end/frontend.py
index bc79ed9..7b96fe3 100644
--- a/loxi_front_end/frontend.py
+++ b/loxi_front_end/frontend.py
@@ -112,7 +112,6 @@
                     ofinput.wire_versions.add(int(decl_ast[2]))
                 else:
                     raise InputError("Unrecognized wire protocol version %r" % decl_ast[2])
-                found_wire_version = True
 
     if not ofinput.wire_versions:
         raise InputError("Missing #version metadata")
diff --git a/loxi_ir/ir.py b/loxi_ir/ir.py
index c8ca04d..0e95473 100644
--- a/loxi_ir/ir.py
+++ b/loxi_ir/ir.py
@@ -220,7 +220,7 @@
         else:
             raise Exception("Not a fixed length member: {}.{} [{}]".format(
                 self.of_class.name,
-                self.name if hasattr("self", name) else "(unnnamed)",
+                self.name if hasattr("self", "name") else "(unnnamed)",
                 type(self).__name__))
 
 """
diff --git a/loxi_ir/ir_offset.py b/loxi_ir/ir_offset.py
index 2e6d004..9c6a5c1 100644
--- a/loxi_ir/ir_offset.py
+++ b/loxi_ir/ir_offset.py
@@ -172,7 +172,6 @@
     """
     count, base_type = type_dec_to_count_base(fe_member.oftype)
 
-    len_update = 0
     if base_type in of_mixed_types:
         base_type = of_mixed_types[base_type][version.wire_version]
 
diff --git a/loxigen.py b/loxigen.py
index 700168a..fcb2788 100755
--- a/loxigen.py
+++ b/loxigen.py
@@ -132,7 +132,6 @@
     filenames = [x for x in filenames if not x.endswith('~')]
 
     # Read input files
-    all_ofinputs = []
     for filename in filenames:
         log("Processing struct file: " + filename)
         ofinput = process_input_file(filename)
@@ -167,20 +166,9 @@
     lang_file = "lang_%s" % options.lang
     lang_module = __import__(lang_file)
 
-    if hasattr(lang_module, "config_sanity_check") and not lang_module.config_sanity_check():
-        debug("Config sanity check failed\n")
-        sys.exit(1)
-
-    # If list files, just list auto-gen files to stdout and exit
-    if options.list_files:
-        for name in lang_module.targets:
-            print options.install_dir + '/' + name
-        sys.exit(0)
-
     log("\nGenerating files for target language %s\n" % options.lang)
 
     loxi_globals.OFVersions.target_versions = target_versions
     inputs = read_input()
     build_ir(inputs)
-    #log_all_class_info()
     lang_module.generate(options.install_dir)
diff --git a/py_gen/codegen.py b/py_gen/codegen.py
index 44b4814..9c32e7f 100644
--- a/py_gen/codegen.py
+++ b/py_gen/codegen.py
@@ -118,9 +118,6 @@
                          ofclasses=modules_by_version[version]['meter_band'],
                          version=version)
 
-def generate_pp(out, name, version):
-    util.render_template(out, 'pp.py')
-
 def generate_util(out, name, version):
     util.render_template(out, 'util.py', version=version)
 
diff --git a/py_gen/tests/generic_util.py b/py_gen/tests/generic_util.py
index 8b2f59f..03885a2 100644
--- a/py_gen/tests/generic_util.py
+++ b/py_gen/tests/generic_util.py
@@ -44,12 +44,6 @@
         self.assertEquals(['\x04abc', '\x03de', '\x02f', '\x01'], a)
 
 class TestOFReader(unittest.TestCase):
-    def test_empty(self):
-        reader = OFReader("")
-        self.assertEquals(str(reader.read('')), "")
-        with self.assertRaisesRegexp(loxi.ProtocolError, "Buffer too short"):
-            reader.read_buf(1)
-
     def test_simple(self):
         reader = OFReader("abcdefg")
         self.assertEquals(reader.read('2s')[0], "ab")
diff --git a/py_gen/util.py b/py_gen/util.py
index 2a0dc54..0d8c43f 100644
--- a/py_gen/util.py
+++ b/py_gen/util.py
@@ -41,18 +41,3 @@
 
 def render_static(out, name):
     template_utils.render_static(out, name, [templates_dir])
-
-def constant_for_value(version, group, value):
-    enums = loxi_globals.ir[version].enums
-    enum = [x for x in enums if x.name == group][0]
-    for name, value2 in enum.values:
-        if value == value2:
-            return "const." + name
-    return repr(value)
-
-def ancestors(ofclass):
-    r = []
-    while ofclass:
-        r.append(ofclass)
-        ofclass = ofclass.superclass
-    return r