Fix bugs found by GCC