diff --git a/Code/Mantid/Framework/API/src/WorkspaceFactory.cpp b/Code/Mantid/Framework/API/src/WorkspaceFactory.cpp
index b641a0c8822a53f4c0907eac8cc8cf2467f7a400..6a9029382591d27297c8b981a76d446c08ead5ad 100644
--- a/Code/Mantid/Framework/API/src/WorkspaceFactory.cpp
+++ b/Code/Mantid/Framework/API/src/WorkspaceFactory.cpp
@@ -87,19 +87,6 @@ MatrixWorkspace_sptr WorkspaceFactoryImpl::create(const MatrixWorkspace_const_sp
 void WorkspaceFactoryImpl::initializeFromParent(const MatrixWorkspace_const_sptr parent,
   const MatrixWorkspace_sptr child, const bool differentSize) const
 {
-  // Check input workspaces
-  if (!parent)
-  {
-    g_log.error() << "WorkspaceFactoryImpl::initializeFromParent:  Input Parent pointer is NULL" << std::endl;
-    throw std::invalid_argument("Input MatrixWorkspace pointer is NULL. ");
-  }
-  if (!child)
-  {
-    g_log.error() << "WorkspaceFactoryImpl::initializeFromParent:  Input Child pointer is NULL" << std::endl;
-    throw std::invalid_argument("Input MatrixWorkspace pointer is NULL. ");
-  }
-
-  // Copy title and comment
   child->setTitle(parent->getTitle());
   child->setComment(parent->getComment());
   child->setInstrument(parent->getInstrument());  // This call also copies the SHARED POINTER to the parameter map
diff --git a/Code/Mantid/Framework/Algorithms/src/ExtractMask.cpp b/Code/Mantid/Framework/Algorithms/src/ExtractMask.cpp
index ad65f06be0a29ef57cafa34a85dd92d50ee650b8..f3f5bc4b4eb7ea8eeb319479c753f4600b2a2616 100644
--- a/Code/Mantid/Framework/Algorithms/src/ExtractMask.cpp
+++ b/Code/Mantid/Framework/Algorithms/src/ExtractMask.cpp
@@ -17,7 +17,6 @@ The spectra containing 0 are also marked as masked and the instrument link is pr
 #include "MantidKernel/MultiThreaded.h"
 #include "MantidKernel/ArrayProperty.h"
 #include "MantidKernel/NullValidator.h"
-#include "MantidAPI/ISpectrum.h"
 
 namespace Mantid
 {
@@ -52,11 +51,9 @@ namespace Mantid
           new WorkspaceProperty<MatrixWorkspace>("InputWorkspace","", Direction::Input),
           "A workspace whose masking is to be extracted"
       );
-
       declareProperty(
           new WorkspaceProperty<MatrixWorkspace>("OutputWorkspace","", Direction::Output),
-          "A workspace containing the masked spectra as zeroes and ones."
-          "If there is one detector per spectrum for all spectra, then the output is a MaskWorkspace.");
+          "A workspace containing the masked spectra as zeroes and ones.");
 
       declareProperty(
           new ArrayProperty<detid_t>("DetectorList", boost::make_shared<NullValidator>(), Direction::Output),
@@ -68,28 +65,17 @@ namespace Mantid
      */
     void ExtractMask::exec()
     {
-      // 1. Input
       MatrixWorkspace_const_sptr inputWS = getProperty("InputWorkspace");
 
-      // b) Check whether there are any grouped workspaces
       const int nHist = static_cast<int>(inputWS->getNumberHistograms());
-      bool groupeddet = false;
-      for (size_t ih = 0; ih < size_t(nHist); ++ih)
-      {
-        const API::ISpectrum *spec = inputWS->getSpectrum(ih);
-        if (!spec)
-        {
-          throw std::invalid_argument("Unable to access some spectrum.");
-        }
-        std::set<int> detids = spec->getDetectorIDs();
-        if (detids.size() > 1)
-        {
-          groupeddet = true;
-          break;
-        }
-      }
 
-      // c) Input workspace is MaskWorkspace?
+      // Create a new workspace for the results, copy from the input to ensure that we copy over the instrument and current masking
+      DataObjects::MaskWorkspace* maskWS = new DataObjects::MaskWorkspace(inputWS->getInstrument(), true);
+      maskWS->initialize(nHist, 1, 1);
+      MatrixWorkspace_sptr outputWS(maskWS);
+      WorkspaceFactory::Instance().initializeFromParent(inputWS, outputWS, false);
+      outputWS->setTitle(inputWS->getTitle());
+
       bool inputWSIsSpecial(false);
       {
         DataObjects::MaskWorkspace_const_sptr temp = boost::dynamic_pointer_cast<const DataObjects::MaskWorkspace>(inputWS);
@@ -98,62 +84,32 @@ namespace Mantid
         g_log.notice() << "Input workspace is a MaskWorkspace.\n";
       }
 
-      // 2. Create a new workspace for the results, copy from the input to ensure that we copy over the instrument and current masking
-      MatrixWorkspace_sptr outputWS;
-
-      if (!groupeddet)
-      {
-        DataObjects::MaskWorkspace* maskWS = new DataObjects::MaskWorkspace(inputWS->getInstrument(), true);
-        maskWS->initialize(nHist, 1, 1);
-        MatrixWorkspace_sptr tempws(maskWS);
-        outputWS = tempws;
-      }
-      else
-      {
-        DataObjects::Workspace2D* twodWS = new DataObjects::Workspace2D();
-        twodWS->initialize(nHist, 1, 1);
-        MatrixWorkspace_sptr tempws(twodWS);
-        outputWS = tempws;
-      }
-
-      WorkspaceFactory::Instance().initializeFromParent(inputWS, outputWS, false);
-      outputWS->setTitle(inputWS->getTitle());
-
-      // 3. Set values
       Progress prog(this,0.0,1.0,nHist);
       MantidVecPtr xValues;
       xValues.access() = MantidVec(1, 0.0);
 
       // List masked of detector IDs
       std::vector<detid_t> detectorList;
-      std::vector<size_t> workspaceindexList;
 
       PARALLEL_FOR2(inputWS, outputWS)
       for( int i = 0; i < nHist; ++i )
       {
         PARALLEL_START_INTERUPT_REGION
-
         // Spectrum in the output workspace
         ISpectrum * outSpec = outputWS->getSpectrum(i);
         // Spectrum in the input workspace
         const ISpectrum * inSpec = inputWS->getSpectrum(i);
-        // Detector IDs
-        std::set<int> detids = inSpec->getDetectorIDs();
 
         // Copy X, spectrum number and detector IDs
         outSpec->copyInfoFrom(*inSpec);
 
         bool inputIsMasked(false);
-        IDetector_const_sptr inputDet;
 
-        // Set value and detector
+        IDetector_const_sptr inputDet;
         try
         {
-          // a) Get effective detector & check masked or not
           inputDet = inputWS->getDetector(i);
-
-          if (inputWSIsSpecial)
-          {
+          if (inputWSIsSpecial) {
             inputIsMasked = (inSpec->dataY()[0] > 0.5);
           }
           // special workspaces can mysteriously have the mask bit set
@@ -163,18 +119,12 @@ namespace Mantid
             inputIsMasked = true;
           }
 
-          // b) Mask output
           if (inputIsMasked)
           {
-            // detid_t id = inputDet->getID();
+            detid_t id = inputDet->getID();
             PARALLEL_CRITICAL(name)
             {
-              for (std::set<int>::iterator detiter = detids.begin(); detiter != detids.end(); ++ detiter)
-              {
-                detid_t detid = detid_t(*detiter);
-                detectorList.push_back(detid);
-              }
-              workspaceindexList.push_back(i);
+              detectorList.push_back(id);
             }
           }
         }
@@ -201,22 +151,10 @@ namespace Mantid
 
 
       // Clear all the "masked" bits on the output masked workspace
-      /*
       Geometry::ParameterMap & pmap = outputWS->instrumentParameters();
       pmap.clearParametersByName("masked");
-      */
-
-      // 4. Mask all detectors listed
-      /*
-      Geometry::Instrument_const_sptr outinstr = outputWS->getInstrument();
-      for (size_t id = 0; id < detectorList.size(); ++id)
-      {
-        Geometry::IDetector_sptr det = outinstr->getDetector(detectorList[id]);
-      }
-      */
 
-      g_log.information() << detectorList.size() << " detectors are masked. " <<
-          workspaceindexList.size() << " spectra are masked. " << std::endl;
+      g_log.information() << detectorList.size() << " spectra are masked\n";
       setProperty("OutputWorkspace", outputWS);
       setProperty("DetectorList", detectorList);
     }
diff --git a/Code/Mantid/Framework/Algorithms/test/ExtractMaskTest.h b/Code/Mantid/Framework/Algorithms/test/ExtractMaskTest.h
index fcecdad1cf91a9963caa0377e444bff862343b9f..3d6ff580398615542ca3e9b913e79d79ee2b8720 100644
--- a/Code/Mantid/Framework/Algorithms/test/ExtractMaskTest.h
+++ b/Code/Mantid/Framework/Algorithms/test/ExtractMaskTest.h
@@ -7,25 +7,12 @@
 #include <cxxtest/TestSuite.h>
 #include "MantidAlgorithms/ExtractMask.h"
 #include "MantidTestHelpers/WorkspaceCreationHelper.h"
-#include "MantidTestHelpers/ComponentCreationHelper.h"
-#include "MantidAPI/ISpectrum.h"
-#include "MantidGeometry/IDetector.h"
-#include "MantidGeometry/Instrument.h"
-#include "MantidAPI/MatrixWorkspace.h"
-#include "MantidDataObjects/EventWorkspace.h"
-#include "MantidDataObjects/Workspace2D.h"
-#include "MantidDataObjects/MaskWorkspace.h"
-#include "MantidGeometry/IDetector.h"
 
-using namespace Mantid;
 using namespace Mantid::API;
 using namespace Mantid::DataObjects;
 using namespace Mantid::Geometry;
 using Mantid::Algorithms::ExtractMask;
 using Mantid::Kernel::Property;
-using Mantid::MantidVecPtr;
-using Mantid::detid_t;
-using Mantid::specid_t;
 
 class ExtractMaskTest : public CxxTest::TestSuite
 {
@@ -152,154 +139,6 @@ private:
     
   }
 
-  //------------------------------------------------------------------------------
-  // Test for workspace with grouped detectors
-  /*
-    * Generate a Workspace which can be (1) EventWorkspace, (2) Workspace2D, and (3) SpecialWorkspace2D
-    * with grouped detectors
-    */
-   void setUpWSwGroupedDetectors(std::set<size_t> maskwsindexList, const std::string & name = "testSpace")
-   {
-     // 1. Instrument
-     // a) By this will create an instrument with 9 detectors
-     Instrument_sptr instr = boost::dynamic_pointer_cast<Instrument>(ComponentCreationHelper::createTestInstrumentCylindrical(1, false));
-     // b) Detectors ID
-     for (detid_t i = 10; i <= 36; ++i)
-     {
-       Detector *d = new Detector("det", i, 0);
-       instr->markAsDetector(d);
-     }
-
-     // 2. Workspace
-     MatrixWorkspace_sptr space;
-     space = WorkspaceFactory::Instance().create("EventWorkspace",9, 6, 5);
-     EventWorkspace_sptr spaceEvent = boost::dynamic_pointer_cast<EventWorkspace>(space);
-
-     // b) Set by each spectrum
-     MantidVecPtr x,vec;
-     vec.access().resize(5,1.0);
-     detid_t currdetid = 1;
-     for (int j = 0; j < 9; ++j)
-     {
-       //Just one event per pixel
-       for (int k = 0; k < 4; ++ k)
-       {
-         TofEvent event(1.23*(1.+double(k)*0.01), int64_t(4.56));
-         spaceEvent->getEventList(j).addEventQuickly(event);
-       }
-       // spaceEvent->getEventList(j).setDetectorID(j);
-       spaceEvent->getAxis(1)->spectraNo(j) = j;
-       Mantid::API::ISpectrum* spec = spaceEvent->getSpectrum(j);
-       std::vector<int> detids;
-       for (size_t k = 0; k < 4; ++k)
-       {
-         detids.push_back(currdetid);
-         currdetid ++;
-       }
-       spec->addDetectorIDs(detids);
-     }
-     spaceEvent->doneAddingEventLists();
-     x.access().push_back(0.0);
-     x.access().push_back(10.0);
-     spaceEvent->setAllX(x);
-
-     space->setInstrument(instr);
-     space->generateSpectraMap();
-
-     // 3. Mask some spectra
-     for (std::set<size_t>::iterator wsiter = maskwsindexList.begin(); wsiter != maskwsindexList.end(); ++ wsiter)
-     {
-       size_t wsindex = *wsiter;
-       space->maskWorkspaceIndex(wsindex);
-     }
-
-     // 4. Register the workspace in the data service
-     AnalysisDataService::Instance().addOrReplace(name, space);
-
-   }
-
-public:
-   /* Test extract mask from workspace w/ grouped detectors
-    *
-    */
-   void test_OnGroupedDetectors()
-   {
-     // 1. Generate input workspace
-     std::set<size_t> maskwsindexList;
-     maskwsindexList.insert(1);
-     maskwsindexList.insert(3);
-     maskwsindexList.insert(6);
-     std::string wsname("TestGroupedDetectorsWS");
-     setUpWSwGroupedDetectors(maskwsindexList, wsname);
-     DataObjects::EventWorkspace_sptr eventWS =
-       AnalysisDataService::Instance().retrieveWS<DataObjects::EventWorkspace>(wsname);
-     TS_ASSERT(eventWS);
-
-     // 2. Extract mask
-     ExtractMask maskExtractor;
-     maskExtractor.initialize();
-     maskExtractor.setPropertyValue("InputWorkspace", wsname);
-     const std::string outputName("masking");
-     maskExtractor.setPropertyValue("OutputWorkspace", outputName);
-     maskExtractor.setRethrows(true);
-     TS_ASSERT_THROWS_NOTHING(maskExtractor.execute());
-     TS_ASSERT(maskExtractor.isExecuted());
-
-     Workspace_sptr workspace = AnalysisDataService::Instance().retrieve(outputName);
-     TS_ASSERT(workspace);
-     if (!workspace)
-     {
-       return;
-     }
-
-     // 3. Check type of output workspace
-     DataObjects::MaskWorkspace_sptr maskws = boost::dynamic_pointer_cast<DataObjects::MaskWorkspace>(workspace);
-     TS_ASSERT(!maskws);
-     DataObjects::Workspace2D_sptr ws2d = boost::dynamic_pointer_cast<DataObjects::Workspace2D>(workspace);
-     TS_ASSERT(ws2d);
-
-     // 4. Check values of output workspace
-     TS_ASSERT_EQUALS(ws2d->getNumberHistograms(), 9);
-
-     for (size_t iws = 0; iws < ws2d->getNumberHistograms(); ++iws)
-     {
-       double value = ws2d->readY(iws)[0];
-       if (iws == 1 || iws == 3 || iws == 6)
-       {
-         TS_ASSERT(value > 0.5);
-       }
-       else
-       {
-         TS_ASSERT(value < 0.5);
-       }
-     }
-
-     // 5. Check detectors
-     Geometry::Instrument_const_sptr instrument = ws2d->getInstrument();
-     TS_ASSERT(instrument);
-
-     for (size_t iws = 0; iws < ws2d->getNumberHistograms(); ++iws)
-     {
-       API::ISpectrum *spec = ws2d->getSpectrum(iws);
-       std::set<int> detids = spec->getDetectorIDs();
-       for (std::set<int>::iterator it = detids.begin(); it != detids.end(); ++it)
-       {
-         detid_t detid = detid_t(*it);
-         Geometry::IDetector_const_sptr tmpdet = instrument->getDetector(detid);
-         if (iws ==  1 || iws == 3 || iws == 6)
-         {
-           TS_ASSERT_EQUALS(tmpdet->isMasked(), true);
-         }
-         else
-         {
-           TS_ASSERT_EQUALS(tmpdet->isMasked(), false);
-         }
-       }
-     }
-
-     return;
-   }
-
 };
 
 
diff --git a/Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/MaskDetectors.h b/Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/MaskDetectors.h
index ae3b7218a470bcf0a938b6d8e3f65138189229d2..ef9cf138f1c918c41f4d312294eb98f4d5a71eed 100644
--- a/Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/MaskDetectors.h
+++ b/Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/MaskDetectors.h
@@ -70,18 +70,6 @@ private:
                                 const API::MatrixWorkspace_sptr WS);
   void appendToIndexListFromWS(std::vector<size_t>& indexList, const API::MatrixWorkspace_sptr maskedWorkspace);
   void appendToIndexListFromMaskWS(std::vector<size_t>& indexList, const DataObjects::MaskWorkspace_const_sptr maskedWorkspace);
-
-  DataObjects::MaskWorkspace_sptr createMaskWorkspace(Geometry::Instrument_const_sptr instrument);
-
-  void applyIndexListToMaskWorkspace(API::MatrixWorkspace_sptr inpWS, std::vector<size_t> indexList);
-
-  void applyDetectorListToMaskWorkspace(std::vector<detid_t> detectorList);
-
-  void applyWorkspaceToMaskWorkspace(API::MatrixWorkspace_sptr maskedWorkspace);
-
-  void maskWorkspace(API::MatrixWorkspace_sptr inpWS);
-
-  DataObjects::MaskWorkspace_sptr mMaskWS;
 };
 
 } // namespace DataHandling
