Index: /trunk/processor/head.m4
===================================================================
--- /trunk/processor/head.m4	(revision 506)
+++ /trunk/processor/head.m4	(revision 507)
@@ -216,8 +216,9 @@
 #ifdef ZEND_ENGINE_2
 /* fix method on store */
-static void xc_fix_method(xc_processor_t *processor, zend_op_array *dst) /* {{{ */
+static void xc_fix_method(xc_processor_t *processor, zend_op_array *dst TSRMLS_DC) /* {{{ */
 {
 	zend_function *zf = (zend_function *) dst;
 	zend_class_entry *ce = processor->active_class_entry_dst;
+	const zend_class_entry *srcce = processor->active_class_entry_src;
 
 	/* Fixing up the default functions for objects here since
@@ -240,14 +241,5 @@
 	}
 	else {
-dnl FIXME: handle common.function_name here
-#define SET_IF_SAME_NAME(member) \
-		do { \
-			if (!strcasecmp(ZSTR_S(zf->common.function_name), #member)) { \
-				ce->member = zf; \
-			} \
-		} \
-		while(0)
-		/* if(ce->member && !strcmp(zf->common.function_name, ce->member->common.function_name)) { \ */
-
+	pushdef(`SET_IF_SAME_NAMEs', `
 		SET_IF_SAME_NAME(__get);
 		SET_IF_SAME_NAME(__set);
@@ -263,6 +255,35 @@
 		SET_IF_SAME_NAME(__tostring);
 #endif
-
+	')
+#ifdef IS_UNICODE
+		if (UG(unicode)) {
+#define SET_IF_SAME_NAME(member) \
+			do { \
+				if (srcce->member && u_strcmp(ZSTR_S(zf->common.function_name), ZSTR_S(srcce->member->common.function_name)) == 0) { \
+					ce->member = zf; \
+				} \
+			} \
+			while(0)
+
+			SET_IF_SAME_NAMEs()
 #undef SET_IF_SAME_NAME
+		}
+		else
+#endif
+		do {
+#define SET_IF_SAME_NAME(member) \
+			do { \
+				if (srcce->member && strcmp(ZSTR_S(zf->common.function_name), ZSTR_S(srcce->member->common.function_name)) == 0) { \
+					ce->member = zf; \
+				} \
+			} \
+			while(0)
+
+			SET_IF_SAME_NAMEs()
+#undef SET_IF_SAME_NAME
+		} while (0);
+
+	popdef(`SET_IF_SAME_NAMEs')
+
 	}
 }
Index: /trunk/processor/processor.m4
===================================================================
--- /trunk/processor/processor.m4	(revision 506)
+++ /trunk/processor/processor.m4	(revision 507)
@@ -668,17 +668,12 @@
 #endif
 
-	IFRESTORE(`
-#ifdef ZEND_ENGINE_2
+#ifdef ZEND_ENGINE_2
+	PROC_CLASS_ENTRY_P(scope)
+	IFCOPY(`
 		if (src->scope) {
-			dst->scope = xc_get_class(processor, (zend_ulong) src->scope);
-			xc_fix_method(processor, dst);
-		}
-		DONE(scope)
-#endif
-	', `
-#ifdef ZEND_ENGINE_2
-		PROC_CLASS_ENTRY_P(scope)
-#endif
-	')
+			xc_fix_method(processor, dst TSRMLS_CC);
+		}
+	')
+#endif
 
 	IFRESTORE(`
