Improve script-building