Fixed a number of things to make the code compilable under Clang, without warnings.