Tidy up state handling slightly
Elect a leader