Fixed most issues with the script. Still get an IndexOutOfBoundsException once in a while during execution. Not sure what that's about