Tidy up and document main code / module interface.
Prep package.json for npm.