Scripts/Misc: Fix issues reported by static analysis