Fixing PVS studio warnings