Fixes for defects from code coverity