diff --git a/daemon/libs/compile_pjsip.sh b/daemon/libs/compile_pjsip.sh
index 4b0ea02816b01a127e42ef1a48d2740b35b5b43c..7bd9df0ff4c533658e2b5462762fdff932c675cd 100755
--- a/daemon/libs/compile_pjsip.sh
+++ b/daemon/libs/compile_pjsip.sh
@@ -2,4 +2,4 @@
 
 # TODO: autotools should be doing this
 cd "`dirname $BASH_SOURCE`"/pjproject
-CFLAGS=-fPIC ./configure && make dep && make -j1 && echo "pjsip successfully compiled"
+CFLAGS="-fPIC" ./configure --disable-sound && make dep && make -j1 && echo "pjsip successfully compiled"
diff --git a/daemon/libs/iax2/iax-client.h b/daemon/libs/iax2/iax-client.h
index e4a80d6280e6e3c58904c20dcd89a1a587775480..36cac57d050299bb1f45017f70c288379d91e330 100644
--- a/daemon/libs/iax2/iax-client.h
+++ b/daemon/libs/iax2/iax-client.h
@@ -11,6 +11,8 @@
  * the GNU Lesser General Public License (LGPL)
  */
 
+#include <sys/socket.h>
+
 #ifndef _ASTERISK_IAX_CLIENT_H
 #define _ASTERISK_IAX_CLIENT_H
 
diff --git a/daemon/libs/pjproject/pjlib/include/pj/config.h b/daemon/libs/pjproject/pjlib/include/pj/config.h
index 489cffcc4959485fe654fc83709e77a73598fd9c..4d64d9564f58428ff007a994f6c5bf19d0e15f40 100644
--- a/daemon/libs/pjproject/pjlib/include/pj/config.h
+++ b/daemon/libs/pjproject/pjlib/include/pj/config.h
@@ -275,6 +275,20 @@
 #   define PJ_HAS_PENTIUM	0
 #   define PJ_IS_LITTLE_ENDIAN	1
 #   define PJ_IS_BIG_ENDIAN	0
+
+#elif defined(PJ_M_SH) || defined(__sh__) || defined(__sh) || \
+	defined(__SH__) || defined(_ARCH_SH) || defined(_SH_)
+    /*
+     * Renesas SuperH, default to little endian
+     */
+#   undef PJ_M_SH
+#   define PJ_M_SH		1
+#   define PJ_M_NAME		"sh"
+#   define PJ_HAS_PENTIUM	0
+#   if !defined(PJ_IS_LITTLE_ENDIAN) && !defined(PJ_IS_BIG_ENDIAN)
+#   	define PJ_IS_LITTLE_ENDIAN	1
+#   	define PJ_IS_BIG_ENDIAN		0
+#   endif
 		
 #else
 #   error "Please specify target machine."
