fix some issues identified by findbugs/coverity