diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt
deleted file mode 100644
index 52c0e40d6a41bec58056cc00d07d70967ed9fcf1..0000000000000000000000000000000000000000
--- a/code/CMakeLists.txt
+++ /dev/null
@@ -1,91 +0,0 @@
-PROJECT(GRM)
-
-cmake_minimum_required(VERSION 2.8)
-
-FIND_PACKAGE(OTB)
-IF(OTB_FOUND)
-  INCLUDE(${OTB_USE_FILE})
-ELSE(OTB_FOUND)
-  MESSAGE(FATAL_ERROR
-    "Cannot build OTB project without OTB. Please set OTB_DIR.")
-ENDIF(OTB_FOUND)
-
-#Check compiler version
-if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
-    # require at least gcc 4.8
-    if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)
-        message(FATAL_ERROR "GCC version must be at least 4.8!")
-    endif()
-elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
-    # require at least clang 3.2
-    if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.2)
-        message(FATAL_ERROR "Clang version must be at least 3.2!")
-    endif()
-else()
-    message(WARNING "You are using an unsupported compiler! Compilation has only been tested with Clang and GCC.")
-endif()
-
-include(CheckCXXCompilerFlag)
-CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
-if(COMPILER_SUPPORTS_CXX11)
-	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fpermissive")
-else()
-        message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
-endif()
-
-file(
-	GLOB_RECURSE
-	HEADERS
-	"src/*.h"
-)
-
-file(
-	GLOB_RECURSE
-	TEMPLATES
-	"src/*.txx"
-)
-
-file(
-	GLOB_RECURSE
-	SOURCES
-	"src/*.cxx"
-)
-
-set(PROJ_INCLUDE_DIRS "")
-foreach(_headerFile ${HEADERS})
-	get_filename_component(_dir ${_headerFile} PATH)
-	list(APPEND PROJ_INCLUDE_DIRS ${_dir})
-endforeach()
-
-foreach(_templateFile ${TEMPLATES})
-	get_filename_component(_dir ${_templateFile} PATH)
-	list(APPEND PROJ_INCLUDE_DIRS ${_dir})
-endforeach()
-
-list(REMOVE_DUPLICATES PROJ_INCLUDE_DIRS)
-
-include_directories(${PROJ_INCLUDE_DIRS})
-
-ADD_EXECUTABLE(
- 	EuclideanDistanceSegmentation
-    apps/EuclideanDistanceSegmentation.cxx
-	${SOURCES}
-)
-
-TARGET_LINK_LIBRARIES(EuclideanDistanceSegmentation OTBCommon OTBIO boost_program_options)
-
-ADD_EXECUTABLE(
-	FLSASegmentation
-	apps/FLSASegmentation.cxx
-	${SOURCES}
-)
-
-TARGET_LINK_LIBRARIES(FLSASegmentation OTBCommon OTBIO boost_program_options)
-
-ADD_EXECUTABLE(
-	BaatzSegmentation
-	apps/BaatzSegmentation.cxx
-	${SOURCES}
-)
-
-TARGET_LINK_LIBRARIES(BaatzSegmentation OTBCommon OTBIO boost_program_options)
diff --git a/grm-copyright.txt b/grmlib-copyright.txt
similarity index 100%
rename from grm-copyright.txt
rename to grmlib-copyright.txt
diff --git a/code/apps/BaatzSegmentation.cxx b/src/Applications/BaatzSegmentation.cxx
similarity index 93%
rename from code/apps/BaatzSegmentation.cxx
rename to src/Applications/BaatzSegmentation.cxx
index dca7de5e00ae0f4d7f097a41c66f0c8de716eea6..8cccbb9262d15f672772d651b64f1c83b101e714 100644
--- a/code/apps/BaatzSegmentation.cxx
+++ b/src/Applications/BaatzSegmentation.cxx
@@ -41,6 +41,7 @@ int main(int argc, char **argv)
 		seg_.SetInput(vm["input"].as<std::string>());
 		seg_.SetOutputRGB(vm["output_rgb"].as<std::string>());
 		seg_.SetParameters(params);
+		seg_.SetNumberOfIterations(vm["iter"].as<unsigned int>());
 
 		seg_.InitFromImage();
 		seg_.Segmentation();
