Correct typo
Remove redundant lines
Don't use global vars
Tidy up fields a bit more