Added election thread and dealt with termination procedure
Fixed heartbeat