@@ -61,8 +62,11 @@ bool init_args(int argc, char ** argv, po::options_description& desc, po::variab
 		("cw", po::value<float>(), "set the spectral weight (mandatory)")
 		("sw", po::value<float>(), "set the shape weight (mandatory)")
 		("sp", po::value<float>(), "set the scale parameter (mandatory)")
-		("iter", po::value<unsigned int>(), "set the number of iterations using LMBF (optional)")
-		("bf", po::value<int>(), "activate the Best Fitting Heuristic (optional)");
+		("iter", po::value<unsigned int>(), "set the number of iterations using LMBF\
+ 											(optional [value by default (70)])")
+		("bf", po::value<int>(), "activate the Best Fitting Heuristic \
+								[1: activated 0: desactivated] \
+								(optional [activated by default])");
 
 	po::store(po::parse_command_line(argc, argv, desc), vm);
 	po::notify(vm);
diff --git a/src/Applications/CMakeLists.txt b/src/Applications/CMakeLists.txt
new file mode 100644
index 0000000000000000000000000000000000000000..73d38e6bab4dcca7ec3f83da8a9e55f1a1c4fbe6
--- /dev/null
+++ b/src/Applications/CMakeLists.txt
@@ -0,0 +1,31 @@
+#=========================================================================
+
+#  Program: Generic Region Merging Library (GRM)
+#  Language: C++
+#  author: Lassalle Pierre
+
+
+
+#  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved
+
+#  See grmlib-copyright.txt for details.
+
+#     This software is distributed WITHOUT ANY WARRANTY; without even
+#     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+#     PURPOSE.  See the above copyright notices for more information.
+
+#=========================================================================
+add_executable(EuclideanDistanceSegmentation EuclideanDistanceSegmentation.cxx)
+target_link_libraries(EuclideanDistanceSegmentation 
+					GRM 
+					boost_program_options)
+
+add_executable(FLSASegmentation FLSASegmentation.cxx)
+target_link_libraries(FLSASegmentation 
+						GRM
+						boost_program_options)
+
+add_executable(BaatzSegmentation BaatzSegmentation.cxx)
+target_link_libraries(BaatzSegmentation 
+					GRM
+					boost_program_options)
diff --git a/code/apps/EuclideanDistanceSegmentation.cxx b/src/Applications/EuclideanDistanceSegmentation.cxx
similarity index 100%
rename from code/apps/EuclideanDistanceSegmentation.cxx
rename to src/Applications/EuclideanDistanceSegmentation.cxx
diff --git a/code/apps/FLSASegmentation.cxx b/src/Applications/FLSASegmentation.cxx
similarity index 97%
rename from code/apps/FLSASegmentation.cxx
rename to src/Applications/FLSASegmentation.cxx
index 1a87d5682d8c3f426bdd7dba0a531169b4468789..2927fc618df3fe9970cf8dd0c41032c4c4b9ed19 100644
--- a/code/apps/FLSASegmentation.cxx
+++ b/src/Applications/FLSASegmentation.cxx
@@ -41,6 +41,7 @@ int main(int argc, char **argv)
 		seg_.SetInput(vm["input"].as<std::string>());
 		seg_.SetOutputRGB(vm["output_rgb"].as<std::string>());
 		seg_.SetParameters(params);
+		seg_.SetNumberOfIterations(vm["iter"].as<unsigned int>());
 
 		seg_.InitFromImage();
 		seg_.Segmentation();
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
new file mode 100644
index 0000000000000000000000000000000000000000..bf76e2092aab7b957ac27218b1e1f41a2ffb552a
--- /dev/null
+++ b/src/CMakeLists.txt
@@ -0,0 +1,50 @@
+#=========================================================================
+
+#  Program: Generic Region Merging Library (GRM)
+#  Language: C++
+#  author: Lassalle Pierre
+
+
+
+#  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved
+
+#  See grmlib-copyright.txt for details.
+
+#     This software is distributed WITHOUT ANY WARRANTY; without even
+#     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+#     PURPOSE.  See the above copyright notices for more information.
+
+#=========================================================================
+project(GRM)
+
+cmake_minimum_required(VERSION 2.8)
+
+find_package(OTB)
+IF(OTB_FOUND)
+  include(${OTB_USE_FILE})
+ELSE(OTB_FOUND)
+  message(FATAL_ERROR
+    "Cannot build OTB project without OTB. Please set OTB_DIR.")
+ENDIF(OTB_FOUND)
+
+#Check compiler version
+if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
+    # require at least gcc 4.8
+    if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)
+        message(FATAL_ERROR "GCC version must be at least 4.8!")
+    endif()
+elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
+    # require at least clang 3.2
+    if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.2)
+        message(FATAL_ERROR "Clang version must be at least 3.2!")
+    endif()
+else()
+    message(WARNING "You are using an unsupported compiler! Compilation has only been tested with Clang and GCC.")
+endif()
+
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fpermissive")
+
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Library)
+
+add_subdirectory(Library)
+add_subdirectory(Applications)
diff --git a/src/Library/CMakeLists.txt b/src/Library/CMakeLists.txt
new file mode 100644
index 0000000000000000000000000000000000000000..dd34c538546abe82961090cf6e4ecfc54b34dc8b
--- /dev/null
+++ b/src/Library/CMakeLists.txt
@@ -0,0 +1,20 @@
+#=========================================================================
+
+#  Program: Generic Region Merging Library (GRM)
+#  Language: C++
+#  author: Lassalle Pierre
+
+
+
+#  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved
+
+#  See grmlib-copyright.txt for details.
+
+#     This software is distributed WITHOUT ANY WARRANTY; without even
+#     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+#     PURPOSE.  See the above copyright notices for more information.
+
+#=========================================================================
+file(GLOB SRC "*.cxx")
+add_library(GRM ${SRC})
+target_link_libraries(GRM OTBCommon OTBIO)
diff --git a/code/src/algo/baatz-algorithm.h b/src/Library/baatz-algorithm.h
similarity index 100%
rename from code/src/algo/baatz-algorithm.h
rename to src/Library/baatz-algorithm.h
diff --git a/code/src/algo/baatz-algorithm.txx b/src/Library/baatz-algorithm.txx
similarity index 100%
rename from code/src/algo/baatz-algorithm.txx
rename to src/Library/baatz-algorithm.txx
diff --git a/code/src/encoder/contour-encoder.cxx b/src/Library/contour-encoder.cxx
similarity index 99%
rename from code/src/encoder/contour-encoder.cxx
rename to src/Library/contour-encoder.cxx
index 27bf715612fccd30f0c24b0667a87017e27a1da9..c963960981a5219c5fdd88c7fe8bf082880aa7d2 100644
--- a/code/src/encoder/contour-encoder.cxx
+++ b/src/Library/contour-encoder.cxx
@@ -1,6 +1,6 @@
 /*=========================================================================
 
-  Program:  Shape Encoder library
+  Program:  Shape Encoder librarie of OBIA (Object Based Image Analysis)
   Language:  C++
   author:    Lassalle Pierre
 
diff --git a/code/src/encoder/contour-encoder.h b/src/Library/contour-encoder.h
similarity index 97%
rename from code/src/encoder/contour-encoder.h
rename to src/Library/contour-encoder.h
index a29162263cdf4555e87a539ad357f86e5793d660..ffbef159390bc345a1fdad79ded92336ac7efd7d 100644
--- a/code/src/encoder/contour-encoder.h
+++ b/src/Library/contour-encoder.h
@@ -1,6 +1,6 @@
 /*=========================================================================
 
-  Program: Shape Encoder library
+  Program: Shape Encoder librarie of OBIA (Object Based Image Analysis)
   Language:  C++
   author:    Lassalle Pierre
 
diff --git a/code/src/algo/euc-dist-algorithm.h b/src/Library/euc-dist-algorithm.h
similarity index 100%
rename from code/src/algo/euc-dist-algorithm.h
rename to src/Library/euc-dist-algorithm.h
diff --git a/code/src/algo/euc-dist-algorithm.txx b/src/Library/euc-dist-algorithm.txx
similarity index 100%
rename from code/src/algo/euc-dist-algorithm.txx
rename to src/Library/euc-dist-algorithm.txx
diff --git a/code/src/algo/fls-algorithm.h b/src/Library/fls-algorithm.h
similarity index 100%
rename from code/src/algo/fls-algorithm.h
rename to src/Library/fls-algorithm.h
diff --git a/code/src/algo/fls-algorithm.txx b/src/Library/fls-algorithm.txx
similarity index 100%
rename from code/src/algo/fls-algorithm.txx
rename to src/Library/fls-algorithm.txx
diff --git a/code/src/grm_core/grm-algorithm.h b/src/Library/grm-algorithm.h
similarity index 100%
rename from code/src/grm_core/grm-algorithm.h
rename to src/Library/grm-algorithm.h
diff --git a/code/src/grm_core/grm-algorithm.txx b/src/Library/grm-algorithm.txx
similarity index 100%
rename from code/src/grm_core/grm-algorithm.txx
rename to src/Library/grm-algorithm.txx
diff --git a/code/src/grm_core/grm-interface.h b/src/Library/grm-interface.h
similarity index 100%
rename from code/src/grm_core/grm-interface.h
rename to src/Library/grm-interface.h
diff --git a/code/src/grm_core/grm-interface.txx b/src/Library/grm-interface.txx
similarity index 100%
rename from code/src/grm_core/grm-interface.txx
rename to src/Library/grm-interface.txx
diff --git a/code/src/grm_core/grm-region.h b/src/Library/grm-region.h
similarity index 100%
rename from code/src/grm_core/grm-region.h
rename to src/Library/grm-region.h
diff --git a/code/src/grm_core/grm-region.txx b/src/Library/grm-region.txx
similarity index 100%
rename from code/src/grm_core/grm-region.txx
rename to src/Library/grm-region.txx
diff --git a/code/src/utilities/macro-generator.h b/src/Library/macro-generator.h
similarity index 100%
rename from code/src/utilities/macro-generator.h
rename to src/Library/macro-generator.h
diff --git a/code/src/utilities/mask-neighborhood.cxx b/src/Library/mask-neighborhood.cxx
similarity index 100%
rename from code/src/utilities/mask-neighborhood.cxx
rename to src/Library/mask-neighborhood.cxx
diff --git a/code/src/utilities/mask-neighborhood.h b/src/Library/mask-neighborhood.h
similarity index 100%
rename from code/src/utilities/mask-neighborhood.h
rename to src/Library/mask-neighborhood.h