Fix a few minor issues detected by CppCheck

Thanks to Dmitry Andriyankov for reporting.