Some basic JSHint linting
Optimize a couple if blocks