[runtime] mono_class_init() - don't look for metadata if the dynamic image doesn...
[mono.git] / mono / metadata / class.c
index 04b597af1398c1c904ba7975f78472d42497bd64..e66d2c3b575169a8b7b7a42b6fb0295c5c41f8e3 100644 (file)
@@ -63,14 +63,14 @@ static MonoClass * mono_class_create_from_typedef (MonoImage *image, guint32 typ
 static gboolean mono_class_get_cached_class_info (MonoClass *klass, MonoCachedClassInfo *res);
 static gboolean can_access_type (MonoClass *access_klass, MonoClass *member_klass);
 static MonoMethod* find_method_in_metadata (MonoClass *klass, const char *name, int param_count, int flags);
-static int generic_array_methods (MonoClass *class);
-static void setup_generic_array_ifaces (MonoClass *class, MonoClass *iface, MonoMethod **methods, int pos);
+static int generic_array_methods (MonoClass *klass);
+static void setup_generic_array_ifaces (MonoClass *klass, MonoClass *iface, MonoMethod **methods, int pos);
 
 static MonoMethod* mono_class_get_virtual_methods (MonoClass* klass, gpointer *iter);
 static char* mono_assembly_name_from_token (MonoImage *image, guint32 type_token);
 static void mono_field_resolve_type (MonoClassField *field, MonoError *error);
 static guint32 mono_field_resolve_flags (MonoClassField *field);
-static void mono_class_setup_vtable_full (MonoClass *class, GList *in_setup);
+static void mono_class_setup_vtable_full (MonoClass *klass, GList *in_setup);
 static void mono_generic_class_setup_parent (MonoClass *klass, MonoClass *gklass);
 
 /*
@@ -163,9 +163,9 @@ MonoClass *
 mono_class_from_typeref (MonoImage *image, guint32 type_token)
 {
        MonoError error;
-       MonoClass *class = mono_class_from_typeref_checked (image, type_token, &error);
+       MonoClass *klass = mono_class_from_typeref_checked (image, type_token, &error);
        g_assert (mono_error_ok (&error)); /*FIXME proper error handling*/
-       return class;
+       return klass;
 }
 
 MonoClass *
@@ -346,6 +346,50 @@ mono_type_name_check_byref (MonoType *type, GString *str)
                g_string_append_c (str, '&');
 }
 
+/**
+ * mono_identifier_escape_type_name_chars:
+ * @str: a destination string
+ * @identifier: an IDENTIFIER in internal form
+ *
+ * Returns: str.
+ *
+ * The displayed form of the identifier is appended to str.
+ *
+ * The displayed form of an identifier has the characters ,+&*[]\
+ * that have special meaning in type names escaped with a preceeding
+ * backslash (\) character.
+ */
+static GString*
+mono_identifier_escape_type_name_chars (GString* str, const char* identifier)
+{
+       if (!identifier)
+               return str;
+
+       size_t n = str->len;
+       // reserve space for common case: there will be no escaped characters.
+       g_string_set_size(str, n + strlen(identifier));
+       g_string_set_size(str, n);
+
+       for (const char* s = identifier; *s != 0 ; s++) {
+               switch (*s) {
+               case ',':
+               case '+':
+               case '&':
+               case '*':
+               case '[':
+               case ']':
+               case '\\':
+                       g_string_append_c (str, '\\');
+                       g_string_append_c (str, *s);
+                       break;
+               default:
+                       g_string_append_c (str, *s);
+                       break;
+               }
+       }
+       return str;
+}
+
 static void
 mono_type_get_name_recurse (MonoType *type, GString *str, gboolean is_recursed,
                            MonoTypeNameFormat format)
