diff --git a/.gitmodules b/.gitmodules
index 8c451bbaebf1dc5a336d41b8622b29db380480cc..20e442982ba43811b2c7ba5978e0f4c38c2648d3 100755
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,24 +1,36 @@
 [submodule "libdap"]
 	path = libdap
 	url = https://github.com/kelvinblockchain/libdap
+	branch = master
+[submodule "libdap-crypto"]
+	path = libdap-crypto
+	url = https://github.com/cellframe/libdap-crypto
+	branch = master
 [submodule "libdap-server-core"]
 	path = libdap-server-core
 	url = https://github.com/kelvinblockchain/libdap-server-core
+	branch = master
 [submodule "libdap-server"]
 	path = libdap-server
 	url = https://github.com/kelvinblockchain/libdap-server
+	branch = master
 [submodule "libdap-stream"]
 	path = libdap-stream
 	url = https://github.com/kelvinblockchain/libdap-stream
+	branch = master
 [submodule "libdap-stream-ch"]
 	path = libdap-stream-ch
 	url = https://github.com/kelvinblockchain/libdap-stream-ch
+	branch = master
 [submodule "test/libdap-test"]
 	path = test/libdap-test
 	url = https://github.com/kelvinblockchain/libdap-test
+	branch = master
 [submodule "libdap-stream-ch-chain"]
 	path = libdap-stream-ch-chain
 	url = https://github.com/kelvinblockchain//libdap-stream-ch-chain
+	branch = master
 [submodule "libdap-server-udp"]
 	path = libdap-server-udp
 	url = https://github.com/kelvinblockchain/libdap-server-udp
+	branch = master
diff --git a/.travis.yml b/.travis.yml
index 87cdc684f359aeb8c7416f0ca055bec25872ca81..e7bbd5baf1095dcbd0ab5679409cda3224a8383d 100755
--- a/.travis.yml
+++ b/.travis.yml
@@ -12,7 +12,7 @@ before_install:
 script:
     - mkdir build
     - cd build 
-    - cmake -DBUILD_LIB_DAP_CLIENT_TESTS=ON ../
+    - cmake -DBUILD_DAP_CLIENT_TESTS=ON ../
     - make
     - ctest --verbose
 
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7acd042de8cc54b7b080e272c86427bdcc9bf361..042edff4b71c2acb9292bdc64a138083c93f97c1 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,27 +1,52 @@
 cmake_minimum_required(VERSION 3.0)
-project (dap_client)
-set(CMAKE_C_STANDARD 11)
+project(dap_client)
+add_definitions ("-D_GNU_SOURCE")
 
 if(NOT (${SUBMODULES_NO_BUILD} MATCHES ON))
     set(SUBMODULES_NO_BUILD ON)
-    add_subdirectory(libdap)
-    add_subdirectory(libdap-server-core)
-    add_subdirectory(libdap-server)
-    add_subdirectory(libdap-server-udp)
-    add_subdirectory(libdap-stream)
-    add_subdirectory(libdap-stream-ch)
+    if ( NOT ( TARGET dap_core ) )
+        add_subdirectory(libdap)
+    endif()
+
+    if ( NOT ( TARGET dap_crypto ) )
+        add_subdirectory(libdap-crypto)
+    endif()
+
+    if ( NOT ( TARGET dap_server_core ) )
+        add_subdirectory(libdap-server-core)
+    endif()
+
+    if ( NOT ( TARGET dap_server ) )
+        add_subdirectory(libdap-server)
+    endif()
+
+    if ( NOT ( TARGET dap_udp_server ) )
+        add_subdirectory(libdap-server-udp)
+    endif()
+
+    if ( NOT ( TARGET libdap-stream ) )
+        add_subdirectory(libdap-stream)
+    endif()
+
+    if ( NOT ( TARGET dap_stream_ch ) )
+        add_subdirectory(libdap-stream-ch)
+    endif()
+
 
-    enable_testing()
-    add_subdirectory(test)
 endif()
 
