Fix defects detected by static code analyzer