diff --git a/Makefile.am b/Makefile.am
index 5a7f31e205f8a67fa6e323c441a1faae162693cc..e2c93d81016e0f85442023ba4eeec209fb3674c7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -11,8 +11,14 @@ SUBDIRS = src doc contrib
 
 DIST_SUBDIRS = src doc contrib
 
-EXTRA_DIST = INSTALL README LICENSE ChangeLog          \
-             ReleaseNotes tor.spec tor.spec.in
+EXTRA_DIST = \
+	ChangeLog					\
+	INSTALL						\
+	LICENSE						\
+	README						\
+	ReleaseNotes					\
+	tor.spec					\
+	tor.spec.in
 
 #install-data-local:
 #	$(INSTALL) -m 755 -d $(LOCALSTATEDIR)/lib/tor
@@ -48,9 +54,12 @@ test: all
 check-spaces:
 	./contrib/checkSpace.pl -C                    \
 	        src/common/*.h                        \
-		src/common/[^asO]*.c src/common/address.c \
-		src/or/[^e]*.[ch] src/or/eventdns_tor.h \
-		src/test/test*.[ch] src/tools/*.[ch] \
+		src/common/[^asO]*.c                  \
+                src/common/address.c                  \
+		src/or/[^e]*.[ch]                     \
+                src/or/eventdns_tor.h                 \
+		src/test/test*.[ch]                   \
+                src/tools/*.[ch]                      \
 		src/tools/tor-fw-helper/*.[ch]
 
 check-docs:
diff --git a/configure.in b/configure.in
index 5c4c56370331dc0ab779aaf1c1f7474180bb5ed0..e1565334e812502af0c0ea9ce7baa40c09d189fa 100644
--- a/configure.in
+++ b/configure.in
@@ -249,7 +249,27 @@ dnl -------------------------------------------------------------------
 dnl Check for functions before libevent, since libevent-1.2 apparently
 dnl exports strlcpy without defining it in a header.
 
-AC_CHECK_FUNCS(gettimeofday ftime socketpair uname inet_aton strptime getrlimit strlcat strlcpy strtoull getaddrinfo localtime_r gmtime_r memmem strtok_r flock prctl vasprintf sysconf)
+AC_CHECK_FUNCS(
+        flock \
+        ftime \
+        getaddrinfo \
+        getrlimit \
+        gettimeofday \
+        gmtime_r \
+        inet_aton \
+        localtime_r \
+        memmem \
+        prctl \
+        socketpair \
+        strlcat \
+        strlcpy \
+        strptime \
+        strtok_r \
+        strtoull \
+        sysconf \
+        uname \
+        vasprintf \
+)
 
 using_custom_malloc=no
 if test x$enable_openbsd_malloc = xyes ; then
@@ -503,13 +523,54 @@ fi
 
 AC_SYS_LARGEFILE
 
-AC_CHECK_HEADERS(unistd.h string.h signal.h sys/stat.h sys/types.h fcntl.h sys/fcntl.h sys/time.h errno.h assert.h time.h, , AC_MSG_WARN(Some headers were not found, compilation may fail.  If compilation succeeds, please send your orconfig.h to the developers so we can fix this warning.))
-
-AC_CHECK_HEADERS(netdb.h sys/ioctl.h sys/socket.h arpa/inet.h netinet/in.h pwd.h grp.h sys/un.h)
+AC_CHECK_HEADERS(
+        assert.h \
+        errno.h \
+        fcntl.h \
+        signal.h \
+        string.h \
+        sys/fcntl.h \
+        sys/stat.h \
+        sys/time.h \
+        sys/types.h \
+        time.h \
+        unistd.h
+ , , AC_MSG_WARN(Some headers were not found, compilation may fail.  If compilation succeeds, please send your orconfig.h to the developers so we can fix this warning.))
 
 dnl These headers are not essential
 
-AC_CHECK_HEADERS(stdint.h sys/types.h inttypes.h sys/param.h sys/wait.h limits.h sys/limits.h netinet/in.h arpa/inet.h machine/limits.h syslog.h sys/time.h sys/resource.h inttypes.h utime.h sys/utime.h sys/mman.h netinet/in6.h malloc.h sys/syslimits.h malloc/malloc.h linux/types.h sys/file.h malloc_np.h sys/prctl.h)
+AC_CHECK_HEADERS(
+        arpa/inet.h \
+        grp.h \
+        inttypes.h \
+        limits.h \
+        linux/types.h \
+        machine/limits.h \
+        malloc.h \
+        malloc/malloc.h \
+        malloc_np.h \
+        netdb.h \
+        netinet/in.h \
+        netinet/in6.h \
+        pwd.h \
+        stdint.h \
+        sys/file.h \
+        sys/ioctl.h \
+        sys/limits.h \
+        sys/mman.h \
+        sys/param.h \
+        sys/prctl.h \
+        sys/resource.h \
+        sys/socket.h \
+        sys/syslimits.h \
+        sys/time.h \
+        sys/types.h \
+        sys/un.h \
+        sys/utime.h \
+        sys/wait.h \
+        syslog.h \
+        utime.h
+)
 
 TOR_CHECK_PROTOTYPE(malloc_good_size, HAVE_MALLOC_GOOD_SIZE_PROTOTYPE,
 [#ifdef HAVE_MALLOC_H
@@ -997,7 +1058,12 @@ if test x$enable_gcc_warnings = xyes || test x$enable_gcc_warnings_advisory = xy
       CFLAGS="$CFLAGS -Wno-system-headers" ;;
   esac
 
-  CFLAGS="$CFLAGS -W -Wfloat-equal -Wundef -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wwrite-strings -Wredundant-decls -Wchar-subscripts -Wcomment -Wformat=2 -Wwrite-strings -Wmissing-declarations -Wredundant-decls -Wnested-externs -Wbad-function-cast -Wswitch-enum"
+  CFLAGS="$CFLAGS -W -Wfloat-equal -Wundef -Wpointer-arith"
+  CFLAGS="$CFLAGS -Wstrict-prototypes -Wmissing-prototypes -Wwrite-strings"
+  CFLAGS="$CFLAGS -Wredundant-decls -Wchar-subscripts -Wcomment -Wformat=2"
+  CFLAGS="$CFLAGS -Wwrite-strings -Wmissing-declarations -Wredundant-decls"
+  CFLAGS="$CFLAGS -Wnested-externs -Wbad-function-cast -Wswitch-enum"
+
   if test x$enable_gcc_warnings = xyes; then
     CFLAGS="$CFLAGS -Werror"
   fi
@@ -1009,14 +1075,14 @@ if test x$enable_gcc_warnings = xyes || test x$enable_gcc_warnings_advisory = xy
     CFLAGS="$CFLAGS -Winit-self -Wmissing-field-initializers -Wdeclaration-after-statement -Wold-style-definition"
   fi
 
-  if test x$have_gcc42 = xyes ; then 
+  if test x$have_gcc42 = xyes ; then
     # These warnings break gcc 4.0.2 and work on gcc 4.2
     # XXXX020 See if any of these work with earlier versions.
     CFLAGS="$CFLAGS -Waddress -Wmissing-noreturn -Wnormalized=id -Woverride-init -Wstrict-overflow=1"
     # We used to use -Wstrict-overflow=5, but that breaks us heavily under 4.3.
   fi
 
-  if test x$have_gcc43 = xyes ; then 
+  if test x$have_gcc43 = xyes ; then
     # These warnings break gcc 4.2 and work on gcc 4.3
     # XXXX020 See if any of these work with earlier versions.
     CFLAGS="$CFLAGS -Wextra -Warray-bounds"
@@ -1034,7 +1100,29 @@ fi
 
 CPPFLAGS="$CPPFLAGS $TOR_CPPFLAGS_libevent $TOR_CPPFLAGS_openssl $TOR_CPPFLAGS_zlib"
 
-AC_CONFIG_FILES([Makefile tor.spec Doxyfile contrib/tor.sh contrib/torctl contrib/torify contrib/tor.logrotate contrib/Makefile src/config/torrc.sample src/Makefile doc/Makefile doc/spec/Makefile src/config/Makefile src/common/Makefile src/or/Makefile src/test/Makefile src/win32/Makefile src/tools/Makefile src/tools/tor-fw-helper/Makefile contrib/suse/Makefile contrib/suse/tor.sh])
+AC_CONFIG_FILES([
+        Doxyfile
+        Makefile
+        contrib/Makefile
+        contrib/suse/Makefile
+        contrib/suse/tor.sh
+        contrib/tor.logrotate
+        contrib/tor.sh
+        contrib/torctl
+        contrib/torify
+        doc/Makefile
+        doc/spec/Makefile
+        src/Makefile
+        src/common/Makefile
+        src/config/Makefile
+        src/config/torrc.sample
+        src/or/Makefile
+        src/test/Makefile
+        src/tools/Makefile
+        src/tools/tor-fw-helper/Makefile
+        src/win32/Makefile
+        tor.spec
+])
 
 AC_OUTPUT
 
diff --git a/contrib/Makefile.am b/contrib/Makefile.am
index 5aae2c819ec3819a74c8f9b472387c932fa6c56b..795c351f3adf75500d53127850be23f73810e327 100644
--- a/contrib/Makefile.am
+++ b/contrib/Makefile.am
@@ -3,7 +3,20 @@ DIST_SUBDIRS = suse
 
 confdir = $(sysconfdir)/tor
 
-EXTRA_DIST = exitlist tor-tsocks.conf tor.nsi.in tor.sh torctl rc.subr cross.sh tor-mingw.nsi.in package_nsis-mingw.sh tor.ico tor-ctrl.sh linux-tor-prio.sh tor-exit-notice.html
+EXTRA_DIST = \
+	cross.sh				\
+	exitlist				\
+	linux-tor-prio.sh			\
+	package_nsis-mingw.sh			\
+	rc.subr					\
+	tor-ctrl.sh				\
+	tor-exit-notice.html			\
+	tor-mingw.nsi.in			\
+	tor-tsocks.conf				\
+	tor.ico					\
+	tor.nsi.in				\
+	tor.sh					\
+	torctl
 
 conf_DATA = tor-tsocks.conf
 
diff --git a/doc/spec/Makefile.am b/doc/spec/Makefile.am
index e2fef42e815780fbd535ed882f0e7d6717f3c0de..a4fba780ee653d11f7c393d66e5fb01027256416 100644
--- a/doc/spec/Makefile.am
+++ b/doc/spec/Makefile.am
@@ -1,5 +1,12 @@
 
-EXTRA_DIST = tor-spec.txt rend-spec.txt control-spec.txt     \
-             dir-spec.txt socks-extensions.txt path-spec.txt \
-             version-spec.txt address-spec.txt bridges-spec.txt
+EXTRA_DIST = \
+	address-spec.txt			\
+	bridges-spec.txt			\
+	control-spec.txt			\
+	dir-spec.txt				\
+	path-spec.txt				\
+	rend-spec.txt				\
+	socks-extensions.txt			\
+	tor-spec.txt				\
+	version-spec.txt
 
diff --git a/src/common/Makefile.am b/src/common/Makefile.am
index b1e03cd7101336b3ed028931761d9f1997d6d836..20e3f5ae161973d78509b3c4d023837b45b8cea9 100644
--- a/src/common/Makefile.am
+++ b/src/common/Makefile.am
@@ -11,12 +11,44 @@ else
 libor_extra_source=
 endif
 
-libor_a_SOURCES = address.c log.c util.c compat.c container.c mempool.c \
-	memarea.c util_codedigest.c $(libor_extra_source)
-libor_crypto_a_SOURCES = crypto.c aes.c tortls.c torgzip.c
+libor_a_SOURCES = \
+  address.c					\
+  compat.c					\
+  container.c					\
+  log.c						\
+  memarea.c					\
+  mempool.c					\
+  util.c					\
+  util_codedigest.c				\
+  $(libor_extra_source)
+
+libor_crypto_a_SOURCES = \
+  aes.c		\
+  crypto.c	\
+  torgzip.c	\
+  tortls.c
+
 libor_event_a_SOURCES = compat_libevent.c
 
-noinst_HEADERS = address.h torlog.h crypto.h util.h compat.h aes.h torint.h tortls.h strlcpy.c strlcat.c torgzip.h container.h ht.h mempool.h memarea.h ciphers.inc compat_libevent.h tortls_states.h
+noinst_HEADERS = 				\
+  address.h					\
+  aes.h						\
+  ciphers.inc					\
+  compat.h					\
+  compat_libevent.h				\
+  container.h					\
+  crypto.h					\
+  ht.h						\
+  memarea.h					\
+  mempool.h					\
+  strlcat.c					\
+  strlcpy.c					\
+  torgzip.h					\
+  torint.h					\
+  torlog.h					\
+  tortls.h					\
+  tortls_states.h				\
+  util.h
 
 common_sha1.i: $(libor_SOURCES) $(libor_crypto_a_SOURCES) $(noinst_HEADERS)
 	if test "@SHA1SUM@" != none; then \
diff --git a/src/or/Makefile.am b/src/or/Makefile.am
index ef9c9903b3029ccf48a2ad2106cfca2347338792..b6637ba6314196133059c06480499e880388fa73 100644
--- a/src/or/Makefile.am
+++ b/src/or/Makefile.am
@@ -15,16 +15,44 @@ else
 evdns_source=eventdns.c
 endif
 
-libtor_a_SOURCES = buffers.c circuitbuild.c circuitlist.c \
-	circuituse.c command.c config.c \
-	connection.c connection_edge.c connection_or.c control.c \
-	cpuworker.c directory.c dirserv.c dirvote.c \
-	dns.c dnsserv.c geoip.c hibernate.c main.c $(tor_platform_source) \
-	microdesc.c \
-	networkstatus.c nodelist.c onion.c policies.c \
-	reasons.c relay.c rendcommon.c rendclient.c rendmid.c \
-	rendservice.c rephist.c router.c routerlist.c routerparse.c \
-	$(evdns_source) config_codedigest.c
+libtor_a_SOURCES = \
+	buffers.c				\
+	circuitbuild.c				\
+	circuitlist.c				\
+	circuituse.c				\
+	command.c				\
+	config.c				\
+	connection.c				\
+	connection_edge.c			\
+	connection_or.c				\
+	control.c				\
+	cpuworker.c				\
+	directory.c				\
+	dirserv.c				\
+	dirvote.c				\
+	dns.c					\
+	dnsserv.c				\
+	geoip.c					\
+	hibernate.c				\
+	main.c					\
+	microdesc.c				\
+	networkstatus.c				\
+	nodelist.c				\
+	onion.c					\
+	policies.c				\
+	reasons.c				\
+	relay.c					\
+	rendclient.c				\
+	rendcommon.c				\
+	rendmid.c				\
+	rendservice.c				\
+	rephist.c				\
+	router.c				\
+	routerlist.c				\
+	routerparse.c				\
+	$(evdns_source)				\
+	$(tor_platform_source)			\
+	config_codedigest.c
 
 #libtor_a_LIBADD = ../common/libor.a ../common/libor-crypto.a \
 #	../common/libor-event.a
@@ -52,14 +80,46 @@ tor_LDADD = ./libtor.a ../common/libor.a ../common/libor-crypto.a \
 	@TOR_ZLIB_LIBS@ -lm @TOR_LIBEVENT_LIBS@ @TOR_OPENSSL_LIBS@ \
 	@TOR_LIB_WS32@ @TOR_LIB_GDI@ $(levent_openssl_lib)
 
-noinst_HEADERS = buffers.h circuitbuild.h circuitlist.h circuituse.h \
-	command.h config.h connection_edge.h connection.h connection_or.h \
-	control.h cpuworker.h directory.h dirserv.h dirvote.h dns.h \
-	dnsserv.h geoip.h hibernate.h main.h microdesc.h networkstatus.h \
-	nodelist.h \
-	ntmain.h onion.h policies.h reasons.h relay.h rendclient.h \
-	rendcommon.h rendmid.h rendservice.h rephist.h router.h routerlist.h \
-	routerparse.h or.h eventdns.h eventdns_tor.h micro-revision.i
+noinst_HEADERS = \
+	buffers.h				\
+	circuitbuild.h				\
+	circuitlist.h				\
+	circuituse.h				\
+	command.h				\
+	config.h				\
+	connection.h				\
+	connection_edge.h			\
+	connection_or.h				\
+	control.h				\
+	cpuworker.h				\
+	directory.h				\
+	dirserv.h				\
+	dirvote.h				\
+	dns.h					\
+	dnsserv.h				\
+	eventdns.h				\
+	eventdns_tor.h				\
+	geoip.h					\
+	hibernate.h				\
+	main.h					\
+	microdesc.h				\
+	networkstatus.h				\
+	nodelist.h				\
+	ntmain.h				\
+	onion.h					\
+	or.h					\
+	policies.h				\
+	reasons.h				\
+	relay.h					\
+	rendclient.h				\
+	rendcommon.h				\
+	rendmid.h				\
+	rendservice.h				\
+	rephist.h				\
+	router.h				\
+	routerlist.h				\
+	routerparse.h				\
+	micro-revision.i
 
 config_codedigest.o: or_sha1.i
 
diff --git a/src/test/Makefile.am b/src/test/Makefile.am
index 16ea66583b8a05fcdcee64e5a2b5082186dbb6a2..174c1af6ef3bb930bdfbab17734c7e02d7155c78 100644
--- a/src/test/Makefile.am
+++ b/src/test/Makefile.am
@@ -12,14 +12,14 @@ AM_CPPFLAGS = -DSHARE_DATADIR="\"$(datadir)\"" \
 # matters a lot there, and is quite hard to debug if you forget to do it.
 
 test_SOURCES = \
-	test_data.c \
 	test.c \
 	test_addr.c \
+	test_containers.c \
 	test_crypto.c \
+	test_data.c \
 	test_dir.c \
-	test_containers.c \
-	test_util.c \
 	test_microdesc.c \
+	test_util.c \
 	tinytest.c
 
 if USE_BUFFEREVENTS
@@ -35,6 +35,9 @@ test_LDADD = ../or/libtor.a ../common/libor.a ../common/libor-crypto.a \
 	@TOR_ZLIB_LIBS@ -lm @TOR_LIBEVENT_LIBS@ @TOR_OPENSSL_LIBS@ \
 	@TOR_LIB_WS32@ @TOR_LIB_GDI@ $(levent_openssl_lib)
 
-noinst_HEADERS = tinytest.h tinytest_macros.h test.h
+noinst_HEADERS = \
+	tinytest.h \
+	tinytest_macros.h \
+	test.h
 
 
diff --git a/src/tools/tor-fw-helper/Makefile.am b/src/tools/tor-fw-helper/Makefile.am
index f01f94c252aabee5ace0854d861bc9c70c88e2fc..5eef6acce39f8eade1f7014097275c8101b7395f 100644
--- a/src/tools/tor-fw-helper/Makefile.am
+++ b/src/tools/tor-fw-helper/Makefile.am
@@ -4,9 +4,14 @@ else
 bin_PROGRAMS =
 endif
 
-tor_fw_helper_SOURCES = tor-fw-helper.c \
-	tor-fw-helper-natpmp.c tor-fw-helper-upnp.c
-tor_fw_helper_INCLUDES = tor-fw-helper.h tor-fw-helper-natpmp.h tor-fw-helper-upnp.h
+tor_fw_helper_SOURCES = \
+	tor-fw-helper.c \
+	tor-fw-helper-natpmp.c \
+	tor-fw-helper-upnp.c
+tor_fw_helper_INCLUDES = \
+	tor-fw-helper.h \
+	tor-fw-helper-natpmp.h \
+	tor-fw-helper-upnp.h
 
 if NAT_PMP
 nat_pmp_ldflags = @TOR_LDFLAGS_libnatpmp@