diff --git a/Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/SaveMask.h b/Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/SaveMask.h
index 3c87d937d3cca88f9a2d36236da3e0f2ba09f0ae..10e0be48a3f4116371666b9df5ed7c0663daa6ba 100644
--- a/Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/SaveMask.h
+++ b/Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/SaveMask.h
@@ -3,9 +3,6 @@
 
 #include "MantidKernel/System.h"
 #include "MantidAPI/Algorithm.h"
-#include "MantidDataObjects/SpecialWorkspace2D.h"
-#include "MantidDataObjects/MaskWorkspace.h"
-#include "MantidAPI/MatrixWorkspace.h"
 
 namespace Mantid
 {
@@ -59,10 +56,6 @@ namespace DataHandling
     /// Main body to execute algorithm
     void exec();
 
-    void getMaskedDetectorsFromMaskWorkspace(DataObjects::MaskWorkspace_const_sptr inpWS, std::vector<detid_t>& detidlist);
-
-    void getMaskedDetectorsFromInstrument(API::MatrixWorkspace_const_sptr inpWS, std::vector<detid_t>& detidlist);
-
   };
 
 
diff --git a/Code/Mantid/Framework/DataHandling/src/LoadMask.cpp b/Code/Mantid/Framework/DataHandling/src/LoadMask.cpp
index 12a3fcea0d85cb85b278a954253611ca44a54f4c..f6aa3d6ef9ea2ce228f158b33c90776cde5db32b 100644
--- a/Code/Mantid/Framework/DataHandling/src/LoadMask.cpp
+++ b/Code/Mantid/Framework/DataHandling/src/LoadMask.cpp
@@ -26,7 +26,6 @@ Supporting
 #include "MantidGeometry/Instrument.h"
 #include "MantidGeometry/ICompAssembly.h"
 #include "MantidGeometry/IDTypes.h"
