Fix most warnings from gcc 4.6.3.

Left a few behind, too hairy to fix and thinking of better (but bigger)
fixes.