Updated for gui scripting and saving as xml