diff --git a/src/implementation/mesh/tnlGrid2D_impl.h b/src/implementation/mesh/tnlGrid2D_impl.h
index 760c113d7bdb03e6b4d7efc409333650d6589419..0879688ebcb4852c2ba4031623fb492a8bdd0f67 100644
--- a/src/implementation/mesh/tnlGrid2D_impl.h
+++ b/src/implementation/mesh/tnlGrid2D_impl.h
@@ -201,7 +201,8 @@ Index tnlGrid< 2, Real, Device, Index, Geometry > :: getEdgeIndex( const Index i
    tnlAssert( dx == 0 && ( dy == 1 || dy == -1 ) ||
               dy == 0 && ( dx == 1 || dx == -1 ),
               cerr << "dx = " << dx << ", dy = " << dy << endl;);
-   return ( j + dy ) * this -> dimensions. x() + i + dx;
+   return ( j + 1 + dy ) * ( 2 * this -> dimensions. x() + 1 ) + i + dx;
+   //return j * ( 2 * this -> dimensions. x() + 1 ) + ( dy + 1 )
 }
 
 
@@ -221,13 +222,13 @@ void tnlGrid< 2, Real, Device, Index, Geometry > :: refresh()
       for( IndexType j = 1; j < dimensions. y() - 1; j ++ )
          for( IndexType i = 1; i < dimensions. x() - 1; i ++ )
          {
-            dualElementsMeasure[ getElementIndex( i + 1, j ) ] =
+            dualElementsMeasure[ getEdgeIndex( i, j,  1, 0 ) ] =
                      geometry. getDualElementMeasure<  1,  0 >( CoordinatesType( i, j ) );
-            dualElementsMeasure[ getElementIndex( i - 1, j ) ] =
+            dualElementsMeasure[ getEdgeIndex( i, j, -1, 0 ) ] =
                      geometry. getDualElementMeasure< -1,  0 >( CoordinatesType( i, j ) );
-            dualElementsMeasure[ getElementIndex( i, j + 1 ) ] =
+            dualElementsMeasure[ getEdgeIndex( i, j,  0,  1 ) ] =
                      geometry. getDualElementMeasure<  0,  1 >( CoordinatesType( i, j ) );
-            dualElementsMeasure[ getElementIndex( i, j - 1 ) ] =
+            dualElementsMeasure[ getEdgeIndex( i, j,  0, -1 ) ] =
                      geometry. getDualElementMeasure<  0, -1 >( CoordinatesType( i, j ) );
          }
 
diff --git a/src/matrix/tnlCSRMatrix.h b/src/matrix/tnlCSRMatrix.h
index 974fa7f0f973b01bf038750a75b504f2103a1c8f..bf694991b3b31332e7f00b1e7da0bd5e08fb2a40 100644
--- a/src/matrix/tnlCSRMatrix.h
+++ b/src/matrix/tnlCSRMatrix.h
@@ -226,6 +226,8 @@ class tnlCSRMatrix : public tnlMatrix< Real, Device, Index >
     */
    bool backwardSpMV;
 
+   template< typename, typename, typename >
+      friend class tnlCSRMatrix;
    friend class tnlMatrix< Real, tnlHost, Index >;
    friend class tnlMatrix< Real, tnlCuda, Index >;
    friend class tnlCusparseCSRMatrix< Real, tnlCuda, Index >;
@@ -662,7 +664,7 @@ bool tnlCSRMatrix< Real, Device, Index > :: performSORIteration( const Real& ome
          cerr << "There is zero on the diagonal in " << i << "-th row. I cannot perform SOR iteration." << endl;
          return false;
       }
-      x[ i ] = ( 1.0 - omega ) * x[ i ] + omega / diagonal * update;
+      x[ i ] = ( ( Real ) 1.0 - omega ) * x[ i ] + omega / diagonal * update;
    }
    return true;
 }