Common code for ModScript