Got script to a working state