Fix some errors found by Gary.

This patch has been tested both with g++ 4.1 and 4.4.