Some bugs found by clang (warnings & static analysis)