diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc
index 50dc8f3..b125ae8 100644
--- a/core/includes/bootstrap.inc
+++ b/core/includes/bootstrap.inc
@@ -1943,6 +1943,8 @@ function _current_path($path = NULL) {
  *   The component specified by $index, or NULL if the specified component was
  *   not found. If called without arguments, it returns an array containing all
  *   the components of the current path.
+ *
+ * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
  */
 function arg($index = NULL, $path = NULL) {
   // Even though $arguments doesn't need to be resettable for any functional
diff --git a/core/includes/theme.inc b/core/includes/theme.inc
index e44f13d..d1e4e6f 100644
--- a/core/includes/theme.inc
+++ b/core/includes/theme.inc
@@ -1984,8 +1984,9 @@ function template_preprocess_html(&$variables) {
   $body_classes[] = $variables['logged_in'] ? 'logged-in' : 'not-logged-in';
   $variables['attributes']['class'] = $body_classes;
 
+  $path_args = explode('/', current_path());
   // Populate the body classes.
-  if ($suggestions = theme_get_suggestions(arg(), 'page', '-')) {
+  if ($suggestions = theme_get_suggestions($path_args, 'page', '-')) {
     foreach ($suggestions as $suggestion) {
       if ($suggestion != 'page-front') {
         // Add current suggestion to page classes to make it possible to theme
@@ -2067,9 +2068,6 @@ function template_preprocess_html(&$variables) {
  * inside "modules/system/page.html.twig". Look in there for the full list of
  * variables.
  *
- * Uses the arg() function to generate a series of page template suggestions
- * based on the current path.
- *
  * @see drupal_render_page()
  */
 function template_preprocess_page(&$variables) {
@@ -2186,7 +2184,7 @@ function template_preprocess_page(&$variables) {
  * additional suggestions or classes on the path of the current page.
  *
  * @param $args
- *   An array of path arguments, such as from function arg().
+ *   An array of path arguments.
  * @param $base
  *   A string identifying the base 'thing' from which more specific suggestions
  *   are derived. For example, 'page' or 'html'.
diff --git a/core/modules/aggregator/lib/Drupal/aggregator/FeedForm.php b/core/modules/aggregator/lib/Drupal/aggregator/FeedForm.php
index 1770f03..675627c 100644
--- a/core/modules/aggregator/lib/Drupal/aggregator/FeedForm.php
+++ b/core/modules/aggregator/lib/Drupal/aggregator/FeedForm.php
@@ -66,12 +66,7 @@ public function save(array $form, array &$form_state) {
     $feed->save();
     if ($insert) {
       drupal_set_message($this->t('The feed %feed has been updated.', array('%feed' => $feed->label())));
-      if (arg(0) == 'admin') {
-        $form_state['redirect_route']['route_name'] = 'aggregator.admin_overview';
-      }
-      else {
-        $form_state['redirect_route'] = $feed->urlInfo('canonical');
-      }
+      $form_state['redirect_route'] = $feed->urlInfo('canonical');
     }
     else {
       watchdog('aggregator', 'Feed %feed added.', array('%feed' => $feed->label()), WATCHDOG_NOTICE, l($this->t('View'), 'admin/config/services/aggregator'));
diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Form/FeedDeleteForm.php b/core/modules/aggregator/lib/Drupal/aggregator/Form/FeedDeleteForm.php
index eacabe9..26c6423 100644
--- a/core/modules/aggregator/lib/Drupal/aggregator/Form/FeedDeleteForm.php
+++ b/core/modules/aggregator/lib/Drupal/aggregator/Form/FeedDeleteForm.php
@@ -43,12 +43,7 @@ public function submit(array $form, array &$form_state) {
     $this->entity->delete();
     watchdog('aggregator', 'Feed %feed deleted.', array('%feed' => $this->entity->label()));
     drupal_set_message($this->t('The feed %feed has been deleted.', array('%feed' => $this->entity->label())));
-    if (arg(0) == 'admin') {
-      $form_state['redirect_route'] = $this->getCancelRoute();
-    }
-    else {
-      $form_state['redirect_route'] = new Url('aggregator.sources');
-    }
+    $form_state['redirect_route'] = new Url('aggregator.sources');
   }
 
 }
diff --git a/core/modules/dblog/dblog.libraries.yml b/core/modules/dblog/dblog.libraries.yml
new file mode 100644
index 0000000..d871d09
--- /dev/null
+++ b/core/modules/dblog/dblog.libraries.yml
@@ -0,0 +1,5 @@
+drupal.dblog:
+  version: VERSION
+  css:
+    component:
+      css/dblog.module.css: {}
diff --git a/core/modules/dblog/dblog.module b/core/modules/dblog/dblog.module
index 1eb61b0..6333187 100644
--- a/core/modules/dblog/dblog.module
+++ b/core/modules/dblog/dblog.module
@@ -53,15 +53,6 @@ function dblog_menu_link_defaults_alter(&$links) {
 }
 
 /**
- * Implements hook_page_build().
- */
-function dblog_page_build(&$page) {
-  if (arg(0) == 'admin' && arg(1) == 'reports') {
-    $page['#attached']['css'][] = drupal_get_path('module', 'dblog') . '/css/dblog.module.css';
-  }
-}
-
-/**
  * Implements hook_cron().
  *
  * Controls the size of the log table, paring it to 'dblog_row_limit' messages.
diff --git a/core/modules/dblog/lib/Drupal/dblog/Controller/DbLogController.php b/core/modules/dblog/lib/Drupal/dblog/Controller/DbLogController.php
index 72ddf22..1f9f48d 100644
--- a/core/modules/dblog/lib/Drupal/dblog/Controller/DbLogController.php
+++ b/core/modules/dblog/lib/Drupal/dblog/Controller/DbLogController.php
@@ -210,6 +210,9 @@ public function overview() {
       '#rows' => $rows,
       '#attributes' => array('id' => 'admin-dblog', 'class' => array('admin-dblog')),
       '#empty' => $this->t('No log messages available.'),
+      '#attached' => array(
+        'library' => array('dblog/drupal.dblog'),
+      ),
     );
     $build['dblog_pager'] = array('#theme' => 'pager');
 
@@ -283,6 +286,9 @@ public function eventDetails($event_id) {
         '#type' => 'table',
         '#rows' => $rows,
         '#attributes' => array('class' => array('dblog-event')),
+        '#attached' => array(
+          'library' => array('dblog/drupal.dblog'),
+        ),
       );
     }
 
@@ -383,6 +389,9 @@ public function topLogMessages($type) {
       '#header' => $header,
       '#rows' => $rows,
       '#empty' => $this->t('No log messages available.'),
+      '#attached' => array(
+        'library' => array('dblog/drupal.dblog'),
+      ),
     );
     $build['dblog_top_pager'] = array('#theme' => 'pager');
 
diff --git a/core/modules/system/system.module b/core/modules/system/system.module
index 8feb47b..1090887 100644
--- a/core/modules/system/system.module
+++ b/core/modules/system/system.module
@@ -651,14 +651,16 @@ function system_element_info() {
  * Implements hook_theme_suggestions_HOOK().
  */
 function system_theme_suggestions_html(array $variables) {
-  return theme_get_suggestions(arg(), 'html');
+  $path_args = explode('/', current_path());
+  return theme_get_suggestions($path_args, 'html');
 }
 
 /**
  * Implements hook_theme_suggestions_HOOK().
  */
 function system_theme_suggestions_page(array $variables) {
-  return theme_get_suggestions(arg(), 'page');
+  $path_args = explode('/', current_path());
+  return theme_get_suggestions($path_args, 'page');
 }
 
 /**
diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument_default/Tid.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument_default/Tid.php
index 33b35a8..f7a097d 100644
--- a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument_default/Tid.php
+++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument_default/Tid.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\taxonomy\Plugin\views\argument_default;
 
+use Drupal\taxonomy\TermInterface;
 use Drupal\views\ViewExecutable;
 use Drupal\views\Plugin\views\display\DisplayPluginBase;
 use Drupal\views\Plugin\views\argument_default\ArgumentDefaultPluginBase;
@@ -159,8 +160,8 @@ public function submitOptionsForm(&$form, &$form_state, &$options = array()) {
   public function getArgument() {
     // Load default argument from taxonomy page.
     if (!empty($this->options['term_page'])) {
-      if (arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric(arg(2))) {
-        return arg(2);
+      if (($taxonomy_term = $this->request->attributes->get('taxonomy_term')) && $taxonomy_term instanceof TermInterface) {
+        return $taxonomy_term->id();
       }
     }
     // Load default argument from node.
diff --git a/core/modules/update/lib/Drupal/update/Tests/UpdateCoreTest.php b/core/modules/update/lib/Drupal/update/Tests/UpdateCoreTest.php
index 7928455..00782b8 100644
--- a/core/modules/update/lib/Drupal/update/Tests/UpdateCoreTest.php
+++ b/core/modules/update/lib/Drupal/update/Tests/UpdateCoreTest.php
@@ -29,7 +29,7 @@ public static function getInfo() {
 
   function setUp() {
     parent::setUp();
-    $admin_user = $this->drupalCreateUser(array('administer site configuration', 'administer modules'));
+    $admin_user = $this->drupalCreateUser(array('administer site configuration', 'administer modules', 'administer themes'));
     $this->drupalLogin($admin_user);
   }
 
diff --git a/core/modules/update/update.module b/core/modules/update/update.module
index 6341857..ee2f107 100644
--- a/core/modules/update/update.module
+++ b/core/modules/update/update.module
@@ -12,6 +12,7 @@
  */
 
 use Drupal\Core\Site\Settings;
+use Symfony\Cmf\Component\Routing\RouteObjectInterface;
 use Symfony\Component\HttpFoundation\Request;
 
 // These are internally used constants for this code, do not modify.
@@ -97,8 +98,11 @@ function update_help($route_name, Request $request) {
  * Implements hook_page_build().
  */
 function update_page_build() {
-  if (arg(0) == 'admin' && user_access('administer site configuration')) {
-    switch (current_path()) {
+  /** @var \Drupal\Core\Routing\AdminContext $admin_context */
+  $admin_context = \Drupal::service('router.admin_context');
+  if ($admin_context->isAdminRoute(\Drupal::request()->attributes->get(RouteObjectInterface::ROUTE_OBJECT)) && \Drupal::currentUser()->hasPermission('administer site configuration')) {
+    $current_path = current_path();
+    switch ($current_path) {
       // These pages don't need additional nagging.
       case 'admin/appearance/update':
       case 'admin/appearance/install':
diff --git a/core/modules/user/lib/Drupal/user/Plugin/Block/UserLoginBlock.php b/core/modules/user/lib/Drupal/user/Plugin/Block/UserLoginBlock.php
index b2cff4c..3466c21 100644
--- a/core/modules/user/lib/Drupal/user/Plugin/Block/UserLoginBlock.php
+++ b/core/modules/user/lib/Drupal/user/Plugin/Block/UserLoginBlock.php
@@ -9,6 +9,7 @@
 
 use Drupal\Core\Session\AccountInterface;
 use Drupal\block\BlockBase;
+use Symfony\Cmf\Component\Routing\RouteObjectInterface;
 
 /**
  * Provides a 'User login' block.
@@ -25,7 +26,8 @@ class UserLoginBlock extends BlockBase {
    * {@inheritdoc}
    */
   public function access(AccountInterface $account) {
-    return (!$account->id() && !(arg(0) == 'user' && !is_numeric(arg(1))));
+    $route_name = \Drupal::request()->attributes->get(RouteObjectInterface::ROUTE_NAME);
+    return ($account->isAnonymous() && !in_array($route_name, array('user.register', 'user.login', 'user.logout')));
   }
 
   /**
diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/argument_default/Raw.php b/core/modules/views/lib/Drupal/views/Plugin/views/argument_default/Raw.php
index 3f144ae..9541b52 100644
--- a/core/modules/views/lib/Drupal/views/Plugin/views/argument_default/Raw.php
+++ b/core/modules/views/lib/Drupal/views/Plugin/views/argument_default/Raw.php
@@ -81,12 +81,13 @@ protected function defineOptions() {
 
   public function buildOptionsForm(&$form, &$form_state) {
     parent::buildOptionsForm($form, $form_state);
-    // Using range(1, 10) will create an array keyed 0-9, which allows arg() to
-    // properly function since it is also zero-based.
     $form['index'] = array(
       '#type' => 'select',
       '#title' => t('Path component'),
       '#default_value' => $this->options['index'],
+      // range(1, 10) returns an array with:
+      // - keys that count from 0 to match PHP array keys from explode().
+      // - values that count from 1 for display to humans.
       '#options' => range(1, 10),
       '#description' => t('The numbering starts from 1, e.g. on the page admin/structure/types, the 3rd path component is "types".'),
     );
diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php b/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php
index 750546f..493c765 100644
--- a/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php
+++ b/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php
@@ -16,6 +16,7 @@
 use Drupal\views\ViewExecutable;
 use Drupal\views\Plugin\views\PluginBase;
 use Drupal\views\Views;
+use Symfony\Cmf\Component\Routing\RouteObjectInterface;
 use Symfony\Component\DependencyInjection\Exception\RuntimeException as DependencyInjectionRuntimeException;
 
 /**
@@ -2399,8 +2400,9 @@ public function getSpecialBlocks() {
    *  The rendered exposed form as string or NULL otherwise.
    */
   public function viewExposedFormBlocks() {
-    // avoid interfering with the admin forms.
-    if (arg(0) == 'admin' && arg(1) == 'structure' && arg(2) == 'views') {
+    // Avoid interfering with the admin forms.
+    $route_name = \Drupal::request()->attributes->get(RouteObjectInterface::ROUTE_NAME);
+    if (strpos($route_name, 'views_ui.') === 0) {
       return;
     }
     $this->view->initHandlers();
