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/FileTools.cpp b/BaseLib/FileTools.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..16d0ee3d59cee03d6e03df0383700af3edc43fe9
--- /dev/null
+++ b/BaseLib/FileTools.cpp
@@ -0,0 +1,63 @@
+/**
+ * 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();
+}
+
+} // end namespace BaseLib
+
diff --git a/BaseLib/FileTools.h b/BaseLib/FileTools.h
index 1020374ad38f64142ebef83c9f357767d16d547c..2858e11f79b48d177d77ebe1dcd8642e5d7b1f79 100644
--- a/BaseLib/FileTools.h
+++ b/BaseLib/FileTools.h
@@ -15,42 +15,38 @@
 #ifndef FILETOOLS_H
 #define FILETOOLS_H
 
-// ** INCLUDES **
-#include <sys/stat.h>
+#include <string>
+#include <fstream>
+
+namespace BaseLib
+{
 
-namespace BaseLib {
 /**
- * Returns true if given file exists. From http://www.techbytes.ca/techbyte103.html
+ * \brief Returns true if given file exists. From http://www.techbytes.ca/techbyte103.html
+ *
+ * \param strFilename         the file name
  */
-static bool IsFileExisting(std::string strFilename)
+bool IsFileExisting(const std::string &strFilename);
+
+/**
+ * \brief write value as binary into the given output stream
+ *
+ * \tparam T    data type of the value
+ * \param out   output stream
+ * \param val   value
+ */
+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);
+
 } // 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/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/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/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
+