diff --git a/TODO.txt b/TODO.txt
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..76c317a4e0007dd82a008bb5e063716f7039c344 100644
--- a/TODO.txt
+++ b/TODO.txt
@@ -0,0 +1,13 @@
+TODO: implementovat tridu tnlFileName pro generovani jmen souboru
+
+TODO: implementovat tridu tnlParabolicSolver pro odvozovani resicu k casove promennym uloham
+
+TODO: Nahradit mGrid2D, mGrid3D za mGrid obecne dimenze
+
+TODO: zavets iteratory pres uzle site misto for cyklu
+
+TODO: implementovat Mersona v CUDA
+
+TODO: metoda Test do tnlObject
+
+TODO: trida tnlTester pro rizeni testu   
\ No newline at end of file
diff --git a/src/debug/tnlDebug.h b/src/debug/tnlDebug.h
index eb4a8bf6b22d63c4de4ff10d7d430d8d6e623634..eecdb0079cca4546e2f30e0c9347d1c97565ff09 100644
--- a/src/debug/tnlDebug.h
+++ b/src/debug/tnlDebug.h
@@ -2,7 +2,7 @@
                           tnlDebug.h  -  description
                              -------------------
     begin                : 2004/09/05
-    copyright            : (C) 2004 by Tom� Oberhuber
+    copyright            : (C) 2004 by Tom� Oberhuber
     email                : oberhuber@seznam.cz
  ***************************************************************************/
 
@@ -64,6 +64,16 @@ extern int __tnldbg_mpi_i_proc;
       << __LINE__ << " | " << #expr << " -> "                 \
       << expr << endl << flush;
 
+#define dbgCondExpr( condition, expr )         \
+   if( _tnldbg_debug_func( _tnldbg_debug_class_name,   \
+                       _tnldbg_debug_func_name ) )  \
+      if( condition )                            \
+         cout << "# MPI proc. " << __tnldbg_mpi_i_proc << " | "  \
+         << _tnldbg_debug_class_name << " :: " \
+         << _tnldbg_debug_func_name << " @ "        \
+         << __LINE__ << " | "                    \
+      << #expr << " -> " << expr << flush << endl;
+
 #else   // now non-MPI definitions
 
 #define dbgCout( args )                                      \
diff --git a/src/dist/Makefile.am b/src/dist/Makefile.am
index 5c19b6116451ab981a41a4e84c522a92ca5f68a3..b500da5eb3af8056fb4e0db3a15b2471a4c6b5f0 100644
--- a/src/dist/Makefile.am
+++ b/src/dist/Makefile.am
@@ -1,7 +1,6 @@
 ## Process this file with automake to produce Makefile.in
 
 headers = \
-   debug.h \
    direct.h \
    fmm2d.h \
    fsm2d.h \
diff --git a/src/dist/Makefile.in b/src/dist/Makefile.in
index 6caeedb08153829156f31f06ce27ef0fe7e540f6..6c0491ae35f8354d6d0ccccf0485be5b56f07758 100644
--- a/src/dist/Makefile.in
+++ b/src/dist/Makefile.in
@@ -69,9 +69,9 @@ libtnldist_dbg_0_1_la_LIBADD =
 am__libtnldist_dbg_0_1_la_SOURCES_DIST = direct.cpp fmm2d.cpp \
 	fsm2d.cpp ftm2d.cpp init_band.cpp iter1d.cpp iter2d.cpp \
 	iter3d.cpp param-crv-dst.cpp msdfSussmanFatemi.cpp \
-	msdfIterBase.cpp debug.h direct.h fmm2d.h fsm2d.h ftm2d.h \
-	init_band.h iter1d.h iter2d.h iter3d.h mdist.h mDistAux.h \
-	param-crv-dst.h msdfSussmanFatemi.h msdfIterBase.h
+	msdfIterBase.cpp direct.h fmm2d.h fsm2d.h ftm2d.h init_band.h \
+	iter1d.h iter2d.h iter3d.h mdist.h mDistAux.h param-crv-dst.h \
+	msdfSussmanFatemi.h msdfIterBase.h debug.h
 am__objects_3 = libtnldist_dbg_0_1_la-direct.lo \
 	libtnldist_dbg_0_1_la-fmm2d.lo libtnldist_dbg_0_1_la-fsm2d.lo \
 	libtnldist_dbg_0_1_la-ftm2d.lo \
