diff --git a/Makefile.in b/Makefile.in
index b1fd4aa..f84ceb1 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -16,7 +16,7 @@
 # with thin-provisioning-tools.  If not, see
 # <http://www.gnu.org/licenses/>.
 
-V=@
+V=
 
 PROGRAMS=\
 	bin/pdata_tools
@@ -160,18 +160,22 @@ endif
 
 TOP_DIR:=@top_srcdir@
 TOP_BUILDDIR:=@top_builddir@
-CFLAGS+=-g -Wall -O3 -fPIC
+CFLAGS+=-g -Wall -fPIC
+CFLAGS+=@CFLAGS@
+CFLAGS+=@CPPFLAGS@
 CFLAGS+=@LFS_FLAGS@
-CXXFLAGS+=-g -Wall -fPIC -fno-strict-aliasing -std=c++11
+CXXFLAGS+=-g -Wall -fPIC -fno-strict-aliasing
+CXXFLAGS+=@CXXFLAGS@
+CXXFLAGS+=@CPPFLAGS@
 
 ifeq ("@DEVTOOLS@", "yes")
 CXXFLAGS+=-DDEV_TOOLS
 endif
 
-CXXFLAGS+=@CXXOPTIMISE_FLAG@
 CXXFLAGS+=@CXXDEBUG_FLAG@
 CXXFLAGS+=@CXX_STRERROR_FLAG@
 CXXFLAGS+=@LFS_FLAGS@
+LDFLAGS=@LDFLAGS@
 INCLUDES+=-I$(TOP_BUILDDIR) -I$(TOP_DIR) -I$(TOP_DIR)/thin-provisioning
 LIBS:=-laio -lexpat -lboost_iostreams -ldl
 
@@ -179,21 +183,15 @@ ifeq ("@DEVTOOLS@", "yes")
 LIBS+=-lncurses
 endif
 
-ifeq ("@STATIC_CXX@", "yes")
-CXXLIB+=-Wl,-Bstatic -lstdc++ -Wl,-Bdynamic -Wl,--as-needed
-else
-CXXLIB+=-lstdc++
-endif
-
 ifeq ("@STATIC@", "yes")
 LDFLAGS+=-static
 endif
 
 INSTALL:=@INSTALL@
-PREFIX:=@prefix@
-BINDIR:=$(DESTDIR)$(PREFIX)/sbin
-DATADIR:=$(DESTDIR)$(PREFIX)/share
-MANPATH:=$(DATADIR)/man
+prefix:=@prefix@
+exec_prefix:=@exec_prefix@
+BINDIR:=$(DESTDIR)@sbindir@
+MANPATH:=$(DESTDIR)@mandir@
 
 vpath %.cc $(TOP_DIR)
 
@@ -290,7 +288,6 @@ MANPAGES:=$(patsubst %,man8/%.8,$(TOOLS))
 install: bin/pdata_tools $(MANPAGES)
 	$(INSTALL_DIR) $(BINDIR)
 	$(INSTALL_PROGRAM) bin/pdata_tools $(BINDIR)
-	$(STRIP) $(BINDIR)/pdata_tools
 	ln -s -f pdata_tools $(BINDIR)/cache_check
 	ln -s -f pdata_tools $(BINDIR)/cache_dump
 	ln -s -f pdata_tools $(BINDIR)/cache_metadata_size
@@ -362,8 +359,7 @@ LIBFT_SOURCE=\
 LIBFT_OBJECTS=$(subst .c,.o,$(LIBFT_SOURCE))
 
 lib/libft.so: $(LIBFT_OBJECTS)
-	@echo "    [LD]" $@
-	$(V) gcc -shared -o $@ $+ -laio
+	$(V) $(CC) $(CFLAGS) -shared -o $@ $+ -laio
 
 .PHONEY: functional-test unit-test
 
diff --git a/bin/txt2man b/bin/txt2man
index 71697ed..cfda534 100755
--- a/bin/txt2man
+++ b/bin/txt2man
@@ -155,7 +155,7 @@ then
 	rel="Device Mapper Tools"
 fi
 
-head=".\\\" Text automatically generated by txt2man
+head="\\\\# Text automatically generated by txt2man
 .TH $title $section \"$rel\" \"$volume\""
 
 # All tabs converted to spaces
