Addressed several minor issues revealed by static analysis (coverity, clang).  Mostly to do with extreme corner cases in which a null pointer would be dereferenced, or dereferencing a non-null (but non-initialized) pointer would result in garbage.