Prefer setImmediate to process.nextTick.

This avoids errors due to recursive process.nextTick calls.