flaws found by #coverity fixed

All 'High impact' defects handled.