diff --git a/BaseLib/CMakeLists.txt b/BaseLib/CMakeLists.txt
index 580ba36bd62c6a6625b7182f9e7e693aba6d0ce5..d20311172ce30fd47ba0f9a388dd6df0393f1b8a 100644
--- a/BaseLib/CMakeLists.txt
+++ b/BaseLib/CMakeLists.txt
@@ -8,9 +8,8 @@ ADD_LIBRARY( BaseLib STATIC ${SOURCES})
 SET_TARGET_PROPERTIES(BaseLib PROPERTIES LINKER_LANGUAGE CXX)
 
 INCLUDE_DIRECTORIES(
-	${CMAKE_SOURCE_DIR}/GeoLib
-	${CMAKE_SOURCE_DIR}/MathLib
 	.
+	zlib
 )
 
 # Add logog subdirectory and group its targets in a Visual Studio folder
diff --git a/BaseLib/CodingTools.h b/BaseLib/CodingTools.h
new file mode 100644
index 0000000000000000000000000000000000000000..7e22f41757da9412ae5c46756c2817a6fcc81c59
--- /dev/null
+++ b/BaseLib/CodingTools.h
@@ -0,0 +1,20 @@
+/**
+ * Copyright (c) 2012, OpenGeoSys Community (http://www.opengeosys.org)
+ *            Distributed under a Modified BSD License.
+ *              See accompanying file LICENSE.txt or
+ *              http://www.opengeosys.org/project/license
+ *
+ *
+ * \file CodingTools.h
+ *
+ * Created on 2012-02-17 by Norihiro Watanabe
+ */
+
+#ifndef CODINGTOOLS_H
+#define CODINGTOOLS_H
+
+#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
+    TypeName(const TypeName&);   \
+    TypeName &operator=(const TypeName&)
+
+#endif
diff --git a/BaseLib/DateTools.cpp b/BaseLib/DateTools.cpp
index 275696f798f22218d2993a07b09569f820d64e2b..d2850d556848069e842d6081c4b97a19c5119ca6 100644
--- a/BaseLib/DateTools.cpp
+++ b/BaseLib/DateTools.cpp
@@ -71,13 +71,13 @@ std::string date2string(double ddate)
 	if (d < 1 || d > 31)
 		std::cout << "Warning: date2String() -- day not in [1:31]" << std::endl;
 
-	std::string day = number2str(d);
+	std::string day = BaseLib::number2str(d);
 	if (d < 10)
 		day = "0" + day;
-	std::string month = number2str(m);
+	std::string month = BaseLib::number2str(m);
 	if (m < 10)
 		month = "0" + month;
-	std::string s =  number2str(y) + "-" + month + "-" + day;
+	std::string s =  BaseLib::number2str(y) + "-" + month + "-" + day;
 	return s;
 }
 
diff --git a/BaseLib/FileTools.cpp b/BaseLib/FileTools.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..bbf7f4b14de1238180b615d1dd50c1cfdff9e788
--- /dev/null
+++ b/BaseLib/FileTools.cpp
@@ -0,0 +1,115 @@
+/**
+ * Copyright (c) 2012, OpenGeoSys Community (http://www.opengeosys.org)
+ *            Distributed under a Modified BSD License.
+ *              See accompanying file LICENSE.txt or
+ *              http://www.opengeosys.org/project/license
+ *
+ *
+ * \file FileTools.cpp
+ *
+ * Created on 2010-04-26 by Lars Bilke
+ *
+ */
+
+#include "FileTools.h"
+
+#include <sys/stat.h>
+
+namespace BaseLib
+{
+
+/**
+ * Returns true if given file exists. From http://www.techbytes.ca/techbyte103.html
+ */
+bool IsFileExisting(const std::string &strFilename)
+{
+	struct stat stFileInfo;
+	bool blnReturn;
+	int intStat;
+
+	// Attempt to get the file attributes
+	intStat = stat(strFilename.c_str(),&stFileInfo);
+
+	if(intStat == 0)
+	{
+		// We were able to get the file attributes
+		// so the file obviously exists.
+		blnReturn = true;
+	}
+	else
+	{
+		// We were not able to get the file attributes.
+		// This may mean that we don't have permission to
+		// access the folder which contains this file. If you
+		// need to do that level of checking, lookup the
+		// return values of stat which will give you
+		// more details on why stat failed.
+		blnReturn = false;
+	}
+
+	return(blnReturn);
+}
+
+/**
+ * \brief truncate a file
+ */
+void truncateFile( std::string const& filename)
+{
+    std::ofstream ofs(filename.c_str(), std::ios_base::trunc);
+    ofs.close();
+}
+
+std::string getFileNameFromPath(const std::string &str, bool with_extension)
+{
+	std::string::size_type beg1 = str.find_last_of('/');
+	std::string::size_type beg2 = str.find_last_of('\\');
+	std::string::size_type beg;
+	if (beg1 == std::string::npos && beg2 == std::string::npos) beg = -1;
+	else if (beg1 == std::string::npos) beg = beg2;
+	else if (beg2 == std::string::npos) beg = beg1;
+	else beg = (beg1<beg2) ? beg2 : beg1;
+	std::string file ( str.substr(beg+1) );
+	if (with_extension) return file;
+	// cut extension
+	std::string::size_type end  = file.find_last_of('.');
+	return file.substr(0,end);
+}
+
+std::string getSuffixFromPath(const std::string &str)
+{
+	std::string::size_type beg(str.find_last_of('.'));
+	return str.substr(beg+1, str.length()-beg-1);
+}
+
+std::string copyPathToFileName(const std::string &file_name, const std::string &source)
+{
+	// check if file_name already contains a full path
+	size_t pos(file_name.rfind("/")); // linux, mac delimiter
+	if (pos == std::string::npos)
+	{
+		pos = file_name.rfind("\\"); // windows delimiter
+		if (pos == std::string::npos)
+		{
+			std::string path;
+			BaseLib::extractPath(source, path);
+			return path.append(file_name);
+		}
+		else return std::string(file_name);
+	}
+	else return std::string(file_name);
+}
+
+void extractPath(std::string const& fname, std::string& path)
+{
+	// extract path for reading external files
+	size_t pos(fname.rfind("/")); // linux, mac delimiter
+	if (pos == std::string::npos) {
+		pos = fname.rfind("\\"); // windows delimiter
+		if (pos == std::string::npos)
+			pos = 0;
+	}
+	path = fname.substr(0, pos==0 ? pos : pos + 1);
+}
+
+} // end namespace BaseLib
+
diff --git a/BaseLib/FileTools.h b/BaseLib/FileTools.h
index 83ad6e7210a5088ac6cbd58dc7ccb3bd289ba37f..2649ac0f81f59f9afbbd5f7c0e43ea45e0d743ed 100644
--- a/BaseLib/FileTools.h
+++ b/BaseLib/FileTools.h
@@ -15,42 +15,60 @@
 #ifndef FILETOOLS_H
 #define FILETOOLS_H
 
