=== modified file 'includes/module.inc'
--- includes/module.inc	
+++ includes/module.inc	
@@ -141,8 +141,11 @@ function module_implements($hook) {
       }
     }
   }
-
-  return $implementations[$hook];
+  // (array) creates a copy. This is needed because $implementations[$hook]
+  // is only a reference to an element of $implementations and if 
+  // there are nested foreaches (even in different functions) for the same
+  // hook, the array pointer will be off.
+  return (array)$implementations[$hook];
 }
 
 /**