@@ -94,9 +94,9 @@ libtnldist_mpi_0_1_la_LIBADD =
 am__libtnldist_mpi_0_1_la_SOURCES_DIST = direct.cpp fmm2d.cpp \
 	fsm2d.cpp ftm2d.cpp init_band.cpp iter1d.cpp iter2d.cpp \
 	iter3d.cpp param-crv-dst.cpp msdfSussmanFatemi.cpp \
-	msdfIterBase.cpp debug.h direct.h fmm2d.h fsm2d.h ftm2d.h \
-	init_band.h iter1d.h iter2d.h iter3d.h mdist.h mDistAux.h \
-	param-crv-dst.h msdfSussmanFatemi.h msdfIterBase.h
+	msdfIterBase.cpp direct.h fmm2d.h fsm2d.h ftm2d.h init_band.h \
+	iter1d.h iter2d.h iter3d.h mdist.h mDistAux.h param-crv-dst.h \
+	msdfSussmanFatemi.h msdfIterBase.h debug.h
 am__objects_4 = libtnldist_mpi_0_1_la-direct.lo \
 	libtnldist_mpi_0_1_la-fmm2d.lo libtnldist_mpi_0_1_la-fsm2d.lo \
 	libtnldist_mpi_0_1_la-ftm2d.lo \
@@ -119,9 +119,9 @@ libtnldist_mpi_dbg_0_1_la_LIBADD =
 am__libtnldist_mpi_dbg_0_1_la_SOURCES_DIST = direct.cpp fmm2d.cpp \
 	fsm2d.cpp ftm2d.cpp init_band.cpp iter1d.cpp iter2d.cpp \
 	iter3d.cpp param-crv-dst.cpp msdfSussmanFatemi.cpp \
-	msdfIterBase.cpp debug.h direct.h fmm2d.h fsm2d.h ftm2d.h \
-	init_band.h iter1d.h iter2d.h iter3d.h mdist.h mDistAux.h \
-	param-crv-dst.h msdfSussmanFatemi.h msdfIterBase.h
+	msdfIterBase.cpp direct.h fmm2d.h fsm2d.h ftm2d.h init_band.h \
+	iter1d.h iter2d.h iter3d.h mdist.h mDistAux.h param-crv-dst.h \
+	msdfSussmanFatemi.h msdfIterBase.h debug.h
 am__objects_5 = libtnldist_mpi_dbg_0_1_la-direct.lo \
 	libtnldist_mpi_dbg_0_1_la-fmm2d.lo \
 	libtnldist_mpi_dbg_0_1_la-fsm2d.lo \
@@ -322,7 +322,6 @@ top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 headers = \
-   debug.h \
    direct.h \
    fmm2d.h \
    fsm2d.h \
diff --git a/src/dist/debug.h b/src/dist/debug.h
deleted file mode 100644
index 3c7a829e7a2e2d02cdbf13cb9db6762f3c681a34..0000000000000000000000000000000000000000
--- a/src/dist/debug.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/***************************************************************************
-                          debug.h  -  description
-                             -------------------
-    begin                : 2005/07/02
-    copyright            : (C) 2005 by Tom� Oberhuber
-    email                : oberhuber@seznam.cz
- ***************************************************************************/
-
-/***************************************************************************
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- ***************************************************************************/
-
-#ifndef debugH
-#define debugH
-
-#include <config.h>
-
-#ifdef HAVE_POUND_H
-#include <pound.h>
-#else
-   #define dbgInit( file_name )
-   #define dbgFunctionName( _class, _func )
-   #define dbgCout( args )
-   #define DBG_PRINTF( expr )
-   #define dbgExpr( expr )
-   #define DBG_CALL( expr )
-   #define DBG_WAIT( )
-   #define DBG_COND_COUT( condition, args )
-   #define DBG_COND_PRINTF( condition, expr )
-   #define DBG_COND_EXPR( condition, expr )
-   #define DBG_COND_CALL( condition, expr )
-   #define DBG_COND_WAIT( condition )
-#endif
-
-#endif
diff --git a/src/dist/direct.cpp b/src/dist/direct.cpp
index 28302c0b6937cffe3f2a7f75199d38723b2b7934..7b55008b7db3d4075cf2e5b3fedb5af5cdbe1e1b 100644
--- a/src/dist/direct.cpp
+++ b/src/dist/direct.cpp
@@ -15,10 +15,14 @@
  *                                                                         *
  ***************************************************************************/
 
