fix for #493
fix for #495
Support for CommonJS (browserify/node) modules

Fixes #499, but could affect others. Changes the factory function to add a case
for CommonJS, and fixes package.json to point to the proper JS file.