diff --git a/daemon/configure.ac b/daemon/configure.ac
index a06fe449c80fd9334c5be2658879084583e8642b..f14d3faba8bca7058ea67562ad241e7c8938ad80 100644
--- a/daemon/configure.ac
+++ b/daemon/configure.ac
@@ -50,7 +50,8 @@ AC_FUNC_ALLOCA
 AC_HEADER_STDC
 AC_CHECK_HEADERS([arpa/inet.h fcntl.h libintl.h limits.h malloc.h memory.h \
                   netdb.h netinet/in.h stdlib.h string.h strings.h \
-                  sys/ioctl.h sys/socket.h sys/time.h unistd.h utime.h ostream])
+                  sys/ioctl.h sys/socket.h sys/time.h unistd.h utime.h \
+                  ostream getopt.h])
 
 dnl Check for typedefs, structures, and compiler characteristics
 AC_HEADER_STAT
diff --git a/daemon/src/Makefile.am b/daemon/src/Makefile.am
index b63fbb53275fb65fcd05161bd3b519b6198720e8..7d7e190ce8c3ca043566b02ad675a0ee6226642a 100644
--- a/daemon/src/Makefile.am
+++ b/daemon/src/Makefile.am
@@ -50,7 +50,8 @@ noinst_HEADERS = \
 		fileutils.h \
 		noncopyable.h \
 		cc_thread.h \
-		cc_config.h
+		cc_config.h \
+		sfl_types.h
 
 libsflphone_la_LIBADD = \
 	$(top_builddir)/libs/iax2/libiax2.la \
diff --git a/daemon/src/audio/Makefile.am b/daemon/src/audio/Makefile.am
index f816e45a5b45953a026a8c78b1b9d83ec0d65881..de8950ed4a11f11d71ea43ce4baf17acae4b5bf3 100644
--- a/daemon/src/audio/Makefile.am
+++ b/daemon/src/audio/Makefile.am
@@ -22,7 +22,6 @@ libaudio_la_SOURCES = \
 
 noinst_HEADERS = \
 		audioloop.h \
-		common.h \
 		ringbuffer.h \
 		mainbuffer.h \
 		audiorecord.h \
diff --git a/daemon/src/audio/alsa/alsalayer.cpp b/daemon/src/audio/alsa/alsalayer.cpp
index 05e7731f80d26993a4683eff8d4ed9a0a9fc44ba..f86566c264fbd29f10f0d824849c23a1001f0940 100644
--- a/daemon/src/audio/alsa/alsalayer.cpp
+++ b/daemon/src/audio/alsa/alsalayer.cpp
@@ -33,6 +33,7 @@
 #include "audio/dcblocker.h"
 #include "eventthread.h"
 #include "audio/samplerateconverter.h"
+#include "logger.h"
 #include "manager.h"
 #include "noncopyable.h"
 #include "dbus/configurationmanager.h"
diff --git a/daemon/src/audio/audiolayer.h b/daemon/src/audio/audiolayer.h
index dbc652cb96dc6dc249c9b5f5165659d57f50c0e6..b9aec5274cc8e9c5d6317c3dc109f717f23248cb 100644
--- a/daemon/src/audio/audiolayer.h
+++ b/daemon/src/audio/audiolayer.h
@@ -31,12 +31,12 @@
  *  as that of the covered work.
  */
 
-#ifndef __AUDIO_LAYER_H__
-#define __AUDIO_LAYER_H__
+#ifndef AUDIO_LAYER_H_
+#define AUDIO_LAYER_H_
 
 #include "cc_thread.h" // for ost::Mutex
 #include <sys/time.h>
-
+#include <vector>
 #include "ringbuffer.h"
 #include "dcblocker.h"
 #include "samplerateconverter.h"
diff --git a/daemon/src/audio/audioloop.cpp b/daemon/src/audio/audioloop.cpp
index 8c34366b7feddd47bd0a2ae74a7a66f10d749ef0..354f7c56f12685997d7a033d0cd43a225cc82959 100644
--- a/daemon/src/audio/audioloop.cpp
+++ b/daemon/src/audio/audioloop.cpp
@@ -37,6 +37,7 @@
 #include <numeric>
 #include <cstring>
 #include <cassert>
+#include "logger.h"
 
 AudioLoop::AudioLoop() : buffer_(0),  size_(0), pos_(0), sampleRate_(0)
 {}
diff --git a/daemon/src/audio/audioloop.h b/daemon/src/audio/audioloop.h
index cc6cc653fbe85e4df52c35e415667f70f497c20f..b7d54a7e0e2a499f22a79170b9654c7c7d1c3eb5 100644
--- a/daemon/src/audio/audioloop.h
+++ b/daemon/src/audio/audioloop.h
@@ -33,7 +33,8 @@
 #ifndef __AUDIOLOOP_H__
 #define __AUDIOLOOP_H__
 
-#include "global.h" // for SFLDataFormat
+#include "sfl_types.h"
+#include <cstring>
 #include "noncopyable.h"
 
 /**
diff --git a/daemon/src/audio/audiorecord.cpp b/daemon/src/audio/audiorecord.cpp
index a8215080c434cb25b9a1f14f55285f6094eea677..54c4bb6918b3c350a90ba8a0e1c29c7f8281c990 100644
--- a/daemon/src/audio/audiorecord.cpp
+++ b/daemon/src/audio/audiorecord.cpp
@@ -31,6 +31,8 @@
 #include "audiorecord.h"
 #include <unistd.h>
 #include <sstream> // for stringstream
+#include <cstdio>
+#include "logger.h"
 
 // structure for the wave header
 
diff --git a/daemon/src/audio/audiorecord.h b/daemon/src/audio/audiorecord.h
index 95571c198bf25eb9241581a4e5f065d7e3e7e8e1..83143255b49a5c108f8f798b1f5f962a2c0b497b 100644
--- a/daemon/src/audio/audiorecord.h
+++ b/daemon/src/audio/audiorecord.h
@@ -35,7 +35,7 @@
 #include <cstdlib>
 #include <memory>
 
-#include "global.h"
+#include "sfl_types.h"
 #include "noncopyable.h"
 
 class AudioRecord {
diff --git a/daemon/src/audio/audiortp/audio_rtp_record_handler.cpp b/daemon/src/audio/audiortp/audio_rtp_record_handler.cpp
index 99c5064d94a00d36bcfba5c137f3a9ff1848e312..3987474727e445b9a472ca471cd44c4f9b590c14 100644
--- a/daemon/src/audio/audiortp/audio_rtp_record_handler.cpp
+++ b/daemon/src/audio/audiortp/audio_rtp_record_handler.cpp
@@ -30,6 +30,7 @@
 #include "audio_rtp_record_handler.h"
 #include <fstream>
 
+#include "logger.h"
 #include "sip/sipcall.h"
 #include "audio/audiolayer.h"
 #include "manager.h"
diff --git a/daemon/src/audio/audiortp/audio_rtp_session.cpp b/daemon/src/audio/audiortp/audio_rtp_session.cpp
index 7a34d7ba82d94d4557502af243526e83d81154c4..b0464cae86f4ef6f1572ee902a68300459a62cdb 100644
--- a/daemon/src/audio/audiortp/audio_rtp_session.cpp
+++ b/daemon/src/audio/audiortp/audio_rtp_session.cpp
@@ -34,7 +34,7 @@
 
 #include "audio_rtp_session.h"
 #include "audio_symmetric_rtp_session.h"
-
+#include "logger.h"
 #include "sip/sdp.h"
 #include "sip/sipcall.h"
 #include "audio/audiolayer.h"
diff --git a/daemon/src/audio/audiortp/audio_srtp_session.cpp b/daemon/src/audio/audiortp/audio_srtp_session.cpp
index fb14463dbb0983fa9e669a9fb03f4fa2ed6021b8..7ad1ee5ee68beb0a732816c4672644262e42de1e 100644
--- a/daemon/src/audio/audiortp/audio_srtp_session.cpp
+++ b/daemon/src/audio/audiortp/audio_srtp_session.cpp
@@ -28,6 +28,7 @@
  *  as that of the covered work.
  */
 #include "audio_srtp_session.h"
