iostream conversion, cppcheck and pvsstudio fixes