-#include <diff/mdiff.h>
-#include "debug.h"
+#include <math.h>
+
+#include <core/mfuncs.h>
+#include <debug/tnlDebug.h>
+
 #include "direct.h"
 
+
 //--------------------------------------------------------------------------
 static double SolvePoint( const double& a,
                           const double& b,
diff --git a/src/dist/direct.h b/src/dist/direct.h
index cff9250f5dd8578944040d464f65b7c5ff8f5ce5..e721b7e7e58a4602068d99452fdf89014765282d 100644
--- a/src/dist/direct.h
+++ b/src/dist/direct.h
@@ -18,7 +18,8 @@
 #ifndef directH
 #define directH
 
-#include <diff/mdiff.h>
+#include <diff/mGrid2D.h>
+
 
 enum mDstDirection { mDstSouth,
                      mDstNorth,
diff --git a/src/dist/fmm2d.cpp b/src/dist/fmm2d.cpp
index 32cb52fff6317d22d282685df80da0934e1e728a..b332f647e228ccae6c5927ea6051a14dac02e2f2 100644
--- a/src/dist/fmm2d.cpp
+++ b/src/dist/fmm2d.cpp
@@ -15,8 +15,11 @@
  *                                                                         *
  ***************************************************************************/
 
-#include <diff/mdiff.h>
-#include "debug.h"
+#include <debug/tnlDebug.h>
+#include <diff/mGrid2D.h>
+#include <core/mList.h>
+#include <core/mVector.h>
+#include <debug/tnlDebug.h>
 #include "direct.h"
 #include "fmm2d.h"
 #include "init_band.h"
@@ -147,7 +150,7 @@ void DstFastMarching2D( mGrid2D< double >& phi,
          }
       }
       //dbgExpr( smallest );
-      dbgExpr( phi( smallest. i, smallest. j ) );
+      dbgExpr( phi( smallest[ 0 ], smallest[ 1 ] ) );
       
       //Add( alive_points, smallest -> data );
       int s_i = smallest[ 0 ];
diff --git a/src/dist/fmm2d.h b/src/dist/fmm2d.h
index 8a251f01497c6642fc3d3cd5eaa3c3ce558a6a7b..cb55dfda4897483a208f76e58a95820ba8c2e1ae 100644
--- a/src/dist/fmm2d.h
+++ b/src/dist/fmm2d.h
@@ -18,7 +18,7 @@
 #ifndef fmm2dH
 #define fmm2dH
 
-#include <diff/mdiff.h>
+#include <diff/mGrid2D.h>
 
 void DstFastMarching2D( mGrid2D< double >& phi, 
                         const double& band_width,
diff --git a/src/dist/fsm2d.cpp b/src/dist/fsm2d.cpp
index 7450d0044ff8f39fbdc45e3308df64470f3bb382..b7dabdc673bb258d7116c767ff3289ec9006b198 100644
--- a/src/dist/fsm2d.cpp
+++ b/src/dist/fsm2d.cpp
@@ -16,7 +16,7 @@
  ***************************************************************************/
 
 #include <float.h>
-#include "debug.h"
+#include <debug/tnlDebug.h>
 #include "direct.h"
 #include "fsm2d.h"
 #include "init_band.h"
diff --git a/src/dist/fsm2d.h b/src/dist/fsm2d.h
index 8a7d19d7973f671b5d3a5d7da4a8b9c79ff5f2a6..8740c6e6621e3c43cdb643c7e63c9b1fd6726064 100644
--- a/src/dist/fsm2d.h
+++ b/src/dist/fsm2d.h
@@ -18,7 +18,7 @@
 #ifndef fsm2dH
 #define fsm2dH
 
-#include <diff/mdiff.h>
+#include <diff/mGrid2D.h>
 
 #define MDST_VERBOSE_ON true
 #define MDST_VERBOSE_OFF false
diff --git a/src/dist/ftm2d.cpp b/src/dist/ftm2d.cpp
index 401e0f6623ccf9400b329398a3c70d71b09b404d..6f61bad7c6333918507001f845bcbc7b21408217 100644
--- a/src/dist/ftm2d.cpp
+++ b/src/dist/ftm2d.cpp
@@ -16,12 +16,17 @@
  ***************************************************************************/
 
 #include <float.h>
-#include <diff/mdiff.h>
-#include "debug.h"
+#include <fstream>
+
+#include <diff/mGrid2D.h>
+#include <core/mVector.h>
+#include <debug/tnlDebug.h>
 #include "direct.h"
 #include "ftm2d.h"
 #include "init_band.h"
 
+using namespace std;
+
 //--------------------------------------------------------------------------
 void DrawStack( const mGrid2D< double >& phi, 
                 mVector< 2, int > * stack,
@@ -69,18 +74,18 @@ double UpdatePoint( mGrid2D< double >& phi,
       s = mDstTentative;
    if( j < y_size - 1 && in_stack( i, j + 1 ) != 0 )
       n = mDstTentative;
-   DBG_COND_EXPR( e == mDstTentative, e );
-   DBG_COND_EXPR( e == mDstTentative, phi( i + 1, j ) );
-   DBG_COND_EXPR( e == mDstTentative, in_stack( i + 1, j ) );
-   DBG_COND_EXPR( w == mDstTentative, w );
-   DBG_COND_EXPR( w == mDstTentative, phi( i - 1, j ) );
-   DBG_COND_EXPR( w == mDstTentative, in_stack( i - 1, j ) );
-   DBG_COND_EXPR( s == mDstTentative, s );
-   DBG_COND_EXPR( s == mDstTentative, phi( i, j - 1 ) );
-   DBG_COND_EXPR( s == mDstTentative, in_stack( i, j - 1 ) );
-   DBG_COND_EXPR( n == mDstTentative, n );
-   DBG_COND_EXPR( n == mDstTentative, phi( i, j + 1 ) );
-   DBG_COND_EXPR( n == mDstTentative, in_stack( i, j + 1 ) );
+   dbgCondExpr( e == mDstTentative, e );
+   dbgCondExpr( e == mDstTentative, phi( i + 1, j ) );
+   dbgCondExpr( e == mDstTentative, in_stack( i + 1, j ) );
+   dbgCondExpr( w == mDstTentative, w );
+   dbgCondExpr( w == mDstTentative, phi( i - 1, j ) );
+   dbgCondExpr( w == mDstTentative, in_stack( i - 1, j ) );
+   dbgCondExpr( s == mDstTentative, s );
+   dbgCondExpr( s == mDstTentative, phi( i, j - 1 ) );
+   dbgCondExpr( s == mDstTentative, in_stack( i, j - 1 ) );
+   dbgCondExpr( n == mDstTentative, n );
+   dbgCondExpr( n == mDstTentative, phi( i, j + 1 ) );
+   dbgCondExpr( n == mDstTentative, in_stack( i, j + 1 ) );
 
    double smallest( DBL_MAX );
    mDstDirection smallest_direction;
diff --git a/src/dist/init_band.cpp b/src/dist/init_band.cpp
index bca6f14c24fe0dfad665c08834ccb7fda659223c..0c58884e24992762c9c5ad2fcfcb2804d5b619df 100644
--- a/src/dist/init_band.cpp
+++ b/src/dist/init_band.cpp
@@ -15,9 +15,11 @@
  *                                                                         *
  ***************************************************************************/
 
-#include <diff/mdiff.h>
+#include <diff/mGrid2D.h>
+#include <core/mVector.h>
+#include <debug/tnlDebug.h>
 #include "init_band.h"
-#include "debug.h"
+
 
 //--------------------------------------------------------------------------
 static void AddCubes( int i, int j,
diff --git a/src/dist/init_band.h b/src/dist/init_band.h
index 52eb43838f57a9e1531790533f7bed021e6e293d..888ffb28e26ac62005ef6b853faa86629b3e9b12 100644
--- a/src/dist/init_band.h
+++ b/src/dist/init_band.h
@@ -18,7 +18,11 @@
 #ifndef init_bandH
 #define init_bandH
 
-#include <diff/mdiff.h>
+#include <math.h>
+
+#include <diff/mGrid2D.h>
+#include <core/mVector.h>
+#include <core/mfuncs.h>
 
 //! Cretes initial band along the curve given as a zero level set
 /*! Only points having a neighbour with different sign will be
diff --git a/src/dist/initial-condition.h b/src/dist/initial-condition.h
index 029bb17bf89d6c2a54adc555ccd49d62dcb6fdf0..cb8114f428048745196fc5edf299b297ba757e25 100644
--- a/src/dist/initial-condition.h
+++ b/src/dist/initial-condition.h
@@ -18,7 +18,8 @@
 #ifndef initial_conditionH
 #define initial_conditionH
 
-#include <diff/mdiff.h>
+#include <diff/mGrid2D.h>
+#include <core/mParameterContainer.h>
 
 bool GetInitialCondition( const mParameterContainer& parameters,
                           mGrid2D< double >*& u );
diff --git a/src/dist/iter1d.cpp b/src/dist/iter1d.cpp
index a1bb349823e342b7d2858993d326b18bd6890501..e1fcdfb87dfab848021db35e4b04ec59e22c5671 100644
--- a/src/dist/iter1d.cpp
+++ b/src/dist/iter1d.cpp
@@ -15,8 +15,8 @@
  *                                                                         *
  ***************************************************************************/
 
-#include <diff/mdiff.h>
-#include "debug.h"
+#include <diff/mGrid1D.h>
+#include <debug/tnlDebug.h>
 #include "iter1d.h"
 #include "mDistAux.h"
 
diff --git a/src/dist/iter1d.h b/src/dist/iter1d.h
index 6db42c6633ada3ff1e74ddbf23322793e48d2b53..9a36c41eccf07f8dfd0c00dd8b42072a67cd5099 100644
--- a/src/dist/iter1d.h
+++ b/src/dist/iter1d.h
@@ -18,7 +18,7 @@
 #ifndef iter1dH
 #define iter1dH
 
-#include <diff/mdiff.h>
+#include <diff/mGrid1D.h>
 
 
 //! Function computing right-hand side of the evolutionary equation
diff --git a/src/dist/iter2d.cpp b/src/dist/iter2d.cpp
index 25bd7545c049c3adacd850ce4355f613cc254440..e795252122172711f4798c714cc5293e8b2a4892 100644
--- a/src/dist/iter2d.cpp
+++ b/src/dist/iter2d.cpp
@@ -15,8 +15,8 @@
  *                                                                         *
  ***************************************************************************/
 
-#include <diff/mdiff.h>
-#include "debug.h"
+#include <diff/mGrid2D.h>
+#include <debug/tnlDebug.h>
 #include "iter1d.h"
 #include "mDistAux.h"
 
diff --git a/src/dist/iter2d.h b/src/dist/iter2d.h
index 1a7c9280eb201f07dbb9e859c276e7c2ff973f43..b989f81ff8efb931bb8cbeb011c7ab3f34f3237d 100644
--- a/src/dist/iter2d.h
+++ b/src/dist/iter2d.h
@@ -18,7 +18,7 @@
 #ifndef iter2dH
 #define iter2dH
 
-#include <diff/mdiff.h>
+#include <diff/mGrid2D.h>
 
 //! Function computing right-hand side of the evolutionary equation
 /*void mDstIter2D( const m_real& t,
diff --git a/src/dist/mDistAux.h b/src/dist/mDistAux.h
index 8506bad0d4f4935970481fa55d90194f00e58a90..d1008b60526f3a2ecfedb81fa7985d8bb5d404cb 100644
--- a/src/dist/mDistAux.h
+++ b/src/dist/mDistAux.h
@@ -18,8 +18,6 @@
 #ifndef mDistAuxH
 #define mDistAuxH
 
-#include <diff/mdiff.h>
-
 enum mDistIterMethod { mDstNone = 0,
                        mDstRegularisedScheme,
                        mDstUpwindScheme,
diff --git a/src/dist/main.cpp b/src/dist/main.cpp
index 04bb83e33739bfb59231dda7678c782be897dfc2..8ceb2f576990dc4b9b918049e8d998dfea46c4c2 100644
--- a/src/dist/main.cpp
+++ b/src/dist/main.cpp
@@ -15,7 +15,8 @@
  *                                                                         *
  ***************************************************************************/
 
-#include <diff/mdiff.h>
+#include <core/mConfig.h>
+#include <debug/tnlDebug.h>
 
 //--------------------------------------------------------------------------
 m_bool GetConfiguration( mConfig& config, 
diff --git a/src/dist/mdist-test.cpp b/src/dist/mdist-test.cpp
index ed9731ddbeb29b4a16a5b29df6096fecf59d42c4..b72b52aeaa63f87f95d16de893eaeb4b8899a3f8 100644
--- a/src/dist/mdist-test.cpp
+++ b/src/dist/mdist-test.cpp
@@ -15,9 +15,9 @@
  *                                                                         *
  ***************************************************************************/
 
-//--------------------------------------------------------------------------
-#include <diff/mdiff.h>
-#include "debug.h"
+#include <core/mCurve.h>
+#include <diff/mGrid2D.h>
+#include <debug/tnlDebug.h>
 #include "mdist.h"
 
 void ParamCircle( const double& t, void* crv_data, double& x, double& y )
diff --git a/src/dist/mdist.cpp b/src/dist/mdist.cpp
index d15f4b752f30aca91404e249d090f8d2c6e63d9c..1c06577cbfa40112570d1f4446e8ec4026f1ddec 100644
--- a/src/dist/mdist.cpp
+++ b/src/dist/mdist.cpp
@@ -15,14 +15,7 @@
  *                                                                         *
  ***************************************************************************/
 
-#include <diff/mdiff.h>
-#include "lib/iter1d.h"
-#include "lib/iter2d.h"
-#include "lib/iter3d.h"
-#include "lib/fmm2d.h"
-#include "lib/fsm2d.h"
-#include "lib/ftm2d.h"
-#include "lib/debug.h"
+#include <debug/tnlDebug.h>
 
 m_bool CheckParameters( mConfig& config )
 {
diff --git a/src/dist/msdfIterBase.cpp b/src/dist/msdfIterBase.cpp
index b564799ec2d5eb509c78d653d115f54a4c26a552..8906cb67d0f4e4ed05ca7a3597addc27375584f3 100644
--- a/src/dist/msdfIterBase.cpp
+++ b/src/dist/msdfIterBase.cpp
@@ -16,6 +16,13 @@
  ***************************************************************************/
 
 #include "msdfIterBase.h"
+#include <core/mCurve.h>
+#include <core/mfuncs.h>
+#include <core/mfilename.h>
+#include <diff/drawGrid2D.h>
+#include <diff/mExplicitSolver.h>
+#include <diff/curve-ident.h>
+
 
 //--------------------------------------------------------------------------
 msdfIterBase :: msdfIterBase()
diff --git a/src/dist/msdfIterBase.h b/src/dist/msdfIterBase.h
index 6091072d537bd158edcd2064b76aab8b890248df..34e2aa93b6a067071568bda4a14d436df202ed5e 100644
--- a/src/dist/msdfIterBase.h
+++ b/src/dist/msdfIterBase.h
@@ -18,7 +18,10 @@
 #ifndef msdfIterBaseH
 #define msdfIterBaseH
 
-#include<diff/mdiff.h>
+#include <diff/mGrid2D.h>
+#include <core/mParameterContainer.h>
+
+template< class GRID, class SCHEME, typename T > class mExplicitSolver;
 
 class msdfIterBase 
 {
diff --git a/src/dist/msdfSussmanFatemi.cpp b/src/dist/msdfSussmanFatemi.cpp
index f866981d612a29f0ea971af8c0380c57c952c988..decf8dd28723df679ed26490628f528626538907 100644
--- a/src/dist/msdfSussmanFatemi.cpp
+++ b/src/dist/msdfSussmanFatemi.cpp
@@ -15,10 +15,15 @@
  *                                                                         *
  ***************************************************************************/
 
-#include <config.h>
 #include "msdfSussmanFatemi.h"
 
+#include <config.h>
 #include <float.h>
+#include <math.h>
+#include <core/mfuncs.h>
+#include <diff/mEulerSolver.h>
+#include <diff/mMersonSolver.h>
+#include <diff/mNonlinearRungeKuttaSolver.h>
 
 //--------------------------------------------------------------------------
 msdfSussmanFatemi :: msdfSussmanFatemi()
diff --git a/src/dist/msdfSussmanFatemi.h b/src/dist/msdfSussmanFatemi.h
index 7e893ca05f9dff88968c820f1f73de894022e8e0..064bedc5ac35d6244422374c38d374876a54f533 100644
--- a/src/dist/msdfSussmanFatemi.h
+++ b/src/dist/msdfSussmanFatemi.h
@@ -18,7 +18,8 @@
 #ifndef msdfSussmanFatemiH
 #define msdfSussmanFatemiH
 
-#include <diff/mdiff.h>
+#include <diff/mGrid2D.h>
+#include <core/mParameterContainer.h>
 #include "msdfIterBase.h"
 
 class msdfSussmanFatemi : public msdfIterBase
diff --git a/src/dist/param-crv-dst.cpp b/src/dist/param-crv-dst.cpp
index 763d6d3a8fee60b23d541dd02941dc51ab7d4ea7..2ec608038d6acb1312ef9e5056faa2cc36c48563 100644
--- a/src/dist/param-crv-dst.cpp
+++ b/src/dist/param-crv-dst.cpp
@@ -15,11 +15,15 @@
  *                                                                         *
  ***************************************************************************/
 
+#include "param-crv-dst.h"
+
 #include <math.h>
 #include <float.h>
-#include "debug.h"
+
+#include <debug/tnlDebug.h>
+#include <core/mfuncs.h>
 #include "fsm2d.h"
-#include "param-crv-dst.h"
+
 
 //--------------------------------------------------------------------------
 mLevelSetCreator :: mLevelSetCreator()
diff --git a/src/dist/param-crv-dst.h b/src/dist/param-crv-dst.h
index 259be58c98bdf8ab612db37ecad88a5cf9b20a6c..5d3adee5fdff0ac7e34a28865d283653a9749e0d 100644
--- a/src/dist/param-crv-dst.h
+++ b/src/dist/param-crv-dst.h
@@ -18,7 +18,7 @@
 #ifndef param_crv_dstH
 #define param_crv_dstH
 
-#include <diff/mdiff.h>
+#include <diff/mGrid2D.h>
 
 class mLevelSetCreator
 {
diff --git a/src/dist/sdf-restore.cpp b/src/dist/sdf-restore.cpp
index 8ef4ecfb81459a62bb80be5267809f95868a2e84..f52ed66a98c28e1d543744cf8beb7c8c0ea788b9 100644
--- a/src/dist/sdf-restore.cpp
+++ b/src/dist/sdf-restore.cpp
@@ -18,7 +18,10 @@
 //--------------------------------------------------------------------------
 #include <sys/utsname.h>
 #include <time.h>
-#include <diff/mdiff.h>
+#include <core/mParameterContainer.h>
+#include <core/mLogger.h>
+
+
 #include "debug.h"
 #include "mdist.h"
 #include "sdf-restore-def.h"
diff --git a/tools/src/bin2gnuplot.cpp b/tools/src/bin2gnuplot.cpp
index 610a9c7d9887b7e66e61ccc078b567fd240680a7..902e546f1e84ad624161b7f90a5b683eec6636f0 100644
--- a/tools/src/bin2gnuplot.cpp
+++ b/tools/src/bin2gnuplot.cpp
@@ -16,7 +16,7 @@
  ***************************************************************************/
 
 #include <fstream>
-#include <diff/mdiff.h>
+#include <diff/mGrid2D.h>
 #include <stdio.h>
 
 //--------------------------------------------------------------------------
diff --git a/tools/src/compare-objects.cpp b/tools/src/compare-objects.cpp
index a78999602a41d4417347a8469e530e7e596ddf0a..fb36709cbbf759603d57f6596fbf24b99e78da81 100644
--- a/tools/src/compare-objects.cpp
+++ b/tools/src/compare-objects.cpp
@@ -17,6 +17,9 @@
 
 #include "compare-objects.h"
 
+#include <math.h>
+#include <core/mfuncs.h>
+
 //--------------------------------------------------------------------------
 bool Compare( const mGrid2D< double >& u1,
               const mGrid2D< double >& u2,
diff --git a/tools/src/compare-objects.h b/tools/src/compare-objects.h
index ee8302432cf62dad120b703ec43a665d3d70b159..0fd244669253df84952c69e617de81dd61dc6f79 100644
--- a/tools/src/compare-objects.h
+++ b/tools/src/compare-objects.h
@@ -18,7 +18,8 @@
 #ifndef compare_objetsH
 #define compare_objetsH
 
-#include <diff/mdiff.h>
+#include <diff/mGrid2D.h>
+#include <diff/mGrid3D.h>
 
 bool Compare( const mGrid2D< double >& u1,
               const mGrid2D< double >& u2,
diff --git a/tools/src/diff-norm.cpp b/tools/src/diff-norm.cpp
index 905f0efad44e8b3b2da3a4cb124607a9326adc49..f32821ed4b87a1f52a39f432d355d649d3c0cde3 100644
--- a/tools/src/diff-norm.cpp
+++ b/tools/src/diff-norm.cpp
@@ -16,7 +16,7 @@
  ***************************************************************************/
 
 #include <fstream>
-#include <diff/mdiff.h>
+#include <diff/mGrid2D.h>
 #include <stdio.h>
 
 bool ReadInputFile( const char* file_name, 
diff --git a/tools/src/mcurve2gnuplot.cpp b/tools/src/mcurve2gnuplot.cpp
index 1609f6f9c5e1530c536c1b4e340c70f792cb0b7d..236696cc39478d163acd7aa967e9492a7eb31b7c 100644
--- a/tools/src/mcurve2gnuplot.cpp
+++ b/tools/src/mcurve2gnuplot.cpp
@@ -15,8 +15,12 @@
  *                                                                         *
  ***************************************************************************/
 
-#include <diff/mdiff.h>
 #include "mcurve2gnuplot-def.h"
+#include <core/mParameterContainer.h>
+#include <core/compress-file.h>
+#include <core/mCurve.h>
+#include <core/mVector.h>
+
 
 //--------------------------------------------------------------------------
 int main( int argc, char* argv[] )
diff --git a/tools/src/mdiff-err-norms.cpp b/tools/src/mdiff-err-norms.cpp
index 02eb8d6287a2df7a8259fa2168ecff6cf0c98432..d795223378d777bf8d8fc4141cbd673bcc0d0b3e 100644
--- a/tools/src/mdiff-err-norms.cpp
+++ b/tools/src/mdiff-err-norms.cpp
@@ -15,10 +15,19 @@
  *                                                                         *
  ***************************************************************************/
 
-#include <debug/tnlDebug.h>
-#include <diff/mdiff.h>
 #include <fstream>
 #include <stdio.h>
+#include <math.h>
+
+#include <debug/tnlDebug.h>
+#include <diff/mGrid1D.h>
+#include <diff/mGrid2D.h>
+#include <diff/drawGrid1D.h>
+#include <diff/drawGrid2D.h>
+#include <core/mConfigDescription.h>
+#include <core/mParameterContainer.h>
+#include <core/mCurve.h>
+
 #include "../../mdiff-err-norms-def.h"
 #include "read-file.h"
 #include "compare-objects.h"
@@ -129,6 +138,7 @@ bool TryCompressFile( const char* file_name,
       cerr << "Unable to compress back the file " << file_name << "." << endl;
       return false;
    }
+   return true;
 }
 //--------------------------------------------------------------------------
 int main( int argc, char* argv[] )
diff --git a/tools/src/mgrid-view.cpp b/tools/src/mgrid-view.cpp
index f880d13ba242924f679187411624f7477378e9ea..524a8753221b76107ba93d75aafc70cea16a867a 100644
--- a/tools/src/mgrid-view.cpp
+++ b/tools/src/mgrid-view.cpp
@@ -15,9 +15,16 @@
  *                                                                         *
  ***************************************************************************/
 
-#include <diff/mdiff.h>
 #include "mgrid-view-def.h"
 
+#include <core/compress-file.h>
+#include <core/mCurve.h>
+#include <core/mConfigDescription.h>
+#include <core/mParameterContainer.h>
+#include <diff/curve-ident.h>
+#include <diff/drawGrid2D.h>
+#include <diff/drawGrid3D.h>
+
 bool ProcessmGrid2D( const mString& file_name, 
                      const mParameterContainer& parameters,
                      int file_index,
diff --git a/tools/src/mgrid2gnuplot.cpp b/tools/src/mgrid2gnuplot.cpp
index 1ba791df13ca37915baa52383fd06663c7f7e40a..781bcda2a4af16a50da7ef8e1c2ea9d944038844 100644
--- a/tools/src/mgrid2gnuplot.cpp
+++ b/tools/src/mgrid2gnuplot.cpp
@@ -15,9 +15,12 @@
  *                                                                         *
  ***************************************************************************/
 
-#include <diff/mdiff.h>
 #include "mgrid2gnuplot-def.h"
 
+#include <diff/mGrid2D.h>
+#include <core/mParameterContainer.h>
+
+
 //--------------------------------------------------------------------------
 int main( int argc, char* argv[] )
 {
diff --git a/tools/src/read-file.h b/tools/src/read-file.h
index 1362dae1b84dd5963e41650366a8713b6d516800..29bdc7af1a165bd2c7c2ae6c4646f76c1d57796b 100644
--- a/tools/src/read-file.h
+++ b/tools/src/read-file.h
@@ -19,7 +19,7 @@
 #define read_fileH
 
 
-#include <diff/mdiff.h>
+#include <core/compress-file.h>
 
 template< class T > bool ReadFile( const char* input_file, T& u )
 {