Fix issues reported by static analyzer