diff --git a/daemon/src/audio/audioloop.cpp b/daemon/src/audio/audioloop.cpp
index 445060a62a1f07c24fa3b92d61e961fc337832f1..63833f7c48e1ab6d6c8f7cfe5d0f488da57f454a 100644
--- a/daemon/src/audio/audioloop.cpp
+++ b/daemon/src/audio/audioloop.cpp
@@ -37,23 +37,21 @@
 #include <cstring>
 #include <cassert>
 
-AudioLoop::AudioLoop() :_buffer (0),  _size (0), _pos (0), _sampleRate (0)
+AudioLoop::AudioLoop() : buffer_(0),  size_(0), pos_(0), sampleRate_(0)
 {
 }
 
 AudioLoop::~AudioLoop()
 {
-    delete [] _buffer;
+    delete [] buffer_;
 }
 
 void
 AudioLoop::getNext (SFLDataFormat* output, size_t total_samples, short volume)
 {
-    size_t pos = _pos;
+    size_t pos = pos_;
 
-    assert(_size);
-
-    if(_size == 0) {
+    if (size_ == 0) {
     	_error("AudioLoop: Error: Audio loop size is 0");
     	return;
     }
@@ -61,26 +59,26 @@ AudioLoop::getNext (SFLDataFormat* output, size_t total_samples, short volume)
     while (total_samples) {
         size_t samples = total_samples;
 
-        if (samples > (_size-pos)) {
-            samples = _size-pos;
-        }
+        if (samples > (size_ - pos))
+            samples = size_ - pos;
 
-        memcpy(output, _buffer+pos, samples*sizeof (SFLDataFormat)); // short>char conversion
+        // short->char conversion
+        memcpy(output, buffer_ + pos, samples * sizeof(SFLDataFormat));
 
-        if (volume!=100) {
-            for (size_t i=0; i<samples; i++) {
-                *output = (*output * volume) /100;
+        if (volume != 100) {
+            double gain = volume * 0.01;
+            for (size_t i = 0; i < samples; i++) {
+                *output *= gain;
                 output++;
             }
-        } else {
+        } else
             output += samples; // this is the destination...
-        }
 
-        pos = (pos + samples) % _size;
+        pos = (pos + samples) % size_;
 
         total_samples -= samples;
     }
 
-    _pos = pos;
+    pos_ = pos;
 }
 
diff --git a/daemon/src/audio/audioloop.h b/daemon/src/audio/audioloop.h
index 58e8f83c211561c92e0123d33c5d418d10d6e62c..aa2916c30e043542d11ea26ad58b5feb1d10b74c 100644
--- a/daemon/src/audio/audioloop.h
+++ b/daemon/src/audio/audioloop.h
@@ -61,36 +61,36 @@ class AudioLoop
          * @param nb of int16 to send
          * @param volume  The volume
          */
-        void getNext (SFLDataFormat* output, size_t samples, short volume=100);
+        void getNext(SFLDataFormat* output, size_t samples, short volume=100);
 
         /**
          * Reset the pointer position
          */
         void reset() {
-            _pos = 0;
+            pos_ = 0;
         }
 
         /**
          * Accessor to the size of the buffer
          * @return unsigned int The size
          */
-        size_t getSize() {
-            return _size;
+        size_t getSize() const {
+            return size_;
         }
 
 
     protected:
         /** The data buffer */
-        SFLDataFormat* _buffer;
+        SFLDataFormat* buffer_;
 
         /** Number of samples inside the buffer */
-        size_t _size;
+        size_t size_;
 
         /** current position, set to 0, when initialize */
-        size_t _pos;
+        size_t pos_;
 
         /** Sample rate */
-        unsigned int _sampleRate;
+        unsigned int sampleRate_;
 
     private:
 
diff --git a/daemon/src/audio/audiorecord.cpp b/daemon/src/audio/audiorecord.cpp
index f84c602d27deb18cd6c6f17325beeb1aa9457739..c534fb583759eb7be74264563dcc9e142a7d579a 100644
--- a/daemon/src/audio/audiorecord.cpp
+++ b/daemon/src/audio/audiorecord.cpp
@@ -73,17 +73,9 @@ AudioRecord::AudioRecord() : fp (NULL)
 
 AudioRecord::~AudioRecord()
 {
-    if (mixBuffer_) {
-        delete [] mixBuffer_;
-    }
-
-    if (micBuffer_) {
-        delete [] micBuffer_;
-    }
-
-    if (spkBuffer_) {
-        delete [] spkBuffer_;
-    }
+    delete [] mixBuffer_;
+    delete [] micBuffer_;
+    delete [] spkBuffer_;
 }
 
 void AudioRecord::setSndSamplingRate (int smplRate)
@@ -96,16 +88,12 @@ int AudioRecord::getSndSamplingRate() const
 	return sndSmplRate_;
 }
 
-void AudioRecord::setRecordingOption (FILE_TYPE type, SOUND_FORMAT format, int sndSmplRate, std::string path)
+void AudioRecord::setRecordingOption(FILE_TYPE type, int sndSmplRate, const std::string &path)
 {
-
     fileType_ = type;
-    sndFormat_ = format;
     channels_ = 1;
     sndSmplRate_ = sndSmplRate;
-
     savePath_ = path + "/";
-
 }
 
 
@@ -309,11 +297,6 @@ bool AudioRecord::setRawFile()
         return false;
     }
 
-    if (sndFormat_ != INT16) {   // TODO need to change INT16 to SINT16
-        sndFormat_ = INT16;
-        _debug ("AudioRecord::setRawFile() : using 16-bit signed integer data format for file.");
-    }
-
     _debug ("AudioRecord:setRawFile() : created RAW file.");
 
     return true;
@@ -342,9 +325,7 @@ bool AudioRecord::setWavFile()
 
     hdr.num_chans = channels_;
 
-    if (sndFormat_ == INT16) {   //  TODO need to write INT16 to SINT16
-        hdr.bits_per_samp = 16;
-    }
+    hdr.bits_per_samp = 16;
 
     hdr.bytes_per_samp = (SINT16) (channels_ * hdr.bits_per_samp / 8);
 
@@ -499,15 +480,11 @@ void AudioRecord::recData (SFLDataFormat* buffer, int nSamples)
             return;
         }
 
