Fixed many uninitialized variable warnings and some potential bug found via -Wall -Werror on gcc.