+#include "logger.h"
 
 #include <openssl/sha.h>
 #include <openssl/hmac.h>
diff --git a/daemon/src/audio/audiortp/audio_symmetric_rtp_session.cpp b/daemon/src/audio/audiortp/audio_symmetric_rtp_session.cpp
index 3324f22ff4358f7713cf8e024decb2eff9f4abc1..ee5e3a53b3614c04633847a31848f00b87bdb188 100644
--- a/daemon/src/audio/audiortp/audio_symmetric_rtp_session.cpp
+++ b/daemon/src/audio/audiortp/audio_symmetric_rtp_session.cpp
@@ -35,6 +35,7 @@
 #include "audio_rtp_session.h"
 #include "audio_symmetric_rtp_session.h"
 #include "audio_rtp_record_handler.h"
+#include "logger.h"
 #include "sip/sdp.h"
 #include "sip/sipcall.h"
 #include "audio/audiolayer.h"
diff --git a/daemon/src/audio/audiortp/audio_zrtp_session.cpp b/daemon/src/audio/audiortp/audio_zrtp_session.cpp
index 180dc0bc25b846f482ed9ed013e8b0399e10bc15..ca4449e3188e8e3b42bee9ef3961dbd0ae6214b5 100644
--- a/daemon/src/audio/audiortp/audio_zrtp_session.cpp
+++ b/daemon/src/audio/audiortp/audio_zrtp_session.cpp
@@ -28,13 +28,17 @@
  *  as that of the covered work.
  */
 
+#ifdef HAVE_CONFIG_H
 #include "config.h"
+#endif
+
 #include "audio_zrtp_session.h"
 #include "zrtp_session_callback.h"
-
+#include "fileutils.h"
 #include "sip/sipcall.h"
 #include "sip/sdp.h"
 #include "audio/audiolayer.h"
+#include "logger.h"
 #include "manager.h"
 
 #include <libzrtpcpp/zrtpccrtp.h>
diff --git a/daemon/src/audio/audiortp/zrtp_session_callback.cpp b/daemon/src/audio/audiortp/zrtp_session_callback.cpp
index 061cf1c64c22b66f270e80302085e149d5328de8..4383d09d1553d3f62439e31f9c0f2f5720255f3a 100644
--- a/daemon/src/audio/audiortp/zrtp_session_callback.cpp
+++ b/daemon/src/audio/audiortp/zrtp_session_callback.cpp
@@ -28,7 +28,7 @@
  *  as that of the covered work.
  */
 #include "zrtp_session_callback.h"
-#include "global.h"
+#include "logger.h"
 #include "sip/sipcall.h"
 #include "dbus/dbusmanager.h"
 #include "dbus/callmanager.h"
diff --git a/daemon/src/audio/codecs/alaw.cpp b/daemon/src/audio/codecs/alaw.cpp
index eb219165d25c2fc7aaa8ea50361d6528940c769b..ab009bc0feed2109a9cb611050a274c5bcee23af 100644
--- a/daemon/src/audio/codecs/alaw.cpp
+++ b/daemon/src/audio/codecs/alaw.cpp
@@ -29,8 +29,7 @@
  *  as that of the covered work.
  */
 
-#include "global.h"
-#include "../common.h"
+#include "sfl_types.h"
 #include "audiocodec.h"
 #include <cassert>
 
diff --git a/daemon/src/audio/codecs/audiocodecfactory.cpp b/daemon/src/audio/codecs/audiocodecfactory.cpp
index 6436a6f6363cb2ec66dca3d83f67f6910a09b33c..809c6a59dcb1bfa932b6f230c4fa12e7507ea98e 100644
--- a/daemon/src/audio/codecs/audiocodecfactory.cpp
+++ b/daemon/src/audio/codecs/audiocodecfactory.cpp
@@ -31,11 +31,15 @@
  *  as that of the covered work.
  */
 
+#ifdef HAVE_CONFIG_H
 #include "config.h"
+#endif
+
 #include "audiocodecfactory.h"
 #include <cstdlib>
 #include <algorithm> // for std::find
 #include "fileutils.h"
+#include "logger.h"
 
 AudioCodecFactory::AudioCodecFactory() :
     codecsMap_(), defaultCodecOrder_(), libCache_(), codecInMemory_()
diff --git a/daemon/src/audio/codecs/g722.cpp b/daemon/src/audio/codecs/g722.cpp
index 94149746d8d50ae63ae0f1024bc0ba119e6b5427..4d1a1333714c913a9a1d9cbd6ecd8475ac7e1b6d 100644
--- a/daemon/src/audio/codecs/g722.cpp
+++ b/daemon/src/audio/codecs/g722.cpp
@@ -30,11 +30,8 @@
  *  as that of the covered work.
  */
 
-
-
-#include "global.h"
-#include "../common.h"
 #include "audiocodec.h"
+#include "sfl_types.h"
 #include "g722.h"
 #include "noncopyable.h"
 
diff --git a/daemon/src/audio/codecs/ulaw.cpp b/daemon/src/audio/codecs/ulaw.cpp
index 6811b45dd16391d1ccf08156c88971eaec653f70..3d535647604170a6251afaa9bfacf31fa7649e3e 100644
--- a/daemon/src/audio/codecs/ulaw.cpp
+++ b/daemon/src/audio/codecs/ulaw.cpp
@@ -29,10 +29,8 @@
  *  as that of the covered work.
  */
 
-
-#include "global.h"
-#include "../common.h"
 #include "audiocodec.h"
