improve comments, update copyright
simplify code a bit
add AMD compat; export in Node.js as a function instead of object