Core/Misc: Refactor scripts to fix static analysis warnings

Eighth batch of fixes targeting 80 issues reported by Coverity