Mega cleanup

Changes include:

* Much stricter compilation flags
* Fixing a possible bug where zlib could try to write to the mmap()ed buf
* Detecting realpath instead of just blindly redefining it on windows
* Using [clang-format](http://clang.llvm.org/docs/ClangFormat.html) to enforce a standard, sane coding style
* Logging when threads start and stop (in debug mode only).