diff --git a/src/Makefile.am b/src/Makefile.am
index 3b101663451fab612a736c781909fb5f224e241a..d4866d5c09a4f5734975a6d1c1c716034a42cdfe 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -6,10 +6,8 @@ sbin_PROGRAMS = knotd
 # $(YACC) will generate header file
 AM_CFLAGS = -Wall
 AM_YFLAGS = -d
-libknot_la_YFLAGS = -pcf_ -d
-libknot_la_LFLAGS = # TODO: reentrant parser, prefix
-
-LDADD = libknot.la @LIBOBJS@
+libknotd_la_YFLAGS = -pcf_ -d
+libknotd_la_LFLAGS = # TODO: reentrant parser, prefix
 
 BUILT_SOURCES =					\
 	dnslib/tests/parsed_data.rc		\
@@ -113,14 +111,15 @@ nodist_unittests_SOURCES =			\
 	dnslib/tests/parsed_data.rc		\
 	dnslib/tests/raw_data_queries.rc	\
 	dnslib/tests/raw_data.rc		\
-	dnslib/tests/parsed_data_queries.rc     \
+	dnslib/tests/parsed_data_queries.rc	\
 	tests/sample_conf.rc
 
 knotd_SOURCES =					\
 	knot/main.c
 
-noinst_LTLIBRARIES = libknot.la
-libknot_la_SOURCES =				\
+noinst_LTLIBRARIES = libknot.la libknotd.la libknots.la
+
+libknots_la_SOURCES =				\
 	common/slab/slab.c			\
 	common/slab/malloc.c			\
 	common/slab/slab.h			\
@@ -142,7 +141,7 @@ libknot_la_SOURCES =				\
 	common/general-tree.c			\
 	common/dynamic-array.h			\
 	common/tree.h				\
-	common/base32hex.h				\
+	common/base32hex.h			\
 	common/evqueue.h		\
 	common/evqueue.c		\
 	common/evsched.h		\
@@ -155,20 +154,61 @@ libknot_la_SOURCES =				\
 	common/crc.c				\
 	common/ref.h				\
 	common/ref.c				\
+	common/errors.h				\
+	common/errors.c
+
+libknotd_la_SOURCES =				\
 	knot/stat/gatherer.c				\
 	knot/stat/stat.c				\
 	knot/stat/gatherer.h				\
 	knot/stat/stat.h				\
-	dnslib/edns.c                           \
-	common/errors.h				\
-	common/errors.c				\
+	knot/common.h				\
+	knot/other/log.c			\
+	knot/other/log.h			\
+	knot/other/debug.h			\
+	knot/other/error.h			\
+	knot/other/error.c			\
+	knot/conf/cf-parse.y			\
+	knot/conf/cf-lex.l			\
+	knot/conf/conf.c			\
+	knot/conf/logconf.c			\
+	knot/conf/logconf.h			\
+	knot/conf/conf.h			\
+	knot/ctl/process.c			\
+	knot/ctl/process.h			\
+	knot/server/dthreads.c			\
+	knot/server/journal.c			\
+	knot/server/socket.c				\
+	knot/server/name-server.c			\
+	knot/server/server.c				\
+	knot/server/udp-handler.c			\
+	knot/server/tcp-handler.c			\
+	knot/server/xfr-handler.c			\
+	knot/server/zones.c				\
+	knot/server/socket.h				\
+	knot/server/name-server.h			\
+	knot/server/udp-handler.h			\
+	knot/server/tcp-handler.h			\
+	knot/server/xfr-handler.h			\
+	knot/server/dthreads.h			\
+	knot/server/journal.h			\
+	knot/server/zones.h				\
+	knot/server/notify.h				\
+	knot/server/notify.c				\
+	knot/server/zones.h				\
+	knot/server/xfr-in.h				\
+	knot/server/xfr-in.c				\
+	knot/server/server.h
+	
+libknot_la_SOURCES =				\
+	dnslib/edns.c				\
 	dnslib/dnslib-error.c			\
 	dnslib/utils.c				\
 	dnslib/rrset.c				\
 	dnslib/dname.c				\
 	dnslib/node.c				\
-	dnslib/packet.c			\
-	dnslib/query.c			\
+	dnslib/packet.c				\
+	dnslib/query.c				\
 	dnslib/response2.c			\
 	dnslib/response.c			\
 	dnslib/zone.c				\
@@ -213,46 +253,19 @@ libknot_la_SOURCES =				\
 	dnslib/wire.h				\
 	dnslib/debug.h				\
 	dnslib/nsec3.h				\
-	dnslib/dname-table.h			\
-	knot/common.h				\
-	knot/other/log.c			\
-	knot/other/log.h			\
-	knot/other/debug.h			\
-	knot/other/error.h			\
-	knot/other/error.c			\
-	knot/conf/cf-parse.y			\
-	knot/conf/cf-lex.l			\
-	knot/conf/conf.c			\
-	knot/conf/logconf.c			\
-	knot/conf/logconf.h			\
-	knot/conf/conf.h			\
-	knot/ctl/process.c			\
-	knot/ctl/process.h			\
-	knot/server/dthreads.c			\
-	knot/server/journal.c			\
-	knot/server/socket.c				\
-	knot/server/name-server.c			\
-	knot/server/server.c				\
-	knot/server/udp-handler.c			\
-	knot/server/tcp-handler.c			\
-	knot/server/xfr-handler.c			\
-	knot/server/zones.c				\
-	knot/server/socket.h				\
-	knot/server/name-server.h			\
-	knot/server/udp-handler.h			\
-	knot/server/tcp-handler.h			\
-	knot/server/xfr-handler.h			\
-	knot/server/dthreads.h			\
-	knot/server/journal.h			\
-	knot/server/zones.h				\
-	knot/server/notify.h				\
-	knot/server/notify.c				\
-	knot/server/zones.h				\
-	knot/server/xfr-in.h				\
-	knot/server/xfr-in.c				\
-	knot/server/server.h
+	dnslib/dname-table.h
+
 
