refactor: cleanup and sync

* Fix Jenkins scripts and sync with ndn-cxx
* Sync waf-tools
* Remove ChronoSync submodule
* Remove commented/dead code and includes
* Use ScopedEventId and ScopedRegisteredPrefixHandle
* Set setCanBePrefix to true explicitly everywhere
* Fix macOS build, add GHA CI
* Use NDN_THROW for throwing errors
* Other smaller fixes

Change-Id: I615e0e239511b97101852e1d7c620a2071a18ff8
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index f475e24..49216c8 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -9,7 +9,7 @@
 jobs:
   linux:
     runs-on: ${{ matrix.os }}
-    name: ${{ matrix.os }} build
+    name: ${{ matrix.os }}
 
     strategy:
       matrix:
@@ -17,7 +17,8 @@
 
     env:
       NODE_LABELS: "Linux Ubuntu ${{ matrix.os }}"
-      WAF_JOBS: 2
+      WAF_JOBS: 4
+      JOB_NAME: limited-build
 
     steps:
     - uses: actions/checkout@v2
@@ -25,3 +26,43 @@
     - name: Run build script
       run: |
         ./.jenkins
+
+  ubuntu-ppa:
+    runs-on: ubuntu-latest
+    name: Ubuntu PPA build
+
+    steps:
+    - uses: actions/checkout@v2
+
+    - name: Run build script
+      run: |
+        sudo apt install -y software-properties-common
+        sudo add-apt-repository ppa:named-data/ppa -y
+        sudo apt update
+        sudo apt-get install nfd libndn-cxx-dev libchronosync-dev
+        sudo apt-get install libcrypto++-dev libboost-all-dev qt5-default
+        ./waf --color=yes configure --debug
+        ./waf --color=yes build -j4
+
+  macos:
+    runs-on: ${{ matrix.os }}
+    continue-on-error: false
+    name: Xcode ${{ matrix.xcode }}
+
+    strategy:
+      matrix:
+        os: [macos-latest]
+        xcode: [11.3.1, 11.7, 12.2]
+
+    env:
+      WAF_JOBS: 4
+      JOB_NAME: limited-build
+
+    steps:
+    - uses: actions/checkout@v2
+
+    - name: Run build script
+      run: |
+        sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer
+        export NODE_LABELS="OSX OSX-$(sw_vers -productVersion | cut -d . -f -2)"
+        ./.jenkins
diff --git a/.gitmodules b/.gitmodules
deleted file mode 100644
index 462f6b1..0000000
--- a/.gitmodules
+++ /dev/null
@@ -1,4 +0,0 @@
-[submodule "ChronoSync"]
-	path = ChronoSync
-	url = git://github.com/named-data/ChronoSync.git
-	branch = master
diff --git a/.jenkins b/.jenkins
index 674d751..bc1c847 100755
--- a/.jenkins
+++ b/.jenkins
@@ -1,10 +1,32 @@
 #!/usr/bin/env bash
 set -e
+source .jenkins.d/util.sh
 
-DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
+export CACHE_DIR=${CACHE_DIR:-/tmp}
+export WAF_JOBS=${WAF_JOBS:-1}
+[[ $JOB_NAME == *"code-coverage" ]] && export DISABLE_ASAN=yes
 
-for file in "$DIR"/.jenkins.d/*; do
+nanos() {
+    # Cannot use date(1) because macOS does not support %N format specifier
+    python3 -c 'import time; print(int(time.time() * 1e9))'
+}
+
+for file in .jenkins.d/*; do
     [[ -f $file && -x $file ]] || continue
-    echo "Run: $file"
+
+    if [[ -n $TRAVIS ]]; then
+        label=$(basename "$file" | sed -E 's/[[:digit:]]+-(.*)\..*/\1/')
+        echo -ne "travis_fold:start:${label}\r"
+        echo -ne "travis_time:start:${label}\r"
+        start=$(nanos)
+    fi
+
+    echo "\$ $file"
     "$file"
+
+    if [[ -n $TRAVIS ]]; then
+        finish=$(nanos)
+        echo -ne "travis_time:end:${label}:start=${start},finish=${finish},duration=$((finish-start)),event=${label}\r"
+        echo -ne "travis_fold:end:${label}\r"
+    fi
 done
diff --git a/.jenkins.d/00-deps.sh b/.jenkins.d/00-deps.sh
index 261097c..34d006e 100755
--- a/.jenkins.d/00-deps.sh
+++ b/.jenkins.d/00-deps.sh
@@ -1,25 +1,37 @@
 #!/usr/bin/env bash
-set -x
-set -e
-
-JDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
-source "$JDIR"/util.sh
-
-[[ -n $NODE_LABELS ]] || exit 0
+set -ex
 
 if has OSX $NODE_LABELS; then
-    brew update
-    brew upgrade
-    brew install boost pkg-config qt4
-    brew cleanup
-fi
+    FORMULAE=(boost openssl pkg-config qt)
+    if has OSX-10.13 $NODE_LABELS || has OSX-10.14 $NODE_LABELS; then
+        FORMULAE+=(python)
+    fi
 
-if has Ubuntu $NODE_LABELS; then
-    sudo apt-get update -qq -y
-    sudo apt-get -qq -y install build-essential
-    sudo apt-get -qq -y install libssl-dev libsqlite3-dev
+    if [[ -n $GITHUB_ACTIONS ]]; then
+        # Homebrew doesn't have cryptopp packages, so build from source
+        git clone https://github.com/weidai11/cryptopp/
+        cd cryptopp
+        make -j4
+        make install
+        cd ..
 
-    sudo apt-get -qq -y install libprotobuf-dev protobuf-compiler libevent-dev libcrypto++-dev
-    sudo apt-get -qq -y install libboost-all-dev
-    sudo apt-get -qq -y install qt5-default
-fi
+        # Travis images come with a large number of pre-installed
+        # brew packages, don't waste time upgrading all of them
+        for FORMULA in "${FORMULAE[@]}"; do
+            brew list --versions "$FORMULA" || brew install "$FORMULA"
+        done
+
+        brew link qt --force
+    else
+        brew update
+        brew upgrade
+        brew install "${FORMULAE[@]}"
+        brew cleanup
+    fi
+
+elif has Ubuntu $NODE_LABELS; then
+    sudo apt-get -qq update
+    sudo apt-get -qy install g++ pkg-config python3-minimal \
+                             libboost-all-dev libssl-dev libsqlite3-dev \
+                             libcrypto++-dev qt5-default
+fi
\ No newline at end of file
diff --git a/.jenkins.d/01-ndn-cxx.sh b/.jenkins.d/01-ndn-cxx.sh
new file mode 100755
index 0000000..4e0e154
--- /dev/null
+++ b/.jenkins.d/01-ndn-cxx.sh
@@ -0,0 +1,55 @@
+#!/usr/bin/env bash
+set -ex
+
+pushd "$CACHE_DIR" >/dev/null
+
+INSTALLED_VERSION=
+if has OSX $NODE_LABELS; then
+    BOOST=$(brew ls --versions boost)
+    OLD_BOOST=$(cat boost.txt || :)
+    if [[ $OLD_BOOST != $BOOST ]]; then
+        echo "$BOOST" > boost.txt
+        INSTALLED_VERSION=NONE
+    fi
+fi
+
+if [[ -z $INSTALLED_VERSION ]]; then
+    INSTALLED_VERSION=$(git -C ndn-cxx rev-parse HEAD 2>/dev/null || echo NONE)
+fi
+
+sudo rm -rf ndn-cxx-latest
+git clone --depth 1 https://github.com/named-data/ndn-cxx.git ndn-cxx-latest
+LATEST_VERSION=$(git -C ndn-cxx-latest rev-parse HEAD 2>/dev/null || echo UNKNOWN)
+
+if [[ $INSTALLED_VERSION != $LATEST_VERSION ]]; then
+    sudo rm -rf ndn-cxx
+    mv ndn-cxx-latest ndn-cxx
+else
+    sudo rm -rf ndn-cxx-latest
+fi
+
+sudo rm -f /usr/local/bin/ndnsec*
+sudo rm -fr /usr/local/include/ndn-cxx
+sudo rm -f /usr/local/lib{,64}/libndn-cxx*
+sudo rm -f /usr/local/lib{,64}/pkgconfig/libndn-cxx.pc
+
+pushd ndn-cxx >/dev/null
+
+if has CentOS-8 $NODE_LABELS; then
+    # https://bugzilla.redhat.com/show_bug.cgi?id=1721553
+    PCH="--without-pch"
+fi
+
+./waf --color=yes configure --disable-static --enable-shared --without-osx-keychain $PCH
+./waf --color=yes build -j$WAF_JOBS
+sudo_preserve_env PATH -- ./waf --color=yes install
+
+popd >/dev/null
+popd >/dev/null
+
+if has CentOS-8 $NODE_LABELS; then
+    sudo tee /etc/ld.so.conf.d/ndn.conf >/dev/null <<< /usr/local/lib64
+fi
+if has Linux $NODE_LABELS; then
+    sudo ldconfig
+fi
diff --git a/.jenkins.d/02-chronosync.sh b/.jenkins.d/02-chronosync.sh
new file mode 100755
index 0000000..642e469
--- /dev/null
+++ b/.jenkins.d/02-chronosync.sh
@@ -0,0 +1,46 @@
+#!/usr/bin/env bash
+set -ex
+
+PROJ=ChronoSync
+
+pushd "$CACHE_DIR" >/dev/null
+
+INSTALLED_VERSION=
+NDN_CXX=$(ndnsec version)
+OLD_NDN_CXX=$(cat "$PROJ-ndn-cxx.txt" || :)
+if [[ $OLD_NDN_CXX != $NDN_CXX ]]; then
+    echo "$NDN_CXX" > "$PROJ-ndn-cxx.txt"
+    INSTALLED_VERSION=NONE
+fi
+
+if [[ -z $INSTALLED_VERSION ]]; then
+    INSTALLED_VERSION=$(git -C "$PROJ" rev-parse HEAD 2>/dev/null || echo NONE)
+fi
+
+sudo rm -rf "$PROJ-latest"
+git clone --depth 1 "https://github.com/named-data/$PROJ.git" "$PROJ-latest"
+LATEST_VERSION=$(git -C "$PROJ-latest" rev-parse HEAD 2>/dev/null || echo UNKNOWN)
+
+if [[ $INSTALLED_VERSION != $LATEST_VERSION ]]; then
+    sudo rm -rf "$PROJ"
+    mv "$PROJ-latest" "$PROJ"
+else
+    sudo rm -rf "$PROJ-latest"
+fi
+
+sudo rm -fr /usr/local/include/"$PROJ"
+sudo rm -f /usr/local/lib{,64}/lib"$PROJ"*
+sudo rm -f /usr/local/lib{,64}/pkgconfig/"$PROJ".pc
+
+pushd "$PROJ" >/dev/null
+
+./waf --color=yes configure
+./waf --color=yes build -j$WAF_JOBS
+sudo_preserve_env PATH -- ./waf --color=yes install
+
+popd >/dev/null
+popd >/dev/null
+
+if has Linux $NODE_LABELS; then
+    sudo ldconfig
+fi
diff --git a/.jenkins.d/10-build.sh b/.jenkins.d/10-build.sh
new file mode 100755
index 0000000..4dd6f6f
--- /dev/null
+++ b/.jenkins.d/10-build.sh
@@ -0,0 +1,30 @@
+#!/usr/bin/env bash
+set -ex
+
+git submodule sync
+git submodule update --init
+
+if [[ $JOB_NAME != *"limited-build" ]]; then
+    # Build in release mode with tests
+    ./waf --color=yes configure --with-tests
+    ./waf --color=yes build -j$WAF_JOBS
+
+    # Cleanup
+    ./waf --color=yes distclean
+
+    # Build in release mode without tests
+    ./waf --color=yes configure
+    ./waf --color=yes build -j$WAF_JOBS
+
+    # Cleanup
+    ./waf --color=yes distclean
+fi
+
+# Build in debug mode with tests
+./waf --color=yes configure --debug --with-tests
+./waf --color=yes build -j$WAF_JOBS
+
+# (tests will be run against the debug version)
+
+# Install
+sudo_preserve_env PATH -- ./waf --color=yes install
diff --git a/.jenkins.d/10-ndn-cxx.sh b/.jenkins.d/10-ndn-cxx.sh
deleted file mode 100755
index 841aa3f..0000000
--- a/.jenkins.d/10-ndn-cxx.sh
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/usr/bin/env bash
-set -x
-set -e
-
-pushd /tmp >/dev/null
-
-INSTALLED_VERSION=$((cd ndn-cxx && git rev-parse HEAD) 2>/dev/null || echo NONE)
-
-sudo rm -Rf ndn-cxx-latest
-git clone --depth 1 git://github.com/named-data/ndn-cxx ndn-cxx-latest
-LATEST_VERSION=$((cd ndn-cxx-latest && git rev-parse HEAD) 2>/dev/null || echo UNKNOWN)
-
-if [[ $INSTALLED_VERSION != $LATEST_VERSION ]]; then
-    sudo rm -Rf ndn-cxx
-    mv ndn-cxx-latest ndn-cxx
-else
-    sudo rm -Rf ndn-cxx-latest
-fi
-
-sudo rm -Rf /usr/local/include/ndn-cxx
-sudo rm -f /usr/local/lib/libndn-cxx*
-sudo rm -f /usr/local/lib/pkgconfig/libndn-cxx*
-
-pushd ndn-cxx >/dev/null
-
-./waf configure --color=yes --enable-shared --disable-static --without-osx-keychain
-./waf --color=yes
-sudo ./waf install --color=yes
-
-popd >/dev/null
-popd >/dev/null
diff --git a/.jenkins.d/11-chronosync.sh b/.jenkins.d/11-chronosync.sh
deleted file mode 100755
index b7484fd..0000000
--- a/.jenkins.d/11-chronosync.sh
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/usr/bin/env bash
-set -x
-set -e
-
-sudo rm -Rf /usr/local/include/ChronoSync
-sudo rm -f /usr/local/lib/libChronoSync*
-sudo rm -f /usr/local/lib/pkgconfig/ChronoSync*
-
-
-# Update ChronoSync
-git submodule init
-git submodule update
-pushd ChronoSync >/dev/null
-sudo ./waf --color=yes distclean
-./waf --color=yes configure
-./waf --color=yes build
-sudo ./waf install --color=yes
-sudo ldconfig || true
-popd >/dev/null
diff --git a/.jenkins.d/20-build.sh b/.jenkins.d/20-build.sh
deleted file mode 100755
index 4174800..0000000
--- a/.jenkins.d/20-build.sh
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/usr/bin/env bash
-set -x
-set -e
-
-# Cleanup
-sudo ./waf --color=yes distclean
-
-# Configure/build in optimized mode with tests
-./waf --color=yes configure --debug --with-tests
-./waf --color=yes build
diff --git a/.jenkins.d/20-tests.sh b/.jenkins.d/20-tests.sh
new file mode 100755
index 0000000..c092071
--- /dev/null
+++ b/.jenkins.d/20-tests.sh
@@ -0,0 +1,31 @@
+#!/usr/bin/env bash
+set -ex
+
+# Prepare environment
+rm -rf ~/.ndn
+
+if has OSX $NODE_LABELS; then
+    security unlock-keychain -p named-data
+fi
+
+ndnsec-keygen "/tmp/jenkins/$NODE_NAME" | ndnsec-install-cert -
+
+# https://github.com/google/sanitizers/wiki/AddressSanitizerFlags
+ASAN_OPTIONS="color=always"
+ASAN_OPTIONS+=":check_initialization_order=1"
+ASAN_OPTIONS+=":detect_stack_use_after_return=1"
+ASAN_OPTIONS+=":strict_init_order=1"
+ASAN_OPTIONS+=":strict_string_checks=1"
+ASAN_OPTIONS+=":detect_invalid_pointer_pairs=2"
+ASAN_OPTIONS+=":detect_container_overflow=0"
+ASAN_OPTIONS+=":detect_leaks=0"
+ASAN_OPTIONS+=":strip_path_prefix=${PWD}/"
+export ASAN_OPTIONS
+
+export BOOST_TEST_BUILD_INFO=1
+export BOOST_TEST_COLOR_OUTPUT=1
+export BOOST_TEST_DETECT_MEMORY_LEAK=0
+export BOOST_TEST_LOGGER=HRF,test_suite,stdout:XML,all,build/xunit-log.xml
+
+# Run unit tests
+./build/unit-tests
diff --git a/.jenkins.d/30-tests.sh b/.jenkins.d/30-tests.sh
deleted file mode 100755
index 7e6610e..0000000
--- a/.jenkins.d/30-tests.sh
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/usr/bin/env bash
-set -x
-set -e
-
-# Prepare environment
-sudo rm -Rf ~/.ndn
-
-./build/unit-tests -l test_suite
diff --git a/.jenkins.d/util.sh b/.jenkins.d/util.sh
index 81c8931..8077a74 100644
--- a/.jenkins.d/util.sh
+++ b/.jenkins.d/util.sh
@@ -1,9 +1,39 @@
 has() {
+    local saved_xtrace
+    [[ $- == *x* ]] && saved_xtrace=-x || saved_xtrace=+x
+    set +x
+
     local p=$1
     shift
-    local x
-    for x in "$@"; do
-        [[ "${x}" == "${p}" ]] && return 0
+    local i ret=1
+    for i in "$@"; do
+        if [[ "${i}" == "${p}" ]]; then
+            ret=0
+            break
+        fi
     done
-    return 1
+
+    set ${saved_xtrace}
+    return ${ret}
 }