-#include "MantidKernel/ArrayProperty.h"
 
 #include <fstream>
 
@@ -102,10 +101,6 @@ namespace DataHandling
     declareProperty(new WorkspaceProperty<DataObjects::MaskWorkspace>("OutputWorkspace", "Masking", Direction::Output),
         "Output Masking Workspace");
 
-    declareProperty(
-        new ArrayProperty<detid_t>("ToMaskDetectorIDsList", boost::make_shared<NullValidator>(), Direction::Output),
-        "A comma separated list or array containing a list of detector ID's to mask." );
-
     return;
   }
 
@@ -145,7 +140,7 @@ namespace DataHandling
     }
 
     // 3. Translate and set geometry
-    g_log.debug() << "To Mask: " << std::endl;
+    g_log.information() << "To Mask: " << std::endl;
     std::vector<int32_t> maskdetids;
     std::vector<int32_t> maskdetidpairsL;
     std::vector<int32_t> maskdetidpairsU;
@@ -155,7 +150,7 @@ namespace DataHandling
     // this->spectrumToDetectors(mask_specid_pair_low, mask_specid_pair_up, maskdetids);
     this->detectorToDetectors(mask_detid_single, mask_detid_pair_low, mask_detid_pair_up, maskdetids, maskdetidpairsL, maskdetidpairsU);
 
-    g_log.debug() << "To UnMask: " << std::endl;
+    g_log.information() << "To UnMask: " << std::endl;
     std::vector<int32_t> unmaskdetids;
     std::vector<int32_t> unmaskdetidpairsL;
     std::vector<int32_t> unmaskdetidpairsU;
@@ -165,14 +160,12 @@ namespace DataHandling
     this->detectorToDetectors(unmask_detid_single, unmask_detid_pair_low, unmask_detid_pair_up, unmaskdetids, unmaskdetidpairsL, unmaskdetidpairsU);
 
     // 4. Apply
+
     this->initDetectors();
     this->processMaskOnDetectors(true, maskdetids, maskdetidpairsL, maskdetidpairsU);
     this->processMaskOnWorkspaceIndex(true, mask_specid_pair_low, mask_specid_pair_up);
-    this->processMaskOnDetectors(false, unmaskdetids, unmaskdetidpairsL, unmaskdetidpairsU);
-
-    // 5. Output
 
-    this->setProperty("ToMaskDetectorIDsList", maskdetids);
+    this->processMaskOnDetectors(false, unmaskdetids, unmaskdetidpairsL, unmaskdetidpairsU);
 
     return;
   }
