Index: src/Fragmentation/EnergyMatrix.cpp
===================================================================
--- src/Fragmentation/EnergyMatrix.cpp	(revision a9b86da232c3a8beead3fa86a30c4841166788f7)
+++ src/Fragmentation/EnergyMatrix.cpp	(revision 9758f70c8acad564988f204ebc13d19c82b5fa37)
@@ -35,7 +35,7 @@
 {
   DoLog(0) && (Log() << Verbose(0) << "Parsing energy indices." << endl);
-  Indices = new int*[MatrixCounter + 1];
+  Indices.resize(MatrixCounter + 1);
   for(int i=MatrixCounter+1;i--;) {
-    Indices[i] = new int[RowCounter[i]];
+    Indices[i].resize(RowCounter[i]);
     for(int j=RowCounter[i];j--;)
       Indices[i][j] = j;
@@ -93,8 +93,9 @@
     }
     // allocate last plus one matrix
-    DoLog(0) && (Log() << Verbose(0) << "Allocating last plus one matrix with " << (RowCounter[MatrixCounter]+1) << " rows and " << ColumnCounter[MatrixCounter] << " columns." << endl);
-    Matrix[MatrixCounter] = new double*[RowCounter[MatrixCounter] + 1];
+    if (Matrix[MatrixCounter].size() <= RowCounter[MatrixCounter] + 2)
+      Matrix[MatrixCounter].resize(RowCounter[MatrixCounter] + 1);
     for(int j=0;j<=RowCounter[MatrixCounter];j++)
-      Matrix[MatrixCounter][j] = new double[ColumnCounter[MatrixCounter]];
+      if (Matrix[MatrixCounter][j].size() <= ColumnCounter[MatrixCounter]+1)
+        Matrix[MatrixCounter][j].resize(ColumnCounter[MatrixCounter]);
 
     // try independently to parse global energysuffix file if present
Index: src/Fragmentation/ForceMatrix.cpp
===================================================================
--- src/Fragmentation/ForceMatrix.cpp	(revision a9b86da232c3a8beead3fa86a30c4841166788f7)
+++ src/Fragmentation/ForceMatrix.cpp	(revision 9758f70c8acad564988f204ebc13d19c82b5fa37)
@@ -44,5 +44,5 @@
 
   DoLog(0) && (Log() << Verbose(0) << "Parsing force indices for " << MatrixCounter << " matrices." << endl);
-  Indices = new int*[MatrixCounter + 1];
+  Indices.resize(MatrixCounter + 1);
   line << name << FRAGMENTPREFIX << FORCESFILE;
   input.open(line.str().c_str(), ios::in);
@@ -57,5 +57,5 @@
     line.str(filename);
     // parse the values
-    Indices[i] = new int[RowCounter[i]];
+    Indices[i].resize(RowCounter[i]);
     FragmentNumber = FixedDigitNumber(MatrixCounter, i);
     //Log() << Verbose(0) << FRAGMENTPREFIX << FragmentNumber << "[" << RowCounter[i] << "]:";
@@ -67,5 +67,5 @@
     //Log() << Verbose(0) << endl;
   }