@@ -216,7 +216,7 @@ BEGIN {
 		pnzls = ls
 	match($0, /[^ ]/)
 	ls = RSTART
-	if (pls == 0 && pnzls > 0 && ls > pnzls && $1 !~ /^[0-9\-\*\o]\.*$/) {
+	if (pls == 0 && pnzls > 0 && ls > pnzls && $1 !~ /^[0-9\-\*o]\.*$/) {
 		# example display block
 		if (prevblankline == 1) {
 			print ".PP"
@@ -270,7 +270,7 @@ section == "SYNOPSIS" {
 		else if ($1 == "#define")
 			subwords["\\<" $2 "\\>"] = "\\fI" $2 "\\fP"
 		for (i = 1; i <= NF; i++) {
-			if ($i ~ /[\,\)]/) {
+			if ($i ~ /[,\)]/) {
 				a = $i
 				sub(/.*\(/, "", a)
 				gsub(/\W/, "", a)
diff --git a/unit-tests/cache_superblock_t.cc b/unit-tests/cache_superblock_t.cc
index f1e2c21..a5352a0 100644
--- a/unit-tests/cache_superblock_t.cc
+++ b/unit-tests/cache_superblock_t.cc
@@ -37,7 +37,9 @@ namespace {
 		damage_visitor_mock visitor_;
 		superblock sb_;
 	};
+}
 
+namespace boost {
 	ostream &operator <<(ostream &out, superblock_invalid const &d) {
 		out << "superblock_invalid: " << d.get_desc();
 		return out;
diff --git a/unit-tests/copier_t.cc b/unit-tests/copier_t.cc
index d1a6687..cb84133 100644
--- a/unit-tests/copier_t.cc
+++ b/unit-tests/copier_t.cc
@@ -33,14 +33,6 @@ namespace {
 	unsigned const BLOCK_SIZE = 64u;
 	using wait_result = io_engine::wait_result;
 
-	ostream &operator <<(ostream &out, optional<wait_result> const &mwr) {
-		if (mwr) {
-			out << "Just[wait_result[" << mwr->first << ", " << mwr->second << "]]";
-		} else
-			out << "Nothing";
-		return out;
-	}
-
 	class io_engine_mock : public io_engine {
 	public:
 		MOCK_METHOD3(open_file, handle(string const &, mode, sharing));
@@ -114,6 +106,21 @@ namespace {
 	};
 }
 
+namespace boost {
+	ostream &operator <<(ostream &out, optional<wait_result> const &mwr) {
+		if (mwr) {
+			out << "Just[wait_result[" << mwr->first << ", " << mwr->second << "]]";
+		} else
+			out << "Nothing";
+		return out;
+	}
+
+	ostream &operator <<(ostream &out, pair<bool, unsigned int> const &i) {
+		out << "Nothing";
+		return out;
+	}
+}
+
 //----------------------------------------------------------------
 
 TEST_F(CopierTests, empty_test)
diff --git a/unit-tests/io_engine_t.cc b/unit-tests/io_engine_t.cc
index d9a25e3..d46b98b 100644
--- a/unit-tests/io_engine_t.cc
+++ b/unit-tests/io_engine_t.cc
@@ -37,11 +37,12 @@ using namespace testing;
 
 namespace {
 	unsigned const MAX_IO = 64;
+	unsigned const BLOCK_SIZE = std::max(64l * 512, PAGE_SIZE);
 
 	class IOEngineTests : public Test {
 	public:
 		IOEngineTests()
-			: pool_(64 * 512, 128 * 512, PAGE_SIZE),
+			: pool_(BLOCK_SIZE, 2 * BLOCK_SIZE, PAGE_SIZE),
 			  src_file_("copy_src", 32),
 			  dest_file_("copy_dest", 32),
 			  engine_(new aio_engine(MAX_IO)) {
diff --git a/unit-tests/rmap_visitor_t.cc b/unit-tests/rmap_visitor_t.cc
index 67196cb..2e9d5d4 100644
--- a/unit-tests/rmap_visitor_t.cc
+++ b/unit-tests/rmap_visitor_t.cc
@@ -72,7 +72,9 @@ namespace {
 
 		rmap_visitor rmap_v_;
 	};
+}
 
+namespace boost {
 	ostream &operator <<(ostream &out, rmap_region const &r) {
 		out << "rmap_region [data_begin = " << r.data_begin
 		    << ", data_end = " << r.data_end
diff --git a/unit-tests/span_iterator_t.cc b/unit-tests/span_iterator_t.cc
index 76ff70e..9c6f9ef 100644
--- a/unit-tests/span_iterator_t.cc
+++ b/unit-tests/span_iterator_t.cc
@@ -2,6 +2,7 @@
 
 #include "base/run_set.h"
 #include "persistent-data/space-maps/subtracting_span_iterator.h"
+#include "test_utils.h"
 
 using namespace std;
 using namespace persistent_data;
@@ -81,7 +82,9 @@ namespace {
 
 		base::run_set<block_address> forbidden;
 	};
+}
 
+namespace boost {
 	ostream &operator <<(ostream &out, maybe_span const &m) {
 		out << "maybe_span[";
 		if (m)
diff --git a/unit-tests/test_utils.h b/unit-tests/test_utils.h
index 1953d7a..b97702f 100644
--- a/unit-tests/test_utils.h
+++ b/unit-tests/test_utils.h
@@ -20,6 +20,7 @@
 #include "persistent-data/transaction_manager.h"
 
 #include <linux/limits.h>
+#include <boost/optional/optional_io.hpp>
 
 //----------------------------------------------------------------
 
@@ -124,9 +125,11 @@ namespace test {
 
 		std::string path_;
 	};
+}
 
 	//--------------------------------
 
+namespace boost {
 	template <typename T>
 	std::ostream &operator <<(std::ostream &out, boost::optional<T> const &maybe) {
 		if (maybe)
