Fix errors reported by static analyzer