Little preparations before moving all script code

Preparations for #4754.
They're trivial changes that can be merged at any point and I can maintain rebased with no effort forever.