first round of fixes as found by coverity