Code cleanup

Cleans up tabs, adds jshint and cleans up JS.
Added to make merge with upstream changes more apparent.