diff --git a/Geo/MElement.cpp b/Geo/MElement.cpp
index ec9fc2202f87c62d52594e4e963c591b5236cb55..592c9c223f5e56141cec4dd8e84c58782d95c1de 100644
--- a/Geo/MElement.cpp
+++ b/Geo/MElement.cpp
@@ -780,9 +780,9 @@ void MElement::xyz2uvw(double xyz[3], double uvw[3]) const
     }
     const nodalBasis *nb = getFunctionSpace();
     fullMatrix<double> refpnts = nb->getReferenceNodes();
-    uvw[0] = refpnts(numNearer, 0);
-    uvw[1] = refpnts(numNearer, 1);
-    uvw[2] = refpnts(numNearer, 2);
+    for (int i=0; i < getDim(); i++){
+      uvw[i] = refpnts(numNearer, i);
+    }
   }
 
   int iter = 1, maxiter = 20;
diff --git a/Solver/linearSystemPETSc.h b/Solver/linearSystemPETSc.h
index 19cc01ad7e0c172701460f2e57eabc09225822ac..0575c5174ede73a51b6ab1fd69fd5d859629ce1d 100644
--- a/Solver/linearSystemPETSc.h
+++ b/Solver/linearSystemPETSc.h
@@ -76,6 +76,13 @@ typedef struct _p_KSP* KSP;
 # define KSPSetOperators(_ksp, _a, _b, OPT_PRECON) (KSPSetOperators(_ksp, _a, _b), KSPSetReusePreconditioner(_ksp,PetscBool(OPT_PRECON == SAME_PRECONDITIONER)))
 #endif
 
+// Deprecated method PetscViewerSetFormat starts 3.7 the only instance we use
+// can be replaced by PetscViewerPushFormat as we do not change the format of the same viewer
+// in such a case PetscViewerPopFormat should be used and the following will not work
+#if (PETSC_VERSION_MAJOR < 3  || (PETSC_VERSION_MAJOR == 3 && PETSC_VERSION_MINOR < 7))
+#define PetscViewerPushFormat(viewer , format) PetscViewerSetFormat(viewer , format)
+#endif
+
 template <class scalar>
 class linearSystemPETSc : public linearSystem<scalar> {
   protected:
diff --git a/Solver/linearSystemPETSc.hpp b/Solver/linearSystemPETSc.hpp
index 289a0cbfbeadb86ee356f992a2b5c760ce90487f..818e730ba56ebf3e897028d4a489458931f1e703 100644
--- a/Solver/linearSystemPETSc.hpp
+++ b/Solver/linearSystemPETSc.hpp
@@ -413,7 +413,7 @@ void linearSystemPETSc<scalar>::printMatlab(const char *filename) const
 
   PetscViewer viewer;
   PetscViewerASCIIOpen(PETSC_COMM_WORLD, filename, &viewer);
-  PetscViewerSetFormat(viewer,PETSC_VIEWER_ASCII_MATLAB);
+  PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_MATLAB);
   MatView(_a, viewer);
   PetscViewerDestroy(&viewer);
   return;