Fix several minor issues found by coverty scan