main
add process.nextTick to avoid long recursion in callbacks
Replace deprecated String.prototype.substr()