Fix some coding mistakes spotted by static code analyzer