Reworking library and header version checks (always print mismatches).
First wave of fixes suggested by coverity static code analyzer.