+export -f has
+
+sudo_preserve_env() {
+    local saved_xtrace
+    [[ $- == *x* ]] && saved_xtrace=-x || saved_xtrace=+x
+    set +x
+
+    local vars=()
+    while [[ $# -gt 0 ]]; do
+        local arg=$1
+        shift
+        case ${arg} in
+            --) break ;;
+            *)  vars+=("${arg}=${!arg}") ;;
+        esac
+    done
+
+    set ${saved_xtrace}
+    sudo env "${vars[@]}" "$@"
+}
+export -f sudo_preserve_env
diff --git a/.waf-tools/boost.py b/.waf-tools/boost.py
new file mode 100644
index 0000000..9feba3a
--- /dev/null
+++ b/.waf-tools/boost.py
@@ -0,0 +1,533 @@
+#!/usr/bin/env python
+# encoding: utf-8
+#
+# partially based on boost.py written by Gernot Vormayr
+# written by Ruediger Sonderfeld <ruediger@c-plusplus.de>, 2008
+# modified by Bjoern Michaelsen, 2008
+# modified by Luca Fossati, 2008
+# rewritten for waf 1.5.1, Thomas Nagy, 2008
+# rewritten for waf 1.6.2, Sylvain Rouquette, 2011
+
+'''
+
+This is an extra tool, not bundled with the default waf binary.
+To add the boost tool to the waf file:
+$ ./waf-light --tools=compat15,boost
+	or, if you have waf >= 1.6.2
+$ ./waf update --files=boost
+
+When using this tool, the wscript will look like:
+
+	def options(opt):
+		opt.load('compiler_cxx boost')
+
+	def configure(conf):
+		conf.load('compiler_cxx boost')
+		conf.check_boost(lib='system filesystem')
+
+	def build(bld):
+		bld(source='main.cpp', target='app', use='BOOST')
+
+Options are generated, in order to specify the location of boost includes/libraries.
+The `check_boost` configuration function allows to specify the used boost libraries.
+It can also provide default arguments to the --boost-mt command-line arguments.
+Everything will be packaged together in a BOOST component that you can use.
+
+When using MSVC, a lot of compilation flags need to match your BOOST build configuration:
+ - you may have to add /EHsc to your CXXFLAGS or define boost::throw_exception if BOOST_NO_EXCEPTIONS is defined.
+   Errors: C4530
+ - boost libraries will try to be smart and use the (pretty but often not useful) auto-linking feature of MSVC
+   So before calling `conf.check_boost` you might want to disabling by adding
+		conf.env.DEFINES_BOOST += ['BOOST_ALL_NO_LIB']
+   Errors:
+ - boost might also be compiled with /MT, which links the runtime statically.
+   If you have problems with redefined symbols,
+		self.env['DEFINES_%s' % var] += ['BOOST_ALL_NO_LIB']
+		self.env['CXXFLAGS_%s' % var] += ['/MD', '/EHsc']
+Passing `--boost-linkage_autodetect` might help ensuring having a correct linkage in some basic cases.
+
+'''
+
+import sys
+import re
+from waflib import Utils, Logs, Errors
+from waflib.Configure import conf
+from waflib.TaskGen import feature, after_method
+
+BOOST_LIBS = ['/usr/lib', '/usr/local/lib', '/opt/local/lib', '/sw/lib', '/lib']
+BOOST_INCLUDES = ['/usr/include', '/usr/local/include', '/opt/local/include', '/sw/include']
+
+BOOST_VERSION_FILE = 'boost/version.hpp'
+BOOST_VERSION_CODE = '''
+#include <iostream>
+#include <boost/version.hpp>
+int main() { std::cout << BOOST_LIB_VERSION << ":" << BOOST_VERSION << std::endl; }
+'''
+
+BOOST_ERROR_CODE = '''
+#include <boost/system/error_code.hpp>
+int main() { boost::system::error_code c; }
+'''
+
+PTHREAD_CODE = '''
+#include <pthread.h>
+static void* f(void*) { return 0; }
+int main() {
+	pthread_t th;
+	pthread_attr_t attr;
+	pthread_attr_init(&attr);
+	pthread_create(&th, &attr, &f, 0);
+	pthread_join(th, 0);
+	pthread_cleanup_push(0, 0);
+	pthread_cleanup_pop(0);
+	pthread_attr_destroy(&attr);
+}
+'''
+
+BOOST_THREAD_CODE = '''
+#include <boost/thread.hpp>
+int main() { boost::thread t; }
+'''
+
+BOOST_LOG_CODE = '''
+#include <boost/log/trivial.hpp>
+int main() { BOOST_LOG_TRIVIAL(info) << "boost_log is working"; }
+'''
+
+BOOST_LOG_SETUP_CODE = '''
+#include <boost/log/trivial.hpp>
+#include <boost/log/utility/setup/console.hpp>
+#include <boost/log/utility/setup/common_attributes.hpp>
+int main() {
+	using namespace boost::log;
+	add_common_attributes();
+	add_console_log(std::clog, keywords::format = "%Message%");
+	BOOST_LOG_TRIVIAL(info) << "boost_log_setup is working";
+}
+'''
+
+# toolsets from {boost_dir}/tools/build/v2/tools/common.jam
+PLATFORM = Utils.unversioned_sys_platform()
+detect_intel = lambda env: (PLATFORM == 'win32') and 'iw' or 'il'
+detect_clang = lambda env: (PLATFORM == 'darwin') and 'clang-darwin' or 'clang'
+detect_mingw = lambda env: (re.search('MinGW', env.CXX[0])) and 'mgw' or 'gcc'
+BOOST_TOOLSETS = {
+	'borland':  'bcb',
+	'clang':	detect_clang,
+	'como':	 'como',
+	'cw':	   'cw',
+	'darwin':   'xgcc',
+	'edg':	  'edg',
+	'g++':	  detect_mingw,
+	'gcc':	  detect_mingw,
+	'icpc':	 detect_intel,
+	'intel':	detect_intel,
+	'kcc':	  'kcc',
+	'kylix':	'bck',
+	'mipspro':  'mp',
+	'mingw':	'mgw',
+	'msvc':	 'vc',
+	'qcc':	  'qcc',
+	'sun':	  'sw',
+	'sunc++':   'sw',
+	'tru64cxx': 'tru',
+	'vacpp':	'xlc'
+}
+
+
+def options(opt):
+	opt = opt.add_option_group('Boost Options')
+	opt.add_option('--boost-includes', type='string',
+				   default='', dest='boost_includes',
+				   help='''path to the directory where the boost includes are,
+				   e.g., /path/to/boost_1_55_0/stage/include''')
+	opt.add_option('--boost-libs', type='string',
+				   default='', dest='boost_libs',
+				   help='''path to the directory where the boost libs are,
+				   e.g., path/to/boost_1_55_0/stage/lib''')
+	opt.add_option('--boost-mt', action='store_true',
+				   default=False, dest='boost_mt',
+				   help='select multi-threaded libraries')
+	opt.add_option('--boost-abi', type='string', default='', dest='boost_abi',
+				   help='''select libraries with tags (gd for debug, static is automatically added),
+				   see doc Boost, Getting Started, chapter 6.1''')
+	opt.add_option('--boost-linkage_autodetect', action='store_true', dest='boost_linkage_autodetect',
+				   help="auto-detect boost linkage options (don't get used to it / might break other stuff)")
+	opt.add_option('--boost-toolset', type='string',
+				   default='', dest='boost_toolset',
+				   help='force a toolset e.g. msvc, vc90, \
+						gcc, mingw, mgw45 (default: auto)')
+	py_version = '%d%d' % (sys.version_info[0], sys.version_info[1])
+	opt.add_option('--boost-python', type='string',
+				   default=py_version, dest='boost_python',
+				   help='select the lib python with this version \
+						(default: %s)' % py_version)
+
+
+@conf
+def __boost_get_version_file(self, d):
+	if not d:
+		return None
+	dnode = self.root.find_dir(d)
+	if dnode:
+		return dnode.find_node(BOOST_VERSION_FILE)
+	return None
+
+@conf
+def boost_get_version(self, d):
+	"""silently retrieve the boost version number"""
+	node = self.__boost_get_version_file(d)
+	if node:
+		try:
+			txt = node.read()
+		except EnvironmentError:
+			Logs.error('Could not read the file %r' % node.abspath())
+		else:
+			re_but1 = re.compile('^#define\\s+BOOST_LIB_VERSION\\s+"(.+)"', re.M)
+			m1 = re_but1.search(txt)
+			re_but2 = re.compile('^#define\\s+BOOST_VERSION\\s+(\\d+)', re.M)
+			m2 = re_but2.search(txt)
+			if m1 and m2:
+				return (m1.group(1), m2.group(1))
+	return self.check_cxx(fragment=BOOST_VERSION_CODE, includes=[d], execute=True, define_ret=True).split(':')
+
+@conf
+def boost_get_includes(self, *k, **kw):
+	includes = k and k[0] or kw.get('includes', None)
+	if includes and self.__boost_get_version_file(includes):
+		return includes
+	for d in self.environ.get('INCLUDE', '').split(';') + BOOST_INCLUDES:
+		if self.__boost_get_version_file(d):
+			return d
+	if includes:
+		self.end_msg('headers not found in %s' % includes, 'YELLOW')
+		self.fatal('The configuration failed')
+	else:
+		self.end_msg('headers not found, please provide a --boost-includes argument (see help)', 'YELLOW')
+		self.fatal('The configuration failed')
+
+
+@conf
+def boost_get_toolset(self, cc):
+	toolset = cc
+	if not cc:
+		build_platform = Utils.unversioned_sys_platform()
+		if build_platform in BOOST_TOOLSETS:
+			cc = build_platform
+		else:
+			cc = self.env.CXX_NAME
+	if cc in BOOST_TOOLSETS:
+		toolset = BOOST_TOOLSETS[cc]
+	return isinstance(toolset, str) and toolset or toolset(self.env)
+
+
+@conf
+def __boost_get_libs_path(self, *k, **kw):
+	''' return the lib path and all the files in it '''
+	if 'files' in kw:
+		return self.root.find_dir('.'), Utils.to_list(kw['files'])
+	libs = k and k[0] or kw.get('libs', None)
+	if libs:
+		path = self.root.find_dir(libs)
+		files = path.ant_glob('*boost_*')
+	if not libs or not files:
+		for d in self.environ.get('LIB', '').split(';') + BOOST_LIBS:
+			if not d:
+				continue
+			path = self.root.find_dir(d)
+			if path:
+				files = path.ant_glob('*boost_*')
+				if files:
+					break
+			path = self.root.find_dir(d + '64')
+			if path:
+				files = path.ant_glob('*boost_*')
+				if files:
+					break
+	if not path:
+		if libs:
+			self.end_msg('libs not found in %s' % libs, 'YELLOW')
+			self.fatal('The configuration failed')
+		else:
+			self.end_msg('libs not found, please provide a --boost-libs argument (see help)', 'YELLOW')
+			self.fatal('The configuration failed')
+
+	self.to_log('Found the boost path in %r with the libraries:' % path)
+	for x in files:
+		self.to_log('    %r' % x)
+	return path, files
+
+@conf
+def boost_get_libs(self, *k, **kw):
+	'''
+	return the lib path and the required libs
+	according to the parameters
+	'''
+	path, files = self.__boost_get_libs_path(**kw)
+	files = sorted(files, key=lambda f: (len(f.name), f.name), reverse=True)
+	toolset = self.boost_get_toolset(kw.get('toolset', ''))
+	toolset_pat = '(-%s[0-9]{0,3})' % toolset
+	version = '-%s' % self.env.BOOST_VERSION
+
+	def find_lib(re_lib, files):
+		for file in files:
+			if re_lib.search(file.name):
+				self.to_log('Found boost lib %s' % file)
+				return file
+		return None
+
+	def format_lib_name(name):
+		if name.startswith('lib') and self.env.CC_NAME != 'msvc':
+			name = name[3:]
+		return name[:name.rfind('.')]
+
+	def match_libs(lib_names, is_static):
+		libs = []
+		lib_names = Utils.to_list(lib_names)
+		if not lib_names:
+			return libs
+		t = []
+		if kw.get('mt', False):
+			t.append('-mt')
+		if kw.get('abi', None):
+			t.append('%s%s' % (is_static and '-s' or '-', kw['abi']))
+		elif is_static:
+			t.append('-s')
+		tags_pat = t and ''.join(t) or ''
+		ext = is_static and self.env.cxxstlib_PATTERN or self.env.cxxshlib_PATTERN
+		ext = ext.partition('%s')[2] # remove '%s' or 'lib%s' from PATTERN
+
+		for lib in lib_names:
+			if lib == 'python':
+				# for instance, with python='27',
+				# accepts '-py27', '-py2', '27' and '2'
+				# but will reject '-py3', '-py26', '26' and '3'
+				tags = '({0})?((-py{2})|(-py{1}(?=[^0-9]))|({2})|({1}(?=[^0-9]))|(?=[^0-9])(?!-py))'.format(tags_pat, kw['python'][0], kw['python'])
+			else:
+				tags = tags_pat
+			# Trying libraries, from most strict match to least one
+			for pattern in ['boost_%s%s%s%s%s$' % (lib, toolset_pat, tags, version, ext),
+							'boost_%s%s%s%s$' % (lib, tags, version, ext),
+							# Give up trying to find the right version
+							'boost_%s%s%s%s$' % (lib, toolset_pat, tags, ext),
+							'boost_%s%s%s$' % (lib, tags, ext),
+							'boost_%s%s$' % (lib, ext),
+							'boost_%s' % lib]:
+				self.to_log('Trying pattern %s' % pattern)
+				file = find_lib(re.compile(pattern), files)
+				if file:
+					libs.append(format_lib_name(file.name))
+					break
+			else:
+				self.end_msg('lib %s not found in %s' % (lib, path.abspath()), 'YELLOW')
+				self.fatal('The configuration failed')
+		return libs
+
+	return  path.abspath(), match_libs(kw.get('lib', None), False), match_libs(kw.get('stlib', None), True)
+
+@conf
+def _check_pthread_flag(self, *k, **kw):
+	'''
+	Computes which flags should be added to CXXFLAGS and LINKFLAGS to compile in multi-threading mode
+
+	Yes, we *need* to put the -pthread thing in CPPFLAGS because with GCC3,
+	boost/thread.hpp will trigger a #error if -pthread isn't used:
+	  boost/config/requires_threads.hpp:47:5: #error "Compiler threading support
+	  is not turned on. Please set the correct command line options for
+	  threading: -pthread (Linux), -pthreads (Solaris) or -mthreads (Mingw32)"
+
+	Based on _BOOST_PTHREAD_FLAG(): https://github.com/tsuna/boost.m4/blob/master/build-aux/boost.m4
+    '''
+
+	var = kw.get('uselib_store', 'BOOST')
+
+	self.start_msg('Checking the flags needed to use pthreads')
+
+	# The ordering *is* (sometimes) important.  Some notes on the
+	# individual items follow:
+	# (none): in case threads are in libc; should be tried before -Kthread and
+	#       other compiler flags to prevent continual compiler warnings
+	# -lpthreads: AIX (must check this before -lpthread)
+	# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
+	# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
+	# -llthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
+	# -pthread: GNU Linux/GCC (kernel threads), BSD/GCC (userland threads)
+	# -pthreads: Solaris/GCC
+	# -mthreads: MinGW32/GCC, Lynx/GCC
+	# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
+	#      doesn't hurt to check since this sometimes defines pthreads too;
+	#      also defines -D_REENTRANT)
+	#      ... -mt is also the pthreads flag for HP/aCC
+	# -lpthread: GNU Linux, etc.
+	# --thread-safe: KAI C++
+	if Utils.unversioned_sys_platform() == 'sunos':
+		# On Solaris (at least, for some versions), libc contains stubbed
+		# (non-functional) versions of the pthreads routines, so link-based
+		# tests will erroneously succeed.  (We need to link with -pthreads/-mt/
+		# -lpthread.)  (The stubs are missing pthread_cleanup_push, or rather
+		# a function called by this macro, so we could check for that, but
+		# who knows whether they'll stub that too in a future libc.)  So,
+		# we'll just look for -pthreads and -lpthread first:
+		boost_pthread_flags = ['-pthreads', '-lpthread', '-mt', '-pthread']
+	else:
+		boost_pthread_flags = ['', '-lpthreads', '-Kthread', '-kthread', '-llthread', '-pthread',
+							   '-pthreads', '-mthreads', '-lpthread', '--thread-safe', '-mt']
+
+	for boost_pthread_flag in boost_pthread_flags:
+		try:
+			self.env.stash()
+			self.env['CXXFLAGS_%s' % var] += [boost_pthread_flag]
+			self.env['LINKFLAGS_%s' % var] += [boost_pthread_flag]
+			self.check_cxx(code=PTHREAD_CODE, msg=None, use=var, execute=False, quiet=True)
+			self.end_msg(boost_pthread_flag)
+			return
+		except self.errors.ConfigurationError:
+			self.env.revert()
+	self.end_msg('none')
+
+@conf
+def check_boost(self, *k, **kw):
+	"""
+	Initialize boost libraries to be used.
+
+	Keywords: you can pass the same parameters as with the command line (without "--boost-").
+	Note that the command line has the priority, and should preferably be used.
+	"""
+	if not self.env['CXX']:
+		self.fatal('load a c++ compiler first, conf.load("compiler_cxx")')
+
+	params = {
+		'lib': k and k[0] or kw.get('lib', None),
+		'stlib': kw.get('stlib', None)
+	}
+	for key, value in self.options.__dict__.items():
+		if not key.startswith('boost_'):
+			continue
+		key = key[len('boost_'):]
+		params[key] = value and value or kw.get(key, '')
+
+	var = kw.get('uselib_store', 'BOOST')
+
+	if not self.env.DONE_FIND_BOOST_COMMON:
+		self.find_program('dpkg-architecture', var='DPKG_ARCHITECTURE', mandatory=False)
+		if self.env.DPKG_ARCHITECTURE:
+			deb_host_multiarch = self.cmd_and_log([self.env.DPKG_ARCHITECTURE[0], '-qDEB_HOST_MULTIARCH'])
+			BOOST_LIBS.insert(0, '/usr/lib/%s' % deb_host_multiarch.strip())
+
+		self.start_msg('Checking boost includes')
+		self.env['INCLUDES_%s' % var] = inc = self.boost_get_includes(**params)
+		versions = self.boost_get_version(inc)
+		self.env.BOOST_VERSION = versions[0]
+		self.env.BOOST_VERSION_NUMBER = int(versions[1])
+		self.end_msg('%d.%d.%d' % (int(versions[1]) / 100000,
+								   int(versions[1]) / 100 % 1000,
+								   int(versions[1]) % 100))
+		if Logs.verbose:
+			Logs.pprint('CYAN', '	path : %s' % self.env['INCLUDES_%s' % var])
+
+		self.env.DONE_FIND_BOOST_COMMON = True
+
+	if not params['lib'] and not params['stlib']:
+		return
+	if 'static' in kw or 'static' in params:
+		Logs.warn('boost: static parameter is deprecated, use stlib instead.')
+	self.start_msg('Checking boost libs')
+	path, libs, stlibs = self.boost_get_libs(**params)
+	self.env['LIBPATH_%s' % var] = [path]
+	self.env['STLIBPATH_%s' % var] = [path]
+	self.env['LIB_%s' % var] = libs
+	self.env['STLIB_%s' % var] = stlibs
+	self.end_msg(' '.join(libs + stlibs))
+	if Logs.verbose:
+		Logs.pprint('CYAN', '	path : %s' % path)
+		Logs.pprint('CYAN', '	shared libs : %s' % libs)
+		Logs.pprint('CYAN', '	static libs : %s' % stlibs)
+
+	def has_shlib(lib):
+		return params['lib'] and lib in params['lib']
+	def has_stlib(lib):
+		return params['stlib'] and lib in params['stlib']
+	def has_lib(lib):
+		return has_shlib(lib) or has_stlib(lib)
+	if has_lib('thread'):
+		# not inside try_link to make check visible in the output
+		self._check_pthread_flag(k, kw)
+
+	def try_link():
+		if has_lib('system'):
+			self.check_cxx(fragment=BOOST_ERROR_CODE, use=var, execute=False)
+		if has_lib('thread'):
+			self.check_cxx(fragment=BOOST_THREAD_CODE, use=var, execute=False)
+		if has_lib('log') or has_lib('log_setup'):
+			if not has_lib('thread'):
+				self.env['DEFINES_%s' % var] += ['BOOST_LOG_NO_THREADS']
+			if has_shlib('log') or has_shlib('log_setup'):
+				self.env['DEFINES_%s' % var] += ['BOOST_LOG_DYN_LINK']
+			if has_lib('log_setup'):
+				self.check_cxx(fragment=BOOST_LOG_SETUP_CODE, use=var, execute=False)
+			else:
+				self.check_cxx(fragment=BOOST_LOG_CODE, use=var, execute=False)
+
+	if params.get('linkage_autodetect', False):
+		self.start_msg('Attempting to detect boost linkage flags')
+		toolset = self.boost_get_toolset(kw.get('toolset', ''))
+		if toolset in ('vc',):
+			# disable auto-linking feature, causing error LNK1181
+			# because the code wants to be linked against
+			self.env['DEFINES_%s' % var] += ['BOOST_ALL_NO_LIB']
+
+			# if no dlls are present, we guess the .lib files are not stubs
+			has_dlls = False
+			for x in Utils.listdir(path):
+				if x.endswith(self.env.cxxshlib_PATTERN % ''):
+					has_dlls = True
+					break
+			if not has_dlls:
+				self.env['STLIBPATH_%s' % var] = [path]
+				self.env['STLIB_%s' % var] = libs
+				del self.env['LIB_%s' % var]
+				del self.env['LIBPATH_%s' % var]
+
+			# we attempt to play with some known-to-work CXXFLAGS combinations
+			for cxxflags in (['/MD', '/EHsc'], []):
+				self.env.stash()
+				self.env['CXXFLAGS_%s' % var] += cxxflags
+				try:
+					try_link()
+					self.end_msg('ok: winning cxxflags combination: %s' % (self.env['CXXFLAGS_%s' % var]))
+					exc = None
+					break
+				except Errors.ConfigurationError as e:
+					self.env.revert()
+					exc = e
+
+			if exc is not None:
+				self.end_msg('Could not auto-detect boost linking flags combination, you may report it to boost.py author', ex=exc)
+				self.fatal('The configuration failed')
+		else:
+			self.end_msg('Boost linkage flags auto-detection not implemented (needed ?) for this toolchain')
+			self.fatal('The configuration failed')
+	else:
+		self.start_msg('Checking for boost linkage')
+		try:
+			try_link()
+		except Errors.ConfigurationError as e:
+			self.end_msg('Could not link against boost libraries using supplied options', 'YELLOW')
+			self.fatal('The configuration failed')
+		self.end_msg('ok')
+
+
+@feature('cxx')
+@after_method('apply_link')
+def install_boost(self):
+	if install_boost.done or not Utils.is_win32 or not self.bld.cmd.startswith('install'):
+		return
+	install_boost.done = True
+	inst_to = getattr(self, 'install_path', '${BINDIR}')
+	for lib in self.env.LIB_BOOST:
+		try:
+			file = self.bld.find_file(self.env.cxxshlib_PATTERN % lib, self.env.LIBPATH_BOOST)
+			self.bld.install_files(inst_to, self.bld.root.find_node(file))
+		except:
+			continue
+install_boost.done = False
\ No newline at end of file
diff --git a/waf-tools/cryptopp.py b/.waf-tools/cryptopp.py
similarity index 100%
rename from waf-tools/cryptopp.py
rename to .waf-tools/cryptopp.py
diff --git a/.waf-tools/default-compiler-flags.py b/.waf-tools/default-compiler-flags.py
new file mode 100644
index 0000000..7a317b1
--- /dev/null
+++ b/.waf-tools/default-compiler-flags.py
@@ -0,0 +1,228 @@
+# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
+
+import platform
+from waflib import Configure, Logs, Utils
+
+def options(opt):
+    opt.add_option('--debug', '--with-debug', action='store_true', default=False,
+                   help='Compile in debugging mode with minimal optimizations (-Og)')
+
+def configure(conf):
+    conf.start_msg('Checking C++ compiler version')
+
+    cxx = conf.env.CXX_NAME # generic name of the compiler
+    ccver = tuple(int(i) for i in conf.env.CC_VERSION)
+    ccverstr = '.'.join(conf.env.CC_VERSION)
+    errmsg = ''
+    warnmsg = ''
+    if cxx == 'gcc':
+        if ccver < (5, 3, 0):
+            errmsg = ('The version of gcc you are using is too old.\n'
+                      'The minimum supported gcc version is 7.4.0.')
+        elif ccver < (7, 4, 0):
+            warnmsg = ('Using a version of gcc older than 7.4.0 is not '
+                       'officially supported and may result in build failures.')
+        conf.flags = GccFlags()
+    elif cxx == 'clang':
+        if Utils.unversioned_sys_platform() == 'darwin' and ccver < (9, 0, 0):
+            errmsg = ('The version of Xcode you are using is too old.\n'
+                      'The minimum supported Xcode version is 9.0.')
+        elif ccver < (4, 0, 0):
+            errmsg = ('The version of clang you are using is too old.\n'
+                      'The minimum supported clang version is 4.0.')
+        conf.flags = ClangFlags()
+    else:
+        warnmsg = '%s compiler is unsupported' % cxx
+        conf.flags = CompilerFlags()
+
+    if errmsg:
+        conf.end_msg(ccverstr, color='RED')
+        conf.fatal(errmsg)
+    elif warnmsg:
+        conf.end_msg(ccverstr, color='YELLOW')
+        Logs.warn('WARNING: ' + warnmsg)
+    else:
+        conf.end_msg(ccverstr)
+
+    conf.areCustomCxxflagsPresent = (len(conf.env.CXXFLAGS) > 0)
+
+    # General flags are always applied (e.g., selecting C++ language standard)
+    generalFlags = conf.flags.getGeneralFlags(conf)
+    conf.add_supported_cxxflags(generalFlags['CXXFLAGS'])
+    conf.add_supported_linkflags(generalFlags['LINKFLAGS'])
+    conf.env.DEFINES += generalFlags['DEFINES']
+
+@Configure.conf
+def check_compiler_flags(conf):
+    # Debug or optimized CXXFLAGS and LINKFLAGS are applied only if the
+    # corresponding environment variables are not set.
+    # DEFINES are always applied.
+    if conf.options.debug:
+        extraFlags = conf.flags.getDebugFlags(conf)
+        if conf.areCustomCxxflagsPresent:
+            missingFlags = [x for x in extraFlags['CXXFLAGS'] if x not in conf.env.CXXFLAGS]
+            if missingFlags:
+                Logs.warn('Selected debug mode, but CXXFLAGS is set to a custom value "%s"'
+                          % ' '.join(conf.env.CXXFLAGS))
+                Logs.warn('Default flags "%s" will not be used' % ' '.join(missingFlags))
+    else:
+        extraFlags = conf.flags.getOptimizedFlags(conf)
+
+    if not conf.areCustomCxxflagsPresent:
+        conf.add_supported_cxxflags(extraFlags['CXXFLAGS'])
+        conf.add_supported_linkflags(extraFlags['LINKFLAGS'])
+
+    conf.env.DEFINES += extraFlags['DEFINES']
+
+@Configure.conf
+def add_supported_cxxflags(self, cxxflags):
+    """
+    Check which cxxflags are supported by compiler and add them to env.CXXFLAGS variable
+    """
+    if len(cxxflags) == 0:
+        return
+
+    self.start_msg('Checking supported CXXFLAGS')
+
+    supportedFlags = []
+    for flags in cxxflags:
+        flags = Utils.to_list(flags)
+        if self.check_cxx(cxxflags=['-Werror'] + flags, mandatory=False):
+            supportedFlags += flags
+
+    self.end_msg(' '.join(supportedFlags))
+    self.env.prepend_value('CXXFLAGS', supportedFlags)
+
+@Configure.conf
+def add_supported_linkflags(self, linkflags):
+    """
+    Check which linkflags are supported by compiler and add them to env.LINKFLAGS variable
+    """
+    if len(linkflags) == 0:
+        return
+
+    self.start_msg('Checking supported LINKFLAGS')
+
+    supportedFlags = []
+    for flags in linkflags:
+        flags = Utils.to_list(flags)
+        if self.check_cxx(linkflags=['-Werror'] + flags, mandatory=False):
+            supportedFlags += flags
+
+    self.end_msg(' '.join(supportedFlags))
+    self.env.prepend_value('LINKFLAGS', supportedFlags)
+
+
+class CompilerFlags(object):
+    def getCompilerVersion(self, conf):
+        return tuple(int(i) for i in conf.env.CC_VERSION)
+
+    def getGeneralFlags(self, conf):
+        """Get dict of CXXFLAGS, LINKFLAGS, and DEFINES that are always needed"""
+        return {'CXXFLAGS': [], 'LINKFLAGS': [], 'DEFINES': []}
+
+    def getDebugFlags(self, conf):
+        """Get dict of CXXFLAGS, LINKFLAGS, and DEFINES that are needed only in debug mode"""
+        return {'CXXFLAGS': [], 'LINKFLAGS': [], 'DEFINES': ['_DEBUG']}
+
+    def getOptimizedFlags(self, conf):
+        """Get dict of CXXFLAGS, LINKFLAGS, and DEFINES that are needed only in optimized mode"""
+        return {'CXXFLAGS': [], 'LINKFLAGS': [], 'DEFINES': ['NDEBUG']}
+
+class GccBasicFlags(CompilerFlags):
+    """
+    This class defines basic flags that work for both gcc and clang compilers
+    """
+    def getGeneralFlags(self, conf):
+        flags = super(GccBasicFlags, self).getGeneralFlags(conf)
+        flags['CXXFLAGS'] += ['-std=c++14']
+        if Utils.unversioned_sys_platform() == 'linux':
+            flags['LINKFLAGS'] += ['-fuse-ld=gold']
+        elif Utils.unversioned_sys_platform() == 'freebsd':
+            flags['LINKFLAGS'] += ['-fuse-ld=lld']
+        return flags
+
+    def getDebugFlags(self, conf):
+        flags = super(GccBasicFlags, self).getDebugFlags(conf)
+        flags['CXXFLAGS'] += ['-Og',
+                              '-g3',
+                              '-pedantic',
+                              '-Wall',
+                              '-Wextra',
+                              '-Werror',
+                              '-Wcatch-value=2',
+                              # '-Wextra-semi', # prevent noisy output with Qt5
+                              '-Wnon-virtual-dtor',
+                              '-Wno-error=deprecated-declarations', # Bug #3795
+                              '-Wno-error=maybe-uninitialized', # Bug #1615
+                              '-Wno-unused-parameter',
+                              '-Wno-error=deprecated-copy', # Qt5
+                              ]
+        flags['LINKFLAGS'] += ['-Wl,-O1']
+        return flags
+
+    def getOptimizedFlags(self, conf):
+        flags = super(GccBasicFlags, self).getOptimizedFlags(conf)
+        flags['CXXFLAGS'] += ['-O2',
+                              '-g',
+                              '-pedantic',
+                              '-Wall',
+                              '-Wextra',
+                              '-Wcatch-value=2',
+                              '-Wextra-semi',
+                              '-Wnon-virtual-dtor',
+                              '-Wno-unused-parameter',
+                              ]
+        flags['LINKFLAGS'] += ['-Wl,-O1']
+        return flags
+
+class GccFlags(GccBasicFlags):
+    def getDebugFlags(self, conf):
+        flags = super(GccFlags, self).getDebugFlags(conf)
+        flags['CXXFLAGS'] += ['-fdiagnostics-color',
+                              '-Wredundant-tags',
+                              ]
+        if platform.machine() == 'armv7l' and self.getCompilerVersion(conf) >= (7, 1, 0):
+            flags['CXXFLAGS'] += ['-Wno-psabi'] # Bug #5106
+        return flags
+
+    def getOptimizedFlags(self, conf):
+        flags = super(GccFlags, self).getOptimizedFlags(conf)
+        flags['CXXFLAGS'] += ['-fdiagnostics-color',
+                              '-Wredundant-tags',
+                              ]
+        if platform.machine() == 'armv7l' and self.getCompilerVersion(conf) >= (7, 1, 0):
+            flags['CXXFLAGS'] += ['-Wno-psabi'] # Bug #5106
+        return flags
+
+class ClangFlags(GccBasicFlags):
+    def getGeneralFlags(self, conf):
+        flags = super(ClangFlags, self).getGeneralFlags(conf)
+        if Utils.unversioned_sys_platform() == 'darwin':
+            # Bug #4296
+            flags['CXXFLAGS'] += [['-isystem', '/usr/local/include'], # for Homebrew
+                                  ['-isystem', '/opt/local/include']] # for MacPorts
+        elif Utils.unversioned_sys_platform() == 'freebsd':
+            # Bug #4790
+            flags['CXXFLAGS'] += [['-isystem', '/usr/local/include']]
+        return flags
+
+    def getDebugFlags(self, conf):
+        flags = super(ClangFlags, self).getDebugFlags(conf)
+        flags['CXXFLAGS'] += ['-fcolor-diagnostics',
+                              '-Wundefined-func-template',
+                              '-Wno-unused-local-typedef', # Bugs #2657 and #3209
+                              ]
+        if self.getCompilerVersion(conf) < (6, 0, 0):
+            flags['CXXFLAGS'] += ['-Wno-missing-braces'] # Bug #4721
+        return flags
+
+    def getOptimizedFlags(self, conf):
+        flags = super(ClangFlags, self).getOptimizedFlags(conf)
+        flags['CXXFLAGS'] += ['-fcolor-diagnostics',
+                              '-Wundefined-func-template',
+                              '-Wno-unused-local-typedef', # Bugs #2657 and #3209
+                              ]
+        if self.getCompilerVersion(conf) < (6, 0, 0):
+            flags['CXXFLAGS'] += ['-Wno-missing-braces'] # Bug #4721
+        return flags
\ No newline at end of file
diff --git a/waf-tools/doxygen.py b/.waf-tools/doxygen.py
similarity index 98%
rename from waf-tools/doxygen.py
rename to .waf-tools/doxygen.py
index ac8c70b..85e0828 100644
--- a/waf-tools/doxygen.py
+++ b/.waf-tools/doxygen.py
@@ -85,7 +85,7 @@
 
 			# Override with any parameters passed to the task generator
 			if getattr(self.generator, 'pars', None):
