diff --git a/compile_definitions.py b/compile_definitions.py
index 26c3d933f13a6f4901adaff535b0779f982ffdb4..8a02a93b594f737b9635c3b78abb0655ce74fe56 100644
--- a/compile_definitions.py
+++ b/compile_definitions.py
@@ -124,9 +124,8 @@ Field = collections.namedtuple('Field', ('name', 'type', 'basic_type', 'reserved
     # Output classes
     for cls in Class.findall(xml):
 
-        cls = cls._replace(
-            properties=[p._replace(basic_type=domain_to_basic_type[p.type]) for
-                        p in cls.properties])
+        cls.properties = [p._replace(basic_type=domain_to_basic_type[p.type]) for
+                        p in cls.properties]
 
         line('''\nclass %s(AMQPClass):
     """
@@ -491,7 +490,7 @@ Field = collections.namedtuple('Field', ('name', 'type', 'basic_type', 'reserved
 
         # Get me a dict - (classid, methodid) => class of method
         dct = {}
-        for cls in get_classes(xml):
+        for cls in Class.findall(xml):
             for method in cls.methods:
                 dct[((cls.index, method.index))] = '%s%s' % (
                     name_class(cls.name), format_method_class_name(method.name))
diff --git a/coolamqp/framing/compilation/utilities.py b/coolamqp/framing/compilation/utilities.py
index 0c3a93fbaa6756a624100c7a6a42e0e3f412742e..a8ae76554557a025efb3353a8fd4a1ff0dd2d030 100644
--- a/coolamqp/framing/compilation/utilities.py
+++ b/coolamqp/framing/compilation/utilities.py
@@ -2,7 +2,7 @@
 from __future__ import absolute_import, division, print_function
 
 import math
-
+import copy
 import six
 
 from coolamqp.framing.base import BASIC_TYPES, DYNAMIC_BASIC_TYPES
@@ -41,6 +41,7 @@ class _ValueField(_Field):
         if not isinstance(xml_names, tuple):
             xml_names = (xml_names, )
         self.xml_names = xml_names
+        assert field_type is not None
         self.field_name = field_name
         self.field_type = field_type
         self.default = default
@@ -95,6 +96,10 @@ class BaseObject(object):
     def findall(cls, xml):
         return [cls(p) for p in xml.findall(cls.NAME)]
 
+    def _replace(self, **kwargs):
+        c = copy.copy(self)
+        c.__dict__.update(**kwargs)
+        return c
 
 class Constant(BaseObject):
     NAME = 'constant'
@@ -110,9 +115,9 @@ class Field(BaseObject):
     FIELDS = [
         _name,
         _ValueField(('domain', 'type'), 'type', str),
-        _SimpleField('label', None),
+        _SimpleField('label', default=None),
         _SimpleField('reserved', lambda x: bool(int(x)), default=0),
-        _ComputedField('basic_type', lambda elem: elem.attrib['type'] == elem.attrib['name']),
+        _ComputedField('basic_type', lambda elem: elem.attrib.get('type', '') == elem.attrib.get('name', '')),
         _docs
     ]
 
@@ -120,7 +125,7 @@ class Class(BaseObject):
     NAME = 'class'
     FIELDS = [
         _name,
-        _ValueField('index', int),
+        _SimpleField('index', int),
         _ComputedField('docs', lambda elem: get_docs(elem, label=True)),
         _ComputedField('methods', lambda elem: sorted(
             [Method(me) for me in elem.getchildren() if me.tag == 'method'],