Use setImmediate instead of process.nextTick

Behaves more like the original code.