Index: trunk/MagicSoft/Mars/mimage/MImgCleanStd.cc
===================================================================
--- trunk/MagicSoft/Mars/mimage/MImgCleanStd.cc	(revision 3183)
+++ trunk/MagicSoft/Mars/mimage/MImgCleanStd.cc	(revision 3415)
@@ -340,5 +340,5 @@
     MCerPhotEvtIter Next(fEvt, kFALSE);
     while ((pix=static_cast<MCerPhotPix*>(Next())))
-        if (data[pix->GetPixId()] <= fCleanLvl1)
+        if (!pix->IsPixelUnmapped() && data[pix->GetPixId()] <= fCleanLvl1)
             pix->SetPixelUnused();
 }
@@ -356,6 +356,7 @@
     // Loop over used pixels only
     TIter Next(*fEvt);
+
     while ((pix=static_cast<MCerPhotPix*>(Next())))
-    {
+          {
         // get pixel id of this entry
         const Int_t idx = pix->GetPixId();
@@ -387,7 +388,10 @@
     // now we declare all pixels that survive as CorePixels
     //
+
     Next.Reset();
     while ((pix=static_cast<MCerPhotPix*>(Next())))
-        pix->SetPixelCore();
+      {
+	if ( pix->IsPixelUsed())
+        pix->SetPixelCore();}
 } 
 
@@ -430,5 +434,7 @@
     //
     if (pix.GetRing() != 0)
-        return;
+      {  
+	return;
+      }
 
     //
@@ -471,20 +477,29 @@
 
         // Loop over all pixels
+
         MCerPhotEvtIter NextAll(fEvt, kFALSE);
         while ((pix=static_cast<MCerPhotPix*>(NextAll())))
-        {
+	  {
             //
-            // if pixel is a core pixel go to the next pixel
+	    // if pixel is a core pixel or unmapped, go to the next pixel
             //
-            if (pix->IsPixelCore())
-                continue;
-
-            if (data[pix->GetPixId()] <= fCleanLvl2)
-                continue;
-
-            if (r==1)
-                CleanStep3b(*pix);
-            else
-                CleanStep4(r, *pix);
+	  if (pix->IsPixelCore())
+	    {
+	    continue;}
+	  if (pix->IsPixelUnmapped())
+	    {
+	    continue;}
+	  
+	  if (data[pix->GetPixId()] <= fCleanLvl2)
+	    {
+	      continue;}
+
+	  if (r==1)
+	    {
+	    CleanStep3b(*pix);}
+	  else
+	    {
+	    CleanStep4(r, *pix);}
+	  
         }
     }
@@ -553,4 +568,5 @@
 #endif
     CleanStep1();
+
 #ifdef DEBUG
     *fLog << all << "CleanStep 2" << endl;
