Fixes suggested by PVS Studio