lots of changes, make it available as a node module