Updated script

Needs completion, but the main stuff is all there now