-
-
-        if (sndFormat_ == INT16) {   // TODO change INT16 to SINT16
-            if (fwrite (buffer, sizeof (SFLDataFormat), nSamples, fp) != (unsigned int) nSamples)
-                _warn ("AudioRecord: Could not record data! ");
-            else {
-                fflush (fp);
-                byteCounter_ += (unsigned long) (nSamples*sizeof (SFLDataFormat));
-            }
+        if (fwrite (buffer, sizeof (SFLDataFormat), nSamples, fp) != (unsigned int) nSamples)
+            _warn ("AudioRecord: Could not record data! ");
+        else {
+            fflush (fp);
+            byteCounter_ += (unsigned long) (nSamples*sizeof (SFLDataFormat));
         }
     }
 
@@ -527,25 +504,16 @@ void AudioRecord::recData (SFLDataFormat* buffer_1, SFLDataFormat* buffer_2, int
             return;
         }
 
+        for (int k = 0; k < nSamples_1; k++) {
+            mixBuffer_[k] = (buffer_1[k]+buffer_2[k]);
 
-        if (sndFormat_ == INT16) {   // TODO change INT16 to SINT16
-            for (int k=0; k<nSamples_1; k++) {
-
-                mixBuffer_[k] = (buffer_1[k]+buffer_2[k]);
-
-
-                if (fwrite (&mixBuffer_[k], 2, 1, fp) != 1)
-                    _warn ("AudioRecord: Could not record data!");
-                else {
-                    fflush (fp);
-                }
-            }
+            if (fwrite (&mixBuffer_[k], 2, 1, fp) != 1)
+                _warn ("AudioRecord: Could not record data!");
+            else
+                fflush (fp);
         }
-
-        byteCounter_ += (unsigned long) (nSamples_1*sizeof (SFLDataFormat));
-
+        byteCounter_ += (unsigned long) (nSamples_1 * sizeof(SFLDataFormat));
     }
-
     return;
 }
 
