Reworked setImmediates to better sync election