diff --git a/app/code/Magento/Backend/App/Config.php b/app/code/Magento/Backend/App/Config.php
index d8eaa7af14254bd16dd3c8f7ae3cc9a549e75cde..0ac5211b41d9f58308d4f57977e0c8054c15e4c7 100644
--- a/app/code/Magento/Backend/App/Config.php
+++ b/app/code/Magento/Backend/App/Config.php
@@ -10,6 +10,8 @@
 
 namespace Magento\Backend\App;
 
+use Magento\Framework\App\Config\ScopeConfigInterface;
+
 /**
  * Backend config accessor
  */
@@ -36,7 +38,7 @@ class Config implements ConfigInterface
      */
     public function getValue($path)
     {
-        return $this->_scopePool->getScope(\Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT, null)->getValue($path);
+        return $this->_scopePool->getScope(ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null)->getValue($path);
     }
 
     /**
@@ -48,7 +50,7 @@ class Config implements ConfigInterface
      */
     public function setValue($path, $value)
     {
-        $this->_scopePool->getScope(\Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT, null)->setValue($path, $value);
+        $this->_scopePool->getScope(ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null)->setValue($path, $value);
     }
 
     /**
@@ -59,6 +61,6 @@ class Config implements ConfigInterface
      */
     public function isSetFlag($path)
     {
-        return !!$this->_scopePool->getScope(\Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT, null)->getValue($path);
+        return !!$this->_scopePool->getScope(ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null)->getValue($path);
     }
 }
diff --git a/app/code/Magento/Backend/Block/Page/System/Config/Robots/Reset.php b/app/code/Magento/Backend/Block/Page/System/Config/Robots/Reset.php
index d32e99a00d814b5a134e9e3060526e7586f9043e..827ae18b0b8e1f908653597bc1816a6c73d9b148 100644
--- a/app/code/Magento/Backend/Block/Page/System/Config/Robots/Reset.php
+++ b/app/code/Magento/Backend/Block/Page/System/Config/Robots/Reset.php
@@ -8,6 +8,8 @@
 
 namespace Magento\Backend\Block\Page\System\Config\Robots;
 
+use Magento\Framework\App\Config\ScopeConfigInterface;
+
 /**
  * "Reset to Defaults" button renderer
  *
@@ -50,7 +52,7 @@ class Reset extends \Magento\Config\Block\System\Config\Form\Field
     public function getRobotsDefaultCustomInstructions()
     {
         return trim((string)$this->_scopeConfig->getValue(
-            self::XML_PATH_ROBOTS_DEFAULT_CUSTOM_INSTRUCTIONS, \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT
+            self::XML_PATH_ROBOTS_DEFAULT_CUSTOM_INSTRUCTIONS, ScopeConfigInterface::SCOPE_TYPE_DEFAULT
         ));
     }
 
diff --git a/app/code/Magento/Backend/Model/Auth/Session.php b/app/code/Magento/Backend/Model/Auth/Session.php
index fec438f70c744d7b7cc9999d8574f3e4deef862c..d5cf7e86c4b8ae8c301a2993893a9d31d615e7e5 100644
--- a/app/code/Magento/Backend/Model/Auth/Session.php
+++ b/app/code/Magento/Backend/Model/Auth/Session.php
@@ -61,9 +61,11 @@ class Session extends \Magento\Framework\Session\SessionManager implements \Mage
      * @param \Magento\Framework\Session\StorageInterface $storage
      * @param CookieManagerInterface $cookieManager
      * @param CookieMetadataFactory $cookieMetadataFactory
+     * @param \Magento\Framework\App\State $appState
      * @param \Magento\Framework\Acl\Builder $aclBuilder
      * @param \Magento\Backend\Model\UrlInterface $backendUrl
      * @param \Magento\Backend\App\ConfigInterface $config
+     * @throws \Magento\Framework\Exception\SessionException
      * @SuppressWarnings(PHPMD.ExcessiveParameterList)
      */
     public function __construct(
@@ -75,6 +77,7 @@ class Session extends \Magento\Framework\Session\SessionManager implements \Mage
         \Magento\Framework\Session\StorageInterface $storage,
         CookieManagerInterface $cookieManager,
         CookieMetadataFactory $cookieMetadataFactory,
+        \Magento\Framework\App\State $appState,
         \Magento\Framework\Acl\Builder $aclBuilder,
         \Magento\Backend\Model\UrlInterface $backendUrl,
         \Magento\Backend\App\ConfigInterface $config
@@ -90,9 +93,9 @@ class Session extends \Magento\Framework\Session\SessionManager implements \Mage
             $validator,
             $storage,
             $cookieManager,
-            $cookieMetadataFactory
+            $cookieMetadataFactory,
+            $appState
         );
-        $this->start();
     }
 
     /**
diff --git a/app/code/Magento/Backend/Model/Locale/Manager.php b/app/code/Magento/Backend/Model/Locale/Manager.php
index 76a327f1364d1b42a05f3ea000474049d5b87068..4f9584c96a81706b0eaefafd3137a27d75291fc3 100644
--- a/app/code/Magento/Backend/Model/Locale/Manager.php
+++ b/app/code/Magento/Backend/Model/Locale/Manager.php
@@ -68,7 +68,7 @@ class Manager
      */
     public function getUserInterfaceLocale()
     {
-        $interfaceLocale = \Magento\Framework\Locale\ResolverInterface::DEFAULT_LOCALE;
+        $interfaceLocale = \Magento\Framework\Locale\Resolver::DEFAULT_LOCALE;
 
         $userData = $this->_authSession->getUser();
         if ($userData && $userData->getInterfaceLocale()) {
diff --git a/app/code/Magento/Backend/Model/Session.php b/app/code/Magento/Backend/Model/Session.php
index c0719bb2ecf9ef98084a0ecba7e11630732eddbf..6dd5af4a3c54830029f8372e214009a4e3b04bef 100644
--- a/app/code/Magento/Backend/Model/Session.php
+++ b/app/code/Magento/Backend/Model/Session.php
@@ -9,39 +9,6 @@ namespace Magento\Backend\Model;
 
 class Session extends \Magento\Framework\Session\SessionManager
 {
-    /**
-     * @param \Magento\Framework\App\Request\Http $request
-     * @param \Magento\Framework\Session\SidResolverInterface $sidResolver
-     * @param \Magento\Framework\Session\Config\ConfigInterface $sessionConfig
-     * @param \Magento\Framework\Session\SaveHandlerInterface $saveHandler
-     * @param \Magento\Framework\Session\ValidatorInterface $validator
-     * @param \Magento\Framework\Session\StorageInterface $storage
-     * @param \Magento\Framework\Stdlib\CookieManagerInterface $cookieManager
-     * @param \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory
-     */
-    public function __construct(
-        \Magento\Framework\App\Request\Http $request,
-        \Magento\Framework\Session\SidResolverInterface $sidResolver,
-        \Magento\Framework\Session\Config\ConfigInterface $sessionConfig,
-        \Magento\Framework\Session\SaveHandlerInterface $saveHandler,
-        \Magento\Framework\Session\ValidatorInterface $validator,
-        \Magento\Framework\Session\StorageInterface $storage,
-        \Magento\Framework\Stdlib\CookieManagerInterface $cookieManager,
-        \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory
-    ) {
-        parent::__construct(
-            $request,
-            $sidResolver,
-            $sessionConfig,
-            $saveHandler,
-            $validator,
-            $storage,
-            $cookieManager,
-            $cookieMetadataFactory
-        );
-        $this->start();
-    }
-
     /**
      * Skip path validation in backend area
      *
diff --git a/app/code/Magento/Backend/Model/Session/Quote.php b/app/code/Magento/Backend/Model/Session/Quote.php
index 2f1f75ab07e9201d03ec0706fc3a0fb20f42ddc1..16d39fd25e4e1bfda7dad905b0e4524b89a4e82f 100644
--- a/app/code/Magento/Backend/Model/Session/Quote.php
+++ b/app/code/Magento/Backend/Model/Session/Quote.php
@@ -83,11 +83,13 @@ class Quote extends \Magento\Framework\Session\SessionManager
      * @param \Magento\Framework\Session\StorageInterface $storage
      * @param \Magento\Framework\Stdlib\CookieManagerInterface $cookieManager
      * @param \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory
+     * @param \Magento\Framework\App\State $appState
      * @param CustomerRepositoryInterface $customerRepository
      * @param \Magento\Quote\Model\QuoteRepository $quoteRepository
      * @param \Magento\Sales\Model\OrderFactory $orderFactory
      * @param \Magento\Store\Model\StoreManagerInterface $storeManager
      * @param GroupManagementInterface $groupManagement
+     * @throws \Magento\Framework\Exception\SessionException
      * @SuppressWarnings(PHPMD.ExcessiveParameterList)
      */
     public function __construct(
@@ -99,6 +101,7 @@ class Quote extends \Magento\Framework\Session\SessionManager
         \Magento\Framework\Session\StorageInterface $storage,
         \Magento\Framework\Stdlib\CookieManagerInterface $cookieManager,
         \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory,
+        \Magento\Framework\App\State $appState,
         CustomerRepositoryInterface $customerRepository,
         \Magento\Quote\Model\QuoteRepository $quoteRepository,
         \Magento\Sales\Model\OrderFactory $orderFactory,
@@ -118,9 +121,9 @@ class Quote extends \Magento\Framework\Session\SessionManager
             $validator,
             $storage,
             $cookieManager,
-            $cookieMetadataFactory
+            $cookieMetadataFactory,
+            $appState
         );
-        $this->start();
         if ($this->_storeManager->hasSingleStore()) {
             $this->setStoreId($this->_storeManager->getStore(true)->getId());
         }
diff --git a/app/code/Magento/Backend/Model/Url.php b/app/code/Magento/Backend/Model/Url.php
index 265a7237ed37e1713fb17d97a3674c633d406341..36fbfafe66974d236c0bc90c2d7133fc3bcf128b 100644
--- a/app/code/Magento/Backend/Model/Url.php
+++ b/app/code/Magento/Backend/Model/Url.php
@@ -83,7 +83,7 @@ class Url extends \Magento\Framework\Url implements \Magento\Backend\Model\UrlIn
      * @param \Magento\Framework\Url\ScopeResolverInterface $scopeResolver
      * @param \Magento\Framework\Session\Generic $session
      * @param \Magento\Framework\Session\SidResolverInterface $sidResolver
-     * @param \Magento\Framework\Url\RouteParamsResolverFactory $routeParamsResolver
+     * @param \Magento\Framework\Url\RouteParamsResolverFactory $routeParamsResolverFactory
      * @param \Magento\Framework\Url\QueryParamsResolverInterface $queryParamsResolver
      * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
      * @param string $scopeType
@@ -105,7 +105,7 @@ class Url extends \Magento\Framework\Url implements \Magento\Backend\Model\UrlIn
         \Magento\Framework\Url\ScopeResolverInterface $scopeResolver,
         \Magento\Framework\Session\Generic $session,
         \Magento\Framework\Session\SidResolverInterface $sidResolver,
-        \Magento\Framework\Url\RouteParamsResolverFactory $routeParamsResolver,
+        \Magento\Framework\Url\RouteParamsResolverFactory $routeParamsResolverFactory,
         \Magento\Framework\Url\QueryParamsResolverInterface $queryParamsResolver,
         \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
         $scopeType,
@@ -126,7 +126,7 @@ class Url extends \Magento\Framework\Url implements \Magento\Backend\Model\UrlIn
             $scopeResolver,
             $session,
             $sidResolver,
-            $routeParamsResolver,
+            $routeParamsResolverFactory,
             $queryParamsResolver,
             $scopeConfig,
             $scopeType,
diff --git a/app/code/Magento/Backend/Test/Unit/Model/Locale/ManagerTest.php b/app/code/Magento/Backend/Test/Unit/Model/Locale/ManagerTest.php
index 000c861f11d8eba4c098f8427df867287de61c2d..a624a526d5dbffd7dcd06460a11872fb1f4328c2 100644
--- a/app/code/Magento/Backend/Test/Unit/Model/Locale/ManagerTest.php
+++ b/app/code/Magento/Backend/Test/Unit/Model/Locale/ManagerTest.php
@@ -5,6 +5,8 @@
  */
 namespace Magento\Backend\Test\Unit\Model\Locale;
 
+use Magento\Framework\Locale\Resolver;
+
 class ManagerTest extends \PHPUnit_Framework_TestCase
 {
     /**
@@ -87,7 +89,7 @@ class ManagerTest extends \PHPUnit_Framework_TestCase
     {
         $locale = $this->_model->getUserInterfaceLocale();
 
-        $this->assertEquals($locale, \Magento\Framework\Locale\ResolverInterface::DEFAULT_LOCALE);
+        $this->assertEquals($locale, Resolver::DEFAULT_LOCALE);
     }
 
     /**
diff --git a/app/code/Magento/Backend/Test/Unit/Model/Session/QuoteTest.php b/app/code/Magento/Backend/Test/Unit/Model/Session/QuoteTest.php
index 13f906bee346b45c02399d3f2cdc59602f9dec3f..d092a33375c6224dd566616b46a616e517f7f021 100644
--- a/app/code/Magento/Backend/Test/Unit/Model/Session/QuoteTest.php
+++ b/app/code/Magento/Backend/Test/Unit/Model/Session/QuoteTest.php
@@ -182,6 +182,13 @@ class QuoteTest extends \PHPUnit_Framework_TestCase
             '',
             false
         );
+        $appStateMock = $this->getMock(
+            'Magento\Framework\App\State',
+            [],
+            [],
+            '',
+            false
+        );
         $this->storeManagerMock = $this->getMockForAbstractClass(
             'Magento\Store\Model\StoreManagerInterface',
             [],
@@ -201,11 +208,12 @@ class QuoteTest extends \PHPUnit_Framework_TestCase
                 'storage' => $this->storageMock,
                 'cookieManager' => $this->cookieManagerMock,
                 'cookieMetadataFactory' => $this->cookieMetadataFactoryMock,
+                'appState' => $appStateMock,
                 'customerRepository' => $this->customerRepositoryMock,
                 'quoteRepository' => $this->quoteRepositoryMock,
                 'orderFactory' => $this->orderFactoryMock,
                 'storeManager' => $this->storeManagerMock,
-                'groupManagement' => $this->groupManagementMock
+                'groupManagement' => $this->groupManagementMock,
             ],
             '',
             true
diff --git a/app/code/Magento/Backend/Test/Unit/Model/UrlTest.php b/app/code/Magento/Backend/Test/Unit/Model/UrlTest.php
index a53b891a17be5e100f0916cf04e6b2a4f3469c71..b833fe25752a09ecd9af87a7147f4debf493affe 100644
--- a/app/code/Magento/Backend/Test/Unit/Model/UrlTest.php
+++ b/app/code/Magento/Backend/Test/Unit/Model/UrlTest.php
@@ -165,7 +165,7 @@ class UrlTest extends \PHPUnit_Framework_TestCase
                 'menuConfig' => $this->_menuConfigMock,
                 'authSession' => $this->_authSessionMock,
                 'encryptor' => $this->_encryptor,
-                'routeParamsResolver' => $this->_paramsResolverMock
+                'routeParamsResolverFactory' => $this->_paramsResolverMock
             ]
         );
         $this->_paramsResolverMock->expects(
@@ -186,7 +186,7 @@ class UrlTest extends \PHPUnit_Framework_TestCase
                 'menuConfig' => $this->_menuConfigMock,
                 'authSession' => $this->_authSessionMock,
                 'encryptor' => $this->_encryptor,
-                'routeParamsResolver' => $this->_paramsResolverMock
+                'routeParamsResolverFactory' => $this->_paramsResolverMock
             ]
         );
 
@@ -259,7 +259,7 @@ class UrlTest extends \PHPUnit_Framework_TestCase
             [
                 'backendHelper' => $helperMock,
                 'authSession' => $this->_authSessionMock,
-                'routeParamsResolver' => $this->_paramsResolverMock
+                'routeParamsResolverFactory' => $this->_paramsResolverMock
             ]
         );
         $urlModel->getAreaFrontName();
diff --git a/app/code/Magento/Backup/README.md b/app/code/Magento/Backup/README.md
index 661f8a5d6ddd86f23772c9f595526420ae51dd9e..59688ea3e716e162e8efa9421de0ffe004ec3cee 100644
--- a/app/code/Magento/Backup/README.md
+++ b/app/code/Magento/Backup/README.md
@@ -1,3 +1,3 @@
 The Backup module allows administrators to perform backups and rollbacks. Types of backups include system, database and media backups. This module relies on the Cron module to schedule backups.
 
-This module does not effect the storefront.
\ No newline at end of file
+This module does not affect the storefront.
diff --git a/app/code/Magento/Backup/view/adminhtml/layout/backup_index_block.xml b/app/code/Magento/Backup/view/adminhtml/layout/backup_index_block.xml
index 861bc2050e44a61e3cf1daf950dcad8fc05d0997..1553a783f6356dca8510044813cd919312ff5fdb 100644
--- a/app/code/Magento/Backup/view/adminhtml/layout/backup_index_block.xml
+++ b/app/code/Magento/Backup/view/adminhtml/layout/backup_index_block.xml
@@ -46,7 +46,6 @@
                         <arguments>
                             <argument name="header" xsi:type="string" translate="true">Name</argument>
                             <argument name="index" xsi:type="string">display_name</argument>
-                            <argument name="filter" xsi:type="string">0</argument>
                             <argument name="sortable" xsi:type="string">1</argument>
                             <argument name="column_css_class" xsi:type="string">col-name</argument>
                             <argument name="header_css_class" xsi:type="string">col-name</argument>
diff --git a/app/code/Magento/Catalog/Block/Product/ProductList/Toolbar.php b/app/code/Magento/Catalog/Block/Product/ProductList/Toolbar.php
index a79466c6007bfb13a619d59a922c29d99d947968..29be0868558ee450d152d492091f5cb5b9bbaef8 100644
--- a/app/code/Magento/Catalog/Block/Product/ProductList/Toolbar.php
+++ b/app/code/Magento/Catalog/Block/Product/ProductList/Toolbar.php
@@ -29,7 +29,7 @@ class Toolbar extends \Magento\Framework\View\Element\Template
      *
      * @var array
      */
-    protected $_availableOrder = [];
+    protected $_availableOrder = null;
 
     /**
      * List of available view types
@@ -146,19 +146,6 @@ class Toolbar extends \Magento\Framework\View\Element\Template
         parent::__construct($context, $data);
     }
 
-    /**
-     * Init Toolbar
-     *
-     * @return null
-     */
-    protected function _construct()
-    {
-        parent::_construct();
-        $this->_orderField = $this->_productListHelper->getDefaultSortField();
-        $this->_availableOrder = $this->_catalogConfig->getAttributeUsedForSortByArray();
-        $this->_availableMode = $this->_productListHelper->getAvailableViewMode();
-    }
-
     /**
      * Disable list state params memorizing
      *
@@ -241,7 +228,7 @@ class Toolbar extends \Magento\Framework\View\Element\Template
         }
 
         $orders = $this->getAvailableOrders();
-        $defaultOrder = $this->_orderField;
+        $defaultOrder = $this->getOrderField();
 
         if (!isset($orders[$defaultOrder])) {
             $keys = array_keys($orders);
@@ -295,6 +282,7 @@ class Toolbar extends \Magento\Framework\View\Element\Template
      */
     public function setDefaultOrder($field)
     {
+        $this->loadAvailableOrders();
         if (isset($this->_availableOrder[$field])) {
             $this->_orderField = $field;
         }
@@ -322,6 +310,7 @@ class Toolbar extends \Magento\Framework\View\Element\Template
      */
     public function getAvailableOrders()
     {
+        $this->loadAvailableOrders();
         return $this->_availableOrder;
     }
 
@@ -346,6 +335,7 @@ class Toolbar extends \Magento\Framework\View\Element\Template
      */
     public function addOrderToAvailableOrders($order, $value)
     {
+        $this->loadAvailableOrders();
         $this->_availableOrder[$order] = $value;
         return $this;
     }
@@ -358,6 +348,7 @@ class Toolbar extends \Magento\Framework\View\Element\Template
      */
     public function removeOrderFromAvailableOrders($order)
     {
+        $this->loadAvailableOrders();
         if (isset($this->_availableOrder[$order])) {
             unset($this->_availableOrder[$order]);
         }
@@ -411,7 +402,7 @@ class Toolbar extends \Magento\Framework\View\Element\Template
         if ($mode) {
             return $mode;
         }
-        $defaultMode = $this->_productListHelper->getDefaultViewMode($this->_availableMode);
+        $defaultMode = $this->_productListHelper->getDefaultViewMode($this->getModes());
         $mode = $this->_toolbarModel->getMode();
         if (!$mode || !isset($this->_availableMode[$mode])) {
             $mode = $defaultMode;
@@ -439,6 +430,9 @@ class Toolbar extends \Magento\Framework\View\Element\Template
      */
     public function getModes()
     {
+        if ($this->_availableMode === []) {
+            $this->_availableMode = $this->_productListHelper->getAvailableViewMode();
+        }
         return $this->_availableMode;
     }
 
@@ -450,6 +444,7 @@ class Toolbar extends \Magento\Framework\View\Element\Template
      */
     public function setModes($modes)
     {
+        $this->getModes();
         if (!isset($this->_availableMode)) {
             $this->_availableMode = $modes;
         }
@@ -691,4 +686,30 @@ class Toolbar extends \Magento\Framework\View\Element\Template
         $options = array_replace_recursive($options, $customOptions);
         return json_encode(['productListToolbarForm' => $options]);
     }
+
+    /**
+     * Get order field
+     *
+     * @return null|string
+     */
+    protected function getOrderField()
+    {
+        if ($this->_orderField === null) {
+            $this->_orderField = $this->_productListHelper->getDefaultSortField();
+        }
+        return $this->_orderField;
+    }
+
+    /**
+     * Load Available Orders
+     *
+     * @return $this
+     */
+    private function loadAvailableOrders()
+    {
+        if ($this->_availableOrder === null) {
+            $this->_availableOrder = $this->_catalogConfig->getAttributeUsedForSortByArray();
+        }
+        return $this;
+    }
 }
diff --git a/app/code/Magento/Catalog/Model/Observer.php b/app/code/Magento/Catalog/Model/Observer.php
index 39e72883f68add9d3672497199eb7c744480a7db..417a4f61811c99663538fd72e3c790ddc0753f3c 100644
--- a/app/code/Magento/Catalog/Model/Observer.php
+++ b/app/code/Magento/Catalog/Model/Observer.php
@@ -34,7 +34,14 @@ class Observer
      *
      * @var \Magento\Catalog\Model\Layer
      */
-    protected $_catalogLayer;
+    private $_catalogLayer = null;
+
+    /**
+     * Catalog layer resolver
+     *
+     * @var \Magento\Catalog\Model\Layer\Resolver
+     */
+    protected $layerResolver;
 
     /**
      * Store manager
@@ -95,7 +102,7 @@ class Observer
         $this->_categoryResource = $categoryResource;
         $this->_catalogProduct = $catalogProduct;
         $this->_storeManager = $storeManager;
-        $this->_catalogLayer = $layerResolver->get();
+        $this->layerResolver = $layerResolver;
         $this->_catalogCategory = $catalogCategory;
         $this->_catalogData = $catalogData;
         $this->categoryFlatConfig = $categoryFlatState;
@@ -184,11 +191,12 @@ class Observer
      */
     protected function hasActive($category)
     {
-        if (!$this->_catalogLayer) {
+        $catalogLayer = $this->getCatalogLayer();
+        if (!$catalogLayer) {
             return false;
         }
 
-        $currentCategory = $this->_catalogLayer->getCurrentCategory();
+        $currentCategory = $catalogLayer->getCurrentCategory();
         if (!$currentCategory) {
             return false;
         }
@@ -196,4 +204,16 @@ class Observer
         $categoryPathIds = explode(',', $currentCategory->getPathInStore());
         return in_array($category->getId(), $categoryPathIds);
     }
+
+    /**
+     * Get catalog layer
+     * @return \Magento\Catalog\Model\Layer
+     */
+    private function getCatalogLayer()
+    {
+        if ($this->_catalogLayer === null) {
+            $this->_catalogLayer = $this->layerResolver->get();
+        }
+        return $this->_catalogLayer;
+    }
 }
diff --git a/app/code/Magento/Catalog/Model/Resource/Category.php b/app/code/Magento/Catalog/Model/Resource/Category.php
index f99d1b9ee9d2c15cdca6c883cc7ded953973afc7..27d7f8b801df56c735259f20150e53aa1a5d7af4 100644
--- a/app/code/Magento/Catalog/Model/Resource/Category.php
+++ b/app/code/Magento/Catalog/Model/Resource/Category.php
@@ -92,13 +92,36 @@ class Category extends AbstractResource
         $this->_categoryTreeFactory = $categoryTreeFactory;
         $this->_categoryCollectionFactory = $categoryCollectionFactory;
         $this->_eventManager = $eventManager;
-        $this->setType(
-            \Magento\Catalog\Model\Category::ENTITY
-        )->setConnection(
-            $this->_resource->getConnection('catalog_read'),
-            $this->_resource->getConnection('catalog_write')
-        );
-        $this->_categoryProductTable = $this->getTable('catalog_category_product');
+
+        $this->_read  = 'catalog_read';
+        $this->_write = 'catalog_write';
+    }
+
+    /**
+     * Entity type getter and lazy loader
+     *
+     * @return \Magento\Eav\Model\Entity\Type
+     * @throws \Magento\Framework\Exception\LocalizedException
+     */
+    public function getEntityType()
+    {
+        if (empty($this->_type)) {
+            $this->setType(\Magento\Catalog\Model\Category::ENTITY);
+        }
+        return parent::getEntityType();
+    }
+
+    /**
+     * Category product table name getter
+     *
+     * @return string
+     */
+    public function getCategoryProductTable()
+    {
+        if (!$this->_categoryProductTable) {
+            $this->_categoryProductTable = $this->getTable('catalog_category_product');
+        }
+        return $this->_categoryProductTable;
     }
 
     /**
@@ -359,7 +382,7 @@ class Category extends AbstractResource
          */
         if (!empty($delete)) {
             $cond = ['product_id IN(?)' => array_keys($delete), 'category_id=?' => $id];
-            $adapter->delete($this->_categoryProductTable, $cond);
+            $adapter->delete($this->getCategoryProductTable(), $cond);
         }
 
         /**
@@ -374,7 +397,7 @@ class Category extends AbstractResource
                     'position' => (int)$position,
                 ];
             }
-            $adapter->insertMultiple($this->_categoryProductTable, $data);
+            $adapter->insertMultiple($this->getCategoryProductTable(), $data);
         }
 
         /**
@@ -384,7 +407,7 @@ class Category extends AbstractResource
             foreach ($update as $productId => $position) {
                 $where = ['category_id = ?' => (int)$id, 'product_id = ?' => (int)$productId];
                 $bind = ['position' => (int)$position];
-                $adapter->update($this->_categoryProductTable, $bind, $where);
+                $adapter->update($this->getCategoryProductTable(), $bind, $where);
             }
         }
 
@@ -417,7 +440,7 @@ class Category extends AbstractResource
     public function getProductsPosition($category)
     {
         $select = $this->_getWriteAdapter()->select()->from(
-            $this->_categoryProductTable,
+            $this->getCategoryProductTable(),
             ['product_id', 'position']
         )->where(
             'category_id = :category_id'
diff --git a/app/code/Magento/Catalog/Model/Resource/Category/Collection.php b/app/code/Magento/Catalog/Model/Resource/Category/Collection.php
index 2abc203eccbcada147503ce7f5be4400deb898e8..f21ce9f363b51f01a7555d79e3ba39aa89598b53 100644
--- a/app/code/Magento/Catalog/Model/Resource/Category/Collection.php
+++ b/app/code/Magento/Catalog/Model/Resource/Category/Collection.php
@@ -33,7 +33,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
      *
      * @var string
      */
-    protected $_productTable;
+    private $_productTable;
 
     /**
      * Store id, that we should count products on
@@ -47,7 +47,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
      *
      * @var string
      */
-    protected $_productWebsiteTable;
+    private $_productWebsiteTable;
 
     /**
      * Load with product count flag
@@ -64,9 +64,6 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
     protected function _construct()
     {
         $this->_init('Magento\Catalog\Model\Category', 'Magento\Catalog\Model\Resource\Category');
-
-        $this->_productWebsiteTable = $this->getTable('catalog_product_website');
-        $this->_productTable = $this->getTable('catalog_category_product');
     }
 
     /**
@@ -224,7 +221,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
             if (!empty($regularIds)) {
                 $select = $this->_conn->select();
                 $select->from(
-                    ['main_table' => $this->_productTable],
+                    ['main_table' => $this->getProductTable()],
                     ['category_id', new \Zend_Db_Expr('COUNT(main_table.product_id)')]
                 )->where(
                     $this->_conn->quoteInto('main_table.category_id IN(?)', $regularIds)
@@ -233,7 +230,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
                 );
                 if ($websiteId) {
                     $select->join(
-                        ['w' => $this->_productWebsiteTable],
+                        ['w' => $this->getProductWebsiteTable()],
                         'main_table.product_id = w.product_id',
                         []
                     )->where(
@@ -259,7 +256,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
                     $bind = ['entity_id' => $item->getId(), 'c_path' => $item->getPath() . '/%'];
                     $select = $this->_conn->select();
                     $select->from(
-                        ['main_table' => $this->_productTable],
+                        ['main_table' => $this->getProductTable()],
                         new \Zend_Db_Expr('COUNT(DISTINCT main_table.product_id)')
                     )->joinInner(
                         ['e' => $this->getTable('catalog_category_entity')],
@@ -272,7 +269,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
                     );
                     if ($websiteId) {
                         $select->join(
-                            ['w' => $this->_productWebsiteTable],
+                            ['w' => $this->getProductWebsiteTable()],
                             'main_table.product_id = w.product_id',
                             []
                         )->where(
@@ -416,4 +413,30 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
         $this->setOrder($field, self::SORT_ORDER_ASC);
         return $this;
     }
+
+    /**
+     * Getter for _productWebsiteTable
+     *
+     * @return string
+     */
+    public function getProductWebsiteTable()
+    {
+        if (empty($this->_productWebsiteTable)) {
+            $this->_productWebsiteTable = $this->getTable('catalog_product_website');
+        }
+        return $this->_productWebsiteTable;
+    }
+
+    /**
+     * Getter for _productTable
+     *
+     * @return string
+     */
+    public function getProductTable()
+    {
+        if (empty($this->_productTable)) {
+            $this->_productTable = $this->getTable('catalog_category_product');
+        }
+        return $this->_productTable;
+    }
 }
diff --git a/app/code/Magento/Catalog/Model/Resource/Product.php b/app/code/Magento/Catalog/Model/Resource/Product.php
index 336d8f796577ecabad0284932cc213cabcfb5f28..6f02829d2bc2a7dff4e95b39b7cd20181d5d1903 100644
--- a/app/code/Magento/Catalog/Model/Resource/Product.php
+++ b/app/code/Magento/Catalog/Model/Resource/Product.php
@@ -91,9 +91,48 @@ class Product extends AbstractResource
             $modelFactory,
             $data
         );
-        $this->setType(\Magento\Catalog\Model\Product::ENTITY)->setConnection('catalog_read', 'catalog_write');
-        $this->_productWebsiteTable = $this->getTable('catalog_product_website');
-        $this->_productCategoryTable = $this->getTable('catalog_category_product');
+        $this->_read  = 'catalog_read';
+        $this->_write = 'catalog_write';
+    }
+
+    /**
+     * Entity type getter and lazy loader
+     *
+     * @return \Magento\Eav\Model\Entity\Type
+     * @throws \Magento\Framework\Exception\LocalizedException
+     */
+    public function getEntityType()
+    {
+        if (empty($this->_type)) {
+            $this->setType(\Magento\Catalog\Model\Product::ENTITY);
+        }
+        return parent::getEntityType();
+    }
+
+    /**
+     * Product Website table name getter
+     *
+     * @return string
+     */
+    public function getProductWebsiteTable()
+    {
+        if (!$this->_productWebsiteTable) {
+            $this->_productWebsiteTable = $this->getTable('catalog_product_website');
+        }
+        return $this->_productWebsiteTable;
+    }
+
+    /**
+     * Product Category table name getter
+     *
+     * @return string
+     */
+    public function getProductCategoryTable()
+    {
+        if (!$this->_productCategoryTable) {
+            $this->_productCategoryTable = $this->getTable('catalog_category_product');
+        }
+        return $this->_productCategoryTable;
     }
 
     /**
@@ -123,7 +162,7 @@ class Product extends AbstractResource
         }
 
         $select = $adapter->select()->from(
-            $this->_productWebsiteTable,
+            $this->getProductWebsiteTable(),
             'website_id'
         )->where(
             'product_id = ?',
@@ -142,7 +181,7 @@ class Product extends AbstractResource
     public function getWebsiteIdsByProductIds($productIds)
     {
         $select = $this->_getWriteAdapter()->select()->from(
-            $this->_productWebsiteTable,
+            $this->getProductWebsiteTable(),
             ['product_id', 'website_id']
         )->where(
             'product_id IN (?)',
@@ -171,7 +210,7 @@ class Product extends AbstractResource
         $adapter = $this->_getReadAdapter();
 
         $select = $adapter->select()->from(
-            $this->_productCategoryTable,
+            $this->getProductCategoryTable(),
             'category_id'
         )->where(
             'product_id = ?',
@@ -274,14 +313,14 @@ class Product extends AbstractResource
             foreach ($insert as $websiteId) {
                 $data[] = ['product_id' => (int)$product->getId(), 'website_id' => (int)$websiteId];
             }
-            $adapter->insertMultiple($this->_productWebsiteTable, $data);
+            $adapter->insertMultiple($this->getProductWebsiteTable(), $data);
         }
 
         if (!empty($delete)) {
             foreach ($delete as $websiteId) {
                 $condition = ['product_id = ?' => (int)$product->getId(), 'website_id = ?' => (int)$websiteId];
 
-                $adapter->delete($this->_productWebsiteTable, $condition);
+                $adapter->delete($this->getProductWebsiteTable(), $condition);
             }
         }
 
@@ -329,7 +368,7 @@ class Product extends AbstractResource
                 ];
             }
             if ($data) {
-                $write->insertMultiple($this->_productCategoryTable, $data);
+                $write->insertMultiple($this->getProductCategoryTable(), $data);
             }
         }
 
@@ -337,7 +376,7 @@ class Product extends AbstractResource
             foreach ($delete as $categoryId) {
                 $where = ['product_id = ?' => (int)$object->getId(), 'category_id = ?' => (int)$categoryId];
 
-                $write->delete($this->_productCategoryTable, $where);
+                $write->delete($this->getProductCategoryTable(), $where);
             }
         }
 
diff --git a/app/code/Magento/Catalog/Model/Session.php b/app/code/Magento/Catalog/Model/Session.php
index b61175b11e7da3ff879834074f303590b664b72b..d7a3748c2810bd82a6b856e4d7dfe814cd0401ab 100644
--- a/app/code/Magento/Catalog/Model/Session.php
+++ b/app/code/Magento/Catalog/Model/Session.php
@@ -8,6 +8,6 @@ namespace Magento\Catalog\Model;
 /**
  * Catalog session model
  */
-class Session extends \Magento\Framework\Session\Generic
+class Session extends \Magento\Framework\Session\SessionManager
 {
 }
diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Product/ProductList/ToolbarTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Product/ProductList/ToolbarTest.php
index df66448c160372d82452ebe45b9ac68b7bb08749..d4501bd7d04393062a693c3491482132a7565d7d 100644
--- a/app/code/Magento/Catalog/Test/Unit/Block/Product/ProductList/ToolbarTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Block/Product/ProductList/ToolbarTest.php
@@ -106,9 +106,6 @@ class ToolbarTest extends \PHPUnit_Framework_TestCase
             '',
             false
         );
-        $this->catalogConfig->expects($this->any())
-            ->method('getAttributeUsedForSortByArray')
-            ->will($this->returnValue(['name' => [], 'price' => []]));
 
         $context = $this->getMock(
             'Magento\Framework\View\Element\Template\Context',
@@ -133,9 +130,6 @@ class ToolbarTest extends \PHPUnit_Framework_TestCase
             '',
             false
         );
-        $this->productListHelper->expects($this->any())
-            ->method('getAvailableViewMode')
-            ->will($this->returnValue(['list' => 'List']));
 
         $this->urlEncoder = $this->getMock('Magento\Framework\Url\EncoderInterface', ['encode'], [], '', false);
         $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
@@ -187,6 +181,9 @@ class ToolbarTest extends \PHPUnit_Framework_TestCase
         $this->model->expects($this->once())
             ->method('getOrder')
             ->will($this->returnValue($order));
+        $this->catalogConfig->expects($this->once())
+            ->method('getAttributeUsedForSortByArray')
+            ->will($this->returnValue(['name' => [], 'price' => []]));
 
         $this->assertEquals($order, $this->block->getCurrentOrder());
     }
@@ -206,6 +203,9 @@ class ToolbarTest extends \PHPUnit_Framework_TestCase
     {
         $mode = 'list';
 
+        $this->productListHelper->expects($this->once())
+            ->method('getAvailableViewMode')
+            ->will($this->returnValue(['list' => 'List']));
         $this->model->expects($this->once())
             ->method('getMode')
             ->will($this->returnValue($mode));
@@ -213,6 +213,40 @@ class ToolbarTest extends \PHPUnit_Framework_TestCase
         $this->assertEquals($mode, $this->block->getCurrentMode());
     }
 
+    public function testGetModes()
+    {
+        $mode = ['list' => 'List'];
+        $this->productListHelper->expects($this->once())
+            ->method('getAvailableViewMode')
+            ->will($this->returnValue($mode));
+
+        $this->assertEquals($mode, $this->block->getModes());
+        $this->assertEquals($mode, $this->block->getModes());
+    }
+
+    /**
+     * @param string[] $mode
+     * @param string[] $expected
+     * @dataProvider setModesDataProvider
+     */
+    public function testSetModes($mode, $expected)
+    {
+        $this->productListHelper->expects($this->once())
+            ->method('getAvailableViewMode')
+            ->will($this->returnValue($mode));
+
+        $block = $this->block->setModes(['mode' => 'mode']);
+        $this->assertEquals($expected, $block->getModes());
+    }
+
+    public function setModesDataProvider()
+    {
+        return [
+            [['list' => 'List'], ['list' => 'List']],
+            [null, ['mode' => 'mode']],
+        ];
+    }
+
     public function testGetLimit()
     {
         $mode = 'list';
@@ -232,6 +266,9 @@ class ToolbarTest extends \PHPUnit_Framework_TestCase
             ->method('getDefaultLimitPerPageValue')
             ->with($this->equalTo('list'))
             ->will($this->returnValue(10));
+        $this->productListHelper->expects($this->any())
+            ->method('getAvailableViewMode')
+            ->will($this->returnValue(['list' => 'List']));
 
         $this->assertEquals($limit, $this->block->getLimit());
     }
