Index: src/moleculelist.cpp
===================================================================
--- src/moleculelist.cpp	(revision a80fbdfe7ff2c5de6edfc1365430bcadc4e1a6a3)
+++ src/moleculelist.cpp	(revision 41194a7bf06101702d6e0b8243fa47ade9e8c24e)
@@ -7,4 +7,5 @@
 #include "config.hpp"
 #include "molecules.hpp"
+#include "memoryallocator.hpp"
 
 /*********************************** Functions for class MoleculeListClass *************************/
@@ -375,9 +376,9 @@
 
   // 0b. allocate memory for constants
-  FitConstant = (double ***) Malloc(sizeof(double **) * 3, "MoleculeListClass::AddHydrogenCorrection: ***FitConstant");
+  FitConstant = Malloc<double**>(3, "MoleculeListClass::AddHydrogenCorrection: ***FitConstant");
   for (int k = 0; k < 3; k++) {
-    FitConstant[k] = (double **) Malloc(sizeof(double *) * a, "MoleculeListClass::AddHydrogenCorrection: **FitConstant[]");
+    FitConstant[k] = Malloc<double*>(a, "MoleculeListClass::AddHydrogenCorrection: **FitConstant[]");
     for (int i = a; i--;) {
-      FitConstant[k][i] = (double *) Malloc(sizeof(double) * b, "MoleculeListClass::AddHydrogenCorrection: *FitConstant[][]");
+      FitConstant[k][i] = Malloc<double>(b, "MoleculeListClass::AddHydrogenCorrection: *FitConstant[][]");
     }
   }
@@ -424,7 +425,7 @@
 
   // 0d. allocate final correction matrix
-  correction = (double **) Malloc(sizeof(double *) * a, "MoleculeListClass::AddHydrogenCorrection: **correction");
+  correction = Malloc<double*>(a, "MoleculeListClass::AddHydrogenCorrection: **correction");
   for (int i = a; i--;)
-    correction[i] = (double *) Malloc(sizeof(double) * b, "MoleculeListClass::AddHydrogenCorrection: *correction[]");
+    correction[i] = Malloc<double>(b, "MoleculeListClass::AddHydrogenCorrection: *correction[]");
 
   // 1a. go through every molecule in the list
@@ -500,9 +501,9 @@
   output.close();
   // 6. free memory of parsed matrices
-  FitConstant = (double ***) Malloc(sizeof(double **) * a, "MoleculeListClass::AddHydrogenCorrection: ***FitConstant");
+  FitConstant = Malloc<double**>(a, "MoleculeListClass::AddHydrogenCorrection: ***FitConstant");
   for (int k = 0; k < 3; k++) {
-    FitConstant[k] = (double **) Malloc(sizeof(double *) * a, "MoleculeListClass::AddHydrogenCorrection: **FitConstant[]");
+    FitConstant[k] = Malloc<double*>(a, "MoleculeListClass::AddHydrogenCorrection: **FitConstant[]");
     for (int i = a; i--;) {
-      FitConstant[k][i] = (double *) Malloc(sizeof(double) * b, "MoleculeListClass::AddHydrogenCorrection: *FitConstant[][]");
+      FitConstant[k][i] = Malloc<double>(b, "MoleculeListClass::AddHydrogenCorrection: *FitConstant[][]");
     }
   }
@@ -665,5 +666,5 @@
     //outputFragment.clear();
     delete (FragmentNumber);
-    //Free((void **)&FragmentNumber, "MoleculeListClass::OutputConfigForListOfFragments: *FragmentNumber");
+    //Free(&FragmentNumber);
   }
   cout << " done." << endl;
@@ -808,7 +809,7 @@
   if ((FreeList) && (ListOfLocalAtoms != NULL)) {
     // free the index lookup list
-    Free((void **) &ListOfLocalAtoms[FragmentCounter], "MoleculeLeafClass::FillBondStructureFromReference - **ListOfLocalAtoms[]");
+    Free(&ListOfLocalAtoms[FragmentCounter]);
     if (FragmentCounter == 0) // first fragments frees the initial pointer to list
-      Free((void **) &ListOfLocalAtoms, "MoleculeLeafClass::FillBondStructureFromReference - ***ListOfLocalAtoms");
+      Free(&ListOfLocalAtoms);
   }
   FragmentCounter--;
@@ -873,5 +874,5 @@
   if (ListOfLocalAtoms == NULL) { // allocated initial pointer
     // allocate and set each field to NULL
-    ListOfLocalAtoms = (atom ***) Malloc(sizeof(atom **) * Counter, "MoleculeLeafClass::FillBondStructureFromReference - ***ListOfLocalAtoms");
+    ListOfLocalAtoms = Malloc<atom**>(Counter, "MoleculeLeafClass::FillBondStructureFromReference - ***ListOfLocalAtoms");
     if (ListOfLocalAtoms != NULL) {
       for (int i = Counter; i--;)
@@ -917,5 +918,5 @@
   if (FragmentList == NULL) {
     KeySetCounter = Count();
-    FragmentList = (Graph **) Malloc(sizeof(Graph *) * KeySetCounter, "MoleculeLeafClass::AssignKeySetsToFragment - **FragmentList");
+    FragmentList = Malloc<Graph*>(KeySetCounter, "MoleculeLeafClass::AssignKeySetsToFragment - **FragmentList");
     for (int i = KeySetCounter; i--;)
       FragmentList[i] = NULL;
@@ -953,7 +954,7 @@
   if ((FreeList) && (ListOfLocalAtoms != NULL)) {
     // free the index lookup list
-    Free((void **) &ListOfLocalAtoms[FragmentCounter], "MoleculeLeafClass::AssignKeySetsToFragment - **ListOfLocalAtoms[]");
+    Free(&ListOfLocalAtoms[FragmentCounter]);
     if (FragmentCounter == 0) // first fragments frees the initial pointer to list
-      Free((void **) &ListOfLocalAtoms, "MoleculeLeafClass::AssignKeySetsToFragment - ***ListOfLocalAtoms");
+      Free(&ListOfLocalAtoms);
   }
   *out << Verbose(1) << "End of AssignKeySetsToFragment." << endl;