-				for k, v in self.generator.pars.iteritems():
+				for k, v in self.generator.pars.items():
 					self.pars[k] = v
 
 			self.doxy_inputs = getattr(self, 'doxy_inputs', [])
@@ -211,4 +211,4 @@
 from waflib.Build import BuildContext
 class doxy(BuildContext):
     cmd = "doxygen"
-    fun = "doxygen"
+    fun = "doxygen"
\ No newline at end of file
diff --git a/waf-tools/qt5.py b/.waf-tools/qt5_custom.py
similarity index 98%
rename from waf-tools/qt5.py
rename to .waf-tools/qt5_custom.py
index 23ff0b8..47d0d4c 100644
--- a/waf-tools/qt5.py
+++ b/.waf-tools/qt5_custom.py
@@ -500,7 +500,7 @@
 	# Qt5 may be compiled with '-reduce-relocations' which requires dependent programs to have -fPIE or -fPIC?
 	frag = '#include <QMap>\nint main(int argc, char **argv) {QMap<int,int> m;return m.keys().size();}\n'
 	uses = 'QT5CORE'
-	for flag in [[], '-fPIE', '-fPIC', '-std=c++11' , ['-std=c++11', '-fPIE'], ['-std=c++11', '-fPIC']]:
+	for flag in [[], '-fPIE', '-fPIC', '-std=c++14' , ['-std=c++14', '-fPIE'], ['-std=c++14', '-fPIC']]:
 		msg = 'See if Qt files compile '
 		if flag:
 			msg += 'with %s' % flag
diff --git a/waf-tools/sphinx_build.py b/.waf-tools/sphinx_build.py
similarity index 82%
rename from waf-tools/sphinx_build.py
rename to .waf-tools/sphinx_build.py
index e61da6e..b44a54f 100644
--- a/waf-tools/sphinx_build.py
+++ b/.waf-tools/sphinx_build.py
@@ -44,28 +44,28 @@
     task.inputs.append(conf)
 
     confdir = conf.parent.abspath()
-    buildername = getattr(self, "builder", "html")
-    srcdir = getattr(self, "srcdir", confdir)
-    outdir = self.path.find_or_declare(getattr(self, "outdir", buildername)).get_bld()
-    doctreedir = getattr(self, "doctreedir", os.path.join(outdir.abspath(), ".doctrees"))
+    buildername = getattr(self, 'builder', 'html')
+    srcdir = getattr(self, 'srcdir', confdir)
+    outdir = self.path.find_or_declare(getattr(self, 'outdir', buildername)).get_bld()
+    doctreedir = getattr(self, 'doctreedir', os.path.join(outdir.abspath(), '.doctrees'))
 
     task.env['BUILDERNAME'] = buildername
     task.env['SRCDIR'] = srcdir
     task.env['DOCTREEDIR'] = doctreedir
     task.env['OUTDIR'] = outdir.abspath()
-    task.env['VERSION'] = "version=%s" % self.VERSION
-    task.env['RELEASE'] = "release=%s" % self.VERSION
+    task.env['VERSION'] = 'version=%s' % self.version
+    task.env['RELEASE'] = 'release=%s' % getattr(self, 'release', self.version)
 
     import imp
     confData = imp.load_source('sphinx_conf', conf.abspath())
 
-    if buildername == "man":
+    if buildername == 'man':
         for i in confData.man_pages:
             target = outdir.find_or_declare('%s.%d' % (i[1], i[4]))
             task.outputs.append(target)
 
             if self.install_path:
-                self.bld.install_files("%s/man%d/" % (self.install_path, i[4]), target)
+                self.bld.install_files('%s/man%d/' % (self.install_path, i[4]), target)
     else:
         task.outputs.append(outdir)
 
diff --git a/ChronoSync b/ChronoSync
deleted file mode 160000
index 5f408ae..0000000
--- a/ChronoSync
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 5f408ae7f52f2fb792c65db733c80c6d4d5ecf48
diff --git a/README.md b/README.md
index c0a2bb7..3737987 100644
--- a/README.md
+++ b/README.md
@@ -6,81 +6,25 @@
 Note that after you click to close ChronoChat, it will keep running on your system tray. To restore it to normal size window, you have to click on the system tray icon (normally on the upper right corner of your screen). Clicking on the dock won't work for now and is still on the to-do list (because I'm using qt for gui, not the native Cocoa framework).
 
 ## Known Issues
----------------
 
 1. When you switch to a new room, you'll temporarily see yourself in two nodes for a minute or so. It won't affect others, just yourself. Hopefully it's not so disturbing.
 2. Sometimes you may not get the most up-to-date chat history.
 
-## For those who want (or is forced to) compile from source code
------------------------------------------------------------------
+## Compilation steps
 