+#include "sfl_types.h"
 #include <cassert>
 
 class Ulaw : public sfl::AudioCodec {
diff --git a/daemon/src/audio/common.h b/daemon/src/audio/common.h
deleted file mode 100644
index e8a2b460fb8e6b436c5b25348dfcc2a155bbbfe9..0000000000000000000000000000000000000000
--- a/daemon/src/audio/common.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- *  Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010, 2011 Savoir-Faire Linux Inc.
- *  Author:
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- *  Additional permission under GNU GPL version 3 section 7:
- *
- *  If you modify this program, or any covered work, by linking or
- *  combining it with the OpenSSL project's OpenSSL library (or a
- *  modified version of that library), containing parts covered by the
- *  terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
- *  grants you additional permission to convey the resulting work.
- *  Corresponding Source for a non-source form of such a combination
- *  shall include the source code for the parts of OpenSSL used as well
- *  as that of the covered work.
- */
-
-/*
-	Type definitions and helper macros which aren't part of Standard C++
-	This will need to be edited on systems where 'char', 'short' and 'int'
-   	have sizes different from 8, 16 and 32 bits.
-*/
-
-#ifndef __COMMON_H__
-#define __COMMON_H__
-
-
-// #define DEBUG	/**< Defined when compiling code for debugging */
-
-/*
-Basic integer types.
-Note 'int' is assumed to be in 2s complement format and at least 32 bits in size
-*/
-typedef unsigned char  uint8;	/**< An 8 bit unsigned integer */
-typedef unsigned short uint16;	/**< An 16 bit unsigned integer */
-typedef unsigned int   uint32;	/**< An 32 bit unsigned integer */
-typedef signed char    int8;	/**< An 8 bit signed integer (2s complement) */
-typedef signed short   int16;	/**< An 16 bit signed integer (2s complement) */
-typedef signed int     int32;	/**< An 32 bit signed integer (2s complement) */
-typedef unsigned int   uint;	/**< An unsigned integer or at least 32 bits */
-
-#ifndef NULL
-#define NULL 0		/**< Used to represent a null pointer type */
-#endif
-
-#ifdef _MSC_VER		// Compiling for Microsoft Visual C++
-
-#define DEBUGGER	{ _asm int 3 }			/**< Invoke debugger */
-#define IMPORT		__declspec(dllexport)	/**< Mark a function which is to be imported from a DLL */
-#define EXPORT		__declspec(dllexport)	/**< Mark a function to be exported from a DLL */
-#define ASSERT(c)	{ if(!(c)) DEBUGGER; }	/**< Assert that expression 'c' is true */
-
-#else				// Not compiling for Microsoft Visual C++ ...
-
-#define DEBUGGER							/**< Invoke debugger */
-#define IMPORT								/**< Mark a function which is to be imported from a DLL */
-#define EXPORT								/**< Mark a function to be exported from a DLL */
-
-#endif
-
-#ifdef DEBUG
-#define ASSERT_DEBUG(c) ASSERT(c)	/**< Assert that expression 'c' is true (when compiled for debugging)*/
-#else
-#define ASSERT_DEBUG(c)
-#endif
-
-#endif
diff --git a/daemon/src/audio/dcblocker.h b/daemon/src/audio/dcblocker.h
index 6dbb073ea50330eef90b3308d20a99b1e2c4f524..aaa614b1ad8cbdbfbbfbeac6e9c7ff43deabe025 100644
--- a/daemon/src/audio/dcblocker.h
+++ b/daemon/src/audio/dcblocker.h
@@ -31,7 +31,7 @@
 #ifndef DCBLOCKER_H
 #define DCBLOCKER_H
 
