remove global functions

It attaches the methods to a new object and returns it, instead of attaching them to `window`.