@@ -280,4 +317,48 @@ class ToolbarTest extends \PHPUnit_Framework_TestCase
 
         $this->assertTrue($this->block->getPagerHtml());
     }
+
+    public function testSetDefaultOrder()
+    {
+        $this->catalogConfig->expects($this->atLeastOnce())
+            ->method('getAttributeUsedForSortByArray')
+            ->will($this->returnValue(['name' => [], 'price' => []]));
+
+        $this->block->setDefaultOrder('field');
+    }
+
+    public function testGetAvailableOrders()
+    {
+        $data = ['name' => [], 'price' => []];
+        $this->catalogConfig->expects($this->once())
+            ->method('getAttributeUsedForSortByArray')
+            ->will($this->returnValue($data));
+
+        $this->assertEquals($data, $this->block->getAvailableOrders());
+        $this->assertEquals($data, $this->block->getAvailableOrders());
+    }
+
+    public function testAddOrderToAvailableOrders()
+    {
+        $data = ['name' => [], 'price' => []];
+        $this->catalogConfig->expects($this->once())
+            ->method('getAttributeUsedForSortByArray')
+            ->will($this->returnValue($data));
+        $expected = $data;
+        $expected['order'] = 'value';
+        $toolbar = $this->block->addOrderToAvailableOrders('order', 'value');
+        $this->assertEquals($expected, $toolbar->getAvailableOrders());
+    }
+
+    public function testRemoveOrderFromAvailableOrders()
+    {
+        $data = ['name' => [], 'price' => []];
+        $this->catalogConfig->expects($this->once())
+            ->method('getAttributeUsedForSortByArray')
+            ->will($this->returnValue($data));
+        $toolbar = $this->block->removeOrderFromAvailableOrders('order', 'value');
+        $this->assertEquals($data, $toolbar->getAvailableOrders());
+        $toolbar2 = $this->block->removeOrderFromAvailableOrders('name');
+        $this->assertEquals(['price' => []], $toolbar2->getAvailableOrders());
+    }
 }
diff --git a/app/code/Magento/Catalog/etc/di.xml b/app/code/Magento/Catalog/etc/di.xml
index acd741fdbbe66d5c107a3d24ce3d99a5ec716b52..8a4efe5a2b862b4be9e489a7a9c01b186ad08b0c 100644
--- a/app/code/Magento/Catalog/etc/di.xml
+++ b/app/code/Magento/Catalog/etc/di.xml
@@ -98,6 +98,7 @@
     <type name="Magento\Catalog\Model\Product">
         <arguments>
             <argument name="catalogProductStatus" xsi:type="object">Magento\Catalog\Model\Product\Attribute\Source\Status\Proxy</argument>
+            <argument name="productLink" xsi:type="object">Magento\Catalog\Model\Product\Link\Proxy</argument>
         </arguments>
     </type>
     <type name="Magento\Catalog\Model\Resource\Product\Collection">
@@ -398,6 +399,11 @@
             <argument name="validatorFile" xsi:type="object">Magento\Catalog\Model\Product\Option\Type\File\ValidatorFile\Proxy</argument>
         </arguments>
     </type>
+    <type name="Magento\Catalog\Model\Attribute\Config">
+        <arguments>
+            <argument name="dataStorage" xsi:type="object">Magento\Catalog\Model\Attribute\Config\Data\Proxy</argument>
+        </arguments>
+    </type>
     <virtualType name="Magento\Catalog\Model\Layer\Search\Context" type="Magento\Catalog\Model\Layer\Context">
         <arguments>
             <argument name="collectionProvider" xsi:type="object">Magento\Catalog\Model\Layer\Search\ItemCollectionProvider</argument>
@@ -464,4 +470,9 @@
     <type name="Magento\Catalog\Api\ProductRepositoryInterface">
         <plugin name="transactionWrapper" type="\Magento\Catalog\Model\Plugin\ProductRepository\TransactionWrapper" sortOrder="-1"/>
     </type>
+    <type name="Magento\Catalog\Model\CategoryRepository">
+        <arguments>
+            <argument name="categoryResource" xsi:type="object">Magento\Catalog\Model\Resource\Category\Proxy</argument>
+        </arguments>
+    </type>
 </config>
diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Proxy/Product/Resource.php b/app/code/Magento/CatalogImportExport/Model/Import/Proxy/Product/Resource.php
index a71fe9dcc496215b69d7573c094c6762a8be4c4d..0f68ad9e99503a7932d2407dd79bd15d55c870f5 100644
--- a/app/code/Magento/CatalogImportExport/Model/Import/Proxy/Product/Resource.php
+++ b/app/code/Magento/CatalogImportExport/Model/Import/Proxy/Product/Resource.php
@@ -13,23 +13,4 @@ namespace Magento\CatalogImportExport\Model\Import\Proxy\Product;
 
 class Resource extends \Magento\Catalog\Model\Resource\Product
 {
-    /**
-     * Product to category table.
-     *
-     * @return string
-     */
-    public function getProductCategoryTable()
-    {
-        return $this->_productCategoryTable;
-    }
-
-    /**
-     * Product to website table.
-     *
-     * @return string
-     */
-    public function getProductWebsiteTable()
-    {
-        return $this->_productWebsiteTable;
-    }
 }
diff --git a/app/code/Magento/CatalogInventory/etc/di.xml b/app/code/Magento/CatalogInventory/etc/di.xml
index 11c98534f732718a84bb3cde28379c3f76137b61..1dbf03634d581640985f406e1ac296ed346ef655 100644
--- a/app/code/Magento/CatalogInventory/etc/di.xml
+++ b/app/code/Magento/CatalogInventory/etc/di.xml
@@ -52,4 +52,9 @@
     <type name="Magento\Catalog\Block\Product\View">
         <plugin name="quantityValidators" type="Magento\CatalogInventory\Block\Plugin\ProductView" />
     </type>
+    <type name="Magento\CatalogInventory\Model\Configuration">
+        <arguments>
+            <argument name="config" xsi:type="object">Magento\Catalog\Model\ProductTypes\Config\Proxy</argument>
+        </arguments>
+    </type>
 </config>
diff --git a/app/code/Magento/Checkout/Model/Session.php b/app/code/Magento/Checkout/Model/Session.php
index 0f7d18e41355b5ffbae94f02f0f6272485d59cbd..da634e082756d1e8be81769a6af6dc32a6874fbe 100644
--- a/app/code/Magento/Checkout/Model/Session.php
+++ b/app/code/Magento/Checkout/Model/Session.php
@@ -90,6 +90,7 @@ class Session extends \Magento\Framework\Session\SessionManager
      * @param \Magento\Framework\Session\StorageInterface $storage
      * @param \Magento\Framework\Stdlib\CookieManagerInterface $cookieManager
      * @param \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory
+     * @param \Magento\Framework\App\State $appState
      * @param \Magento\Sales\Model\OrderFactory $orderFactory
      * @param \Magento\Customer\Model\Session $customerSession
      * @param \Magento\Quote\Model\QuoteRepository $quoteRepository
@@ -97,6 +98,7 @@ class Session extends \Magento\Framework\Session\SessionManager
      * @param \Magento\Framework\Event\ManagerInterface $eventManager
      * @param \Magento\Store\Model\StoreManagerInterface $storeManager
      * @param \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository
+     * @throws \Magento\Framework\Exception\SessionException
      * @SuppressWarnings(PHPMD.ExcessiveParameterList)
      */
     public function __construct(
@@ -108,6 +110,7 @@ class Session extends \Magento\Framework\Session\SessionManager
         \Magento\Framework\Session\StorageInterface $storage,
         \Magento\Framework\Stdlib\CookieManagerInterface $cookieManager,
         \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory,
+        \Magento\Framework\App\State $appState,
         \Magento\Sales\Model\OrderFactory $orderFactory,
         \Magento\Customer\Model\Session $customerSession,
         \Magento\Quote\Model\QuoteRepository $quoteRepository,
@@ -131,9 +134,9 @@ class Session extends \Magento\Framework\Session\SessionManager
             $validator,
             $storage,
             $cookieManager,
-            $cookieMetadataFactory
+            $cookieMetadataFactory,
+            $appState
         );
-        $this->start();
     }
 
     /**
diff --git a/app/code/Magento/Cms/Block/Adminhtml/Block/Widget/Chooser.php b/app/code/Magento/Cms/Block/Adminhtml/Block/Widget/Chooser.php
index fed2f67da6f177806559e463deb8fda56a2fbb3f..11a83c181d64f504d267524440423a30c90b2970 100644
--- a/app/code/Magento/Cms/Block/Adminhtml/Block/Widget/Chooser.php
+++ b/app/code/Magento/Cms/Block/Adminhtml/Block/Widget/Chooser.php
@@ -81,7 +81,7 @@ class Chooser extends \Magento\Backend\Block\Widget\Grid\Extended
         if ($element->getValue()) {
             $block = $this->_blockFactory->create()->load($element->getValue());
             if ($block->getId()) {
-                $chooser->setLabel($block->getTitle());
+                $chooser->setLabel($this->escapeHtml($block->getTitle()));
             }
         }
 
diff --git a/app/code/Magento/Cms/Block/Adminhtml/Page/Widget/Chooser.php b/app/code/Magento/Cms/Block/Adminhtml/Page/Widget/Chooser.php
index addaf3f4926b8e05f48833b16e540eb73ad295ef..54c169c890a9b8f8901203bff0a9a3a6d4e69275 100644
--- a/app/code/Magento/Cms/Block/Adminhtml/Page/Widget/Chooser.php
+++ b/app/code/Magento/Cms/Block/Adminhtml/Page/Widget/Chooser.php
@@ -98,7 +98,7 @@ class Chooser extends \Magento\Backend\Block\Widget\Grid\Extended
         if ($element->getValue()) {
             $page = $this->_pageFactory->create()->load((int)$element->getValue());
             if ($page->getId()) {
-                $chooser->setLabel($page->getTitle());
+                $chooser->setLabel($this->escapeHtml($page->getTitle()));
             }
         }
 
diff --git a/app/code/Magento/Cms/Test/Unit/Block/Adminhtml/Block/Widget/ChooserTest.php b/app/code/Magento/Cms/Test/Unit/Block/Adminhtml/Block/Widget/ChooserTest.php
index 0c075194e3330d099d7bb12b2427b971621f8a81..55761dae44ac94230eb126aa182e22394aaf1d32 100644
--- a/app/code/Magento/Cms/Test/Unit/Block/Adminhtml/Block/Widget/ChooserTest.php
+++ b/app/code/Magento/Cms/Test/Unit/Block/Adminhtml/Block/Widget/ChooserTest.php
@@ -35,6 +35,11 @@ class ChooserTest extends \PHPUnit_Framework_TestCase
      */
     protected $urlBuilderMock;
 
+    /**
+     * @var \Magento\Framework\Escaper|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $escaper;
+
     /**
      * @var \Magento\Cms\Model\BlockFactory|\PHPUnit_Framework_MockObject_MockObject
      */
@@ -66,6 +71,14 @@ class ChooserTest extends \PHPUnit_Framework_TestCase
         $this->urlBuilderMock = $this->getMockBuilder('Magento\Framework\UrlInterface')
             ->disableOriginalConstructor()
             ->getMock();
