Coverity defects

Start addressing some of the issues discovered by Coverity; see:

  https://scan.coverity.com/projects/198