Use strict mode and one var per variable

This adds `'use strict';` to each module and switches to the one var per variable model.  This will make future diffs cleaner, and make it easier to avoid accidentally leaving undeclared global variables.

I've also updated a few locations where the indentation was a little bit strange for JavaScript and where possible I've replaced `var name = function ...` with `function name ...` as that makes for more idiomatic JavaScript.

I'll start looking at the styleguide checker next I think.