added some small change

removed some repetitive code with toString.call
wraped everything in an immediate function
made it compatible with other module loaders
and browser support