diff --git a/MathLib/LinAlg/LinAlg.h b/MathLib/LinAlg/LinAlg.h
index 154d8b45a80118f40162828c2477f9a3715927d0..8577adf1d4e6a879830cf9998b29fd5b1de4d570 100644
--- a/MathLib/LinAlg/LinAlg.h
+++ b/MathLib/LinAlg/LinAlg.h
@@ -213,7 +213,7 @@ namespace LinAlg
 /**
     Set local accessible vector in order to get entries. Call this
     before call operator[] or get(...) of x.
-    The function only has computation if DDC is appied,
+    The function only has computation if DDC is enabled,
     e.g. parallel computing. Up to now, Eigen vector is not used for
     global vectors in parallel computing. Therefore this function is
     empty in the current status.
diff --git a/MathLib/LinAlg/PETSc/PETScVector.cpp b/MathLib/LinAlg/PETSc/PETScVector.cpp
index 0ef9641355cd7f7df3fd309c657471c946600df0..12e1a2b10e109965edfed5965cb456dddb26dcc3 100644
--- a/MathLib/LinAlg/PETSc/PETScVector.cpp
+++ b/MathLib/LinAlg/PETSc/PETScVector.cpp
@@ -66,8 +66,8 @@ PETScVector::PETScVector(const PetscInt vec_size,
     config();
 
     for (PetscInt i=0; i<nghosts; i++)
-        _global_ids2local_ids_ghost.insert
-        (std::make_pair(ghost_ids[i], _size_loc + i));
+        _global_ids2local_ids_ghost.emplace(ghost_ids[i],
+                                            _size_loc + i);
 }
 
 PETScVector::PETScVector(const PETScVector &existing_vec, const bool deep_copy)
@@ -146,10 +146,12 @@ void PETScVector::getGlobalVector(std::vector<PetscScalar>& u) const
     PetscMemoryGetCurrentUsage(&mem1);
 #endif
 
+    assert(u.size() == _size);
+
     PetscScalar *xp = nullptr;
     VecGetArray(_v, &xp);
 
-    gatherLocalVectors(xp, &u[0]);
+    gatherLocalVectors(xp, u.data());
 
     //This following line may be needed late on
     //  for a communication load balance:
@@ -166,17 +168,17 @@ void PETScVector::getGlobalVector(std::vector<PetscScalar>& u) const
 
 void PETScVector::setLocalAccessibleVector() const
 {
-    if (_entry_array.size() == 0)
+    if (_entry_array.empty())
     {
         const PetscInt array_size
             = _global_ids2local_ids_ghost.size() > 0 ?
-              _size_loc + _size_ghosts: _size;
+                      _size_loc + _size_ghosts: _size;
         _entry_array.resize(array_size);
     }
 
-    if (_global_ids2local_ids_ghost.size() > 0)
+    if ( !_global_ids2local_ids_ghost.empty() )
     {
-        double* loc_x = getLocalVector();
+        PetscScalar* loc_x = getLocalVector();
         std::copy_n(loc_x, _size_loc + _size_ghosts,
                     _entry_array.begin());
         restoreArray(loc_x);
@@ -185,11 +187,11 @@ void PETScVector::setLocalAccessibleVector() const
         getGlobalVector(_entry_array);
 }
 
-void PETScVector::copyValues(std::vector<double>& u) const
+void PETScVector::copyValues(std::vector<PetscScalar>& u) const
 {
     assert(u.size() == (std::size_t) (getLocalSize() + getGhostSize()));
 
-    double* loc_x = getLocalVector();
+    PetscScalar* loc_x = getLocalVector();
     std::copy_n(loc_x, getLocalSize() + getGhostSize(), u.begin());
     restoreArray(loc_x);
 }
@@ -207,9 +209,9 @@ PetscScalar PETScVector::get(const PetscInt idx) const
 }
 
 
-std::vector<double> PETScVector::get(std::vector<IndexType> const& indices) const
+std::vector<PetscScalar> PETScVector::get(std::vector<IndexType> const& indices) const
 {
-    std::vector<double> local_x(indices.size());
+    std::vector<PetscScalar> local_x(indices.size());
     // If VecGetValues can get values from different processors,
     // use VecGetValues(_v, indices.size(), indices.data(),
     //                    local_x.data());
diff --git a/MathLib/LinAlg/PETSc/PETScVector.h b/MathLib/LinAlg/PETSc/PETScVector.h
index 706377cfa4d4d5af9fc2d21608253d2edf671638..bb5193109d521e3a668c5c0339ca03f7e39ab9c0 100644
--- a/MathLib/LinAlg/PETSc/PETScVector.h
+++ b/MathLib/LinAlg/PETSc/PETScVector.h
@@ -170,11 +170,11 @@ class PETScVector
 
         /// Get several entries. setLocalAccessibleVector() must be
         /// called beforehand.
-        std::vector<double> get(std::vector<IndexType> const& indices) const;
+        std::vector<PetscScalar> get(std::vector<IndexType> const& indices) const;
 
         /// Get the value of an entry by [] operator.
         /// setLocalAccessibleVector() must be called beforehand.
-        double operator[] (PetscInt idx) const
+        PetscScalar operator[] (PetscInt idx) const
         {
             return get(idx);
         }
@@ -207,7 +207,7 @@ class PETScVector
            Copy local entries including ghost ones to an array
            \param u Preallocated vector for the values of local entries.
         */