diff --git a/daemon/src/audio/audiorecord.h b/daemon/src/audio/audiorecord.h
index 752ce5e3972de40caee836cbeedbd7c4de6446cf..bd7ee523aaf491c276d09f5f1669df6f1a7cc0b6 100644
--- a/daemon/src/audio/audiorecord.h
+++ b/daemon/src/audio/audiorecord.h
@@ -40,25 +40,19 @@ class AudioRecord
 {
 
     public:
+        enum FILE_TYPE { FILE_RAW, FILE_WAV };
 
         AudioRecord();
 
         ~AudioRecord();
 
-	/**
-	 * Set the sampling rate for this recorder
- 	 */
-        void setSndSamplingRate (int smplRate);
-
-	/**
-	 * Get the recrding sampling rate
-	 */
+        void setSndSamplingRate(int smplRate);
+        /**
+         * Get the recrding sampling rate
+         */
         int getSndSamplingRate(void) const;
 
-	/**
-	 * Set the recording option
-	 */
-        void setRecordingOption (FILE_TYPE type, SOUND_FORMAT format, int sndSmplRate, std::string path);
+        void setRecordingOption(FILE_TYPE type, int sndSmplRate, const std::string &path);
 
 	/**
 	 * Init recording file path
@@ -184,11 +178,6 @@ class AudioRecord
          */
         FILE_TYPE fileType_;
 
-        /**
-         * Sound format (SINT16/SINT32)
-         */
-        SOUND_FORMAT sndFormat_;
-
         /**
          * Number of channels
          */
diff --git a/daemon/src/audio/audiortp/AudioZrtpSession.cpp b/daemon/src/audio/audiortp/AudioZrtpSession.cpp
index 0a7ef0fd6bf2982e0d44c3c71be273b9e923d326..798e4cc53527947b0abd4506c2e537941498538a 100644
--- a/daemon/src/audio/audiortp/AudioZrtpSession.cpp
+++ b/daemon/src/audio/audiortp/AudioZrtpSession.cpp
@@ -27,6 +27,8 @@
  *  shall include the source code for the parts of OpenSSL used as well
  *  as that of the covered work.
  */
+
+#include "config.h"
 #include "AudioZrtpSession.h"
 #include "ZrtpSessionCallback.h"
 
@@ -49,14 +51,13 @@ namespace sfl
 {
 
 AudioZrtpSession::AudioZrtpSession (SIPCall * sipcall, const std::string& zidFilename) :
-    // ost::SymmetricZRTPSession (ost::InetHostAddress (sipcall->getLocalIp().c_str()), sipcall->getLocalAudioPort()),
-    AudioRtpSession(sipcall, Zrtp, static_cast<ost::RTPDataQueue *>(this), static_cast<ost::Thread *>(this))
-    ,ost::TRTPSessionBase<ost::SymmetricRTPChannel, ost::SymmetricRTPChannel, ost::ZrtpQueue> (ost::InetHostAddress (sipcall->getLocalIp().c_str()),
-            sipcall->getLocalAudioPort(),
-            0,
-            ost::MembershipBookkeeping::defaultMembersHashSize,
-            ost::defaultApplication())
-    , _zidFilename (zidFilename)
+    AudioRtpSession(sipcall, Zrtp, this, this),
+    ost::TRTPSessionBase<ost::SymmetricRTPChannel, ost::SymmetricRTPChannel, ost::ZrtpQueue>(ost::InetHostAddress(sipcall->getLocalIp().c_str()),
+    sipcall->getLocalAudioPort(),
+    0,
+    ost::MembershipBookkeeping::defaultMembersHashSize,
+    ost::defaultApplication()),
+    _zidFilename (zidFilename)
 {
     _debug ("AudioZrtpSession initialized");
     initializeZid();
@@ -96,7 +97,7 @@ void AudioZrtpSession::initializeZid (void)
 
     // xdg_config = std::string (HOMEDIR) + DIR_SEPARATOR_STR + ".cache/sflphone";
 
-    std::string xdg_config = std::string (HOMEDIR) + DIR_SEPARATOR_STR + ".cache" + DIR_SEPARATOR_STR + PROGDIR + "/" + _zidFilename;
+    std::string xdg_config = std::string(HOMEDIR) + DIR_SEPARATOR_STR + ".cache" + DIR_SEPARATOR_STR + PACKAGE + "/" + _zidFilename;
 
     _debug ("    xdg_config %s", xdg_config.c_str());
 
diff --git a/daemon/src/audio/codecs/audiocodecfactory.cpp b/daemon/src/audio/codecs/audiocodecfactory.cpp
index 60191b19cce367776b41cade72f016bb9e857c7a..632fbc1f148f3ab321aea5a3a0132dbcf1e56ac8 100644
--- a/daemon/src/audio/codecs/audiocodecfactory.cpp
+++ b/daemon/src/audio/codecs/audiocodecfactory.cpp
@@ -31,6 +31,7 @@
  *  as that of the covered work.
  */
 
+#include "config.h"
 #include "audiocodecfactory.h"
 #include <cstdlib>
 #include <algorithm> // for std::find
@@ -142,7 +143,7 @@ std::vector<sfl::Codec*> AudioCodecFactory::scanCodecDirectory()
     std::vector<sfl::Codec*> codecs;
     std::vector<std::string> dirToScan;
 
-    dirToScan.push_back(std::string(HOMEDIR) + DIR_SEPARATOR_STR "." PROGDIR "/");
+    dirToScan.push_back(std::string(HOMEDIR) + DIR_SEPARATOR_STR "." PACKAGE "/");
     dirToScan.push_back(CODECS_DIR "/");
     const char *envDir = getenv("CODECS_PATH");
     if (envDir)
@@ -162,7 +163,7 @@ std::vector<sfl::Codec*> AudioCodecFactory::scanCodecDirectory()
         dirent *dirStruct;
         while ( (dirStruct = readdir (dir))) {
             std::string file = dirStruct->d_name ;
-            if (file == CURRENT_DIR or file == PARENT_DIR)
+            if (file == "." or file == "..")
                 continue;
 
             if (seemsValid (file) && !alreadyInCache (file)) {
@@ -243,8 +244,9 @@ bool AudioCodecFactory::seemsValid (const std::string &lib)
 {
     // The name of the shared library seems valid  <==> it looks like libcodec_xxx.so
     // We check this
-    std::string prefix = SFL_CODEC_VALID_PREFIX;
-    std::string suffix = SFL_CODEC_VALID_EXTEN;
+
+    static const std::string prefix("libcodec_");
+    static const std::string suffix(".so");
 
     ssize_t len = lib.length() - prefix.length() - suffix.length();
     if (len < 0)
@@ -257,17 +259,17 @@ bool AudioCodecFactory::seemsValid (const std::string &lib)
 
 
 #ifndef HAVE_SPEEX_CODEC
-    if (lib.substr (prefix.length() , len) == SPEEX_STRING_DESCRIPTION)
+    if (lib.substr (prefix.length() , len) == "speex")
         return false;
 #endif
 
 #ifndef HAVE_GSM_CODEC
-    if (lib.substr (prefix.length() , len) == GSM_STRING_DESCRIPTION)
+    if (lib.substr (prefix.length() , len) == "gsm")
         return false;
 #endif
 
 #ifndef BUILD_ILBC
-    if (lib.substr (prefix.length() , len) == ILBC_STRING_DESCRIPTION)
+    if (lib.substr (prefix.length() , len) == "ilbc")
         return false;
 #endif
 
diff --git a/daemon/src/audio/recordable.cpp b/daemon/src/audio/recordable.cpp
index e98a39ba32511be7a98a6b7494d73caf99415bc8..2ee5ffe76bd78bf51275abbec528ae2ba4bb6462 100644
--- a/daemon/src/audio/recordable.cpp
+++ b/daemon/src/audio/recordable.cpp
@@ -32,13 +32,8 @@
 
 Recordable::Recordable() : recorder (&recAudio, Manager::instance().getMainBuffer())
 {
-
     _debug("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Recordable Constructor -=-=-=-=-=-=-=-=-=--=-=-=-");
-
-    FILE_TYPE fileType = FILE_WAV;
-    SOUND_FORMAT soundFormat = INT16;
-
-    recAudio.setRecordingOption (fileType, soundFormat, 8000, Manager::instance().audioPreference.getRecordpath());
+    recAudio.setRecordingOption (AudioRecord::FILE_WAV, 8000, Manager::instance().audioPreference.getRecordpath());
 }
 
 
diff --git a/daemon/src/audio/samplerateconverter.cpp b/daemon/src/audio/samplerateconverter.cpp
index 8bfcbeb68756a7c16f0aec2c85ea6467a9692c3c..f2654c5d30c08a23ea4f458739db04fadd584381 100644
--- a/daemon/src/audio/samplerateconverter.cpp
+++ b/daemon/src/audio/samplerateconverter.cpp
@@ -39,8 +39,8 @@ SamplerateConverter::SamplerateConverter (int freq) : _maxFreq(freq)
 
     _samples = (freq * 20) / 1000; // start with 20 ms buffers
 
-    _floatBufferIn = new float32[_samples];
-    _floatBufferOut = new float32[_samples];
+    _floatBufferIn = new float[_samples];
+    _floatBufferOut = new float[_samples];
 }
 
 SamplerateConverter::~SamplerateConverter (void)
@@ -61,7 +61,6 @@ SamplerateConverter::Short2FloatArray (const short *in, float *out, int len)
         out[len] = (float) in[len] * .000030517578125f;
 }
 
-//TODO Add ifdef for int16 or float32 type
 void SamplerateConverter::resample (SFLDataFormat* dataIn , SFLDataFormat* dataOut , int inputFreq , int outputFreq , int nbSamples)
 {
     double sampleFactor = (double) outputFreq / inputFreq;
@@ -77,8 +76,8 @@ void SamplerateConverter::resample (SFLDataFormat* dataIn , SFLDataFormat* dataO
     	_samples = maxSamples;
     	delete [] _floatBufferIn;
     	delete [] _floatBufferOut;
-        _floatBufferIn = new float32[_samples];
-        _floatBufferOut = new float32[_samples];
+        _floatBufferIn = new float[_samples];
+        _floatBufferOut = new float[_samples];
     }
 
 	SRC_DATA src_data;
diff --git a/daemon/src/audio/samplerateconverter.h b/daemon/src/audio/samplerateconverter.h
index 6d17b8d671f84e056ec32cdc1a0c1a5f9fd17af2..58dbd34409483a6a4dc049514d6d516ed8c036a9 100644
--- a/daemon/src/audio/samplerateconverter.h
+++ b/daemon/src/audio/samplerateconverter.h
@@ -78,8 +78,8 @@ class SamplerateConverter
         SamplerateConverter& operator= (const SamplerateConverter& rh);
 
         /* temporary buffers */
-        float32* _floatBufferIn;
-        float32* _floatBufferOut;
+        float * _floatBufferIn;
+        float * _floatBufferOut;
         size_t _samples; // size in samples of temporary buffers
         int _maxFreq; // maximal output frequency
 
diff --git a/daemon/src/audio/sound/audiofile.cpp b/daemon/src/audio/sound/audiofile.cpp
index c744aca12eb7e06cbce7c5f2a1a0a8115ebc3920..ece603e36db9a088f23b6b2d60b6ee716e7b6e9d 100644
--- a/daemon/src/audio/sound/audiofile.cpp
+++ b/daemon/src/audio/sound/audiofile.cpp
@@ -73,51 +73,40 @@ RawFile::RawFile(const std::string& name, sfl::AudioCodec* codec, unsigned int s
     SFLDataFormat *monoBuffer = new SFLDataFormat[decodedSize];
     SFLDataFormat *bufpos = monoBuffer;
     unsigned char *filepos = reinterpret_cast<unsigned char *>(fileBuffer);
-    _size = decodedSize;
-    while(length >= encFrameSize) {
+    size_ = decodedSize;
+    while (length >= encFrameSize) {
     	bufpos += audioCodec->decode (bufpos, filepos, encFrameSize);
     	filepos += encFrameSize;
     	length -= encFrameSize;
     }
-    delete[] fileBuffer;
-
-    if (sampleRate == audioRate) {
-#ifdef DATAFORMAT_IS_FLOAT
-        _buffer = new SFLDataFormat[_size];
-        src_short_to_float_array (monoBuffer, _buffer, _size);
-        delete[] monoBuffer;
-#else
-        _buffer = monoBuffer;
-#endif
-
-    } else {
+    delete [] fileBuffer;
+
+    if (sampleRate == audioRate)
+        buffer_ = monoBuffer;
+    else {
         double factord = (double) sampleRate / audioRate;
-        float* floatBufferIn = new float[_size];
-        int    sizeOut  = ceil(factord*_size);
-        src_short_to_float_array (monoBuffer, floatBufferIn, _size);
-        delete[] monoBuffer;
-        SFLDataFormat* _buffer = new SFLDataFormat[sizeOut];
+        float* floatBufferIn = new float[size_];
+        int    sizeOut  = ceil(factord * size_);
+        src_short_to_float_array (monoBuffer, floatBufferIn, size_);
+        delete [] monoBuffer;
+        delete [] buffer_;
+        buffer_ = new SFLDataFormat[sizeOut];
 
         SRC_DATA src_data;
         src_data.data_in = floatBufferIn;
-        src_data.input_frames = _size;
+        src_data.input_frames = size_;
         src_data.output_frames = sizeOut;
         src_data.src_ratio = factord;
 
-#ifdef DATAFORMAT_IS_FLOAT
-        src_data.data_out = _buffer;
-        src_simple (&src_data, SRC_SINC_BEST_QUALITY, 1);
-#else
         float* floatBufferOut = new float[sizeOut];
         src_data.data_out = floatBufferOut;
 
         src_simple (&src_data, SRC_SINC_BEST_QUALITY, 1);
-        src_float_to_short_array (floatBufferOut, _buffer, src_data.output_frames_gen);
+        src_float_to_short_array (floatBufferOut, buffer_, src_data.output_frames_gen);
 
         delete [] floatBufferOut;
-#endif
         delete [] floatBufferIn;
-        _size = src_data.output_frames_gen;
+        size_ = src_data.output_frames_gen;
     }
 }
 
@@ -148,8 +137,8 @@ WaveFile::WaveFile (const std::string& fileName, unsigned int audioSamplingRate)
     SINT32 chunk_size; // fmt chunk size
     unsigned short formatTag; // data compression tag
 
-    fileStream.read ( (char*) &chunk_size, 4); // Read fmt chunk size.
-    fileStream.read ( (char*) &formatTag, 2);
+    fileStream.read(reinterpret_cast<char*>(&chunk_size), 4); // Read fmt chunk size.
+    fileStream.read(reinterpret_cast<char*>(&formatTag), 2);
 
     if (formatTag != 1) // PCM = 1, FLOAT = 3
         throw AudioFileException("File contains an unsupported data format type");
@@ -158,12 +147,12 @@ WaveFile::WaveFile (const std::string& fileName, unsigned int audioSamplingRate)
     SINT16 chan;
     fileStream.read ( (char*) &chan, 2);
 
-    if(chan > 2)
+    if (chan > 2)
     	throw AudioFileException("WaveFile: unsupported number of channels");
 
     // Get file sample rate from the header.
     SINT32 srate;
-    fileStream.read ( (char*) &srate, 4);
+    fileStream.read( (char*) &srate, 4);
 
     SINT32 avgb;
     fileStream.read ( (char*) &avgb, 4);
@@ -185,7 +174,7 @@ WaveFile::WaveFile (const std::string& fileName, unsigned int audioSamplingRate)
 
     // Sample rate converter initialized with 88200 sample long
     int converterSamples  = ((unsigned int)srate > audioSamplingRate) ? srate : audioSamplingRate;
-    SamplerateConverter _converter (converterSamples);
+    SamplerateConverter converter_(converterSamples);
 
     // Get length of data from the header.
     SINT32 bytes;
@@ -197,31 +186,28 @@ WaveFile::WaveFile (const std::string& fileName, unsigned int audioSamplingRate)
     		nbSamples, bytes,  blockal, srate, avgb, chunk_size, dt);
 
     // Should not be longer than a minute
-    if (nbSamples > (unsigned int) (60*srate))
-        nbSamples = 60*srate;
+    if (nbSamples > static_cast<unsigned int>(60 * srate))
+        nbSamples = 60 * srate;
 
     SFLDataFormat *tempBuffer = new SFLDataFormat[nbSamples];
-    if (!tempBuffer)
-        throw AudioFileException("Could not allocate temporary buffer");
 
-    fileStream.read ( (char *) tempBuffer, nbSamples*sizeof (SFLDataFormat));
+    fileStream.read (reinterpret_cast<char *>(tempBuffer), nbSamples * sizeof(SFLDataFormat));
 
     // mix two channels together if stereo
-    if(chan == 2) {
-    	for(unsigned int i = 0; i < nbSamples-1; i+=2)
-    		tempBuffer[i/2] = (tempBuffer[i] + tempBuffer[i+1]) / 2;
-    	nbSamples /= 2;
+    if (chan == 2) {
+    	for (unsigned int i = 0; i < nbSamples - 1; i += 2)
+            tempBuffer[static_cast<size_t>(i * 0.5)] = (tempBuffer[i] + tempBuffer[i + 1]) * 0.5;
+    	nbSamples *= 0.5;
     }
 
-    if ((unsigned int)srate != audioSamplingRate) {
+    if ((unsigned int) srate != audioSamplingRate) {
         int outSamples = ((float) nbSamples * ( (float) audioSamplingRate / (float) srate));
-	    _buffer = new SFLDataFormat[outSamples];
-		_converter.resample (tempBuffer, _buffer, srate, audioSamplingRate, nbSamples);
-		delete[] tempBuffer;
-    } else {
-    	_buffer = tempBuffer;
-    }
-
-    _size = nbSamples;
-    _sampleRate = audioSamplingRate;
+	    buffer_ = new SFLDataFormat[outSamples];
+		converter_.resample (tempBuffer, buffer_, srate, audioSamplingRate, nbSamples);
+		delete [] tempBuffer;
+    } else
+    	buffer_ = tempBuffer;
+
+    size_ = nbSamples;
+    sampleRate_ = audioSamplingRate;
 }
diff --git a/daemon/src/audio/sound/tone.cpp b/daemon/src/audio/sound/tone.cpp
index d45064ef43a9d65b921a813601c1af642cfdd094..a19e562b3437802b7c5b49e5f9ce58ffcb55672f 100644
--- a/daemon/src/audio/sound/tone.cpp
+++ b/daemon/src/audio/sound/tone.cpp
@@ -35,31 +35,26 @@
  * YM: 2006-11-15: changes unsigned int to std::string::size_type, thanks to Pierre Pomes (AMD64 compilation)
  */
 #include "tone.h"
-#include <math.h>
+#include <cmath>
 #include <cstdlib>
 #include <cstring>
 
-#define TABLE_LENGTH 4096
-double TWOPI = 2 * M_PI;
+static const double TWOPI = 2.0 * M_PI;
 
-Tone::Tone (const std::string& definition, unsigned int sampleRate) : AudioLoop(), _sampleRate (sampleRate), _xhigher (0.0), _xlower (0.0)
+Tone::Tone(const std::string& definition, unsigned int sampleRate) :
+    sampleRate_(sampleRate), xhigher_(0.0), xlower_(0.0)
 {
     fillWavetable();
-    genBuffer (definition); // allocate memory with definition parameter
-}
-
-Tone::~Tone()
-{
+    genBuffer(definition); // allocate memory with definition parameter
 }
 
 void
-Tone::genBuffer (const std::string& definition)
+Tone::genBuffer(const std::string& definition)
 {
-    if (definition.empty()) {
+    if (definition.empty())
         return;
-    }
 
-    _size = 0;
+    size_ = 0;
 
     SFLDataFormat* buffer = new SFLDataFormat[SIZEBUF]; //1kb
     SFLDataFormat* bufferPos = buffer;
@@ -76,67 +71,61 @@ Tone::genBuffer (const std::string& definition)
     do {
         posEnd = definition.find (',', posStart);
 
-        if (posEnd == std::string::npos) {
+        if (posEnd == std::string::npos)
             posEnd = deflen;
-        }
 
+        /* begin scope */
         {
             // Sample string: "350+440" or "350+440/2000,244+655/2000"
             int freq1, freq2, time;
-            s = definition.substr (posStart, posEnd-posStart);
+            s = definition.substr(posStart, posEnd-posStart);
 
             // The 1st frequency is before the first + or the /
-            std::string::size_type pos_plus = s.find ('+');
-            std::string::size_type pos_slash = s.find ('/');
-            std::string::size_type len = s.length();
-            std::string::size_type endfrequency = 0;
+            size_t pos_plus = s.find('+');
+            size_t pos_slash = s.find('/');
+            size_t len = s.length();
+            size_t endfrequency = 0;
 
             if (pos_slash == std::string::npos) {
                 time = 0;
                 endfrequency = len;
             } else {
-                time = atoi ( (s.substr (pos_slash+1,len-pos_slash-1)).data());
+                time = atoi(s.substr(pos_slash + 1, len - pos_slash - 1).c_str());
                 endfrequency = pos_slash;
             }
 
             // without a plus = 1 frequency
             if (pos_plus == std::string::npos) {
-                freq1 = atoi ( (s.substr (0,endfrequency)).data());
+                freq1 = atoi(s.substr(0, endfrequency).c_str());
                 freq2 = 0;
             } else {
-                freq1 = atoi ( (s.substr (0,pos_plus)).data());
-                freq2 = atoi ( (s.substr (pos_plus+1, endfrequency-pos_plus-1)).data());
+                freq1 = atoi(s.substr(0, pos_plus).c_str());
+                freq2 = atoi(s.substr(pos_plus + 1, endfrequency - pos_plus - 1).c_str());
             }
 
             // If there is time or if it's unlimited
-            if (time == 0) {
-                count = _sampleRate;
-            } else {
-                count = (_sampleRate * time) / 1000;
-            }
+            if (time == 0)
+                count = sampleRate_;
+            else
+                count = (sampleRate_ * time) / 1000;
 
             // Generate SAMPLING_RATE samples of sinus, buffer is the result
-            _debug ("genSin(%d, %d)", freq1, freq2);
-            genSin (bufferPos, freq1, freq2, count);
+            _debug("genSin(%d, %d)", freq1, freq2);
+            genSin(bufferPos, freq1, freq2, count);
 
             // To concatenate the different buffers for each section.
-            _size += (count);
+            size_ += count;
+            bufferPos += count;
+        } /* end scope */
 
-            bufferPos += (count);
-        }
-
-        posStart = posEnd+1;
+        posStart = posEnd + 1;
     } while (posStart < deflen);
 
-    _buffer = new SFLDataFormat[_size];
-
-    memcpy (_buffer, buffer, _size*sizeof (SFLDataFormat)); // copy char, not SFLDataFormat.
-
-    delete[] buffer;
+    buffer_ = new SFLDataFormat[size_];
 
-    buffer=0;
+    memcpy(buffer_, buffer, size_ * sizeof(SFLDataFormat)); // copy char, not SFLDataFormat.
 
-    bufferPos=0;
+    delete [] buffer;
 }
 
 void
@@ -144,9 +133,8 @@ Tone::fillWavetable()
 {
     double tableSize = (double) TABLE_LENGTH;
 
-    for (int i = 0; i < TABLE_LENGTH; i++) {
-        _wavetable[i] = sin ( ( (double) i / (tableSize - 1.0)) * TWOPI);
-    }
+    for (int i = 0; i < TABLE_LENGTH; ++i)
+        wavetable_[i] = sin((static_cast<double>(i) / (tableSize - 1.0)) * TWOPI);
 }
 
 double
@@ -156,24 +144,24 @@ Tone::interpolate (double x)
     double yi_0, yi_1, A, B;
 
     xi_0 = (int) x;
-    xi_1 = xi_0+1;
+    xi_1 = xi_0 + 1;
 
-    yi_0  =_wavetable[xi_0];
-    yi_1 = _wavetable[xi_1];
+    yi_0 = wavetable_[xi_0];
+    yi_1 =  wavetable_[xi_1];
 
     A = (x - xi_0);
     B = 1.0 - A;
 
-    return A*yi_0 + B*yi_1;
+    return (A * yi_0) + (B * yi_1);
 }
 
 void
 Tone::genSin (SFLDataFormat* buffer, int frequency1, int frequency2, int nb)
 {
-    _xhigher = 0.0;
-    _xlower = 0.0;
+    xhigher_ = 0.0;
+    xlower_ = 0.0;
 
-    double sr = (double) _sampleRate;
+    double sr = (double) sampleRate_;
     double tableSize = (double) TABLE_LENGTH;
 
     double N_h = sr / (double) (frequency1);
@@ -182,27 +170,25 @@ Tone::genSin (SFLDataFormat* buffer, int frequency1, int frequency2, int nb)
     double dx_h = tableSize / N_h;
     double dx_l = tableSize / N_l;
 
-    double x_h = _xhigher;
-    double x_l = _xlower;
+    double x_h = xhigher_;
+    double x_l = xlower_;
 
-    double amp = (double) SFLDataAmplitude;
+    static const double DATA_AMPLITUDE = 2047;
+    double amp =  DATA_AMPLITUDE;
 
     for (int t = 0; t < nb; t ++) {
-        buffer[t] = (int16) (amp* (interpolate (x_h) + interpolate (x_l)));
+        buffer[t] = static_cast<SFLDataFormat>(amp * (interpolate(x_h) + interpolate(x_l)));
         x_h += dx_h;
         x_l += dx_l;
 
-        if (x_h > tableSize) {
+        while (x_h > tableSize)
             x_h -= tableSize;
-        }
 
-        if (x_l > tableSize) {
+        while (x_l > tableSize)
             x_l -= tableSize;
-        }
     }
 
-    _xhigher = x_h;
-    _xlower = x_l;
-
+    xhigher_ = x_h;
+    xlower_ = x_l;
 }
 
diff --git a/daemon/src/audio/sound/tone.h b/daemon/src/audio/sound/tone.h
index 1cfa3348411298b0afef9b042ee6065202c06666..fc20ef90f8bb3252ac66af9f10339eb90e4a9928 100644
--- a/daemon/src/audio/sound/tone.h
+++ b/daemon/src/audio/sound/tone.h
@@ -36,8 +36,6 @@
 #include <string>
 #include "audio/audioloop.h"
 
-#define TABLE_LENGTH 4096
-
 /**
  * @file tone.h
  * @brief Tone sample (dial, busy, ring, congestion)
@@ -52,11 +50,6 @@ class Tone : public AudioLoop
          */
         Tone (const std::string& definition, unsigned int sampleRate);
 
-        /**
-         * Destructor
-         */
-        ~Tone();
-
         /** The different kind of tones */
         enum TONEID {
             TONE_DIALTONE = 0,
@@ -74,17 +67,17 @@ class Tone : public AudioLoop
          * @param nb are the number of int16 (mono) to generate
          * by example nb=5 generate 10 int16, 5 for the left, 5 for the right
          */
-        void genSin (SFLDataFormat* buffer, int frequency1, int frequency2, int nb);
+        void genSin(SFLDataFormat* buffer, int frequency1, int frequency2, int nb);
 
         /**
          *
          */
-        void fillWavetable (void);
+        void fillWavetable(void);
 
         /**
          *
          */
-        double interpolate (double x);
+        double interpolate(double x);
 
 
     private:
@@ -93,15 +86,16 @@ class Tone : public AudioLoop
          * allocate the memory with the definition
          * @param definition String that contain frequency/time of the tone.
          */
-        void genBuffer (const std::string& definition);
+        void genBuffer(const std::string& definition);
 
         /** Sample rate */
-        unsigned int _sampleRate;
+        unsigned int sampleRate_;
 
-        double _wavetable[TABLE_LENGTH];
+        static const int TABLE_LENGTH = 4096;
+        double wavetable_[TABLE_LENGTH];
 
-        double _xhigher;
-        double _xlower;
+        double xhigher_;
+        double xlower_;
 };
 
 #endif // __TONE_H__
diff --git a/daemon/src/global.h b/daemon/src/global.h
index b7d8458aa872f386a33e8e552f01b4dae30033b1..ef8b085fe4dcce223cc4c254cd4007aae3149ceb 100644
--- a/daemon/src/global.h
+++ b/daemon/src/global.h
@@ -49,38 +49,13 @@
 #define XDG_CACHE_HOME			(getenv ("XDG_CACHE_HOME"))
 const char * const ZRTP_ZID_FILENAME = "sfl.zid";
 
-typedef float float32;
-typedef short int16;
-
 //useful typedefs.
 typedef signed short SINT16;
 typedef signed int SINT32;
 
-typedef unsigned long FILE_TYPE;
-typedef unsigned long SOUND_FORMAT;
-
-const FILE_TYPE  FILE_RAW = 1;
-const FILE_TYPE  FILE_WAV = 2;
-
-static const SOUND_FORMAT INT16 = 0x2; // TODO shold change these symbols
-static const SOUND_FORMAT INT32 = 0x8;
-
 #define PIDFILE "sfl.pid"
 
-#ifdef DATAFORMAT_IS_FLOAT
-#define SFLDataFormat float32
-#define SFLDataFormatString "Float32"
-#define SFLDataAmplitude 0.05
-#else
-#define SFLDataFormat int16
-#define SFLDataFormatString "Int16"
-#define SFLDataAmplitude (32767 >> 4)
-#endif
-
-#define PROGNAME         "sflphoned"		/** Binary name */
-#define PROGDIR          "sflphone"		/** Program directory */
-#define RINGDIR          "ringtones"		/** Ringtones directory */
-#define CODECDIR         "codecs"		/** Codecs directory */
+typedef short SFLDataFormat;
 
 #define SIZEBUF 		 400000 /** About 12 sec of buffering at 8000 Hz*/
 
@@ -92,19 +67,11 @@ static const SOUND_FORMAT INT32 = 0x8;
 #define PCM_DSNOOP	"plug:dsnoop"		/** Alsa plugin for microphone sharing */
 #define PCM_DMIX_DSNOOP "dmix/dsnoop"           /** Audio profile using Alsa dmix/dsnoop */
 
-#define SFL_CODEC_VALID_PREFIX	"libcodec_"	/** Valid prefix for codecs shared library */
-#define SFL_CODEC_VALID_EXTEN	".so"		/** Valid extension for codecs shared library */
-#define CURRENT_DIR		"."		/** Current directory */
-#define PARENT_DIR		".."		/** Parent directory */
-
 #define SFL_PCM_BOTH		0x0021		/** To open both playback and capture devices */
 #define SFL_PCM_PLAYBACK	0x0022		/** To open playback device only */
 #define SFL_PCM_CAPTURE		0x0023		/** To open capture device only */
-#define SFL_PCM_RINGTONE        0x0024
+#define SFL_PCM_RINGTONE    0x0024
 
-#define GSM_STRING_DESCRIPTION	  "gsm"		/** GSM codec string description */
-#define SPEEX_STRING_DESCRIPTION  "speex"	/** SPEEX codec string description */
-#define ILBC_STRING_DESCRIPTION   "ilbc"		/** Ilbc codec string description */
 #define RINGTONE_ENABLED	      TRUE_STR		/** Custom ringtone enable or not */
 #define DISPLAY_DIALPAD		      TRUE_STR		/** Display dialpad or not */
 #define DISPLAY_VOLUME_CONTROLS	  TRUE_STR		/** Display the volume controls or not */
@@ -126,9 +93,6 @@ static const SOUND_FORMAT INT32 = 0x8;
 #define DEFAULT_SIP_PORT    5060
 #define DEFAULT_SIP_TLS_PORT 5061
 
-#define HOOK_DEFAULT_SIP_FIELD      "X-sflphone-url"
-#define HOOK_DEFAULT_URL_COMMAND    "x-www-browser"
-
 /** Enumeration that contains known audio payloads */
 enum {
     // http://www.iana.org/assignments/rtp-parameters
diff --git a/daemon/src/managerimpl.cpp b/daemon/src/managerimpl.cpp
index a59b99b4a88ae5c7755b433ce818d286251585f1..7ce6d1dc8447010503928efd10ec4fbcf9cc7d70 100644
--- a/daemon/src/managerimpl.cpp
+++ b/daemon/src/managerimpl.cpp
@@ -1743,6 +1743,7 @@ void ManagerImpl::ringtone (const std::string& accountID)
     std::string ringchoice = account->getRingtonePath();
 	if (ringchoice.find (DIR_SEPARATOR_STR) == std::string::npos) {
 		// check inside global share directory
+        static const char * RINGDIR = "ringtones";
 		ringchoice = std::string (PROGSHAREDIR) + DIR_SEPARATOR_STR
 					 + RINGDIR + DIR_SEPARATOR_STR + ringchoice;
 	}
@@ -1819,7 +1820,7 @@ ManagerImpl::getTelephoneFile ()
 std::string ManagerImpl::getConfigFile (void) const
 {
 	std::string configdir = std::string (HOMEDIR) + DIR_SEPARATOR_STR + ".config"
-                 + DIR_SEPARATOR_STR + PROGDIR;
+                 + DIR_SEPARATOR_STR + PACKAGE;
 
     if (XDG_CONFIG_HOME != NULL) {
         std::string xdg_env = std::string (XDG_CONFIG_HOME);
@@ -1833,6 +1834,7 @@ std::string ManagerImpl::getConfigFile (void) const
             _debug ("Cannot create directory: %m");
     }
 
+    static const char * PROGNAME = "sflphoned";
     return configdir + DIR_SEPARATOR_STR + PROGNAME + ".yml";
 }