Fixes for clean compilation on MacOSX Mavericks. Also fixes some bugs discovered by Clang.
Merge branch '2.0' into 2.1