diff --git a/core/lib/Drupal/Core/Session/AccountInterface.php b/core/lib/Drupal/Core/Session/AccountInterface.php
index 1dbc13c..ed94bf3 100644
--- a/core/lib/Drupal/Core/Session/AccountInterface.php
+++ b/core/lib/Drupal/Core/Session/AccountInterface.php
@@ -55,4 +55,44 @@ public function getSecureSessionId();
    */
   public function getSessionData();
 
+  /**
+   * Returns TRUE if the account is authenticated.
+   *
+   * @return bool
+   *   TRUE if the account is authenticated.
+   */
+  public function isAuthenticated();
+
+  /**
+   * Returns TRUE if the account is anonymous.
+   *
+   * @return bool
+   *   TRUE if the account is anonymous.
+   */
+  public function isAnonymous();
+
+  /**
+   * Returns the preferred language code of the account.
+   *
+   * @param $type
+   *   Optional string to define which preferred langcode should be used.
+   *   Default to 'preferred_langcode' property.
+   *   If set 'preferred_$type_langcode' is used.
+   * @param $default
+   *   Optional default language code to return if the account
+   *   has no valid language.
+   *
+   * @return string
+   *   The language code that is preferred by the account.
+   */
+  public function getPreferredLangcode($type = NULL, $default = NULL);
+
+  /**
+   * Returns the user name.
+   *
+   * @return string
+   *   Unchanged name of the user.
+   */
+  public function getUsername();
+
 }
