correct mainly minor issues found by scan-build