Change process.nextTick to setImmediate

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