Fixing compiler errors and warnings under clang