-libknot_la_LIBADD = @LIBOBJS@
+libknot_la_LIBADD = libknots.la @LIBOBJS@
+libknotd_la_LIBADD = libknot.la libknots.la @LIBOBJS@
+libknots_la_LIBADD = @LIBOBJS@
+knotd_LDADD = libknotd.la libknot.la libknots.la @LIBOBJS@
+knotc_LDADD = libknotd.la libknot.la libknots.la @LIBOBJS@
+knot_zcompile_LDADD = libknots.la libknot.la @LIBOBJS@
+unittests_LDADD = libknotd.la libknots.la @LIBOBJS@
+unittests_zcompile_LDADD = libknot.la libknots.la @LIBOBJS@
+unittests_dnslib_LDADD = libknot.la libknots.la @LIBOBJS@
+unittests_dnslib_realdata_LDADD = libknot.la libknots.la @LIBOBJS@
 
 # automake complains on % rules:
 #   `%'-style pattern rules are a GNU make extension
diff --git a/src/dnslib/tests/realdata/unittests_dnslib_realdata.c b/src/dnslib/tests/realdata/unittests_dnslib_realdata.c
index ab6b831d6b442f20072d9a5d81c2703c60a15f0a..e5f81825451d36c7b3849434b35977364cac17be 100644
--- a/src/dnslib/tests/realdata/unittests_dnslib_realdata.c
+++ b/src/dnslib/tests/realdata/unittests_dnslib_realdata.c
@@ -1,5 +1,5 @@
 #include <config.h>
-#include "knot/common.h"
+//#include "knot/common.h"
 #include "common/libtap/tap_unit.h"
 
 #include "dnslib/tests/realdata/dnslib_tests_loader_realdata.h"
@@ -26,7 +26,7 @@ int main(int argc, char *argv[])
 	}
 
 	// Open log
-	log_init(LOG_UPTO(LOG_ERR), LOG_MASK(LOG_ERR) | LOG_MASK(LOG_WARNING));
+//	log_init(LOG_UPTO(LOG_ERR), LOG_MASK(LOG_ERR) | LOG_MASK(LOG_WARNING));
 
 	// Build test set
 	unit_api *tests[] = {
@@ -65,7 +65,7 @@ int main(int argc, char *argv[])
 		++id;
 	}
 
-	log_close();
+//	log_close();
 
 	// Evaluate
 	return exit_status();
diff --git a/src/dnslib/tests/unittests_dnslib.c b/src/dnslib/tests/unittests_dnslib.c
index 77ef41563e24ddeef1f7b5d82eec8f4b01cf874e..860fd2e265b956410948dc6e9fa7f221a7394d57 100644
--- a/src/dnslib/tests/unittests_dnslib.c
+++ b/src/dnslib/tests/unittests_dnslib.c
@@ -1,5 +1,5 @@
 #include <config.h>
-#include "knot/common.h"
+//#include "knot/common.h"
 #include "common/libtap/tap_unit.h"
 
 // Units to test
@@ -17,7 +17,7 @@
 int main(int argc, char *argv[])
 {
 	// Open log
-	log_init(LOG_UPTO(LOG_ERR), LOG_MASK(LOG_ERR) | LOG_MASK(LOG_WARNING));
+//	log_init(LOG_UPTO(LOG_ERR), LOG_MASK(LOG_ERR) | LOG_MASK(LOG_WARNING));
 
 	// Build test set
 	unit_api *tests[] = {
@@ -56,7 +56,7 @@ int main(int argc, char *argv[])
 		++id;
 	}
 
-	log_close();
+//	log_close();
 
 	// Evaluate
 	return exit_status();
diff --git a/src/knot/conf/cf-lex.l b/src/knot/conf/cf-lex.l
index 0b54e93f02a108d73b2675f8f810399a5357870f..f36b0f5e73d8f8133c70911097215534aadfef40 100644
--- a/src/knot/conf/cf-lex.l
+++ b/src/knot/conf/cf-lex.l
@@ -16,7 +16,7 @@
 #include "common/sockaddr.h"
 #include "knot/conf/conf.h"
 #include "knot/other/log.h"
-#include "libknot_la-cf-parse.h" /* Automake generated header. */
+#include "libknotd_la-cf-parse.h" /* Automake generated header. */
 
 /* Imported symbols. */
 #define cf_lval (*yylval)
diff --git a/src/knot/conf/cf-parse.y b/src/knot/conf/cf-parse.y
index adb8f551b743ebbc7d3fe9a5269be67654a706e2..e9dc8db5a1a54ca3e28713c7c83664dc92ccb96d 100644
--- a/src/knot/conf/cf-parse.y
+++ b/src/knot/conf/cf-parse.y
@@ -12,7 +12,7 @@
 #include <stdlib.h>
 #include "dnslib/dname.h"
 #include "knot/conf/conf.h"
-#include "libknot_la-cf-parse.h" /* Automake generated header. */
+#include "libknotd_la-cf-parse.h" /* Automake generated header. */
 
 extern int cf_lex (YYSTYPE *lvalp, void *scanner);
 extern void cf_error(const char *msg, void *scanner);