fix setting group to username erroneously
Fix various coverity issues.
Merge branch 'cov'