diff --git a/poll.tokens.inc b/poll.tokens.inc
index afc12be..466443e 100644
--- a/poll.tokens.inc
+++ b/poll.tokens.inc
@@ -5,35 +5,36 @@
  * Builds placeholder replacement tokens for values specific to Poll nodes.
  */
 
+use Drupal\Component\Utility\Xss;
 use Drupal\Core\Render\BubbleableMetadata;
 
 /**
  * Implements hook_token_info().
  */
 function poll_token_info() {
-  $node['poll-votes'] = array(
+  $node['votes'] = array(
     'name' => t("Poll votes"),
     'description' => t("The number of votes that have been cast on a poll."),
   );
-  $node['poll-winner'] = array(
+  $node['winner'] = array(
     'name' => t("Poll winner"),
     'description' => t("The winning poll answer."),
   );
-  $node['poll-winner-votes'] = array(
+  $node['winner-votes'] = array(
     'name' => t("Poll winner votes"),
     'description' => t("The number of votes received by the winning poll answer."),
   );
-  $node['poll-winner-percent'] = array(
+  $node['winner-percent'] = array(
     'name' => t("Poll winner percent"),
     'description' => t("The percentage of votes received by the winning poll answer."),
   );
-  $node['poll-duration'] = array(
+  $node['duration'] = array(
     'name' => t("Poll duration"),
     'description' => t("The length of time the poll is set to run."),
   );
 
   return array(
-    'tokens' => array('node' => $node),
+    'tokens' => array('poll' => $node),
   );
 }
 
@@ -42,55 +43,51 @@ function poll_token_info() {
  */
 function poll_tokens($type, $tokens, array $data, array $options, BubbleableMetadata $bubbleable_metadata) {
   $sanitize = !empty($options['sanitize']);
-  if (isset($options['langcode'])) {
-    $url_options['language'] = \Drupal::languageManager()->getLanguage($options['langcode']);
-    $langcode = $options['langcode'];
-  }
-  else {
-    $langcode = NULL;
-  }
-
   $replacements = array();
 
-  if ($type == 'node' && !empty($data['node']) && $data['node']->type == 'poll') {
-    $node = $data['node'];
+  if ($type == 'poll' && !empty($data['poll'])) {
+    /** @var \Drupal\poll\Entity\Poll $poll */
+    $poll = $data['poll'];
 
     $total_votes = 0;
     $highest_votes = 0;
-    foreach ($node->choice as $choice) {
-      if ($choice['chvotes'] > $highest_votes) {
-        $winner = $choice;
-        $highest_votes = $choice['chvotes'];
+    foreach ($poll->votes as $vote) {
+      $total_votes += $vote;
+    }
+    $options = $poll->getOptions();
+    foreach ($poll->votes as $pid => $vote) {
+      if ($vote > $highest_votes) {
+        $winner = $options[$pid];
+        $highest_votes = $vote;
       }
-      $total_votes = $total_votes + $choice['chvotes'];
     }
     foreach ($tokens as $name => $original) {
       switch ($name) {
-        case 'poll-votes':
+        case 'votes':
           $replacements[$original] = $total_votes;
           break;
 
-        case 'poll-winner':
+        case 'winner':
           if (isset($winner)) {
-            $replacements[$original] = $sanitize ? filter_xss($winner['chtext']) : $winner['chtext'];
+            $replacements[$original] = $sanitize ? Xss::filter($winner) : $winner;
           }
           else {
             $replacements[$original] = '';
           }
           break;
 
-        case 'poll-winner-votes':
+        case 'winner-votes':
           if (isset($winner)) {
-            $replacements[$original] = $winner['chvotes'];
+            $replacements[$original] = $highest_votes;
           }
           else {
             $replacements[$original] = '';
           }
           break;
 
-        case 'poll-winner-percent':
+        case 'winner-percent':
           if (isset($winner)) {
-            $percent = ($winner['chvotes'] / $total_votes) * 100;
+            $percent = ($highest_votes / $total_votes) * 100;
             $replacements[$original] = number_format($percent, 0);
           }
           else {
@@ -98,8 +95,8 @@ function poll_tokens($type, $tokens, array $data, array $options, BubbleableMeta
           }
           break;
 
-        case 'poll-duration':
-          $replacements[$original] = format_interval($node->runtime, 1, $langcode);
+        case 'duration':
+          $replacements[$original] = \Drupal::service('date.formatter')->formatInterval($poll->getRuntime());
           break;
       }
     }
diff --git a/src/Form/PollViewForm.php b/src/Form/PollViewForm.php
index ffd1dcc..6e3ee1c 100644
--- a/src/Form/PollViewForm.php
+++ b/src/Form/PollViewForm.php
@@ -11,6 +11,7 @@ use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Form\FormBase;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\Url;
+use Drupal\poll\Entity\Poll;
 use Drupal\poll\PollInterface;
 use Symfony\Component\HttpFoundation\Request;
 
@@ -51,12 +52,18 @@ class PollViewForm extends FormBase {
     }
     else {
       $options = $poll->getOptions();
-      if ($options) {
+      $elements = array();
+      $i = 1;
+      foreach ($options as $option) {
+        $elements[$i] = $option;
+        $i++;
+      }
+      if ($elements) {
         $form['choice'] = array(
           '#type' => 'radios',
           '#title' => t('Choices'),
           '#title_display' => 'invisible',
-          '#options' => $options,
+          '#options' => $elements,
         );
       }
       // Add the poll to the form.
@@ -254,7 +261,18 @@ class PollViewForm extends FormBase {
    */
   public function save(array $form, FormStateInterface $form_state) {
     $options = array();
-    $options['chid'] = $form_state->getValue('choice');
+    $choice = $form_state->getValue('choice');
+    /** @var Poll $poll */
+    $poll = Poll::load($form_state->getValue('poll')->id());
+    $elements = $poll->getOptions();
+    $count = 1;
+    foreach ($elements as $delta => $option) {
+      if ($count == $choice) {
+        $chid = $delta;
+      }
+      $count++;
+    }
+    $options['chid'] = $chid;
     $options['uid'] = $this->currentUser()->id();
     $options['pid'] = $form_state->getValue('poll')->id();
     $options['hostname'] = \Drupal::request()->getClientIp();
diff --git a/src/Tests/PollTestBase.php b/src/Tests/PollTestBase.php
index f4dff33..049560b 100644
--- a/src/Tests/PollTestBase.php
+++ b/src/Tests/PollTestBase.php
@@ -68,8 +68,8 @@ abstract class PollTestBase extends WebTestBase {
     list($edit, $index) = $this->pollGenerateEdit($question, $choices);
 
     // Re-submit the form until all choices are filled in.
-    if (count($choices) > 1) {
-      while ($index < count($choices)) {
+    if (count($choices) > 0) {
+      for ($delta = 0; $delta <= count($choices); $delta++) {
         $this->drupalPostForm(NULL, $edit, t('Add another item'));
         list($edit, $index) = $this->pollGenerateEdit($question, $choices, $index);
       }
@@ -84,7 +84,9 @@ abstract class PollTestBase extends WebTestBase {
     $this->drupalPostForm(NULL, $edit, t('Save'));
 
     // Load the first node returned from the database.
-    $polls = entity_load_multiple_by_properties('poll', array('question' => $question));
+    $polls = \Drupal::entityManager()
+      ->getStorage('poll')
+      ->loadByProperties(array('question' => $question));
     $poll = reset($polls);
     $this->assertText(t('The poll @question has been added.', array('@question' => $question)), 'Poll has been created.');
     $this->assertTrue($poll->id, 'Poll has been found in the database.');
diff --git a/src/Tests/PollTokenReplaceTest.php b/src/Tests/PollTokenReplaceTest.php
index 14002a7..c205445 100644
--- a/src/Tests/PollTokenReplaceTest.php
+++ b/src/Tests/PollTokenReplaceTest.php
@@ -6,6 +6,8 @@
  */
 
 namespace Drupal\poll\Tests;
+use Drupal\Component\Utility\Xss;
+use Drupal\poll\Entity\Poll;
 
 /**
  * Tests poll token replacements in strings.
@@ -17,70 +19,71 @@ class PollTokenReplaceTest extends PollTestBase {
   /**
    * Creates a poll, then tests the tokens generated from it.
    */
-  function testPollTokenReplacement() {
-//    $language_interface = language(LANGUAGE_TYPE_INTERFACE);
-
-    // Craete a poll with three choices.
+  protected function testPollTokenReplacement() {
+    // Create a poll with three choices.
     $poll = $this->pollCreate(3);
+    $poll->save();
     $poll_nid = $poll->id();
 
     // Create four users and have each of them vote.
-//    $vote_user1 = $this->drupalCreateUser(array('vote on polls', 'access content'));
-//    $this->drupalLogin($vote_user1);
-//    $edit = array(
-//      'choice' => '1',
-//    );
-//    $this->drupalPost('node/' . $poll_nid, $edit, t('Vote'));
-//    $this->drupalLogout();
+    $vote_user1 = $this->drupalCreateUser(array('access polls', 'access content'));
+    $this->drupalLogin($vote_user1);
+    $edit = array(
+      'choice' => 1,
+    );
+    $this->drupalPostForm('poll/' . $poll_nid, $edit, t('Vote'));
+    $this->drupalLogout();
+
+    $vote_user2 = $this->drupalCreateUser(array('access polls', 'access content'));
+    $this->drupalLogin($vote_user2);
+    $edit = array(
+      'choice' => 1,
+    );
+    $this->drupalPostForm('poll/' . $poll_nid, $edit, t('Vote'));
+    $this->drupalLogout();
 
-//    $vote_user2 = $this->drupalCreateUser(array('vote on polls', 'access content'));
-//    $this->drupalLogin($vote_user2);
-//    $edit = array(
-//      'choice' => '1',
-//    );
-//    $this->drupalPost('node/' . $poll_nid, $edit, t('Vote'));
-//    $this->drupalLogout();
+    $vote_user3 = $this->drupalCreateUser(array('access polls', 'access content'));
+    $this->drupalLogin($vote_user3);
+    $edit = array(
+      'choice' => 2,
+    );
+    $this->drupalPostForm('poll/' . $poll_nid, $edit, t('Vote'));
+    $this->drupalLogout();
 
-//    $vote_user3 = $this->drupalCreateUser(array('vote on polls', 'access content'));
-//    $this->drupalLogin($vote_user3);
-//    $edit = array(
-//      'choice' => '2',
-//    );
-//    $this->drupalPost('node/' . $poll_nid, $edit, t('Vote'));
-//    $this->drupalLogout();
+    $vote_user4 = $this->drupalCreateUser(array('access polls', 'access content'));
+    $this->drupalLogin($vote_user4);
+    $edit = array(
+      'choice' => 3,
+    );
+    $this->drupalPostForm('poll/' . $poll_nid, $edit, t('Vote'));
+    $this->drupalLogout();
 
-//    $vote_user4 = $this->drupalCreateUser(array('vote on polls', 'access content'));
-//    $this->drupalLogin($vote_user4);
-//    $edit = array(
-//      'choice' => '3',
-//    );
-//    $this->drupalPost('node/' . $poll_nid, $edit, t('Vote'));
-//    $this->drupalLogout();
-//
-//    $poll = node_load($poll_nid, TRUE);
+    /** @var Poll $poll */
+    $poll = Poll::load($poll_nid);
 
     // Generate and test sanitized tokens.
-//    $tests = array();
-//    $tests['[node:poll-votes]'] = 4;
-//    $tests['[node:poll-winner]'] = filter_xss($poll->choice[1]['chtext']);
-//    $tests['[node:poll-winner-votes]'] = 2;
-//    $tests['[node:poll-winner-percent]'] = 50;
-//    $tests['[node:poll-duration]'] = format_interval($poll->runtime, 1, $language_interface->langcode);
+    $tests = array();
+    $tests['[poll:votes]'] = 4;
+    $tests['[poll:winner]'] = Xss::filter($poll->getOptions()[1 + 7]);
+    $tests['[poll:winner-votes]'] = 2;
+    $tests['[poll:winner-percent]'] = 50;
+    $tests['[poll:duration]'] = \Drupal::service('date.formatter')->formatInterval($poll->getRuntime());
 
     // Test to make sure that we generated something for each token.
-//    $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.');
+    $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.');
 
-//    foreach ($tests as $input => $expected) {
-//      $output = token_replace($input, array('node' => $poll), array('langcode' => $language_interface->langcode));
-//      $this->assertEqual($output, $expected, format_string('Sanitized poll token %token replaced.', array('%token' => $input)));
-//    }
+    $token = \Drupal::service('token');
+    foreach ($tests as $input => $expected) {
+      $output = $token->replace($input, array('poll' => $poll));
+      $this->assertEqual($output, $expected, format_string('Sanitized poll token %token replaced.', array('%token' => $input)));
+    }
 
     // Generate and test unsanitized tokens.
-//    $tests['[node:poll-winner]'] = $poll->choice[1]['chtext'];
+    $tests['[poll:winner]'] = $poll->getOptions()[1 + 7];
 
-//    foreach ($tests as $input => $expected) {
-//      $output = token_replace($input, array('node' => $poll), array('langcode' => $language_interface->langcode, 'sanitize' => FALSE));
-//      $this->assertEqual($output, $expected, format_string('Unsanitized poll token %token replaced.', array('%token' => $input)));
-//    }
+    foreach ($tests as $input => $expected) {
+      $output = $token->replace($input, array('poll' => $poll), array('sanitize' => FALSE));
+      $this->assertEqual($output, $expected, format_string('Unsanitized poll token %token replaced.', array('%token' => $input)));
+    }
   }
 }
