Fix several compile and runtime warnings found by clang 3.2 with the -fsanitize=address option.