refactoring to get the code through the jslint tool ;)

* combined various variable defintions
* moved the invocation into the parens that contain the function
* some minor things