diff --git a/core/lib/Drupal/Core/Session/UserSession.php b/core/lib/Drupal/Core/Session/UserSession.php
index 300cd8f..abda3f4 100644
--- a/core/lib/Drupal/Core/Session/UserSession.php
+++ b/core/lib/Drupal/Core/Session/UserSession.php
@@ -66,6 +66,27 @@ class UserSession implements AccountInterface {
   public $timestamp;
 
   /**
+   * The name of this account.
+   *
+   * @var string
+   */
+  public $name;
+
+  /**
+   * The preferred language code of the account.
+   *
+   * @var string
+   */
+  protected $preferred_langcode;
+
+  /**
+   * The preferred language code of the account.
+   *
+   * @var string
+   */
+  protected $preferred_admin_langcode;
+
+  /**
    * Constructs a new user session.
    *
    * @param array $values
@@ -112,4 +133,45 @@ public function getSessionId() {
     return $this->sid;
   }
 
+  /**
+   * {@inheritdoc}
+   */
+  public function isAuthenticated() {
+    return $this->uid > 0;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function isAnonymous() {
+    return $this->uid == 0;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  function getPreferredLangcode($type = NULL, $default = NULL) {
+    $language_list = language_list();
+    if (isset($type)) {
+      $preferred_langcode = $this->{'preferred_' . $type . '_langcode'};
+    }
+    else {
+      $preferred_langcode = $this->preferred_langcode;
+    }
+    if (!empty($preferred_langcode) && isset($language_list[$preferred_langcode])) {
+      return $language_list[$preferred_langcode]->langcode;
+    }
+    else {
+      return $default ? $default : language_default()->langcode;
+    }
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getUsername() {
+    return $this->name;
+  }
+
+
 }
diff --git a/core/modules/dblog/dblog.admin.inc b/core/modules/dblog/dblog.admin.inc
index cf744b0..d88cf40 100644
--- a/core/modules/dblog/dblog.admin.inc
+++ b/core/modules/dblog/dblog.admin.inc
@@ -108,7 +108,7 @@ function dblog_event($id) {
       ),
       array(
         array('data' => t('User'), 'header' => TRUE),
-        theme('username', array('account' => $dblog)),
+        theme('username', array('account' => user_load($dblog->uid))),
       ),
       array(
         array('data' => t('Location'), 'header' => TRUE),
diff --git a/core/modules/dblog/lib/Drupal/dblog/Controller/DbLogController.php b/core/modules/dblog/lib/Drupal/dblog/Controller/DbLogController.php
index b597c89..386bb9b 100644
--- a/core/modules/dblog/lib/Drupal/dblog/Controller/DbLogController.php
+++ b/core/modules/dblog/lib/Drupal/dblog/Controller/DbLogController.php
@@ -124,7 +124,6 @@ public function overview() {
     $query = $this->database->select('watchdog', 'w')
       ->extend('Drupal\Core\Database\Query\PagerSelectExtender')
       ->extend('Drupal\Core\Database\Query\TableSortExtender');
-    $query->leftJoin('users', 'u', 'w.uid = u.uid');
     $query->fields('w', array(
       'wid',
       'uid',
@@ -134,8 +133,7 @@ public function overview() {
       'message',
       'variables',
       'link',
-      ));
-    $query->addField('u', 'name');
+    ));
 
     if (!empty($filter['where'])) {
       $query->where($filter['where'], $filter['args']);
@@ -169,7 +167,7 @@ public function overview() {
           t($dblog->type),
           format_date($dblog->timestamp, 'short'),
           $message,
-          theme('username', array('account' => $dblog)),
+          theme('username', array('account' => user_load($dblog->uid))),
           filter_xss($dblog->link),
         ),
         // Attributes for table row.
diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module
index c06edde..01827e1 100644
--- a/core/modules/forum/forum.module
+++ b/core/modules/forum/forum.module
@@ -1213,7 +1213,7 @@ function template_preprocess_forum_icon(&$variables) {
  *   - topic: The topic object.
  */
 function template_preprocess_forum_submitted(&$variables) {
-  $variables['author'] = isset($variables['topic']->uid) ? theme('username', array('account' => $variables['topic'])) : '';
+  $variables['author'] = isset($variables['topic']->uid) ? theme('username', array('account' => user_load($variables['topic']->uid))) : '';
   $variables['time'] = isset($variables['topic']->created) ? format_interval(REQUEST_TIME - $variables['topic']->created) : '';
 }
 
diff --git a/core/modules/language/language.module b/core/modules/language/language.module
index 6b45fa1..ac504ba 100644
--- a/core/modules/language/language.module
+++ b/core/modules/language/language.module
@@ -450,8 +450,9 @@ function language_get_default_langcode($entity_type, $bundle) {
 
     case 'authors_default':
       global $user;
-      if (!empty($user->preferred_langcode)) {
-        $default_value = $user->preferred_langcode;
+      $language_code = $user->getPreferredLangcode();
+      if (!empty($language_code)) {
+        $default_value = $language_code;
       }
       else {
         $default_value = $language_interface->langcode;
diff --git a/core/modules/language/language.negotiation.inc b/core/modules/language/language.negotiation.inc
index 82bf713..aabd36c 100644
--- a/core/modules/language/language.negotiation.inc
+++ b/core/modules/language/language.negotiation.inc
@@ -196,8 +196,12 @@ function language_from_user($languages) {
   // User preference (only for authenticated users).
   global $user;
 
-  if ($user->uid && !empty($user->preferred_langcode) && isset($languages[$user->preferred_langcode])) {
-    return $user->preferred_langcode;
+  if ($user->id()) {
+    $langcode = $user->getPreferredLangcode();
+    $default_langcode = language_default()->langcode;
+    if (!empty($langcode) && $langcode != $default_langcode && isset($languages[$langcode])) {
+      return $langcode;
+    }
   }
 
   // No language preference from the user.
@@ -221,9 +225,13 @@ function language_from_user_admin(array $languages, Request $request = NULL) {
   // User preference (only for authenticated users).
   global $user;
 
-  $request_path = $request ? urldecode(trim($request->getPathInfo(), '/')) : _current_path();
-  if ($user->uid && !empty($user->preferred_admin_langcode) && isset($languages[$user->preferred_admin_langcode]) && path_is_admin($request_path)) {
-    return $user->preferred_admin_langcode;
+  if ($user->id()) {
+    $request_path = $request ? urldecode(trim($request->getPathInfo(), '/')) : _current_path();
+    $langcode = $user->getPreferredLangcode('admin');
+    $default_langcode = language_default()->langcode;
+    if (!empty($langcode) && $langcode != $default_langcode && isset($languages[$langcode]) && path_is_admin($request_path)) {
+      return $langcode;
+    }
   }
 
   // No language preference from the user or not on an admin path.
@@ -246,7 +254,7 @@ function language_from_session($languages) {
   // an authenticated user.
   if (isset($_GET[$param]) && isset($languages[$langcode = $_GET[$param]])) {
     global $user;
-    if ($user->uid) {
+    if ($user->id()) {
       $_SESSION[$param] = $langcode;
     }
     return $langcode;
@@ -484,7 +492,7 @@ function language_url_rewrite_session(&$path, &$options) {
   // request processing.
   if (!isset($query_rewrite)) {
     global $user;
-    if (!$user->uid) {
+    if (!$user->id()) {
       $languages = language_list();
       $query_param = check_plain(config('language.negotiation')->get('session.parameter'));
       $query_value = isset($_GET[$query_param]) ? check_plain($_GET[$query_param]) : NULL;
diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php
index c9c05e8..b9b7c48 100644
--- a/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php
+++ b/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php
@@ -279,7 +279,7 @@ function testUILanguageNegotiation() {
       'expect' => $language_string,
       'expected_method_id' => LANGUAGE_NEGOTIATION_USER,
       'http_header' => array(),
-      'message' => 'USER > DEFAULT: defined prefereed user language setting, the UI language is based on user setting',
+      'message' => 'USER > DEFAULT: defined preferred user language setting, the UI language is based on user setting',
     );
     $this->runTest($test);
 
@@ -321,7 +321,7 @@ function testUILanguageNegotiation() {
       'expect' => $language_string,
       'expected_method_id' => LANGUAGE_NEGOTIATION_USER_ADMIN,
       'http_header' => array(),
-      'message' => 'USER ADMIN > DEFAULT: defined prefereed user admin language setting, the UI language is based on user setting',
+      'message' => 'USER ADMIN > DEFAULT: defined preferred user admin language setting, the UI language is based on user setting',
     );
     $this->runTest($test);
 
diff --git a/core/modules/node/node.admin.inc b/core/modules/node/node.admin.inc
index 821f41a..e72eba5 100644
--- a/core/modules/node/node.admin.inc
+++ b/core/modules/node/node.admin.inc
@@ -276,7 +276,7 @@ function node_admin_nodes() {
     );
     $form['nodes'][$node->nid]['author'] = array(
       '#theme' => 'username',
-      '#account' => $node,
+      '#account' => user_load($node->uid),
     );
     $form['nodes'][$node->nid]['status'] = array(
       '#markup' => $node->status ? t('published') : t('not published'),
diff --git a/core/modules/node/node.module b/core/modules/node/node.module
index fbdf07d..a8b79a7 100644
--- a/core/modules/node/node.module
+++ b/core/modules/node/node.module
@@ -1046,7 +1046,7 @@ function template_preprocess_node(&$variables) {
   //   http://drupal.org/node/1941286.
   $username = array(
     '#theme' => 'username',
-    '#account' => $node,
+    '#account' => user_load($node->uid),
     '#link_options' => array('attributes' => array('rel' => 'author')),
   );
   $variables['name'] = drupal_render($username);
@@ -1302,7 +1302,7 @@ function node_search_execute($keys = NULL, $conditions = NULL) {
     $uri = $node->uri();
     $username = array(
       '#theme' => 'username',
-      '#account' => $node,
+      '#account' => user_load($node->uid),
     );
     $results[] = array(
       'link' => url($uri['path'], array_merge($uri['options'], array('absolute' => TRUE, 'language' => $language))),
diff --git a/core/modules/node/node.pages.inc b/core/modules/node/node.pages.inc
index a731f40..abe0d54 100644
--- a/core/modules/node/node.pages.inc
+++ b/core/modules/node/node.pages.inc
@@ -254,7 +254,7 @@ function node_revision_overview($node) {
     if ($revision->current_vid > 0) {
       $username = array(
         '#theme' => 'username',
-        '#account' => $revision,
+        '#account' => user_load($revision->uid),
       );
       $row[] = array('data' => t('!date by !username', array('!date' => l(format_date($revision->revision_timestamp, 'short'), "node/$node->nid"), '!username' => drupal_render($username)))
                                . (($revision->log != '') ? '<p class="revision-log">' . filter_xss($revision->log) . '</p>' : ''),
@@ -264,7 +264,7 @@ function node_revision_overview($node) {
     else {
       $username = array(
         '#theme' => 'username',
-        '#account' => $revision,
+        '#account' => user_load($revision->uid),
       );
       $row[] = t('!date by !username', array('!date' => l(format_date($revision->revision_timestamp, 'short'), "node/$node->nid/revisions/$revision->vid/view"), '!username' => drupal_render($username)))
                . (($revision->log != '') ? '<p class="revision-log">' . filter_xss($revision->log) . '</p>' : '');
diff --git a/core/modules/rest/lib/Drupal/rest/Access/CSRFAccessCheck.php b/core/modules/rest/lib/Drupal/rest/Access/CSRFAccessCheck.php
index 584be0c..52a33ea 100644
--- a/core/modules/rest/lib/Drupal/rest/Access/CSRFAccessCheck.php
+++ b/core/modules/rest/lib/Drupal/rest/Access/CSRFAccessCheck.php
@@ -50,7 +50,7 @@ public function access(Route $route, Request $request) {
     // 2. the user was successfully authenticated and
     // 3. the request comes with a session cookie.
     if (!in_array($method, array('GET', 'HEAD', 'OPTIONS', 'TRACE'))
-      && user_is_logged_in()
+      && $GLOBALS['user']->isAuthenticated()
       && $cookie
     ) {
       $csrf_token = $request->headers->get('X-CSRF-Token');
diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/UpgradePathTestBase.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/UpgradePathTestBase.php
index b613121..cf677ce 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/UpgradePathTestBase.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/UpgradePathTestBase.php
@@ -11,6 +11,7 @@
 use Drupal\Core\Database\Database;
 use Drupal\Core\DependencyInjection\ContainerBuilder;
 use Drupal\Core\DrupalKernel;
+use Drupal\Core\Session\UserSession;
 use Drupal\simpletest\WebTestBase;
 use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
 use Symfony\Component\HttpFoundation\Request;
@@ -144,15 +145,12 @@ protected function setUp() {
     // Ensure that the session is not written to the new environment and replace
     // the global $user session with uid 1 from the new test site.
     drupal_save_session(FALSE);
-    // Login as uid 1.
-    $user = db_query('SELECT * FROM {users} WHERE uid = :uid', array(':uid' => 1))->fetchObject();
-    // Load roles for the user object.
-    $roles = array(DRUPAL_AUTHENTICATED_RID => DRUPAL_AUTHENTICATED_RID);
-    $result = db_query('SELECT rid, uid FROM {users_roles} WHERE uid = :uid', array(':uid' => 1));
-    foreach ($result as $record) {
-      $roles[$record->rid] = $record->rid;
-    }
-    $user->roles = $roles;
+    // Load values for uid 1.
+    $values = db_query('SELECT * FROM {users} WHERE uid = :uid', array(':uid' => 1))->fetchAssoc();
+    // Load rolest.
+    $values['roles'] = array_merge(array(DRUPAL_AUTHENTICATED_RID), db_query('SELECT rid FROM {users_roles} WHERE uid = :uid', array(':uid' => 1))->fetchCol());
+    // Create a new user session object.
+    $user = new UserSession($values);
 
     // Generate and set a D8-compatible session cookie.
     $this->prepareD8Session();
diff --git a/core/modules/tracker/tracker.pages.inc b/core/modules/tracker/tracker.pages.inc
index d33e1f3..3782a4b 100644
--- a/core/modules/tracker/tracker.pages.inc
+++ b/core/modules/tracker/tracker.pages.inc
@@ -83,7 +83,7 @@ function tracker_page($account = NULL, $set_title = FALSE) {
         'type' => check_plain(node_get_type_label($node)),
         // Do not use $node->label(), because $node comes from the database.
         'title' => array('data' => l($node->title, 'node/' . $node->nid) . ' ' . drupal_render($mark_build)),
-        'author' => array('data' => array('#theme' => 'username', '#account' => $node)),
+        'author' => array('data' => array('#theme' => 'username', '#account' => user_load($node->uid))),
         'replies' => array('class' => array('replies'), 'data' => $comments),
         'last updated' => array('data' => t('!time ago', array('!time' => format_interval(REQUEST_TIME - $node->last_activity)))),
       );
diff --git a/core/modules/user/lib/Drupal/user/EventSubscriber/MaintenanceModeSubscriber.php b/core/modules/user/lib/Drupal/user/EventSubscriber/MaintenanceModeSubscriber.php
index bfaee91..2c47414 100644
--- a/core/modules/user/lib/Drupal/user/EventSubscriber/MaintenanceModeSubscriber.php
+++ b/core/modules/user/lib/Drupal/user/EventSubscriber/MaintenanceModeSubscriber.php
@@ -29,7 +29,7 @@ public function onKernelRequestMaintenance(GetResponseEvent $event) {
     $path = $request->attributes->get('system_path');
     if ($site_status == MENU_SITE_OFFLINE) {
       // If the site is offline, log out unprivileged users.
-      if (user_is_logged_in() && !user_access('access site in maintenance mode')) {
+      if ($GLOBALS['user']->isAuthenticated() && !user_access('access site in maintenance mode')) {
         user_logout();
         // Redirect to homepage.
         $event->setResponse(new RedirectResponse(url('<front>', array('absolute' => TRUE))));
@@ -56,7 +56,7 @@ public function onKernelRequestMaintenance(GetResponseEvent $event) {
         }
       }
     }
-    if (user_is_logged_in()) {
+    if ($GLOBALS['user']->isAuthenticated()) {
       if ($path == 'user/login') {
         // If user is logged in, redirect to 'user' instead of giving 403.
         $event->setResponse(new RedirectResponse(url('user', array('absolute' => TRUE))));
@@ -64,7 +64,7 @@ public function onKernelRequestMaintenance(GetResponseEvent $event) {
       }
       if ($path == 'user/register') {
         // Authenticated user should be redirected to user edit page.
-        $event->setResponse(new RedirectResponse(url('user/' . $GLOBALS['user']->uid . '/edit', array('absolute' => TRUE))));
+        $event->setResponse(new RedirectResponse(url('user/' . $GLOBALS['user']->id() . '/edit', array('absolute' => TRUE))));
         return;
       }
     }
diff --git a/core/modules/user/lib/Drupal/user/Plugin/Block/UserNewBlock.php b/core/modules/user/lib/Drupal/user/Plugin/Block/UserNewBlock.php
index d7269a3..26be5ba 100644
--- a/core/modules/user/lib/Drupal/user/Plugin/Block/UserNewBlock.php
+++ b/core/modules/user/lib/Drupal/user/Plugin/Block/UserNewBlock.php
@@ -66,12 +66,12 @@ public function blockSubmit($form, &$form_state) {
    */
   public function build() {
     // Retrieve a list of new users who have accessed the site successfully.
-    $items = db_query_range('SELECT uid, name FROM {users} WHERE status <> 0 AND access <> 0 ORDER BY created DESC', 0, $this->configuration['whois_new_count'])->fetchAll();
+    $uids = db_query_range('SELECT uid FROM {users} WHERE status <> 0 AND access <> 0 ORDER BY created DESC', 0, $this->configuration['whois_new_count'])->fetchCol();
     $build = array(
       '#theme' => 'item_list__user__new',
       '#items' => array(),
     );
-    foreach ($items as $account) {
+    foreach (user_load_multiple($uids) as $account) {
       $username = array(
         '#theme' => 'username',
         '#account' => $account,
diff --git a/core/modules/user/lib/Drupal/user/Plugin/Core/Entity/User.php b/core/modules/user/lib/Drupal/user/Plugin/Core/Entity/User.php
index c9a671b..77cabc9 100644
--- a/core/modules/user/lib/Drupal/user/Plugin/Core/Entity/User.php
+++ b/core/modules/user/lib/Drupal/user/Plugin/Core/Entity/User.php
@@ -53,134 +53,6 @@
 class User extends EntityNG implements UserInterface {
 
   /**
-   * The user ID.
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
-   */
-  public $uid;
-
-  /**
-   * The user UUID.
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
-   */
-  public $uuid;
-
-  /**
-   * The unique user name.
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
-   */
-  public $name;
-
-  /**
-   * The user's password (hashed).
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
-   */
-  public $pass;
-
-  /**
-   * The user's email address.
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
-   */
-  public $mail;
-
-  /**
-   * The user's default theme.
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
-   */
-  public $theme;
-
-  /**
-   * The user's signature.
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
-   */
-  public $signature;
-
-  /**
-   * The user's signature format.
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
-   */
-  public $signature_format;
-
-  /**
-   * The timestamp when the user was created.
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
-   */
-  public $created;
-
-  /**
-   * The timestamp when the user last accessed the site. A value of 0 means the
-   * user has never accessed the site.
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
-   */
-  public $access;
-
-  /**
-   * The timestamp when the user last logged in. A value of 0 means the user has
-   * never logged in.
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
-   */
-  public $login;
-
-  /**
-   * Whether the user is active (1) or blocked (0).
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
-   */
-  public $status;
-
-  /**
-   * The user's timezone.
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
-   */
-  public $timezone;
-
-  /**
-   * The user's langcode.
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
-   */
-  public $langcode;
-
-  /**
-   * The user's preferred langcode for receiving emails and viewing the site.
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
-   */
-  public $preferred_langcode;
-
-  /**
-   * The user's preferred langcode for viewing administration pages.
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
-   */
-  public $preferred_admin_langcode;
-
-  /**
-   * The email address used for initial account creation.
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
-   */
-  public $init;
-
-  /**
-   * The user's roles.
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
-   */
-  public $roles;
-
-  /**
    * {@inheritdoc}
    */
   public function id() {
@@ -190,30 +62,6 @@ public function id() {
   /**
    * {@inheritdoc}
    */
-  protected function init() {
-    parent::init();
-    unset($this->access);
-    unset($this->created);
-    unset($this->init);
-    unset($this->login);
-    unset($this->mail);
-    unset($this->name);
-    unset($this->pass);
-    unset($this->preferred_admin_langcode);
-    unset($this->preferred_langcode);
-    unset($this->roles);
-    unset($this->signature);
-    unset($this->signature_format);
-    unset($this->status);
-    unset($this->theme);
-    unset($this->timezone);
-    unset($this->uid);
-    unset($this->uuid);
-  }
-
-  /**
-   * {@inheritdoc}
-   */
   static function preCreate(EntityStorageControllerInterface $storage_controller, array &$values) {
     if (!isset($values['created'])) {
       $values['created'] = REQUEST_TIME;
@@ -301,6 +149,7 @@ public static function postDelete(EntityStorageControllerInterface $storage_cont
     $storage_controller->deleteUserRoles($uids);
   }
 
+
   /**
    * {@inheritdoc}
    */
@@ -337,7 +186,6 @@ public function getSecureSessionId() {
   public function getSessionData() {
     return array();
   }
-
   /**
    * {@inheritdoc}
    */
@@ -368,4 +216,173 @@ public function removeRole($rid) {
     $this->set('roles', array_diff($this->getRoles(), array($rid)));
   }
 
+  /**
+   * {@inheritdoc}
+   */
+  public function getPassword() {
+    return $this->get('pass')->value;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function setPassword($password) {
+    $this->get('pass')->value = $password;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getEmail() {
+    return $this->get('mail')->value;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function setEmail($mail) {
+    $this->get('mail')->value = $mail;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getDefaultTheme() {
+    return $this->get('theme')->value;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getSignature() {
+    return $this->get('signature')->value;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getSignatureFormat() {
+    return $this->get('signature_format')->value;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getCreatedTime() {
+    return $this->get('created')->value;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getLastAccessedTime() {
+    return $this->get('access')->value;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function setLastAccessTime($timestamp) {
+    $this->get('access')->value = $timestamp;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getLastLoginTime() {
+    return $this->get('login')->value;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function setLastLoginTime($timestamp) {
+    $this->get('login')->value = $timestamp;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function isActive() {
+    return $this->get('status')->value == 1;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function isBlocked() {
+    return $this->get('status')->value == 0;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function activate() {
+    $this->get('status')->value = 1;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function block() {
+    $this->get('status')->value = 0;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getTimeZone() {
+    return $this->get('timezone')->value;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  function getPreferredLangcode($type = NULL, $default = NULL) {
+    $language_list = language_list();
+    if (isset($type)) {
+      $preferred_langcode = $this->get('preferred_' . $type . '_langcode')->value;
+    }
+    else {
+      $preferred_langcode = $this->get('preferred_langcode')->value;
+    }
+    if (!empty($preferred_langcode) && isset($language_list[$preferred_langcode])) {
+      return $language_list[$preferred_langcode]->langcode;
+    }
+    else {
+      return $default ? $default : language_default()->langcode;
+    }
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getInitialEmail() {
+    return $this->get('init')->value;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function isAuthenticated() {
+    return $this->id() > 0;
+  }
+  /**
+   * {@inheritdoc}
+   */
+  public function isAnonymous() {
+    return $this->id() == 0;
+  }
+
+  /**
+   * Returns the user name.
+   *
+   * @return string
+   *   Unchanged name of the user.
+   */
+  public function getUsername() {
+    return $this->get('name')->value;
+  }
+
+
 }
diff --git a/core/modules/user/lib/Drupal/user/Plugin/views/argument_validator/User.php b/core/modules/user/lib/Drupal/user/Plugin/views/argument_validator/User.php
index dc3b42b..8737b1e 100644
--- a/core/modules/user/lib/Drupal/user/Plugin/views/argument_validator/User.php
+++ b/core/modules/user/lib/Drupal/user/Plugin/views/argument_validator/User.php
@@ -124,7 +124,7 @@ public function validateArgument($argument) {
     }
     else {
       if ($type == 'name' || $type == 'either') {
-        $name = !empty($GLOBALS['user']->name) ? $GLOBALS['user']->name : config('user.settings')->get('anonymous');
+        $name = $GLOBALS['user']->getUserName() ?: config('user.settings')->get('anonymous');
         if ($argument == $name) {
           $account = clone $GLOBALS['user'];
         }
@@ -138,11 +138,11 @@ public function validateArgument($argument) {
     }
 
     if (!isset($account)) {
-      $account = $this->database->select('users', 'u')
-        ->fields('u', array('uid', 'name'))
+      $account = user_load($this->database->select('users', 'u')
+        ->fields('u', array('uid'))
         ->condition($condition, $argument)
         ->execute()
-        ->fetchObject();
+        ->fetchField());
     }
     if (empty($account)) {
       // User not found.
@@ -152,12 +152,7 @@ public function validateArgument($argument) {
     // See if we're filtering users based on roles.
     if (!empty($this->options['restrict_roles']) && !empty($this->options['roles'])) {
       $roles = $this->options['roles'];
-      $account->roles = array();
-      $account->roles[] = $account->uid ? DRUPAL_AUTHENTICATED_RID : DRUPAL_ANONYMOUS_RID;
-      foreach ($account->getRoles() as $rid) {
-        $account->roles[] = $rid;
-      }
-      if (!(bool) array_intersect($account->roles, $roles)) {
+      if (!(bool) array_intersect($account->getRoles(), $roles)) {
         return FALSE;
       }
     }
@@ -174,7 +169,7 @@ public function processSummaryArguments(&$args) {
     if ($this->options['type'] == 'name') {
       $users = user_load_multiple($args);
       foreach ($users as $uid => $account) {
-        $args[$uids_arg_keys[$uid]] = $account->name;
+        $args[$uids_arg_keys[$uid]] = $account->label();
       }
     }
   }
diff --git a/core/modules/user/lib/Drupal/user/UserBCDecorator.php b/core/modules/user/lib/Drupal/user/UserBCDecorator.php
index eed508b..7ac95f1 100644
--- a/core/modules/user/lib/Drupal/user/UserBCDecorator.php
+++ b/core/modules/user/lib/Drupal/user/UserBCDecorator.php
@@ -15,6 +15,12 @@
 class UserBCDecorator extends EntityBCDecorator implements UserInterface {
 
   /**
+   *
+   * @var \Drupal\user\UserInterface
+   */
+  protected $decorated;
+
+  /**
    * {@inheritdoc}
    */
   public function &__get($name) {
@@ -76,4 +82,159 @@ public function removeRole($rid) {
     $this->decorated->removeRole($rid);
   }
 
+  /**
+   * {@inheritdoc}
+   */
+  public function getPassword() {
+    return $this->decorated->getPassword();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function setPassword($password) {
+    $this->decorated->setPassword($password);
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getEmail() {
+    return $this->decorated->getEmail();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function setEmail($mail) {
+    $this->decorated->setEmail($mail);
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getDefaultTheme() {
+    return $this->decorated->getDefaultTheme();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getSignature() {
+    return $this->decorated->getDefaultTheme();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getSignatureFormat() {
+    return $this->decorated->getSignatureFormat();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getCreatedTime() {
+    return $this->decorated->getCreatedTime();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getLastAccessedTime() {
+    return $this->decorated->getLastAccessedTime();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function setLastAccessTime($timestamp) {
+    $this->decorated->setLastAccessTime($timestamp);
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getLastLoginTime() {
+    return $this->decorated->getLastLoginTime();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function setLastLoginTime($timestamp) {
+    $this->decorated->setLastLoginTime($timestamp);
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function isActive() {
+    $this->decorated->isActive();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function isBlocked() {
+    return $this->decorated->isBlocked();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function activate() {
+    $this->decorated->activate();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function block() {
+    $this->decorated->block();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getTimeZone() {
+    return $this->decorated->getTimeZone();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getPreferredLangcode($type = NULL, $default = NULL) {
+    return $this->decorated->getPreferredLangcode();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getInitialEmail() {
+    return $this->decorated->getInitialEmail();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function isAuthenticated() {
+    return $this->decorated->id() > 0;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function isAnonymous() {
+    return $this->decorated->id() == 0;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getUsername() {
+    return $this->decorated->getUsername();
+  }
+
+
 }
diff --git a/core/modules/user/lib/Drupal/user/UserInterface.php b/core/modules/user/lib/Drupal/user/UserInterface.php
index 4dc1481..59a13a8 100644
--- a/core/modules/user/lib/Drupal/user/UserInterface.php
+++ b/core/modules/user/lib/Drupal/user/UserInterface.php
@@ -50,4 +50,163 @@ public function addRole($rid);
    */
   public function removeRole($rid);
 
+  /**
+   * Returns the hashed password.
+   *
+   * @return string
+   *   The hashed password.
+   */
+  public function getPassword();
+
+  /**
+   * Sets the user password.
+   *
+   * @param string $password
+   *   The new unhashed password.
+   */
+  public function setPassword($password);
+
+  /**
+   * Returns the e-mail address of the user.
+   *
+   * @return string
+   *   The e-mail address.
+   */
+  public function getEmail();
+
+  /**
+   * Sets the e-mail address of the user.
+   *
+   * @param string $mail
+   *   The new e-mail address of the user.
+   */
+  public function setEmail($mail);
+
+  /**
+   * Returns the default theme of the user.
+   *
+   * @return string
+   *   Name of the theme.
+   */
+  public function getDefaultTheme();
+
+  /**
+   * Returns the user signature.
+   *
+   * @todo: Convert this to a field.
+   *
+   * @return string
+   *   The signature text.
+   */
+  public function getSignature();
+
+  /**
+   * Returns the signature format.
+   *
+   * @return string
+   *   Name of the filter format.
+   */
+  public function getSignatureFormat();
+
+  /**
+   * Returns the creation time of the user as a UNIX timestamp.
+   *
+   * @return int
+   *   Timestamp of the creation date.
+   *
+   */
+  public function getCreatedTime();
+
+  /**
+   * The timestamp when the user last accessed the site.
+   *
+   * A value of 0 means the user has never accessed the site.
+   *
+   * @return int
+   *   Timestamp of the last access.
+   */
+  public function getLastAccessedTime();
+
+  /**
+   * Sets the UNIX timestamp when the user last accessed the site..
+   *
+   * @param int $timestamp
+   *   Timestamp of the last access.
+   */
+  public function setLastAccessTime($timestamp);
+
+  /**
+   * Returns the UNIX timestamp when the user last logged in.
+   *
+   * @return int
+   *   Timestamp of the last login time.
+   */
+  public function getLastLoginTime();
+
+  /**
+   * Sets the UNIX timestamp when the user last logged in.
+   *
+   * @param int $timestamp
+   *   Timestamp of the last login time.
+   */
+  public function setLastLoginTime($timestamp);
+
+  /**
+   * Returns TRUE if the user is active.
+   *
+   * @return bool
+   *   TRUE if the user is active, false otherwise.
+   */
+  public function isActive();
+
+  /**
+   * Returns TRUE if the user is blocked.
+   *
+   * @return bool
+   *   TRUE if the user is blocked, false otherwise.
+   */
+  public function isBlocked();
+
+  /**
+   * Activates the user.
+   */
+  public function activate();
+
+  /**
+   * Blocks the user.
+   */
+  public function block();
+
+  /**
+   * Returns the timezone of the user.
+   *
+   * @return string
+   *   Name of the timezone.
+   */
+  public function getTimeZone();
+
+  /**
+   * Returns the preferred language code of the user.
+   *
+   * @param $type
+   *   Optional string to define which preferred langcode should be used.
+   *   Default to 'preferred_langcode' property.
+   *   If set 'preferred_$type_langcode' is used.
+   * @param $default
+   *   Optional default language code to return if the account
+   *   has no valid language.
+   *
+   * @return string
+   *   The language code that is preferred by the user.
+   */
+  public function getPreferredLangcode($type = NULL, $default = NULL);
+
+  /**
+   * Returns the e-mail that was used when the user was registered.
+   *
+   * @return string
+   *   Initial e-mail address of the user.
+   */
+  public function getInitialEmail();
+
 }
diff --git a/core/modules/user/user.module b/core/modules/user/user.module
index bf0b052..e1ee0f3 100644
--- a/core/modules/user/user.module
+++ b/core/modules/user/user.module
@@ -411,7 +411,8 @@ function user_password($length = 10) {
  * Determine the permissions for one or more roles.
  *
  * @param $roles
- *   An array whose values are the role IDs of interest, such as $user->roles.
+ *   An array whose values are the role IDs of interest, such as
+ *   \Drupal\Core\Session\AccountInterface::getRoles().
  *
  * @return
  *   An array indexed by role ID. Each value is an array whose keys are the
@@ -473,11 +474,8 @@ function user_access($string, AccountInterface $account = NULL) {
     $account = $user;
   }
 
-  // Make sure we are working with the BC decorator.
-  $account = $account instanceof User ? $account->getBCEntity() : $account;
-
   // User #1 has all privileges:
-  if ($account->uid == 1) {
+  if ($account->id() == 1) {
     return TRUE;
   }
 
@@ -489,17 +487,17 @@ function user_access($string, AccountInterface $account = NULL) {
     $drupal_static_fast['perm'] = &drupal_static(__FUNCTION__);
   }
   $perm = &$drupal_static_fast['perm'];
-  if (!isset($perm[$account->uid])) {
+  if (!isset($perm[$account->id()])) {
     $role_permissions = user_role_permissions($account->getRoles());
 
     $perms = array();
     foreach ($role_permissions as $one_role) {
       $perms += $one_role;
     }
-    $perm[$account->uid] = $perms;
+    $perm[$account->id()] = $perms;
   }
 
-  return isset($perm[$account->uid][$string]);
+  return isset($perm[$account->id()][$string]);
 }
 
 /**
@@ -600,10 +598,10 @@ function user_search_execute($keys = NULL, $conditions = NULL) {
   foreach ($accounts as $account) {
     $result = array(
       'title' => user_format_name($account),
-      'link' => url('user/' . $account->uid, array('absolute' => TRUE)),
+      'link' => url('user/' . $account->id(), array('absolute' => TRUE)),
     );
     if (user_access('administer users')) {
-      $result['title'] .= ' (' . $account->mail . ')';
+      $result['title'] .= ' (' . $account->getEmail() . ')';
     }
     $results[] = $result;
   }
@@ -687,7 +685,7 @@ function user_preprocess_block(&$variables) {
  *
  * @see hook_user_format_name_alter()
  *
- * @param $account
+ * @param \Drupal\Core\Session\Interface $account
  *   The account object for the user whose name is to be formatted.
  *
  * @return
@@ -695,8 +693,8 @@ function user_preprocess_block(&$variables) {
  *   this result must ensure that check_plain() is called on it before it is
  *   printed to the page.
  */
-function user_format_name($account) {
-  $name = !empty($account->name) ? $account->name : config('user.settings')->get('anonymous');
+function user_format_name(AccountInterface $account) {
+  $name = $account->getUsername() ?: Drupal::config('user.settings')->get('anonymous');
   drupal_alter('user_format_name', $name, $account);
   return $name;
 }
@@ -721,7 +719,7 @@ function user_template_preprocess_default_variables_alter(&$variables) {
   unset($variables['user']->pass, $variables['user']->sid, $variables['user']->ssid);
 
   $variables['is_admin'] = user_access('access administration pages');
-  $variables['logged_in'] = ($user->uid > 0);
+  $variables['logged_in'] = $user->isAuthenticated();
 }
 
 /**
@@ -734,20 +732,14 @@ function user_template_preprocess_default_variables_alter(&$variables) {
  * @see template_process_username()
  */
 function template_preprocess_username(&$variables) {
-  $account = $variables['account'];
-  if ($account instanceof User) {
-    $account = $account->getBCEntity();
-  }
+  $account = $variables['account'] ?: drupal_anonymous_user();
 
   $variables['extra'] = '';
-  if (empty($account->uid)) {
-   $variables['uid'] = 0;
-   if (theme_get_setting('features.comment_user_verification')) {
-     $variables['extra'] = ' (' . t('not verified') . ')';
-   }
-  }
-  else {
-    $variables['uid'] = (int) $account->uid;
+  $variables['uid'] = $account->id();
+  if (empty($variables['uid'])) {
+    if (theme_get_setting('features.comment_user_verification')) {
+      $variables['extra'] = ' (' . t('not verified') . ')';
+    }
   }
 
   // Set the name to a formatted name that is safe for printing and
@@ -824,7 +816,7 @@ function theme_username($variables) {
  */
 function user_is_anonymous() {
   // Menu administrators can see items for anonymous when administering.
-  return !$GLOBALS['user']->uid || !empty($GLOBALS['menu_admin']);
+  return $GLOBALS['user']->isAnonymous() || !empty($GLOBALS['menu_admin']);
 }
 
 /**
@@ -832,9 +824,11 @@ function user_is_anonymous() {
  *
  * @return bool
  *   TRUE if the user is logged in, FALSE if the user is anonymous.
+ *
+ * @deprecated Use \Drupal\Core\Session\UserSession::isAuthenticated().
  */
 function user_is_logged_in() {
-  return (bool) $GLOBALS['user']->uid;
+  return $GLOBALS['user']->isAuthenticated();
 }
 
 /**
@@ -1063,7 +1057,7 @@ function user_menu_breadcrumb_alter(&$active_trail, $item) {
 function user_menu_link_load($menu_links) {
   // Hide the "User account" link for anonymous users.
   foreach ($menu_links as $link) {
-    if ($link['link_path'] == 'user' && $link['module'] == 'system' && !$GLOBALS['user']->uid) {
+    if ($link['link_path'] == 'user' && $link['module'] == 'system' && !$GLOBALS['user']->id()) {
       $link['hidden'] = 1;
     }
   }
@@ -1109,7 +1103,7 @@ function user_uid_only_optional_to_arg($arg) {
  */
 function user_uid_optional_load($uid = NULL) {
   if (!isset($uid)) {
-    $uid = $GLOBALS['user']->uid;
+    $uid = $GLOBALS['user']->id();
   }
   return user_load($uid);
 }
@@ -1123,7 +1117,7 @@ function user_uid_optional_to_arg($arg) {
   // Give back the current user uid when called from eg. tracker, aka.
   // with an empty arg. Also use the current user uid when called from
   // the menu with a % for the current account link.
-  return empty($arg) || $arg == '%' ? $GLOBALS['user']->uid : $arg;
+  return empty($arg) || $arg == '%' ? $GLOBALS['user']->id() : $arg;
 }
 
 /**
@@ -1133,7 +1127,7 @@ function user_uid_optional_to_arg($arg) {
  * authenticated users are expected to see "My account".
  */
 function user_menu_title() {
-  if (!user_is_logged_in()) {
+  if ($GLOBALS['user']->isAnonymous()) {
     switch (current_path()) {
       case 'user' :
       case 'user/login' :
@@ -1339,11 +1333,11 @@ function user_authenticate($name, $password) {
       $password_hasher = drupal_container()->get('password');
       if ($password_hasher->check($password, $account)) {
         // Successful authentication.
-        $uid = $account->uid;
+        $uid = $account->id();
 
         // Update user to new password scheme if needed.
         if ($password_hasher->userNeedsNewHash($account)) {
-          $account->pass = $password;
+          $account->setPassword($password);
           $account->save();
         }
       }
@@ -1365,13 +1359,13 @@ function user_authenticate($name, $password) {
  */
 function user_login_finalize(&$edit = array()) {
   global $user;
-  watchdog('user', 'Session opened for %name.', array('%name' => $user->name));
+  watchdog('user', 'Session opened for %name.', array('%name' => $user->label()));
   // Update the user table timestamp noting user has logged in.
   // This is also used to invalidate one-time login links.
-  $user->login = REQUEST_TIME;
+  $user->setLastLoginTime(REQUEST_TIME);
   db_update('users')
-    ->fields(array('login' => $user->login))
-    ->condition('uid', $user->uid)
+    ->fields(array('login' => $user->getLastLoginTime()))
+    ->condition('uid', $user->id())
     ->execute();
 
   // Regenerate the session ID to prevent against session fixation attacks.
@@ -1390,7 +1384,7 @@ function user_login_finalize(&$edit = array()) {
 function user_login_form_submit($form, &$form_state) {
   global $user;
   $user = user_load($form_state['uid']);
-  $form_state['redirect'] = 'user/' . $user->uid;
+  $form_state['redirect'] = 'user/' . $user->id();
 
   user_login_finalize($form_state);
 }
@@ -1432,9 +1426,9 @@ function user_user_logout($account) {
  */
 function user_pass_reset_url($account, $options = array()) {
   $timestamp = REQUEST_TIME;
-  $langcode = isset($options['langcode']) ? $options['langcode'] : user_preferred_langcode($account);
+  $langcode = isset($options['langcode']) ? $options['langcode'] : $account->getPreferredLangcode();
   $url_options = array('absolute' => TRUE, 'language' => language_load($langcode));
-  return url("user/reset/$account->uid/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login), $url_options);
+  return url("user/reset/" . $account->id() . "/$timestamp/" . user_pass_rehash($account->getPassword(), $timestamp, $account->getLastLoginTime()), $url_options);
 }
 
 /**
@@ -1460,9 +1454,9 @@ function user_pass_reset_url($account, $options = array()) {
  */
 function user_cancel_url($account, $options = array()) {
   $timestamp = REQUEST_TIME;
-  $langcode = isset($options['langcode']) ? $options['langcode'] : user_preferred_langcode($account);
+  $langcode = isset($options['langcode']) ? $options['langcode'] : $account->getPreferredLangcode();
   $url_options = array('absolute' => TRUE, 'language' => language_load($langcode));
-  return url("user/$account->uid/cancel/confirm/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login), $url_options);
+  return url("user/" . $account->id() . "/cancel/confirm/$timestamp/" . user_pass_rehash($account->getPassword(), $timestamp, $account->login), $url_options);
 }
 
 /**
@@ -1541,7 +1535,7 @@ function user_cancel($edit, $uid, $method) {
   );
 
   // After cancelling account, ensure that user is logged out.
-  if ($account->uid == $user->uid) {
+  if ($account->id() == $user->id()) {
     // Batch API stores data in the session, so use the finished operation to
     // manipulate the current user's session id.
     $batch['finished'] = '_user_cancel_session_regenerate';
@@ -1584,7 +1578,7 @@ function _user_cancel($edit, $account, $method) {
       if (!empty($edit['user_cancel_notify'])) {
         _user_mail_notify('status_canceled', $account);
       }
-      user_delete($account->uid);
+      $account->delete();
       drupal_set_message(t('%name has been deleted.', array('%name' => $account->name)));
       watchdog('user', 'Deleted user: %name %email.', array('%name' => $account->name, '%email' => '<' . $account->mail . '>'), WATCHDOG_NOTICE);
       break;
@@ -1594,7 +1588,7 @@ function _user_cancel($edit, $account, $method) {
   // their session though, as we might have information in it, and we can't
   // regenerate it because batch API uses the session ID, we will regenerate it
   // in _user_cancel_session_regenerate().
-  if ($account->uid == $user->uid) {
+  if ($account->id() == $user->id()) {
     $user = drupal_anonymous_user();
   }
 
@@ -1991,7 +1985,7 @@ function user_role_revoke_permissions($rid, array $permissions = array()) {
 
 function user_multiple_cancel_confirm($form, &$form_state) {
   // Retrieve the accounts to be canceled from the temp store.
-  $accounts = Drupal::service('user.tempstore')->get('user_user_operations_cancel')->get($GLOBALS['user']->uid);
+  $accounts = Drupal::service('user.tempstore')->get('user_user_operations_cancel')->get($GLOBALS['user']->id());
   $form['accounts'] = array('#prefix' => '<ul>', '#suffix' => '</ul>', '#tree' => TRUE);
   foreach ($accounts as $account) {
     $uid = $account->id();
@@ -2059,7 +2053,7 @@ function user_multiple_cancel_confirm_submit($form, &$form_state) {
   global $user;
 
   // Clear out the accounts from the temp store.
-  Drupal::service('user.tempstore')->get('user_user_operations_cancel')->delete($user->uid);
+  Drupal::service('user.tempstore')->get('user_user_operations_cancel')->delete($user->id());
   if ($form_state['values']['confirm']) {
     foreach ($form_state['values']['accounts'] as $uid => $value) {
       // Prevent programmatic form submissions from cancelling user 1.
@@ -2067,12 +2061,12 @@ function user_multiple_cancel_confirm_submit($form, &$form_state) {
         continue;
       }
       // Prevent user administrators from deleting themselves without confirmation.
-      if ($uid == $user->uid) {
+      if ($uid == $user->id()) {
         $admin_form_state = $form_state;
         unset($admin_form_state['values']['user_cancel_confirm']);
         // The $user global is not a complete user entity, so load the full
         // entity.
-        $admin_form_state['values']['_account'] = user_load($user->uid);
+        $admin_form_state['values']['_account'] = user_load($user->id());
         user_cancel_confirm_form_submit(array(), $admin_form_state);
       }
       else {
@@ -2197,31 +2191,18 @@ function theme_user_signature($variables) {
  * choose a preferred language, or is the anonymous user, the $default
  * value, or if it is not set, the site default language will be returned.
  *
- * @param $account
+ * @param \Drupal\Core\Session\AccountInterface $account
  *   User account to look up language for.
- * @param $type
+ * @param string $type
  *   Optional string to define which preferred langcode should be used.
  *   Default to 'preferred_langcode' property.
  *   If set 'preferred_$type_langcode' is used.
- * @param $default
+ * @param string $default
  *   Optional default language code to return if the account
  *   has no valid language.
  */
-function user_preferred_langcode($account, $type = NULL, $default = NULL) {
-  $language_list = language_list();
-  $account = $account->getBCEntity();
-  if (isset($type)) {
-    $preferred_langcode = $account->{'preferred_' . $type . '_langcode'};
-  }
-  else {
-    $preferred_langcode = $account->preferred_langcode;
-  }
-  if (!empty($preferred_langcode) && isset($language_list[$preferred_langcode])) {
-    return $language_list[$preferred_langcode]->langcode;
-  }
-  else {
-    return $default ? $default : language_default()->langcode;
-  }
+function user_preferred_langcode(AccountInterface $account, $type = NULL, $default = NULL) {
+  return $account->getPreferredLangcode($type, $default);
 }
 
 /**
@@ -2260,7 +2241,7 @@ function _user_mail_notify($op, $account, $langcode = NULL) {
   $notify = config('user.settings')->get('notify.' . $op);
   if ($notify || ($op != 'status_canceled' && $op != 'status_blocked')) {
     $params['account'] = $account;
-    $langcode = $langcode ? $langcode : user_preferred_langcode($account);
+    $langcode = $langcode ? $langcode : $account->getPreferredLangcode();
     // Get the custom site notification email to use as the from email address
     // if it has been set.
     $site_mail = config('system.site')->get('mail_notification');
@@ -2513,7 +2494,7 @@ function user_toolbar() {
   global $user;
 
   // Add logout & user account links or login link.
-  if ($user->uid) {
+  if ($user->isAuthenticated()) {
     $links = array(
       'account' => array(
         'title' => t('View profile'),
@@ -2525,7 +2506,7 @@ function user_toolbar() {
       ),
       'account_edit' => array(
         'title' => t('Edit profile'),
-        'href' => 'user/' . $user->uid . '/edit',
+        'href' => 'user/' . $user->id() . '/edit',
         'html' => TRUE,
         'attributes' => array(
           'title' => t('Edit user account'),
