diff --git a/.waf-tools/coverage.py b/.waf-tools/coverage.py
index ce92883..cc58165 100644
--- a/.waf-tools/coverage.py
+++ b/.waf-tools/coverage.py
@@ -1,15 +1,15 @@
 # -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
 
-from waflib import TaskGen, Logs
+from waflib import TaskGen
 
 def options(opt):
-    opt.add_option('--with-coverage', action='store_true', default=False, dest='with_coverage',
-                   help='''Set compiler flags for gcc to enable code coverage information''')
+    opt.add_option('--with-coverage', action='store_true', default=False,
+                   help='Add compiler flags to enable code coverage information')
 
 def configure(conf):
     if conf.options.with_coverage:
         if not conf.options.debug:
-            conf.fatal("Code coverage flags require debug mode compilation (add --debug)")
+            conf.fatal('Code coverage flags require debug mode compilation (add --debug)')
         conf.check_cxx(cxxflags=['-fprofile-arcs', '-ftest-coverage', '-fPIC'],
                        linkflags=['-fprofile-arcs'], uselib_store='GCOV', mandatory=True)
 
diff --git a/.waf-tools/default-compiler-flags.py b/.waf-tools/default-compiler-flags.py
index bba2b1e..54db7ea 100644
--- a/.waf-tools/default-compiler-flags.py
+++ b/.waf-tools/default-compiler-flags.py
@@ -1,16 +1,17 @@
 # -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
 
-from waflib import Logs, Configure, Utils
+from waflib import Configure, Logs, Utils
 
 def options(opt):
-    opt.add_option('--debug', '--with-debug', action='store_true', default=False, dest='debug',
-                   help='''Compile in debugging mode with minimal optimizations (-O0 or -Og)''')
+    opt.add_option('--debug', '--with-debug', action='store_true', default=False,
+                   help='Compile in debugging mode with minimal optimizations (-O0 or -Og)')
 
 def configure(conf):
     conf.start_msg('Checking C++ compiler version')
 
-    cxx = conf.env['CXX_NAME'] # CXX_NAME is the generic name of the compiler
-    ccver = tuple(int(i) for i in conf.env['CC_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':
@@ -28,13 +29,13 @@
         conf.flags = CompilerFlags()
 
     if errmsg:
-        conf.end_msg('.'.join(conf.env['CC_VERSION']), color='RED')
+        conf.end_msg(ccverstr, color='RED')
         conf.fatal(errmsg)
     elif warnmsg:
-        conf.end_msg('.'.join(conf.env['CC_VERSION']), color='YELLOW')
+        conf.end_msg(ccverstr, color='YELLOW')
         Logs.warn(warnmsg)
     else:
-        conf.end_msg('.'.join(conf.env['CC_VERSION']))
+        conf.end_msg(ccverstr)
 
     conf.areCustomCxxflagsPresent = (len(conf.env.CXXFLAGS) > 0)
 
@@ -53,10 +54,10 @@
         extraFlags = conf.flags.getDebugFlags(conf)
         if conf.areCustomCxxflagsPresent:
             missingFlags = [x for x in extraFlags['CXXFLAGS'] 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))
+            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)
 
@@ -106,6 +107,9 @@
 
 
 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': []}
@@ -160,16 +164,14 @@
 class GccFlags(GccBasicFlags):
     def getDebugFlags(self, conf):
         flags = super(GccFlags, self).getDebugFlags(conf)
-        version = tuple(int(i) for i in conf.env['CC_VERSION'])
-        if version < (5, 1, 0):
+        if self.getCompilerVersion(conf) < (5, 1, 0):
             flags['CXXFLAGS'] += ['-Wno-missing-field-initializers']
         flags['CXXFLAGS'] += ['-fdiagnostics-color'] # gcc >= 4.9
         return flags
 
     def getOptimizedFlags(self, conf):
         flags = super(GccFlags, self).getOptimizedFlags(conf)
-        version = tuple(int(i) for i in conf.env['CC_VERSION'])
-        if version < (5, 1, 0):
+        if self.getCompilerVersion(conf) < (5, 1, 0):
             flags['CXXFLAGS'] += ['-Wno-missing-field-initializers']
         flags['CXXFLAGS'] += ['-fdiagnostics-color'] # gcc >= 4.9
         return flags
@@ -177,8 +179,8 @@
 class ClangFlags(GccBasicFlags):
     def getGeneralFlags(self, conf):
         flags = super(ClangFlags, self).getGeneralFlags(conf)
-        version = tuple(int(i) for i in conf.env['CC_VERSION'])
-        if Utils.unversioned_sys_platform() == 'darwin' and version >= (9, 0, 0): # Bug #4296
+        if Utils.unversioned_sys_platform() == 'darwin' and self.getCompilerVersion(conf) >= (9, 0, 0):
+            # Bug #4296
             flags['CXXFLAGS'] += [['-isystem', '/usr/local/include'], # for Homebrew
                                   ['-isystem', '/opt/local/include']] # for MacPorts
         return flags
