JSLint improvement

Cleaned up the code using JSLint as a guide for best practice. Doesn't change the functionality, just reduces the chance of unexpected errors and improves maintenance.

Changes include:
1. ensure vars are declared out of loop and are not out of scope define radix for parseint
2. using !== to compare to null and removed repeated var declaration removed repeated var 
3. declarations added missing semicolons
4. updated another comparison to 0 to ===
5. using === to compare to 0
6. removed all trailing whitespace and mixture of space and tabs