+        $this->escaper = $this->getMockBuilder('Magento\Framework\Escaper')
+            ->disableOriginalConstructor()
+            ->setMethods(
+                [
+                    'escapeHtml',
+                ]
+            )
+            ->getMock();
         $this->blockFactoryMock = $this->getMockBuilder('Magento\Cms\Model\BlockFactory')
             ->setMethods(
                 [
@@ -90,6 +103,7 @@ class ChooserTest extends \PHPUnit_Framework_TestCase
                 [
                     'getTitle',
                     'load',
+                    'getId',
                 ]
             )
             ->getMock();
@@ -112,15 +126,16 @@ class ChooserTest extends \PHPUnit_Framework_TestCase
         $this->context = $objectManager->getObject(
             'Magento\Backend\Block\Template\Context',
             [
-                'layout' => $this->layoutMock,
+                'layout'     => $this->layoutMock,
                 'mathRandom' => $this->mathRandomMock,
-                'urlBuilder' => $this->urlBuilderMock
+                'urlBuilder' => $this->urlBuilderMock,
+                'escaper'    => $this->escaper,
             ]
         );
         $this->this = $objectManager->getObject(
             'Magento\Cms\Block\Adminhtml\Block\Widget\Chooser',
             [
-                'context' => $this->context,
+                'context'      => $this->context,
                 'blockFactory' => $this->blockFactoryMock
             ]
         );
@@ -135,13 +150,14 @@ class ChooserTest extends \PHPUnit_Framework_TestCase
      */
     public function testPrepareElementHtml($elementValue, $modelBlockId)
     {
-        $elementId = 1;
-        $uniqId = '126hj4h3j73hk7b347jhkl37gb34';
-        $sourceUrl = 'cms/block_widget/chooser/126hj4h3j73hk7b347jhkl37gb34';
-        $config = ['key1' => 'value1'];
-        $fieldsetId = 2;
-        $html = 'some html';
-        $title = 'some title';
+        $elementId    = 1;
+        $uniqId       = '126hj4h3j73hk7b347jhkl37gb34';
+        $sourceUrl    = 'cms/block_widget/chooser/126hj4h3j73hk7b347jhkl37gb34';
+        $config       = ['key1' => 'value1'];
+        $fieldsetId   = 2;
+        $html         = 'some html';
+        $title        = 'some "><img src=y onerror=prompt(document.domain)>; title';
+        $titleEscaped = 'some &quot;&gt;&lt;img src=y onerror=prompt(document.domain)&gt;; title';
 
         $this->this->setConfig($config);
         $this->this->setFieldsetId($fieldsetId);
@@ -197,13 +213,18 @@ class ChooserTest extends \PHPUnit_Framework_TestCase
         $this->modelBlockMock->expects($this->any())
             ->method('getTitle')
             ->willReturn($title);
-        $this->chooserMock->expects($this->any())
-            ->method('setLabel')
-            ->with($title)
-            ->willReturnSelf();
         $this->chooserMock->expects($this->atLeastOnce())
             ->method('toHtml')
             ->willReturn($html);
+        if (!empty($elementValue) && !empty($modelBlockId)) {
+            $this->escaper->expects(($this->atLeastOnce()))
+                ->method('escapeHtml')
+                ->willReturn($titleEscaped);
+            $this->chooserMock->expects($this->atLeastOnce())
+                ->method('setLabel')
+                ->with($titleEscaped)
+                ->willReturnSelf();
+        }
         $this->elementMock->expects($this->atLeastOnce())
             ->method('setData')
             ->with('after_element_html', $html)
diff --git a/app/code/Magento/Cms/Test/Unit/Block/Adminhtml/Page/Widget/ChooserTest.php b/app/code/Magento/Cms/Test/Unit/Block/Adminhtml/Page/Widget/ChooserTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..75107bcb42de11db287607e49595aa6fecfd637b
--- /dev/null
+++ b/app/code/Magento/Cms/Test/Unit/Block/Adminhtml/Page/Widget/ChooserTest.php
@@ -0,0 +1,271 @@
+<?php
+/**
+ * Copyright © 2015 Magento. All rights reserved.
+ * See COPYING.txt for license details.
+ */
+namespace Magento\Cms\Test\Unit\Block\Adminhtml\Page\Widget;
+
+/**
+ * @covers \Magento\Cms\Block\Adminhtml\Page\Widget\Chooser
+ */
+class ChooserTest extends \PHPUnit_Framework_TestCase
+{
+    /**
+     * @var \Magento\Cms\Block\Adminhtml\Page\Widget\Chooser
+     */
+    protected $this;
+
+    /**
+     * @var \Magento\Backend\Block\Template\Context
+     */
+    protected $context;
+
+    /**
+     * @var \Magento\Framework\Math\Random|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $mathRandomMock;
+
+    /**
+     * @var \Magento\Framework\UrlInterface|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $urlBuilderMock;
+
+    /**
+     * @var \Magento\Framework\Escaper|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $escaper;
+
+    /**
+     * @var \Magento\Cms\Model\Page|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $cmsPageMock;
+
+    /**
+     * @var \Magento\Framework\View\LayoutInterface|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $layoutMock;
+
+    /**
+     * @var \Magento\Cms\Model\PageFactory|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $pageFactoryMock;
+
+    /**
+     * @var \Magento\Framework\Data\Form\Element\AbstractElement|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $elementMock;
+
+    /**
+     * @var \Magento\Framework\View\Element\BlockInterface|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $chooserMock;
+
+    protected function setUp()
+    {
+        $this->layoutMock = $this->getMockBuilder('Magento\Framework\View\LayoutInterface')
+            ->disableOriginalConstructor()
+            ->getMock();
+        $this->mathRandomMock = $this->getMockBuilder('Magento\Framework\Math\Random')
+            ->disableOriginalConstructor()
+            ->getMock();
+        $this->urlBuilderMock = $this->getMockBuilder('Magento\Framework\UrlInterface')
+            ->disableOriginalConstructor()
+            ->getMock();
+        $this->escaper = $this->getMockBuilder('Magento\Framework\Escaper')
+            ->disableOriginalConstructor()
+            ->setMethods(
+                [
+                    'escapeHtml',
+                ]
+            )
+            ->getMock();
+        $this->pageFactoryMock = $this->getMockBuilder('Magento\Cms\Model\PageFactory')
+            ->setMethods(
+                [
+                    'create',
+                ]
+            )
+            ->disableOriginalConstructor()
+            ->getMock();
+        $this->elementMock = $this->getMockBuilder('Magento\Framework\Data\Form\Element\AbstractElement')
+            ->disableOriginalConstructor()
+            ->setMethods(
+                [
+                    'getId',
+                    'getValue',
+                    'setData',
+                ]
+            )
+            ->getMock();
+        $this->cmsPageMock = $this->getMockBuilder('Magento\Cms\Model\Page')
+            ->disableOriginalConstructor()
+            ->setMethods(
+                [
+                    'getTitle',
+                    'load',
+                    'getId',
+                ]
+            )
+            ->getMock();
+        $this->chooserMock = $this->getMockBuilder('Magento\Framework\View\Element\BlockInterface')
+            ->disableOriginalConstructor()
+            ->setMethods(
+                [
+                    'setElement',
+                    'setConfig',
+                    'setFieldsetId',
+                    'setSourceUrl',
+                    'setUniqId',
+                    'setLabel',
+                    'toHtml',
+                ]
+            )
+            ->getMock();
+
+        $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+        $this->context = $objectManager->getObject(
+            'Magento\Backend\Block\Template\Context',
+            [
+                'layout'     => $this->layoutMock,
+                'mathRandom' => $this->mathRandomMock,
+                'urlBuilder' => $this->urlBuilderMock,
+                'escaper'    => $this->escaper,
+            ]
+        );
+        $this->this = $objectManager->getObject(
+            'Magento\Cms\Block\Adminhtml\Page\Widget\Chooser',
+            [
+                'context'     => $this->context,
+                'pageFactory' => $this->pageFactoryMock
+            ]
+        );
+    }
+
+    /**
+     * @covers \Magento\Cms\Block\Adminhtml\Block\Widget\Chooser::prepareElementHtml
+     *
+     * @param string $elementValue
+     * @param integer|null $cmsPageId
+     *
+     * @dataProvider prepareElementHtmlDataProvider
+     */
+    public function testPrepareElementHtml($elementValue, $cmsPageId)
+    {
+        //$elementValue = 12345;
+        //$cmsPageId    = 1;
+        $elementId    = 1;
+        $uniqId       = '126hj4h3j73hk7b347jhkl37gb34';
+        $sourceUrl    = 'cms/page_widget/chooser/126hj4h3j73hk7b347jhkl37gb34';
+        $config       = ['key1' => 'value1'];
+        $fieldsetId   = 2;
+        $html         = 'some html';
+        $title        = 'some "><img src=y onerror=prompt(document.domain)>; title';
+        $titleEscaped = 'some &quot;&gt;&lt;img src=y onerror=prompt(document.domain)&gt;; title';
+
+        $this->this->setConfig($config);
+        $this->this->setFieldsetId($fieldsetId);
+
+        $this->elementMock->expects($this->atLeastOnce())
+            ->method('getId')
+            ->willReturn($elementId);
+        $this->mathRandomMock->expects($this->atLeastOnce())
+            ->method('getUniqueHash')
+            ->with($elementId)
+            ->willReturn($uniqId);
+        $this->urlBuilderMock->expects($this->atLeastOnce())
+            ->method('getUrl')
+            ->with('cms/page_widget/chooser', ['uniq_id' => $uniqId])
+            ->willReturn($sourceUrl);
+        $this->layoutMock->expects($this->atLeastOnce())
+            ->method('createBlock')
+            ->with('Magento\Widget\Block\Adminhtml\Widget\Chooser')
+            ->willReturn($this->chooserMock);
+        $this->chooserMock->expects($this->atLeastOnce())
+            ->method('setElement')
+            ->with($this->elementMock)
+            ->willReturnSelf();
+        $this->chooserMock->expects($this->atLeastOnce())
+            ->method('setConfig')
+            ->with($config)
+            ->willReturnSelf();
+        $this->chooserMock->expects($this->atLeastOnce())
+            ->method('setFieldsetId')
+            ->with($fieldsetId)
+            ->willReturnSelf();
+        $this->chooserMock->expects($this->atLeastOnce())
+            ->method('setSourceUrl')
+            ->with($sourceUrl)
+            ->willReturnSelf();
+        $this->chooserMock->expects($this->atLeastOnce())
+            ->method('setUniqId')
+            ->with($uniqId)
+            ->willReturnSelf();
+        $this->elementMock->expects($this->atLeastOnce())
+            ->method('getValue')
+            ->willReturn($elementValue);
+        $this->pageFactoryMock->expects($this->any())
+            ->method('create')
+            ->willReturn($this->cmsPageMock);
+        $this->cmsPageMock->expects($this->any())
+            ->method('load')
+            ->with((int)$elementValue)
+            ->willReturnSelf();
+        $this->cmsPageMock->expects($this->any())
+            ->method('getId')
+            ->willReturn($cmsPageId);
+        $this->cmsPageMock->expects($this->any())
+            ->method('getTitle')
+            ->willReturn($title);
+        $this->chooserMock->expects($this->atLeastOnce())
+            ->method('toHtml')
+            ->willReturn($html);
+        if (!empty($elementValue) && !empty($cmsPageId)) {
+            $this->escaper->expects(($this->atLeastOnce()))
+                ->method('escapeHtml')
+                ->willReturn($titleEscaped);
+            $this->chooserMock->expects($this->atLeastOnce())
+                ->method('setLabel')
+                ->with($titleEscaped)
+                ->willReturnSelf();
+        }
+        $this->elementMock->expects($this->atLeastOnce())
+            ->method('setData')
+            ->with('after_element_html', $html)
+            ->willReturnSelf();
+
+        $this->assertEquals($this->elementMock, $this->this->prepareElementHtml($this->elementMock));
+    }
+
+    public function prepareElementHtmlDataProvider()
+    {
+        return [
+            'elementValue NOT EMPTY, modelBlockId NOT EMPTY' => [
+                'elementValue' => 'some value',
+                'cmsPageId' => 1,
+            ],
+            'elementValue NOT EMPTY, modelBlockId IS EMPTY' => [
+                'elementValue' => 'some value',
+                'cmsPageId' => null,
+            ],
+            'elementValue IS EMPTY, modelBlockId NEVER REACHED' => [
+                'elementValue' => '',
+                'cmsPageId' => 1,
+            ]
+        ];
+    }
+
+    /**
+     * @covers \Magento\Cms\Block\Adminhtml\Page\Widget\Chooser::getGridUrl
+     */
+    public function testGetGridUrl()
+    {
+        $url = 'some url';
+
+        $this->urlBuilderMock->expects($this->atLeastOnce())
+            ->method('getUrl')
+            ->with('cms/page_widget/chooser', ['_current' => true])
+            ->willReturn($url);
+
+        $this->assertEquals($url, $this->this->getGridUrl());
+    }
+}
diff --git a/app/code/Magento/Config/Model/Config/Backend/File.php b/app/code/Magento/Config/Model/Config/Backend/File.php
index e7a119f79af9f0bf78d8f459ff0d30875abd097b..a08ed7d4f23894640e6592728f9a2c6a8eb1432b 100644
--- a/app/code/Magento/Config/Model/Config/Backend/File.php
+++ b/app/code/Magento/Config/Model/Config/Backend/File.php
@@ -5,6 +5,7 @@
  */
 namespace Magento\Config\Model\Config\Backend;
 
+use Magento\Framework\App\Config\ScopeConfigInterface;
 use Magento\Framework\App\Filesystem\DirectoryList;
 use Magento\Framework\Filesystem;
 
@@ -196,7 +197,7 @@ class File extends \Magento\Framework\App\Config\Value
     protected function _prependScopeInfo($path)
     {
         $scopeInfo = $this->getScope();
-        if (\Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT != $this->getScope()) {
+        if (ScopeConfigInterface::SCOPE_TYPE_DEFAULT != $this->getScope()) {
             $scopeInfo .= '/' . $this->getScopeId();
         }
         return $scopeInfo . '/' . $path;
@@ -213,7 +214,7 @@ class File extends \Magento\Framework\App\Config\Value
     protected function _appendScopeInfo($path)
     {
         $path .= '/' . $this->getScope();
-        if (\Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT != $this->getScope()) {
+        if (ScopeConfigInterface::SCOPE_TYPE_DEFAULT != $this->getScope()) {
             $path .= '/' . $this->getScopeId();
         }
         return $path;
diff --git a/app/code/Magento/Config/Model/Config/Backend/Locale.php b/app/code/Magento/Config/Model/Config/Backend/Locale.php
index 0881afdebfc3839d52d0c27de0052ae6a8bd68b1..3d057fd6df864d23061ba4d1d762e265482eb595 100644
--- a/app/code/Magento/Config/Model/Config/Backend/Locale.php
+++ b/app/code/Magento/Config/Model/Config/Backend/Locale.php
@@ -9,6 +9,8 @@
  */
 namespace Magento\Config\Model\Config\Backend;
 
+use Magento\Framework\App\Config\ScopeConfigInterface;
+
 class Locale extends \Magento\Framework\App\Config\Value
 {
     /**
@@ -91,7 +93,7 @@ class Locale extends \Magento\Framework\App\Config\Value
                     }
 
                     switch ($data->getScope()) {
-                        case \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT:
+                        case ScopeConfigInterface::SCOPE_TYPE_DEFAULT:
                             $scopeName = __('Default scope');
                             break;
 
diff --git a/app/code/Magento/Config/Model/Config/ScopeDefiner.php b/app/code/Magento/Config/Model/Config/ScopeDefiner.php
index 893496d874009b9834fc2f1821057283ba01e323..f69e9dd96d2eb820a87a9d1f5905445df9c576df 100644
--- a/app/code/Magento/Config/Model/Config/ScopeDefiner.php
+++ b/app/code/Magento/Config/Model/Config/ScopeDefiner.php
@@ -5,6 +5,7 @@
  */
 namespace Magento\Config\Model\Config;
 
+use Magento\Framework\App\Config\ScopeConfigInterface;
 use Magento\Store\Model\ScopeInterface as StoreScopeInterface;
 
 /**
@@ -38,6 +39,6 @@ class ScopeDefiner
             'store'
         ) ? StoreScopeInterface::SCOPE_STORE : ($this->_request->getParam(
             'website'
-        ) ? StoreScopeInterface::SCOPE_WEBSITE : \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT);
+        ) ? StoreScopeInterface::SCOPE_WEBSITE : ScopeConfigInterface::SCOPE_TYPE_DEFAULT);
     }
 }
diff --git a/app/code/Magento/Config/Model/Config/Structure/AbstractElement.php b/app/code/Magento/Config/Model/Config/Structure/AbstractElement.php
index e10a1a1c3e725333743bea341d6170865f17d119..03ed66f29abec3ebd79735f648aefcd633dc44cc 100644
--- a/app/code/Magento/Config/Model/Config/Structure/AbstractElement.php
+++ b/app/code/Magento/Config/Model/Config/Structure/AbstractElement.php
@@ -5,6 +5,7 @@
  */
 namespace Magento\Config\Model\Config\Structure;
 
+use Magento\Framework\App\Config\ScopeConfigInterface;
 use Magento\Store\Model\StoreManagerInterface;
 
 abstract class AbstractElement implements ElementInterface
@@ -136,7 +137,7 @@ abstract class AbstractElement implements ElementInterface
         $showInScope = [
             \Magento\Store\Model\ScopeInterface::SCOPE_STORE => $this->_hasVisibilityValue('showInStore'),
             \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE => $this->_hasVisibilityValue('showInWebsite'),
-            \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT => $this->_hasVisibilityValue('showInDefault'),
+            ScopeConfigInterface::SCOPE_TYPE_DEFAULT => $this->_hasVisibilityValue('showInDefault'),
         ];
 
         if ($this->_storeManager->isSingleStoreMode()) {
diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/ScopeDefinerTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/ScopeDefinerTest.php
index 23069beec258fa8c6ab4e398c537a4874a9010b7..e0c64a35053ad44c88baa18861e84641a995d17d 100644
--- a/app/code/Magento/Config/Test/Unit/Model/Config/ScopeDefinerTest.php
+++ b/app/code/Magento/Config/Test/Unit/Model/Config/ScopeDefinerTest.php
@@ -5,6 +5,7 @@
  */
 namespace Magento\Config\Test\Unit\Model\Config;
 
+use Magento\Framework\App\Config\ScopeConfigInterface;
 use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
 
 class ScopeDefinerTest extends \PHPUnit_Framework_TestCase
@@ -31,7 +32,7 @@ class ScopeDefinerTest extends \PHPUnit_Framework_TestCase
 
     public function testGetScopeReturnsDefaultScopeIfNoScopeDataIsSpecified()
     {
-        $this->assertEquals(\Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT, $this->_model->getScope());
+        $this->assertEquals(ScopeConfigInterface::SCOPE_TYPE_DEFAULT, $this->_model->getScope());
     }
 
     public function testGetScopeReturnsStoreScopeIfStoreIsSpecified()
diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/AbstractElementTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/AbstractElementTest.php
index 03e9fd8d2266e5c9256c74a81716e59e4eb40ac0..778141ab2132096aa8d0e750f7175bebdcea935b 100644
--- a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/AbstractElementTest.php
+++ b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/AbstractElementTest.php
@@ -5,6 +5,8 @@
  */
 namespace Magento\Config\Test\Unit\Model\Config\Structure;
 
+use Magento\Framework\App\Config\ScopeConfigInterface;
+
 class AbstractElementTest extends \PHPUnit_Framework_TestCase
 {
     /**
@@ -77,7 +79,7 @@ class AbstractElementTest extends \PHPUnit_Framework_TestCase
         $this->_storeManager->expects($this->once())->method('isSingleStoreMode')->will($this->returnValue(true));
         $this->_model->setData(
             ['showInDefault' => 1, 'showInStore' => 0, 'showInWebsite' => 0],
-            \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT
+            ScopeConfigInterface::SCOPE_TYPE_DEFAULT
         );
         $this->assertTrue($this->_model->isVisible());
     }
@@ -87,7 +89,7 @@ class AbstractElementTest extends \PHPUnit_Framework_TestCase
         $this->_storeManager->expects($this->once())->method('isSingleStoreMode')->will($this->returnValue(true));
         $this->_model->setData(
             ['hide_in_single_store_mode' => 1, 'showInDefault' => 1, 'showInStore' => 0, 'showInWebsite' => 0],
-            \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT
+            ScopeConfigInterface::SCOPE_TYPE_DEFAULT
         );
         $this->assertFalse($this->_model->isVisible());
     }
@@ -100,7 +102,7 @@ class AbstractElementTest extends \PHPUnit_Framework_TestCase
         $this->_storeManager->expects($this->once())->method('isSingleStoreMode')->will($this->returnValue(true));
         $this->_model->setData(
             ['showInDefault' => 0, 'showInStore' => 0, 'showInWebsite' => 0],
-            \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT
+            ScopeConfigInterface::SCOPE_TYPE_DEFAULT
         );
         $this->assertFalse($this->_model->isVisible());
     }
@@ -121,7 +123,7 @@ class AbstractElementTest extends \PHPUnit_Framework_TestCase
         return [
             [
                 ['showInDefault' => 1, 'showInStore' => 0, 'showInWebsite' => 0],
-                \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT,
+                ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
             ],
             [
                 ['showInDefault' => 0, 'showInStore' => 1, 'showInWebsite' => 0],
@@ -150,7 +152,7 @@ class AbstractElementTest extends \PHPUnit_Framework_TestCase
         return [
             [
                 ['showInDefault' => 0, 'showInStore' => 1, 'showInWebsite' => 1],
-                \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT,
+                ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
             ],
             [
                 ['showInDefault' => 1, 'showInStore' => 0, 'showInWebsite' => 1],
diff --git a/app/code/Magento/Customer/Model/Config/Backend/Address/Street.php b/app/code/Magento/Customer/Model/Config/Backend/Address/Street.php
index 7e187a71e5c08bdad11cf84b9cfdc3c9ca85632c..b25f4c6d0b3a3cb83b3693f1d2d7c08fb4859247 100644
--- a/app/code/Magento/Customer/Model/Config/Backend/Address/Street.php
+++ b/app/code/Magento/Customer/Model/Config/Backend/Address/Street.php
@@ -5,6 +5,8 @@
  */
 namespace Magento\Customer\Model\Config\Backend\Address;
 
+use Magento\Framework\App\Config\ScopeConfigInterface;
+
 /**
  * Line count config model for customer address street attribute
  *
@@ -64,7 +66,7 @@ class Street extends \Magento\Framework\App\Config\Value
                 }
                 break;
 
-            case \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT:
+            case ScopeConfigInterface::SCOPE_TYPE_DEFAULT:
                 $attribute->setData('multiline_count', $value);
                 break;
         }
diff --git a/app/code/Magento/Customer/Model/Customer.php b/app/code/Magento/Customer/Model/Customer.php
index c65cda9e51bbae8fa77d7f89b0bb440a7fb121f7..776c8e74e1ace9aa8cc4205174c6fb0977032368 100644
--- a/app/code/Magento/Customer/Model/Customer.php
+++ b/app/code/Magento/Customer/Model/Customer.php
@@ -12,6 +12,7 @@ use Magento\Customer\Model\Resource\Address\CollectionFactory;
 use Magento\Customer\Model\Resource\Customer as ResourceCustomer;
 use Magento\Customer\Api\Data\CustomerInterfaceFactory;
 use Magento\Customer\Model\Data\Customer as CustomerData;
+use Magento\Framework\App\Config\ScopeConfigInterface;
 use Magento\Framework\Reflection\DataObjectProcessor;
 use Magento\Framework\Exception\EmailNotConfirmedException;
 use Magento\Framework\Exception\InvalidEmailOrPasswordException;
@@ -1310,7 +1311,7 @@ class Customer extends \Magento\Framework\Model\AbstractModel
     {
         return (int)$this->_scopeConfig->getValue(
             self::XML_PATH_CUSTOMER_RESET_PASSWORD_LINK_EXPIRATION_PERIOD,
-            \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT
+            ScopeConfigInterface::SCOPE_TYPE_DEFAULT
         );
     }
 
diff --git a/app/code/Magento/Customer/Model/Resource/Address.php b/app/code/Magento/Customer/Model/Resource/Address.php
index 57a5c1cbcf3d9c28e975a999395d5ffd18600696..3b6ae0a28c8f9e812e762b72dbfe45d35681ebe9 100644
--- a/app/code/Magento/Customer/Model/Resource/Address.php
+++ b/app/code/Magento/Customer/Model/Resource/Address.php
@@ -45,13 +45,22 @@ class Address extends \Magento\Eav\Model\Entity\AbstractEntity
      */
     protected function _construct()
     {
-        $resource = $this->_resource;
-        $this->setType(
-            'customer_address'
-        )->setConnection(
-            $resource->getConnection('customer_read'),
-            $resource->getConnection('customer_write')
-        );
+        $this->_read = 'customer_read';
+        $this->_write = 'customer_write';
+    }
+
+    /**
+     * Getter and lazy loader for _type
+     *
+     * @throws \Magento\Framework\Exception\LocalizedException
+     * @return \Magento\Eav\Model\Entity\Type
+     */
+    public function getEntityType()
+    {
+        if (empty($this->_type)) {
+            $this->setType('customer_address');
+        }
+        return parent::getEntityType();
     }
 
     /**
diff --git a/app/code/Magento/Customer/Model/Session.php b/app/code/Magento/Customer/Model/Session.php
index c01cd99d642cf7cb72c963fc20513f2e8e525235..4212be78b59114439b049203b03eca3a488991e4 100644
--- a/app/code/Magento/Customer/Model/Session.php
+++ b/app/code/Magento/Customer/Model/Session.php
@@ -102,6 +102,7 @@ class Session extends \Magento\Framework\Session\SessionManager
      * @param \Magento\Framework\Session\StorageInterface $storage
      * @param \Magento\Framework\Stdlib\CookieManagerInterface $cookieManager
      * @param \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory
+     * @param \Magento\Framework\App\State $appState
      * @param Share $configShare
      * @param \Magento\Framework\Url\Helper\Data $coreUrl
      * @param \Magento\Customer\Model\Url $customerUrl
@@ -113,6 +114,7 @@ class Session extends \Magento\Framework\Session\SessionManager
      * @param \Magento\Framework\App\Http\Context $httpContext
      * @param CustomerRepositoryInterface $customerRepository
      * @param GroupManagementInterface $groupManagement
+     * @throws \Magento\Framework\Exception\SessionException
      * @SuppressWarnings(PHPMD.ExcessiveParameterList)
      */
     public function __construct(
@@ -124,6 +126,7 @@ class Session extends \Magento\Framework\Session\SessionManager
         \Magento\Framework\Session\StorageInterface $storage,
         \Magento\Framework\Stdlib\CookieManagerInterface $cookieManager,
         \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory,
+        \Magento\Framework\App\State $appState,
         Config\Share $configShare,
         \Magento\Framework\Url\Helper\Data $coreUrl,
         \Magento\Customer\Model\Url $customerUrl,
@@ -154,9 +157,9 @@ class Session extends \Magento\Framework\Session\SessionManager
             $validator,
             $storage,
             $cookieManager,
-            $cookieMetadataFactory
+            $cookieMetadataFactory,
+            $appState
         );
-        $this->start();
         $this->groupManagement = $groupManagement;
         $this->_eventManager->dispatch('customer_session_init', ['customer_session' => $this]);
     }
diff --git a/app/code/Magento/Customer/Test/Unit/Block/Widget/DobTest.php b/app/code/Magento/Customer/Test/Unit/Block/Widget/DobTest.php
index 5d1e91708b4fcd6da306011c551415bf3586d66a..834c64df6701f19605ccd05fb8298d1def87fa4a 100644
--- a/app/code/Magento/Customer/Test/Unit/Block/Widget/DobTest.php
+++ b/app/code/Magento/Customer/Test/Unit/Block/Widget/DobTest.php
@@ -10,6 +10,7 @@ namespace Magento\Customer\Test\Unit\Block\Widget;
 
 use Magento\Framework\Exception\NoSuchEntityException;
 use Magento\Customer\Block\Widget\Dob;
+use Magento\Framework\Locale\Resolver;
 
 class DobTest extends \PHPUnit_Framework_TestCase
 {
@@ -69,7 +70,7 @@ class DobTest extends \PHPUnit_Framework_TestCase
         $localeResolver = $this->getMock('\Magento\Framework\Locale\ResolverInterface');
         $localeResolver->expects($this->any())
             ->method('getLocale')
-            ->willReturn(\Magento\Framework\Locale\ResolverInterface::DEFAULT_LOCALE);
+            ->willReturn(Resolver::DEFAULT_LOCALE);
         $timezone = $objectManager->getObject(
             'Magento\Framework\Stdlib\DateTime\Timezone',
             ['localeResolver' => $localeResolver]
diff --git a/app/code/Magento/Customer/Test/Unit/Model/Resource/AddressTest.php b/app/code/Magento/Customer/Test/Unit/Model/Resource/AddressTest.php
index fe17aa1aca70eb47723da99b6c9a8639944b76de..c15cf1596c8245fb30d8a79ba097923d545c26b0 100644
--- a/app/code/Magento/Customer/Test/Unit/Model/Resource/AddressTest.php
+++ b/app/code/Magento/Customer/Test/Unit/Model/Resource/AddressTest.php
@@ -18,6 +18,9 @@ class AddressTest extends \PHPUnit_Framework_TestCase
     /** @var \Magento\Customer\Model\CustomerFactory|\PHPUnit_Framework_MockObject_MockObject */
     protected $customerFactory;
 
+    /** @var \Magento\Eav\Model\Entity\Type */
+    protected $eavConfigType;
+
     protected function setUp()
     {
         $this->addressResource = (new ObjectManagerHelper($this))->getObject(
@@ -178,16 +181,16 @@ class AddressTest extends \PHPUnit_Framework_TestCase
                 )
             );
 
-        $eavConfigType = $this->getMock(
+        $this->eavConfigType = $this->getMock(
             'Magento\Eav\Model\Entity\Type',
             ['getEntityIdField', 'getId', 'getEntityTable', '__wakeup'],
             [],
             '',
             false
         );
-        $eavConfigType->expects($this->any())->method('getEntityIdField')->willReturn(false);
-        $eavConfigType->expects($this->any())->method('getId')->willReturn(false);
-        $eavConfigType->expects($this->any())->method('getEntityTable')->willReturn('customer_address_entity');
+        $this->eavConfigType->expects($this->any())->method('getEntityIdField')->willReturn(false);
+        $this->eavConfigType->expects($this->any())->method('getId')->willReturn(false);
+        $this->eavConfigType->expects($this->any())->method('getEntityTable')->willReturn('customer_address_entity');
 
         $eavConfig = $this->getMock(
             'Magento\Eav\Model\Config',
@@ -199,10 +202,10 @@ class AddressTest extends \PHPUnit_Framework_TestCase
         $eavConfig->expects($this->any())
             ->method('getEntityType')
             ->with('customer_address')
-            ->willReturn($eavConfigType);
+            ->willReturn($this->eavConfigType);
         $eavConfig->expects($this->any())
             ->method('getEntityAttributeCodes')
-            ->with($eavConfigType)
+            ->with($this->eavConfigType)
             ->willReturn(
                 [
                     'entity_type_id',
@@ -217,13 +220,13 @@ class AddressTest extends \PHPUnit_Framework_TestCase
         $eavConfig->expects($this->any())
             ->method('getAttribute')
             ->willReturnMap([
-                [$eavConfigType, 'entity_type_id', $attributeMock],
-                [$eavConfigType, 'attribute_set_id', $attributeMock],
-                [$eavConfigType, 'created_at', $attributeMock],
-                [$eavConfigType, 'updated_at', $attributeMock],
-                [$eavConfigType, 'parent_id', $attributeMock],
-                [$eavConfigType, 'increment_id', $attributeMock],
-                [$eavConfigType, 'entity_id', $attributeMock],
+                [$this->eavConfigType, 'entity_type_id', $attributeMock],
+                [$this->eavConfigType, 'attribute_set_id', $attributeMock],
+                [$this->eavConfigType, 'created_at', $attributeMock],
+                [$this->eavConfigType, 'updated_at', $attributeMock],
+                [$this->eavConfigType, 'parent_id', $attributeMock],
+                [$this->eavConfigType, 'increment_id', $attributeMock],
+                [$this->eavConfigType, 'entity_id', $attributeMock],
             ]);
 
         return $eavConfig;
@@ -261,4 +264,9 @@ class AddressTest extends \PHPUnit_Framework_TestCase
         $this->customerFactory = $this->getMock('Magento\Customer\Model\CustomerFactory', ['create'], [], '', false);
         return $this->customerFactory;
     }
+
+    public function testGetType()
+    {
+        $this->assertSame($this->eavConfigType, $this->addressResource->getEntityType());
+    }
 }
diff --git a/app/code/Magento/DesignEditor/Model/Url/NavigationMode.php b/app/code/Magento/DesignEditor/Model/Url/NavigationMode.php
index af413fcd477b0b044e36d1bc9ed4bfc3c6637eb5..cb54368e519392d63b842cd6227cce1644e51c7d 100644
--- a/app/code/Magento/DesignEditor/Model/Url/NavigationMode.php
+++ b/app/code/Magento/DesignEditor/Model/Url/NavigationMode.php
@@ -38,7 +38,7 @@ class NavigationMode extends \Magento\Framework\Url
      * @param \Magento\Framework\Url\ScopeResolverInterface $scopeResolver
      * @param \Magento\Framework\Session\Generic $session
      * @param \Magento\Framework\Session\SidResolverInterface $sidResolver
-     * @param \Magento\Framework\Url\RouteParamsResolverFactory $routeParamsResolver
+     * @param \Magento\Framework\Url\RouteParamsResolverFactory $routeParamsResolverFactory
      * @param \Magento\Framework\Url\QueryParamsResolverInterface $queryParamsResolver
      * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
      * @param string $scopeType
@@ -53,7 +53,7 @@ class NavigationMode extends \Magento\Framework\Url
         \Magento\Framework\Url\ScopeResolverInterface $scopeResolver,
         \Magento\Framework\Session\Generic $session,
         \Magento\Framework\Session\SidResolverInterface $sidResolver,
-        \Magento\Framework\Url\RouteParamsResolverFactory $routeParamsResolver,
+        \Magento\Framework\Url\RouteParamsResolverFactory $routeParamsResolverFactory,
         \Magento\Framework\Url\QueryParamsResolverInterface $queryParamsResolver,
         \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
         $scopeType,
@@ -75,7 +75,7 @@ class NavigationMode extends \Magento\Framework\Url
             $scopeResolver,
             $session,
             $sidResolver,
-            $routeParamsResolver,
+            $routeParamsResolverFactory,
             $queryParamsResolver,
             $scopeConfig,
             $scopeType,
diff --git a/app/code/Magento/DesignEditor/Test/Unit/Model/Url/NavigationModeTest.php b/app/code/Magento/DesignEditor/Test/Unit/Model/Url/NavigationModeTest.php
index e6de82bcf54ee3798e263bafb0d3a5f77c5e1435..e4ee8ff76365954f2ec2b404f72515d4c2cc3249 100644
--- a/app/code/Magento/DesignEditor/Test/Unit/Model/Url/NavigationModeTest.php
+++ b/app/code/Magento/DesignEditor/Test/Unit/Model/Url/NavigationModeTest.php
@@ -90,7 +90,7 @@ class NavigationModeTest extends \PHPUnit_Framework_TestCase
             [
                 'helper' => $this->_designHelperMock,
                 'data' => $this->_testData,
-                'routeParamsResolver' => $this->_routeParamsMock,
+                'routeParamsResolverFactory' => $this->_routeParamsMock,
                 'scopeResolver' => $this->_scopeResolverMock
             ]
         );
diff --git a/app/code/Magento/Developer/etc/adminhtml/system.xml b/app/code/Magento/Developer/etc/adminhtml/system.xml
index f858f6b51bc275787d5b476b42a1a3f62277ec11..13ec5c3a13106fc5820440bb0b7754e6404a5074 100644
--- a/app/code/Magento/Developer/etc/adminhtml/system.xml
+++ b/app/code/Magento/Developer/etc/adminhtml/system.xml
@@ -9,7 +9,7 @@
         <section id="dev" translate="label">
             <group id="front_end_development_workflow" translate="label" type="text" sortOrder="8" showInDefault="1" showInWebsite="1" showInStore="1">
                 <label>Front-end development workflow</label>
-                <field id="type" translate="label comment" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
+                <field id="type" translate="label comment" type="select" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0">
                     <label>Workflow type</label>
                     <comment>Not available in production mode</comment>
                     <source_model>Magento\Developer\Model\Config\Source\WorkflowType</source_model>
diff --git a/app/code/Magento/Eav/Model/Entity/AbstractEntity.php b/app/code/Magento/Eav/Model/Entity/AbstractEntity.php
index ac8c5805f4b72f8727d09a4a4cbc71a0f05c2258..c8fa8214eab58921da003c19e9a5c55b4a3d66c1 100755
--- a/app/code/Magento/Eav/Model/Entity/AbstractEntity.php
+++ b/app/code/Magento/Eav/Model/Entity/AbstractEntity.php
@@ -31,14 +31,14 @@ abstract class AbstractEntity extends \Magento\Framework\Model\Resource\Abstract
     /**
      * Read connection
      *
-     * @var \Magento\Framework\DB\Adapter\Pdo\Mysql
+     * @var \Magento\Framework\DB\Adapter\Pdo\Mysql | string
      */
     protected $_read;
 
     /**
      * Write connection
      *
-     * @var \Magento\Framework\DB\Adapter\Pdo\Mysql
+     * @var \Magento\Framework\DB\Adapter\Pdo\Mysql | string
      */
     protected $_write;
 
diff --git a/app/code/Magento/Eav/etc/di.xml b/app/code/Magento/Eav/etc/di.xml
index 3dfebf456c7ff4ae26f6f8a118431872c7c2f67e..00524114f784dd3bc859a8395a9c1d23012433cc 100644
--- a/app/code/Magento/Eav/etc/di.xml
+++ b/app/code/Magento/Eav/etc/di.xml
@@ -57,4 +57,9 @@
             </argument>
         </arguments>
     </type>
+    <type name="Magento\Eav\Model\Entity\Attribute">
+        <arguments>
+            <argument name="reservedAttributeList" xsi:type="object">Magento\Catalog\Model\Product\ReservedAttributeList\Proxy</argument>
+        </arguments>
+    </type>
 </config>
diff --git a/app/code/Magento/Email/Model/BackendTemplate.php b/app/code/Magento/Email/Model/BackendTemplate.php
index be5b232564a67e139724e96f6d7a51a89702ed9c..c8bc6b34398e0c492f9123cfaeedc8182da23299 100644
--- a/app/code/Magento/Email/Model/BackendTemplate.php
+++ b/app/code/Magento/Email/Model/BackendTemplate.php
@@ -5,6 +5,8 @@
  */
 namespace Magento\Email\Model;
 
+use Magento\Framework\App\Config\ScopeConfigInterface;
+
 /**
  * Adminhtml email template model
  *
@@ -78,7 +80,7 @@ class BackendTemplate extends Template
             return [];
         }
 
-        $configData = $this->_scopeConfig->getValue(null, \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT);
+        $configData = $this->_scopeConfig->getValue(null, ScopeConfigInterface::SCOPE_TYPE_DEFAULT);
         $paths = $this->_findEmailTemplateUsages($templateCode, $configData, '');
         return $paths;
     }
diff --git a/app/code/Magento/GoogleAdwords/etc/di.xml b/app/code/Magento/GoogleAdwords/etc/di.xml
new file mode 100644
index 0000000000000000000000000000000000000000..293db157d7c38cca198df46a541016f71c97dd54
--- /dev/null
+++ b/app/code/Magento/GoogleAdwords/etc/di.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0"?>
+<!--
+/**
+ * Copyright © 2015 Magento. All rights reserved.
+ * See COPYING.txt for license details.
+ */
+-->
+<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
+    <type name="Magento\GoogleAdwords\Model\Observer">
+        <arguments>
+            <argument name="collection" xsi:type="object">Magento\Sales\Model\Resource\Order\Collection\Proxy</argument>
+        </arguments>
+    </type>
+</config>
diff --git a/app/code/Magento/Newsletter/Model/Session.php b/app/code/Magento/Newsletter/Model/Session.php
index 18d680df142601fb39eab95181cee59a79cca4cb..2ffb0b2f25236066922a7510267f10135c1a518f 100644
--- a/app/code/Magento/Newsletter/Model/Session.php
+++ b/app/code/Magento/Newsletter/Model/Session.php
@@ -8,7 +8,7 @@ namespace Magento\Newsletter\Model;
 /**
  * Newsletter session model
  */
-class Session extends \Magento\Framework\Session\Generic
+class Session extends \Magento\Framework\Session\SessionManager
 {
     /**
      * Set error message
diff --git a/app/code/Magento/Quote/etc/di.xml b/app/code/Magento/Quote/etc/di.xml
index 4eeb1ff2b61a7e865d24c28af7411c599b7c3f05..0b46fc59fb7dcbead0e93d40563787ce7f6af5b7 100644
--- a/app/code/Magento/Quote/etc/di.xml
+++ b/app/code/Magento/Quote/etc/di.xml
@@ -25,7 +25,6 @@
     <preference for="Magento\Quote\Api\Data\TotalsInterface" type="\Magento\Quote\Model\Cart\Totals" />
     <preference for="Magento\Quote\Api\Data\TotalsItemInterface" type="\Magento\Quote\Model\Quote\Cart\Totals\Item" />
     <preference for="Magento\Quote\Api\Data\CurrencyInterface" type="\Magento\Quote\Model\Cart\Currency" />
-
     <preference for="Magento\Quote\Api\GuestCartManagementInterface" type="Magento\Quote\Model\GuestCart\GuestCartManagement" />
     <preference for="Magento\Quote\Api\GuestCartRepositoryInterface" type="Magento\Quote\Model\GuestCart\GuestCartRepository" />
     <preference for="Magento\Quote\Api\GuestCartItemRepositoryInterface" type="Magento\Quote\Model\GuestCart\GuestCartItemRepository" />
@@ -35,7 +34,6 @@
     <preference for="Magento\Quote\Api\GuestShippingAddressManagementInterface" type="Magento\Quote\Model\GuestCart\GuestShippingAddressManagement" />
     <preference for="Magento\Quote\Api\GuestShippingMethodManagementInterface" type="Magento\Quote\Model\GuestCart\GuestShippingMethodManagement" />
     <preference for="Magento\Quote\Api\GuestBillingAddressManagementInterface" type="Magento\Quote\Model\GuestCart\GuestBillingAddressManagement" />
-
     <type name="Magento\Webapi\Controller\Rest\ParamsOverrider">
         <arguments>
             <argument name="paramOverriders" xsi:type="array">
@@ -43,4 +41,14 @@
             </argument>
         </arguments>
     </type>
+    <type name="Magento\Quote\Model\QuoteRepository">
+        <arguments>
+            <argument name="quoteCollection" xsi:type="object">Magento\Quote\Model\Resource\Quote\Collection\Proxy</argument>
+        </arguments>
+    </type>
+    <type name="Magento\Quote\Model\Quote\Address">
+        <arguments>
+            <argument name="addressConfig" xsi:type="object">Magento\Customer\Model\Address\Config\Proxy</argument>
+        </arguments>
+    </type>
 </config>
diff --git a/app/code/Magento/Review/Model/Resource/Review/Collection.php b/app/code/Magento/Review/Model/Resource/Review/Collection.php
index 7bd2de244b7adb3bdff739d5782cb681e832c41b..d32a6b04ac03043b9fc8a2c596ece7d84af58eaf 100644
--- a/app/code/Magento/Review/Model/Resource/Review/Collection.php
+++ b/app/code/Magento/Review/Model/Resource/Review/Collection.php
@@ -17,35 +17,35 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac
      *
      * @var string
      */
-    protected $_reviewTable;
+    protected $_reviewTable = null;
 
     /**
      * Review detail table
      *
      * @var string
      */
-    protected $_reviewDetailTable;
+    protected $_reviewDetailTable = null;
 
     /**
      * Review status table
      *
      * @var string
      */
-    protected $_reviewStatusTable;
+    protected $_reviewStatusTable = null;
 
     /**
      * Review entity table
      *
      * @var string
      */
-    protected $_reviewEntityTable;
+    protected $_reviewEntityTable = null;
 
     /**
      * Review store table
      *
      * @var string
      */
-    protected $_reviewStoreTable;
+    protected $_reviewStoreTable = null;
 
     /**
      * Add store data flag
@@ -111,11 +111,6 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac
     protected function _construct()
     {
         $this->_init('Magento\Review\Model\Review', 'Magento\Review\Model\Resource\Review');
-        $this->_reviewTable = $this->getTable('review');
-        $this->_reviewDetailTable = $this->getTable('review_detail');
-        $this->_reviewStatusTable = $this->getTable('review_status');
-        $this->_reviewEntityTable = $this->getTable('review_entity');
-        $this->_reviewStoreTable = $this->getTable('review_store');
     }
 
     /**
@@ -127,7 +122,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac
     {
         parent::_initSelect();
         $this->getSelect()->join(
-            ['detail' => $this->_reviewDetailTable],
+            ['detail' => $this->getReviewDetailTable()],
             'main_table.review_id = detail.review_id',
             ['detail_id', 'title', 'detail', 'nickname', 'customer_id']
         );
@@ -156,7 +151,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac
     {
         $inCond = $this->getConnection()->prepareSqlCondition('store.store_id', ['in' => $storeId]);
         $this->getSelect()->join(
-            ['store' => $this->_reviewStoreTable],
+            ['store' => $this->getReviewStoreTable()],
             'main_table.review_id=store.review_id',
             []
         );
@@ -184,18 +179,19 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac
      */
     public function addEntityFilter($entity, $pkValue)
     {
+        $reviewEntityTable = $this->getReviewEntityTable();
         if (is_numeric($entity)) {
             $this->addFilter('entity', $this->getConnection()->quoteInto('main_table.entity_id=?', $entity), 'string');
         } elseif (is_string($entity)) {
             $this->_select->join(
-                $this->_reviewEntityTable,
-                'main_table.entity_id=' . $this->_reviewEntityTable . '.entity_id',
+                $reviewEntityTable,
+                'main_table.entity_id=' . $reviewEntityTable . '.entity_id',
                 ['entity_code']
             );
 
             $this->addFilter(
                 'entity',
-                $this->getConnection()->quoteInto($this->_reviewEntityTable . '.entity_code=?', $entity),
+                $this->getConnection()->quoteInto($reviewEntityTable . '.entity_code=?', $entity),
                 'string'
             );
         }
@@ -268,7 +264,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac
     public function addReviewsTotalCount()
     {
         $this->_select->joinLeft(
-            ['r' => $this->_reviewTable],
+            ['r' => $this->getReviewTable()],
             'main_table.entity_pk_value = r.entity_pk_value',
             ['total_reviews' => new \Zend_Db_Expr('COUNT(r.review_id)')]
         )->group(
@@ -311,7 +307,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac
         $storesToReviews = [];
         if (count($reviewsIds) > 0) {
             $inCond = $adapter->prepareSqlCondition('review_id', ['in' => $reviewsIds]);
-            $select = $adapter->select()->from($this->_reviewStoreTable)->where($inCond);
+            $select = $adapter->select()->from($this->getReviewStoreTable())->where($inCond);
             $result = $adapter->fetchAll($select);
             foreach ($result as $row) {
                 if (!isset($storesToReviews[$row['review_id']])) {
@@ -329,4 +325,69 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac
             }
         }
     }
+
+    /**
+     * Get review table
+     *
+     * @return string
+     */
+    protected function getReviewTable()
+    {
+        if ($this->_reviewTable === null) {
+            $this->_reviewTable = $this->getTable('review');
+        }
+        return $this->_reviewTable;
+    }
+
+    /**
+     * Get review detail table
+     *
+     * @return string
+     */
+    protected function getReviewDetailTable()
+    {
+        if ($this->_reviewDetailTable === null) {
+            $this->_reviewDetailTable = $this->getTable('review_detail');
+        }
+        return $this->_reviewDetailTable;
+    }
+
+    /**
+     * Get review status table
+     *
+     * @return string
+     */
+    protected function getReviewStatusTable()
+    {
+        if ($this->_reviewStatusTable === null) {
+            $this->_reviewStatusTable = $this->getTable('review_status');
+        }
+        return $this->_reviewStatusTable;
+    }
+
+    /**
+     * Get review entity table
+     *
+     * @return string
+     */
+    protected function getReviewEntityTable()
+    {
+        if ($this->_reviewEntityTable === null) {
+            $this->_reviewEntityTable = $this->getTable('review_entity');
+        }
+        return $this->_reviewEntityTable;
+    }
+
+    /**
+     * Get review store table
+     *
+     * @return string
+     */
+    protected function getReviewStoreTable()
+    {
+        if ($this->_reviewStoreTable === null) {
+            $this->_reviewStoreTable = $this->getTable('review_store');
+        }
+        return $this->_reviewStoreTable;
+    }
 }
diff --git a/app/code/Magento/Review/Test/Unit/Model/Resource/Review/CollectionTest.php b/app/code/Magento/Review/Test/Unit/Model/Resource/Review/CollectionTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..67e67cdf8381745aa356f7b85129945f2d563d33
--- /dev/null
+++ b/app/code/Magento/Review/Test/Unit/Model/Resource/Review/CollectionTest.php
@@ -0,0 +1,188 @@
+<?php
+/**
+ * Copyright © 2015 Magento. All rights reserved.
+ * See COPYING.txt for license details.
+ */
+namespace Magento\Review\Test\Unit\Model\Resource\Review;
+
+class CollectionTest extends \PHPUnit_Framework_TestCase
+{
+    /**
+     * @var \Magento\Review\Model\Resource\Review\Collection
+     */
+    protected $model;
+
+    /**
+     * @var \Zend_Db_Select | \PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $selectMock;
+
+    /**
+     * @var \Magento\Store\Model\StoreManagerInterface | \PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $storeManagerMock;
+
+    /**
+     * @var \Magento\Framework\Model\Resource\Db\AbstractDb | \PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $resourceMock;
+
+    /**
+     * @var \Zend_Db_Adapter_Abstract | \PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $readerAdapterMock;
+
+    /**
+     * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
+     */
+    protected $objectManager;
+
+    public function setUp()
+    {
+        $store = $this->getMock('\Magento\Store\Model\Store', ['getId'], [], '', false);
+        $store->expects($this->any())->method('getId')->will($this->returnValue(1));
+        $this->storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface');
+        $this->storeManagerMock->expects($this->any())->method('getStore')->will($this->returnValue($store));
+        $this->objectManager = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this));
+        $this->resourceMock = $this->getMockBuilder('Magento\Framework\Model\Resource\Db\AbstractDb')
+            ->disableOriginalConstructor()
+            ->setMethods(['getReadConnection', 'getMainTable', 'getTable'])
+            ->getMockForAbstractClass();
+        $this->readerAdapterMock = $this->getMockBuilder('\Zend_Db_Adapter_Abstract')
+            ->disableOriginalConstructor()
+            ->setMethods(['select', 'prepareSqlCondition', 'quoteInto'])
+            ->getMockForAbstractClass();
+        $this->selectMock = $this->getMockBuilder('\Zend_Db_Select')
+            ->disableOriginalConstructor()
+            ->getMock();
+        $this->readerAdapterMock->expects($this->any())
+            ->method('select')
+            ->willReturn($this->selectMock);
+        $this->resourceMock->expects($this->any())
+            ->method('getReadConnection')
+            ->willReturn($this->readerAdapterMock);
+        $this->resourceMock->expects($this->any())
+            ->method('getMainTable')
+            ->willReturn('maintable');
+        $this->resourceMock->expects($this->any())
+            ->method('getTable')
+            ->willReturnCallback(function ($table) {
+                return $table;
+            });
+        $this->model = $this->objectManager->getObject(
+            '\Magento\Review\Model\Resource\Review\Collection',
+            [
+                'storeManager' => $this->storeManagerMock,
+                'resource' => $this->resourceMock,
+            ]
+        );
+
+    }
+
+    public function testInitSelect()
+    {
+        $this->selectMock->expects($this->once())
+            ->method('join')
+            ->with(
+                ['detail' => 'review_detail'],
+                'main_table.review_id = detail.review_id',
+                ['detail_id', 'title', 'detail', 'nickname', 'customer_id']
+            );
+        $this->objectManager->getObject(
+            '\Magento\Review\Model\Resource\Review\Collection',
+            [
+                'storeManager' => $this->storeManagerMock,
+                'resource' => $this->resourceMock,
+            ]
+        );
+    }
+
+    public function testAddStoreFilter()
+    {
+        $this->readerAdapterMock->expects($this->once())
+            ->method('prepareSqlCondition');
+        $this->selectMock->expects($this->once())
+            ->method('join')
+            ->with(
+                ['store' => 'review_store'],
+                'main_table.review_id=store.review_id',
+                []
+            );
+        $this->model->addStoreFilter(1);
+    }
+
+    /**
+     * @param int|string $entity
+     * @param int $pkValue
+     * @param string $quoteIntoArguments1
+     * @param string $quoteIntoArguments2
+     * @param string $quoteIntoReturn1
+     * @param string $quoteIntoReturn2
+     * @param int $callNum
+     * @dataProvider addEntityFilterDataProvider
+     */
+    public function testAddEntityFilter(
+        $entity,
+        $pkValue,
+        $quoteIntoArguments1,
+        $quoteIntoArguments2,
+        $quoteIntoReturn1,
+        $quoteIntoReturn2,
+        $callNum
+    ) {
+        $this->readerAdapterMock->expects($this->at(0))
+            ->method('quoteInto')
+            ->with($quoteIntoArguments1[0], $quoteIntoArguments1[1])
+            ->willReturn($quoteIntoReturn1);
+        $this->readerAdapterMock->expects($this->at(1))
+            ->method('quoteInto')
+            ->with($quoteIntoArguments2[0], $quoteIntoArguments2[1])
+            ->willReturn($quoteIntoReturn2);
+        $this->selectMock->expects($this->exactly($callNum))
+            ->method('join')
+            ->with(
+                'review_entity',
+                'main_table.entity_id=' . 'review_entity' . '.entity_id',
+                ['entity_code']
+            );
+        $this->model->addEntityFilter($entity, $pkValue);
+    }
+
+    public function addEntityFilterDataProvider()
+    {
+        return [
+            [
+                1,
+                2,
+                ['main_table.entity_id=?', 1],
+                ['main_table.entity_pk_value=?', 2],
+                'quoteIntoReturn1',
+                'quoteIntoReturn2',
+                0
+            ],
+            [
+                'entity',
+                2,
+                ['review_entity.entity_code=?', 'entity'],
+                ['main_table.entity_pk_value=?', 2],
+                'quoteIntoReturn1',
+                'quoteIntoReturn2',
+                1
+            ]
+        ];
+    }
+
+    public function testAddReviewsTotalCount()
+    {
+        $this->selectMock->expects($this->once())
+            ->method('joinLeft')
+            ->with(
+                ['r' => 'review'],
+                'main_table.entity_pk_value = r.entity_pk_value',
+                ['total_reviews' => new \Zend_Db_Expr('COUNT(r.review_id)')]
+            )->willReturnSelf();
+        $this->selectMock->expects($this->once())
+            ->method('group');
+        $this->model->addReviewsTotalCount();
+    }
+}
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/EditInterface.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/EditInterface.php
deleted file mode 100644
index 79fefe2a18515d4f143f561aba1c9a2f9e3f4cde..0000000000000000000000000000000000000000
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/EditInterface.php
+++ /dev/null
@@ -1,11 +0,0 @@
-<?php
-/**
- *
- * Copyright © 2015 Magento. All rights reserved.
- * See COPYING.txt for license details.
- */
-namespace Magento\Sales\Controller\Adminhtml\Order;
-
-interface EditInterface extends \Magento\Framework\App\ActionInterface
-{
-}
diff --git a/app/code/Magento/Sales/Test/Unit/Model/Config/Backend/Email/AsyncSendingTest.php b/app/code/Magento/Sales/Test/Unit/Model/Config/Backend/Email/AsyncSendingTest.php
index 69f3f6e0df310d27dc7c7c6774ad5a62ca1e82cb..9359af03ee68dfcb020c7e7ed1a9923bd4d456ec 100644
--- a/app/code/Magento/Sales/Test/Unit/Model/Config/Backend/Email/AsyncSendingTest.php
+++ b/app/code/Magento/Sales/Test/Unit/Model/Config/Backend/Email/AsyncSendingTest.php
@@ -63,7 +63,7 @@ class AsyncSendingTest extends \PHPUnit_Framework_TestCase
     public function testAfterSave($value, $oldValue, $eventName)
     {
         $path = 'sales_email/general/async_sending';
-        $scope = \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT;
+        $scope = \Magento\Framework\App\Config\ScopeConfigInterface::SCOPE_TYPE_DEFAULT;
 
         $this->object->setData(['value' => $value, 'path' => $path, 'scope' => $scope]);
 
diff --git a/app/code/Magento/Sales/Test/Unit/Model/Config/Backend/Grid/AsyncIndexingTest.php b/app/code/Magento/Sales/Test/Unit/Model/Config/Backend/Grid/AsyncIndexingTest.php
index 972cfae38e2ae4273235a2c7a7d1ac260b4f45a3..729c19940ccff8b5f464eeeb895bc74e5aeafa16 100644
--- a/app/code/Magento/Sales/Test/Unit/Model/Config/Backend/Grid/AsyncIndexingTest.php
+++ b/app/code/Magento/Sales/Test/Unit/Model/Config/Backend/Grid/AsyncIndexingTest.php
@@ -63,7 +63,7 @@ class AsyncIndexingTest extends \PHPUnit_Framework_TestCase
     public function testAfterSave($value, $oldValue, $eventName)
     {
         $path = 'dev/grid/async_indexing';
-        $scope = \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT;
+        $scope = \Magento\Framework\App\Config\ScopeConfigInterface::SCOPE_TYPE_DEFAULT;
 
         $this->object->setData(['value' => $value, 'path' => $path, 'scope' => $scope]);
 
diff --git a/app/code/Magento/Search/Model/SearchEngine.php b/app/code/Magento/Search/Model/SearchEngine.php
index c4d5c4787a17af5dbfd7f042da520650493642c3..f80e6bfd8796f2d6e2dae2901f27028964c97b6c 100644
--- a/app/code/Magento/Search/Model/SearchEngine.php
+++ b/app/code/Magento/Search/Model/SearchEngine.php
@@ -17,14 +17,21 @@ class SearchEngine implements SearchEngineInterface
     /**
      * @var AdapterInterface
      */
-    protected $adapter;
+    private $adapter = null;
+
+    /**
+     * Adapter factory
+     *
+     * @var AdapterFactory
+     */
+    private $adapterFactory;
 
     /**
      * @param AdapterFactory $adapterFactory
      */
     public function __construct(AdapterFactory $adapterFactory)
     {
-        $this->adapter = $adapterFactory->create();
+        $this->adapterFactory = $adapterFactory;
     }
 
     /**
@@ -32,6 +39,19 @@ class SearchEngine implements SearchEngineInterface
      */
     public function search(RequestInterface $request)
     {
-        return $this->adapter->query($request);
+        return $this->getAdapter()->query($request);
+    }
+
+    /**
+     * Get adapter
+     *
+     * @return AdapterInterface
+     */
+    protected function getAdapter()
+    {
+        if ($this->adapter === null) {
+            $this->adapter = $this->adapterFactory->create();
+        }
+        return $this->adapter;
     }
 }
diff --git a/app/code/Magento/Store/Model/Config/Reader/DefaultReader.php b/app/code/Magento/Store/Model/Config/Reader/DefaultReader.php
index 4f03885e8cd7a910cb35abf05970bd86deb5a790..7bb9981369440c9c8062ffe6308376c8b089a05f 100644
--- a/app/code/Magento/Store/Model/Config/Reader/DefaultReader.php
+++ b/app/code/Magento/Store/Model/Config/Reader/DefaultReader.php
@@ -7,6 +7,9 @@
  */
 namespace Magento\Store\Model\Config\Reader;
 
+use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\Exception\LocalizedException;
+
 class DefaultReader implements \Magento\Framework\App\Config\Scope\ReaderInterface
 {
     /**
@@ -42,14 +45,21 @@ class DefaultReader implements \Magento\Framework\App\Config\Scope\ReaderInterfa
     /**
      * Read configuration data
      *
+     * @param null|string $scope
+     * @throws LocalizedException Exception is thrown when scope other than default is given
      * @return array
      */
-    public function read()
+    public function read($scope = null)
     {
-        $config = $this->_initialConfig->getData(\Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT);
+        $scope = $scope === null ? ScopeConfigInterface::SCOPE_TYPE_DEFAULT : $scope;
+        if ($scope !== ScopeConfigInterface::SCOPE_TYPE_DEFAULT) {
+            throw new \Magento\Framework\Exception\LocalizedException(__("Only default scope allowed"));
+        }
+
+        $config = $this->_initialConfig->getData($scope);
 
         $collection = $this->_collectionFactory->create(
-            ['scope' => \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT]
+            ['scope' => $scope]
         );
         $dbDefaultConfig = [];
         foreach ($collection as $item) {
diff --git a/app/code/Magento/Store/Model/Config/Reader/Store.php b/app/code/Magento/Store/Model/Config/Reader/Store.php
index c5456bcb102f9ad2952c17f33ac41f48c1ae777a..151c3625f2b1dbf596d222eaf10b3f7c9e07ce5e 100644
--- a/app/code/Magento/Store/Model/Config/Reader/Store.php
+++ b/app/code/Magento/Store/Model/Config/Reader/Store.php
@@ -5,6 +5,7 @@
  */
 namespace Magento\Store\Model\Config\Reader;
 
+use Magento\Framework\App\Config\ScopeConfigInterface;
 use Magento\Framework\Exception\NoSuchEntityException;
 
 class Store implements \Magento\Framework\App\Config\Scope\ReaderInterface
@@ -66,7 +67,7 @@ class Store implements \Magento\Framework\App\Config\Scope\ReaderInterface
     /**
      * Read configuration by code
      *
-     * @param string $code
+     * @param null|string $code
      * @return array
      * @throws NoSuchEntityException
      */
@@ -74,7 +75,7 @@ class Store implements \Magento\Framework\App\Config\Scope\ReaderInterface
     {
         if (empty($code)) {
             $store = $this->_storeManager->getStore();
-        } elseif (($code == \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT)) {
+        } elseif (($code == ScopeConfigInterface::SCOPE_TYPE_DEFAULT)) {
             $store = $this->_storeManager->getDefaultStoreView();
         } else {
             $store = $this->_storeFactory->create();
diff --git a/app/code/Magento/Store/Model/Config/Reader/Website.php b/app/code/Magento/Store/Model/Config/Reader/Website.php
index 1448b04bf9afbf5e6b49b5e223f53b9ec2a52f69..7971deb6c9713199cfe7c85617ebe767556edb18 100644
--- a/app/code/Magento/Store/Model/Config/Reader/Website.php
+++ b/app/code/Magento/Store/Model/Config/Reader/Website.php
@@ -5,6 +5,8 @@
  */
 namespace Magento\Store\Model\Config\Reader;
 
+use Magento\Framework\App\Config\ScopeConfigInterface;
+
 class Website implements \Magento\Framework\App\Config\Scope\ReaderInterface
 {
     /**
@@ -62,7 +64,7 @@ class Website implements \Magento\Framework\App\Config\Scope\ReaderInterface
     public function read($code = null)
     {
         $config = array_replace_recursive(
-            $this->_scopePool->getScope(\Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT)->getSource(),
+            $this->_scopePool->getScope(ScopeConfigInterface::SCOPE_TYPE_DEFAULT)->getSource(),
             $this->_initialConfig->getData("websites|{$code}")
         );
 
diff --git a/app/code/Magento/Store/Model/Store.php b/app/code/Magento/Store/Model/Store.php
index 1da41cae73e20593dcdc498b6b4a1bc94bb5a0b6..494d1c129254154208d81e6956d72027003f9dc4 100644
--- a/app/code/Magento/Store/Model/Store.php
+++ b/app/code/Magento/Store/Model/Store.php
@@ -5,6 +5,7 @@
  */
 namespace Magento\Store\Model;
 
+use Magento\Framework\App\Config\ScopeConfigInterface;
 use Magento\Framework\App\Filesystem\DirectoryList;
 use Magento\Framework\App\Http\Context;
 use Magento\Framework\Model\AbstractModel;
@@ -55,7 +56,7 @@ class Store extends AbstractModel implements
     const XML_PATH_UNSECURE_BASE_URL = 'web/unsecure/base_url';
 
     const XML_PATH_SECURE_BASE_URL = 'web/secure/base_url';
-    
+
     const XML_PATH_SECURE_IN_FRONTEND = 'web/secure/use_in_frontend';
 
     const XML_PATH_SECURE_IN_ADMINHTML = 'web/secure/use_in_adminhtml';
@@ -479,7 +480,7 @@ class Store extends AbstractModel implements
     {
         $data = $this->_config->getValue($path, ScopeInterface::SCOPE_STORE, $this->getCode());
         if (!$data) {
-            $data = $this->_config->getValue($path, \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT);
+            $data = $this->_config->getValue($path, ScopeConfigInterface::SCOPE_TYPE_DEFAULT);
         }
         return $data === false ? null : $data;
     }
@@ -788,7 +789,7 @@ class Store extends AbstractModel implements
         if ($configValue == self::PRICE_SCOPE_GLOBAL) {
             return $this->_config->getValue(
                 \Magento\Directory\Model\Currency::XML_PATH_CURRENCY_BASE,
-                \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT
+                ScopeConfigInterface::SCOPE_TYPE_DEFAULT
             );
         } else {
             return $this->_getConfig(\Magento\Directory\Model\Currency::XML_PATH_CURRENCY_BASE);
diff --git a/app/code/Magento/Store/Test/Unit/Model/Config/Reader/DefaultReaderTest.php b/app/code/Magento/Store/Test/Unit/Model/Config/Reader/DefaultReaderTest.php
index 9e91f4b43281522ac0a2d3688167488893df43e3..25875ae67dd5973525a0a59cbf7e2c1635c58691 100644
--- a/app/code/Magento/Store/Test/Unit/Model/Config/Reader/DefaultReaderTest.php
+++ b/app/code/Magento/Store/Test/Unit/Model/Config/Reader/DefaultReaderTest.php
@@ -5,6 +5,8 @@
  */
 namespace Magento\Store\Test\Unit\Model\Config\Reader;
 
+use Magento\Framework\App\Config\ScopeConfigInterface;
+
 class DefaultReaderTest extends \PHPUnit_Framework_TestCase
 {
     /**
@@ -46,7 +48,7 @@ class DefaultReaderTest extends \PHPUnit_Framework_TestCase
         )->method(
             'getData'
         )->with(
-            \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT
+            ScopeConfigInterface::SCOPE_TYPE_DEFAULT
         )->will(
             $this->returnValue(['config' => ['key1' => 'default_value1', 'key2' => 'default_value2']])
         );
diff --git a/app/code/Magento/Store/Test/Unit/Model/StoreTest.php b/app/code/Magento/Store/Test/Unit/Model/StoreTest.php
index e9a6f8ecf7207c03889a4043d02168d18e6e5b72..8d305848c554f900bd521f04490c7b8f18fca6a4 100644
--- a/app/code/Magento/Store/Test/Unit/Model/StoreTest.php
+++ b/app/code/Magento/Store/Test/Unit/Model/StoreTest.php
@@ -8,6 +8,7 @@
 
 namespace Magento\Store\Test\Unit\Model;
 
+use Magento\Framework\App\Config\ScopeConfigInterface;
 use Magento\Store\Model\ScopeInterface;
 use Magento\Framework\App\Config\ReinitableConfigInterface;
 use Magento\Store\Model\Store;
@@ -399,7 +400,7 @@ class StoreTest extends \PHPUnit_Framework_TestCase
                 ['catalog/price/scope', ScopeInterface::SCOPE_STORE, 'scope_code', $priceScope],
                 [
                     \Magento\Directory\Model\Currency::XML_PATH_CURRENCY_BASE,
-                    \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT,
+                    ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
                     null,
                     'USD'
                 ],
diff --git a/app/code/Magento/Store/etc/di.xml b/app/code/Magento/Store/etc/di.xml
index ebbc61f6036c8723c1fe943e07795097b63f1f6d..c1584145c2d3db3ad86924dd7ac6b0099155aa18 100644
--- a/app/code/Magento/Store/etc/di.xml
+++ b/app/code/Magento/Store/etc/di.xml
@@ -79,7 +79,7 @@
         <arguments>
             <argument name="session" xsi:type="object" shared="false">Magento\Framework\Session\Generic\Proxy</argument>
             <argument name="isCustomEntryPoint" xsi:type="init_parameter">Magento\Store\Model\Store::CUSTOM_ENTRY_POINT_PARAM</argument>
-            <argument name="url" xsi:type="object" shared="false">Magento\Framework\UrlInterface</argument>
+            <argument name="url" xsi:type="object" shared="false">Magento\Framework\UrlInterface\Proxy</argument>
         </arguments>
     </type>
     <type name="Magento\Store\Model\StoreManager">
diff --git a/app/code/Magento/Tax/Controller/Adminhtml/Tax/IgnoreTaxNotification.php b/app/code/Magento/Tax/Controller/Adminhtml/Tax/IgnoreTaxNotification.php
index d84a09825b08fb4391830a6ec8261b24d152557a..9fede0b0238787abcc72a691b7473f588a90434b 100644
--- a/app/code/Magento/Tax/Controller/Adminhtml/Tax/IgnoreTaxNotification.php
+++ b/app/code/Magento/Tax/Controller/Adminhtml/Tax/IgnoreTaxNotification.php
@@ -6,6 +6,7 @@
  */
 namespace Magento\Tax\Controller\Adminhtml\Tax;
 
+use Magento\Framework\App\Config\ScopeConfigInterface;
 use Magento\Framework\Controller\ResultFactory;
 
 class IgnoreTaxNotification extends \Magento\Tax\Controller\Adminhtml\Tax
@@ -43,7 +44,7 @@ class IgnoreTaxNotification extends \Magento\Tax\Controller\Adminhtml\Tax
             try {
                 $path = 'tax/notification/ignore_' . $section;
                 $this->_objectManager->get('Magento\Config\Model\Resource\Config')
-                    ->saveConfig($path, 1, \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT, 0);
+                    ->saveConfig($path, 1, ScopeConfigInterface::SCOPE_TYPE_DEFAULT, 0);
             } catch (\Exception $e) {
                 $this->messageManager->addError($e->getMessage());
             }
diff --git a/app/code/Magento/Tax/Model/Config/Notification.php b/app/code/Magento/Tax/Model/Config/Notification.php
index c886452442406056cb369dd15210a1c32b0c9829..f4b395a290856cf26c36fae743ac7a3ce9797c9b 100644
--- a/app/code/Magento/Tax/Model/Config/Notification.php
+++ b/app/code/Magento/Tax/Model/Config/Notification.php
@@ -5,6 +5,8 @@
  */
 namespace Magento\Tax\Model\Config;
 
+use Magento\Framework\App\Config\ScopeConfigInterface;
+
 /**
  * Tax Config Notification
  */
@@ -59,7 +61,7 @@ class Notification extends \Magento\Framework\App\Config\Value
      */
     protected function _resetNotificationFlag($path)
     {
-        $this->resourceConfig->saveConfig($path, 0, \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT, 0);
+        $this->resourceConfig->saveConfig($path, 0, ScopeConfigInterface::SCOPE_TYPE_DEFAULT, 0);
         return $this;
     }
 }
diff --git a/app/code/Magento/Tax/Test/Unit/Controller/Adminhtml/Tax/IgnoreTaxNotificationTest.php b/app/code/Magento/Tax/Test/Unit/Controller/Adminhtml/Tax/IgnoreTaxNotificationTest.php
index 2f2a823d5f64d3cb8c3b00a4c864a7108e181c32..8714905efc56bc118efd516eb8346ec1e2045ad6 100644
--- a/app/code/Magento/Tax/Test/Unit/Controller/Adminhtml/Tax/IgnoreTaxNotificationTest.php
+++ b/app/code/Magento/Tax/Test/Unit/Controller/Adminhtml/Tax/IgnoreTaxNotificationTest.php
@@ -5,6 +5,7 @@
  */
 namespace Magento\Tax\Test\Unit\Controller\Adminhtml\Tax;
 
+use Magento\Framework\App\Config\ScopeConfigInterface;
 use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
 
 class IgnoreTaxNotificationTest extends \PHPUnit_Framework_TestCase
@@ -51,7 +52,7 @@ class IgnoreTaxNotificationTest extends \PHPUnit_Framework_TestCase
             ->getMock();
         $config->expects($this->once())
             ->method('saveConfig')
-            ->with('tax/notification/ignore_tax', 1, \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT, 0)
+            ->with('tax/notification/ignore_tax', 1, ScopeConfigInterface::SCOPE_TYPE_DEFAULT, 0)
             ->willReturn(null);
 
         $manager = $this->getMockBuilder('\Magento\Framework\ObjectManagerInterface')
diff --git a/app/code/Magento/Theme/Model/Config.php b/app/code/Magento/Theme/Model/Config.php
index 5993e9bf010d5586384e03bdc4df50010f882547..39332cc9a0b7b7705db033cb7996e0fd3c482e90 100644
--- a/app/code/Magento/Theme/Model/Config.php
+++ b/app/code/Magento/Theme/Model/Config.php
@@ -9,6 +9,8 @@
  */
 namespace Magento\Theme\Model;
 
+use Magento\Framework\App\Config\ScopeConfigInterface;
+
 class Config
 {
     /**
@@ -173,7 +175,7 @@ class Config
     protected function _assignThemeToDefaultScope($themeId, &$isReassigned)
     {
         $configPath = \Magento\Framework\View\DesignInterface::XML_PATH_THEME_ID;
-        $this->_configWriter->save($configPath, $themeId, \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT);
+        $this->_configWriter->save($configPath, $themeId, ScopeConfigInterface::SCOPE_TYPE_DEFAULT);
         $isReassigned = true;
         return $this;
     }
diff --git a/app/code/Magento/Theme/Model/View/Design.php b/app/code/Magento/Theme/Model/View/Design.php
index f839d6ba900f71e2998634aa9e36776bcd863105..f0cf795f6b4482b9c8ac59bc444e62f4af24f14c 100644
--- a/app/code/Magento/Theme/Model/View/Design.php
+++ b/app/code/Magento/Theme/Model/View/Design.php
@@ -6,6 +6,8 @@
 
 namespace Magento\Theme\Model\View;
 
+use Magento\Framework\App\Config\ScopeConfigInterface;
+
 /**
  * Keeps design settings for current request
  */
@@ -167,7 +169,7 @@ class Design implements \Magento\Framework\View\DesignInterface
             if ($this->_storeManager->isSingleStoreMode()) {
                 $theme = $this->_scopeConfig->getValue(
                     self::XML_PATH_THEME_ID,
-                    \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT
+                    ScopeConfigInterface::SCOPE_TYPE_DEFAULT
                 );
             } else {
                 $theme = (string) $this->_scopeConfig->getValue(
diff --git a/app/code/Magento/User/Controller/Adminhtml/User/Edit.php b/app/code/Magento/User/Controller/Adminhtml/User/Edit.php
index 3d3ad64cd201a0bf5cc7eb3691852ab451317e21..39ac43d55391ba02f47089b28233a7f13e791d86 100644
--- a/app/code/Magento/User/Controller/Adminhtml/User/Edit.php
+++ b/app/code/Magento/User/Controller/Adminhtml/User/Edit.php
@@ -6,6 +6,8 @@
  */
 namespace Magento\User\Controller\Adminhtml\User;
 
+use Magento\Framework\Locale\Resolver;
+
 class Edit extends \Magento\User\Controller\Adminhtml\User
 {
     /**
@@ -25,7 +27,7 @@ class Edit extends \Magento\User\Controller\Adminhtml\User
                 return;
             }
         } else {
-            $model->setInterfaceLocale(\Magento\Framework\Locale\ResolverInterface::DEFAULT_LOCALE);
+            $model->setInterfaceLocale(Resolver::DEFAULT_LOCALE);
         }
 
         // Restore previously entered form data from session
diff --git a/app/etc/di.xml b/app/etc/di.xml
index c461dc254c841721a21146ff4010a00f848f1124..7ffd8702c787b917c82fb2073953559106c98119 100755
--- a/app/etc/di.xml
+++ b/app/etc/di.xml
@@ -964,6 +964,11 @@
             </argument>
         </arguments>
     </type>
+    <type name="Magento\Framework\Object\Copy\Config">
+        <arguments>
+            <argument name="dataStorage" xsi:type="object">Magento\Framework\Object\Copy\Config\Data\Proxy</argument>
+        </arguments>
+    </type>
     <type name="Magento\Framework\Object\Copy\Config\Reader">
         <arguments>
             <argument name="fileName" xsi:type="string">fieldset.xml</argument>
@@ -1101,4 +1106,9 @@
             </argument>
         </arguments>
     </type>
+    <type name="Magento\Framework\Url\Decoder">
+        <arguments>
+            <argument name="urlBuilder" xsi:type="object">Magento\Framework\UrlInterface\Proxy</argument>
+        </arguments>
+    </type>
 </config>
diff --git a/dev/tests/integration/framework/Magento/TestFramework/Annotation/ConfigFixture.php b/dev/tests/integration/framework/Magento/TestFramework/Annotation/ConfigFixture.php
index 9854602a507fcc0045fcc2f5be86a85f96073b0d..3809d7f293849488c696e4631c03e6ed34e0de02 100644
--- a/dev/tests/integration/framework/Magento/TestFramework/Annotation/ConfigFixture.php
+++ b/dev/tests/integration/framework/Magento/TestFramework/Annotation/ConfigFixture.php
@@ -9,6 +9,8 @@
  */
 namespace Magento\TestFramework\Annotation;
 
+use Magento\Framework\App\Config\ScopeConfigInterface;
+
 class ConfigFixture
 {
     /**
@@ -73,7 +75,7 @@ class ConfigFixture
                 )->setValue(
                     $configPath,
                     $value,
-                    \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT
+                    ScopeConfigInterface::SCOPE_TYPE_DEFAULT
                 );
             }
         } else {
diff --git a/dev/tests/integration/testsuite/Magento/Backend/Model/Locale/ResolverTest.php b/dev/tests/integration/testsuite/Magento/Backend/Model/Locale/ResolverTest.php
index 09c21758cba336cbd15982d610875cbc0aa19117..c0cc101fd36bfe94dd5dcc19481d81d14b926132 100644
--- a/dev/tests/integration/testsuite/Magento/Backend/Model/Locale/ResolverTest.php
+++ b/dev/tests/integration/testsuite/Magento/Backend/Model/Locale/ResolverTest.php
@@ -5,6 +5,8 @@
  */
 namespace Magento\Backend\Model\Locale;
 
+use Magento\Framework\Locale\Resolver;
+
 /**
  * @magentoAppArea adminhtml
  */
@@ -28,7 +30,7 @@ class ResolverTest extends \PHPUnit_Framework_TestCase
      */
     public function testSetLocaleWithDefaultLocale()
     {
-        $this->_checkSetLocale(\Magento\Framework\Locale\ResolverInterface::DEFAULT_LOCALE);
+        $this->_checkSetLocale(Resolver::DEFAULT_LOCALE);
     }
 
     /**
diff --git a/dev/tests/integration/testsuite/Magento/Framework/Session/SessionManagerTest.php b/dev/tests/integration/testsuite/Magento/Framework/Session/SessionManagerTest.php
index c8379e5e9c39f37bb5d4edd46ed4720aa250b788..18a4314710c3d9a19f51bf5688afcc7087b90f93 100644
--- a/dev/tests/integration/testsuite/Magento/Framework/Session/SessionManagerTest.php
+++ b/dev/tests/integration/testsuite/Magento/Framework/Session/SessionManagerTest.php
@@ -3,153 +3,214 @@
  * Copyright © 2015 Magento. All rights reserved.
  * See COPYING.txt for license details.
  */
-namespace Magento\Framework\Session;
-
-class SessionManagerTest extends \PHPUnit_Framework_TestCase
-{
-    /**
-     * @var \Magento\Framework\Session\SessionManagerInterface
-     */
-    protected $_model;
-
-    /**
-     * @var \Magento\Framework\Session\SidResolverInterface
-     */
-    protected $_sidResolver;
-
-    /**
-     * @var string
-     */
-    protected $sessionName;
-
-    /**
-     * @var \Magento\Framework\App\RequestInterface
-     */
-    protected $request;
-
-    protected function setUp()
-    {
-        $this->sessionName = 'frontEndSession';
-
-        ini_set('session.use_only_cookies', '0');
-        ini_set('session.name', $this->sessionName);
-
-        $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
-
-        /** @var \Magento\Framework\Session\SidResolverInterface $sidResolver */
-        $this->_sidResolver = $objectManager->get('Magento\Framework\Session\SidResolverInterface');
-
-        $this->request = $objectManager->get('Magento\Framework\App\RequestInterface');
-
-        /** @var \Magento\Framework\Session\SessionManager _model */
-        $this->_model = $objectManager->create(
-            'Magento\Framework\Session\SessionManager',
-            [
-                $this->request,
-                $this->_sidResolver,
-                $objectManager->get('Magento\Framework\Session\Config\ConfigInterface'),
-                $objectManager->get('Magento\Framework\Session\SaveHandlerInterface'),
-                $objectManager->get('Magento\Framework\Session\ValidatorInterface'),
-                $objectManager->get('Magento\Framework\Session\StorageInterface')
-            ]
-        );
-    }
-
-    public function testSessionNameFromIni()
-    {
-        $this->_model->start();
-        $this->assertSame($this->sessionName, $this->_model->getName());
-        $this->_model->destroy();
-    }
-
-    public function testSessionUseOnlyCookies()
-    {
-        $expectedValue = '1';
-        $sessionUseOnlyCookies = ini_get('session.use_only_cookies');
-        $this->assertSame($expectedValue, $sessionUseOnlyCookies);
-    }
-
-    public function testGetData()
-    {
-        $this->_model->setData(['test_key' => 'test_value']);
-        $this->assertEquals('test_value', $this->_model->getData('test_key', true));
-        $this->assertNull($this->_model->getData('test_key'));
-    }
-
-    public function testGetSessionId()
-    {
-        $this->assertEquals(session_id(), $this->_model->getSessionId());
-    }
-
-    public function testGetName()
-    {
-        $this->assertEquals(session_name(), $this->_model->getName());
-    }
-
-    public function testSetName()
-    {
-        $this->_model->setName('test');
-        $this->assertEquals('test', $this->_model->getName());
-    }
-
-    public function testDestroy()
-    {
-        $data = ['key' => 'value'];
-        $this->_model->setData($data);
-
-        $this->assertEquals($data, $this->_model->getData());
-        $this->_model->destroy();
-
-        $this->assertEquals([], $this->_model->getData());
-    }
+// @codingStandardsIgnoreStart
+namespace {
+    $mockPHPFunctions = false;
+}
 
-    public function testSetSessionId()
-    {
-        $sessionId = $this->_model->getSessionId();
-        $this->_model->setSessionId($this->_sidResolver->getSid($this->_model));
-        $this->assertEquals($sessionId, $this->_model->getSessionId());
-
-        $this->_model->setSessionId('test');
-        $this->assertEquals('test', $this->_model->getSessionId());
-    }
+namespace Magento\Framework\Session {
+    // @codingStandardsIgnoreEnd
 
     /**
-     * @magentoConfigFixture current_store web/session/use_frontend_sid 1
+     * Mock session_status if in test mode, or continue normal execution otherwise
+     *
+     * @return int Session status code
      */
-    public function testSetSessionIdFromParam()
+    function session_status()
     {
-        $this->assertNotEquals('test_id', $this->_model->getSessionId());
-        $this->request->getQuery()->set($this->_sidResolver->getSessionIdQueryParam($this->_model), 'test-id');
-        $this->_model->setSessionId($this->_sidResolver->getSid($this->_model));
-
-        $this->assertEquals('test-id', $this->_model->getSessionId());
-
-        /* Use not valid identifier */
-        $this->request->getQuery()->set($this->_sidResolver->getSessionIdQueryParam($this->_model), 'test_id');
-        $this->_model->setSessionId($this->_sidResolver->getSid($this->_model));
-        $this->assertEquals('test-id', $this->_model->getSessionId());
+        global $mockPHPFunctions;
+        if ($mockPHPFunctions) {
+            return PHP_SESSION_NONE;
+        }
+        return call_user_func_array('\session_status', func_get_args());
     }
 
-    public function testGetSessionIdForHost()
+    function headers_sent()
     {
-        $this->request->getServer()->set('HTTP_HOST', 'localhost');
-        $this->_model->start();
-        $this->assertEmpty($this->_model->getSessionIdForHost('localhost'));
-        $this->assertNotEmpty($this->_model->getSessionIdForHost('test'));
-        $this->_model->destroy();
+        global $mockPHPFunctions;
+        if ($mockPHPFunctions) {
+            return false;
+        }
+        return call_user_func_array('\headers_sent', func_get_args());
     }
 
-    public function testIsValidForHost()
+    class SessionManagerTest extends \PHPUnit_Framework_TestCase
     {
-        $this->request->getServer()->set('HTTP_HOST', 'localhost');
-        $this->_model->start();
-
-        $reflection = new \ReflectionMethod($this->_model, '_addHost');
-        $reflection->setAccessible(true);
-        $reflection->invoke($this->_model);
-
-        $this->assertFalse($this->_model->isValidForHost('test.com'));
-        $this->assertTrue($this->_model->isValidForHost('localhost'));
-        $this->_model->destroy();
+        /**
+         * @var \Magento\Framework\Session\SessionManagerInterface
+         */
+        protected $_model;
+
+        /**
+         * @var \Magento\Framework\Session\SidResolverInterface
+         */
+        protected $_sidResolver;
+
+        /**
+         * @var string
+         */
+        protected $sessionName;
+
+        /**
+         * @var \Magento\Framework\ObjectManagerInterface
+         */
+        protected $objectManager;
+
+        protected function setUp()
+        {
+            $this->sessionName = 'frontEndSession';
+
+            ini_set('session.use_only_cookies', '0');
+            ini_set('session.name', $this->sessionName);
+
+            $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
+
+            /** @var \Magento\Framework\Session\SidResolverInterface $sidResolver */
+            $this->_sidResolver = $this->objectManager->get('Magento\Framework\Session\SidResolverInterface');
+
+            $this->request = $this->objectManager->get('Magento\Framework\App\RequestInterface');
+
+            /** @var \Magento\Framework\Session\SessionManager _model */
+            $this->_model = $this->objectManager->create(
+                'Magento\Framework\Session\SessionManager',
+                [
+                    $this->objectManager->get('Magento\Framework\App\Request\Http'),
+                    $this->_sidResolver,
+                    $this->objectManager->get('Magento\Framework\Session\Config\ConfigInterface'),
+                    $this->objectManager->get('Magento\Framework\Session\SaveHandlerInterface'),
+                    $this->objectManager->get('Magento\Framework\Session\ValidatorInterface'),
+                    $this->objectManager->get('Magento\Framework\Session\StorageInterface')
+                ]
+            );
+        }
+
+        public function testSessionNameFromIni()
+        {
+            $this->_model->start();
+            $this->assertSame($this->sessionName, $this->_model->getName());
+            $this->_model->destroy();
+        }
+
+        public function testSessionUseOnlyCookies()
+        {
+            $expectedValue = '1';
+            $sessionUseOnlyCookies = ini_get('session.use_only_cookies');
+            $this->assertSame($expectedValue, $sessionUseOnlyCookies);
+        }
+
+        public function testGetData()
+        {
+            $this->_model->setData(['test_key' => 'test_value']);
+            $this->assertEquals('test_value', $this->_model->getData('test_key', true));
+            $this->assertNull($this->_model->getData('test_key'));
+        }
+
+        public function testGetSessionId()
+        {
+            $this->assertEquals(session_id(), $this->_model->getSessionId());
+        }
+
+        public function testGetName()
+        {
+            $this->assertEquals(session_name(), $this->_model->getName());
+        }
+
+        public function testSetName()
+        {
+            $this->_model->setName('test');
+            $this->assertEquals('test', $this->_model->getName());
+        }
+
+        public function testDestroy()
+        {
+            $data = ['key' => 'value'];
+            $this->_model->setData($data);
+
+            $this->assertEquals($data, $this->_model->getData());
+            $this->_model->destroy();
+
+            $this->assertEquals([], $this->_model->getData());
+        }
+
+        public function testSetSessionId()
+        {
+            $sessionId = $this->_model->getSessionId();
+            $this->_model->setSessionId($this->_sidResolver->getSid($this->_model));
+            $this->assertEquals($sessionId, $this->_model->getSessionId());
+
+            $this->_model->setSessionId('test');
+            $this->assertEquals('test', $this->_model->getSessionId());
+        }
+
+        /**
+         * @magentoConfigFixture current_store web/session/use_frontend_sid 1
+         */
+        public function testSetSessionIdFromParam()
+        {
+            $this->assertNotEquals('test_id', $this->_model->getSessionId());
+            $this->request->getQuery()->set($this->_sidResolver->getSessionIdQueryParam($this->_model), 'test-id');
+            $this->_model->setSessionId($this->_sidResolver->getSid($this->_model));
+            $this->assertEquals('test-id', $this->_model->getSessionId());
+            /* Use not valid identifier */
+            $this->request->getQuery()->set($this->_sidResolver->getSessionIdQueryParam($this->_model), 'test_id');
+            $this->_model->setSessionId($this->_sidResolver->getSid($this->_model));
+            $this->assertEquals('test-id', $this->_model->getSessionId());
+        }
+
+        public function testGetSessionIdForHost()
+        {
+            $_SERVER['HTTP_HOST'] = 'localhost';
+            $this->_model->start();
+            $this->assertEmpty($this->_model->getSessionIdForHost('localhost'));
+            $this->assertNotEmpty($this->_model->getSessionIdForHost('test'));
+            $this->_model->destroy();
+        }
+
+        public function testIsValidForHost()
+        {
+            $_SERVER['HTTP_HOST'] = 'localhost';
+            $this->_model->start();
+
+            $reflection = new \ReflectionMethod($this->_model, '_addHost');
+            $reflection->setAccessible(true);
+            $reflection->invoke($this->_model);
+
+            $this->assertFalse($this->_model->isValidForHost('test.com'));
+            $this->assertTrue($this->_model->isValidForHost('localhost'));
+            $this->_model->destroy();
+        }
+
+
+        /**
+         * @expectedException \Magento\Framework\Exception\SessionException
+         * @expectedExceptionMessage Area code not set: Area code must be set before starting a session.
+         */
+        public function testStartAreaNotSet()
+        {
+            $scope = $this->objectManager->get('Magento\Framework\Config\ScopeInterface');
+            $appState = new \Magento\Framework\App\State($scope);
+
+            /**
+             * Must be created by "new" in order to get a real Magento\Framework\App\State object that
+             * is not overridden in the TestFramework
+             *
+             * @var \Magento\Framework\Session\SessionManager _model
+             */
+            $this->_model = new \Magento\Framework\Session\SessionManager(
+                $this->objectManager->get('Magento\Framework\App\Request\Http'),
+                $this->_sidResolver,
+                $this->objectManager->get('Magento\Framework\Session\Config\ConfigInterface'),
+                $this->objectManager->get('Magento\Framework\Session\SaveHandlerInterface'),
+                $this->objectManager->get('Magento\Framework\Session\ValidatorInterface'),
+                $this->objectManager->get('Magento\Framework\Session\StorageInterface'),
+                $this->objectManager->get('Magento\Framework\Stdlib\CookieManagerInterface'),
+                $this->objectManager->get('Magento\Framework\Stdlib\Cookie\CookieMetadataFactory'),
+                $appState
+            );
+
+            global $mockPHPFunctions;
+            $mockPHPFunctions = true;
+            $this->_model->start();
+        }
     }
 }
diff --git a/dev/tests/integration/testsuite/Magento/Payment/Model/ObserverTest.php b/dev/tests/integration/testsuite/Magento/Payment/Model/ObserverTest.php
index 14f306766a10720ac021fc9ce9b94ecff8ee08cd..f83337a307eb201a8d5fd2fc8ef9dc8d6005880a 100644
--- a/dev/tests/integration/testsuite/Magento/Payment/Model/ObserverTest.php
+++ b/dev/tests/integration/testsuite/Magento/Payment/Model/ObserverTest.php
@@ -5,6 +5,8 @@
  */
 namespace Magento\Payment\Model;
 
+use Magento\Framework\App\Config\ScopeConfigInterface;
+
 /**
  * @magentoAppArea adminhtml
  */
@@ -68,7 +70,7 @@ class ObserverTest extends \PHPUnit_Framework_TestCase
         $config->saveConfig(
             'payment/checkmo/order_status',
             $statusCode,
-            \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT,
+            ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
             0
         );
 
diff --git a/dev/tests/integration/testsuite/Magento/Tax/Model/Sales/Total/Quote/SetupUtil.php b/dev/tests/integration/testsuite/Magento/Tax/Model/Sales/Total/Quote/SetupUtil.php
index 861079efbac7df145af34557037fa6b79bb886e0..331bfebab31ad4078259e912e982010cb44302e6 100644
--- a/dev/tests/integration/testsuite/Magento/Tax/Model/Sales/Total/Quote/SetupUtil.php
+++ b/dev/tests/integration/testsuite/Magento/Tax/Model/Sales/Total/Quote/SetupUtil.php
@@ -8,6 +8,7 @@
 
 namespace Magento\Tax\Model\Sales\Total\Quote;
 
+use Magento\Framework\App\Config\ScopeConfigInterface;
 use Magento\Tax\Model\Config;
 use Magento\Tax\Model\Calculation;
 
@@ -221,7 +222,7 @@ class SetupUtil
             $config->saveConfig(
                 $path,
                 $value,
-                \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT,
+                ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
                 0
             );
         }
diff --git a/dev/tests/performance/testsuite/fixtures/catalog_category_flat_enabled.php b/dev/tests/performance/testsuite/fixtures/catalog_category_flat_enabled.php
index 00cd8ce5cb1d148ff81ebcad4ad463fd1933df2f..056fe99b815516c7bb1b20181297a78013312268 100644
--- a/dev/tests/performance/testsuite/fixtures/catalog_category_flat_enabled.php
+++ b/dev/tests/performance/testsuite/fixtures/catalog_category_flat_enabled.php
@@ -3,6 +3,7 @@
  * Copyright © 2015 Magento. All rights reserved.
  * See COPYING.txt for license details.
  */
+use Magento\Framework\App\Config\ScopeConfigInterface;
 
 /** @var \Magento\TestFramework\Application $this */
 
@@ -13,7 +14,7 @@ $configData = $this->getObjectManager()->create('Magento\Framework\App\Config\Va
 $configData->setPath(
     'catalog/frontend/flat_catalog_category'
 )->setScope(
-    \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT
+    ScopeConfigInterface::SCOPE_TYPE_DEFAULT
 )->setScopeId(
     0
 )->setValue(
diff --git a/dev/tests/performance/testsuite/fixtures/catalog_product_flat_enabled.php b/dev/tests/performance/testsuite/fixtures/catalog_product_flat_enabled.php
index 2258e72023d4ad642e1e799134e8b32cbb94d1ab..e06ed0e26c053f2742d6a132f17b4a0f4b8558ce 100644
--- a/dev/tests/performance/testsuite/fixtures/catalog_product_flat_enabled.php
+++ b/dev/tests/performance/testsuite/fixtures/catalog_product_flat_enabled.php
@@ -3,6 +3,7 @@
  * Copyright © 2015 Magento. All rights reserved.
  * See COPYING.txt for license details.
  */
+use Magento\Framework\App\Config\ScopeConfigInterface;
 
 /** @var \Magento\TestFramework\Application $this */
 
@@ -13,7 +14,7 @@ $configData = $this->getObjectManager()->create('Magento\Framework\App\Config\Va
 $configData->setPath(
     'catalog/frontend/flat_catalog_product'
 )->setScope(
-    \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT
+    ScopeConfigInterface::SCOPE_TYPE_DEFAULT
 )->setScopeId(
     0
 )->setValue(
diff --git a/dev/tests/performance/testsuite/fixtures/shipping_flatrate_enabled.php b/dev/tests/performance/testsuite/fixtures/shipping_flatrate_enabled.php
index e0f50505c4adcf397a358a5d8d31e336bd00a3e6..15b445ce1f8b5ca75cf4b6eb1ae20a179bcfa356 100644
--- a/dev/tests/performance/testsuite/fixtures/shipping_flatrate_enabled.php
+++ b/dev/tests/performance/testsuite/fixtures/shipping_flatrate_enabled.php
@@ -3,6 +3,7 @@
  * Copyright © 2015 Magento. All rights reserved.
  * See COPYING.txt for license details.
  */
+use Magento\Framework\App\Config\ScopeConfigInterface;
 
 /** @var \Magento\TestFramework\Application $this */
 
@@ -13,7 +14,7 @@ $configData = $this->getObjectManager()->create('Magento\Framework\App\Config\Va
 $configData->setPath(
     'carriers/flatrate/active'
 )->setScope(
-    \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT
+    ScopeConfigInterface::SCOPE_TYPE_DEFAULT
 )->setScopeId(
     0
 )->setValue(
diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/Readme/_files/blacklist/ce.txt b/dev/tests/static/testsuite/Magento/Test/Integrity/Readme/_files/blacklist/ce.txt
index 2fd6ad123621cb9b830d5d02b3840463d4520fbc..564d756255d7e6b7be5db625ccf8ebb0e634a026 100644
--- a/dev/tests/static/testsuite/Magento/Test/Integrity/Readme/_files/blacklist/ce.txt
+++ b/dev/tests/static/testsuite/Magento/Test/Integrity/Readme/_files/blacklist/ce.txt
@@ -35,5 +35,6 @@ lib/internal/Magento/Framework/System
 lib/internal/Magento/Framework/Test
 lib/internal/Magento/Framework/App/Utility
 lib/internal/Magento/Framework/Url
+lib/internal/Magento/Framework/UrlInterface
 lib/internal/Magento/Framework/Xml
 lib/internal/Magento/Framework
diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_constants.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_constants.php
index a3fa40a7f43a6718bc2949067c23dd314b874c11..b0e6f2627029a8da911b3e6a4358c3aff4f133af 100644
--- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_constants.php
+++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_constants.php
@@ -702,4 +702,26 @@ return [
         'Use \Magento\Eav\Model\Entity\Type::getDefaultAttributeSetId() method instead',
     ],
     ['CONFIG_PATH_WSDL_CACHE_ENABLED', 'Magento\Webapi\Model\Soap\Server'],
+    ['ENTITY', 'Magento\Framework\App\Config\ValueInterface'],
+    ['XML_PATH_ALLOW_CURRENCIES_INSTALLED', 'Magento\Framework\Locale\CurrencyInterface'],
+    [
+        'DEFAULT_CURRENCY',
+        'Magento\Framework\Locale\CurrencyInterface',
+        'Magento\Framework\Locale\Currency::DEFAULT_CURRENCY'
+    ],
+    [
+        'DEFAULT_LOCALE',
+        'Magento\Framework\Locale\ResolverInterface',
+        'Magento\Framework\Locale\Resolver::DEFAULT_LOCALE'
+    ],
+    [
+        'DEFAULT_GROUP',
+        'Magento\Framework\Message\ManagerInterface',
+        'Magento\Framework\Message\Manager::DEFAULT_GROUP'
+    ],
+    [
+        'SCOPE_DEFAULT',
+        'Magento\Framework\App\ScopeInterface',
+        'Magento\Framework\App\Config\ScopeConfigInterface::SCOPE_TYPE_DEFAULT'
+    ]
 ];
diff --git a/lib/internal/Magento/Framework/App/Area/FrontNameResolverInterface.php b/lib/internal/Magento/Framework/App/Area/FrontNameResolverInterface.php
index bbdd3787b1825ffa9c35882776a9173c03b9607a..e8a3e92263e7d9b50226911e4d445b1a663171f7 100644
--- a/lib/internal/Magento/Framework/App/Area/FrontNameResolverInterface.php
+++ b/lib/internal/Magento/Framework/App/Area/FrontNameResolverInterface.php
@@ -7,6 +7,10 @@
  */
 namespace Magento\Framework\App\Area;
 
+/**
+ * Interface FrontNameResolverInterface
+ * @api
+ */
 interface FrontNameResolverInterface
 {
     /**
diff --git a/lib/internal/Magento/Framework/App/AreaInterface.php b/lib/internal/Magento/Framework/App/AreaInterface.php
index 806a7983424599690e3b7f02443fb7e9b4b328a5..544ac56e19e6f10dd13c5a284d56dba2d6e4b010 100644
--- a/lib/internal/Magento/Framework/App/AreaInterface.php
+++ b/lib/internal/Magento/Framework/App/AreaInterface.php
@@ -6,6 +6,9 @@
  */
 namespace Magento\Framework\App;
 
+/**
+ * Interface AreaInterface
+ */
 interface AreaInterface
 {
     const PART_CONFIG = 'config';
diff --git a/lib/internal/Magento/Framework/App/AreaList.php b/lib/internal/Magento/Framework/App/AreaList.php
index 270fb22e36675b08576b06500e7cd6da38f39466..c010388797d870fa25e7aec9a192edef8ed0a73b 100644
--- a/lib/internal/Magento/Framework/App/AreaList.php
+++ b/lib/internal/Magento/Framework/App/AreaList.php
@@ -63,6 +63,7 @@ class AreaList
      *
      * @param string $frontName
      * @return null|string
+     * @api
      */
     public function getCodeByFrontName($frontName)
     {
@@ -84,6 +85,7 @@ class AreaList
      *
      * @param string $areaCode
      * @return string
+     * @api
      */
     public function getFrontName($areaCode)
     {
@@ -94,6 +96,7 @@ class AreaList
      * Retrieve area codes
      *
      * @return string[]
+     * @api
      */
     public function getCodes()
     {
@@ -105,6 +108,7 @@ class AreaList
      *
      * @param string $areaCode
      * @return string
+     * @api
      */
     public function getDefaultRouter($areaCode)
     {
diff --git a/lib/internal/Magento/Framework/App/Cache/Type/Config.php b/lib/internal/Magento/Framework/App/Cache/Type/Config.php
index ded73329969b9f7faec6409ed73715cab06390eb..506eff32a8e099edc9a4a9193b7e42bafdc2ac58 100644
--- a/lib/internal/Magento/Framework/App/Cache/Type/Config.php
+++ b/lib/internal/Magento/Framework/App/Cache/Type/Config.php
@@ -25,10 +25,40 @@ class Config extends TagScope implements CacheInterface
     const CACHE_TAG = 'CONFIG';
 
     /**
-     * @param FrontendPool $cacheFrontendPool
+     * @var \Magento\Framework\App\Cache\Type\FrontendPool
      */
-    public function __construct(FrontendPool $cacheFrontendPool)
+    private $cacheFrontendPool;
+
+    /**
+     * @param \Magento\Framework\App\Cache\Type\FrontendPool $cacheFrontendPool
+     */
+    public function __construct(\Magento\Framework\App\Cache\Type\FrontendPool $cacheFrontendPool)
+    {
+        $this->cacheFrontendPool = $cacheFrontendPool;
+    }
+
+    /**
+     * Retrieve cache frontend instance being decorated
+     *
+     * @return \Magento\Framework\Cache\FrontendInterface
+     */
+    protected function _getFrontend()
+    {
+        $frontend = parent::_getFrontend();
+        if (!$frontend) {
+            $frontend = $this->cacheFrontendPool->get(self::TYPE_IDENTIFIER);
+            $this->setFrontend($frontend);
+        }
+        return $frontend;
+    }
+
+    /**
+     * Retrieve cache tag name
+     *
+     * @return string
+     */
+    public function getTag()
     {
-        parent::__construct($cacheFrontendPool->get(self::TYPE_IDENTIFIER), self::CACHE_TAG);
+        return self::CACHE_TAG;
     }
 }
diff --git a/lib/internal/Magento/Framework/App/Config.php b/lib/internal/Magento/Framework/App/Config.php
index 047849f0034bde6164c2a054c81817e2daccdd2a..898a19a00ea5f20ff98bce5a7cb5eaa322972869 100644
--- a/lib/internal/Magento/Framework/App/Config.php
+++ b/lib/internal/Magento/Framework/App/Config.php
@@ -7,6 +7,8 @@
  */
 namespace Magento\Framework\App;
 
+use Magento\Framework\App\Config\ScopeConfigInterface;
+
 class Config implements \Magento\Framework\App\Config\ScopeConfigInterface
 {
     /**
@@ -37,7 +39,7 @@ class Config implements \Magento\Framework\App\Config\ScopeConfigInterface
      */
     public function getValue(
         $path = null,
-        $scope = \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT,
+        $scope = ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
         $scopeCode = null
     ) {
         return $this->_scopePool->getScope($scope, $scopeCode)->getValue($path);
@@ -51,7 +53,7 @@ class Config implements \Magento\Framework\App\Config\ScopeConfigInterface
      * @param null|string $scopeCode
      * @return bool
      */
-    public function isSetFlag($path, $scope = \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT, $scopeCode = null)
+    public function isSetFlag($path, $scope = ScopeConfigInterface::SCOPE_TYPE_DEFAULT, $scopeCode = null)
     {
         return (bool) $this->getValue($path, $scope, $scopeCode);
     }
diff --git a/lib/internal/Magento/Framework/App/Config/Data.php b/lib/internal/Magento/Framework/App/Config/Data.php
index 3b5f17fe71639559575a77bc431fccc7071388f0..38389e71e40aaf297d4983bdde8377db615d5493 100644
--- a/lib/internal/Magento/Framework/App/Config/Data.php
+++ b/lib/internal/Magento/Framework/App/Config/Data.php
@@ -42,10 +42,7 @@ class Data implements DataInterface
     }
 
     /**
-     * Retrieve configuration value by path
-     *
-     * @param null|string $path
-     * @return array|string
+     * @inheritdoc
      */
     public function getValue($path = null)
     {
@@ -65,11 +62,7 @@ class Data implements DataInterface
     }
 
     /**
-     * Set configuration value
-     *
-     * @param string $path
-     * @param mixed $value
-     * @return void
+     * @inheritdoc
      */
     public function setValue($path, $value)
     {
diff --git a/lib/internal/Magento/Framework/App/Config/Data/ProcessorFactory.php b/lib/internal/Magento/Framework/App/Config/Data/ProcessorFactory.php
index 8f473e2a37b2ba3c9cf3a0e707dd43f9bbe70902..8084dcd5d08f45c755a9c5b0490bf1fea78f8894 100644
--- a/lib/internal/Magento/Framework/App/Config/Data/ProcessorFactory.php
+++ b/lib/internal/Magento/Framework/App/Config/Data/ProcessorFactory.php
@@ -30,21 +30,22 @@ class ProcessorFactory
     /**
      * Get concrete Processor Interface instance
      *
-     * @param string $model
+     * @param string $processorModel Classname of the instance to get
      * @return ProcessorInterface
-     * @throws \InvalidArgumentException
+     * @throws \InvalidArgumentException In case the given classname is not an instance of ProcessorInterface
+     * @api
      */
-    public function get($model)
+    public function get($processorModel)
     {
-        if (!isset($this->_pool[$model])) {
-            $instance = $this->_objectManager->create($model);
+        if (!isset($this->_pool[$processorModel])) {
+            $instance = $this->_objectManager->create($processorModel);
             if (!$instance instanceof ProcessorInterface) {
                 throw new \InvalidArgumentException(
-                    $model . ' is not instance of \Magento\Framework\App\Config\Data\ProcessorInterface'
+                    $processorModel . ' is not instance of \Magento\Framework\App\Config\Data\ProcessorInterface'
                 );
             }
-            $this->_pool[$model] = $instance;
+            $this->_pool[$processorModel] = $instance;
         }
-        return $this->_pool[$model];
+        return $this->_pool[$processorModel];
     }
 }
diff --git a/lib/internal/Magento/Framework/App/Config/Data/ProcessorInterface.php b/lib/internal/Magento/Framework/App/Config/Data/ProcessorInterface.php
index 71102131f42cf4071b6d213d225ac8178956945a..d4467339676739d2e92250b986d992458772cc68 100644
--- a/lib/internal/Magento/Framework/App/Config/Data/ProcessorInterface.php
+++ b/lib/internal/Magento/Framework/App/Config/Data/ProcessorInterface.php
@@ -1,19 +1,22 @@
 <?php
 /**
- * Processor interface
- *
  * Copyright © 2015 Magento. All rights reserved.
  * See COPYING.txt for license details.
  */
 namespace Magento\Framework\App\Config\Data;
 
+/**
+ * Processes data from admin store configuration fields
+ *
+ * @api
+ */
 interface ProcessorInterface
 {
     /**
      * Process config value
      *
-     * @param string $value
-     * @return string
+     * @param string $value Raw value of the configuration field
+     * @return string Processed value
      */
     public function processValue($value);
 }
diff --git a/lib/internal/Magento/Framework/App/Config/DataInterface.php b/lib/internal/Magento/Framework/App/Config/DataInterface.php
index bbdaf54d1c342a11803527f92160ebacef27a0a6..b07ca0e0df1fc3ce8085227057148619c371f0f9 100644
--- a/lib/internal/Magento/Framework/App/Config/DataInterface.php
+++ b/lib/internal/Magento/Framework/App/Config/DataInterface.php
@@ -5,11 +5,27 @@
  */
 namespace Magento\Framework\App\Config;
 
+/**
+ * Configuration data storage
+ *
+ * @api
+ */
 interface DataInterface
 {
     /**
+     * Retrieve configuration value by path
+     *
      * @param string|null $path
-     * @return string|array
+     * @return mixed
      */
     public function getValue($path);
+
+    /**
+     * Set configuration value by path
+     *
+     * @param string $path
+     * @param mixed $value
+     * @return void
+     */
+    public function setValue($path, $value);
 }
diff --git a/lib/internal/Magento/Framework/App/Config/Initial.php b/lib/internal/Magento/Framework/App/Config/Initial.php
index 68db7b1eb84d42c669f3874b180038292a087983..3b2beb5ca37423ee054d94d2d3289bdacd21bca5 100644
--- a/lib/internal/Magento/Framework/App/Config/Initial.php
+++ b/lib/internal/Magento/Framework/App/Config/Initial.php
@@ -7,6 +7,8 @@
  */
 namespace Magento\Framework\App\Config;
 
+use Magento\Framework\App\Config\ScopeConfigInterface;
+
 class Initial
 {
     /**
@@ -50,14 +52,14 @@ class Initial
     /**
      * Get initial data by given scope
      *
-     * @param string $scope
+     * @param string $scope Format is scope type and scope code separated by pipe: e.g. "type|code"
      * @return array
      */
     public function getData($scope)
     {
         list($scopeType, $scopeCode) = array_pad(explode('|', $scope), 2, null);
 
-        if (\Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT == $scopeType) {
+        if (ScopeConfigInterface::SCOPE_TYPE_DEFAULT == $scopeType) {
             return isset($this->_data[$scopeType]) ? $this->_data[$scopeType] : [];
         } elseif ($scopeCode) {
             return isset($this->_data[$scopeType][$scopeCode]) ? $this->_data[$scopeType][$scopeCode] : [];
diff --git a/lib/internal/Magento/Framework/App/Config/MutableScopeConfigInterface.php b/lib/internal/Magento/Framework/App/Config/MutableScopeConfigInterface.php
index 37a371b547f40439addcfad205d29dd9c178fb07..f68048ddc94611267e17df9c85eb203bf28097a2 100644
--- a/lib/internal/Magento/Framework/App/Config/MutableScopeConfigInterface.php
+++ b/lib/internal/Magento/Framework/App/Config/MutableScopeConfigInterface.php
@@ -8,6 +8,9 @@
 
 namespace Magento\Framework\App\Config;
 
+/**
+ * @api
+ */
 interface MutableScopeConfigInterface extends \Magento\Framework\App\Config\ScopeConfigInterface
 {
     /**
@@ -15,14 +18,14 @@ interface MutableScopeConfigInterface extends \Magento\Framework\App\Config\Scop
      *
      * @param string $path
      * @param mixed $value
-     * @param string $scope
+     * @param string $scopeType
      * @param null|string $scopeCode
      * @return void
      */
     public function setValue(
         $path,
         $value,
-        $scope = \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT,
+        $scopeType = \Magento\Framework\App\Config\ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
         $scopeCode = null
     );
 }
diff --git a/lib/internal/Magento/Framework/App/Config/ReinitableConfigInterface.php b/lib/internal/Magento/Framework/App/Config/ReinitableConfigInterface.php
index 5b9d9d78eb3b4789a2ac6477e5e686ff3e4f0c6f..f9fc887a878e0ec0b73e2ad956ae0ff3b1ae166a 100644
--- a/lib/internal/Magento/Framework/App/Config/ReinitableConfigInterface.php
+++ b/lib/internal/Magento/Framework/App/Config/ReinitableConfigInterface.php
@@ -8,6 +8,9 @@
 
 namespace Magento\Framework\App\Config;
 
+/**
+ * @api
+ */
 interface ReinitableConfigInterface extends \Magento\Framework\App\Config\MutableScopeConfigInterface
 {
     /**
diff --git a/lib/internal/Magento/Framework/App/Config/Resource/ConfigInterface.php b/lib/internal/Magento/Framework/App/Config/Resource/ConfigInterface.php
index aa0e06048980767a44d1f0688ebe6956bbb13355..8084c21ab0d9cd26be2319dd9cfad4e00992dae7 100644
--- a/lib/internal/Magento/Framework/App/Config/Resource/ConfigInterface.php
+++ b/lib/internal/Magento/Framework/App/Config/Resource/ConfigInterface.php
@@ -6,12 +6,12 @@
 namespace Magento\Framework\App\Config\Resource;
 
 /**
- * Resource Config Interface
+ * Resource for storing store configuration values
  */
 interface ConfigInterface
 {
     /**
-     * Save config value
+     * Save config value to the storage resource
      *
      * @param string $path
      * @param string $value
@@ -22,7 +22,7 @@ interface ConfigInterface
     public function saveConfig($path, $value, $scope, $scopeId);
 
     /**
-     * Delete config value
+     * Delete config value from the storage resource
      *
      * @param string $path
      * @param string $scope
diff --git a/lib/internal/Magento/Framework/App/Config/Scope/ReaderInterface.php b/lib/internal/Magento/Framework/App/Config/Scope/ReaderInterface.php
index bf20ecd1d530881e76749275afcff6dbd87939d1..cdcbb42828e51d4ff2f3e13c9449037c64ac9ad5 100644
--- a/lib/internal/Magento/Framework/App/Config/Scope/ReaderInterface.php
+++ b/lib/internal/Magento/Framework/App/Config/Scope/ReaderInterface.php
@@ -12,7 +12,9 @@ interface ReaderInterface
     /**
      * Read configuration scope
      *
+     * @param string|null $scopeType
+     * @throws \Exception May throw an exception if the given scope is invalid
      * @return array
      */
-    public function read();
+    public function read($scopeType = null);
 }
diff --git a/lib/internal/Magento/Framework/App/Config/ScopeConfigInterface.php b/lib/internal/Magento/Framework/App/Config/ScopeConfigInterface.php
index ac84e7358b5d2599a531ea45047d92626370bd44..e98fe284024f1780d731500d810516011b7528ba 100644
--- a/lib/internal/Magento/Framework/App/Config/ScopeConfigInterface.php
+++ b/lib/internal/Magento/Framework/App/Config/ScopeConfigInterface.php
@@ -8,25 +8,33 @@
 
 namespace Magento\Framework\App\Config;
 
+/**
+ * @api
+ */
 interface ScopeConfigInterface
 {
     /**
-     * Retrieve config value by path and scope
+     * Default scope type
+     */
+    const SCOPE_TYPE_DEFAULT = 'default';
+
+    /**
+     * Retrieve config value by path and scope.
      *
-     * @param string $path
-     * @param string $scope
+     * @param string $path The path through the tree of configuration values, e.g., 'general/store_information/name'
+     * @param string $scopeType The scope to use to determine config value, e.g., 'store' or 'default'
      * @param null|string $scopeCode
      * @return mixed
      */
-    public function getValue($path, $scope = \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT, $scopeCode = null);
+    public function getValue($path, $scopeType = ScopeConfigInterface::SCOPE_TYPE_DEFAULT, $scopeCode = null);
 
     /**
      * Retrieve config flag by path and scope
      *
-     * @param string $path
-     * @param string $scope
+     * @param string $path The path through the tree of configuration values, e.g., 'general/store_information/name'
+     * @param string $scopeType The scope to use to determine config value, e.g., 'store' or 'default'
      * @param null|string $scopeCode
      * @return bool
      */
-    public function isSetFlag($path, $scope = \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT, $scopeCode = null);
+    public function isSetFlag($path, $scopeType = ScopeConfigInterface::SCOPE_TYPE_DEFAULT, $scopeCode = null);
 }
diff --git a/lib/internal/Magento/Framework/App/Config/ScopePool.php b/lib/internal/Magento/Framework/App/Config/ScopePool.php
index 34b24deb0028b63402dc2d169f2dbb47566dae9d..1a15575b1a514a0a0a04b728e454c2c18ef0645e 100644
--- a/lib/internal/Magento/Framework/App/Config/ScopePool.php
+++ b/lib/internal/Magento/Framework/App/Config/ScopePool.php
@@ -5,6 +5,8 @@
  */
 namespace Magento\Framework\App\Config;
 
+use Magento\Framework\App\Config\ScopeConfigInterface;
+
 class ScopePool
 {
     const CACHE_TAG = 'config_scopes';
@@ -78,7 +80,7 @@ class ScopePool
                 $data = unserialize($data);
             } else {
                 $reader = $this->_readerPool->getReader($scopeType);
-                if ($scopeType === \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT) {
+                if ($scopeType === ScopeConfigInterface::SCOPE_TYPE_DEFAULT) {
                     $data = $reader->read();
                 } else {
                     $data = $reader->read($scopeCode);
@@ -111,7 +113,7 @@ class ScopePool
     protected function _getScopeCode($scopeType, $scopeCode)
     {
         if (($scopeCode === null || is_numeric($scopeCode))
-            && $scopeType !== \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT
+            && $scopeType !== ScopeConfigInterface::SCOPE_TYPE_DEFAULT
         ) {
             $scopeResolver = $this->_scopeResolverPool->get($scopeType);
             $scopeCode = $scopeResolver->getScope($scopeCode);
diff --git a/lib/internal/Magento/Framework/App/Config/Storage/Writer.php b/lib/internal/Magento/Framework/App/Config/Storage/Writer.php
index b98e4074efa1b953fac38e02be2bbe435568d8c5..63b5ae83dfec68c85f61ebf17ae11396b485373e 100644
--- a/lib/internal/Magento/Framework/App/Config/Storage/Writer.php
+++ b/lib/internal/Magento/Framework/App/Config/Storage/Writer.php
@@ -7,6 +7,8 @@
  */
 namespace Magento\Framework\App\Config\Storage;
 
+use Magento\Framework\App\Config\ScopeConfigInterface;
+
 class Writer implements \Magento\Framework\App\Config\Storage\WriterInterface
 {
     /**
@@ -32,7 +34,7 @@ class Writer implements \Magento\Framework\App\Config\Storage\WriterInterface
      * @param   int $scopeId
      * @return  void
      */
-    public function delete($path, $scope = \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT, $scopeId = 0)
+    public function delete($path, $scope = ScopeConfigInterface::SCOPE_TYPE_DEFAULT, $scopeId = 0)
     {
         $this->_resource->deleteConfig(rtrim($path, '/'), $scope, $scopeId);
     }
@@ -46,7 +48,7 @@ class Writer implements \Magento\Framework\App\Config\Storage\WriterInterface
      * @param int $scopeId
      * @return void
      */
-    public function save($path, $value, $scope = \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT, $scopeId = 0)
+    public function save($path, $value, $scope = ScopeConfigInterface::SCOPE_TYPE_DEFAULT, $scopeId = 0)
     {
         $this->_resource->saveConfig(rtrim($path, '/'), $value, $scope, $scopeId);
     }
diff --git a/lib/internal/Magento/Framework/App/Config/Storage/WriterInterface.php b/lib/internal/Magento/Framework/App/Config/Storage/WriterInterface.php
index 3a3a3af6241361ca757699bf1d1e37ecfab6ad45..67b2aebd5d4a6da8d19eaad74175ca26726a57e0 100644
--- a/lib/internal/Magento/Framework/App/Config/Storage/WriterInterface.php
+++ b/lib/internal/Magento/Framework/App/Config/Storage/WriterInterface.php
@@ -7,6 +7,8 @@
  */
 namespace Magento\Framework\App\Config\Storage;
 
+use Magento\Framework\App\Config\ScopeConfigInterface;
+
 interface WriterInterface
 {
     /**
@@ -17,7 +19,7 @@ interface WriterInterface
      * @param   int $scopeId
      * @return void
      */
-    public function delete($path, $scope = \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT, $scopeId = 0);
+    public function delete($path, $scope = ScopeConfigInterface::SCOPE_TYPE_DEFAULT, $scopeId = 0);
 
     /**
      * Save config value to storage
@@ -28,5 +30,5 @@ interface WriterInterface
      * @param int $scopeId
      * @return void
      */
-    public function save($path, $value, $scope = \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT, $scopeId = 0);
+    public function save($path, $value, $scope = ScopeConfigInterface::SCOPE_TYPE_DEFAULT, $scopeId = 0);
 }
diff --git a/lib/internal/Magento/Framework/App/Config/Value.php b/lib/internal/Magento/Framework/App/Config/Value.php
index 17c50d20b8b3a854cb7f61a319ba5d21b21e1dac..92ee527a9c48eb77a35f527c2c471c2507d1b546 100644
--- a/lib/internal/Magento/Framework/App/Config/Value.php
+++ b/lib/internal/Magento/Framework/App/Config/Value.php
@@ -91,7 +91,7 @@ class Value extends \Magento\Framework\Model\AbstractModel implements \Magento\F
     {
         return (string)$this->_config->getValue(
             $this->getPath(),
-            $this->getScope() ?: \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT,
+            $this->getScope() ?: ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
             $this->getScopeCode()
         );
     }
diff --git a/lib/internal/Magento/Framework/App/MutableScopeConfig.php b/lib/internal/Magento/Framework/App/MutableScopeConfig.php
index c94fb73f9d5e4cb35ddf246710bf464a932a25ad..418817465bd6f11af59b2ae5f4eaf53eea7559cd 100644
--- a/lib/internal/Magento/Framework/App/MutableScopeConfig.php
+++ b/lib/internal/Magento/Framework/App/MutableScopeConfig.php
@@ -9,6 +9,7 @@
 namespace Magento\Framework\App;
 
 use Magento\Framework\App\Config\MutableScopeConfigInterface;
+use Magento\Framework\App\Config\ScopeConfigInterface;
 
 class MutableScopeConfig extends Config implements MutableScopeConfigInterface
 {
@@ -24,7 +25,7 @@ class MutableScopeConfig extends Config implements MutableScopeConfigInterface
     public function setValue(
         $path,
         $value,
-        $scope = \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT,
+        $scope = ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
         $scopeCode = null
     ) {
         if (empty($scopeCode)) {
diff --git a/lib/internal/Magento/Framework/App/Request/Http.php b/lib/internal/Magento/Framework/App/Request/Http.php
index c09ead13054e791d5e6bff403623545b4e24f9e6..e6e502cf38171387aef13cdf606845d082f8664d 100644
--- a/lib/internal/Magento/Framework/App/Request/Http.php
+++ b/lib/internal/Magento/Framework/App/Request/Http.php
@@ -7,6 +7,7 @@
  */
 namespace Magento\Framework\App\Request;
 
+use Magento\Framework\App\Config\ScopeConfigInterface;
 use Magento\Framework\App\RequestInterface;
 use Magento\Framework\App\Route\ConfigInterface\Proxy as ConfigInterface;
 use Magento\Framework\HTTP\PhpEnvironment\Request;
@@ -384,7 +385,7 @@ class Http extends Request implements RequestInterface
         $offLoaderHeader = trim(
             (string)$config->getValue(
                 self::XML_PATH_OFFLOADER_HEADER,
-                \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT
+                ScopeConfigInterface::SCOPE_TYPE_DEFAULT
             )
         );
 
diff --git a/lib/internal/Magento/Framework/App/Resource.php b/lib/internal/Magento/Framework/App/Resource.php
index b38629a460a4fa8a7ed78c1a9e77450ec23c1c8a..b498ec9d349fea88b942b42d2ff6277c23a2449a 100644
--- a/lib/internal/Magento/Framework/App/Resource.php
+++ b/lib/internal/Magento/Framework/App/Resource.php
@@ -126,6 +126,7 @@ class Resource
      * @param   string|string[] $modelEntity
      * @param   string $connectionName
      * @return  string
+     * @api
      */
     public function getTableName($modelEntity, $connectionName = self::DEFAULT_READ_RESOURCE)
     {
diff --git a/lib/internal/Magento/Framework/App/Route/ConfigInterface.php b/lib/internal/Magento/Framework/App/Route/ConfigInterface.php
index c6798f7ce4ab659e813488a155d0aa467ac41449..d96a4af89eac0d2a4c3932995643c1cbccec25e5 100644
--- a/lib/internal/Magento/Framework/App/Route/ConfigInterface.php
+++ b/lib/internal/Magento/Framework/App/Route/ConfigInterface.php
@@ -1,12 +1,15 @@
 <?php
 /**
- * Routes configuration interface
- *
  * Copyright © 2015 Magento. All rights reserved.
  * See COPYING.txt for license details.
  */
 namespace Magento\Framework\App\Route;
 
+/**
+ * Routes configuration interface
+ *
+ * @api
+ */
 interface ConfigInterface
 {
     /**
@@ -32,7 +35,7 @@ interface ConfigInterface
      *
      * @param string $frontName
      * @param string $scope
-     * @return array
+     * @return string[]
      */
     public function getModulesByFrontName($frontName, $scope = null);
 }
diff --git a/lib/internal/Magento/Framework/App/ScopeInterface.php b/lib/internal/Magento/Framework/App/ScopeInterface.php
index d244ec5bf3a1f612722795b72e938fef77f1102f..77c8a8b890ac209400fdf8005636ee869d8ecfd0 100644
--- a/lib/internal/Magento/Framework/App/ScopeInterface.php
+++ b/lib/internal/Magento/Framework/App/ScopeInterface.php
@@ -7,11 +7,6 @@ namespace Magento\Framework\App;
 
 interface ScopeInterface
 {
-    /**
-     * Default scope type
-     */
-    const SCOPE_DEFAULT = 'default';
-
     /**
      * Retrieve scope code
      *
diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Cache/Type/ConfigTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Cache/Type/ConfigTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..c6887709da50fbd2bf4fdb303f3e256749a4e197
--- /dev/null
+++ b/lib/internal/Magento/Framework/App/Test/Unit/Cache/Type/ConfigTest.php
@@ -0,0 +1,169 @@
+<?php
+/**
+ * Copyright © 2015 Magento. All rights reserved.
+ * See COPYING.txt for license details.
+ */
+namespace Magento\Framework\App\Test\Unit\Cache\Type;
+
+use Magento\Framework\App\Cache\Type\FrontendPool;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+
+class ConfigTest extends \PHPUnit_Framework_TestCase
+{
+    /**
+     * @var \Magento\Framework\App\Cache\Type\Config
+     */
+    protected $model;
+
+    /**
+     * @var \Magento\Framework\Cache\FrontendInterface|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $frontendMock;
+
+    protected function setUp()
+    {
+        $cacheFrontendPoolMock = $this->getMockBuilder('Magento\Framework\App\Cache\Type\FrontendPool')
+            ->disableOriginalConstructor()
+            ->getMock();
+        $this->model = (new ObjectManager($this))->getObject(
+            'Magento\Framework\App\Cache\Type\Config',
+            ['cacheFrontendPool' => $cacheFrontendPoolMock]
+        );
+        $this->frontendMock = $this->getMock('Magento\Framework\Cache\FrontendInterface');
+        $cacheFrontendPoolMock->expects($this->once())
+            ->method('get')
+            ->with(\Magento\Framework\App\Cache\Type\Config::TYPE_IDENTIFIER)
+            ->willReturn($this->frontendMock);
+    }
+
+    /**
+     * @param string $method
+     * @param array $params
+     * @param mixed $expectedResult
+     * @dataProvider proxyMethodDataProvider
+     */
+    public function testProxyMethod($method, $params, $expectedResult)
+    {
+        $helper = new \Magento\Framework\TestFramework\Unit\Helper\ProxyTesting();
+        $result = $helper->invokeWithExpectations($this->model, $this->frontendMock, $method, $params, $expectedResult);
+        $this->assertSame($expectedResult, $result);
+    }
+
+    /**
+     * @return array
+     */
+    public function proxyMethodDataProvider()
+    {
+        return [
+            ['test', ['record_id'], 111],
+            ['load', ['record_id'], '111'],
+            ['remove', ['record_id'], true],
+            ['getBackend', [], $this->getMock('Zend_Cache_Backend')],
+            ['getLowLevelFrontend', [], $this->getMock('Zend_Cache_Core')],
+        ];
+    }
+
+    public function testSave()
+    {
+        $expectedResult = new \stdClass();
+        $this->frontendMock->expects(
+            $this->once()
+        )->method(
+            'save'
+        )->with(
+            'test_value',
+            'test_id',
+            ['test_tag_one', 'test_tag_two', \Magento\Framework\App\Cache\Type\Config::CACHE_TAG],
+            111
+        )->will(
+            $this->returnValue($expectedResult)
+        );
+        $actualResult = $this->model->save('test_value', 'test_id', ['test_tag_one', 'test_tag_two'], 111);
+        $this->assertSame($expectedResult, $actualResult);
+    }
+
+    public function testCleanModeAll()
+    {
+        $expectedResult = new \stdClass();
+        $this->frontendMock->expects(
+            $this->once()
+        )->method(
+            'clean'
+        )->with(
+            \Zend_Cache::CLEANING_MODE_MATCHING_TAG,
+            [\Magento\Framework\App\Cache\Type\Config::CACHE_TAG]
+        )->will(
+            $this->returnValue($expectedResult)
+        );
+        $actualResult = $this->model->clean(
+            \Zend_Cache::CLEANING_MODE_ALL,
+            ['ignored_tag_one', 'ignored_tag_two']
+        );
+        $this->assertSame($expectedResult, $actualResult);
+    }
+
+    public function testCleanModeMatchingTag()
+    {
+        $expectedResult = new \stdClass();
+        $this->frontendMock->expects(
+            $this->once()
+        )->method(
+            'clean'
+        )->with(
+            \Zend_Cache::CLEANING_MODE_MATCHING_TAG,
+            ['test_tag_one', 'test_tag_two', \Magento\Framework\App\Cache\Type\Config::CACHE_TAG]
+        )->will(
+            $this->returnValue($expectedResult)
+        );
+        $actualResult = $this->model->clean(
+            \Zend_Cache::CLEANING_MODE_MATCHING_TAG,
+            ['test_tag_one', 'test_tag_two']
+        );
+        $this->assertSame($expectedResult, $actualResult);
+    }
+
+    /**
+     * @param bool $fixtureResultOne
+     * @param bool $fixtureResultTwo
+     * @param bool $expectedResult
+     * @dataProvider cleanModeMatchingAnyTagDataProvider
+     */
+    public function testCleanModeMatchingAnyTag($fixtureResultOne, $fixtureResultTwo, $expectedResult)
+    {
+        $this->frontendMock->expects(
+            $this->at(0)
+        )->method(
+            'clean'
+        )->with(
+            \Zend_Cache::CLEANING_MODE_MATCHING_TAG,
+            ['test_tag_one', \Magento\Framework\App\Cache\Type\Config::CACHE_TAG]
+        )->will(
+            $this->returnValue($fixtureResultOne)
+        );
+        $this->frontendMock->expects(
+            $this->at(1)
+        )->method(
+            'clean'
+        )->with(
+            \Zend_Cache::CLEANING_MODE_MATCHING_TAG,
+            ['test_tag_two', \Magento\Framework\App\Cache\Type\Config::CACHE_TAG]
+        )->will(
+            $this->returnValue($fixtureResultTwo)
+        );
+        $actualResult = $this->model->clean(
+            \Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG,
+            ['test_tag_one', 'test_tag_two']
+        );
+        $this->assertEquals($expectedResult, $actualResult);
+    }
+
+    public function cleanModeMatchingAnyTagDataProvider()
+    {
+        return [
+            'failure, failure' => [false, false, false],
+            'failure, success' => [false, true, true],
+            'success, failure' => [true, false, true],
+            'success, success' => [true, true, true]
+        ];
+    }
+}
diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Config/Storage/WriterTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Config/Storage/WriterTest.php
index 57040f09ee4dd82eb4ec80df99f0b827cc859573..887a1cf477663f00253816aed0bfdd273cd6fe5f 100644
--- a/lib/internal/Magento/Framework/App/Test/Unit/Config/Storage/WriterTest.php
+++ b/lib/internal/Magento/Framework/App/Test/Unit/Config/Storage/WriterTest.php
@@ -5,6 +5,7 @@
  */
 namespace Magento\Framework\App\Test\Unit\Config\Storage;
 
+use Magento\Framework\App\Config\ScopeConfigInterface;
 use Magento\Framework\App\ScopeInterface;
 
 class WriterTest extends \PHPUnit_Framework_TestCase
@@ -40,7 +41,7 @@ class WriterTest extends \PHPUnit_Framework_TestCase
     {
         $this->resource->expects($this->once())
             ->method('deleteConfig')
-            ->with('path', ScopeInterface::SCOPE_DEFAULT, 0);
+            ->with('path', ScopeConfigInterface::SCOPE_TYPE_DEFAULT, 0);
         $this->model->delete('path');
     }
 
@@ -58,7 +59,7 @@ class WriterTest extends \PHPUnit_Framework_TestCase
     {
         $this->resource->expects($this->once())
             ->method('saveConfig')
-            ->with('path', 'value', ScopeInterface::SCOPE_DEFAULT, 0);
+            ->with('path', 'value', ScopeConfigInterface::SCOPE_TYPE_DEFAULT, 0);
         $this->model->save('path', 'value');
     }
 }
diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Request/HttpTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Request/HttpTest.php
index 090580da2726653983a7ed76ec9f16405393092f..8bfb9be2f3bb253932ba96c59d11d9819b704b50 100644
--- a/lib/internal/Magento/Framework/App/Test/Unit/Request/HttpTest.php
+++ b/lib/internal/Magento/Framework/App/Test/Unit/Request/HttpTest.php
@@ -9,6 +9,7 @@
 
 namespace Magento\Framework\App\Test\Unit\Request;
 
+use Magento\Framework\App\Config\ScopeConfigInterface;
 use \Magento\Framework\App\Request\Http;
 use Magento\Framework\App\ScopeInterface;
 use Zend\Stdlib\Parameters;
@@ -325,7 +326,7 @@ class HttpTest extends \PHPUnit_Framework_TestCase
             ->getMock();
         $configMock->expects($this->exactly($configCall))
             ->method('getValue')
-            ->with(\Magento\Framework\App\Request\Http::XML_PATH_OFFLOADER_HEADER, ScopeInterface::SCOPE_DEFAULT)
+            ->with(\Magento\Framework\App\Request\Http::XML_PATH_OFFLOADER_HEADER, ScopeConfigInterface::SCOPE_TYPE_DEFAULT)
             ->willReturn($configOffloadHeader);
         $this->objectManager->expects($this->exactly($configCall))
             ->method('get')
diff --git a/lib/internal/Magento/Framework/Cache/Frontend/Decorator/Bare.php b/lib/internal/Magento/Framework/Cache/Frontend/Decorator/Bare.php
index b856e8608aa726ebf0f32e07ecb01ad7ac8d7d6f..cae35e66ff83d2b40b562b77aaaeaed4d030221e 100644
--- a/lib/internal/Magento/Framework/Cache/Frontend/Decorator/Bare.php
+++ b/lib/internal/Magento/Framework/Cache/Frontend/Decorator/Bare.php
@@ -27,6 +27,18 @@ class Bare implements \Magento\Framework\Cache\FrontendInterface
         $this->_frontend = $frontend;
     }
 
+    /**
+     * Set frontend
+     *
+     * @param \Magento\Framework\Cache\FrontendInterface $frontend
+     * @return $this
+     */
+    protected function setFrontend(\Magento\Framework\Cache\FrontendInterface $frontend)
+    {
+        $this->_frontend = $frontend;
+        return $this;
+    }
+
     /**
      * Retrieve cache frontend instance being decorated
      *
@@ -42,7 +54,7 @@ class Bare implements \Magento\Framework\Cache\FrontendInterface
      */
     public function test($identifier)
     {
-        return $this->_frontend->test($identifier);
+        return $this->_getFrontend()->test($identifier);
     }
 
     /**
@@ -50,7 +62,7 @@ class Bare implements \Magento\Framework\Cache\FrontendInterface
      */
     public function load($identifier)
     {
-        return $this->_frontend->load($identifier);
+        return $this->_getFrontend()->load($identifier);
     }
 
     /**
@@ -60,7 +72,7 @@ class Bare implements \Magento\Framework\Cache\FrontendInterface
      */
     public function save($data, $identifier, array $tags = [], $lifeTime = null)
     {
-        return $this->_frontend->save($data, $identifier, $tags, $lifeTime);
+        return $this->_getFrontend()->save($data, $identifier, $tags, $lifeTime);
     }
 
     /**
@@ -68,7 +80,7 @@ class Bare implements \Magento\Framework\Cache\FrontendInterface
      */
     public function remove($identifier)
     {
-        return $this->_frontend->remove($identifier);
+        return $this->_getFrontend()->remove($identifier);
     }
 
     /**
@@ -76,7 +88,7 @@ class Bare implements \Magento\Framework\Cache\FrontendInterface
      */
     public function clean($mode = \Zend_Cache::CLEANING_MODE_ALL, array $tags = [])
     {
-        return $this->_frontend->clean($mode, $tags);
+        return $this->_getFrontend()->clean($mode, $tags);
     }
 
     /**
@@ -84,7 +96,7 @@ class Bare implements \Magento\Framework\Cache\FrontendInterface
      */
     public function getBackend()
     {
-        return $this->_frontend->getBackend();
+        return $this->_getFrontend()->getBackend();
     }
 
     /**
@@ -92,6 +104,6 @@ class Bare implements \Magento\Framework\Cache\FrontendInterface
      */
     public function getLowLevelFrontend()
     {
-        return $this->_frontend->getLowLevelFrontend();
+        return $this->_getFrontend()->getLowLevelFrontend();
     }
 }
diff --git a/lib/internal/Magento/Framework/Cache/Frontend/Decorator/TagScope.php b/lib/internal/Magento/Framework/Cache/Frontend/Decorator/TagScope.php
index 32c9e4422417cf220a28db98137ef954a26ba705..0f74b1894865754521bd9b595f0b14a5572e1e8c 100644
--- a/lib/internal/Magento/Framework/Cache/Frontend/Decorator/TagScope.php
+++ b/lib/internal/Magento/Framework/Cache/Frontend/Decorator/TagScope.php
@@ -45,7 +45,7 @@ class TagScope extends \Magento\Framework\Cache\Frontend\Decorator\Bare
      */
     public function save($data, $identifier, array $tags = [], $lifeTime = null)
     {
-        $tags[] = $this->_tag;
+        $tags[] = $this->getTag();
         return parent::save($data, $identifier, $tags, $lifeTime);
     }
 
@@ -59,16 +59,16 @@ class TagScope extends \Magento\Framework\Cache\Frontend\Decorator\Bare
         if ($mode == \Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG) {
             $result = false;
             foreach ($tags as $tag) {
-                if (parent::clean(\Zend_Cache::CLEANING_MODE_MATCHING_TAG, [$tag, $this->_tag])) {
+                if (parent::clean(\Zend_Cache::CLEANING_MODE_MATCHING_TAG, [$tag, $this->getTag()])) {
                     $result = true;
                 }
             }
         } else {
             if ($mode == \Zend_Cache::CLEANING_MODE_ALL) {
                 $mode = \Zend_Cache::CLEANING_MODE_MATCHING_TAG;
-                $tags = [$this->_tag];
+                $tags = [$this->getTag()];
             } else {
-                $tags[] = $this->_tag;
+                $tags[] = $this->getTag();
             }
             $result = parent::clean($mode, $tags);
         }
diff --git a/lib/internal/Magento/Framework/Data/Collection/Filesystem.php b/lib/internal/Magento/Framework/Data/Collection/Filesystem.php
index 817c4b420519697de1ad27984ca0d286e151a125..cec62bc94a82b655866f71fe5118c13336868bef 100644
--- a/lib/internal/Magento/Framework/Data/Collection/Filesystem.php
+++ b/lib/internal/Magento/Framework/Data/Collection/Filesystem.php
@@ -284,6 +284,7 @@ class Filesystem extends \Magento\Framework\Data\Collection
      * @param bool $printQuery
      * @param bool $logQuery
      * @return $this
+     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
      * @throws \Exception
      */
     public function loadData($printQuery = false, $logQuery = false)
@@ -668,6 +669,7 @@ class Filesystem extends \Magento\Framework\Data\Collection
      * @param string $value
      * @param string $type
      * @return $this
+     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
      */
     public function addFilter($field, $value, $type = 'and')
     {
@@ -696,7 +698,7 @@ class Filesystem extends \Magento\Framework\Data\Collection
      */
     public function filterCallbackLike($field, $filterValue, $row)
     {
-        $filterValueRegex = str_replace('%', '(.*?)', preg_quote($filterValue, '/'));
+        $filterValueRegex = str_replace('%', '(.*?)', str_replace('\'', '', preg_quote($filterValue, '/')));
         return (bool)preg_match("/^{$filterValueRegex}\$/i", $row[$field]);
     }
 
diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/Collection/FilesystemTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/Collection/FilesystemTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..b764079a841b7f07f35dc9a692b9ffeb6968fe5f
--- /dev/null
+++ b/lib/internal/Magento/Framework/Data/Test/Unit/Collection/FilesystemTest.php
@@ -0,0 +1,30 @@
+<?php
+/***
+ * Copyright © 2015 Magento. All rights reserved.
+ * See COPYING.txt for license details.
+ */
+
+namespace Magento\Framework\Data\Test\Unit\Collection;
+
+class FilesystemTest extends \PHPUnit_Framework_TestCase
+{
+    /** @var \Magento\Framework\Data\Collection\Filesystem */
+    private $model;
+
+    public function setUp()
+    {
+        $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+        $this->model = $objectManager->getObject('Magento\Framework\Data\Collection\Filesystem');
+    }
+
+    public function testFilterCallbackLike()
+    {
+        $field = 'field';
+        $row = [$field => 'beginning_filter_target_end',];
+        $filterValueSuccess = new \Zend_Db_Expr('%filter_target%');
+        $filterValueFailure = new \Zend_Db_Expr('%not_found_in_the_row%');
+
+        $this->assertTrue($this->model->filterCallbackLike($field, $filterValueSuccess, $row));
+        $this->assertFalse($this->model->filterCallbackLike($field, $filterValueFailure, $row));
+    }
+}
diff --git a/lib/internal/Magento/Framework/Locale/ConfigInterface.php b/lib/internal/Magento/Framework/Locale/ConfigInterface.php
index 3539f09409a800e83665f16d58871797f96161d0..e0f28fd015c33675eaed0445956c7a728a5e0d84 100644
--- a/lib/internal/Magento/Framework/Locale/ConfigInterface.php
+++ b/lib/internal/Magento/Framework/Locale/ConfigInterface.php
@@ -5,19 +5,24 @@
  */
 namespace Magento\Framework\Locale;
 
+/**
+ * Provides access to locale-related config information
+ *
+ * @api
+ */
 interface ConfigInterface
 {
     /**
      * Get list pre-configured allowed locales
      *
-     * @return array
+     * @return string[]
      */
     public function getAllowedLocales();
 
     /**
      * Get list pre-configured allowed currencies
      *
-     * @return array
+     * @return string[]
      */
     public function getAllowedCurrencies();
 }
diff --git a/lib/internal/Magento/Framework/Locale/Currency.php b/lib/internal/Magento/Framework/Locale/Currency.php
index 5d3c5a9ec9b7e961d870e4a458bc4b3fa69b5b89..f0be6c12172278b8e3a32b86848f296cd606d96a 100644
--- a/lib/internal/Magento/Framework/Locale/Currency.php
+++ b/lib/internal/Magento/Framework/Locale/Currency.php
@@ -7,6 +7,10 @@ namespace Magento\Framework\Locale;
 
 class Currency implements \Magento\Framework\Locale\CurrencyInterface
 {
+    /**
+     * Default currency
+     */
+    const DEFAULT_CURRENCY = 'USD';
     /**
      * @var array
      */
@@ -45,20 +49,15 @@ class Currency implements \Magento\Framework\Locale\CurrencyInterface
     }
 
     /**
-     * Retrieve currency code
-     *
-     * @return string
+     * @inheritdoc
      */
     public function getDefaultCurrency()
     {
-        return \Magento\Framework\Locale\CurrencyInterface::DEFAULT_CURRENCY;
+        return self::DEFAULT_CURRENCY;
     }
 
     /**
-     * Create \Zend_Currency object for current locale
-     *
-     * @param   string $currency
-     * @return  \Magento\Framework\Currency
+     * @inheritdoc
      */
     public function getCurrency($currency)
     {
diff --git a/lib/internal/Magento/Framework/Locale/CurrencyInterface.php b/lib/internal/Magento/Framework/Locale/CurrencyInterface.php
index 774f7d5120f3cead8f11e9d7545928e62634faa2..00bbc4452eedd604d19cb9144d1f38e9417e9568 100644
--- a/lib/internal/Magento/Framework/Locale/CurrencyInterface.php
+++ b/lib/internal/Magento/Framework/Locale/CurrencyInterface.php
@@ -5,27 +5,22 @@
  */
 namespace Magento\Framework\Locale;
 
+/**
+ * Provides access to currency config information
+ *
+ * @api
+ */
 interface CurrencyInterface
 {
     /**
-     * Default currency
-     */
-    const DEFAULT_CURRENCY = 'USD';
-
-    /**
-     * XML path to installed currencies
-     */
-    const XML_PATH_ALLOW_CURRENCIES_INSTALLED = 'system/currency/installed';
-
-    /**
-     * Retrieve currency code
+     * Retrieve default currency code
      *
      * @return string
      */
     public function getDefaultCurrency();
 
     /**
-     * Create \Magento\Framework\Currency object for current locale
+     * Create Currency object for current locale
      *
      * @param   string $currency
      * @return  \Magento\Framework\Currency
diff --git a/lib/internal/Magento/Framework/Locale/Resolver.php b/lib/internal/Magento/Framework/Locale/Resolver.php
index b78be470920ec0638dd4a8a786d13b97470277f3..6a81f60cc5a0cda5d7d55a31f7f9b599e905c94a 100644
--- a/lib/internal/Magento/Framework/Locale/Resolver.php
+++ b/lib/internal/Magento/Framework/Locale/Resolver.php
@@ -9,6 +9,10 @@ use Magento\Framework\App\Config\ScopeConfigInterface;
 
 class Resolver implements ResolverInterface
 {
+    /**
+     * Default locale
+     */
+    const DEFAULT_LOCALE = 'en_US';
     /**
      * Default locale code
      *
@@ -85,7 +89,7 @@ class Resolver implements ResolverInterface
         if (!$this->defaultLocale) {
             $locale = $this->scopeConfig->getValue($this->getDefaultLocalePath(), $this->scopeType);
             if (!$locale) {
-                $locale = ResolverInterface::DEFAULT_LOCALE;
+                $locale = self::DEFAULT_LOCALE;
             }
             $this->defaultLocale = $locale;
         }
diff --git a/lib/internal/Magento/Framework/Locale/ResolverInterface.php b/lib/internal/Magento/Framework/Locale/ResolverInterface.php
index 08add444266f073aaa354935b6857be2c7edd34f..a17932ed8628870f7ce9f086946807498c836807 100644
--- a/lib/internal/Magento/Framework/Locale/ResolverInterface.php
+++ b/lib/internal/Magento/Framework/Locale/ResolverInterface.php
@@ -5,13 +5,13 @@
  */
 namespace Magento\Framework\Locale;
 
+/**
+ * Manages locale config information
+ *
+ * @api
+ */
 interface ResolverInterface
 {
-    /**
-     * Default locale
-     */
-    const DEFAULT_LOCALE = 'en_US';
-
     /**
      * Return path to default locale
      *
diff --git a/lib/internal/Magento/Framework/Locale/Test/Unit/CurrencyTest.php b/lib/internal/Magento/Framework/Locale/Test/Unit/CurrencyTest.php
index 01552d3a972294bd649141074cc91f985829743b..226e8d4d8508be64e2a9a9454aeaa94cbb3de243 100644
--- a/lib/internal/Magento/Framework/Locale/Test/Unit/CurrencyTest.php
+++ b/lib/internal/Magento/Framework/Locale/Test/Unit/CurrencyTest.php
@@ -8,6 +8,7 @@
 
 namespace Magento\Framework\Locale\Test\Unit;
 
+use Magento\Framework\Locale\Currency;
 use Magento\Framework\Locale\CurrencyInterface;
 
 class CurrencyTest extends \PHPUnit_Framework_TestCase
@@ -68,7 +69,7 @@ class CurrencyTest extends \PHPUnit_Framework_TestCase
 
     public function testGetDefaultCurrency()
     {
-        $expectedDefaultCurrency = CurrencyInterface::DEFAULT_CURRENCY;
+        $expectedDefaultCurrency = Currency::DEFAULT_CURRENCY;
         $retrievedDefaultCurrency = $this->testCurrencyObject->getDefaultCurrency();
         $this->assertEquals($expectedDefaultCurrency, $retrievedDefaultCurrency);
     }
diff --git a/lib/internal/Magento/Framework/Locale/Validator.php b/lib/internal/Magento/Framework/Locale/Validator.php
index b30727562c45755db8b67dfb00be40c18bae09fc..0cdf265af01b329f3a87eca97ac8de8c723902b6 100644
--- a/lib/internal/Magento/Framework/Locale/Validator.php
+++ b/lib/internal/Magento/Framework/Locale/Validator.php
@@ -29,10 +29,12 @@ class Validator
     }
 
     /**
-     * Validate locale code
+     * Validate locale code. Code must be in the list of allowed locales.
      *
      * @param string $localeCode
      * @return bool
+     *
+     * @api
      */
     public function isValid($localeCode)
     {
diff --git a/lib/internal/Magento/Framework/Message/Factory.php b/lib/internal/Magento/Framework/Message/Factory.php
index 4c16064b5b6599dbb98f48307601dfff7eda1ee3..be7e3c9bb566a041c026a5916f4e51364e06b07d 100644
--- a/lib/internal/Magento/Framework/Message/Factory.php
+++ b/lib/internal/Magento/Framework/Message/Factory.php
@@ -45,11 +45,12 @@ class Factory
     }
 
     /**
-     * Create message instance with specified parameters
+     * Create a message instance of a given type with given text.
      *
-     * @param string $type
-     * @param string $text
-     * @throws \InvalidArgumentException
+     * @param string $type The message type to create, must correspond to a message type under the
+     * namespace Magento\Framework\Message\
+     * @param string $text The text to inject into the message
+     * @throws \InvalidArgumentException Exception gets thrown if type does not correspond to a valid Magento message
      * @return MessageInterface
      */
     public function create($type, $text)
diff --git a/lib/internal/Magento/Framework/Message/Manager.php b/lib/internal/Magento/Framework/Message/Manager.php
index 73b212a58e3ee88769bd653a815c15ecafde2578..815296c80bad2d8453564f10797ade913a2e5c7f 100644
--- a/lib/internal/Magento/Framework/Message/Manager.php
+++ b/lib/internal/Magento/Framework/Message/Manager.php
@@ -14,6 +14,10 @@ use Psr\Log\LoggerInterface as Logger;
  */
 class Manager implements ManagerInterface
 {
+    /**
+     * Default message group
+     */
+    const DEFAULT_GROUP = 'default';
     /**
      * @var Session
      */
@@ -74,9 +78,7 @@ class Manager implements ManagerInterface
     }
 
     /**
-     * Retrieve default message group
-     *
-     * @return string
+     * {@inheritdoc}
      */
     public function getDefaultGroup()
     {
@@ -95,7 +97,7 @@ class Manager implements ManagerInterface
     }
 
     /**
-     * Retrieve messages
+     * @inheritdoc
      *
      * @param string|null $group
      * @param bool $clear
@@ -118,7 +120,7 @@ class Manager implements ManagerInterface
     }
 
     /**
-     * Adding new message to message collection
+     * @inheritdoc
      *
      * @param MessageInterface $message
      * @param string|null $group
@@ -133,7 +135,7 @@ class Manager implements ManagerInterface
     }
 
     /**
-     * Adding messages array to message collection
+     * @inheritdoc
      *
      * @param MessageInterface[] $messages
      * @param string|null $group
@@ -148,7 +150,7 @@ class Manager implements ManagerInterface
     }
 
     /**
-     * Adding new error message
+     * @inheritdoc
      *
      * @param string $message
      * @param string|null $group
@@ -161,7 +163,7 @@ class Manager implements ManagerInterface
     }
 
     /**
-     * Adding new warning message
+     * @inheritdoc
      *
      * @param string $message
      * @param string|null $group
@@ -174,7 +176,7 @@ class Manager implements ManagerInterface
     }
 
     /**
-     * Adding new notice message
+     * @inheritdoc
      *
      * @param string $message
      * @param string|null $group
@@ -187,7 +189,7 @@ class Manager implements ManagerInterface
     }
 
     /**
-     * Adding new success message
+     * @inheritdoc
      *
      * @param string $message
      * @param string|null $group
@@ -200,7 +202,7 @@ class Manager implements ManagerInterface
     }
 
     /**
-     * Adds messages array to message collection, but doesn't add duplicates to it
+     * @inheritdoc
      *
      * @param MessageInterface[]|MessageInterface $messages
      * @param string|null $group
@@ -244,7 +246,7 @@ class Manager implements ManagerInterface
     }
 
     /**
-     * Not Magento exception handling
+     * @inheritdoc
      *
      * @param \Exception $exception
      * @param string $alternativeText
diff --git a/lib/internal/Magento/Framework/Message/ManagerInterface.php b/lib/internal/Magento/Framework/Message/ManagerInterface.php
index 36851dc866c49be7c9e0f0ea15490c79b776db4a..dd73d2a2fcfbc8acbd9aabdef42a3f5d59616f4d 100644
--- a/lib/internal/Magento/Framework/Message/ManagerInterface.php
+++ b/lib/internal/Magento/Framework/Message/ManagerInterface.php
@@ -6,15 +6,12 @@
 namespace Magento\Framework\Message;
 
 /**
- * Message manager interface
+ * Adds different types of messages to the session, and allows access to existing messages.
+ *
+ * @api
  */
 interface ManagerInterface
 {
-    /**
-     * Default message group
-     */
-    const DEFAULT_GROUP = 'default';
-
     /**
      * Retrieve messages
      *
@@ -32,7 +29,7 @@ interface ManagerInterface
     public function getDefaultGroup();
 
     /**
-     * Adding new message to message collection
+     * Adds new message to message collection
      *
      * @param MessageInterface $message
      * @param string|null $group
@@ -41,7 +38,7 @@ interface ManagerInterface
     public function addMessage(MessageInterface $message, $group = null);
 
     /**
-     * Adding messages array to message collection
+     * Adds messages array to message collection
      *
      * @param array $messages
      * @param string|null $group
@@ -50,7 +47,7 @@ interface ManagerInterface
     public function addMessages(array $messages, $group = null);
 
     /**
-     * Adding new error message
+     * Adds new error message
      *
      * @param string $message
      * @param string|null $group
@@ -59,7 +56,7 @@ interface ManagerInterface
     public function addError($message, $group = null);
 
     /**
-     * Adding new warning message
+     * Adds new warning message
      *
      * @param string $message
      * @param string|null $group
@@ -68,7 +65,7 @@ interface ManagerInterface
     public function addWarning($message, $group = null);
 
     /**
-     * Adding new notice message
+     * Adds new notice message
      *
      * @param string $message
      * @param string|null $group
@@ -77,7 +74,7 @@ interface ManagerInterface
     public function addNotice($message, $group = null);
 
     /**
-     * Adding new success message
+     * Adds new success message
      *
      * @param string $message
      * @param string|null $group
@@ -86,7 +83,7 @@ interface ManagerInterface
     public function addSuccess($message, $group = null);
 
     /**
-     * Adds messages array to message collection, but doesn't add duplicates to it
+     * Adds messages array to message collection, without adding duplicate messages
      *
      * @param array|MessageInterface $messages
      * @param string|null $group
@@ -95,7 +92,7 @@ interface ManagerInterface
     public function addUniqueMessages($messages, $group = null);
 
     /**
-     * Not Magento exception handling
+     * Adds a message describing an exception. Does not contain Exception handling logic.
      *
      * @param \Exception $exception
      * @param string $alternativeText
diff --git a/lib/internal/Magento/Framework/Message/MessageInterface.php b/lib/internal/Magento/Framework/Message/MessageInterface.php
index e5342f49ac042e79fb0b572fca328a1285ab8b22..d9d60e047b1713fd6a6288a86b2a7b74b8ddae0a 100644
--- a/lib/internal/Magento/Framework/Message/MessageInterface.php
+++ b/lib/internal/Magento/Framework/Message/MessageInterface.php
@@ -6,7 +6,9 @@
 namespace Magento\Framework\Message;
 
 /**
- * Interface for message
+ * Represent a message with a type, content text, and an isSticky attribute to prevent message from being cleared.
+ *
+ * @api
  */
 interface MessageInterface
 {
diff --git a/lib/internal/Magento/Framework/Message/Session.php b/lib/internal/Magento/Framework/Message/Session.php
index da86d172577a4f0ae18dce396deaf6688cd42d2e..8ceb66543e370ccf34321cef02be325bedb2cf85 100644
--- a/lib/internal/Magento/Framework/Message/Session.php
+++ b/lib/internal/Magento/Framework/Message/Session.php
@@ -8,6 +8,6 @@ namespace Magento\Framework\Message;
 /**
  * Message session model
  */
-class Session extends \Magento\Framework\Session\Generic
+class Session extends \Magento\Framework\Session\SessionManager
 {
 }
diff --git a/lib/internal/Magento/Framework/Message/Test/Unit/ManagerTest.php b/lib/internal/Magento/Framework/Message/Test/Unit/ManagerTest.php
index c4980974bc289f00167474eb50040197e020cb66..d65a5459a4ee92dae76a266743cb03d39c3220b6 100644
--- a/lib/internal/Magento/Framework/Message/Test/Unit/ManagerTest.php
+++ b/lib/internal/Magento/Framework/Message/Test/Unit/ManagerTest.php
@@ -5,6 +5,7 @@
  */
 namespace Magento\Framework\Message\Test\Unit;
 
+use Magento\Framework\Message\Manager;
 use Magento\Framework\Message\MessageInterface;
 use Magento\Framework\Message\ManagerInterface;
 
@@ -86,7 +87,7 @@ class ManagerTest extends \PHPUnit_Framework_TestCase
 
     public function testGetDefaultGroup()
     {
-        $this->assertEquals(ManagerInterface::DEFAULT_GROUP, $this->model->getDefaultGroup());
+        $this->assertEquals(Manager::DEFAULT_GROUP, $this->model->getDefaultGroup());
 
         $customDefaultGroup = 'some_group';
         $customManager = $this->objectManager->getObject(
@@ -117,7 +118,7 @@ class ManagerTest extends \PHPUnit_Framework_TestCase
         )->method(
             'getData'
         )->with(
-            ManagerInterface::DEFAULT_GROUP
+            Manager::DEFAULT_GROUP
         )->will(
             $this->returnValue(null)
         );
@@ -126,7 +127,7 @@ class ManagerTest extends \PHPUnit_Framework_TestCase
         )->method(
             'setData'
         )->with(
-            ManagerInterface::DEFAULT_GROUP,
+            Manager::DEFAULT_GROUP,
             $messageCollection
         )->will(
             $this->returnValue($this->session)
@@ -136,7 +137,7 @@ class ManagerTest extends \PHPUnit_Framework_TestCase
         )->method(
             'getData'
         )->with(
-            ManagerInterface::DEFAULT_GROUP
+            Manager::DEFAULT_GROUP
         )->will(
             $this->returnValue($messageCollection)
         );
@@ -161,7 +162,7 @@ class ManagerTest extends \PHPUnit_Framework_TestCase
         )->method(
             'getData'
         )->with(
-            ManagerInterface::DEFAULT_GROUP
+            Manager::DEFAULT_GROUP
         )->will(
             $this->returnValue($messageCollection)
         );
@@ -209,7 +210,7 @@ class ManagerTest extends \PHPUnit_Framework_TestCase
         )->method(
             'getData'
         )->with(
-            ManagerInterface::DEFAULT_GROUP
+            Manager::DEFAULT_GROUP
         )->will(
             $this->returnValue($messageCollection)
         );
diff --git a/lib/internal/Magento/Framework/Model/Resource/AbstractResource.php b/lib/internal/Magento/Framework/Model/Resource/AbstractResource.php
index 831dcf5ae71fb2f832a7372efd8abdfe49a0ac40..c2a9bd81aad960e498303fae9f00a0f333a26272 100644
--- a/lib/internal/Magento/Framework/Model/Resource/AbstractResource.php
+++ b/lib/internal/Magento/Framework/Model/Resource/AbstractResource.php
@@ -61,6 +61,7 @@ abstract class AbstractResource
      * Start resource transaction
      *
      * @return $this
+     * @api
      */
     public function beginTransaction()
     {
@@ -73,6 +74,7 @@ abstract class AbstractResource
      *
      * @param array $callback
      * @return $this
+     * @api
      */
     public function addCommitCallback($callback)
     {
@@ -85,6 +87,7 @@ abstract class AbstractResource
      * Commit resource transaction
      *
      * @return $this
+     * @api
      */
     public function commit()
     {
@@ -109,6 +112,7 @@ abstract class AbstractResource
      * Roll back resource transaction
      *
      * @return $this
+     * @api
      */
     public function rollBack()
     {
diff --git a/lib/internal/Magento/Framework/Model/Resource/Db/AbstractDb.php b/lib/internal/Magento/Framework/Model/Resource/Db/AbstractDb.php
index 351365b08d9eb57d45b6b65a50c53edbb93d482c..ba80e64a256222d7d02ac7eaae6cd95f7ec3717a 100644
--- a/lib/internal/Magento/Framework/Model/Resource/Db/AbstractDb.php
+++ b/lib/internal/Magento/Framework/Model/Resource/Db/AbstractDb.php
@@ -233,6 +233,7 @@ abstract class AbstractDb extends \Magento\Framework\Model\Resource\AbstractReso
      *
      * @throws LocalizedException
      * @return string
+     * @api
      */
     public function getIdFieldName()
     {
@@ -248,6 +249,7 @@ abstract class AbstractDb extends \Magento\Framework\Model\Resource\AbstractReso
      *
      * @throws LocalizedException
      * @return string
+     * @api
      */
     public function getMainTable()
     {
@@ -262,6 +264,7 @@ abstract class AbstractDb extends \Magento\Framework\Model\Resource\AbstractReso
      *
      * @param string $tableName
      * @return string
+     * @api
      */
     public function getTable($tableName)
     {
@@ -391,6 +394,7 @@ abstract class AbstractDb extends \Magento\Framework\Model\Resource\AbstractReso
      * @param \Magento\Framework\Model\AbstractModel $object
      * @return $this
      * @SuppressWarnings(PHPMD.CyclomaticComplexity)
+     * @api
      */
     public function save(\Magento\Framework\Model\AbstractModel $object)
     {
diff --git a/lib/internal/Magento/Framework/Object/Copy.php b/lib/internal/Magento/Framework/Object/Copy.php
index 9145e0aba3bc9b9a106863967d2b7c5a3bd8b124..c0d87722872490ec10c4b15efb33fc3f2385fd33 100644
--- a/lib/internal/Magento/Framework/Object/Copy.php
+++ b/lib/internal/Magento/Framework/Object/Copy.php
@@ -47,6 +47,8 @@ class Copy
      * @param array|\Magento\Framework\Object $target
      * @param string $root
      * @return array|\Magento\Framework\Object|null the value of $target
+     *
+     * @api
      */
     public function copyFieldsetToTarget($fieldset, $aspect, $source, $target, $root = 'global')
     {
@@ -91,6 +93,8 @@ class Copy
      * @param array|\Magento\Framework\Object $source
      * @param string $root
      * @return array $data
+     *
+     * @api
      */
     public function getDataFromFieldset($fieldset, $aspect, $source, $root = 'global')
     {
diff --git a/lib/internal/Magento/Framework/Object/Copy/Config/Data/Proxy.php b/lib/internal/Magento/Framework/Object/Copy/Config/Data/Proxy.php
new file mode 100644
index 0000000000000000000000000000000000000000..ea974307333d3da54ea344c57d8b72331f30a44f
--- /dev/null
+++ b/lib/internal/Magento/Framework/Object/Copy/Config/Data/Proxy.php
@@ -0,0 +1,124 @@
+<?php
+/**
+ * Copyright © 2015 Magento. All rights reserved.
+ * See COPYING.txt for license details.
+ */
+namespace Magento\Framework\Object\Copy\Config\Data;
+
+/**
+ * Proxy class for @see \Magento\Framework\Object\Copy\Config\Data
+ */
+class Proxy extends \Magento\Framework\Object\Copy\Config\Data
+{
+    /**
+     * Object Manager instance
+     *
+     * @var \Magento\Framework\ObjectManagerInterface
+     */
+    protected $_objectManager = null;
+
+    /**
+     * Proxied instance name
+     *
+     * @var string
+     */
+    protected $_instanceName = null;
+
+    /**
+     * Proxied instance
+     *
+     * @var \Magento\Framework\Object\Copy\Config\Data
+     */
+    protected $_subject = null;
+
+    /**
+     * Instance shareability flag
+     *
+     * @var bool
+     */
+    protected $_isShared = null;
+
+    /**
+     * Proxy constructor
+     *
+     * @param \Magento\Framework\ObjectManagerInterface $objectManager
+     * @param string $instanceName
+     * @param bool $shared
+     */
+    public function __construct(
+        \Magento\Framework\ObjectManagerInterface $objectManager,
+        $instanceName = '\\Magento\\Framework\\Object\\Copy\\Config\\Data',
+        $shared = true
+    ) {
+        $this->_objectManager = $objectManager;
+        $this->_instanceName = $instanceName;
+        $this->_isShared = $shared;
+    }
+
+    /**
+     * @return array
+     */
+    public function __sleep()
+    {
+        return ['_subject', '_isShared'];
+    }
+
+    /**
+     * Retrieve ObjectManager from global scope
+     *
+     * @return void
+     */
+    public function __wakeup()
+    {
+        $this->_objectManager = \Magento\Framework\App\ObjectManager::getInstance();
+    }
+
+    /**
+     * Clone proxied instance
+     *
+     * @return void
+     */
+    public function __clone()
+    {
+        $this->_subject = clone $this->_getSubject();
+    }
+
+    /**
+     * Get proxied instance
+     *
+     * @return \Magento\Framework\Object\Copy\Config\Data
+     */
+    protected function _getSubject()
+    {
+        if (!$this->_subject) {
+            $this->_subject = true === $this->_isShared
+                ? $this->_objectManager->get($this->_instanceName)
+                : $this->_objectManager->create($this->_instanceName);
+        }
+        return $this->_subject;
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function merge(array $config)
+    {
+        return $this->_getSubject()->merge($config);
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function get($path = null, $default = null)
+    {
+        return $this->_getSubject()->get($path, $default);
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function reset()
+    {
+        return $this->_getSubject()->reset();
+    }
+}
diff --git a/lib/internal/Magento/Framework/ObjectManager/Profiler/FactoryDecorator.php b/lib/internal/Magento/Framework/ObjectManager/Profiler/FactoryDecorator.php
index ad3864500bbc9502a1d8d6ecbaa296c76ac82d19..895377327281b908c2a8d0944a9415bbdb400275 100644
--- a/lib/internal/Magento/Framework/ObjectManager/Profiler/FactoryDecorator.php
+++ b/lib/internal/Magento/Framework/ObjectManager/Profiler/FactoryDecorator.php
@@ -8,6 +8,11 @@ namespace Magento\Framework\ObjectManager\Profiler;
 
 class FactoryDecorator implements \Magento\Framework\ObjectManager\FactoryInterface
 {
+    /**
+     * Name of the class that generates logging wrappers
+     */
+    const GENERATOR_NAME = 'Magento\Framework\ObjectManager\Profiler\Code\Generator\Logger';
+
     /**
      * @var \Magento\Framework\ObjectManager\FactoryInterface
      */
@@ -45,9 +50,12 @@ class FactoryDecorator implements \Magento\Framework\ObjectManager\FactoryInterf
     {
         $this->log->startCreating($requestedType);
         $result = $this->subject->create($requestedType, $arguments);
-        $loggerClassName = get_class($result) . "\\Logger";
-        $wrappedResult = new $loggerClassName($result, $this->log);
-        $this->log->stopCreating($result);
-        return $wrappedResult;
+        if ($requestedType !== self::GENERATOR_NAME) {
+            $loggerClassName = get_class($result) . "\\Logger";
+            $wrappedResult = new $loggerClassName($result, $this->log);
+            $this->log->stopCreating($result);
+            $result = $wrappedResult;
+        }
+        return $result;
     }
 }
diff --git a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Profiler/FactoryDecoratorTest.php b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Profiler/FactoryDecoratorTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..1d0fa91e42286c72588946788f40491de72e925e
--- /dev/null
+++ b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Profiler/FactoryDecoratorTest.php
@@ -0,0 +1,75 @@
+<?php
+/***
+ * Copyright © 2015 Magento. All rights reserved.
+ * See COPYING.txt for license details.
+ */
+
+namespace Magento\Framework\ObjectManager\Test\Unit\Profiler;
+
+class FactoryDecoratorTest extends \PHPUnit_Framework_TestCase
+{
+    /**
+     * Name of the base class to wrap in logger
+     */
+    const CLASS_NAME = 'Magento\Test\Di\WrappedClass';
+
+    /**
+     * Name of the wrapper class that does logging
+     */
+    const LOGGER_NAME = 'Magento\Test\Di\WrappedClass\Logger';
+
+    /**
+     * Name of the class that generates wrappers - should not be wrapped by logger
+     */
+    const GENERATOR_NAME = 'Magento\Framework\ObjectManager\Profiler\Code\Generator\Logger';
+
+    /** @var  \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\ObjectManager\FactoryInterface*/
+    private $objectManagerMock;
+
+    /** @var  \Magento\Framework\ObjectManager\Profiler\FactoryDecorator */
+    private $model;
+
+    public function setUp()
+    {
+        require_once __DIR__ . '/../_files/logger_classes.php';
+        $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+
+        $this->objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManager\FactoryInterface')
+            ->disableOriginalConstructor()
+            ->getMock();
+
+        // Instantiate SUT
+        $this->model = $objectManager->getObject(
+            'Magento\Framework\ObjectManager\Profiler\FactoryDecorator',
+            ['subject' => $this->objectManagerMock]
+        );
+    }
+
+    public function testCreate()
+    {
+        $baseObjectName = self::CLASS_NAME;
+        $baseObject = new $baseObjectName();
+
+        $arguments = [1, 2, 3];
+
+        $this->objectManagerMock->expects($this->once())
+            ->method('create')
+            ->with(self::CLASS_NAME, $arguments)
+            ->willReturn($baseObject);
+
+        $this->assertInstanceOf(self::LOGGER_NAME, $this->model->create(self::CLASS_NAME, $arguments));
+    }
+
+    public function testCreateNeglectGenerator()
+    {
+        $arguments = [1, 2, 3];
+        $loggerMock = $this->getMockBuilder(self::GENERATOR_NAME)->disableOriginalConstructor()->getMock();
+
+        $this->objectManagerMock->expects($this->once())
+            ->method('create')
+            ->with(self::GENERATOR_NAME, $arguments)
+            ->willReturn($loggerMock);
+
+        $this->assertSame($loggerMock, $this->model->create(self::GENERATOR_NAME, $arguments));
+    }
+}
diff --git a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/_files/logger_classes.php b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/_files/logger_classes.php
new file mode 100644
index 0000000000000000000000000000000000000000..da593225f2079af53a730190a56afc0cb7715400
--- /dev/null
+++ b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/_files/logger_classes.php
@@ -0,0 +1,26 @@
+<?php
+/***
+ * Copyright © 2015 Magento. All rights reserved.
+ * See COPYING.txt for license details.
+ */
+
+//@codingStandardsIgnoreStart
+namespace Magento\Test\Di {
+
+    /**
+     * Test classes used for \Magento\Framework\ObjectManager\Test\Unit\Profiler\FactoryDecoratorTest
+     */
+    class WrappedClass
+    {
+
+    }
+}
+
+namespace Magento\Test\Di\WrappedClass {
+
+    class Logger
+    {
+
+    }
+}
+//@codingStandardsIgnoreEnd
diff --git a/lib/internal/Magento/Framework/Search/Dynamic/DataProviderFactory.php b/lib/internal/Magento/Framework/Search/Dynamic/DataProviderFactory.php
index 1cfc1477a7957b46fe1f58f752749b3d8a4193a2..1b534b4dbf4991c3c5f71f2b8009bd6efd9f20df 100644
--- a/lib/internal/Magento/Framework/Search/Dynamic/DataProviderFactory.php
+++ b/lib/internal/Magento/Framework/Search/Dynamic/DataProviderFactory.php
@@ -33,7 +33,7 @@ class DataProviderFactory
         ScopeConfigInterface $scopeConfig,
         $configPath,
         $dataProviders,
-        $scope = ScopeInterface::SCOPE_DEFAULT
+        $scope = ScopeConfigInterface::SCOPE_TYPE_DEFAULT
     ) {
         $this->objectManager = $objectManager;
         $configValue = $scopeConfig->getValue($configPath, $scope);
diff --git a/lib/internal/Magento/Framework/Search/Dynamic/IntervalFactory.php b/lib/internal/Magento/Framework/Search/Dynamic/IntervalFactory.php
index bba9824e19083f82aa5c249338bf16d2d4da5575..80ac66bb04e62950ae6a7d4dedc4e0fd8dd148d4 100644
--- a/lib/internal/Magento/Framework/Search/Dynamic/IntervalFactory.php
+++ b/lib/internal/Magento/Framework/Search/Dynamic/IntervalFactory.php
@@ -33,7 +33,7 @@ class IntervalFactory
         ScopeConfigInterface $scopeConfig,
         $configPath,
         $intervals,
-        $scope = ScopeInterface::SCOPE_DEFAULT
+        $scope = ScopeConfigInterface::SCOPE_TYPE_DEFAULT
     ) {
         $this->objectManager = $objectManager;
         $configValue = $scopeConfig->getValue($configPath, $scope);
diff --git a/lib/internal/Magento/Framework/Search/Request/Mapper.php b/lib/internal/Magento/Framework/Search/Request/Mapper.php
index e2dcbef74cda6ab201ed6bdd7dc6b3dcda916cd7..d69d5e4e6d6689170096767166c1cc44fba09d6d 100644
--- a/lib/internal/Magento/Framework/Search/Request/Mapper.php
+++ b/lib/internal/Magento/Framework/Search/Request/Mapper.php
@@ -14,6 +14,11 @@ use Magento\Framework\Phrase;
  */
 class Mapper
 {
+    /**
+     * @var QueryInterface
+     */
+    private $rootQuery;
+
     /**
      * @var array
      */
@@ -45,9 +50,9 @@ class Mapper
     private $objectManager;
 
     /**
-     * @var QueryInterface
+     * @var string
      */
-    private $rootQuery = null;
+    private $rootQueryName;
 
     /**
      * @param \Magento\Framework\ObjectManagerInterface $objectManager
@@ -70,26 +75,26 @@ class Mapper
         $this->queries = $queries;
         $this->aggregations = $aggregations;
         $this->filters = $filters;
-
-        $this->rootQuery = $this->get($rootQueryName);
+        $this->rootQueryName = $rootQueryName;
     }
 
     /**
      * Get Query Interface by name
      *
-     * @param string $queryName
      * @return QueryInterface
      * @throws \Exception
      * @throws \InvalidArgumentException
      * @throws StateException
      */
-    private function get($queryName)
+    public function getRootQuery()
     {
-        $this->mappedQueries = [];
-        $this->mappedFilters = [];
-        $query = $this->mapQuery($queryName);
-        $this->validate();
-        return $query;
+        if (!$this->rootQuery) {
+            $this->mappedQueries = [];
+            $this->mappedFilters = [];
+            $this->rootQuery = $this->mapQuery($this->rootQueryName);
+            $this->validate();
+        }
+        return $this->rootQuery;
     }
 
     /**
@@ -304,14 +309,6 @@ class Mapper
         $this->validateNotUsed($this->filters, $this->mappedFilters, 'Filter %1 is not used in request hierarchy');
     }
 
-    /**
-     * @return QueryInterface
-     */
-    public function getRootQuery()
-    {
-        return $this->rootQuery;
-    }
-
     /**
      * Build BucketInterface[] from array
      *
diff --git a/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/DimensionsTest.php b/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/DimensionsTest.php
index 3b37a0bf3d574e10044e2bdea2f8c4b2c2eccebb..5b0736c5fa2ef890b1362bae14c6d9b70f38bf97 100644
--- a/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/DimensionsTest.php
+++ b/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/DimensionsTest.php
@@ -6,6 +6,7 @@
 
 namespace Magento\Framework\Search\Test\Unit\Adapter\Mysql;
 
+use Magento\Framework\App\Config\ScopeConfigInterface;
 use \Magento\Framework\Search\Adapter\Mysql\Dimensions;
 
 use Magento\Framework\Search\Adapter\Mysql\Dimensions as DimensionsBuilder;
@@ -103,7 +104,7 @@ class DimensionsTest extends \PHPUnit_Framework_TestCase
     {
         $tableAlias = 'search_index';
         $name = 'scope';
-        $value = \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT;
+        $value = ScopeConfigInterface::SCOPE_TYPE_DEFAULT;
         $scopeId = -123456;
 
         $this->dimension->expects($this->once())
diff --git a/lib/internal/Magento/Framework/Search/Test/Unit/Dynamic/IntervalFactoryTest.php b/lib/internal/Magento/Framework/Search/Test/Unit/Dynamic/IntervalFactoryTest.php
index 0d7b52e00630adde68df4600dd353d1d7e314207..232f789de3ae77014a26ee1e251dbcce6235d0e5 100644
--- a/lib/internal/Magento/Framework/Search/Test/Unit/Dynamic/IntervalFactoryTest.php
+++ b/lib/internal/Magento/Framework/Search/Test/Unit/Dynamic/IntervalFactoryTest.php
@@ -5,6 +5,7 @@
  */
 namespace Magento\Framework\Search\Test\Unit\Dynamic;
 
+use Magento\Framework\App\Config\ScopeConfigInterface;
 use Magento\Framework\Search\Dynamic\IntervalInterface;
 use Magento\Framework\App\ScopeInterface;
 use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
@@ -63,7 +64,7 @@ class IntervalFactoryTest extends \PHPUnit_Framework_TestCase
     {
         $this->scopeConfig->expects($this->once())
             ->method('getValue')
-            ->with(self::CONFIG_PATH, ScopeInterface::SCOPE_DEFAULT)
+            ->with(self::CONFIG_PATH, ScopeConfigInterface::SCOPE_TYPE_DEFAULT)
             ->willReturn(self::CONFIG_PATH . 't');
         $this->objectManager->expects($this->once())
             ->method('create')
@@ -83,7 +84,7 @@ class IntervalFactoryTest extends \PHPUnit_Framework_TestCase
     {
         $this->scopeConfig->expects($this->once())
             ->method('getValue')
-            ->with(self::CONFIG_PATH, ScopeInterface::SCOPE_DEFAULT)
+            ->with(self::CONFIG_PATH, ScopeConfigInterface::SCOPE_TYPE_DEFAULT)
             ->willReturn('t');
 
         $this->factoryCreate();
@@ -97,7 +98,7 @@ class IntervalFactoryTest extends \PHPUnit_Framework_TestCase
     {
         $this->scopeConfig->expects($this->once())
             ->method('getValue')
-            ->with(self::CONFIG_PATH, ScopeInterface::SCOPE_DEFAULT)
+            ->with(self::CONFIG_PATH, ScopeConfigInterface::SCOPE_TYPE_DEFAULT)
             ->willReturn(self::CONFIG_PATH . 't');
         $this->objectManager->expects($this->once())
             ->method('create')
diff --git a/lib/internal/Magento/Framework/Session/Generic.php b/lib/internal/Magento/Framework/Session/Generic.php
index dd7da87c933a3fff8be209f77e93b77c5eebea1a..bfaf48d74ee9d7f4851e181e8e69f06437da8993 100644
--- a/lib/internal/Magento/Framework/Session/Generic.php
+++ b/lib/internal/Magento/Framework/Session/Generic.php
@@ -7,38 +7,4 @@ namespace Magento\Framework\Session;
 
 class Generic extends SessionManager
 {
-    /**
-     * Constructor
-     *
-     * @param \Magento\Framework\App\Request\Http $request
-     * @param SidResolverInterface $sidResolver
-     * @param \Magento\Framework\Session\Config\ConfigInterface $sessionConfig
-     * @param SaveHandlerInterface $saveHandler
-     * @param ValidatorInterface $validator
-     * @param StorageInterface $storage
-     * @param \Magento\Framework\Stdlib\CookieManagerInterface $cookieManager
-     * @param \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory
-     */
-    public function __construct(
-        \Magento\Framework\App\Request\Http $request,
-        SidResolverInterface $sidResolver,
-        \Magento\Framework\Session\Config\ConfigInterface $sessionConfig,
-        SaveHandlerInterface $saveHandler,
-        ValidatorInterface $validator,
-        StorageInterface $storage,
-        \Magento\Framework\Stdlib\CookieManagerInterface $cookieManager,
-        \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory
-    ) {
-        parent::__construct(
-            $request,
-            $sidResolver,
-            $sessionConfig,
-            $saveHandler,
-            $validator,
-            $storage,
-            $cookieManager,
-            $cookieMetadataFactory
-        );
-        $this->start();
-    }
 }
diff --git a/lib/internal/Magento/Framework/Session/SessionManager.php b/lib/internal/Magento/Framework/Session/SessionManager.php
index 17636fa0776804b433129011dd25b2edaec33275..c66672e87ca8f6b7098a3ecf17a0df582dad6072 100644
--- a/lib/internal/Magento/Framework/Session/SessionManager.php
+++ b/lib/internal/Magento/Framework/Session/SessionManager.php
@@ -11,6 +11,7 @@ use Magento\Framework\Session\Config\ConfigInterface;
 
 /**
  * Session Manager
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
  */
 class SessionManager implements SessionManagerInterface
 {
@@ -87,8 +88,11 @@ class SessionManager implements SessionManagerInterface
     protected $cookieMetadataFactory;
 
     /**
-     * Constructor
-     *
+     * @var \Magento\Framework\App\State
+     */
+    private $appState;
+
+    /**
      * @param \Magento\Framework\App\Request\Http $request
      * @param SidResolverInterface $sidResolver
      * @param ConfigInterface $sessionConfig
@@ -97,6 +101,8 @@ class SessionManager implements SessionManagerInterface
      * @param StorageInterface $storage
      * @param \Magento\Framework\Stdlib\CookieManagerInterface $cookieManager
      * @param \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory
+     * @param \Magento\Framework\App\State $appState
+     * @throws \Magento\Framework\Exception\SessionException
      */
     public function __construct(
         \Magento\Framework\App\Request\Http $request,
@@ -106,7 +112,8 @@ class SessionManager implements SessionManagerInterface
         ValidatorInterface $validator,
         StorageInterface $storage,
         \Magento\Framework\Stdlib\CookieManagerInterface $cookieManager,
-        \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory
+        \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory,
+        \Magento\Framework\App\State $appState
     ) {
         $this->request = $request;
         $this->sidResolver = $sidResolver;
@@ -116,9 +123,11 @@ class SessionManager implements SessionManagerInterface
         $this->storage = $storage;
         $this->cookieManager = $cookieManager;
         $this->cookieMetadataFactory = $cookieMetadataFactory;
+        $this->appState = $appState;
 
         // Enable session.use_only_cookies
         ini_set('session.use_only_cookies', '1');
+        $this->start();
     }
 
     /**
@@ -152,12 +161,25 @@ class SessionManager implements SessionManagerInterface
     /**
      * Configure session handler and start session
      *
+     * @throws \Magento\Framework\Exception\SessionException
      * @return $this
      */
     public function start()
     {
         if (!$this->isSessionExists()) {
             \Magento\Framework\Profiler::start('session_start');
+
+            try {
+                $this->appState->getAreaCode();
+            } catch (\Magento\Framework\Exception\LocalizedException $e) {
+                throw new \Magento\Framework\Exception\SessionException(
+                    new \Magento\Framework\Phrase(
+                        'Area code not set: Area code must be set before starting a session.'
+                    ),
+                    $e
+                );
+            }
+
             // Need to apply the config options so they can be ready by session_start
             $this->initIniOptions();
             $this->registerSaveHandler();
diff --git a/lib/internal/Magento/Framework/Shell.php b/lib/internal/Magento/Framework/Shell.php
index 0652d49d039e0c43d21375d3d87153db78b1e243..2372ba4088571c89d7865d4a9d2b7523fdd6e1eb 100644
--- a/lib/internal/Magento/Framework/Shell.php
+++ b/lib/internal/Magento/Framework/Shell.php
@@ -49,7 +49,7 @@ class Shell implements ShellInterface
         $command = $this->commandRenderer->render($command, $arguments);
         $this->log($command);
 
-        $disabled = explode(',', ini_get('disable_functions'));
+        $disabled = explode(',', str_replace(' ', ',', ini_get('disable_functions')));
         if (in_array('exec', $disabled)) {
             throw new Exception\LocalizedException(new \Magento\Framework\Phrase("exec function is disabled."));
         }
diff --git a/lib/internal/Magento/Framework/Simplexml/Config.php b/lib/internal/Magento/Framework/Simplexml/Config.php
index 4e1265ebd4a4c180d7bbc4a8b84b0334b5b1676a..2f45cd6550b87a9417f2e50355866765c26d2a2b 100644
--- a/lib/internal/Magento/Framework/Simplexml/Config.php
+++ b/lib/internal/Magento/Framework/Simplexml/Config.php
@@ -118,12 +118,12 @@ class Config
      */
     public function getNode($path = null)
     {
-        if (!$this->_xml instanceof Element) {
+        if (!$this->getXml() instanceof Element) {
             return false;
         } elseif ($path === null) {
-            return $this->_xml;
+            return $this->getXml();
         } else {
-            return $this->_xml->descend($path);
+            return $this->getXml()->descend($path);
         }
     }
 
@@ -135,11 +135,12 @@ class Config
      */
     public function getXpath($xpath)
     {
-        if (empty($this->_xml)) {
+        $xml = $this->getXml();
+        if (empty($xml)) {
             return false;
         }
 
-        if (!($result = @$this->_xml->xpath($xpath))) {
+        if (!($result = @$xml->xpath($xpath))) {
             return false;
         }
 
@@ -476,7 +477,7 @@ class Config
         if (!empty($string)) {
             $xml = simplexml_load_string($string, $this->_elementClass);
             if ($xml) {
-                $this->_xml = $xml;
+                $this->setXml($xml);
                 return true;
             }
         }
@@ -493,7 +494,7 @@ class Config
     {
         $xml = simplexml_import_dom($dom, $this->_elementClass);
         if ($xml) {
-            $this->_xml = $xml;
+            $this->setXml($xml);
             return true;
         }
 
@@ -510,7 +511,7 @@ class Config
      */
     public function setNode($path, $value, $overwrite = true)
     {
-        $this->_xml->setNode($path, $value, $overwrite);
+        $this->getXml()->setNode($path, $value, $overwrite);
         return $this;
     }
 
@@ -575,4 +576,14 @@ class Config
     {
         $this->_xml = null;
     }
+
+    /**
+     * Getter for xml element
+     *
+     * @return Element
+     */
+    protected function getXml()
+    {
+        return $this->_xml;
+    }
 }
diff --git a/lib/internal/Magento/Framework/Test/Unit/UrlTest.php b/lib/internal/Magento/Framework/Test/Unit/UrlTest.php
index 46d9a13f0bf0a5290fd6086d78aab72a9bf502ca..69e2260002ce05ff621e5b63baf613c7e30a879b 100644
--- a/lib/internal/Magento/Framework/Test/Unit/UrlTest.php
+++ b/lib/internal/Magento/Framework/Test/Unit/UrlTest.php
@@ -73,9 +73,10 @@ class UrlTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
+     * @param bool $resolve
      * @return \Magento\Framework\Url\RouteParamsResolverFactory|\PHPUnit_Framework_MockObject_MockObject
      */
-    protected function getRouteParamsResolver()
+    protected function getRouteParamsResolverFactory($resolve = true)
     {
         $routeParamsResolverFactoryMock = $this->getMock(
             'Magento\Framework\Url\RouteParamsResolverFactory',
@@ -84,8 +85,10 @@ class UrlTest extends \PHPUnit_Framework_TestCase
             '',
             false
         );
-        $routeParamsResolverFactoryMock->expects($this->once())->method('create')
-            ->will($this->returnValue($this->routeParamsResolverMock));
+        if ($resolve) {
+            $routeParamsResolverFactoryMock->expects($this->once())->method('create')
+                    ->will($this->returnValue($this->routeParamsResolverMock));
+        }
         return $routeParamsResolverFactoryMock;
     }
 
@@ -152,7 +155,10 @@ class UrlTest extends \PHPUnit_Framework_TestCase
     public function testGetBaseUrlNotLinkType()
     {
         $model = $this->getUrlModel(
-            ['scopeResolver' => $this->scopeResolverMock, 'routeParamsResolver' => $this->getRouteParamsResolver()]
+            [
+                'scopeResolver' => $this->scopeResolverMock,
+                'routeParamsResolverFactory' => $this->getRouteParamsResolverFactory()
+            ]
         );
 
         $baseUrl = 'base-url';
@@ -184,9 +190,12 @@ class UrlTest extends \PHPUnit_Framework_TestCase
         $requestMock = $this->getRequestMock();
         $routeConfigMock = $this->getMock('Magento\Framework\App\Route\ConfigInterface');
         $model = $this->getUrlModel(
-            ['scopeResolver' => $this->scopeResolverMock, 'routeParamsResolver' => $this->getRouteParamsResolver(),
+            [
+                'scopeResolver' => $this->scopeResolverMock,
+                'routeParamsResolverFactory' => $this->getRouteParamsResolverFactory(),
                 'queryParamsResolver' => $this->queryParamsResolverMock,
-                'request' => $requestMock, 'routeConfig' => $routeConfigMock, ]
+                'request' => $requestMock, 'routeConfig' => $routeConfigMock,
+            ]
         );
 
         $baseUrl = 'http://localhost/index.php/';
@@ -218,7 +227,7 @@ class UrlTest extends \PHPUnit_Framework_TestCase
     {
         $model = $this->getUrlModel([
             'scopeResolver' => $this->scopeResolverMock,
-            'routeParamsResolver' => $this->getRouteParamsResolver(),
+            'routeParamsResolverFactory' => $this->getRouteParamsResolverFactory(),
         ]);
         $model->setData('route_path', 'catalog/product/view');
 
@@ -233,7 +242,7 @@ class UrlTest extends \PHPUnit_Framework_TestCase
     {
         $model = $this->getUrlModel([
             'scopeResolver' => $this->scopeResolverMock,
-            'routeParamsResolver' => $this->getRouteParamsResolver(),
+            'routeParamsResolverFactory' => $this->getRouteParamsResolverFactory(),
             'request' => $this->getRequestMock()
         ]);
         $model->setData('route_name', 'catalog');
@@ -251,7 +260,7 @@ class UrlTest extends \PHPUnit_Framework_TestCase
             ->will($this->returnValue(['foo' => 'bar', 'true' => false]));
         $model = $this->getUrlModel([
             'scopeResolver' => $this->scopeResolverMock,
-            'routeParamsResolver' => $this->getRouteParamsResolver(),
+            'routeParamsResolverFactory' => $this->getRouteParamsResolverFactory(),
             'request' => $this->getRequestMock()
         ]);
 
@@ -270,7 +279,7 @@ class UrlTest extends \PHPUnit_Framework_TestCase
         $request->expects($this->once())->method('getAlias')->will($this->returnValue('/catalog/product/view/'));
         $model = $this->getUrlModel([
             'scopeResolver' => $this->scopeResolverMock,
-            'routeParamsResolver' => $this->getRouteParamsResolver(),
+            'routeParamsResolverFactory' => $this->getRouteParamsResolverFactory(),
             'request' => $request,
         ]);
 
@@ -299,9 +308,12 @@ class UrlTest extends \PHPUnit_Framework_TestCase
         $requestMock = $this->getRequestMock();
         $routeConfigMock = $this->getMock('Magento\Framework\App\Route\ConfigInterface');
         $model = $this->getUrlModel(
-            ['scopeResolver' => $this->scopeResolverMock, 'routeParamsResolver' => $this->getRouteParamsResolver(),
+            [
+                'scopeResolver' => $this->scopeResolverMock,
+                'routeParamsResolverFactory' => $this->getRouteParamsResolverFactory(),
                 'queryParamsResolver' => $this->queryParamsResolverMock,
-                'request' => $requestMock, 'routeConfig' => $routeConfigMock, ]
+                'request' => $requestMock, 'routeConfig' => $routeConfigMock,
+            ]
         );
 
         $baseUrl = 'http://localhost/index.php/';
@@ -332,9 +344,12 @@ class UrlTest extends \PHPUnit_Framework_TestCase
         $requestMock = $this->getRequestMock();
         $routeConfigMock = $this->getMock('Magento\Framework\App\Route\ConfigInterface');
         $model = $this->getUrlModel(
-            ['scopeResolver' => $this->scopeResolverMock, 'routeParamsResolver' => $this->getRouteParamsResolver(),
+            [
+                'scopeResolver' => $this->scopeResolverMock,
+                'routeParamsResolverFactory' => $this->getRouteParamsResolverFactory(),
                 'queryParamsResolver' => $this->queryParamsResolverMock,
-                'request' => $requestMock, 'routeConfig' => $routeConfigMock, ]
+                'request' => $requestMock, 'routeConfig' => $routeConfigMock,
+            ]
         );
 
         $baseUrl = 'http://localhost/index.php/';
@@ -363,7 +378,7 @@ class UrlTest extends \PHPUnit_Framework_TestCase
             'request' => $requestMock,
             'sidResolver' => $this->sidResolverMock,
             'scopeResolver' => $this->scopeResolverMock,
-            'routeParamsResolver' => $this->getRouteParamsResolver(),
+            'routeParamsResolverFactory' => $this->getRouteParamsResolverFactory(false),
             'queryParamsResolver' => $this->queryParamsResolverMock,
         ]);
 
@@ -376,8 +391,12 @@ class UrlTest extends \PHPUnit_Framework_TestCase
     public function testGetRedirectUrl()
     {
         $model = $this->getUrlModel(
-            ['routeParamsResolver' => $this->getRouteParamsResolver(), 'session' => $this->sessionMock,
-                'sidResolver' => $this->sidResolverMock, 'queryParamsResolver' => $this->queryParamsResolverMock, ]
+            [
+                'routeParamsResolverFactory' => $this->getRouteParamsResolverFactory(),
+                'session' => $this->sessionMock,
+                'sidResolver' => $this->sidResolverMock,
+                'queryParamsResolver' => $this->queryParamsResolverMock,
+            ]
         );
 
         $this->sidResolverMock->expects($this->once())->method('getUseSessionInUrl')->will($this->returnValue(true));
@@ -396,8 +415,12 @@ class UrlTest extends \PHPUnit_Framework_TestCase
     public function testGetRedirectUrlWithSessionId()
     {
         $model = $this->getUrlModel(
-            ['routeParamsResolver' => $this->getRouteParamsResolver(), 'session' => $this->sessionMock,
-                'sidResolver' => $this->sidResolverMock, 'queryParamsResolver' => $this->queryParamsResolverMock, ]
+            [
+                'routeParamsResolverFactory' => $this->getRouteParamsResolverFactory(false),
+                'session' => $this->sessionMock,
+                'sidResolver' => $this->sidResolverMock,
+                'queryParamsResolver' => $this->queryParamsResolverMock,
+            ]
         );
 
         $this->sidResolverMock->expects($this->once())->method('getUseSessionInUrl')->will($this->returnValue(true));
@@ -422,7 +445,7 @@ class UrlTest extends \PHPUnit_Framework_TestCase
 
     public function testGetRouteUrlWithValidUrl()
     {
-        $model = $this->getUrlModel(['routeParamsResolver' => $this->getRouteParamsResolver()]);
+        $model = $this->getUrlModel(['routeParamsResolverFactory' => $this->getRouteParamsResolverFactory(false)]);
 
         $this->routeParamsResolverMock->expects($this->never())->method('unsetData');
         $this->assertEquals('http://example.com', $model->getRouteUrl('http://example.com'));
@@ -485,7 +508,7 @@ class UrlTest extends \PHPUnit_Framework_TestCase
         $urlSecurityInfoMock = $this->getMock('Magento\Framework\Url\SecurityInfoInterface');
         $model = $this->getUrlModel([
             'urlSecurityInfo' => $urlSecurityInfoMock,
-            'routeParamsResolver' => $this->getRouteParamsResolver(),
+            'routeParamsResolverFactory' => $this->getRouteParamsResolverFactory(),
             'scopeResolver' => $this->scopeResolverMock,
             'scopeConfig' => $this->scopeConfig,
         ]);
@@ -530,7 +553,7 @@ class UrlTest extends \PHPUnit_Framework_TestCase
     public function testGetConfigDataWithSecureIsForcedParam()
     {
         $model = $this->getUrlModel([
-            'routeParamsResolver' => $this->getRouteParamsResolver(),
+            'routeParamsResolverFactory' => $this->getRouteParamsResolverFactory(),
             'scopeResolver' => $this->scopeResolverMock,
             'scopeConfig' => $this->scopeConfig,
         ]);
@@ -562,8 +585,13 @@ class UrlTest extends \PHPUnit_Framework_TestCase
     {
         $requestMock = $this->getRequestMock();
         $model = $this->getUrlModel(
-            ['session' => $this->sessionMock, 'request' => $requestMock, 'sidResolver' => $this->sidResolverMock,
-                'scopeResolver' => $this->scopeResolverMock, 'routeParamsResolver' => $this->getRouteParamsResolver(), ]
+            [
+                'session' => $this->sessionMock,
+                'request' => $requestMock,
+                'sidResolver' => $this->sidResolverMock,
+                'scopeResolver' => $this->scopeResolverMock,
+                'routeParamsResolverFactory' => $this->getRouteParamsResolverFactory(),
+            ]
         );
 
         $requestMock->expects($this->once())
@@ -585,8 +613,13 @@ class UrlTest extends \PHPUnit_Framework_TestCase
     {
         $requestMock = $this->getRequestMock();
         $model = $this->getUrlModel(
-            ['session' => $this->sessionMock, 'request' => $requestMock, 'sidResolver' => $this->sidResolverMock,
-                'scopeResolver' => $this->scopeResolverMock, 'routeParamsResolver' => $this->getRouteParamsResolver(), ]
+            [
+                'session' => $this->sessionMock,
+                'request' => $requestMock,
+                'sidResolver' => $this->sidResolverMock,
+                'scopeResolver' => $this->scopeResolverMock,
+                'routeParamsResolverFactory' => $this->getRouteParamsResolverFactory(),
+            ]
         );
 
         $requestMock->expects($this->once())->method('getHttpHost')->will($this->returnValue('localhost'));
diff --git a/lib/internal/Magento/Framework/Url.php b/lib/internal/Magento/Framework/Url.php
index efffc744e3fe46da126f655f16a95c9f1c5bd4a7..697e461df050f1f623075655acd3ea4fc13ccaa9 100644
--- a/lib/internal/Magento/Framework/Url.php
+++ b/lib/internal/Magento/Framework/Url.php
@@ -56,6 +56,7 @@ namespace Magento\Framework;
  * - G: route_path
  * - H: route_url
  * @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
  */
 class Url extends \Magento\Framework\Object implements \Magento\Framework\UrlInterface
 {
@@ -133,8 +134,12 @@ class Url extends \Magento\Framework\Object implements \Magento\Framework\UrlInt
     /**
      * @var \Magento\Framework\Url\RouteParamsResolverInterface
      */
-    protected $_routeParamsResolver;
+    private $_routeParamsResolver;
 
+    /**
+     * @var \Magento\Framework\Url\RouteParamsResolverFactory
+     */
+    private $_routeParamsResolverFactory;
     /**
      * @var \Magento\Framework\Url\ScopeResolverInterface
      */
@@ -157,7 +162,7 @@ class Url extends \Magento\Framework\Object implements \Magento\Framework\UrlInt
      * @param \Magento\Framework\Url\ScopeResolverInterface $scopeResolver
      * @param \Magento\Framework\Session\Generic $session
      * @param \Magento\Framework\Session\SidResolverInterface $sidResolver
-     * @param \Magento\Framework\Url\RouteParamsResolverFactory $routeParamsResolver
+     * @param \Magento\Framework\Url\RouteParamsResolverFactory $routeParamsResolverFactory
      * @param \Magento\Framework\Url\QueryParamsResolverInterface $queryParamsResolver
      * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
      * @param string $scopeType
@@ -171,7 +176,7 @@ class Url extends \Magento\Framework\Object implements \Magento\Framework\UrlInt
         \Magento\Framework\Url\ScopeResolverInterface $scopeResolver,
         \Magento\Framework\Session\Generic $session,
         \Magento\Framework\Session\SidResolverInterface $sidResolver,
-        \Magento\Framework\Url\RouteParamsResolverFactory $routeParamsResolver,
+        \Magento\Framework\Url\RouteParamsResolverFactory $routeParamsResolverFactory,
         \Magento\Framework\Url\QueryParamsResolverInterface $queryParamsResolver,
         \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
         $scopeType,
@@ -183,7 +188,7 @@ class Url extends \Magento\Framework\Object implements \Magento\Framework\UrlInt
         $this->_scopeResolver = $scopeResolver;
         $this->_session = $session;
         $this->_sidResolver = $sidResolver;
-        $this->_routeParamsResolver = $routeParamsResolver->create();
+        $this->_routeParamsResolverFactory = $routeParamsResolverFactory;
         $this->_queryParamsResolver = $queryParamsResolver;
         $this->_scopeConfig = $scopeConfig;
         $this->_scopeType = $scopeType;
@@ -322,10 +327,10 @@ class Url extends \Magento\Framework\Object implements \Magento\Framework\UrlInt
      */
     protected function _getType()
     {
-        if (!$this->_routeParamsResolver->hasData('type')) {
-            $this->_routeParamsResolver->setData('type', self::DEFAULT_URL_TYPE);
+        if (!$this->getRouteParamsResolver()->hasData('type')) {
+            $this->getRouteParamsResolver()->setData('type', self::DEFAULT_URL_TYPE);
         }
-        return $this->_routeParamsResolver->getType();
+        return $this->getRouteParamsResolver()->getType();
     }
 
     /**
@@ -335,27 +340,27 @@ class Url extends \Magento\Framework\Object implements \Magento\Framework\UrlInt
      */
     protected function _isSecure()
     {
-        if ($this->_routeParamsResolver->hasData('secure_is_forced')) {
-            return (bool) $this->_routeParamsResolver->getData('secure');
+        if ($this->getRouteParamsResolver()->hasData('secure_is_forced')) {
+            return (bool) $this->getRouteParamsResolver()->getData('secure');
         }
 
         if (!$this->_getScope()->isUrlSecure()) {
             return false;
         }
 
-        if (!$this->_routeParamsResolver->hasData('secure')) {
+        if (!$this->getRouteParamsResolver()->hasData('secure')) {
             if ($this->_getType() == UrlInterface::URL_TYPE_LINK) {
                 $pathSecure = $this->_urlSecurityInfo->isSecure('/' . $this->_getActionPath());
-                $this->_routeParamsResolver->setData('secure', $pathSecure);
+                $this->getRouteParamsResolver()->setData('secure', $pathSecure);
             } elseif ($this->_getType() == UrlInterface::URL_TYPE_STATIC) {
                 $isRequestSecure = $this->_getRequest()->isSecure();
-                $this->_routeParamsResolver->setData('secure', $isRequestSecure);
+                $this->getRouteParamsResolver()->setData('secure', $isRequestSecure);
             } else {
-                $this->_routeParamsResolver->setData('secure', true);
+                $this->getRouteParamsResolver()->setData('secure', true);
             }
         }
 
-        return $this->_routeParamsResolver->getData('secure');
+        return $this->getRouteParamsResolver()->getData('secure');
     }
 
     /**
@@ -367,7 +372,7 @@ class Url extends \Magento\Framework\Object implements \Magento\Framework\UrlInt
     public function setScope($params)
     {
         $this->setData('scope', $this->_scopeResolver->getScope($params));
-        $this->_routeParamsResolver->setScope($this->_scopeResolver->getScope($params));
+        $this->getRouteParamsResolver()->setScope($this->_scopeResolver->getScope($params));
         return $this;
     }
 
@@ -401,11 +406,11 @@ class Url extends \Magento\Framework\Object implements \Magento\Framework\UrlInt
             $this->setScope($params['_scope']);
         }
         if (isset($params['_type'])) {
-            $this->_routeParamsResolver->setType($params['_type']);
+            $this->getRouteParamsResolver()->setType($params['_type']);
         }
 
         if (isset($params['_secure'])) {
-            $this->_routeParamsResolver->setSecure($params['_secure']);
+            $this->getRouteParamsResolver()->setSecure($params['_secure']);
         }
 
         /**
@@ -416,13 +421,13 @@ class Url extends \Magento\Framework\Object implements \Magento\Framework\UrlInt
                 $this->_getRouteFrontName()
             )
         ) {
-            $this->_routeParamsResolver->setType(UrlInterface::URL_TYPE_DIRECT_LINK);
+            $this->getRouteParamsResolver()->setType(UrlInterface::URL_TYPE_DIRECT_LINK);
         }
 
         $result = $this->_getScope()->getBaseUrl($this->_getType(), $this->_isSecure());
         // setting back the original scope
         $this->setScope($origScope);
-        $this->_routeParamsResolver->setType(self::DEFAULT_URL_TYPE);
+        $this->getRouteParamsResolver()->setType(self::DEFAULT_URL_TYPE);
         return $result;
     }
 
@@ -471,7 +476,7 @@ class Url extends \Magento\Framework\Object implements \Magento\Framework\UrlInt
                 $key = array_shift($routePieces);
                 if (!empty($routePieces)) {
                     $value = array_shift($routePieces);
-                    $this->_routeParamsResolver->setRouteParam($key, $value);
+                    $this->getRouteParamsResolver()->setRouteParam($key, $value);
                 }
             }
         }
@@ -650,7 +655,7 @@ class Url extends \Magento\Framework\Object implements \Magento\Framework\UrlInt
      */
     protected function _setRouteParams(array $data, $unsetOldParams = true)
     {
-        $this->_routeParamsResolver->setRouteParams($data, $unsetOldParams);
+        $this->getRouteParamsResolver()->setRouteParams($data, $unsetOldParams);
         return $this;
     }
 
@@ -661,7 +666,7 @@ class Url extends \Magento\Framework\Object implements \Magento\Framework\UrlInt
      */
     protected function _getRouteParams()
     {
-        return $this->_routeParamsResolver->getRouteParams();
+        return $this->getRouteParamsResolver()->getRouteParams();
     }
 
     /**
@@ -677,7 +682,7 @@ class Url extends \Magento\Framework\Object implements \Magento\Framework\UrlInt
             return $routePath;
         }
 
-        $this->_routeParamsResolver->unsetData('route_params');
+        $this->getRouteParamsResolver()->unsetData('route_params');
 
         if (isset($routeParams['_direct'])) {
             if (is_array($routeParams)) {
@@ -786,7 +791,7 @@ class Url extends \Magento\Framework\Object implements \Magento\Framework\UrlInt
          * this method has condition for adding default controller and action names
          * in case when we have params
          */
-        $this->_routeParamsResolver->unsetData('secure');
+        $this->getRouteParamsResolver()->unsetData('secure');
         $fragment = null;
         if (isset($routeParams['_fragment'])) {
             $fragment = $routeParams['_fragment'];
@@ -840,7 +845,7 @@ class Url extends \Magento\Framework\Object implements \Magento\Framework\UrlInt
         if (!is_null($fragment)) {
             $url .= '#' . $fragment;
         }
-        $this->_routeParamsResolver->unsetData('secure');
+        $this->getRouteParamsResolver()->unsetData('secure');
         return $this->escape($url);
     }
 
@@ -1038,4 +1043,17 @@ class Url extends \Magento\Framework\Object implements \Magento\Framework\UrlInt
         $url = $this->_request->getScheme() . '://' . $this->_request->getHttpHost() . $port . $requestUri;
         return $url;
     }
+
+    /**
+     * Get Route Params Resolver
+     *
+     * @return Url\RouteParamsResolverInterface
+     */
+    protected function getRouteParamsResolver()
+    {
+        if (!$this->_routeParamsResolver) {
+            $this->_routeParamsResolver = $this->_routeParamsResolverFactory->create();
+        }
+        return $this->_routeParamsResolver;
+    }
 }
diff --git a/lib/internal/Magento/Framework/Url/ScopeResolverInterface.php b/lib/internal/Magento/Framework/Url/ScopeResolverInterface.php
index 893443659220d4b68e5ec3514f25beb0ea3c7725..a31ae25c76ea41a6efea88d85ccfb5c424092143 100644
--- a/lib/internal/Magento/Framework/Url/ScopeResolverInterface.php
+++ b/lib/internal/Magento/Framework/Url/ScopeResolverInterface.php
@@ -10,7 +10,7 @@ interface ScopeResolverInterface extends \Magento\Framework\App\ScopeResolverInt
     /**
      * Retrieve area code
      *
-     * @return \Magento\Framework\Url\ScopeInterface[]
+     * @return string|null
      */
     public function getAreaCode();
 }
diff --git a/lib/internal/Magento/Framework/UrlInterface/Proxy.php b/lib/internal/Magento/Framework/UrlInterface/Proxy.php
new file mode 100644
index 0000000000000000000000000000000000000000..7ed1a1bbc7bff3df6959ec70ed2aa2c779b21636
--- /dev/null
+++ b/lib/internal/Magento/Framework/UrlInterface/Proxy.php
@@ -0,0 +1,212 @@
+<?php
+/**
+ * Copyright © 2015 Magento. All rights reserved.
+ * See COPYING.txt for license details.
+ */
+namespace Magento\Framework\UrlInterface;
+
+/**
+ * Proxy class for @see \Magento\Framework\UrlInterface
+ */
+class Proxy implements \Magento\Framework\UrlInterface
+{
+    /**
+     * Object Manager instance
+     *
+     * @var \Magento\Framework\ObjectManagerInterface
+     */
+    protected $_objectManager = null;
+
+    /**
+     * Proxied instance name
+     *
+     * @var string
+     */
+    protected $_instanceName = null;
+
+    /**
+     * Proxied instance
+     *
+     * @var \Magento\Framework\UrlInterface
+     */
+    protected $_subject = null;
+
+    /**
+     * Instance shareability flag
+     *
+     * @var bool
+     */
+    protected $_isShared = null;
+
+    /**
+     * Proxy constructor
+     *
+     * @param \Magento\Framework\ObjectManagerInterface $objectManager
+     * @param string $instanceName
+     * @param bool $shared
+     */
+    public function __construct(
+        \Magento\Framework\ObjectManagerInterface $objectManager,
+        $instanceName = '\\Magento\\Framework\\UrlInterface',
+        $shared = true
+    ) {
+        $this->_objectManager = $objectManager;
+        $this->_instanceName = $instanceName;
+        $this->_isShared = $shared;
+    }
+
+    /**
+     * @return array
+     */
+    public function __sleep()
+    {
+        return ['_subject', '_isShared'];
+    }
+
+    /**
+     * Retrieve ObjectManager from global scope
+     *
+     * @return void
+     */
+    public function __wakeup()
+    {
+        $this->_objectManager = \Magento\Framework\App\ObjectManager::getInstance();
+    }
+
+    /**
+     * Clone proxied instance
+     *
+     * @return void
+     */
+    public function __clone()
+    {
+        $this->_subject = clone $this->_getSubject();
+    }
+
+    /**
+     * Get proxied instance
+     *
+     * @return \Magento\Framework\UrlInterface
+     */
+    protected function _getSubject()
+    {
+        if (!$this->_subject) {
+            $this->_subject = true === $this->_isShared
+                ? $this->_objectManager->get($this->_instanceName)
+                : $this->_objectManager->create($this->_instanceName);
+        }
+        return $this->_subject;
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function getUseSession()
+    {
+        return $this->_getSubject()->getUseSession();
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function getBaseUrl($params = [])
+    {
+        return $this->_getSubject()->getBaseUrl($params);
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function getCurrentUrl()
+    {
+        return $this->_getSubject()->getCurrentUrl();
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function getRouteUrl($routePath = null, $routeParams = null)
+    {
+        return $this->_getSubject()->getRouteUrl($routePath, $routeParams);
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function addSessionParam()
+    {
+        return $this->_getSubject()->addSessionParam();
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function addQueryParams(array $data)
+    {
+        return $this->_getSubject()->addQueryParams($data);
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function setQueryParam($key, $data)
+    {
+        return $this->_getSubject()->setQueryParam($key, $data);
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function getUrl($routePath = null, $routeParams = null)
+    {
+        return $this->_getSubject()->getUrl($routePath, $routeParams);
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function escape($value)
+    {
+        return $this->_getSubject()->escape($value);
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function getDirectUrl($url, $params = [])
+    {
+        return $this->_getSubject()->getDirectUrl($url, $params);
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function sessionUrlVar($html)
+    {
+        return $this->_getSubject()->sessionUrlVar($html);
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function isOwnOriginUrl()
+    {
+        return $this->_getSubject()->isOwnOriginUrl();
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function getRedirectUrl($url)
+    {
+        return $this->_getSubject()->getRedirectUrl($url);
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function setScope($params)
+    {
+        return $this->_getSubject()->setScope($params);
+    }
+}
diff --git a/lib/internal/Magento/Framework/Validator/Factory.php b/lib/internal/Magento/Framework/Validator/Factory.php
index a663b91cc745f01f164e1d30a1f6e9f04682087b..ef5679b220c2460dbc1e94d7d09760af0436fa31 100644
--- a/lib/internal/Magento/Framework/Validator/Factory.php
+++ b/lib/internal/Magento/Framework/Validator/Factory.php
@@ -24,6 +24,11 @@ class Factory
      */
     protected $_configFiles = null;
 
+    /**
+     * @var bool
+     */
+    private $isDefaultTranslatorInitialized = false;
+
     /**
      * Initialize dependencies
      *
@@ -36,7 +41,6 @@ class Factory
     ) {
         $this->_objectManager = $objectManager;
         $this->_configFiles = $moduleReader->getConfigurationFiles('validation.xml');
-        $this->_initializeDefaultTranslator();
     }
 
     /**
@@ -46,15 +50,18 @@ class Factory
      */
     protected function _initializeDefaultTranslator()
     {
-        // Pass translations to \Magento\Framework\TranslateInterface from validators
-        $translatorCallback = function () {
-            $argc = func_get_args();
-            return (string)new \Magento\Framework\Phrase(array_shift($argc), $argc);
-        };
-        /** @var \Magento\Framework\Translate\Adapter $translator */
-        $translator = $this->_objectManager->create('Magento\Framework\Translate\Adapter');
-        $translator->setOptions(['translator' => $translatorCallback]);
-        \Magento\Framework\Validator\AbstractValidator::setDefaultTranslator($translator);
+        if (!$this->isDefaultTranslatorInitialized) {
+            // Pass translations to \Magento\Framework\TranslateInterface from validators
+            $translatorCallback = function () {
+                $argc = func_get_args();
+                return (string)new \Magento\Framework\Phrase(array_shift($argc), $argc);
+            };
+            /** @var \Magento\Framework\Translate\Adapter $translator */
+            $translator = $this->_objectManager->create('Magento\Framework\Translate\Adapter');
+            $translator->setOptions(['translator' => $translatorCallback]);
+            \Magento\Framework\Validator\AbstractValidator::setDefaultTranslator($translator);
+            $this->isDefaultTranslatorInitialized = true;
+        }
     }
 
     /**
@@ -66,6 +73,7 @@ class Factory
      */
     public function getValidatorConfig()
     {
+        $this->_initializeDefaultTranslator();
         return $this->_objectManager->create('Magento\Framework\Validator\Config', ['configFiles' => $this->_configFiles]);
     }
 
@@ -79,6 +87,7 @@ class Factory
      */
     public function createValidatorBuilder($entityName, $groupName, array $builderConfig = null)
     {
+        $this->_initializeDefaultTranslator();
         return $this->getValidatorConfig()->createValidatorBuilder($entityName, $groupName, $builderConfig);
     }
 
@@ -92,6 +101,7 @@ class Factory
      */
     public function createValidator($entityName, $groupName, array $builderConfig = null)
     {
+        $this->_initializeDefaultTranslator();
         return $this->getValidatorConfig()->createValidator($entityName, $groupName, $builderConfig);
     }
 }
diff --git a/lib/internal/Magento/Framework/View/Layout.php b/lib/internal/Magento/Framework/View/Layout.php
index 6c857548d18ed329d6767bbc6f35684f8205e059..da8130891b3b05e624f358c2f0fe5b1b52d7444d 100644
--- a/lib/internal/Magento/Framework/View/Layout.php
+++ b/lib/internal/Magento/Framework/View/Layout.php
@@ -23,6 +23,12 @@ use Magento\Framework\View\Layout\ScheduledStructure;
  */
 class Layout extends \Magento\Framework\Simplexml\Config implements \Magento\Framework\View\LayoutInterface
 {
+
+    /**
+     * Empty layout xml
+     */
+    const LAYOUT_NODE = '<layout/>';
+
     /**
      * Layout Update module
      *
@@ -173,7 +179,6 @@ class Layout extends \Magento\Framework\Simplexml\Config implements \Magento\Fra
         $cacheable = true
     ) {
         $this->_elementClass = 'Magento\Framework\View\Layout\Element';
-        $this->setXml(simplexml_load_string('<layout/>', $this->_elementClass));
         $this->_renderingOutput = new \Magento\Framework\Object();
 
         $this->_processorFactory = $processorFactory;
@@ -188,8 +193,6 @@ class Layout extends \Magento\Framework\Simplexml\Config implements \Magento\Fra
 
         $this->readerContextFactory = $readerContextFactory;
         $this->generatorContextFactory = $generatorContextFactory;
-
-        $this->readerContext = $this->readerContextFactory->create();
     }
 
     /**
@@ -248,7 +251,7 @@ class Layout extends \Magento\Framework\Simplexml\Config implements \Magento\Fra
             $this->_update = null;
         }
         $this->_blocks = [];
-        $this->_xml = null;
+        parent::__destruct();
     }
 
     /**
@@ -278,14 +281,6 @@ class Layout extends \Magento\Framework\Simplexml\Config implements \Magento\Fra
         return $this;
     }
 
-    /**
-     * @return Layout\Reader\Context
-     */
-    public function getReaderContext()
-    {
-        return $this->readerContext;
-    }
-
     /**
      * Create structure of elements from the loaded XML configuration
      *
@@ -297,13 +292,12 @@ class Layout extends \Magento\Framework\Simplexml\Config implements \Magento\Fra
         $cacheId = 'structure_' . $this->getUpdate()->getCacheId();
         $result = $this->cache->load($cacheId);
         if ($result) {
-            /** @var Layout\Reader\Context $readerContext */
             $this->readerContext = unserialize($result);
         } else {
             \Magento\Framework\Profiler::start('build_structure');
-            $this->readerPool->interpret($this->readerContext, $this->getNode());
+            $this->readerPool->interpret($this->getReaderContext(), $this->getNode());
             \Magento\Framework\Profiler::stop('build_structure');
-            $this->cache->save(serialize($this->readerContext), $cacheId, $this->getUpdate()->getHandles());
+            $this->cache->save(serialize($this->getReaderContext()), $cacheId, $this->getUpdate()->getHandles());
         }
 
         $generatorContext = $this->generatorContextFactory->create(
@@ -314,7 +308,7 @@ class Layout extends \Magento\Framework\Simplexml\Config implements \Magento\Fra
         );
 
         \Magento\Framework\Profiler::start('generate_elements');
-        $this->generatorPool->process($this->readerContext, $generatorContext);
+        $this->generatorPool->process($this->getReaderContext(), $generatorContext);
         \Magento\Framework\Profiler::stop('generate_elements');
 
         $this->addToOutputRootContainers();
@@ -1035,7 +1029,7 @@ class Layout extends \Magento\Framework\Simplexml\Config implements \Magento\Fra
     public function isCacheable()
     {
         $this->build();
-        $cacheableXml = !(bool)count($this->_xml->xpath('//' . Element::TYPE_BLOCK . '[@cacheable="false"]'));
+        $cacheableXml = !(bool)count($this->getXml()->xpath('//' . Element::TYPE_BLOCK . '[@cacheable="false"]'));
         return $this->cacheable && $cacheableXml;
     }
 
@@ -1060,4 +1054,30 @@ class Layout extends \Magento\Framework\Simplexml\Config implements \Magento\Fra
         $this->isPrivate = (bool)$isPrivate;
         return $this;
     }
+
+    /**
+     * Getter and lazy loader for xml element
+     *
+     * @return \Magento\Framework\Simplexml\Element
+     */
+    protected function getXml()
+    {
+        if (!$this->_xml) {
+            $this->setXml(simplexml_load_string(self::LAYOUT_NODE, $this->_elementClass));
+        }
+        return $this->_xml;
+    }
+
+    /**
+     * Getter and lazy loader for reader context
+     *
+     * @return Layout\Reader\Context
+     */
+    public function getReaderContext()
+    {
+        if (!$this->readerContext) {
+            $this->readerContext = $this->readerContextFactory->create();
+        }
+        return $this->readerContext;
+    }
 }
diff --git a/lib/internal/Magento/Framework/View/Layout/Proxy.php b/lib/internal/Magento/Framework/View/Layout/Proxy.php
index 8c399f4e4161a7f847b4f22db49e7e97e8528ef2..95220e34913df356a84e427d9d72e04f5c73b6ac 100644
--- a/lib/internal/Magento/Framework/View/Layout/Proxy.php
+++ b/lib/internal/Magento/Framework/View/Layout/Proxy.php
@@ -6,8 +6,7 @@
 namespace Magento\Framework\View\Layout;
 
 /**
- * Proxy class for \Magento\Framework\View\Layout
- *
+ * Proxy class for @see \Magento\Framework\View\Layout
  * @SuppressWarnings(PHPMD.ExcessivePublicCount)
  */
 class Proxy extends \Magento\Framework\View\Layout
@@ -17,42 +16,44 @@ class Proxy extends \Magento\Framework\View\Layout
      *
      * @var \Magento\Framework\ObjectManagerInterface
      */
-    protected $objectManager;
+    protected $_objectManager = null;
 
     /**
      * Proxied instance name
      *
      * @var string
      */
-    protected $instanceName;
+    protected $_instanceName = null;
 
     /**
      * Proxied instance
      *
      * @var \Magento\Framework\View\Layout
      */
-    protected $subject;
+    protected $_subject = null;
 
     /**
      * Instance shareability flag
      *
      * @var bool
      */
-    protected $isShared;
+    protected $_isShared = null;
 
     /**
+     * Proxy constructor
+     *
      * @param \Magento\Framework\ObjectManagerInterface $objectManager
      * @param string $instanceName
      * @param bool $shared
      */
     public function __construct(
         \Magento\Framework\ObjectManagerInterface $objectManager,
-        $instanceName = 'Magento\Framework\View\Layout',
+        $instanceName = '\\Magento\\Framework\\View\\Layout',
         $shared = true
     ) {
-        $this->objectManager = $objectManager;
-        $this->instanceName = $instanceName;
-        $this->isShared = $shared;
+        $this->_objectManager = $objectManager;
+        $this->_instanceName = $instanceName;
+        $this->_isShared = $shared;
     }
 
     /**
@@ -70,7 +71,7 @@ class Proxy extends \Magento\Framework\View\Layout
      */
     public function __wakeup()
     {
-        $this->objectManager = \Magento\Framework\App\ObjectManager::getInstance();
+        $this->_objectManager = \Magento\Framework\App\ObjectManager::getInstance();
     }
 
     /**
@@ -80,7 +81,7 @@ class Proxy extends \Magento\Framework\View\Layout
      */
     public function __clone()
     {
-        $this->subject = clone $this->getSubject();
+        $this->_subject = clone $this->_getSubject();
     }
 
     /**
@@ -88,415 +89,334 @@ class Proxy extends \Magento\Framework\View\Layout
      *
      * @return \Magento\Framework\View\Layout
      */
-    protected function getSubject()
+    protected function _getSubject()
     {
-        if (!$this->subject) {
-            $this->subject = true === $this->isShared
-                ? $this->objectManager->get($this->instanceName)
-                : $this->objectManager->create($this->instanceName);
+        if (!$this->_subject) {
+            $this->_subject = true === $this->_isShared
+                ? $this->_objectManager->get($this->_instanceName)
+                : $this->_objectManager->create($this->_instanceName);
         }
-        return $this->subject;
+        return $this->_subject;
     }
 
     /**
-     * Retrieve the layout update instance
-     *
-     * @return \Magento\Framework\View\Layout\ProcessorInterface
+     * {@inheritdoc}
+     */
+    public function setGeneratorPool(\Magento\Framework\View\Layout\GeneratorPool $generatorPool)
+    {
+        return $this->_getSubject()->setGeneratorPool($generatorPool);
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function setBuilder(\Magento\Framework\View\Layout\BuilderInterface $builder)
+    {
+        return $this->_getSubject()->setBuilder($builder);
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function publicBuild()
+    {
+        $this->_getSubject()->publicBuild();
+    }
+
+    /**
+     * {@inheritdoc}
      */
     public function getUpdate()
     {
-        return $this->getSubject()->getUpdate();
+        return $this->_getSubject()->getUpdate();
     }
 
     /**
-     * Layout xml generation
-     *
-     * @return $this
+     * {@inheritdoc}
      */
     public function generateXml()
     {
-        return $this->getSubject()->generateXml();
+        return $this->_getSubject()->generateXml();
     }
 
     /**
-     * Create structure of elements from the loaded XML configuration
-     *
-     * @return void
+     * {@inheritdoc}
      */
     public function generateElements()
     {
-        $this->getSubject()->generateElements();
+        $this->_getSubject()->generateElements();
     }
 
     /**
-     * Get child block if exists
-     *
-     * @param string $parentName
-     * @param string $alias
-     * @return bool|\Magento\Framework\View\Element\AbstractBlock
+     * {@inheritdoc}
      */
     public function getChildBlock($parentName, $alias)
     {
-        return $this->getSubject()->getChildBlock($parentName, $alias);
+        return $this->_getSubject()->getChildBlock($parentName, $alias);
     }
 
     /**
-     * Set child element into layout structure
-     *
-     * @param string $parentName
-     * @param string $elementName
-     * @param string $alias
-     * @return $this
+     * {@inheritdoc}
      */
     public function setChild($parentName, $elementName, $alias)
     {
-        return $this->getSubject()->setChild($parentName, $elementName, $alias);
+        return $this->_getSubject()->setChild($parentName, $elementName, $alias);
     }
 
     /**
-     * Reorder a child of a specified element
-     *
-     * If $offsetOrSibling is null, it will put the element to the end
-     * If $offsetOrSibling is numeric (integer) value, it will put the element after/before specified position
-     * Otherwise -- after/before specified sibling
-     *
-     * @param string $parentName
-     * @param string $childName
-     * @param string|int|null $offsetOrSibling
-     * @param bool $after
-     * @return void
+     * {@inheritdoc}
      */
     public function reorderChild($parentName, $childName, $offsetOrSibling, $after = true)
     {
-        $this->getSubject()->reorderChild($parentName, $childName, $offsetOrSibling, $after);
+        $this->_getSubject()->reorderChild($parentName, $childName, $offsetOrSibling, $after);
     }
 
     /**
-     * Remove child element from parent
-     *
-     * @param string $parentName
-     * @param string $alias
-     * @return $this
+     * {@inheritdoc}
      */
     public function unsetChild($parentName, $alias)
     {
-        return $this->getSubject()->unsetChild($parentName, $alias);
+        return $this->_getSubject()->unsetChild($parentName, $alias);
     }
 
     /**
-     * Get list of child names
-     *
-     * @param string $parentName
-     * @return array
+     * {@inheritdoc}
      */
     public function getChildNames($parentName)
     {
-        return $this->getSubject()->getChildNames($parentName);
+        return $this->_getSubject()->getChildNames($parentName);
     }
 
     /**
-     * Get list of child blocks
-     *
-     * Returns associative array of <alias> => <block instance>
-     *
-     * @param string $parentName
-     * @return array
+     * {@inheritdoc}
      */
     public function getChildBlocks($parentName)
     {
-        return $this->getSubject()->getChildBlocks($parentName);
+        return $this->_getSubject()->getChildBlocks($parentName);
     }
 
     /**
-     * Get child name by alias
-     *
-     * @param string $parentName
-     * @param string $alias
-     * @return bool|string
+     * {@inheritdoc}
      */
     public function getChildName($parentName, $alias)
     {
-        return $this->getSubject()->getChildName($parentName, $alias);
+        return $this->_getSubject()->getChildName($parentName, $alias);
     }
 
     /**
-     * Find an element in layout, render it and return string with its output
-     *
-     * @param string $name
-     * @param bool $useCache
-     * @return string
+     * {@inheritdoc}
      */
     public function renderElement($name, $useCache = true)
     {
-        return $this->getSubject()->renderElement($name, $useCache);
+        return $this->_getSubject()->renderElement($name, $useCache);
     }
 
     /**
-     * Add element to parent group
-     *
-     * @param string $blockName
-     * @param string $parentGroupName
-     * @return bool
+     * {@inheritdoc}
+     */
+    public function renderNonCachedElement($name)
+    {
+        return $this->_getSubject()->renderNonCachedElement($name);
+    }
+
+    /**
+     * {@inheritdoc}
      */
     public function addToParentGroup($blockName, $parentGroupName)
     {
-        return $this->getSubject()->addToParentGroup($blockName, $parentGroupName);
+        return $this->_getSubject()->addToParentGroup($blockName, $parentGroupName);
     }
 
     /**
-     * Get element names for specified group
-     *
-     * @param string $blockName
-     * @param string $groupName
-     * @return array
+     * {@inheritdoc}
      */
     public function getGroupChildNames($blockName, $groupName)
     {
-        return $this->getSubject()->getGroupChildNames($blockName, $groupName);
+        return $this->_getSubject()->getGroupChildNames($blockName, $groupName);
     }
 
     /**
-     * Check if element exists in layout structure
-     *
-     * @param string $name
-     * @return bool
+     * {@inheritdoc}
      */
     public function hasElement($name)
     {
-        return $this->getSubject()->hasElement($name);
+        return $this->_getSubject()->hasElement($name);
     }
 
     /**
-     * Get property value of an element
-     *
-     * @param string $name
-     * @param string $attribute
-     * @return mixed
+     * {@inheritdoc}
      */
     public function getElementProperty($name, $attribute)
     {
-        return $this->getSubject()->getElementProperty($name, $attribute);
+        return $this->_getSubject()->getElementProperty($name, $attribute);
     }
 
     /**
-     * Whether specified element is a block
-     *
-     * @param string $name
-     * @return bool
+     * {@inheritdoc}
      */
     public function isBlock($name)
     {
-        return $this->getSubject()->isBlock($name);
+        return $this->_getSubject()->isBlock($name);
     }
 
     /**
-     * Checks if element with specified name is container
-     *
-     * @param string $name
-     * @return bool
+     * {@inheritdoc}
+     */
+    public function isUiComponent($name)
+    {
+        return $this->_getSubject()->isUiComponent($name);
+    }
+
+    /**
+     * {@inheritdoc}
      */
     public function isContainer($name)
     {
-        return $this->getSubject()->isContainer($name);
+        return $this->_getSubject()->isContainer($name);
     }
 
     /**
-     * Whether the specified element may be manipulated externally
-     *
-     * @param string $name
-     * @return bool
+     * {@inheritdoc}
      */
     public function isManipulationAllowed($name)
     {
-        return $this->getSubject()->isManipulationAllowed($name);
+        return $this->_getSubject()->isManipulationAllowed($name);
     }
 
     /**
-     * Save block in blocks registry
-     *
-     * @param string $name
-     * @param \Magento\Framework\View\Element\AbstractBlock $block
-     * @return $this
+     * {@inheritdoc}
      */
     public function setBlock($name, $block)
     {
-        return $this->getSubject()->setBlock($name, $block);
+        return $this->_getSubject()->setBlock($name, $block);
     }
 
     /**
-     * Remove block from registry
-     *
-     * @param string $name
-     * @return $this
+     * {@inheritdoc}
      */
     public function unsetElement($name)
     {
-        return $this->getSubject()->unsetElement($name);
+        return $this->_getSubject()->unsetElement($name);
     }
 
     /**
-     * Block Factory
-     *
-     * @param  string $type
-     * @param  string $name
-     * @param  array $attributes
-     * @return \Magento\Framework\View\Element\AbstractBlock
+     * {@inheritdoc}
      */
-    public function createBlock($type, $name = '', array $attributes = [])
+    public function createBlock($type, $name = '', array $arguments = [])
     {
-        return $this->getSubject()->createBlock($type, $name, $attributes);
+        return $this->_getSubject()->createBlock($type, $name, $arguments);
     }
 
     /**
-     * Add a block to registry, create new object if needed
-     *
-     * @param string|\Magento\Framework\View\Element\AbstractBlock $block
-     * @param string $name
-     * @param string $parent
-     * @param string $alias
-     * @return \Magento\Framework\View\Element\AbstractBlock
+     * {@inheritdoc}
      */
     public function addBlock($block, $name = '', $parent = '', $alias = '')
     {
-        return $this->getSubject()->addBlock($block, $name, $parent, $alias);
+        return $this->_getSubject()->addBlock($block, $name, $parent, $alias);
     }
 
     /**
-     * Insert container into layout structure
-     *
-     * @param string $name
-     * @param string $label
-     * @param array $options
-     * @param string $parent
-     * @param string $alias
-     * @return void
+     * {@inheritdoc}
      */
     public function addContainer($name, $label, array $options = [], $parent = '', $alias = '')
     {
-        $this->getSubject()->addContainer($name, $label, $options, $parent, $alias);
+        $this->_getSubject()->addContainer($name, $label, $options, $parent, $alias);
     }
 
     /**
-     * Rename element in layout and layout structure
-     *
-     * @param string $oldName
-     * @param string $newName
-     * @return bool
+     * {@inheritdoc}
      */
     public function renameElement($oldName, $newName)
     {
-        return $this->getSubject()->renameElement($oldName, $newName);
+        return $this->_getSubject()->renameElement($oldName, $newName);
     }
 
     /**
-     * Retrieve all blocks from registry as array
-     *
-     * @return array
+     * {@inheritdoc}
      */
     public function getAllBlocks()
     {
-        return $this->getSubject()->getAllBlocks();
+        return $this->_getSubject()->getAllBlocks();
     }
 
     /**
-     * Get block object by name
-     *
-     * @param string $name
-     * @return \Magento\Framework\View\Element\AbstractBlock|bool
+     * {@inheritdoc}
      */
     public function getBlock($name)
     {
-        return $this->getSubject()->getBlock($name);
+        return $this->_getSubject()->getBlock($name);
     }
 
     /**
-     * Gets parent name of an element with specified name
-     *
-     * @param string $childName
-     * @return bool|string
+     * {@inheritdoc}
+     */
+    public function getUiComponent($name)
+    {
+        return $this->_getSubject()->getUiComponent($name);
+    }
+
+    /**
+     * {@inheritdoc}
      */
     public function getParentName($childName)
     {
-        return $this->getSubject()->getParentName($childName);
+        return $this->_getSubject()->getParentName($childName);
     }
 
     /**
-     * Get element alias by name
-     *
-     * @param string $name
-     * @return bool|string
+     * {@inheritdoc}
      */
     public function getElementAlias($name)
     {
-        return $this->getSubject()->getElementAlias($name);
+        return $this->_getSubject()->getElementAlias($name);
     }
 
     /**
-     * Add an element to output
-     *
-     * @param string $name
-     * @return $this
+     * {@inheritdoc}
      */
     public function addOutputElement($name)
     {
-        return $this->getSubject()->addOutputElement($name);
+        return $this->_getSubject()->addOutputElement($name);
     }
 
     /**
-     * Remove an element from output
-     *
-     * @param string $name
-     * @return $this
+     * {@inheritdoc}
      */
     public function removeOutputElement($name)
     {
-        return $this->getSubject()->removeOutputElement($name);
+        return $this->_getSubject()->removeOutputElement($name);
     }
 
     /**
-     * Get all blocks marked for output
-     *
-     * @return string
+     * {@inheritdoc}
      */
     public function getOutput()
     {
-        return $this->getSubject()->getOutput();
+        return $this->_getSubject()->getOutput();
     }
 
     /**
-     * Retrieve messages block
-     *
-     * @return \Magento\Framework\View\Element\Messages
+     * {@inheritdoc}
      */
     public function getMessagesBlock()
     {
-        return $this->getSubject()->getMessagesBlock();
+        return $this->_getSubject()->getMessagesBlock();
     }
 
     /**
-     * Get block singleton
-     *
-     * @param string $type
-     * @throws \Magento\Framework\Exception\LocalizedException
-     * @return \Magento\Framework\App\Helper\AbstractHelper
+     * {@inheritdoc}
      */
     public function getBlockSingleton($type)
     {
-        return $this->getSubject()->getBlockSingleton($type);
+        return $this->_getSubject()->getBlockSingleton($type);
     }
 
     /**
-     * @param string $namespace
-     * @param string $staticType
-     * @param string $dynamicType
-     * @param string $type
-     * @param string $template
-     * @param array $data
-     * @return $this
+     * {@inheritdoc}
      */
     public function addAdjustableRenderer($namespace, $staticType, $dynamicType, $type, $template, $data = [])
     {
-        return $this->getSubject()->addAdjustableRenderer(
+        return $this->_getSubject()->addAdjustableRenderer(
             $namespace,
             $staticType,
             $dynamicType,
@@ -507,394 +427,298 @@ class Proxy extends \Magento\Framework\View\Layout
     }
 
     /**
-     * Get renderer options
-     *
-     * @param string $namespace
-     * @param string $staticType
-     * @param string $dynamicType
-     * @return array|null
+     * {@inheritdoc}
      */
     public function getRendererOptions($namespace, $staticType, $dynamicType)
     {
-        return $this->getSubject()->getRendererOptions($namespace, $staticType, $dynamicType);
+        return $this->_getSubject()->getRendererOptions($namespace, $staticType, $dynamicType);
     }
 
     /**
-     * Execute renderer
-     *
-     * @param string $namespace
-     * @param string $staticType
-     * @param string $dynamicType
-     * @param array $data
-     * @return void
+     * {@inheritdoc}
      */
     public function executeRenderer($namespace, $staticType, $dynamicType, $data = [])
     {
-        $this->getSubject()->executeRenderer($namespace, $staticType, $dynamicType, $data);
+        $this->_getSubject()->executeRenderer($namespace, $staticType, $dynamicType, $data);
     }
 
     /**
-     * Init messages by message storage(s), loading and adding messages to layout messages block
-     *
-     * @param string|array $messageGroups
-     * @return void
+     * {@inheritdoc}
      */
     public function initMessages($messageGroups = [])
     {
-        $this->getSubject()->initMessages($messageGroups);
+        $this->_getSubject()->initMessages($messageGroups);
     }
 
     /**
-     * Check is exists non-cacheable layout elements
-     *
-     * @return bool
+     * {@inheritdoc}
      */
     public function isCacheable()
     {
-        return $this->getSubject()->isCacheable();
+        return $this->_getSubject()->isCacheable();
     }
 
     /**
-     * Check is exists non-cacheable layout elements
-     *
-     * @return bool
+     * {@inheritdoc}
      */
     public function isPrivate()
     {
-        return $this->getSubject()->isPrivate();
+        return $this->_getSubject()->isPrivate();
     }
 
     /**
-     * Mark layout as private
-     *
-     * @param bool $isPrivate
-     * @return $this
+     * {@inheritdoc}
      */
     public function setIsPrivate($isPrivate = true)
     {
-        return $this->getSubject()->setIsPrivate($isPrivate);
+        return $this->_getSubject()->setIsPrivate($isPrivate);
     }
 
     /**
-     * Sets xml for this configuration
-     *
-     * @param \Magento\Framework\Simplexml\Element $node
-     * @return $this
+     * {@inheritdoc}
+     */
+    public function getReaderContext()
+    {
+        return $this->_getSubject()->getReaderContext();
+    }
+
+    /**
+     * {@inheritdoc}
      */
     public function setXml(\Magento\Framework\Simplexml\Element $node)
     {
-        return $this->getSubject()->setXml($node);
+        return $this->_getSubject()->setXml($node);
     }
 
     /**
-     * Returns node found by the $path
-     *
-     * @param string $path
-     * @return \Magento\Framework\Simplexml\Element|bool
-     * @see \Magento\Framework\Simplexml\Element::descend
+     * {@inheritdoc}
      */
     public function getNode($path = null)
     {
-        return $this->getSubject()->getNode($path);
+        return $this->_getSubject()->getNode($path);
     }
 
     /**
-     * Returns nodes found by xpath expression
-     *
-     * @param string $xpath
-     * @return \SimpleXMLElement[]|bool
+     * {@inheritdoc}
      */
     public function getXpath($xpath)
     {
-        return $this->getSubject()->getXpath($xpath);
+        return $this->_getSubject()->getXpath($xpath);
     }
 
     /**
-     * Set cache
-     *
-     * @param \Magento\Framework\Simplexml\Config\Cache\AbstractCache $cache
-     * @return $this
+     * {@inheritdoc}
      */
     public function setCache($cache)
     {
-        return $this->getSubject()->setCache($cache);
+        return $this->_getSubject()->setCache($cache);
     }
 
     /**
-     * Return cache
-     *
-     * @return \Magento\Framework\Simplexml\Config\Cache\AbstractCache
+     * {@inheritdoc}
      */
     public function getCache()
     {
-        return $this->getSubject()->getCache();
+        return $this->_getSubject()->getCache();
     }
 
     /**
-     * Set whether cache is saved
-     *
-     * @param boolean $flag
-     * @return $this
+     * {@inheritdoc}
      */
     public function setCacheSaved($flag)
     {
-        return $this->getSubject()->setCacheSaved($flag);
+        return $this->_getSubject()->setCacheSaved($flag);
     }
 
     /**
-     * Return whether cache is saved
-     *
-     * @return bool
-     *
-     * @SuppressWarnings(PHPMD.BooleanGetMethodName)
+     * {@inheritdoc}
      */
     public function getCacheSaved()
     {
-        return $this->getSubject()->getCacheSaved();
+        return $this->_getSubject()->getCacheSaved();
     }
 
     /**
-     * Set cache ID
-     *
-     * @param string $id
-     * @return $this
+     * {@inheritdoc}
      */
     public function setCacheId($id)
     {
-        return $this->getSubject()->setCacheId($id);
+        return $this->_getSubject()->setCacheId($id);
     }
 
     /**
-     * Return cache ID
-     *
-     * @return string
+     * {@inheritdoc}
      */
     public function getCacheId()
     {
-        return $this->getSubject()->getCacheId();
+        return $this->_getSubject()->getCacheId();
     }
 
     /**
-     * Set cache tags
-     *
-     * @param array $tags
-     * @return $this
+     * {@inheritdoc}
      */
     public function setCacheTags($tags)
     {
-        return $this->getSubject()->setCacheTags($tags);
+        return $this->_getSubject()->setCacheTags($tags);
     }
 
     /**
-     * Return cache tags
-     *
-     * @return array
+     * {@inheritdoc}
      */
     public function getCacheTags()
     {
-        return $this->getSubject()->getCacheTags();
+        return $this->_getSubject()->getCacheTags();
     }
 
     /**
-     * Set cache lifetime
-     *
-     * @param int $lifetime
-     * @return $this
+     * {@inheritdoc}
      */
     public function setCacheLifetime($lifetime)
     {
-        return $this->getSubject()->setCacheLifetime($lifetime);
+        return $this->_getSubject()->setCacheLifetime($lifetime);
     }
 
     /**
-     * Return cache lifetime
-     *
-     * @return int
+     * {@inheritdoc}
      */
     public function getCacheLifetime()
     {
-        return $this->getSubject()->getCacheLifetime();
+        return $this->_getSubject()->getCacheLifetime();
     }
 
     /**
-     * Set cache checksum
-     *
-     * @param string $data
-     * @return $this
+     * {@inheritdoc}
      */
     public function setCacheChecksum($data)
     {
-        return $this->getSubject()->setCacheChecksum($data);
+        return $this->_getSubject()->setCacheChecksum($data);
     }
 
     /**
-     * Update cache checksum
-     *
-     * @param string $data
-     * @return $this
+     * {@inheritdoc}
      */
     public function updateCacheChecksum($data)
     {
-        return $this->getSubject()->updateCacheChecksum($data);
+        return $this->_getSubject()->updateCacheChecksum($data);
     }
 
     /**
-     * Return cache checksum
-     *
-     * @return string
+     * {@inheritdoc}
      */
     public function getCacheChecksum()
     {
-        return $this->getSubject()->getCacheChecksum();
+        return $this->_getSubject()->getCacheChecksum();
     }
 
     /**
-     * Get cache checksum ID
-     *
-     * @return string
+     * {@inheritdoc}
      */
     public function getCacheChecksumId()
     {
-        return $this->getSubject()->getCacheChecksumId();
+        return $this->_getSubject()->getCacheChecksumId();
     }
 
     /**
-     * Fetch cache checksum
-     *
-     * @return boolean
+     * {@inheritdoc}
      */
     public function fetchCacheChecksum()
     {
-        return $this->getSubject()->fetchCacheChecksum();
+        return $this->_getSubject()->fetchCacheChecksum();
     }
 
     /**
-     * Validate cache checksum
-     *
-     * @return boolean
+     * {@inheritdoc}
      */
     public function validateCacheChecksum()
     {
-        return $this->getSubject()->validateCacheChecksum();
+        return $this->_getSubject()->validateCacheChecksum();
     }
 
     /**
-     * Load cache
-     *
-     * @return boolean
+     * {@inheritdoc}
      */
     public function loadCache()
     {
-        return $this->getSubject()->loadCache();
+        return $this->_getSubject()->loadCache();
     }
 
     /**
-     * Save cache
-     *
-     * @param array $tags
-     * @return $this
+     * {@inheritdoc}
      */
     public function saveCache($tags = null)
     {
-        return $this->getSubject()->saveCache($tags);
+        return $this->_getSubject()->saveCache($tags);
     }
 
     /**
-     * Return Xml of node as string
-     *
-     * @return string
+     * {@inheritdoc}
      */
     public function getXmlString()
     {
-        return $this->getSubject()->getXmlString();
+        return $this->_getSubject()->getXmlString();
     }
 
     /**
-     * Remove cache
-     *
-     * @return $this
+     * {@inheritdoc}
      */
     public function removeCache()
     {
-        return $this->getSubject()->removeCache();
+        return $this->_getSubject()->removeCache();
     }
 
     /**
-     * Imports XML file
-     *
-     * @param string $filePath
-     * @return boolean
+     * {@inheritdoc}
      */
     public function loadFile($filePath)
     {
-        return $this->getSubject()->loadFile($filePath);
+        return $this->_getSubject()->loadFile($filePath);
     }
 
     /**
-     * Imports XML string
-     *
-     * @param string $string
-     * @return boolean
+     * {@inheritdoc}
      */
     public function loadString($string)
     {
-        return $this->getSubject()->loadString($string);
+        return $this->_getSubject()->loadString($string);
     }
 
     /**
-     * Imports DOM node
-     *
-     * @param \DOMNode $dom
-     * @return bool
+     * {@inheritdoc}
      */
     public function loadDom(\DOMNode $dom)
     {
-        return $this->getSubject()->loadDom($dom);
+        return $this->_getSubject()->loadDom($dom);
     }
 
     /**
-     * Create node by $path and set its value.
-     *
-     * @param string $path separated by slashes
-     * @param string $value
-     * @param boolean $overwrite
-     * @return $this
+     * {@inheritdoc}
      */
     public function setNode($path, $value, $overwrite = true)
     {
-        return $this->getSubject()->setNode($path, $value, $overwrite);
+        return $this->_getSubject()->setNode($path, $value, $overwrite);
     }
 
     /**
-     * Process configuration xml
-     *
-     * @return $this
+     * {@inheritdoc}
      */
     public function applyExtends()
     {
-        return $this->getSubject()->applyExtends();
+        return $this->_getSubject()->applyExtends();
     }
 
     /**
-     * Stub method for processing file data right after loading the file text
-     *
-     * @param string $text
-     * @return string
+     * {@inheritdoc}
      */
     public function processFileData($text)
     {
-        return $this->getSubject()->processFileData($text);
+        return $this->_getSubject()->processFileData($text);
     }
 
     /**
-     * Extend configuration
-     *
-     * @param \Magento\Framework\Simplexml\Config $config
-     * @param boolean $overwrite
-     * @return $this
+     * {@inheritdoc}
      */
     public function extend(\Magento\Framework\Simplexml\Config $config, $overwrite = true)
     {
-        return $this->getSubject()->extend($config, $overwrite);
+        return $this->_getSubject()->extend($config, $overwrite);
     }
 }
diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Element/MessagesTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Element/MessagesTest.php
index bd18ebe344f884734c1b78233ed278c6c8b6b440..6f552656be534c3322b7f778a769fb55c83a366c 100644
--- a/lib/internal/Magento/Framework/View/Test/Unit/Element/MessagesTest.php
+++ b/lib/internal/Magento/Framework/View/Test/Unit/Element/MessagesTest.php
@@ -9,6 +9,7 @@
  */
 namespace Magento\Framework\View\Test\Unit\Element;
 
+use Magento\Framework\Message\Manager;
 use \Magento\Framework\View\Element\Messages;
 
 use Magento\Framework\Message\ManagerInterface;
@@ -229,7 +230,7 @@ class MessagesTest extends \PHPUnit_Framework_TestCase
         $this->assertEquals($emptyMessagesCacheKey, $this->messages->getCacheKeyInfo());
 
         $messagesCacheKey = ['storage_types' => 'a:1:{i:0;s:7:"default";}'];
-        $this->messages->addStorageType(ManagerInterface::DEFAULT_GROUP);
+        $this->messages->addStorageType(Manager::DEFAULT_GROUP);
         $this->assertEquals($messagesCacheKey, $this->messages->getCacheKeyInfo());
     }
 
diff --git a/lib/internal/Magento/Framework/View/Test/Unit/LayoutTest.php b/lib/internal/Magento/Framework/View/Test/Unit/LayoutTest.php
index 45effcf449e43c4e7a05dcc77d37003195069eea..3d60c5e411300fd1ba642d03ed96720959434828 100644
--- a/lib/internal/Magento/Framework/View/Test/Unit/LayoutTest.php
+++ b/lib/internal/Magento/Framework/View/Test/Unit/LayoutTest.php
@@ -134,9 +134,6 @@ class LayoutTest extends \PHPUnit_Framework_TestCase
         $this->readerContextMock = $this->getMockBuilder('Magento\Framework\View\Layout\Reader\Context')
             ->disableOriginalConstructor()
             ->getMock();
-        $this->readerContextFactoryMock->expects($this->once())
-            ->method('create')
-            ->willReturn($this->readerContextMock);
         $this->generatorContextFactoryMock = $this->getMockBuilder(
             'Magento\Framework\View\Layout\Generator\ContextFactory'
         )->disableOriginalConstructor()
@@ -683,6 +680,9 @@ class LayoutTest extends \PHPUnit_Framework_TestCase
 
     public function testGenerateElementsWithoutCache()
     {
+        $this->readerContextFactoryMock->expects($this->once())
+            ->method('create')
+            ->willReturn($this->readerContextMock);
         $layoutCacheId = 'layout_cache_id';
         $handles = ['default', 'another'];
         /** @var \Magento\Framework\View\Layout\Element $xml */
@@ -807,4 +807,10 @@ class LayoutTest extends \PHPUnit_Framework_TestCase
 
         $this->model->generateElements();
     }
+
+    public function testGetXml()
+    {
+        $xml = '<layout/>';
+        $this->assertSame($xml, \Magento\Framework\View\Layout::LAYOUT_NODE);
+    }
 }
diff --git a/setup/src/Magento/Setup/Model/Installer.php b/setup/src/Magento/Setup/Model/Installer.php
index 5db3a546a66113ea49ff556c9f346281ec8afc44..414ef89f37a612ce5dcbbe14f6438d30e11a11a5 100644
--- a/setup/src/Magento/Setup/Model/Installer.php
+++ b/setup/src/Magento/Setup/Model/Installer.php
@@ -787,6 +787,9 @@ class Installer
     public function installUserConfig($data)
     {
         $userConfig = new StoreConfigurationDataMapper();
+        /** @var \Magento\Framework\App\State $appState */
+        $appState = $this->objectManagerProvider->get()->get('Magento\Framework\App\State');
+        $appState->setAreaCode('setup');
         $configData = $userConfig->getConfigData($data);
         if (count($configData) === 0) {
             return;
diff --git a/setup/src/Magento/Setup/Model/Lists.php b/setup/src/Magento/Setup/Model/Lists.php
index e898ed40c16c383ac2fa1ccadbdab2419aae793d..e52e921594caec60421e975f3782c8abf552ac13 100644
--- a/setup/src/Magento/Setup/Model/Lists.php
+++ b/setup/src/Magento/Setup/Model/Lists.php
@@ -10,6 +10,7 @@ use Magento\Framework\Locale\Bundle\CurrencyBundle;
 use Magento\Framework\Locale\Bundle\LanguageBundle;
 use Magento\Framework\Locale\Bundle\RegionBundle;
 use Magento\Framework\Locale\ConfigInterface;
+use Magento\Framework\Locale\Resolver;
 use Magento\Framework\Locale\ResolverInterface;
 
 class Lists
@@ -42,7 +43,7 @@ class Lists
             $list[$code] = \IntlTimeZone::createTimeZone($code)->getDisplayName(
                 false,
                 \IntlTimeZone::DISPLAY_LONG,
-                ResolverInterface::DEFAULT_LOCALE
+                Resolver::DEFAULT_LOCALE
             ) . ' (' . $code . ')';
         }
         asort($list);
@@ -56,7 +57,7 @@ class Lists
      */
     public function getCurrencyList()
     {
-        $currencies = (new CurrencyBundle())->get(ResolverInterface::DEFAULT_LOCALE)['Currencies'];
+        $currencies = (new CurrencyBundle())->get(Resolver::DEFAULT_LOCALE)['Currencies'];
         $list = [];
         foreach ($currencies as $code => $data) {
             $list[$code] = $data[1] . ' (' . $code . ')';
@@ -72,8 +73,8 @@ class Lists
      */
     public function getLocaleList()
     {
-        $languages = (new LanguageBundle())->get(ResolverInterface::DEFAULT_LOCALE)['Languages'];
-        $countries = (new RegionBundle())->get(ResolverInterface::DEFAULT_LOCALE)['Countries'];
+        $languages = (new LanguageBundle())->get(Resolver::DEFAULT_LOCALE)['Languages'];
+        $countries = (new RegionBundle())->get(Resolver::DEFAULT_LOCALE)['Countries'];
         $locales = \ResourceBundle::getLocales(null);
 
         $list = [];
diff --git a/setup/src/Magento/Setup/Test/Unit/Model/InstallerTest.php b/setup/src/Magento/Setup/Test/Unit/Model/InstallerTest.php
index 553c5c8ed4c1ec544a824a240237a1b0eb505dca..e3e44ebd20a3b43114e32d7df801c2c86591bf02 100644
--- a/setup/src/Magento/Setup/Test/Unit/Model/InstallerTest.php
+++ b/setup/src/Magento/Setup/Test/Unit/Model/InstallerTest.php
@@ -234,12 +234,21 @@ class InstallerTest extends \PHPUnit_Framework_TestCase
         $cacheManager = $this->getMock('Magento\Framework\App\Cache\Manager', [], [], '', false);
         $cacheManager->expects($this->once())->method('getAvailableTypes')->willReturn(['foo', 'bar']);
         $cacheManager->expects($this->once())->method('setEnabled')->willReturn(['foo', 'bar']);
+        $appState = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject(
+            'Magento\Framework\App\State'
+        );
         $this->objectManager->expects($this->any())
             ->method('create')
             ->will($this->returnValueMap([
                 ['Magento\Setup\Module\Setup', ['resource' => $resource], $setup],
                 ['Magento\Setup\Module\DataSetup', [], $dataSetup],
                 ['Magento\Framework\App\Cache\Manager', [], $cacheManager],
+                ['Magento\Framework\App\State', [], $appState],
+            ]));
+        $this->objectManager->expects($this->any())
+            ->method('get')
+            ->will($this->returnValueMap([
+                ['Magento\Framework\App\State', $appState],
             ]));
         $this->adminFactory->expects($this->once())->method('create')->willReturn(
             $this->getMock('Magento\Setup\Model\AdminAccount', [], [], '', false)