-        void copyValues(std::vector<double>& u) const;
+        void copyValues(std::vector<PetscScalar>& u) const;
 
         /*! View the global vector for test purpose. Do not use it for output a big vector.
             \param file_name  File name for output
diff --git a/NumLib/DOF/MeshComponentMap.cpp b/NumLib/DOF/MeshComponentMap.cpp
index c9be0069205f1c602c74e2cf08106a1e6a9c8aad..a365bffd7bf742bacd5883cf0e9bcdc81df08872 100644
--- a/NumLib/DOF/MeshComponentMap.cpp
+++ b/NumLib/DOF/MeshComponentMap.cpp
@@ -71,12 +71,7 @@ MeshComponentMap::MeshComponentMap(
             for (std::size_t j = 0; j < mesh_subset.getNumberOfNodes(); j++)
             {
                 GlobalIndexType global_id = 0;
-                if (order == ComponentOrder::BY_LOCATION)
-                {
-                    global_id = static_cast<GlobalIndexType>(
-                        components.size() * mesh.getGlobalNodeID(j) + comp_id);
-                }
-                else
+                if (order != ComponentOrder::BY_LOCATION)
                 {
                     // Deactivated since this case is not suitable to
                     // arrange non ghost entries of a partition within
@@ -85,6 +80,9 @@ MeshComponentMap::MeshComponentMap(
                               " can only be numbered by the oder type"
                               " of ComponentOrder::BY_LOCATION");
                 }
+                global_id = static_cast<GlobalIndexType>(
+                    components.size() * mesh.getGlobalNodeID(j)
+                        + comp_id);
                 const bool is_ghost =
                     mesh.isGhostNode(mesh.getNode(j)->getID());
                 if (is_ghost)
diff --git a/ProcessLib/GlobalVectorFromNamedFunction.cpp b/ProcessLib/GlobalVectorFromNamedFunction.cpp
index a0d3519e5b3c5877cd9caf9b51270de64e67b8bc..82020a384e3361a22acf8eed09bd3cee2ee338d2 100644
--- a/ProcessLib/GlobalVectorFromNamedFunction.cpp
+++ b/ProcessLib/GlobalVectorFromNamedFunction.cpp
@@ -54,7 +54,6 @@ GlobalVector const& GlobalVectorFromNamedFunction::call(
         _context.index = node_id;
         auto const value = _function_caller.call(args);
 
-        // Problems with PETSc also uses global index.
         result->set(node_id, value);
     }