Scripting refactor