Fixed bugs found by static analyzers.