Fix warnings from pvs studio static analysis

one commit per fix