Core/Misc: Refactor scripts to fix static analysis warnings