Convert the "module systems magic dance" to proper UMD from https://github.com/umdjs/umd/blob/master/returnExports.js.

Fixes #167.