Added code injection to scripting, required some refactoring