@@ -427,16 +471,19 @@ mono_type_get_name_recurse (MonoType *type, GString *str, gboolean is_recursed,
                        else
                                g_string_append_c (str, '+');
                } else if (*klass->name_space) {
-                       g_string_append (str, klass->name_space);
+                       if (format == MONO_TYPE_NAME_FORMAT_IL)
+                               g_string_append (str, klass->name_space);
+                       else
+                               mono_identifier_escape_type_name_chars (str, klass->name_space);
                        g_string_append_c (str, '.');
                }
                if (format == MONO_TYPE_NAME_FORMAT_IL) {
                        char *s = strchr (klass->name, '`');
                        int len = s ? s - klass->name : strlen (klass->name);
-
                        g_string_append_len (str, klass->name, len);
-               } else
-                       g_string_append (str, klass->name);
+               } else {
+                       mono_identifier_escape_type_name_chars (str, klass->name);
+               }
                if (is_recursed)
                        break;
                if (klass->generic_class) {
@@ -537,9 +584,9 @@ mono_type_get_name_full (MonoType *type, MonoTypeNameFormat format)
  * The inverse of mono_reflection_parse_type ().
  */
 char *
-mono_type_get_full_name (MonoClass *class)
+mono_type_get_full_name (MonoClass *klass)
 {
-       return mono_type_get_name_full (mono_class_get_type (class), MONO_TYPE_NAME_FORMAT_REFLECTION);
+       return mono_type_get_name_full (mono_class_get_type (klass), MONO_TYPE_NAME_FORMAT_REFLECTION);
 }
 
 /**
@@ -632,7 +679,7 @@ inflate_generic_type (MonoImage *image, MonoType *type, MonoGenericContext *cont
                MonoType *nt;
                int num = mono_type_get_generic_param_num (type);
                MonoGenericInst *inst = context->method_inst;
-               if (!inst || !inst->type_argv)
+               if (!inst)
                        return NULL;
                if (num >= inst->type_argc) {
                        MonoGenericParamInfo *info = mono_generic_param_info (type->data.generic_param);
@@ -758,9 +805,9 @@ mono_generic_class_get_context (MonoGenericClass *gclass)
 }
 
 MonoGenericContext *
-mono_class_get_context (MonoClass *class)
+mono_class_get_context (MonoClass *klass)
 {
-       return class->generic_class ? mono_generic_class_get_context (class->generic_class) : NULL;
+       return klass->generic_class ? mono_generic_class_get_context (klass->generic_class) : NULL;
 }
 
 /*
@@ -1245,21 +1292,21 @@ mono_method_set_generic_container (MonoMethod *method, MonoGenericContainer* con
  * in a separate function since it is cheaper than calling mono_class_setup_fields.
  */
 static MonoType*
-mono_class_find_enum_basetype (MonoClass *class, MonoError *error)
+mono_class_find_enum_basetype (MonoClass *klass, MonoError *error)
 {
        MonoGenericContainer *container = NULL;
-       MonoImage *m = class->image; 
-       const int top = class->field.count;
+       MonoImage *m = klass->image;
+       const int top = klass->field.count;
        int i;
 
-       g_assert (class->enumtype);
+       g_assert (klass->enumtype);
 
        mono_error_init (error);
 
-       if (class->generic_container)
-               container = class->generic_container;
-       else if (class->generic_class) {
-               MonoClass *gklass = class->generic_class->container_class;
+       if (klass->generic_container)
+               container = klass->generic_container;
+       else if (klass->generic_class) {
+               MonoClass *gklass = klass->generic_class->container_class;
 
                container = gklass->generic_container;
                g_assert (container);
@@ -1271,17 +1318,17 @@ mono_class_find_enum_basetype (MonoClass *class, MonoError *error)
        for (i = 0; i < top; i++){
                const char *sig;
                guint32 cols [MONO_FIELD_SIZE];
-               int idx = class->field.first + i;
+               int idx = klass->field.first + i;
                MonoType *ftype;
 
-               /* class->field.first and idx points into the fieldptr table */
+               /* klass->field.first and idx points into the fieldptr table */
                mono_metadata_decode_table_row (m, MONO_TABLE_FIELD, idx, cols, MONO_FIELD_SIZE);
 
                if (cols [MONO_FIELD_FLAGS] & FIELD_ATTRIBUTE_STATIC) //no need to decode static fields
                        continue;
 
-               if (!mono_verifier_verify_field_signature (class->image, cols [MONO_FIELD_SIGNATURE], NULL)) {
-                       mono_error_set_bad_image (error, class->image, "Invalid field signature %x", cols [MONO_FIELD_SIGNATURE]);
+               if (!mono_verifier_verify_field_signature (klass->image, cols [MONO_FIELD_SIGNATURE], NULL)) {
+                       mono_error_set_bad_image (error, klass->image, "Invalid field signature %x", cols [MONO_FIELD_SIGNATURE]);
                        goto fail;
                }
 
@@ -1289,21 +1336,21 @@ mono_class_find_enum_basetype (MonoClass *class, MonoError *error)
                mono_metadata_decode_value (sig, &sig);
                /* FIELD signature == 0x06 */
                if (*sig != 0x06) {
-                       mono_error_set_bad_image (error, class->image, "Invalid field signature %x, expected 0x6 but got %x", cols [MONO_FIELD_SIGNATURE], *sig);
+                       mono_error_set_bad_image (error, klass->image, "Invalid field signature %x, expected 0x6 but got %x", cols [MONO_FIELD_SIGNATURE], *sig);
                        goto fail;
                }
 
-               ftype = mono_metadata_parse_type_full (m, container, MONO_PARSE_FIELD, cols [MONO_FIELD_FLAGS], sig + 1, &sig);
+               ftype = mono_metadata_parse_type_full (m, container, cols [MONO_FIELD_FLAGS], sig + 1, &sig);
                if (!ftype) {
                        if (mono_loader_get_last_error ()) /*FIXME plug the above to not leak errors*/
                                mono_error_set_from_loader_error (error);
                        else
-                               mono_error_set_bad_image (error, class->image, "Could not parse type for field signature %x", cols [MONO_FIELD_SIGNATURE]);
+                               mono_error_set_bad_image (error, klass->image, "Could not parse type for field signature %x", cols [MONO_FIELD_SIGNATURE]);
                        goto fail;
                }
-               if (class->generic_class) {
+               if (klass->generic_class) {
                        //FIXME do we leak here?
-                       ftype = mono_class_inflate_generic_type_checked (ftype, mono_class_get_context (class), error);
+                       ftype = mono_class_inflate_generic_type_checked (ftype, mono_class_get_context (klass), error);
                        if (!mono_error_ok (error))
                                goto fail;
                        ftype->attrs = cols [MONO_FIELD_FLAGS];
@@ -1311,7 +1358,7 @@ mono_class_find_enum_basetype (MonoClass *class, MonoError *error)
 
                return ftype;
        }
-       mono_error_set_type_load_class (error, class, "Could not find base type");
+       mono_error_set_type_load_class (error, klass, "Could not find base type");
 
 fail:
        mono_loader_assert_no_error ();
@@ -1345,50 +1392,50 @@ mono_type_has_exceptions (MonoType *type)
  * or from the heap.
  */
 static gpointer
-mono_class_alloc (MonoClass *class, int size)
+mono_class_alloc (MonoClass *klass, int size)
 {
-       if (class->generic_class)
-               return mono_image_set_alloc (class->generic_class->owner, size);
+       if (klass->generic_class)
+               return mono_image_set_alloc (klass->generic_class->owner, size);
        else
-               return mono_image_alloc (class->image, size);
+               return mono_image_alloc (klass->image, size);
 }
 
 static gpointer
-mono_class_alloc0 (MonoClass *class, int size)
+mono_class_alloc0 (MonoClass *klass, int size)
 {
        gpointer res;
 
-       res = mono_class_alloc (class, size);
+       res = mono_class_alloc (klass, size);
        memset (res, 0, size);
        return res;
 }
 
-#define mono_class_new0(class,struct_type, n_structs)          \
-    ((struct_type *) mono_class_alloc0 ((class), ((gsize) sizeof (struct_type)) * ((gsize) (n_structs))))
+#define mono_class_new0(klass,struct_type, n_structs)          \
+    ((struct_type *) mono_class_alloc0 ((klass), ((gsize) sizeof (struct_type)) * ((gsize) (n_structs))))
 
 /**
  * mono_class_setup_basic_field_info:
  * @class: The class to initialize
  *
- * Initializes the class->fields.
+ * Initializes the klass->fields.
  * LOCKING: Assumes the loader lock is held.
  */
 static void
-mono_class_setup_basic_field_info (MonoClass *class)
+mono_class_setup_basic_field_info (MonoClass *klass)
 {
        MonoClassField *field;
        MonoClass *gtd;
        MonoImage *image;
        int i, top;
 
-       if (class->fields)
+       if (klass->fields)
                return;
 
-       gtd = class->generic_class ? mono_class_get_generic_type_definition (class) : NULL;
-       image = class->image;
-       top = class->field.count;
+       gtd = klass->generic_class ? mono_class_get_generic_type_definition (klass) : NULL;
+       image = klass->image;
+       top = klass->field.count;
 
-       if (class->generic_class && image_is_dynamic (class->generic_class->container_class->image) && !class->generic_class->container_class->wastypebuilder) {
+       if (klass->generic_class && image_is_dynamic (klass->generic_class->container_class->image) && !klass->generic_class->container_class->wastypebuilder) {
                /*
                 * This happens when a generic instance of an unfinished generic typebuilder
                 * is used as an element type for creating an array type. We can't initialize
@@ -1402,24 +1449,24 @@ mono_class_setup_basic_field_info (MonoClass *class)
                mono_class_setup_basic_field_info (gtd);
 
                top = gtd->field.count;
-               class->field.first = gtd->field.first;
-               class->field.count = gtd->field.count;
+               klass->field.first = gtd->field.first;
+               klass->field.count = gtd->field.count;
        }
 
-       class->fields = mono_class_alloc0 (class, sizeof (MonoClassField) * top);
+       klass->fields = mono_class_alloc0 (klass, sizeof (MonoClassField) * top);
 
        /*
         * Fetch all the field information.
         */
        for (i = 0; i < top; i++){
-               field = &class->fields [i];
-               field->parent = class;
+               field = &klass->fields [i];
+               field->parent = klass;
 
                if (gtd) {
                        field->name = mono_field_get_name (&gtd->fields [i]);
                } else {
-                       int idx = class->field.first + i;
-                       /* class->field.first and idx points into the fieldptr table */
+                       int idx = klass->field.first + i;
+                       /* klass->field.first and idx points into the fieldptr table */
                        guint32 name_idx = mono_metadata_decode_table_row_col (image, MONO_TABLE_FIELD, idx, MONO_FIELD_NAME);
                        /* The name is needed for fieldrefs */
                        field->name = mono_metadata_string_heap (image, name_idx);
@@ -1431,23 +1478,23 @@ mono_class_setup_basic_field_info (MonoClass *class)
  * mono_class_setup_fields:
  * @class: The class to initialize
  *
- * Initializes the class->fields.
+ * Initializes the klass->fields.
  * LOCKING: Assumes the loader lock is held.
  */
 static void
-mono_class_setup_fields (MonoClass *class)
+mono_class_setup_fields (MonoClass *klass)
 {
        MonoError error;
-       MonoImage *m = class->image; 
+       MonoImage *m = klass->image;
        int top;
-       guint32 layout = class->flags & TYPE_ATTRIBUTE_LAYOUT_MASK;
+       guint32 layout = klass->flags & TYPE_ATTRIBUTE_LAYOUT_MASK;
        int i, blittable = TRUE;
        guint32 real_size = 0;
        guint32 packing_size = 0;
        gboolean explicit_size;
        MonoClassField *field;
        MonoGenericContainer *container = NULL;
-       MonoClass *gtd = class->generic_class ? mono_class_get_generic_type_definition (class) : NULL;
+       MonoClass *gtd = klass->generic_class ? mono_class_get_generic_type_definition (klass) : NULL;
 
        /*
         * FIXME: We have a race condition here.  It's possible that this function returns
@@ -1462,14 +1509,14 @@ mono_class_setup_fields (MonoClass *class)
         * This function is called for a class whenever one of its subclasses is inited.
         * For example, it's called for every subclass of Object.  What it does is this:
         *
-        *     if (class->setup_fields_called)
+        *     if (klass->setup_fields_called)
         *         return;
         *     ...
-        *     class->instance_size = 0;
+        *     klass->instance_size = 0;
         *     ...
-        *     class->setup_fields_called = 1;
+        *     klass->setup_fields_called = 1;
         *     ... critical point
-        *     class->instance_size = actual_instance_size;
+        *     klass->instance_size = actual_instance_size;
         *
         * The last two steps are sometimes reversed, but that only changes the way in which
         * the race condition works.
@@ -1480,14 +1527,14 @@ mono_class_setup_fields (MonoClass *class)
         *
         * The other case looks like this:
         *
-        *     if (class->setup_fields_called)
+        *     if (klass->setup_fields_called)
         *         return;
         *     ... critical point X
-        *     class->instance_size = 0;
+        *     klass->instance_size = 0;
         *     ... critical point Y
-        *     class->instance_size = actual_instance_size;
+        *     klass->instance_size = actual_instance_size;
         *     ...
-        *     class->setup_fields_called = 1;
+        *     klass->setup_fields_called = 1;
         *
         * Assume thread A goes through the function and makes it to critical point X.  Now
         * thread B runs through the whole of the function, returning, assuming
@@ -1495,10 +1542,10 @@ mono_class_setup_fields (MonoClass *class)
         * critical point Y, at which time `instance_size` is `0` again, invalidating thread
         * B's assumption.
         */
-       if (class->setup_fields_called)
+       if (klass->setup_fields_called)
                return;
 
-       if (class->generic_class && image_is_dynamic (class->generic_class->container_class->image) && !class->generic_class->container_class->wastypebuilder) {
+       if (klass->generic_class && image_is_dynamic (klass->generic_class->container_class->image) && !klass->generic_class->container_class->wastypebuilder) {
                /*
                 * This happens when a generic instance of an unfinished generic typebuilder
                 * is used as an element type for creating an array type. We can't initialize
@@ -1508,39 +1555,39 @@ mono_class_setup_fields (MonoClass *class)
                return;
        }
 
-       mono_class_setup_basic_field_info (class);
-       top = class->field.count;
+       mono_class_setup_basic_field_info (klass);
+       top = klass->field.count;
 
        if (gtd) {
                mono_class_setup_fields (gtd);
                if (gtd->exception_type) {
-                       mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, NULL);
+                       mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, NULL);
                        return;
                }
        }
 
-       class->instance_size = 0;
-       if (!class->rank)
-               class->sizes.class_size = 0;
+       klass->instance_size = 0;
+       if (!klass->rank)
+               klass->sizes.class_size = 0;
 
-       if (class->parent) {
-               /* For generic instances, class->parent might not have been initialized */
-               mono_class_init (class->parent);
-               if (!class->parent->size_inited) {
-                       mono_class_setup_fields (class->parent);
-                       if (class->parent->exception_type) {
-                               mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, NULL);
+       if (klass->parent) {
+               /* For generic instances, klass->parent might not have been initialized */
+               mono_class_init (klass->parent);
+               if (!klass->parent->size_inited) {
+                       mono_class_setup_fields (klass->parent);
+                       if (klass->parent->exception_type) {
+                               mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, NULL);
                                return;
                        }
                }
-               class->instance_size += class->parent->instance_size;
-               class->min_align = class->parent->min_align;
+               klass->instance_size += klass->parent->instance_size;
+               klass->min_align = klass->parent->min_align;
                /* we use |= since it may have been set already */
-               class->has_references |= class->parent->has_references;
-               blittable = class->parent->blittable;
+               klass->has_references |= klass->parent->has_references;
+               blittable = klass->parent->blittable;
        } else {
-               class->instance_size = sizeof (MonoObject);
-               class->min_align = 1;
+               klass->instance_size = sizeof (MonoObject);
+               klass->min_align = 1;
        }
 
        /* We can't really enable 16 bytes alignment until the GC supports it.
@@ -1548,42 +1595,42 @@ mono_class_setup_fields (MonoClass *class)
        boxed instance, which leads to unexplainable holes at the beginning of an object embedding a simd type.
        Bug #506144 is an example of this issue.
 
-        if (class->simd_type)
-               class->min_align = 16;
+        if (klass->simd_type)
+               klass->min_align = 16;
         */
        /* Get the real size */
-       explicit_size = mono_metadata_packing_from_typedef (class->image, class->type_token, &packing_size, &real_size);
+       explicit_size = mono_metadata_packing_from_typedef (klass->image, klass->type_token, &packing_size, &real_size);
 
        if (explicit_size) {
                if ((packing_size & 0xffffff00) != 0) {
-                       char *err_msg = g_strdup_printf ("Could not load struct '%s' with packing size %d >= 256", class->name, packing_size);
-                       mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, err_msg);
+                       char *err_msg = g_strdup_printf ("Could not load struct '%s' with packing size %d >= 256", klass->name, packing_size);
+                       mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, err_msg);
                        return;
                }
-               class->packing_size = packing_size;
-               real_size += class->instance_size;
+               klass->packing_size = packing_size;
+               real_size += klass->instance_size;
        }
 
        if (!top) {
                if (explicit_size && real_size) {
-                       class->instance_size = MAX (real_size, class->instance_size);
+                       klass->instance_size = MAX (real_size, klass->instance_size);
                }
-               class->blittable = blittable;
+               klass->blittable = blittable;
                mono_memory_barrier ();
-               class->size_inited = 1;
-               class->fields_inited = 1;
-               class->setup_fields_called = 1;
+               klass->size_inited = 1;
+               klass->fields_inited = 1;
+               klass->setup_fields_called = 1;
                return;
        }
 
-       if (layout == TYPE_ATTRIBUTE_AUTO_LAYOUT && !(mono_is_corlib_image (class->image) && !strcmp (class->name_space, "System") && !strcmp (class->name, "ValueType")))
+       if (layout == TYPE_ATTRIBUTE_AUTO_LAYOUT && !(mono_is_corlib_image (klass->image) && !strcmp (klass->name_space, "System") && !strcmp (klass->name, "ValueType")))
                blittable = FALSE;
 
        /* Prevent infinite loops if the class references itself */
-       class->setup_fields_called = 1;
+       klass->setup_fields_called = 1;
 
-       if (class->generic_container) {
-               container = class->generic_container;
+       if (klass->generic_container) {
+               container = klass->generic_container;
        } else if (gtd) {
                container = gtd->generic_container;
                g_assert (container);
@@ -1593,10 +1640,10 @@ mono_class_setup_fields (MonoClass *class)
         * Fetch all the field information.
         */
        for (i = 0; i < top; i++){
-               int idx = class->field.first + i;
-               field = &class->fields [i];
+               int idx = klass->field.first + i;
+               field = &klass->fields [i];
 
-               field->parent = class;
+               field->parent = klass;
 
                if (!field->type) {
                        mono_field_resolve_type (field, &error);
@@ -1606,7 +1653,7 @@ mono_class_setup_fields (MonoClass *class)
                                return;
                        }
                        if (!field->type)
-                               g_error ("could not resolve %s:%s\n", mono_type_get_full_name(class), field->name);
+                               g_error ("could not resolve %s:%s\n", mono_type_get_full_name(klass), field->name);
                        g_assert (field->type);
                }
 
@@ -1622,15 +1669,15 @@ mono_class_setup_fields (MonoClass *class)
                                field->offset = offset;
 
                                if (field->offset == (guint32)-1 && !(field->type->attrs & FIELD_ATTRIBUTE_STATIC)) {
-                                       mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Missing field layout info for %s", field->name));
+                                       mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Missing field layout info for %s", field->name));
                                        break;
                                }
                                if (field->offset < -1) { /*-1 is used to encode special static fields */
-                                       mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Invalid negative field offset %d for %s", field->offset, field->name));
+                                       mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Invalid negative field offset %d for %s", field->offset, field->name));
                                        break;
                                }
-                               if (class->generic_container) {
-                                       mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Generic class cannot have explicit layout."));
+                               if (klass->generic_container) {
+                                       mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Generic class cannot have explicit layout."));
                                        break;
                                }
                        }
@@ -1645,7 +1692,7 @@ mono_class_setup_fields (MonoClass *class)
                                if (field_class) {
                                        mono_class_setup_fields (field_class);
                                        if (field_class->exception_type) {
-                                               mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, NULL);
+                                               mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, NULL);
                                                break;
                                        }
                                }
@@ -1654,16 +1701,16 @@ mono_class_setup_fields (MonoClass *class)
                        }
                }
 
-               if (class->enumtype && !(field->type->attrs & FIELD_ATTRIBUTE_STATIC)) {
-                       class->cast_class = class->element_class = mono_class_from_mono_type (field->type);
-                       blittable = class->element_class->blittable;
+               if (klass->enumtype && !(field->type->attrs & FIELD_ATTRIBUTE_STATIC)) {
+                       klass->cast_class = klass->element_class = mono_class_from_mono_type (field->type);
+                       blittable = klass->element_class->blittable;
                }
 
                if (mono_type_has_exceptions (field->type)) {
-                       char *class_name = mono_type_get_full_name (class);
+                       char *class_name = mono_type_get_full_name (klass);
                        char *type_name = mono_type_full_name (field->type);
 
-                       mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, NULL);
+                       mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, NULL);
                        g_warning ("Invalid type %s for instance field %s:%s", type_name, class_name, field->name);
                        g_free (class_name);
                        g_free (type_name);
@@ -1672,46 +1719,46 @@ mono_class_setup_fields (MonoClass *class)
                /* The def_value of fields is compute lazily during vtable creation */
        }
 
-       if (class == mono_defaults.string_class)
+       if (klass == mono_defaults.string_class)
                blittable = FALSE;
 
-       class->blittable = blittable;
+       klass->blittable = blittable;
 
-       if (class->enumtype && !mono_class_enum_basetype (class)) {
-               mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, NULL);
+       if (klass->enumtype && !mono_class_enum_basetype (klass)) {
+               mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, NULL);
                return;
        }
        if (explicit_size && real_size) {
-               class->instance_size = MAX (real_size, class->instance_size);
+               klass->instance_size = MAX (real_size, klass->instance_size);
        }
 
-       if (class->exception_type)
+       if (klass->exception_type)
                return;
-       mono_class_layout_fields (class);
+       mono_class_layout_fields (klass);
 
        /*valuetypes can't be neither bigger than 1Mb or empty. */
-       if (class->valuetype && (class->instance_size <= 0 || class->instance_size > (0x100000 + sizeof (MonoObject))))
-               mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, NULL);
+       if (klass->valuetype && (klass->instance_size <= 0 || klass->instance_size > (0x100000 + sizeof (MonoObject))))
+               mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, NULL);
 
        mono_memory_barrier ();
-       class->fields_inited = 1;
+       klass->fields_inited = 1;
 }
 
 /** 
  * mono_class_setup_fields_locking:
  * @class: The class to initialize
  *
- * Initializes the class->fields array of fields.
+ * Initializes the klass->fields array of fields.
  * Aquires the loader lock.
  */
 void
-mono_class_setup_fields_locking (MonoClass *class)
+mono_class_setup_fields_locking (MonoClass *klass)
 {
        /* This can be checked without locks */
-       if (class->fields_inited)
+       if (klass->fields_inited)
                return;
        mono_loader_lock ();
-       mono_class_setup_fields (class);
+       mono_class_setup_fields (klass);
        mono_loader_unlock ();
 }
 
@@ -1780,11 +1827,11 @@ type_has_references (MonoClass *klass, MonoType *ftype)
  * LOCKING: this is supposed to be called with the loader lock held.
  */
 void
-mono_class_layout_fields (MonoClass *class)
+mono_class_layout_fields (MonoClass *klass)
 {
        int i;
-       const int top = class->field.count;
-       guint32 layout = class->flags & TYPE_ATTRIBUTE_LAYOUT_MASK;
+       const int top = klass->field.count;
+       guint32 layout = klass->flags & TYPE_ATTRIBUTE_LAYOUT_MASK;
        guint32 pass, passes, real_size;
        gboolean gc_aware_layout = FALSE;
        gboolean has_static_fields = FALSE;
@@ -1808,7 +1855,7 @@ mono_class_layout_fields (MonoClass *class)
         */
         /* corlib is missing [StructLayout] directives in many places */
        if (layout == TYPE_ATTRIBUTE_AUTO_LAYOUT) {
-               if (!class->valuetype)
+               if (!klass->valuetype)
                        gc_aware_layout = TRUE;
        }
 
@@ -1820,41 +1867,41 @@ mono_class_layout_fields (MonoClass *class)
        for (i = 0; i < top; i++) {
                MonoType *ftype;
 
-               field = &class->fields [i];
+               field = &klass->fields [i];
 
                if (!(field->type->attrs & FIELD_ATTRIBUTE_STATIC)) {
                        ftype = mono_type_get_underlying_type (field->type);
                        ftype = mono_type_get_basic_type_from_generic (ftype);
-                       if (type_has_references (class, ftype))
-                               class->has_references = TRUE;
+                       if (type_has_references (klass, ftype))
+                               klass->has_references = TRUE;
                }
        }
 
        for (i = 0; i < top; i++) {
                MonoType *ftype;
 
-               field = &class->fields [i];
+               field = &klass->fields [i];
 
                if (field->type->attrs & FIELD_ATTRIBUTE_STATIC) {
                        ftype = mono_type_get_underlying_type (field->type);
                        ftype = mono_type_get_basic_type_from_generic (ftype);
-                       if (type_has_references (class, ftype))
-                               class->has_static_refs = TRUE;
+                       if (type_has_references (klass, ftype))
+                               klass->has_static_refs = TRUE;
                }
        }
 
        for (i = 0; i < top; i++) {
                MonoType *ftype;
 
-               field = &class->fields [i];
+               field = &klass->fields [i];
 
                ftype = mono_type_get_underlying_type (field->type);
                ftype = mono_type_get_basic_type_from_generic (ftype);
-               if (type_has_references (class, ftype)) {
+               if (type_has_references (klass, ftype)) {
                        if (field->type->attrs & FIELD_ATTRIBUTE_STATIC)
-                               class->has_static_refs = TRUE;
+                               klass->has_static_refs = TRUE;
                        else
-                               class->has_references = TRUE;
+                               klass->has_references = TRUE;
                }
        }
 
@@ -1874,13 +1921,13 @@ mono_class_layout_fields (MonoClass *class)
                if (layout != TYPE_ATTRIBUTE_AUTO_LAYOUT)
                        passes = 1;
 
-               if (class->parent) {
-                       mono_class_setup_fields (class->parent);
-                       if (class->parent->exception_type) {
-                               mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, NULL);
+               if (klass->parent) {
+                       mono_class_setup_fields (klass->parent);
+                       if (klass->parent->exception_type) {
+                               mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, NULL);
                                return;
                        }
-                       real_size = class->parent->instance_size;
+                       real_size = klass->parent->instance_size;
                } else {
                        real_size = sizeof (MonoObject);
                }
@@ -1891,7 +1938,7 @@ mono_class_layout_fields (MonoClass *class)
                                guint32 size;
                                MonoType *ftype;
 
-                               field = &class->fields [i];
+                               field = &klass->fields [i];
 
                                if (mono_field_is_deleted (field))
                                        continue;
@@ -1901,7 +1948,7 @@ mono_class_layout_fields (MonoClass *class)
                                ftype = mono_type_get_underlying_type (field->type);
                                ftype = mono_type_get_basic_type_from_generic (ftype);
                                if (gc_aware_layout) {
-                                       if (type_has_references (class, ftype)) {
+                                       if (type_has_references (klass, ftype)) {
                                                if (pass == 1)
                                                        continue;
                                        } else {
@@ -1910,7 +1957,7 @@ mono_class_layout_fields (MonoClass *class)
                                        }
                                }
 
-                               if ((top == 1) && (class->instance_size == sizeof (MonoObject)) &&
+                               if ((top == 1) && (klass->instance_size == sizeof (MonoObject)) &&
                                        (strcmp (mono_field_get_name (field), "$PRIVATE$") == 0)) {
                                        /* This field is a hack inserted by MCS to empty structures */
                                        continue;
@@ -1919,29 +1966,29 @@ mono_class_layout_fields (MonoClass *class)
                                size = mono_type_size (field->type, &align);
                        
                                /* FIXME (LAMESPEC): should we also change the min alignment according to pack? */
-                               align = class->packing_size ? MIN (class->packing_size, align): align;
+                               align = klass->packing_size ? MIN (klass->packing_size, align): align;
                                /* if the field has managed references, we need to force-align it
                                 * see bug #77788
                                 */
-                               if (type_has_references (class, ftype))
+                               if (type_has_references (klass, ftype))
                                        align = MAX (align, sizeof (gpointer));
 
-                               class->min_align = MAX (align, class->min_align);
+                               klass->min_align = MAX (align, klass->min_align);
                                field->offset = real_size;
                                if (align) {
                                        field->offset += align - 1;
                                        field->offset &= ~(align - 1);
                                }
                                /*TypeBuilders produce all sort of weird things*/
-                               g_assert (image_is_dynamic (class->image) || field->offset > 0);
+                               g_assert (image_is_dynamic (klass->image) || field->offset > 0);
                                real_size = field->offset + size;
                        }
 
-                       class->instance_size = MAX (real_size, class->instance_size);
+                       klass->instance_size = MAX (real_size, klass->instance_size);
        
-                       if (class->instance_size & (class->min_align - 1)) {
-                               class->instance_size += class->min_align - 1;
-                               class->instance_size &= ~(class->min_align - 1);
+                       if (klass->instance_size & (klass->min_align - 1)) {
+                               klass->instance_size += klass->min_align - 1;
+                               klass->instance_size &= ~(klass->min_align - 1);
                        }
                }
                break;
@@ -1954,7 +2001,7 @@ mono_class_layout_fields (MonoClass *class)
                        guint32 size;
                        MonoType *ftype;
 
-                       field = &class->fields [i];
+                       field = &klass->fields [i];
 
                        /*
                         * There must be info about all the fields in a type if it
@@ -1966,8 +2013,8 @@ mono_class_layout_fields (MonoClass *class)
                                continue;
 
                        size = mono_type_size (field->type, &align);
-                       align = class->packing_size ? MIN (class->packing_size, align): align;
-                       class->min_align = MAX (align, class->min_align);
+                       align = klass->packing_size ? MIN (klass->packing_size, align): align;
+                       klass->min_align = MAX (align, klass->min_align);
 
                        /*
                         * When we get here, field->offset is already set by the
@@ -1978,9 +2025,9 @@ mono_class_layout_fields (MonoClass *class)
                        field->offset += sizeof (MonoObject);
                        ftype = mono_type_get_underlying_type (field->type);
                        ftype = mono_type_get_basic_type_from_generic (ftype);
-                       if (type_has_references (class, ftype)) {
+                       if (type_has_references (klass, ftype)) {
                                if (field->offset % sizeof (gpointer)) {
-                                       mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, NULL);
+                                       mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, NULL);
                                }
                        }
 
@@ -1990,14 +2037,14 @@ mono_class_layout_fields (MonoClass *class)
                        real_size = MAX (real_size, size + field->offset);
                }
 
-               if (class->has_references) {
+               if (klass->has_references) {
                        ref_bitmap = g_new0 (guint8, real_size / sizeof (gpointer));
 
                        /* Check for overlapping reference and non-reference fields */
                        for (i = 0; i < top; i++) {
                                MonoType *ftype;
 
-                               field = &class->fields [i];
+                               field = &klass->fields [i];
 
                                if (mono_field_is_deleted (field))
                                        continue;
@@ -2008,7 +2055,7 @@ mono_class_layout_fields (MonoClass *class)
                                        ref_bitmap [field->offset / sizeof (gpointer)] = 1;
                        }
                        for (i = 0; i < top; i++) {
-                               field = &class->fields [i];
+                               field = &klass->fields [i];
 
                                if (mono_field_is_deleted (field))
                                        continue;
@@ -2018,18 +2065,18 @@ mono_class_layout_fields (MonoClass *class)
                                // FIXME: Too much code does this
 #if 0
                                if (!MONO_TYPE_IS_REFERENCE (field->type) && ref_bitmap [field->offset / sizeof (gpointer)]) {
-                                       char *err_msg = g_strdup_printf ("Could not load type '%s' because it contains an object field at offset %d that is incorrectly aligned or overlapped by a non-object field.", class->name, field->offset);
-                                       mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, err_msg);
+                                       char *err_msg = g_strdup_printf ("Could not load type '%s' because it contains an object field at offset %d that is incorrectly aligned or overlapped by a non-object field.", klass->name, field->offset);
+                                       mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, err_msg);
                                }
 #endif
                        }
                        g_free (ref_bitmap);
                }
 
-               class->instance_size = MAX (real_size, class->instance_size);
-               if (class->instance_size & (class->min_align - 1)) {
-                       class->instance_size += class->min_align - 1;
-                       class->instance_size &= ~(class->min_align - 1);
+               klass->instance_size = MAX (real_size, klass->instance_size);
+               if (klass->instance_size & (klass->min_align - 1)) {
+                       klass->instance_size += klass->min_align - 1;
+                       klass->instance_size &= ~(klass->min_align - 1);
                }
                break;
        }
@@ -2045,13 +2092,13 @@ mono_class_layout_fields (MonoClass *class)
                 * unaligned accesses otherwise. See #78990 for a testcase.
                 */
                if (mono_align_small_structs) {
-                       if (class->instance_size <= sizeof (MonoObject) + sizeof (gpointer))
-                               class->min_align = MAX (class->min_align, class->instance_size - sizeof (MonoObject));
+                       if (klass->instance_size <= sizeof (MonoObject) + sizeof (gpointer))
+                               klass->min_align = MAX (klass->min_align, klass->instance_size - sizeof (MonoObject));
                }
        }
 
        mono_memory_barrier ();
-       class->size_inited = 1;
+       klass->size_inited = 1;
 
        /*
         * Compute static field layout and size
@@ -2060,7 +2107,7 @@ mono_class_layout_fields (MonoClass *class)
                gint32 align;
                guint32 size;
 
-               field = &class->fields [i];
+               field = &klass->fields [i];
                        
                if (!(field->type->attrs & FIELD_ATTRIBUTE_STATIC) || field->type->attrs & FIELD_ATTRIBUTE_LITERAL)
                        continue;
@@ -2068,32 +2115,32 @@ mono_class_layout_fields (MonoClass *class)
                        continue;
 
                if (mono_type_has_exceptions (field->type)) {
-                       mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, NULL);
+                       mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, NULL);
                        break;
                }
 
                has_static_fields = TRUE;
 
                size = mono_type_size (field->type, &align);
-               field->offset = class->sizes.class_size;
+               field->offset = klass->sizes.class_size;
                /*align is always non-zero here*/
                field->offset += align - 1;
                field->offset &= ~(align - 1);
-               class->sizes.class_size = field->offset + size;
+               klass->sizes.class_size = field->offset + size;
        }
 
-       if (has_static_fields && class->sizes.class_size == 0)
+       if (has_static_fields && klass->sizes.class_size == 0)
                /* Simplify code which depends on class_size != 0 if the class has static fields */
-               class->sizes.class_size = 8;
+               klass->sizes.class_size = 8;
 }
 
 static MonoMethod*
-create_array_method (MonoClass *class, const char *name, MonoMethodSignature *sig)
+create_array_method (MonoClass *klass, const char *name, MonoMethodSignature *sig)
 {
        MonoMethod *method;
 
-       method = (MonoMethod *) mono_image_alloc0 (class->image, sizeof (MonoMethodPInvoke));
-       method->klass = class;
+       method = (MonoMethod *) mono_image_alloc0 (klass->image, sizeof (MonoMethodPInvoke));
+       method->klass = klass;
        method->flags = METHOD_ATTRIBUTE_PUBLIC;
        method->iflags = METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL;
        method->signature = sig;
@@ -2118,47 +2165,47 @@ create_array_method (MonoClass *class, const char *name, MonoMethodSignature *si
  * Methods belonging to an interface are assigned a sequential slot starting
  * from 0.
  *
- * On failure this function sets class->exception_type
+ * On failure this function sets klass->exception_type
  */
 void
-mono_class_setup_methods (MonoClass *class)
+mono_class_setup_methods (MonoClass *klass)
 {
        int i, count;
        MonoMethod **methods;
 
-       if (class->methods)
+       if (klass->methods)
                return;
 
-       if (class->generic_class) {
+       if (klass->generic_class) {
                MonoError error;
-               MonoClass *gklass = class->generic_class->container_class;
+               MonoClass *gklass = klass->generic_class->container_class;
 
                mono_class_init (gklass);
                if (!gklass->exception_type)
                        mono_class_setup_methods (gklass);
                if (gklass->exception_type) {
                        /* FIXME make exception_data less opaque so it's possible to dup it here */
-                       mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Generic type definition failed to load"));
+                       mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Generic type definition failed to load"));
                        return;
                }
 
                /* The + 1 makes this always non-NULL to pass the check in mono_class_setup_methods () */
                count = gklass->method.count;
-               methods = mono_class_alloc0 (class, sizeof (MonoMethod*) * (count + 1));
+               methods = mono_class_alloc0 (klass, sizeof (MonoMethod*) * (count + 1));
 
                for (i = 0; i < count; i++) {
                        methods [i] = mono_class_inflate_generic_method_full_checked (
-                               gklass->methods [i], class, mono_class_get_context (class), &error);
+                               gklass->methods [i], klass, mono_class_get_context (klass), &error);
                        if (!mono_error_ok (&error)) {
                                char *method = mono_method_full_name (gklass->methods [i], TRUE);
-                               mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Could not inflate method %s due to %s", method, mono_error_get_message (&error)));
+                               mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Could not inflate method %s due to %s", method, mono_error_get_message (&error)));
 
                                g_free (method);
                                mono_error_cleanup (&error);
                                return;                         
                        }
                }
-       } else if (class->rank) {
+       } else if (klass->rank) {
                MonoError error;
                MonoMethod *amethod;
                MonoMethodSignature *sig;
@@ -2166,104 +2213,104 @@ mono_class_setup_methods (MonoClass *class)
                int method_num = 0;
                gboolean jagged_ctor = FALSE;
 
-               count = 3 + (class->rank > 1? 2: 1);
+               count = 3 + (klass->rank > 1? 2: 1);
 
-               mono_class_setup_interfaces (class, &error);
+               mono_class_setup_interfaces (klass, &error);
                g_assert (mono_error_ok (&error)); /*FIXME can this fail for array types?*/
 
-               if (class->rank == 1 && class->element_class->rank) {
+               if (klass->rank == 1 && klass->element_class->rank) {
                        jagged_ctor = TRUE;
-                       class->method.count ++;
+                       klass->method.count ++;
                }
 
-               if (class->interface_count) {
-                       count_generic = generic_array_methods (class);
+               if (klass->interface_count) {
+                       count_generic = generic_array_methods (klass);
                        first_generic = count;
-                       count += class->interface_count * count_generic;
+                       count += klass->interface_count * count_generic;
                }
 
-               methods = mono_class_alloc0 (class, sizeof (MonoMethod*) * count);
+               methods = mono_class_alloc0 (klass, sizeof (MonoMethod*) * count);
 
-               sig = mono_metadata_signature_alloc (class->image, class->rank);
+               sig = mono_metadata_signature_alloc (klass->image, klass->rank);
                sig->ret = &mono_defaults.void_class->byval_arg;
                sig->pinvoke = TRUE;
                sig->hasthis = TRUE;
-               for (i = 0; i < class->rank; ++i)
+               for (i = 0; i < klass->rank; ++i)
                        sig->params [i] = &mono_defaults.int32_class->byval_arg;
 
-               amethod = create_array_method (class, ".ctor", sig);
+               amethod = create_array_method (klass, ".ctor", sig);
                methods [method_num++] = amethod;
-               if (class->rank > 1) {
-                       sig = mono_metadata_signature_alloc (class->image, class->rank * 2);
+               if (klass->rank > 1) {
+                       sig = mono_metadata_signature_alloc (klass->image, klass->rank * 2);
                        sig->ret = &mono_defaults.void_class->byval_arg;
                        sig->pinvoke = TRUE;
                        sig->hasthis = TRUE;
-                       for (i = 0; i < class->rank * 2; ++i)
+                       for (i = 0; i < klass->rank * 2; ++i)
                                sig->params [i] = &mono_defaults.int32_class->byval_arg;
 
-                       amethod = create_array_method (class, ".ctor", sig);
+                       amethod = create_array_method (klass, ".ctor", sig);
                        methods [method_num++] = amethod;
                }
 
                if (jagged_ctor) {
                        /* Jagged arrays have an extra ctor in .net which creates an array of arrays */
-                       sig = mono_metadata_signature_alloc (class->image, class->rank + 1);
+                       sig = mono_metadata_signature_alloc (klass->image, klass->rank + 1);
                        sig->ret = &mono_defaults.void_class->byval_arg;
                        sig->pinvoke = TRUE;
                        sig->hasthis = TRUE;
-                       for (i = 0; i < class->rank + 1; ++i)
+                       for (i = 0; i < klass->rank + 1; ++i)
                                sig->params [i] = &mono_defaults.int32_class->byval_arg;
-                       amethod = create_array_method (class, ".ctor", sig);
+                       amethod = create_array_method (klass, ".ctor", sig);
                        methods [method_num++] = amethod;
                }
 
                /* element Get (idx11, [idx2, ...]) */
-               sig = mono_metadata_signature_alloc (class->image, class->rank);
-               sig->ret = &class->element_class->byval_arg;
+               sig = mono_metadata_signature_alloc (klass->image, klass->rank);
+               sig->ret = &klass->element_class->byval_arg;
                sig->pinvoke = TRUE;
                sig->hasthis = TRUE;
-               for (i = 0; i < class->rank; ++i)
+               for (i = 0; i < klass->rank; ++i)
                        sig->params [i] = &mono_defaults.int32_class->byval_arg;
-               amethod = create_array_method (class, "Get", sig);
+               amethod = create_array_method (klass, "Get", sig);
                methods [method_num++] = amethod;
                /* element& Address (idx11, [idx2, ...]) */
-               sig = mono_metadata_signature_alloc (class->image, class->rank);
-               sig->ret = &class->element_class->this_arg;
+               sig = mono_metadata_signature_alloc (klass->image, klass->rank);
+               sig->ret = &klass->element_class->this_arg;
                sig->pinvoke = TRUE;
                sig->hasthis = TRUE;
-               for (i = 0; i < class->rank; ++i)
+               for (i = 0; i < klass->rank; ++i)
                        sig->params [i] = &mono_defaults.int32_class->byval_arg;
-               amethod = create_array_method (class, "Address", sig);
+               amethod = create_array_method (klass, "Address", sig);
                methods [method_num++] = amethod;
                /* void Set (idx11, [idx2, ...], element) */
-               sig = mono_metadata_signature_alloc (class->image, class->rank + 1);
+               sig = mono_metadata_signature_alloc (klass->image, klass->rank + 1);
                sig->ret = &mono_defaults.void_class->byval_arg;
                sig->pinvoke = TRUE;
                sig->hasthis = TRUE;
-               for (i = 0; i < class->rank; ++i)
+               for (i = 0; i < klass->rank; ++i)
                        sig->params [i] = &mono_defaults.int32_class->byval_arg;
-               sig->params [i] = &class->element_class->byval_arg;
-               amethod = create_array_method (class, "Set", sig);
+               sig->params [i] = &klass->element_class->byval_arg;
+               amethod = create_array_method (klass, "Set", sig);
                methods [method_num++] = amethod;
 
-               for (i = 0; i < class->interface_count; i++)
-                       setup_generic_array_ifaces (class, class->interfaces [i], methods, first_generic + i * count_generic);
+               for (i = 0; i < klass->interface_count; i++)
+                       setup_generic_array_ifaces (klass, klass->interfaces [i], methods, first_generic + i * count_generic);
        } else {
                MonoError error;
 
-               count = class->method.count;
-               methods = mono_class_alloc (class, sizeof (MonoMethod*) * count);
+               count = klass->method.count;
+               methods = mono_class_alloc (klass, sizeof (MonoMethod*) * count);
                for (i = 0; i < count; ++i) {
-                       int idx = mono_metadata_translate_token_index (class->image, MONO_TABLE_METHOD, class->method.first + i + 1);
-                       methods [i] = mono_get_method_checked (class->image, MONO_TOKEN_METHOD_DEF | idx, class, NULL, &error);
+                       int idx = mono_metadata_translate_token_index (klass->image, MONO_TABLE_METHOD, klass->method.first + i + 1);
+                       methods [i] = mono_get_method_checked (klass->image, MONO_TOKEN_METHOD_DEF | idx, klass, NULL, &error);
                        if (!methods [i]) {
-                               mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Could not load method %d due to %s", i, mono_error_get_message (&error)));
+                               mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Could not load method %d due to %s", i, mono_error_get_message (&error)));
                                mono_error_cleanup (&error);
                        }
                }
        }
 
-       if (MONO_CLASS_IS_INTERFACE (class)) {
+       if (MONO_CLASS_IS_INTERFACE (klass)) {
                int slot = 0;
                /*Only assign slots to virtual methods as interfaces are allowed to have static methods.*/
                for (i = 0; i < count; ++i) {
@@ -2272,38 +2319,38 @@ mono_class_setup_methods (MonoClass *class)
                }
        }
 
-       mono_image_lock (class->image);
+       mono_image_lock (klass->image);
 
-       if (!class->methods) {
-               class->method.count = count;
+       if (!klass->methods) {
+               klass->method.count = count;
 
                /* Needed because of the double-checking locking pattern */
                mono_memory_barrier ();
 
-               class->methods = methods;
+               klass->methods = methods;
        }
 
-       mono_image_unlock (class->image);
+       mono_image_unlock (klass->image);
 }
 
 /*
  * mono_class_get_method_by_index:
  *
- *   Returns class->methods [index], initializing class->methods if neccesary.
+ *   Returns klass->methods [index], initializing klass->methods if neccesary.
  *
  * LOCKING: Acquires the loader lock.
  */
 MonoMethod*
-mono_class_get_method_by_index (MonoClass *class, int index)
+mono_class_get_method_by_index (MonoClass *klass, int index)
 {
        MonoError error;
        /* Avoid calling setup_methods () if possible */
-       if (class->generic_class && !class->methods) {
-               MonoClass *gklass = class->generic_class->container_class;
+       if (klass->generic_class && !klass->methods) {
+               MonoClass *gklass = klass->generic_class->container_class;
                MonoMethod *m;
 
                m = mono_class_inflate_generic_method_full_checked (
-                               gklass->methods [index], class, mono_class_get_context (class), &error);
+                               gklass->methods [index], klass, mono_class_get_context (klass), &error);
                g_assert (mono_error_ok (&error)); /* FIXME don't swallow the error */
                /*
                 * If setup_methods () is called later for this class, no duplicates are created,
@@ -2311,16 +2358,16 @@ mono_class_get_method_by_index (MonoClass *class, int index)
                 * is created for each context.
                 */
                /*
-               mono_class_setup_methods (class);
-               g_assert (m == class->methods [index]);
+               mono_class_setup_methods (klass);
+               g_assert (m == klass->methods [index]);
                */
                return m;
        } else {
-               mono_class_setup_methods (class);
-               if (class->exception_type) /*FIXME do proper error handling*/
+               mono_class_setup_methods (klass);
+               if (klass->exception_type) /*FIXME do proper error handling*/
                        return NULL;
-               g_assert (index >= 0 && index < class->method.count);
-               return class->methods [index];
+               g_assert (index >= 0 && index < klass->method.count);
+               return klass->methods [index];
        }
 }      
 
@@ -2331,9 +2378,9 @@ mono_class_get_method_by_index (MonoClass *class, int index)
  * CLASS's generic definition, return the inflated method corresponding to METHOD.
  */
 MonoMethod*
-mono_class_get_inflated_method (MonoClass *class, MonoMethod *method)
+mono_class_get_inflated_method (MonoClass *klass, MonoMethod *method)
 {
-       MonoClass *gklass = class->generic_class->container_class;
+       MonoClass *gklass = klass->generic_class->container_class;
        int i;
 
        g_assert (method->klass == gklass);
@@ -2343,11 +2390,11 @@ mono_class_get_inflated_method (MonoClass *class, MonoMethod *method)
 
        for (i = 0; i < gklass->method.count; ++i) {
                if (gklass->methods [i] == method) {
-                       if (class->methods) {
-                               return class->methods [i];
+                       if (klass->methods) {
+                               return klass->methods [i];
                        } else {
                                MonoError error;
-                               MonoMethod *result = mono_class_inflate_generic_method_full_checked (gklass->methods [i], class, mono_class_get_context (class), &error);
+                               MonoMethod *result = mono_class_inflate_generic_method_full_checked (gklass->methods [i], klass, mono_class_get_context (klass), &error);
                                g_assert (mono_error_ok (&error)); /* FIXME don't swallow this error */
                                return result;
                        }
@@ -2360,37 +2407,37 @@ mono_class_get_inflated_method (MonoClass *class, MonoMethod *method)
 /*
  * mono_class_get_vtable_entry:
  *
- *   Returns class->vtable [offset], computing it if neccesary. Returns NULL on failure.
+ *   Returns klass->vtable [offset], computing it if neccesary. Returns NULL on failure.
  * LOCKING: Acquires the loader lock.
  */
 MonoMethod*
-mono_class_get_vtable_entry (MonoClass *class, int offset)
+mono_class_get_vtable_entry (MonoClass *klass, int offset)
 {
        MonoMethod *m;
 
-       if (class->rank == 1) {
+       if (klass->rank == 1) {
                /* 
                 * szarrays do not overwrite any methods of Array, so we can avoid
                 * initializing their vtables in some cases.
                 */
-               mono_class_setup_vtable (class->parent);
-               if (offset < class->parent->vtable_size)
-                       return class->parent->vtable [offset];
+               mono_class_setup_vtable (klass->parent);
+               if (offset < klass->parent->vtable_size)
+                       return klass->parent->vtable [offset];
        }
 
-       if (class->generic_class) {
+       if (klass->generic_class) {
                MonoError error;
-               MonoClass *gklass = class->generic_class->container_class;
+               MonoClass *gklass = klass->generic_class->container_class;
                mono_class_setup_vtable (gklass);
                m = gklass->vtable [offset];
 
-               m = mono_class_inflate_generic_method_full_checked (m, class, mono_class_get_context (class), &error);
+               m = mono_class_inflate_generic_method_full_checked (m, klass, mono_class_get_context (klass), &error);
                g_assert (mono_error_ok (&error)); /* FIXME don't swallow this error */
        } else {
-               mono_class_setup_vtable (class);
-               if (class->exception_type)
+               mono_class_setup_vtable (klass);
+               if (klass->exception_type)
                        return NULL;
-               m = class->vtable [offset];
+               m = klass->vtable [offset];
        }
 
        return m;
@@ -2412,34 +2459,34 @@ mono_class_get_vtable_size (MonoClass *klass)
 /*
  * mono_class_setup_properties:
  *
- *   Initialize class->ext.property and class->ext.properties.
+ *   Initialize klass->ext.property and klass->ext.properties.
  *
  * This method can fail the class.
  */
 static void
-mono_class_setup_properties (MonoClass *class)
+mono_class_setup_properties (MonoClass *klass)
 {
        guint startm, endm, i, j;
        guint32 cols [MONO_PROPERTY_SIZE];
-       MonoTableInfo *msemt = &class->image->tables [MONO_TABLE_METHODSEMANTICS];
+       MonoTableInfo *msemt = &klass->image->tables [MONO_TABLE_METHODSEMANTICS];
        MonoProperty *properties;
        guint32 last;
        int first, count;
 
-       if (class->ext && class->ext->properties)
+       if (klass->ext && klass->ext->properties)
                return;
 
-       if (class->generic_class) {
-               MonoClass *gklass = class->generic_class->container_class;
+       if (klass->generic_class) {
+               MonoClass *gklass = klass->generic_class->container_class;
 
                mono_class_init (gklass);
                mono_class_setup_properties (gklass);
                if (gklass->exception_type) {
-                       mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Generic type definition failed to load"));
+                       mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Generic type definition failed to load"));
                        return;
                }
 
-               properties = mono_class_new0 (class, MonoProperty, gklass->ext->property.count + 1);
+               properties = mono_class_new0 (klass, MonoProperty, gklass->ext->property.count + 1);
 
                for (i = 0; i < gklass->ext->property.count; i++) {
                        MonoError error;
@@ -2449,47 +2496,47 @@ mono_class_setup_properties (MonoClass *class)
 
                        if (prop->get)
                                prop->get = mono_class_inflate_generic_method_full_checked (
-                                       prop->get, class, mono_class_get_context (class), &error);
+                                       prop->get, klass, mono_class_get_context (klass), &error);
                        if (prop->set)
                                prop->set = mono_class_inflate_generic_method_full_checked (
-                                       prop->set, class, mono_class_get_context (class), &error);
+                                       prop->set, klass, mono_class_get_context (klass), &error);
 
                        g_assert (mono_error_ok (&error)); /*FIXME proper error handling*/
-                       prop->parent = class;
+                       prop->parent = klass;
                }
 
                first = gklass->ext->property.first;
                count = gklass->ext->property.count;
        } else {
-               first = mono_metadata_properties_from_typedef (class->image, mono_metadata_token_index (class->type_token) - 1, &last);
+               first = mono_metadata_properties_from_typedef (klass->image, mono_metadata_token_index (klass->type_token) - 1, &last);
                count = last - first;
 
                if (count) {
-                       mono_class_setup_methods (class);
-                       if (class->exception_type)
+                       mono_class_setup_methods (klass);
+                       if (klass->exception_type)
                                return;
                }
 
-               properties = mono_class_alloc0 (class, sizeof (MonoProperty) * count);
+               properties = mono_class_alloc0 (klass, sizeof (MonoProperty) * count);
                for (i = first; i < last; ++i) {
-                       mono_metadata_decode_table_row (class->image, MONO_TABLE_PROPERTY, i, cols, MONO_PROPERTY_SIZE);
-                       properties [i - first].parent = class;
+                       mono_metadata_decode_table_row (klass->image, MONO_TABLE_PROPERTY, i, cols, MONO_PROPERTY_SIZE);
+                       properties [i - first].parent = klass;
                        properties [i - first].attrs = cols [MONO_PROPERTY_FLAGS];
-                       properties [i - first].name = mono_metadata_string_heap (class->image, cols [MONO_PROPERTY_NAME]);
+                       properties [i - first].name = mono_metadata_string_heap (klass->image, cols [MONO_PROPERTY_NAME]);
 
-                       startm = mono_metadata_methods_from_property (class->image, i, &endm);
+                       startm = mono_metadata_methods_from_property (klass->image, i, &endm);
                        for (j = startm; j < endm; ++j) {
                                MonoMethod *method;
 
                                mono_metadata_decode_row (msemt, j, cols, MONO_METHOD_SEMA_SIZE);
 
-                               if (class->image->uncompressed_metadata) {
+                               if (klass->image->uncompressed_metadata) {
                                        MonoError error;
                                        /* It seems like the MONO_METHOD_SEMA_METHOD column needs no remapping */
-                                       method = mono_get_method_checked (class->image, MONO_TOKEN_METHOD_DEF | cols [MONO_METHOD_SEMA_METHOD], class, NULL, &error);
+                                       method = mono_get_method_checked (klass->image, MONO_TOKEN_METHOD_DEF | cols [MONO_METHOD_SEMA_METHOD], klass, NULL, &error);
                                        mono_error_cleanup (&error); /* FIXME don't swallow this error */
                                } else {
-                                       method = class->methods [cols [MONO_METHOD_SEMA_METHOD] - 1 - class->method.first];
+                                       method = klass->methods [cols [MONO_METHOD_SEMA_METHOD] - 1 - klass->method.first];
                                }
 
                                switch (cols [MONO_METHOD_SEMA_SEMANTICS]) {
@@ -2506,30 +2553,30 @@ mono_class_setup_properties (MonoClass *class)
                }
        }
 
-       mono_class_alloc_ext (class);
+       mono_class_alloc_ext (klass);
 
-       mono_image_lock (class->image);
+       mono_image_lock (klass->image);
 
-       if (class->ext->properties) {
+       if (klass->ext->properties) {
                /* We leak 'properties' which was allocated from the image mempool */
-               mono_image_unlock (class->image);
+               mono_image_unlock (klass->image);
                return;
        }
 
-       class->ext->property.first = first;
-       class->ext->property.count = count;
+       klass->ext->property.first = first;
+       klass->ext->property.count = count;
 
-       /* Flush any pending writes as we do double checked locking on class->ext->properties */
+       /* Flush any pending writes as we do double checked locking on klass->ext->properties */
        mono_memory_barrier ();
 
        /* Leave this assignment as the last op in the function */
-       class->ext->properties = properties;
+       klass->ext->properties = properties;
 
-       mono_image_unlock (class->image);
+       mono_image_unlock (klass->image);
 }
 
 static MonoMethod**
-inflate_method_listz (MonoMethod **methods, MonoClass *class, MonoGenericContext *context)
+inflate_method_listz (MonoMethod **methods, MonoClass *klass, MonoGenericContext *context)
 {
        MonoMethod **om, **retval;
        int count;
@@ -2541,7 +2588,7 @@ inflate_method_listz (MonoMethod **methods, MonoClass *class, MonoGenericContext
        count = 0;
        for (om = methods, count = 0; *om; ++om, ++count) {
                MonoError error;
-               retval [count] = mono_class_inflate_generic_method_full_checked (*om, class, context, &error);
+               retval [count] = mono_class_inflate_generic_method_full_checked (*om, klass, context, &error);
                g_assert (mono_error_ok (&error)); /*FIXME proper error handling*/
        }
 
@@ -2550,35 +2597,35 @@ inflate_method_listz (MonoMethod **methods, MonoClass *class, MonoGenericContext
 
 /*This method can fail the class.*/
 static void
-mono_class_setup_events (MonoClass *class)
+mono_class_setup_events (MonoClass *klass)
 {
        int first, count;
        guint startm, endm, i, j;
        guint32 cols [MONO_EVENT_SIZE];
-       MonoTableInfo *msemt = &class->image->tables [MONO_TABLE_METHODSEMANTICS];
+       MonoTableInfo *msemt = &klass->image->tables [MONO_TABLE_METHODSEMANTICS];
        guint32 last;
        MonoEvent *events;
 
-       if (class->ext && class->ext->events)
+       if (klass->ext && klass->ext->events)
                return;
 
-       if (class->generic_class) {
-               MonoClass *gklass = class->generic_class->container_class;
+       if (klass->generic_class) {
+               MonoClass *gklass = klass->generic_class->container_class;
                MonoGenericContext *context = NULL;
 
                mono_class_setup_events (gklass);
                if (gklass->exception_type) {
-                       mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Generic type definition failed to load"));
+                       mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Generic type definition failed to load"));
                        return;
                }
 
                first = gklass->ext->event.first;
                count = gklass->ext->event.count;
 
-               events = mono_class_new0 (class, MonoEvent, count);
+               events = mono_class_new0 (klass, MonoEvent, count);
 
                if (count)
-                       context = mono_class_get_context (class);
+                       context = mono_class_get_context (klass);
 
                for (i = 0; i < count; i++) {
                        MonoError error;
@@ -2587,54 +2634,54 @@ mono_class_setup_events (MonoClass *class)
 
                        mono_error_init (&error); //since we do conditional calls, we must ensure the default value is ok
 
-                       event->parent = class;
+                       event->parent = klass;
                        event->name = gevent->name;
-                       event->add = gevent->add ? mono_class_inflate_generic_method_full_checked (gevent->add, class, context, &error) : NULL;
+                       event->add = gevent->add ? mono_class_inflate_generic_method_full_checked (gevent->add, klass, context, &error) : NULL;
                        g_assert (mono_error_ok (&error)); /*FIXME proper error handling*/
-                       event->remove = gevent->remove ? mono_class_inflate_generic_method_full_checked (gevent->remove, class, context, &error) : NULL;
+                       event->remove = gevent->remove ? mono_class_inflate_generic_method_full_checked (gevent->remove, klass, context, &error) : NULL;
                        g_assert (mono_error_ok (&error)); /*FIXME proper error handling*/
-                       event->raise = gevent->raise ? mono_class_inflate_generic_method_full_checked (gevent->raise, class, context, &error) : NULL;
+                       event->raise = gevent->raise ? mono_class_inflate_generic_method_full_checked (gevent->raise, klass, context, &error) : NULL;
                        g_assert (mono_error_ok (&error)); /*FIXME proper error handling*/
 
 #ifndef MONO_SMALL_CONFIG
-                       event->other = gevent->other ? inflate_method_listz (gevent->other, class, context) : NULL;
+                       event->other = gevent->other ? inflate_method_listz (gevent->other, klass, context) : NULL;
 #endif
                        event->attrs = gevent->attrs;
                }
        } else {
-               first = mono_metadata_events_from_typedef (class->image, mono_metadata_token_index (class->type_token) - 1, &last);
+               first = mono_metadata_events_from_typedef (klass->image, mono_metadata_token_index (klass->type_token) - 1, &last);
                count = last - first;
 
                if (count) {
-                       mono_class_setup_methods (class);
-                       if (class->exception_type) {
-                               mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Generic type definition failed to load"));
+                       mono_class_setup_methods (klass);
+                       if (klass->exception_type) {
+                               mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Generic type definition failed to load"));
                                return;
                        }
                }
 
-               events = mono_class_alloc0 (class, sizeof (MonoEvent) * count);
+               events = mono_class_alloc0 (klass, sizeof (MonoEvent) * count);
                for (i = first; i < last; ++i) {
                        MonoEvent *event = &events [i - first];
 
-                       mono_metadata_decode_table_row (class->image, MONO_TABLE_EVENT, i, cols, MONO_EVENT_SIZE);
-                       event->parent = class;
+                       mono_metadata_decode_table_row (klass->image, MONO_TABLE_EVENT, i, cols, MONO_EVENT_SIZE);
+                       event->parent = klass;
                        event->attrs = cols [MONO_EVENT_FLAGS];
-                       event->name = mono_metadata_string_heap (class->image, cols [MONO_EVENT_NAME]);
+                       event->name = mono_metadata_string_heap (klass->image, cols [MONO_EVENT_NAME]);
 
-                       startm = mono_metadata_methods_from_event (class->image, i, &endm);
+                       startm = mono_metadata_methods_from_event (klass->image, i, &endm);
                        for (j = startm; j < endm; ++j) {
                                MonoMethod *method;
 
                                mono_metadata_decode_row (msemt, j, cols, MONO_METHOD_SEMA_SIZE);
 
-                               if (class->image->uncompressed_metadata) {
+                               if (klass->image->uncompressed_metadata) {
                                        MonoError error;
                                        /* It seems like the MONO_METHOD_SEMA_METHOD column needs no remapping */
-                                       method = mono_get_method_checked (class->image, MONO_TOKEN_METHOD_DEF | cols [MONO_METHOD_SEMA_METHOD], class, NULL, &error);
+                                       method = mono_get_method_checked (klass->image, MONO_TOKEN_METHOD_DEF | cols [MONO_METHOD_SEMA_METHOD], klass, NULL, &error);
                                        mono_error_cleanup (&error); /* FIXME don't swallow this error */
                                } else {
-                                       method = class->methods [cols [MONO_METHOD_SEMA_METHOD] - 1 - class->method.first];
+                                       method = klass->methods [cols [MONO_METHOD_SEMA_METHOD] - 1 - klass->method.first];
                                }
 
                                switch (cols [MONO_METHOD_SEMA_SEMANTICS]) {
@@ -2671,25 +2718,25 @@ mono_class_setup_events (MonoClass *class)
                }
        }
 
-       mono_class_alloc_ext (class);
+       mono_class_alloc_ext (klass);
 
-       mono_image_lock (class->image);
+       mono_image_lock (klass->image);
 
-       if (class->ext->events) {
-               mono_image_unlock (class->image);
+       if (klass->ext->events) {
+               mono_image_unlock (klass->image);
                return;
        }
 
-       class->ext->event.first = first;
-       class->ext->event.count = count;
+       klass->ext->event.first = first;
+       klass->ext->event.count = count;
 
-       /* Flush any pending writes as we do double checked locking on class->ext.events */
+       /* Flush any pending writes as we do double checked locking on klass->ext.events */
        mono_memory_barrier ();
 
        /* Leave this assignment as the last op in the function */
-       class->ext->events = events;
+       klass->ext->events = events;
 
-       mono_image_unlock (class->image);
+       mono_image_unlock (klass->image);
 }
 
 /*
@@ -2715,11 +2762,11 @@ mono_unload_interface_ids (MonoBitSet *bitset)
 }
 
 void
-mono_unload_interface_id (MonoClass *class)
+mono_unload_interface_id (MonoClass *klass)
 {
-       if (global_interface_bitset && class->interface_id) {
+       if (global_interface_bitset && klass->interface_id) {
                classes_lock ();
-               mono_bitset_clear (global_interface_bitset, class->interface_id);
+               mono_bitset_clear (global_interface_bitset, klass->interface_id);
                classes_unlock ();
        }
 }
@@ -2734,11 +2781,11 @@ mono_unload_interface_id (MonoClass *class)
  * Returns: the new ID.
  */
 static guint
-mono_get_unique_iid (MonoClass *class)
+mono_get_unique_iid (MonoClass *klass)
 {
        int iid;
        
-       g_assert (MONO_CLASS_IS_INTERFACE (class));
+       g_assert (MONO_CLASS_IS_INTERFACE (klass));
 
        classes_lock ();
 
@@ -2756,17 +2803,17 @@ mono_get_unique_iid (MonoClass *class)
        }
        mono_bitset_set (global_interface_bitset, iid);
        /* set the bit also in the per-image set */
-       if (!class->generic_class) {
-               if (class->image->interface_bitset) {
-                       if (iid >= mono_bitset_size (class->image->interface_bitset)) {
-                               MonoBitSet *new_set = mono_bitset_clone (class->image->interface_bitset, iid + 1);
-                               mono_bitset_free (class->image->interface_bitset);
-                               class->image->interface_bitset = new_set;
+       if (!klass->generic_class) {
+               if (klass->image->interface_bitset) {
+                       if (iid >= mono_bitset_size (klass->image->interface_bitset)) {
+                               MonoBitSet *new_set = mono_bitset_clone (klass->image->interface_bitset, iid + 1);
+                               mono_bitset_free (klass->image->interface_bitset);
+                               klass->image->interface_bitset = new_set;
                        }
                } else {
-                       class->image->interface_bitset = mono_bitset_new (iid + 1, 0);
+                       klass->image->interface_bitset = mono_bitset_new (iid + 1, 0);
                }
-               mono_bitset_set (class->image->interface_bitset, iid);
+               mono_bitset_set (klass->image->interface_bitset, iid);
        }
 
        classes_unlock ();
@@ -2774,14 +2821,14 @@ mono_get_unique_iid (MonoClass *class)
 #ifndef MONO_SMALL_CONFIG
        if (mono_print_vtable) {
                int generic_id;
-               char *type_name = mono_type_full_name (&class->byval_arg);
-               if (class->generic_class && !class->generic_class->context.class_inst->is_open) {
-                       generic_id = class->generic_class->context.class_inst->id;
+               char *type_name = mono_type_full_name (&klass->byval_arg);
+               if (klass->generic_class && !klass->generic_class->context.class_inst->is_open) {
+                       generic_id = klass->generic_class->context.class_inst->id;
                        g_assert (generic_id != 0);
                } else {
                        generic_id = 0;
                }
-               printf ("Interface: assigned id %d to %s|%s|%d\n", iid, class->image->name, type_name, generic_id);
+               printf ("Interface: assigned id %d to %s|%s|%d\n", iid, klass->image->name, type_name, generic_id);
                g_free (type_name);
        }
 #endif
@@ -2962,9 +3009,9 @@ inflate_class_one_arg (MonoClass *gtype, MonoClass *arg0)
 }
 
 static MonoClass*
-array_class_get_if_rank (MonoClass *class, guint rank)
+array_class_get_if_rank (MonoClass *klass, guint rank)
 {
-       return rank ? mono_array_class_get (class, rank) :  class;
+       return rank ? mono_array_class_get (klass, rank) : klass;
 }
 
 static void
@@ -3005,9 +3052,9 @@ fill_valuetype_array_derived_types (MonoClass **valuetype_types, MonoClass *ecla
  * Fixing this should kill quite some code, save some bits and improve compatibility.
  */
 static MonoClass**
-get_implicit_generic_array_interfaces (MonoClass *class, int *num, int *is_enumerator)
+get_implicit_generic_array_interfaces (MonoClass *klass, int *num, int *is_enumerator)
 {
-       MonoClass *eclass = class->element_class;
+       MonoClass *eclass = klass->element_class;
        static MonoClass* generic_icollection_class = NULL;
        static MonoClass* generic_ienumerable_class = NULL;
        static MonoClass* generic_ienumerator_class = NULL;
@@ -3027,12 +3074,12 @@ get_implicit_generic_array_interfaces (MonoClass *class, int *num, int *is_enume
        internal_enumerator = FALSE;
        eclass_is_valuetype = FALSE;
        original_rank = eclass->rank;
-       if (class->byval_arg.type != MONO_TYPE_SZARRAY) {
-               if (class->generic_class && class->nested_in == mono_defaults.array_class && strcmp (class->name, "InternalEnumerator`1") == 0)  {
+       if (klass->byval_arg.type != MONO_TYPE_SZARRAY) {
+               if (klass->generic_class && klass->nested_in == mono_defaults.array_class && strcmp (klass->name, "InternalEnumerator`1") == 0)  {
                        /*
                         * For a Enumerator<T[]> we need to get the list of interfaces for T.
                         */
-                       eclass = mono_class_from_mono_type (class->generic_class->context.class_inst->type_argv [0]);
+                       eclass = mono_class_from_mono_type (klass->generic_class->context.class_inst->type_argv [0]);
                        original_rank = eclass->rank;
                        if (!eclass->rank)
                                eclass = eclass->element_class;
@@ -3204,7 +3251,7 @@ get_implicit_generic_array_interfaces (MonoClass *class, int *num, int *is_enume
        }
 #if 0
        {
-       char *type_name = mono_type_get_name_full (&class->byval_arg, 0);
+       char *type_name = mono_type_get_name_full (&klass->byval_arg, 0);
        for (i = 0; i  < real_count; ++i) {
                char *name = mono_type_get_name_full (&interfaces [i]->byval_arg, 0);
                g_print ("%s implements %s\n", type_name, name);
@@ -3235,25 +3282,25 @@ find_array_interface (MonoClass *klass, const char *name)
  * FIXME It would be nice if this information could be cached somewhere.
  */
 static int
-count_virtual_methods (MonoClass *class)
+count_virtual_methods (MonoClass *klass)
 {
        int i, count = 0;
        guint32 flags;
-       class = mono_class_get_generic_type_definition (class); /*We can find this information by looking at the GTD*/
+       klass = mono_class_get_generic_type_definition (klass); /*We can find this information by looking at the GTD*/
 
-       if (class->methods || !MONO_CLASS_HAS_STATIC_METADATA (class)) {
-               mono_class_setup_methods (class);
-               if (class->exception_type)
+       if (klass->methods || !MONO_CLASS_HAS_STATIC_METADATA (klass)) {
+               mono_class_setup_methods (klass);
+               if (klass->exception_type)
                        return -1;
 
-               for (i = 0; i < class->method.count; ++i) {
-                       flags = class->methods [i]->flags;
+               for (i = 0; i < klass->method.count; ++i) {
+                       flags = klass->methods [i]->flags;
                        if (flags & METHOD_ATTRIBUTE_VIRTUAL)
                                ++count;
                }
        } else {
-               for (i = 0; i < class->method.count; ++i) {
-                       flags = mono_metadata_decode_table_row_col (class->image, MONO_TABLE_METHOD, class->method.first + i, MONO_METHOD_FLAGS);
+               for (i = 0; i < klass->method.count; ++i) {
+                       flags = mono_metadata_decode_table_row_col (klass->image, MONO_TABLE_METHOD, klass->method.first + i, MONO_METHOD_FLAGS);
 
                        if (flags & METHOD_ATTRIBUTE_VIRTUAL)
                                ++count;
@@ -3431,7 +3478,7 @@ mono_class_interface_match (const uint8_t *bitmap, int id)
  * Return -1 on failure and set exception_type
  */
 static int
-setup_interface_offsets (MonoClass *class, int cur_slot, gboolean overwrite)
+setup_interface_offsets (MonoClass *klass, int cur_slot, gboolean overwrite)
 {
        MonoError error;
        MonoClass *k, *ic;
@@ -3445,20 +3492,20 @@ setup_interface_offsets (MonoClass *class, int cur_slot, gboolean overwrite)
        int num_array_interfaces;
        int is_enumerator = FALSE;
 
-       mono_class_setup_supertypes (class);
+       mono_class_setup_supertypes (klass);
        /* 
         * get the implicit generic interfaces for either the arrays or for System.Array/InternalEnumerator<T>
         * implicit interfaces have the property that they are assigned the same slot in the
         * vtables for compatible interfaces
         */
-       array_interfaces = get_implicit_generic_array_interfaces (class, &num_array_interfaces, &is_enumerator);
+       array_interfaces = get_implicit_generic_array_interfaces (klass, &num_array_interfaces, &is_enumerator);
 
        /* compute maximum number of slots and maximum interface id */
        max_iid = 0;
        num_ifaces = num_array_interfaces; /* this can include duplicated ones */
-       ifaces_array = g_new0 (GPtrArray *, class->idepth);
-       for (j = 0; j < class->idepth; j++) {
-               k = class->supertypes [j];
+       ifaces_array = g_new0 (GPtrArray *, klass->idepth);
+       for (j = 0; j < klass->idepth; j++) {
+               k = klass->supertypes [j];
                num_ifaces += k->interface_count;
                for (i = 0; i < k->interface_count; i++) {
                        ic = k->interfaces [i];
@@ -3472,7 +3519,7 @@ setup_interface_offsets (MonoClass *class, int cur_slot, gboolean overwrite)
                ifaces = mono_class_get_implemented_interfaces (k, &error);
                if (!mono_error_ok (&error)) {
                        char *name = mono_type_get_full_name (k);
-                       mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Error getting the interfaces of %s due to %s", name, mono_error_get_message (&error)));
+                       mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Error getting the interfaces of %s due to %s", name, mono_error_get_message (&error)));
                        g_free (name);
                        mono_error_cleanup (&error);
                        cur_slot = -1;
@@ -3496,12 +3543,12 @@ setup_interface_offsets (MonoClass *class, int cur_slot, gboolean overwrite)
                        max_iid = ic->interface_id;
        }
 
-       if (MONO_CLASS_IS_INTERFACE (class)) {
+       if (MONO_CLASS_IS_INTERFACE (klass)) {
                num_ifaces++;
-               if (max_iid < class->interface_id)
-                       max_iid = class->interface_id;
+               if (max_iid < klass->interface_id)
+                       max_iid = klass->interface_id;
        }
-       class->max_interface_id = max_iid;
+       klass->max_interface_id = max_iid;
        /* compute vtable offset for interfaces */
        interfaces_full = g_malloc0 (sizeof (MonoClass*) * num_ifaces);
        interface_offsets_full = g_malloc (sizeof (int) * num_ifaces);
@@ -3511,8 +3558,8 @@ setup_interface_offsets (MonoClass *class, int cur_slot, gboolean overwrite)
        }
 
        /* skip the current class */
-       for (j = 0; j < class->idepth - 1; j++) {
-               k = class->supertypes [j];
+       for (j = 0; j < klass->idepth - 1; j++) {
+               k = klass->supertypes [j];
                ifaces = ifaces_array [j];
 
                if (ifaces) {
@@ -3528,8 +3575,8 @@ setup_interface_offsets (MonoClass *class, int cur_slot, gboolean overwrite)
                }
        }
 
-       g_assert (class == class->supertypes [class->idepth - 1]);
-       ifaces = ifaces_array [class->idepth - 1];
+       g_assert (klass == klass->supertypes [klass->idepth - 1]);
+       ifaces = ifaces_array [klass->idepth - 1];
        if (ifaces) {
                for (i = 0; i < ifaces->len; ++i) {
                        int count;
@@ -3539,7 +3586,7 @@ setup_interface_offsets (MonoClass *class, int cur_slot, gboolean overwrite)
                        count = count_virtual_methods (ic);
                        if (count == -1) {
                                char *name = mono_type_get_full_name (ic);
-                               mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Error calculating interface offset of %s", name));
+                               mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Error calculating interface offset of %s", name));
                                g_free (name);
                                cur_slot = -1;
                                goto end;
@@ -3548,13 +3595,13 @@ setup_interface_offsets (MonoClass *class, int cur_slot, gboolean overwrite)
                }
        }
 
-       if (MONO_CLASS_IS_INTERFACE (class))
-               set_interface_and_offset (num_ifaces, interfaces_full, interface_offsets_full, class, cur_slot, TRUE);
+       if (MONO_CLASS_IS_INTERFACE (klass))
+               set_interface_and_offset (num_ifaces, interfaces_full, interface_offsets_full, klass, cur_slot, TRUE);
 
        if (num_array_interfaces) {
                if (is_enumerator) {
-                       int ienumerator_idx = find_array_interface (class, "IEnumerator`1");
-                       int ienumerator_offset = find_interface_offset (num_ifaces, interfaces_full, interface_offsets_full, class->interfaces [ienumerator_idx]);
+                       int ienumerator_idx = find_array_interface (klass, "IEnumerator`1");
+                       int ienumerator_offset = find_interface_offset (num_ifaces, interfaces_full, interface_offsets_full, klass->interfaces [ienumerator_idx]);
                        g_assert (ienumerator_offset >= 0);
                        for (i = 0; i < num_array_interfaces; ++i) {
                                ic = array_interfaces [i];
@@ -3562,21 +3609,21 @@ setup_interface_offsets (MonoClass *class, int cur_slot, gboolean overwrite)
                                        set_interface_and_offset (num_ifaces, interfaces_full, interface_offsets_full, ic, ienumerator_offset, TRUE);
                                else
                                        g_assert_not_reached ();
-                               /*g_print ("type %s has %s offset at %d (%s)\n", class->name, ic->name, interface_offsets_full [ic->interface_id], class->interfaces [0]->name);*/
+                               /*g_print ("type %s has %s offset at %d (%s)\n", klass->name, ic->name, interface_offsets_full [ic->interface_id], klass->interfaces [0]->name);*/
                        }
                } else {
                        int ilist_offset, icollection_offset, ienumerable_offset, ireadonlylist_offset, ireadonlycollection_offset;
-                       int ilist_iface_idx = find_array_interface (class, "IList`1");
-                       MonoClass* ilist_class = class->interfaces [ilist_iface_idx];
-                       int ireadonlylist_iface_idx = find_array_interface (class, "IReadOnlyList`1");
-                       MonoClass* ireadonlylist_class = ireadonlylist_iface_idx != -1 ? class->interfaces [ireadonlylist_iface_idx] : NULL;
+                       int ilist_iface_idx = find_array_interface (klass, "IList`1");
+                       MonoClass* ilist_class = klass->interfaces [ilist_iface_idx];
+                       int ireadonlylist_iface_idx = find_array_interface (klass, "IReadOnlyList`1");
+                       MonoClass* ireadonlylist_class = ireadonlylist_iface_idx != -1 ? klass->interfaces [ireadonlylist_iface_idx] : NULL;
                        int icollection_iface_idx = find_array_interface (ilist_class, "ICollection`1");
                        int ienumerable_iface_idx = find_array_interface (ilist_class, "IEnumerable`1");
                        int ireadonlycollection_iface_idx = ireadonlylist_iface_idx != -1 ? find_array_interface (ireadonlylist_class, "IReadOnlyCollection`1") : -1;
-                       ilist_offset = find_interface_offset (num_ifaces, interfaces_full, interface_offsets_full, class->interfaces [ilist_iface_idx]);
+                       ilist_offset = find_interface_offset (num_ifaces, interfaces_full, interface_offsets_full, klass->interfaces [ilist_iface_idx]);
                        icollection_offset = find_interface_offset (num_ifaces, interfaces_full, interface_offsets_full, ilist_class->interfaces [icollection_iface_idx]);
                        ienumerable_offset = find_interface_offset (num_ifaces, interfaces_full, interface_offsets_full, ilist_class->interfaces [ienumerable_iface_idx]);
-                       ireadonlylist_offset = ireadonlylist_iface_idx != -1 ? find_interface_offset (num_ifaces, interfaces_full, interface_offsets_full, class->interfaces [ireadonlylist_iface_idx]) : -1;
+                       ireadonlylist_offset = ireadonlylist_iface_idx != -1 ? find_interface_offset (num_ifaces, interfaces_full, interface_offsets_full, klass->interfaces [ireadonlylist_iface_idx]) : -1;
                        ireadonlycollection_offset = ireadonlycollection_iface_idx != -1 ? find_interface_offset (num_ifaces, interfaces_full, interface_offsets_full, ireadonlylist_class->interfaces [ireadonlycollection_iface_idx]) : -1;
                        g_assert (ilist_offset >= 0 && icollection_offset >= 0 && ienumerable_offset >= 0);
                        for (i = 0; i < num_array_interfaces; ++i) {
@@ -3595,7 +3642,7 @@ setup_interface_offsets (MonoClass *class, int cur_slot, gboolean overwrite)
                                else
                                        g_assert_not_reached ();
                                set_interface_and_offset (num_ifaces, interfaces_full, interface_offsets_full, ic, offset, TRUE);
-                               /*g_print ("type %s has %s offset at %d (%s)\n", class->name, ic->name, offset, class->interfaces [0]->name);*/
+                               /*g_print ("type %s has %s offset at %d (%s)\n", klass->name, ic->name, offset, klass->interfaces [0]->name);*/
                        }
                }
        }
@@ -3614,36 +3661,36 @@ setup_interface_offsets (MonoClass *class, int cur_slot, gboolean overwrite)
         * mono_class_setup_interface_offsets () passes 0 as CUR_SLOT, so the computed interface offsets will be invalid. This
         * means we have to overwrite those when called from other places (#4440).
         */
-       if (class->interfaces_packed) {
+       if (klass->interfaces_packed) {
                if (!overwrite)
-                       g_assert (class->interface_offsets_count == interface_offsets_count);
+                       g_assert (klass->interface_offsets_count == interface_offsets_count);
        } else {
                uint8_t *bitmap;
                int bsize;
-               class->interface_offsets_count = interface_offsets_count;
-               class->interfaces_packed = mono_class_alloc (class, sizeof (MonoClass*) * interface_offsets_count);
-               class->interface_offsets_packed = mono_class_alloc (class, sizeof (guint16) * interface_offsets_count);
+               klass->interface_offsets_count = interface_offsets_count;
+               klass->interfaces_packed = mono_class_alloc (klass, sizeof (MonoClass*) * interface_offsets_count);
+               klass->interface_offsets_packed = mono_class_alloc (klass, sizeof (guint16) * interface_offsets_count);
                bsize = (sizeof (guint8) * ((max_iid + 1) >> 3)) + (((max_iid + 1) & 7)? 1 :0);
 #ifdef COMPRESSED_INTERFACE_BITMAP
                bitmap = g_malloc0 (bsize);
 #else
-               bitmap = mono_class_alloc0 (class, bsize);
+               bitmap = mono_class_alloc0 (klass, bsize);
 #endif
                for (i = 0; i < interface_offsets_count; i++) {
                        int id = interfaces_full [i]->interface_id;
                        bitmap [id >> 3] |= (1 << (id & 7));
-                       class->interfaces_packed [i] = interfaces_full [i];
-                       class->interface_offsets_packed [i] = interface_offsets_full [i];
+                       klass->interfaces_packed [i] = interfaces_full [i];
+                       klass->interface_offsets_packed [i] = interface_offsets_full [i];
                        /*if (num_array_interfaces)
-                         g_print ("type %s has %s offset at %d\n", mono_type_get_name_full (&class->byval_arg, 0), mono_type_get_name_full (&interfaces_full [i]->byval_arg, 0), interface_offsets_full [i]);*/
+                         g_print ("type %s has %s offset at %d\n", mono_type_get_name_full (&klass->byval_arg, 0), mono_type_get_name_full (&interfaces_full [i]->byval_arg, 0), interface_offsets_full [i]);*/
                }
 #ifdef COMPRESSED_INTERFACE_BITMAP
                i = mono_compress_bitmap (NULL, bitmap, bsize);
-               class->interface_bitmap = mono_class_alloc0 (class, i);
-               mono_compress_bitmap (class->interface_bitmap, bitmap, bsize);
+               klass->interface_bitmap = mono_class_alloc0 (klass, i);
+               mono_compress_bitmap (klass->interface_bitmap, bitmap, bsize);
                g_free (bitmap);
 #else
-               class->interface_bitmap = bitmap;
+               klass->interface_bitmap = bitmap;
 #endif
        }
 
@@ -3651,7 +3698,7 @@ end:
        g_free (interfaces_full);
        g_free (interface_offsets_full);
        g_free (array_interfaces);
-       for (i = 0; i < class->idepth; i++) {
+       for (i = 0; i < klass->idepth; i++) {
                ifaces = ifaces_array [i];
                if (ifaces)
                        g_ptr_array_free (ifaces, TRUE);
@@ -3659,7 +3706,7 @@ end:
        g_free (ifaces_array);
        
        //printf ("JUST DONE: ");
-       //print_implemented_interfaces (class);
+       //print_implemented_interfaces (klass);
  
        return cur_slot;
 }
@@ -3667,20 +3714,20 @@ end:
 /*
  * Setup interface offsets for interfaces. 
  * Initializes:
- * - class->max_interface_id
- * - class->interface_offsets_count
- * - class->interfaces_packed
- * - class->interface_offsets_packed
- * - class->interface_bitmap
+ * - klass->max_interface_id
+ * - klass->interface_offsets_count
+ * - klass->interfaces_packed
+ * - klass->interface_offsets_packed
+ * - klass->interface_bitmap
  *
  * This function can fail @class.
  */
 void
-mono_class_setup_interface_offsets (MonoClass *class)
+mono_class_setup_interface_offsets (MonoClass *klass)
 {
        mono_loader_lock ();
 
-       setup_interface_offsets (class, 0, FALSE);
+       setup_interface_offsets (klass, 0, FALSE);
 
        mono_loader_unlock ();
 }
@@ -3705,32 +3752,32 @@ mono_class_has_gtd_parent (MonoClass *klass, MonoClass *parent)
 }
 
 gboolean
-mono_class_check_vtable_constraints (MonoClass *class, GList *in_setup)
+mono_class_check_vtable_constraints (MonoClass *klass, GList *in_setup)
 {
        MonoGenericInst *ginst;
        int i;
-       if (!class->generic_class) {
-               mono_class_setup_vtable_full (class, in_setup);
-               return class->exception_type == 0;
+       if (!klass->generic_class) {
+               mono_class_setup_vtable_full (klass, in_setup);
+               return klass->exception_type == 0;
        }
 
-       mono_class_setup_vtable_full (mono_class_get_generic_type_definition (class), in_setup);
-       if (class->generic_class->container_class->exception_type) {
-               mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Failed to load generic definition vtable"));
+       mono_class_setup_vtable_full (mono_class_get_generic_type_definition (klass), in_setup);
+       if (klass->generic_class->container_class->exception_type) {
+               mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Failed to load generic definition vtable"));
                return FALSE;
        }
 
-       ginst = class->generic_class->context.class_inst;
+       ginst = klass->generic_class->context.class_inst;
        for (i = 0; i < ginst->type_argc; ++i) {
                MonoClass *arg;
                if (ginst->type_argv [i]->type != MONO_TYPE_GENERICINST)
                        continue;
                arg = mono_class_from_mono_type (ginst->type_argv [i]);
                /*Those 2 will be checked by mono_class_setup_vtable itself*/
-               if (mono_class_has_gtd_parent (class, arg) || mono_class_has_gtd_parent (arg, class))
+               if (mono_class_has_gtd_parent (klass, arg) || mono_class_has_gtd_parent (arg, klass))
                        continue;
                if (!mono_class_check_vtable_constraints (arg, in_setup)) {
-                       mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Failed to load generic parameter %d", i));
+                       mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Failed to load generic parameter %d", i));
                        return FALSE;
                }
        }
@@ -3745,18 +3792,18 @@ mono_class_check_vtable_constraints (MonoClass *class, GList *in_setup)
  * - vtable
  * - vtable_size
  * Plus all the fields initialized by setup_interface_offsets ().
- * If there is an error during vtable construction, class->exception_type is set.
+ * If there is an error during vtable construction, klass->exception_type is set.
  *
  * LOCKING: Acquires the loader lock.
  */
 void
-mono_class_setup_vtable (MonoClass *class)
+mono_class_setup_vtable (MonoClass *klass)
 {
-       mono_class_setup_vtable_full (class, NULL);
+       mono_class_setup_vtable_full (klass, NULL);
 }
 
 static void
-mono_class_setup_vtable_full (MonoClass *class, GList *in_setup)
+mono_class_setup_vtable_full (MonoClass *klass, GList *in_setup)
 {
        MonoMethod **overrides;
        MonoGenericContext *context;
@@ -3764,66 +3811,66 @@ mono_class_setup_vtable_full (MonoClass *class, GList *in_setup)
        int onum = 0;
        gboolean ok = TRUE;
 
-       if (class->vtable)
+       if (klass->vtable)
                return;
 
-       if (MONO_CLASS_IS_INTERFACE (class)) {
+       if (MONO_CLASS_IS_INTERFACE (klass)) {
                /* This sets method->slot for all methods if this is an interface */
-               mono_class_setup_methods (class);
+               mono_class_setup_methods (klass);
                return;
        }
 
-       if (class->exception_type)
+       if (klass->exception_type)
                return;
 
-       if (g_list_find (in_setup, class))
+       if (g_list_find (in_setup, klass))
                return;
 
        mono_loader_lock ();
 
-       if (class->vtable) {
+       if (klass->vtable) {
                mono_loader_unlock ();
                return;
        }
 
        mono_stats.generic_vtable_count ++;
-       in_setup = g_list_prepend (in_setup, class);
+       in_setup = g_list_prepend (in_setup, klass);
 
-       if (class->generic_class) {
-               if (!mono_class_check_vtable_constraints (class, in_setup)) {
+       if (klass->generic_class) {
+               if (!mono_class_check_vtable_constraints (klass, in_setup)) {
                        mono_loader_unlock ();
-                       g_list_remove (in_setup, class);
+                       g_list_remove (in_setup, klass);
                        return;
                }
 
-               context = mono_class_get_context (class);
-               type_token = class->generic_class->container_class->type_token;
+               context = mono_class_get_context (klass);
+               type_token = klass->generic_class->container_class->type_token;
        } else {
-               context = (MonoGenericContext *) class->generic_container;              
-               type_token = class->type_token;
+               context = (MonoGenericContext *) klass->generic_container;
+               type_token = klass->type_token;
        }
 
-       if (image_is_dynamic (class->image)) {
+       if (image_is_dynamic (klass->image)) {
                /* Generic instances can have zero method overrides without causing any harm.
                 * This is true since we don't do layout all over again for them, we simply inflate
                 * the layout of the parent.
                 */
-               mono_reflection_get_dynamic_overrides (class, &overrides, &onum);
+               mono_reflection_get_dynamic_overrides (klass, &overrides, &onum);
        } else {
                /* The following call fails if there are missing methods in the type */
                /* FIXME it's probably a good idea to avoid this for generic instances. */
-               ok = mono_class_get_overrides_full (class->image, type_token, &overrides, &onum, context);
+               ok = mono_class_get_overrides_full (klass->image, type_token, &overrides, &onum, context);
        }
 
        if (ok)
-               mono_class_setup_vtable_general (class, overrides, onum, in_setup);
+               mono_class_setup_vtable_general (klass, overrides, onum, in_setup);
        else
-               mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Could not load list of method overrides"));
+               mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Could not load list of method overrides"));
                
        g_free (overrides);
 
        mono_loader_unlock ();
-       g_list_remove (in_setup, class);
+       g_list_remove (in_setup, klass);
 
        return;
 }
@@ -3909,7 +3956,7 @@ is_wcf_hack_disabled (void)
 }
 
 static gboolean
-check_interface_method_override (MonoClass *class, MonoMethod *im, MonoMethod *cm, gboolean require_newslot, gboolean interface_is_explicitly_implemented_by_class, gboolean slot_is_empty)
+check_interface_method_override (MonoClass *klass, MonoMethod *im, MonoMethod *cm, gboolean require_newslot, gboolean interface_is_explicitly_implemented_by_class, gboolean slot_is_empty)
 {
        MonoMethodSignature *cmsig, *imsig;
        if (strcmp (im->name, cm->name) == 0) {
@@ -3934,7 +3981,7 @@ check_interface_method_override (MonoClass *class, MonoMethod *im, MonoMethod *c
                cmsig = mono_method_signature (cm);
                imsig = mono_method_signature (im);
                if (!cmsig || !imsig) {
-                       mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Could not resolve the signature of a virtual method"));
+                       mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Could not resolve the signature of a virtual method"));
                        return FALSE;
                }
 
@@ -3946,13 +3993,13 @@ check_interface_method_override (MonoClass *class, MonoMethod *im, MonoMethod *c
                }
                TRACE_INTERFACE_VTABLE (printf ("[SECURITY CHECKS]"));
                if (mono_security_core_clr_enabled ())
-                       mono_security_core_clr_check_override (class, cm, im);
+                       mono_security_core_clr_check_override (klass, cm, im);
 
                TRACE_INTERFACE_VTABLE (printf ("[NAME CHECK OK]"));
                if (is_wcf_hack_disabled () && !mono_method_can_access_method_full (cm, im, NULL)) {
                        char *body_name = mono_method_full_name (cm, TRUE);
                        char *decl_name = mono_method_full_name (im, TRUE);
-                       mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Method %s overrides method '%s' which is not accessible", body_name, decl_name));
+                       mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Method %s overrides method '%s' which is not accessible", body_name, decl_name));
                        g_free (body_name);
                        g_free (decl_name);
                        return FALSE;
@@ -3976,7 +4023,7 @@ check_interface_method_override (MonoClass *class, MonoMethod *im, MonoMethod *c
                cmsig = mono_method_signature (cm);
                imsig = mono_method_signature (im);
                if (!cmsig || !imsig) {
-                       mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Could not resolve the signature of a virtual method"));
+                       mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Could not resolve the signature of a virtual method"));
                        return FALSE;
                }
 
@@ -4027,13 +4074,13 @@ check_interface_method_override (MonoClass *class, MonoMethod *im, MonoMethod *c
                
                TRACE_INTERFACE_VTABLE (printf ("[SECURITY CHECKS (INJECTED CASE)]"));
                if (mono_security_core_clr_enabled ())
-                       mono_security_core_clr_check_override (class, cm, im);
+                       mono_security_core_clr_check_override (klass, cm, im);
 
                TRACE_INTERFACE_VTABLE (printf ("[INJECTED INTERFACE CHECK OK]"));
                if (is_wcf_hack_disabled () && !mono_method_can_access_method_full (cm, im, NULL)) {
                        char *body_name = mono_method_full_name (cm, TRUE);
                        char *decl_name = mono_method_full_name (im, TRUE);
-                       mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Method %s overrides method '%s' which is not accessible", body_name, decl_name));
+                       mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Method %s overrides method '%s' which is not accessible", body_name, decl_name));
                        g_free (body_name);
                        g_free (decl_name);
                        return FALSE;
@@ -4066,20 +4113,20 @@ print_overrides (GHashTable *override_map, const char *message) {
        }
 }
 static void
-print_vtable_full (MonoClass *class, MonoMethod** vtable, int size, int first_non_interface_slot, const char *message, gboolean print_interfaces) {
-       char *full_name = mono_type_full_name (&class->byval_arg);
+print_vtable_full (MonoClass *klass, MonoMethod** vtable, int size, int first_non_interface_slot, const char *message, gboolean print_interfaces) {
+       char *full_name = mono_type_full_name (&klass->byval_arg);
        int i;
        int parent_size;
        
        printf ("*** Vtable for class '%s' at \"%s\" (size %d)\n", full_name, message, size);
        
        if (print_interfaces) {
-               print_implemented_interfaces (class);
+               print_implemented_interfaces (klass);
                printf ("* Interfaces for class '%s' done.\nStarting vtable (size %d):\n", full_name, size);
        }
        
-       if (class->parent) {
-               parent_size = class->parent->vtable_size;
+       if (klass->parent) {
+               parent_size = klass->parent->vtable_size;
        } else {
                parent_size = 0;
        }
@@ -4109,20 +4156,20 @@ mono_method_try_get_vtable_index (MonoMethod *method)
 }
 
 static void
-mono_class_verify_vtable (MonoClass *class)
+mono_class_verify_vtable (MonoClass *klass)
 {
        int i;
-       char *full_name = mono_type_full_name (&class->byval_arg);
+       char *full_name = mono_type_full_name (&klass->byval_arg);
 
        printf ("*** Verifying VTable of class '%s' \n", full_name);
        g_free (full_name);
        full_name = NULL;
        
-       if (!class->methods)
+       if (!klass->methods)
                return;
 
-       for (i = 0; i < class->method.count; ++i) {
-               MonoMethod *cm = class->methods [i];
+       for (i = 0; i < klass->method.count; ++i) {
+               MonoMethod *cm = klass->methods [i];
                int slot;
 
                if (!(cm->flags & METHOD_ATTRIBUTE_VIRTUAL))
@@ -4133,13 +4180,13 @@ mono_class_verify_vtable (MonoClass *class)
 
                slot = mono_method_try_get_vtable_index (cm);
                if (slot >= 0) {
-                       if (slot >= class->vtable_size) {
-                               printf ("\tInvalid method %s at index %d with vtable of length %d\n", full_name, slot, class->vtable_size);
+                       if (slot >= klass->vtable_size) {
+                               printf ("\tInvalid method %s at index %d with vtable of length %d\n", full_name, slot, klass->vtable_size);
                                continue;
                        }
 
-                       if (slot >= 0 && class->vtable [slot] != cm && (class->vtable [slot])) {
-                               char *other_name = class->vtable [slot] ? mono_method_full_name (class->vtable [slot], TRUE) : g_strdup ("[null value]");
+                       if (slot >= 0 && klass->vtable [slot] != cm && (klass->vtable [slot])) {
+                               char *other_name = klass->vtable [slot] ? mono_method_full_name (klass->vtable [slot], TRUE) : g_strdup ("[null value]");
                                printf ("\tMethod %s has slot %d but vtable has %s on it\n", full_name, slot, other_name);
                                g_free (other_name);
                        }
@@ -4151,7 +4198,7 @@ mono_class_verify_vtable (MonoClass *class)
 #endif
 
 static void
-print_unimplemented_interface_method_info (MonoClass *class, MonoClass *ic, MonoMethod *im, int im_slot, MonoMethod **overrides, int onum) {
+print_unimplemented_interface_method_info (MonoClass *klass, MonoClass *ic, MonoMethod *im, int im_slot, MonoMethod **overrides, int onum) {
        int index;
        char *method_signature;
        char *type_name;
@@ -4161,20 +4208,20 @@ print_unimplemented_interface_method_info (MonoClass *class, MonoClass *ic, Mono
                         overrides [index*2+1]->slot, overrides [index*2]->name, overrides [index*2]->slot);
        }
        method_signature = mono_signature_get_desc (mono_method_signature (im), FALSE);
-       type_name = mono_type_full_name (&class->byval_arg);
+       type_name = mono_type_full_name (&klass->byval_arg);
        mono_trace_warning (MONO_TRACE_TYPE, "no implementation for interface method %s::%s(%s) in class %s\n",
                mono_type_get_name (&ic->byval_arg), im->name, method_signature, type_name);
        g_free (method_signature);
        g_free (type_name);
-       mono_class_setup_methods (class);
-       if (class->exception_type) {
-               char *name = mono_type_get_full_name (class);
+       mono_class_setup_methods (klass);
+       if (klass->exception_type) {
+               char *name = mono_type_get_full_name (klass);
                mono_trace_warning (MONO_TRACE_TYPE, "CLASS %s failed to resolve methods\n", name);
                g_free (name);
                return;
        }
-       for (index = 0; index < class->method.count; ++index) {
-               MonoMethod *cm = class->methods [index];
+       for (index = 0; index < klass->method.count; ++index) {
+               MonoMethod *cm = klass->methods [index];
                method_signature = mono_signature_get_desc (mono_method_signature (cm), TRUE);
 
                mono_trace_warning (MONO_TRACE_TYPE, "METHOD %s(%s)\n", cm->name, method_signature);
@@ -4191,7 +4238,7 @@ mono_method_get_method_definition (MonoMethod *method)
 }
 
 static gboolean
-verify_class_overrides (MonoClass *class, MonoMethod **overrides, int onum)
+verify_class_overrides (MonoClass *klass, MonoMethod **overrides, int onum)
 {
        int i;
 
@@ -4199,29 +4246,29 @@ verify_class_overrides (MonoClass *class, MonoMethod **overrides, int onum)
                MonoMethod *decl = overrides [i * 2];
                MonoMethod *body = overrides [i * 2 + 1];
 
-               if (mono_class_get_generic_type_definition (body->klass) != mono_class_get_generic_type_definition (class)) {
-                       mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Method belongs to a different class than the declared one"));
+               if (mono_class_get_generic_type_definition (body->klass) != mono_class_get_generic_type_definition (klass)) {
+                       mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Method belongs to a different class than the declared one"));
                        return FALSE;
                }
 
                if (!(body->flags & METHOD_ATTRIBUTE_VIRTUAL) || (body->flags & METHOD_ATTRIBUTE_STATIC)) {
                        if (body->flags & METHOD_ATTRIBUTE_STATIC)
-                               mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Method must not be static to override a base type"));
+                               mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Method must not be static to override a base type"));
                        else
-                               mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Method must be virtual to override a base type"));
+                               mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Method must be virtual to override a base type"));
                        return FALSE;
                }
 
                if (!(decl->flags & METHOD_ATTRIBUTE_VIRTUAL) || (decl->flags & METHOD_ATTRIBUTE_STATIC)) {
                        if (body->flags & METHOD_ATTRIBUTE_STATIC)
-                               mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Cannot override a static method in a base type"));
+                               mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Cannot override a static method in a base type"));
                        else
-                               mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Cannot override a non virtual method in a base type"));
+                               mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Cannot override a non virtual method in a base type"));
                        return FALSE;
                }
 
-               if (!mono_class_is_assignable_from_slow (decl->klass, class)) {
-                       mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Method overrides a class or interface that extended or implemented by this type"));
+               if (!mono_class_is_assignable_from_slow (decl->klass, klass)) {
+                       mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Method overrides a class or interface that extended or implemented by this type"));
                        return FALSE;
                }
 
@@ -4231,7 +4278,7 @@ verify_class_overrides (MonoClass *class, MonoMethod **overrides, int onum)
                if (is_wcf_hack_disabled () && !mono_method_can_access_method_full (body, decl, NULL)) {
                        char *body_name = mono_method_full_name (body, TRUE);
                        char *decl_name = mono_method_full_name (decl, TRUE);
-                       mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Method %s overrides method '%s' which is not accessible", body_name, decl_name));
+                       mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Method %s overrides method '%s' which is not accessible", body_name, decl_name));
                        g_free (body_name);
                        g_free (decl_name);
                        return FALSE;
@@ -4241,16 +4288,16 @@ verify_class_overrides (MonoClass *class, MonoMethod **overrides, int onum)
 }
 
 static gboolean
-mono_class_need_stelemref_method (MonoClass *class)
+mono_class_need_stelemref_method (MonoClass *klass)
 {
-       return class->rank == 1 && MONO_TYPE_IS_REFERENCE (&class->element_class->byval_arg);
+       return klass->rank == 1 && MONO_TYPE_IS_REFERENCE (&klass->element_class->byval_arg);
 }
 
 /*
  * LOCKING: this is supposed to be called with the loader lock held.
  */
 void
-mono_class_setup_vtable_general (MonoClass *class, MonoMethod **overrides, int onum, GList *in_setup)
+mono_class_setup_vtable_general (MonoClass *klass, MonoMethod **overrides, int onum, GList *in_setup)
 {
        MonoError error;
        MonoClass *k, *ic;
@@ -4265,16 +4312,16 @@ mono_class_setup_vtable_general (MonoClass *class, MonoMethod **overrides, int o
        GSList *virt_methods = NULL, *l;
        int stelemref_slot = 0;
 
-       if (class->vtable)
+       if (klass->vtable)
                return;
 
-       if (overrides && !verify_class_overrides (class, overrides, onum))
+       if (overrides && !verify_class_overrides (klass, overrides, onum))
                return;
 
-       ifaces = mono_class_get_implemented_interfaces (class, &error);
+       ifaces = mono_class_get_implemented_interfaces (klass, &error);
        if (!mono_error_ok (&error)) {
-               char *name = mono_type_get_full_name (class);
-               mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Could not resolve %s interfaces due to %s", name, mono_error_get_message (&error)));
+               char *name = mono_type_get_full_name (klass);
+               mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Could not resolve %s interfaces due to %s", name, mono_error_get_message (&error)));
                g_free (name);
                mono_error_cleanup (&error);
                return;
@@ -4287,25 +4334,25 @@ mono_class_setup_vtable_general (MonoClass *class, MonoMethod **overrides, int o
                ifaces = NULL;
        }
        
-       if (class->parent) {
-               mono_class_init (class->parent);
-               mono_class_setup_vtable_full (class->parent, in_setup);
+       if (klass->parent) {
+               mono_class_init (klass->parent);
+               mono_class_setup_vtable_full (klass->parent, in_setup);
 
-               if (class->parent->exception_type) {
-                       char *name = mono_type_get_full_name (class->parent);
-                       mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Parent %s failed to load", name));
+               if (klass->parent->exception_type) {
+                       char *name = mono_type_get_full_name (klass->parent);
+                       mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Parent %s failed to load", name));
                        g_free (name);
                        return;
                }
 
-               max_vtsize += class->parent->vtable_size;
-               cur_slot = class->parent->vtable_size;
+               max_vtsize += klass->parent->vtable_size;
+               cur_slot = klass->parent->vtable_size;
        }
 
-       max_vtsize += class->method.count;
+       max_vtsize += klass->method.count;
 
        /*Array have a slot for stelemref*/
-       if (mono_class_need_stelemref_method (class)) {
+       if (mono_class_need_stelemref_method (klass)) {
                stelemref_slot = cur_slot;
                ++max_vtsize;
                ++cur_slot;
@@ -4314,35 +4361,35 @@ mono_class_setup_vtable_general (MonoClass *class, MonoMethod **overrides, int o
        vtable = alloca (sizeof (gpointer) * max_vtsize);
        memset (vtable, 0, sizeof (gpointer) * max_vtsize);
 
-       /* printf ("METAINIT %s.%s\n", class->name_space, class->name); */
+       /* printf ("METAINIT %s.%s\n", klass->name_space, klass->name); */
 
-       cur_slot = setup_interface_offsets (class, cur_slot, TRUE);
+       cur_slot = setup_interface_offsets (klass, cur_slot, TRUE);
        if (cur_slot == -1) /*setup_interface_offsets fails the type.*/
                return;
 
-       max_iid = class->max_interface_id;
+       max_iid = klass->max_interface_id;
        DEBUG_INTERFACE_VTABLE (first_non_interface_slot = cur_slot);
 
        /* Optimized version for generic instances */
-       if (class->generic_class) {
+       if (klass->generic_class) {
                MonoError error;
-               MonoClass *gklass = class->generic_class->container_class;
+               MonoClass *gklass = klass->generic_class->container_class;
                MonoMethod **tmp;
 
                mono_class_setup_vtable_full (gklass, in_setup);
                if (gklass->exception_type != MONO_EXCEPTION_NONE) {
-                       mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, NULL);
+                       mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, NULL);
                        return;
                }
 
-               tmp = mono_class_alloc0 (class, sizeof (gpointer) * gklass->vtable_size);
-               class->vtable_size = gklass->vtable_size;
+               tmp = mono_class_alloc0 (klass, sizeof (gpointer) * gklass->vtable_size);
+               klass->vtable_size = gklass->vtable_size;
                for (i = 0; i < gklass->vtable_size; ++i)
                        if (gklass->vtable [i]) {
-                               MonoMethod *inflated = mono_class_inflate_generic_method_full_checked (gklass->vtable [i], class, mono_class_get_context (class), &error);
+                               MonoMethod *inflated = mono_class_inflate_generic_method_full_checked (gklass->vtable [i], klass, mono_class_get_context (klass), &error);
                                if (!mono_error_ok (&error)) {
                                        char *err_msg = g_strdup_printf ("Could not inflate method due to %s", mono_error_get_message (&error));
-                                       mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, err_msg);
+                                       mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, err_msg);
                                        g_free (err_msg);
                                        mono_error_cleanup (&error);
                                        return;
@@ -4351,20 +4398,20 @@ mono_class_setup_vtable_general (MonoClass *class, MonoMethod **overrides, int o
                                tmp [i]->slot = gklass->vtable [i]->slot;
                        }
                mono_memory_barrier ();
-               class->vtable = tmp;
+               klass->vtable = tmp;
 
                /* Have to set method->slot for abstract virtual methods */
-               if (class->methods && gklass->methods) {
-                       for (i = 0; i < class->method.count; ++i)
-                               if (class->methods [i]->slot == -1)
-                                       class->methods [i]->slot = gklass->methods [i]->slot;
+               if (klass->methods && gklass->methods) {
+                       for (i = 0; i < klass->method.count; ++i)
+                               if (klass->methods [i]->slot == -1)
+                                       klass->methods [i]->slot = gklass->methods [i]->slot;
                }
 
                return;
        }
 
-       if (class->parent && class->parent->vtable_size) {
-               MonoClass *parent = class->parent;
+       if (klass->parent && klass->parent->vtable_size) {
+               MonoClass *parent = klass->parent;
                int i;
                
                memcpy (vtable, parent->vtable,  sizeof (gpointer) * parent->vtable_size);
@@ -4375,7 +4422,7 @@ mono_class_setup_vtable_general (MonoClass *class, MonoMethod **overrides, int o
                // classes the ".override" information is not used anymore.
                for (i = 0; i < parent->interface_offsets_count; i++) {
                        MonoClass *parent_interface = parent->interfaces_packed [i];
-                       int interface_offset = mono_class_interface_offset (class, parent_interface);
+                       int interface_offset = mono_class_interface_offset (klass, parent_interface);
                        /*FIXME this is now dead code as this condition will never hold true.
                        Since interface offsets are inherited then the offset of an interface implemented
                        by a parent will never be the out of it's vtable boundary.
@@ -4386,7 +4433,7 @@ mono_class_setup_vtable_general (MonoClass *class, MonoMethod **overrides, int o
                                
                                mono_class_setup_methods (parent_interface); /*FIXME Just kill this whole chunk of dead code*/
                                TRACE_INTERFACE_VTABLE (printf ("    +++ Inheriting interface %s.%s\n", parent_interface->name_space, parent_interface->name));
-                               for (j = 0; j < parent_interface->method.count && !class->exception_type; j++) {
+                               for (j = 0; j < parent_interface->method.count && !klass->exception_type; j++) {
                                        vtable [interface_offset + j] = parent->vtable [parent_interface_offset + j];
                                        TRACE_INTERFACE_VTABLE (printf ("    --- Inheriting: [%03d][(%03d)+(%03d)] => [%03d][(%03d)+(%03d)]\n",
                                                        parent_interface_offset + j, parent_interface_offset, j,
@@ -4398,8 +4445,8 @@ mono_class_setup_vtable_general (MonoClass *class, MonoMethod **overrides, int o
        }
 
        /*Array have a slot for stelemref*/
-       if (mono_class_need_stelemref_method (class)) {
-               MonoMethod *method = mono_marshal_get_virtual_stelemref (class);
+       if (mono_class_need_stelemref_method (klass)) {
+               MonoMethod *method = mono_marshal_get_virtual_stelemref (klass);
                if (!method->slot)
                        method->slot = stelemref_slot;
                else
@@ -4408,7 +4455,7 @@ mono_class_setup_vtable_general (MonoClass *class, MonoMethod **overrides, int o
                vtable [stelemref_slot] = method;
        }
 
-       TRACE_INTERFACE_VTABLE (print_vtable_full (class, vtable, cur_slot, first_non_interface_slot, "AFTER INHERITING PARENT VTABLE", TRUE));
+       TRACE_INTERFACE_VTABLE (print_vtable_full (klass, vtable, cur_slot, first_non_interface_slot, "AFTER INHERITING PARENT VTABLE", TRUE));
        /* override interface methods */
        for (i = 0; i < onum; i++) {
                MonoMethod *decl = overrides [i*2];
@@ -4416,11 +4463,11 @@ mono_class_setup_vtable_general (MonoClass *class, MonoMethod **overrides, int o
                        int dslot;
                        dslot = mono_method_get_vtable_slot (decl);
                        if (dslot == -1) {
-                               mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, NULL);
+                               mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, NULL);
                                return;
                        }
 
-                       dslot += mono_class_interface_offset (class, decl->klass);
+                       dslot += mono_class_interface_offset (klass, decl->klass);
                        vtable [dslot] = overrides [i*2 + 1];
                        vtable [dslot]->slot = dslot;
                        if (!override_map)
@@ -4429,11 +4476,11 @@ mono_class_setup_vtable_general (MonoClass *class, MonoMethod **overrides, int o
                        g_hash_table_insert (override_map, overrides [i * 2], overrides [i * 2 + 1]);
 
                        if (mono_security_core_clr_enabled ())
-                               mono_security_core_clr_check_override (class, vtable [dslot], decl);
+                               mono_security_core_clr_check_override (klass, vtable [dslot], decl);
                }
        }
        TRACE_INTERFACE_VTABLE (print_overrides (override_map, "AFTER OVERRIDING INTERFACE METHODS"));
-       TRACE_INTERFACE_VTABLE (print_vtable_full (class, vtable, cur_slot, first_non_interface_slot, "AFTER OVERRIDING INTERFACE METHODS", FALSE));
+       TRACE_INTERFACE_VTABLE (print_vtable_full (klass, vtable, cur_slot, first_non_interface_slot, "AFTER OVERRIDING INTERFACE METHODS", FALSE));
 
        /*
         * Create a list of virtual methods to avoid calling 
@@ -4445,22 +4492,22 @@ mono_class_setup_vtable_general (MonoClass *class, MonoMethod **overrides, int o
                MonoMethod *cm;
 
                virt_methods = NULL;
-               while ((cm = mono_class_get_virtual_methods (class, &iter))) {
+               while ((cm = mono_class_get_virtual_methods (klass, &iter))) {
                        virt_methods = g_slist_prepend (virt_methods, cm);
                }
-               if (class->exception_type)
+               if (klass->exception_type)
                        goto fail;
        }
        
        // Loop on all implemented interfaces...
-       for (i = 0; i < class->interface_offsets_count; i++) {
-               MonoClass *parent = class->parent;
+       for (i = 0; i < klass->interface_offsets_count; i++) {
+               MonoClass *parent = klass->parent;
                int ic_offset;
                gboolean interface_is_explicitly_implemented_by_class;
                int im_index;
                
-               ic = class->interfaces_packed [i];
-               ic_offset = mono_class_interface_offset (class, ic);
+               ic = klass->interfaces_packed [i];
+               ic_offset = mono_class_interface_offset (klass, ic);
 
                mono_class_setup_methods (ic);
                if (ic->exception_type)
@@ -4470,8 +4517,8 @@ mono_class_setup_vtable_general (MonoClass *class, MonoMethod **overrides, int o
                if (parent != NULL) {
                        int implemented_interfaces_index;
                        interface_is_explicitly_implemented_by_class = FALSE;
-                       for (implemented_interfaces_index = 0; implemented_interfaces_index < class->interface_count; implemented_interfaces_index++) {
-                               if (ic == class->interfaces [implemented_interfaces_index]) {
+                       for (implemented_interfaces_index = 0; implemented_interfaces_index < klass->interface_count; implemented_interfaces_index++) {
+                               if (ic == klass->interfaces [implemented_interfaces_index]) {
                                        interface_is_explicitly_implemented_by_class = TRUE;
                                        break;
                                }
@@ -4501,7 +4548,7 @@ mono_class_setup_vtable_general (MonoClass *class, MonoMethod **overrides, int o
                                for (l = virt_methods; l; l = l->next) {
                                        cm = l->data;
                                        TRACE_INTERFACE_VTABLE (printf ("    For slot %d ('%s'.'%s':'%s'), trying method '%s'.'%s':'%s'... [EXPLICIT IMPLEMENTATION = %d][SLOT IS NULL = %d]", im_slot, ic->name_space, ic->name, im->name, cm->klass->name_space, cm->klass->name, cm->name, interface_is_explicitly_implemented_by_class, (vtable [im_slot] == NULL)));
-                                       if (check_interface_method_override (class, im, cm, TRUE, interface_is_explicitly_implemented_by_class, (vtable [im_slot] == NULL))) {
+                                       if (check_interface_method_override (klass, im, cm, TRUE, interface_is_explicitly_implemented_by_class, (vtable [im_slot] == NULL))) {
                                                TRACE_INTERFACE_VTABLE (printf ("[check ok]: ASSIGNING"));
                                                vtable [im_slot] = cm;
                                                /* Why do we need this? */
@@ -4510,19 +4557,19 @@ mono_class_setup_vtable_general (MonoClass *class, MonoMethod **overrides, int o
                                                }
                                        }
                                        TRACE_INTERFACE_VTABLE (printf ("\n"));
-                                       if (class->exception_type)  /*Might be set by check_interface_method_override*/ 
+                                       if (klass->exception_type)  /*Might be set by check_interface_method_override*/
                                                goto fail;
                                }
                                
                                // If the slot is still empty, look in all the inherited virtual methods...
-                               if ((vtable [im_slot] == NULL) && class->parent != NULL) {
-                                       MonoClass *parent = class->parent;
+                               if ((vtable [im_slot] == NULL) && klass->parent != NULL) {
+                                       MonoClass *parent = klass->parent;
                                        // Reverse order, so that last added methods are preferred
                                        for (cm_index = parent->vtable_size - 1; cm_index >= 0; cm_index--) {
                                                MonoMethod *cm = parent->vtable [cm_index];
                                                
                                                TRACE_INTERFACE_VTABLE ((cm != NULL) && printf ("    For slot %d ('%s'.'%s':'%s'), trying (ancestor) method '%s'.'%s':'%s'... ", im_slot, ic->name_space, ic->name, im->name, cm->klass->name_space, cm->klass->name, cm->name));
-                                               if ((cm != NULL) && check_interface_method_override (class, im, cm, FALSE, FALSE, TRUE)) {
+                                               if ((cm != NULL) && check_interface_method_override (klass, im, cm, FALSE, FALSE, TRUE)) {
                                                        TRACE_INTERFACE_VTABLE (printf ("[everything ok]: ASSIGNING"));
                                                        vtable [im_slot] = cm;
                                                        /* Why do we need this? */
@@ -4531,7 +4578,7 @@ mono_class_setup_vtable_general (MonoClass *class, MonoMethod **overrides, int o
                                                        }
                                                        break;
                                                }
-                                               if (class->exception_type) /*Might be set by check_interface_method_override*/ 
+                                               if (klass->exception_type) /*Might be set by check_interface_method_override*/
                                                        goto fail;
                                                TRACE_INTERFACE_VTABLE ((cm != NULL) && printf ("\n"));
                                        }
@@ -4547,13 +4594,13 @@ mono_class_setup_vtable_general (MonoClass *class, MonoMethod **overrides, int o
        // it can happen (for injected generic array interfaces) that the same slot is
        // processed multiple times (those interfaces have overlapping slots), and it
        // will not always be the first pass the one that fills the slot.
-       if (! (class->flags & TYPE_ATTRIBUTE_ABSTRACT)) {
-               for (i = 0; i < class->interface_offsets_count; i++) {
+       if (! (klass->flags & TYPE_ATTRIBUTE_ABSTRACT)) {
+               for (i = 0; i < klass->interface_offsets_count; i++) {
                        int ic_offset;
                        int im_index;
                        
-                       ic = class->interfaces_packed [i];
-                       ic_offset = mono_class_interface_offset (class, ic);
+                       ic = klass->interfaces_packed [i];
+                       ic_offset = mono_class_interface_offset (klass, ic);
                        
                        for (im_index = 0; im_index < ic->method.count; im_index++) {
                                MonoMethod *im = ic->methods [im_index];
@@ -4565,14 +4612,14 @@ mono_class_setup_vtable_general (MonoClass *class, MonoMethod **overrides, int o
                                TRACE_INTERFACE_VTABLE (printf ("      [class is not abstract, checking slot %d for interface '%s'.'%s', method %s, slot check is %d]\n",
                                                im_slot, ic->name_space, ic->name, im->name, (vtable [im_slot] == NULL)));
                                if (vtable [im_slot] == NULL) {
-                                       print_unimplemented_interface_method_info (class, ic, im, im_slot, overrides, onum);
+                                       print_unimplemented_interface_method_info (klass, ic, im, im_slot, overrides, onum);
                                        goto fail;
                                }
                        }
                }
        }
 
-       TRACE_INTERFACE_VTABLE (print_vtable_full (class, vtable, cur_slot, first_non_interface_slot, "AFTER SETTING UP INTERFACE METHODS", FALSE));
+       TRACE_INTERFACE_VTABLE (print_vtable_full (klass, vtable, cur_slot, first_non_interface_slot, "AFTER SETTING UP INTERFACE METHODS", FALSE));
        for (l = virt_methods; l; l = l->next) {
                cm = l->data;
                /*
@@ -4581,7 +4628,7 @@ mono_class_setup_vtable_general (MonoClass *class, MonoMethod **overrides, int o
                 */
                if (!(cm->flags & METHOD_ATTRIBUTE_NEW_SLOT)) {
                        int slot = -1;
-                       for (k = class->parent; k ; k = k->parent) {
+                       for (k = klass->parent; k ; k = k->parent) {
                                gpointer k_iter;
                                MonoMethod *m1;
 
@@ -4593,7 +4640,7 @@ mono_class_setup_vtable_general (MonoClass *class, MonoMethod **overrides, int o
                                        m1sig = mono_method_signature (m1);
 
                                        if (!cmsig || !m1sig) {
-                                               mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, NULL);
+                                               mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, NULL);
                                                return;
                                        }
 
@@ -4601,7 +4648,7 @@ mono_class_setup_vtable_general (MonoClass *class, MonoMethod **overrides, int o
                                            mono_metadata_signature_equal (cmsig, m1sig)) {
 
                                                if (mono_security_core_clr_enabled ())
-                                                       mono_security_core_clr_check_override (class, cm, m1);
+                                                       mono_security_core_clr_check_override (klass, cm, m1);
 
                                                slot = mono_method_get_vtable_slot (m1);
                                                if (slot == -1)
@@ -4610,7 +4657,7 @@ mono_class_setup_vtable_general (MonoClass *class, MonoMethod **overrides, int o
                                                if (is_wcf_hack_disabled () && !mono_method_can_access_method_full (cm, m1, NULL)) {
                                                        char *body_name = mono_method_full_name (cm, TRUE);
                                                        char *decl_name = mono_method_full_name (m1, TRUE);
-                                                       mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Method %s overrides method '%s' which is not accessible", body_name, decl_name));
+                                                       mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Method %s overrides method '%s' which is not accessible", body_name, decl_name));
                                                        g_free (body_name);
                                                        g_free (decl_name);
                                                        goto fail;
@@ -4662,7 +4709,7 @@ mono_class_setup_vtable_general (MonoClass *class, MonoMethod **overrides, int o
                        g_hash_table_insert (override_map, decl, overrides [i * 2 + 1]);
 
                        if (mono_security_core_clr_enabled ())
-                               mono_security_core_clr_check_override (class, vtable [decl->slot], decl);
+                               mono_security_core_clr_check_override (klass, vtable [decl->slot], decl);
                }
        }
 
@@ -4690,12 +4737,12 @@ mono_class_setup_vtable_general (MonoClass *class, MonoMethod **overrides, int o
        virt_methods = NULL;
 
        /* Ensure that all vtable slots are filled with concrete instance methods */
-       if (!(class->flags & TYPE_ATTRIBUTE_ABSTRACT)) {
+       if (!(klass->flags & TYPE_ATTRIBUTE_ABSTRACT)) {
                for (i = 0; i < cur_slot; ++i) {
                        if (vtable [i] == NULL || (vtable [i]->flags & (METHOD_ATTRIBUTE_ABSTRACT | METHOD_ATTRIBUTE_STATIC))) {
-                               char *type_name = mono_type_get_full_name (class);
+                               char *type_name = mono_type_get_full_name (klass);
                                char *method_name = vtable [i] ? mono_method_full_name (vtable [i], TRUE) : g_strdup ("none");
-                               mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Type %s has invalid vtable method slot %d with method %s", type_name, i, method_name));
+                               mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Type %s has invalid vtable method slot %d with method %s", type_name, i, method_name));
                                g_free (type_name);
                                g_free (method_name);
                                return;
@@ -4703,42 +4750,42 @@ mono_class_setup_vtable_general (MonoClass *class, MonoMethod **overrides, int o
                }
        }
 
-       if (class->generic_class) {
-               MonoClass *gklass = class->generic_class->container_class;
+       if (klass->generic_class) {
+               MonoClass *gklass = klass->generic_class->container_class;
 
                mono_class_init (gklass);
 
-               class->vtable_size = MAX (gklass->vtable_size, cur_slot);
+               klass->vtable_size = MAX (gklass->vtable_size, cur_slot);
        } else {
                /* Check that the vtable_size value computed in mono_class_init () is correct */
-               if (class->vtable_size)
-                       g_assert (cur_slot == class->vtable_size);
-               class->vtable_size = cur_slot;
+               if (klass->vtable_size)
+                       g_assert (cur_slot == klass->vtable_size);
+               klass->vtable_size = cur_slot;
        }
 
        /* Try to share the vtable with our parent. */
-       if (class->parent && (class->parent->vtable_size == class->vtable_size) && (memcmp (class->parent->vtable, vtable, sizeof (gpointer) * class->vtable_size) == 0)) {
+       if (klass->parent && (klass->parent->vtable_size == klass->vtable_size) && (memcmp (klass->parent->vtable, vtable, sizeof (gpointer) * klass->vtable_size) == 0)) {
                mono_memory_barrier ();
-               class->vtable = class->parent->vtable;
+               klass->vtable = klass->parent->vtable;
        } else {
-               MonoMethod **tmp = mono_class_alloc0 (class, sizeof (gpointer) * class->vtable_size);
-               memcpy (tmp, vtable,  sizeof (gpointer) * class->vtable_size);
+               MonoMethod **tmp = mono_class_alloc0 (klass, sizeof (gpointer) * klass->vtable_size);
+               memcpy (tmp, vtable,  sizeof (gpointer) * klass->vtable_size);
                mono_memory_barrier ();
-               class->vtable = tmp;
+               klass->vtable = tmp;
        }
 
-       DEBUG_INTERFACE_VTABLE (print_vtable_full (class, class->vtable, class->vtable_size, first_non_interface_slot, "FINALLY", FALSE));
+       DEBUG_INTERFACE_VTABLE (print_vtable_full (klass, klass->vtable, klass->vtable_size, first_non_interface_slot, "FINALLY", FALSE));
        if (mono_print_vtable) {
                int icount = 0;
 
-               print_implemented_interfaces (class);
+               print_implemented_interfaces (klass);
                
                for (i = 0; i <= max_iid; i++)
-                       if (MONO_CLASS_IMPLEMENTS_INTERFACE (class, i))
+                       if (MONO_CLASS_IMPLEMENTS_INTERFACE (klass, i))
                                icount++;
 
-               printf ("VTable %s (vtable entries = %d, interfaces = %d)\n", mono_type_full_name (&class->byval_arg), 
-                       class->vtable_size, icount); 
+               printf ("VTable %s (vtable entries = %d, interfaces = %d)\n", mono_type_full_name (&klass->byval_arg),
+                       klass->vtable_size, icount);
 
                for (i = 0; i < cur_slot; ++i) {
                        MonoMethod *cm;
@@ -4752,34 +4799,34 @@ mono_class_setup_vtable_general (MonoClass *class, MonoMethod **overrides, int o
 
 
                if (icount) {
-                       printf ("Interfaces %s.%s (max_iid = %d)\n", class->name_space, 
-                               class->name, max_iid);
+                       printf ("Interfaces %s.%s (max_iid = %d)\n", klass->name_space,
+                               klass->name, max_iid);
        
-                       for (i = 0; i < class->interface_count; i++) {
-                               ic = class->interfaces [i];
+                       for (i = 0; i < klass->interface_count; i++) {
+                               ic = klass->interfaces [i];
                                printf ("  slot offset: %03d, method count: %03d, iid: %03d %s\n",  
-                                       mono_class_interface_offset (class, ic),
+                                       mono_class_interface_offset (klass, ic),
                                        count_virtual_methods (ic), ic->interface_id, mono_type_full_name (&ic->byval_arg));
                        }
 
-                       for (k = class->parent; k ; k = k->parent) {
+                       for (k = klass->parent; k ; k = k->parent) {
                                for (i = 0; i < k->interface_count; i++) {
                                        ic = k->interfaces [i]; 
                                        printf ("  parent slot offset: %03d, method count: %03d, iid: %03d %s\n",  
-                                               mono_class_interface_offset (class, ic),
+                                               mono_class_interface_offset (klass, ic),
                                                count_virtual_methods (ic), ic->interface_id, mono_type_full_name (&ic->byval_arg));
                                }
                        }
                }
        }
 
-       VERIFY_INTERFACE_VTABLE (mono_class_verify_vtable (class));
+       VERIFY_INTERFACE_VTABLE (mono_class_verify_vtable (klass));
        return;
 
 fail:
        {
-       char *name = mono_type_get_full_name (class);
-       mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("VTable setup of type %s failed", name));
+       char *name = mono_type_get_full_name (klass);
+       mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("VTable setup of type %s failed", name));
        g_free (name);
        if (override_map)
                g_hash_table_destroy (override_map);
@@ -4857,15 +4904,15 @@ static int finalize_slot = -1;
 static int ghc_slot = -1;
 
 static void
-initialize_object_slots (MonoClass *class)
+initialize_object_slots (MonoClass *klass)
 {
        int i;
        if (default_ghc)
                return;
-       if (class == mono_defaults.object_class) { 
-               mono_class_setup_vtable (class);                       
-               for (i = 0; i < class->vtable_size; ++i) {
-                       MonoMethod *cm = class->vtable [i];
+       if (klass == mono_defaults.object_class) {
+               mono_class_setup_vtable (klass);
+               for (i = 0; i < klass->vtable_size; ++i) {
+                       MonoMethod *cm = klass->vtable [i];
        
                        if (!strcmp (cm->name, "GetHashCode"))
                                ghc_slot = i;
@@ -4874,10 +4921,10 @@ initialize_object_slots (MonoClass *class)
                }
 
                g_assert (ghc_slot > 0);
-               default_ghc = class->vtable [ghc_slot];
+               default_ghc = klass->vtable [ghc_slot];
 
                g_assert (finalize_slot > 0);
-               default_finalize = class->vtable [finalize_slot];
+               default_finalize = klass->vtable [finalize_slot];
        }
 }
 
@@ -4890,16 +4937,16 @@ static int generic_array_method_num = 0;
 static GenericArrayMethodInfo *generic_array_method_info = NULL;
 
 static int
-generic_array_methods (MonoClass *class)
+generic_array_methods (MonoClass *klass)
 {
        int i, count_generic = 0;
        GList *list = NULL, *tmp;
        if (generic_array_method_num)
                return generic_array_method_num;
-       mono_class_setup_methods (class->parent); /*This is setting up System.Array*/
-       g_assert (!class->parent->exception_type); /*So hitting this assert is a huge problem*/
-       for (i = 0; i < class->parent->method.count; i++) {
-               MonoMethod *m = class->parent->methods [i];
+       mono_class_setup_methods (klass->parent); /*This is setting up System.Array*/
+       g_assert (!klass->parent->exception_type); /*So hitting this assert is a huge problem*/
+       for (i = 0; i < klass->parent->method.count; i++) {
+               MonoMethod *m = klass->parent->methods [i];
                if (!strncmp (m->name, "InternalArray__", 15)) {
                        count_generic++;
                        list = g_list_prepend (list, m);
@@ -4949,7 +4996,7 @@ generic_array_methods (MonoClass *class)
 }
 
 static void
-setup_generic_array_ifaces (MonoClass *class, MonoClass *iface, MonoMethod **methods, int pos)
+setup_generic_array_ifaces (MonoClass *klass, MonoClass *iface, MonoMethod **methods, int pos)
 {
        MonoGenericContext tmp_context;
        int i;
@@ -4965,7 +5012,7 @@ setup_generic_array_ifaces (MonoClass *class, MonoClass *iface, MonoMethod **met
 
                inflated = mono_class_inflate_generic_method_checked (m, &tmp_context, &error);
                g_assert (mono_error_ok (&error)); /*FIXME proper error handling*/
-               methods [pos++] = mono_marshal_get_generic_array_helper (class, iface, generic_array_method_info [i].name, inflated);
+               methods [pos++] = mono_marshal_get_generic_array_helper (klass, iface, generic_array_method_info [i].name, inflated);
        }
 }
 
@@ -4984,17 +5031,17 @@ concat_two_strings_with_zero (MonoImage *image, const char *s1, const char *s2)
 }
 
 static void
-set_failure_from_loader_error (MonoClass *class, MonoLoaderError *error)
+set_failure_from_loader_error (MonoClass *klass, MonoLoaderError *error)
 {
        gpointer exception_data = NULL;
 
        switch (error->exception_type) {
        case MONO_EXCEPTION_TYPE_LOAD:
-               exception_data = concat_two_strings_with_zero (class->image, error->class_name, error->assembly_name);
+               exception_data = concat_two_strings_with_zero (klass->image, error->class_name, error->assembly_name);
                break;
 
        case MONO_EXCEPTION_MISSING_METHOD:
-               exception_data = concat_two_strings_with_zero (class->image, error->class_name, error->member_name);
+               exception_data = concat_two_strings_with_zero (klass->image, error->class_name, error->member_name);
                break;
 
        case MONO_EXCEPTION_MISSING_FIELD: {
@@ -5006,7 +5053,7 @@ set_failure_from_loader_error (MonoClass *class, MonoLoaderError *error)
                else
                        class_name = error->klass->name;
 
-               exception_data = concat_two_strings_with_zero (class->image, class_name, error->member_name);
+               exception_data = concat_two_strings_with_zero (klass->image, class_name, error->member_name);
                
                if (name_space)
                        g_free ((void*)class_name);
@@ -5021,7 +5068,7 @@ set_failure_from_loader_error (MonoClass *class, MonoLoaderError *error)
                else
                        msg = "Could not load file or assembly '%s' or one of its dependencies.";
 
-               exception_data = concat_two_strings_with_zero (class->image, msg, error->assembly_name);
+               exception_data = concat_two_strings_with_zero (klass->image, msg, error->assembly_name);
                break;
        }
 
@@ -5033,7 +5080,7 @@ set_failure_from_loader_error (MonoClass *class, MonoLoaderError *error)
                g_assert_not_reached ();
        }
 
-       mono_class_set_failure (class, error->exception_type, exception_data);
+       mono_class_set_failure (klass, error->exception_type, exception_data);
 }
 
 /**
@@ -5048,117 +5095,117 @@ set_failure_from_loader_error (MonoClass *class, MonoLoaderError *error)
  * LOCKING: Acquires the loader lock.
  */
 gboolean
-mono_class_init (MonoClass *class)
+mono_class_init (MonoClass *klass)
 {
        int i;
        MonoCachedClassInfo cached_info;
        gboolean has_cached_info;
        
-       g_assert (class);
+       g_assert (klass);
 
        /* Double-checking locking pattern */
-       if (class->inited || class->exception_type)
-               return class->exception_type == MONO_EXCEPTION_NONE;
+       if (klass->inited || klass->exception_type)
+               return klass->exception_type == MONO_EXCEPTION_NONE;
 
-       /*g_print ("Init class %s\n", mono_type_get_full_name (class));*/
+       /*g_print ("Init class %s\n", mono_type_get_full_name (klass));*/
 
        /* We do everything inside the lock to prevent races */
        mono_loader_lock ();
 
-       if (class->inited || class->exception_type) {
+       if (klass->inited || klass->exception_type) {
                mono_loader_unlock ();
                /* Somebody might have gotten in before us */
-               return class->exception_type == MONO_EXCEPTION_NONE;
+               return klass->exception_type == MONO_EXCEPTION_NONE;
        }
 
-       if (class->init_pending) {
-               mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Recursive type definition detected"));
+       if (klass->init_pending) {
+               mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Recursive type definition detected"));
                goto leave;
        }
 
-       class->init_pending = 1;
+       klass->init_pending = 1;
 
-       if (mono_verifier_is_enabled_for_class (class) && !mono_verifier_verify_class (class)) {
-               mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, concat_two_strings_with_zero (class->image, class->name, class->image->assembly_name));
+       if (mono_verifier_is_enabled_for_class (klass) && !mono_verifier_verify_class (klass)) {
+               mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, concat_two_strings_with_zero (klass->image, klass->name, klass->image->assembly_name));
                goto leave;
        }
 
 
-       if (class->byval_arg.type == MONO_TYPE_ARRAY || class->byval_arg.type == MONO_TYPE_SZARRAY) {
-               MonoClass *element_class = class->element_class;
+       if (klass->byval_arg.type == MONO_TYPE_ARRAY || klass->byval_arg.type == MONO_TYPE_SZARRAY) {
+               MonoClass *element_class = klass->element_class;
                if (!element_class->inited) 
                        mono_class_init (element_class);
                if (element_class->exception_type != MONO_EXCEPTION_NONE) {
-                       mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, NULL);
+                       mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, NULL);
                        goto leave;
                }
        }
 
        mono_stats.initialized_class_count++;
 
-       if (class->generic_class && !class->generic_class->is_dynamic) {
-               MonoClass *gklass = class->generic_class->container_class;
+       if (klass->generic_class && !klass->generic_class->is_dynamic) {
+               MonoClass *gklass = klass->generic_class->container_class;
 
                mono_stats.generic_class_count++;
 
-               class->method = gklass->method;
-               class->field = gklass->field;
+               klass->method = gklass->method;
+               klass->field = gklass->field;
 
                mono_class_init (gklass);
                // FIXME: Why is this needed ?
                if (!gklass->exception_type)
                        mono_class_setup_methods (gklass);
                if (gklass->exception_type) {
-                       mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Generic Type Defintion failed to init"));
+                       mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Generic Type Defintion failed to init"));
                        goto leave;
                }
 
-               if (MONO_CLASS_IS_INTERFACE (class))
-                       class->interface_id = mono_get_unique_iid (class);
+               if (MONO_CLASS_IS_INTERFACE (klass))
+                       klass->interface_id = mono_get_unique_iid (klass);
        }
 
-       if (class->parent && !class->parent->inited)
-               mono_class_init (class->parent);
+       if (klass->parent && !klass->parent->inited)
+               mono_class_init (klass->parent);
 
-       has_cached_info = mono_class_get_cached_class_info (class, &cached_info);
+       has_cached_info = mono_class_get_cached_class_info (klass, &cached_info);
 
-       if (class->generic_class || image_is_dynamic (class->image) || !class->type_token || (has_cached_info && !cached_info.has_nested_classes))
-               class->nested_classes_inited = TRUE;
+       if (klass->generic_class || image_is_dynamic (klass->image) || !klass->type_token || (has_cached_info && !cached_info.has_nested_classes))
+               klass->nested_classes_inited = TRUE;
 
        /*
         * Computes the size used by the fields, and their locations
         */
        if (has_cached_info) {
-               class->instance_size = cached_info.instance_size;
-               class->sizes.class_size = cached_info.class_size;
-               class->packing_size = cached_info.packing_size;
-               class->min_align = cached_info.min_align;
-               class->blittable = cached_info.blittable;
-               class->has_references = cached_info.has_references;
-               class->has_static_refs = cached_info.has_static_refs;
-               class->no_special_static_fields = cached_info.no_special_static_fields;
+               klass->instance_size = cached_info.instance_size;
+               klass->sizes.class_size = cached_info.class_size;
+               klass->packing_size = cached_info.packing_size;
+               klass->min_align = cached_info.min_align;
+               klass->blittable = cached_info.blittable;
+               klass->has_references = cached_info.has_references;
+               klass->has_static_refs = cached_info.has_static_refs;
+               klass->no_special_static_fields = cached_info.no_special_static_fields;
        }
        else
-               if (!class->size_inited){
-                       mono_class_setup_fields (class);
-                       if (class->exception_type || mono_loader_get_last_error ())
+               if (!klass->size_inited){
+                       mono_class_setup_fields (klass);
+                       if (klass->exception_type || mono_loader_get_last_error ())
                                goto leave;
                }
                                
        /* Initialize arrays */
-       if (class->rank) {
-               class->method.count = 3 + (class->rank > 1? 2: 1);
+       if (klass->rank) {
+               klass->method.count = 3 + (klass->rank > 1? 2: 1);
 
-               if (class->interface_count) {
-                       int count_generic = generic_array_methods (class);
-                       class->method.count += class->interface_count * count_generic;
+               if (klass->interface_count) {
+                       int count_generic = generic_array_methods (klass);
+                       klass->method.count += klass->interface_count * count_generic;
                }
        }
 
-       mono_class_setup_supertypes (class);
+       mono_class_setup_supertypes (klass);
 
        if (!default_ghc)
-               initialize_object_slots (class);
+               initialize_object_slots (klass);
 
        /* 
         * Initialize the rest of the data without creating a generic vtable if possible.
@@ -5167,74 +5214,74 @@ mono_class_init (MonoClass *class)
         */
        if (has_cached_info) {
                /* AOT case */
-               class->vtable_size = cached_info.vtable_size;
-               class->has_finalize = cached_info.has_finalize;
-               class->has_finalize_inited = TRUE;
-               class->ghcimpl = cached_info.ghcimpl;
-               class->has_cctor = cached_info.has_cctor;
-       } else if (class->rank == 1 && class->byval_arg.type == MONO_TYPE_SZARRAY) {
+               klass->vtable_size = cached_info.vtable_size;
+               klass->has_finalize = cached_info.has_finalize;
+               klass->has_finalize_inited = TRUE;
+               klass->ghcimpl = cached_info.ghcimpl;
+               klass->has_cctor = cached_info.has_cctor;
+       } else if (klass->rank == 1 && klass->byval_arg.type == MONO_TYPE_SZARRAY) {
                /* SZARRAY can have 2 vtable layouts, with and without the stelemref method.
                 * The first slot if for array with.
                 */
                static int szarray_vtable_size[2] = { 0 };
 
-               int slot = MONO_TYPE_IS_REFERENCE (&class->element_class->byval_arg) ? 0 : 1;
+               int slot = MONO_TYPE_IS_REFERENCE (&klass->element_class->byval_arg) ? 0 : 1;
 
                /* SZARRAY case */
                if (!szarray_vtable_size [slot]) {
-                       mono_class_setup_vtable (class);
-                       szarray_vtable_size [slot] = class->vtable_size;
+                       mono_class_setup_vtable (klass);
+                       szarray_vtable_size [slot] = klass->vtable_size;
                } else {
-                       class->vtable_size = szarray_vtable_size[slot];
+                       klass->vtable_size = szarray_vtable_size[slot];
                }
-       } else if (class->generic_class && !MONO_CLASS_IS_INTERFACE (class)) {
-               MonoClass *gklass = class->generic_class->container_class;
+       } else if (klass->generic_class && !MONO_CLASS_IS_INTERFACE (klass)) {
+               MonoClass *gklass = klass->generic_class->container_class;
 
                /* Generic instance case */
-               class->ghcimpl = gklass->ghcimpl;
-               class->has_cctor = gklass->has_cctor;
+               klass->ghcimpl = gklass->ghcimpl;
+               klass->has_cctor = gklass->has_cctor;
 
                mono_class_setup_vtable (gklass);
                if (gklass->exception_type) {
-                       mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, NULL);
+                       mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, NULL);
                        goto leave;
                }
 
-               class->vtable_size = gklass->vtable_size;
+               klass->vtable_size = gklass->vtable_size;
        } else {
                /* General case */
 
                /* ghcimpl is not currently used
-               class->ghcimpl = 1;
-               if (class->parent) { 
-                       MonoMethod *cmethod = class->vtable [ghc_slot];
+               klass->ghcimpl = 1;
+               if (klass->parent) {
+                       MonoMethod *cmethod = klass->vtable [ghc_slot];
                        if (cmethod->is_inflated)
                                cmethod = ((MonoMethodInflated*)cmethod)->declaring;
                        if (cmethod == default_ghc) {
-                               class->ghcimpl = 0;
+                               klass->ghcimpl = 0;
                        }
                }
                */
 
                /* C# doesn't allow interfaces to have cctors */
-               if (!MONO_CLASS_IS_INTERFACE (class) || class->image != mono_defaults.corlib) {
+               if (!MONO_CLASS_IS_INTERFACE (klass) || klass->image != mono_defaults.corlib) {
                        MonoMethod *cmethod = NULL;
 
-                       if (class->type_token) {
-                               cmethod = find_method_in_metadata (class, ".cctor", 0, METHOD_ATTRIBUTE_SPECIAL_NAME);
+                       if (klass->type_token && !image_is_dynamic(klass->image)) {
+                               cmethod = find_method_in_metadata (klass, ".cctor", 0, METHOD_ATTRIBUTE_SPECIAL_NAME);
                                /* The find_method function ignores the 'flags' argument */
                                if (cmethod && (cmethod->flags & METHOD_ATTRIBUTE_SPECIAL_NAME))
-                                       class->has_cctor = 1;
+                                       klass->has_cctor = 1;
                        } else {
-                               mono_class_setup_methods (class);
-                               if (class->exception_type)
+                               mono_class_setup_methods (klass);
+                               if (klass->exception_type)
                                        goto leave;
 
-                               for (i = 0; i < class->method.count; ++i) {
-                                       MonoMethod *method = class->methods [i];
+                               for (i = 0; i < klass->method.count; ++i) {
+                                       MonoMethod *method = klass->methods [i];
                                        if ((method->flags & METHOD_ATTRIBUTE_SPECIAL_NAME) && 
                                                (strcmp (".cctor", method->name) == 0)) {
-                                               class->has_cctor = 1;
+                                               klass->has_cctor = 1;
                                                break;
                                        }
                                }
@@ -5242,58 +5289,58 @@ mono_class_init (MonoClass *class)
                }
        }
 
-       if (class->parent) {
+       if (klass->parent) {
                int first_iface_slot;
-               /* This will compute class->parent->vtable_size for some classes */
-               mono_class_init (class->parent);
-               if (class->parent->exception_type) {
-                       mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, NULL);
+               /* This will compute klass->parent->vtable_size for some classes */
+               mono_class_init (klass->parent);
+               if (klass->parent->exception_type) {
+                       mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, NULL);
                        goto leave;
                }
                if (mono_loader_get_last_error ())
                        goto leave;
-               if (!class->parent->vtable_size) {
+               if (!klass->parent->vtable_size) {
                        /* FIXME: Get rid of this somehow */
-                       mono_class_setup_vtable (class->parent);
-                       if (class->parent->exception_type) {
-                               mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, NULL);
+                       mono_class_setup_vtable (klass->parent);
+                       if (klass->parent->exception_type) {
+                               mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, NULL);
                                goto leave;
                        }
                        if (mono_loader_get_last_error ())
                                goto leave;
                }
-               first_iface_slot = class->parent->vtable_size;
-               if (mono_class_need_stelemref_method (class))
+               first_iface_slot = klass->parent->vtable_size;
+               if (mono_class_need_stelemref_method (klass))
                        ++first_iface_slot;
-               setup_interface_offsets (class, first_iface_slot, TRUE);
+               setup_interface_offsets (klass, first_iface_slot, TRUE);
        } else {
-               setup_interface_offsets (class, 0, TRUE);
+               setup_interface_offsets (klass, 0, TRUE);
        }
 
        if (mono_security_core_clr_enabled ())
-               mono_security_core_clr_check_inheritance (class);
+               mono_security_core_clr_check_inheritance (klass);
 
        if (mono_loader_get_last_error ()) {
-               if (class->exception_type == MONO_EXCEPTION_NONE) {
-                       set_failure_from_loader_error (class, mono_loader_get_last_error ());
+               if (klass->exception_type == MONO_EXCEPTION_NONE) {
+                       set_failure_from_loader_error (klass, mono_loader_get_last_error ());
                }
                mono_loader_clear_error ();
        }
 
-       if (class->generic_class && !mono_verifier_class_is_valid_generic_instantiation (class))
-               mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Invalid generic instantiation"));
+       if (klass->generic_class && !mono_verifier_class_is_valid_generic_instantiation (klass))
+               mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Invalid generic instantiation"));
 
        goto leave;
 
  leave:
        /* Because of the double-checking locking pattern */
        mono_memory_barrier ();
-       class->inited = 1;
-       class->init_pending = 0;
+       klass->inited = 1;
+       klass->init_pending = 0;
 
        mono_loader_unlock ();
 
-       return class->exception_type == MONO_EXCEPTION_NONE;
+       return klass->exception_type == MONO_EXCEPTION_NONE;
 }
 
 /*
@@ -5305,40 +5352,39 @@ mono_class_init (MonoClass *class)
 gboolean
 mono_class_has_finalizer (MonoClass *klass)
 {
-       MonoClass *class = klass;
        gboolean has_finalize = FALSE;
 
        if (klass->has_finalize_inited)
                return klass->has_finalize;
 
        /* Interfaces and valuetypes are not supposed to have finalizers */
-       if (!(MONO_CLASS_IS_INTERFACE (class) || class->valuetype)) {
+       if (!(MONO_CLASS_IS_INTERFACE (klass) || klass->valuetype)) {
                MonoMethod *cmethod = NULL;
 
-               if (class->rank == 1 && class->byval_arg.type == MONO_TYPE_SZARRAY) {
-               } else if (class->generic_class) {
-                       MonoClass *gklass = class->generic_class->container_class;
+               if (klass->rank == 1 && klass->byval_arg.type == MONO_TYPE_SZARRAY) {
+               } else if (klass->generic_class) {
+                       MonoClass *gklass = klass->generic_class->container_class;
 
                        has_finalize = mono_class_has_finalizer (gklass);
-               } else if (class->parent && class->parent->has_finalize) {
+               } else if (klass->parent && klass->parent->has_finalize) {
                        has_finalize = TRUE;
                } else {
-                       if (class->parent) {
+                       if (klass->parent) {
                                /*
                                 * Can't search in metadata for a method named Finalize, because that
                                 * ignores overrides.
                                 */
-                               mono_class_setup_vtable (class);
-                               if (class->exception_type || mono_loader_get_last_error ())
+                               mono_class_setup_vtable (klass);
+                               if (klass->exception_type || mono_loader_get_last_error ())
                                        cmethod = NULL;
                                else
-                                       cmethod = class->vtable [finalize_slot];
+                                       cmethod = klass->vtable [finalize_slot];
                        }
 
                        if (cmethod) {
-                               g_assert (class->vtable_size > finalize_slot);
+                               g_assert (klass->vtable_size > finalize_slot);
 
-                               if (class->parent) {
+                               if (klass->parent) {
                                        if (cmethod->is_inflated)
                                                cmethod = ((MonoMethodInflated*)cmethod)->declaring;
                                        if (cmethod != default_finalize)
@@ -5376,42 +5422,42 @@ mono_is_corlib_image (MonoImage *image)
  * LOCKING: this assumes the loader lock is held
  */
 void
-mono_class_setup_mono_type (MonoClass *class)
+mono_class_setup_mono_type (MonoClass *klass)
 {
-       const char *name = class->name;
-       const char *nspace = class->name_space;
-       gboolean is_corlib = mono_is_corlib_image (class->image);
+       const char *name = klass->name;
+       const char *nspace = klass->name_space;
+       gboolean is_corlib = mono_is_corlib_image (klass->image);
 
-       class->this_arg.byref = 1;
-       class->this_arg.data.klass = class;
-       class->this_arg.type = MONO_TYPE_CLASS;
-       class->byval_arg.data.klass = class;
-       class->byval_arg.type = MONO_TYPE_CLASS;
+       klass->this_arg.byref = 1;
+       klass->this_arg.data.klass = klass;
+       klass->this_arg.type = MONO_TYPE_CLASS;
+       klass->byval_arg.data.klass = klass;
+       klass->byval_arg.type = MONO_TYPE_CLASS;
 
        if (is_corlib && !strcmp (nspace, "System")) {
                if (!strcmp (name, "ValueType")) {
                        /*
                         * do not set the valuetype bit for System.ValueType.
-                        * class->valuetype = 1;
+                        * klass->valuetype = 1;
                         */
-                       class->blittable = TRUE;
+                       klass->blittable = TRUE;
                } else if (!strcmp (name, "Enum")) {
                        /*
                         * do not set the valuetype bit for System.Enum.
-                        * class->valuetype = 1;
+                        * klass->valuetype = 1;
                         */
-                       class->valuetype = 0;
-                       class->enumtype = 0;
+                       klass->valuetype = 0;
+                       klass->enumtype = 0;
                } else if (!strcmp (name, "Object")) {
-                       class->this_arg.type = class->byval_arg.type = MONO_TYPE_OBJECT;
+                       klass->this_arg.type = klass->byval_arg.type = MONO_TYPE_OBJECT;
                } else if (!strcmp (name, "String")) {
-                       class->this_arg.type = class->byval_arg.type = MONO_TYPE_STRING;
+                       klass->this_arg.type = klass->byval_arg.type = MONO_TYPE_STRING;
                } else if (!strcmp (name, "TypedReference")) {
-                       class->this_arg.type = class->byval_arg.type = MONO_TYPE_TYPEDBYREF;
+                       klass->this_arg.type = klass->byval_arg.type = MONO_TYPE_TYPEDBYREF;
                }
        }
 
-       if (class->valuetype) {
+       if (klass->valuetype) {
                int t = MONO_TYPE_VALUETYPE;
 
                if (is_corlib && !strcmp (nspace, "System")) {
@@ -5421,7 +5467,7 @@ mono_class_setup_mono_type (MonoClass *class)
                                        t = MONO_TYPE_BOOLEAN;
                                } else if (!strcmp(name, "Byte")) {
                                        t = MONO_TYPE_U1;
-                                       class->blittable = TRUE;                                                
+                                       klass->blittable = TRUE;                                                
                                }
                                break;
                        case 'C':
@@ -5432,52 +5478,52 @@ mono_class_setup_mono_type (MonoClass *class)
                        case 'D':
                                if (!strcmp (name, "Double")) {
                                        t = MONO_TYPE_R8;
-                                       class->blittable = TRUE;                                                
+                                       klass->blittable = TRUE;                                                
                                }
                                break;
                        case 'I':
                                if (!strcmp (name, "Int32")) {
                                        t = MONO_TYPE_I4;
-                                       class->blittable = TRUE;
+                                       klass->blittable = TRUE;
                                } else if (!strcmp(name, "Int16")) {
                                        t = MONO_TYPE_I2;
-                                       class->blittable = TRUE;
+                                       klass->blittable = TRUE;
                                } else if (!strcmp(name, "Int64")) {
                                        t = MONO_TYPE_I8;
-                                       class->blittable = TRUE;
+                                       klass->blittable = TRUE;
                                } else if (!strcmp(name, "IntPtr")) {
                                        t = MONO_TYPE_I;
-                                       class->blittable = TRUE;
+                                       klass->blittable = TRUE;
                                }
                                break;
                        case 'S':
                                if (!strcmp (name, "Single")) {
                                        t = MONO_TYPE_R4;
-                                       class->blittable = TRUE;                                                
+                                       klass->blittable = TRUE;                                                
                                } else if (!strcmp(name, "SByte")) {
                                        t = MONO_TYPE_I1;
-                                       class->blittable = TRUE;
+                                       klass->blittable = TRUE;
                                }
                                break;
                        case 'U':
                                if (!strcmp (name, "UInt32")) {
                                        t = MONO_TYPE_U4;
-                                       class->blittable = TRUE;
+                                       klass->blittable = TRUE;
                                } else if (!strcmp(name, "UInt16")) {
                                        t = MONO_TYPE_U2;
-                                       class->blittable = TRUE;
+                                       klass->blittable = TRUE;
                                } else if (!strcmp(name, "UInt64")) {
                                        t = MONO_TYPE_U8;
-                                       class->blittable = TRUE;
+                                       klass->blittable = TRUE;
                                } else if (!strcmp(name, "UIntPtr")) {
                                        t = MONO_TYPE_U;
-                                       class->blittable = TRUE;
+                                       klass->blittable = TRUE;
                                }
                                break;
                        case 'T':
                                if (!strcmp (name, "TypedReference")) {
                                        t = MONO_TYPE_TYPEDBYREF;
-                                       class->blittable = TRUE;
+                                       klass->blittable = TRUE;
                                }
                                break;
                        case 'V':
@@ -5489,11 +5535,11 @@ mono_class_setup_mono_type (MonoClass *class)
                                break;
                        }
                }
-               class->this_arg.type = class->byval_arg.type = t;
+               klass->this_arg.type = klass->byval_arg.type = t;
        }
 
-       if (MONO_CLASS_IS_INTERFACE (class))
-               class->interface_id = mono_get_unique_iid (class);
+       if (MONO_CLASS_IS_INTERFACE (klass))
+               klass->interface_id = mono_get_unique_iid (klass);
 
 }
 
@@ -5505,16 +5551,16 @@ mono_class_setup_mono_type (MonoClass *class)
  * lacks the types that COM depends on (e.g. Variant on Silverlight).
  */
 static void
-init_com_from_comimport (MonoClass *class)
+init_com_from_comimport (MonoClass *klass)
 {
        /* we don't always allow COM initialization under the CoreCLR (e.g. Moonlight does not require it) */
        if (mono_security_core_clr_enabled ()) {
                /* but some other CoreCLR user could requires it for their platform (i.e. trusted) code */
-               if (!mono_security_core_clr_determine_platform_image (class->image)) {
+               if (!mono_security_core_clr_determine_platform_image (klass->image)) {
                        /* but it can not be made available for application (i.e. user code) since all COM calls
                         * are considered native calls. In this case we fail with a TypeLoadException (just like
                         * Silverlight 2 does */
-                       mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, NULL);
+                       mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, NULL);
                        return;
                }
        }
@@ -5527,30 +5573,30 @@ init_com_from_comimport (MonoClass *class)
  * LOCKING: this assumes the loader lock is held
  */
 void
-mono_class_setup_parent (MonoClass *class, MonoClass *parent)
+mono_class_setup_parent (MonoClass *klass, MonoClass *parent)
 {
        gboolean system_namespace;
-       gboolean is_corlib = mono_is_corlib_image (class->image);
+       gboolean is_corlib = mono_is_corlib_image (klass->image);
 
-       system_namespace = !strcmp (class->name_space, "System") && is_corlib;
+       system_namespace = !strcmp (klass->name_space, "System") && is_corlib;
 
        /* if root of the hierarchy */
-       if (system_namespace && !strcmp (class->name, "Object")) {
-               class->parent = NULL;
-               class->instance_size = sizeof (MonoObject);
+       if (system_namespace && !strcmp (klass->name, "Object")) {
+               klass->parent = NULL;
+               klass->instance_size = sizeof (MonoObject);
                return;
        }
-       if (!strcmp (class->name, "<Module>")) {
-               class->parent = NULL;
-               class->instance_size = 0;
+       if (!strcmp (klass->name, "<Module>")) {
+               klass->parent = NULL;
+               klass->instance_size = 0;
                return;
        }
 
-       if (!MONO_CLASS_IS_INTERFACE (class)) {
+       if (!MONO_CLASS_IS_INTERFACE (klass)) {
                /* Imported COM Objects always derive from __ComObject. */
 #ifndef DISABLE_COM
-               if (MONO_CLASS_IS_IMPORT (class)) {
-                       init_com_from_comimport (class);
+               if (MONO_CLASS_IS_IMPORT (klass)) {
+                       init_com_from_comimport (klass);
                        if (parent == mono_defaults.object_class)
                                parent = mono_class_get_com_object_class ();
                }
@@ -5558,10 +5604,10 @@ mono_class_setup_parent (MonoClass *class, MonoClass *parent)
                if (!parent) {
                        /* set the parent to something useful and safe, but mark the type as broken */
                        parent = mono_defaults.object_class;
-                       mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, NULL);
+                       mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, NULL);
                }
 
-               class->parent = parent;
+               klass->parent = parent;
 
                if (parent->generic_class && !parent->name) {
                        /*
@@ -5573,41 +5619,41 @@ mono_class_setup_parent (MonoClass *class, MonoClass *parent)
                }
 
 #ifndef DISABLE_REMOTING
-               class->marshalbyref = parent->marshalbyref;
-               class->contextbound  = parent->contextbound;
+               klass->marshalbyref = parent->marshalbyref;
+               klass->contextbound  = parent->contextbound;
 #endif
 
-               class->delegate  = parent->delegate;
+               klass->delegate  = parent->delegate;
 
-               if (MONO_CLASS_IS_IMPORT (class) || mono_class_is_com_object (parent))
-                       mono_class_set_is_com_object (class);
+               if (MONO_CLASS_IS_IMPORT (klass) || mono_class_is_com_object (parent))
+                       mono_class_set_is_com_object (klass);
                
                if (system_namespace) {
 #ifndef DISABLE_REMOTING
-                       if (*class->name == 'M' && !strcmp (class->name, "MarshalByRefObject"))
-                               class->marshalbyref = 1;
+                       if (klass->name [0] == 'M' && !strcmp (klass->name, "MarshalByRefObject"))
+                               klass->marshalbyref = 1;
 
-                       if (*class->name == 'C' && !strcmp (class->name, "ContextBoundObject")) 
-                               class->contextbound  = 1;
+                       if (klass->name [0] == 'C' && !strcmp (klass->name, "ContextBoundObject")) 
+                               klass->contextbound  = 1;
 #endif
-                       if (*class->name == 'D' && !strcmp (class->name, "Delegate")) 
-                               class->delegate  = 1;
+                       if (klass->name [0] == 'D' && !strcmp (klass->name, "Delegate")) 
+                               klass->delegate  = 1;
                }
 
-               if (class->parent->enumtype || (mono_is_corlib_image (class->parent->image) && (strcmp (class->parent->name, "ValueType") == 0) && 
-                                               (strcmp (class->parent->name_space, "System") == 0)))
-                       class->valuetype = 1;
-               if (mono_is_corlib_image (class->parent->image) && ((strcmp (class->parent->name, "Enum") == 0) && (strcmp (class->parent->name_space, "System") == 0))) {
-                       class->valuetype = class->enumtype = 1;
+               if (klass->parent->enumtype || (mono_is_corlib_image (klass->parent->image) && (strcmp (klass->parent->name, "ValueType") == 0) && 
+                                               (strcmp (klass->parent->name_space, "System") == 0)))
+                       klass->valuetype = 1;
+               if (mono_is_corlib_image (klass->parent->image) && ((strcmp (klass->parent->name, "Enum") == 0) && (strcmp (klass->parent->name_space, "System") == 0))) {
+                       klass->valuetype = klass->enumtype = 1;
                }
-               /*class->enumtype = class->parent->enumtype; */
+               /*klass->enumtype = klass->parent->enumtype; */
        } else {
                /* initialize com types if COM interfaces are present */
 #ifndef DISABLE_COM
-               if (MONO_CLASS_IS_IMPORT (class))
-                       init_com_from_comimport (class);
+               if (MONO_CLASS_IS_IMPORT (klass))
+                       init_com_from_comimport (klass);
 #endif
-               class->parent = NULL;
+               klass->parent = NULL;
        }
 
 }
@@ -5626,33 +5672,33 @@ mono_class_setup_parent (MonoClass *class, MonoClass *parent)
  * LOCKING: This function is atomic, in case of contention we waste memory.
  */
 void
-mono_class_setup_supertypes (MonoClass *class)
+mono_class_setup_supertypes (MonoClass *klass)
 {
        int ms;
        MonoClass **supertypes;
 
-       mono_atomic_load_acquire (supertypes, void*, &class->supertypes);
+       mono_atomic_load_acquire (supertypes, void*, &klass->supertypes);
        if (supertypes)
                return;
 
-       if (class->parent && !class->parent->supertypes)
-               mono_class_setup_supertypes (class->parent);
-       if (class->parent)
-               class->idepth = class->parent->idepth + 1;
+       if (klass->parent && !klass->parent->supertypes)
+               mono_class_setup_supertypes (klass->parent);
+       if (klass->parent)
+               klass->idepth = klass->parent->idepth + 1;
        else
-               class->idepth = 1;
+               klass->idepth = 1;
 
-       ms = MAX (MONO_DEFAULT_SUPERTABLE_SIZE, class->idepth);
-       supertypes = mono_class_alloc0 (class, sizeof (MonoClass *) * ms);
+       ms = MAX (MONO_DEFAULT_SUPERTABLE_SIZE, klass->idepth);
+       supertypes = mono_class_alloc0 (klass, sizeof (MonoClass *) * ms);
 
-       if (class->parent) {
-               supertypes [class->idepth - 1] = class;
-               memcpy (supertypes, class->parent->supertypes, class->parent->idepth * sizeof (gpointer));
+       if (klass->parent) {
+               supertypes [klass->idepth - 1] = klass;
+               memcpy (supertypes, klass->parent->supertypes, klass->parent->idepth * sizeof (gpointer));
        } else {
-               supertypes [0] = class;
+               supertypes [0] = klass;
        }
 
-       mono_atomic_store_release (&class->supertypes, supertypes);
+       mono_atomic_store_release (&klass->supertypes, supertypes);
 }
 
 static gboolean
@@ -5671,25 +5717,25 @@ fix_gclass_incomplete_instantiation (MonoClass *gclass, void *user_data)
 }
 
 static void
-mono_class_set_failure_and_error (MonoClass *class, MonoError *error, const char *msg)
+mono_class_set_failure_and_error (MonoClass *klass, MonoError *error, const char *msg)
 {
-       mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup (msg));
-       mono_error_set_type_load_class (error, class, msg);
+       mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup (msg));
+       mono_error_set_type_load_class (error, klass, msg);
 }
 
 static void
-mono_class_set_failure_from_loader_error (MonoClass *class, MonoError *error, char *msg)
+mono_class_set_failure_from_loader_error (MonoClass *klass, MonoError *error, char *msg)
 {
        MonoLoaderError *lerror = mono_loader_get_last_error ();
 
        if (lerror) {
-               set_failure_from_loader_error (class, lerror);
+               set_failure_from_loader_error (klass, lerror);
                mono_error_set_from_loader_error (error);
                if (msg)
                        g_free (msg);
        } else {
-               mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, msg);
-               mono_error_set_type_load_class (error, class, msg);
+               mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, msg);
+               mono_error_set_type_load_class (error, klass, msg);
        }
 }
 
@@ -5708,7 +5754,7 @@ static MonoClass *
 mono_class_create_from_typedef (MonoImage *image, guint32 type_token, MonoError *error)
 {
        MonoTableInfo *tt = &image->tables [MONO_TABLE_TYPEDEF];
-       MonoClass *class, *parent = NULL;
+       MonoClass *klass, *parent = NULL;
        guint32 cols [MONO_TYPEDEF_SIZE];
        guint32 cols_next [MONO_TYPEDEF_SIZE];
        guint tidx = mono_metadata_token_index (type_token);
@@ -5729,10 +5775,10 @@ mono_class_create_from_typedef (MonoImage *image, guint32 type_token, MonoError
 
        mono_loader_lock ();
 
-       if ((class = mono_internal_hash_table_lookup (&image->class_cache, GUINT_TO_POINTER (type_token)))) {
+       if ((klass = mono_internal_hash_table_lookup (&image->class_cache, GUINT_TO_POINTER (type_token)))) {
                mono_loader_unlock ();
                mono_loader_assert_no_error ();
-               return class;
+               return klass;
        }
 
        mono_metadata_decode_row (tt, tidx - 1, cols, MONO_TYPEDEF_SIZE);
@@ -5740,32 +5786,32 @@ mono_class_create_from_typedef (MonoImage *image, guint32 type_token, MonoError
        name = mono_metadata_string_heap (image, cols [MONO_TYPEDEF_NAME]);
        nspace = mono_metadata_string_heap (image, cols [MONO_TYPEDEF_NAMESPACE]);
 
-       class = mono_image_alloc0 (image, sizeof (MonoClass));
+       klass = mono_image_alloc0 (image, sizeof (MonoClass));
 
-       class->name = name;
-       class->name_space = nspace;
+       klass->name = name;
+       klass->name_space = nspace;
 
-       mono_profiler_class_event (class, MONO_PROFILE_START_LOAD);
+       mono_profiler_class_event (klass, MONO_PROFILE_START_LOAD);
 
-       class->image = image;
-       class->type_token = type_token;
-       class->flags = cols [MONO_TYPEDEF_FLAGS];
+       klass->image = image;
+       klass->type_token = type_token;
+       klass->flags = cols [MONO_TYPEDEF_FLAGS];
 
-       mono_internal_hash_table_insert (&image->class_cache, GUINT_TO_POINTER (type_token), class);
+       mono_internal_hash_table_insert (&image->class_cache, GUINT_TO_POINTER (type_token), klass);
 
        classes_size += sizeof (MonoClass);
 
        /*
         * Check whether we're a generic type definition.
         */
-       class->generic_container = mono_metadata_load_generic_params (image, class->type_token, NULL);
-       if (class->generic_container) {
-               class->is_generic = 1;
-               class->generic_container->owner.klass = class;
-               context = &class->generic_container->context;
+       klass->generic_container = mono_metadata_load_generic_params (image, klass->type_token, NULL);
+       if (klass->generic_container) {
+               klass->is_generic = 1;
+               klass->generic_container->owner.klass = klass;
+               context = &klass->generic_container->context;
        }
 
-       if (class->generic_container)
+       if (klass->generic_container)
                enable_gclass_recording ();
 
        if (cols [MONO_TYPEDEF_EXTENDS]) {
@@ -5774,80 +5820,80 @@ mono_class_create_from_typedef (MonoImage *image, guint32 type_token, MonoError
 
                if (mono_metadata_token_table (parent_token) == MONO_TABLE_TYPESPEC) {
                        /*WARNING: this must satisfy mono_metadata_type_hash*/
-                       class->this_arg.byref = 1;
-                       class->this_arg.data.klass = class;
-                       class->this_arg.type = MONO_TYPE_CLASS;
-                       class->byval_arg.data.klass = class;
-                       class->byval_arg.type = MONO_TYPE_CLASS;
+                       klass->this_arg.byref = 1;
+                       klass->this_arg.data.klass = klass;
+                       klass->this_arg.type = MONO_TYPE_CLASS;
+                       klass->byval_arg.data.klass = klass;
+                       klass->byval_arg.type = MONO_TYPE_CLASS;
                }
                parent = mono_class_get_checked (image, parent_token, error);
                if (parent && context) /* Always inflate */
                        parent = mono_class_inflate_generic_class_checked (parent, context, error);
 
                if (parent == NULL) {
-                       mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup (mono_error_get_message (error)));
+                       mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup (mono_error_get_message (error)));
                        goto parent_failure;
                }
 
                for (tmp = parent; tmp; tmp = tmp->parent) {
-                       if (tmp == class) {
-                               mono_class_set_failure_and_error (class, error, "Cycle found while resolving parent");
+                       if (tmp == klass) {
+                               mono_class_set_failure_and_error (klass, error, "Cycle found while resolving parent");
                                goto parent_failure;
                        }
-                       if (class->generic_container && tmp->generic_class && tmp->generic_class->container_class == class) {
-                               mono_class_set_failure_and_error (class, error, "Parent extends generic instance of this type");
+                       if (klass->generic_container && tmp->generic_class && tmp->generic_class->container_class == klass) {
+                               mono_class_set_failure_and_error (klass, error, "Parent extends generic instance of this type");
                                goto parent_failure;
                        }
                }
        }
 
-       mono_class_setup_parent (class, parent);
+       mono_class_setup_parent (klass, parent);
 
        /* uses ->valuetype, which is initialized by mono_class_setup_parent above */
-       mono_class_setup_mono_type (class);
+       mono_class_setup_mono_type (klass);
 
-       if (class->generic_container)
-               disable_gclass_recording (fix_gclass_incomplete_instantiation, class);
+       if (klass->generic_container)
+               disable_gclass_recording (fix_gclass_incomplete_instantiation, klass);
 
        /* 
-        * This might access class->byval_arg for recursion generated by generic constraints,
+        * This might access klass->byval_arg for recursion generated by generic constraints,
         * so it has to come after setup_mono_type ().
         */
        if ((nesting_tokeen = mono_metadata_nested_in_typedef (image, type_token))) {
-               class->nested_in = mono_class_create_from_typedef (image, nesting_tokeen, error);
+               klass->nested_in = mono_class_create_from_typedef (image, nesting_tokeen, error);
                if (!mono_error_ok (error)) {
                        /*FIXME implement a mono_class_set_failure_from_mono_error */
-                       mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup (mono_error_get_message (error)));
+                       mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup (mono_error_get_message (error)));
                        mono_loader_unlock ();
-                       mono_profiler_class_loaded (class, MONO_PROFILE_FAILED);
+                       mono_profiler_class_loaded (klass, MONO_PROFILE_FAILED);
                        mono_loader_assert_no_error ();
                        return NULL;
                }
        }
 
-       if ((class->flags & TYPE_ATTRIBUTE_STRING_FORMAT_MASK) == TYPE_ATTRIBUTE_UNICODE_CLASS)
-               class->unicode = 1;
+       if ((klass->flags & TYPE_ATTRIBUTE_STRING_FORMAT_MASK) == TYPE_ATTRIBUTE_UNICODE_CLASS)
+               klass->unicode = 1;
 
 #ifdef HOST_WIN32
-       if ((class->flags & TYPE_ATTRIBUTE_STRING_FORMAT_MASK) == TYPE_ATTRIBUTE_AUTO_CLASS)
-               class->unicode = 1;
+       if ((klass->flags & TYPE_ATTRIBUTE_STRING_FORMAT_MASK) == TYPE_ATTRIBUTE_AUTO_CLASS)
+               klass->unicode = 1;
 #endif
 
-       class->cast_class = class->element_class = class;
+       klass->cast_class = klass->element_class = klass;
 
-       if (!class->enumtype) {
+       if (!klass->enumtype) {
                if (!mono_metadata_interfaces_from_typedef_full (
                            image, type_token, &interfaces, &icount, FALSE, context, error)){
 
-                       mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup (mono_error_get_message (error)));
+                       mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup (mono_error_get_message (error)));
                        mono_loader_unlock ();
-                       mono_profiler_class_loaded (class, MONO_PROFILE_FAILED);
+                       mono_profiler_class_loaded (klass, MONO_PROFILE_FAILED);
                        return NULL;
                }
 
-               class->interfaces = interfaces;
-               class->interface_count = icount;
-               class->interfaces_inited = 1;
+               klass->interfaces = interfaces;
+               klass->interface_count = icount;
+               klass->interfaces_inited = 1;
        }
 
        /*g_print ("Load class %s\n", name);*/
@@ -5855,8 +5901,8 @@ mono_class_create_from_typedef (MonoImage *image, guint32 type_token, MonoError
        /*
         * Compute the field and method lists
         */
-       class->field.first  = cols [MONO_TYPEDEF_FIELD_LIST] - 1;
-       class->method.first = cols [MONO_TYPEDEF_METHOD_LIST] - 1;
+       klass->field.first  = cols [MONO_TYPEDEF_FIELD_LIST] - 1;
+       klass->method.first = cols [MONO_TYPEDEF_METHOD_LIST] - 1;
 
        if (tt->rows > tidx){           
                mono_metadata_decode_row (tt, tidx, cols_next, MONO_TYPEDEF_SIZE);
@@ -5869,33 +5915,33 @@ mono_class_create_from_typedef (MonoImage *image, guint32 type_token, MonoError
 
        if (cols [MONO_TYPEDEF_FIELD_LIST] && 
            cols [MONO_TYPEDEF_FIELD_LIST] <= image->tables [MONO_TABLE_FIELD].rows)
-               class->field.count = field_last - class->field.first;
+               klass->field.count = field_last - klass->field.first;
        else
-               class->field.count = 0;
+               klass->field.count = 0;
 
        if (cols [MONO_TYPEDEF_METHOD_LIST] <= image->tables [MONO_TABLE_METHOD].rows)
-               class->method.count = method_last - class->method.first;
+               klass->method.count = method_last - klass->method.first;
        else
-               class->method.count = 0;
+               klass->method.count = 0;
 
        /* reserve space to store vector pointer in arrays */
        if (mono_is_corlib_image (image) && !strcmp (nspace, "System") && !strcmp (name, "Array")) {
-               class->instance_size += 2 * sizeof (gpointer);
-               g_assert (class->field.count == 0);
+               klass->instance_size += 2 * sizeof (gpointer);
+               g_assert (klass->field.count == 0);
        }
 
-       if (class->enumtype) {
-               MonoType *enum_basetype = mono_class_find_enum_basetype (class, error);
+       if (klass->enumtype) {
+               MonoType *enum_basetype = mono_class_find_enum_basetype (klass, error);
                if (!enum_basetype) {
                        /*set it to a default value as the whole runtime can't handle this to be null*/
-                       class->cast_class = class->element_class = mono_defaults.int32_class;
-                       mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup (mono_error_get_message (error)));
+                       klass->cast_class = klass->element_class = mono_defaults.int32_class;
+                       mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup (mono_error_get_message (error)));
                        mono_loader_unlock ();
-                       mono_profiler_class_loaded (class, MONO_PROFILE_FAILED);
+                       mono_profiler_class_loaded (klass, MONO_PROFILE_FAILED);
                        mono_loader_assert_no_error ();
                        return NULL;
                }
-               class->cast_class = class->element_class = mono_class_from_mono_type (enum_basetype);
+               klass->cast_class = klass->element_class = mono_class_from_mono_type (enum_basetype);
        }
 
        /*
@@ -5903,30 +5949,30 @@ mono_class_create_from_typedef (MonoImage *image, guint32 type_token, MonoError
         * We must do this after the class has been constructed to make certain recursive scenarios
         * work.
         */
-       if (class->generic_container && !mono_metadata_load_generic_param_constraints_checked (image, type_token, class->generic_container, error)) {
-               mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Could not load generic parameter constrains due to %s", mono_error_get_message (error)));
+       if (klass->generic_container && !mono_metadata_load_generic_param_constraints_checked (image, type_token, klass->generic_container, error)) {
+               mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Could not load generic parameter constrains due to %s", mono_error_get_message (error)));
                mono_loader_unlock ();
-               mono_profiler_class_loaded (class, MONO_PROFILE_FAILED);
+               mono_profiler_class_loaded (klass, MONO_PROFILE_FAILED);
                mono_loader_assert_no_error ();
                return NULL;
        }
 
-       if (class->image->assembly_name && !strcmp (class->image->assembly_name, "Mono.Simd") && !strcmp (nspace, "Mono.Simd")) {
+       if (klass->image->assembly_name && !strcmp (klass->image->assembly_name, "Mono.Simd") && !strcmp (nspace, "Mono.Simd")) {
                if (!strncmp (name, "Vector", 6))
-                       class->simd_type = !strcmp (name + 6, "2d") || !strcmp (name + 6, "2ul") || !strcmp (name + 6, "2l") || !strcmp (name + 6, "4f") || !strcmp (name + 6, "4ui") || !strcmp (name + 6, "4i") || !strcmp (name + 6, "8s") || !strcmp (name + 6, "8us") || !strcmp (name + 6, "16b") || !strcmp (name + 6, "16sb");
+                       klass->simd_type = !strcmp (name + 6, "2d") || !strcmp (name + 6, "2ul") || !strcmp (name + 6, "2l") || !strcmp (name + 6, "4f") || !strcmp (name + 6, "4ui") || !strcmp (name + 6, "4i") || !strcmp (name + 6, "8s") || !strcmp (name + 6, "8us") || !strcmp (name + 6, "16b") || !strcmp (name + 6, "16sb");
        }
 
        mono_loader_unlock ();
 
-       mono_profiler_class_loaded (class, MONO_PROFILE_OK);
+       mono_profiler_class_loaded (klass, MONO_PROFILE_OK);
        mono_loader_assert_no_error ();
 
-       return class;
+       return klass;
 
 parent_failure:
-       mono_class_setup_mono_type (class);
+       mono_class_setup_mono_type (klass);
        mono_loader_unlock ();
-       mono_profiler_class_loaded (class, MONO_PROFILE_FAILED);
+       mono_profiler_class_loaded (klass, MONO_PROFILE_FAILED);
        mono_loader_assert_no_error ();
        return NULL;
 }
@@ -6570,7 +6616,7 @@ MonoClass *
 mono_bounded_array_class_get (MonoClass *eclass, guint32 rank, gboolean bounded)
 {
        MonoImage *image;
-       MonoClass *class;
+       MonoClass *klass;
        MonoClass *parent = NULL;
        GSList *list, *rootlist = NULL;
        int nsize;
@@ -6594,10 +6640,10 @@ mono_bounded_array_class_get (MonoClass *eclass, guint32 rank, gboolean bounded)
                mono_mutex_lock (&image->szarray_cache_lock);
                if (!image->szarray_cache)
                        image->szarray_cache = g_hash_table_new (mono_aligned_addr_hash, NULL);
-               class = g_hash_table_lookup (image->szarray_cache, eclass);
+               klass = g_hash_table_lookup (image->szarray_cache, eclass);
                mono_mutex_unlock (&image->szarray_cache_lock);
-               if (class)
-                       return class;
+               if (klass)
+                       return klass;
 
                mono_loader_lock ();
        } else {
@@ -6608,10 +6654,10 @@ mono_bounded_array_class_get (MonoClass *eclass, guint32 rank, gboolean bounded)
 
                if ((rootlist = list = g_hash_table_lookup (image->array_cache, eclass))) {
                        for (; list; list = list->next) {
-                               class = list->data;
-                               if ((class->rank == rank) && (class->byval_arg.type == (((rank > 1) || bounded) ? MONO_TYPE_ARRAY : MONO_TYPE_SZARRAY))) {
+                               klass = list->data;
+                               if ((klass->rank == rank) && (klass->byval_arg.type == (((rank > 1) || bounded) ? MONO_TYPE_ARRAY : MONO_TYPE_SZARRAY))) {
                                        mono_loader_unlock ();
-                                       return class;
+                                       return klass;
                                }
                        }
                }
@@ -6627,10 +6673,10 @@ mono_bounded_array_class_get (MonoClass *eclass, guint32 rank, gboolean bounded)
                        mono_class_init (parent);
        }
 
-       class = mono_image_alloc0 (image, sizeof (MonoClass));
+       klass = mono_image_alloc0 (image, sizeof (MonoClass));
 
-       class->image = image;
-       class->name_space = eclass->name_space;
+       klass->image = image;
+       klass->name_space = eclass->name_space;
        nsize = strlen (eclass->name);
        name = g_malloc (nsize + 2 + rank + 1);
        memcpy (name, eclass->name, nsize);
@@ -6641,95 +6687,95 @@ mono_bounded_array_class_get (MonoClass *eclass, guint32 rank, gboolean bounded)
                name [nsize + rank] = '*';
        name [nsize + rank + bounded] = ']';
        name [nsize + rank + bounded + 1] = 0;
-       class->name = mono_image_strdup (image, name);
+       klass->name = mono_image_strdup (image, name);
        g_free (name);
 
-       mono_profiler_class_event (class, MONO_PROFILE_START_LOAD);
+       mono_profiler_class_event (klass, MONO_PROFILE_START_LOAD);
 
        classes_size += sizeof (MonoClass);
 
-       class->type_token = 0;
+       klass->type_token = 0;
        /* all arrays are marked serializable and sealed, bug #42779 */
-       class->flags = TYPE_ATTRIBUTE_CLASS | TYPE_ATTRIBUTE_SERIALIZABLE | TYPE_ATTRIBUTE_SEALED | TYPE_ATTRIBUTE_PUBLIC;
-       class->parent = parent;
-       class->instance_size = mono_class_instance_size (class->parent);
+       klass->flags = TYPE_ATTRIBUTE_CLASS | TYPE_ATTRIBUTE_SERIALIZABLE | TYPE_ATTRIBUTE_SEALED | TYPE_ATTRIBUTE_PUBLIC;
+       klass->parent = parent;
+       klass->instance_size = mono_class_instance_size (klass->parent);
 
        if (eclass->byval_arg.type == MONO_TYPE_TYPEDBYREF || eclass->byval_arg.type == MONO_TYPE_VOID) {
                /*Arrays of those two types are invalid.*/
-               mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, NULL);
+               mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, NULL);
        } else if (eclass->enumtype && !mono_class_enum_basetype (eclass)) {
                if (!eclass->ref_info_handle || eclass->wastypebuilder) {
                        g_warning ("Only incomplete TypeBuilder objects are allowed to be an enum without base_type");
                        g_assert (eclass->ref_info_handle && !eclass->wastypebuilder);
                }
                /* element_size -1 is ok as this is not an instantitable type*/
-               class->sizes.element_size = -1;
+               klass->sizes.element_size = -1;
        } else
-               class->sizes.element_size = mono_class_array_element_size (eclass);
+               klass->sizes.element_size = mono_class_array_element_size (eclass);
 
-       mono_class_setup_supertypes (class);
+       mono_class_setup_supertypes (klass);
 
        if (eclass->generic_class)
                mono_class_init (eclass);
        if (!eclass->size_inited)
                mono_class_setup_fields (eclass);
        if (eclass->exception_type) /*FIXME we fail the array type, but we have to let other fields be set.*/
-               mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, NULL);
+               mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, NULL);
 
-       class->has_references = MONO_TYPE_IS_REFERENCE (&eclass->byval_arg) || eclass->has_references? TRUE: FALSE;
+       klass->has_references = MONO_TYPE_IS_REFERENCE (&eclass->byval_arg) || eclass->has_references? TRUE: FALSE;
 
-       class->rank = rank;
+       klass->rank = rank;
        
        if (eclass->enumtype)
-               class->cast_class = eclass->element_class;
+               klass->cast_class = eclass->element_class;
        else
-               class->cast_class = eclass;
+               klass->cast_class = eclass;
 
-       switch (class->cast_class->byval_arg.type) {
+       switch (klass->cast_class->byval_arg.type) {
        case MONO_TYPE_I1:
-               class->cast_class = mono_defaults.byte_class;
+               klass->cast_class = mono_defaults.byte_class;
                break;
        case MONO_TYPE_U2:
-               class->cast_class = mono_defaults.int16_class;
+               klass->cast_class = mono_defaults.int16_class;
                break;
        case MONO_TYPE_U4:
 #if SIZEOF_VOID_P == 4
        case MONO_TYPE_I:
        case MONO_TYPE_U:
 #endif
-               class->cast_class = mono_defaults.int32_class;
+               klass->cast_class = mono_defaults.int32_class;
                break;
        case MONO_TYPE_U8:
 #if SIZEOF_VOID_P == 8
        case MONO_TYPE_I:
        case MONO_TYPE_U:
 #endif
-               class->cast_class = mono_defaults.int64_class;
+               klass->cast_class = mono_defaults.int64_class;
                break;
        default:
                break;
        }
 
-       class->element_class = eclass;
+       klass->element_class = eclass;
 
        if ((rank > 1) || bounded) {
                MonoArrayType *at = mono_image_alloc0 (image, sizeof (MonoArrayType));
-               class->byval_arg.type = MONO_TYPE_ARRAY;
-               class->byval_arg.data.array = at;
+               klass->byval_arg.type = MONO_TYPE_ARRAY;
+               klass->byval_arg.data.array = at;
                at->eklass = eclass;
                at->rank = rank;
                /* FIXME: complete.... */
        } else {
-               class->byval_arg.type = MONO_TYPE_SZARRAY;
-               class->byval_arg.data.klass = eclass;
+               klass->byval_arg.type = MONO_TYPE_SZARRAY;
+               klass->byval_arg.data.klass = eclass;
        }
-       class->this_arg = class->byval_arg;
-       class->this_arg.byref = 1;
+       klass->this_arg = klass->byval_arg;
+       klass->this_arg.byref = 1;
        if (corlib_type) {
-               class->inited = 1;
+               klass->inited = 1;
        }
 
-       class->generic_container = eclass->generic_container;
+       klass->generic_container = eclass->generic_container;
 
        if (rank == 1 && !bounded) {
                MonoClass *prev_class;
@@ -6738,20 +6784,20 @@ mono_bounded_array_class_get (MonoClass *eclass, guint32 rank, gboolean bounded)
                prev_class = g_hash_table_lookup (image->szarray_cache, eclass);
                if (prev_class)
                        /* Someone got in before us */
-                       class = prev_class;
+                       klass = prev_class;
                else
-                       g_hash_table_insert (image->szarray_cache, eclass, class);
+                       g_hash_table_insert (image->szarray_cache, eclass, klass);
                mono_mutex_unlock (&image->szarray_cache_lock);
        } else {
-               list = g_slist_append (rootlist, class);
+               list = g_slist_append (rootlist, klass);
                g_hash_table_insert (image->array_cache, eclass, list);
        }
 
        mono_loader_unlock ();
 
-       mono_profiler_class_loaded (class, MONO_PROFILE_OK);
+       mono_profiler_class_loaded (klass, MONO_PROFILE_OK);
 
-       return class;
+       return klass;
 }
 
 /**
@@ -6854,34 +6900,34 @@ mono_class_data_size (MonoClass *klass)
  * Takes a field index instead of a field token.
  */
 static MonoClassField *
-mono_class_get_field_idx (MonoClass *class, int idx)
+mono_class_get_field_idx (MonoClass *klass, int idx)
 {
-       mono_class_setup_fields_locking (class);
-       if (class->exception_type)
+       mono_class_setup_fields_locking (klass);
+       if (klass->exception_type)
                return NULL;
 
-       while (class) {
-               if (class->image->uncompressed_metadata) {
+       while (klass) {
+               if (klass->image->uncompressed_metadata) {
                        /* 
-                        * class->field.first points to the FieldPtr table, while idx points into the
+                        * klass->field.first points to the FieldPtr table, while idx points into the
                         * Field table, so we have to do a search.
                         */
                        /*FIXME this is broken for types with multiple fields with the same name.*/
-                       const char *name = mono_metadata_string_heap (class->image, mono_metadata_decode_row_col (&class->image->tables [MONO_TABLE_FIELD], idx, MONO_FIELD_NAME));
+                       const char *name = mono_metadata_string_heap (klass->image, mono_metadata_decode_row_col (&klass->image->tables [MONO_TABLE_FIELD], idx, MONO_FIELD_NAME));
                        int i;
 
-                       for (i = 0; i < class->field.count; ++i)
-                               if (mono_field_get_name (&class->fields [i]) == name)
-                                       return &class->fields [i];
+                       for (i = 0; i < klass->field.count; ++i)
+                               if (mono_field_get_name (&klass->fields [i]) == name)
+                                       return &klass->fields [i];
                        g_assert_not_reached ();
                } else {                        
-                       if (class->field.count) {
-                               if ((idx >= class->field.first) && (idx < class->field.first + class->field.count)){
-                                       return &class->fields [idx - class->field.first];
+                       if (klass->field.count) {
+                               if ((idx >= klass->field.first) && (idx < klass->field.first + klass->field.count)){
+                                       return &klass->fields [idx - klass->field.first];
                                }
                        }
                }
-               class = class->parent;
+               klass = klass->parent;
        }
        return NULL;
 }
@@ -6896,13 +6942,13 @@ mono_class_get_field_idx (MonoClass *class, int idx)
  * class.
  */
 MonoClassField *
-mono_class_get_field (MonoClass *class, guint32 field_token)
+mono_class_get_field (MonoClass *klass, guint32 field_token)
 {
        int idx = mono_metadata_token_index (field_token);
 
        g_assert (mono_metadata_token_code (field_token) == MONO_TOKEN_FIELD_DEF);
 
-       return mono_class_get_field_idx (class, idx - 1);
+       return mono_class_get_field_idx (klass, idx - 1);
 }
 
 /**
@@ -7284,29 +7330,29 @@ MonoClass *
 mono_class_get_full (MonoImage *image, guint32 type_token, MonoGenericContext *context)
 {
        MonoError error;
-       MonoClass *class;
-       class = mono_class_get_checked (image, type_token, &error);
+       MonoClass *klass;
+       klass = mono_class_get_checked (image, type_token, &error);
 
-       if (class && context && mono_metadata_token_table (type_token) == MONO_TABLE_TYPESPEC)
-               class = mono_class_inflate_generic_class_checked (class, context, &error);
+       if (klass && context && mono_metadata_token_table (type_token) == MONO_TABLE_TYPESPEC)
+               klass = mono_class_inflate_generic_class_checked (klass, context, &error);
 
        g_assert (mono_error_ok (&error)); /* FIXME deprecate this function and forbit the runtime from using it. */
-       return class;
+       return klass;
 }
 
 
 MonoClass *
 mono_class_get_and_inflate_typespec_checked (MonoImage *image, guint32 type_token, MonoGenericContext *context, MonoError *error)
 {
-       MonoClass *class;
+       MonoClass *klass;
 
        mono_error_init (error);
-       class = mono_class_get_checked (image, type_token, error);
+       klass = mono_class_get_checked (image, type_token, error);
 
-       if (class && context && mono_metadata_token_table (type_token) == MONO_TABLE_TYPESPEC)
-               class = mono_class_inflate_generic_class_checked (class, context, error);
+       if (klass && context && mono_metadata_token_table (type_token) == MONO_TABLE_TYPESPEC)
+               klass = mono_class_inflate_generic_class_checked (klass, context, error);
 
-       return class;
+       return klass;
 }
 /**
  * mono_class_get_checked:
@@ -7319,7 +7365,7 @@ mono_class_get_and_inflate_typespec_checked (MonoImage *image, guint32 type_toke
 MonoClass *
 mono_class_get_checked (MonoImage *image, guint32 type_token, MonoError *error)
 {
-       MonoClass *class = NULL;
+       MonoClass *klass = NULL;
 
        mono_error_init (error);
 
@@ -7330,19 +7376,19 @@ mono_class_get_checked (MonoImage *image, guint32 type_token, MonoError *error)
                        mono_error_set_bad_image (error, image,"Bad token table for dynamic image: %x", table);
                        return NULL;
                }
-               class = mono_lookup_dynamic_token (image, type_token, NULL); /*FIXME proper error handling*/
+               klass = mono_lookup_dynamic_token (image, type_token, NULL); /*FIXME proper error handling*/
                goto done;
        }
 
        switch (type_token & 0xff000000){
        case MONO_TOKEN_TYPE_DEF:
-               class = mono_class_create_from_typedef (image, type_token, error);
+               klass = mono_class_create_from_typedef (image, type_token, error);
                break;          
        case MONO_TOKEN_TYPE_REF:
-               class = mono_class_from_typeref_checked (image, type_token, error);
+               klass = mono_class_from_typeref_checked (image, type_token, error);
                break;
        case MONO_TOKEN_TYPE_SPEC:
-               class = mono_class_create_from_typespec (image, type_token, NULL, error);
+               klass = mono_class_create_from_typespec (image, type_token, NULL, error);
                break;
        default:
                mono_error_set_bad_image (error, image, "Unknown type token %x", type_token & 0xff000000);
@@ -7350,13 +7396,13 @@ mono_class_get_checked (MonoImage *image, guint32 type_token, MonoError *error)
 
 done:
        /* Generic case, should be avoided for when a better error is possible. */
-       if (!class && mono_error_ok (error)) {
+       if (!klass && mono_error_ok (error)) {
                char *name = mono_class_name_from_token (image, type_token);
                char *assembly = mono_assembly_name_from_token (image, type_token);
                mono_error_set_type_load_name (error, name, assembly, "Could not resolve type with token %08x", type_token);
        }
 
-       return class;
+       return klass;
 }
 
 
@@ -7384,15 +7430,15 @@ mono_type_get_checked (MonoImage *image, guint32 type_token, MonoGenericContext
                return mono_class_get_type (mono_lookup_dynamic_token (image, type_token, context));
 
        if ((type_token & 0xff000000) != MONO_TOKEN_TYPE_SPEC) {
-               MonoClass *class = mono_class_get_checked (image, type_token, error);
+               MonoClass *klass = mono_class_get_checked (image, type_token, error);
 
-               if (!class) {
+               if (!klass) {
                        mono_loader_assert_no_error ();
                        return NULL;
                }
 
-               g_assert (class);
-               return mono_class_get_type (class);
+               g_assert (klass);
+               return mono_class_get_type (klass);
        }
 
        type = mono_type_retrieve_from_typespec (image, type_token, context, &inflated, error);
@@ -7510,6 +7556,8 @@ mono_image_init_name_cache (MonoImage *image)
        }
 
        g_hash_table_destroy (name_cache2);
+
+       mono_image_lock (image);
        if (image->name_cache) {
                /* Somebody initialized it before us */
                g_hash_table_destroy (the_name_cache);
@@ -7642,7 +7690,7 @@ mono_class_from_name_case_checked (MonoImage *image, const char* name_space, con
 }
 
 static MonoClass*
-return_nested_in (MonoClass *class, char *nested)
+return_nested_in (MonoClass *klass, char *nested)
 {
        MonoClass *found;
        char *s = strchr (nested, '/');
@@ -7653,7 +7701,7 @@ return_nested_in (MonoClass *class, char *nested)
                s++;
        }
 
-       while ((found = mono_class_get_nested_types (class, &iter))) {
+       while ((found = mono_class_get_nested_types (klass, &iter))) {
                if (strcmp (found->name, nested) == 0) {
                        if (s)
                                return return_nested_in (found, s);
@@ -7668,7 +7716,7 @@ search_modules (MonoImage *image, const char *name_space, const char *name)
 {
        MonoTableInfo *file_table = &image->tables [MONO_TABLE_FILE];
        MonoImage *file_image;
-       MonoClass *class;
+       MonoClass *klass;
        int i;
 
        /* 
@@ -7685,9 +7733,9 @@ search_modules (MonoImage *image, const char *name_space, const char *name)
 
                file_image = mono_image_load_file_for_image (image, i + 1);
                if (file_image) {
-                       class = mono_class_from_name (file_image, name_space, name);
-                       if (class)
-                               return class;
+                       klass = mono_class_from_name (file_image, name_space, name);
+                       if (klass)
+                               return klass;
                }
        }
 
@@ -7701,7 +7749,7 @@ mono_class_from_name_checked_aux (MonoImage *image, const char* name_space, cons
        MonoImage *loaded_image;
        guint32 token = 0;
        int i;
-       MonoClass *class;
+       MonoClass *klass;
        char *nested;
        char buf [1024];
 
@@ -7726,14 +7774,14 @@ mono_class_from_name_checked_aux (MonoImage *image, const char* name_space, cons
 
        /* FIXME: get_class_from_name () can't handle types in the EXPORTEDTYPE table */
        if (get_class_from_name && image->tables [MONO_TABLE_EXPORTEDTYPE].rows == 0) {
-               gboolean res = get_class_from_name (image, name_space, name, &class);
+               gboolean res = get_class_from_name (image, name_space, name, &klass);
                if (res) {
-                       if (!class)
-                               class = search_modules (image, name_space, name);
+                       if (!klass)
+                               klass = search_modules (image, name_space, name);
                        if (nested)
-                               return class ? return_nested_in (class, nested) : NULL;
+                               return klass ? return_nested_in (klass, nested) : NULL;
                        else
-                               return class;
+                               return klass;
                }
        }
 
@@ -7752,16 +7800,16 @@ mono_class_from_name_checked_aux (MonoImage *image, const char* name_space, cons
                for (i = 0; i < image->module_count; ++i) {
                        MonoImage *module = image->modules [i];
 
-                       class = mono_class_from_name (module, name_space, name);
-                       if (class)
-                               return class;
+                       klass = mono_class_from_name (module, name_space, name);
+                       if (klass)
+                               return klass;
                }
        }
 
        if (!token) {
-               class = search_modules (image, name_space, name);
-               if (class)
-                       return class;
+               klass = search_modules (image, name_space, name);
+               if (klass)
+                       return klass;
        }
 
        if (!token)
@@ -7781,10 +7829,10 @@ mono_class_from_name_checked_aux (MonoImage *image, const char* name_space, cons
                        loaded_image = mono_assembly_load_module (image->assembly, impl >> MONO_IMPLEMENTATION_BITS);
                        if (!loaded_image)
                                return NULL;
-                       class = mono_class_from_name_checked_aux (loaded_image, name_space, name, error, visited_images);
+                       klass = mono_class_from_name_checked_aux (loaded_image, name_space, name, error, visited_images);
                        if (nested)
-                               return return_nested_in (class, nested);
-                       return class;
+                               return return_nested_in (klass, nested);
+                       return klass;
                } else if ((impl & MONO_IMPLEMENTATION_MASK) == MONO_IMPLEMENTATION_ASSEMBLYREF) {
                        guint32 assembly_idx;
 
@@ -7803,10 +7851,10 @@ mono_class_from_name_checked_aux (MonoImage *image, const char* name_space, cons
 
        token = MONO_TOKEN_TYPE_DEF | token;
 
-       class = mono_class_get_checked (image, token, error);
+       klass = mono_class_get_checked (image, token, error);
        if (nested)
-               return return_nested_in (class, nested);
-       return class;
+               return return_nested_in (klass, nested);
+       return klass;
 }
 
 MonoClass *
@@ -8580,7 +8628,7 @@ mono_ldtoken_checked (MonoImage *image, guint32 token, MonoClass **handle_class,
                return type;
        }
        case MONO_TOKEN_FIELD_DEF: {
-               MonoClass *class;
+               MonoClass *klass;
                guint32 type = mono_metadata_typedef_from_field (image, mono_metadata_token_index (token));
                if (!type) {
                        mono_error_set_bad_image (error, image, "Bad ldtoken %x", token);
@@ -8588,12 +8636,12 @@ mono_ldtoken_checked (MonoImage *image, guint32 token, MonoClass **handle_class,
                }
                if (handle_class)
                        *handle_class = mono_defaults.fieldhandle_class;
-               class = mono_class_get_and_inflate_typespec_checked (image, MONO_TOKEN_TYPE_DEF | type, context, error);
-               if (!class)
+               klass = mono_class_get_and_inflate_typespec_checked (image, MONO_TOKEN_TYPE_DEF | type, context, error);
+               if (!klass)
                        return NULL;
 
-               mono_class_init (class);
-               return mono_class_get_field (class, token);
+               mono_class_init (klass);
+               return mono_class_get_field (klass, token);
        }
        case MONO_TOKEN_METHOD_DEF:
        case MONO_TOKEN_METHOD_SPEC: {
@@ -9044,7 +9092,7 @@ mono_class_get_virtual_methods (MonoClass* klass, gpointer *iter)
                for (i = start_index; i < klass->method.count; ++i) {
                        guint32 flags;
 
-                       /* class->method.first points into the methodptr table */
+                       /* klass->method.first points into the methodptr table */
                        flags = mono_metadata_decode_table_row_col (klass->image, MONO_TABLE_METHOD, klass->method.first + i, MONO_METHOD_FLAGS);
 
                        if (flags & METHOD_ATTRIBUTE_VIRTUAL)
@@ -9612,7 +9660,7 @@ find_method_in_metadata (MonoClass *klass, const char *name, int param_count, in
                MonoMethod *method;
                MonoMethodSignature *sig;
 
-               /* class->method.first points into the methodptr table */
+               /* klass->method.first points into the methodptr table */
                mono_metadata_decode_table_row (klass->image, MONO_TABLE_METHOD, klass->method.first + i, cols, MONO_METHOD_SIZE);
 
                if (!strcmp (mono_metadata_string_heap (klass->image, cols [MONO_METHOD_NAME]), name)) {
@@ -9663,7 +9711,8 @@ mono_class_get_method_from_name_flags (MonoClass *klass, const char *name, int p
                if (res) {
                        MonoError error;
                        res = mono_class_inflate_generic_method_full_checked (res, klass, mono_class_get_context (klass), &error);
-                       g_assert (mono_error_ok (&error)); /*FIXME proper error handling*/
+                       if (!mono_error_ok (&error))
+                               mono_error_cleanup (&error); /*FIXME don't swallow the error */
                }
                return res;
        }
@@ -10346,11 +10395,11 @@ mono_generic_class_is_generic_type_definition (MonoGenericClass *gklass)
  * LOCKING: Acquires the loader lock.
  */
 void
-mono_class_setup_interface_id (MonoClass *class)
+mono_class_setup_interface_id (MonoClass *klass)
 {
        mono_loader_lock ();
-       if (MONO_CLASS_IS_INTERFACE (class) && !class->interface_id)
-               class->interface_id = mono_get_unique_iid (class);
+       if (MONO_CLASS_IS_INTERFACE (klass) && !klass->interface_id)
+               klass->interface_id = mono_get_unique_iid (klass);
        mono_loader_unlock ();
 }
 
@@ -10379,7 +10428,7 @@ mono_class_alloc_ext (MonoClass *klass)
 /*
  * mono_class_setup_interfaces:
  *
- *   Initialize class->interfaces/interfaces_count.
+ *   Initialize klass->interfaces/interfaces_count.
  * LOCKING: Acquires the loader lock.
  * This function can fail the type.
  */
@@ -10447,10 +10496,10 @@ mono_class_setup_interfaces (MonoClass *klass, MonoError *error)
 static void
 mono_field_resolve_type (MonoClassField *field, MonoError *error)
 {
-       MonoClass *class = field->parent;
-       MonoImage *image = class->image;
-       MonoClass *gtd = class->generic_class ? mono_class_get_generic_type_definition (class) : NULL;
-       int field_idx = field - class->fields;
+       MonoClass *klass = field->parent;
+       MonoImage *image = klass->image;
+       MonoClass *gtd = klass->generic_class ? mono_class_get_generic_type_definition (klass) : NULL;
+       int field_idx = field - klass->fields;
 
        mono_error_init (error);
 
@@ -10459,38 +10508,38 @@ mono_field_resolve_type (MonoClassField *field, MonoError *error)
                MonoType *gtype = mono_field_get_type_checked (gfield, error);
                if (!mono_error_ok (error)) {
                        char *err_msg = g_strdup_printf ("Could not load field %d type due to: %s", field_idx, mono_error_get_message (error));
-                       mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, err_msg);
+                       mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, err_msg);
                        g_free (err_msg);
                }
 
-               field->type = mono_class_inflate_generic_type_no_copy (image, gtype, mono_class_get_context (class), error);
+               field->type = mono_class_inflate_generic_type_no_copy (image, gtype, mono_class_get_context (klass), error);
                if (!mono_error_ok (error)) {
                        char *err_msg = g_strdup_printf ("Could not load field %d type due to: %s", field_idx, mono_error_get_message (error));
-                       mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, err_msg);
+                       mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, err_msg);
                        g_free (err_msg);
                }
        } else {
                const char *sig;
                guint32 cols [MONO_FIELD_SIZE];
                MonoGenericContainer *container = NULL;
-               int idx = class->field.first + field_idx;
+               int idx = klass->field.first + field_idx;
 
                /*FIXME, in theory we do not lazy load SRE fields*/
                g_assert (!image_is_dynamic (image));
 
-               if (class->generic_container) {
-                       container = class->generic_container;
+               if (klass->generic_container) {
+                       container = klass->generic_container;
                } else if (gtd) {
                        container = gtd->generic_container;
                        g_assert (container);
                }
 
-               /* class->field.first and idx points into the fieldptr table */
+               /* klass->field.first and idx points into the fieldptr table */
                mono_metadata_decode_table_row (image, MONO_TABLE_FIELD, idx, cols, MONO_FIELD_SIZE);
 
                if (!mono_verifier_verify_field_signature (image, cols [MONO_FIELD_SIGNATURE], NULL)) {
-                       mono_error_set_type_load_class (error, class, "Could not verify field %s signature", field->name);
-                       mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, NULL);
+                       mono_error_set_type_load_class (error, klass, "Could not verify field %s signature", field->name);
+                       mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, NULL);
                        return;
                }
 
@@ -10499,26 +10548,26 @@ mono_field_resolve_type (MonoClassField *field, MonoError *error)
                mono_metadata_decode_value (sig, &sig);
                /* FIELD signature == 0x06 */
                g_assert (*sig == 0x06);
-               field->type = mono_metadata_parse_type_full (image, container, MONO_PARSE_FIELD, cols [MONO_FIELD_FLAGS], sig + 1, &sig);
+               field->type = mono_metadata_parse_type_full (image, container, cols [MONO_FIELD_FLAGS], sig + 1, &sig);
                if (!field->type)
-                       mono_class_set_failure_from_loader_error (class, error, g_strdup_printf ("Could not load field %s type", field->name));
+                       mono_class_set_failure_from_loader_error (klass, error, g_strdup_printf ("Could not load field %s type", field->name));
        }
 }
 
 static guint32
 mono_field_resolve_flags (MonoClassField *field)
 {
-       MonoClass *class = field->parent;
-       MonoImage *image = class->image;
-       MonoClass *gtd = class->generic_class ? mono_class_get_generic_type_definition (class) : NULL;
-       int field_idx = field - class->fields;
+       MonoClass *klass = field->parent;
+       MonoImage *image = klass->image;
+       MonoClass *gtd = klass->generic_class ? mono_class_get_generic_type_definition (klass) : NULL;
+       int field_idx = field - klass->fields;
 
 
        if (gtd) {
                MonoClassField *gfield = &gtd->fields [field_idx];
                return mono_field_get_flags (gfield);
        } else {
-               int idx = class->field.first + field_idx;
+               int idx = klass->field.first + field_idx;
 
                /*FIXME, in theory we do not lazy load SRE fields*/
                g_assert (!image_is_dynamic (image));
@@ -10531,14 +10580,14 @@ mono_field_resolve_flags (MonoClassField *field)
  * mono_class_setup_basic_field_info:
  * @class: The class to initialize
  *
- * Initializes the class->fields array of fields.
+ * Initializes the klass->fields array of fields.
  * Aquires the loader lock.
  */
 static void
-mono_class_setup_basic_field_info_locking (MonoClass *class)
+mono_class_setup_basic_field_info_locking (MonoClass *klass)
 {
        mono_loader_lock ();
-       mono_class_setup_basic_field_info (class);
+       mono_class_setup_basic_field_info (klass);
        mono_loader_unlock ();
 }