Removed extra $toolsDir code
Moved Debug code to the top of the file to make it easier to enable debugging