JS improvements.

A selection of (mostly) JavaScript improvements, marked up for 1.1.0 (but feel free to change!).

See the individual commits for any inline notes.

Obviously needs to be tested more thoroughly. For me, and the test license key I have, I'm getting no results for the library, on any search time - I'm not sure if I've got something wrong in the refactor, or the production API isn't responding correctly / to my key.