Fixes for Node 10.X

These changes fix the use of `process.nextTick` where `setImmediate` is preferred.