added guards around raft struct state regarding candidate/follower and lastIndex