Big rework to allow importation as a module.

Yet it can also be run in NodeWebKit and in the browser, as well.