Add unused to jshint, and various refactoring:

* Pull constant and one-time initialized variables to top
* Simplify initialization and make rootUrl private
* Remove unnecessary comments
* Change fm and variable declarations to match conventions
* Remove unused variables and function parameters.

Change-Id: Icc50440b65951fccdd10c2ee812dea88a7194061