-// ** INCLUDES **
-#include <sys/stat.h>
+#include <string>
+#include <fstream>
+
+namespace BaseLib
+{
+
+/**
+ * \brief Returns true if given file exists. From http://www.techbytes.ca/techbyte103.html
+ *
+ * \param strFilename         the file name
+ */
+bool IsFileExisting(const std::string &strFilename);
 
-namespace BaseLib {
 /**
- * Returns true if given file exists. From http://www.techbytes.ca/techbyte103.html
+ * \brief write value as binary into the given output stream
+ *
+ * \param T    data type of the value
+ * \param out   output stream, have to be opened in binary mode
+ * \param val   value
  */
-bool IsFileExisting(std::string strFilename)
+template <typename T> void writeValueBinary(std::ostream &out, T const& val)
 {
-	struct stat stFileInfo;
-	bool blnReturn;
-	int intStat;
-
-	// Attempt to get the file attributes
-	intStat = stat(strFilename.c_str(),&stFileInfo);
-
-	if(intStat == 0)
-	{
-		// We were able to get the file attributes
-		// so the file obviously exists.
-		blnReturn = true;
-	}
-	else
-	{
-		// We were not able to get the file attributes.
-		// This may mean that we don't have permission to
-		// access the folder which contains this file. If you
-		// need to do that level of checking, lookup the
-		// return values of stat which will give you
-		// more details on why stat failed.
-		blnReturn = false;
-	}
-
-	return(blnReturn);
+    out.write((const char*)&val, sizeof(T));
 }
 
+/**
+ * \brief truncate a file
+ *
+ * \param file_path         the file name
+ */
+void truncateFile( std::string const& file_path);
+
+/**
+ * Extract the filename from a path
+ */
+std::string getFileNameFromPath(const std::string &str, bool with_extension = false);
+
+/**
+ * Extract the file type / suffix from a path
+ */
+std::string getSuffixFromPath(const std::string &str);
+
+
+/**
+ * Checks if file_name already contains a qualified path and if not copies the path from source.
+ */
+std::string copyPathToFileName(const std::string &file_name, const std::string &source);
+
+/**
+ * extracts the path of a fully qualified path name of the file
+ * @param fname [input] the fully qualified path name of the file
+ * @param path [output] the path of the fully qualified path name of the file
+ */
+void extractPath(std::string const& fname, std::string& path);
 } // end namespace BaseLib
 
 #endif // FILETOOLS_H
diff --git a/BaseLib/MemWatch.cpp b/BaseLib/MemWatch.cpp
index 537b127fb065fa26baa0b444445fe1724d91bc06..20a82badef9f9dbcd86f2dbe434bd70ca966b95f 100644
--- a/BaseLib/MemWatch.cpp
+++ b/BaseLib/MemWatch.cpp
@@ -12,7 +12,7 @@
 
 #include "MemWatch.h"
 
-#ifndef WIN32
+#ifndef _MSC_VER
 
 namespace BaseLib {
 
@@ -71,4 +71,4 @@ unsigned long MemWatch::getCodeMemUsage () {
 
 } // end namespace BaseLib
 
-#endif // WIN
+#endif // _MSC_VER
diff --git a/BaseLib/MemWatch.h b/BaseLib/MemWatch.h
index d34d29426edb20c9776a83a5940b3f860ec52a5e..f3934e90d200708063b39898085c1bf5e2beaafe 100644
--- a/BaseLib/MemWatch.h
+++ b/BaseLib/MemWatch.h
@@ -13,7 +13,7 @@
 #ifndef MEMWATCH_H_
 #define MEMWATCH_H_
 
-#ifndef WIN32
+#ifndef _MSC_VER
 
 #include <sys/types.h>
 #include <unistd.h>
diff --git a/BaseLib/RunTime.cpp b/BaseLib/RunTime.cpp
index fe517531f49ad14c0c90e18307e646258d6416e9..787b0d9e389fe0518600ee12d2a620ccb00fac22 100644
--- a/BaseLib/RunTime.cpp
+++ b/BaseLib/RunTime.cpp
@@ -16,7 +16,7 @@ namespace BaseLib {
 
 void RunTime::start()
 {
-#ifndef _WIN32
+#ifndef _MSC_VER
 	gettimeofday(&_start, 0);
 #else
 	_start = timeGetTime();
@@ -25,7 +25,7 @@ void RunTime::start()
 
 void RunTime::stop()
 {
-#ifndef _WIN32
+#ifndef _MSC_VER
 	gettimeofday(&_stop, 0);
 #else
 	_stop = timeGetTime();
@@ -34,7 +34,7 @@ void RunTime::stop()
 
 double RunTime::elapsed()
 {
-#ifndef _WIN32
+#ifndef _MSC_VER
 	return (_stop.tv_sec + _stop.tv_usec/1000000.0 - (_start.tv_sec + _start.tv_usec/1000000.0));
 #else
 	return (_stop - _start) / 1000.0;
diff --git a/BaseLib/RunTime.h b/BaseLib/RunTime.h
index bfcc113c17503938bf5e3804379e03d4bc78a443..23a5dc43cbb0db32f74ad6691341a858d0b39775 100644
--- a/BaseLib/RunTime.h
+++ b/BaseLib/RunTime.h
@@ -15,7 +15,7 @@
 
 #include "TimeMeasurementBase.h"
 
-#ifndef _WIN32
+#ifndef _MSC_VER
 #include <sys/time.h>
 #else
 #include <windows.h>
@@ -33,7 +33,7 @@ public:
 	virtual double elapsed();
 	~RunTime() {};
 private:
-#ifndef _WIN32
+#ifndef _MSC_VER
 	timeval _start;
 	timeval _stop;
 #else
diff --git a/BaseLib/StringTools.cpp b/BaseLib/StringTools.cpp
index 709b1645c3591e3f7b75c9f4473946a69bf4a727..e752f605f9ec5168b04a0adc7eb5688b87462903 100644
--- a/BaseLib/StringTools.cpp
+++ b/BaseLib/StringTools.cpp
@@ -12,6 +12,8 @@
 
 #include "StringTools.h"
 
+namespace BaseLib {
+
 std::list<std::string> splitString(const std::string &str, char delim)
 {
 	std::list<std::string> strList;
@@ -47,61 +49,6 @@ void trim(std::string &str, char ch)
   else str.erase(str.begin(), str.end());
 }
 
-namespace BaseLib {
-
-std::string getFileNameFromPath(const std::string &str, bool with_extension)
-{
-	std::string::size_type beg1 = str.find_last_of('/');
-	std::string::size_type beg2 = str.find_last_of('\\');
-	std::string::size_type beg;
-	if (beg1 == std::string::npos && beg2 == std::string::npos) beg = -1;
-	else if (beg1 == std::string::npos) beg = beg2;
-	else if (beg2 == std::string::npos) beg = beg1;
-	else beg = (beg1<beg2) ? beg2 : beg1;
-	std::string file ( str.substr(beg+1) );
-	if (with_extension) return file;
-	// cut extension
-	std::string::size_type end  = file.find_last_of('.');
-	return file.substr(0,end);
-}
-
-std::string getSuffixFromPath(const std::string &str)
-{
-	std::string::size_type beg (str.find_last_of('.'));
-	return str.substr(beg+1, str.length()-beg-1);
-}
-
-std::string copyPathToFileName(const std::string &file_name, const std::string &source)
-{
-	// check if file_name already contains a full path
-	size_t pos(file_name.rfind("/")); // linux, mac delimiter
-	if (pos == std::string::npos)
-	{
-		pos = file_name.rfind("\\"); // windows delimiter
-		if (pos == std::string::npos)
-		{
-			std::string path;
-			BaseLib::extractPath(source, path);
-			return path.append(file_name);
-		}
-		else return std::string(file_name);
-	}
-	else return std::string(file_name);
-}
-
-
-void extractPath (std::string const& fname, std::string& path)
-{
-	// extract path for reading external files
-	size_t pos(fname.rfind("/")); // linux, mac delimiter
-	if (pos == std::string::npos) {
-		pos = fname.rfind("\\"); // windows delimiter
-		if (pos == std::string::npos)
-			pos = 0;
-	}
-	path = fname.substr(0, pos==0 ? pos : pos + 1);
-}
-
 } // end namespace BaseLib
 
 
diff --git a/BaseLib/StringTools.h b/BaseLib/StringTools.h
index 3f11c0fbbf224cfd5139d7651de5dfc253a98dce..29061d08d24ec1d551ed44479826416033abbe3e 100644
--- a/BaseLib/StringTools.h
+++ b/BaseLib/StringTools.h
@@ -20,6 +20,7 @@
 #include <iostream>
 #include <ctype.h>
 
+namespace BaseLib {
 
 /**
  *   Splits a string into a list of strings.
@@ -69,32 +70,6 @@ template<typename T> T str2number (const std::string &str)
  */
 void trim(std::string &str, char ch=' ');
 
-namespace BaseLib {
-
-/**
- * Extract the filename from a path
- */
-std::string getFileNameFromPath(const std::string &str, bool with_extension = false);
-
-/**
- * Extract the file type / suffix from a path
- */
-std::string getSuffixFromPath(const std::string &str);
-
-
-/**
- * Checks if file_name already contains a qualified path and if not copies the path from source.
- */
-std::string copyPathToFileName(const std::string &file_name, const std::string &source);
-
-/**
- * extracts the path of a fully qualified path name of the file
- * @param fname [input] the fully qualified path name of the file
- * @param path [output] the path of the fully qualified path name of the file
- */
-void extractPath (std::string const& fname, std::string& path);
-
-
 } // end namespace BaseLib
 
 #ifdef MSVC
diff --git a/BaseLib/SystemTools.h b/BaseLib/SystemTools.h
new file mode 100644
index 0000000000000000000000000000000000000000..8939814f1fe3aa7f9ac895fdb9e5c4ac87de537e
--- /dev/null
+++ b/BaseLib/SystemTools.h
@@ -0,0 +1,31 @@
+/**
+ * Copyright (c) 2012, OpenGeoSys Community (http://www.opengeosys.org)
+ *            Distributed under a Modified BSD License.
+ *              See accompanying file LICENSE.txt or
+ *              http://www.opengeosys.org/project/license
+ *
+ *
+ * \file SystemTools.h
+ *
+ * Created on 2012-07-16 by Norihiro Watanabe
+ */
+
+#ifndef SYSTEMTOOLS_H
+#define SYSTEMTOOLS_H
+
+namespace BaseLib
+{
+
+/// return if this system supports little endian or not
+inline bool IsLittleEndian()
+{
+#ifdef ENDIAN_IS_BIG
+    return false;
+#elif ENDIAN_IS_LITTLE
+    return true;
+#endif
+}
+
+}
+
+#endif
diff --git a/FileIO/GMSInterface.cpp b/FileIO/GMSInterface.cpp
index 727d12feb06ab06cb8f2e4d0ba166ff83bd125b0..a65c3cd22984813df4c96d3f1f73a237004d5121 100644
--- a/FileIO/GMSInterface.cpp
+++ b/FileIO/GMSInterface.cpp
@@ -9,6 +9,8 @@
  * Created on 2010-06-08 by Karsten Rink
  */
 
+#include <fstream>
+
 #include "GMSInterface.h"
 #include "Station.h"
 #include "Mesh.h"
@@ -17,8 +19,9 @@
 #include "Elements/Pyramid.h"
 #include "Elements/Prism.h"
 #include "MshEnums.h"
+// BaseLib
 #include "StringTools.h"
-#include <fstream>
+#include "FileTools.h"
 
 int GMSInterface::readBoreholesFromGMS(std::vector<GeoLib::Point*>* boreholes,
                                        const std::string &filename)
@@ -42,7 +45,7 @@ int GMSInterface::readBoreholesFromGMS(std::vector<GeoLib::Point*>* boreholes,
 	/* read all stations */
 	while ( getline(in, line) )
 	{
-		std::list<std::string> fields = splitString(line, '\t');
+		std::list<std::string> fields = BaseLib::splitString(line, '\t');
 
 		if (fields.size() >= 5)
 		{
@@ -222,7 +225,7 @@ std::vector<std::string> GMSInterface::readSoilIDfromFile(const std::string &fil
 	if (in.is_open())
 		while ( getline(in, line) )
 		{
-			trim(line);
+			BaseLib::trim(line);
 			soilID.push_back(line);
 		}
 	in.close();
diff --git a/FileIO/Gmsh2GeoIO.cpp b/FileIO/Gmsh2GeoIO.cpp
index 1e72c76dbe301e289bb8b861c4a340799f10682f..0f00fccbad2d622392df9a988659582606c9cf6f 100644
--- a/FileIO/Gmsh2GeoIO.cpp
+++ b/FileIO/Gmsh2GeoIO.cpp
@@ -40,7 +40,7 @@ void Gmsh2GeoIO::loadMeshAsGeometry (std::string & fname, GeoLib::GEOObjects* ge
 	getline (ins, line);
 	// read number of nodes
 	getline (ins, line);
-	const size_t n_pnts (str2number<size_t>(line));
+	const size_t n_pnts (BaseLib::str2number<size_t>(line));
 	std::vector<GeoLib::Point*>* pnts (new std::vector<GeoLib::Point*>);
 	for (size_t k(0); k < n_pnts; k++)
 	{
@@ -52,15 +52,15 @@ void Gmsh2GeoIO::loadMeshAsGeometry (std::string & fname, GeoLib::GEOObjects* ge
 		// parse x coordinate
 		pos_beg = pos_end + 1;
 		pos_end = line.find(" ", pos_beg);
-		double x (str2number<double>(line.substr(pos_beg, pos_end - pos_beg)));
+		double x (BaseLib::str2number<double>(line.substr(pos_beg, pos_end - pos_beg)));
 		// parse y coordinate
 		pos_beg = pos_end + 1;
 		pos_end = line.find(" ", pos_beg);
-		double y (str2number<double>(line.substr(pos_beg, pos_end - pos_beg)));
+		double y (BaseLib::str2number<double>(line.substr(pos_beg, pos_end - pos_beg)));
 		// parse z coordinate
 		pos_beg = pos_end + 1;
 		pos_end = line.find("\n", pos_beg);
-		double z (str2number<double>(line.substr(pos_beg, pos_end - pos_beg)));
+		double z (BaseLib::str2number<double>(line.substr(pos_beg, pos_end - pos_beg)));
 
 		pnts->push_back (new GeoLib::Point (x,y,z));
 	}
@@ -74,7 +74,7 @@ void Gmsh2GeoIO::loadMeshAsGeometry (std::string & fname, GeoLib::GEOObjects* ge
 	getline (ins, line);
 	// read number of elements
 	getline (ins, line);
-	const size_t n_elements (str2number<size_t>(line));
+	const size_t n_elements (BaseLib::str2number<size_t>(line));
 	GeoLib::Surface* sfc (new GeoLib::Surface (*pnts));
 	for (size_t k(0); k < n_elements; k++)
 	{
@@ -86,12 +86,12 @@ void Gmsh2GeoIO::loadMeshAsGeometry (std::string & fname, GeoLib::GEOObjects* ge
 		// parse element type
 		pos_beg = pos_end + 1;
 		pos_end = line.find(" ", pos_beg);
-		size_t ele_type (str2number<size_t>(line.substr(pos_beg, pos_end - pos_beg)));
+		size_t ele_type (BaseLib::str2number<size_t>(line.substr(pos_beg, pos_end - pos_beg)));
 		if (ele_type == 2) // read 3 node triangle
 		{ // parse number of tags
 			pos_beg = pos_end + 1;
 			pos_end = line.find(" ", pos_beg);
-			const size_t n_tags (str2number<size_t>(line.substr(pos_beg,
+			const size_t n_tags (BaseLib::str2number<size_t>(line.substr(pos_beg,
 			                                                    pos_end - pos_beg)));
 			// (over) read tags
 			for (size_t j(0); j < n_tags; j++)
@@ -102,17 +102,17 @@ void Gmsh2GeoIO::loadMeshAsGeometry (std::string & fname, GeoLib::GEOObjects* ge
 			// parse first id of triangle
 			pos_beg = pos_end + 1;
 			pos_end = line.find(" ", pos_beg);
-			const size_t id0 (str2number<size_t>(line.substr(pos_beg,
+			const size_t id0 (BaseLib::str2number<size_t>(line.substr(pos_beg,
 			                                                 pos_end - pos_beg)) - 1); // shift -1!
 			// parse second id of triangle
 			pos_beg = pos_end + 1;
 			pos_end = line.find(" ", pos_beg);
-			const size_t id1 (str2number<size_t>(line.substr(pos_beg,
+			const size_t id1 (BaseLib::str2number<size_t>(line.substr(pos_beg,
 			                                                 pos_end - pos_beg)) - 1); // shift -1!
 			// parse third id of triangle
 			pos_beg = pos_end + 1;
 			pos_end = line.find(" ", pos_beg);
-			const size_t id2 (str2number<size_t>(line.substr(pos_beg,
+			const size_t id2 (BaseLib::str2number<size_t>(line.substr(pos_beg,
 			                                                 pos_end - pos_beg)) - 1); // shift -1!
 			sfc->addTriangle (pnt_id_map[id0], pnt_id_map[id1], pnt_id_map[id2]);
 		}
diff --git a/FileIO/Legacy/MeshIO.cpp b/FileIO/Legacy/MeshIO.cpp
index 2a1c6b420cd3e1e16313884b02de27b2ffa4bf33..0717314aaf01c4d973167b7486b8d3423f409e51 100644
--- a/FileIO/Legacy/MeshIO.cpp
+++ b/FileIO/Legacy/MeshIO.cpp
@@ -10,7 +10,13 @@
  * Created on 2012-05-08 by Karsten Rink
  */
 
+#include <iomanip>
+#include <sstream>
+
+// GeoLib
 #include "GEOObjects.h"
+
+// MeshLib
 #include "MeshIO.h"
 #include "Node.h"
 #include "Elements/Edge.h"
@@ -21,10 +27,9 @@
 #include "Elements/Pyramid.h"
 #include "Elements/Prism.h"
 
+// BaseLib
 #include "StringTools.h"
-
-#include <iomanip>
-#include <sstream>
+#include "FileTools.h"
 
 namespace FileIO
 {
@@ -66,7 +71,7 @@ MeshLib::Mesh* MeshIO::loadMeshFromFile(const std::string& file_name)
 				double x, y, z, double_dummy;
 				unsigned idx;
 				getline(in, line_string);
-				trim(line_string);
+				BaseLib::trim(line_string);
 				unsigned nNodes = atoi(line_string.c_str());
 				std::string s;
 				for (unsigned i = 0; i < nNodes; i++)
@@ -84,7 +89,7 @@ MeshLib::Mesh* MeshIO::loadMeshFromFile(const std::string& file_name)
 			else if (line_string.find("$ELEMENTS") != std::string::npos)
 			{
 				getline(in, line_string);
-				trim(line_string);
+				BaseLib::trim(line_string);
 				unsigned nElements = atoi(line_string.c_str());
 				for (unsigned i = 0; i < nElements; i++)
 				{
diff --git a/FileIO/Legacy/OGSIOVer4.cpp b/FileIO/Legacy/OGSIOVer4.cpp
index 85191ba7f200022f4e1ff4a0c4846bbfc3514fca..2d41e601fdd322bb1e1393eb94b9827fb1005f38 100644
--- a/FileIO/Legacy/OGSIOVer4.cpp
+++ b/FileIO/Legacy/OGSIOVer4.cpp
@@ -16,11 +16,12 @@
 #include "MeshIO/GMSHInterface.h"
 #include "OGSIOVer4.h"
 
-// Base
+// BaseLib
 #include "StringTools.h"
+#include "FileTools.h"
 #include "quicksort.h"
 
-// GEO
+// GeoLib
 #include "GEOObjects.h"
 #include "Point.h"
 #include "Polygon.h"
@@ -193,7 +194,7 @@ std::string readPolyline(std::istream &in,
 				        ==
 				        std::string::npos))
 				{
-					size_t pnt_id(str2number<size_t> (line));
+					size_t pnt_id(BaseLib::str2number<size_t> (line));
 					if (!zero_based_indexing)
 						pnt_id--;  // one based indexing
 					size_t ply_size (ply->getNumberOfPoints());
@@ -757,7 +758,7 @@ void writeAllDataToGLIFileV4 (const std::string& fname, const GeoLib::GEOObjects
 						os << "\t$NAME " << std::endl << "\t\t" << sfc_name << std::endl;
 					} else {
 						os << "\t$NAME " << std::endl << "\t\t" << sfcs_cnt << std::endl;
-						sfc_name += number2str (sfcs_cnt);
+						sfc_name += BaseLib::number2str (sfcs_cnt);
 					}
 					sfc_name += ".tin";
 					os << "\t$TIN" << std::endl;
diff --git a/FileIO/MeshIO/GMSHInterface.cpp b/FileIO/MeshIO/GMSHInterface.cpp
index 8838ffc65457a7fbf84ece6b29215439b942fb87..7c60bad6f89ebe029638bafd24b6113b8dfb0b1e 100644
--- a/FileIO/MeshIO/GMSHInterface.cpp
+++ b/FileIO/MeshIO/GMSHInterface.cpp
@@ -17,7 +17,7 @@
 #include "StringTools.h"
 #include "Configure.h"
 #include "BuildInfo.h"
-#include "StringTools.h"
+#include "FileTools.h"
 
 // FileIO
 #include "GMSHInterface.h"
diff --git a/FileIO/MeshIO/TetGenInterface.cpp b/FileIO/MeshIO/TetGenInterface.cpp
index 585cc74cc9c6132e7f109bffb5a87a6baa7c8e21..d3104df588ee1e1c0b65e929016d60b02f32921b 100644
--- a/FileIO/MeshIO/TetGenInterface.cpp
+++ b/FileIO/MeshIO/TetGenInterface.cpp
@@ -122,7 +122,7 @@ bool TetGenInterface::parseNodesFileHeader(std::string &line,
 	pos_beg = line.find_first_not_of (" ");
 	pos_end = line.find_first_of(" ", pos_beg);
 	if (pos_beg != std::string::npos && pos_end != std::string::npos)
-		n_nodes = str2number<size_t> (line.substr(pos_beg, pos_end - pos_beg));
+		n_nodes = BaseLib::str2number<size_t> (line.substr(pos_beg, pos_end - pos_beg));
 	else
 	{
 		ERR("TetGenInterface::parseNodesFileHeader(): could not correct read TetGen mesh header - number of nodes");
@@ -131,11 +131,11 @@ bool TetGenInterface::parseNodesFileHeader(std::string &line,
 	// dimension
 	pos_beg = line.find_first_not_of (" ", pos_end);
 	pos_end = line.find_first_of(" ", pos_beg);
-	dim = str2number<size_t> (line.substr(pos_beg, pos_end - pos_beg));
+	dim = BaseLib::str2number<size_t> (line.substr(pos_beg, pos_end - pos_beg));
 	// number of attributes
 	pos_beg = line.find_first_not_of (" ", pos_end);
 	pos_end = line.find_first_of(" ", pos_beg);
-	n_attributes = str2number<size_t> (line.substr(pos_beg, pos_end - pos_beg));
+	n_attributes = BaseLib::str2number<size_t> (line.substr(pos_beg, pos_end - pos_beg));
 	// boundary marker at nodes?
 	pos_beg = line.find_first_not_of (" ", pos_end);
 	pos_end = line.find_first_of(" ", pos_beg);
@@ -165,7 +165,7 @@ bool TetGenInterface::parseNodes(std::ifstream& ins, size_t n_nodes, size_t dim)
 				pos_beg = line.find_first_not_of(" ", pos_end);
 				pos_end = line.find_first_of(" \n", pos_beg);
 				if (pos_beg != std::string::npos && pos_end != std::string::npos) {
-					id = str2number<size_t> (line.substr(pos_beg, pos_end - pos_beg));
+					id = BaseLib::str2number<size_t> (line.substr(pos_beg, pos_end - pos_beg));
 					if (k == 0 && id == 0)
 						_zero_based_idx = true;
 				} else {
@@ -178,7 +178,7 @@ bool TetGenInterface::parseNodes(std::ifstream& ins, size_t n_nodes, size_t dim)
 					pos_end = line.find_first_of(" \n", pos_beg);
 					if (pos_end == std::string::npos) pos_end = line.size();
 					if (pos_beg != std::string::npos)
-						coordinates[i] = str2number<double> (
+						coordinates[i] = BaseLib::str2number<double> (
 										line.substr(pos_beg, pos_end - pos_beg));
 					else {
 						ERR("TetGenInterface::parseNodes(): error reading coordinate %d of node %d", i, k);
@@ -243,7 +243,7 @@ bool TetGenInterface::parseElementsFileHeader(std::string &line,
 	pos_beg = line.find_first_not_of (" ");
 	pos_end = line.find_first_of(" ", pos_beg);
 	if (pos_beg != std::string::npos && pos_end != std::string::npos)
-		n_tets = str2number<size_t> (line.substr(pos_beg, pos_end - pos_beg));
+		n_tets = BaseLib::str2number<size_t> (line.substr(pos_beg, pos_end - pos_beg));
 	else {
 		ERR("TetGenInterface::parseElementsFileHeader(): could not correct read TetGen mesh header - number of tetrahedras");
 		return false;
@@ -251,7 +251,7 @@ bool TetGenInterface::parseElementsFileHeader(std::string &line,
 	// nodes per tet - either 4 or 10
 	pos_beg = line.find_first_not_of (" \t", pos_end);
 	pos_end = line.find_first_of(" \t", pos_beg);
-	n_nodes_per_tet = str2number<size_t> (line.substr(pos_beg, pos_end - pos_beg));
+	n_nodes_per_tet = BaseLib::str2number<size_t> (line.substr(pos_beg, pos_end - pos_beg));
 	// region attribute at tetrahedra?
 	pos_beg = line.find_first_not_of (" \t", pos_end);
 	pos_end = line.find_first_of(" \t\n", pos_beg);
@@ -285,7 +285,7 @@ bool TetGenInterface::parseElements(std::ifstream& ins, size_t n_tets, size_t n_
 				pos_beg = line.find_first_not_of(" ", pos_end);
 				pos_end = line.find_first_of(" \n", pos_beg);
 				if (pos_beg != std::string::npos && pos_end != std::string::npos)
-					id = str2number<size_t>(line.substr(pos_beg, pos_end - pos_beg));
+					id = BaseLib::str2number<size_t>(line.substr(pos_beg, pos_end - pos_beg));
 				else {
 					ERR("TetGenInterface::parseElements(): error reading id of tetrahedra %d", k);
 					return false;
@@ -299,7 +299,7 @@ bool TetGenInterface::parseElements(std::ifstream& ins, size_t n_tets, size_t n_
 						pos_end = line.size();
 					if (pos_beg != std::string::npos && pos_end !=
 					    std::string::npos)
-						ids[i] = str2number<std::size_t>(line.substr(pos_beg, pos_end - pos_beg));
+						ids[i] = BaseLib::str2number<std::size_t>(line.substr(pos_beg, pos_end - pos_beg));
 					else
 					{
 						ERR("TetGenInterface::parseElements(): error reading node %d of tetrahedra %d", i, k);
@@ -319,7 +319,7 @@ bool TetGenInterface::parseElements(std::ifstream& ins, size_t n_tets, size_t n_
 					pos_end = line.find_first_of(" ", pos_beg);
 					if (pos_end == std::string::npos) pos_end = line.size();
 					if (pos_beg != std::string::npos && pos_end != std::string::npos)
-						region = str2number<unsigned> (line.substr(pos_beg, pos_end - pos_beg));
+						region = BaseLib::str2number<unsigned> (line.substr(pos_beg, pos_end - pos_beg));
 					else {
 						ERR("TetGenInterface::parseElements(): error reading region attribute of tetrahedra %d", k);
 						return false;
diff --git a/FileIO/PetrelInterface.cpp b/FileIO/PetrelInterface.cpp
index f5f41d5a3197ee47974fec4f348e22625a136c6c..fe1ca2431592d75c7298839bb3635889ec6e37ba 100644
--- a/FileIO/PetrelInterface.cpp
+++ b/FileIO/PetrelInterface.cpp
@@ -118,7 +118,7 @@ void PetrelInterface::readPetrelWellTrace(std::istream &in)
 		// read well name
 		in.getline(buffer, MAX_COLS_PER_ROW);
 		line = buffer;
-		std::list<std::string> str_list(splitString(line, ' '));
+		std::list<std::string> str_list(BaseLib::splitString(line, ' '));
 		std::list<std::string>::const_iterator it(str_list.begin());
 		while (it != str_list.end())
 			std::cout << *it++ << " " << std::flush;
@@ -127,7 +127,7 @@ void PetrelInterface::readPetrelWellTrace(std::istream &in)
 		// read well head x coordinate
 		in.getline(buffer, MAX_COLS_PER_ROW);
 		line = buffer;
-		str_list = splitString(line, ' ');
+		str_list = BaseLib::splitString(line, ' ');
 		it = str_list.begin();
 		while (it != str_list.end())
 			std::cout << *it++ << " " << std::flush;
@@ -140,7 +140,7 @@ void PetrelInterface::readPetrelWellTrace(std::istream &in)
 		// read well head y coordinate
 		in.getline(buffer, MAX_COLS_PER_ROW);
 		line = buffer;
-		str_list = splitString(line, ' ');
+		str_list = BaseLib::splitString(line, ' ');
 		it = str_list.begin();
 		while (it != str_list.end())
 			std::cout << *it++ << " " << std::flush;
@@ -152,7 +152,7 @@ void PetrelInterface::readPetrelWellTrace(std::istream &in)
 		// read well KB
 		in.getline(buffer, MAX_COLS_PER_ROW);
 		line = buffer;
-		str_list = splitString(line, ' ');
+		str_list = BaseLib::splitString(line, ' ');
 		it = str_list.begin();
 		while (it != str_list.end())
 			std::cout << *it++ << " " << std::flush;
@@ -171,7 +171,7 @@ void PetrelInterface::readPetrelWellTrace(std::istream &in)
 		// read well type
 		in.getline(buffer, MAX_COLS_PER_ROW);
 		line = buffer;
-		str_list = splitString(line, ' ');
+		str_list = BaseLib::splitString(line, ' ');
 		it = str_list.begin();
 		while (it != str_list.end())
 			std::cout << *it++ << " " << std::flush;
@@ -200,7 +200,7 @@ void PetrelInterface::readPetrelWellTraceData(std::istream &in)
 	}
 
 	// read column information
-	str_list = splitString(line, ' ');
+	str_list = BaseLib::splitString(line, ' ');
 	it = str_list.begin();
 	while (it != str_list.end())
 		std::cout << *it++ << " " << std::flush;
diff --git a/FileIO/RapidXmlIO/RapidStnInterface.cpp b/FileIO/RapidXmlIO/RapidStnInterface.cpp
index 9b4d9dc3b3d42f3a09194890a56f36312e95a962..6bd313e75171e436817f62d0e4b27bf11d76bea5 100644
--- a/FileIO/RapidXmlIO/RapidStnInterface.cpp
+++ b/FileIO/RapidXmlIO/RapidStnInterface.cpp
@@ -8,11 +8,17 @@
  *
  *  Created on 2012-08-16 by Karsten Rink
  */
+
+#include <iostream>
+
 //RapidXML
 #include "RapidStnInterface.h"
-#include <iostream>
 
+// BaseLib
 #include "StringTools.h"
+#include "FileTools.h"
+
+// GeoLib
 #include "Station.h"
 
 namespace FileIO
diff --git a/FileIO/RapidXmlIO/RapidVtuInterface.cpp b/FileIO/RapidXmlIO/RapidVtuInterface.cpp
index f7c257d6da8b3e0c29aac6f5299ada1ce648ba4a..1dc0bd180c83eb653ab08f5289ebf52d40eb658b 100644
--- a/FileIO/RapidXmlIO/RapidVtuInterface.cpp
+++ b/FileIO/RapidXmlIO/RapidVtuInterface.cpp
@@ -15,6 +15,7 @@
 
 #include "RapidXML/rapidxml_print.hpp"
 #include "StringTools.h"
+#include "FileTools.h"
 #include "ProjectData.h"
 
 // MSH
@@ -355,9 +356,9 @@ int RapidVtuInterface::write(std::ostream& stream)
 	root_node->append_node(grid_node);
 	xml_node<> *piece_node (_doc->allocate_node(node_element, "Piece"));
 	grid_node->append_node(piece_node);
-	const std::string str_nNodes (number2str(nNodes));
+	const std::string str_nNodes (BaseLib::number2str(nNodes));
 	piece_node->append_attribute (_doc->allocate_attribute("NumberOfPoints", str_nNodes.c_str()));
-	const std::string str_nElems (number2str(nElems));
+	const std::string str_nElems (BaseLib::number2str(nElems));
 	piece_node->append_attribute(_doc->allocate_attribute("NumberOfCells", str_nElems.c_str()));
 
 	// scalar arrays for point- and cell-data
@@ -457,7 +458,7 @@ xml_node<>* RapidVtuInterface::addDataArray(const std::string &name, const std::
 	dataarray_node->append_attribute(attr);
 	if (nComponents > 1)
 	{
-		attr = _doc->allocate_attribute(_doc->allocate_string("NumberOfComponents"), _doc->allocate_string(number2str(nComponents).c_str()));
+		attr = _doc->allocate_attribute(_doc->allocate_string("NumberOfComponents"), _doc->allocate_string(BaseLib::number2str(nComponents).c_str()));
 		dataarray_node->append_attribute(attr);
 	}
 	std::string comp_type = (_use_compressor) ? "appended" : "ascii";
diff --git a/FileIO/SHPInterface.cpp b/FileIO/SHPInterface.cpp
index 8fd5d0db272b49ba469b7fa2676aa477e8b55690..d8799c2a7e46dc588ca9f18b2542363c54a933e8 100644
--- a/FileIO/SHPInterface.cpp
+++ b/FileIO/SHPInterface.cpp
@@ -79,7 +79,7 @@ void SHPInterface::readStations(const SHPHandle &hSHP, int numberOfElements, std
 		{
 			hSHPObject = SHPReadObject(hSHP,i);
 			GeoLib::Station* stn =
-			        GeoLib::Station::createStation( number2str(i), *(hSHPObject->padfX),
+			        GeoLib::Station::createStation( BaseLib::number2str(i), *(hSHPObject->padfX),
 			                                        *(hSHPObject->padfY),
 			                                        *(hSHPObject->padfZ) );
 			stations->push_back(stn);
diff --git a/FileIO/XmlIO/XmlStnInterface.cpp b/FileIO/XmlIO/XmlStnInterface.cpp
index 52a0f085ebb6cabdc9ff1dba1aef43fc4755abaa..a4dd078c87f67beaa8d91528de165ebb6aeb474b 100644
--- a/FileIO/XmlIO/XmlStnInterface.cpp
+++ b/FileIO/XmlIO/XmlStnInterface.cpp
@@ -10,14 +10,17 @@
  * Created on 2011-11-23 by Karsten Rink
  */
 
-#include "XmlStnInterface.h"
-#include "DateTools.h"
 #include <limits>
+#include <iostream>
 
 #include <QFile>
 #include <QtXml/QDomDocument>
 
-#include <iostream>
+#include "XmlStnInterface.h"
+
+// BaseLib
+#include "DateTools.h"
+#include "FileTools.h"
 
 namespace FileIO
 {
diff --git a/FileIO/readMeshFromFile.cpp b/FileIO/readMeshFromFile.cpp
index ad817c8a210bb12aeb2902d24f53addb014d23c4..faa38a619bf1b10d0f8f8e40b89d53ec60cda4fc 100644
--- a/FileIO/readMeshFromFile.cpp
+++ b/FileIO/readMeshFromFile.cpp
@@ -11,11 +11,14 @@
  */
 
 #include "readMeshFromFile.h"
-#include "StringTools.h"
 #include "Mesh.h"
 #include "RapidXmlIO/RapidVtuInterface.h"
 #include "Legacy/MeshIO.h"
 
+// BaseLib
+#include "StringTools.h"
+#include "FileTools.h"
+
 namespace FileIO {
 
 MeshLib::Mesh* readMeshFromFile(const std::string &file_name)
@@ -36,4 +39,4 @@ MeshLib::Mesh* readMeshFromFile(const std::string &file_name)
 	return mesh;
 }
 
-}
\ No newline at end of file
+}
diff --git a/GeoLib/Color.cpp b/GeoLib/Color.cpp
index 7a4e92a821deaa9bc96bcbdce4b1909f902a197f..0564dca9ac134c8002444c9c3f0d70fcf52bdc14 100644
--- a/GeoLib/Color.cpp
+++ b/GeoLib/Color.cpp
@@ -37,7 +37,7 @@ int readColorLookupTable(std::map<std::string, Color*> &colors, const std::strin
 
 	while ( getline(in, line) )
 	{
-		std::list<std::string> fields = splitString(line, '\t');
+		std::list<std::string> fields = BaseLib::splitString(line, '\t');
 		Color *c = new Color();
 
 		if (fields.size()>=4)
diff --git a/GeoLib/GEOObjects.cpp b/GeoLib/GEOObjects.cpp
index 10ab4ba9785278b0e6496580e3d06b94aa8f0281..b4b32df6ed4d66df679a8a1c8a307faf2c2a6707 100644
--- a/GeoLib/GEOObjects.cpp
+++ b/GeoLib/GEOObjects.cpp
@@ -341,7 +341,7 @@ bool GEOObjects::isUniquePointVecName(std::string &name)
 		// If the original name already exists we start to add numbers to name for
 		// as long as it takes to make the name unique.
 		if (count > 1)
-			cpName = cpName + "-" + number2str(count);
+			cpName = cpName + "-" + BaseLib::number2str(count);
 
 		for (size_t i = 0; i < _pnt_vecs.size(); i++)
 			if ( cpName.compare(_pnt_vecs[i]->getName()) == 0 )
diff --git a/GeoLib/Grid.h b/GeoLib/Grid.h
index 96c452b395fb3bfc6720f26dc157d8ddcc2afe5d..c3d98bacc89539539da34d7ab8e5f97c998102d8 100644
--- a/GeoLib/Grid.h
+++ b/GeoLib/Grid.h
@@ -386,11 +386,11 @@ void Grid<POINT>::createGridGeometry(GeoLib::GEOObjects* geo_obj) const
 			for (std::size_t k(0); k<_n_steps[2]; k++) {
 
 				std::string name("Grid-");
-				name += number2str<std::size_t>(i);
+				name += BaseLib::number2str<std::size_t>(i);
 				name +="-";
-				name += number2str<std::size_t>(j);
+				name += BaseLib::number2str<std::size_t>(j);
 				name += "-";
-				name += number2str<std::size_t> (k);
+				name += BaseLib::number2str<std::size_t> (k);
 				grid_names.push_back(name);
 
 				std::vector<GeoLib::Point*>* points (new std::vector<GeoLib::Point*>);
diff --git a/GeoLib/SensorData.cpp b/GeoLib/SensorData.cpp
index ecbb0080375fc51abd8d56ba786d26686f2e5735..6e3992c36ca77405dc4a418b21a66109c608b27d 100644
--- a/GeoLib/SensorData.cpp
+++ b/GeoLib/SensorData.cpp
@@ -102,7 +102,7 @@ int SensorData::readDataFromFile(const std::string &file_name)
 
 	/* first line contains field names */
 	getline(in, line);
-	std::list<std::string> fields = splitString(line, '\t');
+	std::list<std::string> fields = BaseLib::splitString(line, '\t');
 	std::list<std::string>::const_iterator it (fields.begin());
 	size_t nFields = fields.size();
 
@@ -122,7 +122,7 @@ int SensorData::readDataFromFile(const std::string &file_name)
 
 	while ( getline(in, line) )
 	{
-		fields = splitString(line, '\t');
+		fields = BaseLib::splitString(line, '\t');
 
 		if (nFields == fields.size())
 		{
diff --git a/GeoLib/Station.cpp b/GeoLib/Station.cpp
index 1c730e5769d87c80c13860abccc986935353302f..b672ee203b16fae1003e643a894602d7a8508797 100644
--- a/GeoLib/Station.cpp
+++ b/GeoLib/Station.cpp
@@ -66,16 +66,16 @@ Station* Station::createStation(const std::string & line)
 {
 	std::list<std::string>::const_iterator it;
 	Station* station = new Station();
-	std::list<std::string> fields = splitString(line, '\t');
+	std::list<std::string> fields = BaseLib::splitString(line, '\t');
 
 	if (fields.size() >= 3)
 	{
 		it = fields.begin();
 		station->_name  = *it;
-		(*station)[0]     = strtod((replaceString(",", ".", *(++it))).c_str(), NULL);
-		(*station)[1]     = strtod((replaceString(",", ".", *(++it))).c_str(), NULL);
+		(*station)[0]     = strtod((BaseLib::replaceString(",", ".", *(++it))).c_str(), NULL);
+		(*station)[1]     = strtod((BaseLib::replaceString(",", ".", *(++it))).c_str(), NULL);
 		if (++it != fields.end())
-			(*station)[2] = strtod((replaceString(",", ".", *it)).c_str(), NULL);
+			(*station)[2] = strtod((BaseLib::replaceString(",", ".", *it)).c_str(), NULL);
 	}
 	else
 	{
@@ -175,7 +175,7 @@ int StationBorehole::readStratigraphyFile(const std::string &path,
 
 	while ( getline(in, line) )
 	{
-		std::list<std::string> fields = splitString(line, '\t');
+		std::list<std::string> fields = BaseLib::splitString(line, '\t');
 		data.push_back(fields);
 	}
 
@@ -228,7 +228,7 @@ int StationBorehole::addLayer(std::list<std::string> fields, StationBorehole* bo
 
 			std::cerr << "StationBorehole::addLayer - assuming correct order" <<
 			std::endl;
-			double thickness(strtod(replaceString(",", ".", fields.front()).c_str(), 0));
+			double thickness(strtod(BaseLib::replaceString(",", ".", fields.front()).c_str(), 0));
 			fields.pop_front();
 			borehole->addSoilLayer(thickness, fields.front());
 		}
@@ -285,7 +285,7 @@ int StationBorehole::addStratigraphies(const std::string &path, std::vector<Poin
 				fields.pop_front();
 				//the method just assumes that layers are read in correct order
 				fields.pop_front();
-				double thickness (strtod(replaceString(",", ".",
+				double thickness (strtod(BaseLib::replaceString(",", ".",
 				                                       fields.front()).c_str(), 0));
 				fields.pop_front();
 				std::string soil_name (fields.front());
@@ -310,19 +310,19 @@ int StationBorehole::addStratigraphies(const std::string &path, std::vector<Poin
 StationBorehole* StationBorehole::createStation(const std::string &line)
 {
 	StationBorehole* borehole = new StationBorehole();
-	std::list<std::string> fields = splitString(line, '\t');
+	std::list<std::string> fields = BaseLib::splitString(line, '\t');
 
 	if (fields.size()      >= 5)
 	{
 		borehole->_name     = fields.front();
 		fields.pop_front();
-		(*borehole)[0]      = strtod((replaceString(",", ".", fields.front())).c_str(), NULL);
+		(*borehole)[0]      = strtod((BaseLib::replaceString(",", ".", fields.front())).c_str(), NULL);
 		fields.pop_front();
-		(*borehole)[1]      = strtod((replaceString(",", ".", fields.front())).c_str(), NULL);
+		(*borehole)[1]      = strtod((BaseLib::replaceString(",", ".", fields.front())).c_str(), NULL);
 		fields.pop_front();
-		(*borehole)[2]      = strtod((replaceString(",", ".", fields.front())).c_str(), NULL);
+		(*borehole)[2]      = strtod((BaseLib::replaceString(",", ".", fields.front())).c_str(), NULL);
 		fields.pop_front();
-		borehole->_depth    = strtod((replaceString(",", ".", fields.front())).c_str(), NULL);
+		borehole->_depth    = strtod((BaseLib::replaceString(",", ".", fields.front())).c_str(), NULL);
 		fields.pop_front();
 		if (fields.empty())
 			borehole->_date = 0;
diff --git a/Gui/DataView/DiagramView/DiagramList.cpp b/Gui/DataView/DiagramView/DiagramList.cpp
index b2b2056707647075e05d7f681e336483a7c95956..ffaffd99b937402cce208c19a256596345283f6b 100644
--- a/Gui/DataView/DiagramView/DiagramList.cpp
+++ b/Gui/DataView/DiagramView/DiagramList.cpp
@@ -160,7 +160,7 @@ int DiagramList::readList(const QString &path, std::vector<DiagramList*> &lists)
 		{
 			DiagramList* l = new DiagramList;
 			l->setName(fields.takeFirst());
-			//value = strtod(replaceString(",", ".", fields.takeFirst().toStdString()).c_str(),0);
+			//value = strtod(BaseLib::replaceStringreplaceString(",", ".", fields.takeFirst().toStdString()).c_str(),0);
 			//l->setStartDate(startDate);
 			//l->addNextPoint(0,value);
 			lists.push_back(l);
@@ -192,7 +192,7 @@ int DiagramList::readList(const QString &path, std::vector<DiagramList*> &lists)
 
 				for (int i = 0; i < nLists; i++)
 				{
-					value = strtod(replaceString(",", ".",fields.takeFirst().toStdString()).c_str(),0);
+					value = strtod(BaseLib::replaceString(",", ".",fields.takeFirst().toStdString()).c_str(),0);
 					lists[i]->addNextPoint(numberOfSecs,value);
 				}
 			}
diff --git a/Gui/DataView/FEMConditionSetupDialog.cpp b/Gui/DataView/FEMConditionSetupDialog.cpp
index 9fe94ee023002c5b5d595e6de1e90716b8fc1a2c..fbd10102f52f121ea21e067e1ed3e10f1d89d29b 100644
--- a/Gui/DataView/FEMConditionSetupDialog.cpp
+++ b/Gui/DataView/FEMConditionSetupDialog.cpp
@@ -307,7 +307,7 @@ void FEMConditionSetupDialog::copyCondOnPoints()
 			FEMCondition* cond = new FEMCondition(_cond);
 			cond->setGeoObj(NULL);
 			cond->setGeoType(GeoLib::POINT);
-			cond->setGeoName(_cond.getAssociatedGeometryName() + "_Point" + number2str(ply->getPointID(i)));
+			cond->setGeoName(_cond.getAssociatedGeometryName() + "_Point" + BaseLib::number2str(ply->getPointID(i)));
 			cond->clearDisValues();
 			cond->setConstantDisValue((*ply->getPoint(i))[2]);
 			conditions.push_back(this->typeCast(*cond));
@@ -326,7 +326,7 @@ void FEMConditionSetupDialog::copyCondOnPoints()
 				FEMCondition* cond = new FEMCondition(_cond);
 				cond->setGeoObj(NULL);
 				cond->setGeoType(GeoLib::POINT);
-				cond->setGeoName(_cond.getAssociatedGeometryName() + "_Point" + number2str((*tri)[j]));
+				cond->setGeoName(_cond.getAssociatedGeometryName() + "_Point" + BaseLib::number2str((*tri)[j]));
 				cond->clearDisValues();
 				cond->setConstantDisValue((*tri->getPoint(j))[2]);
 				conditions.push_back(this->typeCast(*cond));
diff --git a/Gui/DataView/GEOModels.cpp b/Gui/DataView/GEOModels.cpp
index 7ffb6a263e216783bdfc90ec76ff5a1ca3d400c7..db05fa64d0facb803131897851b384734bd85af2 100644
--- a/Gui/DataView/GEOModels.cpp
+++ b/Gui/DataView/GEOModels.cpp
@@ -44,7 +44,7 @@ void GEOModels::updateGeometry(const std::string &geo_name)
 		this->_geoModel->removeGeoList(geo_name, GeoLib::POINT);
 		_geoModel->addPointList(QString::fromStdString(geo_name), points);
 		emit geoDataAdded(_geoModel, geo_name, GeoLib::POINT);
-	
+
 		if (lines)
 		{
 			emit geoDataRemoved(_geoModel, geo_name, GeoLib::POLYLINE);
@@ -52,7 +52,7 @@ void GEOModels::updateGeometry(const std::string &geo_name)
 			_geoModel->addPolylineList(QString::fromStdString(geo_name), lines);
 			emit geoDataAdded(_geoModel, geo_name, GeoLib::POLYLINE);
 		}
-	
+
 		if (surfaces)
 		{
 			emit geoDataRemoved(_geoModel, geo_name, GeoLib::SURFACE);
@@ -268,7 +268,7 @@ void GEOModels::addNameForObjectPoints(const std::string &geometry_name, const G
 		const GeoLib::Polyline* ply = dynamic_cast<const GeoLib::Polyline*>(obj);
 		size_t nPoints = ply->getNumberOfPoints();
 		for (size_t i=0; i<nPoints; i++)
-			pnt_vec->setNameForElement(ply->getPointID(i), new_name + "_Point" + number2str(ply->getPointID(i)));
+			pnt_vec->setNameForElement(ply->getPointID(i), new_name + "_Point" + BaseLib::number2str(ply->getPointID(i)));
 	}
 	else if (object_type == GeoLib::SURFACE)
 	{
@@ -277,9 +277,9 @@ void GEOModels::addNameForObjectPoints(const std::string &geometry_name, const G
 		for (size_t i=0; i<nTriangles; i++)
 		{
 			const GeoLib::Triangle* tri = (*sfc)[i];
-			pnt_vec->setNameForElement((*tri)[0], new_name + "_Point" + number2str((*tri)[0]));
-			pnt_vec->setNameForElement((*tri)[1], new_name + "_Point" + number2str((*tri)[1]));
-			pnt_vec->setNameForElement((*tri)[2], new_name + "_Point" + number2str((*tri)[2]));
+			pnt_vec->setNameForElement((*tri)[0], new_name + "_Point" + BaseLib::number2str((*tri)[0]));
+			pnt_vec->setNameForElement((*tri)[1], new_name + "_Point" + BaseLib::number2str((*tri)[1]));
+			pnt_vec->setNameForElement((*tri)[2], new_name + "_Point" + BaseLib::number2str((*tri)[2]));
 		}
 	}
 	else
diff --git a/Gui/DataView/GMSHPrefsDialog.cpp b/Gui/DataView/GMSHPrefsDialog.cpp
index c7e85c0a055a4adb884574380b5cf4d47443bb5c..abfe017dcf75a5f7880c4857b9d3fa312052a1bf 100644
--- a/Gui/DataView/GMSHPrefsDialog.cpp
+++ b/Gui/DataView/GMSHPrefsDialog.cpp
@@ -153,7 +153,7 @@ void GMSHPrefsDialog::accept()
 
 	if (this->radioAdaptive->isChecked())
 	{
-		max_number_of_points_in_quadtree_leaf = str2number<unsigned> (
+		max_number_of_points_in_quadtree_leaf = BaseLib::str2number<unsigned> (
 		        param1->text().toStdString().c_str());
 		if (max_number_of_points_in_quadtree_leaf == 0)
 			max_number_of_points_in_quadtree_leaf = 10;
diff --git a/Gui/DataView/ListPropertiesDialog.cpp b/Gui/DataView/ListPropertiesDialog.cpp
index a4c6e82ecad51d31c8949fcf4c7afeb24b646796..dd4153e0062cada31a5deb857b63d17c86770077 100644
--- a/Gui/DataView/ListPropertiesDialog.cpp
+++ b/Gui/DataView/ListPropertiesDialog.cpp
@@ -136,11 +136,10 @@ void ListPropertiesDialog::accept()
 		}
 		else
 		{
-			minVal = strtod(replaceString(",", ".",
+			minVal = strtod(BaseLib::replaceString(",", ".",
 			                              _minValue[i]->text().toStdString()).c_str(),0);
-			maxVal = strtod(replaceString(",", ".",
-			                              _maxValue[i]->text().toStdString()).c_str(),
-			                0);
+			maxVal = strtod(BaseLib::replaceString(",", ".",
+			                              _maxValue[i]->text().toStdString()).c_str(),0);
 		}
 		PropertyBounds b(_propLabel[i]->text().toStdString(), minVal, maxVal);
 		bounds.push_back(b);
diff --git a/Gui/VtkVis/VtkRaster.cpp b/Gui/VtkVis/VtkRaster.cpp
index e54b9597ac922c9215329e427054b2f95b961e46..593a51c9d32694ecfd8119b04db9043160bb45b8 100644
--- a/Gui/VtkVis/VtkRaster.cpp
+++ b/Gui/VtkVis/VtkRaster.cpp
@@ -139,7 +139,7 @@ bool VtkRaster::readASCHeader(ascHeader &header, std::ifstream &in)
 	if (tag.compare("xllcorner") == 0)
 	{
 		in >> value;
-		header.x = strtod(replaceString(",", ".", value).c_str(),0);
+		header.x = strtod(BaseLib::replaceString(",", ".", value).c_str(),0);
 	}
 	else
 		return false;
@@ -147,7 +147,7 @@ bool VtkRaster::readASCHeader(ascHeader &header, std::ifstream &in)
 	if (tag.compare("yllcorner") == 0)
 	{
 		in >> value;
-		header.y = strtod(replaceString(",", ".", value).c_str(),0);
+		header.y = strtod(BaseLib::replaceString(",", ".", value).c_str(),0);
 	}
 	else
 		return false;
@@ -155,7 +155,7 @@ bool VtkRaster::readASCHeader(ascHeader &header, std::ifstream &in)
 	if (tag.compare("cellsize") == 0)
 	{
 		in >> value;
-		header.cellsize = strtod(replaceString(",", ".", value).c_str(),0);
+		header.cellsize = strtod(BaseLib::replaceString(",", ".", value).c_str(),0);
 	}
 	else
 		return false;
@@ -215,7 +215,7 @@ float* VtkRaster::loadDataFromASC(const std::string &fileName,
 			{
 				in >> s;
 				unsigned index = 2*(col_index+i);
-				values[index] = static_cast<float>(strtod(replaceString(",", ".", s).c_str(),0));
+				values[index] = static_cast<float>(strtod(BaseLib::replaceString(",", ".", s).c_str(),0));
 				if (values[index] > max_val)
 					max_val = values[index];
 			}
@@ -318,7 +318,7 @@ float* VtkRaster::loadDataFromSurfer(const std::string &fileName,
 				if (s.compare(header.noData) == 0)
 					s = "-9999";
 				unsigned index = 2*(col_index+i);
-				values[index] = static_cast<float>(strtod(replaceString(",", ".", s).c_str(),0));
+				values[index] = static_cast<float>(strtod(BaseLib::replaceString(",", ".", s).c_str(),0));
 				if (values[index] > max_val)
 					max_val = values[index];
 			}
diff --git a/Gui/mainwindow.cpp b/Gui/mainwindow.cpp
index ad38cb27b97617087b7d3d929b99b8a4cd463720..59302d6aa48bf3d9d8716979ee5050c23ffee7a2 100644
--- a/Gui/mainwindow.cpp
+++ b/Gui/mainwindow.cpp
@@ -1322,7 +1322,7 @@ void MainWindow::on_actionExportVTK_triggered(bool checked /*= false*/)
 		{
 			count++;
 			static_cast<VtkVisPipelineItem*> (*it)->writeToFile(basename
-			                                                    + number2str(count));
+			                                                    + BaseLib::number2str(count));
 			++it;
 		}
 	}
diff --git a/OGS/ProjectData.cpp b/OGS/ProjectData.cpp
index 318f207f1a64761ed7c44265c4e9379080920f09..22ab8ea8b7d985e20a62aaa31661b7038dabbc81 100644
--- a/OGS/ProjectData.cpp
+++ b/OGS/ProjectData.cpp
@@ -210,7 +210,7 @@ bool ProjectData::isUniqueMeshName(std::string &name)
 		// If the original name already exists we start to add numbers to name for
 		// as long as it takes to make the name unique.
 		if (count > 1)
-			cpName = cpName + "-" + number2str(count);
+			cpName = cpName + "-" + BaseLib::number2str(count);
 
 		for (std::vector<MeshLib::Mesh*>::iterator it = _msh_vec.begin(); it != _msh_vec.end(); ++it)
 			if ( cpName.compare((*it)->getName()) == 0 )
diff --git a/SimpleTests/MeshTests/MeshRead.cpp b/SimpleTests/MeshTests/MeshRead.cpp
index dc14c0fac49158fd10b1891c8806b64a03aaa7d4..a45edf5ffb61a57a238b8c756f06d44b42e65f98 100644
--- a/SimpleTests/MeshTests/MeshRead.cpp
+++ b/SimpleTests/MeshTests/MeshRead.cpp
@@ -8,6 +8,7 @@
 #include "MemWatch.h"
 #include "RunTime.h"
 #include "StringTools.h"
+#include "FileTools.h"
 #include "tclap/CmdLine.h"
 #include "LogogSimpleFormatter.h"
 
diff --git a/Tests/BaseLib/TestSystemTools.cpp b/Tests/BaseLib/TestSystemTools.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..16666ee91dbece3e7101d11d61314c8200c060b1
--- /dev/null
+++ b/Tests/BaseLib/TestSystemTools.cpp
@@ -0,0 +1,25 @@
+/**
+ * Copyright (c) 2012, OpenGeoSys Community (http://www.opengeosys.org)
+ *            Distributed under a Modified BSD License.
+ *              See accompanying file LICENSE.txt or
+ *              http://www.opengeosys.org/project/license
+ *
+ * \file TestSystemTools.cpp
+ *
+ * Created on 2012-10-30 by Norihiro Watanabe
+ */
+
+// ** INCLUDES **
+#include "gtest.h"
+
+#include "SystemTools.h"
+
+TEST(BaseLib, EndianLittle) {
+    bool isLittle = false;
+    int x = 0x00000001;
+    if (*(char*)&x)
+        isLittle = true;              //am little
+
+	ASSERT_EQ (isLittle, BaseLib::IsLittleEndian());
+}
+
diff --git a/Utils/FileConverter/ConvertSHPToGLI.cpp b/Utils/FileConverter/ConvertSHPToGLI.cpp
index 954bbcb45ee27cdaf88f8635bb2bec1da552af76..7276ec255b002f6b98740e20074d45bedb8e7719 100644
--- a/Utils/FileConverter/ConvertSHPToGLI.cpp
+++ b/Utils/FileConverter/ConvertSHPToGLI.cpp
@@ -87,7 +87,7 @@ void convertPoints (DBFHandle dbf_handle,
 					name += DBFReadStringAttribute(dbf_handle, k, name_component_ids[j]);
 					name += " ";
 				}
-		} else name = number2str(k);
+		} else name = BaseLib::number2str(k);
 
 		if (station) {
 			GeoLib::Station* pnt(GeoLib::Station::createStation(name, x, y, z));
diff --git a/scripts/cmake/CheckTypeSizes.cmake b/scripts/cmake/CheckTypeSizes.cmake
index 4d9f23b54b1e5625997e2be48ee0c893a4c081a7..e88ff9e73d1eb40254410f97e54db55483fb2c83 100644
--- a/scripts/cmake/CheckTypeSizes.cmake
+++ b/scripts/cmake/CheckTypeSizes.cmake
@@ -14,4 +14,16 @@ ELSE()
 	SET( HAVE_64_BIT 1 )
 	ADD_DEFINITIONS(-DHAVE_64_BIT)
 	SET( BITS 64)
-ENDIF()
\ No newline at end of file
+ENDIF()
+
+# Check endian of the system
+INCLUDE (TestBigEndian)
+TEST_BIG_ENDIAN (IS_BIG_ENDIAN)
+IF (IS_BIG_ENDIAN)
+    ADD_DEFINITIONS(-DENDIAN_IS_BIG)
+   # cannot use BIG_ENDIAN because it's reserved in Linux
+ELSE ()
+    ADD_DEFINITIONS(-DENDIAN_IS_LITTLE)
+   # cannot use LITTLE_ENDIAN because it's reserved in Linux
+ENDIF () # IS_BIG_ENDIAN
+