-  Indices[MatrixCounter] = new int[RowCounter[MatrixCounter]];
+  Indices[MatrixCounter].resize(RowCounter[MatrixCounter]);
   for(int j=RowCounter[MatrixCounter];j--;) {
     Indices[MatrixCounter][j] = j;
@@ -152,8 +152,9 @@
 
     // allocate last plus one matrix
-    DoLog(0) && (Log() << Verbose(0) << "Allocating last plus one matrix with " << (RowCounter[MatrixCounter]+1) << " rows and " << ColumnCounter[MatrixCounter] << " columns." << endl);
-    Matrix[MatrixCounter] = new double*[RowCounter[MatrixCounter] + 1];
+    if (Matrix[MatrixCounter].size() <= RowCounter[MatrixCounter] + 2)
+      Matrix[MatrixCounter].resize(RowCounter[MatrixCounter] + 1);
     for(int j=0;j<=RowCounter[MatrixCounter];j++)
-      Matrix[MatrixCounter][j] = new double[ColumnCounter[MatrixCounter]];
+      if (Matrix[MatrixCounter][j].size() <= ColumnCounter[MatrixCounter]+1)
+        Matrix[MatrixCounter][j].resize(ColumnCounter[MatrixCounter]);
 
     // try independently to parse global forcesuffix file if present
Index: src/Fragmentation/HessianMatrix.cpp
===================================================================
--- src/Fragmentation/HessianMatrix.cpp	(revision a9b86da232c3a8beead3fa86a30c4841166788f7)
+++ src/Fragmentation/HessianMatrix.cpp	(revision 9758f70c8acad564988f204ebc13d19c82b5fa37)
@@ -44,5 +44,5 @@
 
   DoLog(0) && (Log() << Verbose(0) << "Parsing hessian indices for " << MatrixCounter << " matrices." << endl);
-  Indices = new int*[MatrixCounter + 1];
+  Indices.resize(MatrixCounter + 1);
   line << name << FRAGMENTPREFIX << FORCESFILE;
   input.open(line.str().c_str(), ios::in);
@@ -57,5 +57,5 @@
     line.str(filename);
     // parse the values
-    Indices[i] = new int[RowCounter[i]];
+    Indices[i].resize(RowCounter[i]);
     FragmentNumber = FixedDigitNumber(MatrixCounter, i);
     //Log() << Verbose(0) << FRAGMENTPREFIX << FragmentNumber << "[" << RowCounter[i] << "]:";
@@ -67,5 +67,5 @@
     //Log() << Verbose(0) << endl;
   }
