       Process.send_after(pid, {:append_entries, []}, @append_entries_interval_ms)
     end
 
-    def maybe_step_down(state, remote_term) do
+    def get_last_log_term(state) do
+      case List.last(state.log) do
+        nil -> 0
+        tl -> tl.term
+      end
+    end
+
+    def maybe_step_down(state, member, remote_term) do
       if state.term < remote_term do
-        Logger.info("Remote node has higher term! Stepping down")
-        %{state | term: remote_term, role: :follower, voted_for: nil, leader: nil}
+        Logger.info("#{member.name} has higher term! Stepping down")
+        %{state | term: remote_term, role: :follower, voted_for: nil, leader: member.name}
       else
         state
       end
     end
 
     # AppendEntries RPC implementation.
-    def handle_rpc(state, _member, %RPC.AppendEntries{} = rpc) do
-      # TODO: Need to do some checks to see if we should accept this message
-      state = maybe_step_down(state, rpc.term)
+    def handle_rpc(state, member, %RPC.AppendEntries{} = rpc) do
+      state = maybe_step_down(state, member, rpc.term)
       |> State.reset_election_timer(self())
 
       {accept_append, state} =

    end
  end

  # TODO: Vote for self, Publish a RequestVote RPC
  def handle_info(:leader_election, state) do
    state = State.reset_election_timer(state, self())



        # If we became a candidate in the previous cycle, use this
        # cycle to count votes and declare election results
        :candidate ->
          votes = state.leader_state.votes |> MapSet.size
          majority_votes = div(Map.size(Pontoon.Membership.list()), 2) + 1
