Use `setImmediate` instead of `nextTick`.

Closes #316.