Updated the script.

With some help from SomeSortOfDuck.