Working on AMD format for modules

Should make it possible to move the library as a client script as well
as on the server for node.js.