Various coverity fixes
Use correct variable for error