Implement MasterElection

It's kinda related to the rest of this method - I think it helps to see that it's being explicitly updated here (you could conceivably miss it otherwise.)