@@ -242,8 +235,8 @@ namespace DataHandling
    *  -
    */
   void LoadMask::componentToDetectors(std::vector<std::string> componentnames,
-      std::vector<int32_t>& detectors)
-  {
+      std::vector<int32_t>& detectors){
+
     Geometry::Instrument_const_sptr minstrument = mMaskWS->getInstrument();
 
     for (size_t i = 0; i < componentnames.size(); i ++){
@@ -407,21 +400,30 @@ namespace DataHandling
    */
   void LoadMask::detectorToDetectors(std::vector<int32_t> singles, std::vector<int32_t> pairslow, std::vector<int32_t> pairsup,
       std::vector<int32_t>& detectors,
-      std::vector<int32_t>& detectorpairslow, std::vector<int32_t>& detectorpairsup)
-  {
+      std::vector<int32_t>& detectorpairslow, std::vector<int32_t>& detectorpairsup){
     UNUSED_ARG(detectorpairslow)
     UNUSED_ARG(detectorpairsup)
 
+    /*
+    for (size_t i = 0; i < singles.size(); i ++){
+      g_log.information() << "Detector " << singles[i] << std::endl;
+    }
+    for (size_t i = 0; i < pairslow.size(); i ++){
+      g_log.information() << "Detector " << pairslow[i] << "  To " << pairsup[i] << std::endl;
+    }
+    */
     for (size_t i = 0; i < singles.size(); i ++){
       detectors.push_back(singles[i]);
     }
-    for (size_t i = 0; i < pairslow.size(); i ++)
-    {
-      for (int32_t j = 0; j < pairsup[i]-pairslow[i]+1; j ++)
-      {
+    for (size_t i = 0; i < pairslow.size(); i ++){
+      for (int32_t j = 0; j < pairsup[i]-pairslow[i]+1; j ++){
         int32_t detid = pairslow[i]+j;
         detectors.push_back(detid);
       }
+      /*
+      detectorpairslow.push_back(pairslow[i]);
+      detectorpairsup.push_back(pairsup[i]);
+      */
     }
 
     return;
@@ -632,26 +634,19 @@ namespace DataHandling
     this->parseRangeText(inputstr, singles, pairs);
 
     // 2. Set to data storage
-    if (tomask)
-    {
-      for (size_t i = 0; i < singles.size(); i ++)
-      {
+    if (tomask){
+      for (size_t i = 0; i < singles.size(); i ++){
         mask_detid_single.push_back(singles[i]);
       }
-      for (size_t i = 0; i < pairs.size()/2; i ++)
-      {
+      for (size_t i = 0; i < pairs.size()/2; i ++){
         mask_detid_pair_low.push_back(pairs[2*i]);
         mask_detid_pair_up.push_back(pairs[2*i+1]);
       }
-    }
-    else
-    {
-      for (size_t i = 0; i < singles.size(); i ++)
-      {
+    } else {
+      for (size_t i = 0; i < singles.size(); i ++){
         unmask_detid_single.push_back(singles[i]);
       }
-      for (size_t i = 0; i < pairs.size()/2; i ++)
-      {
+      for (size_t i = 0; i < pairs.size()/2; i ++){
         unmask_detid_pair_low.push_back(pairs[2*i]);
         unmask_detid_pair_up.push_back(pairs[2*i+1]);
       }
@@ -718,8 +713,7 @@ namespace DataHandling
     return;
   }
 
-  void LoadMask::splitString(std::string inputstr, std::vector<std::string>& strings, std::string sep)
-  {
+  void LoadMask::splitString(std::string inputstr, std::vector<std::string>& strings, std::string sep){
 
     // std::vector<std::string> SplitVec;
     boost::split(strings, inputstr, boost::is_any_of(sep), boost::token_compress_on);
diff --git a/Code/Mantid/Framework/DataHandling/src/MaskDetectors.cpp b/Code/Mantid/Framework/DataHandling/src/MaskDetectors.cpp
index 675a91cf6eaf1e47cc2245cdf616c15f2e25cca3..ee2ef350de0db522afebcc5232c045e78380e9bd 100644
--- a/Code/Mantid/Framework/DataHandling/src/MaskDetectors.cpp
+++ b/Code/Mantid/Framework/DataHandling/src/MaskDetectors.cpp
@@ -86,141 +86,135 @@ void MaskDetectors::init()
  */
 void MaskDetectors::exec()
 {
-  // 1. Get the input workspace
+  // Get the input workspace
   const MatrixWorkspace_sptr WS = getProperty("Workspace");
-  //    Is it an event workspace?
+
+  // Is it an event workspace?
   EventWorkspace_sptr eventWS = boost::dynamic_pointer_cast<EventWorkspace>(WS);
-  //    Is it a Mask Workspace ?
+
+  // Is it a Mask Workspace ?
   MaskWorkspace_sptr isMaskWS = boost::dynamic_pointer_cast<MaskWorkspace>(WS);
 
-  // 2. Get information for masking
   std::vector<size_t> indexList = getProperty("WorkspaceIndexList");
   std::vector<specid_t> spectraList = getProperty("SpectraList");
   const std::vector<detid_t> detectorList = getProperty("DetectorList");
-  const MatrixWorkspace_sptr inputMaskWS = getProperty("MaskedWorkspace");
-
-  g_log.debug() << "MaskDetectors(): Input WorkspaceIndexList Size = " << indexList.size() <<
-      "  SpectraList Size = " << spectraList.size() <<
-      "  DetectorList Size = " << detectorList.size() << std::endl;
+  const MatrixWorkspace_sptr prevMasking = getProperty("MaskedWorkspace");
 
-  // 3. Each one of these values is optional but the user can't leave all four blank
-  if ( indexList.empty() && spectraList.empty() && detectorList.empty() && !inputMaskWS )
+  // each one of these values is optional but the user can't leave all four blank
+  if ( indexList.empty() && spectraList.empty() && detectorList.empty() && !prevMasking )
   {
-    g_log.error(name() + ": There is nothing to mask, the index, spectra, "
+    g_log.information(name() + ": There is nothing to mask, the index, spectra, "
 		      "detector lists and masked workspace properties are all empty");
     return;
   }
 
-  if (!spectraList.empty() && !indexList.empty())
+  // If the spectraList property has been set, need to loop over the workspace looking for the
+  // appropriate spectra number and adding the indices they are linked to the list to be processed
+  if ( ! spectraList.empty() )
+  {
+    fillIndexListFromSpectra(indexList,spectraList,WS);
+  }// End dealing with spectraList
+  else if ( ! detectorList.empty() )
   {
-    g_log.error() << "It is not allowed to input both spectra list and workspace indices list. " << std::endl;
-    throw std::invalid_argument("Not allowed to input both spectra list and workspace indices list.");
+    // Convert from detectors to workspace indexes
+    // This call can be way too slow! Go back to the old way pending improving that
+    //    WS->getIndicesFromDetectorIDs(detectorList, indexList);
+    std::vector<specid_t> mySpectraList = WS->spectraMap().getSpectra(detectorList);
+    fillIndexListFromSpectra(indexList,mySpectraList,WS);
   }
+  // If we have a workspace that could contain masking,copy that in too
 
-  // 4. Create MaskWorkspace if necessary
-  bool createmaskws = true;
-  if (inputMaskWS)
+  if( prevMasking )
   {
-    mMaskWS = boost::dynamic_pointer_cast<DataObjects::MaskWorkspace>(inputMaskWS);
-    if (mMaskWS)
+    DataObjects::MaskWorkspace_const_sptr maskWS = boost::dynamic_pointer_cast<DataObjects::MaskWorkspace>(prevMasking);
+    if (maskWS)
     {
-      if (mMaskWS->getNumberHistograms() != WS->getInstrument()->getDetectorIDs(true).size())
+      if (maskWS->getInstrument()->getDetectorIDs().size() != WS->getInstrument()->getDetectorIDs().size())
       {
-        g_log.error() << "Input MaskWorkspace has different number of workspace indices "
-            << mMaskWS->getNumberHistograms() << " than number of detectors of workspace to mask "
-            << WS->getInstrument()->getDetectorIDs().size() << std::endl;
-        throw std::invalid_argument("Unmatched instrument of mask workspace and workspace to mask.");
+        throw std::runtime_error("Size mismatch between input Workspace and MaskWorkspace");
       }
-      createmaskws = false;
-    }
-  }
-  if (createmaskws)
-  {
-    mMaskWS = createMaskWorkspace(WS->getInstrument());
-  }
-  g_log.debug() << "MaskDetectors():  Internal mask workspace size = " << mMaskWS->getNumberHistograms() << std::endl;
 
-  // 5. Apply spectra/workspace indices
-  if ( ! spectraList.empty() )
-  {
-    // a) If the spectraList property has been set, need to loop over the workspace looking for the
-    //    appropriate spectra number and adding the indices they are linked to the list to be processed
-    fillIndexListFromSpectra(indexList,spectraList,WS);
+      g_log.debug() << "Extracting mask from MaskWorkspace (" << maskWS->name() << ")" << std::endl;
+      appendToIndexListFromMaskWS(indexList, maskWS);
+    }
+    else
+    {
+      // Check the provided workspace has the same number of spectra as the input
+      if(prevMasking->getNumberHistograms() > WS->getNumberHistograms() )
+      {
+        g_log.error() << "Input workspace has " << WS->getNumberHistograms() << " histograms   vs. " <<
+            "Input masking workspace has " << prevMasking->getNumberHistograms() << " histograms. " << std::endl;
+        throw std::runtime_error("Size mismatch between two input workspaces.");
+      }
+      appendToIndexListFromWS(indexList,prevMasking);
+    }
   }
-  // b) Sort the index list and remove duplicated
-  std::vector<size_t> cleanedindices;
-  if (indexList.size() > 0)
+  
+  // Need to get hold of the parameter map
+  Geometry::ParameterMap& pmap = WS->instrumentParameters();
+  
+  // If explicitly given a list of detectors to mask, just mark those.
+  // Otherwise, mask all detectors pointing to the requested spectra in indexlist loop below
+  std::vector<detid_t>::const_iterator it;
+  Instrument_const_sptr instrument = WS->getInstrument();
+  if ( !detectorList.empty() )
   {
-    g_log.debug() << "MaskDetectros()  List of index Size = " << indexList.size() << " to sort. "<< std::endl;
-    std::sort(indexList.begin(), indexList.end());
-    std::vector<size_t>::iterator vit;
-    size_t numdeleted = 0;
-    g_log.debug() << "MaskDetectros()  List of index Size start to have duplicated removed. " << std::endl;
-
-    cleanedindices.push_back(indexList[0]);
-
-    for (size_t i = 1; i < indexList.size(); ++i)
+    for (it = detectorList.begin(); it != detectorList.end(); ++it)
     {
-      if (indexList[i] != indexList[i-1])
+      try
       {
-        cleanedindices.push_back(indexList[i]);
+        if ( const Geometry::ComponentID det = instrument->getDetector(*it)->getComponentID() )
+        {
+          pmap.addBool(det,"masked",true);
+        }
       }
-      else
+      catch(Kernel::Exception::NotFoundError &e)
       {
-        numdeleted ++;
+        g_log.warning() << e.what() << " Found while running MaskDetectors" << std::endl;
       }
     }
-    if (numdeleted > 0)
-    {
-      g_log.debug() << "MaskDetectors():  " << numdeleted << " input workspace indices are duplicated and thus deleted. " << std::endl;
-    }
-    else
-    {
-      g_log.debug() << "MaskDetectors(): No workspace index removed from list due to duplicate." << std::endl;
-    }
   }
-
-  // c) Put to the workspaces
-  if (cleanedindices.size() > 0)
-    applyIndexListToMaskWorkspace(WS, cleanedindices);
-
-  // 6. Detectors List
-  if ( !detectorList.empty() )
+  
+  if ( indexList.empty() )
   {
-    applyDetectorListToMaskWorkspace(detectorList);
+      g_log.warning("No spectra affected.");
+      return;
   }
+  
+  // Get a reference to the spectra-detector map to get hold of detector ID's
+  double prog=0.0;
+  std::vector<size_t>::const_iterator wit;
+  for (wit = indexList.begin(); wit != indexList.end(); ++wit)
+  {
+    WS->maskWorkspaceIndex(*wit);
 
-  // 7. Non-MaskWorkspace masking workspace
-  if (inputMaskWS && createmaskws)
-    applyWorkspaceToMaskWorkspace(inputMaskWS);
+    //Progress
+    prog+= (1.0/static_cast<int>(indexList.size()));
+    progress(prog);
+  }
 
-  // 8. Apply Mask to input
-  maskWorkspace(WS);
-  
-  // 9. Finalize
-  // a) Event workspace to clear MRU
   if (eventWS)
   {
     //Also clear the MRU for event workspaces.
     eventWS->clearMRU();
   }
 
-  // b) If the input was a mask workspace, then extract the mask to ensure
-  //     we are returning the correct thing.
   if (isMaskWS)
   {
-    IAlgorithm_sptr alg = createSubAlgorithm("ExtractMask");
-    alg->setProperty<MatrixWorkspace_sptr>("InputWorkspace", WS);
-    alg->executeAsSubAlg();
-    MatrixWorkspace_sptr ws = alg->getProperty("OutputWorkspace");
-    setProperty("Workspace", ws);
+      // If the input was a mask workspace, then extract the mask to ensure
+      // we are returning the correct thing.
+      IAlgorithm_sptr alg = createSubAlgorithm("ExtractMask");
+      alg->setProperty<MatrixWorkspace_sptr>("InputWorkspace", WS);
+      alg->executeAsSubAlg();
+      MatrixWorkspace_sptr ws = alg->getProperty("OutputWorkspace");
+      setProperty("Workspace", ws);
   }
 
-  // c) This rebuild request call, gives the workspace the opportunity to rebuild the nearest neighbours map
-  //    and therfore pick up any detectors newly masked with this algorithm.
+  /*
+  This rebuild request call, gives the workspace the opportunity to rebuild the nearest neighbours map
+  and therfore pick up any detectors newly masked with this algorithm.
+  */
   WS->rebuildNearestNeighbours();
-
-  return;
 }
 
 /**
@@ -309,266 +303,5 @@ void MaskDetectors::appendToIndexListFromMaskWS(std::vector<size_t>& indexList,
   return;
 } // appendToIndexListFromWS
 
-
-/*
- * Create an empty MaskWorkspace w/o any detectors masked.
- */
-DataObjects::MaskWorkspace_sptr MaskDetectors::createMaskWorkspace(Geometry::Instrument_const_sptr instrument)
-{
-  //   Geometry::Instrument_const_sptr minstrument = tempWS->getInstrument();
-  DataObjects::MaskWorkspace_sptr maskws =
-      DataObjects::MaskWorkspace_sptr(new DataObjects::MaskWorkspace(instrument));
-  for (size_t i = 0; i < maskws->getNumberHistograms(); ++i)
-  {
-    maskws->dataY(i)[0] = 0.0;
-  }
-  maskws->setTitle("Mask");
-
-  return maskws;
-}
-
-/*
- * Apply the list of workspace indices to mask workspace
- */
-void MaskDetectors::applyIndexListToMaskWorkspace(API::MatrixWorkspace_sptr inpWS, std::vector<size_t> indexList)
-{
-  // 1. Get map
-  g_log.notice() << "MaskDetectors.applyIndexListToMaskWorkspace ... " << std::endl;
-  detid2index_map *map = mMaskWS->getDetectorIDToWorkspaceIndexMap(false);
-  if (!map)
-  {
-    g_log.error() << "MaskDetectors() Unable to get DetectorIDToWorkspaceIndex map()! " << std::endl;
-    throw std::runtime_error("Unable to getDetectorIDtoWorkspaceIndexMap.");
-  }
-
-  // 2. Apply
-  double prog=0.0;
-  std::vector<size_t>::const_iterator wit;
-
-  size_t numdettomask = 0;
-  std::set<size_t> wsset;
-  g_log.debug() << "MaskDetectors(): Number of WorkspaceIndex to Mask = " << indexList.size() << std::endl;
-  for (size_t iws = 0; iws < indexList.size(); ++ iws)
-  {
-    // a) Get detectors
-    API::ISpectrum* spec = inpWS->getSpectrum(indexList[iws]);
-    std::set<detid_t> detids = spec->getDetectorIDs();
-
-    // b) Apply to mask workspace
-    std::set<detid_t>::iterator setit;
-    for (setit = detids.begin(); setit != detids.end(); ++ setit)
-    {
-      detid_t detid = *setit;
-      detid2index_map::iterator dit;
-      dit = map->find(detid);
-      if (dit != map->end())
-      {
-        size_t wsindex = dit->second;
-        mMaskWS->dataY(wsindex)[0] = 1.0;
-        wsset.insert(wsindex);
-        ++ numdettomask;
-      }
-      else
-      {
-        g_log.warning() << "Detector w/ ID " << detid << " is not defined in instrument. " << std::endl;
-      }
-    }
-
-    // c) Progress
-    prog+= (0.25/static_cast<int>(indexList.size()));
-    progress(prog);
-  }
-
-  g_log.debug() << "MaskDetectors(): " << numdettomask << " detectors are to be masked." <<
-      " and there are " << wsset.size() << "  individual workspace indices" << std::endl;
-
-  // 3. Clean
-  delete map;
-
-  return;
-}
-
-/*
- * Apply a list of detectors (ID) to mask workspace
- */
-void MaskDetectors::applyDetectorListToMaskWorkspace(std::vector<detid_t> detectorList)
-{
-  // 1. Get map
-  // detid2index_map *map = inpWS->getDetectorIDToWorkspaceIndexMap(false);
-  detid2index_map *map = mMaskWS->getDetectorIDToWorkspaceIndexMap(false);
-
-  // 2. Apply
-  for (size_t idet = 0; idet < detectorList.size(); ++ idet)
-  {
-    detid_t detid = detectorList[idet];
-    detid2index_map::iterator dit;
-    dit = map->find(detid);
-    if (dit != map->end())
-    {
-      size_t wsindex = dit->second;
-      mMaskWS->dataY(wsindex)[0] = 1.0;
-    }
-    else
-    {
-      g_log.warning() << "Detector w/ ID " << detid << " is not defined in instrument. " << std::endl;
-    }
-  }
-
-  // 3. Clean
-  delete map;
-
-  return;
-}
-
-/*
- * Apply a non-MaskWorkspace's masked workspace to WS
- */
-void MaskDetectors::applyWorkspaceToMaskWorkspace(API::MatrixWorkspace_sptr maskedWorkspace)
-{
-  // Convert the vector of properties into a set for easy searching
-  int endIndex = getProperty("EndWorkspaceIndex");
-  if (endIndex == EMPTY_INT() )
-    endIndex = static_cast<int>(maskedWorkspace->getNumberHistograms() - 1);
-  int startIndex = getProperty("StartWorkspaceIndex");
-
-  // 1. Get map
-  detid2index_map *maskmap = mMaskWS->getDetectorIDToWorkspaceIndexMap(false);
-
-  for (specid_t iws = startIndex; iws <= endIndex; ++iws)
-  {
-    // a) Get one detector to check whether the detector of this workspace is masked
-    IDetector_const_sptr det;
-    try
-    {
-      det = maskedWorkspace->getDetector(iws);
-    }
-    catch(Exception::NotFoundError &)
-    {
-      continue;
-    }
-
-    // b) If the 'one' detector is masked, then mask mask workspace
-    if( det->isMasked())
-    {
-      API::ISpectrum* spec = maskedWorkspace->getSpectrum(iws);
-      std::set<detid_t> detids = spec->getDetectorIDs();
-
-      // b) Apply to mask workspace
-      std::set<detid_t>::iterator setit;
-      for (setit = detids.begin(); setit != detids.end(); ++ setit)
-      {
-        detid_t detid = *setit;
-        detid2index_map::iterator dit;
-        dit = maskmap->find(detid);
-        if (dit != maskmap->end())
-        {
-          size_t wsindex = dit->second;
-          mMaskWS->dataY(wsindex)[0] = 1.0;
-        }
-        else
-        {
-          g_log.warning() << "Detector w/ ID " << detid << " is not defined in instrument. " << std::endl;
-        }
-      } // FOR DetIDs
-    } // ENDIF-masked
-  } // ENDFOR workspace index
-
-  // 3) Clean
-  delete maskmap;
-
-  return;
-}
-
-/*
- * Mask workspace via myMaskWorkspace
- */
-void MaskDetectors::maskWorkspace(API::MatrixWorkspace_sptr inpWS)
-{
-  index2detid_map *maskmap = mMaskWS->getWorkspaceIndexToDetectorIDMap();
-  index2detid_map::iterator mit;
-
-  detid2index_map *inwsmap = inpWS->getDetectorIDToWorkspaceIndexMap(false);
-  detid2index_map::iterator pit; 
-
-  Geometry::Instrument_const_sptr instrument = inpWS->getInstrument();
-  Geometry::ParameterMap& pmap = inpWS->instrumentParameters();
-
-  // FIXME Efficiency + Correctness if grouped detectors
-  double prog = 0.25;
-  size_t numdetmasked = 0;
-  size_t numdettomask = 0;
-  for (size_t iws = 0; iws < mMaskWS->getNumberHistograms(); ++ iws)
-  {
-    if (mMaskWS->dataY(iws)[0] > 0.5)
-    {
-      numdettomask += 1;
-
-      // If it is masked
-      mit = maskmap->find(iws);
-      if (mit == maskmap->end())
-      {
-        g_log.warning() << "Workspace Index " << iws << " has not detector ID associated!" << std::endl;
-        continue;
-      }
-      detid_t detid = mit->second;
-      try
-      {
-        const Geometry::ComponentID det = instrument->getDetector(detid)->getComponentID();
-        if (det)
-        {
-          pmap.addBool(det, "masked", true);
-        
-          pit = inwsmap->find(detid);
-          if (pit == inwsmap->end())
-          {
-              g_log.warning() << "InputWorkspace has no workspace associated with detector w/ ID " << detid << std::endl;
-              continue;
-          }
-          specid_t newiws = static_cast<specid_t>(pit->second);
-          ISpectrum *spec = inpWS->getSpectrum(newiws);
-          if (!spec)
-              throw std::invalid_argument("Got a null spectrum");
-          else
-              spec->clearData();
-
-          ++ numdetmasked;
-        }
-        else
-        {
-          g_log.warning() << "Detector ID " << detid << " is not a component ID for detector. " << std::endl;
-        }
-      }
-      catch(Kernel::Exception::NotFoundError &e)
-      {
-        g_log.warning() << e.what() << " Found while running MaskDetectors" << std::endl;
-      }
-    } // END IF
-
-    // Report progress
-    int denom = static_cast<int>(mMaskWS->getNumberHistograms()/10);
-    if (denom == 0)
-    {
-      denom = 1;
-    }
-    if (iws % (denom) == 0)
-    {
-      prog+= (0.75/static_cast<double>(mMaskWS->getNumberHistograms()));
-      progress(prog);
-    }
-
-  } // ENDFOR
-
-  g_log.debug() << "Total " << numdetmasked << " detectors are masked. vs. " << numdettomask << " to mask." << std::endl;
-
-  progress(1.0);
-
-  // -1 Clean
-  delete maskmap;
-  delete inwsmap;
-
-  return;
-}
-
-
 } // namespace DataHandling
 } // namespace Mantid
diff --git a/Code/Mantid/Framework/DataHandling/src/SaveMask.cpp b/Code/Mantid/Framework/DataHandling/src/SaveMask.cpp
index ce55ef333e4326df17215c22ce6f481dba862e7a..0cc037b123b8fc0905fddbe515c27b2aa4be2de7 100644
--- a/Code/Mantid/Framework/DataHandling/src/SaveMask.cpp
+++ b/Code/Mantid/Framework/DataHandling/src/SaveMask.cpp
@@ -9,9 +9,9 @@ This algorithm saves a SpecialWorkspace2D/MaskWorkspace to an XML file.
 
 #include "MantidDataHandling/SaveMask.h"
 #include "MantidKernel/System.h"
+#include "MantidDataObjects/SpecialWorkspace2D.h"
 #include "MantidAPI/FileProperty.h"
 #include "MantidAPI/ISpectrum.h"
-#include "MantidGeometry/IDetector.h"
 
 #include "fstream"
 #include "sstream"
@@ -54,16 +54,16 @@ namespace DataHandling
   /// Sets documentation strings for this algorithm
   void SaveMask::initDocs()
   {
-    this->setWikiSummary("Save a mask workspace to an XML file.");
-    this->setOptionalMessage("Mask workspace can be a MaskWorkspace or a regular MatrixWorkspace. "
-        "In the second case, the detectors' masking information come from detectors. ");
+    this->setWikiSummary("Save a MaskWorkspace/SpecialWorkspace2D to an XML file.");
+    this->setOptionalMessage("Save a MaskWorkspace/SpecialWorkspace2D to an XML file.");
   }
 
   /// Define input parameters
   void SaveMask::init()
   {
-    declareProperty(new API::WorkspaceProperty<API::MatrixWorkspace>("InputWorkspace", "", Direction::Input),
-        "MaskingWorkspace (MaskWorkspace or regular MatrixWorkspace) to output to XML file (SpecialWorkspace2D)");
+
+    declareProperty(new API::WorkspaceProperty<DataObjects::SpecialWorkspace2D>("InputWorkspace", "", Direction::Input),
+        "MaskingWorkspace to output to XML file (SpecialWorkspace2D)");
     declareProperty(new FileProperty("OutputFile", "", FileProperty::Save, ".xml"),
         "File to save the detectors mask in XML format");
     declareProperty("GroupedDetectors", false,
@@ -75,33 +75,42 @@ namespace DataHandling
   void SaveMask::exec()
   {
     // 1. Get input
-    API::MatrixWorkspace_const_sptr inpWS = this->getProperty("InputWorkspace");
-    // DataObjects::SpecialWorkspace2D_const_sptr inpWS = this->getProperty("InputWorkspace");
+    DataObjects::SpecialWorkspace2D_const_sptr inpWS = this->getProperty("InputWorkspace");
     std::string outxmlfilename = this->getPropertyValue("OutputFile");
+    bool groupeddetectors = this->getProperty("GroupedDetectors");
 
-    // 2. Convert Workspace to a list of detectors of masked
+    // 2. Convert Workspace to ...
     std::vector<detid_t> detid0s;
+    for (size_t i = 0; i < inpWS->getNumberHistograms(); i ++){
+      if (inpWS->dataY(i)[0] > 0.1)
+      {
+        // It is way from 0 but smaller than 1
+        // a) workspace index -> spectrum -> detector ID
+        const API::ISpectrum *spec = inpWS->getSpectrum(i);
+        if (!spec)
+        {
+          g_log.error() << "No spectrum corresponds to workspace index " << i << std::endl;
+          throw std::invalid_argument("Cannot find spectrum");
+        }
 
-    bool ismaskworkspace;
-    DataObjects::MaskWorkspace_const_sptr inpMaskWS = boost::dynamic_pointer_cast<const DataObjects::MaskWorkspace>(inpWS);
-    if (inpMaskWS)
-    {
-      ismaskworkspace = true;
-    }
-    else
-    {
-      ismaskworkspace = false;
-    }
-
-    if (ismaskworkspace)
-    {
-      getMaskedDetectorsFromMaskWorkspace(inpMaskWS, detid0s);
-    }
-    else
-    {
-      getMaskedDetectorsFromInstrument(inpWS, detid0s);
-    }
+        const std::set<detid_t> detids = spec->getDetectorIDs();
+        if (!groupeddetectors && detids.size() != 1)
+        {
+          g_log.error() << "Impossible Situation! Workspace " << i << " corresponds to #(Det) = " << detids.size() << std::endl;
+          throw std::invalid_argument("Impossible number of detectors");
+        }
 
+        // b) get detector id & Store
+        detid_t detid;;
+        std::set<detid_t>::const_iterator it;
+        for (it=detids.begin(); it!=detids.end(); ++it)
+        {
+          detid = *it;
+          // c) store
+          detid0s.push_back(detid);
+        }
+      } // if
+    } // for
 
     // d) sort
     g_log.debug() << "Number of detectors to be masked = " << detid0s.size() << std::endl;
@@ -204,78 +213,6 @@ namespace DataHandling
     return;
   }
 
-  /*
-   * Get the list of detector IDs for detectors that are masked
-   */
-  void SaveMask::getMaskedDetectorsFromMaskWorkspace(DataObjects::MaskWorkspace_const_sptr inpWS, std::vector<detid_t>& detidlist)
-  {
-    for (size_t i = 0; i < inpWS->getNumberHistograms(); i ++)
-    {
-      if (inpWS->dataY(i)[0] > 0.1)
-      {
-        // It is way from 0 but smaller than 1
-        // a) workspace index -> spectrum -> detector ID
-        const API::ISpectrum *spec = inpWS->getSpectrum(i);
-        if (!spec)
-        {
-          g_log.error() << "No spectrum corresponds to workspace index " << i << std::endl;
-          throw std::invalid_argument("Cannot find spectrum");
-        }
-
-        const std::set<detid_t> detids = spec->getDetectorIDs();
-        if (detids.size() != 1)
-        {
-          g_log.error() << "Impossible Situation! Workspace " << i << " corresponds to #(Det) = " << detids.size() << std::endl;
-          throw std::invalid_argument("Impossible number of detectors");
-        }
-
-        // b) get detector id & Store
-        detid_t detid;;
-        std::set<detid_t>::const_iterator it;
-        for (it=detids.begin(); it!=detids.end(); ++it)
-        {
-          detid = *it;
-        }
-
-        // c) store
-        detidlist.push_back(detid);
-      } // if
-    } // for
-
-    return;
-  }
-
-  /*
-   * Get the list of masked detectors' IDs
-   */
-  void SaveMask::getMaskedDetectorsFromInstrument(API::MatrixWorkspace_const_sptr inpWS, std::vector<detid_t>& detidlist)
-  {
-    // 1. Get instrument
-    Geometry::Instrument_const_sptr instrument = inpWS->getInstrument();
-    if (!instrument)
-    {
-      g_log.error() << "InputWorkspace " << inpWS->getName() << " has no instrument (NULL). " << std::endl;
-      throw std::invalid_argument("InputWorkspace has no instrument. ");
-    }
-
-    for (size_t iw = 0; iw < inpWS->getNumberHistograms(); ++iw)
-    {
-      const API::ISpectrum *spec = inpWS->getSpectrum(iw);
-      std::set<int> detids = spec->getDetectorIDs();
-      bool ismasked = inpWS->getDetector(iw)->isMasked();
-      if (ismasked)
-      {
-        for (std::set<int>::iterator dit = detids.begin(); dit != detids.end(); ++dit)
-        {
-          detid_t detid = detid_t(*dit);
-          detidlist.push_back(detid);
-        }
-      }
-    }
-
-    return;
-  }
-
 
 } // namespace DataHandling
 } // namespace Mantid
diff --git a/Code/Mantid/Framework/DataHandling/test/MaskDetectorsTest.h b/Code/Mantid/Framework/DataHandling/test/MaskDetectorsTest.h
index 99414fa136f0de6aaaa290758ef2617ec69c91eb..4fe4ef0640f851c887a5e70e69f0ee4f295aa7f7 100644
--- a/Code/Mantid/Framework/DataHandling/test/MaskDetectorsTest.h
+++ b/Code/Mantid/Framework/DataHandling/test/MaskDetectorsTest.h
@@ -15,11 +15,7 @@
 #include "MantidAPI/SpectraDetectorMap.h"
 #include "MantidTestHelpers/ComponentCreationHelper.h"
 #include "MantidGeometry/IDetector.h"
-#include "MantidAPI/ISpectrum.h"
-#include "MantidGeometry/Instrument.h"
-#include "MantidAPI/MatrixWorkspace.h"
 
-using namespace Mantid;
 using namespace Mantid::DataHandling;
 using namespace Mantid::Kernel;
 using namespace Mantid::API;
@@ -113,105 +109,17 @@ public:
       space = boost::dynamic_pointer_cast<MatrixWorkspace>(specspace);
     }
 
-    if (!asMaskWorkspace)
-    {
+    if (!asMaskWorkspace){
       space->setInstrument(instr);
       space->generateSpectraMap();
-    }
-    // Register the workspace in the data service
-    AnalysisDataService::Instance().addOrReplace(name, space);
-
-  }
-
-  /*
-   * Generate a Workspace which can be (1) EventWorkspace, (2) Workspace2D, and (3) SpecialWorkspace2D
-   * with grouped detectors
-   */
-  void setUpWSwGroupedDetectors(bool event, const std::string & name = "testSpace", bool asMaskWorkspace = false, size_t numspec=9)
-  {
-    // 1. Instrument
-    Instrument_sptr instr = boost::dynamic_pointer_cast<Instrument>(ComponentCreationHelper::createTestInstrumentCylindrical(1, false));
-
-    for (detid_t i = 10; i <= 36; ++i)
-    {
-      Detector *d = new Detector("det", i, 0);
-      instr->markAsDetector(d);
-    }
-
-    // 2. Workspace
-    MatrixWorkspace_sptr space;
-    // Set up a small workspace for testing
-    if (event)
-    {
-      space = WorkspaceFactory::Instance().create("EventWorkspace",numspec,6,5);
-      EventWorkspace_sptr spaceEvent = boost::dynamic_pointer_cast<EventWorkspace>(space);
-
-      MantidVecPtr x,vec;
-      vec.access().resize(5,1.0);
-      detid_t currdetid = 1;
-      for (int j = 0; j < 9; ++j)
-      {
-        //Just one event per pixel
-        for (int k = 0; k < 4; ++ k)
-        {
-          TofEvent event(1.23*(1.+double(k)*0.01), int64_t(4.56));
-          spaceEvent->getEventList(j).addEventQuickly(event);
-        }
-        // spaceEvent->getEventList(j).setDetectorID(j);
-        spaceEvent->getAxis(1)->spectraNo(j) = j;
-        Mantid::API::ISpectrum* spec = spaceEvent->getSpectrum(j);
-        std::vector<int> detids;
-        for (size_t k = 0; k < 4; ++k)
-        {
-          detids.push_back(currdetid);
-          currdetid ++;
-        }
-        spec->addDetectorIDs(detids);
-      }
-      spaceEvent->doneAddingEventLists();
-      x.access().push_back(0.0);
-      x.access().push_back(10.0);
-      spaceEvent->setAllX(x);
-    }
-    else if (!asMaskWorkspace)
-    {
-      space = WorkspaceFactory::Instance().create("Workspace2D",numspec,6,5);
-      Workspace2D_sptr space2D = boost::dynamic_pointer_cast<Workspace2D>(space);
-
-      MantidVecPtr x,vec;
-      x.access().resize(6,10.0);
-      vec.access().resize(5,1.0);
-      for (int j = 0; j < 9; ++j)
-      {
-        space2D->setX(j,x);
-        space2D->setData(j,vec,vec);
-        space2D->getSpectrum(j)->setSpectrumNo(j);
-        space2D->getSpectrum(j)->setDetectorID(j);
-      }
-    }
-    else
-    {
-      // In case of MaskWorkspace
-      Mantid::DataObjects::MaskWorkspace_sptr specspace(new  Mantid::DataObjects::MaskWorkspace(instr));
-      for (size_t i = 0; i < specspace->getNumberHistograms(); i ++)
-      {
-        // default to use all the detectors
-        specspace->dataY(i)[0] = 0.0;
-      }
-      space = boost::dynamic_pointer_cast<MatrixWorkspace>(specspace);
-    }
 
-    if (!asMaskWorkspace)
-    {
-      space->setInstrument(instr);
-      space->generateSpectraMap();
+      std::cout << "another way of find number of detectors = " << space->getInstrument()->getDetectorIDs().size() << std::endl;
     }
     // Register the workspace in the data service
     AnalysisDataService::Instance().addOrReplace(name, space);
 
   }
 
-
   //---------------------------------------------------------------------------------------------
   void testInit()
   {
@@ -296,8 +204,6 @@ public:
     marker.setPropertyValue("DetectorList","");
     TS_ASSERT_THROWS_NOTHING( marker.execute());
 
-    MatrixWorkspace_const_sptr outputWSx = AnalysisDataService::Instance().retrieveWS<const MatrixWorkspace>("testSpace");
-
     MaskDetectors marker2;
     marker2.initialize();
     marker2.setPropertyValue("Workspace","testSpace");
@@ -462,91 +368,6 @@ public:
 
   }
 
-  //---------------------------------------------------------------------------------------------
-  void test_GroupedDetectors()
-  {
-    // 1. Genearte an EventWorkspace
-    bool event = true;
-    std::string name = "GroupedDetectorsSpace";
-    bool asMaskWorkspace = false;
-    size_t numspec=9;
-
-    setUpWSwGroupedDetectors(event, name, asMaskWorkspace, numspec);
-    DataObjects::EventWorkspace_sptr eventWS =
-      AnalysisDataService::Instance().retrieveWS<DataObjects::EventWorkspace>(name);
-    TS_ASSERT(eventWS);
-
-    TS_ASSERT_EQUALS(eventWS->getNumberHistograms(), 9);
-
-    // 2. Mask some spectra
-    std::vector<specid_t> tomaskspecs;
-    tomaskspecs.push_back(1);
-    tomaskspecs.push_back(3);
-    tomaskspecs.push_back(6);
-
-    MaskDetectors mask;
-    mask.initialize();
-    mask.setPropertyValue("Workspace",name);
-    mask.setPropertyValue("DetectorList","");
-    mask.setPropertyValue("WorkspaceIndexList","1, 3, 6, 3, 6");
-    TS_ASSERT_THROWS_NOTHING( mask.execute());
-    TS_ASSERT( mask.isExecuted() );
-
-    // The detectors' indices are to be masked should be 4~7, 12~15, 24~27
-
-    DataObjects::EventWorkspace_sptr maskedWS =
-      AnalysisDataService::Instance().retrieveWS<DataObjects::EventWorkspace>(name);
-    Geometry::Instrument_const_sptr maskedinstr = maskedWS->getInstrument();
-    TS_ASSERT(maskedinstr);
-    if (!maskedinstr)
-    {
-      return;
-    }
-
-    // 3. Check detectors's status about being masked.
-    for (size_t iws = 0; iws < maskedWS->getNumberHistograms(); ++iws)
-    {
-      API::ISpectrum *spec = maskedWS->getSpectrum(iws);
-      TS_ASSERT(spec);
-      if (!spec)
-        return;
-
-      bool shouldbemasked;
-      if (iws == 1 || iws == 3 || iws == 6)
-        shouldbemasked = true;
-      else
-        shouldbemasked = false;
-
-      std::set<int> detids = spec->getDetectorIDs();
-      for (std::set<int>::iterator detiter = detids.begin(); detiter != detids.end(); ++detiter)
-      {
-        IDetector_const_sptr det = maskedinstr->getDetector(*detiter);
-        TS_ASSERT_EQUALS(det->isMasked(), shouldbemasked);
-      }
-    } // ENDFOR iws
-
-
-    // 4. Check the value of spectra is cleared to zero or not
-    for (size_t iws = 0; iws < maskedWS->getNumberHistograms(); ++ iws)
-    {
-      double sumY = 0.0;
-      const MantidVec& yarray = maskedWS->readY(iws);
-      for (size_t iy = 0; iy < yarray.size(); ++ iy)
-        sumY += yarray[iy];
-      if  (iws == 1 || iws == 3 || iws == 6)
-      {
-        TS_ASSERT_EQUALS(sumY, 0.0);
-      }
-      else
-      {
-        bool larger = (sumY > 0.0);
-        TS_ASSERT(larger);
-      }
-    }
-
-    return;
-  }
-
 private:
   MaskDetectors marker;
 };
diff --git a/Code/Mantid/Framework/DataHandling/test/SaveMaskTest.h b/Code/Mantid/Framework/DataHandling/test/SaveMaskTest.h
index e99a6b59ba580d73f219e69335bb06c232c73fdd..b43282a42fb00f052a7e5172b774908200713f3e 100644
--- a/Code/Mantid/Framework/DataHandling/test/SaveMaskTest.h
+++ b/Code/Mantid/Framework/DataHandling/test/SaveMaskTest.h
@@ -10,19 +10,6 @@
 #include "MantidDataHandling/SaveMask.h"
 #include "MantidDataHandling/LoadMask.h"
 #include "MantidDataObjects/SpecialWorkspace2D.h"
-#include "MantidDataObjects/MaskWorkspace.h"
-#include "MantidTestHelpers/WorkspaceCreationHelper.h"
-#include "MantidTestHelpers/ComponentCreationHelper.h"
-#include "MantidAPI/ISpectrum.h"
-#include "MantidGeometry/IDetector.h"
-#include "MantidGeometry/Instrument.h"
-#include "MantidAPI/MatrixWorkspace.h"
-#include "MantidDataObjects/EventWorkspace.h"
-#include "MantidDataObjects/Workspace2D.h"
-#include "MantidDataObjects/MaskWorkspace.h"
-#include "MantidGeometry/IDetector.h"
-#include "MantidGeometry/Instrument.h"
-#include "MantidGeometry/Instrument/Detector.h"
 
 #include "Poco/File.h"
 
@@ -104,136 +91,6 @@ public:
     Poco::File cleanfile(file1);
     cleanfile.remove(false);
 
-    return;
-  }
-
-
-  /*
-   * Generate a Workspace with grouped detectors
-   * and some of them are masked
-   */
-  void setUpWSwGroupedDetectors(std::set<size_t> maskwsindexList, const std::string & name = "testSpace")
-  {
-    // 1. Instrument
-    // a) By this will create an instrument with 9 detectors
-    Mantid::Geometry::Instrument_sptr instr = boost::dynamic_pointer_cast<Mantid::Geometry::Instrument>(ComponentCreationHelper::createTestInstrumentCylindrical(1, false));
-    // b) Detectors ID
-    for (detid_t i = 10; i <= 36; ++i)
-    {
-      Mantid::Geometry::Detector *d = new Mantid::Geometry::Detector("det", i, 0);
-      instr->markAsDetector(d);
-    }
-
-    // 2. Workspace
-    MatrixWorkspace_sptr space;
-    space = WorkspaceFactory::Instance().create("EventWorkspace",9, 6, 5);
-    Mantid::DataObjects::EventWorkspace_sptr spaceEvent = boost::dynamic_pointer_cast<Mantid::DataObjects::EventWorkspace>(space);
-
-    // b) Set by each spectrum
-    MantidVecPtr x,vec;
-    vec.access().resize(5,1.0);
-    detid_t currdetid = 1;
-    for (int j = 0; j < 9; ++j)
-    {
-      //Just one event per pixel
-      for (int k = 0; k < 4; ++ k)
-      {
-        Mantid::DataObjects::TofEvent event(1.23*(1.+double(k)*0.01), int64_t(4.56));
-        spaceEvent->getEventList(j).addEventQuickly(event);
-      }
-      // spaceEvent->getEventList(j).setDetectorID(j);
-      spaceEvent->getAxis(1)->spectraNo(j) = j;
-      Mantid::API::ISpectrum* spec = spaceEvent->getSpectrum(j);
-      std::vector<int> detids;
-      for (size_t k = 0; k < 4; ++k)
-      {
-        detids.push_back(currdetid);
-        currdetid ++;
-      }
-      spec->addDetectorIDs(detids);
-    }
-    spaceEvent->doneAddingEventLists();
-    x.access().push_back(0.0);
-    x.access().push_back(10.0);
-    spaceEvent->setAllX(x);
-
-    space->setInstrument(instr);
-    space->generateSpectraMap();
-
-    // 3. Mask some spectra
-    for (std::set<size_t>::iterator wsiter = maskwsindexList.begin(); wsiter != maskwsindexList.end(); ++ wsiter)
-    {
-      size_t wsindex = *wsiter;
-      space->maskWorkspaceIndex(wsindex);
-    }
-
-    // 4. Register the workspace in the data service
-    AnalysisDataService::Instance().addOrReplace(name, space);
-
-    return;
-  }
-
-  void test_SaveFileGroupedDetectors()
-  {
-    // 1. Init SaveDetectorMasking
-    SaveMask savealg;
-    savealg.initialize();
-
-    // 2. Create input workspace
-    std::set<size_t> maskwsindexList;
-    maskwsindexList.insert(1);
-    maskwsindexList.insert(3);
-    maskwsindexList.insert(6);
-    std::string wsname("GroupedDetectorWS");
-    setUpWSwGroupedDetectors(maskwsindexList, wsname);
-    DataObjects::EventWorkspace_const_sptr inpws =
-          AnalysisDataService::Instance().retrieveWS<DataObjects::EventWorkspace>(wsname);
-
-    // 3. Set property and run
-    API::MatrixWorkspace_const_sptr inpmatrixws = boost::dynamic_pointer_cast<const API::MatrixWorkspace>(inpws);
-    TS_ASSERT(inpmatrixws);
-
-    TS_ASSERT(savealg.setProperty("InputWorkspace", wsname));
-    TS_ASSERT(savealg.setProperty("OutputFile", "groupeddetmask.xml"));
-    TS_ASSERT_THROWS_NOTHING(savealg.execute());
-    TS_ASSERT(savealg.isExecuted());
-
-    // Retrieve the full path to file
-    std::string file1 = savealg.getPropertyValue("OutputFile");
-
-    // 4. Load the new XML file
-    LoadMask loadfile2;
-    loadfile2.initialize();
-
-    // Note: must put a real instrument or LoadMask() won't work.
-    loadfile2.setProperty("Instrument", "POWGEN");
-    loadfile2.setProperty("InputFile", file1);
-    loadfile2.setProperty("OutputWorkspace", "PG3MaskCopy");
-
-    TS_ASSERT(loadfile2.execute());
-
-    DataObjects::MaskWorkspace_const_sptr maskws2 =
-          AnalysisDataService::Instance().retrieveWS<DataObjects::MaskWorkspace>("PG3MaskCopy");
-    TS_ASSERT(maskws2);
-    if (!maskws2)
-      return;
-
-    // 5. Check
-    std::vector<detid_t> detidinfile = loadfile2.getProperty("ToMaskDetectorIDsList");
-    TS_ASSERT_EQUALS(detidinfile.size(), 12);
-    std::sort(detidinfile.begin(), detidinfile.end());
-    for (size_t i = 0; i < 4; i ++)
-      TS_ASSERT_EQUALS(detidinfile[i], 5+i);
-    for (size_t i = 0; i < 4; i ++)
-      TS_ASSERT_EQUALS(detidinfile[i+4], 13+i);
-    for (size_t i = 0; i < 4; i ++)
-      TS_ASSERT_EQUALS(detidinfile[i+8], 25+i);
-
-    // 6. Clean the file
-    Poco::File cleanfile(file1);
-    cleanfile.remove(false);
-
-    return;
   }
 
 };
diff --git a/Code/Mantid/Framework/DataObjects/src/SpecialWorkspace2D.cpp b/Code/Mantid/Framework/DataObjects/src/SpecialWorkspace2D.cpp
index 0e2b39db6a5357b77ce2425253bef1ce2c788c78..07ad22b811365f3c52ba0220c8c605e461098966 100644
--- a/Code/Mantid/Framework/DataObjects/src/SpecialWorkspace2D.cpp
+++ b/Code/Mantid/Framework/DataObjects/src/SpecialWorkspace2D.cpp
@@ -56,59 +56,6 @@ namespace DataObjects
         detID_to_WI[detID] = int(wi);
       }
     }
-
-    /* Check whether the instrument is correct or not
-    detid2index_map *detToindexmap = this->getDetectorIDToWorkspaceIndexMap(false);
-    index2detid_map *indexTodetmap = this->getWorkspaceIndexToDetectorIDMap();
-
-    std::cout << "Detector2IndexMap Size = " << detToindexmap->size() << "  Index2DetectorMap Size = " << indexTodetmap->size() << std::endl;
-
-    bool roundtripgood = true;
-    detid2index_map::iterator detit;
-    index2detid_map::iterator indexit;
-    for (detit = detToindexmap->begin(); detit != detToindexmap->end(); ++detit)
-    {
-      detid_t detid = detit->first;
-      size_t index = detit->second;
-      indexit = indexTodetmap->find(index);
-      if (indexit == indexTodetmap->end())
-      {
-        g_log.error() << "Round trip instrument test error for detector " << detid << std::endl;
-        std::cout << "Round trip instrument test error for detector " << detid << std::endl;
-        roundtripgood = false;
-      }
-      else
-      {
-        detid_t rounddetid = indexit->second;
-
-        if (index == 142 || index == 162)
-          std::cout << "WS Index = " << index << " ... Detector = " << detid << std::endl;
-
-        if (rounddetid != detid)
-        {
-          g_log.error() << "Round trip instrument test error for detector " << detid << "  Trip back ID = " << rounddetid << std::endl;
-          std::cout << "Round trip instrument test error for detector " << detid << "  Trip back ID = " << rounddetid << std::endl;
-          roundtripgood = false;
-        }
-      }
-      if (!roundtripgood)
-        break;
-    }
-
-    delete detToindexmap;
-    delete indexTodetmap;
-
-    if (!roundtripgood)
-    {
-      throw std::invalid_argument("Input instrument is not correct!");
-    }
-    else
-    {
-      std::cout << "Successfully generate a SpecialWorkspace2D object!" << std::endl;
-    }
-    */
-
-    return;
   }