Clean-up code

Converted spaces to tabs to match rest of code
Removed unnecessary global variables
Made spacing consistent