Compile fix for Mac OS X with Clang 6.0
Also fixed quite some warnings under Clang 6.0