big fat batch of changes

Pulled in #96 then got caught in a death-spiral of JSHint, reformatting and fixing bugs and tests for other (and older) browsers; some recent tests were obviously just targeting Chrome.

Submitting as a PR rather than just merging cause it's kind of major and you might want to have a browse over it @ded.

Will comment inline.