diff --git a/daemon/src/audio/audiortp/audio_rtp_factory.cpp b/daemon/src/audio/audiortp/audio_rtp_factory.cpp
index 0f3e7eb4a66fc6869fc425f24c587c771f5686a9..5e82038387a8b9ef3b279ac3d8c64404a8d9c94f 100644
--- a/daemon/src/audio/audiortp/audio_rtp_factory.cpp
+++ b/daemon/src/audio/audiortp/audio_rtp_factory.cpp
@@ -194,11 +194,15 @@ void sfl::AudioRtpFactory::initLocalCryptoInfoOnOffHold()
 
 void AudioRtpFactory::setRemoteCryptoInfo(sfl::SdesNegotiator& nego)
 {
-    if (rtpSession_ and keyExchangeProtocol_ == SDES) {
-        AudioSrtpSession *srtp = static_cast<AudioSrtpSession *>(rtpSession_);
-        srtp->setRemoteCryptoInfo(nego);
+    if (rtpSession_ ) {
+        if (keyExchangeProtocol_ == SDES) {
+            AudioSrtpSession *srtp = static_cast<AudioSrtpSession *>(rtpSession_);
+            srtp->setRemoteCryptoInfo(nego);
+        } else {
+            ERROR("Should not store remote crypto info for non-SDES sessions");
+        }
     } else
-        throw AudioRtpFactoryException("RTP: Error: rtpSession_ is NULL in setRemoteCryptoInfo");
+        throw AudioRtpFactoryException("rtpSession_ is NULL in setRemoteCryptoInfo");
 }
 
 void AudioRtpFactory::setDtmfPayloadType(unsigned int payloadType)
@@ -209,7 +213,8 @@ void AudioRtpFactory::setDtmfPayloadType(unsigned int payloadType)
 
 void AudioRtpFactory::sendDtmfDigit(int digit)
 {
-    rtpSession_->putDtmfEvent(digit);
+    if (rtpSession_)
+        rtpSession_->putDtmfEvent(digit);
 }
 
 void sfl::AudioRtpFactory::saveLocalContext()
diff --git a/daemon/src/fileutils.cpp b/daemon/src/fileutils.cpp
index 0cbbc84c711640de03584a9f5bf7b9bb498e35b5..594d186126c77e4ae8806f3c9fa256b79e00bd02 100644
--- a/daemon/src/fileutils.cpp
+++ b/daemon/src/fileutils.cpp
@@ -28,6 +28,8 @@
  *  as that of the covered work.
  */
 
+#include <sys/types.h>
+#include <unistd.h>
 #include <libgen.h>
 #include <dirent.h>
 #include <sys/stat.h>
diff --git a/daemon/src/sip/sipvoiplink.cpp b/daemon/src/sip/sipvoiplink.cpp
index b42be97263c58d784a6090cdcc70a570d6b343b1..3f37a8d1c53e6a751b1a90bb9ea2c586af282dfc 100644
--- a/daemon/src/sip/sipvoiplink.cpp
+++ b/daemon/src/sip/sipvoiplink.cpp
@@ -305,9 +305,15 @@ pj_bool_t transaction_request_cb(pjsip_rx_data *rdata)
     call->getLocalSDP()->setLocalIP(addrSdp);
 
     call->getAudioRtp().initConfig();
-    call->getAudioRtp().initSession();
+    try {
+        call->getAudioRtp().initSession();
+    } catch (const ost::Socket::Error &err) {
+        ERROR("AudioRtp socket error");
+        delete call;
+        return PJ_FALSE;
+    }
 
-    if (body and body->len > 0) {
+    if (body and body->len > 0 and call->getAudioRtp().isSdesEnabled()) {
         std::string sdpOffer(static_cast<const char*>(body->data), body->len);
         size_t start = sdpOffer.find("a=crypto:");
 
diff --git a/daemon/src/video/video_receive_thread.cpp b/daemon/src/video/video_receive_thread.cpp
index 1f55d57a2dc594bd022980a22d5350e5c3f9ef77..0b6be837b5dd9b86d73f6e15cf348b71aa9858b1 100644
--- a/daemon/src/video/video_receive_thread.cpp
+++ b/daemon/src/video/video_receive_thread.cpp
@@ -150,7 +150,13 @@ void VideoReceiveThread::setup()
     inputCtx_ = avformat_alloc_context();
     inputCtx_->interrupt_callback = interruptCb_;
     int ret = avformat_open_input(&inputCtx_, input.c_str(), file_iformat, options ? &options : NULL);
-    EXIT_IF_FAIL(ret == 0, "Could not open input \"%s\"", input.c_str());
+
+    if (ret < 0) {
+        if (options)
+            av_dict_free(&options);
+        ERROR("Could not open input \"%s\"", input.c_str());
+        ost::Thread::exit();
+    }
 
     DEBUG("Finding stream info");
     if (requestKeyFrameCallback_)
@@ -161,6 +167,8 @@ void VideoReceiveThread::setup()
 #else
     ret = avformat_find_stream_info(inputCtx_, options ? &options : NULL);
 #endif
+    if (options)
+        av_dict_free(&options);
     if (ret < 0) {
         // workaround for this bug:
         // http://patches.libav.org/patch/22541/
diff --git a/daemon/src/video/video_send_thread.cpp b/daemon/src/video/video_send_thread.cpp
index bfecea613d518c6b3cba558c7b52d925e6340baf..38178a28088caf3eb57eb366f86b35c1fba1bed9 100644
--- a/daemon/src/video/video_send_thread.cpp
+++ b/daemon/src/video/video_send_thread.cpp
@@ -187,12 +187,19 @@ void VideoSendThread::setup()
     inputCtx_->interrupt_callback = interruptCb_;
     int ret = avformat_open_input(&inputCtx_, args_["input"].c_str(),
                                   file_iformat, options ? &options : NULL);
-    EXIT_IF_FAIL(ret == 0, "Could not open input file %s", args_["input"].c_str());
+    if (ret < 0) {
+        if (options)
+            av_dict_free(&options);
+        ERROR("Could not open input file %s", args_["input"].c_str());
+        ost::Thread::exit();
+    }
 #if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(53, 8, 0)
     ret = av_find_stream_info(inputCtx_);
 #else
     ret = avformat_find_stream_info(inputCtx_, options ? &options : NULL);
 #endif
+    if (options)
+        av_dict_free(&options);
     EXIT_IF_FAIL(ret >= 0, "Couldn't find stream info");
 
     // find the first video stream from the input
@@ -277,8 +284,13 @@ void VideoSendThread::setup()
         DEBUG("Writing stream header for payload type %s", args_["payload_type"].c_str());
         av_dict_set(&outOptions, "payload_type", args_["payload_type"].c_str(), 0);
     }
-    EXIT_IF_FAIL(avformat_write_header(outputCtx_, outOptions ? &outOptions : NULL) >= 0, "Could not write "
-                 "header for output file...check codec parameters")
+
+
+    ret = avformat_write_header(outputCtx_, outOptions ? &outOptions : NULL);
+    if (outOptions)
+        av_dict_free(&outOptions);
+    EXIT_IF_FAIL(ret >= 0, "Could not write header for output file...check codec parameters");
+
     av_dump_format(outputCtx_, 0, outputCtx_->filename, 1);
     print_sdp();
 
@@ -432,8 +444,11 @@ VideoSendThread::~VideoSendThread()
     // before you close the CodecContexts open when you wrote the
     // header; otherwise write_trailer may try to use memory that
     // was freed on av_codec_close()
-    if (outputCtx_ and outputCtx_->priv_data)
+    if (outputCtx_ and outputCtx_->priv_data) {
         av_write_trailer(outputCtx_);
+        if (outputCtx_->pb)
+            avio_close(outputCtx_->pb);
+    }
 
     if (scaledPictureBuf_)
         av_free(scaledPictureBuf_);