Just some little quick advice on top of what dozza wrote,
Reusing code is a great thing, my advice though when rewriting a script is to maximazie your learning by only using your old code as a guide line for areas, method etc.
Have your code open on one side and on the other start the rewrite, we have all done this at one point when we said "who is the fucking dumbass who wrote this, ohh wait me", in my opinion this is the goal of rewriting a script because you can improve a lot when learning from your old mistakes. Just my opinion.
Great improvement on the script though, keep it up.
(Also it does a apply a bit less if your goal isn't to improve but to get a working product as fast as possible)