Fix defects found by coverity scan