Fix OS X build and cppcheck