Implement MasterElection

Locking stuff has all changed