@@ -194,7 +196,7 @@
                               '-Wno-error=unneeded-internal-declaration', # Bug #1588
                               '-Wno-unused-local-typedef', # Bugs #2657 and #3209
                               ]
-        version = tuple(int(i) for i in conf.env['CC_VERSION'])
+        version = self.getCompilerVersion(conf)
         if version < (3, 9, 0) or (Utils.unversioned_sys_platform() == 'darwin' and version < (8, 1, 0)):
             flags['CXXFLAGS'] += ['-Wno-unknown-pragmas']
         return flags
@@ -206,7 +208,7 @@
                               '-Wundefined-func-template',
                               '-Wno-unused-local-typedef', # Bugs #2657 and #3209
                               ]
-        version = tuple(int(i) for i in conf.env['CC_VERSION'])
+        version = self.getCompilerVersion(conf)
         if version < (3, 9, 0) or (Utils.unversioned_sys_platform() == 'darwin' and version < (8, 1, 0)):
             flags['CXXFLAGS'] += ['-Wno-unknown-pragmas']
         return flags
diff --git a/.waf-tools/pch.py b/.waf-tools/pch.py
deleted file mode 100644
index 3df299f..0000000
--- a/.waf-tools/pch.py
+++ /dev/null
@@ -1,153 +0,0 @@
-#! /usr/bin/env python
-# encoding: utf-8
-# Alexander Afanasyev (UCLA), 2014
-
-"""
-Enable precompiled C++ header support (currently only clang++ and g++ are supported)
-
-To use this tool, wscript should look like:
-
-	def options(opt):
-		opt.load('pch')
-		# This will add `--with-pch` configure option.
-		# Unless --with-pch during configure stage specified, the precompiled header support is disabled
-
-	def configure(conf):
-		conf.load('pch')
-		# this will set conf.env.WITH_PCH if --with-pch is specified and the supported compiler is used
-		# Unless conf.env.WITH_PCH is set, the precompiled header support is disabled
-
-	def build(bld):
-		bld(features='cxx pch',
-			target='precompiled-headers',
-			name='precompiled-headers',
-			headers='a.h b.h c.h', # headers to pre-compile into `precompiled-headers`
-
-			# Other parameters to compile precompiled headers
-			# includes=...,
-			# export_includes=...,
-			# use=...,
-			# ...
-
-			# Exported parameters will be propagated even if precompiled headers are disabled
-		)
-
-		bld(
-			target='test',
-			features='cxx cxxprogram',
-			source='a.cpp b.cpp d.cpp main.cpp',
-			use='precompiled-headers',
-		)
-
-		# or
-
-		bld(
-			target='test',
-			features='pch cxx cxxprogram',
-			source='a.cpp b.cpp d.cpp main.cpp',
-			headers='a.h b.h c.h',
-		)
-
-Note that precompiled header must have multiple inclusion guards.  If the guards are missing, any benefit of precompiled header will be voided and compilation may fail in some cases.
-"""
-
-import os
-from waflib import Task, TaskGen, Logs, Utils
-from waflib.Tools import c_preproc, cxx
-
-
-PCH_COMPILER_OPTIONS = {
-	'clang++': [['-include'], '.pch', ['-x', 'c++-header']],
-	'g++':     [['-include'], '.gch', ['-x', 'c++-header']],
-}
-
-
-def options(opt):
-	opt.add_option('--without-pch', action='store_false', default=True, dest='with_pch', help='''Try to use precompiled header to speed up compilation (only g++ and clang++)''')
-
-def configure(conf):
-	if (conf.options.with_pch and conf.env['COMPILER_CXX'] in PCH_COMPILER_OPTIONS.keys()):
-		if Utils.unversioned_sys_platform() == "darwin" and conf.env['CXX_NAME'] == 'clang':
-			version = tuple(int(i) for i in conf.env['CC_VERSION'])
-			if version < (6, 1, 0):
-				# Issue #2804
-				return
-		conf.env.WITH_PCH = True
-		flags = PCH_COMPILER_OPTIONS[conf.env['COMPILER_CXX']]
-		conf.env.CXXPCH_F = flags[0]
-		conf.env.CXXPCH_EXT = flags[1]
-		conf.env.CXXPCH_FLAGS = flags[2]
-
-
-@TaskGen.feature('pch')
-@TaskGen.before('process_source')
-def apply_pch(self):
-	if not self.env.WITH_PCH:
-		return
-
-	if getattr(self.bld, 'pch_tasks', None) is None:
-		self.bld.pch_tasks = {}
-
-	if getattr(self, 'headers', None) is None:
-		return
-
-	self.headers = self.to_nodes(self.headers)
-
-	if getattr(self, 'name', None):
-		try:
-			task = self.bld.pch_tasks[self.name]
-			self.bld.fatal("Duplicated 'pch' task with name %r" % self.name)
-		except KeyError:
-			pass
-
-	out = '%s.%d%s' % (self.target, self.idx, self.env['CXXPCH_EXT'])
-	out = self.path.find_or_declare(out)
-	task = self.create_task('gchx', self.headers, out)
-
-	# target should be an absolute path of `out`, but without precompiled header extension
-	task.target = out.abspath()[:-len(out.suffix())]
-
-	self.pch_task = task
-	if getattr(self, 'name', None):
-		self.bld.pch_tasks[self.name] = task
-
-@TaskGen.feature('cxx')
-@TaskGen.after_method('process_source', 'propagate_uselib_vars')
-def add_pch(self):
-	if not (self.env['WITH_PCH'] and getattr(self, 'use', None) and getattr(self, 'compiled_tasks', None) and getattr(self.bld, 'pch_tasks', None)):
-		return
-
-	pch = None
-	# find pch task, if any
-
-	if getattr(self, 'pch_task', None):
-		pch = self.pch_task
-	else:
-		for use in Utils.to_list(self.use):
-			try:
-				pch = self.bld.pch_tasks[use]
-			except KeyError:
-				pass
-
-	if pch:
-		for x in self.compiled_tasks:
-			x.env.append_value('CXXFLAGS', self.env['CXXPCH_F'] + [pch.target])
-
-class gchx(Task.Task):
-	run_str = '${CXX} ${ARCH_ST:ARCH} ${CXXFLAGS} ${CPPFLAGS} ${CXXPCH_FLAGS} ${FRAMEWORKPATH_ST:FRAMEWORKPATH} ${CPPPATH_ST:INCPATHS} ${DEFINES_ST:DEFINES} ${CXXPCH_F:SRC} ${CXX_SRC_F}${SRC[0].abspath()} ${CXX_TGT_F}${TGT[0].abspath()}'
-	scan    = c_preproc.scan
-	color   = 'BLUE'
-	ext_out=['.h']
-
-	def runnable_status(self):
-		try:
-			node_deps = self.generator.bld.node_deps[self.uid()]
-		except KeyError:
-			node_deps = []
-		ret = Task.Task.runnable_status(self)
-		if ret == Task.SKIP_ME and self.env.CXX_NAME == 'clang':
-			t = os.stat(self.outputs[0].abspath()).st_mtime
-			for n in self.inputs + node_deps:
-				if os.stat(n.abspath()).st_mtime > t:
-					return Task.RUN_ME
-		return ret
diff --git a/.waf-tools/protoc.py b/.waf-tools/protoc.py
deleted file mode 100644
index 8ae3ad2..0000000
--- a/.waf-tools/protoc.py
+++ /dev/null
@@ -1,94 +0,0 @@
-#!/usr/bin/env python
-# encoding: utf-8
-# Philipp Bender, 2012
-# Matt Clarkson, 2012
-
-import re
-from waflib.Task import Task
-from waflib.TaskGen import extension 
-
-"""
-A simple tool to integrate protocol buffers into your build system.
-
-Example::
-
-    def configure(conf):
-        conf.load('compiler_cxx cxx protoc')
-
-    def build(bld):
-        bld(
-                features = 'cxx cxxprogram'
-                source   = 'main.cpp file1.proto proto/file2.proto', 
-                include  = '. proto',
-                target   = 'executable') 
-
-Notes when using this tool:
-
-- protoc command line parsing is tricky.
-
-  The generated files can be put in subfolders which depend on
-  the order of the include paths.
-
-  Try to be simple when creating task generators
-  containing protoc stuff.
-
-"""
-
-class protoc(Task):
-	# protoc expects the input proto file to be an absolute path.
-	run_str = '${PROTOC} ${PROTOC_FLAGS} ${PROTOC_ST:INCPATHS} ${SRC[0].abspath()}'
-	color   = 'BLUE'
-	ext_out = ['.h', 'pb.cc']
-	def scan(self):
-		"""
-		Scan .proto dependencies
-		"""
-		node = self.inputs[0]
-
-		nodes = []
-		names = []
-		seen = []
-
-		if not node: return (nodes, names)
-
-		search_paths = [self.generator.path.find_node(x) for x in self.generator.includes]
-
-		def parse_node(node):
-			if node in seen:
-				return
-			seen.append(node)
-			code = node.read().split("\n")
-			for line in code:
-				m = re.search(r'^import\s+"(.*)";.*(//)?.*', line)
-				if m:
-					dep = m.groups()[0]
-					for incpath in search_paths:
-						found = incpath.find_resource(dep)
-						if found:
-							nodes.append(found)
-							parse_node(found)
-						else:
-							names.append(dep)
-
-		parse_node(node)
-		return (nodes, names)
-
-@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'
-