+file(GLOB DAP_CLIENT_SOURCES src/*.c)
+file(GLOB DAP_CLIENT_HEADERS include/*.h)
 
-file(GLOB DAP_CLIENT_SRCS *.c)
-file(GLOB DAP_CLIENT_HEADERS *.h)
+add_library(${PROJECT_NAME} STATIC ${DAP_CLIENT_HEADERS} ${DAP_CLIENT_SOURCES})
 
-add_library(${PROJECT_NAME} STATIC ${DAP_CLIENT_SRCS} ${DAP_CLIENT_HEADERS})
+target_link_libraries(${PROJECT_NAME} dap_test dap_core dap_crypto dap_server dap_udp_server dap_http_server dap_http_client dap_stream dap_session dap_stream_ch pthread memcached ev)
+target_include_directories(${PROJECT_NAME} PUBLIC include)
+target_include_directories(${PROJECT_NAME} PRIVATE src)
 
-target_link_libraries(${PROJECT_NAME} dap_crypto dap_core dap_http_server dap_session dap_stream dap_stream_ch curl)
 
-target_include_directories(${PROJECT_NAME} INTERFACE .)
+if (${BUILD_DAP_CLIENT_TESTS} MATCHES ON)
+    enable_testing()
+    add_subdirectory(test)
+endif()
 
diff --git a/dap_client.h b/include/dap_client.h
similarity index 100%
rename from dap_client.h
rename to include/dap_client.h
diff --git a/dap_client_pool.h b/include/dap_client_pool.h
similarity index 100%
rename from dap_client_pool.h
rename to include/dap_client_pool.h
diff --git a/dap_client_pvt.h b/include/dap_client_pvt.h
similarity index 100%
rename from dap_client_pvt.h
rename to include/dap_client_pvt.h
diff --git a/libdap b/libdap
index d37b2aa26d2a7cc068529db343a87fd728904d33..4ab41cdcaa8087323652cd5fef702876ccc25dab 160000
--- a/libdap
+++ b/libdap
@@ -1 +1 @@
-Subproject commit d37b2aa26d2a7cc068529db343a87fd728904d33
+Subproject commit 4ab41cdcaa8087323652cd5fef702876ccc25dab
diff --git a/libdap-crypto b/libdap-crypto
new file mode 160000
index 0000000000000000000000000000000000000000..ff63d762657f9687173db825705b8bf4b958abee
--- /dev/null
+++ b/libdap-crypto
@@ -0,0 +1 @@
+Subproject commit ff63d762657f9687173db825705b8bf4b958abee
diff --git a/libdap-server b/libdap-server
index 2520382b703cc4308a6bb017da3b2cc5b95083b9..2cc113d3ef8234037016ac21f33731998bba6552 160000
--- a/libdap-server
+++ b/libdap-server
@@ -1 +1 @@
-Subproject commit 2520382b703cc4308a6bb017da3b2cc5b95083b9
+Subproject commit 2cc113d3ef8234037016ac21f33731998bba6552
diff --git a/libdap-server-core b/libdap-server-core
index e5bb9b75237cd702c5980b4070da9842d1f101e2..1008394f0ecdbc41d995a4cc5bbc4b51ad789eaf 160000
--- a/libdap-server-core
+++ b/libdap-server-core
@@ -1 +1 @@
-Subproject commit e5bb9b75237cd702c5980b4070da9842d1f101e2
+Subproject commit 1008394f0ecdbc41d995a4cc5bbc4b51ad789eaf
diff --git a/libdap-server-udp b/libdap-server-udp
index 1668210c08275ec85f8278a80c66b50e7414d61c..bbf1b9db2c3af9a3a59f6debb90ddc8db55ae2eb 160000
--- a/libdap-server-udp
+++ b/libdap-server-udp
@@ -1 +1 @@
-Subproject commit 1668210c08275ec85f8278a80c66b50e7414d61c
+Subproject commit bbf1b9db2c3af9a3a59f6debb90ddc8db55ae2eb
diff --git a/libdap-stream b/libdap-stream
index 550a546222f8b07c0687c9feaea32d3f2c66e87c..7a53ab997e1079000d0f7477d30e4d58cf4185f7 160000
--- a/libdap-stream
+++ b/libdap-stream
@@ -1 +1 @@
-Subproject commit 550a546222f8b07c0687c9feaea32d3f2c66e87c
+Subproject commit 7a53ab997e1079000d0f7477d30e4d58cf4185f7
diff --git a/dap_client.c b/src/dap_client.c
similarity index 99%
rename from dap_client.c
rename to src/dap_client.c
index 32a47fbb61b4bd24e1f66b3057238fb12bd1a246..391b95b3cf45dfa00bb237f7548e034884a6828a 100644
--- a/dap_client.c
+++ b/src/dap_client.c
@@ -302,12 +302,8 @@ int dap_client_disconnect( dap_client_t *a_client )
 //            l_client_internal->stream_es = NULL;
 //        }
 
-<<<<<<< HEAD
 //        l_client_internal->stream_es->signal_close = true;
         dap_events_kill_socket( l_client_internal->stream_es );
-=======
-        l_client_internal->stream_es->signal_close = true;
->>>>>>> bec1af426c69b6a96e831f61603c00135bbd9305
 
 //        if (l_client_internal->stream_socket ) {
 //            close (l_client_internal->stream_socket);
diff --git a/dap_client_pool.c b/src/dap_client_pool.c
similarity index 100%
rename from dap_client_pool.c
rename to src/dap_client_pool.c
diff --git a/dap_client_pvt.c b/src/dap_client_pvt.c
similarity index 100%
rename from dap_client_pvt.c
rename to src/dap_client_pvt.c
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 4ea6b6a688233d28707ffefb1600484d9c681e63..065db522c9ca6c0ce661dc47e244e3f7c16cf6dc 100755
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -1,18 +1,18 @@
-if(TARGET libdap_client_test)
-    return() # The project has already been built.
-endif()
-project(libdap_client_test)
+project(dap_client_test)
+
 
-add_subdirectory(libdap-test)
+if ( NOT ( TARGET dap_test ) )
+    add_subdirectory(libdap-test)
+endif()
 
-file(GLOB SOURCES *.c)
-file(GLOB HEADERS *.h)
+file(GLOB DAP_CLIENT_TEST_SOURCES *.c)
+file(GLOB DAP_CLIENT_TEST_HEADERS *.h)
 
-add_executable(${PROJECT_NAME} ${SOURCES} ${HEADERS})
+add_executable(${PROJECT_NAME} ${DAP_CLIENT_TEST_SOURCES} ${DAP_CLIENT_TEST_HEADERS})
 
-target_link_libraries(${PROJECT_NAME} dap_test dap_core)
+target_link_libraries(${PROJECT_NAME} dap_test dap_core dap_crypto dap_server_core ev pthread)
 
 add_test(
-    NAME libdap_client_test
-    COMMAND libdap_client_test
+    NAME dap_client_test
+    COMMAND dap_client_test
 )
diff --git a/test/main.c b/test/main.c
index d015aec2588f35b803c5923f045beeb994a85583..6527055741bdd36b50929c42c1a6bec70f6007cf 100755
--- a/test/main.c
+++ b/test/main.c
@@ -2,6 +2,6 @@
 
 int main(void) {
     // switch off debug info from library
-    set_log_level(L_CRITICAL);
+    dap_log_level_set(L_CRITICAL);
     return 0;
 }