Core/Misc: Refactor scripts to fix static analysis warnings

Last issue to be fixed, fixes #12960