Added guard for PETSc related calls