-#include "global.h"
+#include "sfl_types.h"
 
 class DcBlocker {
     public:
diff --git a/daemon/src/audio/delaydetection.h b/daemon/src/audio/delaydetection.h
index 286baab13c628402b9ebfb615b5bd2fbb80ff99c..f83dba536e7e87463100e0b95dca9c2ef3b734c0 100644
--- a/daemon/src/audio/delaydetection.h
+++ b/daemon/src/audio/delaydetection.h
@@ -32,7 +32,7 @@
 #ifndef DELAYDETECTION_H
 #define DELAYDETECTION_H
 
-#include "global.h"
+#include "sfl_types.h"
 #include <vector>
 
 // Template size in samples for correlation
diff --git a/daemon/src/audio/echosuppress.cpp b/daemon/src/audio/echosuppress.cpp
index 4f384c0bf8a747ab752d52cf6ee6ccff86f17be8..b509155f8641cd83a17caad595d8d9ddb72769d2 100644
--- a/daemon/src/audio/echosuppress.cpp
+++ b/daemon/src/audio/echosuppress.cpp
@@ -7,8 +7,9 @@
 
 #include <cassert>
 #include <stdexcept>
-
+#include "logger.h"
 #include "echosuppress.h"
+#include "pjmedia/echo.h"
 #include "pj/pool.h"
 #include "pj/os.h"
 
diff --git a/daemon/src/audio/echosuppress.h b/daemon/src/audio/echosuppress.h
index 15b7eed93231622d00ed5d6c56ebcc014fd61e68..9b7d08fbecb83674d30c9e0a4fc81cf7190c1c89 100644
--- a/daemon/src/audio/echosuppress.h
+++ b/daemon/src/audio/echosuppress.h
@@ -8,10 +8,12 @@
 #ifndef ECHOSUPPRESS_H_
 #define ECHOSUPPRESS_H_
 
-#include "pjmedia/echo.h"
-#include "global.h"
+#include "sfl_types.h"
 #include "noncopyable.h"
 
+class pjmedia_echo_state;
+class pj_pool_t;
+
 class EchoSuppress {
     public:
         EchoSuppress(pj_pool_t *pool);
diff --git a/daemon/src/audio/gaincontrol.cpp b/daemon/src/audio/gaincontrol.cpp
index 336d99870cd5ebb93b69b451ac7c85c380da0982..1b100d73d861d7cd15c09496aba52ae14646a765 100644
--- a/daemon/src/audio/gaincontrol.cpp
+++ b/daemon/src/audio/gaincontrol.cpp
@@ -2,7 +2,8 @@
 #include <climits>
 #include <fstream>
 
-#include "global.h"
+#include "sfl_types.h"
+#include "logger.h"
 #include "gaincontrol.h"
 
 #define SFL_GAIN_ATTACK_TIME 10
diff --git a/daemon/src/audio/mainbuffer.cpp b/daemon/src/audio/mainbuffer.cpp
index 5982da64b0305e1ee54d3848f4079880ee71ef28..79984d8c0fc35e480fa90299142839b09492c201 100644
--- a/daemon/src/audio/mainbuffer.cpp
+++ b/daemon/src/audio/mainbuffer.cpp
@@ -31,6 +31,7 @@
 
 #include "mainbuffer.h"
 #include <utility> // for std::pair
+#include "logger.h"
 #include "manager.h"
 
 MainBuffer::MainBuffer() : ringBufferMap_(), callIDMap_(), mutex_(), internalSamplingRate_(8000)
diff --git a/daemon/src/audio/noisesuppress.h b/daemon/src/audio/noisesuppress.h
index 0e58f20ac7ffaee5ec641305c71648d4c495e5ac..30197386db6266afa660657c9758fc49cac3eb81 100644
--- a/daemon/src/audio/noisesuppress.h
+++ b/daemon/src/audio/noisesuppress.h
@@ -32,7 +32,7 @@
 #define NOISESUPPRESS_H
 
 #include <speex/speex_preprocess.h>
-#include "global.h" // for SFLDataFormat
+#include "sfl_types.h"
 #include "noncopyable.h"
 
 class NoiseSuppress {
diff --git a/daemon/src/audio/pulseaudio/audiostream.cpp b/daemon/src/audio/pulseaudio/audiostream.cpp
index 4053d5b4ab72c7cef7425b7521e93e0444d7e587..8ac348f7823a47697a57614aa7f6ff2edda5b820 100644
--- a/daemon/src/audio/pulseaudio/audiostream.cpp
+++ b/daemon/src/audio/pulseaudio/audiostream.cpp
@@ -30,6 +30,7 @@
 
 #include "audiostream.h"
 #include "pulselayer.h"
+#include "logger.h"
 #include <stdexcept>
 
 AudioStream::AudioStream(pa_context *c, pa_threaded_mainloop *m, const char *desc, int type, int smplrate, std::string& deviceName)
@@ -95,7 +96,7 @@ AudioStream::~AudioStream()
 }
 
 void
-AudioStream::stream_state_callback(pa_stream* s, void* user_data UNUSED)
+AudioStream::stream_state_callback(pa_stream* s, void* /*user_data*/)
 {
     char str[PA_SAMPLE_SPEC_SNPRINT_MAX];
 
diff --git a/daemon/src/audio/pulseaudio/pulselayer.cpp b/daemon/src/audio/pulseaudio/pulselayer.cpp
index 748fec0642175cc64b8673f84a9e5a3817c1014e..77d74bb4edfb6e4e31fd8ca9015eed27318e53f6 100644
--- a/daemon/src/audio/pulseaudio/pulselayer.cpp
+++ b/daemon/src/audio/pulseaudio/pulselayer.cpp
@@ -36,6 +36,7 @@
 #include "pulselayer.h"
 #include "audio/samplerateconverter.h"
 #include "audio/dcblocker.h"
+#include "logger.h"
 #include "manager.h"
 
 namespace {
diff --git a/daemon/src/audio/ringbuffer.cpp b/daemon/src/audio/ringbuffer.cpp
index 9119838ffea0acfdebc05288b9204bfb8963c269..8e0f95590ca813c1632fff486f230894dc9b7f9d 100644
--- a/daemon/src/audio/ringbuffer.cpp
+++ b/daemon/src/audio/ringbuffer.cpp
@@ -36,8 +36,8 @@
 #include <cstring>
 #include <utility> // for std::pair
 
+#include "logger.h"
 #include "ringbuffer.h"
-#include "global.h"
 
 // corespond to 106 ms (about 5 rtp packets)
 #define MIN_BUFFER_SIZE	1280
diff --git a/daemon/src/audio/samplerateconverter.h b/daemon/src/audio/samplerateconverter.h
index f367161eba2e0d3e6afb7a2ef52123ff522a1fd1..31518d203aabf3d4f78cca5854edf44dac9730af 100644
--- a/daemon/src/audio/samplerateconverter.h
+++ b/daemon/src/audio/samplerateconverter.h
@@ -33,8 +33,9 @@
 
 #include <samplerate.h>
 #include <cmath>
+#include <cstring>
 
-#include "global.h"
+#include "sfl_types.h"
 #include "noncopyable.h"
 
 class SamplerateConverter {
diff --git a/daemon/src/audio/sound/audiofile.cpp b/daemon/src/audio/sound/audiofile.cpp
index c9f88e6975914d8929e970aed8a9925217b3f17b..443c42436f9b5c6bf9fef865ac1165e07a38f5d2 100644
--- a/daemon/src/audio/sound/audiofile.cpp
+++ b/daemon/src/audio/sound/audiofile.cpp
@@ -31,7 +31,7 @@
  *  as that of the covered work.
  */
 #include <fstream>
-#include <math.h>
+#include <cmath>
 #include <samplerate.h>
 #include <cstring>
 #include <vector>
@@ -41,6 +41,7 @@
 #include "audio/codecs/audiocodecfactory.h"
 #include "audio/codecs/audiocodec.h"
 #include "audio/samplerateconverter.h"
+#include "logger.h"
 
 #include "manager.h"
 
diff --git a/daemon/src/audio/sound/tone.cpp b/daemon/src/audio/sound/tone.cpp
index 5f0086373155048ccc3a1d9825eaee781592cd1e..02c3903d5b10c0e56fd4e16facd40371dc6baf74 100644
--- a/daemon/src/audio/sound/tone.cpp
+++ b/daemon/src/audio/sound/tone.cpp
@@ -35,10 +35,13 @@
  * YM: 2006-11-15: changes unsigned int to std::string::size_type, thanks to Pierre Pomes (AMD64 compilation)
  */
 #include "tone.h"
+#include "logger.h"
+#include "sfl_types.h"
 #include <cmath>
 #include <cassert>
 #include <cstdlib>
 #include <cstring>
+#include <vector>
 
 Tone::Tone(const std::string& definition, unsigned int sampleRate) :
     sampleRate_(sampleRate), xhigher_(0.0), xlower_(0.0)
@@ -55,8 +58,8 @@ Tone::genBuffer(const std::string& definition)
 
     size_ = 0;
 
-    SFLDataFormat* buffer = new SFLDataFormat[SIZEBUF]; //1kb
-    SFLDataFormat* bufferPos = buffer;
+    std::vector<SFLDataFormat> buffer(SIZEBUF); // 1kb
+    SFLDataFormat* bufferPos = &(*buffer.begin());
 
     // Number of format sections
     std::string::size_type posStart = 0; // position of precedent comma
@@ -123,9 +126,7 @@ Tone::genBuffer(const std::string& definition)
     assert(!buffer_);
     buffer_ = new SFLDataFormat[size_];
 
-    memcpy(buffer_, buffer, size_ * sizeof(SFLDataFormat)); // copy char, not SFLDataFormat.
-
-    delete [] buffer;
+    memcpy(buffer_, &(*buffer.begin()), size_ * sizeof(SFLDataFormat)); // copy char, not SFLDataFormat.
 }
 
 void
diff --git a/daemon/src/audio/speexechocancel.cpp b/daemon/src/audio/speexechocancel.cpp
index 9c61182692ece610c9e4a3952eff24510e3265d7..65581c47ec7f2ea1260624ed074f753a468310c6 100644
--- a/daemon/src/audio/speexechocancel.cpp
+++ b/daemon/src/audio/speexechocancel.cpp
@@ -21,6 +21,7 @@
 #include <climits>
 
 #include "speexechocancel.h"
+#include "logger.h"
 #include <speex/speex_echo.h>
 #include <speex/speex_preprocess.h>
 #include "manager.h"
diff --git a/daemon/src/call.h b/daemon/src/call.h
index 36ca85fc01b708486f972214a21f05287ba682c6..2c6b688a4d81d6998902e0d74656862ef0b9be2d 100644
--- a/daemon/src/call.h
+++ b/daemon/src/call.h
@@ -33,6 +33,7 @@
 #define CALL_H
 
 #include <sstream>
+#include <map>
 #include "cc_thread.h"
 #include "audio/recordable.h"
 
diff --git a/daemon/src/config/config.cpp b/daemon/src/config/config.cpp
index 2f1d06b19380ad456258f497ba3a17bc20f2831e..b556451f85ba47514670614cd84e7c8a4f203aa7 100644
--- a/daemon/src/config/config.cpp
+++ b/daemon/src/config/config.cpp
@@ -29,8 +29,10 @@
  *  as that of the covered work.
  */
 
+#ifdef HAVE_CONFIG_H
 #include "config.h"
-#include "../global.h"
+#endif
+#include "logger.h"
 #include <fstream>
 #include <cstdlib>
 #include <sys/types.h>
diff --git a/daemon/src/config/yamlemitter.cpp b/daemon/src/config/yamlemitter.cpp
index 2b611c5126aeab2b9ad53212ee17bfaf71aac250..ead739b77ac00677b099bc8e9b38aeef5a1fc70b 100644
--- a/daemon/src/config/yamlemitter.cpp
+++ b/daemon/src/config/yamlemitter.cpp
@@ -29,8 +29,8 @@
  */
 
 #include "yamlemitter.h"
-#include <stdio.h>
-#include "../global.h"
+#include <cstdio>
+#include "logger.h"
 
 namespace Conf {
 
diff --git a/daemon/src/config/yamlnode.cpp b/daemon/src/config/yamlnode.cpp
index 16951e028037ec1d45d1b8b1b897c1614f58b191..50adef83d9048b8d1b7bb82b7a405595d0ac55d4 100644
--- a/daemon/src/config/yamlnode.cpp
+++ b/daemon/src/config/yamlnode.cpp
@@ -29,7 +29,8 @@
  */
 
 #include "yamlnode.h"
-#include "global.h"
+#include <cstdlib>
+#include "logger.h"
 
 namespace Conf {
 
@@ -137,7 +138,7 @@ void MappingNode::getValue(const std::string &key, int *i) const
     if (!node)
         return;
 
-    *i = atoi(node->getValue().c_str());
+    *i = std::atoi(node->getValue().c_str());
 }
 
 void MappingNode::getValue(const std::string &key, std::string *v) const
diff --git a/daemon/src/dbus/callmanager.cpp b/daemon/src/dbus/callmanager.cpp
index f7c8750b6f42b4f2a61a1e073b40aecdccb72716..e74a0ec5baa17de2c70acbdca330e07586cf1ce1 100644
--- a/daemon/src/dbus/callmanager.cpp
+++ b/daemon/src/dbus/callmanager.cpp
@@ -39,6 +39,7 @@
 #include "audio/audiortp/audio_rtp_factory.h"
 #include "audio/audiortp/audio_zrtp_session.h"
 
+#include "logger.h"
 #include "manager.h"
 
 CallManager::CallManager(DBus::Connection& connection)
diff --git a/daemon/src/dbus/configurationmanager.cpp b/daemon/src/dbus/configurationmanager.cpp
index fe6b4c3a6ac5e653bd1ca3aaff5ac8439748421a..f067e5ec9317fbad9a6dad1d920fb49517522f6d 100644
--- a/daemon/src/dbus/configurationmanager.cpp
+++ b/daemon/src/dbus/configurationmanager.cpp
@@ -30,15 +30,17 @@
  *  as that of the covered work.
  */
 
+#ifdef HAVE_CONFIG_H
 #include "config.h"
+#endif
 
 #include "configurationmanager.h"
 #include <sstream>
-#include "config.h"
 #include "../manager.h"
 #include "sip/sipvoiplink.h"
 #include "sip/siptransport.h"
 #include "account.h"
+#include "logger.h"
 #include "sip/sipaccount.h"
 
 const char* ConfigurationManager::SERVER_PATH =
diff --git a/daemon/src/dbus/dbusmanager.cpp b/daemon/src/dbus/dbusmanager.cpp
index becd522679892b2a071910dc9c30c3e3c23223f7..cfd6e5cb2f1beae6232881e103adb37c7239297f 100644
--- a/daemon/src/dbus/dbusmanager.cpp
+++ b/daemon/src/dbus/dbusmanager.cpp
@@ -32,6 +32,7 @@
 #include "dbusmanager.h"
 #include "global.h"
 #include "manager.h"
+#include "logger.h"
 #include "instance.h"
 
 #include "callmanager.h"
@@ -86,7 +87,7 @@ void DBusManager::exec()
         ERROR("%s: %s, exiting\n", err.name(), err.what());
         ::exit(EXIT_FAILURE);
     } catch (const std::exception &err) {
-        ERROR("%s: %s, exiting\n", err.what());
+        ERROR("%s: exiting\n", err.what());
         ::exit(EXIT_FAILURE);
     }
 }
@@ -100,7 +101,7 @@ DBusManager::exit()
         ERROR("%s: %s, exiting\n", err.name(), err.what());
         ::exit(EXIT_FAILURE);
     } catch (const std::exception &err) {
-        ERROR("%s: %s, exiting\n", err.what());
+        ERROR("%s: exiting\n", err.what());
         ::exit(EXIT_FAILURE);
     }
 }
diff --git a/daemon/src/fileutils.cpp b/daemon/src/fileutils.cpp
index 744d002fb99c47c17e81cebe93c433aa4fb20d22..bed4d2ea3d74bb2b095af5cd04929dd4fd51cea0 100644
--- a/daemon/src/fileutils.cpp
+++ b/daemon/src/fileutils.cpp
@@ -34,7 +34,10 @@
 #include <cstdio>
 #include <cstdlib>
 #include <signal.h>
-#include "global.h"
+#include <string>
+#include <sstream>
+#include "fileutils.h"
+#include "logger.h"
 
 namespace {
 // returns true if directory exists
diff --git a/daemon/src/fileutils.h b/daemon/src/fileutils.h
index 8f8a7b66b104db06f44f8d536197f04738c6c38d..67bc019d6811b1e0a6225b6785cc22de0cc048fc 100644
--- a/daemon/src/fileutils.h
+++ b/daemon/src/fileutils.h
@@ -28,8 +28,18 @@
  *  as that of the covered work.
  */
 
-#ifndef __FILEUTILS_H__
-#define __FILEUTILS_H__
+#ifndef FILEUTILS_H_
+#define FILEUTILS_H_
+
+#define HOMEDIR					(getenv ("HOME"))				/** Home directory */
+#define XDG_DATA_HOME			(getenv ("XDG_DATA_HOME"))
+#define XDG_CONFIG_HOME			(getenv ("XDG_CONFIG_HOME"))
+#define XDG_CACHE_HOME			(getenv ("XDG_CACHE_HOME"))
+#define PIDFILE "sfl.pid"
+
+
+#define DIR_SEPARATOR_STR "/"   // Directory separator char
+#define DIR_SEPARATOR_CH = '/'  // Directory separator string
 
 namespace fileutils {
     void set_program_dir(char *program_path);
@@ -37,4 +47,4 @@ namespace fileutils {
     bool create_pidfile();
 }
 
-#endif	// __FILEUTILS_H__
+#endif	// FILEUTILS_H_
diff --git a/daemon/src/global.h b/daemon/src/global.h
index 8524caf8c75c4d1d34f471f28d623412d9ce94b7..fd766c1a2448837b9d89b6bc2be473377a68a5c6 100644
--- a/daemon/src/global.h
+++ b/daemon/src/global.h
@@ -33,32 +33,17 @@
 #ifndef __GLOBAL_H__
 #define __GLOBAL_H__
 
-#include <stdio.h>
+#include <cstdio>
 #include <libintl.h>
 #include <locale.h>
 #include <string>
-#include <stdlib.h>
+#include <cstdlib>
 #include <sstream>
 #include <map>
 #include <vector>
-#include "logger.h"
 
-#define HOMEDIR					(getenv ("HOME"))				/** Home directory */
-#define XDG_DATA_HOME			(getenv ("XDG_DATA_HOME"))
-#define XDG_CONFIG_HOME			(getenv ("XDG_CONFIG_HOME"))
-#define XDG_CACHE_HOME			(getenv ("XDG_CACHE_HOME"))
 const char * const ZRTP_ZID_FILENAME = "sfl.zid";
 
-//useful typedefs.
-typedef signed short SINT16;
-typedef signed int SINT32;
-
-#define PIDFILE "sfl.pid"
-
-typedef short SFLDataFormat;
-
-#define SIZEBUF 		 400000     /** About 12 sec of buffering at 8000 Hz*/
-
 #define ALSA_DFT_CARD_ID 0          /** Index of the default soundcard */
 
 #define PCM_PLUGHW	"plughw"		/** Alsa plugin */
@@ -121,7 +106,4 @@ enum {
 /** The struct to reflect the order the user wants to use the codecs */
 typedef std::vector<int> CodecOrder;
 
-#define DIR_SEPARATOR_STR "/" // Directory separator char
-#define DIR_SEPARATOR_CH = '/' /** Directory separator string */
-
 #endif	// __GLOBAL_H__
diff --git a/daemon/src/history/history.cpp b/daemon/src/history/history.cpp
index 423825fa70fa952b81d7676437338bdd10c649ed..42284b99fa755bbc75c42b57cfdf6ca8aedfa570 100644
--- a/daemon/src/history/history.cpp
+++ b/daemon/src/history/history.cpp
@@ -36,7 +36,7 @@
 #include <fstream>
 #include <sys/stat.h> // for mkdir
 #include <ctime>
-#include "global.h"
+#include "fileutils.h"
 #include "logger.h"
 #include "call.h"
 
diff --git a/daemon/src/iax/iaxaccount.cpp b/daemon/src/iax/iaxaccount.cpp
index 48e1da5ca806be30dc069900b523d6b66e25d4e4..c6bd7d62930936b07a60c4e6de9a95edf66259a6 100644
--- a/daemon/src/iax/iaxaccount.cpp
+++ b/daemon/src/iax/iaxaccount.cpp
@@ -31,10 +31,13 @@
  *  as that of the covered work.
  */
 
+#ifdef HAVE_CONFIG_H
 #include "config.h"
+#endif
 
 #include "iaxaccount.h"
 #include "iaxvoiplink.h"
+#include "logger.h"
 #include "manager.h"
 #include "config/yamlnode.h"
 #include "config/yamlemitter.h"
diff --git a/daemon/src/iax/iaxcall.cpp b/daemon/src/iax/iaxcall.cpp
index 2b09b4944fbbeb18685d916e072fb464f4c8b870..488dec90815037e4a6cff917a090913637a734b2 100644
--- a/daemon/src/iax/iaxcall.cpp
+++ b/daemon/src/iax/iaxcall.cpp
@@ -34,6 +34,7 @@
 #include <iax-client.h>
 #include "iaxcall.h"
 #include "iax2/frame.h"
+#include "logger.h"
 #include "account.h"
 #include "manager.h"
 
diff --git a/daemon/src/iax/iaxvoiplink.cpp b/daemon/src/iax/iaxvoiplink.cpp
index e91792a6d8c4c5416ad4d6253b91dc0bfef5c60a..aabb9eae777326d0cdf587e6fffe63e76520dfdc 100644
--- a/daemon/src/iax/iaxvoiplink.cpp
+++ b/daemon/src/iax/iaxvoiplink.cpp
@@ -33,6 +33,7 @@
 #include "eventthread.h"
 #include "im/instant_messaging.h"
 #include "iaxaccount.h"
+#include "logger.h"
 #include "manager.h"
 #include "hooks/urlhook.h"
 #include "audio/audiolayer.h"
diff --git a/daemon/src/iax/iaxvoiplink.h b/daemon/src/iax/iaxvoiplink.h
index 11e264f002ead74a8eb1285008e12e6e2eef58c7..9a421d1d2c14cb30b7f8a23e8683a8c34d659b96 100644
--- a/daemon/src/iax/iaxvoiplink.h
+++ b/daemon/src/iax/iaxvoiplink.h
@@ -35,7 +35,7 @@
 #include "voiplink.h"
 #include <iax-client.h>
 #include "audio/codecs/audiocodec.h" // for DEC_BUFFER_SIZE
-#include "global.h"
+#include "sfl_types.h"
 #include "noncopyable.h"
 #include "audio/samplerateconverter.h"
 
@@ -116,7 +116,7 @@ class IAXVoIPLink : public VoIPLink {
          * Cancel a call
          * @param id The ID of the call
          */
-        virtual void cancel(const std::string& id UNUSED) {}
+        virtual void cancel(const std::string& /*id*/) {}
 
         /**
          * Put a call on hold
diff --git a/daemon/src/main.cpp b/daemon/src/main.cpp
index 05af64d9b04eb90390d5414ec6cb03e2f4715edd..bd7df2d020b79d1a8f496c66638edc68ce866a9e 100644
--- a/daemon/src/main.cpp
+++ b/daemon/src/main.cpp
@@ -35,50 +35,99 @@
 #endif
 
 #include <iostream>
-#include <memory> // for auto_ptr
-#include <string>
-// #include <commoncpp/common.h>
+#include <getopt.h>
 #include "fileutils.h"
-
 #include "dbus/dbusmanager.h"
+#include "logger.h"
 #include "manager.h"
-/*
-ost::CommandOptionNoArg	console(
-    "console", "c", "Log in console (instead of syslog)"
-);
-
-ost::CommandOptionNoArg	debug(
-    "debug", "d", "Debug mode (more verbose)"
-);
-
-ost::CommandOptionNoArg	help(
-    "help", "h", "Print help"
-);
-*/
-int main(int /*argc*/, char **argv)
+
+namespace {
+    void print_title()
+    {
+        std::cout << "SFLphone Daemon " << VERSION <<
+            ", by Savoir-Faire Linux 2004-2012" << std::endl <<
+            "http://www.sflphone.org/" << std::endl;
+    }
+
+    void print_usage()
+    {
+        std::cout << std::endl <<
+        "-c, --console \t- Log in console (instead of syslog)" << std::endl <<
+        "-d, --debug \t- Debug mode (more verbose)" << std::endl <<
+        "-h, --help \t- Print help" << std::endl;
+    }
+
+    // Parse command line arguments, setting debug options or printing a help
+    // message accordingly.
+    // returns true if we should quit (i.e. help was printed), false otherwise
+    bool parse_args(int argc, char *argv[])
+    {
+        int consoleFlag = false;
+        int debugFlag = false;
+        int helpFlag = false;
+        int versionFlag = false;
+        static const struct option long_options[] = {
+            /* These options set a flag. */
+            {"debug", no_argument, NULL, 'd'},
+            {"console", no_argument, NULL, 'c'},
+            {"help", no_argument, NULL, 'h'},
+            {"version", no_argument, NULL, 'v'},
+            {0, 0, 0, 0} /* Sentinel */
+        };
+
+        while (true) {
+            /* getopt_long stores the option index here. */
+            int option_index = 0;
+            int c = getopt_long(argc, argv, "dchv", long_options, &option_index);
+
+            /* Detect the end of the options. */
+            if (c == -1)
+                break;
+
+            switch (c) {
+                case 'd':
+                    debugFlag = true;
+                    break;
+
+                case 'c':
+                    consoleFlag = true;
+                    break;
+
+                case 'h':
+                case '?':
+                    helpFlag = true;
+                    break;
+
+                case 'v':
+                    versionFlag = true;
+                    break;
+
+                default:
+                    break;
+            }
+        }
+
+        bool quit = false;
+        if (helpFlag) {
+            print_usage();
+            quit = true;
+        } else if (versionFlag) {
+            // We've always print the title/version, so we can just exit
+            quit = true;
+        } else {
+            Logger::setConsoleLog(consoleFlag);
+            Logger::setDebugMode(debugFlag);
+        }
+        return quit;
+    }
+}
+
+int main(int argc, char *argv [])
 {
     fileutils::set_program_dir(argv[0]);
-    // makeCommandOptionParse allocates the object with operator new, so
-    // auto_ptr is fine in this context.
-    // TODO: This should eventually be replaced with std::unique_ptr for C++0x
-    // std::auto_ptr<ost::CommandOptionParse> args(ost::makeCommandOptionParse(argc, argv, ""));
-
-    printf("SFLphone Daemon " VERSION ", by Savoir-Faire Linux 2004-2012\n" \
-           "http://www.sflphone.org/\n");
-/*
-    if (help.numSet) {
-        std::cerr << args->printUsage();
+    print_title();
+    if (parse_args(argc, argv))
         return 0;
-    } else if (args->argsHaveError()) {
-        std::cerr << args->printErrors();
-        std::cerr << args->printUsage();
-        return 1;
-    }
-*/
-    // Logger::setConsoleLog(console.numSet);
-    // Logger::setDebugMode(debug.numSet);
-    Logger::setConsoleLog(1);
-    Logger::setDebugMode(1);
 
     if (!fileutils::create_pidfile())
         return 1;
@@ -89,7 +138,8 @@ int main(int /*argc*/, char **argv)
         std::cerr << e.what() << std::endl;
         return 1;
     } catch (...) {
-        std::cerr << "An exception occured when initializing the system." << std::endl;
+        std::cerr << "An exception occured when initializing " PACKAGE <<
+            std::endl;
         return 1;
     }
 
diff --git a/daemon/src/managerimpl.cpp b/daemon/src/managerimpl.cpp
index cf475d5540487739fa0cfc0234b597d433011953..5faadca43e24848df52016d7ae61e811d8d5a788 100644
--- a/daemon/src/managerimpl.cpp
+++ b/daemon/src/managerimpl.cpp
@@ -36,11 +36,13 @@
 #include "config.h"
 #endif
 
+#include "logger.h"
 #include "managerimpl.h"
 
 #include "account.h"
 #include "dbus/callmanager.h"
 #include "global.h"
+#include "fileutils.h"
 #include "sip/sipaccount.h"
 #include "im/instant_messaging.h"
 #include "iax/iaxaccount.h"
diff --git a/daemon/src/numbercleaner.cpp b/daemon/src/numbercleaner.cpp
index c49c2240ed345b6b732b36327171ba52971817b0..eae039454351ab0f1ad33c708e3bd9172487ec4c 100644
--- a/daemon/src/numbercleaner.cpp
+++ b/daemon/src/numbercleaner.cpp
@@ -30,6 +30,7 @@
  */
 
 #include "numbercleaner.h"
+#include "logger.h"
 #include <algorithm>
 
 namespace {
diff --git a/daemon/src/preferences.cpp b/daemon/src/preferences.cpp
index df98457a40e61cb67caf9215db107f103b621402..15bf1e50cf48b36e4927528b343ecf9da021c0ab 100644
--- a/daemon/src/preferences.cpp
+++ b/daemon/src/preferences.cpp
@@ -29,6 +29,7 @@
  */
 
 #include "preferences.h"
+#include "logger.h"
 #include "audio/alsa/alsalayer.h"
 #include "audio/pulseaudio/pulselayer.h"
 #include "config/yamlemitter.h"
diff --git a/daemon/src/sfl_types.h b/daemon/src/sfl_types.h
new file mode 100644
index 0000000000000000000000000000000000000000..31025875d8cde87a5bac37a841809edcf7fd0110
--- /dev/null
+++ b/daemon/src/sfl_types.h
@@ -0,0 +1,42 @@
+/*
+ *  Copyright (C) 2004-2012 Savoir-Faire Linux Inc.
+ *  Author: Tristan Matthews <tristan.matthews@savoirfairelinux.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ *  Additional permission under GNU GPL version 3 section 7:
+ *
+ *  If you modify this program, or any covered work, by linking or
+ *  combining it with the OpenSSL project's OpenSSL library (or a
+ *  modified version of that library), containing parts covered by the
+ *  terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
+ *  grants you additional permission to convey the resulting work.
+ *  Corresponding Source for a non-source form of such a combination
+ *  shall include the source code for the parts of OpenSSL used as well
+ *  as that of the covered work.
+ */
+
+#ifndef SFL_TYPES_H_
+#define SFL_TYPES_H_
+
+#include <cstring> // for size_t
+
+typedef short SFLDataFormat;
+typedef signed short SINT16;
+typedef signed int SINT32;
+
+static const size_t SIZEBUF = 400000; /** About 12 sec of buffering at 8000 Hz*/
+
+#endif // SFL_TYPES_H_
diff --git a/daemon/src/sip/sdp.cpp b/daemon/src/sip/sdp.cpp
index 2034f39c71f43d8e527d620fe98d13246531fe04..a517e97af5d3d1f3862ff99af5f888d5da7f4955 100644
--- a/daemon/src/sip/sdp.cpp
+++ b/daemon/src/sip/sdp.cpp
@@ -31,7 +31,7 @@
  */
 
 #include "sdp.h"
-#include "global.h"
+#include "logger.h"
 #include "manager.h"
 #include <cassert>
 
diff --git a/daemon/src/sip/sipaccount.cpp b/daemon/src/sip/sipaccount.cpp
index 4ec4f52c707d1d860047b2e4a54b2036be66ebbf..b70667080e7c031963c3cbf57a0fd5d79b9ffd20 100644
--- a/daemon/src/sip/sipaccount.cpp
+++ b/daemon/src/sip/sipaccount.cpp
@@ -38,6 +38,7 @@
 #include "sipvoiplink.h"
 #include "config/yamlnode.h"
 #include "config/yamlemitter.h"
+#include "logger.h"
 #include "manager.h"
 #include <pwd.h>
 #include <sstream>
diff --git a/daemon/src/sip/siptransport.cpp b/daemon/src/sip/siptransport.cpp
index 2f07f5e979a7b3d65f07c13b2c92663a8984f9f4..38a908656ba8bec237f7ae9d10f957ca8c82929d 100644
--- a/daemon/src/sip/siptransport.cpp
+++ b/daemon/src/sip/siptransport.cpp
@@ -47,6 +47,7 @@
 #include <arpa/inet.h>
 #include <net/if.h>
 
+#include "logger.h"
 #include "siptransport.h"
 #include "manager.h"
 
diff --git a/daemon/src/sip/sipvoiplink.cpp b/daemon/src/sip/sipvoiplink.cpp
index 4c9dd1638e61573c61324201efcc19b0fbc845fc..7b39a06f9f3bd7c823dd1103b2d43028a4590e2a 100644
--- a/daemon/src/sip/sipvoiplink.cpp
+++ b/daemon/src/sip/sipvoiplink.cpp
@@ -36,9 +36,9 @@
 #include "config.h"
 #endif
 
-
 #include "sipvoiplink.h"
 #include "manager.h"
+#include "logger.h"
 
 #include "sip/sdp.h"
 #include "sipcall.h"
diff --git a/daemon/src/voiplink.cpp b/daemon/src/voiplink.cpp
index 49bc2d4d0ecdd8ffc1c7d0f9f092653b6c3fe6d4..d46954f14afd21e5d970e535ee217827b52c2887 100644
--- a/daemon/src/voiplink.cpp
+++ b/daemon/src/voiplink.cpp
@@ -32,6 +32,7 @@
  */
 
 #include "call.h"
+#include "logger.h"
 #include "voiplink.h"
 
 VoIPLink::VoIPLink() : callMap_(), callMapMutex_(), handlingEvents_(false) {}
diff --git a/daemon/test/configurationtest.cpp b/daemon/test/configurationtest.cpp
index b93394b3b538a0606046ed8445a3478c729474ca..46a7803a790ff05704ccbfa3907f5c721d16a920 100644
--- a/daemon/test/configurationtest.cpp
+++ b/daemon/test/configurationtest.cpp
@@ -33,6 +33,7 @@
 #include "config/yamlemitter.h"
 #include "config/yamlparser.h"
 #include "account.h"
+#include "logger.h"
 #include "audio/alsa/alsalayer.h"
 #include "audio/pulseaudio/pulselayer.h"
 #include "sip/sipaccount.h"
diff --git a/daemon/test/gaincontroltest.h b/daemon/test/gaincontroltest.h
index b7d782453330766bac7b068dd3f014242d4c4a4c..1f1bef03607bf39cce561d98f25eaabcb79b4c91 100644
--- a/daemon/test/gaincontroltest.h
+++ b/daemon/test/gaincontroltest.h
@@ -42,6 +42,8 @@
 #include <cppunit/TestCase.h>
 #include <cppunit/TestSuite.h>
 
+#include "sfl_types.h"
+
 class GainControlTest: public CppUnit::TestFixture {
 
         CPPUNIT_TEST_SUITE(GainControlTest);
diff --git a/daemon/test/instantmessagingtest.cpp b/daemon/test/instantmessagingtest.cpp
index baa6cd10d1314c763dcb88711202524ae0b49915..82571a2f3c7ab23fbcf6dbde186634391ec6200a 100644
--- a/daemon/test/instantmessagingtest.cpp
+++ b/daemon/test/instantmessagingtest.cpp
@@ -30,13 +30,12 @@
 
 #include <iostream>
 #include <fstream>
+#include <expat.h>
 #include "test_utils.h"
 
 #include "instantmessagingtest.h"
 #include "im/instant_messaging.h"
-
-#include "expat.h"
-
+#include "logger.h"
 
 #define MAXIMUM_SIZE	10
 #define DELIMITER_CHAR	"\n\n"
diff --git a/daemon/test/numbercleanertest.cpp b/daemon/test/numbercleanertest.cpp
index d9642a7201aae83b6d2b95506f0d8969776c547f..7cbb28f885d9a5be2a986986b8d86db64c9ab41f 100644
--- a/daemon/test/numbercleanertest.cpp
+++ b/daemon/test/numbercleanertest.cpp
@@ -28,11 +28,11 @@
  *  as that of the covered work.
  */
 
-#include <stdio.h>
+#include <cstdio>
 #include <sstream>
 #include <dlfcn.h>
 
-#include "global.h"
+#include "logger.h"
 
 #include "numbercleanertest.h"
 
diff --git a/daemon/test/sdesnegotiatortest.cpp b/daemon/test/sdesnegotiatortest.cpp
index 8bca64625cf18a56f195a6153362579028f2fa1c..26014a1a28596ca6040bf173d711f120ffdc8bf3 100644
--- a/daemon/test/sdesnegotiatortest.cpp
+++ b/daemon/test/sdesnegotiatortest.cpp
@@ -45,15 +45,15 @@
 #include "sip/sdes_negotiator.h"
 
 #include <unistd.h>
-#include "global.h"
+#include "test_utils.h"
+#include "logger.h"
 
 using std::cout;
 using std::endl;
 
 void SdesNegotiatorTest::testTagPattern()
 {
-    DEBUG("-------------------- SdesNegotiatorTest::testTagPattern --------------------\n");
-
+    TITLE();
     std::string subject = "a=crypto:4";
 
     sfl::Pattern pattern("^a=crypto:(?P<tag>[0-9]{1,9})");
@@ -66,8 +66,7 @@ void SdesNegotiatorTest::testTagPattern()
 
 void SdesNegotiatorTest::testCryptoSuitePattern()
 {
-    DEBUG("-------------------- SdesNegotiatorTest::testCryptoSuitePattern --------------------\n");
-
+    TITLE();
     std::string subject = "AES_CM_128_HMAC_SHA1_80";
 
     sfl::Pattern pattern("(?P<cryptoSuite>AES_CM_128_HMAC_SHA1_80|" \
@@ -83,7 +82,7 @@ void SdesNegotiatorTest::testCryptoSuitePattern()
 
 void SdesNegotiatorTest::testKeyParamsPattern()
 {
-    DEBUG("-------------------- SdesNegotiatorTest::testKeyParamsPattern --------------------\n");
+    TITLE();
 
     std::string subject = "inline:d0RmdmcmVCspeEc3QGZiNWpVLFJhQX1cfHAwJSoj|2^20|1:32";
 
@@ -107,7 +106,7 @@ void SdesNegotiatorTest::testKeyParamsPattern()
 
 void SdesNegotiatorTest::testKeyParamsPatternWithoutMKI()
 {
-    DEBUG("-------------------- SdesNegotiatorTest::testKeyParamsPatternWithoutMKI --------------------\n");
+    TITLE();
 
     std::string subject("inline:d0RmdmcmVCspeEc3QGZiNWpVLFJhQX1cfHAwJSoj");
 
@@ -131,7 +130,7 @@ void SdesNegotiatorTest::testKeyParamsPatternWithoutMKI()
  */
 void SdesNegotiatorTest::testNegotiation()
 {
-    DEBUG("-------------------- SdesNegotiatorTest::testNegotiation --------------------\n");
+    TITLE();
 
     // Add a new SDES crypto line to be processed.
     std::vector<std::string> remoteOffer;
@@ -154,7 +153,7 @@ void SdesNegotiatorTest::testNegotiation()
  */
 void SdesNegotiatorTest::testComponent()
 {
-    DEBUG("-------------------- SdesNegotiatorTest::testComponent --------------------\n");
+    TITLE();
 
     // Register the local capabilities.
     std::vector<sfl::CryptoSuiteDefinition> capabilities;
@@ -177,7 +176,7 @@ void SdesNegotiatorTest::testComponent()
  */
 void SdesNegotiatorTest::testMostSimpleCase()
 {
-    DEBUG("-------------------- SdesNegotiatorTest::testMostSimpleCase --------------------\n");
+    TITLE();
 
     // Register the local capabilities.
     std::vector<sfl::CryptoSuiteDefinition> capabilities;
@@ -207,7 +206,7 @@ void SdesNegotiatorTest::testMostSimpleCase()
 
 void SdesNegotiatorTest::test32ByteKeyLength()
 {
-    DEBUG("-------------------- SdesNegotiatorTest::test32ByteKeyLength --------------------\n");
+    TITLE();
 
     // Register the local capabilities.
     std::vector<sfl::CryptoSuiteDefinition> capabilities;
diff --git a/gnome/configure.ac b/gnome/configure.ac
index 542e7996f0cc9274921bca83962472261a01142d..e9738278d7cf6d69fdfa2a74141e7444833e9e1d 100644
--- a/gnome/configure.ac
+++ b/gnome/configure.ac
@@ -40,7 +40,8 @@ PKG_CHECK_MODULES(X11, x11)
 PKG_CHECK_MODULES(JAVASCRIPT_CORE_GTK, javascriptcoregtk-3.0, ,
 		  AC_MSG_RESULT(javascriptcoregtk not installed))
 
-PKG_CHECK_MODULES([CHECK], [check >= 0.9.4])
+PKG_CHECK_MODULES([CHECK], [check >= 0.9.4],,
+                  AC_MSG_RESULT([check not installed]))
 
 AC_CONFIG_FILES([
 Makefile