More coverity fixes

This are probably the last bits for this year, still ~80 open issues. Defect density is around 0.4x defects per KLOC which is in the average. Please review.