First changes to add promise support (untested).
Changes for latest node.js compatability.