Added debuging mode, compatibility with node 0.6.x and added some comments