-  Indices[MatrixCounter] = new int[RowCounter[MatrixCounter]];
+  Indices[MatrixCounter].resize(RowCounter[MatrixCounter]);
   for(int j=RowCounter[MatrixCounter];j--;) {
     Indices[MatrixCounter][j] = j;
@@ -243,7 +243,9 @@
     // allocate last plus one matrix
     DoLog(0) && (Log() << Verbose(0) << "Allocating last plus one matrix with " << (RowCounter[MatrixCounter]+1) << " rows and " << ColumnCounter[MatrixCounter] << " columns." << endl);
-    Matrix[MatrixCounter] = new double*[RowCounter[MatrixCounter] + 1];
+    if (Matrix[MatrixCounter].size() <= RowCounter[MatrixCounter] + 2)
+      Matrix[MatrixCounter].resize(RowCounter[MatrixCounter] + 1);
     for(int j=0;j<=RowCounter[MatrixCounter];j++)
-      Matrix[MatrixCounter][j] = new double[ColumnCounter[MatrixCounter]];
+      if (Matrix[MatrixCounter][j].size() <= ColumnCounter[MatrixCounter]+1)
+        Matrix[MatrixCounter][j].resize(ColumnCounter[MatrixCounter]);
 
     // try independently to parse global forcesuffix file if present
Index: src/Fragmentation/KeySetsContainer.cpp
===================================================================
--- src/Fragmentation/KeySetsContainer.cpp	(revision a9b86da232c3a8beead3fa86a30c4841166788f7)
+++ src/Fragmentation/KeySetsContainer.cpp	(revision 9758f70c8acad564988f204ebc13d19c82b5fa37)
@@ -21,4 +21,5 @@
 
 #include <fstream>
+#include <sstream>
 
 #include "CodePatterns/Log.hpp"
@@ -32,10 +33,7 @@
  */
 KeySetsContainer::KeySetsContainer() :
-  KeySets(NULL),
-  AtomCounter(NULL),
   FragmentCounter(0),
   Order(0),
-  FragmentsPerOrder(0),
-  OrderSet(NULL)
+  FragmentsPerOrder(0)
 {};
 
@@ -43,12 +41,12 @@
  */
 KeySetsContainer::~KeySetsContainer() {
-  for(int i=FragmentCounter;i--;)
-    delete[](KeySets[i]);
-  for(int i=Order;i--;)
-    delete[](OrderSet[i]);
-  delete[](KeySets);
-  delete[](OrderSet);
-  delete[](AtomCounter);
-  delete[](FragmentsPerOrder);
+//  for(int i=FragmentCounter;i--;)
+//    delete[](KeySets[i]);
+//  for(int i=Order;i--;)
+//    delete[](OrderSet[i]);
+//  delete[](KeySets);
+//  delete[](OrderSet);
+//  delete[](AtomCounter);
+//  delete[](FragmentsPerOrder);
 };
 
@@ -59,5 +57,5 @@
  * \return parsing succesful
  */
-bool KeySetsContainer::ParseKeySets(const char *name, const int *ACounter, const int FCounter) {
+bool KeySetsContainer::ParseKeySets(const std::string name, const IntVector ACounter, const int FCounter) {
   ifstream input;
   char *FragmentNumber = NULL;
@@ -67,7 +65,5 @@
   FragmentCounter = FCounter;
   DoLog(0) && (Log() << Verbose(0) << "Parsing key sets." << endl);
-  KeySets = new int*[FragmentCounter];
-  for(int i=FragmentCounter;i--;)
-    KeySets[i] = NULL;
+  KeySets.resize(FragmentCounter);
   file << name << FRAGMENTPREFIX << KEYSETFILE;
   input.open(file.str().c_str(), ios::in);
@@ -77,10 +73,10 @@
   }
 
-  AtomCounter = new int[FragmentCounter];
+  AtomCounter.resize(FragmentCounter);
   for(int i=0;(i<FragmentCounter) && (!input.eof());i++) {
     stringstream line;
     AtomCounter[i] = ACounter[i];
     // parse the values
-    KeySets[i] = new int[AtomCounter[i]];
+    KeySets[i].resize(AtomCounter[i]);
     for(int j=AtomCounter[i];j--;)
       KeySets[i][j] = -1;
@@ -121,7 +117,7 @@
 
   // scan through all to determine fragments per order
-  FragmentsPerOrder = new int[Order];
-  for(int i=Order;i--;)
-    FragmentsPerOrder[i] = 0;
+  FragmentsPerOrder.resize(Order);
+//  for(int i=Order;i--;)
+//    FragmentsPerOrder[i] = 0;
   for(int i=FragmentCounter;i--;) {
     Counter=0;
@@ -135,7 +131,7 @@
 
   // scan through all to gather indices to each order set
-  OrderSet = new int*[Order];
+  OrderSet.resize(Order);
   for(int i=Order;i--;)
-    OrderSet[i] = new int[FragmentsPerOrder[i]];
+    OrderSet[i].resize(FragmentsPerOrder[i]);
   for(int i=Order;i--;)
     FragmentsPerOrder[i] = 0;
Index: src/Fragmentation/KeySetsContainer.hpp
===================================================================
--- src/Fragmentation/KeySetsContainer.hpp	(revision a9b86da232c3a8beead3fa86a30c4841166788f7)
+++ src/Fragmentation/KeySetsContainer.hpp	(revision 9758f70c8acad564988f204ebc13d19c82b5fa37)
@@ -20,15 +20,17 @@
 class KeySetsContainer {
   public:
-    int **KeySets;
-    int *AtomCounter;
+    typedef std::vector<int> IntVector;
+    typedef std::vector<IntVector> ArrayOfIntVectors;
+    ArrayOfIntVectors KeySets;
+    IntVector AtomCounter;
     int FragmentCounter;
     int Order;
-    int *FragmentsPerOrder;
-    int **OrderSet;
+    IntVector FragmentsPerOrder;
+    ArrayOfIntVectors OrderSet;
 
   KeySetsContainer();
   ~KeySetsContainer();
 
-  bool ParseKeySets(const char *name, const int *ACounter, const int FCounter);
+  bool ParseKeySets(const std::string name, const std::vector<int> ACounter, const int FCounter);
   bool ParseManyBodyTerms();
   bool Contains(const int GreaterSet, const int SmallerSet);
Index: src/Fragmentation/MatrixContainer.cpp
===================================================================
--- src/Fragmentation/MatrixContainer.cpp	(revision a9b86da232c3a8beead3fa86a30c4841166788f7)
+++ src/Fragmentation/MatrixContainer.cpp	(revision 9758f70c8acad564988f204ebc13d19c82b5fa37)
@@ -35,53 +35,17 @@
 /** Constructor of MatrixContainer class.
  */
-MatrixContainer::MatrixContainer() :
-  Indices(NULL)
-{
-  Header = new char*[1];
-  Matrix = new double**[1]; // one more each for the total molecule
-  RowCounter = new int[1];
-  ColumnCounter = new int[1];
-  Header[0] = NULL;
-  Matrix[0] = NULL;
-  RowCounter[0] = -1;
+MatrixContainer::MatrixContainer()
+{
+  Header.resize(1);
+  RowCounter.resize(1);
+  ColumnCounter.resize(1);
+  ColumnCounter[0] = -1;
   MatrixCounter = 0;
-  ColumnCounter[0] = -1;
 };
 
 /** Destructor of MatrixContainer class.
  */
-MatrixContainer::~MatrixContainer() {
-  if (Matrix != NULL) {
-    // free Matrix[MatrixCounter]
-    if ((ColumnCounter != NULL) && (RowCounter != NULL) && (Matrix[MatrixCounter] != NULL))
-      for(int j=RowCounter[MatrixCounter]+1;j--;)
-        delete[](Matrix[MatrixCounter][j]);
-    //if (MatrixCounter != 0)
-    delete[](Matrix[MatrixCounter]);
-    // free all matrices but ultimate one
-    for(int i=MatrixCounter;i--;) {
-      if ((ColumnCounter != NULL) && (RowCounter != NULL)) {
-          for(int j=RowCounter[i]+1;j--;)
-            delete[](Matrix[i][j]);
-          delete[](Matrix[i]);
-      }
-    }
-    delete[](Matrix);
-  }
-  // free indices
-  if (Indices != NULL)
-    for(int i=MatrixCounter+1;i--;) {
-      delete[](Indices[i]);
-    }
-  delete[](Indices);
-
-  // free header and counters
-  if (Header != NULL)
-    for(int i=MatrixCounter+1;i--;)
-      delete[](Header[i]);
-  delete[](Header);
-  delete[](RowCounter);
-  delete[](ColumnCounter);
-};
+MatrixContainer::~MatrixContainer()
+{}
 
 /** Either copies index matrix from another MatrixContainer or initialises with trivial mapping if NULL.
@@ -90,12 +54,12 @@
  * \return true - copy/initialisation sucessful, false - dimension false for copying
  */
-bool MatrixContainer::InitialiseIndices(class MatrixContainer *Matrix)
+bool MatrixContainer::InitialiseIndices(class MatrixContainer *_container)
 {
   DoLog(0) && (Log() << Verbose(0) << "Initialising indices");
-  if (Matrix == NULL) {
+  if (_container == NULL) {
     DoLog(0) && (Log() << Verbose(0) << " with trivial mapping." << endl);
-    Indices = new int*[MatrixCounter + 1];
+    Indices.resize(MatrixCounter + 1);
     for(int i=MatrixCounter+1;i--;) {
-      Indices[i] = new int[RowCounter[i]];
+      Indices[i].resize(RowCounter[i]);
       for(int j=RowCounter[i];j--;)
         Indices[i][j] = j;
@@ -103,13 +67,13 @@
   } else {
     DoLog(0) && (Log() << Verbose(0) << " from other MatrixContainer." << endl);
-    if (MatrixCounter != Matrix->MatrixCounter)
+    if (MatrixCounter != _container->MatrixCounter)
       return false;
-    Indices = new int*[MatrixCounter + 1];
+    Indices.resize(MatrixCounter + 1);
     for(int i=MatrixCounter+1;i--;) {
-      if (RowCounter[i] != Matrix->RowCounter[i])
+      if (RowCounter[i] != _container->RowCounter[i])
         return false;
-      Indices[i] = new int[Matrix->RowCounter[i]];
-      for(int j=Matrix->RowCounter[i];j--;) {
-        Indices[i][j] = Matrix->Indices[i][j];
+      Indices[i].resize(_container->RowCounter[i]);
+      for(int j=_container->RowCounter[i];j--;) {
+        Indices[i][j] = _container->Indices[i][j];
         //Log() << Verbose(0) << Indices[i][j] << "\t";
       }
@@ -133,5 +97,5 @@
  * \return parsing successful
  */
-bool MatrixContainer::ParseMatrix(std::istream &input, int skiplines, int skipcolumns, int MatrixNr)
+bool MatrixContainer::ParseMatrix(std::istream &input, int skiplines, int skipcolumns, size_t MatrixNr)
 {
   stringstream line;
@@ -146,15 +110,18 @@
 
   // parse header
-  if (Header[MatrixNr] != NULL)
-    delete[] Header[MatrixNr];
-  Header[MatrixNr] = new char[1024];
+  if (Header.size() <= MatrixNr)
+    Header.resize(MatrixNr);
+  Header[MatrixNr] = std::string("");
+  char dummy[1024];
   for (int m=skiplines+1;m--;)
-    input.getline(Header[MatrixNr], 1023);
-
-  // scan header for number of columns
-  line.str(Header[MatrixNr]);
+    input.getline(dummy, 1023);
+  line.str(dummy);
   for(int k=skipcolumns;k--;)
     line >> Header[MatrixNr];
   Log() << Verbose(0) << line.str() << endl;
+
+  // scan header for number of columns
+  if (ColumnCounter.size() <= MatrixNr)
+    ColumnCounter.resize(MatrixNr);
   ColumnCounter[MatrixNr]=0;
   while ( getline(line,token, '\t') ) {
@@ -170,4 +137,6 @@
 
   // scan rest for number of rows/lines
+  if (RowCounter.size() <= MatrixNr)
+    RowCounter.resize(MatrixNr);
   RowCounter[MatrixNr]=-1;    // counts one line too much
   while (!input.eof()) {
@@ -186,46 +155,42 @@
 
   // allocate matrix if it's not zero dimension in one direction
-  if ((ColumnCounter[MatrixNr] > 0) && (RowCounter[MatrixNr] > -1)) {
-    if (Matrix[MatrixNr] != NULL)
-      delete[] Matrix[MatrixNr];
-    Matrix[MatrixNr] = new double*[RowCounter[MatrixNr] + 1];
-    for(int j=0;j<RowCounter[MatrixNr]+1;j++)
-      Matrix[MatrixNr][j] = 0;
-
-    // parse in each entry for this matrix
-    input.clear();
-    input.seekg(ios::beg);
-    for (int m=skiplines+1;m--;)
-      input.getline(Header[MatrixNr], 1023);    // skip header
-    line.str(Header[MatrixNr]);
-    Log() << Verbose(0) << "Header: " << line.str() << endl;
-    for(int k=skipcolumns;k--;)  // skip columns in header too
-      line >> filename;
-    strncpy(Header[MatrixNr], line.str().c_str(), 1023);
-    for(int j=0;j<RowCounter[MatrixNr];j++) {
-      if (Matrix[MatrixNr][j] != NULL)
-        delete[] Matrix[MatrixNr][j];
-      Matrix[MatrixNr][j] = new double[ColumnCounter[MatrixNr]];
-      for(int k=0;k<ColumnCounter[MatrixNr];k++)
+  if (Matrix.size() <= MatrixNr)
+    Matrix.resize(MatrixNr+1);
+  if ((Matrix[MatrixNr].size() <= (size_t)RowCounter[MatrixNr] + 1) && (RowCounter[MatrixNr] > -1)) {
+    Matrix[MatrixNr].resize(RowCounter[MatrixNr] + 2);
+    for(int j=0;j<=RowCounter[MatrixNr];j++) {
+      if ((Matrix[MatrixNr][j].size() <= (size_t)ColumnCounter[MatrixNr]) && (ColumnCounter[MatrixNr] > -1))
+        Matrix[MatrixNr][j].resize(ColumnCounter[MatrixNr]+1);
+      // clear
+      for(int k=0;k<=ColumnCounter[MatrixNr];k++)
         Matrix[MatrixNr][j][k] = 0;
-
-      input.getline(filename, 1023);
-      stringstream lines(filename);
-      Log() << Verbose(2) << "Matrix at level " << j << ":";// << filename << endl;
-      for(int k=skipcolumns;k--;)
-        lines >> filename;
-      for(int k=0;(k<ColumnCounter[MatrixNr]) && (!lines.eof());k++) {
-        lines >> Matrix[MatrixNr][j][k];
-        Log() << Verbose(1) << " " << std::setprecision(2) << Matrix[MatrixNr][j][k] << endl;
-      }
-      if (Matrix[MatrixNr][ RowCounter[MatrixNr] ] != NULL)
-        delete[] Matrix[MatrixNr][ RowCounter[MatrixNr] ];
-      Matrix[MatrixNr][ RowCounter[MatrixNr] ] = new double[ColumnCounter[MatrixNr]];
-      for(int j=ColumnCounter[MatrixNr];j--;)
-        Matrix[MatrixNr][ RowCounter[MatrixNr] ][j] = 0.;
     }
   } else {
-    DoeLog(1) && (eLog()<< Verbose(1) << "Matrix nr. " << MatrixNr << " has column and row count of (" << ColumnCounter[MatrixNr] << "," << RowCounter[MatrixNr] << "), could not allocate nor parse!" << endl);
-  }
+    ELOG(1, "Matrix nr. " << MatrixNr << " has column and row count of (" << ColumnCounter[MatrixNr] << "," << RowCounter[MatrixNr] << "), could not allocate nor parse!");
+    return false;
+  }
+
+  // parse in each entry for this matrix
+  input.clear();
+  input.seekg(ios::beg);
+  for (int m=skiplines+1;m--;)
+    input.getline(dummy, 1023);    // skip header
+  line.str(dummy);
+  Log() << Verbose(0) << "Header: " << line.str() << endl;
+  for(int k=skipcolumns;k--;)  // skip columns in header too
+    line >> filename;
+  Header[MatrixNr] = line.str();
+  for(int j=0;j<RowCounter[MatrixNr];j++) {
+    input.getline(filename, 1023);
+    stringstream lines(filename);
+    Log() << Verbose(2) << "Matrix at level " << j << ":";// << filename << endl;
+    for(int k=skipcolumns;k--;)
+      lines >> filename;
+    for(int k=0;(k<ColumnCounter[MatrixNr]) && (!lines.eof());k++) {
+      lines >> Matrix[MatrixNr][j][k];
+      Log() << Verbose(1) << " " << std::setprecision(2) << Matrix[MatrixNr][j][k] << endl;
+    }
+  }
+
   return true;
 };
@@ -249,5 +214,5 @@
  * \return parsing successful
  */
-bool MatrixContainer::ParseFragmentMatrix(const char *name, const char *prefix, string suffix, int skiplines, int skipcolumns)
+bool MatrixContainer::ParseFragmentMatrix(const std::string name, const std::string prefix, std::string suffix, int skiplines, int skipcolumns)
 {
   char filename[1023];
@@ -274,18 +239,12 @@
 
   DoLog(0) && (Log() << Verbose(0) << "Parsing through each fragment and retrieving " << prefix << suffix << "." << endl);
-  delete[](Header);
-  delete[](Matrix);
-  delete[](RowCounter);
-  delete[](ColumnCounter);
-  Header = new char*[MatrixCounter + 1]; // one more each for the total molecule
-  Matrix = new double**[MatrixCounter + 1]; // one more each for the total molecule
-  RowCounter = new int[MatrixCounter + 1];
-  ColumnCounter = new int[MatrixCounter + 1];
-  for(int i=MatrixCounter+1;i--;) {
-    Matrix[i] = NULL;
-    Header[i] = NULL;
-    RowCounter[i] = -1;
-    ColumnCounter[i] = -1;
-  }
+  Header.clear();
+  Matrix.clear();
+  RowCounter.clear();
+  ColumnCounter.clear();
+  Header.resize(MatrixCounter + 1); // one more each for the total molecule
+  Matrix.resize(MatrixCounter + 1); // one more each for the total molecule
+  RowCounter.resize(MatrixCounter + 1);
+  ColumnCounter.resize(MatrixCounter + 1);
   for(int i=0; i < MatrixCounter;i++) {
     // open matrix file
@@ -312,22 +271,21 @@
  * \return Allocation successful
  */
-bool MatrixContainer::AllocateMatrix(char **GivenHeader, int MCounter, int *RCounter, int *CCounter)
+bool MatrixContainer::AllocateMatrix(StringVector GivenHeader, int MCounter, IntVector RCounter, IntVector CCounter)
 {
   MatrixCounter = MCounter;
-  Header = new char*[MatrixCounter + 1];
-  Matrix = new double**[MatrixCounter + 1]; // one more each for the total molecule
-  RowCounter = new int[MatrixCounter + 1];
-  ColumnCounter = new int[MatrixCounter + 1];
+  Header.resize(MatrixCounter + 1);
+  Matrix.resize(MatrixCounter + 1); // one more each for the total molecule
+  RowCounter.resize(MatrixCounter + 1);
+  ColumnCounter.resize(MatrixCounter + 1);
   for(int i=MatrixCounter+1;i--;) {
-    Header[i] = new char[1024];
-    strncpy(Header[i], GivenHeader[i], 1023);
+    Header[i] = GivenHeader[i];
     RowCounter[i] = RCounter[i];
     ColumnCounter[i] = CCounter[i];
-    Matrix[i] = new double*[RowCounter[i] + 1];
-    for(int j=RowCounter[i]+1;j--;) {
-      Matrix[i][j] = new double[ColumnCounter[i]];
-      for(int k=ColumnCounter[i];k--;)
-        Matrix[i][j][k] = 0.;
-    }
+    if (Matrix[i].size() <= RowCounter[i] + 2)
+      Matrix[i].resize(RowCounter[i] + 1);
+    for(int j=0;j<=RowCounter[i];j++)
+      if (Matrix[i][j].size() <= ColumnCounter[i]+1)
+        Matrix[i][j].resize(ColumnCounter[i]);
+    // allocation with 0 is guaranted by STL
   }
   return true;
@@ -396,5 +354,5 @@
  * \return true if successful
  */
-bool MatrixContainer::SetLastMatrix(double **values, int skipcolumns)
+bool MatrixContainer::SetLastMatrix(const MatrixArray &values, int skipcolumns)
 {
   for(int j=RowCounter[MatrixCounter]+1;j--;)
@@ -466,5 +424,5 @@
  * \return file was written
  */
-bool MatrixContainer::WriteTotalFragments(const char *name, const char *prefix)
+bool MatrixContainer::WriteTotalFragments(const std::string name, const std::string prefix)
 {
   ofstream output;
@@ -500,5 +458,5 @@
  * \return file was written
  */
-bool MatrixContainer::WriteLastMatrix(const char *name, const char *prefix, const char *suffix)
+bool MatrixContainer::WriteLastMatrix(const std::string name, const std::string prefix, const std::string suffix)
 {
   ofstream output;
Index: src/Fragmentation/MatrixContainer.hpp
===================================================================
--- src/Fragmentation/MatrixContainer.hpp	(revision a9b86da232c3a8beead3fa86a30c4841166788f7)
+++ src/Fragmentation/MatrixContainer.hpp	(revision 9758f70c8acad564988f204ebc13d19c82b5fa37)
@@ -14,7 +14,5 @@
 #endif
 
-#include "boost/serialization/array.hpp"
-
-#include "boost/multi_array.hpp"
+#include <vector>
 
 /** Contains a sequence of matrices parsed from file.
@@ -23,10 +21,16 @@
 class MatrixContainer {
   public:
-    double ***Matrix;
-    int **Indices;
-    char **Header;
+    typedef std::vector<std::vector<double> > MatrixArray;
+    typedef std::vector<MatrixArray> ArrayOfMatrices;
+    typedef std::vector<std::string> StringVector;
+    typedef std::vector<int> IntVector;
+    typedef std::vector<IntVector> VectorOfIntVectors;
+
+    ArrayOfMatrices Matrix;
+    VectorOfIntVectors Indices;
+    StringVector Header;
     int MatrixCounter;
-    int *RowCounter;
-    int *ColumnCounter;
+    IntVector RowCounter;
+    IntVector ColumnCounter;
 
   MatrixContainer();
@@ -34,17 +38,17 @@
 
   bool InitialiseIndices(class MatrixContainer *Matrix = NULL);
-  bool ParseMatrix(std::istream &input, int skiplines, int skipcolumns, int MatrixNr);
-  virtual bool ParseFragmentMatrix(const char *name, const char *prefix, std::string suffix, int skiplines, int skipcolumns);
-  bool AllocateMatrix(char **GivenHeader, int MCounter, int *RCounter, int *CCounter);
+  bool ParseMatrix(std::istream &input, int skiplines, int skipcolumns, size_t MatrixNr);
+  virtual bool ParseFragmentMatrix(const std::string name, const std::string prefix, std::string suffix, int skiplines, int skipcolumns);
+  bool AllocateMatrix(StringVector GivenHeader, int MCounter, IntVector RCounter, IntVector CCounter);
   bool ResetMatrix();
   double FindMinValue();
   double FindMaxValue();
   bool SetLastMatrix(double value, int skipcolumns);
-  bool SetLastMatrix(double **values, int skipcolumns);
+  bool SetLastMatrix(const MatrixArray &values, int skipcolumns);
   //bool ParseIndices();
   //bool SumSubValues();
   bool SumSubManyBodyTerms(class MatrixContainer &Matrix, class KeySetsContainer &KeySets, int Order);
-  bool WriteTotalFragments(const char *name, const char *prefix);
-  bool WriteLastMatrix(const char *name, const char *prefix, const char *suffix);
+  bool WriteTotalFragments(const std::string name, const std::string prefix);
+  bool WriteLastMatrix(const std::string name, const std::string prefix, const std::string suffix);
 };
 
