 			delete _meshToDrawCalls[mesh];
 			delete _meshBindingsToMesh[meshBindings];
 			
-			var meshesWithSameEffect : Vector.<Mesh> = _effectToMeshes[meshEffect];
-			
+			var meshesWithSameEffect : Vector.<Mesh> = _effectToMeshes[effect];
+
 			meshesWithSameEffect.splice(meshesWithSameEffect.indexOf(mesh), 1);
 			
 			if (meshesWithSameEffect.length == 0)
 			{
-				delete _effectToMeshes[meshEffect];
-				meshEffect.passesChanged.remove(effectPassesChangedHandler);
+				delete _effectToMeshes[effect];
+                effect.passesChanged.remove(effectPassesChangedHandler);
 			}
 		}
 		

		
		private function removeDrawCalls(mesh : Mesh, effect : Effect) : void
		{
			var meshEffect		: Effect		= mesh.material.effect;
			var meshBindings	: DataBindings	= mesh.bindings;
			
			// retrieve drawcalls

			
			if (!_effectToMeshes[newEffect])
			{
				_effectToMeshes[newEffect] = new <Mesh>[];
				newEffect.passesChanged.add(effectPassesChangedHandler);
			}
			