-### Compilation steps for OSX
+1. On Ubuntu, configure [NDN PPA repository](http://named-data.net/doc/NFD/current/FAQ.html#how-to-start-using-ndn-ppa-repository-on-ubuntu-linux) and install NFD and ChronoSYnc if you don't have it yet, then install dependencies
 
-1. Install MacPorts, if not yet installed (http://www.macports.org/), configure [NDN ports repository](http://named-data.net/doc/NFD/current/FAQ.html#how-to-start-using-ndn-macports-repository-on-osx) and install NFD if you don't have it yet.
+        sudo apt-get install nfd libndn-cxx-dev libchronosync-dev
+        sudo apt-get install libcrypto++-dev libboost-all-dev qt5-default
 
-        sudo port install nfd
-        sudo nfd-start
+2. Fetch source code
 
-2. Install ChronoChat dependencies
+        git clone https://github.com/named-data/ChronoChat
 
-        sudo port install pkgconfig protobuf-cpp boost qt4-mac
+3. Configure and build ChronoChat
 
-3. Fetch source code with submodules
-
-        git clone --recursive git://github.com/named-data/ChronoChat
-
-If you already cloned repository, you can update submodules this way:
-
-        git submodule update --init
-
-4. Configure and install ChronoSync
-
-        cd ChronoChat/ChronoSync
-        ./waf configure
-        ./waf
-        sudo ./waf install
-
-5. Configure and build ChronoChat
-
-        cd ..
-        PKG_CONFIG_PATH=/opt/local/lib/pkgconfig:/usr/local/lib/pkgconfig:/usr/lib/pkgconfig ./waf configure
-        ./waf
-
-Congratulations! build/ChronoChat.app is ready to use (on a Mac).
-
-### Compilation steps for Ubuntu 18.04, 20.04
-
-1. Configure [NDN PPA repository](http://named-data.net/doc/NFD/current/FAQ.html#how-to-start-using-ndn-ppa-repository-on-ubuntu-linux) and install NFD if you don't have it yet.
-
-        sudo apt-get install nfd
-
-2. Install ChronoChat dependencies
-
-        sudo apt-get install libprotobuf-dev protobuf-compiler libevent-dev libcrypto++-dev
-        sudo apt-get install libboost-all-dev
-        sudo apt-get install qt5-default
-
-3. Fetch source code with submodules
-
-        git clone --recursive git://github.com/named-data/ChronoChat
-
-If you already cloned repository, you can update submodules this way:
-
-	    git submodule update --init
-
-4. Configure and install ChronoSync
-
-        cd ChronoChat/ChronoSync
-        ./waf configure
-        ./waf
-        sudo ./waf install
-        sudo ldconfig
-
-5. Configure and build ChronoChat
-
-        cd ..
         ./waf configure
         ./waf
 
-Congratulations! build/ChronoChat is ready to use.  Do not forget to start NFD and configure FIB before using ChronoChat.
+Congratulations! `build/ChronoChat` is ready to use.  Do not forget to start NFD and configure FIB before using ChronoChat.
 For ease of debugging, you can generate trusted identities in your local TPM using `debug-tools/create-cert`.
diff --git a/debug-tools/create-cert.cc b/debug-tools/create-cert.cpp
similarity index 93%
rename from debug-tools/create-cert.cc
rename to debug-tools/create-cert.cpp
index 5941783..09399b1 100644
--- a/debug-tools/create-cert.cc
+++ b/debug-tools/create-cert.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /**
- * Copyright (C) 2013 Regents of the University of California.
+ * Copyright (C) 2020 Regents of the University of California.
  * @author: Yingdi Yu <yingdi@cs.ucla.edu>
  * See COPYING for copyright and distribution information.
  */
@@ -19,7 +19,7 @@
 generateCertificate(KeyChain& keyChain, Name name) {
   try {
     keyChain.getPib().getIdentity(name);
-  } catch (ndn::security::pib::Pib::Error&) {
+  } catch (const ndn::security::pib::Pib::Error&) {
     Identity id = keyChain.createIdentity(name);
     Key key = id.getDefaultKey();
     Certificate cert = Certificate(key.getDefaultCertificate());
diff --git a/disabled/send-invitation-request-dialog.cpp b/disabled/send-invitation-request-dialog.cpp
deleted file mode 100644
index 8cc0640..0000000
--- a/disabled/send-invitation-request-dialog.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-#include "send-invitation-request-dialog.hpp"
-#include "ui_send-invitation-request-dialog.h"
-
-using namespace chronos;
-
-SendInvitationRequestDialog::SendInvitationRequestDialog(QWidget *parent) :
-  QDialog(parent),
-  ui(new Ui::SendInvitationRequestDialog),
-  m_stringListModel(new QStringListModel)
-{
-  ui->setupUi(this);
-  ui->contactsListView->setEditTriggers(ui->contactsListView->NoEditTriggers);
-  ui->contactsListView->setModel(m_stringListModel);
-
-  connect(ui->sendButton, SIGNAL(clicked()),
-          this, SLOT(onSendButtonClicked()));
-  connect(ui->cancelButton, SIGNAL(clicked()),
-          this, SLOT(onCancelButtonClicked()));
-  connect(ui->contactsListView, SIGNAL(clicked(QModelIndex)),
-          this, SLOT(onContactListViewClicked(QModelIndex)));
-  connect(ui->contactsListView,SIGNAL(doubleClicked(QModelIndex)),
-          this, SLOT(onContactListViewDoubleClicked(QModelIndex)));
-}
-
-SendInvitationRequestDialog::~SendInvitationRequestDialog()
-{
-  delete ui;
-}
-
-void
-SendInvitationRequestDialog::setContacts(const std::vector<ndn::Name>& contacts)
-{
-  QStringList contactsList;
-  for(int i = 0; i < contacts.size(); i++){
-    contactsList.append(QString::fromStdString(contacts[i].toUri()));
-  }
-  m_stringListModel->setStringList(contactsList);
-}
-
-void
-SendInvitationRequestDialog::onSendButtonClicked()
-{
-  if(ui->contactsListView->selectionModel()->selectedRows().size() == 0){
-    QMessageBox messageBox;
-    messageBox.addButton(QMessageBox::Ok);
-    messageBox.setIcon(QMessageBox::Information);
-    messageBox.setText("Please select a contact to send invitation request");
-    messageBox.exec();
-  }
-  else{
-    //send invitation request
-    int selectedRow = ui->contactsListView->selectionModel()->selectedRows()[0].row();
-    QString contactName = m_stringListModel->stringList()[selectedRow];
-    qDebug() << contactName;
-
-    QMessageBox messageBox;
-    messageBox.addButton(QMessageBox::Yes);
-    messageBox.addButton(QMessageBox::No);
-    messageBox.setIcon(QMessageBox::Question);
-    messageBox.setText("Send invitation request to "+ contactName +"?");
-
-    int selection = messageBox.exec();
-
-    if(selection == QMessageBox::Yes){
-      //send invitation request
-      //need to have another message box when successfully send
-      //emit sendInvitationRequest(m_chatroomName, contactName);
-    }
-  }
-}
-
-
-void
-SendInvitationRequestDialog::onCancelButtonClicked()
-{
-  //qDebug() << "cancel";
-  this->close();
-}
-
-void
-SendInvitationRequestDialog::onContactListViewClicked(QModelIndex modelIndex)
-{}
-
-void
-SendInvitationRequestDialog::onContactListViewDoubleClicked(QModelIndex modelIndex)
-{
-  onSendButtonClicked();
-}
-
-void
-SendInvitationRequestDialog::setChatroomName(const QString chatroomName)
-{
-  m_chatroomName = chatroomName;
-}
-
-
-#if WAF
-#include "send-invitation-request-dialog.moc"
-#endif
diff --git a/disabled/send-invitation-request-dialog.hpp b/disabled/send-invitation-request-dialog.hpp
deleted file mode 100644
index ea86676..0000000
--- a/disabled/send-invitation-request-dialog.hpp
+++ /dev/null
@@ -1,55 +0,0 @@
-#ifndef SENDINVITATIONREQUESTDIALOG_H
-#define SENDINVITATIONREQUESTDIALOG_H
-
-#include <QDialog>
-#include <QStringListModel>
-#include <QMessageBox>
-#include <QDebug>
-#include <QAbstractItemView>
-
-#ifndef Q_MOC_RUN
-#include "chatroom-discovery.hpp"
-#endif
-
-namespace Ui {
-class SendInvitationRequestDialog;
-}
-
-namespace chronos {
-
-class SendInvitationRequestDialog : public QDialog
-{
-  Q_OBJECT
-
-public:
-  explicit SendInvitationRequestDialog(QWidget *parent = 0);
-  ~SendInvitationRequestDialog();
-
-  void
-  setContacts(const std::vector<ndn::Name>& contacts);
-
-  void
-  setChatroomName(const QString chatroomName);
-
-public slots:
-  void
-  onSendButtonClicked();
-
-  void
-  onCancelButtonClicked();
-
-  void
-  onContactListViewClicked(QModelIndex modelIndex);
-
-  void
-  onContactListViewDoubleClicked(QModelIndex modelIndex);
-
-private:
-  Ui::SendInvitationRequestDialog *ui;
-  QString m_chatroomName;
-  QStringListModel *m_stringListModel;
-};
-
-} //namespace chronos
-
-#endif // SENDINVITATIONREQUESTDIALOG_H
diff --git a/disabled/send-invitation-request-dialog.ui b/disabled/send-invitation-request-dialog.ui
deleted file mode 100644
index 1108478..0000000
--- a/disabled/send-invitation-request-dialog.ui
+++ /dev/null
@@ -1,68 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>SendInvitationRequestDialog</class>
- <widget class="QDialog" name="SendInvitationRequestDialog">
-  <property name="geometry">
-   <rect>
-    <x>0</x>
-    <y>0</y>
-    <width>441</width>
-    <height>308</height>
-   </rect>
-  </property>
-  <property name="windowTitle">
-   <string>Dialog</string>
-  </property>
-  <widget class="QLabel" name="introLabel">
-   <property name="geometry">
-    <rect>
-     <x>40</x>
-     <y>20</y>
-     <width>391</width>
-     <height>16</height>
-    </rect>
-   </property>
-   <property name="text">
-    <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Choose your contact to send invitation request:&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
-   </property>
-  </widget>
-  <widget class="QListView" name="contactsListView">
-   <property name="geometry">
-    <rect>
-     <x>40</x>
-     <y>50</y>
-     <width>351</width>
-     <height>192</height>
-    </rect>
-   </property>
-  </widget>
-  <widget class="QPushButton" name="sendButton">
-   <property name="geometry">
-    <rect>
-     <x>230</x>
-     <y>260</y>
-     <width>91</width>
-     <height>32</height>
-    </rect>
-   </property>
-   <property name="text">
-    <string>Send</string>
-   </property>
-  </widget>
-  <widget class="QPushButton" name="cancelButton">
-   <property name="geometry">
-    <rect>
-     <x>330</x>
-     <y>260</y>
-     <width>91</width>
-     <height>32</height>
-    </rect>
-   </property>
-   <property name="text">
-    <string>Cancel</string>
-   </property>
-  </widget>
- </widget>
- <resources/>
- <connections/>
-</ui>
diff --git a/log4cxx.properties b/log4cxx.properties
deleted file mode 100644
index bdbc1a2..0000000
--- a/log4cxx.properties
+++ /dev/null
@@ -1,24 +0,0 @@
-# Set root logger level to DEBUG and its only appender to A1.
-log4j.rootLogger=TRACE, A1
-#, rollingFile
-
-# A1 is set to be a ConsoleAppender.
-log4j.appender.A1=org.apache.log4j.ConsoleAppender
-
-# A1 uses PatternLayout.
-log4j.appender.A1.layout=org.apache.log4j.PatternLayout
-log4j.appender.A1.target=System.err
-#log4j.appender.A1.layout.ConversionPattern=%d{dd-MMM HH:MM:SS,SSS} %p %c %m%n
-#log4j.appender.A1.layout.ConversionPattern=%d{hh:mm:ss,SSS} %-14t %-14c  %m%n
-log4j.appender.A1.layout.ConversionPattern=%d{ss,SSS} %-5p %-12c  %m%n
-
-log4j.appender.rollingFile=org.apache.log4j.RollingFileAppender
-log4j.appender.rollingFile.File=logfile.txt
-log4j.appender.rollingFile.MaxFileSize=10MB
-log4j.appender.rollingFile.MaxBackupIndex=9
-log4j.appender.rollingFile.layout = org.apache.log4j.PatternLayout
-log4j.appender.rollingFile.layout.ConversionPattern=%d{ss,SSS} %-5p %-12c  %m%n
-
-log4j.logger.Executor = ERROR
-#log4j.logger.Scheduler = ERROR
-
diff --git a/logging.cc b/logging.cc
deleted file mode 100644
index 04fb6c3..0000000
--- a/logging.cc
+++ /dev/null
@@ -1,51 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- *                     Alexander Afanasyev
- *                     Zhenkai Zhu
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- *         Zhenkai Zhu <zhenkai@cs.ucla.edu>
- */
-
-#include "logging.h"
-
-#ifdef HAVE_LOG4CXX
-
-#include <log4cxx/logger.h>
-#include <log4cxx/basicconfigurator.h>
-#include <log4cxx/consoleappender.h>
-#include <log4cxx/patternlayout.h>
-#include <log4cxx/level.h>
-#include <log4cxx/propertyconfigurator.h>
-#include <log4cxx/defaultconfigurator.h>
-#include <log4cxx/helpers/exception.h>
-using namespace log4cxx;
-using namespace log4cxx::helpers;
-
-#include <unistd.h>
-
-void
-INIT_LOGGERS ()
-{
-  static bool configured = false;
-
-  if (configured) return;
-
-  if (access ("log4cxx.properties", R_OK)==0)
-    PropertyConfigurator::configureAndWatch ("log4cxx.properties");
-  else
-    {
-      PatternLayoutPtr   layout   (new PatternLayout ("%d{HH:mm:ss} %p %c{1} - %m%n"));
-      ConsoleAppenderPtr appender (new ConsoleAppender (layout));
-
-      BasicConfigurator::configure( appender );
-      Logger::getRootLogger()->setLevel (log4cxx::Level::getInfo ());
-    }
-
-  configured = true;
-}
-
-#endif
diff --git a/logging.h b/logging.h
deleted file mode 100644
index 2aa3344..0000000
--- a/logging.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- *                     Alexander Afanasyev
- *                     Zhenkai Zhu
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- *         Zhenkai Zhu <zhenkai@cs.ucla.edu>
- */
-
-#ifndef LOGGING_H
-#define LOGGING_H
-
-#include "config.h"
-
-#ifdef HAVE_LOG4CXX
-
-#include <log4cxx/logger.h>
-
-#define MEMBER_LOGGER                           \
-  static log4cxx::LoggerPtr staticModuleLogger;
-
-#define INIT_MEMBER_LOGGER(className,name)          \
-  log4cxx::LoggerPtr className::staticModuleLogger =  log4cxx::Logger::getLogger (name);
-
-#define INIT_LOGGER(name) \
-  static log4cxx::LoggerPtr staticModuleLogger = log4cxx::Logger::getLogger (name);
-
-#define _LOG_DEBUG(x) \
-  LOG4CXX_DEBUG(staticModuleLogger, x);
-
-#define _LOG_TRACE(x) \
-  LOG4CXX_TRACE(staticModuleLogger, x);
-
-#define _LOG_FUNCTION(x) \
-  LOG4CXX_TRACE(staticModuleLogger, __FUNCTION__ << "(" << x << ")");
-
-#define _LOG_FUNCTION_NOARGS \
-  LOG4CXX_TRACE(staticModuleLogger, __FUNCTION__ << "()");
-
-#define _LOG_ERROR(x) \
-  LOG4CXX_ERROR(staticModuleLogger, x);
-
-#define _LOG_ERROR_COND(cond,x) \
-  if (cond) { _LOG_ERROR(x) }
-
-#define _LOG_DEBUG_COND(cond,x) \
-  if (cond) { _LOG_DEBUG(x) }
-
-void
-INIT_LOGGERS ();
-
-#else // else HAVE_LOG4CXX
-
-#define INIT_LOGGER(name)
-#define _LOG_FUNCTION(x)
-#define _LOG_FUNCTION_NOARGS
-#define _LOG_TRACE(x)
-#define INIT_LOGGERS(x)
-#define _LOG_ERROR(x)
-#define _LOG_ERROR_COND(cond,x)
-#define _LOG_DEBUG_COND(cond,x)
-
-#define MEMBER_LOGGER
-#define INIT_MEMBER_LOGGER(className,name)
-
-#ifdef _DEBUG
-
-#include <boost/thread/thread.hpp>
-#include <boost/date_time/posix_time/posix_time.hpp>
-#include <iostream>
-
-#define _LOG_DEBUG(x) \
-  std::clog << boost::get_system_time () << " " << boost::this_thread::get_id () << " " << x << std::endl;
-
-#else
-#define _LOG_DEBUG(x)
-#endif
-
-#endif // HAVE_LOG4CXX
-
-#endif // LOGGING_H
diff --git a/src/add-contact-panel.cpp b/src/add-contact-panel.cpp
index 770f039..48e59d6 100644
--- a/src/add-contact-panel.cpp
+++ b/src/add-contact-panel.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *                     Yingdi Yu
  *
  * BSD license, See the LICENSE file for more information
@@ -11,9 +11,6 @@
 #include "add-contact-panel.hpp"
 #include "ui_add-contact-panel.h"
 
-#ifndef Q_MOC_RUN
-#endif
-
 namespace chronochat {
 
 AddContactPanel::AddContactPanel(QWidget *parent)
@@ -98,5 +95,4 @@
 
 #if WAF
 #include "add-contact-panel.moc"
-// #include "add-contact-panel.cpp.moc"
 #endif
diff --git a/src/add-contact-panel.hpp b/src/add-contact-panel.hpp
index fe8f851..0c73fa7 100644
--- a/src/add-contact-panel.hpp
+++ b/src/add-contact-panel.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *                     Yingdi Yu
  *
  * BSD license, See the LICENSE file for more information
@@ -20,7 +20,7 @@
 
 namespace Ui {
 class AddContactPanel;
-}
+} // namespace Ui
 
 namespace chronochat {
 
diff --git a/src/browse-contact-dialog.cpp b/src/browse-contact-dialog.cpp
index bf9df24..887c664 100644
--- a/src/browse-contact-dialog.cpp
+++ b/src/browse-contact-dialog.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *                     Yingdi Yu
  *
  * BSD license, See the LICENSE file for more information
@@ -135,5 +135,4 @@
 
 #if WAF
 #include "browse-contact-dialog.moc"
-// #include "browse-contact-dialog.cpp.moc"
 #endif
diff --git a/src/browse-contact-dialog.hpp b/src/browse-contact-dialog.hpp
index 4a081e0..f80f684 100644
--- a/src/browse-contact-dialog.hpp
+++ b/src/browse-contact-dialog.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *                     Yingdi Yu
  *
  * BSD license, See the LICENSE file for more information
@@ -24,7 +24,7 @@
 
 namespace Ui {
 class BrowseContactDialog;
-}
+} // namespace Ui
 
 namespace chronochat {
 
@@ -61,7 +61,7 @@
   onNameListReady(const QStringList& nameList);
 
   void
-  onIdCertReady(const ndn::security::Certificate & idCert);
+  onIdCertReady(const ndn::security::Certificate& idCert);
 
 signals:
   void
diff --git a/src/chat-dialog-backend.cpp b/src/chat-dialog-backend.cpp
index 234e4a3..53bfdb3 100644
--- a/src/chat-dialog-backend.cpp
+++ b/src/chat-dialog-backend.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013-2016, Regents of the University of California
+ * Copyright (c) 2013-2020, Regents of the University of California
  *                          Yingdi Yu
  *
  * BSD license, See the LICENSE file for more information
@@ -68,7 +68,7 @@
     try {
       m_face->getIoService().run();
     }
-    catch (std::runtime_error& e) {
+    catch (const std::runtime_error& e) {
       {
         std::lock_guard<std::mutex>lock(m_nfdConnectionMutex);
         m_isNfdConnected = false;
@@ -131,10 +131,8 @@
                         bind(&ChatDialogBackend::sendJoin, this));
 
   // cancel existing hello event if it exists
-  if (m_helloEventId) {
+  if (m_helloEventId)
     m_helloEventId.cancel();
-    m_helloEventId.reset();
-  }
 }
 
 class IoDeviceSource
@@ -229,7 +227,7 @@
   try {
     msg.wireDecode(data.getContent().blockFromValue());
   }
-  catch (tlv::Error&) {
+  catch (const tlv::Error&) {
     // nasty stuff: as a remedy, we'll form some standard msg for inparsable msgs
     msg.setNick("inconnu");
     msg.setMsgType(ChatMessage::OTHER);
@@ -243,7 +241,7 @@
 
     if (it != m_roster.end()) {
       // cancel timeout event
-      if (static_cast<bool>(it->second.timeoutEventId))
+      if (it->second.timeoutEventId)
         it->second.timeoutEventId.cancel();
 
       // notify frontend to remove the remote session (node)
@@ -268,10 +266,6 @@
 
     uint64_t seqNo = data.getName().get(-1).toNumber();
 
-    // If a timeout event has been scheduled, cancel it.
-    if (static_cast<bool>(it->second.timeoutEventId))
-      it->second.timeoutEventId.cancel();
-
     // (Re)schedule another timeout event after 3 HELLO_INTERVAL;
     it->second.timeoutEventId =
       m_scheduler->schedule(HELLO_INTERVAL * 3,
@@ -414,7 +408,7 @@
 void
 ChatDialogBackend::prepareChatMessage(const QString& text,
                                       time_t timestamp,
-                                      ChatMessage &msg)
+                                      ChatMessage& msg)
 {
   msg.setNick(m_nick);
   msg.setChatroomName(m_chatroomName);
@@ -514,5 +508,4 @@
 
 #if WAF
 #include "chat-dialog-backend.moc"
-// #include "chat-dialog-backend.cpp.moc"
 #endif
diff --git a/src/chat-dialog-backend.hpp b/src/chat-dialog-backend.hpp
index e9543bb..0c417c3 100644
--- a/src/chat-dialog-backend.hpp
+++ b/src/chat-dialog-backend.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *
  * BSD license, See the LICENSE file for more information
  *
@@ -25,18 +25,20 @@
 
 namespace chronochat {
 
-class NodeInfo {
+class NodeInfo
+{
 public:
   QString sessionPrefix;
   chronosync::SeqNo seqNo;
 };
 
-class UserInfo {
+class UserInfo
+{
 public:
   ndn::Name sessionPrefix;
   bool hasNick;
   std::string userNick;
-  ndn::scheduler::EventId timeoutEventId;
+  ndn::scheduler::ScopedEventId timeoutEventId;
 };
 
 class ChatDialogBackend : public QThread
@@ -98,7 +100,7 @@
   void
   prepareChatMessage(const QString& text,
                      time_t timestamp,
-                     ChatMessage &msg);
+                     ChatMessage& msg);
 
   void
   updatePrefixes();
diff --git a/src/chat-dialog.cpp b/src/chat-dialog.cpp
index 0158496..2d93156 100644
--- a/src/chat-dialog.cpp
+++ b/src/chat-dialog.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *                     Yingdi Yu
  *
  * BSD license, See the LICENSE file for more information
@@ -150,7 +150,7 @@
 void
 ChatDialog::changeEvent(QEvent *e)
 {
-  switch(e->type()) {
+  switch (e->type()) {
   case QEvent::ActivationChange:
     if (isActiveWindow()) {
       emit resetIcon();
@@ -450,5 +450,4 @@
 
 #if WAF
 #include "chat-dialog.moc"
-// #include "chat-dialog.cpp.moc"
 #endif
diff --git a/src/chat-dialog.hpp b/src/chat-dialog.hpp
index 6510297..5b9a14f 100644
--- a/src/chat-dialog.hpp
+++ b/src/chat-dialog.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *
  * BSD license, See the LICENSE file for more information
  *
@@ -32,7 +32,7 @@
 
 namespace Ui {
 class ChatDialog;
-}
+} // namespace Ui
 
 namespace chronochat {
 
diff --git a/src/chat-message.cpp b/src/chat-message.cpp
index 7932321..9a78f9d 100644
--- a/src/chat-message.cpp
+++ b/src/chat-message.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *
  * BSD license, See the LICENSE file for more information
  *
@@ -101,23 +101,23 @@
   m_wire.parse();
 
   if (m_wire.type() != tlv::ChatMessage)
-    throw Error("Unexpected TLV number when decoding chat message packet");
+    NDN_THROW(Error("Unexpected TLV number when decoding chat message packet"));
 
   Block::element_const_iterator i = m_wire.elements_begin();
   if (i == m_wire.elements_end() || i->type() != tlv::Nick)
-    throw Error("Expect Nick but get ...");
+    NDN_THROW(Error("Expect Nick but get ..."));
   m_nick = std::string(reinterpret_cast<const char* >(i->value()),
                        i->value_size());;
   i++;
 
   if (i == m_wire.elements_end() || i->type() != tlv::ChatroomName)
-    throw Error("Expect Chatroom Name but get ...");
+    NDN_THROW(Error("Expect Chatroom Name but get ..."));
   m_chatroomName = std::string(reinterpret_cast<const char* >(i->value()),
                        i->value_size());;
   i++;
 
   if (i == m_wire.elements_end() || i->type() != tlv::ChatMessageType)
-    throw Error("Expect Chat Message Type but get ...");
+    NDN_THROW(Error("Expect Chat Message Type but get ..."));
   m_msgType = static_cast<ChatMessageType>(readNonNegativeInteger(*i));
   i++;
 
@@ -125,19 +125,19 @@
     m_data = "";
   else {
     if (i == m_wire.elements_end() || i->type() != tlv::ChatData)
-      throw Error("Expect Chat Data but get ...");
+      NDN_THROW(Error("Expect Chat Data but get ..."));
     m_data = std::string(reinterpret_cast<const char* >(i->value()),
                        i->value_size());;
     i++;
   }
 
   if (i == m_wire.elements_end() || i->type() != tlv::Timestamp)
-    throw Error("Expect Timestamp but get ...");
+    NDN_THROW(Error("Expect Timestamp but get ..."));
   m_timestamp = static_cast<time_t>(readNonNegativeInteger(*i));
   i++;
 
   if (i != m_wire.elements_end()) {
-    throw Error("Unexpected element");
+    NDN_THROW(Error("Unexpected element"));
   }
 
 }
@@ -177,4 +177,4 @@
   m_timestamp = timestamp;
 }
 
-}// namespace chronochat
+} // namespace chronochat
diff --git a/src/chat-message.hpp b/src/chat-message.hpp
index 778f505..1a44005 100644
--- a/src/chat-message.hpp
+++ b/src/chat-message.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *
  * BSD license, See the LICENSE file for more information
  *
@@ -61,13 +61,13 @@
   const std::string&
   getChatroomName() const;
 
-  const ChatMessageType
+  ChatMessageType
   getMsgType() const;
 
   const std::string&
   getData() const;
 
-  const time_t
+  time_t
   getTimestamp() const;
 
   void
@@ -112,7 +112,7 @@
   return m_chatroomName;
 }
 
-inline const ChatMessage::ChatMessageType
+inline ChatMessage::ChatMessageType
 ChatMessage::getMsgType() const
 {
   return m_msgType;
@@ -124,7 +124,7 @@
   return m_data;
 }
 
-inline const time_t
+inline time_t
 ChatMessage::getTimestamp() const
 {
   return m_timestamp;
@@ -132,4 +132,4 @@
 
 } // namespace chronochat
 
-#endif //CHRONOCHAT_CHAT_MESSAGE_HPP
+#endif // CHRONOCHAT_CHAT_MESSAGE_HPP
diff --git a/src/chatroom-discovery-backend.cpp b/src/chatroom-discovery-backend.cpp
index 67dd7fa..3f92e01 100644
--- a/src/chatroom-discovery-backend.cpp
+++ b/src/chatroom-discovery-backend.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *
  * BSD license, See the LICENSE file for more information
  *
@@ -11,7 +11,6 @@
 #include "chatroom-discovery-backend.hpp"
 #include <QStringList>
 
-
 #ifndef Q_MOC_RUN
 
 #endif
@@ -63,7 +62,7 @@
     try {
       m_face->getIoService().run();
     }
-    catch (std::runtime_error& e) {
+    catch (const std::runtime_error& e) {
       {
         std::lock_guard<std::mutex>lock(m_nfdConnectionMutex);
         m_isNfdConnected = false;
@@ -113,9 +112,6 @@
                                                 this, _1));
 
   // add an timer to refresh front end
-  if (m_refreshPanelId) {
-    m_refreshPanelId.cancel();
-  }
   m_refreshPanelId = m_scheduler->schedule(REFRESH_INTERVAL,
                                            [this] { sendChatroomList(); });
 }
@@ -124,7 +120,6 @@
 ChatroomDiscoveryBackend::close()
 {
   m_scheduler->cancelAllEvents();
-  m_refreshPanelId.reset();
   m_chatroomList.clear();
   m_sock.reset();
 }
@@ -169,9 +164,9 @@
         return;
       }
       else {
-        if (it->second.helloTimeoutEventId) {
+        if (it->second.helloTimeoutEventId)
           it->second.helloTimeoutEventId.cancel();
-        }
+
         it->second.isManager = false;
       }
 
@@ -250,10 +245,6 @@
   if (it != m_chatroomList.end() && it->second.isManager) {
     ndn::Block buf = it->second.info.wireEncode();
 
-    if (it->second.helloTimeoutEventId) {
-      it->second.helloTimeoutEventId.cancel();
-    }
-
     m_sock->publishData(buf.wire(), buf.size(), FRESHNESS_PERIOD, it->second.chatroomPrefix);
 
     it->second.helloTimeoutEventId =
@@ -431,9 +422,6 @@
   }
 
   emit chatroomListReady(chatroomList);
-  if (m_refreshPanelId) {
-    m_refreshPanelId.cancel();
-  }
   m_refreshPanelId = m_scheduler->schedule(REFRESH_INTERVAL,
                                            [this] { sendChatroomList(); });
 }
diff --git a/src/chatroom-discovery-backend.hpp b/src/chatroom-discovery-backend.hpp
index ad471ac..0c40ee4 100644
--- a/src/chatroom-discovery-backend.hpp
+++ b/src/chatroom-discovery-backend.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *
  * BSD license, See the LICENSE file for more information
  *
@@ -24,7 +24,8 @@
 
 namespace chronochat {
 
-class ChatroomInfoBackend {
+class ChatroomInfoBackend
+{
 public:
   std::string chatroomName;
   Name chatroomPrefix;
@@ -36,7 +37,7 @@
   // For a user to check the status of the chatroom that he is not in.
   ndn::scheduler::EventId remoteChatroomTimeoutEventId;
   // If the user is manager, he will need the helloEventId to keep track of hello message
-  ndn::scheduler::EventId helloTimeoutEventId;
+  ndn::scheduler::ScopedEventId helloTimeoutEventId;
   // To tell whether the user is in this chatroom
   bool isParticipant;
   // To tell whether the user is the manager
@@ -228,7 +229,7 @@
   shared_ptr<ndn::Face> m_face;
 
   unique_ptr<ndn::Scheduler> m_scheduler;            // scheduler
-  ndn::scheduler::EventId m_refreshPanelId;
+  ndn::scheduler::ScopedEventId m_refreshPanelId;
   shared_ptr<chronosync::Socket> m_sock; // SyncSocket
 
   ChatroomList m_chatroomList;
diff --git a/src/chatroom-info.cpp b/src/chatroom-info.cpp
index aa8efcc..e8d47eb 100644
--- a/src/chatroom-info.cpp
+++ b/src/chatroom-info.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *                     Yingdi Yu
  *
  * BSD license, See the LICENSE file for more information
@@ -137,47 +137,47 @@
   //                   Name+
 
   if (m_wire.type() != tlv::ChatroomInfo)
-    throw Error("Unexpected TLV number when decoding chatroom packet");
+    NDN_THROW(Error("Unexpected TLV number when decoding chatroom packet"));
 
   // Chatroom Info
   Block::element_const_iterator i = m_wire.elements_begin();
   if (i == m_wire.elements_end())
-    throw Error("Missing Chatroom Name");
+    NDN_THROW(Error("Missing Chatroom Name"));
   if (i->type() != tlv::ChatroomName)
-    throw Error("Expect Chatroom Name but get TLV Type " + std::to_string(i->type()));
+    NDN_THROW(Error("Expect Chatroom Name but get TLV Type " + std::to_string(i->type())));
   m_chatroomName.wireDecode(i->blockFromValue());
   ++i;
 
   // Trust Model
   if (i == m_wire.elements_end())
-    throw Error("Missing Trust Model");
+    NDN_THROW(Error("Missing Trust Model"));
   if (i->type() != tlv::TrustModel)
-    throw Error("Expect Trust Model but get TLV Type " + std::to_string(i->type()));
+    NDN_THROW(Error("Expect Trust Model but get TLV Type " + std::to_string(i->type())));
   m_trustModel =
       static_cast<TrustModel>(readNonNegativeInteger(*i));
   ++i;
 
   // Chatroom Sync Prefix
   if (i == m_wire.elements_end())
-    throw Error("Missing Chatroom Prefix");
+    NDN_THROW(Error("Missing Chatroom Prefix"));
   if (i->type() != tlv::ChatroomPrefix)
-    throw Error("Expect Chatroom Prefix but get TLV Type " + std::to_string(i->type()));
+    NDN_THROW(Error("Expect Chatroom Prefix but get TLV Type " + std::to_string(i->type())));
   m_syncPrefix.wireDecode(i->blockFromValue());
   ++i;
 
   // Manager Prefix
   if (i == m_wire.elements_end())
-    throw Error("Missing Manager Prefix");
+    NDN_THROW(Error("Missing Manager Prefix"));
   if (i->type() != tlv::ManagerPrefix)
-    throw Error("Expect Manager Prefix but get TLV Type " + std::to_string(i->type()));
+    NDN_THROW(Error("Expect Manager Prefix but get TLV Type " + std::to_string(i->type())));
   m_manager.wireDecode(i->blockFromValue());
   ++i;
 
   // Participants
   if (i == m_wire.elements_end())
-    throw Error("Missing Participant");
+    NDN_THROW(Error("Missing Participant"));
   if (i->type() != tlv::Participants)
-    throw Error("Expect Participant but get TLV Type " + std::to_string(i->type()));
+    NDN_THROW(Error("Expect Participant but get TLV Type " + std::to_string(i->type())));
 
   Block temp = *i;
   temp.parse();
@@ -189,15 +189,15 @@
     ++j;
   }
   if (j != temp.elements_end())
-    throw Error("Unexpected element");
+    NDN_THROW(Error("Unexpected element"));
 
   if (m_participants.empty())
-    throw Error("No participant in the chatroom");
+    NDN_THROW(Error("No participant in the chatroom"));
 
   ++i;
 
   if (i != m_wire.elements_end()) {
-    throw Error("Unexpected element");
+    NDN_THROW(Error("Unexpected element"));
   }
 }
 
diff --git a/src/chatroom-info.hpp b/src/chatroom-info.hpp
index 81e0fde..2572193 100644
--- a/src/chatroom-info.hpp
+++ b/src/chatroom-info.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *                     Yingdi Yu
  *
  * BSD license, See the LICENSE file for more information
@@ -64,7 +64,7 @@
   const Name::Component&
   getName() const;
 
-  const TrustModel
+  TrustModel
   getTrustModel() const;
 
   const Name&
@@ -115,7 +115,7 @@
   return m_chatroomName;
 }
 
-inline const ChatroomInfo::TrustModel
+inline ChatroomInfo::TrustModel
 ChatroomInfo::getTrustModel() const
 {
   return m_trustModel;
diff --git a/src/common.hpp b/src/common.hpp
index 3b14f79..90f5e54 100644
--- a/src/common.hpp
+++ b/src/common.hpp
@@ -1,6 +1,13 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * COPYRIGHT MSG GOES HERE...
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2020, Regents of the University of California
+ *                     Yingdi Yu
+ *
+ * BSD license, See the LICENSE file for more information
+ *
+ * Author: Mengjin Yan <jane.yan0129@gmail.com>
+ *         Yingdi Yu <yingdi@cs.ucla.edu>
+ *         Qiuhan Ding <qiuhanding@cs.ucla.edu>
  */
 
 #ifndef CHRONOCHAT_COMMON_HPP
@@ -22,51 +29,33 @@
 
 #include <cstddef>
 #include <list>
-#include <set>
 #include <map>
-#include <queue>
 #include <vector>
 #include <string>
 
+#include <boost/assert.hpp>
+
 #include <ndn-cxx/interest.hpp>
 #include <ndn-cxx/data.hpp>
 
-#include <boost/algorithm/string.hpp>
-#include <boost/asio.hpp>
-#include <boost/assert.hpp>
-#include <boost/lexical_cast.hpp>
-#include <boost/noncopyable.hpp>
-#include <boost/property_tree/ptree.hpp>
-
 namespace chronochat {
 
 using std::size_t;
 
-using boost::noncopyable;
-
 using std::shared_ptr;
 using std::unique_ptr;
-using std::weak_ptr;
-using std::enable_shared_from_this;
 using std::make_shared;
-using std::static_pointer_cast;
-using std::dynamic_pointer_cast;
-using std::const_pointer_cast;
 using std::function;
 using std::bind;
-using std::ref;
-using std::cref;
 
 using ndn::Interest;
 using ndn::Data;
 using ndn::Name;
 using ndn::Block;
-using ndn::Signature;
-using ndn::KeyLocator;
 
 namespace tlv {
 using namespace ndn::tlv;
-}
+} // namespace tlv
 
 namespace name = ndn::name;
 namespace time = ndn::time;
diff --git a/src/conf.cpp b/src/conf.cpp
index d02fe08..db44604 100644
--- a/src/conf.cpp
+++ b/src/conf.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *
  * BSD license, See the LICENSE file for more information
  *
@@ -79,14 +79,14 @@
   //            String
 
   if (m_wire.type() != tlv::Conf)
-    throw Error("Unexpected TLV number when decoding conf packet");
+    NDN_THROW(Error("Unexpected TLV number when decoding conf packet"));
 
   // Identity
   Block::element_const_iterator i = m_wire.elements_begin();
   if (i == m_wire.elements_end())
-    throw Error("Missing Identity");
+    NDN_THROW(Error("Missing Identity"));
   if (i->type() != tlv::Name)
-    throw Error("Expect Identity but get TLV Type " + std::to_string(i->type()));
+    NDN_THROW(Error("Expect Identity but get TLV Type " + std::to_string(i->type())));
 
   m_identity.wireDecode(*i);
   ++i;
@@ -95,15 +95,14 @@
   if (i == m_wire.elements_end())
     return;
   if (i->type() != tlv::Nick)
-    throw Error("Expect Nick but get TLV Type " + std::to_string(i->type()));
+    NDN_THROW(Error("Expect Nick but get TLV Type " + std::to_string(i->type())));
 
   m_nick = std::string(reinterpret_cast<const char* >(i->value()),
                        i->value_size());
   ++i;
 
-  if (i != m_wire.elements_end()) {
-    throw Error("Unexpected element");
-  }
+  if (i != m_wire.elements_end())
+    NDN_THROW(Error("Unexpected element"));
 }
 
 void
diff --git a/src/conf.hpp b/src/conf.hpp
index 3b4f394..8df9f62 100644
--- a/src/conf.hpp
+++ b/src/conf.hpp
@@ -1,21 +1,17 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *
  * BSD license, See the LICENSE file for more information
  *
  * Author: Qiuhan Ding <qiuhanding@cs.ucla.edu>
  */
 
-#ifndef CHRONOCHAT_CONFIG_HPP
-#define CHRONOCHAT_CONFIG_HPP
+#ifndef CHRONOCHAT_CONF_HPP
+#define CHRONOCHAT_CONF_HPP
 
 #include "common.hpp"
 #include "tlv.hpp"
-#include <ndn-cxx/util/concepts.hpp>
-#include <ndn-cxx/encoding/block.hpp>
-#include <ndn-cxx/encoding/encoding-buffer.hpp>
-#include <list>
 
 namespace chronochat {
 
@@ -84,4 +80,4 @@
 
 } // namespace chronochat
 
-#endif //CHRONOCHAT_CONF_HPP
+#endif // CHRONOCHAT_CONF_HPP
diff --git a/src/contact-manager.cpp b/src/contact-manager.cpp
index 2bb5153..5a5f5bb 100644
--- a/src/contact-manager.cpp
+++ b/src/contact-manager.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013-2016, Regents of the University of California
+ * Copyright (c) 2013-2020, Regents of the University of California
  *                          Yingdi Yu
  *
  * BSD license, See the LICENSE file for more information
@@ -9,10 +9,6 @@
  *         Qiuhan Ding <qiuhanding@cs.ucla.edu>
  */
 
-#if __clang__
-#pragma clang diagnostic ignored "-Wtautological-compare"
-#endif
-
 #include "contact-manager.hpp"
 #include <QStringList>
 #include <QFile>
@@ -28,7 +24,6 @@
 #include <boost/asio.hpp>
 #include <boost/tokenizer.hpp>
 #include <boost/filesystem.hpp>
-#include "logging.h"
 #endif
 
 namespace fs = boost::filesystem;
@@ -97,6 +92,7 @@
 
   Interest interest(interestName);
   interest.setInterestLifetime(time::milliseconds(1000));
+  interest.setCanBePrefix(true);
   interest.setMustBeFresh(false);
 
   m_face.expressInterest(interest,
@@ -112,17 +108,14 @@
 void
 ContactManager::prepareEndorseInfo(const Name& identity)
 {
-  // _LOG_DEBUG("prepareEndorseInfo");
   const Profile& profile = m_bufferedContacts[identity].m_selfEndorseCert->getProfile();
 
   shared_ptr<EndorseInfo> endorseInfo = make_shared<EndorseInfo>();
   m_bufferedContacts[identity].m_endorseInfo = endorseInfo;
 
   map<string, size_t> endorseCount;
-  for (Profile::const_iterator pIt = profile.begin(); pIt != profile.end(); pIt++) {
-    // _LOG_DEBUG("prepareEndorseInfo: profile[" << pIt->first << "]: " << pIt->second);
+  for (Profile::const_iterator pIt = profile.begin(); pIt != profile.end(); pIt++)
     endorseCount[pIt->first] = 0;
-  }
 
   size_t endorseCertCount = 0;
 
@@ -179,13 +172,13 @@
     else
       emit contactInfoFetchFailed(QString::fromStdString(identity.toUri() + ": verification failed"));
   }
-  catch(Block::Error& e) {
+  catch (const Block::Error& e) {
     emit contactInfoFetchFailed(QString::fromStdString(identity.toUri() + ": block error " + e.what()));
   }
-  catch(EndorseCertificate::Error& e) {
+  catch (const EndorseCertificate::Error& e) {
     emit contactInfoFetchFailed(QString::fromStdString(identity.toUri() + ": cert error " + e.what()));
   }
-  catch(Data::Error& e) {
+  catch (const Data::Error& e) {
     emit contactInfoFetchFailed(QString::fromStdString(identity.toUri() + ": data error " + e.what()));
   }
 }
@@ -219,7 +212,7 @@
     m_bufferedContacts[identity].m_endorseCollection = endorseCollection;
     fetchEndorseCertificateInternal(identity, 0);
   }
-  catch (std::runtime_error&) {
+  catch (const std::runtime_error&) {
     prepareEndorseInfo(identity);
   }
 }
@@ -235,7 +228,6 @@
 void
 ContactManager::onDnsCollectEndorseTimeoutNotify(const Interest& interest, const Name& identity)
 {
-  // _LOG_DEBUG("onDnsCollectEndorseTimeoutNotify: " << interest.getName());
   prepareEndorseInfo(identity);
 }
 
@@ -283,6 +275,7 @@
 
       Interest interest(interestName);
       interest.setMustBeFresh(true);
+      interest.setCanBePrefix(true);
       interest.setInterestLifetime(time::milliseconds(1000));
 
       ndn::security::DataValidationSuccessCallback onValidated =
@@ -368,14 +361,12 @@
 ContactManager::onIdentityCertValidationFailed(const Data& data,
                                                const ndn::security::ValidationError& error)
 {
-  // _LOG_DEBUG("ContactManager::onIdentityCertValidationFailed " << data->getName());
   decreaseIdCertCount();
 }
 
 void
 ContactManager::onIdentityCertTimeoutNotify(const Interest& interest)
 {
-  // _LOG_DEBUG("ContactManager::onIdentityCertTimeoutNotify: " << interest.getName());
   decreaseIdCertCount();
 }
 
@@ -527,7 +518,6 @@
                                 const ndn::security::DataValidationFailureCallback& onValidationFailed,
                                 const TimeoutNotify& timeoutNotify)
 {
-  // _LOG_DEBUG("On interest timeout: " << interest.getName());
   if (retry > 0)
     sendInterest(interest, onValidated, onValidationFailed, timeoutNotify, retry-1);
   else
@@ -578,7 +568,7 @@
                                                 .getDefaultCertificate();
     if (cert.getKeyName() == interestName)
       return m_face.put(cert);
-  } catch (ndn::security::Pib::Error&) {}
+  } catch (const ndn::security::Pib::Error&) {}
 
   data = m_contactStorage->getSelfEndorseCertificate();
   if (static_cast<bool>(data) && data->getKeyName().equals(interestName))
@@ -597,38 +587,20 @@
 
   m_contactStorage = make_shared<ContactStorage>(m_identity);
 
-  Name dnsPrefix;
-  dnsPrefix.append(m_identity).append("DNS");
-  auto dnsListenerId = make_shared<ndn::RegisteredPrefixHandle>(
-    m_face.setInterestFilter(dnsPrefix,
-                             bind(&ContactManager::onDnsInterest, this, _1, _2),
-                             bind(&ContactManager::onDnsRegisterFailed, this, _1, _2)));
+  m_dnsListenerHandle = m_face.setInterestFilter(
+    Name(m_identity).append("DNS"),
+    bind(&ContactManager::onDnsInterest, this, _1, _2),
+    bind(&ContactManager::onDnsRegisterFailed, this, _1, _2));
 
-  Name keyPrefix;
-  keyPrefix.append(m_identity).append("KEY");
-  auto keyListenerId = make_shared<ndn::RegisteredPrefixHandle>(
-    m_face.setInterestFilter(keyPrefix,
-                             bind(&ContactManager::onKeyInterest, this, _1, _2),
-                             bind(&ContactManager::onDnsRegisterFailed, this, _1, _2)));
+  m_keyListenerHandle = m_face.setInterestFilter(
+    Name(m_identity).append("KEY"),
+    bind(&ContactManager::onKeyInterest, this, _1, _2),
+    bind(&ContactManager::onDnsRegisterFailed, this, _1, _2));
 
-  Name profileCertPrefix;
-  profileCertPrefix.append(m_identity).append("PROFILE-CERT");
-  auto profileCertListenerId = make_shared<ndn::RegisteredPrefixHandle>(
-    m_face.setInterestFilter(profileCertPrefix,
-                             bind(&ContactManager::onKeyInterest, this, _1, _2),
-                             bind(&ContactManager::onDnsRegisterFailed, this, _1, _2)));
-
-  if (m_dnsListenerId != 0)
-    m_dnsListenerId->unregister();
-  m_dnsListenerId = dnsListenerId;
-
-  if (m_keyListenerId != 0)
-    m_keyListenerId->unregister();
-  m_keyListenerId = keyListenerId;
-
-  if (m_profileCertListenerId != 0)
-    m_profileCertListenerId->unregister();
-  m_profileCertListenerId = profileCertListenerId;
+  m_profileCertListenerHandle = m_face.setInterestFilter(
+    Name(m_identity).append("PROFILE-CERT"),
+    bind(&ContactManager::onKeyInterest, this, _1, _2),
+    bind(&ContactManager::onDnsRegisterFailed, this, _1, _2));
 
   m_contactList.clear();
   m_contactStorage->getAllContacts(m_contactList);
@@ -647,10 +619,9 @@
   Name interestName;
   interestName.append(identityName).append("DNS").append("PROFILE");
 
-  // _LOG_DEBUG("onFetchContactInfo " << identity.toStdString() << " profile: " << interestName);
-
   Interest interest(interestName);
   interest.setInterestLifetime(time::milliseconds(1000));
+  interest.setCanBePrefix(true);
   interest.setMustBeFresh(true);
 
   ndn::security::DataValidationSuccessCallback onValidated =
@@ -666,14 +637,12 @@
 void
 ContactManager::onAddFetchedContact(const QString& identity)
 {
-  // _LOG_DEBUG("onAddFetchedContact");
-
   Name identityName(identity.toStdString());
 
   BufferedContacts::const_iterator it = m_bufferedContacts.find(identityName);
   if (it != m_bufferedContacts.end()) {
     Contact contact(*(it->second.m_selfEndorseCert));
-    // _LOG_DEBUG("onAddFetchedContact: contact ready");
+
     try {
       m_contactStorage->addContact(contact);
       m_bufferedContacts.erase(identityName);
@@ -683,7 +652,7 @@
 
       onWaitForContactList();
     }
-    catch(ContactStorage::Error& e) {
+    catch (const ContactStorage::Error& e) {
       emit warning(QString::fromStdString(e.what()));
     }
   }
@@ -699,8 +668,6 @@
   if (!static_cast<bool>(newProfile))
     return;
 
-  // _LOG_DEBUG("ContactManager::onUpdateProfile: getProfile");
-
   shared_ptr<EndorseCertificate> newEndorseCertificate =
     getSignedSelfEndorseCertificate(*newProfile);
 
@@ -773,7 +740,7 @@
       if (!it->empty())
         bufferedIdCertNames.push_back(*it);
   }
-  catch(std::exception &e) {
+  catch (const std::exception& e) {
     emit warning(QString::fromStdString("Fail to fetch certificate directory! #N"));
   }
 
@@ -790,6 +757,7 @@
     Interest interest(certName);
     interest.setInterestLifetime(time::milliseconds(1000));
     interest.setMustBeFresh(true);
+    interest.setCanBePrefix(true);
 
     ndn::security::DataValidationSuccessCallback onValidated =
     bind(&ContactManager::onIdentityCertValidated, this, _1);
@@ -829,7 +797,7 @@
 
       onWaitForContactList();
     }
-    catch(ContactStorage::Error& e) {
+    catch (const ContactStorage::Error& e) {
       emit warning(QString::fromStdString(e.what()));
     }
   }
@@ -908,5 +876,4 @@
 
 #if WAF
 #include "contact-manager.moc"
-// #include "contact-manager.cpp.moc"
 #endif
diff --git a/src/contact-manager.hpp b/src/contact-manager.hpp
index b475eb4..456a19d 100644
--- a/src/contact-manager.hpp
+++ b/src/contact-manager.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *                     Yingdi Yu
  *
  * BSD license, See the LICENSE file for more information
@@ -256,7 +256,8 @@
 
 private:
 
-  class FetchedInfo {
+  class FetchedInfo
+  {
   public:
     shared_ptr<EndorseCertificate> m_selfEndorseCert;
     shared_ptr<EndorseCollection> m_endorseCollection;
@@ -283,9 +284,9 @@
   BufferedIdCerts m_bufferedIdCerts;
 
   // Tmp Dns
-  shared_ptr<ndn::RegisteredPrefixHandle> m_dnsListenerId;
-  shared_ptr<ndn::RegisteredPrefixHandle> m_keyListenerId;
-  shared_ptr<ndn::RegisteredPrefixHandle> m_profileCertListenerId;
+  ndn::ScopedRegisteredPrefixHandle m_dnsListenerHandle;
+  ndn::ScopedRegisteredPrefixHandle m_keyListenerHandle;
+  ndn::ScopedRegisteredPrefixHandle m_profileCertListenerHandle;
 
   RecLock m_collectCountMutex;
   size_t m_collectCount;
diff --git a/src/contact-panel.cpp b/src/contact-panel.cpp
index 8841d5d..04b68d5 100644
--- a/src/contact-panel.cpp
+++ b/src/contact-panel.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *                     Yingdi Yu
  *
  * BSD license, See the LICENSE file for more information
@@ -18,12 +18,6 @@
 #include <QtSql/QSqlField>
 #include <QtSql/QSqlError>
 
-#ifndef Q_MOC_RUN
-#include "logging.h"
-#endif
-
-// INIT_LOGGER("ContactPanel");
-
 namespace chronochat {
 
 ContactPanel::ContactPanel(QWidget *parent)
@@ -129,15 +123,10 @@
 void
 ContactPanel::onCloseDBModule()
 {
-  // _LOG_DEBUG("close db module");
-  if (m_trustScopeModel) {
+  if (m_trustScopeModel)
     delete m_trustScopeModel;
-    // _LOG_DEBUG("trustScopeModel closed");
-  }
-  if (m_endorseDataModel) {
+  if (m_endorseDataModel)
     delete m_endorseDataModel;
-    // _LOG_DEBUG("endorseDataModel closed");
-  }
 }
 
 void
@@ -211,8 +200,8 @@
 
 // private slots
 void
-ContactPanel::onSelectionChanged(const QItemSelection &selected,
-                                 const QItemSelection &deselected)
+ContactPanel::onSelectionChanged(const QItemSelection& selected,
+                                 const QItemSelection& deselected)
 {
   QModelIndexList items = selected.indexes();
   QString alias = m_contactListModel->data(items.first(), Qt::DisplayRole).toString();
@@ -341,5 +330,4 @@
 
 #if WAF
 #include "contact-panel.moc"
-// #include "contact-panel.cpp.moc"
 #endif
diff --git a/src/contact-panel.hpp b/src/contact-panel.hpp
index 7eec224..737b487 100644
--- a/src/contact-panel.hpp
+++ b/src/contact-panel.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *                     Yingdi Yu
  *
  * BSD license, See the LICENSE file for more information
@@ -11,20 +11,20 @@
 #ifndef CHRONOCHAT_CONTACT_PANEL_HPP
 #define CHRONOCHAT_CONTACT_PANEL_HPP
 
+#include "set-alias-dialog.hpp"
+#include "endorse-combobox-delegate.hpp"
+
 #include <QDialog>
 #include <QStringListModel>
 #include <QSqlTableModel>
 #include <QItemSelection>
 
-#include "set-alias-dialog.hpp"
-#include "endorse-combobox-delegate.hpp"
-
 #ifndef Q_MOC_RUN
 #endif
 
 namespace Ui {
 class ContactPanel;
-}
+} // namespace Ui
 
 namespace chronochat {
 
diff --git a/src/contact-storage.cpp b/src/contact-storage.cpp
index d5e0fe2..76ae31d 100644
--- a/src/contact-storage.cpp
+++ b/src/contact-storage.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *                     Yingdi Yu
  *
  * BSD license, See the LICENSE file for more information
@@ -10,10 +10,9 @@
  */
 
 #include "contact-storage.hpp"
-
-#include <boost/filesystem.hpp>
 #include "cryptopp.hpp"
 
+#include <boost/filesystem.hpp>
 
 namespace chronochat {
 
@@ -167,7 +166,7 @@
 
   int res = sqlite3_open((chronosDir / getDBName()).c_str(), &m_db);
   if (res != SQLITE_OK)
-    throw Error("chronochat DB cannot be open/created");
+    NDN_THROW(Error("chronochat DB cannot be open/created"));
 
   initializeTable("SelfProfile", INIT_SP_TABLE);
   initializeTable("SelfEndorse", INIT_SE_TABLE);
@@ -215,9 +214,9 @@
 
   if (!tableExist) {
     char *errmsg = 0;
-    res = sqlite3_exec(m_db, sqlCreateStmt.c_str (), NULL, NULL, &errmsg);
+    res = sqlite3_exec(m_db, sqlCreateStmt.c_str (), nullptr, nullptr, &errmsg);
     if (res != SQLITE_OK && errmsg != 0)
-      throw Error("Init \"error\" in " + tableName);
+      NDN_THROW(Error("Init \"error\" in " + tableName));
   }
 }
 
@@ -396,7 +395,7 @@
 ContactStorage::addContact(const Contact& contact)
 {
   if (doesContactExist(contact.getNameSpace()))
-    throw Error("Normal Contact has already existed");
+    NDN_THROW(Error("Normal Contact has already existed"));
 
   string identity = contact.getNameSpace().toUri();
   bool isIntroducer = contact.isIntroducer();
diff --git a/src/contact-storage.hpp b/src/contact-storage.hpp
index 10bb117..b4f4e04 100644
--- a/src/contact-storage.hpp
+++ b/src/contact-storage.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *                     Yingdi Yu
  *
  * BSD license, See the LICENSE file for more information
@@ -25,7 +25,7 @@
   class Error : public std::runtime_error
   {
   public:
-    Error(const std::string &what)
+    Error(const std::string& what)
       : std::runtime_error(what)
     {
     }
diff --git a/src/contact.hpp b/src/contact.hpp
index b0fe674..4b04b47 100644
--- a/src/contact.hpp
+++ b/src/contact.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *                     Yingdi Yu
  *
  * BSD license, See the LICENSE file for more information
@@ -12,11 +12,12 @@
 #define CHRONOCHAT_CONTACT_HPP
 
 #include "common.hpp"
-#include <ndn-cxx/security/certificate.hpp>
-#include <ndn-cxx/util/regex.hpp>
 #include "endorse-certificate.hpp"
 #include "profile.hpp"
 
+#include <ndn-cxx/security/certificate.hpp>
+#include <ndn-cxx/util/regex.hpp>
+
 namespace chronochat {
 
 class Contact
@@ -45,7 +46,7 @@
     try {
       m_notBefore = identityCertificate.getValidityPeriod().getPeriod().first;
       m_notAfter = identityCertificate.getValidityPeriod().getPeriod().second;
-    } catch (tlv::Error&) {}
+    } catch (const tlv::Error&) {}
   }
 
   Contact(const EndorseCertificate& endorseCertificate,
@@ -69,7 +70,7 @@
     try {
       m_notBefore = endorseCertificate.getValidityPeriod().getPeriod().first;
       m_notAfter = endorseCertificate.getValidityPeriod().getPeriod().second;
-    } catch (tlv::Error&) {}
+    } catch (const tlv::Error&) {}
   }
 
   Contact(const Name& identity,
diff --git a/src/controller-backend.cpp b/src/controller-backend.cpp
index 7c6b8a5..9078cf2 100644
--- a/src/controller-backend.cpp
+++ b/src/controller-backend.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013-2016, Regents of the University of California
+ * Copyright (c) 2013-2020, Regents of the University of California
  *                          Yingdi Yu
  *
  * BSD license, See the LICENSE file for more information
@@ -12,11 +12,14 @@
 #include "controller-backend.hpp"
 
 #ifndef Q_MOC_RUN
+#include <iostream>
+#include <boost/asio.hpp>
+
 #include <ndn-cxx/util/segment-fetcher.hpp>
 #include <ndn-cxx/security/signing-helpers.hpp>
 #include <ndn-cxx/security/certificate-fetcher-offline.hpp>
+
 #include "invitation.hpp"
-#include <iostream>
 #endif
 
 namespace chronochat {
@@ -58,7 +61,7 @@
       setInvitationListener();
       m_face.processEvents();
     }
-    catch (std::runtime_error& e) {
+    catch (const std::runtime_error& e) {
       {
         std::lock_guard<std::mutex>lock(m_nfdConnectionMutex);
         m_isNfdConnected = false;
@@ -136,35 +139,13 @@
   invitationPrefix.append(m_identity).append("CHRONOCHAT-INVITATION");
   requestPrefix.append(m_identity).append("CHRONOCHAT-INVITATION-REQUEST");
 
-  auto invitationListenerId =
-    make_shared<ndn::RegisteredPrefixHandle>(m_face.setInterestFilter(invitationPrefix,
-                             bind(&ControllerBackend::onInvitationInterest,
-                                  this, _1, _2, offset),
-                             bind(&ControllerBackend::onInvitationRegisterFailed,
-                                  this, _1, _2)));
+  m_invitationListenerHandle = m_face.setInterestFilter(invitationPrefix,
+    bind(&ControllerBackend::onInvitationInterest, this, _1, _2, offset),
+    bind(&ControllerBackend::onInvitationRegisterFailed, this, _1, _2));
 
-  if (m_invitationListenerId != 0) {
-    invitationListenerId->unregister(
-      bind(&ControllerBackend::onInvitationPrefixReset, this),
-      bind(&ControllerBackend::onInvitationPrefixResetFailed, this, _1));
-  }
-
-  m_invitationListenerId = invitationListenerId;
-
-  auto requestListenerId =
-    make_shared<ndn::RegisteredPrefixHandle>(
-      m_face.setInterestFilter(requestPrefix,
-                               bind(&ControllerBackend::onInvitationRequestInterest,
-                                    this, _1, _2, offset),
-                               [] (const Name& prefix, const std::string& failInfo) {}));
-
-  if (m_requestListenerId != 0) {
-    m_requestListenerId->unregister(
-      []{},
-      [] (const std::string& failInfo) {});
-  }
-
-  m_requestListenerId = requestListenerId;
+  m_requestListenerHandle = m_face.setInterestFilter(requestPrefix,
+    bind(&ControllerBackend::onInvitationRequestInterest, this, _1, _2, offset),
+    [] (const Name& prefix, const std::string& failInfo) {});
 }
 
 ndn::Name
@@ -173,25 +154,12 @@
   return Name("/ndn/broadcast");
 }
 
-void
-ControllerBackend::onInvitationPrefixReset()
-{
-  // _LOG_DEBUG("ControllerBackend::onInvitationPrefixReset");
-}
-
-void
-ControllerBackend::onInvitationPrefixResetFailed(const std::string& failInfo)
-{
-  // _LOG_DEBUG("ControllerBackend::onInvitationPrefixResetFailed: " << failInfo);
-}
-
 
 void
 ControllerBackend::onInvitationInterest(const ndn::Name& prefix,
                                         const ndn::Interest& interest,
                                         size_t routingPrefixOffset)
 {
-  // _LOG_DEBUG("onInvitationInterest: " << interest.getName());
   shared_ptr<Interest> invitationInterest =
     make_shared<Interest>(interest.getName().getSubName(routingPrefixOffset));
 
@@ -201,7 +169,7 @@
       if (m_chatDialogList.contains(QString::fromStdString(invitation.getChatroom())))
         return;
   }
-  catch (Invitation::Error& e) {
+  catch (const Invitation::Error& e) {
     // Cannot parse the invitation;
     return;
   }
@@ -215,7 +183,6 @@
 void
 ControllerBackend::onInvitationRegisterFailed(const Name& prefix, const std::string& failInfo)
 {
-  // _LOG_DEBUG("ControllerBackend::onInvitationRegisterFailed: " << failInfo);
 }
 
 void
@@ -258,8 +225,6 @@
 ControllerBackend::onInvitationValidationFailed(const Interest& interest,
                                                 const ndn::security::ValidationError& failureInfo)
 {
-  // _LOG_DEBUG("Invitation: " << interest->getName() <<
-  //            " cannot not be validated due to: " << failureInfo);
 }
 
 void
@@ -288,7 +253,7 @@
         prefix = Name("/private/local");
     }
   }
-  catch (Block::Error& e) {
+  catch (const Block::Error& e) {
     prefix = Name("/private/local");
   }
 
@@ -441,8 +406,6 @@
       .append(ROUTING_HINT_SEPARATOR)
       .append(response->getName());
 
-    // _LOG_DEBUG("onInvitationResponded: prepare reply " << wrappedName);
-
     shared_ptr<Data> wrappedData = make_shared<Data>(wrappedName);
     wrappedData->setContent(response->wireEncode());
     wrappedData->setFreshnessPeriod(time::milliseconds(1000));
@@ -485,6 +448,7 @@
   Interest interest(interestName);
   interest.setInterestLifetime(time::milliseconds(10000));
   interest.setMustBeFresh(true);
+  interest.setCanBePrefix(true);
   interest.getNonce();
   m_face.expressInterest(interest,
                          bind(&ControllerBackend::onRequestResponse, this, _1, _2),
@@ -517,5 +481,4 @@
 
 #if WAF
 #include "controller-backend.moc"
-// #include "controller-backend.cpp.moc"
 #endif
diff --git a/src/controller-backend.hpp b/src/controller-backend.hpp
index 18b1cd8..2e3aa9f 100644
--- a/src/controller-backend.hpp
+++ b/src/controller-backend.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *
  * BSD license, See the LICENSE file for more information
  *
@@ -57,12 +57,6 @@
   getInvitationRoutingPrefix();
 
   void
-  onInvitationPrefixReset();
-
-  void
-  onInvitationPrefixResetFailed(const std::string& failInfo);
-
-  void
   onInvitationInterest(const ndn::Name& prefix, const ndn::Interest& interest,
                        size_t routingPrefixOffset);
 
@@ -170,8 +164,8 @@
   ndn::security::ValidatorNull m_nullValidator;
 
   // RegisteredPrefixId
-  shared_ptr<ndn::RegisteredPrefixHandle> m_invitationListenerId;
-  shared_ptr<ndn::RegisteredPrefixHandle> m_requestListenerId;
+  ndn::ScopedRegisteredPrefixHandle m_invitationListenerHandle;
+  ndn::ScopedRegisteredPrefixHandle m_requestListenerHandle;
 
   // ChatRoomList
   QStringList m_chatDialogList;
diff --git a/src/controller.cpp b/src/controller.cpp
index d41b65d..b8b2c97 100644
--- a/src/controller.cpp
+++ b/src/controller.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *                     Yingdi Yu
  *
  * BSD license, See the LICENSE file for more information
@@ -9,23 +9,18 @@
  *         Qiuhan Ding <qiuhanding@cs.ucla.edu>
  */
 
+#include "controller.hpp"
+#include "cryptopp.hpp"
+#include "conf.hpp"
+#include "endorse-info.hpp"
+
 #include <QApplication>
 #include <QMessageBox>
 #include <QDir>
 #include <QTimer>
-#include "controller.hpp"
 
-#ifndef Q_MOC_RUN
 #include <boost/filesystem.hpp>
-#include <boost/lexical_cast.hpp>
 #include <ndn-cxx/util/random.hpp>
-#include "cryptopp.hpp"
-#include "logging.h"
-#include "conf.hpp"
-#include "endorse-info.hpp"
-#endif
-
-INIT_LOGGER("chronochat.Controller");
 
 Q_DECLARE_METATYPE(ndn::Name)
 Q_DECLARE_METATYPE(ndn::security::Certificate)
@@ -286,9 +281,6 @@
   m_db.setDatabaseName(path);
 
   m_db.open();
-
-  // bool ok = m_db.open();
-  // _LOG_DEBUG("DB opened: " << std::boolalpha << ok );
 }
 
 void
@@ -322,12 +314,12 @@
     else
       m_nick = m_identity.get(-1).toUri();
   }
-  catch (tlv::Error&) {
+  catch (const tlv::Error&) {
     try {
       ndn::KeyChain keyChain;
       m_identity = keyChain.getPib().getDefaultIdentity().getName();
     }
-    catch (ndn::security::pib::Pib::Error&) {
+    catch (const ndn::security::pib::Pib::Error&) {
       m_identity.clear();
       m_identity.append("chronochat-tmp-identity")
                 .append(getRandomString());
@@ -553,7 +545,6 @@
 Controller::onIdentityUpdatedContinued()
 {
   QString connection = m_db.connectionName();
-  // _LOG_DEBUG("connection name: " << connection.toStdString());
   QSqlDatabase::removeDatabase(connection);
   m_db.close();
 
@@ -839,5 +830,4 @@
 
 #if WAF
 #include "controller.moc"
-// #include "controller.cpp.moc"
 #endif
diff --git a/src/digest-tree-scene.cpp b/src/digest-tree-scene.cpp
index 55d9a36..093b33d 100644
--- a/src/digest-tree-scene.cpp
+++ b/src/digest-tree-scene.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *                     Yingdi Yu
  *
  * BSD license, See the LICENSE file for more information
@@ -165,7 +165,7 @@
 }
 
 void
-DigestTreeScene::plotEdge(const std::vector<TreeLayout::Coordinate> &childNodesCo, int nodeSize)
+DigestTreeScene::plotEdge(const std::vector<TreeLayout::Coordinate>& childNodesCo, int nodeSize)
 {
   int n = childNodesCo.size();
   for (int i = 0; i < n; i++) {
@@ -275,5 +275,4 @@
 
 #if WAF
 #include "digest-tree-scene.moc"
-// #include "digest-tree-scene.cpp.moc"
 #endif
diff --git a/src/digest-tree-scene.hpp b/src/digest-tree-scene.hpp
index 562feeb..57d6387 100644
--- a/src/digest-tree-scene.hpp
+++ b/src/digest-tree-scene.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *                     Yingdi Yu
  *
  * BSD license, See the LICENSE file for more information
diff --git a/src/discovery-panel.cpp b/src/discovery-panel.cpp
index 06c7cf7..4c5dcf7 100644
--- a/src/discovery-panel.cpp
+++ b/src/discovery-panel.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *
  * BSD license, See the LICENSE file for more information
  *
@@ -105,7 +105,7 @@
   ui->NameData->setText(QString::fromStdString(info.getName().toUri()));
   ui->NameSpaceData->setText(QString::fromStdString(info.getSyncPrefix().toUri()));
 
-  switch(info.getTrustModel()) {
+  switch (info.getTrustModel()) {
   case 2:
     {
       ui->TrustModelData->setText(QString("Hierarchical"));
@@ -162,8 +162,8 @@
 
 // private slots
 void
-DiscoveryPanel::onSelectedChatroomChanged(const QItemSelection &selected,
-                                          const QItemSelection &deselected)
+DiscoveryPanel::onSelectedChatroomChanged(const QItemSelection& selected,
+                                          const QItemSelection& deselected)
 {
   QModelIndexList items = selected.indexes();
   QString chatroomName = m_chatroomListModel->data(items.first(), Qt::DisplayRole).toString();
@@ -187,8 +187,8 @@
 }
 
 void
-DiscoveryPanel::onSelectedParticipantChanged(const QItemSelection &selected,
-                                             const QItemSelection &deselected)
+DiscoveryPanel::onSelectedParticipantChanged(const QItemSelection& selected,
+                                             const QItemSelection& deselected)
 {
   if (m_isParticipant)
     return;
@@ -231,5 +231,4 @@
 
 #if WAF
 #include "discovery-panel.moc"
-// #include "discovery-panel.cpp.moc"
 #endif
diff --git a/src/discovery-panel.hpp b/src/discovery-panel.hpp
index 473283f..59c07b8 100644
--- a/src/discovery-panel.hpp
+++ b/src/discovery-panel.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *
  * BSD license, See the LICENSE file for more information
  *
@@ -21,7 +21,7 @@
 
 namespace Ui {
 class DiscoveryPanel;
-}
+} // namespace Ui
 
 namespace chronochat {
 
diff --git a/src/endorse-certificate.cpp b/src/endorse-certificate.cpp
index f9286c6..42b1cb1 100644
--- a/src/endorse-certificate.cpp
+++ b/src/endorse-certificate.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *                     Yingdi Yu
  *
  * BSD license, See the LICENSE file for more information
@@ -10,12 +10,12 @@
  */
 
 #include "endorse-certificate.hpp"
+#include "endorse-extension.hpp"
+
 #include <boost/iostreams/stream.hpp>
 #include <ndn-cxx/encoding/buffer-stream.hpp>
 #include <ndn-cxx/security/additional-description.hpp>
 #include <ndn-cxx/security/validity-period.hpp>
-#include "endorse-extension.hpp"
-#include <list>
 
 namespace chronochat {
 
@@ -81,7 +81,7 @@
 
   try {
     signatureInfo.setValidityPeriod(kskCertificate.getValidityPeriod());
-  } catch (tlv::Error&) {
+  } catch (const tlv::Error&) {
     signatureInfo.setValidityPeriod(ndn::security::ValidityPeriod(
       time::system_clock::now(), time::system_clock::now() + time::days(3650)));
   }
@@ -121,7 +121,7 @@
 
   try {
     signatureInfo.setValidityPeriod(endorseCertificate.getValidityPeriod());
-  } catch (tlv::Error&) {
+  } catch (const tlv::Error&) {
     signatureInfo.setValidityPeriod(ndn::security::ValidityPeriod(
       time::system_clock::now(), time::system_clock::now() + time::days(3650)));
   }
diff --git a/src/endorse-certificate.hpp b/src/endorse-certificate.hpp
index defc8a8..62bbb5a 100644
--- a/src/endorse-certificate.hpp
+++ b/src/endorse-certificate.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *                     Yingdi Yu
  *
  * BSD license, See the LICENSE file for more information
diff --git a/src/endorse-collection.cpp b/src/endorse-collection.cpp
index 9b937a7..a4c6a44 100644
--- a/src/endorse-collection.cpp
+++ b/src/endorse-collection.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *
  * BSD license, See the LICENSE file for more information
  *
@@ -86,13 +86,13 @@
   m_entries.clear();
 
   if (m_wire.type() != tlv::EndorseCollection)
-    throw Error("Unexpected TLV number when decoding endorse collection packet");
+    NDN_THROW(Error("Unexpected TLV number when decoding endorse collection packet"));
 
   Block::element_const_iterator i = m_wire.elements_begin();
   if (i == m_wire.elements_end())
-    throw Error("Missing Endorse Collection Entry");
+    NDN_THROW(Error("Missing Endorse Collection Entry"));
   if (i->type() != tlv::EndorseCollectionEntry)
-    throw Error("Expect Endorse Collection Entry but get TLV Type " + std::to_string(i->type()));
+    NDN_THROW(Error("Expect Endorse Collection Entry but get TLV Type " + std::to_string(i->type())));
 
   while (i != m_wire.elements_end() && i->type() == tlv::EndorseCollectionEntry) {
     CollectionEntry entry;
@@ -100,31 +100,30 @@
     temp.parse();
     Block::element_const_iterator j = temp.elements_begin();
     if (j == temp.elements_end())
-      throw Error("Missing Cert Name");
+      NDN_THROW(Error("Missing Cert Name"));
     if (j->type() != tlv::Name)
-      throw Error("Expect Cert Name but get TLV Type " + std::to_string(j->type()));
+      NDN_THROW(Error("Expect Cert Name but get TLV Type " + std::to_string(j->type())));
 
     entry.certName.wireDecode(*j);
 
     ++j;
     if (j == temp.elements_end())
-      throw Error("Missing Hash");
+      NDN_THROW(Error("Missing Hash"));
     if (j->type() != tlv::Hash)
-      throw Error("Expect Hash but get TLV Type " + std::to_string(j->type()));
+      NDN_THROW(Error("Expect Hash but get TLV Type " + std::to_string(j->type())));
 
     entry.hash = std::string(reinterpret_cast<const char* >(j->value()),
                              j->value_size());
     ++j;
-    if (j != temp.elements_end()) {
-      throw Error("Unexpected element");
-    }
+    if (j != temp.elements_end())
+      NDN_THROW(Error("Unexpected element"));
+
     m_entries.push_back(entry);
     ++i;
   }
 
-  if (i != m_wire.elements_end()) {
-      throw Error("Unexpected element");
-  }
+  if (i != m_wire.elements_end())
+      NDN_THROW(Error("Unexpected element"));
 }
 
 void
diff --git a/src/endorse-collection.hpp b/src/endorse-collection.hpp
index dd16bc3..1371839 100644
--- a/src/endorse-collection.hpp
+++ b/src/endorse-collection.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *
  * BSD license, See the LICENSE file for more information
  *
@@ -77,4 +77,4 @@
 
 } // namespace chronochat
 
-#endif //CHRONOCHAT_ENDORSE_COLLECTION_HPP
+#endif // CHRONOCHAT_ENDORSE_COLLECTION_HPP
diff --git a/src/endorse-combobox-delegate.cpp b/src/endorse-combobox-delegate.cpp
index 319135a..d753c87 100644
--- a/src/endorse-combobox-delegate.cpp
+++ b/src/endorse-combobox-delegate.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *                     Yingdi Yu
  *
  * BSD license, See the LICENSE file for more information
@@ -13,10 +13,6 @@
 #include <QComboBox>
 #include <QApplication>
 
-#ifndef Q_MOC_RUN
-#include "logging.h"
-#endif
-
 namespace chronochat {
 
 EndorseComboBoxDelegate::EndorseComboBoxDelegate(QObject* parent)
@@ -80,5 +76,4 @@
 
 #if WAF
 #include "endorse-combobox-delegate.moc"
-// #include "endorse-combobox-delegate.cpp.moc"
 #endif
diff --git a/src/endorse-combobox-delegate.hpp b/src/endorse-combobox-delegate.hpp
index 0611461..16ee85a 100644
--- a/src/endorse-combobox-delegate.hpp
+++ b/src/endorse-combobox-delegate.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *                     Yingdi Yu
  *
  * BSD license, See the LICENSE file for more information
diff --git a/src/endorse-extension.cpp b/src/endorse-extension.cpp
index 0c9f6c4..37b82d6 100644
--- a/src/endorse-extension.cpp
+++ b/src/endorse-extension.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *
  * BSD license, See the LICENSE file for more information
  *
@@ -79,14 +79,14 @@
   //
 
   if (m_wire.type() != tlv::EndorseExtension)
-    throw Error("Unexpected TLV number when decoding endorse extension packet");
+    NDN_THROW(Error("Unexpected TLV number when decoding endorse extension packet"));
 
   // EntryData
   Block::element_const_iterator i = m_wire.elements_begin();
   if (i == m_wire.elements_end())
-    throw Error("Missing Entry Data");
+    NDN_THROW(Error("Missing Entry Data"));
   if (i->type() != tlv::EntryData)
-    throw Error("Expect Entry Data but get TLV Type " + std::to_string(i->type()));
+    NDN_THROW(Error("Expect Entry Data but get TLV Type " + std::to_string(i->type())));
 
    while (i != m_wire.elements_end() && i->type() == tlv::EntryData) {
      m_entries.push_back(std::string(reinterpret_cast<const char* >(i->value()),
@@ -94,9 +94,8 @@
      ++i;
   }
 
-  if (i != m_wire.elements_end()) {
-    throw Error("Unexpected element");
-  }
+  if (i != m_wire.elements_end())
+    NDN_THROW(Error("Unexpected element"));
 }
 
 void
diff --git a/src/endorse-extension.hpp b/src/endorse-extension.hpp
index c8bd11e..56827e0 100644
--- a/src/endorse-extension.hpp
+++ b/src/endorse-extension.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *
  * BSD license, See the LICENSE file for more information
  *
@@ -75,4 +75,4 @@
 
 } // namespace chronochat
 
-#endif //CHRONOCHAT_ENDORSE_EXTENSION_HPP
+#endif // CHRONOCHAT_ENDORSE_EXTENSION_HPP
diff --git a/src/endorse-info.cpp b/src/endorse-info.cpp
index 1aa9385..7efdfce 100644
--- a/src/endorse-info.cpp
+++ b/src/endorse-info.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *
  * BSD license, See the LICENSE file for more information
  *
@@ -101,14 +101,14 @@
   m_endorsements.clear();
 
   if (m_wire.type() != tlv::EndorseInfo)
-    throw Error("Unexpected TLV number when decoding endorse info packet");
+    NDN_THROW(Error("Unexpected TLV number when decoding endorse info packet"));
 
   // Endorsement
   Block::element_const_iterator i = m_wire.elements_begin();
   if (i == m_wire.elements_end())
-    throw Error("Missing Endorsement");
+    NDN_THROW(Error("Missing Endorsement"));
   if (i->type() != tlv::Endorsement)
-    throw Error("Expect Endorsement but get TLV Type " + std::to_string(i->type()));
+    NDN_THROW(Error("Expect Endorsement but get TLV Type " + std::to_string(i->type())));
 
   while (i != m_wire.elements_end() && i->type() == tlv::Endorsement) {
     Endorsement endorsement;
@@ -118,9 +118,9 @@
 
     // Endorse Type
     if (j == temp.elements_end())
-      throw Error("Missing Endorse Type");
+      NDN_THROW(Error("Missing Endorse Type"));
     if (j->type() != tlv::EndorseType)
-      throw Error("Expect Endorse Type but get TLV Type " + std::to_string(j->type()));
+      NDN_THROW(Error("Expect Endorse Type but get TLV Type " + std::to_string(j->type())));
 
     endorsement.type = std::string(reinterpret_cast<const char* >(j->value()),
                                    j->value_size());;
@@ -128,9 +128,9 @@
 
     // Endorse Value
     if (j == temp.elements_end())
-      throw Error("Missing Endorse Value");
+      NDN_THROW(Error("Missing Endorse Value"));
     if (j->type() != tlv::EndorseValue)
-      throw Error("Expect Endorse Value but get TLV Type " + std::to_string(j->type()));
+      NDN_THROW(Error("Expect Endorse Value but get TLV Type " + std::to_string(j->type())));
 
     endorsement.value = std::string(reinterpret_cast<const char* >(j->value()),
                                     j->value_size());
@@ -138,23 +138,22 @@
 
     // Endorse Count
     if (j == temp.elements_end())
-      throw Error("Missing Endorse Count");
+      NDN_THROW(Error("Missing Endorse Count"));
     if (j->type() != tlv::EndorseCount)
-      throw Error("Expect Endorse Count but get TLV Type " + std::to_string(j->type()));
+      NDN_THROW(Error("Expect Endorse Count but get TLV Type " + std::to_string(j->type())));
 
     endorsement.count = std::string(reinterpret_cast<const char* >(j->value()),
                                     j->value_size());
     ++j;
-    if (j != temp.elements_end()) {
-      throw Error("Unexpected element");
-    }
+    if (j != temp.elements_end())
+      NDN_THROW(Error("Unexpected element"));
+
     m_endorsements.push_back(endorsement);
     ++i;
   }
 
-  if (i != m_wire.elements_end()) {
-      throw Error("Unexpected element");
-  }
+  if (i != m_wire.elements_end())
+      NDN_THROW(Error("Unexpected element"));
 }
 
 void
diff --git a/src/endorse-info.hpp b/src/endorse-info.hpp
index a794c63..a265dd9 100644
--- a/src/endorse-info.hpp
+++ b/src/endorse-info.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *
  * BSD license, See the LICENSE file for more information
  *
@@ -33,7 +33,8 @@
     }
   };
 
-  class Endorsement {
+  class Endorsement
+  {
   public:
     std::string type;
     std::string value;
@@ -78,4 +79,4 @@
 
 } // namespace chronochat
 
-#endif //CHRONOCHAT_ENDORSE_INFO_HPP
+#endif // CHRONOCHAT_ENDORSE_INFO_HPP
diff --git a/src/invitation-dialog.cpp b/src/invitation-dialog.cpp
index aac02e0..b7a4725 100644
--- a/src/invitation-dialog.cpp
+++ b/src/invitation-dialog.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *                     Yingdi Yu
  *
  * BSD license, See the LICENSE file for more information
@@ -65,5 +65,4 @@
 
 #if WAF
 #include "invitation-dialog.moc"
-// #include "invitation-dialog.cpp.moc"
 #endif
diff --git a/src/invitation-dialog.hpp b/src/invitation-dialog.hpp
index 030cec8..8a0f2ee 100644
--- a/src/invitation-dialog.hpp
+++ b/src/invitation-dialog.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *                     Yingdi Yu
  *
  * BSD license, See the LICENSE file for more information
@@ -11,15 +11,12 @@
 #ifndef CHRONOCHAT_INVITATION_DIALOG_HPP
 #define CHRONOCHAT_INVITATION_DIALOG_HPP
 
-#include <QDialog>
-
-#ifndef Q_MOC_RUN
 #include "common.hpp"
-#endif
+#include <QDialog>
 
 namespace Ui {
 class InvitationDialog;
-}
+} // namespace Ui
 
 namespace chronochat {
 
diff --git a/src/invitation-request-dialog.cpp b/src/invitation-request-dialog.cpp
index 47b63f1..15a6726 100644
--- a/src/invitation-request-dialog.cpp
+++ b/src/invitation-request-dialog.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *
  * BSD license, See the LICENSE file for more information
  *
@@ -67,5 +67,4 @@
 
 #if WAF
 #include "invitation-request-dialog.moc"
-// #include "invitation-request-dialog.cpp.moc"
 #endif
diff --git a/src/invitation-request-dialog.hpp b/src/invitation-request-dialog.hpp
index c15fce2..6441b4b 100644
--- a/src/invitation-request-dialog.hpp
+++ b/src/invitation-request-dialog.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *
  * BSD license, See the LICENSE file for more information
  *
@@ -11,17 +11,14 @@
 #ifndef CHRONOCHAT_INVITATION_REQUEST_DIALOG_HPP
 #define CHRONOCHAT_INVITATION_REQUEST_DIALOG_HPP
 
-#include <QDialog>
-
-#ifndef Q_MOC_RUN
 #include "common.hpp"
-#endif
+#include <QDialog>
 
 namespace Ui {
 class InvitationRequestDialog;
-}
+} // namespace Ui
 
-namespace chronochat{
+namespace chronochat {
 
 class InvitationRequestDialog : public QDialog
 {
diff --git a/src/invitation.cpp b/src/invitation.cpp
index e7d2ac5..9af3c4d 100644
--- a/src/invitation.cpp
+++ b/src/invitation.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *                     Yingdi Yu
  *
  * BSD license, See the LICENSE file for more information
@@ -12,8 +12,6 @@
 
 #include <ndn-cxx/security/signature-sha256-with-rsa.hpp>
 
-#include "logging.h"
-
 namespace chronochat {
 
 using std::string;
@@ -35,10 +33,10 @@
   size_t nameSize = interestName.size();
 
   if (nameSize < NAME_SIZE_MIN)
-    throw Error("Wrong Invitation Name: Wrong length");
+    NDN_THROW(Error("Wrong Invitation Name: Wrong length"));
 
   if (interestName.get(CHRONOCHAT_INVITATION).toUri() != "CHRONOCHAT-INVITATION")
-    throw Error("Wrong Invitation Name: Wrong application tags");
+    NDN_THROW(Error("Wrong Invitation Name: Wrong application tags"));
 
   m_interestName = interestName.getPrefix(KEY_LOCATOR);
   m_timestamp = interestName.get(TIMESTAMP).toNumber();
diff --git a/src/invitation.hpp b/src/invitation.hpp
index c9d3731..133a3aa 100644
--- a/src/invitation.hpp
+++ b/src/invitation.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *                     Yingdi Yu
  *
  * BSD license, See the LICENSE file for more information
@@ -91,7 +91,7 @@
     return m_inviterCertificate;
   }
 
-  const uint64_t
+  uint64_t
   getTimestamp() const
   {
     return m_timestamp;
diff --git a/src/invite-list-dialog.cpp b/src/invite-list-dialog.cpp
index 435e2f6..23af0c9 100644
--- a/src/invite-list-dialog.cpp
+++ b/src/invite-list-dialog.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *                     Yingdi Yu
  *
  * BSD license, See the LICENSE file for more information
@@ -82,5 +82,4 @@
 
 #if WAF
 #include "invite-list-dialog.moc"
-// #include "invite-list-dialog.cpp.moc"
 #endif
diff --git a/src/invite-list-dialog.hpp b/src/invite-list-dialog.hpp
index e5e8fd3..ee2561c 100644
--- a/src/invite-list-dialog.hpp
+++ b/src/invite-list-dialog.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *                     Yingdi Yu
  *
  * BSD license, See the LICENSE file for more information
@@ -14,12 +14,9 @@
 #include <QDialog>
 #include <QStringListModel>
 
-#ifndef Q_MOC_RUN
-#endif
-
 namespace Ui {
 class InviteListDialog;
-}
+} // namespace Ui
 
 namespace chronochat {
 
diff --git a/src/main.cpp b/src/main.cpp
index 90f1d9d..039fa42 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *                     Yingdi Yu
  *
  * BSD license, See the LICENSE file for more information
@@ -8,10 +8,11 @@
  * Author: Yingdi Yu <yingdi@cs.ucla.edu>
  */
 
+#include "controller.hpp"
+
 #include <QApplication>
 #include <QTextCodec>
 
-#include "controller.hpp"
 #include <iostream>
 #include <ndn-cxx/face.hpp>
 #include <boost/thread/thread.hpp>
@@ -28,9 +29,9 @@
   notify(QObject* receiver, QEvent* event)
   {
     try {
-        return QApplication::notify(receiver, event);
+      return QApplication::notify(receiver, event);
     }
-    catch (std::exception& e) {
+    catch (const std::exception& e) {
       std::cerr << "Exception thrown:" << e.what() << std::endl;
       return false;
     }
diff --git a/src/nfd-connection-checker.cpp b/src/nfd-connection-checker.cpp
index eda7197..e349b92 100644
--- a/src/nfd-connection-checker.cpp
+++ b/src/nfd-connection-checker.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *
  * BSD license, See the LICENSE file for more information
  *
@@ -9,10 +9,6 @@
 
 #include "nfd-connection-checker.hpp"
 
-#ifndef Q_MOC_RUN
-
-#endif
-
 namespace chronochat {
 
 static const int CONNECTION_RETRY_TIMER = 2;
@@ -38,7 +34,9 @@
       m_nfdConnected = true;
     }
     try {
-      m_face->expressInterest(Interest("/localhost/nfd/status"),
+      Interest interest("/localhost/nfd/status");
+      interest.setCanBePrefix(true);
+      m_face->expressInterest(interest,
                               [&] (const Interest& interest, const Data& data) {
                                 m_face->shutdown();
                               },
@@ -46,7 +44,7 @@
                               [] (const Interest& interest) {});
       m_face->processEvents(time::milliseconds::zero(), true);
     }
-    catch (std::runtime_error& e) {
+    catch (const std::runtime_error& e) {
       {
         std::lock_guard<std::mutex>lock(m_nfdMutex);
         m_nfdConnected = false;
@@ -73,5 +71,4 @@
 
 #if WAF
 #include "nfd-connection-checker.moc"
-// #include "nfd-connection-checker.cpp.moc"
 #endif
diff --git a/src/nfd-connection-checker.hpp b/src/nfd-connection-checker.hpp
index 08b6085..75784f7 100644
--- a/src/nfd-connection-checker.hpp
+++ b/src/nfd-connection-checker.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *
  * BSD license, See the LICENSE file for more information
  *
@@ -10,14 +10,12 @@
 #ifndef CHRONOCHAT_NFD_CONNECTION_CHECKER_HPP
 #define CHRONOCHAT_NFD_CONNECTION_CHECKER_HPP
 
-#include <QThread>
-
-#ifndef Q_MOC_RUN
 #include "common.hpp"
+
+#include <QThread>
 #include <mutex>
 #include <boost/thread.hpp>
 #include <ndn-cxx/face.hpp>
-#endif
 
 namespace chronochat {
 
diff --git a/src/profile-editor.cpp b/src/profile-editor.cpp
index f0b067d..fbfe105 100644
--- a/src/profile-editor.cpp
+++ b/src/profile-editor.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *                     Yingdi Yu
  *
  * BSD license, See the LICENSE file for more information
@@ -14,12 +14,6 @@
 #include <QtSql/QSqlField>
 #include <QtSql/QSqlError>
 
-#ifndef Q_MOC_RUN
-#include "logging.h"
-#endif
-
-// INIT_LOGGER("ProfileEditor")
-
 namespace chronochat {
 
 ProfileEditor::ProfileEditor(QWidget *parent)
@@ -40,9 +34,7 @@
 ProfileEditor::~ProfileEditor()
 {
     delete ui;
-
-    if (m_tableModel)
-      delete m_tableModel;
+    delete m_tableModel;
 }
 
 void
@@ -109,5 +101,4 @@
 
 #if WAF
 #include "profile-editor.moc"
-// #include "profile-editor.cpp.moc"
 #endif
diff --git a/src/profile-editor.hpp b/src/profile-editor.hpp
index a18f8fc..01d5f57 100644
--- a/src/profile-editor.hpp
+++ b/src/profile-editor.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *                     Yingdi Yu
  *
  * BSD license, See the LICENSE file for more information
@@ -14,12 +14,9 @@
 #include <QDialog>
 #include <QtSql/QSqlTableModel>
 
-#ifndef Q_MOC_RUN
-#endif
-
 namespace Ui {
 class ProfileEditor;
-}
+} // namespace Ui
 
 namespace chronochat {
 
@@ -58,7 +55,7 @@
 
 private:
   Ui::ProfileEditor* ui;
-  QSqlTableModel* m_tableModel;
+  QSqlTableModel* m_tableModel = 0;
   QString m_identity;
 };
 
diff --git a/src/profile.cpp b/src/profile.cpp
index dc89fa9..06cb1e5 100644
--- a/src/profile.cpp
+++ b/src/profile.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *                     Yingdi Yu
  *
  * BSD license, See the LICENSE file for more information
@@ -10,7 +10,6 @@
  */
 
 #include "profile.hpp"
-#include "logging.h"
 #include <ndn-cxx/security/additional-description.hpp>
 
 namespace chronochat {
@@ -149,45 +148,43 @@
   m_wire.parse();
 
   if (m_wire.type() != tlv::Profile)
-    throw Error("Unexpected TLV number when decoding profile packet");
+    NDN_THROW(Error("Unexpected TLV number when decoding profile packet"));
 
   Block::element_const_iterator i = m_wire.elements_begin();
   if (i == m_wire.elements_end())
-    throw Error("Missing Profile Entry");
+    NDN_THROW(Error("Missing Profile Entry"));
   if (i->type() != tlv::ProfileEntry)
-    throw Error("Expect Profile Entry but get TLV Type " + std::to_string(i->type()));
+    NDN_THROW(Error("Expect Profile Entry but get TLV Type " + std::to_string(i->type())));
 
   while (i != m_wire.elements_end() && i->type() == tlv::ProfileEntry) {
     Block temp = *i;
     temp.parse();
     Block::element_const_iterator j = temp.elements_begin();
     if (j == temp.elements_end())
-      throw Error("Missing Oid");
+      NDN_THROW(Error("Missing Oid"));
     if (j->type() != tlv::Oid)
-      throw Error("Expect Oid but get TLV Type" + std::to_string(j->type()));
+      NDN_THROW(Error("Expect Oid but get TLV Type" + std::to_string(j->type())));
 
     string Oid = std::string(reinterpret_cast<const char* >(j->value()),
                              j->value_size());
     ++j;
     if (j == temp.elements_end())
-      throw Error("Missing EntryData");
+      NDN_THROW(Error("Missing EntryData"));
     if (j->type() != tlv::EntryData)
-      throw Error("Expect EntryData but get TLV Type " + std::to_string(j->type()));
+      NDN_THROW(Error("Expect EntryData but get TLV Type " + std::to_string(j->type())));
 
     string EntryData = std::string(reinterpret_cast<const char* >(j->value()),
                                    j->value_size());
     ++j;
-    if (j != temp.elements_end()) {
-      throw Error("Unexpected element");
-    }
+    if (j != temp.elements_end())
+      NDN_THROW(Error("Unexpected element"));
+
     m_entries[Oid] = EntryData;
     ++i;
   }
 
-  if (i != m_wire.elements_end()) {
-      throw Error("Unexpected element");
-  }
-
+  if (i != m_wire.elements_end())
+      NDN_THROW(Error("Unexpected element"));
 }
 
 bool
diff --git a/src/profile.hpp b/src/profile.hpp
index 43dba96..6692127 100644
--- a/src/profile.hpp
+++ b/src/profile.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *                     Yingdi Yu
  *
  * BSD license, See the LICENSE file for more information
@@ -40,9 +40,7 @@
   typedef std::map<std::string, std::string>::iterator iterator;
   typedef std::map<std::string, std::string>::const_iterator const_iterator;
 
-  Profile()
-  {
-  }
+  Profile() = default;
 
   Profile(const ndn::security::Certificate& identityCertificate);
 
@@ -56,9 +54,8 @@
 
   Profile(const Block& profileWire);
 
-  ~Profile()
-  {
-  }
+  Profile&
+  operator=(const Profile&) = default;
 
   const Block&
   wireEncode() const;
diff --git a/src/set-alias-dialog.cpp b/src/set-alias-dialog.cpp
index ae75a2b..d241e58 100644
--- a/src/set-alias-dialog.cpp
+++ b/src/set-alias-dialog.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *                     Yingdi Yu
  *
  * BSD license, See the LICENSE file for more information
@@ -56,5 +56,4 @@
 
 #if WAF
 #include "set-alias-dialog.moc"
-// #include "set-alias-dialog.cpp.moc"
 #endif
diff --git a/src/set-alias-dialog.hpp b/src/set-alias-dialog.hpp
index 7ae2438..e044bab 100644
--- a/src/set-alias-dialog.hpp
+++ b/src/set-alias-dialog.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *                     Yingdi Yu
  *
  * BSD license, See the LICENSE file for more information
@@ -19,7 +19,7 @@
 
 namespace Ui {
 class SetAliasDialog;
-}
+} // namespace Ui
 
 namespace chronochat {
 
diff --git a/src/setting-dialog.cpp b/src/setting-dialog.cpp
index 9f38cac..18dd460 100644
--- a/src/setting-dialog.cpp
+++ b/src/setting-dialog.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *                     Yingdi Yu
  *
  * BSD license, See the LICENSE file for more information
@@ -85,5 +85,4 @@
 
 #if WAF
 #include "setting-dialog.moc"
-// #include "setting-dialog.cpp.moc"
 #endif
diff --git a/src/setting-dialog.hpp b/src/setting-dialog.hpp
index a8cef6c..5b6ad11 100644
--- a/src/setting-dialog.hpp
+++ b/src/setting-dialog.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *                     Yingdi Yu
  *
  * BSD license, See the LICENSE file for more information
@@ -13,12 +13,9 @@
 
 #include <QDialog>
 
-#ifndef Q_MOC_RUN
-#endif
-
 namespace Ui {
 class SettingDialog;
-}
+} // namespace Ui
 
 namespace chronochat {
 
diff --git a/src/start-chat-dialog.cpp b/src/start-chat-dialog.cpp
index d3949e5..160275f 100644
--- a/src/start-chat-dialog.cpp
+++ b/src/start-chat-dialog.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *                     Yingdi Yu
  *
  * BSD license, See the LICENSE file for more information
@@ -56,5 +56,4 @@
 
 #if WAF
 #include "start-chat-dialog.moc"
-// #include "start-chat-dialog.cpp.moc"
 #endif
diff --git a/src/start-chat-dialog.hpp b/src/start-chat-dialog.hpp
index d0439d7..7af4994 100644
--- a/src/start-chat-dialog.hpp
+++ b/src/start-chat-dialog.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *                     Yingdi Yu
  *
  * BSD license, See the LICENSE file for more information
@@ -19,7 +19,7 @@
 
 namespace Ui {
 class StartChatDialog;
-}
+} // namespace Ui
 
 namespace chronochat {
 
diff --git a/src/tree-layout.cpp b/src/tree-layout.cpp
index 9bf3627..6df61ad 100644
--- a/src/tree-layout.cpp
+++ b/src/tree-layout.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *                     Yingdi Yu
  *
  * BSD license, See the LICENSE file for more information
diff --git a/src/tree-layout.hpp b/src/tree-layout.hpp
index 514b1ed..b180b83 100644
--- a/src/tree-layout.hpp
+++ b/src/tree-layout.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *                     Yingdi Yu
  *
  * BSD license, See the LICENSE file for more information
diff --git a/src/trust-tree-node.hpp b/src/trust-tree-node.hpp
index dc38894..cb275b2 100644
--- a/src/trust-tree-node.hpp
+++ b/src/trust-tree-node.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *                     Yingdi Yu
  *
  * BSD license, See the LICENSE file for more information
diff --git a/src/trust-tree-scene.cpp b/src/trust-tree-scene.cpp
index 3a23718..58e9861 100644
--- a/src/trust-tree-scene.cpp
+++ b/src/trust-tree-scene.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *                     Yingdi Yu
  *
  * BSD license, See the LICENSE file for more information
@@ -104,9 +104,8 @@
   }
 }
 
-} //namespace chronochat
+} // namespace chronochat
 
 #if WAF
 #include "trust-tree-scene.moc"
-// #include "trust-tree-scene.cpp.moc"
 #endif
diff --git a/src/trust-tree-scene.hpp b/src/trust-tree-scene.hpp
index 0412914..1d4d0e1 100644
--- a/src/trust-tree-scene.hpp
+++ b/src/trust-tree-scene.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *                     Yingdi Yu
  *
  * BSD license, See the LICENSE file for more information
@@ -11,15 +11,15 @@
 #ifndef CHRONOCHAT_TRUST_TREE_SCENE_HPP
 #define CHRONOCHAT_TRUST_TREE_SCENE_HPP
 
-#include <QGraphicsScene>
-#include <QColor>
-#include <QMap>
-
 #ifndef Q_MOC_RUN
 #include "trust-tree-node.hpp"
 #include "tree-layout.hpp"
 #endif
 
+#include <QGraphicsScene>
+#include <QColor>
+#include <QMap>
+
 class QGraphicsTextItem;
 
 namespace chronochat {
diff --git a/test/chat-message.t.cpp b/test/chat-message.t.cpp
index 09ab127..848dfde 100644
--- a/test/chat-message.t.cpp
+++ b/test/chat-message.t.cpp
@@ -1,19 +1,19 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *
  * BSD license, See the LICENSE file for more information
  *
  * Author: Qiuhan Ding <qiuhanding@cs.ucla.edu>
  */
 
-#include <boost/test/unit_test.hpp>
-
 #include "chat-message.hpp"
+
+#include <boost/test/unit_test.hpp>
 #include <ndn-cxx/encoding/buffer-stream.hpp>
 
-namespace chronochat{
-namespace tests{
+namespace chronochat {
+namespace tests {
 
 using std::string;
 
diff --git a/test/chatroom-info.t.cpp b/test/chatroom-info.t.cpp
index f138172..af223d4 100644
--- a/test/chatroom-info.t.cpp
+++ b/test/chatroom-info.t.cpp
@@ -1,3 +1,10 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2020, Regents of the University of California
+ *
+ * BSD license, See the LICENSE file for more information
+ */
+
 #include "chatroom-info.hpp"
 #include <boost/test/unit_test.hpp>
 #include <ndn-cxx/encoding/block.hpp>
diff --git a/test/conf.t.cpp b/test/conf.t.cpp
index 9af3e5d..fabbcfc 100644
--- a/test/conf.t.cpp
+++ b/test/conf.t.cpp
@@ -1,18 +1,18 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *
  * BSD license, See the LICENSE file for more information
  *
  * Author: Qiuhan Ding <qiuhanding@cs.ucla.edu>
  */
 
-#include <boost/test/unit_test.hpp>
-
 #include "conf.hpp"
+
+#include <boost/test/unit_test.hpp>
 #include <ndn-cxx/encoding/buffer-stream.hpp>
 
-namespace chronochat{
+namespace chronochat {
 namespace tests {
 
 using std::string;
diff --git a/test/contact-storage.t.cpp b/test/contact-storage.t.cpp
index 07be3e7..a9265e6 100644
--- a/test/contact-storage.t.cpp
+++ b/test/contact-storage.t.cpp
@@ -1,14 +1,14 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /**
- * Copyright (C) 2013 Regents of the University of California.
+ * Copyright (C) 2020 Regents of the University of California.
  * @author: Yingdi Yu <yingdi@cs.ucla.edu>
  * See COPYING for copyright and distribution information.
  */
 
-#include <boost/test/unit_test.hpp>
-
 #include "contact-storage.hpp"
 #include "cryptopp.hpp"
+
+#include <boost/test/unit_test.hpp>
 #include <boost/filesystem.hpp>
 
 namespace chronochat {
diff --git a/test/endorse-certificate.t.cpp b/test/endorse-certificate.t.cpp
index baa2ecf..6fef721 100644
--- a/test/endorse-certificate.t.cpp
+++ b/test/endorse-certificate.t.cpp
@@ -1,17 +1,12 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /**
- * Copyright (C) 2013 Regents of the University of California.
+ * Copyright (C) 2020 Regents of the University of California.
  * @author: Yingdi Yu <yingdi@cs.ucla.edu>
  * See COPYING for copyright and distribution information.
  */
 
-#if __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wtautological-compare"
-#pragma clang diagnostic ignored "-Wunused-function"
-#elif __GNUC__
-#pragma GCC diagnostic ignored "-Wunused-function"
-#endif
+#include "endorse-certificate.hpp"
+#include "cryptopp.hpp"
 
 #include <boost/test/unit_test.hpp>
 #include <boost/filesystem.hpp>
@@ -20,8 +15,6 @@
 #include <ndn-cxx/encoding/buffer-stream.hpp>
 #include <ndn-cxx/util/time.hpp>
 #include <ndn-cxx/util/io.hpp>
-#include "cryptopp.hpp"
-#include "endorse-certificate.hpp"
 
 namespace chronochat {
 namespace tests {
diff --git a/test/endorse-collection.t.cpp b/test/endorse-collection.t.cpp
index 1af3f6b..8448779 100644
--- a/test/endorse-collection.t.cpp
+++ b/test/endorse-collection.t.cpp
@@ -1,18 +1,18 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *
  * BSD license, See the LICENSE file for more information
  *
  * Author: Qiuhan Ding <qiuhanding@cs.ucla.edu>
  */
 
-#include <boost/test/unit_test.hpp>
-
 #include "endorse-collection.hpp"
+
+#include <boost/test/unit_test.hpp>
 #include <ndn-cxx/encoding/buffer-stream.hpp>
 
-namespace chronochat{
+namespace chronochat {
 namespace tests {
 
 using std::string;
diff --git a/test/main.cpp b/test/main.cpp
index 6b0a14a..e418730 100644
--- a/test/main.cpp
+++ b/test/main.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2013, Regents of the University of California
+ * Copyright (c) 2020, Regents of the University of California
  *
  * BSD license, See the LICENSE file for more information
  *
@@ -9,5 +9,6 @@
 
 #define BOOST_TEST_MAIN 1
 #define BOOST_TEST_DYN_LINK 1
+#define BOOST_TEST_MODULE chronochat
 
 #include <boost/test/unit_test.hpp>
diff --git a/test/profile.t.cpp b/test/profile.t.cpp
index 3e85f38..33ebb06 100644
--- a/test/profile.t.cpp
+++ b/test/profile.t.cpp
@@ -1,13 +1,13 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /**
- * Copyright (C) 2013 Regents of the University of California.
+ * Copyright (C) 2020 Regents of the University of California.
  * @author: Yingdi Yu <yingdi@cs.ucla.edu>
  * See COPYING for copyright and distribution information.
  */
 
-#include <boost/test/unit_test.hpp>
-
 #include "profile.hpp"
+
+#include <boost/test/unit_test.hpp>
 #include <ndn-cxx/encoding/buffer-stream.hpp>
 
 namespace chronochat {
diff --git a/waf-tools/boost.py b/waf-tools/boost.py
deleted file mode 100644
index 8c36b34..0000000
--- a/waf-tools/boost.py
+++ /dev/null
@@ -1,381 +0,0 @@
-#!/usr/bin/env python
-# encoding: utf-8
-#
-# partially based on boost.py written by Gernot Vormayr
-# written by Ruediger Sonderfeld <ruediger@c-plusplus.de>, 2008
-# modified by Bjoern Michaelsen, 2008
-# modified by Luca Fossati, 2008
-# rewritten for waf 1.5.1, Thomas Nagy, 2008
-# rewritten for waf 1.6.2, Sylvain Rouquette, 2011
-
-'''
-
-This is an extra tool, not bundled with the default waf binary.
-To add the boost tool to the waf file:
-$ ./waf-light --tools=compat15,boost
-	or, if you have waf >= 1.6.2
-$ ./waf update --files=boost
-
-When using this tool, the wscript will look like:
-
-	def options(opt):
-		opt.load('compiler_cxx boost')
-
-	def configure(conf):
-		conf.load('compiler_cxx boost')
-		conf.check_boost(lib='system filesystem')
-
-	def build(bld):
-		bld(source='main.cpp', target='app', use='BOOST')
-
-Options are generated, in order to specify the location of boost includes/libraries.
-The `check_boost` configuration function allows to specify the used boost libraries.
-It can also provide default arguments to the --boost-static and --boost-mt command-line arguments.
-Everything will be packaged together in a BOOST component that you can use.
-
-When using MSVC, a lot of compilation flags need to match your BOOST build configuration:
- - you may have to add /EHsc to your CXXFLAGS or define boost::throw_exception if BOOST_NO_EXCEPTIONS is defined.
-   Errors: C4530
- - boost libraries will try to be smart and use the (pretty but often not useful) auto-linking feature of MSVC
-   So before calling `conf.check_boost` you might want to disabling by adding:
-   	conf.env.DEFINES_BOOST += ['BOOST_ALL_NO_LIB']
-   Errors:
- - boost might also be compiled with /MT, which links the runtime statically.
-   If you have problems with redefined symbols,
-		self.env['DEFINES_%s' % var] += ['BOOST_ALL_NO_LIB']
-		self.env['CXXFLAGS_%s' % var] += ['/MD', '/EHsc']
-Passing `--boost-linkage_autodetect` might help ensuring having a correct linkage in some basic cases.
-
-'''
-
-import sys
-import re
-from waflib import Utils, Logs, Errors
-from waflib.Configure import conf
-
-BOOST_LIBS = ['/usr/lib', '/usr/local/lib', '/opt/local/lib', '/sw/lib', '/lib',
-              '/usr/lib/x86_64-linux-gnu', '/usr/lib/i386-linux-gnu',
-              '/usr/local/ndn/lib', '/opt/ndn/lib']
-BOOST_INCLUDES = ['/usr/include', '/usr/local/include', '/opt/local/include', '/sw/include',
-                  '/usr/local/ndn/include', '/opt/ndn/include']
-BOOST_VERSION_FILE = 'boost/version.hpp'
-BOOST_VERSION_CODE = '''
-#include <iostream>
-#include <boost/version.hpp>
-int main() { std::cout << BOOST_LIB_VERSION << ":" << BOOST_VERSION << std::endl; }
-'''
-BOOST_SYSTEM_CODE = '''
-#include <boost/system/error_code.hpp>
-int main() { boost::system::error_code c; }
-'''
-BOOST_THREAD_CODE = '''
-#include <boost/thread.hpp>
-int main() { boost::thread t; }
-'''
-
-# toolsets from {boost_dir}/tools/build/v2/tools/common.jam
-PLATFORM = Utils.unversioned_sys_platform()
-detect_intel = lambda env: (PLATFORM == 'win32') and 'iw' or 'il'
-detect_clang = lambda env: (PLATFORM == 'darwin') and 'clang-darwin' or 'clang'
-detect_mingw = lambda env: (re.search('MinGW', env.CXX[0])) and 'mgw' or 'gcc'
-BOOST_TOOLSETS = {
-	'borland':  'bcb',
-	'clang':	detect_clang,
-	'como':	 'como',
-	'cw':	   'cw',
-	'darwin':   'xgcc',
-	'edg':	  'edg',
-	'g++':	  detect_mingw,
-	'gcc':	  detect_mingw,
-	'icpc':	 detect_intel,
-	'intel':	detect_intel,
-	'kcc':	  'kcc',
-	'kylix':	'bck',
-	'mipspro':  'mp',
-	'mingw':	'mgw',
-	'msvc':	 'vc',
-	'qcc':	  'qcc',
-	'sun':	  'sw',
-	'sunc++':   'sw',
-	'tru64cxx': 'tru',
-	'vacpp':	'xlc'
-}
-
-
-def options(opt):
-	opt = opt.add_option_group('Boost Options')
-
-	opt.add_option('--boost-includes', type='string',
-				   default='', dest='boost_includes',
-				   help='''path to the directory where the boost includes are, e.g., /path/to/boost_1_55_0/stage/include''')
-	opt.add_option('--boost-libs', type='string',
-				   default='', dest='boost_libs',
-				   help='''path to the directory where the boost libs are, e.g., /path/to/boost_1_55_0/stage/lib''')
-	opt.add_option('--boost-static', action='store_true',
-				   default=False, dest='boost_static',
-				   help='link with static boost libraries (.lib/.a)')
-	opt.add_option('--boost-mt', action='store_true',
-				   default=False, dest='boost_mt',
-				   help='select multi-threaded libraries')
-	opt.add_option('--boost-abi', type='string', default='', dest='boost_abi',
-				   help='''select libraries with tags (dgsyp, d for debug), see doc Boost, Getting Started, chapter 6.1''')
-	opt.add_option('--boost-linkage_autodetect', action="store_true", dest='boost_linkage_autodetect',
-				   help="auto-detect boost linkage options (don't get used to it / might break other stuff)")
-	opt.add_option('--boost-toolset', type='string',
-				   default='', dest='boost_toolset',
-				   help='force a toolset e.g. msvc, vc90, gcc, mingw, mgw45 (default: auto)')
-	py_version = '%d%d' % (sys.version_info[0], sys.version_info[1])
-	opt.add_option('--boost-python', type='string',
-				   default=py_version, dest='boost_python',
-				   help='select the lib python with this version (default: %s)' % py_version)
-
-
-@conf
-def __boost_get_version_file(self, d):
-	dnode = self.root.find_dir(d)
-	if dnode:
-		return dnode.find_node(BOOST_VERSION_FILE)
-	return None
-
-@conf
-def boost_get_version(self, d):
-	"""silently retrieve the boost version number"""
-	node = self.__boost_get_version_file(d)
-	if node:
-		try:
-			txt = node.read()
-		except (OSError, IOError):
-			Logs.error("Could not read the file %r" % node.abspath())
-		else:
-			re_but1 = re.compile('^#define\\s+BOOST_LIB_VERSION\\s+"(.*)"', re.M)
-			m1 = re_but1.search(txt)
-
-			re_but2 = re.compile('^#define\\s+BOOST_VERSION\\s+(\\d*)', re.M)
-			m2 = re_but2.search(txt)
-
-			if m1 and m2:
-				return (m1.group(1), m2.group(1))
-
-	return self.check_cxx(fragment=BOOST_VERSION_CODE, includes=[d], execute=True, define_ret=True).split(":")
-
-@conf
-def boost_get_includes(self, *k, **kw):
-	includes = k and k[0] or kw.get('includes', None)
-	if includes and self.__boost_get_version_file(includes):
-		return includes
-	for d in Utils.to_list(self.environ.get('INCLUDE', '')) + BOOST_INCLUDES:
-		if self.__boost_get_version_file(d):
-			return d
-	if includes:
-		self.end_msg('headers not found in %s' % includes)
-		self.fatal('The configuration failed')
-	else:
-		self.end_msg('headers not found, please provide a --boost-includes argument (see help)')
-		self.fatal('The configuration failed')
-
-
-@conf
-def boost_get_toolset(self, cc):
-	toolset = cc
-	if not cc:
-		build_platform = Utils.unversioned_sys_platform()
-		if build_platform in BOOST_TOOLSETS:
-			cc = build_platform
-		else:
-			cc = self.env.CXX_NAME
-	if cc in BOOST_TOOLSETS:
-		toolset = BOOST_TOOLSETS[cc]
-	return isinstance(toolset, str) and toolset or toolset(self.env)
-
-
-@conf
-def __boost_get_libs_path(self, *k, **kw):
-	''' return the lib path and all the files in it '''
-	if 'files' in kw:
-		return self.root.find_dir('.'), Utils.to_list(kw['files'])
-	libs = k and k[0] or kw.get('libs', None)
-	if libs:
-		path = self.root.find_dir(libs)
-		files = path.ant_glob('*boost_*')
-	if not libs or not files:
-		for d in Utils.to_list(self.environ.get('LIB', [])) + BOOST_LIBS:
-			path = self.root.find_dir(d)
-			if path:
-				files = path.ant_glob('*boost_*')
-				if files:
-					break
-			path = self.root.find_dir(d + '64')
-			if path:
-				files = path.ant_glob('*boost_*')
-				if files:
-					break
-	if not path:
-		if libs:
-			self.end_msg('libs not found in %s' % libs)
-			self.fatal('The configuration failed')
-		else:
-			self.end_msg('libs not found, please provide a --boost-libs argument (see help)')
-			self.fatal('The configuration failed')
-
-	self.to_log('Found the boost path in %r with the libraries:' % path)
-	for x in files:
-		self.to_log('    %r' % x)
-	return path, files
-
-@conf
-def boost_get_libs(self, *k, **kw):
-	'''
-	return the lib path and the required libs
-	according to the parameters
-	'''
-	path, files = self.__boost_get_libs_path(**kw)
-	t = []
-	if kw.get('mt', False):
-		t.append('mt')
-	if kw.get('abi', None):
-		t.append(kw['abi'])
-	tags = t and '(-%s)+' % '-'.join(t) or ''
-	toolset = self.boost_get_toolset(kw.get('toolset', ''))
-	toolset_pat = '(-%s[0-9]{0,3})+' % toolset
-	version = '(-%s)+' % self.env.BOOST_VERSION
-
-	def find_lib(re_lib, files):
-		for file in files:
-			if re_lib.search(file.name):
-				self.to_log('Found boost lib %s' % file)
-				return file
-		return None
-
-	def format_lib_name(name):
-		if name.startswith('lib') and self.env.CC_NAME != 'msvc':
-			name = name[3:]
-		return name[:name.rfind('.')]
-
-	libs = []
-	for lib in Utils.to_list(k and k[0] or kw.get('lib', None)):
-		py = (lib == 'python') and '(-py%s)+' % kw['python'] or ''
-		# Trying libraries, from most strict match to least one
-		for pattern in ['boost_%s%s%s%s%s' % (lib, toolset_pat, tags, py, version),
-						'boost_%s%s%s%s' % (lib, tags, py, version),
-						'boost_%s%s%s' % (lib, tags, version),
-						# Give up trying to find the right version
-						'boost_%s%s%s%s' % (lib, toolset_pat, tags, py),
-						'boost_%s%s%s' % (lib, tags, py),
-						'boost_%s%s' % (lib, tags)]:
-			self.to_log('Trying pattern %s' % pattern)
-			file = find_lib(re.compile(pattern), files)
-			if file:
-				libs.append(format_lib_name(file.name))
-				break
-		else:
-			self.end_msg('lib %s not found in %s' % (lib, path.abspath()))
-			self.fatal('The configuration failed')
-
-	return path.abspath(), libs
-
-
-@conf
-def check_boost(self, *k, **kw):
-	"""
-	Initialize boost libraries to be used.
-
-	Keywords: you can pass the same parameters as with the command line (without "--boost-").
-	Note that the command line has the priority, and should preferably be used.
-	"""
-	if not self.env['CXX']:
-		self.fatal('load a c++ compiler first, conf.load("compiler_cxx")')
-
-	params = {'lib': k and k[0] or kw.get('lib', None)}
-	for key, value in self.options.__dict__.items():
-		if not key.startswith('boost_'):
-			continue
-		key = key[len('boost_'):]
-		params[key] = value and value or kw.get(key, '')
-
-	var = kw.get('uselib_store', 'BOOST')
-
-	self.start_msg('Checking boost includes')
-	self.env['INCLUDES_%s' % var] = inc = self.boost_get_includes(**params)
-	versions = self.boost_get_version(inc)
-	self.env.BOOST_VERSION = versions[0]
-	self.env.BOOST_VERSION_NUMBER = int(versions[1])
-	self.end_msg("%d.%d.%d" % (int(versions[1]) / 100000,
-				   int(versions[1]) / 100 % 1000,
-				   int(versions[1]) % 100))
-	if Logs.verbose:
-		Logs.pprint('CYAN', '	path : %s' % self.env['INCLUDES_%s' % var])
-
-	if not params['lib']:
-		return
-	self.start_msg('Checking boost libs')
-	suffix = params.get('static', None) and 'ST' or ''
-	path, libs = self.boost_get_libs(**params)
-	self.env['%sLIBPATH_%s' % (suffix, var)] = [path]
-	self.env['%sLIB_%s' % (suffix, var)] = libs
-	self.end_msg('ok')
-	if Logs.verbose:
-		Logs.pprint('CYAN', '	path : %s' % path)
-		Logs.pprint('CYAN', '	libs : %s' % libs)
-
-
-	def try_link():
-		if 'system' in params['lib']:
-			self.check_cxx(
-			 fragment=BOOST_SYSTEM_CODE,
-			 use=var,
-			 execute=False,
-			)
-		if 'thread' in params['lib']:
-			self.check_cxx(
-			 fragment=BOOST_THREAD_CODE,
-			 use=var,
-			 execute=False,
-			)
-
-	if params.get('linkage_autodetect', False):
-		self.start_msg("Attempting to detect boost linkage flags")
-		toolset = self.boost_get_toolset(kw.get('toolset', ''))
-		if toolset in ['vc']:
-			# disable auto-linking feature, causing error LNK1181
-			# because the code wants to be linked against
-			self.env['DEFINES_%s' % var] += ['BOOST_ALL_NO_LIB']
-
-			# if no dlls are present, we guess the .lib files are not stubs
-			has_dlls = False
-			for x in Utils.listdir(path):
-				if x.endswith(self.env.cxxshlib_PATTERN % ''):
-					has_dlls = True
-					break
-			if not has_dlls:
-				self.env['STLIBPATH_%s' % var] = [path]
-				self.env['STLIB_%s' % var] = libs
-				del self.env['LIB_%s' % var]
-				del self.env['LIBPATH_%s' % var]
-
-			# we attempt to play with some known-to-work CXXFLAGS combinations
-			for cxxflags in (['/MD', '/EHsc'], []):
-				self.env.stash()
-				self.env["CXXFLAGS_%s" % var] += cxxflags
-				try:
-					try_link()
-					self.end_msg("ok: winning cxxflags combination: %s" % (self.env["CXXFLAGS_%s" % var]))
-					e = None
-					break
-				except Errors.ConfigurationError as exc:
-					self.env.revert()
-					e = exc
-
-			if e is not None:
-				self.end_msg("Could not auto-detect boost linking flags combination, you may report it to boost.py author", ex=e)
-				self.fatal('The configuration failed')
-		else:
-			self.end_msg("Boost linkage flags auto-detection not implemented (needed ?) for this toolchain")
-			self.fatal('The configuration failed')
-	else:
-		self.start_msg('Checking for boost linkage')
-		try:
-			try_link()
-		except Errors.ConfigurationError as e:
-			self.end_msg("Could not link against boost libraries using supplied options")
-			self.fatal('The configuration failed')
-		self.end_msg('ok')
diff --git a/waf-tools/default-compiler-flags.py b/waf-tools/default-compiler-flags.py
deleted file mode 100644
index c7b4c2c..0000000
--- a/waf-tools/default-compiler-flags.py
+++ /dev/null
@@ -1,72 +0,0 @@
-# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
-
-from waflib import Logs, Configure
-
-def options(opt):
-    opt.add_option('--debug', '--with-debug', action='store_true', default=False, dest='debug',
-                   help='''Compile in debugging mode without optimizations (-O0 or -Og)''')
-
-def configure(conf):
-    areCustomCxxflagsPresent = (len(conf.env.CXXFLAGS) > 0)
-    defaultFlags = ['-std=c++14',
-                    '-Wall']
-
-    if conf.options.debug:
-        conf.define('_DEBUG', 1)
-        conf.env['_DEBUG'] = 1
-        defaultFlags += ['-O0',
-                         '-Og', # gcc >= 4.8
-                         '-g3',
-                         '-fcolor-diagnostics', # clang
-                         '-fdiagnostics-color', # gcc >= 4.9
-                         '-Werror',
-                         '-Wno-unused-variable',
-                         '-Wno-error=deprecated-register',
-                         '-Wno-error=maybe-uninitialized', # Bug #1615
-                         '-Wno-error=unneeded-internal-declaration', # Bug #1588
-                        ]
-        if areCustomCxxflagsPresent:
-            missingFlags = [x for x in defaultFlags if x not in conf.env.CXXFLAGS]
-            if len(missingFlags) > 0:
-                Logs.warn("Selected debug mode, but CXXFLAGS is set to a custom value '%s'"
-                          % " ".join(conf.env.CXXFLAGS))
-                Logs.warn("Default flags '%s' are not activated" % " ".join(missingFlags))
-        else:
-            conf.add_supported_cxxflags(defaultFlags)
-    else:
-        defaultFlags += ['-O2', '-g']
-        if not areCustomCxxflagsPresent:
-            conf.add_supported_cxxflags(defaultFlags)
-
-    # clang on OSX < 10.9 by default uses gcc's libstdc++, which is not C++11 compatible
-    conf.add_supported_linkflags(['-stdlib=libc++'])
-
-@Configure.conf
-def add_supported_cxxflags(self, cxxflags):
-    """
-    Check which cxxflags are supported by compiler and add them to env.CXXFLAGS variable
-    """
-    self.start_msg('Checking supported CXXFLAGS')
-
-    supportedFlags = []
-    for flag in cxxflags:
-        if self.check_cxx(cxxflags=['-Werror', flag], mandatory=False):
-            supportedFlags += [flag]
-
-    self.end_msg(' '.join(supportedFlags))
-    self.env.CXXFLAGS = supportedFlags + self.env.CXXFLAGS
-
-@Configure.conf
-def add_supported_linkflags(self, linkflags):
-    """
-    Check which linkflags are supported by compiler and add them to env.LINKFLAGS variable
-    """
-    self.start_msg('Checking supported LINKFLAGS')
-
-    supportedFlags = []
-    for flag in linkflags:
-        if self.check_cxx(linkflags=['-Werror', flag], mandatory=False):
-            supportedFlags += [flag]
-
-    self.end_msg(' '.join(supportedFlags))
-    self.env.LINKFLAGS = supportedFlags + self.env.LINKFLAGS
diff --git a/waf-tools/ndn_cpp.py b/waf-tools/ndn_cpp.py
deleted file mode 100644
index d0432ab..0000000
--- a/waf-tools/ndn_cpp.py
+++ /dev/null
@@ -1,79 +0,0 @@
-#! /usr/bin/env python
-# encoding: utf-8
-
-'''
-
-When using this tool, the wscript will look like:
-
-	def options(opt):
-	        opt.tool_options('ndn_cpp', tooldir=["waf-tools"])
-
-	def configure(conf):
-		conf.load('compiler_cxx ndn_cpp')
-
-	def build(bld):
-		bld(source='main.cpp', target='app', use='NDNCPP')
-
-Options are generated, in order to specify the location of ndn-cpp includes/libraries.
-
-
-'''
-
-import sys
-import re
-from waflib import Utils,Logs,Errors
-from waflib.Configure import conf
-NDNCPP_DIR=['/usr/local/ndn', '/usr', '/usr/local', '/opt/local','/sw']
-NDNCPP_VERSION_FILE='ndn-cpp-config.h'
-NDNCPP_VERSION_CODE='''
-#include <iostream>
-#include <ndn-cpp/ndn-cpp-config.h>
-int main() { std::cout << NDN_CPP_PACKAGE_VERSION; }
-'''
-
-def options(opt):
-	opt.add_option('--ndn-cpp',type='string',default='/usr/local/ndn',dest='ndn_cpp_dir',help='''path to where ndn-cpp is installed, e.g. /usr/local/ndn''')
-@conf
-def __ndncpp_get_version_file(self,dir):
-	try:
-		return self.root.find_dir(dir).find_node('%s/%s' % ('include/ndn-cpp', NDNCPP_VERSION_FILE))
-	except:
-		return None
-@conf
-def ndncpp_get_version(self,dir):
-	val=self.check_cxx(fragment=NDNCPP_VERSION_CODE,includes=['%s/%s' % (dir, 'include')], execute=True, define_ret = True, mandatory=True)
-	return val
-@conf
-def ndncpp_get_root(self,*k,**kw):
-	root=k and k[0]or kw.get('path',None)
-	# Logs.pprint ('RED', '   %s' %root)
-	if root and self.__ndncpp_get_version_file(root):
-		return root
-	for dir in NDNCPP_DIR:
-		if self.__ndncpp_get_version_file(dir):
-			return dir
-	if root:
-		self.fatal('NDNCPP not found in %s'%root)
-	else:
-		self.fatal('NDNCPP not found, please provide a --ndn-cpp argument (see help)')
-@conf
-def check_ndncpp(self,*k,**kw):
-	if not self.env['CXX']:
-		self.fatal('load a c++ compiler first, conf.load("compiler_cxx")')
-
-	var=kw.get('uselib_store','NDNCPP')
-	self.start_msg('Checking ndn-cpp')
-	root = self.ndncpp_get_root(*k,**kw)
-	self.env.NDNCPP_VERSION=self.ndncpp_get_version(root)
-
-	self.env['INCLUDES_%s'%var]= '%s/%s' % (root, "include")
-	self.env['LIB_%s'%var] = "ndn-cpp"
-	self.env['LIBPATH_%s'%var] = '%s/%s' % (root, "lib")
-
-	self.end_msg(self.env.NDNCPP_VERSION)
-	if Logs.verbose:
-		Logs.pprint('CYAN','	NDNCPP include : %s'%self.env['INCLUDES_%s'%var])
-		Logs.pprint('CYAN','	NDNCPP lib     : %s'%self.env['LIB_%s'%var])
-		Logs.pprint('CYAN','	NDNCPP libpath : %s'%self.env['LIBPATH_%s'%var])
-
-
diff --git a/waf-tools/protoc.py b/waf-tools/protoc.py
deleted file mode 100644
index f9d871f..0000000
--- a/waf-tools/protoc.py
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/usr/bin/env python
-# encoding: utf-8
-# Philipp Bender, 2012
-# Matt Clarkson, 2012
-
-from waflib.Task import Task
-from waflib.TaskGen import extension 
-
-"""
-A simple tool to integrate protocol buffers into your build system.
-
-    def configure(conf):
-        conf.load('compiler_cxx cxx protoc')
-
-    def build(bld):
-        bld(
-                features = 'cxx cxxprogram'
-                source   = 'main.cpp file1.proto proto/file2.proto', 
-                includes = '. proto',
-                target   = 'executable') 
-
-"""
-
-class protoc(Task):
-	run_str = '${PROTOC} ${PROTOC_FLAGS} ${PROTOC_ST:INCPATHS} ${SRC[0].abspath()}'
-	color   = 'BLUE'
-	ext_out = ['.h', 'pb.cc']
-
-@extension('.proto')
-def process_protoc(self, node):
-	cpp_node = node.change_ext('.pb.cc')
-	hpp_node = node.change_ext('.pb.h')
-	self.create_task('protoc', node, [cpp_node, hpp_node])
-	self.source.append(cpp_node)
-
-	if 'cxx' in self.features and not self.env.PROTOC_FLAGS:
-		self.env.PROTOC_FLAGS = '--cpp_out=%s' % node.parent.get_bld().abspath()
-
-	use = getattr(self, 'use', '')
-	if not 'PROTOBUF' in use:
-		self.use = self.to_list(use) + ['PROTOBUF']
-
-def configure(conf):
-	conf.check_cfg(package="protobuf", uselib_store="PROTOBUF", args=['--cflags', '--libs'])
-	conf.find_program('protoc', var='PROTOC')
-	conf.env.PROTOC_ST = '-I%s'
-
diff --git a/wscript b/wscript
index e65a6ba..ca889e9 100644
--- a/wscript
+++ b/wscript
@@ -7,34 +7,26 @@
 
 def options(opt):
 
-    opt.load(['compiler_c', 'compiler_cxx', 'qt5', 'gnu_dirs'])
+    opt.load(['compiler_c', 'compiler_cxx', 'gnu_dirs'])
 
-    opt.load(['default-compiler-flags', 'boost', 'protoc',
-              'doxygen', 'sphinx_build', 'qt5', 'cryptopp'],
-              tooldir=['waf-tools'])
+    opt.load(['default-compiler-flags', 'boost',
+              'doxygen', 'sphinx_build', 'qt5_custom', 'cryptopp'],
+              tooldir=['.waf-tools'])
 
-    opt = opt.add_option_group('ChronotChat Options')
+    opt = opt.add_option_group('ChronoChat Options')
 
     opt.add_option('--with-tests', action='store_true', default=False, dest='with_tests',
                    help='''build unit tests''')
 
-    opt.add_option('--with-log4cxx', action='store_true', default=False, dest='log4cxx',
-                   help='''Enable log4cxx''')
-
 def configure(conf):
-    conf.load(['compiler_c', 'compiler_cxx', 'qt5',
-               'default-compiler-flags', 'boost', 'protoc', 'gnu_dirs',
+    conf.load(['compiler_c', 'compiler_cxx', 'qt5_custom',
+               'default-compiler-flags', 'boost', 'gnu_dirs',
                'doxygen', 'sphinx_build', 'cryptopp'])
 
     conf.check_cfg(package='libndn-cxx', args=['--cflags', '--libs'],
                    uselib_store='NDN_CXX', mandatory=True)
 
-    if conf.options.log4cxx:
-        conf.check_cfg(package='liblog4cxx', args=['--cflags', '--libs'],
-                       uselib_store='LOG4CXX', mandatory=True)
-        conf.define("HAVE_LOG4CXX", 1)
-
-    conf.check_cfg (package='ChronoSync', args=['ChronoSync >= 0.1', '--cflags', '--libs'],
+    conf.check_cfg (package='ChronoSync', args=['ChronoSync >= 0.5', '--cflags', '--libs'],
                     uselib_store='SYNC', mandatory=True)
 
     boost_libs = 'system random thread filesystem'
@@ -43,14 +35,18 @@
         conf.define('WITH_TESTS', 1);
         boost_libs += ' unit_test_framework'
 
-    conf.check_boost(lib=boost_libs)
-    if conf.env.BOOST_VERSION_NUMBER < 104800:
-        Logs.error("Minimum required boost version is 1.48.0")
-        Logs.error("Please upgrade your distribution or install custom boost libraries" +
-                   " (http://redmine.named-data.net/projects/nfd/wiki/Boost_FAQ)")
-        return
+    conf.check_boost(lib=boost_libs, mt=True)
+    if conf.env.BOOST_VERSION_NUMBER < 105800:
+        conf.fatal('The minimum supported version of Boost is 1.65.1.\n'
+                   'Please upgrade your distribution or manually install a newer version of Boost.\n'
+                   'For more information, see https://redmine.named-data.net/projects/nfd/wiki/Boost')
+    elif conf.env.BOOST_VERSION_NUMBER < 106501:
+        Logs.warn('WARNING: Using a version of Boost older than 1.65.1 is not officially supported and may not work.\n'
+                  'If you encounter any problems, please upgrade your distribution or manually install a newer version of Boost.\n'
+                  'For more information, see https://redmine.named-data.net/projects/nfd/wiki/Boost')
 
     conf.check_cryptopp()
+    conf.check_compiler_flags()
     conf.write_config_header('src/config.h')
 
 def build (bld):
@@ -64,9 +60,9 @@
         target = "ChronoChat",
         features = feature_list,
         defines = "WAF=1",
-        source = bld.path.ant_glob(['src/*.cpp', 'src/*.ui', '*.qrc', 'logging.cc', 'src/*.proto']),
+        source = bld.path.ant_glob(['src/*.cpp', 'src/*.ui', '*.qrc']),
         includes = "src .",
-        use = "QT5CORE QT5GUI QT5WIDGETS QT5SQL NDN_CXX BOOST LOG4CXX SYNC CRYPTOPP",
+        use = "QT5CORE QT5GUI QT5WIDGETS QT5SQL NDN_CXX BOOST SYNC CRYPTOPP",
         )
 
     # Unit tests
@@ -81,10 +77,10 @@
           )
 
     # Debug tools
-    if bld.env["_DEBUG"]:
-        for app in bld.path.ant_glob('debug-tools/*.cc'):
+    if "_DEBUG" in bld.env["DEFINES"]:
+        for app in bld.path.ant_glob('debug-tools/*.cpp'):
             bld(features=['cxx', 'cxxprogram'],
-                target = '%s' % (str(app.change_ext('','.cc'))),
+                target = '%s' % (str(app.change_ext('','.cpp'))),
                 source = app,
                 use = 'NDN_CXX',
                 includes = "src .",