Thanks to Ivan for the save state spot, I've cleaned up a few of the variables that aren't used (nw)