Fix misc bugs discovered by clang.