Refactored Leader Election agent and added a RecoveryModeFactory.