Misc fixes reported by static analyzer