cleans up loaded scripts
fixes update function, adds a reference to index