Fix warnings and a bug found by g++ 4.3.