convert from coco to javascript
clean up lib/daemon.js