Moved leader election into its own file