diff --git a/Solver/linearSystemPETSc.cpp b/Solver/linearSystemPETSc.cpp
index 0d241d368de423e0f21cbab2402dda5835316750..b458d8b2ba30908f92358a245711347833d69fac 100644
--- a/Solver/linearSystemPETSc.cpp
+++ b/Solver/linearSystemPETSc.cpp
@@ -27,6 +27,18 @@ void linearSystemPETScBlockDouble::_kspCreate()
   _kspAllocated = true;
 }
 
+linearSystemPETScBlockDouble::~linearSystemPETScBlockDouble()
+{
+  if (_isAllocated) {
+    MatDestroy(&_a);
+    VecDestroy(&_b);
+    VecDestroy(&_x);
+  }
+  if (_kspAllocated) {
+    KSPDestroy(&_ksp);
+  }
+}
+
 void linearSystemPETScBlockDouble::addToMatrix(int row, int col,
                                                const fullMatrix<double> &val)
 {
diff --git a/Solver/linearSystemPETSc.h b/Solver/linearSystemPETSc.h
index b82aa17d17bd2cf5cab2a63c6c1f8ce72260ded9..3d28023c44c144c45880222c4ce033caa4d6ef4e 100644
--- a/Solver/linearSystemPETSc.h
+++ b/Solver/linearSystemPETSc.h
@@ -84,7 +84,7 @@ class linearSystemPETSc : public linearSystem<scalar> {
   virtual void zeroSolution();
   virtual int systemSolve();
   Mat &getMatrix(){ return _a; }
-  std::vector<scalar> getData();
+  //std::vector<scalar> getData();
   std::vector<int> getRowPointers();
   std::vector<int> getColumnsIndices();
   #ifndef SWIG
@@ -122,6 +122,7 @@ class linearSystemPETScBlockDouble : public linearSystem<fullMatrix<double> > {
   double normInfRightHandSide() const;
   void insertInSparsityPattern (int i, int j);
   linearSystemPETScBlockDouble(bool sequential = false);
+  ~linearSystemPETScBlockDouble();
 };
 
 #else
diff --git a/Solver/linearSystemPETSc.hpp b/Solver/linearSystemPETSc.hpp
index 7922ec42bc003d701b05b50a9a762e6f7220bee1..ecafc8af35db1654467fee509ae5ed19cb919923 100644
--- a/Solver/linearSystemPETSc.hpp
+++ b/Solver/linearSystemPETSc.hpp
@@ -349,7 +349,7 @@ int linearSystemPETSc<scalar>::systemSolve()
   return 1;
 }
 
-template <class scalar>
+/*template <class scalar>
 std::vector<scalar> linearSystemPETSc<scalar>::getData()
 {
   _try(MatAssemblyBegin(_a, MAT_FINAL_ASSEMBLY));
@@ -369,15 +369,15 @@ std::vector<scalar> linearSystemPETSc<scalar>::getData()
 #endif
   _try(MatRestoreArray(_a,&v));
   return data;
-}
+}*/
 
 template <class scalar>
 std::vector<int> linearSystemPETSc<scalar>::getRowPointers()
 {
   _try(MatAssemblyBegin(_a, MAT_FINAL_ASSEMBLY));
   _try(MatAssemblyEnd(_a, MAT_FINAL_ASSEMBLY));
-  PetscInt *rows;
-  PetscInt *columns;
+  const PetscInt *rows;
+  const PetscInt *columns;
   PetscInt n;
   PetscTruth done;
   _try(MatGetRowIJ(_a,0,PETSC_FALSE,PETSC_FALSE,&n,&rows,&columns,&done));        //case done == PETSC_FALSE should be handled
@@ -393,8 +393,8 @@ std::vector<int> linearSystemPETSc<scalar>::getColumnsIndices()
 {
   _try(MatAssemblyBegin(_a, MAT_FINAL_ASSEMBLY));
   _try(MatAssemblyEnd(_a, MAT_FINAL_ASSEMBLY));
-  PetscInt *rows;
-  PetscInt *columns;
+  const PetscInt *rows;
+  const PetscInt *columns;
   PetscInt n;
   PetscTruth done;
   _try(MatGetRowIJ(_a,0,PETSC_FALSE,PETSC_FALSE,&n,&rows,&columns,&done));        //case done == PETSC_FALSE should be handled