Converted process.nextTick calls to setImmediate

Node V10 warns when recursevly calling process.nextTick. This change fixes that.