Switch from setTimeout(, 0) to setImmediate()