Scripts/Misc: Some code optimisations